Автор: Mike van Riel (mike.vanriel@naenius.com)
Наследование: extends Pimple\Container
Пример #1
0
 public function register(Application $app)
 {
     $app['twig.options'] = array();
     $app['twig.form.templates'] = array('form_div_layout.html.twig');
     $app['twig.path'] = array();
     $app['twig.templates'] = array();
     $app['twig'] = $app->share(function ($app) {
         $app['twig.options'] = array_replace(array('charset' => "UTF-8", 'debug' => isset($app['debug']) ? $app['debug'] : false, 'strict_variables' => isset($app['debug']) ? $app['debug'] : false), $app['twig.options']);
         $twig = new \Twig_Environment($app['twig.loader'], $app['twig.options']);
         $twig->addGlobal('app', $app);
         $twig->addExtension(new TwigCoreExtension());
         if (isset($app['debug']) && $app['debug']) {
             $twig->addExtension(new \Twig_Extension_Debug());
         }
         return $twig;
     });
     $app['twig.loader.filesystem'] = $app->share(function ($app) {
         return new \Twig_Loader_Filesystem($app['twig.path']);
     });
     $app['twig.loader.array'] = $app->share(function ($app) {
         return new \Twig_Loader_Array($app['twig.templates']);
     });
     $app['twig.loader.string'] = $app->share(function ($app) {
         return new \Twig_Loader_String();
     });
     $app['twig.loader'] = $app->share(function ($app) {
         return new \Twig_Loader_Chain(array($app['twig.loader.filesystem'], $app['twig.loader.array'], $app['twig.loader.string']));
     });
 }
Пример #2
0
 /**
  * Method responsible for adding the commands for this application.
  *
  * @param Application $app
  *
  * @return void
  */
 protected function addCommands(Application $app)
 {
     $app->command(new Command\Manual\ToHtmlCommand(null, $app[self::TEMPLATE_FACTORY], $app[self::CONVERTER_FACTORY]));
     // FIXME: Disabled the ToLatex and ToPdf commands for now to prevent confusion of users.
     // $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToLatexCommand());
     // $this->command(new \phpDocumentor\Plugin\Scrybe\Command\Manual\ToPdfCommand());
 }
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['hipchat'] = $app->share(function () use($app) {
         if (empty($app['hipchat.rooms'])) {
             return new NullLogger();
         }
         $log = new TargetMappingLogger();
         $app['hipchat.configure']($log);
         return $log;
     });
     $app['hipchat.configure'] = $app->protect(function (TargetMappingLogger $log) use($app) {
         $roomConfigs = $app['hipchat.rooms'];
         $defaults = ['targets' => [], 'name' => 'HipChat', 'notify' => false, 'level' => Logger::INFO, 'bubble' => true, 'useSSL' => true, 'format' => 'text', 'host' => 'api.hipchat.com', 'version' => HipChatHandler::API_V2, 'guzzle' => false];
         if (isset($roomConfigs['_default'])) {
             $defaults = $roomConfigs['_default'] + $defaults;
             unset($roomConfigs['_default']);
         }
         foreach ($roomConfigs as $roomConfig) {
             $roomConfig += $defaults;
             $logger = new Logger('hcm');
             if (!isset($roomConfig['room']) || !isset($roomConfig['token'])) {
                 throw new InvalidArgumentException('missing room/token configuration');
             }
             if (isset($roomConfig['guzzle']) && is_array($roomConfig['guzzle'])) {
                 $logger->pushHandler(new GuzzleHipChatHandler(new Client('', $this->prepareGuzzleOptions($roomConfig['guzzle'])), $roomConfig['token'], $roomConfig['room'], $roomConfig['name'], $roomConfig['notify'], $roomConfig['level'], $roomConfig['bubble'], $roomConfig['useSSL'], $roomConfig['format'], $roomConfig['host'], $roomConfig['version']));
             } else {
                 $logger->pushHandler(new HipChatHandler($roomConfig['token'], $roomConfig['room'], $roomConfig['name'], $roomConfig['notify'], $roomConfig['level'], $roomConfig['bubble'], $roomConfig['useSSL'], $roomConfig['format'], $roomConfig['host'], $roomConfig['version']));
             }
             $log->addLogger($logger, $roomConfig['targets']);
         }
     });
 }
