set() public method

Store a module setting
public set ( string $module, string $key, mixed $value )
$module string The module wherefore a setting has to be stored.
$key string The name of the setting.
$value mixed The value to save
 /**
  * @return bool
  */
 public function handle()
 {
     $this->form->cleanupFields();
     if (!$this->form->isSubmitted() || !$this->isValid()) {
         return false;
     }
     $this->settings->set('Analytics', 'web_property_id', $this->form->getField('web_property_id')->getValue());
     return true;
 }
 /**
  * @return bool
  */
 public function handle()
 {
     $this->form->cleanupFields();
     if (!$this->form->isSubmitted() || !$this->isValid()) {
         return false;
     }
     $certificate = base64_encode(file_get_contents($this->form->getField('certificate')->getTempFileName()));
     $this->settings->set('Analytics', 'certificate', $certificate);
     $this->settings->set('Analytics', 'email', $this->form->getField('email')->getValue());
     return true;
 }
Ejemplo n.º 3
0
 public function testSettingAValueForANewModule()
 {
     $databaseMock = $this->getDatabaseMock();
     $databaseMock->expects($this->once())->method('execute');
     $modulesSettings = new ModulesSettings($databaseMock, new InMemoryCache());
     $this->assertNull($modulesSettings->get('Fake', 'module'));
     $modulesSettings->set('Fake', 'module', 'value');
     $this->assertEquals('value', $modulesSettings->get('Fake', 'module'));
 }
Ejemplo n.º 4
0
 /**
  * @param SaveSettings $settings
  */
 public function handle(SaveSettings $settings)
 {
     // Define module
     $module = 'Mailmotor';
     // set our settings
     $this->modulesSettings->set($module, 'mail_engine', $settings->mailEngine);
     $this->modulesSettings->set($module, 'overwrite_interests', $settings->overwriteInterests);
     $this->modulesSettings->set($module, 'automatically_subscribe_from_form_builder_submitted_form', $settings->automaticallySubscribeFromFormBuilderSubmittedForm);
     // mail engine is empty
     if ($settings->mailEngine === 'not_implemented') {
         $this->modulesSettings->delete($module, 'api_key');
         $this->modulesSettings->delete($module, 'list_id');
         return;
     }
     $this->modulesSettings->set($module, 'api_key', $settings->apiKey);
     $this->modulesSettings->set($module, 'list_id', $settings->listId);
 }
Ejemplo n.º 5
0
 /**
  * @param bool $force
  */
 private function installWorkingLocale($force = false)
 {
     $installLocaleCommand = $this->getApplication()->find('forkcms:locale:import');
     $installBackendLocaleCommandArguments = ['-f' => PATH_WWW . '/src/Backend/Core/Installer/Data/locale.xml', '-o' => $force, '-l' => $this->workingLocale];
     $this->formatter->writeln('<info>Installing Core locale</info>');
     $installLocaleCommand->run(new ArrayInput($installBackendLocaleCommandArguments), $this->output);
     foreach ($this->installedModules as $installedModule) {
         $installModuleLocaleCommandArguments = ['-m' => $installedModule, '-o' => $force, '-l' => $this->workingLocale];
         $this->formatter->writeln('<info>Installing ' . $installedModule . ' locale</info>');
         try {
             $installLocaleCommand->run(new ArrayInput($installModuleLocaleCommandArguments), $this->output);
         } catch (Exception $exception) {
             $this->formatter->error($installedModule . ': skipped because ' . $exception->getMessage());
         }
     }
     if (!array_key_exists($this->workingLocale, $this->installedLocale)) {
         // add the working locale to the installed locale
         $this->installedLocale = array_flip($this->installedLocale);
         $this->installedLocale[] = $this->workingLocale;
         $this->settings->set('Core', 'languages', $this->installedLocale);
         $this->installedLocale = array_flip($this->installedLocale);
     }
 }