Exemplo n.º 1
0
 /**
  * @param string $path the working directory for filesystem operations
  *
  * @throws \InvalidArgumentException
  * @throws IOException
  */
 public function setWorkingDirectory($path)
 {
     $directory = preg_replace('#/+#', '/', $path);
     // remove multiple slashes
     try {
         $directory = $this->locator->locate($directory);
         if (false === is_string($directory)) {
             $directory = strval(reset($directory));
             $this->logger->alert(sprintf('Ambiguous filename %s, choosing %s', $path, $directory));
         }
     } catch (\InvalidArgumentException $exception) {
         // continue to check if dir exists even if locator doesn't locate
     }
     $exists = $this->filesystem->exists($directory);
     if (!$exists) {
         try {
             $this->filesystem->mkdir($directory);
             $this->logger->notice("Working directory created at " . $directory);
         } catch (IOException $exception) {
             $this->logger->error("An error occurred while creating directory at " . $exception->getPath(), $exception->getTrace());
             throw $exception;
         }
     }
     $this->directory = $directory;
 }
 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $this->bindParameters($container, $this->getAlias(), $config);
     // Fallback for missing intl extension
     $intlExtensionInstalled = extension_loaded('intl');
     $container->setParameter('lunetics_locale.intl_extension_installed', $intlExtensionInstalled);
     $iso3166 = array();
     $iso639one = array();
     $iso639two = array();
     $localeScript = array();
     if (!$intlExtensionInstalled) {
         $yamlParser = new YamlParser();
         $file = new FileLocator(__DIR__ . '/../Resources/config');
         $iso3166 = $yamlParser->parse(file_get_contents($file->locate('iso3166-1-alpha-2.yml')));
         $iso639one = $yamlParser->parse(file_get_contents($file->locate('iso639-1.yml')));
         $iso639two = $yamlParser->parse(file_get_contents($file->locate('iso639-2.yml')));
         $localeScript = $yamlParser->parse(file_get_contents($file->locate('locale_script.yml')));
     }
     $container->setParameter('lunetics_locale.intl_extension_fallback.iso3166', $iso3166);
     $mergedValues = array_merge($iso639one, $iso639two);
     $container->setParameter('lunetics_locale.intl_extension_fallback.iso639', $mergedValues);
     $container->setParameter('lunetics_locale.intl_extension_fallback.script', $localeScript);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('validator.xml');
     $loader->load('guessers.xml');
     $loader->load('services.xml');
     $loader->load('switcher.xml');
     $loader->load('form.xml');
     if (!$config['strict_match']) {
         $container->removeDefinition('lunetics_locale.best_locale_matcher');
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function execute(ImageInterface $image, $parameters)
 {
     $maskPath = isset($parameters['image']) ? $this->fileLocator->locate($parameters['image']) : null;
     if (!$maskPath) {
         return $image;
     }
     $originalWidth = $image->getSize()->getWidth();
     $originalHeight = $image->getSize()->getHeight();
     $top = isset($parameters['top']) ? $parameters['top'] : 0;
     $left = isset($parameters['left']) ? $parameters['left'] : 0;
     $width = isset($parameters['width']) ? $parameters['width'] : $originalWidth;
     $height = isset($parameters['height']) ? $parameters['height'] : $originalHeight;
     // imagine will error when mask is bigger then the given image
     // this could happen in forceRatio true mode so we need also scale the mask
     if ($width > $originalWidth) {
         $width = $originalWidth;
         $height = (int) ($height / $width * $originalWidth);
     }
     if ($height > $originalHeight) {
         $height = $originalHeight;
         $width = (int) ($width / $height * $originalHeight);
     }
     // create mask
     $mask = $this->createMask($maskPath, $width, $height);
     // add mask to image
     $image->paste($mask, new Point($top, $left));
     return $image;
 }
Exemplo n.º 4
0
 /** {@inheritdoc} */
 public function prepend(ContainerBuilder $container)
 {
     $configs = Yaml::parse($this->fileLocator->locate('redis.yml'));
     foreach ($configs as $name => $config) {
         $container->prependExtensionConfig($name, $config);
     }
 }
 public static function setUpBeforeClass()
 {
     $yamlParser = new YamlParser();
     $file = new FileLocator(__DIR__ . '/../../Resources/config');
     self::$iso3166 = $yamlParser->parse(file_get_contents($file->locate('iso3166-1-alpha-2.yml')));
     self::$iso639 = array_merge($yamlParser->parse(file_get_contents($file->locate('iso639-1.yml'))), $yamlParser->parse(file_get_contents($file->locate('iso639-2.yml'))));
     self::$script = $yamlParser->parse(file_get_contents($file->locate('locale_script.yml')));
 }
 /**
  * Validates the received data with the given json schema
  *
  * @param Schema $annotation
  * @param array $data
  *
  * @throws JsonSchemaException
  */
 public function validate(Schema $annotation, $data)
 {
     $schemaUrl = $this->fileLocator->locate($annotation->getPathToSchema());
     $schema = json_decode(file_get_contents($schemaUrl));
     $data = json_decode(json_encode($data));
     if (!$this->validator->isValid($data, $schema)) {
         throw new JsonSchemaException($this->validator->getErrors());
     }
 }
Exemplo n.º 7
0
 /**
  * Get configuration
  *
  * @return array
  */
 public function getConfiguration()
 {
     $configurationFiles = $this->locator->locate('config.yml', null, false);
     $configurations = [];
     foreach ($configurationFiles as $path) {
         $configurations[] = $this->loader->load($path);
     }
     return $this->processor->processConfiguration($this->configuration, $configurations);
 }
 /** {@inheritdoc} */
 public function prepend(ContainerBuilder $container)
 {
     if ($container->hasParameter('redis_dsn')) {
         $configs = Yaml::parse($this->fileLocator->locate('redis.yml'));
     } else {
         $configs = Yaml::parse($this->fileLocator->locate('redis_dummy.yml'));
     }
     foreach ($configs as $name => $config) {
         $container->prependExtensionConfig($name, $config);
     }
 }
Exemplo n.º 9
0
 public function fetchAction()
 {
     $em = $this->getDoctrine()->getEntityManager();
     // TODO move to a cron job
     // TODO move google credentials to symfony parameters file
     $configDirectories = array(__DIR__ . '/../Resources/config');
     $locator = new FileLocator($configDirectories);
     $clientSecret = $locator->locate('client_secret.json');
     $credentialsPath = $locator->locate('calendar-api-quickstart.json');
     // Get the API client and construct the service object.
     $client = new \Google_Client();
     $client->setApplicationName('Google Calendar API Quickstart');
     $client->setScopes(implode(' ', array(\Google_Service_Calendar::CALENDAR_READONLY)));
     $client->setAuthConfigFile($clientSecret);
     $client->setAccessType('offline');
     // Load previously authorized credentials from a file.
     if (file_exists($credentialsPath)) {
         $accessToken = file_get_contents($credentialsPath);
     } else {
         //TODO this should be accomplished with an error status
         return $this->render('TechlancasterWebBundle:Default:calendar.html.twig', array('message' => 'Invalid Credentials'));
     }
     $client->setAccessToken($accessToken);
     // Refresh the token if it's expired.
     if ($client->isAccessTokenExpired()) {
         $client->refreshToken($client->getRefreshToken());
         file_put_contents($credentialsPath, $client->getAccessToken());
     }
     $service = new \Google_Service_Calendar($client);
     $calendarId = '*****@*****.**';
     $optParams = array('maxResults' => 29, 'orderBy' => 'startTime', 'singleEvents' => true, 'timeMin' => date('c'));
     $results = $service->events->listEvents($calendarId, $optParams);
     $events = array();
     $connection = $em->getConnection();
     $platform = $connection->getDatabasePlatform();
     $connection->executeUpdate($platform->getTruncateTableSQL('event', false));
     /**
      * @var $googleEvent Google_Service_Calendar_Event
      */
     foreach ($results->getItems() as $googleEvent) {
         $event = new Event();
         $event->setId($googleEvent->getId());
         $event->setDescription($googleEvent->getDescription());
         $event->setLocation($googleEvent->getLocation());
         $event->setStart(new \DateTime($googleEvent->getStart()->dateTime));
         $event->setEnd(new \DateTime($googleEvent->getEnd()->dateTime));
         $event->setSummary($googleEvent->getSummary());
         $em->persist($event);
         $events[] = $event;
     }
     $em->flush();
     return $this->render('TechlancasterWebBundle:Default:calendar.html.twig', array('message' => json_encode($events)));
 }
Exemplo n.º 10
0
 /**
  * Returns the file path to an image file which represents the passed mimetype.
  *
  * @param string $mimetype The mimetype
  *
  * @return string A path to the mimetype icon
  */
 public function getMimetypeIcon($mimetype)
 {
     $file = str_replace('/', '-', $mimetype) . '.svg';
     $iconDirectory = $this->container->getParameter('partkeepr.directories.mimetype_icons');
     $fileLocator = new FileLocator($iconDirectory);
     try {
         $iconFile = $fileLocator->locate($file);
     } catch (\InvalidArgumentException $e) {
         $file = 'empty.svg';
         $iconFile = $fileLocator->locate($file);
     }
     return $iconFile;
 }
 public function setUp()
 {
     $kernel = static::createKernel();
     $kernel->boot();
     if ($kernel->getContainer()->getParameter('database_driver') == 'pdo_sqlite') {
         $this->markTestSkipped("The SQLite does not support joins.");
     }
     $this->em = $kernel->getContainer()->get('knp_bundles.entity_manager');
     $fileLocator = new FileLocator(__DIR__ . '/fixtures/');
     $path = $fileLocator->locate('trending-bundles.yml');
     $data = Yaml::parse($path);
     $developer = new Developer();
     $developer->setName('someName');
     $developer->setScore(0);
     $this->em->persist($developer);
     foreach ($data['bundles'] as $bundleName => $bundleData) {
         $bundle = new Bundle('vendor/' . $bundleName);
         $bundle->setDescription('some description');
         $bundle->setScore(100);
         $bundle->setOwner($developer);
         foreach ($bundleData['scores'] as $scoreData) {
             $bundle->setDescription(md5(time() . serialize($scoreData)));
             $score = new Score();
             $score->setDate(new \DateTime($scoreData['date']));
             $score->setBundle($bundle);
             $score->setValue($scoreData['value']);
             $this->em->persist($score);
         }
         $this->em->persist($bundle);
     }
     $this->em->flush();
 }
Exemplo n.º 12
0
 /**
  * Initialize the service container (and extensions), and load the config file
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @throws \Exception if user-provided configuration file causes an error
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $root = $input->getArgument('root');
     // Setup container
     $containerBuilder = new ContainerBuilder();
     $extension = new BrancherExtension();
     $containerBuilder->registerExtension($extension);
     $containerBuilder->addCompilerPass(new ExtensionCompilerPass());
     $containerBuilder->addCompilerPass(new RegisterListenersPass('event_dispatcher', 'brancher.event_listener', 'brancher.event_subscriber'));
     // Try and load config file
     $locator = new FileLocator([getcwd(), $input->getArgument('root'), __DIR__ . '/../']);
     /** @var \Symfony\Component\DependencyInjection\Loader\FileLoader $loader */
     $loader = new DelegatingLoader(new LoaderResolver([new YamlFileLoader($containerBuilder, $locator), new XmlFileLoader($containerBuilder, $locator), new PhpFileLoader($containerBuilder, $locator), new IniFileLoader($containerBuilder, $locator)]));
     $config = null;
     try {
         $config = $locator->locate($input->getOption('config'));
         $loader->load($input->getOption('config'));
     } catch (\Exception $ex) {
         // Only rethrow if the issue was with the user-provided value
         if ($input->getOption('config') !== '_config.yml') {
             throw $ex;
         }
     }
     // Add in final config from command line options
     $containerBuilder->setParameter('castlepointanime.brancher.build.config', $config);
     $containerBuilder->loadFromExtension($extension->getAlias(), ['build' => array_filter(['config' => dirname($config) ?: $root, 'root' => $root, 'special' => $input->getOption('special'), 'output' => $input->getArgument('output'), 'templates' => array_filter(array_map('realpath', $input->getOption('template-dir')), 'is_dir'), 'data' => $input->getOption('data-dir'), 'exclude' => $input->getOption('exclude')])]);
     $containerBuilder->compile();
     $this->setContainer($containerBuilder);
 }
