phpcr/src/PHPCR/NodeType/NodeTypeManagerInterface.php
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.
\PHPCR\NodeType\NodeTypeManagerInterface
Accessed via WorkspaceInterface::getNodeTypeManager().
The \Traversable interface enables the implementation to be addressed with foreach. NodeTypeManager has to implement either \RecursiveIterator or \Iterator. The iterator is equivalent to getAllNodeTypes() returning a list of all node types. The iterator keys have no significant meaning.
- Parent(s)
- \Traversable
- Api
Methods
createNodeDefinitionTemplate() : \PHPCR\NodeType\NodeDefinitionTemplateInterface
Returns an empty NodeDefinitionTemplate which can then be used to create a child node definition and attached to a NodeTypeTemplate.
Type | Description |
---|---|
\PHPCR\NodeType\NodeDefinitionTemplateInterface | A NodeDefinitionTemplate. |
Exception | Description |
---|---|
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
createNodeTypeTemplate(\PHPCR\NodeType\NodeTypeDefinitionInterface $ntd = null) : \PHPCR\NodeType\NodeTypeTemplateInterface
Returns an empty NodeTypeTemplateInterface which can then be used to define a node type and passed to NodeTypeManagerInterface::registerNodeType().
If $ntd is given: Returns a NodeTypeTemplateInterface holding the specified node type definition. This template can then be altered and passed to NodeTypeManagerInterface::registerNodeType().
Name | Type | Description |
---|---|---|
$ntd | \PHPCR\NodeType\NodeTypeDefinitionInterface | a NodeTypeDefinition. |
Type | Description |
---|---|
\PHPCR\NodeType\NodeTypeTemplateInterface | A NodeTypeTemplate. |
Exception | Description |
---|---|
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
createPropertyDefinitionTemplate() : \PHPCR\NodeType\PropertyDefinitionTemplateInterface
Returns an empty PropertyDefinitionTemplateInterface which can then be used to create a property definition and attached to a NodeTypeTemplateInterface.
Type | Description |
---|---|
\PHPCR\NodeType\PropertyDefinitionTemplateInterface | An empty PropertyDefinitionTemplateInterface instance. |
Exception | Description |
---|---|
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getAllNodeTypes() : \Iterator
Returns an iterator over all available node types (primary and mixin).
Type | Description |
---|---|
\Iterator | implementing <b>SeekableIterator</b> and <b>Countable</b>. Keys are the node type names, values the corresponding NodeTypeInterface instances. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getMixinNodeTypes() : \Iterator
Returns an iterator over all available mixin node types.
If none are available, an empty iterator is returned.
Type | Description |
---|---|
\Iterator | implementing <b>SeekableIterator</b> and <b>Countable</b>. Keys are the node type names, values the corresponding NodeTypeInterface instances. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getNodeType(string $nodeTypeName) : \PHPCR\NodeType\NodeTypeInterface
Returns the named node type.
Name | Type | Description |
---|---|---|
$nodeTypeName | string | the name of an existing node type. |
Type | Description |
---|---|
\PHPCR\NodeType\NodeTypeInterface | A NodeType object. |
Exception | Description |
---|---|
\PHPCR\NodeType\NoSuchNodeTypeException | if no node type of the given name exists. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getPrimaryNodeTypes() : \Iterator
Returns an iterator over all available primary node types.
Type | Description |
---|---|
\Iterator | implementing <b>SeekableIterator</b> and <b>Countable</b>. Keys are the node type names, values the corresponding NodeTypeInterface instances. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
hasNodeType(string $name) : boolean
Determines if the given node type is registered.
Returns true if a node type with the specified name is registered. Returns false otherwise.
Name | Type | Description |
---|---|---|
$name | string | The name of node type. |
Type | Description |
---|---|
boolean | True, if the node type identified by its name is registered, else false. |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
registerNodeType(\PHPCR\NodeType\NodeTypeDefinitionInterface $ntd, boolean $allowUpdate) : \PHPCR\NodeType\NodeTypeInterface
Registers a new node type or updates an existing node type using the specified definition and returns the resulting NodeTypeInterface object.
Typically, the object passed to this method will be a NodeTypeTemplateInterface (a subclass of NodeTypeDefinitionInterface) acquired from NodeTypeManagerInterface::createNodeTypeTemplate() and then filled-in with definition information.
Name | Type | Description |
---|---|---|
$ntd | \PHPCR\NodeType\NodeTypeDefinitionInterface | a NodeTypeDefinitionInterface instance. |
$allowUpdate | boolean | whether to fail if node already exists or to update it. |
Type | Description |
---|---|
\PHPCR\NodeType\NodeTypeInterface | the registered node type. |
Exception | Description |
---|---|
\PHPCR\NodeType\InvalidNodeTypeDefinitionException | if the NodeTypeDefinitionInterface is invalid. |
\PHPCR\NodeType\NodeTypeExistsException | if allowUpdate is false and the NodeTypeDefinition specifies a node type name that is already registered. |
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
registerNodeTypes(array $definitions, boolean $allowUpdate) : \Iterator
Registers or updates the specified array of NodeTypeDefinition objects.
This method is used to register or update a set of node types with mutual dependencies. Returns an iterator over the resulting NodeType objects. The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
Name | Type | Description |
---|---|---|
$definitions | array | an array of NodeTypeDefinitions. |
$allowUpdate | boolean | whether to fail if node already exists or to update it. |
Type | Description |
---|---|
\Iterator | over the registered node types implementing <b>SeekableIterator</b> and <b>Countable</b>. Keys are the node type names, values the corresponding NodeTypeInterface instances. |
Exception | Description |
---|---|
\PHPCR\NodeType\InvalidNodeTypeDefinitionException | if a NodeTypeDefinitionInterface within the Collection is invalid or if the Collection contains an object of a type other than NodeTypeDefinitionInterface. |
\PHPCR\NodeType\NodeTypeExistsException | if allowUpdate is false and a NodeTypeDefinition within the Collection specifies a node type name that is already registered. |
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
registerNodeTypesCnd(string $cnd, boolean $allowUpdate) : \Iterator
Registers or updates the node type definitions as per the Compact Node Definition (CND) given by the supplied string.
This method is used to register or update a set of node types with mutual dependencies. Returns an iterator over the resulting NodeType objects.
The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
A simple example is <'phpcr'='http://www.doctrine-project.org/projects/phpcr_odm'> [phpcr:managed] mixin - phpcr:class (string)
For full documentation of the format, see http://jackrabbit.apache.org/node-type-notation.html
PHPCR Note: Rather than doing mixed arguments we decided to name this method explicitly different, as we have no operator overloading in PHP.
Name | Type | Description |
---|---|---|
$cnd | string | containing the node type definitions in CND format |
$allowUpdate | boolean | whether existing node type definitions should be modified/updated. |
Type | Description |
---|---|
\Iterator | over the registered node types implementing <b>SeekableIterator</b> and <b>Countable</b>. Keys are the node type names, values the corresponding NodeTypeInterface instances. |
Exception | Description |
---|---|
\PHPCR\NodeType\InvalidNodeTypeDefinitionException | if a NodeTypeDefinition within the CND is invalid. |
\PHPCR\NodeType\NodeTypeExistsException | if allowUpdate is false and a the NodeTypeDefinition within the CND string specifies a node type name that is already registered. |
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\RepositoryException | if another error occurs. |
- Since
- JCR 2.1
unregisterNodeType(string $name) : void
Unregisters the specified node type.
Name | Type | Description |
---|---|---|
$name | string | The name of the node type to be removed from the registry. |
Exception | Description |
---|---|
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\NodeType\NoSuchNodeTypeException | if no registered node type exists with the specified name. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
unregisterNodeTypes(array $names) : void
Unregisters the specified set of node types.
Used to unregister a set of node types with mutual dependencies.
Name | Type | Description |
---|---|---|
$names | array | List of node type names to be removed from the registry. |
Exception | Description |
---|---|
\PHPCR\UnsupportedRepositoryOperationException | if this implementation does not support node type registration. |
\PHPCR\NodeType\NoSuchNodeTypeException | if one of the names listed is not a registered node type. |
\PHPCR\RepositoryException | if another error occurs. |
- Api