phpcr-utils/src/PHPCR/Util/NodeHelper.php

Show: PublicProtectedPrivateinherited
Table of Contents
This file is part of the PHPCR Utils

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

License
Apache Software License 2.0  
Link
http://phpcr.github.com/  

\PHPCR\Util\NodeHelper

Package: Default
Helper with only static methods to work with PHPCR nodes
Author
Daniel Barsotti  
Author
David Buchmann  

Methods

methodprivate__construct() : void

Do not create an instance of this class

methodpubliccalculateOrderBefore(array $old, array $new) : array
static

Compare two arrays and generate a list of move operations that executed in order will transform $old into $new.

The result is an array with the keys being elements of the array to move right before the element in the value. A value of null means move to the end.

If $old contains elements not present in $new, those elements are ignored and do not show up.

Parameters
NameTypeDescription
$oldarray

old order

$newarray

new order

Returns
TypeDescription
arraythe keys are elements to move, values the destination to move before or null to move to the end.
methodpubliccreatePath(\PHPCR\SessionInterface $session, string $path) : \PHPCR\NodeInterface
static

Create a node and it's parents, if necessary.

Like mkdir -p.

Parameters
NameTypeDescription
$session\PHPCR\SessionInterface

the PHPCR session to create the path

$pathstring

full path, like /content/jobs/data

Returns
TypeDescription
\PHPCR\NodeInterfacethe last node of the path, i.e. data
methodpublicdeleteAllNodes( $session) : void
static

Kept as alias of purgeWorkspace for BC compatibility

Parameters
NameTypeDescription
$session
Details
Deprecated
 
methodpublicgenerateAutoNodeName(string[] $usedNames, string[] $namespaces, string $defaultNamespace, string $nameHint = null) : string
static

Helper method to implement NodeInterface::addNodeAutoNamed

This method only checks for valid namespaces. All other exceptions must be thrown by the addNodeAutoNamed implementation.

Parameters
NameTypeDescription
$usedNamesstring[]

list of child names that is currently used and may not be chosen.

$namespacesstring[]

namespace prefix to uri map of all currently known namespaces.

$defaultNamespacestring

namespace prefix to use if the hint does not specify.

$nameHintstring

the name hint according to the API definition

Returns
TypeDescription
stringA valid node name for this node
Throws
ExceptionDescription
\PHPCR\NamespaceExceptionif a namespace prefix is provided in the $nameHint which does not exist and this implementation performs this validation immediately.
methodprivategenerateWithPrefix(string[] $usedNames, string $prefix, string $namepart = '') : string
static

Repeatedly generate a name with a random part until we hit one that is not yet used.

Parameters
NameTypeDescription
$usedNamesstring[]

names that are forbidden

$prefixstring

the prefix including the colon at the end

$namepartstring

start for the localname

Returns
TypeDescription
string
methodpublicisSystemItem(\PHPCR\ItemInterface $item) : void
static

Determine whether this item has a namespace that is to be considered a system namespace

Parameters
NameTypeDescription
$item\PHPCR\ItemInterface
methodpublicorderBeforeArray(string $name, string $destination, array $list) : array
static

Move the element $name of $list to right before $destination, validating existence of all elements.

Parameters
NameTypeDescription
$namestring

name of the element to move

$destinationstring

name of the element $srcChildRelPath has to be ordered before, null to move to the end

$listarray

the array of names

Returns
TypeDescription
arrayThe updated $nodes array with new order
Throws
ExceptionDescription
\PHPCR\ItemNotFoundExceptionif $srcChildRelPath or $destChildRelPath are not found in $nodes
methodpublicpurgeWorkspace(\PHPCR\SessionInterface $session) : void
static

Delete all content in the workspace this session is bound to.

Remember to save the session after calling the purge method.

Note that if you want to delete a node under your root node, you can just use the remove method on that node. This method is just here to help you because the implementation might add nodes like jcr:system to the root node which you are not allowed to remove.

Parameters
NameTypeDescription
$session\PHPCR\SessionInterface

the session to remove all children of the root node

Details
See
\PHPCR\Util\isSystemItem  
Documentation was generated by phpDocumentor 2.0.0a12.