You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

3 years ago
  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. use Symfony\Contracts\Service\ResetInterface;
  12. /**
  13. * Resets provided services.
  14. *
  15. * @author Alexander M. Turek <me@derrabus.de>
  16. * @author Nicolas Grekas <p@tchwork.com>
  17. *
  18. * @internal
  19. */
  20. class ServicesResetter implements ResetInterface
  21. {
  22. private $resettableServices;
  23. private $resetMethods;
  24. public function __construct(\Traversable $resettableServices, array $resetMethods)
  25. {
  26. $this->resettableServices = $resettableServices;
  27. $this->resetMethods = $resetMethods;
  28. }
  29. public function reset()
  30. {
  31. foreach ($this->resettableServices as $id => $service) {
  32. foreach ((array) $this->resetMethods[$id] as $resetMethod) {
  33. $service->$resetMethod();
  34. }
  35. }
  36. }
  37. }