• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ORM\EntityManagerInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createActivityType

 private function createActivityType(EntityManagerInterface $em)
 {
     $activityType = new ResourceType();
     $activityType->setName('activity');
     $em->persist($activityType);
     $em->flush();
 }
开发者ID:stefk,项目名称:CompetencyBundle,代码行数:7,代码来源:AdditionalInstallerTest.php


示例2: __construct

 /**
  * @param EntityManager $em
  * @param Cache $cache
  * @param CacheHitsContainer $hitsContainer
  */
 public function __construct(EntityManagerInterface $em, Cache $cache, CacheHitsContainer $hitsContainer)
 {
     $this->em = $em;
     $this->connection = $em->getConnection();
     $this->cache = $cache;
     $this->hitsContainer = $hitsContainer;
 }
开发者ID:lsnova,项目名称:simple-query-executor,代码行数:12,代码来源:DbCacheableExecutor.php


示例3: uniqueNameExists

 /**
  * @param $fileName
  * @return bool
  */
 protected function uniqueNameExists($fileName, EntityManagerInterface $em)
 {
     $dql = "SELECT COUNT(image) FROM EDVFileBundle:EdImage AS image WHERE image.hashString = :name";
     $query = $em->createQuery($dql)->setParameters(array('name' => $fileName));
     $result = $query->getSingleScalarResult();
     return $result > 0;
 }
开发者ID:vlatosev,项目名称:filebundle,代码行数:11,代码来源:ImageManager.php


示例4: it_performs_a_fulltext_query

 public function it_performs_a_fulltext_query(EntityManagerInterface $entityManager, AbstractQuery $query, $result = [])
 {
     $entityManager->createQuery(Argument::any())->shouldBeCalled()->willReturn($query);
     $query->setParameter(Argument::any(), Argument::any())->shouldBeCalled()->willReturn($query);
     $query->getResult()->shouldBeCalled()->willReturn($result);
     $this->query('black', $entityManager)->shouldBeArray();
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:7,代码来源:OrmFinderSpec.php


示例5: getEntityManager

 /**
  * Returns the global entity manager.
  *
  * @return \Doctrine\ORM\EntityManagerInterface
  */
 public function getEntityManager()
 {
     if ($this->entityManager === null || !$this->entityManager->isOpen()) {
         $this->entityManager = $this->createEntityManager();
     }
     return $this->entityManager;
 }
开发者ID:ableron,项目名称:ableron-core,代码行数:12,代码来源:PersistenceManager.php


示例6:

 function it_handles_a_delete_command(Entity $entity, Delete $command, EntityManagerInterface $em)
 {
     $command->getEntity()->willReturn($entity);
     $em->remove($entity)->shouldBeCalled();
     $em->flush()->shouldBeCalled();
     $this->handle($command);
 }
开发者ID:indigophp,项目名称:crud-doctrine,代码行数:7,代码来源:RemoverSpec.php


示例7:

 function it_handles_a_find_all_query(FindAll $query, EntityRepository $repository, EntityManagerInterface $em)
 {
     $query->getEntityClass()->willReturn('Indigo\\Crud\\Stub\\Entity');
     $repository->findAll()->shouldBeCalled();
     $em->getRepository('Indigo\\Crud\\Stub\\Entity')->willReturn($repository);
     $this->handle($query);
 }
开发者ID:indigophp,项目名称:crud-doctrine,代码行数:7,代码来源:AllFinderSpec.php


示例8: 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);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:15,代码来源:DefaultRepositoryFactory.php


示例9: __construct

 /**
  * @param EntityManagerInterface $em
  */
 public function __construct(EntityManagerInterface $em)
 {
     $params = $em->getConnection()->getParams();
     $dsn = "mysql:host={$params['host']};dbname={$params['dbname']}";
     $this->pdo = new PDO($dsn, $params['user'], $params['password']);
     $this->pdo->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
 }
开发者ID:b4nan,项目名称:doctrine,代码行数:10,代码来源:DatabaseBackup.php


示例10: __construct

 /**
  * @param EntityManagerInterface $entityManager
  * @param UserManagerInterface $userManager
  * @param ValidatorInterface $validator
  */
 public function __construct(EntityManagerInterface $entityManager, UserManagerInterface $userManager, ValidatorInterface $validator)
 {
     $this->entityManager = $entityManager;
     $this->userRepository = $entityManager->getRepository('AppBundle:User');
     $this->userManager = $userManager;
     $this->validator = $validator;
 }
开发者ID:sfarkas1988,项目名称:timekeepingAPI,代码行数:12,代码来源:UserService.php


示例11: isUsedCode

 /**
  * @param string $token
  *
  * @return Boolean
  */
 protected function isUsedCode($token)
 {
     $this->manager->getFilters()->disable('softdeleteable');
     $isUsed = null !== $this->repository->findOneBy(array('confirmationToken' => $token));
     $this->manager->getFilters()->enable('softdeleteable');
     return $isUsed;
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:12,代码来源:TokenProvider.php


示例12: convert

 /**
  * {@inheritdoc}
  */
 public function convert($value)
 {
     if ($value) {
         return $this->em->getReference($this->entityClass, $value);
     }
     return null;
 }
开发者ID:Exanrus,项目名称:crm-bundle,代码行数:10,代码来源:AbstractEntityConverter.php


示例13: 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);
 }
