public function settings($key = null)
    {
        $plugin = $this->name();
        if ($cache = $this->config('settings')) {
            if ($key !== null) {
                $cache = isset($cache[$key]) ? $cache[$key] : null;
            }

            return $cache;
        }

        $pluginsTable = TableRegistry::get('System.Plugins');
        $settings = [];
        $dbInfo = $pluginsTable->find()
            ->cache("{$plugin}_settings", 'plugins')
            ->select(['name', 'settings'])
            ->where(['name' => $plugin])
            ->limit(1)
            ->first();

        if ($dbInfo) {
            $settings = (array)$dbInfo->settings;
        }

        if (empty($settings)) {
            $settings = (array)$pluginsTable->trigger("Plugin.{$plugin}.settingsDefaults")->result;
        }

        $this->config('settings', $settings);
        if ($key !== null) {
            $settings = isset($settings[$key]) ? $settings[$key] : null;
        }

        return $settings;
    }
public function settings($key = null)
    {
        $plugin = $this->name();
        if ($cache = $this->config('settings')) {
            if ($key !== null) {
                $cache = isset($cache[$key]) ? $cache[$key] : null;
            }

            return $cache;
        }

        $pluginsTable = TableRegistry::get('System.Plugins');
        $settings = [];
        $dbInfo = $pluginsTable->find()
            ->cache("{$plugin}_settings", 'plugins')
            ->select(['name', 'settings'])
            ->where(['name' => $plugin])
            ->limit(1)
            ->first();

        if ($dbInfo) {
            $settings = (array)$dbInfo->settings;
        }

        if (empty($settings)) {
            $settings = (array)$pluginsTable->trigger("Plugin.{$plugin}.settingsDefaults")->result;
        }

        $this->config('settings', $settings);
        if ($key !== null) {
            $settings = isset($settings[$key]) ? $settings[$key] : null;
        }

        return $settings;
    }
public function settings ( $ key = null ) { $ plugin = $ this -> name ( ) ; if ( $ cache = $ this -> config ( 'settings' ) ) { if ( $ key !== null ) { $ cache = isset ( $ cache [ $ key ] ) ? $ cache [ $ key ] : null ; } return $ cache ; } $ pluginsTable = TableRegistry :: get ( 'System.Plugins' ) ; $ settings = [ ] ; $ dbInfo = $ pluginsTable -> find ( ) -> cache ( "{$plugin}_settings" , 'plugins' ) -> select ( [ 'name' , 'settings' ] ) -> where ( [ 'name' => $ plugin ] ) -> limit ( 1 ) -> first ( ) ; if ( $ dbInfo ) { $ settings = ( array ) $ dbInfo -> settings ; } if ( empty ( $ settings ) ) { $ settings = ( array ) $ pluginsTable -> trigger ( "Plugin.{$plugin}.settingsDefaults" ) -> result ; } $ this -> config ( 'settings' , $ settings ) ; if ( $ key !== null ) { $ settings = isset ( $ settings [ $ key ] ) ? $ settings [ $ key ] : null ; } return $ settings ; }
Gets settings from DB for this plugin. Or reads a single settings key value.

@param string $key Which setting to read, the entire settings will be
returned if no key is provided
@return mixed Array of settings if $key was not provided, or the requested
value for the given $key (null of key does not exists)
Gets settings from DB for this plugin . Or reads a single settings key value .