本文整理汇总了PHP中Kdyby\Doctrine\EntityManager::getMetadataFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getMetadataFactory方法的具体用法?PHP EntityManager::getMetadataFactory怎么用?PHP EntityManager::getMetadataFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kdyby\Doctrine\EntityManager
的用法示例。
在下文中一共展示了EntityManager::getMetadataFactory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isEntity
/**
* 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);
}
示例2: execute
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
}
}
示例3: setIdentity
/**
* 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);
}
示例4: execute
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
}
}