开发者ID:silversolutions,项目名称:content-loader-bundle,代码行数:12,代码来源:DatabaseSchemaCreator.php


示例14: delete

 /**
  * @inheritdoc
  */
 public function delete(UserModel $user) : UserModel
 {
     $user->delete();
     $this->em->persist($user);
     $this->em->flush();
     return $user;
 }
开发者ID:mrprompt,项目名称:silex-api-skel,代码行数:10,代码来源:User.php


示例15: tryDelete

 /**
  * @param Category $category
  * @throws \Exception
  */
 public function tryDelete(Category $category)
 {
     $this->tryValidate($category);
     $this->em->transactional(function () use($category) {
         $this->em->remove($category);
     });
 }
开发者ID:pinekta,项目名称:mysymfonysample,代码行数:11,代码来源:CategoryManager.php


示例16: onRender

 public function onRender(RendererEvent $event)
 {
     $renderer = $event->getRenderer();
     $content = $renderer->getObject();
     $links = $content->getParamValue('link');
     $link = ['url' => '', 'title' => 'Visit', 'target' => '_self'];
     if (!empty($links)) {
         $links = reset($links);
         if (isset($links['pageUid']) && !empty($links['pageUid'])) {
             $page = $this->entityManager->getRepository('BackBee\\CoreDomain\\NestedNode\\Page')->find($links['pageUid']);
             if ($page !== null) {
                 $link['url'] = $page->getUrl();
             }
         }
         if (empty($link['url']) && isset($links['url'])) {
             $link['url'] = $links['url'];
         }
         if (isset($links['title'])) {
             $link['title'] = $links['title'];
         }
         if (isset($links['target'])) {
             $link['target'] = $links['target'];
         }
     }
     $renderer->assign('link', $link);
 }
开发者ID:ReissClothing,项目名称:BackBee,代码行数:26,代码来源:QuoteListener.php


示例17: renewRental

 /**
  * Renueva el alquiler.
  *
  * @param Rental $rental
  *
  * @return Rental
  */
 public function renewRental(Rental $rental)
 {
     if ($rental->getReturnAt()) {
         throw new FinishedRentalException();
     }
     if ($rental->getUser()->getIsPenalized()) {
         throw new PenalizedUserException();
     }
     if ($rental->getUser()->getFaculty()->getIsEnabled() === false) {
         throw new PenalizedFacultyException();
     }
     if (!$rental->getIsRenewable()) {
         throw new NotRenewableRentalException();
     }
     if ($rental->getIsExpired()) {
         throw new ExpiredRentalException();
     }
     if ($rental->getDaysLeft() > $this->days_before_renovation) {
         throw new TooEarlyRenovationException();
     }
     $left = $rental->getDaysLeft() + $this->days_length_rental;
     $rental->setEndAt(new \DateTime($left . ' days midnight'));
     $this->manager->persist($rental);
     $this->manager->flush();
     $event = new RentalEvent($rental);
     $this->dispatcher->dispatch(RentalEvents::LOCKER_RENEWED, $event);
     return $rental;
 }
开发者ID:aulasoftwarelibre,项目名称:seta,代码行数:35,代码来源:RenewService.php


示例18: activate

 /**
  * Activates new user by activation code
  *
  * @param string $code
  *
  * @throws IOException
  */
 public function activate($code)
 {
     $user = $this->userRepository->findOneBy(['code' => $code, 'frozen' => true]);
     $user->activate();
     $this->entityManager->persist($user);
     $this->entityManager->flush();
 }
开发者ID:janlavicka,项目名称:devstack,代码行数:14,代码来源:RegistrationService.php


示例19: getFreeWorkTimes

 public function getFreeWorkTimes(User $user, \DateTime $date = null)
 {
     $allTimes = [];
     //if($date)
     //{
     $startTime = new \DateTime($date->format('Y-m-d H:i'));
     $endTime = new \DateTime($date->format('Y-m-d H:i'));
     $startTime->setTime($user->getStartTime()->format('H'), $user->getStartTime()->format('i'));
     $endTime->setTime($user->getEndTime()->format('H'), $user->getEndTime()->format('i'));
     //}else
     //{
     //    $startTime = new \DateTime($user->getStartTime()->format('H:i'));
     //    $endTime = new \DateTime($user->getEndTime()->format('H:i'));
     //}
     $busyTimes = $this->em->getRepository('WorkerBundle:WorkTime')->getUserBusyTimes($user->getId());
     while ($startTime < $endTime) {
         if ($startTime > new \DateTime()) {
             //    if ($date) {
             $allTimes[] = $startTime->format('Y-m-d H:i');
             //    } else {
             //          $allTimes[] = date('Y-m-d') . ' ' . $startTime->format('H:i');
             //   }
         }
         $startTime->modify('+1hour');
     }
     return $this->removeBlockedTimes($allTimes, $busyTimes);
 }
开发者ID:deileo,项目名称:Autoservisas_Kursinis,代码行数:27,代码来源:WorkTimeService.php


示例20: createMessage

 public function createMessage($text, $username, $email = null)
 {
     $message = new GuestBookMessage();
     $message->setText($text)->setUsername($username)->setEmail($email);
     $this->manager->persist($message);
     $this->manager->flush();
 }
开发者ID:mkhrystunov,项目名称:guest_book,代码行数:7,代码来源:MessageCreator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ORM\EntityRepository类代码示例发布时间:2022-05-23
下一篇:
PHP ORM\EntityManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap