[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_contact/src/Helper/ -> AssociationHelper.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_contact
   6   *
   7   * @copyright   (C) 2013 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\Contact\Site\Helper;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\Language\Associations;
  15  use Joomla\Component\Categories\Administrator\Helper\CategoryAssociationHelper;
  16  
  17  // phpcs:disable PSR1.Files.SideEffects
  18  \defined('_JEXEC') or die;
  19  // phpcs:enable PSR1.Files.SideEffects
  20  
  21  /**
  22   * Contact Component Association Helper
  23   *
  24   * @since  3.0
  25   */
  26  abstract class AssociationHelper extends CategoryAssociationHelper
  27  {
  28      /**
  29       * Method to get the associations for a given item
  30       *
  31       * @param   integer  $id    Id of the item
  32       * @param   string   $view  Name of the view
  33       *
  34       * @return  array   Array of associations for the item
  35       *
  36       * @since  3.0
  37       */
  38      public static function getAssociations($id = 0, $view = null)
  39      {
  40          $jinput = Factory::getApplication()->input;
  41          $view   = $view ?? $jinput->get('view');
  42          $id     = empty($id) ? $jinput->getInt('id') : $id;
  43  
  44          if ($view === 'contact') {
  45              if ($id) {
  46                  $associations = Associations::getAssociations('com_contact', '#__contact_details', 'com_contact.item', $id);
  47  
  48                  $return = array();
  49  
  50                  foreach ($associations as $tag => $item) {
  51                      $return[$tag] = RouteHelper::getContactRoute($item->id, (int) $item->catid, $item->language);
  52                  }
  53  
  54                  return $return;
  55              }
  56          }
  57  
  58          if ($view === 'category' || $view === 'categories') {
  59              return self::getCategoryAssociations($id, 'com_contact');
  60          }
  61  
  62          return array();
  63      }
  64  }


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