X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fleague%2Fcontainer%2Fsrc%2FServiceProvider%2FServiceProviderAggregate.php;fp=vendor%2Fleague%2Fcontainer%2Fsrc%2FServiceProvider%2FServiceProviderAggregate.php;h=74e508b6d99c7a553e8ea4fca973f3775acd0822;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/league/container/src/ServiceProvider/ServiceProviderAggregate.php b/vendor/league/container/src/ServiceProvider/ServiceProviderAggregate.php new file mode 100644 index 000000000..74e508b6d --- /dev/null +++ b/vendor/league/container/src/ServiceProvider/ServiceProviderAggregate.php @@ -0,0 +1,88 @@ +setContainer($this->getContainer()); + } + + if ($provider instanceof BootableServiceProviderInterface) { + $provider->boot(); + } + + if ($provider instanceof ServiceProviderInterface) { + foreach ($provider->provides() as $service) { + $this->providers[$service] = $provider; + } + + return $this; + } + + throw new \InvalidArgumentException( + 'A service provider must be a fully qualified class name or instance ' . + 'of (\League\Container\ServiceProvider\ServiceProviderInterface)' + ); + } + + /** + * {@inheritdoc} + */ + public function provides($service) + { + return array_key_exists($service, $this->providers); + } + + /** + * {@inheritdoc} + */ + public function register($service) + { + if (! array_key_exists($service, $this->providers)) { + throw new \InvalidArgumentException( + sprintf('(%s) is not provided by a service provider', $service) + ); + } + + $provider = $this->providers[$service]; + $signature = get_class($provider); + + if ($provider instanceof SignatureServiceProviderInterface) { + $signature = $provider->getSignature(); + } + + // ensure that the provider hasn't already been invoked by any other service request + if (in_array($signature, $this->registered)) { + return; + } + + $provider->register(); + + $this->registered[] = $signature; + } +}