本文整理汇总了PHP中Doctrine\ORM\EntityManagerInterface::getMetadataFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManagerInterface::getMetadataFactory方法的具体用法?PHP EntityManagerInterface::getMetadataFactory怎么用?PHP EntityManagerInterface::getMetadataFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityManagerInterface
的用法示例。
在下文中一共展示了EntityManagerInterface::getMetadataFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
public function fire()
{
$this->info('Starting proxy generation....');
// flush all generated and cached entities, etc
\D2Cache::flushAll();
try {
$metadata = $this->d2em->getMetadataFactory()->getAllMetadata();
} catch (\Doctrine\Common\Persistence\Mapping\MappingException $e) {
if ($this->option('verbose') == 3) {
throw $e;
}
$this->error("Caught Doctrine\\Common\\Persistence\\Mapping\\MappingException: " . $e->getMessage());
$this->info("Re-optimizing:");
$this->call('optimize');
$this->comment("*** You must now rerun this artisan command ***");
exit(-1);
}
if (empty($metadata)) {
$this->error('No metadata found to generate entities.');
return -1;
}
$directory = Config::get('d2doctrine.paths.proxies');
if (!$directory) {
$this->error('The proxy directory has not been set.');
return -1;
}
$this->info('Processing entities:');
foreach ($metadata as $item) {
$this->line($item->name);
}
$this->d2em->getProxyFactory()->generateProxyClasses($metadata, $directory);
$this->info('Proxies have been created.');
}
示例2: createDoctrineSchema
/**
* Creates schema for doctrine entities
*
* @throws \Doctrine\ORM\Tools\ToolsException
*/
protected function createDoctrineSchema()
{
$metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
$tool = new SchemaTool($this->entityManager);
$tool->dropSchema($metadata);
$tool->createSchema($metadata);
}
示例3: rebuildDatabase
/**
* Builds the DB Schema
*
* @return void
*/
protected function rebuildDatabase()
{
# 2. Drop the existing database schema
$this->schemaTool->dropDatabase();
# 3. Create the new database schema based on (1)
$entityMeta = $this->em->getMetadataFactory()->getAllMetadata();
$this->schemaTool->updateSchema($entityMeta);
}
示例4: createSchema
/**
* {@inheritdoc}
*/
public function createSchema()
{
$metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
if (empty($metadata)) {
throw new \UnexpectedValueException('No mapping information to process');
}
$tool = new SchemaTool($this->entityManager);
return $tool->getSchemaFromMetadata($metadata);
}
示例5: generateSchema
public function generateSchema()
{
$metadatas = $this->em->getMetadataFactory()->getAllMetadata();
if (!empty($metadatas)) {
$tool = new \Doctrine\ORM\Tools\SchemaTool($this->om);
$tool->dropDatabase();
$tool->dropSchema($metadatas);
$tool->createSchema($metadatas);
}
}
示例6: __construct
/**
* Initializes a new instance of the <tt>ProxyFactory</tt> class that is
* connected to the given <tt>EntityManager</tt>.
*
* @param EntityManagerInterface $em The EntityManager the new factory works for.
* @param string $proxyDir The directory to use for the proxy classes. It must exist.
* @param string $proxyNs The namespace to use for the proxy classes.
* @param boolean|int $autoGenerate The strategy for automatically generating proxy classes. Possible
* values are constants of Doctrine\Common\Proxy\AbstractProxyFactory.
*/
public function __construct(EntityManagerInterface $em, $proxyDir, $proxyNs, $autoGenerate = AbstractProxyFactory::AUTOGENERATE_NEVER)
{
$proxyGenerator = new ProxyGenerator($proxyDir, $proxyNs);
$proxyGenerator->setPlaceholder('baseProxyInterface', 'Doctrine\\ORM\\Proxy\\Proxy');
parent::__construct($proxyGenerator, $em->getMetadataFactory(), $autoGenerate);
$this->em = $em;
$this->uow = $em->getUnitOfWork();
$this->proxyNs = $proxyNs;
$this->identifierFlattener = new IdentifierFlattener($this->uow, $em->getMetadataFactory());
}
示例7: setUp
public function setUp()
{
$client = self::createClient();
$this->entityManager = $client->getContainer()->get('doctrine')->getManager();
$metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
if (!empty($metadata)) {
$tool = new SchemaTool($this->entityManager);
$tool->dropSchema($metadata);
$tool->createSchema($metadata);
}
}
示例8: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
$this->connection = new MysqlPersistentConnection();
$params = $this->connection->getConnectionParams();
$config = Setup::createAnnotationMetadataConfiguration([__DIR__ . '/Entity'], true, null, null, false);
$this->em = EntityManager::create($params, $config);
// create tables in the database
$metadata = $this->em->getMetadataFactory()->getAllMetadata();
$schema_tool = new SchemaTool($this->em);
$schema_tool->createSchema($metadata);
$this->provider = new EntityMutationMetadataProvider(new AnnotationReader());
}
示例9: setUpBeforeClass
public static function setUpBeforeClass()
{
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/../../../metadata/TestEntities"), $isDevMode, null, null, false);
$connectionOptions = array('driver' => 'pdo_sqlite', 'memory' => true);
// obtaining the entity manager
self::$em = EntityManager::create($connectionOptions, $config);
$schemaTool = new SchemaTool(self::$em);
$cmf = self::$em->getMetadataFactory();
$classes = $cmf->getAllMetadata();
$schemaTool->dropDatabase();
$schemaTool->createSchema($classes);
}
示例10: regenerateSchema
protected function regenerateSchema()
{
$this->client = static::createClient();
$container = $this->client->getContainer();
$doctrine = $container->get('doctrine');
$this->em = $doctrine->getManager();
$metadata = $this->em->getMetadataFactory()->getAllMetadata();
/**
* Drops current schema and creates a brand new one
*/
if (!empty($metadata)) {
$tool = new SchemaTool($this->em);
$tool->dropSchema($metadata);
$tool->createSchema($metadata);
}
}
示例11: initOrm
protected function initOrm(EntityManagerInterface $entityManager)
{
$schemaTool = new SchemaTool($entityManager);
$metadatas = $entityManager->getMetadataFactory()->getAllMetadata();
$schemaTool->dropSchema($metadatas);
$schemaTool->createSchema($metadatas);
}
示例12: processParameterValue
/**
* Processes an individual parameter value.
*
* @param mixed $value
*
* @return array|string
*
* @throws \Doctrine\ORM\ORMInvalidArgumentException
*/
public function processParameterValue($value)
{
if (is_scalar($value)) {
return $value;
}
if ($value instanceof Collection) {
$value = $value->toArray();
}
if (is_array($value)) {
foreach ($value as $key => $paramValue) {
$paramValue = $this->processParameterValue($paramValue);
$value[$key] = is_array($paramValue) ? reset($paramValue) : $paramValue;
}
return $value;
}
if (is_object($value) && $this->_em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($value))) {
$value = $this->_em->getUnitOfWork()->getSingleIdentifierValue($value);
if ($value === null) {
throw ORMInvalidArgumentException::invalidIdentifierBindingEntity();
}
}
if ($value instanceof Mapping\ClassMetadata) {
return $value->name;
}
return $value;
}
示例13: createSchemaForSupportedEntities
/**
* Creates the schema for the managed entities.
*
* @param EntityManagerInterface $entityManager
*/
protected function createSchemaForSupportedEntities(EntityManagerInterface $entityManager)
{
$entityClasses = $this->getEntityClasses();
$entityClasses[] = $this->getRepositoryObjectClass();
$metadata = array_map(function ($className) use($entityManager) {
return $entityManager->getMetadataFactory()->getMetadataFor($className);
}, $entityClasses);
$schemaTool = new SchemaTool($entityManager);
$schemaTool->createSchema($metadata);
}
示例14: toIdentifierArray
/**
* @param \Doctrine\ORM\Mapping\ClassMetadata $metadata The entity metadata.
* @param mixed $identifier The entity identifier.
*
* @return array
*/
private function toIdentifierArray(ClassMetadata $metadata, $identifier)
{
if (is_object($identifier) && $this->em->getMetadataFactory()->hasMetadataFor(ClassUtils::getClass($identifier))) {
$identifier = $this->uow->getSingleIdentifierValue($identifier);
if ($identifier === null) {
throw ORMInvalidArgumentException::invalidIdentifierBindingEntity();
}
}
return array($metadata->identifier[0] => $identifier);
}
示例15: fire
public function fire()
{
$this->info('Starting proxy generation....');
$metadata = $this->entityManager->getMetadataFactory()->getAllMetadata();
if (empty($metadata)) {
$this->error('No metadata found to generate any entities.');
exit;
}
$directory = $this->laravel['config']['doctrine::doctrine.proxy.directory'];
if (!$directory) {
$this->error('The proxy directory has not been set.');
exit;
}
$this->info('Processing entities:');
foreach ($metadata as $item) {
$this->line($item->name);
}
$this->entityManager->getProxyFactory()->generateProxyClasses($metadata, $directory);
$this->info('Proxies have been created.');
}