/** * Generate the plugin. */ public function generate() { $name = $this->getName(); if ($this->plugin->has($name)) { if ($this->force) { $this->plugin->delete($name); } else { $this->console->error("plugin [{$name}] already exist!"); return; } } $this->generateFolders(); $this->generateFiles(); if (!$this->plain) { $this->generateResources(); } $this->console->info("plugin [{$name}] created successfully."); }
/** * Delete plugin from Plugin Folder * * @param string plugin name/folder */ public static function delete($folder = NULL) { if ($folder) { if (is_dir(PLUGINPATH . $folder)) { // First Delete Files Recursively $files = scandir(PLUGINPATH . $folder); array_shift($files); // remove '.' from array array_shift($files); // remove '..' from array foreach ($files as $file) { $file = PLUGINPATH . $folder . "/" . $file; if (is_dir($file)) { plugin::delete($file); try { rmdir($file); } catch (Kohana_Database_Exception $e) { // Log exceptions Kohana::log('error', 'Caught exception: ' . $e->getMessage()); } } else { try { unlink($file); } catch (Kohana_Database_Exception $e) { // Log exceptions Kohana::log('error', 'Caught exception: ' . $e->getMessage()); } } } } } }