[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/di/ -> service_collection.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\di;
  15  
  16  use Symfony\Component\DependencyInjection\ContainerInterface;
  17  
  18  /**
  19  * Collection of services to be configured at container compile time.
  20  */
  21  class service_collection extends \ArrayObject
  22  {
  23      /**
  24      * @var \Symfony\Component\DependencyInjection\ContainerInterface
  25      */
  26      protected $container;
  27  
  28      /**
  29      * @var array
  30      */
  31      protected $service_classes;
  32  
  33      /**
  34      * Constructor
  35      *
  36      * @param ContainerInterface $container Container object
  37      */
  38  	public function __construct(ContainerInterface $container)
  39      {
  40          $this->container = $container;
  41          $this->service_classes = array();
  42      }
  43  
  44      /**
  45      * {@inheritdoc}
  46      */
  47  	public function getIterator()
  48      {
  49          return new service_collection_iterator($this);
  50      }
  51  
  52      // Because of a PHP issue we have to redefine offsetExists
  53      // (even with a call to the parent):
  54      //         https://bugs.php.net/bug.php?id=66834
  55      //         https://bugs.php.net/bug.php?id=67067
  56      // But it triggers a sniffer issue that we have to skip
  57      // @codingStandardsIgnoreStart
  58      /**
  59      * {@inheritdoc}
  60      */
  61  	public function offsetExists($index)
  62      {
  63          return parent::offsetExists($index);
  64      }
  65      // @codingStandardsIgnoreEnd
  66  
  67      /**
  68      * {@inheritdoc}
  69      */
  70  	public function offsetGet($index)
  71      {
  72          return $this->container->get($index);
  73      }
  74  
  75      /**
  76      * Add a service to the collection
  77      *
  78      * @param string $name The service name
  79      * @return null
  80      */
  81  	public function add($name)
  82      {
  83          $this->offsetSet($name, null);
  84      }
  85  
  86      /**
  87      * Add a service's class to the collection
  88      *
  89      * @param string    $service_id
  90      * @param string    $class
  91      */
  92  	public function add_service_class($service_id, $class)
  93      {
  94          $this->service_classes[$service_id] = $class;
  95      }
  96  
  97      /**
  98      * Get services' classes
  99      *
 100      * @return array
 101      */
 102  	public function get_service_classes()
 103      {
 104          return $this->service_classes;
 105      }
 106  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1