Пример #4
0
 /**
  * Test that register will throw an exception if an unknown
  * format is passed in
  *
  * @return void
  */
 public function testRegisterThrowsExceptionIfAnUnknownFormatIsPassed()
 {
     $this->setExpectedException('InvalidArgumentException', 'Unable to load configuration; the provided file extension was not recognized. Only yml or xml allowed');
     $app = new Application('Test');
     $app->register(new ConfigServiceProvider(), array('config.path' => __DIR__ . '/../../../data/config.unknownfiletype'));
     $config = $app['config'];
 }
Пример #5
0
 /**
  * Tests whether the register method applies the provided parameters to this
  * application and correctly registers the ServiceProvider.
  */
 public function testRegister()
 {
     $provider = new ServiceProviderMock();
     $this->fixture->register($provider, array('mock.param' => true));
     $this->assertTrue($this->fixture['mock.param']);
     $this->assertSame($this->fixture['mock'], $provider);
 }
 public function register(Application $app)
 {
     $app['bugsnag'] = $app->share(function () use($app) {
         $client = new \Bugsnag_Client($app['bugsnag.options']['apiKey']);
         set_error_handler(array($client, 'errorhandler'));
         set_exception_handler(array($client, 'exceptionhandler'));
         return $client;
     });
 }
Пример #7
0
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['video'] = $app->share(function () use($app) {
         return new VideoWrapper($app['monolog'], $app['db']);
     });
     $app['option'] = $app->share(function () use($app) {
         return new OptionWrapper($app['monolog'], $app['db']);
     });
 }
Пример #8
0
 /**
  * {@inheritDoc}
  */
 public function register(Application $app)
 {
     $prefix = $this->prefix;
     if (!isset($app["{$prefix}.client_options"])) {
         $app["{$prefix}.client_options"] = [];
     }
     $app["{$prefix}"] = $app->share(function () use($app, $prefix) {
         return new Client($app["{$prefix}.client_options"]);
     });
 }
Пример #9
0
 /**
  * Initialize
  */
 private function _initialize()
 {
     $wildcardPath = implode(DIRECTORY_SEPARATOR, [$this->app['config']->getProjectPath(), 'application/cli', '*Command.php']);
     foreach (new \GlobIterator($wildcardPath, \GlobIterator::CURRENT_AS_FILEINFO) as $fileInfo) {
         /** @var \SplFileInfo $fileInfo */
         if (preg_match('/^(?<command>[a-zA-Z]+Command).php$/', $fileInfo->getFilename(), $match)) {
             $command_namespace = $this->config['namespace'] . $match['command'];
             $this->app->command(new $command_namespace());
         }
     }
 }
Пример #10
0
 /**
  * Registers the translator using the currently active locale.
  *
  * @param Application $app
  */
 public function register(Application $app)
 {
     /** @var ApplicationConfiguration $config */
     $config = $app['config'];
     $app['translator.locale'] = $config->getTranslator()->getLocale();
     $app['translator'] = $app->share(function ($app) {
         $translator = new Translator();
         $translator->setLocale($app['translator.locale']);
         return $translator;
     });
 }
