[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_categories/src/Helper/ -> CategoryAssociationHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_categories
   6   *
   7   * @copyright   (C) 2012 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\Component\Categories\Administrator\Helper;
  12  
  13  // phpcs:disable PSR1.Files.SideEffects
  14  \defined('_JEXEC') or die;
  15  // phpcs:enable PSR1.Files.SideEffects
  16  
  17  /**
  18   * Category Component Association Helper
  19   *
  20   * @since  3.0
  21   */
  22  abstract class CategoryAssociationHelper
  23  {
  24      /**
  25       * Flag if associations are present for categories
  26       *
  27       * @var    boolean
  28       * @since  3.0
  29       */
  30      public static $category_association = true;
  31  
  32      /**
  33       * Method to get the associations for a given category
  34       *
  35       * @param   integer      $id         Id of the item
  36       * @param   string       $extension  Name of the component
  37       * @param   string|null  $layout     Category layout
  38       *
  39       * @return  array    Array of associations for the component categories
  40       *
  41       * @since  3.0
  42       */
  43      public static function getCategoryAssociations($id = 0, $extension = 'com_content', $layout = null)
  44      {
  45          $return = array();
  46  
  47          if ($id) {
  48              $helperClassname = ucfirst(substr($extension, 4)) . 'HelperRoute';
  49  
  50              $associations = CategoriesHelper::getAssociations($id, $extension);
  51  
  52              foreach ($associations as $tag => $item) {
  53                  if (class_exists($helperClassname) && \is_callable(array($helperClassname, 'getCategoryRoute'))) {
  54                      $return[$tag] = $helperClassname::getCategoryRoute($item, $tag, $layout);
  55                  } else {
  56                      $viewLayout = $layout ? '&layout=' . $layout : '';
  57  
  58                      $return[$tag] = 'index.php?option=' . $extension . '&view=category&id=' . $item . $viewLayout;
  59                  }
  60              }
  61          }
  62  
  63          return $return;
  64      }
  65  }


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