当前位置: 首页>>代码示例>>PHP>>正文


PHP static::em方法代码示例

本文整理汇总了PHP中static::em方法的典型用法代码示例。如果您正苦于以下问题:PHP static::em方法的具体用法?PHP static::em怎么用?PHP static::em使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在static的用法示例。


在下文中一共展示了static::em方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getEntityManager

 /**
  * @return EntityManager
  */
 public static function getEntityManager()
 {
     if (static::$em === null) {
         static::$em = static::createEntityManager();
     }
     return static::$em;
 }
开发者ID:activelamp,项目名称:taxonomy,代码行数:10,代码来源:TestCase.php

示例2: getMetadata

 public static function getMetadata()
 {
     /** @var EntityManagerInterface $em */
     static::$em = static::$kernel->getContainer()->get('doctrine')->getManager();
     $metadata = static::$em->getMetadataFactory()->getAllMetadata();
     return $metadata;
 }
开发者ID:scaytrase,项目名称:symfony-test-utils,代码行数:7,代码来源:FixtureTestCase.php

示例3: setUpEntityManager

 protected static function setUpEntityManager()
 {
     $config = new Configuration();
     $config->setSQLLogger(null);
     $config->setAutoGenerateProxyClasses(true);
     $config->setProxyDir(\sys_get_temp_dir());
     $config->setProxyNamespace('Proxies');
     $config->setMetadataDriverImpl(static::getMetadataDriverImpl());
     $config->setQueryCacheImpl(new ArrayCache());
     $config->setMetadataCacheImpl(new ArrayCache());
     $dbPath = __DIR__ . '/../db.sqlite';
     if (file_exists($dbPath)) {
         unlink($dbPath);
     }
     $connection = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
     // Event listeners
     $interfaces = DoctrineBundleMapping::getDefaultImplementations();
     $evm = new EventManager();
     // Resolve entity target subscriber
     $rtel = new ResolveTargetEntityListener();
     foreach ($interfaces as $model => $implementation) {
         $rtel->addResolveTargetEntity($model, $implementation, []);
     }
     $evm->addEventSubscriber($rtel);
     // Load metadata subscriber
     $lm = new LoadMetadataSubscriber([], $interfaces);
     $evm->addEventSubscriber($lm);
     static::$em = EntityManager::create($connection, $config, $evm);
 }
开发者ID:ekyna,项目名称:commerce,代码行数:29,代码来源:OrmTestCase.php

示例4: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     static::$client = static::createClient();
     static::$router = self::$client->getContainer()->get('router');
     static::$em = self::$client->getContainer()->get('doctrine.orm.entity_manager');
     static::$container = self::getContainer();
 }
开发者ID:bzis,项目名称:zomba,代码行数:7,代码来源:TestCase.php

示例5: init

 /**
  * Initialize the entity manager
  *
  * @return \Doctrine\ORM\EntityManager
  */
 public function init()
 {
     $config = DoctrineSetup::createAnnotationMetadataConfiguration($this->entityPaths, $this->isDevMode, $this->proxyDir, $this->cache, false);
     $em = EntityManager::create($this->getDbParams(), $config);
     $platform = $em->getConnection()->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('enum', 'string');
     static::$em = $em;
     return $em;
 }
开发者ID:asimlqt,项目名称:byng-pimcore-doctrine,代码行数:14,代码来源:Setup.php

示例6: getEm

 /**
  * @return EntityManager
  */
 public static function getEm()
 {
     if (!static::$em instanceof EntityManager) {
         $helper = (include "src/cli_config.php");
         static::$em = $helper->get("em")->getEntityManager();
         static::$db = $helper->get("db");
     }
     return static::$em;
 }
开发者ID:epoplive,项目名称:pillow,代码行数:12,代码来源:Entity.php

示例7: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     if (null === static::$kernel) {
         static::$kernel = static::createKernel();
     }
     static::$kernel->boot();
     static::$kernel->getContainer()->get('request')->setLocale('en_EN');
     static::$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
     static::$translator = static::$kernel->getContainer()->get('translator');
     $schemaTool = new SchemaTool(static::$em);
     static::$metadata = static::$em->getMetadataFactory()->getAllMetadata();
 }
开发者ID:pigroupe,项目名称:SfynxAuthBundle,代码行数:13,代码来源:WebTestCase.php

示例8: setUpBeforeClass

 /**  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     parent::deleteTmpDir('Ticket');
     static::bootKernel(['test_case' => 'Ticket']);
     static::$em = static::$kernel->getContainer()->get('doctrine')->getManager();
     static::prepareSchema();
     static::fixMediaContext();
     static::addFixture(new LoadTicketUsers());
     static::addFixture(new LoadTicketCategories());
     static::addFixture(new LoadTicket());
     static::executeFixtures();
 }
开发者ID:dreamlex,项目名称:ticketbundle,代码行数:14,代码来源:TicketControllerTest.php

示例9: setUpBeforeClass

 /**
  * {@inheritdoc}
  */
 public static final function setUpBeforeClass()
 {
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     static::$container = static::$kernel->getContainer();
     if (self::emExists()) {
         static::$em = static::$container->get('doctrine.orm.entity_manager');
     }
     if (static::getIsolationLevel() == self::IM_CLASS && self::emExists()) {
         static::$em->getConnection()->beginTransaction();
     }
     static::doSetUpBeforeClass();
 }
