[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Form/ -> FormFactoryAwareTrait.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\Form;
  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 FormFactoryInterface Aware Class.
  18   *
  19   * @since  4.0.0
  20   */
  21  trait FormFactoryAwareTrait
  22  {
  23      /**
  24       * FormFactoryInterface
  25       *
  26       * @var    FormFactoryInterface
  27       * @since  4.0.0
  28       */
  29      private $formFactory;
  30  
  31      /**
  32       * Get the FormFactoryInterface.
  33       *
  34       * @return  FormFactoryInterface
  35       *
  36       * @since   4.0.0
  37       * @throws  \UnexpectedValueException May be thrown if the FormFactory has not been set.
  38       */
  39      public function getFormFactory(): FormFactoryInterface
  40      {
  41          if ($this->formFactory) {
  42              return $this->formFactory;
  43          }
  44  
  45          throw new \UnexpectedValueException('FormFactory not set in ' . __CLASS__);
  46      }
  47  
  48      /**
  49       * Set the form factory to use.
  50       *
  51       * @param   FormFactoryInterface  $formFactory  The form factory to use.
  52       *
  53       * @return  $this
  54       *
  55       * @since   4.0.0
  56       */
  57      public function setFormFactory(FormFactoryInterface $formFactory = null)
  58      {
  59          $this->formFactory = $formFactory;
  60  
  61          return $this;
  62      }
  63  }


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