Пример #11
0
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     if (!isset($app['descriptor.builder'])) {
         throw new Exception\MissingDependencyException('The builder object that is used to construct the ProjectDescriptor is missing');
     }
     if (!isset($app['serializer'])) {
         throw new Exception\MissingDependencyException('The serializer object that is used to read the template configuration with is missing');
     }
     $templateDir = __DIR__ . '/../../../data/templates';
     // vendored installation
     if (file_exists(__DIR__ . '/../../../../templates')) {
         $templateDir = __DIR__ . '/../../../../templates';
     }
     // parameters
     $app['transformer.template.location'] = $templateDir;
     $app['linker.substitutions'] = array('phpDocumentor\\Descriptor\\ProjectDescriptor' => array('files'), 'phpDocumentor\\Descriptor\\FileDescriptor' => array('tags', 'classes', 'interfaces', 'traits'), 'phpDocumentor\\Descriptor\\ClassDescriptor' => array('tags', 'parent', 'interfaces', 'constants', 'properties', 'methods'), 'phpDocumentor\\Descriptor\\InterfaceDescriptor' => array('tags', 'parent', 'constants', 'methods'), 'phpDocumentor\\Descriptor\\TraitDescriptor' => array('tags', 'properties', 'methods'), 'phpDocumentor\\Descriptor\\MethodDescriptor' => array('tags', 'arguments'), 'phpDocumentor\\Descriptor\\ArgumentDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\PropertyDescriptor' => array('tags', 'types'), 'phpDocumentor\\Descriptor\\ConstantDescriptor' => array('tags', 'types'), 'phpDocumentor\\Descriptor\\Tag\\ParamDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\Tag\\ReturnDescriptor' => array('types'), 'phpDocumentor\\Descriptor\\Tag\\SeeDescriptor' => array('reference'));
     // services
     $app['compiler'] = $app->share(function ($container) {
         $compiler = new Compiler();
         $compiler->insert(new ElementsIndexBuilder(), ElementsIndexBuilder::COMPILER_PRIORITY);
         $compiler->insert(new PackageTreeBuilder(), PackageTreeBuilder::COMPILER_PRIORITY);
         $compiler->insert(new NamespaceTreeBuilder(), NamespaceTreeBuilder::COMPILER_PRIORITY);
         $compiler->insert($container['linker'], Linker::COMPILER_PRIORITY);
         $compiler->insert($container['transformer'], Transformer::COMPILER_PRIORITY);
         $compiler->insert(new Debug($container['monolog'], $container['descriptor.analyzer']), Debug::COMPILER_PRIORITY);
         return $compiler;
     });
     $app['linker'] = $app->share(function ($app) {
         return new Linker($app['linker.substitutions']);
     });
     $app['transformer.behaviour.collection'] = $app->share(function () {
         return new Behaviour\Collection();
     });
     $app['transformer.routing.queue'] = $app->share(function () {
         $queue = new Router\Queue();
         // TODO: load from app configuration instead of hardcoded
         $queue->insert(new Router\StandardRouter(), 10000);
         return $queue;
     });
     $app['transformer.writer.collection'] = $app->share(function ($container) {
         return new Writer\Collection($container['transformer.routing.queue']);
     });
     $app['transformer.template.collection'] = $app->share(function ($container) {
         return new Template\Collection($container['transformer.template.location'], $container['serializer']);
     });
     $app['transformer'] = $app->share(function ($container) {
         $transformer = new Transformer($container['transformer.template.collection'], $container['transformer.writer.collection']);
         $transformer->setBehaviours($container['transformer.behaviour.collection']);
         return $transformer;
     });
     $app->command(new TransformCommand($app['descriptor.builder'], $app['transformer'], $app['compiler']));
     $app->command(new ListCommand());
 }
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['validator'] = $app->share(function ($app) {
         return new Validator($app['validator.mapping.class_metadata_factory'], $app['validator.validator_factory'], isset($app['translator']) ? $app['translator'] : new DefaultTranslator());
     });
     $app['validator.mapping.class_metadata_factory'] = $app->share(function () {
         return new ClassMetadataFactory(new StaticMethodLoader());
     });
     $app['validator.validator_factory'] = $app->share(function () use($app) {
         $validators = isset($app['validator.validator_service_ids']) ? $app['validator.validator_service_ids'] : array();
         return new ConstraintValidatorFactory($app, $validators);
     });
 }
 public function register(Application $app)
 {
     $app['validator'] = $app->share(function () use($app) {
         return new Validator($app['validator.mapping.class_metadata_factory'], $app['validator.validator_factory']);
     });
     $app['validator.mapping.class_metadata_factory'] = $app->share(function () use($app) {
         return new ClassMetadataFactory(new StaticMethodLoader());
     });
     $app['validator.validator_factory'] = $app->share(function () {
         return new ConstraintValidatorFactory();
     });
     if (isset($app['validator.class_path'])) {
         $app['autoloader']->registerNamespace('Symfony\\Component\\Validator', $app['validator.class_path']);
     }
 }
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['client_factory'] = $app->protect(function ($platformId) use($app) {
         $config = $app['config'];
         if (!property_exists($config, $platformId)) {
             throw new RuntimeException("Couldn't find platform details for {$platformId}. Run the 'authorize' command first.");
         }
         $platformDetails = (array) $config->{$platformId};
         $client = new Client(['base_url' => $platformDetails['base_url'], 'defaults' => ['auth' => 'oauth', 'verify' => false, 'headers' => ['Accept' => 'application/json']]]);
         $platformDetails['callback'] = 'http://127.0.0.1:8000';
         $oauth = new Oauth1($platformDetails);
         $client->getEmitter()->attach($oauth);
         return $client;
     });
 }
