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

Show: PublicProtectedPrivateinherited
Table of Contents
This file is part of the PHPCR Utils and was originally ported from the Java JCR API to PHP by Karsten Dambekalns for the FLOW3 project.

Copyright 2008-2011 Karsten Dambekalns karsten@typo3.org

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\TraversingItemVisitor

Package: Default
An implementation of ItemVisitor.

TraversingItemVisitor is an abstract utility class which allows to easily traverse an Item hierarchy. You overwrite entering and leaving methods that get called for all properties encountered

TraversingItemVisitor makes use of the Visitor Pattern as described in the book 'Design Patterns' by the Gang Of Four (Gamma et al.). Tree traversal is done observing the left-to-right order of child Items if such an order is supported and exists.

Implements
\PHPCR\ItemVisitorInterface
Api
 
Author
Karsten Dambekalns  
Author
Day Management AG, Switzerland  

Properties

>VPropertyprotectedboolean $breadthFirst = false
Indicates if traversal should be done in a breadth-first manner rather than depth-first (which is the default).
Default valuefalseDetails
Type
boolean
>VPropertyprotectedinteger $currentDepth
Used to track hierarchy depth of item currently being processed.
Details
Type
integer
>VPropertyprotected\SplQueue $currentQueue
Queue used to implement breadth-first traversal.
Details
Type
\SplQueue
>VPropertyprotectedinteger $maxDepth = -1
The 0-based depth up to which the hierarchy should be traversed (if it's -1, the hierarchy will be traversed until there are no more children of the current item).
Default value-1Details
Type
integer
>VPropertyprotected\SplQueue $nextQueue
Queue used to implement breadth-first traversal.
Details
Type
\SplQueue

Methods

methodpublic__construct(boolean $breadthFirst = false, integer $maxDepth = -1) : void

Constructs a new instance of this class.

Parameters
NameTypeDescription
$breadthFirstboolean

if $breadthFirst is true then traversal is done in a breadth-first manner; otherwise it is done in a depth-first manner (which is the default behavior).

$maxDepthinteger

the 0-based depth relative to the root node up to which the hierarchy should be traversed (if it's -1, the hierarchy will be traversed until there are no more children of the current item).

Details
Api
 
methodprotectedentering(\PHPCR\ItemInterface $item, integer $depth) : void
abstract

Implement this method to add behavior performed before a Property is visited.

Parameters
NameTypeDescription
$item\PHPCR\ItemInterface

the Item that is accepting this visitor.

$depthinteger

hierarchy level of this node (the root node starts at depth 0).

Throws
ExceptionDescription
\PHPCR\RepositoryExceptionif an error occurs.
Details
Api
 
methodprotectedleaving(\PHPCR\ItemInterface $item, integer $depth) : void
abstract

Implement this method to add behavior performed after a Property is visited.

Parameters
NameTypeDescription
$item\PHPCR\ItemInterface

the Item that is accepting this visitor.

$depthinteger

hierarchy level of this property (the root node starts at depth 0).

Throws
ExceptionDescription
\PHPCR\RepositoryExceptionif an error occurs.
Details
Api
 
methodpublicsetLevel(int $level) : void

Update the current depth level for indention

Parameters
NameTypeDescription
$levelint
methodpublicvisit(\PHPCR\ItemInterface $item) : void

Called when the Visitor is passed to an Item.

It calls TraversingItemVisitor::entering() followed by TraversingItemVisitor::leaving(). Implement these abstract methods to specify behavior on 'arrival at' and 'after leaving' the $item.

If this method throws, the visiting process is aborted.

Parameters
NameTypeDescription
$item\PHPCR\ItemInterface

the Node or Property that is accepting this visitor.

Throws
ExceptionDescription
\PHPCR\RepositoryExceptionif an error occurs.
Details
Api
 
Documentation was generated by phpDocumentor 2.0.0a12.