/**
  * Configures cache for test-suites.
  *
  * @param Repository $config
  */
 protected function getCacheConfiguredBy(Repository $config)
 {
     // Configuration for Redis.
     $config->set('cache.stores.redis', ['cluster' => false, 'test_connection' => ['host' => '127.0.0.1', 'port' => 6379, 'database' => 0]]);
     // Configuration for Redis.
     $config->set('yacache', ['driver' => 'redis', 'default' => 'redis', 'connection' => 'test_connection', 'prefix' => 'prefix', 'codec' => 'Illuminate\\YetAnother\\Cache\\Serializer\\Codec\\MsgPack']);
 }
Beispiel #2
0
 /**
  * Setup
  *
  * @throws Exception
  */
 private function setUp()
 {
     if (!$this->config->has('purifier')) {
         if (!$this->config->has('mews.purifier')) {
             throw new Exception('Configuration parameters not loaded!');
         }
         $this->config->set('purifier', $this->config->get('mews.purifier'));
     }
     $this->checkCacheDirectory();
     // Create a new configuration object
     $config = HTMLPurifier_Config::createDefault();
     // Allow configuration to be modified
     if (!$this->config->get('purifier.finalize')) {
         $config->autoFinalize = false;
     }
     $config->loadArray($this->getConfig());
     if ($def = $config->maybeGetRawHTMLDefinition()) {
         if ($addElement = $this->config->get('purifier.addElement')) {
             foreach ($addElement as $item) {
                 call_user_func_array(array($def, "addElement"), $item);
             }
         }
         if ($addAttribute = $this->config->get('purifier.addAttribute')) {
             foreach ($addAttribute as $item) {
                 call_user_func_array(array($def, "addAttribute"), $item);
             }
         }
     }
     // Create HTMLPurifier object
     $this->purifier = new HTMLPurifier($config);
 }
 /**
  * Handle the event.
  */
 public function handle()
 {
     if ($locale = $this->preferences->get('streams::locale')) {
         $this->application->setLocale($locale);
         $this->config->set('app.locale', $locale);
     }
 }
 /**
  * This is what happens, wenn the detection passes
  *
  * @param $lookup
  *
  * @return mixed
  */
 protected function handleDetectionComplete($lookup)
 {
     debugger()->info('Language detected: ' . $this->detected->slug);
     Cookie::queue($this->keys['cookie'], $this->detected->slug);
     $this->session->set($this->keys['session'], $this->detected->slug);
     $this->config->set('app.locale', $this->detected->slug);
     return $this->detected;
 }
Beispiel #5
0
 /**
  * {@inheritdoc}
  */
 public function validate()
 {
     $challenge = $this->request->get('recaptcha_challenge_field');
     $value = $this->request->get('recaptcha_response_field');
     if (empty($challenge) || empty($value)) {
         return false;
     }
     // Dirty hack to make use of our key instead of the config one
     $this->config->set('recaptcha.private_key', $this->settings->get('captcha.recaptcha_private_key'));
     return $this->service->check($challenge, $value);
 }
Beispiel #6
0
 /**
  * {@inheritdoc}
  */
 public function validate()
 {
     $value = $this->request->get('g-recaptcha-response');
     if (empty($value)) {
         return false;
     }
     // Dirty hack to make use of our key instead of the config one
     $this->config->set('recaptcha.private_key', $this->settings->get('captcha.nocaptcha_private_key'));
     $this->config->set('recaptcha.driver', 'curl');
     return $this->service->check(null, $value);
 }
 /**
  * Handle the command.
  *
  * @param Application                   $app
  * @param Repository                    $config
  * @param Request                       $request
  * @param PreferenceRepositoryInterface $preferences
  */
 function handle(Application $app, Repository $config, Request $request, PreferenceRepositoryInterface $preferences)
 {
     // Set using admin locale if in admin.
     if ($request->segment(1) === 'admin' && ($locale = $preferences->get('streams::admin_locale'))) {
         $app->setLocale($locale->getValue());
         $config->set('app.locale', $locale->getValue());
     }
     // Set using public locale if NOT in admin.
     if (!defined('LOCALE') && $request->segment(1) !== 'admin' && ($locale = $preferences->get('streams::public_locale'))) {
         $app->setLocale($locale->getValue());
         $config->set('app.locale', $locale->getValue());
     }
 }
