/** * Load and override services into container; the load order is from the most global to the most specific * depends on context and environment. */ private function loadApplicationServices() { // setting default services $this->container->set('bbapp', $this->application); $this->container->set('container.builder', $this); $services_directory = $this->application->getBBDir() . '/Config/services'; foreach (scandir($services_directory) as $file) { if (1 === preg_match('#(\\w+)\\.(yml|xml)$#', $file, $matches)) { if ('yml' === $matches[2]) { ServiceLoader::loadServicesFromYamlFile($this->container, $services_directory, $matches[1]); } else { ServiceLoader::loadServicesFromXmlFile($this->container, $services_directory, $matches[1]); } } } // define in which directory we have to looking for services yml or xml $directories = ConfigDirectory::getDirectories(null, $this->repository_directory, $this->context, $this->environment); // Loop into every directory where we can potentially found a services.yml or services.xml foreach ($directories as $directory) { if (true === is_readable($directory . DIRECTORY_SEPARATOR . self::SERVICE_FILENAME . '.yml')) { ServiceLoader::loadServicesFromYamlFile($this->container, $directory); } if (true === is_readable($directory . DIRECTORY_SEPARATOR . self::SERVICE_FILENAME . '.xml')) { ServiceLoader::loadServicesFromXmlFile($this->container, $directory); } } $this->loadLoggerDefinition(); }
/** * @covers ::supports */ public function test_supports() { //Symfony\Component\Serializer\Encoder\EncoderInterface //Symfony\Component\Serializer\Encoder\DecoderInterface $container = new \BackBee\DependencyInjection\Container(); $jsonEncoderId = 'unit_test.json_encoder'; $container->set($jsonEncoderId, new \Symfony\Component\Serializer\Encoder\JsonEncoder()); $provider = new ContainerEncoderProvider(['json' => $jsonEncoderId]); $provider->setContainer($container); $this->assertTrue($provider->supports('json')); $this->assertFalse($provider->supports('xml')); }