Пример #15
0
 /**
  * Initializes all components used by phpDocumentor.
  */
 public function __construct()
 {
     ini_set('memory_limit', -1);
     self::$VERSION = file_get_contents(__DIR__ . '/../../VERSION');
     parent::__construct('phpDocumentor', self::$VERSION);
     $this->addAutoloader();
     $this->addConfiguration();
     $this->addLogging();
     $this->setTimezone();
     $this->addEventDispatcher();
     $this['console']->getHelperSet()->set(new ProgressHelper());
     $this['translator.locale'] = 'en';
     $this['translator'] = $this->share(function ($app) {
         $translator = new Translator();
         $translator->setLocale($app['translator.locale']);
         return $translator;
     });
     $this->addSerializer();
     $this->register(new ValidatorServiceProvider());
     $this->register(new Descriptor\ServiceProvider());
     $this->register(new Parser\ServiceProvider());
     $this->register(new Transformer\ServiceProvider());
     // TODO: make plugin service provider calls registrable from config
     $this->register(new Plugin\Core\ServiceProvider());
     $this->addCommandsForProjectNamespace();
 }
Пример #16
0
 /**
  * Initializes all components used by phpDocumentor.
  *
  * @param ClassLoader $autoloader
  * @param array       $values
  */
 public function __construct($autoloader = null, array $values = array())
 {
     $this->defineIniSettings();
     self::$VERSION = strpos('@package_version@', '@') === 0 ? trim(file_get_contents(__DIR__ . '/../../VERSION')) : '@package_version@';
     parent::__construct('phpDocumentor', self::$VERSION, $values);
     $this['kernel.timer.start'] = time();
     $this['kernel.stopwatch'] = function () {
         return new Stopwatch();
     };
     $this['autoloader'] = $autoloader;
     $this->register(new JmsSerializerServiceProvider());
     $this->register(new Configuration\ServiceProvider());
     $this->addEventDispatcher();
     $this->addLogging();
     $this->register(new ValidatorServiceProvider());
     $this->register(new Translator\ServiceProvider());
     $this->register(new Descriptor\ServiceProvider());
     $this->register(new Parser\ServiceProvider());
     $this->register(new Partials\ServiceProvider());
     $this->register(new Transformer\ServiceProvider());
     $this->register(new Plugin\ServiceProvider());
     $this->addCommandsForProjectNamespace();
     if (\Phar::running()) {
         $this->addCommandsForPharNamespace();
     }
 }
Пример #17
0
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  *
  * @throws Exception\MissingDependencyException if the Descriptor Builder is not present.
  *
  * @return void
  */
 public function register(Application $app)
 {
     if (!isset($app['descriptor.builder'])) {
         throw new Exception\MissingDependencyException('The builder object that is used to construct the ProjectDescriptor is missing');
     }
     $app['parser'] = $app->share(function () {
         return new Parser();
     });
     /** @var Translator $translator  */
     $translator = $app['translator'];
     $translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
     $app->command(new ParseCommand($app['descriptor.builder'], $app['parser'], $translator));
     /** @var Dispatcher $dispatcher  */
     $dispatcher = $app['event_dispatcher'];
     $dispatcher->addListener('reflection.docblock-extraction.post', array($this, 'validateDocBlocks'));
 }
 public function register(Application $app)
 {
     $this->app = $app;
     $app['config'] = $app->share(function () use($app) {
         $config = array();
         foreach ($app['config.paths'] as $path) {
             if (!file_exists($path)) {
                 continue;
             }
             $parser = new Yaml\Parser();
             $result = @file_get_contents($path);
             if ($result === FALSE) {
                 $result = $app['process']->executeSudoCommand("cat " . $path, true);
             }
             $config = array_replace_recursive($config, $parser->parse($result));
         }
         return $config;
     });
 }
