/**
  * 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 event.
  *
  * @param ModuleWasUninstalled $event
  */
 public function handle(ModuleWasUninstalled $event)
 {
     $module = $event->getModule();
     foreach ($this->settings->findAllByNamespace($module->getNamespace()) as $setting) {
         $this->settings->delete($setting);
     }
 }
 /**
  * Handle the event.
  *
  * @param ExtensionWasUninstalled $event
  */
 public function handle(ExtensionWasUninstalled $event)
 {
     $extension = $event->getExtension();
     foreach ($this->settings->findAllByNamespace($extension->getNamespace()) as $setting) {
         $this->settings->delete($setting);
     }
 }
 /**
  * Save the form.
  *
  * @param FormBuilder $builder
  * @return bool|mixed
  */
 public function save(FormBuilder $builder)
 {
     $form = $builder->getForm();
     $namespace = $form->getEntry() . '::';
     /* @var FieldType $field */
     foreach ($form->getFields() as $field) {
         $this->preferences->set($namespace . $field->getField(), $form->getValue($field->getInputName()));
     }
 }
 /**
  * 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);
 }
 /**
  * Handle the command.
  *
  * @param PreferenceRepositoryInterface $preferences
  * @return mixed
  */
 public function handle(PreferenceRepositoryInterface $preferences)
 {
     return $preferences->value($this->key, $this->default);
 }