/** * @return void */ public function fire() { if (!$this->isDataSetted) { $this->setDataFromConsoling(); } $this->config->set('database', ['fetch' => PDO::FETCH_OBJ, 'default' => $this->data->get('driver'), 'connections' => [], 'redis' => []]); switch ($this->data->get('driver')) { case 'mysql': $this->config->set('database.connections.mysql', ['driver' => 'mysql', 'host' => $this->data->get('database_host'), 'database' => $this->data->get('database'), 'username' => $this->data->get('database_username'), 'password' => $this->data->get('database_password'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => $this->data->get('database_prefix'), 'strict' => true, 'engine' => null]); break; case 'pgsql': $this->config->set('database.connections.pgsql', ['driver' => 'pgsql', 'host' => $this->data->get('database_host'), 'database' => $this->data->get('database'), 'username' => $this->data->get('database_username'), 'password' => $this->data->get('database_password'), 'charset' => 'utf8', 'prefix' => $this->data->get('database_prefix'), 'schema' => 'public', 'sslmode' => 'prefer']); break; case 'sqlite': $this->config->set('database.connections.sqlite', ['driver' => 'sqlite', 'database' => $this->container->storagePath() . DIRECTORY_SEPARATOR . 'bootstraps' . DIRECTORY_SEPARATOR . 'database.sqlite', 'prefix' => $this->data->get('database_prefix')]); touch($this->container->storagePath() . DIRECTORY_SEPARATOR . 'bootstraps' . DIRECTORY_SEPARATOR . 'database.sqlite'); break; } $this->call('migrate', ['--force' => true, '--path' => str_replace(base_path() . DIRECTORY_SEPARATOR, '', database_path('migrations'))]); $this->call('passport:keys'); $this->call('passport:client', ['--password' => true, '--name' => 'Notadd Administrator Client']); $setting = $this->container->make(SettingsRepository::class); $setting->set('site.name', $this->data->get('website')); $setting->set('setting.image.engine', 'webp'); if ($this->data->get('image_engine', false)) { } else { $setting->set('setting.image.engine', 'normal'); } $this->createAdministrationUser(); $this->writingConfiguration(); $this->call('key:generate'); $this->info('Notadd Installed!'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if ($tz = $request->header('Time-Zone')) { $this->config->set('cachet.timezone', $tz); } return $next($request); }
/** * @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $application * @param \Illuminate\Contracts\Config\Repository $repository * * @return void */ protected function loadConfigurationFiles(Application $application, RepositoryContract $repository) { foreach ($this->getConfigurationFiles($application) as $key => $path) { $repository->set($key, require $path); } if ($application->isInstalled()) { $database = (require $application->storagePath() . DIRECTORY_SEPARATOR . 'bootstraps' . DIRECTORY_SEPARATOR . 'replace.php'); $repository->set('database', $database); } }
/** * Load the configuration items from all of the files. * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Config\Repository $config * @return void */ protected function loadConfigurationFiles(Application $app, \Illuminate\Contracts\Config\Repository $config) { foreach ($this->getConfigurationFiles($app) as $key => $path) { $config->set($key, require $path); } foreach ($this->getConfigurationFilesYml($app) as $key => $path) { $c = Yaml::parse($this->files->get($path)); $config->set($key, $c); } }
/** * Map configuration to allow orchestra to store it in database. * * @param string $name * @param array $aliases * * @return bool */ public function map($name, $aliases) { $memory = $this->memory->make(); $meta = $memory->get("extension_{$name}", []); foreach ($aliases as $current => $default) { isset($meta[$current]) && $this->config->set($default, $meta[$current]); $meta[$current] = $this->config->get($default); } $memory->put("extension_{$name}", $meta); return true; }
/** * @return void */ public function fire() { if (!$this->isDataSetted) { $this->setDataFromConsoling(); } $this->config->set('database', ['fetch' => PDO::FETCH_CLASS, 'default' => 'mysql', 'connections' => ['mysql' => ['driver' => 'mysql', 'host' => $this->data->get('host'), 'database' => $this->data->get('database'), 'username' => $this->data->get('username'), 'password' => $this->data->get('password'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => $this->data->get('prefix'), 'strict' => true]], 'migrations' => 'migrations', 'redis' => []]); $this->call('migrate'); $this->setting->set('site.title', $this->data->get('title')); $this->setting->set('seo.title', $this->data->get('title')); $this->createAdministrationUser(); $this->writingConfiguration(); $this->comment('Application Installed!'); }
/** * Add namespace overrides to configuration. * * @param $namespace * @param $directory */ public function addNamespaceOverrides($namespace, $directory) { if (!$this->files->isDirectory($directory)) { return; } /* @var SplFileInfo $file */ foreach ($this->files->allFiles($directory) as $file) { $key = trim(str_replace($directory, '', $file->getPath()) . DIRECTORY_SEPARATOR . $file->getBaseName('.php'), DIRECTORY_SEPARATOR); // Normalize key slashes. $key = str_replace('\\', '/', $key); $this->config->set($namespace . '::' . $key, array_replace($this->config->get($namespace . '::' . $key, []), $this->files->getRequire($file->getPathname()))); } }
protected function loadConfigurationFiles(Application $app, RepositoryContract $repository) { foreach ($this->getConfigurationFiles($app) as $key => $path) { $parts = explode(".", $path); $ext = array_pop($parts); switch ($ext) { case 'php': $repository->set($key, require $path); break; case 'ini': $repository->set($key, parse_ini_file($path, true)); break; } } }
/** * Load the configuration items from all of the files. * * @param Application $app * @param Repository $config * * @return void */ protected function loadConfigurationFiles(Application $app, Repository $config) { foreach ($this->getConfigurationFiles($app) as $key => $path) { $ext = substr($path, strrpos($path, '.') + 1); switch ($ext) { case 'php': $config->set($key, require $path); break; case 'yml': case 'yaml': $config->set($key, $this->parseYamlOrLoadFromCache($path)); break; } } }
/** * 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('Revirtiendo la ultima migracion en ' . $bd->nombre); $this->config->set('database.connections.' . $this->argument('connection') . '.database', $bd->nombre); $this->call('migrate:rollback', ['--database' => $this->argument('connection')]); DB::disconnect($this->argument('connection')); $this->output->progressAdvance(); } $this->output->progressFinish(); }
protected function loadConfigurationFiles(Application $app, RepositoryContract $config) { foreach ($this->getConfigurationFiles($app) as $key => $paths) { $config->set($key, require $paths[0]); if (count($paths) > 1) { foreach ($paths as $i => $path) { if ($i === 0) { continue; } $values = (require $paths[$i]); $config->set($key, array_replace_recursive($config->get($key), $values)); } } } }
/** * Set the handles to orchestra/extension package config (if available). * * @param string $name * @param array $options * * @return void */ protected function registerExtensionHandles($name, array $options) { $handles = Arr::get($options, 'config.handles'); if (!is_null($handles)) { $this->config->set("orchestra/extension::handles.{$name}", $handles); } }
/** * Save the given property's value in this handler's * configuration * * @param Property $property * @param mixed $valueToBeSaved */ protected function saveValueFor(Property $property, $valueToBeSaved) { // Change the configuration $this->config->set($this->key, $valueToBeSaved); // Save the value as a "previous" answer self::$previousAnswers[$property->getId()] = $valueToBeSaved; // Output what value is being used $this->outputStatus($valueToBeSaved, $property->getType(), $property->getId()); }
/** * Handle the form. * * @param ForgotPasswordFormBuilder $builder * @param UserRepositoryInterface $users * @param UserPassword $password */ public function handle(ForgotPasswordFormBuilder $builder, UserRepositoryInterface $users, UserPassword $password, Repository $config) { $user = $users->findByEmail($builder->getFormValue('email')); if ($path = $builder->getFormOption('reset_path')) { $config->set('anomaly.module.users::paths.reset', $path); } $password->forgot($user); $password->send($user, $builder->getFormOption('reset_redirect')); }
/** * Merge the items in the given files into the items. * * @param RepositoryContract $repository * @param string $env * @param array $filesByEnv * * @return void */ protected function mergeEnv(RepositoryContract $repository, $env, $filesByEnv) { $ignoreCount = strlen($env) + 1; foreach ($filesByEnv as $key => $path) { $key = substr($key, $ignoreCount); $origin = $repository->get($key); $repository->set($key, array_replace_recursive($origin, require $path)); } }
/** * Handle the command. * * @param SettingRepositoryInterface $settings * @param AddonCollection $addons * @param Repository $config */ public function handle(SettingRepositoryInterface $settings, AddonCollection $addons, Repository $config) { /* @var Addon $addon */ foreach ($addons->withConfig('settings') as $addon) { foreach ($config->get($addon->getNamespace('settings')) as $key => $setting) { if (isset($setting['env']) && env($setting['env']) !== null) { continue; } if (!isset($setting['bind'])) { continue; } if (!$settings->has($key = $addon->getNamespace($key))) { continue; } $config->set($setting['bind'], $settings->value($key)); } } foreach ($addons->withConfig('settings/settings') as $addon) { foreach ($config->get($addon->getNamespace('settings/settings')) as $key => $setting) { if (isset($setting['env']) && env($setting['env']) !== null) { continue; } if (!isset($setting['bind'])) { continue; } if (!$settings->has($key = $addon->getNamespace($key))) { continue; } $config->set($setting['bind'], $settings->value($key)); } } foreach ($config->get('streams::settings/settings', []) as $key => $setting) { if (isset($setting['env']) && env($setting['env']) !== null) { continue; } if (!isset($setting['bind'])) { continue; } if (!$settings->has($key = 'streams::' . $key)) { continue; } $config->set($setting['bind'], $settings->value($key)); } }
/** * Load the configuration items from all of the files. * * @param string $configPath * @param \Illuminate\Contracts\Config\Repository $config * @param string namespace * @return void */ protected function loadConfigurationFiles($configPath, RepositoryContract $config, $namespace = '') { foreach ($this->getConfigurationFiles($configPath) as $key => $path) { //Module config default filename is config //This way module config is accessible via // Config::get('namespace.value') //Instead of : // Config::get('namespace.config.value') //Inspire from : https://octobercms.com/docs/plugin/settings#file-configuration //But doesn't use :: notation for namespace cause otherwise it would have been // Config::get('namespace::.value') //@todo change the way Repository works to be able to use namespaces if ($namespace !== '' && $key === 'config') { $config->set($namespace, require $path); } else { $config->set($namespace . $key, require $path); } } }
/** * Override give config values from persistent setting storage. * * @param array $override * @param \Illuminate\Contracts\Config\Repository $config * @param \Krucas\Settings\Settings $settings * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher */ protected function overrideConfig(array $override, Repository $config, Settings $settings, Dispatcher $dispatcher) { foreach ($override as $key => $settingKey) { $configKey = is_string($key) ? $key : $settingKey; $dispatcher->fire("settings.overriding: {$configKey}", [$configKey, $settingKey]); $settingValue = $settings->get($settingKey); $configValue = $config->get($configKey); $config->set($configKey, $settingValue); $dispatcher->fire("settings.override: {$configKey}", [$configKey, $configValue, $settingKey, $settingValue]); } }
/** * Load the configuration items from all of the files. * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Config\Repository $repository * @return void */ protected function loadConfigurationFiles(Application $app, RepositoryContract $repository) { $baseFiles = $this->getConfigurationFiles($app->baseConfigPath()); $projFiles = !$app->isBaseProject() ? $this->getConfigurationFiles($app->configPath()) : []; $keys = array_unique(array_merge(array_keys($baseFiles), array_keys($projFiles))); foreach ($keys as $key) { $baseCfg = array_key_exists($key, $baseFiles) ? require $baseFiles[$key] : []; $projCfg = array_key_exists($key, $projFiles) ? require $projFiles[$key] : []; $repository->set($key, array_merge($baseCfg, $projCfg)); } }
/** * Obtiene las obras de un usuario cadeco de todas las bases de datos definidas * * @param $idUsuario * @return Collection|Obra */ public function getObras($idUsuario) { $obrasUsuario = new Collection(); $basesDatos = BaseDatosCadeco::where('activa', true)->orderBy('nombre')->get(); foreach ($basesDatos as $bd) { $this->config->set('database.connections.cadeco.database', $bd->nombre); $usuarioCadeco = $this->getUsuarioCadeco($idUsuario); $obras = $this->getObrasUsuario($usuarioCadeco); foreach ($obras as $obra) { $obra->databaseName = $bd->nombre; $obrasUsuario->push($obra); } DB::disconnect('cadeco'); } $perPage = 10; $currentPage = Paginator::resolveCurrentPage(); $currentPage = $currentPage ? $currentPage : 1; $offset = $currentPage * $perPage - $perPage; $paginator = new LengthAwarePaginator($obrasUsuario->slice($offset, $perPage), $obrasUsuario->count(), $perPage); return $paginator; }
/** * Handle the form. * * @param ForgotPasswordFormBuilder $builder * @param UserRepositoryInterface $users * @param UserPassword $password * @param MessageBag $messages * @param Repository $config */ public function handle(ForgotPasswordFormBuilder $builder, UserRepositoryInterface $users, UserPassword $password, MessageBag $messages, Repository $config) { if ($builder->hasFormErrors()) { return; } $user = $users->findByEmail($builder->getFormValue('email')); if ($path = $builder->getFormOption('reset_path')) { $config->set('anomaly.module.users::paths.reset', $path); } $password->forgot($user); $password->send($user, $builder->getFormOption('reset_redirect')); $messages->success('anomaly.module.users::message.confirm_reset_password'); }
/** * Look for locale=LOCALE in the query string. * * @param Request $request * @param \Closure $next * @return mixed */ public function handle(Request $request, Closure $next) { if (defined('LOCALE')) { return $next($request); } if ($locale = $request->get('_locale')) { if ($locale) { $request->session()->put('_locale', $locale); } else { $request->session()->remove('_locale'); } return $this->redirect->to($request->path()); } if ($locale = $request->session()->get('_locale')) { $this->application->setLocale($locale); $this->config->set('_locale', $locale); } if (!$locale) { $this->application->setLocale($this->config->get('streams::locales.default')); } return $next($request); }
/** * Run booting on installed application. * * @throws \Exception * * @return \Orchestra\Contracts\Memory\Provider */ protected function bootInstalledApplication() { // Initiate Memory class from App, this to allow advanced user // to use other implementation if there is a need for it. $memory = $this->app->make('orchestra.memory')->make(); $name = $memory->get('site.name'); if (is_null($name)) { throw new Exception('Installation is not completed'); } $this->config->set('app.name', $name); // In event where we reach this point, we can consider no // exception has occur, we should be able to compile acl and // menu configuration $this->acl()->attach($memory); // In any event where Memory failed to load, we should set // Installation status to false routing for installation is // enabled. $this->app->instance('orchestra.installed', true); $this->createAdminMenu(); return $memory; }
/** * Set a configuration value. * * @param $name * @param $value * * @return mixed */ public function set($name, $value) { $item = $this->getItemPath($name); return $this->config->set($item, $value); }
/** * Set the default connection name. * * @param string $name * * @return void */ public function setDefaultConnection($name) { $this->config->set($this->getConfigName() . '.default', $name); }
/** * @param Repository $config * @param Container $container */ public function syncUsers(Repository $config, Container $container) { $this->output->write('Start user sync...'); $config->set('gitter.output', false); $client = Client::make($config->get('gitter.token'), $this->argument('room')); $room = $container->make(Room::class); $users = $client->request('room.users', ['roomId' => $room->id]); $message = "\r<comment>[%s/%s]</comment> %s%80s"; $count = count($users); $current = 1; foreach ($users as $user) { $user = User::fromGitterObject($user); $this->output->write(sprintf($message, $current, $count, $user->login, '')); $current++; } $this->output->write(sprintf($message, $count, $count, 'OK', '')); }
/** * Load the configuration items from all of the files. * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Contracts\Config\Repository $config * @return void */ protected function loadConfigurationFiles(Application $app, RepositoryContract $config) { foreach ($this->getConfigurationFiles($app) as $key => $path) { $config->set($key, require $path); } }
/** * Handle the command. * * @param Repository $config */ public function handle(Repository $config) { $config->set('database.connections.core', $config->get('database.connections.' . $config->get('database.default'))); }
/** * Boot the service provider. * * @param Repository $config * @param Application $application */ public function boot(Repository $config, Application $application) { $config->set('search', $config->get('anomaly.module.search::engine')); $config->set('search.connections.zend.path', str_replace('storage::', $application->getStoragePath() . '/', $config->get('search.connections.zend.path'))); }
/** * Set a given configuration value. * * @param array|string $key * @param mixed $value */ public function set($key, $value = null) { $this->repository->set($key, $value); }