Jackalope\ObjectManager::registerNodeTypes PHP Method

registerNodeTypes() public method

This is only a proxy to the transport
public registerNodeTypes ( array $types, boolean $allowUpdate ) : boolean
$types array an array of NodeTypeDefinitions
$allowUpdate boolean whether to fail if node already exists or to update it
return boolean true on success
    public function registerNodeTypes($types, $allowUpdate)
    {
        if ($this->transport instanceof NodeTypeManagementInterface) {
            return $this->transport->registerNodeTypes($types, $allowUpdate);
        }
        if ($this->transport instanceof NodeTypeCndManagementInterface) {
            $writer = new CndWriter($this->session->getWorkspace()->getNamespaceRegistry());
            return $this->transport->registerNodeTypesCnd($writer->writeString($types), $allowUpdate);
        }
        throw new UnsupportedRepositoryOperationException('Transport does not support registering node types');
    }

Usage Example

Example #1
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function registerNodeTypes(array $definitions, $allowUpdate)
 {
     $nts = array();
     // prepare them first (all or nothing)
     foreach ($definitions as $definition) {
         $nts[$definition->getName()] = $this->createNodeType($definition, $allowUpdate);
     }
     $this->objectManager->registerNodeTypes($definitions, $allowUpdate);
     // no need to fetch the node types as with cnd, we already have the def and can
     // now register them ourselves
     foreach ($nts as $nt) {
         $this->addNodeType($nt);
     }
     return new ArrayIterator($nts);
 }