ServicesResetter.php 901B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel\DependencyInjection;
  11. /**
  12. * Resets provided services.
  13. *
  14. * @author Alexander M. Turek <me@derrabus.de>
  15. * @author Nicolas Grekas <p@tchwork.com>
  16. *
  17. * @internal
  18. */
  19. class ServicesResetter
  20. {
  21. private $resettableServices;
  22. private $resetMethods;
  23. public function __construct(\Traversable $resettableServices, array $resetMethods)
  24. {
  25. $this->resettableServices = $resettableServices;
  26. $this->resetMethods = $resetMethods;
  27. }
  28. public function reset()
  29. {
  30. foreach ($this->resettableServices as $id => $service) {
  31. $service->{$this->resetMethods[$id]}();
  32. }
  33. }
  34. }