本文整理汇总了PHP中Doctrine\ORM\EntityManager::getMetadataFactory方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getMetadataFactory方法的具体用法?PHP EntityManager::getMetadataFactory怎么用?PHP EntityManager::getMetadataFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityManager
的用法示例。
在下文中一共展示了EntityManager::getMetadataFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
public function convert($cacheDir)
{
$fs = new Filesystem();
$targetDir = $cacheDir . '/js_entities';
$webDir = $this->kernel->getRootDir() . '/../web/js';
$fs->mkdir($targetDir);
$fs->mkdir($webDir);
$namespaces = [];
$metas = $this->entityManager->getMetadataFactory()->getAllMetadata();
foreach ($metas as $metadata) {
$meta = $this->convertMetadata($metadata);
$directory = $targetDir . '/' . $meta->namespace;
$fs->mkdir($directory);
$meta->filename = $directory . '/' . $meta->functionName . '.js';
$this->generator->generateEntity($meta);
if (!isset($namespaces[$meta->namespace])) {
$namespaces[$meta->namespace] = array();
}
$namespaces[$meta->namespace][] = $meta;
}
foreach ($namespaces as $namespace => $metas) {
$targetFile = $targetDir . '/' . $namespace . '.js';
$webFile = $webDir . '/' . $namespace . '.js';
$this->generator->generateNamespace($namespace, $metas, $targetFile);
$fs->copy($targetFile, $webFile);
}
}
示例2: boot
/**
* @throws \Doctrine\ORM\ORMException
*/
public function boot()
{
$this->serializer = SerializerBuilder::create()->setDebug($this->devMode)->build();
$this->entityFolder->create();
AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . '/../../../../vendor/jms/serializer/src');
$proxyDoctrineFolder = new Folder(sys_get_temp_dir() . '/doctrine');
$config = Setup::createAnnotationMetadataConfiguration([$this->entityFolder->absolute()], $this->isDevMode(), $proxyDoctrineFolder->absolute());
if ($this->cache !== null) {
$config->setQueryCacheImpl($this->getCache());
$config->setResultCacheImpl($this->getCache());
}
$this->entityManager = $this->createEntityManager($config);
$debugStack = new DebugStack();
$this->entityManager->getConnection()->getConfiguration()->setSQLLogger($debugStack);
if ($this->getFileCreation()->getContent() == 1) {
return;
}
if ($proxyDoctrineFolder->isFolder()) {
$proxyDoctrineFolder->removeFiles();
}
$tool = new SchemaTool($this->entityManager);
$metadatas = $this->entityManager->getMetadataFactory()->getAllMetadata();
$proxyDoctrineFolder->create();
$this->entityManager->getProxyFactory()->generateProxyClasses($metadatas, $proxyDoctrineFolder->absolute());
if ($this->cloudFoundryBoot->isInCloudFoundry()) {
$tool->updateSchema($metadatas);
} else {
$tool->createSchema($metadatas);
}
$this->getFileCreation()->setContent(1);
}
示例3: purge
/**
* {@inheritdoc}
*/
public function purge()
{
$classes = array();
$metadatas = $this->em->getMetadataFactory()->getAllMetadata();
foreach ($metadatas as $metadata) {
if (!$metadata->isMappedSuperclass) {
$classes[] = $metadata;
}
}
$commitOrder = $this->getCommitOrder($this->em, $classes);
// Drop association tables first
$orderedTables = $this->getAssociationTables($commitOrder);
// Get platform parameters
$platform = $this->em->getConnection()->getDatabasePlatform();
// Drop tables in reverse commit order
for ($i = count($commitOrder) - 1; $i >= 0; --$i) {
$class = $commitOrder[$i];
if ($class->isInheritanceTypeSingleTable() && $class->name != $class->rootEntityName || $class->isMappedSuperclass) {
continue;
}
$orderedTables[] = $class->getQuotedTableName($platform);
}
$orderedTables = array_diff($orderedTables, $this->excludedTables);
foreach ($orderedTables as $tbl) {
if ($this->purgeMode === self::PURGE_MODE_DELETE) {
$this->em->getConnection()->executeUpdate("DELETE FROM " . $tbl);
} else {
$this->em->getConnection()->executeUpdate($platform->getTruncateTableSQL($tbl, true));
}
}
}
示例4: loadClassMetadata
/**
* @param LoadClassMetadataEventArgs $args
*/
public function loadClassMetadata(LoadClassMetadataEventArgs $args)
{
$this->em = $args->getEntityManager();
$this->meta = $args->getClassMetadata();
if (!$this->em->getConnection()->getWrappedConnection() instanceof AbstractConnection) {
return;
}
if ($this->meta->customPersisterClassName === null) {
$this->meta->setCustomPersisterClass(EntityPersister::class);
}
$this->markIndex();
foreach ($this->meta->fieldMappings as $property => &$mapping) {
$this->remapIdentifier($property, $mapping);
$this->remapVersion($property, $mapping);
$this->markField($property, $mapping);
}
foreach ($this->meta->associationMappings as $property => &$mapping) {
$this->remapAnyToOneAssociation($property, $mapping);
$this->remapAnyToManyAssociation($property, $mapping);
$this->remapManyToManyAssociation($property, $mapping);
}
if ($cache = $this->em->getMetadataFactory()->getCacheDriver()) {
$cache->save($this->meta->name . '$CLASSMETADATA', $this->meta, null);
}
}
示例5: getExtensionMetadata
/**
* Reads extension metadata
*
* @param ClassMetadataInfo $meta
* @return array - the metatada configuration
*/
public function getExtensionMetadata(ClassMetadataInfo $meta)
{
if ($meta->isMappedSuperclass) {
return;
// ignore mappedSuperclasses for now
}
$config = array();
// collect metadata from inherited classes
foreach (array_reverse(class_parents($meta->name)) as $parentClass) {
// read only inherited mapped classes
if ($this->_em->getMetadataFactory()->hasMetadataFor($parentClass)) {
$this->_driver->readExtendedMetadata($this->_em->getClassMetadata($parentClass), $config);
}
}
$this->_driver->readExtendedMetadata($meta, $config);
$this->_driver->validateFullMetadata($meta, $config);
if ($config) {
// cache the metadata
$cacheId = self::getCacheId($meta->name, $this->_extensionNamespace);
if ($cacheDriver = $this->_em->getMetadataFactory()->getCacheDriver()) {
$cacheDriver->save($cacheId, $config, null);
}
}
return $config;
}
示例6: getMetadata
public static function getMetadata()
{
/** @var EntityManagerInterface $em */
static::$em = static::$kernel->getContainer()->get('doctrine')->getManager();
$metadata = static::$em->getMetadataFactory()->getAllMetadata();
return $metadata;
}
示例7: resetDatabase
public function resetDatabase()
{
$metadatas = $this->em->getMetadataFactory()->getAllMetadata();
$tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
$tool->dropDatabase();
$tool->createSchema($metadatas);
}
示例8: __construct
public function __construct(EntityManager $em, $currencyClassName)
{
$this->em = $em;
$this->currencyClassName = $currencyClassName;
if (!$currencyClassName || !$this->em->getMetadataFactory()->hasMetadataFor($currencyClassName) && !$this->em->getClassMetadata($currencyClassName)) {
throw new \Exception("Class for currency \"{$currencyClassName}\" not found");
}
}
示例9: init
protected function init()
{
$this->em = $this->app['em'];
$this->connection = $this->em->getConnection();
$this->schemaManager = $this->em->getConnection()->getSchemaManager();
$this->schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
$this->validator = new \Doctrine\ORM\Tools\SchemaValidator($this->em);
$this->metadatas = $this->em->getMetadataFactory()->getAllMetadata();
}
示例10: generateSchema
/**
* @return null
*/
protected function generateSchema()
{
$metadatas = $this->em->getMetadataFactory()->getAllMetadata();
if (!empty($metadatas)) {
$tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
$tool->dropSchema($metadatas);
$tool->createSchema($metadatas);
}
}
示例11: createSchema
private function createSchema()
{
$this->getProvider()->deleteDatabase($this->getDatabaseName());
$schemaTool = new SchemaTool($this->entityManager);
$schemaTool->createSchema($this->entityManager->getMetadataFactory()->getAllMetadata());
$this->loadFixtures();
$this->getProvider()->backupDatabase($this->getDatabaseName());
self::$schemaExists = true;
}
示例12: getEntityClassesFromEntityManager
/**
* @return array
*/
protected function getEntityClassesFromEntityManager()
{
$entityClasses = [];
$metaData = $this->entityManager->getMetadataFactory()->getAllMetadata();
foreach ($metaData as $classMetaData) {
$entityClasses[] = $classMetaData->getName();
}
return $entityClasses;
}
示例13: getManagedEntities
/**
* @return ChoiceQuestion
*/
protected function getManagedEntities()
{
$metadata = $this->em->getMetadataFactory()->getAllMetadata();
$entities = [];
/** @var ClassMetadata $meta */
foreach ($metadata as $index => $meta) {
$entities[$index] = $meta->getReflectionClass()->getName();
}
return $entities;
}
示例14: setUp
public function setUp()
{
$dbParams = array('dbname' => 'metamodel_test', 'memory' => 'true', 'driver' => 'pdo_sqlite');
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/Fixture"), true);
$this->em = EntityManager::create($dbParams, $config);
$tool = new SchemaTool($this->em);
$tool->createSchema($this->em->getMetadataFactory()->getAllMetadata());
$this->metaModel = new MetaModel();
$this->metaModel->addObjectManager(new EntityManagerBridge($this->em));
}
示例15: setUp
protected function setUp()
{
parent::setUp();
if (!isset(static::$_sharedConn)) {
static::$_sharedConn = $this->_getDefaultConnection();
}
$this->_em = $this->_getTestEntityManager(static::$_sharedConn);
$this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em);
$this->_schemaTool->createSchema($this->_em->getMetadataFactory()->getAllMetadata());
}