本文整理汇总了PHP中Doctrine\Common\Collections\Criteria::expr方法的典型用法代码示例。如果您正苦于以下问题:PHP Criteria::expr方法的具体用法?PHP Criteria::expr怎么用?PHP Criteria::expr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\Criteria
的用法示例。
在下文中一共展示了Criteria::expr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMenu
public function getMenu()
{
$criteria = new Criteria();
$criteria->orderBy(['hierarchy' => 'asc']);
$criteria->andWhere($criteria->expr()->eq('parent', null));
return $this->adminMenuRepository->matching($criteria);
}
示例2: visualizaAction
/**
* view the property selected, if tenant ask for more informations, as him to register
* @return ViewModel
*/
public function visualizaAction()
{
//save new tenant or get the tenant prior registered
if ($this->getRequest()->isPost()) {
//getting posible tenant prior registered
$criterio = new Criteria();
$criterio->where($criterio->expr()->eq('nome', $this->getRequest()->getPost('nome')))->andWhere($criterio->expr()->eq('email', $this->getRequest()->getPost('email')))->andWhere($criterio->expr()->eq('foneCelular', $this->getRequest()->getPost('telefone')));
$locatario = $this->getEm()->getRepository('MyClasses\\Entities\\Locatario')->matching($criterio);
//if quantity of tenants by criteria above is zero...
if (!$locatario->count()) {
//...register new tenant...
$locatario = new Locatario();
$locatario->setNome($this->getRequest()->getPost('nome'));
$locatario->setEmail($this->getRequest()->getPost('email'));
$locatario->setFoneCelular($this->getRequest()->getPost('telefone'));
$this->getEm()->persist($locatario);
$this->getEm()->flush();
//...else, get the tenant prior registered
} else {
$locatario = $locatario->first();
}
$this->sessao->locatario = $locatario;
}
//get the property and send to view
if ($this->Params('id')) {
$imovel = $this->getEm()->getRepository("MyClasses\\Entities\\Imovel")->find($this->Params('id'));
return new ViewModel(array('imovel' => $imovel, 'mais' => $this->Params('mais'), 'locatario' => $this->sessao->locatario));
}
}
示例3: getCriteria
/**
* Returns the report's criteria
*
* @param ReportConfiguration $configuration
*
* @return Criteria
*/
protected function getCriteria(ReportConfiguration $configuration)
{
$criteria = new Criteria();
$criteria->where($criteria->expr()->gte('createdAt', $configuration->getStartDate()));
$criteria->andWhere($criteria->expr()->lte('createdAt', $configuration->getEndDate()));
return $criteria;
}
示例4: getProductReviews
public function getProductReviews(ProductInterface $product) : Collection
{
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('product', $product));
$criteria->andWhere($criteria->expr()->eq('enabled', true));
return $this->matching($criteria);
}
示例5: findPreviousOrdersToday
private function findPreviousOrdersToday() : Collection
{
$today = Carbon::now()->startOfDay();
$criteria = new Criteria();
$criteria->where($criteria->expr()->gte('updatedAt', $today));
$criteria->andWhere($criteria->expr()->eq('confirmed', true));
return $this->orderRepository->matching($criteria);
}
示例6: resolve
public function resolve(int $currentShopId, string $url) : ShopInterface
{
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('id', $currentShopId));
$criteria->orWhere($criteria->expr()->eq('url', $url));
$criteria->orWhere($criteria->expr()->gte('id', 1));
return $this->matching($criteria)->first();
}
示例7: indexAction
/**
* list the projects
* @return \Zend\View\Model\ViewModel
*/
public function indexAction()
{
$usuario = $this->getEm()->getRepository('MyClasses\\Entities\\AclUsuario')->findOneBy(array("id" => $this->identity()[0]->getId()));
if ($this->identity()[1] == "adm") {
$criterio = new Criteria();
$criterio->where($criterio->expr()->eq('usuario', $usuario))->orWhere($criterio->expr()->isNull('usuario'));
$projetos = $this->getEm()->getRepository('MyClasses\\Entities\\Projeto')->matching($criterio);
} else {
$projetos = $usuario->getProjetos();
}
return new ViewModel(array('projetos' => $projetos));
}
示例8: query
/**
* @param DataStructure\Query\Query $queries
*
* @return mixed
*/
public function query(DataStructure\Query\Query $queries)
{
$logicFunc = 'andWhere';
if ($queries instanceof DataStructure\OrQuery) {
$logicFunc = 'orWhere';
}
foreach ($queries as $query) {
if ($this->isExcludedProperty($query->getProperty())) {
continue;
}
$value = $this->unlockSpecialProperty($query->getProperty(), $query->getValue());
if ($query instanceof Expression\Equal) {
$this->criteria->{$logicFunc}(Criteria::expr()->eq($query->getProperty(), $value));
} elseif ($query instanceof Expression\NotEqual) {
$this->criteria->{$logicFunc}(Criteria::expr()->neq($query->getProperty(), $value));
} elseif ($query instanceof Expression\GreaterThan) {
$this->criteria->{$logicFunc}(Criteria::expr()->gt($query->getProperty(), $value));
} elseif ($query instanceof Expression\GreaterThanEqual) {
$this->criteria->{$logicFunc}(Criteria::expr()->gte($query->getProperty(), $value));
} elseif ($query instanceof Expression\LesserThan) {
$this->criteria->{$logicFunc}(Criteria::expr()->lt($query->getProperty(), $value));
} elseif ($query instanceof Expression\LesserThanEqual) {
$this->criteria->{$logicFunc}(Criteria::expr()->lte($query->getProperty(), $value));
} elseif ($query instanceof Expression\In) {
$this->criteria->{$logicFunc}(Criteria::expr()->in($query->getProperty(), $value));
} elseif ($query instanceof Expression\NotIn) {
$this->criteria->{$logicFunc}(Criteria::expr()->notIn($query->getProperty(), $query->getValue()));
}
}
}
示例9: getGoalsAction
/**
* @Rest\View
* @Rest\Get("/goals")
*/
public function getGoalsAction(Request $request)
{
$user_id = $request->get('user_id');
if ($user_id == 0) {
$user = $this->container->get('security.context')->getToken()->getUser();
} else {
$user = $this->getDoctrine()->getRepository('AcmeUserBundle:User')->find($user_id);
}
if (!$user) {
throw $this->createNotFoundException('user.not_found');
}
/** @var $user User */
$goals = $user->getGoals()->matching(Criteria::create()->where(Criteria::expr()->eq('isDeleted', 0)));
if ($user_id != 0 && $user != $this->container->get('security.context')->getToken()->getUser()) {
$goals = $goals->matching(Criteria::create()->where(Criteria::expr()->eq('isPrivate', 0)));
}
$response = [];
foreach ($goals as $goal) {
$oneGoal = ['title' => $goal->getName(), 'id' => $goal->getId()];
$oneGoal['actions'] = [];
$oneGoal['images'] = [];
foreach ($goal->getImages() as $image) {
$oneGoal['images'][] = ['webPath' => $image->getWebPath()];
}
foreach ($goal->getActions() as $action) {
$oneGoal['actions'][] = ['title' => $action->getTitle()];
}
$response[] = $oneGoal;
}
return $response;
}
示例10: findAvailableForUser
/**
* @param User $user
* @param int $limit
* @return Collection|Game[]
*/
public function findAvailableForUser(User $user, $limit)
{
$criteria = new Criteria();
$expr = Criteria::expr();
$criteria->where($expr->neq('user1', $user))->andWhere($expr->isNull('user2'))->setMaxResults($limit)->orderBy(['id' => 'DESC']);
return $this->matching($criteria);
}
示例11: subactionComplete
public function subactionComplete(SubactionProgressEvent $event, $name, EventDispatcher $dispatcher)
{
$action = $event->getSubaction()->getAction();
$user = $event->getUser();
$userAction = $this->em->getRepository('AcmeEdelaBundle:UserAction')->findOneBy(array('user' => $user, 'action' => $action));
$userTime = $user->getCurrentDateTime();
$dayStart = clone $userTime;
$dayFinish = clone $userTime;
$dayStart->modify('today midnight');
$dayFinish->modify('tomorrow midnight');
$existingProgress = $this->em->getRepository('AcmeEdelaBundle:UserActionProgress')->matching(Criteria::create()->where(Criteria::expr()->eq('userAction', $userAction))->andWhere(Criteria::expr()->gte('createdAt', $dayStart))->andWhere(Criteria::expr()->lte('createdAt', $dayFinish)));
$dispatch = null;
if (!$existingProgress->count() && $action->getSubactions()->count() == count($this->em->getRepository('AcmeEdelaBundle:Action')->getSubactions($action->getId(), $user, null, true))) {
$progress = new UserActionProgress();
$progress->setUserAction($userAction);
$progress->setResult(1);
$this->em->persist($progress);
$dispatch = true;
} elseif ($existingProgress->count()) {
$this->em->remove($existingProgress->first());
$dispatch = false;
}
$this->em->flush();
if ($dispatch !== null) {
$event = new ActionEvent($action, $user, $dispatch);
$dispatcher->dispatch($this->completeEvent, $event);
}
}
示例12: getPaymentsHistoryAction
/**
* @Rest\View
* @Rest\Get("/payment/history")
*/
public function getPaymentsHistoryAction(Request $request)
{
/** @var User $currentUser */
$currentUser = $this->container->get('security.context')->getToken()->getUser();
$transactions = $currentUser->getTransactions()->matching(Criteria::create()->where(Criteria::expr()->eq('isProcessed', 1)));
return $transactions;
}
示例13: confirmAction
/**
* Confirm email
*
* @return \Zend\Http\Response
*/
public function confirmAction()
{
$confirm = $this->params('confirm');
try {
if (!$confirm) {
//$this->getResponse()->setStatusCode(404);
throw new \Exception('Invalid confirmation code');
}
/**
* @var \Doctrine\ORM\EntityManager $objectManager
*/
$objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
/** @var \User\Entity\User $user */
$user = $objectManager->getRepository('User\\Entity\\User')->findOneBy(array('confirm' => $confirm));
if (!$user) {
throw new \Exception('Invalid confirmation code');
}
$user->activate();
$objectManager->persist($user);
$objectManager->flush();
$criteria = Criteria::create()->where(Criteria::expr()->eq('provider', 'equals'));
$user->getAuths()->matching($criteria)->first()->login($this->getServiceLocator());
$this->flashMessenger()->addSuccessMessage("You've successfully activated your account");
} catch (\Exception $exception) {
$this->flashMessenger()->addErrorMessage($exception->getMessage());
}
return $this->redirect()->toRoute('home');
}
示例14: loadWhere
/**
* @param array $criteria
* @param null $order
* @param null $limit
* @param null $offset
*
* @return static[]
*/
public static function loadWhere(array $criteria, $order = null, $limit = null, $offset = null)
{
$crit = Criteria::create();
if ($order) {
$crit->orderBy($order);
}
$crit->setMaxResults($limit);
$crit->setFirstResult($offset);
foreach ($criteria as $k => $v) {
if ($v instanceof Criteria) {
$crit->andWhere($crit->getWhereExpression());
} elseif ($v instanceof Expression) {
$crit->andWhere($v);
} elseif (is_array($v)) {
$expr = Criteria::expr();
$crit->andWhere($expr->andX($expr->in($k, $v)));
} else {
$expr = Criteria::expr();
$crit->andWhere($expr->andX($expr->eq($k, $v)));
}
}
$entities = static::getEntityManager()->getRepository(get_called_class())->matching($crit)->toArray();
foreach ($entities as $entity) {
/**
* @var $entity static
*/
$entity->setExists(true);
$entity->setPersistedData(call_user_func('get_object_vars', $entity));
}
return $entities;
}
示例15: getOfferingsForTeachingReminders
/**
* {@inheritdoc}
*/
public function getOfferingsForTeachingReminders($daysInAdvance)
{
$now = time();
$startDate = new \DateTime();
$startDate->setTimezone(new \DateTimeZone('UTC'));
$startDate->setTimestamp($now);
$startDate->modify("midnight +{$daysInAdvance} days");
$daysInAdvance++;
$endDate = new \DateTime();
$endDate->setTimezone(new \DateTimeZone('UTC'));
$endDate->setTimestamp($now);
$endDate->modify("midnight +{$daysInAdvance} days");
$criteria = Criteria::create();
$expr = Criteria::expr();
$criteria->where($expr->andX($expr->eq('deleted', 0), $expr->gte('startDate', $startDate), $expr->lt('startDate', $endDate)));
$offerings = $this->getRepository()->matching($criteria);
// filter out any offerings belonging to unpublished events
// and with deleted parentage
$offerings->filter(function (OfferingInterface $offering) {
$session = $offering->getSession();
$course = $session->getCourse();
$publishEvent = $offering->getSession()->getPublishEvent();
$school = $course->getSchool();
return isset($publishEvent) && isset($school) && !$session->isDeleted() && !$course->isDeleted();
});
return $offerings;
}