[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Service/Provider/ -> Form.php (source)

   1  <?php
   2  
   3  /**
   4   * Joomla! Content Management System
   5   *
   6   * @copyright  (C) 2017 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\Service\Provider;
  11  
  12  use Joomla\CMS\Form\FormFactory;
  13  use Joomla\CMS\Form\FormFactoryInterface;
  14  use Joomla\Database\DatabaseInterface;
  15  use Joomla\DI\Container;
  16  use Joomla\DI\ServiceProviderInterface;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('JPATH_PLATFORM') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Service provider for the form dependency
  24   *
  25   * @since  4.0.0
  26   */
  27  class Form implements ServiceProviderInterface
  28  {
  29      /**
  30       * Registers the service provider with a DI container.
  31       *
  32       * @param   Container  $container  The DI container.
  33       *
  34       * @return  void
  35       *
  36       * @since   4.0.0
  37       */
  38      public function register(Container $container)
  39      {
  40          $container->alias('form.factory', FormFactoryInterface::class)
  41              ->alias(FormFactory::class, FormFactoryInterface::class)
  42              ->share(
  43                  FormFactoryInterface::class,
  44                  function (Container $container) {
  45                      $factory = new FormFactory();
  46                      $factory->setDatabase($container->get(DatabaseInterface::class));
  47  
  48                      return $factory;
  49                  },
  50                  true
  51              );
  52      }
  53  }


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