phpcr/src/PHPCR/NamespaceRegistryInterface.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\NamespaceRegistryInterface
Each repository has a single, persistent namespace registry represented by the NamespaceRegistry object, accessed via WorkspaceInterface::getNamespaceRegistry(). The namespace registry contains the default prefixes of the registered namespaces. The namespace registry may contain namespaces that are not used in repository content, and there may be repository content with namespaces that are not included n the registry.
The \Traversable interface enables the implementation to be addressed with foreach. NamespaceRegistry has to implement either \IteratorAggregate or \Iterator. The iterator lets you iterate over all namespaces, with the prefixes as keys and corresponding url as value.
- Parent(s)
- \Traversable
- Api
Constants
NAMESPACE_JCR
= "http://www.jcp.org/jcr/1.0"
- Api
NAMESPACE_NT
= "http://www.jcp.org/jcr/nt/1.0"
- Api
NAMESPACE_SV
= "http://www.jcp.org/jcr/sv/1.0"
- Api
NAMESPACE_MIX
= "http://www.jcp.org/jcr/mix/1.0"
- Api
NAMESPACE_XML
= "http://www.w3.org/XML/1998/namespace"
- Api
Methods
getPrefix(string $uri) : string
Returns the prefix which is mapped to the given uri.
Name | Type | Description |
---|---|---|
$uri | string | a string |
Type | Description |
---|---|
string | a string |
Exception | Description |
---|---|
\PHPCR\NamespaceException | if a mapping with the specified uri does not exist. |
\PHPCR\RepositoryException | if another error occurs |
- Api
getPrefixes() : array
Returns an array holding all currently registered namespace prefixes.
Type | Description |
---|---|
array | a string array |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
getURI(string $prefix) : string
Returns the namespace URI to which the given prefix is mapped.
Name | Type | Description |
---|---|---|
$prefix | string | a string |
Type | Description |
---|---|
string | a string |
Exception | Description |
---|---|
\PHPCR\NamespaceException | if a mapping with the specified prefix does not exist. |
\PHPCR\RepositoryException | if another error occurs |
- Api
getURIs() : array
Returns an array holding all currently registered namespace URIs.
Type | Description |
---|---|
array | a string array |
Exception | Description |
---|---|
\PHPCR\RepositoryException | if an error occurs. |
- Api
registerNamespace(string $prefix, string $uri) : void
Sets a one-to-one mapping between prefix and uri in the global namespace registry of this repository.
Assigning a new prefix to a URI that already exists in the namespace registry erases the old prefix. In general this can almost always be done, though an implementation is free to prevent particular remappings by throwing a NamespaceException.
On the other hand, taking a prefix that is already assigned to a URI and re-assigning it to a new URI in effect unregisters that URI. Therefore, the same restrictions apply to this operation as to NamespaceRegistryInterface::unregisterNamespace():
- Attempting to re-assign a built-in prefix (jcr, nt, mix, sv, xml, or the empty prefix) to a new URI will throw a NamespaceException.
- Attempting to register a namespace with a prefix that begins with the characters "xml" (in any combination of case) will throw a NamespaceException.
- An implementation may prevent the re-assignment of any other namespace prefixes for implementation-specific reasons by throwing a NamespaceException.
Name | Type | Description |
---|---|---|
$prefix | string | The prefix to be mapped. |
$uri | string | The URI to be mapped. |
Exception | Description |
---|---|
\PHPCR\NamespaceException | If an attempt is made to re-assign a built-in prefix to a new URI or, to register a namespace with a prefix that begins with the characters "xml" (in any combination of case) or an attempt is made to perform a prefix re-assignment that is forbidden for implementation-specific reasons. |
\PHPCR\UnsupportedRepositoryOperationException | if this repository does not support namespace registry changes. |
\PHPCR\AccessDeniedException | if the current session does not have sufficient access to register the namespace. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
unregisterNamespaceByURI(string $uri) : void
Removes the specified namespace URI from namespace registry.
The following restrictions apply:
- Attempting to unregister a built-in namespace (jcr, nt, mix, sv, xml or the empty namespace) will throw a NamespaceException.
- An attempt to unregister a namespace that is not currently registered will throw a NamespaceException.
- An implementation may prevent the unregistering of any other namespace for implementation-specific reasons by throwing a NamespaceException.
Name | Type | Description |
---|---|---|
$uri | string | The URI to be removed. |
Exception | Description |
---|---|
\PHPCR\NamespaceException | unregister a built-in namespace or a namespace that is not currently registered or a namespace whose unregistration is forbidden for implementation-specific reasons. |
\PHPCR\UnsupportedRepositoryOperationException | if this repository does not support namespace registry changes. |
\PHPCR\AccessDeniedException | if the current session does not have sufficient access to unregister the namespace. |
\PHPCR\RepositoryException | if another error occurs. |
- Api