暂无描述

ServicesResetter.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. }