Ejemplo n.º 1
0
 public function installThemePlugin($pluginName)
 {
     $toDir = ipFile('Plugin/' . $pluginName . '/');
     $fromDir = ipThemeFile('Plugin/' . $pluginName . '/');
     if (is_dir($toDir)) {
         throw new \Ip\Exception('This plugin has been already installed');
     }
     if (!is_dir($fromDir)) {
         throw new \Ip\Exception('Plugin is missing.');
     }
     $pluginConfiguration = \Ip\Internal\Plugins\Service::parsePluginConfigFile($fromDir);
     if (!$pluginConfiguration) {
         throw new \Ip\Exception('Can\'t read plugin configuration file.');
     }
     if (!is_writable(ipFile('Plugin/'))) {
         throw new \Ip\Exception('Please make plugin dir writable (' . esc($this->getThemePluginDir()) . ')');
     }
     $helper = Helper::instance();
     $helper->cpDir($fromDir, $toDir);
     \Ip\Internal\Plugins\Service::activatePlugin($pluginName);
 }