/** * Get all Comercio entities. * * @View(serializerEnableMaxDepthChecks=true) * * @param ParamFetcherInterface $paramFetcher * * @return Response * * @QueryParam(name="q", nullable=true, description="Search text.") * @QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing notes.") * @QueryParam(name="limit", requirements="\d+", default="20", description="How many notes to return.") * @QueryParam(name="order_by", nullable=true, array=true, description="Order by fields. Must be an array ie. &order_by[name]=ASC&order_by[description]=DESC") * @QueryParam(name="filters", nullable=true, array=true, description="Filter by fields. Must be an array ie. &filters[id]=3") * @Get("/filters/operators") */ public function operatorsAction(ParamFetcherInterface $paramFetcher) { try { $operators = Utility::operators(); if ($operators) { return array($operators); } return FOSView::create('Not Found', Codes::HTTP_NO_CONTENT); } catch (\Exception $e) { return FOSView::create($e->getMessage(), Codes::HTTP_INTERNAL_SERVER_ERROR); } }
public function findByAdapter(array $filters = array(), array $order_by = array(), $q = '', $key_operator = '') { $fields = array_keys($this->getClassMetadata()->reflFields); $qb = $this->createQueryBuilder('c'); $operatorsLike = Utility::operatorsLike(); $operatorsNotLike = Utility::operatorsNotLike(); $sqlOperators = array_merge($operatorsLike, $operatorsNotLike); $operatorsLikeKey = array_keys($operatorsLike); $operatorsNotLikeKey = array_keys($operatorsNotLike); $qLike = false; $qNotLike = false; $qLikeValue = ''; foreach ($sqlOperators as $key => $value) { if ($key === $key_operator) { if (in_array($key, $operatorsNotLikeKey)) { $qNotLike = true; } else { $qLike = true; } $qLikeValue = $value; } } $ORs = array(); foreach ($fields as $field) { if (isset($filters[$field])) { if (!empty($filters[$field])) { $qb->andWhere('c.' . $field . '=' . $filters[$field]); } if ($qLike && $qLikeValue) { if (empty($filters[$field])) { $ORs[] = $qb->expr()->like('c.' . $field, $qb->expr()->literal(sprintf($qLikeValue, $q))); } } if ($qNotLike && $qLikeValue) { $ORs[] = $qb->expr()->notLike('c.' . $field, $qb->expr()->literal(sprintf($qLikeValue, $q))); } } if (isset($order_by[$field])) { $sortDir = $order_by[$field] === 'ASC' ? 'ASC' : 'DESC'; $qb->addOrderBy('c.' . $field, $sortDir); } } $orx = $qb->expr()->orX(); foreach ($ORs as $or) { $orx->add($or); } $qb->andWhere($orx); $adapter = new DoctrineORMAdapter($qb); return $adapter; }
/** * Hook on pre-update operations. * * @ORM\PreUpdate */ public function preUpdate() { $this->edoNomb = Utility::upperCase($this->edoNomb); }
/** * Hook on pre-update operations. * * @ORM\PreUpdate */ public function preUpdate() { $this->fechmodi = new \DateTime(); $this->cedu = Utility::upperCase($this->cedu); $this->naci = Utility::upperCase($this->naci); $this->nomb = Utility::upperCase($this->nomb); $this->apell = Utility::upperCase($this->apell); $this->profesionFix = Utility::upperCase($this->profesionFix); $this->correo = Utility::lowerCase($this->correo); }