original_string: 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]);
      }
code: 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]);
      }
code_tokens: 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 ] ) ; }
docstring: Set the related list criteria.
  
  @param NewsCriteria $criteria
  @param Module       $module
  
  @throws NoNewsException
docstring_tokens: Set the related list criteria .