[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Tag/ -> TagServiceTrait.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE
   8   */
   9  
  10  namespace Joomla\CMS\Tag;
  11  
  12  use Joomla\CMS\Helper\ContentHelper;
  13  
  14  // phpcs:disable PSR1.Files.SideEffects
  15  \defined('JPATH_PLATFORM') or die;
  16  // phpcs:enable PSR1.Files.SideEffects
  17  
  18  /**
  19   * Trait for component tags service.
  20   *
  21   * @since  4.0.0
  22   */
  23  trait TagServiceTrait
  24  {
  25      /**
  26       * Adds Count Items for Tag Manager.
  27       *
  28       * @param   \stdClass[]  $items      The content objects
  29       * @param   string       $extension  The name of the active view.
  30       *
  31       * @return  void
  32       *
  33       * @since   4.0.0
  34       */
  35      public function countTagItems(array $items, string $extension)
  36      {
  37          $parts   = explode('.', $extension);
  38          $section = \count($parts) > 1 ? $parts[1] : null;
  39  
  40          $config = (object) array(
  41              'related_tbl'   => $this->getTableNameForSection($section),
  42              'state_col'     => $this->getStateColumnForSection($section),
  43              'group_col'     => 'tag_id',
  44              'extension'     => $extension,
  45              'relation_type' => 'tag_assigments',
  46          );
  47  
  48          ContentHelper::countRelations($items, $config);
  49      }
  50  
  51      /**
  52       * Returns the table for the count items functions for the given section.
  53       *
  54       * @param   string  $section  The section
  55       *
  56       * @return  string|null
  57       *
  58       * @since   4.0.0
  59       */
  60      protected function getTableNameForSection(string $section = null)
  61      {
  62          return null;
  63      }
  64  
  65      /**
  66       * Returns the state column for the count items functions for the given section.
  67       *
  68       * @param   string  $section  The section
  69       *
  70       * @return  string|null
  71       *
  72       * @since   4.0.0
  73       */
  74      protected function getStateColumnForSection(string $section = null)
  75      {
  76          return 'state';
  77      }
  78  }


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