Skip to content

Commit 81caa98

Browse files
committed
Merge remote-tracking branch 'origin/master' into command-helpers
Conflicts: src/PHPCR/Util/Console/Command/BaseCommand.php
2 parents f5a5faa + 998c8c0 commit 81caa98

File tree

83 files changed

+1170
-1445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1170
-1445
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Changelog
2+
=========
3+
4+
* **2013-06-15**: [Command] Added `--apply-closure` option to `phpcr:nodes:update` command.

LICENSE.txt

Lines changed: 24 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
phpcr-utils is dual licensed under the MIT license and the Apache License Version 2.0.
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2013 Liip and others
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
this software and associated documentation files (the "Software"), to deal in
9+
the Software without restriction, including without limitation the rights to
10+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
the Software, and to permit persons to whom the Software is furnished to do so,
12+
subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
124

225
Apache License
326
Version 2.0, January 2004
@@ -187,7 +210,7 @@
187210
same "printed page" as the copyright notice for easier
188211
identification within third-party archives.
189212

190-
Copyright [yyyy] [name of copyright owner]
213+
Copyright 2010-2013 Liip and others
191214

192215
Licensed under the Apache License, Version 2.0 (the "License");
193216
you may not use this file except in compliance with the License.
@@ -200,65 +223,3 @@
200223
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201224
See the License for the specific language governing permissions and
202225
limitations under the License.
203-
204-
205-
APACHE JACKRABBIT SUBCOMPONENTS
206-
207-
Apache Jackrabbit includes parts with separate copyright notices and license
208-
terms. Your use of these subcomponents is subject to the terms and conditions
209-
of the following licenses:
210-
211-
XPath 2.0/XQuery 1.0 Parser:
212-
http://www.w3.org/2002/11/xquery-xpath-applets/xgrammar.zip
213-
214-
Copyright (C) 2002 World Wide Web Consortium, (Massachusetts Institute of
215-
Technology, European Research Consortium for Informatics and Mathematics,
216-
Keio University). All Rights Reserved.
217-
218-
This work is distributed under the W3C(R) Software License in the hope
219-
that it will be useful, but WITHOUT ANY WARRANTY; without even the
220-
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
221-
222-
W3C(R) SOFTWARE NOTICE AND LICENSE
223-
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
224-
225-
This work (and included software, documentation such as READMEs, or
226-
other related items) is being provided by the copyright holders under
227-
the following license. By obtaining, using and/or copying this work,
228-
you (the licensee) agree that you have read, understood, and will comply
229-
with the following terms and conditions.
230-
231-
Permission to copy, modify, and distribute this software and its
232-
documentation, with or without modification, for any purpose and
233-
without fee or royalty is hereby granted, provided that you include
234-
the following on ALL copies of the software and documentation or
235-
portions thereof, including modifications:
236-
237-
1. The full text of this NOTICE in a location viewable to users
238-
of the redistributed or derivative work.
239-
240-
2. Any pre-existing intellectual property disclaimers, notices,
241-
or terms and conditions. If none exist, the W3C Software Short
242-
Notice should be included (hypertext is preferred, text is
243-
permitted) within the body of any redistributed or derivative code.
244-
245-
3. Notice of any changes or modifications to the files, including
246-
the date changes were made. (We recommend you provide URIs to the
247-
location from which the code is derived.)
248-
249-
THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
250-
HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
251-
INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS
252-
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
253-
DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
254-
TRADEMARKS OR OTHER RIGHTS.
255-
256-
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL
257-
OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
258-
DOCUMENTATION.
259-
260-
The name and trademarks of copyright holders may NOT be used in
261-
advertising or publicity pertaining to the software without specific,
262-
written prior permission. Title to copyright in this software and
263-
any associated documentation will at all times remain with
264-
copyright holders.

