common\ModulesSettings::delete PHP Метод

delete() публичный Метод

Deletes a module setting
public delete ( string $module, string $key )
$module string
$key string
    public function delete($module, $key)
    {
        $this->database->delete('modules_settings', 'module = :module and name = :name', array('module' => $module, 'name' => $key));
        /*
         * Instead of invalidating the cache, we could also fetch existing
         * settings, update them & re-store them to cache. That would save
         * us the next query to repopulate the cache.
         * However, there could be race conditions where 2 concurrent
         * requests write at the same time and one ends up overwriting the
         * other (unless we do a CAS, but PSR-6 doesn't support that)
         * Clearing cache will be safe: in the case of concurrent requests
         * & cache being regenerated while the other is being saved, it will
         * be cleared again after saving the new setting!
         */
        $this->cache->deleteItems(array('settings'));
    }

Usage Example

Пример #1
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);
 }
All Usage Examples Of common\ModulesSettings::delete