Hooks::add_option ( $name,  $value = '' )

Add an option to the table

Source file: app/src/Hooks.php

View source



Source

    public function add_option($name, $value = '')
    {
        // Make sure the option doesn't already exist
        if (null !== $this->get_option($name)) {
            return;
        }

        $_value = $this->maybe_serialize($value);
        
        etsis_cache_delete($name, 'option');

        $this->do_action('add_option', $name, $_value);
        try {            
            $this->app->db->options_meta()->insert([
                'meta_key' => $name,
                'meta_value' => $_value
            ]);
            $this->app->db->option[$name] = $value;
            return;
        } catch (NotFoundException $e) {
            Cascade::getLogger('error')->error(sprintf('SQLSTATE[%s]: Error: %s', $e->getCode(), $e->getMessage()));
            _etsis_flash()->error(_etsis_flash()->notice(409));
        } catch (ORMException $e) {
            Cascade::getLogger('error')->error(sprintf('SQLSTATE[%s]: Error: %s', $e->getCode(), $e->getMessage()));
            _etsis_flash()->error(_etsis_flash()->notice(409));
        } catch (Exception $e) {
            Cascade::getLogger('error')->error(sprintf('SQLSTATE[%s]: Error: %s', $e->getCode(), $e->getMessage()));
            _etsis_flash()->error(_etsis_flash()->notice(409));
        }
    }


User Contributed Notes

You must log in before being able to contribute a note.