Exemplo n.º 13
0
 /**
  * Returns a full path for a given template
  *
  * @param mixed       $name
  * @param string|null $dir
  * @param bool        $first
  *
  * @return array|string
  */
 public function locate($name, $dir = null, $first = true)
 {
     if ('@' === $name[0]) {
         return $this->themeManager->locateTemplate($name);
     }
     return parent::locate($name, $dir, $first);
 }
Exemplo n.º 14
0
    /**
     * 
     * @param string $configDirectories
     * @param string $configFiles
     * @param string $cachePath
     * @param bool $debug
     */
    public function __construct($configDirectories, $configFiles, $cachePath, $debug = false)
    {
        $this->configDirectories = (array) $configDirectories;
        $this->configFiles = (array) $configFiles;
        $this->cachePath = $cachePath . '/faker_config.php';
        $configCache = new ConfigCache($this->cachePath, $debug);
        if (!$configCache->isFresh()) {
            $locator = new FileLocator($this->configDirectories);
            $loaderResolver = new LoaderResolver([new YamlLoader($locator)]);
            $delegatingLoader = new DelegatingLoader($loaderResolver);
            $resources = [];
            $config = [];
            foreach ($this->configFiles as $configFile) {
                $path = $locator->locate($configFile);
                $config = array_merge($config, $delegatingLoader->load($path));
                $resources[] = new FileResource($path);
            }
            $exportConfig = var_export($this->parseRawConfig(isset($config['faker']) ? $config['faker'] : []), true);
            $code = <<<PHP
<?php
return {$exportConfig};
PHP;
            $configCache->write($code, $resources);
        }
        if (file_exists($this->cachePath)) {
            $this->config = (include $this->cachePath);
        }
    }
