Esempio n. 1
0
 /**
  * Handle the event.
  */
 public function handle()
 {
     if ($locale = $this->preferences->get('streams::locale')) {
         $this->application->setLocale($locale);
         $this->config->set('app.locale', $locale);
     }
 }
 /**
  * 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());
     }
 }
 /**
  * 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());
     }
 }
 /**
  * Return the form fields.
  *
  * @param PreferenceFormBuilder $builder
  */
 public function handle(PreferenceFormBuilder $builder, PreferenceRepositoryInterface $preferences)
 {
     $namespace = $builder->getEntry() . '::';
     /**
      * Get the fields from the config system. Sections are
      * optionally defined the same way.
      */
     if (!($fields = $this->config->get($namespace . 'preferences/preferences'))) {
         $fields = $fields = $this->config->get($namespace . 'preferences', []);
     }
     if ($sections = $this->config->get($namespace . 'preferences/sections')) {
         $builder->setSections($sections);
     }
     /**
      * Finish each field.
      */
     foreach ($fields as $slug => &$field) {
         /**
          * Force an array. This is done later
          * too in normalization but we need it now
          * because we are normalizing / guessing our
          * own parameters somewhat.
          */
         if (is_string($field)) {
             $field = ['type' => $field];
         }
         // Make sure we have a config property.
         $field['config'] = array_get($field, 'config', []);
         // Default the label.
         $field['label'] = array_get($field, 'label', $namespace . 'preference.' . $slug . '.label');
         // Default the placeholder.
         $field['config']['placeholder'] = array_get($field['config'], 'placeholder', $namespace . 'preference.' . $slug . '.placeholder');
         // Default the instructions.
         $field['instructions'] = array_get($field, 'instructions', $namespace . 'preference.' . $slug . '.instructions');
         // Get the value defaulting to the default value.
         if ($preference = $preferences->get($namespace . $slug)) {
             $field['value'] = $preference->getValue();
         } else {
             $field['value'] = array_get($field['config'], 'default_value');
         }
     }
     $builder->setFields($fields);
 }