/** * __construct * * @param string $fieldName The field name to perform the query on * @param string $value The field value to match * @param array $options Optional regex options */ public function __construct($fieldName, $value, array $options = []) { if (!empty($options)) { $this->options = $options; } $this->spec = SF::mongoRegex($fieldName, $this->getPattern($value)); }
/** * orX * * Return a new composite OR specification, chaining the current instance with the provided specification * * @param \ArpOdmSpecification\Entity\Specification\OdmSpecificationInterface $spec * @return \ArpOdmSpecification\Entity\Specification\OrSpecification */ public function orX(OdmSpecificationInterface $spec) { if ($this->spec) { // Replace with self return SF::orX($this->spec, $spec); } // return given spec! return $spec; }
/** * filter * * Perform the specification filtering * * @param \Dcotrine\MongoDb\Query\Builder $qb * @return \Dcotrine\MongoDb\Query\Expr */ public function filter(Query\Builder $qb) { $spec = SF::isEqual($this->fieldName . '._id', new \MongoId($this->fieldValue)); return $spec->filter($qb); }
/** * orX * * Return a new composite OR specification, chaining the current instance with the provided specification * * @param \ArpOdmSpecification\Entity\Specification\OdmSpecificationInterface $spec * @return \ArpOdmSpecification\Entity\Specification\OrSpecification */ public function orX(SpecificationInterface $spec) { return SF::orX($this, $spec); }
/** * filter * * Filter the query * * @param \Doctrine\MongoDB\Query\Builder $qb * @return \Doctrine\MongoDB\Query\Expr */ public function filter(Query\Builder $qb) { $spec = SF::isEqual($this->fieldName, $this->fieldValue); return $this->spec->filter($qb); }
/** * filter * * Perform the filter on the query builder * * @param \Doctrine\MongoDB\Query $qb * @return \Doctrine\MongoDB\Query\Expr */ public function filter(Query\Builder $qb) { $spec = SF::isEqual($fieldName, new \MongoRegex($regex)); return $spec->filter($qb); }