Beispiel #8
0
 protected function setUp()
 {
     $this->config = new \Illuminate\Config\Repository();
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $items = $filesystem->getRequire(__DIR__ . '/config/config.php');
     $this->config->set("ytake-laravel-smarty", $items);
     new \Illuminate\Config\Repository();
     $viewFinder = new \Illuminate\View\FileViewFinder($filesystem, ['views'], ['.tpl']);
     $this->factory = new \Ytake\LaravelSmarty\SmartyFactory(new \Illuminate\View\Engines\EngineResolver(), $viewFinder, new \Illuminate\Events\Dispatcher(), new Smarty(), $this->config);
     $this->factory->setSmartyConfigure();
     $this->factory->addSmartyExtension();
     $this->factory->resolveSmartyCache();
 }
 function let(Application $app, Repository $cfg)
 {
     $cfg->get(Argument::type('string'), Argument::any())->willReturn([]);
     $cfg->set(Argument::type('string'), Argument::any())->willReturn([]);
     $app->offsetGet('config')->willReturn($cfg);
     $this->beConstructedWith($app);
 }
 /**
  * Handle the command.
  *
  * @param Repository                    $config
  * @param PreferenceRepositoryInterface $preferences
  */
 function handle(Repository $config, PreferenceRepositoryInterface $preferences)
 {
     // Set the timezone.
     if ($timezone = $preferences->get('streams::timezone')) {
         $config->set('app.timezone', $timezone->getValue());
         $config->set('streams::datetime.timezone', $timezone->getValue());
     }
     // Set the date format.
     if ($format = $preferences->get('streams::date_format')) {
         $config->set('streams::datetime.date_format', $format->getValue());
     }
     // Set the time format.
     if ($format = $preferences->get('streams::time_format')) {
         $config->set('streams::datetime.time_format', $format->getValue());
     }
 }
 /**
  * Enables/Disables Global Text Styles
  *
  * @param boolean $enabled
  * @param textStyle $globalTextStyle
  */
 public static function globalTextStyle(boolean $enabled, textStyle $globalTextStyle = NULL)
 {
     $this->config->set('lavacharts::globalTextStyleEnabled', $enabled);
     if (!is_null($globalTextStyle)) {
         $this->config->set('lavacharts::globalTextStyle', $globalTextStyle);
     }
 }
 private function getConfig()
 {
     $applicationConfig = (include __DIR__ . '/AppConfig.php');
     $packageConfig = (include __DIR__ . '/../../config/culpa.php');
     $packageConfig['users']['classname'] = User::class;
     $applicationRepository = new Repository($applicationConfig);
     $applicationRepository->set('culpa', $packageConfig);
     return $applicationRepository;
 }
Beispiel #13
0
 protected function setUp()
 {
     $this->config = new \Illuminate\Config\Repository();
     $filesystem = new \Illuminate\Filesystem\Filesystem();
     $items = $filesystem->getRequire(__DIR__ . '/config/config.php');
     $this->config->set("ytake-laravel-smarty", $items);
     new \Illuminate\Config\Repository();
     $viewFinder = new \Illuminate\View\FileViewFinder($filesystem, ['views'], ['.tpl']);
     $this->factory = new \Ytake\LaravelSmarty\SmartyFactory(new \Illuminate\View\Engines\EngineResolver(), $viewFinder, new \Illuminate\Events\Dispatcher(), new Smarty(), $this->config);
     $this->factory->setSmartyConfigure();
     $this->factory->resolveSmartyCache();
     $extension = $this->config->get('ytake-laravel-smarty.extension', 'tpl');
     $this->factory->addExtension($extension, 'smarty', function () {
         // @codeCoverageIgnoreStart
         return new \Ytake\LaravelSmarty\Engines\SmartyEngine($this->factory->getSmarty());
         // @codeCoverageIgnoreEnd
     });
 }
Beispiel #14
0
 /**
  * @param string $key
  * @param mixed $value
  * @return $this|Larfing
  */
 public function set($key, $value)
 {
     parent::set($key, $value);
     if ($this->setting['queue'] === false) {
         return $this->put($key);
     }
     $this->_put[implode('', array_slice($this->parseKey($key), 0, 2))] = $key;
     return $this;
 }
 /**
  * Bind the core classes to the container
  */
 protected function bindCoreClasses()
 {
     // Bind request
     $this->app->bindIf('request', function () {
         return Request::createFromGlobals();
     });
     // Bind config
     $this->app->bindIf('config', function ($app) {
         $fileloader = new ConfigLoader($app['files'], __DIR__ . '/../');
         $config = new Repository($fileloader, 'config');
         $config->set('cache.driver', 'file');
         $config->set('cache.path', __DIR__ . '/../../cache');
         return $config;
     }, true);
     // Bind cache
     $this->app->bindIf('cache', function ($app) {
         return new CacheManager($app);
     });
 }
