/** * Apply scopes to criteria, will create criteria object if not provided and pass it by reference * @param CriteriaInterface|array|null $criteria * @return CriteriaInterface */ public function apply(&$criteria = null) { if (null === $criteria) { return $this->getModelCriteria(); } elseif (is_array($criteria)) { $criteria = new Criteria($criteria); } $criteria->mergeWith($this->criteria); $criteria->mergeWith($this->getModelCriteria()); return $criteria; }
/** * Finds document with the specified primary key. Primary key by default * is defined by `_id` field. But could be any other. For simple (one column) * keys use it's value. * * For composite use key-value with column names as keys * and values for values. * * Example for simple pk: * ```php * $pk = '51b616fcc0986e30026d0748' * ``` * * Composite pk: * ```php * $pk = [ * 'mainPk' => 1, * 'secondaryPk' => 2 * ]; * ``` * * @param mixed $pkValue primary key value. Use array for composite key. * @param array|CriteriaInterface $criteria * @return AnnotatedInterface|null * @Ignored */ public function findByPk($pkValue, $criteria = null) { $pkCriteria = new Criteria($criteria); $pkCriteria->decorateWith($this->model); $pkCriteria->mergeWith(PkManager::prepare($this->model, $pkValue)); return $this->find($pkCriteria); }