[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/MVC/Factory/ -> MVCFactoryServiceTrait.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\MVC\Factory;
  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 MVC factory service class.
  18   *
  19   * @since  4.0.0
  20   */
  21  trait MVCFactoryServiceTrait
  22  {
  23      /**
  24       * The MVC Factory.
  25       *
  26       * @var MVCFactoryInterface
  27       */
  28      private $mvcFactory;
  29  
  30      /**
  31       * Get the factory.
  32       *
  33       * @return  MVCFactoryInterface
  34       *
  35       * @since   4.0.0
  36       * @throws  \UnexpectedValueException May be thrown if the factory has not been set.
  37       */
  38      public function getMVCFactory(): MVCFactoryInterface
  39      {
  40          if (!$this->mvcFactory) {
  41              throw new \UnexpectedValueException('MVC factory not set in ' . __CLASS__);
  42          }
  43  
  44          return $this->mvcFactory;
  45      }
  46  
  47      /**
  48       * The MVC Factory.
  49       *
  50       * @param   MVCFactoryInterface  $mvcFactory  The factory
  51       *
  52       * @return  void
  53       *
  54       * @since  4.0.0
  55       */
  56      public function setMVCFactory(MVCFactoryInterface $mvcFactory)
  57      {
  58          $this->mvcFactory = $mvcFactory;
  59      }
  60  }


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