Jarves\Storage\Propel::search PHP Method

    public function search($query, Condition $condition = null, $max = 20)
    {
        if (!$this->definition->isSearchable()) {
            return null;
        }
        $fields = [];
        $options = [];
        $filter = [];
        $queryCondition = new Condition();
        if ($fieldName = $this->definition->getLabelField()) {
            $fields[] = $fieldName;
            $queryCondition->addAnd([$fieldName, 'LIKE', str_replace('*', '%', $query)]);
            $condition->addAnd($queryCondition);
        }
        if ($this->definition->getTreeLabel()) {
            $fields[] = $this->definition->getTreeLabel();
        }
        $query = $this->getQueryClass();
        list($fields, $relations, $relationFields) = $this->getFields($fields);
        $selects = array_keys($fields);
        $query->limit($max);
        $this->mapOptions($query, $options);
        $this->mapToOneRelationFields($query, $relations, $relationFields);
        $this->mapFilter($query, $filter);
        if ($this->definition->isNested()) {
            $query->filterByLft(1, Criteria::GREATER_THAN);
            $selects[] = 'Lft';
            $selects[] = 'Rgt';
            $selects[] = 'Lvl';
        }
        $query->select($selects);
        $stmt = $this->getStm($query, $condition);
        $clazz = $this->getPhpName();
        $result = [];
        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $result[] = $this->populateRow($clazz, $row, $selects, $relations, $relationFields, isset($options['permissionCheck']) ? $options['permissionCheck'] : null);
        }
        return $result;
    }