Exemplo n.º 15
0
 /**
  * Loads the configuration file data.
  */
 public function load($workingDir)
 {
     $locator = new FileLocator($this->getPotentialDirectories($workingDir));
     $loader = new YamlLoader($locator);
     // Config validation.
     $processor = new Processor();
     $schema = new BuddySchema();
     $files = $locator->locate(static::FILENAME, NULL, FALSE);
     foreach ($files as $file) {
         // After loading the raw data from the yaml file, we validate given
         // configuration.
         $raw = $loader->load($file);
         $conf = $processor->processConfiguration($schema, array('buddy' => $raw));
         if (isset($conf['commands'])) {
             foreach ($conf['commands'] as $command => $specs) {
                 if (!isset($this->commands[$command])) {
                     $this->commands[$command] = array('options' => $specs, 'file' => $file);
                 }
             }
         }
         // In the case 'root' is set, we do not process any parent buddy files.
         if (!empty($values['root'])) {
             break;
         }
     }
     return $this;
 }
 public function __construct($configFile)
 {
     $locator = new FileLocator(array(dirname($configFile)));
     $loader = new YamlLoader($locator);
     $processor = new Processor();
     $this->configuration = $processor->processConfiguration(new Definition(), $loader->load($locator->locate(basename($configFile))));
 }
