/** * @param PersistEvent $event */ public function handleChangeParent(PersistEvent $event) { $document = $event->getDocument(); $node = $this->inspector->getNode($document); $parentNode = $event->getParentNode(); if ($parentNode->getPath() === $node->getParent()->getPath()) { return; } $this->documentManager->move($document, $parentNode->getPath()); }
/** * @param $template * @param $data * @param $parent * * @return PageDocument */ private function savePage($template, $data, $parent, $tags = []) { $data = array_merge(['structureType' => $template, 'parent' => $parent, 'workflowStage' => 2, 'webspace_key' => 'sulu_io'], $data); $document = $this->documentManager->create('page'); $options = ['csrf_protection' => false, 'webspace_key' => 'sulu_io']; $form = $this->formFactory->create('page', $document, $options); $clearMissing = false; $form->submit($data, $clearMissing); $this->documentManager->persist($document, 'en', ['user' => 1]); $this->documentManager->flush(); $node = $this->inspector->getNode($document); $node->setProperty('i18n:en-excerpt-tags', $tags); $node->getSession()->save(); return $document; }
private function removeReferences($document) { $node = $this->documentInspector->getNode($document); $this->removeReferencesForNode($this->defaultSession->getNode($node->getPath())); $this->removeReferencesForNode($this->liveSession->getNode($node->getPath())); }