Build `if_page_contains` rule based on other previous rules defined for:
- single_page_link.
- next_page_link.

First one has priority over the next one.

@param SiteConfig $config    Current config
@param string     $condition XPath condition
961421
private function handleIfPageContainsCondition(SiteConfig $config, $condition)
    {
        if (!empty($config->single_page_link)) {
            $rule = 'single_page_link';
        } elseif (!empty($config->next_page_link)) {
            $rule = 'next_page_link';
        } else {
            // no link found, we can't apply "if_page_contains"
            return;
        }

        $key = end($config->$rule);
        reset($config->$rule);

        $config->if_page_contains[$rule][$key] = (string) $condition;
    }
489004
public function addCondition(\Sulu\Bundle\ResourceBundle\Entity\Condition $conditions)
    {
        $this->conditions[] = $conditions;

        return $this;
    }
391541
public static function loadConfig($config = null)
    {
        if ($config !== null) {
            Configure::write('CakeResque', $config);
        }

        if (
            ($hasCheck = method_exists('Configure', 'check')) && !Configure::check('CakeResque') ||
            !$hasCheck && !self::checkConfig('CakeResque')
        ) {
            Configure::load('CakeResque.config');
        }
    }
16141
protected function _setup($config) {
        if (!empty($config['url'])) {
            $this->_url = $config['url'];
        }
        if (!empty($config['params'])) {
            $this->_params = $config['params'];
        }
    }
264756
public static function wrapOnDemand($condition, $tag, $content)
    {
        if ($condition) {
            echo sprintf('<%s>%s</%s>', $tag, $content, $tag);
        } else {
            echo $content;
        }
    }
392567
private function setConditionUrlParams(\Magento\Rule\Model\Condition\AbstractCondition $conditions, $urlParams)
    {
        $conditions->setUrlParams($urlParams);

        if ($conditions->getConditions() && is_array($conditions->getConditions())) {
            foreach ($conditions->getConditions() as $condition) {
                $this->setConditionUrlParams($condition, $urlParams);
            }
        }
    }
1157665
protected function maybeInvalidConfig(Config $config): ?Error
    {
        $expected = (string) $config->get('url');

        return (empty($expected))
            ? ResultFactory::makeError($this, 'Expected URL not defined in preflight.toml.')
            : null;
    }
842321
public function link($query, $condition = array(), $options = array())
    {
        if (is_string($query)) {
            if (strpos($query, '.') === false) {
                $name = $query;

                if ($property = $this->getRepository()->getDescription()->getProperty($name)) {
                    $name = $property->getName();
                }

                AnDomainQueryHelper::addRelationship($this, $name);
                $link = $this->getLink($name);
                $config = new AnConfig($condition);
                $config->append(array(
                        'type' => $link->type,
                        'bind_type' => $link->bind_type,
                        'conditions' => array(),
                ));
                $link->offsetSet('type', $config->type)->offsetSet('bind_type', $config->bind_type);
                foreach ($config->conditions as $key => $value) {
                    if (is_string($value)) {
                        $value = AnDomainQueryBuilder::getInstance()->parseMethods($this, $value);
                    } elseif ($value instanceof AnDomainResourceColumn) {
                        $value = clone $value;
                    }
                    $link->conditions[$key] = $value;
                }

                return $this;
            } else {
                $query = AnDomain::getRepository($query)->getQuery();
            }
        } elseif ($query instanceof AnDomainRepositoryAbstract) {
            $query = $query->getQuery();
        }

        settype($condition, 'array');

        $options = new AnConfig($options);

        $options->append(array(
            'type' => 'strong',
            'resource' => $query->getRepository()->getResources()->main(),
            'as' => $query->getRepository()->getDescription()->getEntityIdentifier()->name,
        ));

        if (!isset($this->link[$options->as])) {
            $options->resource->setAlias(AnInflector::underscore($options->as));

            $destination = $query->getRepository()->getDescription()->getInheritanceColumn();

            $link = array(
                'query' => $query,
                'resource' => $options->resource,
                'resource_name' => $options->resource->getAlias(),
                'type' => $options->type,
                'conditions' => array(),
                'bind_type' => $destination ? clone $destination : null,
            );

            foreach ($condition as $key => $value) {
                $link['conditions'][$key] = $value instanceof AnDomainResourceColumn ? clone $value : $value;
            }

            $this->link[$options->as] = new AnConfig($link);

            $this->distinct = true;
        }

        return $this;
    }