开发者ID:modera,项目名称:foundation,代码行数:16,代码来源:FunctionalTestCase.php

示例10: setUpBeforeClass

 /**
  * Prepara el entorno antes de la primer prueba.
  */
 public static function setUpBeforeClass()
 {
     // Inicializamos el framework web.
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     $container = static::$kernel->getContainer();
     // Obtenemos algunos servicios de uso común.
     static::$em = $container->get('doctrine')->getManager();
     static::$rootUrl = $container->getParameter('api.base_url');
     if ($fixtures = static::getFixtures()) {
         $loader = new ContainerAwareLoader($container);
         array_walk($fixtures, array($loader, 'addFixture'));
         $purger = new ORMPurger(static::$em);
         $executor = new ORMExecutor(static::$em, $purger);
         $executor->execute($loader->getFixtures());
     }
 }
开发者ID:mb3rnard,项目名称:hateoas-bundle,代码行数:20,代码来源:ApiTestCase.php

示例11: setUpBeforeClass

 /**
  * Class initialization
  *
  */
 public static function setUpBeforeClass()
 {
     $dbParams = array('driver' => 'pdo_sqlite', 'memory' => true);
     $config = Setup::createAnnotationMetadataConfiguration(array(static::getEntityPath()), false);
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     $driverImpl = $config->newDefaultAnnotationDriver(static::getEntityPath(), false);
     $config->setMetadataCacheImpl($cache);
     $config->setMetadataDriverImpl($driverImpl);
     $config->setQueryCacheImpl($cache);
     $proxiesIdentifier = uniqid('Proxies', true);
     $config->setProxyDir(sys_get_temp_dir() . '/' . $proxiesIdentifier);
     $config->setProxyNamespace('MyProject\\Proxies\\' . $proxiesIdentifier);
     $config->setAutoGenerateProxyClasses(true);
     $em = EntityManager::create($dbParams, $config);
     $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
     $classes = array_map(function ($className) use($em) {
         return $em->getClassMetadata($className);
     }, static::getEntityClasses());
     $tool->createSchema($classes);
     static::$em = $em;
 }
开发者ID:leapt,项目名称:core-bundle,代码行数:25,代码来源:DoctrineORMPaginatorTest.php

示例12: setUp

 public function setUp()
 {
     static::$em = static::$kernel->getContainer()->get("doctrine")->getManager();
     static::$em->getConnection()->beginTransaction();
 }
开发者ID:bonesmccoy,项目名称:symfex,代码行数:5,代码来源:UserTest.php

示例13: tearDownAfterClass

 /**
  * {@inheritDoc}
  * 
  * @see PHPUnit_Framework_TestCase::tearDownAfterClass()
  * 
  * @uses KernelTestCase::ensureKernelShutdown()
  */
 public static function tearDownAfterClass()
 {
     parent::ensureKernelShutdown();
     static::$em->close();
     static::$em = null;
     // avoid memory leaks
     static::$repository->clear();
     static::$repository = null;
 }
开发者ID:vaxz,项目名称:bc-genome,代码行数:16,代码来源:ChromosomeRepositoryTest.php

示例14: getEntityManager

 /**
  * Retrieve entity manager
  *
  * @return EntityManager
  */
 public static function getEntityManager()
 {
     global $dbh;
     $class = __CLASS__;
     $table = empty(static::$table) ? strtolower(__CLASS__) : static::$table;
     if (empty(static::$fields)) {
         $reflectionData = new \ReflectionClass(__CLASS__);
         $staticProperties = array_keys($reflectionData->getStaticProperties());
         $properties = $reflectionData->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED | \ReflectionProperty::IS_PRIVATE);
         array_walk($properties, function (&$value, $key) {
             $value = $value->getName();
         });
         $fields = array_diff($properties, $staticProperties, array('id'));
     } else {
         $fields = explode(',', static::$fields);
     }
     if (!static::$em instanceof EntityManager) {
         static::$em = new EntityManager($dbh, $class, $table, $fields);
     }
     return static::$em;
 }
开发者ID:cyve,项目名称:orm,代码行数:26,代码来源:Entity.php

示例15: startEntityManager

 /**
  * Start Doctrine entity manager
  *
  * @return void
  */
 public function startEntityManager()
 {
     // Initialize DB connection and entity manager
     static::$em = \Doctrine\ORM\EntityManager::create($this->getDSN(), $this->configuration);
     if (\XLite\Core\Profiler::getInstance()->enabled) {
         static::$em->getConnection()->getConfiguration()->setSQLLogger(\XLite\Core\Profiler::getInstance());
     }
     static::registerCustomTypes(static::$em);
     // Set charset for DB connection
     $this->setCharset();
     // Bind events
     $events = array(\Doctrine\ORM\Events::loadClassMetadata);
     if (static::$cacheDriver) {
         // Bind cache chekers
         $events[] = \Doctrine\ORM\Events::postPersist;
         $events[] = \Doctrine\ORM\Events::postUpdate;
         $events[] = \Doctrine\ORM\Events::postRemove;
     }
     static::$em->getEventManager()->addEventListener($events, $this);
 }
开发者ID:kingsj,项目名称:core,代码行数:25,代码来源:Database.php


注:本文中的static::em方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。