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


PHP EntityManager类代码示例

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


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

示例1: testExceptionOnNonMappedEntity

 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage Unable to find the mapping information for the class classname. Please check the 'auto_mapping' option (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview) or add the bundle to the 'mappings' section in the doctrine configuration
  */
 public function testExceptionOnNonMappedEntity()
 {
     $registry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $registry->expects($this->once())->method('getManagerForClass')->will($this->returnValue(null));
     $manager = new EntityManager('classname', $registry);
     $manager->getObjectManager();
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:11,代码来源:BaseEntityManagerTest.php

示例2: setFromStdClass

 /**
  * @param stdClass      $stdClass
  * @param EntityManager $manager
  *
  * @return $this
  */
 public function setFromStdClass($stdClass, $manager)
 {
     $this->id = $stdClass->id;
     $this->name = $stdClass->title;
     $this->city = $manager->find('NetworkStoreBundle:City', $stdClass->city_id);
     return $this;
 }
开发者ID:rotanov,项目名称:fefu-social-network,代码行数:13,代码来源:School.php

示例3: clearWebcode

 /**
  * Clears old webcode
  *
  * @param EntityManager $em            Entity Manager
  * @param string        $articleNumber Article
  *
  * @return void
  */
 private function clearWebcode($em, $articleNumber, $articleLanguage)
 {
     $webcode = $em->getRepository('Newscoop\\Entity\\Webcode')->createQueryBuilder('w')->leftJoin('w.article', 'a')->where('a.number = :number')->andWhere('a.language = :language')->setParameter('number', $articleNumber)->setParameter('language', $articleLanguage)->getQuery()->getOneOrNullResult();
     if ($webcode) {
         $em->remove($webcode);
         $em->flush();
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:16,代码来源:GenerateWebcodeCommand.php

示例4: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->em = $this->getEntityManager();
     $this->purgeDatabase();
     $this->setUpTestData();
     $this->em->flush();
     $this->client = $this->createAuthenticatedClient();
 }
开发者ID:sulu,项目名称:SuluPricingBundle,代码行数:11,代码来源:PricingControllerTest.php

示例5: assertDatabaseEntries

 /**
  * Counts the number of entries in each tables.
  *
  * @param EntityManager $em
  * @param int $expected
  */
 protected function assertDatabaseEntries($em, $expected)
 {
     $number = $em->getRepository(self::ENTITY_TRANS_UNIT_CLASS)->createQueryBuilder('tu')->select('COUNT(tu.id)')->getQuery()->getSingleScalarResult();
     $this->assertEquals($expected, $number);
     $number = $em->getRepository(self::ENTITY_TRANSLATION_CLASS)->createQueryBuilder('t')->select('COUNT(t.id)')->getQuery()->getSingleScalarResult();
     $this->assertEquals($expected * 2, $number);
     $number = $em->getRepository(self::ENTITY_FILE_CLASS)->createQueryBuilder('f')->select('COUNT(f.id)')->getQuery()->getSingleScalarResult();
     $this->assertEquals($expected, $number);
 }
开发者ID:cwd,项目名称:LexikTranslationBundle,代码行数:15,代码来源:FileImporterTest.php

示例6: getOrCreateUser

 /**
  * {@inheritDoc}
  */
 public function getOrCreateUser($email, $googleId)
 {
     if ($this->isConfiguredDomain($email)) {
         $user = $this->userFinder->findUserByGoogleSignInData($email, $googleId);
         if (!$user instanceof $this->userClass) {
             //User not present in database, create new one
             $user = new $this->userClass();
             $user->setUsername($email);
             $user->setEmail($email);
             $user->setPlainPassword($googleId . $email . time());
             $user->setEnabled(true);
             $user->setLocked(false);
             $user->setAdminLocale('en');
             $user->setPasswordChanged(true);
         }
         foreach ($this->getAccessLevels($email) as $accessLevel) {
             $user->addRole($accessLevel);
         }
         $user->setGoogleId($googleId);
         // Persist
         $this->em->persist($user);
         $this->em->flush();
     }
     return isset($user) ? $user : null;
 }
开发者ID:bakie,项目名称:KunstmaanBundlesCMS,代码行数:28,代码来源:OAuthUserCreator.php

示例7: testconfiguration

 public function testconfiguration()
 {
     $config = new Configuration();
     $config->setCurrentUser($this->ZfcUserMock);
     $prefix = "prefix";
     $config->setTablePrefix($prefix);
     $suffix = "suffix";
     $config->setTableSuffix($suffix);
     $fieldName = "fieldName";
     $config->setRevisionFieldName($fieldName);
     $revisionIdFieldType = "string";
     $config->setRevisionIdFieldType($revisionIdFieldType);
     $tableName = "tableName";
     $config->setRevisionTableName($tableName);
     $revisionTypeFieldName = "string";
     $config->setRevisionTypeFieldName($revisionTypeFieldName);
     $ipaddress = $config->getIpAddress();
     $config->setAuditedEntityClasses(array('ZF2EntityAuditTest\\Entity\\Article', 'ZF2EntityAuditTest\\Entity\\Writer'));
     $config->setNote("default note");
     $this->auditManager = new Manager($config);
     $this->auditManager->registerEvents($this->em->getEventManager());
     /// creating the tables
     $this->schemaTool = $this->getSchemaTool();
     $this->schemaTool->createSchema(array($this->em->getClassMetadata('ZF2EntityAuditTest\\Entity\\Article'), $this->em->getClassMetadata('ZF2EntityAuditTest\\Entity\\Writer')));
     $this->assertInstanceOf("ZfcUser\\Entity\\User", $this->ZfcUserMock);
     $this->assertEquals($prefix, $config->getTablePrefix());
     $this->assertEquals($suffix, $config->getTableSuffix());
     $this->assertEquals($fieldName, $config->getRevisionFieldName());
     $this->assertEquals($tableName, $config->getRevisionTableName());
     $this->assertEquals($revisionIdFieldType, $config->getRevisionIdFieldType());
     $this->assertEquals($revisionTypeFieldName, $config->getRevisionIdFieldType());
     $this->assertEquals($ipaddress, "1.1.1.9");
 }
开发者ID:tawfekov,项目名称:zf2entityaudit,代码行数:33,代码来源:ConfigurationTest.php

示例8: savePdf

 public function savePdf()
 {
     $pnr = $this->em->getRepository('AppCoreBundle:Pnr')->find($this->id);
     if (!$pnr) {
         return \Exception('PNR not found');
     }
     //Trick to prevent cache size exceeded
     //set_time_limit(0);
     while (ob_get_level()) {
         ob_end_clean();
     }
     ob_implicit_flush(true);
     /*
      * Construct PDF with Mpdf service
      * Layout based on HTML twig template
      */
     $service = $this->tfox;
     $pdf = $service->getMpdf(array('', 'A4', 8, 'Helvetica', 10, 10, 15, 15, 9, 9, 'L'));
     $pdf->AliasNbPages('{NBPAGES}');
     $pdf->setTitle('billet-' . date('d-m-Y-H-i', time()) . '.pdf');
     $pdf->SetHeader('Billet');
     $pdf->SetFooter('{DATE j/m/Y}|{PAGENO}/{NBPAGES}');
     $html = $this->templating->renderResponse('AppCoreBundle:Pnr:billetpdf.pdf.twig', array('pnr' => $pnr));
     $pdf->WriteHTML($html);
     //$url = 'billet-'.$pnr->getNumero().'.pdf';
     //$pdf->Output($url, 'F');
     $pdf->Output();
     /*$this->get('session')->getFlashBag()->add(
     		 'success',
     				'Le billet a bien été enregistré !'
     		);*/
     //return $this->redirect($this->generateUrl('pnr_emit', array('id' => $id)));
     //return $url;
 }
开发者ID:Bobarisoa,项目名称:noucoz-release,代码行数:34,代码来源:Billet.php

示例9: locateEntities

 /**
  * Gather all entities in a given directory
  *
  * Assumes PSR-0/4 compliant entity class names, and an appropriate auto-loader is installed.
  *
  * @param string $dir       Directory to scan
  * @param string $namespace PSR base namespace for the directory
  * @param string $regex     Filter for file matching
  * @return string[]
  */
 public function locateEntities($dir, $namespace, $regex = '/^.+\\.php$/i')
 {
     $dir = str_replace('\\', '/', $dir);
     if (substr($dir, -1) != '/') {
         $dir .= '/';
     }
     $base_len = strlen($dir);
     $namespace = str_replace('/', '\\', $namespace);
     if (substr($namespace, -1) != '\\') {
         $namespace .= '\\';
     }
     $normaliser = $this->getNormaliser();
     $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)), $regex, \RecursiveRegexIterator::GET_MATCH);
     $out = [];
     foreach ($iterator as $fn => $data) {
         $suffix = str_replace('/', '\\', substr($fn, $base_len));
         $class = $normaliser($namespace . $suffix);
         if (!class_exists($class)) {
             continue;
         }
         if ($this->entity_manager) {
             try {
                 $this->entity_manager->getMapper()->getEntityMetadata($class);
             } catch (\Exception $e) {
                 continue;
             }
         }
         $out[] = $class;
     }
     return $out;
 }
