Jackalope\Transport\WritingInterface::registerNamespace PHP Метод

registerNamespace() публичный Метод

Validation based on what was returned from getNamespaces has already happened in the NamespaceRegistry. The transport is however responsible of removing an existing prefix for that uri, if one exists. As well as removing the current uri mapped to this prefix if this prefix is already existing.
public registerNamespace ( string $prefix, string $uri )
$prefix string The prefix to be mapped.
$uri string The URI to be mapped.
    public function registerNamespace($prefix, $uri);

Usage Example

Пример #1
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function registerNamespace($prefix, $uri)
 {
     if (!$this->transport instanceof WritingInterface) {
         throw new UnsupportedRepositoryOperationException('Transport does not support writing');
     }
     // prevent default namespace prefixes to be overridden.
     $this->checkPrefix($prefix);
     // prevent default namespace uris to be overridden
     if (false !== array_search($uri, $this->defaultNamespaces)) {
         throw new NamespaceException("Can not change default namespace {$prefix} = {$uri}");
     }
     $this->lazyLoadNamespaces();
     //first try putting the stuff in backend, and only afterwards update local info
     // this has no impact on running sessions, go directly to storage
     $this->transport->registerNamespace($prefix, $uri);
     // update local info
     if (false !== ($oldpref = array_search($uri, $this->userNamespaces))) {
         // the backend takes care of storing this, but we have to update frontend info
         unset($this->userNamespaces[$oldpref]);
     }
     $this->userNamespaces[$prefix] = $uri;
 }