/**
  * {@inheritdoc}
  */
 public function createNodeForDocument($document, NodeInterface $parentNode, $name)
 {
     $metadata = $this->metadataFactory->getMetadataForClass(get_class($document));
     $node = $parentNode->addNode($name);
     $node->addMixin($metadata->getPhpcrType());
     $node->setProperty('jcr:uuid', UUIDHelper::generateUUID());
     return $node;
 }
 /**
  * It should set the parent document.
  */
 public function testSetParentDocument()
 {
     $this->persistEvent->getDocument()->willReturn($this->document->reveal());
     $this->persistEvent->getLocale()->willReturn('fr');
     $this->metadataFactory->getMetadataForClass(get_class($this->document->reveal()))->willReturn($this->metadata->reveal());
     $this->metadata->getAlias()->willReturn('test');
     $this->nodeManager->createPath('/')->willReturn($this->parentNode->reveal());
     $this->persistEvent->hasParentNode()->shouldBeCalled();
     $this->persistEvent->setParentNode($this->parentNode->reveal())->shouldBeCalled();
     $this->documentManager->find('/test', 'fr')->willReturn($this->parentDocument);
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }
 /**
  * @param $document
  *
  * @return string
  */
 protected function getParentName($document)
 {
     return $this->metadataFactory->getMetadataForClass(get_class($document))->getAlias();
 }
Exemple #4
0
 private function getQuery($classFqn)
 {
     $metadata = $this->metadataFactory->getMetadataForClass($classFqn);
     // TODO: Use the document manager query builder.
     return $this->documentManager->createQuery(sprintf('SELECT * FROM [nt:unstructured] AS a WHERE [jcr:mixinTypes] = "%s"', $metadata->getPhpcrType()));
 }
 /**
  * {@inheritdoc}
  */
 public function getMetadataForClass($class)
 {
     return $this->metadataFactory->getMetadataForClass($class);
 }