开发者ID:bravo3,项目名称:orm,代码行数:41,代码来源:EntityLocator.php

示例10: testInvalidToOneJoinColumnSchema

 /**
  * @group DDC-1439
  */
 public function testInvalidToOneJoinColumnSchema()
 {
     $class1 = $this->em->getClassMetadata(__NAMESPACE__ . '\\InvalidEntity1');
     $class2 = $this->em->getClassMetadata(__NAMESPACE__ . '\\InvalidEntity2');
     $ce = $this->validator->validateClass($class2);
     $this->assertEquals(array("The referenced column name 'id' does not have a corresponding field with this column name on the class 'Doctrine\\Tests\\ORM\\Tools\\InvalidEntity1'.", "The join columns of the association 'assoc' have to match to ALL identifier columns of the source entity 'Doctrine\\Tests\\ORM\\Tools\\InvalidEntity2', however 'key3, key4' are missing."), $ce);
 }
开发者ID:ncking,项目名称:doctrine2,代码行数:10,代码来源:SchemaValidatorTest.php

示例11: testReverseTransform

 public function testReverseTransform()
 {
     $transformer = $this->createTransformer();
     $tag = new Tag("name");
     $this->em->persist($tag);
     $this->em->flush();
     $this->assertSame($tag, $transformer->reverseTransform(1, null));
 }