831156
public function getSiteStats( $config = [] ) {

		$status	= isset( $config[ 'status' ] ) ? $config[ 'status' ] : null;
		$type	= isset( $config[ 'type' ] ) ? $config[ 'type' ] : null;
		$limit	= isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 0;

		$modelClass	= static::$modelClass;
        $modelTable	= $modelClass::tableName();

        $query = new Query();

        $query->select( [ 'siteId', 'count(id) as total' ] )
			->from( $modelTable );

		// Filter Status
		if( isset( $status ) ) {

			$query->where( "$modelTable.status=:status", [ ':status' => $status ] );
		}

		// Filter Type
		if( isset( $type ) ) {

			$query->andWhere( "$modelTable.type=:type", [ ':type' => $type ] );
		}

		// Limit
		if( $limit > 0 ) {

			$query->limit( $limit );
		}

		// Group and Order
		$query->groupBy( 'siteId' )->orderBy( 'total DESC' );

        return $query->all();
    }
422274
public function where($condition, $value = null, $type = null)
    {

        switch ($type) {
            case null:
                $clause = 'WHERE';
                break;
            case 'or':
                $clause = 'OR';
                break;
            case 'and':
                $clause = 'AND';
                break;
            default:
                $clause = 'WHERE';
        }

        $this->oosql_where .= " $clause $condition";

        if ($value instanceof oosql) {

            $this->oosql_where .= $value->getSql();
        } elseif (null !== $value) {

            $this->oosql_conValues[] = $value;
        }

        return $this;
    }
867120
protected function _applyRule($config)
    {
        if (!is_array($config)) {
            return false;
        }
        if (!$calssName = ArrayHelper::getValue($config, 'class')) {
            return false;
        }
        if (!class_exists($calssName)) {
            return false;
        }
        $rule = new $calssName;
        if (!$rule instanceof Rule) {
            return false;
        }

        if ($ruleExist = \Yii::$app->authManager->getRule($rule->name)) {
            return $ruleExist;
        }

        if (\Yii::$app->authManager->add($rule)) {
            return $rule;
        }

        return false;
    }
1306736
protected function processTokenCondition($condition)
    {
        if (false === $this->condition->hasCondition($condition)) {
            $this->addError('The condition "' . $condition . '" does not exist.', self::ERROR_CODE_CONDITION_NOT_FOUND);
        } else {
            $node = new ConditionNode($condition, $this->condition->getCondition($condition));
            $this->scope
                ->setNode($node)
                ->shiftExpression();
        }
    }
573014
private function checkConfigOptions($config)
    {
        if (!isset($config['cas_host'])) {
            throw new Exception("CAS host required!", 500);
        }
        if (!isset($config['cas_port'])) {
            throw new Exception("CAS port required!", 500);
        }
        if (!isset($config['cas_context'])) {
            throw new Exception("CAS path required!", 500);
        }
        if (!isset($config['ca_cert_path'])) {
            throw new Exception("CA cert path for CAS server required!", 500);
        }
    }
1148758
protected function createMatcher(ConditionGroup $conditions)
    {
        if (!$conditions->hasConditions()) {
            return function () { return true; };
        }
        return $this->matcher->compile($conditions);
    }
1362247
private function hasConfig($config, $attr)
    {
        return (isset($attr[self::CONFIG_ALL]) && $attr[self::CONFIG_ALL]) || (isset($attr[$config]) && $attr[$config]);
    }
278198
protected function applyRootCondition(&$condition)
    {
        if (false !== $this->rootAttribute) {
            $condition[] = [$this->rootAttribute => $this->node->{$this->rootAttribute}];
        }
    }
678108
public function persist(Config $config, $enable_config_per_site = self::DEFAULT_CONFIG_PER_SITE_VALUE)
    {
        if (null === $this->persistors) {
            $this->loadPersistors();
        }

        if (true === $enable_config_per_site) {
            $this->updateConfigOverridedSectionsForSite($config);
        }

        $this->doPersist($config, $config->getAllRawSections());

        // restore current config state after persist if config per site is enabled
        if (true === $enable_config_per_site) {
            $override_sections = $config->getRawSection('override_site');
            $site_uid = $this->application->getSite()->getUid();
            if (is_array($override_sections) && array_key_exists($site_uid, $override_sections)) {
                foreach ($override_sections[$site_uid] as $section_name => $section_settings) {
                    $config->setSection($section_name, $section_settings);
                }
            }
        }
    }