Set the related list criteria.

@param NewsCriteria $criteria
@param Module       $module

@throws NoNewsException
8308
private function setRelatedListCriteria(NewsCriteria $criteria, Module $module)
    {
        if (null === ($news = $module->currentNews)) {
            throw new NoNewsException();
        }

        /** @var Model $adapter */
        $adapter = $this->framework->getAdapter(Model::class);
        $categories = \array_unique($adapter->getRelatedValues($news->getTable(), 'categories', $news->id));

        // This news has no news categories assigned
        if (0 === \count($categories)) {
            throw new NoNewsException();
        }

        $categories = \array_map('intval', $categories);
        $excluded = $this->db->fetchAll('SELECT id FROM tl_news_category WHERE excludeInRelated=1');

        // Exclude the categories
        foreach ($excluded as $category) {
            if (false !== ($index = \array_search((int) $category['id'], $categories, true))) {
                unset($categories[$index]);
            }
        }

        // Exclude categories by root
        if ($module->news_categoriesRoot > 0) {
            $categories = array_intersect($categories, NewsCategoryModel::getAllSubcategoriesIds($module->news_categoriesRoot));
        }

        // There are no categories left
        if (0 === \count($categories)) {
            throw new NoNewsException();
        }

        $criteria->setDefaultCategories($categories, (bool) $module->news_includeSubcategories, $module->news_relatedCategoriesOrder);
        $criteria->setExcludedNews([$news->id]);
    }
1316385
public void addOrCriteria(Criteria pc)
    {
        if (!m_criteria.isEmpty())
        {
            pc.setEmbraced(true);
            pc.setType(OR);
            addCriteria(pc);
        }
        else
        {
            setEmbraced(false);
            pc.setType(OR);
            addCriteria(pc);
        }
    }
934914
public function setCriteriaType($query_name, $criteria_type)
    {

        $this->checkColumnName("set_criteria_ltype", $query_name);
        if (($cl = &ReporticoUtility::getQueryColumn($query_name, $this->columns))) {
            $cl->setCriteriaType($criteria_type);
        }
    }
390400
public function buildCriteria()
    {
        $criteria = new Criteria(CategoryTableMap::DATABASE_NAME);

        if ($this->isColumnModified(CategoryTableMap::COL_ID)) {
            $criteria->add(CategoryTableMap::COL_ID, $this->id);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_SOURCE_ID)) {
            $criteria->add(CategoryTableMap::COL_SOURCE_ID, $this->source_id);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_PAGEID)) {
            $criteria->add(CategoryTableMap::COL_PAGEID, $this->pageid);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TITLE)) {
            $criteria->add(CategoryTableMap::COL_TITLE, $this->title);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_FILES)) {
            $criteria->add(CategoryTableMap::COL_FILES, $this->files);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_SUBCATS)) {
            $criteria->add(CategoryTableMap::COL_SUBCATS, $this->subcats);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_PAGES)) {
            $criteria->add(CategoryTableMap::COL_PAGES, $this->pages);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_SIZE)) {
            $criteria->add(CategoryTableMap::COL_SIZE, $this->size);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_HIDDEN)) {
            $criteria->add(CategoryTableMap::COL_HIDDEN, $this->hidden);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_CREATED_AT)) {
            $criteria->add(CategoryTableMap::COL_CREATED_AT, $this->created_at);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_UPDATED_AT)) {
            $criteria->add(CategoryTableMap::COL_UPDATED_AT, $this->updated_at);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TREE_LEFT)) {
            $criteria->add(CategoryTableMap::COL_TREE_LEFT, $this->tree_left);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TREE_RIGHT)) {
            $criteria->add(CategoryTableMap::COL_TREE_RIGHT, $this->tree_right);
        }
        if ($this->isColumnModified(CategoryTableMap::COL_TREE_LEVEL)) {
            $criteria->add(CategoryTableMap::COL_TREE_LEVEL, $this->tree_level);
        }

        return $criteria;
    }
259952
public void addQueryCriterion(QueryCriterion criterion){
        if( criteria == null){
            criteria = new ArrayList<QueryCriterion>();
        }
        criteria.add(criterion);
    }
1100449
public function getCriteriaForMenuModule(array $archives, Module $module)
    {
        $criteria = new NewsCriteria($this->framework);

        try {
            $criteria->setBasicCriteria($archives, $module->news_order);

            // Set the regular list criteria
            $this->setRegularListCriteria($criteria, $module);
        } catch (NoNewsException $e) {
            return null;
        }

        return $criteria;
    }