Пример #19
0
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  *
  * @throws Exception\MissingDependencyException if the Descriptor Builder is not present.
  *
  * @return void
  */
 public function register(Application $app)
 {
     if (!isset($app['descriptor.builder'])) {
         throw new Exception\MissingDependencyException('The builder object that is used to construct the ProjectDescriptor is missing');
     }
     $app['parser'] = $app->share(function ($app) {
         $parser = new Parser();
         $parser->setStopwatch($app['kernel.stopwatch']);
         $parser->setLogger($app['monolog']);
         return $parser;
     });
     $app['markdown'] = $app->share(function () {
         return \Parsedown::instance();
     });
     /** @var Translator $translator  */
     $translator = $app['translator'];
     $translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
     $app['parser.files'] = new Collection();
     $app->command(new ParseCommand($app['descriptor.builder'], $app['parser'], $translator, $app['parser.files']));
 }
Пример #20
0
 /**
  * Initializes all components used by phpDocumentor.
  */
 function __construct()
 {
     parent::__construct('phpDocumentor', self::VERSION);
     $this->addAutoloader();
     $this->addLogging();
     $this->addConfiguration();
     $this->addEventDispatcher();
     $this->loadPlugins();
     $this['console']->getHelperSet()->set(new \phpDocumentor\Console\Helper\ProgressHelper());
     $this->addCommandsForProjectNamespace();
 }
Пример #21
0
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance.
  */
 public function register(Application $app)
 {
     /** @var Translator $translator  */
     $translator = $app['translator'];
     $translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
     /** @var Collection $writerCollection */
     $writerCollection = $app['transformer.writer.collection'];
     $writerCollection['FileIo'] = new Writer\FileIo();
     $writerCollection['checkstyle'] = new Writer\Checkstyle();
     $writerCollection['sourcecode'] = new Writer\Sourcecode();
     $writerCollection['statistics'] = new Writer\Statistics();
     $writerCollection['xml'] = new Writer\Xml($app['transformer.routing.standard']);
     $writerCollection['xsl'] = new Writer\Xsl($app['monolog']);
     $writerCollection['checkstyle']->setTranslator($translator);
     $writerCollection['xml']->setTranslator($translator);
     Xslt\Extension::$routers = $app['transformer.routing.queue'];
     Xslt\Extension::$descriptorBuilder = $app['descriptor.builder'];
     $app->register(new \phpDocumentor\Plugin\Graphs\ServiceProvider());
     $app->register(new \phpDocumentor\Plugin\Twig\ServiceProvider());
     $app->register(new \phpDocumentor\Plugin\Pdf\ServiceProvider());
 }
Пример #22
0
 public function register(Application $app)
 {
     $app['monolog'] = $app->share(function () use($app) {
         $log = new Logger(isset($app['monolog.name']) ? $app['monolog.name'] : 'myapp');
         $app['monolog.configure']($log);
         return $log;
     });
     $app['monolog.configure'] = $app->protect(function ($log) use($app) {
         $log->pushHandler($app['monolog.handler']);
     });
     $app['monolog.handler'] = function () use($app) {
         return new StreamHandler($app['monolog.logfile'], $app['monolog.level']);
     };
     if (!isset($app['monolog.level'])) {
         $app['monolog.level'] = function () {
             return Logger::DEBUG;
         };
     }
     if (isset($app['monolog.class_path'])) {
         $app['autoloader']->registerNamespace('Monolog', $app['monolog.class_path']);
     }
 }
