本文整理汇总了PHP中Doctrine\ORM\EntityManagerInterface类的典型用法代码示例。如果您正苦于以下问题:PHP EntityManagerInterface类的具体用法?PHP EntityManagerInterface怎么用?PHP EntityManagerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntityManagerInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createActivityType
private function createActivityType(EntityManagerInterface $em)
{
$activityType = new ResourceType();
$activityType->setName('activity');
$em->persist($activityType);
$em->flush();
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
示例7: 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;
}
示例8: convert
/**
* {@inheritdoc}
*/
public function convert($value)
{
if ($value) {
return $this->em->getReference($this->entityClass, $value);
}
return null;
}
示例9: 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);
}
示例10: delete
/**
* @inheritdoc
*/
public function delete(UserModel $user) : UserModel
{
$user->delete();
$this->em->persist($user);
$this->em->flush();
return $user;
}
示例11: tryDelete
/**
* @param Category $category
* @throws \Exception
*/
public function tryDelete(Category $category)
{
$this->tryValidate($category);
$this->em->transactional(function () use($category) {
$this->em->remove($category);
});
}
示例12: 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);
}
示例13: 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;
}
示例14: 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();
}
示例15: 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);
}