1118926
private function _initCriteriaSlice( MW_Common_Criteria_Interface $criteria, stdClass $params )
	{
		if( isset( $params->start ) && isset( $params->limit ) )
		{
			$start = ( isset( $params->start ) ? $params->start : 0 );
			$size = ( isset( $params->limit ) ? $params->limit : 25 );

			$criteria->setSlice( $start, $size );
		}
	}
667648
public function setModule($module)
        {
            if (null !== $module && !is_string($module)) {
                throw new Exception(
                    'Invalid argument: $module must be a string or null'
                );
            }

            $this->_module    = $module;
            $this->_hrefCache = null;

            return $this;
        }
144528
protected static function processCriteriaWithType(&$criteria){

        $class = get_called_class();
        $types = $class::getModelTypes();
        if (count($types) > 1) {
            $criteria['_type'] = $class::getClassName(false);
        }

    }
118717
public static function setAlreadyAddSubmodulesFor($module, $app = null)
    {
        if (empty($app)) {
            $app = Yii::$app;
        }
        $appKey = UniApplication::appKey($app);
        if($module instanceof YiiBaseModule) {
            static::$_modulesWithInstalledSubmodules[$appKey][$module::className()] = $module->uniqueId; // uniqueId for Yii::$app = ''
        }
    }
27386
private void setScanCriteria(Scan scan, String columnFamily, List<Map<String, Object>> columnsToOutput,
            Filter filter)
    {
        if (filter != null)
        {
            scan.setFilter(filter);
        }
    }
719916
public function setCriteriaAttribute($query_name, $attrib_name, $attrib_value)
    {

        if (array_key_exists($query_name, $this->lookup_queries)) {
            $col = &$this->lookup_queries[$query_name];
            $col->setAttribute($attrib_name, $attrib_value);
        }
    }
1209938
public void addIn(String attribute, Collection values)
    {
        List list = splitInCriteria(attribute, values, false, IN_LIMIT);
        int index = 0;
        InCriteria inCrit;
        Criteria allInCritaria;

        inCrit = (InCriteria) list.get(index);
        allInCritaria = new Criteria(inCrit);

        for (index = 1; index < list.size(); index++)
        {
            inCrit = (InCriteria) list.get(index);
            allInCritaria.addOrCriteria(new Criteria(inCrit));
        }

        addAndCriteria(allInCritaria);
    }
879236
public function onNewsListCountItems(array $archives, $featured, ModuleNewsList $module)
    {
        if (null === ($criteria = $this->getCriteria($archives, $featured, $module))) {
            return 0;
        }

        return $criteria->getNewsModelAdapter()->countBy($criteria->getColumns(), $criteria->getValues());
    }
42835
private function _initCriteriaSortations( MW_Common_Criteria_Interface $criteria, stdClass $params )
	{
		if( isset( $params->sort ) && isset( $params->dir ) )
		{
			$sortation = array();

			switch( $params->dir )
			{
				case 'ASC':
					$sortation[] = $criteria->sort( '+', $params->sort ); break;
				case 'DESC':
					$sortation[] = $criteria->sort( '-', $params->sort ); break;
				default:
					throw new Controller_ExtJS_Exception( sprintf( 'Invalid sort direction "%1$s"', $params->sort ) );
			}

			$criteria->setSortations( $sortation );
		}


		if( $this->_sort !== null )
		{
			$sort = $criteria->getSortations();
			$sort[] = $criteria->sort( '+', $this->_sort );
			$criteria->setSortations( $sort );
		}
	}
319428
private void addCriteria(List<GenericCriteria> list, byte[] block)
   {
      byte[] leftBlock = getChildBlock(block);
      byte[] rightBlock1 = getListNextBlock(leftBlock);
      byte[] rightBlock2 = getListNextBlock(rightBlock1);
      TestOperator operator = TestOperator.getInstance(MPPUtility.getShort(block, 0) - 0x3E7);
      FieldType leftValue = getFieldType(leftBlock);
      Object rightValue1 = getValue(leftValue, rightBlock1);
      Object rightValue2 = rightBlock2 == null ? null : getValue(leftValue, rightBlock2);

      GenericCriteria criteria = new GenericCriteria(m_properties);
      criteria.setLeftValue(leftValue);
      criteria.setOperator(operator);
      criteria.setRightValue(0, rightValue1);
      criteria.setRightValue(1, rightValue2);
      list.add(criteria);

      if (m_criteriaType != null)
      {
         m_criteriaType[0] = leftValue.getFieldTypeClass() == FieldTypeClass.TASK;
         m_criteriaType[1] = !m_criteriaType[0];
      }

      if (m_fields != null)
      {
         m_fields.add(leftValue);
      }

      processBlock(list, getListNextBlock(block));
   }
1357841
protected function applyCriteria(Builder $builder, array $criteria)
    {
        foreach ($criteria as $criterion) {
            $criterion->apply($builder);
        }
    }