public function registerPlugins()
    {
        $jsonFile = Environment::getJsonConfigFilename();
        if (!$jsonFile) {
            return;
        }

        $config = new Config;
        $var    = $config->validate($jsonFile);

        foreach ($var['plugins'] as $plugin) {
            if (class_exists($plugin['class'])) {
                if (isset($plugin['options'])) {
                    $options = $plugin['options'];
                    if (is_string($options)) {
                        if (class_exists($options)) {
                            $options = new $options;
                        } else {
                            $options = null;
                        }
                    }
                } else {
                    $options = null;
                }
                $plugin = new $plugin['class']($options);

                if ($plugin instanceof PluginInterface) {
                    $this->addPlugin($plugin);
                }
            }
        }
    }