/** * {@inheritDoc} * * @api */ public function getMixinNodeTypes() { $this->checkNodeTypeEvent(); $nt = array(); foreach ($this->mixinNodeTypeNames as $name) { $nt[$name] = $this->ntm->getNodeType($name); } return $nt; }
/** * @expectedException \PHPCR\NodeType\NoSuchNodeTypeException */ public function testGetNodeTypeNoSuch() { $this->nodeTypeManager->getNodeType('no-such-type'); }
/** * {@inheritDoc} */ public function getNode($path) { $this->assertLoggedIn(); $path = $this->validatePath($path); $coll = $this->db->selectCollection(self::COLLNAME_NODES); $qb = $coll->createQueryBuilder()->field('path')->equals($path)->field('w_id')->equals($this->workspaceId); $query = $qb->getQuery(); $node = $query->getSingleResult(); if (!$node) { throw new ItemNotFoundException('Item ' . $path . ' not found.'); } $data = new \stdClass(); $data->{'jcr:primaryType'} = $node['type']; foreach ($node['props'] as $prop) { $name = $prop['name']; $type = $prop['type']; if ($type == PropertyType::TYPENAME_BINARY) { if (isset($prop['multi']) && $prop['multi'] == true) { foreach ($prop['value'] as $value) { $data->{":" . $name}[] = $value; } } else { $data->{":" . $name} = $prop['value']; } } elseif ($type == PropertyType::TYPENAME_DATE) { if (isset($prop['multi']) && $prop['multi'] == true) { foreach ($prop['value'] as $value) { $date = new \DateTime(date('Y-m-d H:i:s', $value['date']->sec), new \DateTimeZone($value['timezone'])); $data->{$name}[] = $date->format('c'); } } else { $date = new \DateTime(date('Y-m-d H:i:s', $prop['value']['date']->sec), new \DateTimeZone($prop['value']['timezone'])); $data->{$name} = $date->format('c'); } $data->{":" . $name} = $type; } elseif ($type == PropertyType::TYPENAME_BOOLEAN) { if (isset($prop['multi']) && $prop['multi'] == true) { $booleanValue = array(); foreach ($prop['value'] as $booleanEntry) { $booleanValue[] = $this->fetchBooleanPropertyValue($booleanEntry); } } else { $booleanValue = $this->fetchBooleanPropertyValue($prop['value']); } $data->{$name} = $booleanValue; $data->{":" . $name} = $type; } else { if (isset($prop['multi']) && $prop['multi'] == true) { foreach ($prop['value'] as $value) { $data->{$name}[] = $value; } } else { $data->{$name} = $prop['value']; } $data->{":" . $name} = $type; } } // 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') && $node['_id'] instanceof \MongoBinData) { $data->{'jcr:uuid'} = $node['_id']->bin; break; } } } $qb = $coll->createQueryBuilder()->field('parent')->equals($path)->field('w_id')->equals($this->workspaceId); $query = $qb->getQuery(); $children = $query->getIterator(); foreach ($children as $child) { $childName = explode('/', $child['path']); $childName = end($childName); $data->{$childName} = new \stdClass(); } return $data; }
/** * requires the implementation to support unstructured nodes. */ public function testCanSetPropertyWildcard() { $undef = $this->ntm->getNodeType('nt:unstructured'); $this->assertTrue($undef->canSetProperty('something', true)); }