Beispiel #16
0
 /**
  * Setup
  *
  * @throws Exception
  */
 private function setUp()
 {
     if (!$this->config->has('purifier')) {
         if (!$this->config->has('mews.purifier')) {
             throw new Exception('Configuration parameters not loaded!');
         }
         $this->config->set('purifier', $this->config->get('mews.purifier'));
     }
     $this->checkCacheDirectory();
     // Create a new configuration object
     $config = HTMLPurifier_Config::createDefault();
     // Allow configuration to be modified
     if (!$this->config->get('purifier.finalize')) {
         $config->autoFinalize = false;
     }
     $config->loadArray($this->getConfig());
     // Create HTMLPurifier object
     $this->purifier = new HTMLPurifier($this->configure($config));
 }
Beispiel #17
0
 /**
  * @throws Exception
  */
 public function run()
 {
     # we leverage the Illuminate/Config part of Laravel for managing our simple config!
     # create our console app & add the commands
     $this->config = new Repository();
     $this->console = new Application('Webdev', WEBDEV_VERSION);
     if (!WEBDEV_CONFIGURED) {
         $this->console->add(new InitCommand());
         echo "Looks like you just installed the webdev tool. I'm gonna run the 'init' command!\n";
         $this->console->run(new ArrayInput(['command' => 'init']));
     } else {
         $this->config->set(include WEBDEV_CONFIG_FILE);
         # add all commmands
         $this->console->add(new InitCommand());
         $this->console->add(new ConfigCommand());
         $this->console->add(new CreateCommand());
         $this->console->add(new AddCommand());
         $this->console->run();
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // Obtener las bases de datos
     $bds = BaseDatosCadeco::all();
     $this->output->progressStart(count($bds));
     foreach ($bds as $bd) {
         $this->output->newLine();
         $this->info('Ejecutando migraciones en ' . $bd->nombre);
         $this->config->set('database.connections.' . $this->argument('connection') . '.database', $bd->nombre);
         if ($this->option('path')) {
             $this->call('migrate', ['--database' => $this->argument('connection'), '--path' => $this->option('path')]);
         }
         $this->call('migrate', ['--database' => $this->argument('connection')]);
         if ($this->option('seed')) {
             $this->call('db:seed', ['--force' => true, '--database' => $this->argument('connection')]);
         }
         DB::disconnect($this->argument('connection'));
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
 }
Beispiel #19
0
 /**
  * Create a new remote manager instance.
  *
  * @param Application|\Illuminate\Foundation\Application $app
  * @param Mailer                                         $mailer
  * @param Request                                        $request
  */
 public function __construct(Application $app, Mailer $mailer, Request $request)
 {
     $this->app = $app;
     $this->mailer = $mailer;
     $this->request = $request;
     $this->config = $this->app['config'];
     $this->basePath = $this->config->get('deployer.base_path', base_path());
     $this->commands = $this->config->get('deployer.commands', []);
     $this->tasks = $this->config->get('deployer.tasks', []);
     $this->tasksMailOnCompletion = $this->config->get('deployer.tasks_mail_on_completed', false);
     # Set the config values for the remote package
     $this->config->set('remote.connections.production.host', $this->config->get('deployer.remote_connection.host'));
     $this->config->set('remote.connections.production.username', $this->config->get('deployer.remote_connection.username'));
     $this->config->set('remote.connections.production.password', $this->config->get('deployer.remote_connection.password'));
     $this->config->set('remote.connections.production.key', $this->config->get('deployer.remote_connection.key'));
     $this->config->set('remote.connections.production.keytext', $this->config->get('deployer.remote_connection.keytext'));
     $this->config->set('remote.connections.production.keyphrase', $this->config->get('deployer.remote_connection.keyphrase'));
     $this->config->set('remote.connections.production.timeout', $this->config->get('deployer.remote_connection.timeout'));
     # Set remote connection after configuration has been set
     $this->remoteConnection = $this->into('production');
 }
 /**
  *  Returns a list of all available locales.
  *
  *  @return array
  */
 public function availableLocales()
 {
     if ($this->config->has('translator.locales')) {
         return $this->config->get('translator.locales');
     }
     if ($this->tableExists()) {
         $locales = $this->model->distinct()->get()->pluck('locale')->toArray();
         $this->config->set('translator.locales', $locales);
         return $locales;
     }
     return $this->defaultAvailableLocales;
 }
 /**
  * set new Config value by given key and value.
  * And save the file.
  *
  * @param $key
  * @param $value
  *
  * @return int
  */
 protected function setConfigValue($key, $value)
 {
     $fs = new Filesystem();
     $fn = $fs->name($key);
     // First string until dot should be the file name.
     $filename = strstr($fn, '.', true);
     if (strpos($filename, '.') !== false) {
         $filename = $fn;
     }
     $this->items->set($key, $value);
     return $fs->put($this->getConfigDir() . DIRECTORY_SEPARATOR . $filename . '.php', '<?php return ' . var_export($this->items[$fn], true) . ';');
 }
Beispiel #22
0
 /**
  * Changes the default connection name and tries to establish a connection.
  *
  * @param $database
  */
 protected function setDefaultConnection($database)
 {
     try {
         // Explicitely set the default connection name
         $this->config->set('database.default', $database);
         // Try to connect
         $connection = $this->db->connection();
         // Close the connection
         $connection = null;
     } catch (\Exception $e) {
         throw new \RuntimeException("Can't establish a db connection '" . $e->getMessage() . "'.");
     }
 }
Beispiel #23
0
 /**
  * Constructor
  *
  * @param Filesystem $files
  * @param Repository $config
  * @param ImageManager $imageManager
  * @param Session $session
  * @param Hasher $hasher
  * @param Str $str
  * @throws Exception
  * @internal param Validator $validator
  */
 public function __construct(Filesystem $files, Repository $config, ImageManager $imageManager, Session $session, Hasher $hasher, Str $str)
 {
     $this->files = $files;
     $this->config = $config;
     $this->imageManager = $imageManager;
     $this->session = $session;
     $this->hasher = $hasher;
     $this->str = $str;
     if (!$this->config->has('captcha')) {
         if (!$this->config->has('mews.captcha')) {
             throw new Exception('Configuration parameters not loaded!');
         }
         $this->config->set('captcha', $this->config->get('mews.captcha'));
     }
 }
Beispiel #24
0
 /**
  * Load the external config files specified by the command line option.
  */
 protected function loadExternalConfig()
 {
     $config = new Repository(static::getDefaultConfig());
     $filesystem = new Filesystem();
     foreach ($this->getConfigFiles($filesystem) as $filename) {
         $this->output->writeln("<info>Reading config from <path>{$filename}</path></info>");
         if ($filesystem->extension($filename) == 'php') {
             $configValues = $filesystem->getRequire($filename);
         } else {
             $configValues = Yaml::parse($filesystem->get($filename));
         }
         $config->set(array_dot($configValues));
     }
     $this->container->instance('config', $config);
 }
 public function __construct(KernelInterface $kernel, ContainerInterface $container, $configs)
 {
     $this->container = $container;
     $this->instance('config', $config = new Repository());
     $this->singleton(\Illuminate\Contracts\Debug\ExceptionHandler::class, \CULabs\IlluminateBundle\Bridge\Foundation\Exceptions\Handler::class);
     $this->alias('queue', \Illuminate\Contracts\Queue\Factory::class);
     foreach ($configs as $key => $item) {
         $config->set($key, $item);
     }
     foreach ($this->servicesProvider() as $class) {
         $provider = new $class($this);
         if (!$provider instanceof ServiceProvider) {
             throw new \InvalidArgumentException(sprintf('The class "%s" is not subclass of "%s".', $class, ServiceProvider::class));
         }
         $this->register($provider);
     }
     $this->registerSchedule($kernel);
 }
 /**
  * bootstrap method
  *
  * @param \Raphaelb\Foundation\Application $app
  *
  * @return mixed
  */
 public function bootstrap(Application $app)
 {
     $items = [];
     /** @var \Illuminate\Filesystem\Filesystem $fs */
     $fs = new Filesystem();
     $app->instance('config', $config = new Repository($items));
     foreach ($fs->files($app->getConfigPath()) as $file) {
         $config->set(Path::getFilenameWithoutExtension($file), $fs->getRequire($file));
     }
     // Foreach loop for .phar file.
     //  foreach (scandir($app->getConfigPath()) as $file )
     //  {
     //      $config->set(
     //          Path::getFilenameWithoutExtension($file),
     //          $fs->getRequire($app->getConfigPath() . '/' .$file)
     //      );
     //  }
     return $config;
 }
 /**
  * Handle the command.
  *
  * @param Repository  $config
  * @param Application $application
  */
 public function handle(Repository $config, Application $application)
 {
     // First trigger to resolve.
     $application->make('translator');
     /*
      * Change the lang loader so we can
      * add a few more necessary override
      * paths to the API.
      */
     $application->singleton('translation.loader', function ($application) {
         return new Loader($application['files'], $application['path.lang']);
     });
     /*
      * Re-bind the translator so we can use
      * the new loader defined above.
      */
     $application->singleton('translator', function ($application) {
         $loader = $application->make('translation.loader');
         // When registering the translator component, we'll need to set the default
         // locale as well as the fallback locale. So, we'll grab the application
         // configuration so we can easily get both of these values from there.
         $locale = $application['config']['app.locale'];
         $trans = new Translator($loader, $locale);
         $trans->setFallback($application['config']['app.fallback_locale']);
         return $trans;
     });
     /*
      * Set the locale if LOCALE is defined.
      *
      * LOCALE is defined first thing in our
      * HTTP Kernel. Respect it!
      */
     if (defined('LOCALE')) {
         $application->setLocale(LOCALE);
         $config->set('app.locale', LOCALE);
     }
     // Set our locale namespace.
     $application->make('translator')->addNamespace('streams', realpath(__DIR__ . '/../../../resources/lang'));
 }
Beispiel #28
0
 /**
  * Loads and resolves the scaffold configuration
  *
  * @param string $pathToConfig
  * @param string $outputPath
  *
  * @return Repository|RepositoryInterface
  */
 protected function loadAndResolveConfiguration($pathToConfig, $outputPath)
 {
     // Load configuration
     $config = $this->getConfigLoader()->parse($pathToConfig);
     // Get the filename (without file extension) so that we know what
     // part of the configuration to fetch. The filename acts as the
     // configuration's entry key.
     $filename = strtolower(pathinfo($pathToConfig, PATHINFO_FILENAME));
     // Fetch the content of the configuration and pass it
     // into a new configuration, which is the one that we are
     // going to pass on to each task
     $config = new Repository($config->get($filename));
     // Resolve the output path and added it to the configuration
     if (substr($outputPath, -1) != DIRECTORY_SEPARATOR) {
         $outputPath = $outputPath . DIRECTORY_SEPARATOR;
     }
     $config->set('outputPath', $outputPath);
     // Output title and what configuration file is being used
     $this->output->title(sprintf('Building %s', $config->get('name')));
     $this->output->text(sprintf('%s', $config->get('description')));
     $this->output->text(sprintf('Using: %s', $pathToConfig));
     // Finally, return the configuration
     return $config;
 }
Beispiel #29
0
 /**
  * Set a given configuration value.
  *
  * @param array|string $key
  * @param mixed $value
  * @return void 
  * @static 
  */
 public static function set($key, $value = null)
 {
     \Illuminate\Config\Repository::set($key, $value);
 }
 /**
  * @param Repository $config
  */
 protected function configureCache(Repository $config)
 {
     $config->set('database.redis', ['cluster' => false, 'test_connection' => ['host' => '127.0.0.1', 'port' => 6379, 'database' => 0]]);
     if (version_compare(Application::VERSION, "5.0", '>=')) {
         $cacheConfigKey = 'cache.stores.redis';
     } else {
         $cacheConfigKey = 'cache';
     }
     $config->set($cacheConfigKey, ['driver' => 'fh-redis', 'connection' => 'test_connection', 'prefix' => 'prefix', 'coders' => [Model::class => ModelCoder::class, Collection::class => CollectionCoder::class, stdClass::class => PhpSerializeCoder::class, 'arrays' => function ($value) {
         if (is_array($value)) {
             return new PhpSerializeCoder();
         }
         return null;
     }]]);
 }