[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/HTML/ -> HTMLRegistryAwareTrait.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   7   * @license    GNU General Public License version 2 or later; see LICENSE.txt
   8   */
   9  
  10  namespace Joomla\CMS\HTML;
  11  
  12  // phpcs:disable PSR1.Files.SideEffects
  13  \defined('_JEXEC') or die;
  14  // phpcs:enable PSR1.Files.SideEffects
  15  
  16  /**
  17   * Defines the trait for a HTML Registry aware class.
  18   *
  19   * @since  4.0.0
  20   */
  21  trait HTMLRegistryAwareTrait
  22  {
  23      /**
  24       * The registry
  25       *
  26       * @var    Registry
  27       * @since  4.0.0
  28       */
  29      private $registry;
  30  
  31      /**
  32       * Get the registry.
  33       *
  34       * @return  Registry
  35       *
  36       * @since   4.0.0
  37       * @throws  \UnexpectedValueException May be thrown if the registry has not been set.
  38       */
  39      public function getRegistry()
  40      {
  41          if ($this->registry) {
  42              return $this->registry;
  43          }
  44  
  45          throw new \UnexpectedValueException('HTML registry not set in ' . __CLASS__);
  46      }
  47  
  48      /**
  49       * Set the registry to use.
  50       *
  51       * @param   Registry  $registry  The registry
  52       *
  53       * @return  void
  54       *
  55       * @since   4.0.0
  56       */
  57      public function setRegistry(Registry $registry = null)
  58      {
  59          $this->registry = $registry;
  60      }
  61  }


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