开发者ID:notbrain,项目名称:symfony,代码行数:8,代码来源:EntityToIDTransformerTest.php

示例12: tearDown

 /**
  * Rollback changes.
  */
 public function tearDown()
 {
     $this->_em->rollback();
     @exec('php app/console syw:user:delete ' . $this->test1_username . ' >/dev/null 2>&1');
     @exec('php app/console syw:user:delete ' . $this->test2_username . ' >/dev/null 2>&1');
     parent::tearDown();
     $this->_em->close();
 }
开发者ID:Jheengut,项目名称:linuxcounter.new,代码行数:11,代码来源:BaseControllerTest.php

示例13: createSchema

 public function createSchema()
 {
     $metas = [];
     foreach (Deployment::instance()->models as $model) {
         $metas[] = $this->entityManager->getClassMetadata($model);
     }
     $this->schemaTool->createSchema($metas);
 }
开发者ID:BGCX261,项目名称:zool-php-framework-svn-to-git,代码行数:8,代码来源:DatabaseController.php

示例14: findOneById

 public function findOneById($area_id)
 {
     try {
         $area = $this->em->find(Area_tematica_dao::REPOSITORY, $area_id);
         return $area;
     } catch (Exception $ex) {
         $this->CI->log->write_log('error', $ex->getMessage() . ' - area_tematica_dao::findOneById ');
     }
 }
开发者ID:jeanlopes,项目名称:mostra-ifrs-poa,代码行数:9,代码来源:area_tematica_dao.php

示例15: getLastPosition

 public function getLastPosition($entity)
 {
     $query = $this->em->createQuery(sprintf('SELECT MAX(m.%s) FROM %s m', $positionFiles = $this->getPositionFieldByEntity($entity), $entity));
     $result = $query->getResult();
     if (array_key_exists(0, $result)) {
         return intval($result[0][1]);
     }
     return 0;
 }
开发者ID:orthes,项目名称:pixSortableBehaviorBundle,代码行数:9,代码来源:PositionORMHandler.php


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