/** * Check object status is enity * * @param object|string $entity * @return bool */ protected function isEntity($entity) { if (is_object($entity)) { $entity = ClassUtils::getClass($entity); } return !$this->entityManager->getMetadataFactory()->isTransient($entity); }
protected function execute(InputInterface $input, OutputInterface $output) { try { $schemaTool = new Doctrine\ORM\Tools\SchemaTool($this->em); $schemaTool->updateSchema($this->em->getMetadataFactory()->getAllMetadata()); $output->writeLn('<info>[OK] - BLOG:UPDATE</info>'); return 0; // zero return code means everything is ok } catch (\Exception $exc) { $output->writeLn('<error>BLOG:UPDATE - ' . $exc->getMessage() . '</error>'); return 1; // non-zero return code means error } }
/** * Sets the user identity. * @return UserStorage Provides a fluent interface */ public function setIdentity(IIdentity $identity = null) { if ($identity !== NULL) { $class = get_class($identity); // we want to convert identity entities into fake identity // so only the identifier fields are stored, // but we are only interested in identities which are correctly // mapped as doctrine entities if ($this->entityManager->getMetadataFactory()->hasMetadataFor($class)) { $cm = $this->entityManager->getClassMetadata($class); $identifier = $cm->getIdentifierValues($identity); $identity = new FakeIdentity($identifier, $class); } } return parent::setIdentity($identity); }
protected function execute(InputInterface $input, OutputInterface $output) { try { $schemaTool = new Doctrine\ORM\Tools\SchemaTool($this->em); $schemaTool->createSchema($this->em->getMetadataFactory()->getAllMetadata()); $post = new Entity\Post(); $post->title = 'Vítejte na svém novém blogu!'; $post->slug = 'vitejte-na-svem-novem-blogu'; $post->body = 'Instalace proběhla úspěšně. Jupí! (-:'; $post->date = new \DateTime(); $post->publish_date = new \DateTime(); $this->em->persist($post); $this->em->flush(); $output->writeLn('<info>[OK] - BLOG:INSTALL</info>'); return 0; // zero return code means everything is ok } catch (\Exception $exc) { $output->writeLn('<error>BLOG:INSTALL - ' . $exc->getMessage() . '</error>'); return 1; // non-zero return code means error } }