/** * {@inheritDoc} */ public function getNode() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getNode', array()); return parent::getNode(); }
/** * Convert the given generic document to an auto route document. * * @param Generic $document * @param object $contentDocument * @param string $autoRouteTag * @param string $routeType * * @return AutoRouteInterface */ private function migrateGenericToAutoRoute(Generic $document, $contentDocument, $autoRouteTag, $routeType) { $autoRouteClassName = $this->autoRouteFqcn; $mapper = $this->dm->getConfiguration()->getDocumentClassMapper(); $mapper->writeMetadata($this->dm, $document->getNode(), $autoRouteClassName); $this->dm->getPhpcrSession()->save(); // Detach is needed to force Doctrine to re-load the node $this->dm->detach($document); $autoRoute = $this->dm->find(null, $document->getId()); if (!$autoRoute instanceof $autoRouteClassName) { throw new \RuntimeException(sprintf('Failed to migrate existing, non-managed, PHPCR node at "%s" to a managed document implementing ' . 'the AutoRouteInterface. It is an instance of "%s".', $document->getId(), get_class($autoRoute))); } $autoRoute->setContent($contentDocument); $autoRoute->setAutoRouteTag($autoRouteTag); $autoRoute->setType($routeType); return $autoRoute; }