本文整理匯總了PHP中Doctrine\ORM\EntityManagerInterface::getConfiguration方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityManagerInterface::getConfiguration方法的具體用法?PHP EntityManagerInterface::getConfiguration怎麽用?PHP EntityManagerInterface::getConfiguration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\ORM\EntityManagerInterface
的用法示例。
在下文中一共展示了EntityManagerInterface::getConfiguration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getProfilingLogger
/**
* Gets a profiling logger.
*
* @return OrmLogger|null
*/
protected function getProfilingLogger()
{
if (null === $this->entityManager) {
return null;
}
$config = $this->entityManager->getConfiguration();
return $config instanceof OrmConfiguration ? $config->getAttribute('OrmProfilingLogger') : null;
}
示例2: boot
/**
* Boot the extensions
*/
public function boot()
{
foreach ($this->registry->getManagers() as $em) {
$this->em = $em;
$this->evm = $this->em->getEventManager();
$this->metadata = $this->em->getConfiguration();
$this->reader = $this->driverChain->getReader();
foreach ($this->extensions as $extension) {
$this->bootExtension($extension);
}
}
}
示例3: createRepository
/**
* Create a new repository instance for an entity class.
*
* @param \Doctrine\ORM\EntityManagerInterface $entityManager The EntityManager instance.
* @param string $entityName The name of the entity.
*
* @return \Doctrine\Common\Persistence\ObjectRepository
*/
private function createRepository(EntityManagerInterface $entityManager, $entityName)
{
/* @var $metadata \Doctrine\ORM\Mapping\ClassMetadata */
$metadata = $entityManager->getClassMetadata($entityName);
$repositoryClassName = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName();
return new $repositoryClassName($entityManager, $metadata);
}
示例4: boot
/**
* Boot the extensions
*/
public function boot()
{
foreach ($this->registry->getManagers() as $em) {
$this->em = $em;
$this->evm = $this->em->getEventManager();
$this->metadata = $this->em->getConfiguration();
$this->reader = $this->driverChain->getReader();
$hash = spl_object_hash($em);
if (!isset($this->subscribedExtensions[$hash])) {
$this->subscribedExtensions[$hash] = [];
}
foreach ($this->extensions as $extension) {
$this->bootExtension($extension);
}
}
}
示例5: __construct
/**
* Initializes a new SchemaTool instance that uses the connection of the
* provided EntityManager.
*
* @param \Doctrine\ORM\EntityManagerInterface $em
*/
public function __construct(EntityManagerInterface $auditEm, EntityManagerInterface $sourceEm)
{
$this->auditEm = $auditEm;
$this->sourceEm = $sourceEm;
$this->platform = $auditEm->getConnection()->getDatabasePlatform();
$this->quoteStrategy = $auditEm->getConfiguration()->getQuoteStrategy();
}
示例6: boot
/**
* Boot the extensions
*/
public function boot()
{
foreach ($this->registry->getManagers() as $em) {
$this->em = $em;
$this->chain = new MappingDriverChain();
$this->evm = $this->em->getEventManager();
$this->metadata = $this->em->getConfiguration();
$this->reader = method_exists($this->metadata->getMetadataDriverImpl(), 'getReader') ? $this->metadata->getMetadataDriverImpl()->getReader() : false;
if ($this->gedmo['enabled']) {
$this->bootGedmoExtensions($this->gedmo['namespace'], $this->gedmo['all']);
}
foreach ($this->extensions as $extenion) {
$this->bootExtension($extenion);
}
}
}
示例7: __construct
/**
* Initializes a new instance of a class derived from AbstractCollectionPersister.
*
* @param EntityManagerInterface $em
*/
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
$this->uow = $em->getUnitOfWork();
$this->conn = $em->getConnection();
$this->platform = $this->conn->getDatabasePlatform();
$this->quoteStrategy = $em->getConfiguration()->getQuoteStrategy();
}
示例8: indexEntityClassNames
/**
* @return array
*/
private function indexEntityClassNames()
{
$indexedClassNames = [];
$entityClassNames = $this->em->getConfiguration()->getMetadataDriverImpl()->getAllClassNames();
foreach ($entityClassNames as $name) {
// @todo Support subtypes.
$resourceType = Util\Inflector::typify($name);
$indexedClassNames[$resourceType][] = $name;
}
//Config class override
foreach ($this->getResourcesConfig()->getAll() as $resource) {
if (!empty($resource->type) && !empty($resource->class)) {
$indexedClassNames[$resource->type] = array($resource->class);
}
}
return $indexedClassNames;
}
示例9: __construct
/**
* @param EntityManagerInterface $em
* @param AuditConfiguration $config
* @param MetadataFactory $factory
*/
public function __construct(EntityManagerInterface $em, AuditConfiguration $config, MetadataFactory $factory)
{
$this->em = $em;
$this->config = $config;
$this->metadataFactory = $factory;
$this->platform = $this->em->getConnection()->getDatabasePlatform();
$this->quoteStrategy = $this->em->getConfiguration()->getQuoteStrategy();
}
示例10: __construct
/**
* @param \Doctrine\ORM\EntityManagerInterface $em The entity manager.
* @param \Doctrine\ORM\Cache\Region $region The query region.
*/
public function __construct(EntityManagerInterface $em, Region $region)
{
$cacheConfig = $em->getConfiguration()->getSecondLevelCacheConfiguration();
$this->em = $em;
$this->region = $region;
$this->uow = $em->getUnitOfWork();
$this->cacheLogger = $cacheConfig->getCacheLogger();
$this->validator = $cacheConfig->getQueryValidator();
}
示例11: createRepository
/**
* @param EntityManagerInterface $entityManager
* @param string $entityName
*
* @return ObjectRepository
*/
protected function createRepository(EntityManagerInterface $entityManager, $entityName)
{
$metadata = $entityManager->getClassMetadata($entityName);
$repository = $metadata->customRepositoryClassName;
if ($repository === null) {
$repository = $entityManager->getConfiguration()->getDefaultRepositoryClassName();
}
return $this->createResourceRepository($repository, $entityManager, $metadata, $this->resolveResource($metadata->getName()));
}
示例12: setUp
public function setUp()
{
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('DoctrineExtensions\\Tests\\Proxies');
$config->setAutoGenerateProxyClasses(true);
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(__DIR__ . '/../Entities'));
$config->setCustomDatetimeFunctions(array('YEAR' => 'DoctrineExtensions\\Query\\Sqlite\\Year', 'WEEKDAY' => 'DoctrineExtensions\\Query\\Sqlite\\WeekDay', 'WEEK' => 'DoctrineExtensions\\Query\\Sqlite\\Week', 'Month' => 'DoctrineExtensions\\Query\\Sqlite\\Month', 'MINUTE' => 'DoctrineExtensions\\Query\\Sqlite\\Minute', 'HOUR' => 'DoctrineExtensions\\Query\\Sqlite\\Hour', 'DAY' => 'DoctrineExtensions\\Query\\Sqlite\\Day', 'DATE' => 'DoctrineExtensions\\Query\\Sqlite\\Date', 'STRFTIME' => 'DoctrineExtensions\\Query\\Sqlite\\StrfTime', 'DATE_FORMAT' => 'DoctrineExtensions\\Query\\Sqlite\\DateFormat'));
$this->entityManager = \Doctrine\ORM\EntityManager::create(array('driver' => 'pdo_sqlite', 'memory' => true), $config);
$configuration = $this->entityManager->getConfiguration();
if (method_exists($configuration, 'getQuoteStrategy') === false) {
// doctrine < 2.3
$this->columnAlias = 'sclr0';
} else {
$this->columnAlias = $configuration->getQuoteStrategy()->getColumnAlias('sclr', 0, $this->entityManager->getConnection()->getDatabasePlatform(), $this->entityManager->getClassMetadata('DoctrineExtensions\\Tests\\Entities\\Date'));
}
}
示例13: createRepository
/**
* Create a new repository instance for an entity class.
*
* @param \Doctrine\ORM\EntityManagerInterface $entityManager The EntityManager instance.
* @param string $entityName The name of the entity.
*
* @return \Doctrine\Common\Persistence\ObjectRepository
*/
protected function createRepository(EntityManagerInterface $entityManager, $entityName)
{
$metadata = $entityManager->getClassMetadata($entityName);
$repositoryClassName = $metadata->customRepositoryClassName;
if ($repositoryClassName === null) {
$configuration = $entityManager->getConfiguration();
$repositoryClassName = $configuration->getDefaultRepositoryClassName();
}
return new $repositoryClassName($entityManager, $metadata);
}
示例14: createRepository
/**
* Create a new repository instance for an entity class.
*
* @param \Doctrine\ORM\EntityManagerInterface $entityManager The EntityManager instance.
* @param string $entityName The name of the entity.
*
* @return ObjectRepository
*/
private function createRepository(EntityManagerInterface $entityManager, $entityName)
{
/* @var $metadata ClassMetadata */
$metadata = $entityManager->getClassMetadata($entityName);
$repositoryClassName = $metadata->customRepositoryClassName ?: $entityManager->getConfiguration()->getDefaultRepositoryClassName();
$result = new $repositoryClassName($entityManager, $metadata);
if ($result instanceof ContainerAwareInterface) {
$result->setContainer($this->container);
}
return $result;
}
示例15: getRepository
/**
* Gets the repository for an entity class.
*
* @param \Doctrine\ORM\EntityManagerInterface $entityManager The EntityManager instance.
* @param string $entityName The name of the entity.
*
* @return \Doctrine\Common\Persistence\ObjectRepository
*/
public function getRepository(EntityManagerInterface $entityManager, $entityName)
{
if ($this->entityRepositoryManager->has($entityName)) {
$repository = $this->entityRepositoryManager->get($entityName);
} else {
$entityMetadata = $entityManager->getClassMetadata($entityName);
$className = $entityManager->getConfiguration()->getDefaultRepositoryClassName();
/** @var EntityRepository $defaultRepository */
$repository = new $className($entityManager, $entityMetadata);
}
return $repository;
}