Пример #23
0
 public function register(Application $app)
 {
     /** @var ApplicationConfiguration $config */
     $config = $app['config'];
     $plugins = $config->getPlugins();
     if (!$plugins) {
         $app->register(new Core\ServiceProvider());
         $app->register(new Scrybe\ServiceProvider());
         return;
     }
     array_walk($plugins, function ($plugin) use($app) {
         /** @var Plugin $plugin */
         $provider = strpos($plugin->getClassName(), '\\') === false ? sprintf('phpDocumentor\\Plugin\\%s\\ServiceProvider', $plugin->getClassName()) : $plugin->getClassName();
         if (!class_exists($provider)) {
             throw new \RuntimeException('Loading Service Provider for ' . $provider . ' failed.');
         }
         try {
             $app->register(new $provider($plugin));
         } catch (\InvalidArgumentException $e) {
             throw new \RuntimeException($e->getMessage());
         }
     });
 }
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $vendorPath = isset($app['composer.vendor_path']) ? $app['composer.vendor_path'] : __DIR__ . '/../../../vendor';
     $serializerPath = $vendorPath . '/jms/serializer/src';
     if (!file_exists($serializerPath)) {
         $serializerPath = __DIR__ . '/../../../../../jms/serializer/src';
     }
     $app['serializer.annotations'] = array(array('namespace' => 'JMS\\Serializer\\Annotation', 'path' => $serializerPath));
     $app['serializer'] = $app->share(function ($container) {
         if (!isset($container['serializer.annotations']) || !is_array($container['serializer.annotations'])) {
             throw new \RuntimeException('Expected the container to have an array called "serializer.annotations" that describes which ' . 'annotations are supported by the Serializer and where it can find them');
         }
         foreach ($container['serializer.annotations'] as $annotationsDefinition) {
             if (!isset($annotationsDefinition['namespace'])) {
                 throw new \UnexpectedValueException('The annotation definition for the Serializer should have a key "namespace" that tells the ' . 'serializer what the namespace for the provided annotations are.');
             }
             if (!isset($annotationsDefinition['path'])) {
                 throw new \UnexpectedValueException('The annotation definition for the Serializer should have a key "path" that tells the ' . 'serializer where it can find the provided annotations.');
             }
             AnnotationRegistry::registerAutoloadNamespace($annotationsDefinition['namespace'], $annotationsDefinition['path']);
         }
         return SerializerBuilder::create()->build();
     });
 }
 public function register(Application $app)
 {
     $app['translator'] = $app->share(function ($app) {
         $translator = new Translator('en', $app['translator.message_selector']);
         // Handle deprecated 'locale_fallback'
         if (isset($app['locale_fallback'])) {
             $app['locale_fallbacks'] = (array) $app['locale_fallback'];
         }
         $translator->setFallbackLocales($app['locale_fallbacks']);
         $translator->addLoader('array', new ArrayLoader());
         $translator->addLoader('xliff', new XliffFileLoader());
         foreach ($app['translator.domains'] as $domain => $data) {
             foreach ($data as $locale => $messages) {
                 $translator->addResource('array', $messages, $locale, $domain);
             }
         }
         return $translator;
     });
     $app['translator.message_selector'] = $app->share(function () {
         return new MessageSelector();
     });
     $app['translator.domains'] = array();
     $app['locale_fallbacks'] = array('en');
 }
Пример #26
0
 public function register(Application $app)
 {
     $app['config'] = $app->share(function () use($app) {
         if (!file_exists($app['config.path'])) {
             throw new \InvalidArgumentException($app['config.path'] . ' is not a valid path to the ' . 'configuration');
         }
         $fullpath = explode('.', $app['config.path']);
         switch (strtolower(end($fullpath))) {
             case 'yml':
                 $parser = new Yaml\Parser();
                 $result = new \ArrayObject($parser->parse(file_get_contents($app['config.path'])));
                 break;
             case 'xml':
                 $result = simplexml_load_file($app['config.path']);
                 break;
             case 'json':
                 $result = json_decode(file_get_contents($app['config.path']));
                 break;
             default:
                 throw new \InvalidArgumentException('Unable to load configuration; the provided file ' . 'extension was not recognized. Only yml or xml allowed');
         }
         return $result;
     });
 }
Пример #27
0
 public function __construct($values = array())
 {
     parent::__construct("Kengrabber", self::VERSION, $values);
     $this->initialize();
 }
Пример #28
0
 /**
  * Tests whether the getService method correctly retrieves an element from
  * the container.
  */
 public function testGetService()
 {
     $app = new Application('Test');
     $app->command($this->fixture);
     $this->assertInstanceOf('Symfony\\Component\\Console\\Application', $this->fixture->getService('console'));
 }
Пример #29
0
 /**
  * Adds validators for the descriptors to the validator manager.
  *
  * @param Application $app
  *
  * @throws Exception\MissingDependencyException if the validator could not be found.
  *
  * @return void
  */
 protected function addValidators(Application $app)
 {
     if (!isset($app['validator'])) {
         throw new Exception\MissingDependencyException('The validator manager is missing');
     }
     $provider = $this;
     $app['validator'] = $app->share($app->extend('validator', function ($validatorManager) use($provider) {
         return $provider->attachValidators($validatorManager);
     }));
 }
 /**
  * @param Application $app
  */
 public function register(Application $app)
 {
     $app['vandpibe.generator.heroku'] = $app->share(function () use($app) {
         return new HerokuGenerator();
     });
 }