/** * On delete node. * * @param NodeInterface $node */ public function onDeleteNode(NodeInterface $node) { $textNode = $this->textNodeManager->findTextNodeByNode($node); if (null !== $textNode) { $this->textNodeManager->remove($textNode); $this->textManager->remove($textNode->getText()); } }
/** * Process text. * * @param Request $request * @param FormInterface $form * * @return bool */ public function process(Request $request, FormInterface $form) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { /** @var TextInterface $text */ $text = $form->getData(); foreach ($text->getTranslations() as $translation) { $translation->setText($text); } $this->textManager->add($form->getData()); return true; } } return false; }
/** * Get text node. * * @param NodeInterface $node * * @return TextNodeInterface */ private function getTextNode(NodeInterface $node) { $textNode = $this->textNodeManager->findTextNodeByNode($node); if (null === $textNode) { $textNode = $this->textNodeManager->create(); $text = $this->textManager->create(); $textNode->setText($text); $textNode->setNode($node); $this->textManager->add($text); $this->textNodeManager->add($textNode); } return $textNode; }