Exemplo n.º 17
0
 protected function setConnection()
 {
     $fileLocator = new FileLocator(getcwd());
     $configFile = $fileLocator->locate('rentgen.yml');
     $config = Yaml::parse($configFile);
     $this->connection = new Connection(new ConnectionConfig($config['connection']));
 }
 /**
  * @expectedException \Symfony\Component\Yaml\Exception\ParseException
  */
 public function testInvalid()
 {
     $configDirectories = array(FIXTURES_PATH);
     $locator = new FileLocator($configDirectories);
     $YamlLoader = new YamlLoader($locator);
     $YamlLoader->load($locator->locate('invalid.yml'));
 }
 /**
  * @param string $file
  * @return array
  */
 public function loadConfig($file = self::DEFAULT_CONFIG)
 {
     $configDirectories = ['./'];
     $locator = new FileLocator($configDirectories);
     $file = $locator->locate($file);
     return json_decode(file_get_contents($file), true);
 }
 /**
  * @return DatabaseBackupStrategyModel[]
  */
 public function collectDatabasesStrategies()
 {
     $fileLocator = new FileLocator(__DIR__ . '/../../../app/config');
     try {
         $fileStrategies = $fileLocator->locate('strategies.yml');
     } catch (InvalidArgumentException $ex) {
         /* No strategies file detected? No strategies then. :=) */
         return [];
     }
     $strategies = file_get_contents($fileStrategies);
     $config = Yaml::parse($strategies);
     $config = $config['easy_backups'];
     $processor = new Processor();
     $configuration = new DatabaseStrategyConfiguration();
     $validatedConfig = $processor->processConfiguration($configuration, [$config]);
     $strategies = [];
     if (isset($validatedConfig['strategies'])) {
         foreach ($validatedConfig['strategies'] as $strategyConfig) {
             $strategy = new DatabaseBackupStrategyModel($strategyConfig['identifier'], $strategyConfig['compressor_strategy'], $strategyConfig['saver_strategy'], $strategyConfig['dump_settings']['type'], new DatabaseSettings($strategyConfig['dump_settings']['options']['host'], $strategyConfig['dump_settings']['options']['user'], $strategyConfig['dump_settings']['options']['pass'], $strategyConfig['dump_settings']['options']['name'], $strategyConfig['dump_settings']['options']['port'], $strategyConfig['dump_settings']['options']['ignore_tables'], $strategyConfig['dump_settings']['options']['one_dump_per_table']));
             $strategy->setDescription($strategyConfig['description']);
             $strategies[] = $strategy;
         }
     }
     return $strategies;
 }
