vendor/knplabs/knp-menu/src/Knp/Menu/Provider/ChainProvider.php line 22

Open in your IDE?
  1. <?php
  2. namespace Knp\Menu\Provider;
  3. use Knp\Menu\ItemInterface;
  4. class ChainProvider implements MenuProviderInterface
  5. {
  6.     /**
  7.      * @var iterable|MenuProviderInterface[]
  8.      */
  9.     private $providers;
  10.     /**
  11.      * @param MenuProviderInterface[]|iterable $providers
  12.      */
  13.     public function __construct($providers)
  14.     {
  15.         $this->providers $providers;
  16.     }
  17.     public function get(string $name, array $options = []): ItemInterface
  18.     {
  19.         foreach ($this->providers as $provider) {
  20.             if ($provider->has($name$options)) {
  21.                 return $provider->get($name$options);
  22.             }
  23.         }
  24.         throw new \InvalidArgumentException(\sprintf('The menu "%s" is not defined.'$name));
  25.     }
  26.     public function has(string $name, array $options = []): bool
  27.     {
  28.         foreach ($this->providers as $provider) {
  29.             if ($provider->has($name$options)) {
  30.                 return true;
  31.             }
  32.         }
  33.         return false;
  34.     }
  35. }