/** * @return ServiceManager * * @throws MissingOptionException if the serviceManager option was not passed */ public function getServiceManager() { if (is_string($this->serviceManager)) { $this->serviceManager = $this->app->container->get(ServiceManager::getServiceName($this->serviceManager)); } return $this->serviceManager; }
/** * Tests that tagged services can be retrieved */ public function testThatTaggedServicesCanBeRetrieved() { $serviceConfig = ['services' => ['testServiceOne' => ['class' => 'CubicMushroom\\Slim\\ServiceManager\\TestService', 'tags' => [['tag1'], ['tag2', ['argument']], ['tag2', ['another_argument']]]], 'testServiceTwo' => ['class' => 'CubicMushroom\\Slim\\ServiceManager\\TestService', 'tags' => [['tag1'], ['tag3', ['@testService', 123]]]], 'testServiceThree' => ['class' => 'CubicMushroom\\Slim\\ServiceManager\\TestService', 'tags' => [['tag2', ['argument']]]]]]; $app = new Slim($serviceConfig); $sc = new ServiceManager($app); $this->assertArrayHasKey('@testServiceOne', $sc->getTaggedServices('tag1')); $this->assertArrayHasKey('@testServiceTwo', $sc->getTaggedServices('tag1')); $this->assertArrayNotHasKey('@testServiceThree', $sc->getTaggedServices('tag1')); $this->assertArrayHasKey('@testServiceOne', $sc->getTaggedServices('tag2')); $this->assertArrayNotHasKey('@testServiceTwo', $sc->getTaggedServices('tag2')); $this->assertArrayHasKey('@testServiceThree', $sc->getTaggedServices('tag2')); $this->assertArrayNotHasKey('@testServiceOne', $sc->getTaggedServices('tag3')); $this->assertArrayHasKey('@testServiceTwo', $sc->getTaggedServices('tag3')); $this->assertArrayNotHasKey('@testServiceThree', $sc->getTaggedServices('tag3')); }