Example #1
0
 /**
  * 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);
 }
Example #2
0
 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
     }
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 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
     }
 }