/** * @covers Jackalope\NodeTYpe\NodeTypeTemplate::getPropertyDefinitionTemplates */ public function testPropertyDefinitionTemplatesMutable() { $nt = $this->ntm->getNodeType('nt:file'); $newnt = $this->ntm->createNodeTypeTemplate($nt); $property = $this->ntm->createPropertyDefinitionTemplate(); $property->setName('test:propdef'); $properties = $newnt->getPropertyDefinitionTemplates(); $this->assertInstanceOf('ArrayObject', $properties); $properties[] = $property; $propertiesAgain = $newnt->getPropertyDefinitionTemplates(); $this->assertInstanceOf('ArrayObject', $propertiesAgain); $this->assertCount(1, $propertiesAgain); $propertiesArray = $propertiesAgain->getArrayCopy(); $this->assertSame($property, reset($propertiesArray)); $this->assertEquals('test:propdef', reset($propertiesArray)->getName()); }
/** * 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; }
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; }
/** * {@inheritDoc} * * @api */ public function getDeclaringNodeType() { return $this->nodeTypeManager->getNodeType($this->declaringNodeType); }