RSS feeder.

Similar to `ServeController::search()` but it uses `rss` layout instead of
default layout.

@param string $criteria A search criteria. e.g.: `"this phrase" -"but not this" OR -hello`
@return void
191965
public function rss($criteria)
    {
        $this->loadModel('Content.Contents');

        try {
            $contents = $this->Contents
                ->search($criteria)
                ->limit(10);
        } catch (\Exception $e) {
            $contents = [];
        }

        $this->set(compact('contents', 'criteria'));
        $this->viewMode('rss');
        $this->RequestHandler->renderAs($this, 'rss');
        $this->RequestHandler->respondAs('xml');
    }
1083928
public function matching(Criteria $criteria)
    {
        $clause = [];
        /** @var Comparison $whereClause */
        $whereClause = $criteria->getWhereExpression();
        if (null !== $whereClause) {
            if (Comparison::EQ !== $whereClause->getOperator()) {
                throw new \InvalidArgumentException(sprintf('Support for Selectable is limited to the EQUALS "=" operator, 
                 % given', $whereClause->getOperator()));
            }

            $clause = [$whereClause->getField() => $whereClause->getValue()->getValue()];
        }

        return $this->findBy($clause, $criteria->getOrderings(), $criteria->getMaxResults(), $criteria->getFirstResult());
    }
963548
public function findFirst($criteria = null)
    {
        $this->getQuery()->setLimit(1);
        
        $resultSet = $this->findBy($criteria);
        $resultSet->rewind();
        
        return $resultSet->valid() ? $resultSet->current() : null;
    }
893977
public function init(Criteria $criteria)
    {
        // init $this->db
        try {
            $db = Propel::getDB($criteria->getDbName());
            $this->setDB($db);
        } catch (Exception $e) {
            // we are only doing this to allow easier debugging, so
            // no need to throw up the exception, just make note of it.
            Propel::log("Could not get a DBAdapter, sql may be wrong", Propel::LOG_ERR);
        }

        // init $this->realtable
        $realtable = $criteria->getTableForAlias($this->table);
        $this->realtable = $realtable ? $realtable : $this->table;
    }
42104
protected function getSelectConditionCriteriaSQL(Criteria $criteria)
    {
        $expression = $criteria->getWhereExpression();

        if ($expression === null) {
            return '';
        }

        $visitor = new SqlExpressionVisitor($this, $this->class);

        return $visitor->dispatch($expression);
    }
1172138
private function bracketCriteria(array &$criteria, string $bracket = self::BRACKET_OPEN, string $connector = self::LOGICAL_AND): self
    {
        $criteria[] = [
            'bracket'   => $bracket,
            'connector' => $connector,
        ];

        return $this;
    }
133253
public function findFirst($criteria = null) {
		if ($criteria !== null) {
			trigger_error('Attempts to set criteria are vain for the File datagate');
		}
		
		$fileIterator = new FileIterator(
			$this->getFile(),
			$this->delimiter,
			$this->partsNames
		);
		
		return $this->createResult($fileIterator->current());
	}
1165028
public function mergeCriteria(array $criteria)
    {
        $this->criteria = null === $this->criteria ? $criteria : array_merge($this->criteria, $criteria);

        return $this;
    }
23859
public function findOneBy(array $criteria) : ?array
    {
        foreach ($this->objects as $object) {
            $matches = true;

            foreach ($criteria as $key => $value) {
                if ($object[$key] === $value) {
                    continue;
                }

                $matches = false;
            }

            if ($matches) {
                return $object;
            }
        }

        return null;
    }
846064
public function criteria(Criteria\Criteria $cri = null)
    {
        if (! $cri) $cri = new Criteria\Criteria($this);
        $cri->setTable($this);

        return $cri;
    }
1179061
public static function findByCriteria(array $criteria): ?Model\Collection
    {
        try {
            list($columns, $values, $options) = static::parseCriteria($criteria);
        } catch (NoTagsException $e) {
            return null;
        }

        if (\count($columns) < 1) {
            return static::findAll($options);
        }

        return static::findBy($columns, $values, $options);
    }
954141
public function countBy(array $criteria = null)
    {
        /** @var \Doctrine\ORM\QueryBuilder $qb */
        $qb = $this->createQueryBuilder('e');
        $qb->select('count(e.id)');

        $firstCriteria = true;
        if (!empty($criteria)) {
            foreach ($criteria as $field => $value) {
                if ($firstCriteria) {
                    if ($value === null or $value === 'null') {
                        $qb->where("e.$field IS NULL");
                    } elseif ($value === 'not null') {
                        $qb->where("e.$field IS NOT NULL");
                    } else {
                        $qb->where("e.$field = :$field");
                        $qb->setParameter($field, $value);
                    }

                    $firstCriteria = false;
                } else {
                    if ($value === null or $value === 'null') {
                        $qb->andWhere("e.$field IS NULL");
                    } elseif ($value === 'not null') {
                        $qb->andWhere("e.$field IS NOT NULL");
                    } else {
                        $qb->andWhere("e.$field = :$field");
                        $qb->setParameter($field, $value);
                    }
                }
            }
        }

        return $qb->getQuery()->getSingleScalarResult();
    }
519641
public function applyLimit($criteria)
	{
		$criteria->limit=$this->getLimit();
		$criteria->offset=$this->getOffset();
	}
457655
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
    {
        $this->throwBadMethodException('findBy');
    }
511633
private function applyCriteriaToQueryBuilder(Criteria $criteria, QueryBuilder $qb, $prefix)
    {
        if ($criteria->getMode() === Criteria::MODE_OR) {
            $expr = $qb->expr()->orX();
        } else {
            $expr = $qb->expr()->andX();
        }
        foreach ($criteria as $criterium) {
            if ($criterium instanceof Criteria) {
                $expr->add(
                    $this->applyCriteriaToQueryBuilder($criterium, $qb, $prefix)
                );
            } else {
                $this->applyCriteriumToQueryBuilder($criterium, $qb, $expr, $prefix);
            }
        }

        return $expr;
    }
168619
private function parseCriteria(array $criteria)
    {
        $out = '';
        if (!empty($criteria)) {
            $conditions = [];
            foreach ($criteria as $field => $value) {
                if (is_array($value)) {
                    $values = array_map(function($value) { return $this->connection->quote($value); }, $value);
                    $conditions[] = sprintf('%s IN (%s)', $field, implode(', ', $values));
                } else {
                    $operator = '=';
                    $ops = ['<>', '<', '>', '<=', '>='];
                    foreach ($ops as $op) {
                        if (false !== strpos($value, $op)) {
                            $operator = $op;
                            $value = str_replace(sprintf('%s ', $op), '', $value);
                            break;
                        }
                    }
                    $conditions[] = sprintf('%s %s %s', $field, $operator, $this->connection->quote($value));
                }
            }
            $out = sprintf(' WHERE %s', implode(' AND ', $conditions));
        }
        return $out;
    }
435836
public function countByCriteria(Criteria $criteria)
    {
        $qb = $this->createCriteriaQueryBuilder($criteria, 'm');

        $qb->select('COUNT(m.id)');

        return $qb->getQuery()->getSingleScalarResult();
    }