Exemplo n.º 21
0
 /**
  * {@inheritDoc}
  */
 public function getStructureMetadata($type, $structureType = null)
 {
     $cacheKey = $type . $structureType;
     if (isset($this->cache[$cacheKey])) {
         return $this->cache[$cacheKey];
     }
     $this->assertExists($type);
     if (!$structureType) {
         $structureType = $this->getDefaultStructureType($type);
     }
     if (!is_string($structureType)) {
         throw new \InvalidArgumentException(sprintf('Expected string for structureType, got: %s', is_object($structureType) ? get_class($structureType) : gettype($structureType)));
     }
     $cachePath = sprintf('%s/%s%s', $this->cachePath, Inflector::camelize($type), Inflector::camelize($structureType));
     $cache = new ConfigCache($cachePath, $this->debug);
     if ($this->debug || !$cache->isFresh()) {
         $paths = $this->getPaths($type);
         // reverse paths, so that the last path overrides previous ones
         $fileLocator = new FileLocator(array_reverse($paths));
         try {
             $filePath = $fileLocator->locate(sprintf('%s.xml', $structureType));
         } catch (\InvalidArgumentException $e) {
             throw new Exception\StructureTypeNotFoundException(sprintf('Could not load structure type "%s" for document type "%s", looked in "%s"', $structureType, $type, implode('", "', $paths)), null, $e);
         }
         $metadata = $this->loader->load($filePath, $type);
         $resources = [new FileResource($filePath)];
         $cache->write(sprintf('<?php $metadata = \'%s\';', serialize($metadata)), $resources);
     }
     require $cachePath;
     $structure = unserialize($metadata);
     $this->cache[$cacheKey] = $structure;
     return $structure;
 }
Exemplo n.º 22
0
 /**
  * {@inheritdoc}
  */
 public function locate($file, $currentPath = null, $first = true)
 {
     if ('@' === $file[0]) {
         return $this->kernel->locateResource($file, $this->path, $first);
     }
     return parent::locate($file, $currentPath, $first);
 }
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testFileNotFound()
 {
     $configDirectories = array(FIXTURES_PATH);
     $locator = new FileLocator($configDirectories);
     $PhpLoader = new PhpLoader($locator);
     $PhpLoader->load($locator->locate('notFound.php'));
 }
Exemplo n.º 24
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.StaticAccess)
  */
 public function load()
 {
     $locator = new FileLocator($this->paths);
     $configFile = $locator->locate('pgca.yml');
     $fileContents = Yaml::parse(file_get_contents($configFile), true);
     $this->config = new Data($fileContents);
 }
 /**
  * @return array
  */
 private static function getParameters()
 {
     $locator = new FileLocator(__DIR__ . '/../../../../');
     $configLoc = $locator->locate('config.yml');
     $config = Yaml::parse($configLoc);
     return $config['parameters'];
 }
Exemplo n.º 26
0
 /**
  * Loads the config
  */
 private function loadConfig()
 {
     $directories = [BASE_DIR . '/config', '/etc/blackhole-bot/'];
     $locator = new FileLocator($directories);
     $loader = new YamlConfigLoader($locator);
     $this->container->set('config', (new Processor())->processConfiguration($this, $loader->load($locator->locate('blackhole.yml'))));
 }