README.md

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ If you are using or implementing [PHPCR](https://github.com/phpcr/phpcr) you
66
probably want some of the things in here.
77

88
PHPCR Users: Note that your PHPCR implementation probably already bundles the
9-
utils. Jackalope for example depends on them and they are found in its
10-
lib/phpcr-utils folder.
9+
utils.
10+
11+
## License
12+
13+
This code is dual licensed under the MIT license and the Apache License Version
14+
2.0. Please see the file LICENSE in this folder.
1115

1216

1317
# Documentation
@@ -18,7 +22,7 @@ classes for common tasks.
1822

1923
## Commands
2024

21-
There are a couple of useful commands to interact with a phpcr repository.
25+
There are a couple of useful commands to interact with a PHPCR repository.
2226

2327
To use the console, make sure you have initialized the git submodules of
2428
phpcr-utils, then copy cli-config.php.dist to cli-config.php and adjust it
@@ -28,36 +32,35 @@ NOTE: If you are using PHPCR inside of Symfony, the DoctrinePHPCRBundle
2832
provides the commands inside the normal Symfony console and you don't need to
2933
prepare anything special.
3034

31-
* ``phpcr:workspace:create <name>``: Create the workspace name in the configured repository
32-
* ``phpcr:register-node-types --allow-update [cnd-file]``: Register namespaces and node types from a "Compact Node Type Definition" .cnd file
33-
* ``phpcr:dump [--sys_nodes[="..."]] [--props[="..."]] [path]``: Show the node names
34-
under the specified path. If you set sys_nodes=yes you will also see system nodes.
35-
If you set props=yes you will additionally see all properties of the dumped nodes.
36-
* ``phpcr:purge``: Remove all content from the configured repository in the
37-
configured workspace
38-
* ``phpcr:sql2``: Run a query in the JCR SQL2 language against the repository and dump
39-
the resulting rows to the console.
40-
41-
**TODO:**
42-
43-
* Implement commands for phpcr:import and phpcr:export to import and export the
44-
PHPCR document view and system view XML dumps.
45-
* Implement a simple .cnd parser in PHP and use it to make register-node-types
46-
work with all repositories
47-
35+
To get a list of the available commands, run `bin/phpcr` or set the commands up
36+
in your application. Running `bin/phpcr help <command-name>` outputs the
37+
documentation of that command.
4838

4939
## Helper Classes
5040

5141
The helper classes provide implementations for basic common tasks to help users
52-
and implementors of PHPCR. They are all in the namespace PHPCR\Util
42+
and implementers of PHPCR. They are all in the namespace PHPCR\Util
5343

44+
### PathHelper
5445

55-
### TraversingItemVisitor
46+
Used to manipulate paths. Implementations are recommended to use this, and
47+
applications also profit from it. Using `dirname` and similar file system
48+
operations on paths is not compatible with Microsoft Windows systems, thus you
49+
should always use the methods in PathHelper.
5650

57-
This ``ItemVisitorInterface`` implementation is a basic implementation of crawling
58-
a PHPCR tree. You can extend it to define what it should do while crawling the
59-
tree.
51+
### NodeHelper
6052

53+
This helper has some generally useful methods like one to generate empty
54+
`nt:unstructured` nodes to make sure a parent path exists. It also provides
55+
some useful helper methods for implementations.
56+
57+
### UUIDHelper
58+
59+
This little helper is mainly of interest for PHPCR implementers. It generates
60+
valid *Universally Unique IDs* and can determine whether a given string is a
61+
valid UUID.
62+
We recommend all implementations to use this implementation to guarantee
63+
consistent behaviour.
6164

6265
### QOM QueryBuilder
6366

@@ -66,25 +69,14 @@ The ``QueryBuilder`` is a fluent query builder with method names matching the
6669
on top of the QOM factory. It is the easiest way to programmatically build a
6770
PHPCR query.
6871

69-
7072
### Query Object Model Converter
7173

7274
In the PHPCR\Util\QOM namespace we provide, implementation-independant code to
7375
convert between SQL2 and QOM. ``Sql2ToQomQueryConverter`` parses SQL2 queries
7476
into QOM . ``QomToSql2QueryConverter`` generates SQL2 out of a QOM.
7577

78+
### TraversingItemVisitor
7679

77-
### UUIDHelper
78-
79-
This little helper is mainly of interest for PHPCR implementors. It generates
80-
valid *Universally Unique IDs* and can determine wheter a given string is a
81-
valid UUID.
82-
We recommend all implementations to use this implementation to guarantee
83-
constistent behaviour.
84-
85-
86-
# TODO
87-
88-
Move tests about the query converter from phpcr-api-tests tests/06_Query/QOM to
89-
the tests folder. How to do the tests without a QOM factory implementation?
90-
80+
This ``ItemVisitorInterface`` implementation is a basic implementation of crawling
81+
a PHPCR tree. You can extend it to define what it should do while crawling the
82+
tree.

bin/phpcr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ $cli->addCommands(array(
4444
new \PHPCR\Util\Console\Command\NodeMoveCommand(),
4545
new \PHPCR\Util\Console\Command\NodeRemoveCommand(),
4646
new \PHPCR\Util\Console\Command\NodeTouchCommand(),
47+
new \PHPCR\Util\Console\Command\NodesUpdateCommand(),
4748
new \PHPCR\Util\Console\Command\NodeTypeListCommand(),
4849
new \PHPCR\Util\Console\Command\NodeTypeRegisterCommand(),
4950
new \PHPCR\Util\Console\Command\WorkspaceCreateCommand(),

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"description": "PHP Content Repository implementation independant utilities",
55
"keywords": ["phpcr", "contentrepository", "cli"],
66
"homepage": "http://phpcr.github.com",
7-
"license": "Apache-2.0",
7+
"license": [
8+
"MIT",
9+
"Apache-2.0"
10+
],
811
"authors": [
912
{
1013
"name": "David Buchmann",
@@ -25,7 +28,7 @@
2528
],
2629
"require": {
2730
"php": ">=5.3.0",
28-
"phpcr/phpcr": "~2.1.0-beta10",
31+
"phpcr/phpcr": "~2.1.0",
2932
"symfony/console": "~2.0"
3033
},
3134
"autoload": {

src/PHPCR/Util/CND/Exception/ParserException.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
namespace PHPCR\Util\CND\Exception;
44

5-
use PHPCR\Util\CND\Scanner\TokenQueue,
6-
PHPCR\Util\CND\Scanner\GenericToken;
5+
use PHPCR\Util\CND\Scanner\TokenQueue;
6+
use PHPCR\Util\CND\Scanner\GenericToken;
77

88
/**
99
* @author Daniel Barsotti <[email protected]>
10+
*
11+
* @license http://www.apache.org/licenses Apache License Version 2.0, January 2004
12+
* @license http://opensource.org/licenses/MIT MIT License
13+
*
1014
*/
1115
class ParserException extends \Exception
1216
{
@@ -17,7 +21,7 @@ public function __construct(TokenQueue $queue, $msg)
1721

1822
// construct a lookup of the next tokens
1923
$lookup = '';
20-
for($i = 1; $i <= 5; $i++) {
24+
for ($i = 1; $i <= 5; $i++) {
2125
if ($queue->isEof()) {
2226
break;
2327
}

src/PHPCR/Util/CND/Exception/ScannerException.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use PHPCR\Util\CND\Reader\ReaderInterface;
66

77
/**
8+
* @license http://www.apache.org/licenses Apache License Version 2.0, January 2004
9+
* @license http://opensource.org/licenses/MIT MIT License
10+
*
811
* @author Daniel Barsotti <[email protected]>
912
*/
1013
class ScannerException extends \Exception

src/PHPCR/Util/CND/Parser/AbstractParser.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@
1515
* - expectToken - expect the next token to match
1616
* - checkAndExpectToken - check and then expect the next token to match
1717
*
18+
* @license http://www.apache.org/licenses Apache License Version 2.0, January 2004
19+
* @license http://opensource.org/licenses/MIT MIT License
20+
*
1821
* @author Daniel Barsotti <[email protected]>
1922
*/
2023
abstract class AbstractParser
2124
{
2225
/**
2326
* The token queue
27+
*
2428
* @var TokenQueue
2529
*/
2630
protected $tokenQueue;
@@ -30,11 +34,11 @@ abstract class AbstractParser
3034
* If the data is not provided (equal to null) then only the token type is checked.
3135
* Return false otherwise.
3236
*
33-
* @param int $type The expected token type
34-
* @param null|string $data The expected data or null
35-
* @param bool $ignoreCase whether to do string comparisons case insensitive or sensitive
37+
* @param int $type The expected token type
38+
* @param null|string $data The expected data or null
39+
* @param bool $ignoreCase whether to do string comparisons case insensitive or sensitive
3640
*
37-
* @return bool
41+
* @return boolean
3842
*/
3943
protected function checkToken($type, $data = null, $ignoreCase = false)
4044
{
@@ -65,7 +69,7 @@ protected function checkToken($type, $data = null, $ignoreCase = false)
6569
* @param int $type
6670
* @param array $data
6771
*
68-
* @return bool
72+
* @return boolean
6973
*/
7074
protected function checkTokenIn($type, array $data, $ignoreCase = false)
7175
{
@@ -82,7 +86,7 @@ protected function checkTokenIn($type, array $data, $ignoreCase = false)
8286
* Check if the next token matches the expected type and data. If it does, then consume and return it,
8387
* otherwise throw an exception.
8488
*
85-
* @param int $type The expected token type
89+
* @param int $type The expected token type
8690
* @param null|string $data The expected token data or null
8791
*
8892
* @return Token
@@ -106,15 +110,17 @@ protected function expectToken($type, $data = null)
106110
* Check if the next token matches the expected type and data. If it does, then consume it, otherwise
107111
* return false.
108112
*
109-
* @param int $type The expected token type
113+
* @param int $type The expected token type
110114
* @param null|string $data The expected token data or null
111-
* @return bool|Token
115+
*
116+
* @return boolean|Token
112117
*/
113118
protected function checkAndExpectToken($type, $data = null)
114119
{
115120
if ($this->checkToken($type, $data)) {
116121
$token = $this->tokenQueue->peek();
117122
$this->tokenQueue->next();
123+
118124
return $token;
119125
}
120126

0 commit comments

Comments
 (0)