Exemple #1
0
 /**
  * Implementation specific way to register node types from cnd with the
  * backend.
  *
  * This is only a proxy to the transport
  *
  * @param $cnd a string with cnd information
  * @param boolean $allowUpdate whether to fail if node already exists or to update it
  * @return bool true on success
  */
 public function registerNodeTypesCnd($cnd, $allowUpdate)
 {
     if (!$this->transport instanceof NodeTypeCndManagementInterface) {
         if ($this->transport instanceof NodeTypeManagementInterface) {
             throw new UnsupportedRepositoryOperationException('TODO: parse cnd and call registerNodeTypes');
         }
         throw new UnsupportedRepositoryOperationException('Transport does not support registering node types');
     }
     return $this->transport->registerNodeTypesCnd($cnd, $allowUpdate);
 }
Exemple #2
0
 /**
  * Register node types with compact node definition format
  *
  * This is only a proxy to the transport
  *
  * @param  string  $cnd         a string with cnd information
  * @param  boolean $allowUpdate whether to fail if node already exists or to update it
  * @return bool    true on success
  */
 public function registerNodeTypesCnd($cnd, $allowUpdate)
 {
     if ($this->transport instanceof NodeTypeCndManagementInterface) {
         return $this->transport->registerNodeTypesCnd($cnd, $allowUpdate);
     }
     if ($this->transport instanceof NodeTypeManagementInterface) {
         $workspace = $this->session->getWorkspace();
         $nsRegistry = $workspace->getNamespaceRegistry();
         $parser = new CndParser($workspace->getNodeTypeManager());
         $res = $parser->parseString($cnd);
         $ns = $res['namespaces'];
         $types = $res['nodeTypes'];
         foreach ($ns as $prefix => $uri) {
             $nsRegistry->registerNamespace($prefix, $uri);
         }
         return $workspace->getNodeTypeManager()->registerNodeTypes($types, $allowUpdate);
     }
     throw new UnsupportedRepositoryOperationException('Transport does not support registering node types');
 }