Exemplo n.º 27
0
 public function load(array $configs, ContainerBuilder $container)
 {
     foreach ($configs as $config) {
         if ($this->isConnectionConfig($config)) {
             $connectionConfig = $config;
         }
     }
     if ($container->hasParameter('connection_config')) {
         $connectionConfig = $container->getParameter('connection_config');
     }
     $this->defineParameters($container);
     $definition = new Definition('Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher');
     $definition->setArguments(array(new Reference('service_container')));
     $container->setDefinition('event_dispatcher', $definition);
     $definition = new Definition('Rentgen\\Schema\\Manipulation');
     $definition->setArguments(array(new Reference('service_container')));
     $container->setDefinition('rentgen.schema.manipulation', $definition);
     $definition = new Definition('Rentgen\\Schema\\Info');
     $definition->setArguments(array(new Reference('service_container')));
     $container->setDefinition('rentgen.schema.info', $definition);
     if (!isset($connectionConfig)) {
         $fileLocator = new FileLocator(getcwd());
         try {
             $configFile = $fileLocator->locate('rentgen.yml');
             $content = file_get_contents('rentgen.yml');
             $config = Yaml::parse($content);
             $connectionConfig = $config;
         } catch (\InvalidArgumentException $e) {
             $connectionConfig['environments']['dev'] = array('adapter' => 'pgsql', 'host' => 'localhost', 'database' => null, 'username' => 'postgres', 'password' => '', 'port' => 5432);
         }
     }
     $definition = new Definition('Rentgen\\Database\\Connection\\ConnectionConfig');
     $definition->setArguments(array($connectionConfig['environments']));
     $container->setDefinition('connection_config', $definition);
     $definition = new Definition('Rentgen\\Database\\Connection\\Connection');
     $definition->setArguments(array(new Reference('connection_config')));
     $container->setDefinition('connection', $definition);
     $this->connection = $container->getDefinition('connection');
     $this->eventDispatcher = $container->getDefinition('event_dispatcher');
     $this->setDefinition('rentgen.create_table', 'rentgen.command.manipulation.create_table.class', $container);
     $this->setDefinition('rentgen.drop_table', 'rentgen.command.manipulation.drop_table.class', $container);
     $this->setDefinition('rentgen.add_column', 'rentgen.command.manipulation.add_column.class', $container);
     $this->setDefinition('rentgen.drop_column', 'rentgen.command.manipulation.drop_column.class', $container);
     $this->setDefinition('rentgen.add_constraint', 'rentgen.command.manipulation.add_constraint.class', $container);
     $this->setDefinition('rentgen.drop_constraint', 'rentgen.command.manipulation.drop_constraint.class', $container);
     $this->setDefinition('rentgen.create_index', 'rentgen.command.manipulation.create_index.class', $container);
     $this->setDefinition('rentgen.create_schema', 'rentgen.command.manipulation.create_schema.class', $container);
     $this->setDefinition('rentgen.drop_schema', 'rentgen.command.manipulation.drop_schema.class', $container);
     $this->setDefinition('rentgen.drop_index', 'rentgen.command.manipulation.drop_index.class', $container);
     $this->setDefinition('rentgen.table_exists', 'rentgen.command.info.table_exists.class', $container);
     $this->setDefinition('rentgen.get_table', 'rentgen.command.info.get_table.class', $container);
     $this->setDefinition('rentgen.get_tables', 'rentgen.command.info.get_tables.class', $container);
     $this->setDefinition('rentgen.get_schemas', 'rentgen.command.info.get_schemas.class', $container);
     $this->setDefinition('rentgen.schema_exists', 'rentgen.command.info.schema_exists.class', $container);
     $definition = new Definition($container->getParameter('rentgen.command.manipulation.clear_database.class'), array(new Reference('rentgen.get_schemas')));
     $definition->addMethodCall('setConnection', array(new Reference('connection')));
     $definition->addMethodCall('setEventDispatcher', array(new Reference('event_dispatcher')));
     $container->setDefinition('rentgen.clear_database', $definition);
 }
Exemplo n.º 28
0
 private static function prepareConfig()
 {
     $configDirectories = array(dirname(__FILE__) . '/../../config');
     $locator = new FileLocator($configDirectories);
     $loaderResolver = new LoaderResolver(array(new \App\ConfigLoader($locator)));
     $ymlConfig = $locator->locate(dirname(__FILE__) . '/../../config/config.yml', null, false);
     return $loaderResolver->resolve($ymlConfig)->load($ymlConfig);
 }
Exemplo n.º 29
0
function getConfig($yml)
{
    $m = new FileLocator(PATH_CONFIG);
    $yaml = new Parser();
    $file = $m->locate($yml);
    $parameters = $yaml->parse(file_get_contents($file));
    return $parameters;
}
Exemplo n.º 30
0
 /**
  * Constructor
  *
  * @param string $configFileName
  * @param array  $configDirectories
  */
 public function __construct($configFileName, array $configDirectories = array('.'))
 {
     $this->configFileName = $configFileName;
     $this->configDirectories = $configDirectories;
     $locator = new FileLocator($this->configDirectories);
     $this->configFilePath = $locator->locate($this->configFileName);
     $this->parseAndValidateConfig();
 }