In Jackalope, we try to do lazy fetching of node types to reduce overhead. Jackalope supports registering node types, and when using the jackrabbit for transport, there is an additional method registerNodeTypesCnd for the jackrabbit specific textual node type specification
Inheritance: implements IteratorAggregat\IteratorAggregate, implements PHPCR\NodeType\NodeTypeManagerInterface
コード例 #1
0
 /**
  * @covers Jackalope\NodeTYpe\NodeTypeTemplate::getPropertyDefinitionTemplates
  */
 public function testEmptyPropertyDefinitionTemplatesMutable()
 {
     $nt = $this->ntm->createNodeTypeTemplate();
     $property = $this->ntm->createPropertyDefinitionTemplate();
     $property->setName('test:propdef');
     $this->assertNull($nt->getDeclaredPropertyDefinitions());
     $properties = $nt->getPropertyDefinitionTemplates();
     $this->assertInstanceOf('ArrayObject', $properties);
     $properties[] = $property;
     $propertiesAgain = $nt->getPropertyDefinitionTemplates();
     $this->assertInstanceOf('ArrayObject', $propertiesAgain);
     $this->assertCount(1, $propertiesAgain);
     $propertiesArray = $propertiesAgain->getArrayCopy();
     $this->assertSame($property, reset($propertiesArray));
     $this->assertEquals('test:propdef', reset($propertiesArray)->getName());
 }
コード例 #2
0
 /**
  * Build the raw data for a list of database result rows, fetching the
  * additional information in one single query.
  *
  * @param array $rows
  *
  * @return \stdClass[]
  */
 private function getNodesData($rows)
 {
     $data = array();
     $paths = array();
     foreach ($rows as $row) {
         $this->nodeIdentifiers[$row['path']] = $row['identifier'];
         $data[$row['path']] = $this->xmlToProps($row['props']);
         $data[$row['path']]->{'jcr:primaryType'} = $row['type'];
         $paths[] = $row['path'];
     }
     $query = 'SELECT path, parent FROM phpcr_nodes WHERE parent IN (?) AND workspace_name = ? ORDER BY sort_order ASC';
     if ($this->getConnection()->getDatabasePlatform() instanceof SqlitePlatform) {
         $childrenRows = array();
         foreach (array_chunk($paths, self::SQLITE_MAXIMUM_IN_PARAM_COUNT) as $chunk) {
             $childrenRows += $this->getConnection()->fetchAll($query, array($chunk, $this->workspaceName), array(Connection::PARAM_STR_ARRAY, null));
         }
     } else {
         $childrenRows = $this->getConnection()->fetchAll($query, array($paths, $this->workspaceName), array(Connection::PARAM_STR_ARRAY, null));
     }
     foreach ($childrenRows as $child) {
         $childName = explode('/', $child['path']);
         $childName = end($childName);
         if (!isset($data[$child['parent']]->{$childName})) {
             $data[$child['parent']]->{$childName} = new \stdClass();
         }
     }
     foreach (array_keys($data) as $path) {
         // If the node is referenceable, return jcr:uuid.
         if (isset($data[$path]->{"jcr:mixinTypes"})) {
             foreach ((array) $data[$path]->{"jcr:mixinTypes"} as $mixin) {
                 if ($this->nodeTypeManager->getNodeType($mixin)->isNodeType('mix:referenceable')) {
                     $data[$path]->{'jcr:uuid'} = $this->nodeIdentifiers[$path];
                     break;
                 }
             }
         }
     }
     return $data;
 }
コード例 #3
0
ファイル: Client.php プロジェクト: xxspartan16/BMS-Market
    private function getNodeData($path, $row)
    {
        $this->nodeIdentifiers[$path] = $row['identifier'];

        $data = self::xmlToProps($row['props'], $this->valueConverter);
        $data->{'jcr:primaryType'} = $row['type'];

        $query = 'SELECT path FROM phpcr_nodes WHERE parent = ? AND workspace_name = ? ORDER BY sort_order ASC';
        $children = $this->conn->fetchAll($query, array($path, $this->workspaceName));
        foreach ($children as $child) {
            $childName = explode('/', $child['path']);
            $childName = end($childName);
            if (!isset($data->{$childName})) {
                $data->{$childName} = new \stdClass();
            }
        }

        // If the node is referenceable, return jcr:uuid.
        if (isset($data->{"jcr:mixinTypes"})) {
            foreach ((array) $data->{"jcr:mixinTypes"} as $mixin) {
                if ($this->nodeTypeManager->getNodeType($mixin)->isNodeType('mix:referenceable')) {
                    $data->{'jcr:uuid'} = $row['identifier'];
                    break;
                }
            }
        }

        return $data;
    }
コード例 #4
0
ファイル: TestCase.php プロジェクト: nikophil/cmf-tests
 /**
  * Get the (real) node type manager with a mock object manager that returns
  * real node type data for getNodeTypes.
  *
  * @return NodeTypeManager
  */
 protected function getNodeTypeManager()
 {
     $factory = new Factory();
     $dom = new \DOMDocument();
     $dom->load(__DIR__ . '/../fixtures/nodetypes.xml');
     $converter = new NodeTypeXmlConverter($factory);
     $om = $this->getObjectManagerMock();
     $om->expects($this->any())->method('getNodeTypes')->will($this->returnValue($converter->getNodeTypesFromXml($dom)));
     $ns = $this->getMockBuilder('Jackalope\\NamespaceRegistry')->disableOriginalConstructor()->getMock();
     $ntm = new NodeTypeManager($factory, $om, $ns);
     // we need to initialize as getting a single node type calls a different method on the om.
     $ntm->getAllNodeTypes();
     return $ntm;
 }
コード例 #5
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function getDeclaringNodeType()
 {
     return $this->nodeTypeManager->getNodeType($this->declaringNodeType);
 }