vendor/pimcore/pimcore/lib/DependencyInjection/ServiceCollection.php line 50

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Pimcore
  5. *
  6. * This source file is available under two different licenses:
  7. * - GNU General Public License version 3 (GPLv3)
  8. * - Pimcore Commercial License (PCL)
  9. * Full copyright and license information is available in
  10. * LICENSE.md which is distributed with this source code.
  11. *
  12. * @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13. * @license http://www.pimcore.org/license GPLv3 and PCL
  14. */
  15. namespace Pimcore\DependencyInjection;
  16. use Psr\Container\ContainerInterface;
  17. /**
  18. * @internal
  19. */
  20. class ServiceCollection implements \IteratorAggregate
  21. {
  22. /**
  23. * @var ContainerInterface
  24. */
  25. private $container;
  26. /**
  27. * @var array
  28. */
  29. private $ids = [];
  30. /**
  31. * @param ContainerInterface $container
  32. * @param array $ids
  33. */
  34. public function __construct(ContainerInterface $container, array $ids)
  35. {
  36. $this->container = $container;
  37. $this->ids = $ids;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function getIterator()
  43. {
  44. foreach ($this->ids as $id) {
  45. yield $this->container->get($id);
  46. }
  47. }
  48. }