[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/modules/mod_articles_categories/src/Helper/ -> ArticlesCategoriesHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  mod_articles_categories
   6   *
   7   * @copyright   (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  namespace Joomla\Module\ArticlesCategories\Site\Helper;
  12  
  13  use Joomla\CMS\Categories\Categories;
  14  
  15  // phpcs:disable PSR1.Files.SideEffects
  16  \defined('_JEXEC') or die;
  17  // phpcs:enable PSR1.Files.SideEffects
  18  
  19  /**
  20   * Helper for mod_articles_categories
  21   *
  22   * @since  1.5
  23   */
  24  abstract class ArticlesCategoriesHelper
  25  {
  26      /**
  27       * Get list of articles
  28       *
  29       * @param   \Joomla\Registry\Registry  &$params  module parameters
  30       *
  31       * @return  array
  32       *
  33       * @since   1.5
  34       */
  35      public static function getList(&$params)
  36      {
  37          $options               = [];
  38          $options['countItems'] = $params->get('numitems', 0);
  39  
  40          $categories = Categories::getInstance('Content', $options);
  41          $category   = $categories->get($params->get('parent', 'root'));
  42  
  43          if ($category !== null) {
  44              $items = $category->getChildren();
  45  
  46              $count = $params->get('count', 0);
  47  
  48              if ($count > 0 && \count($items) > $count) {
  49                  $items = \array_slice($items, 0, $count);
  50              }
  51  
  52              return $items;
  53          }
  54      }
  55  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer