private static function load_plugin(ContextManager $context, DirectoryIterator $plugin_path) { $plugin_load_file = $plugin_path->getPathname() . DIRECTORY_SEPARATOR . 'init.php'; if ($plugin_path->isDir() && is_file($plugin_load_file) && (require $plugin_load_file)) { $class = Plugins::plugin_class_name($plugin_path); try { $klass = new ReflectionClass($class); Plugins::add($klass->newInstance($context)); $context->logger()->debugf('%s --> %s', str_replace(MEDICK_PATH, '${' . $context->config()->application_name() . '}', $plugin_load_file), $class); } catch (ReflectionException $rfEx) { $context->logger()->warn('failed to load plugin `' . $plugin_path->getFilename() . '`: ' . $rfEx->getMessage()); } } }
public function skel() { Cli::enableHelp(); $dir = opendir(getcwd()); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..' && $file != 'data') { Cli::question("The current folder is not empty, do you want to continue?"); break; } } closedir($dir); Cli::pinfo("Create new CF project"); System::copyTree($this->getDir() . DIRECTORY_SEPARATOR . "project", getcwd()); $this->updateFiles(); chmod(getcwd() . DIRECTORY_SEPARATOR . "setup", 0755); System::ensureDir(DATA_DIR); $conf = Config::getInstance(); $conf->load(CONFIG_DIR . DIRECTORY_SEPARATOR . "config.json"); foreach ($conf->get("plugins", array()) as $plugin) { Plugins::add($plugin); } Cli::install(); Options::updateConf(array("DEBUG" => true)); }
/** * Create a new Plugin! * * @param string $name The name of the plugin. * @param string $author The creator of the plugin. * @param string $description A description of the plugin. Can be any length, but should be long enough to describe the plugin. * @param string $version * @param string $link Optional. The path to the homepage of the plugin. */ public function __construct($name, $author, $description, $version, $link = '') { $backtrace = debug_backtrace(); $caller = dirname($backtrace[0]['file']); $caller = str_replace('\\', '/', $caller); $caller = explode('/', rtrim($caller, '/\\')); $folderName = end($caller) . '/'; $this->dir = $folderName; $this->version = $version; $this->name = $name; $this->author = $author; $this->description = $description; if (Validate::link($link)) { $this->link = $link; } Plugins::add($this); }
* modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ if (!defined("ROOT_DIR")) { define("ROOT_DIR", getcwd()); } require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "cf.php"; if (file_exists(ROOT_DIR . "/phpunit.phar")) { include_once ROOT_DIR . "/phpunit.phar"; } if (!IS_CLI) { die("Not running from CLI"); } $logger = Logger::getInstance(); $logger->setLevel(Logger::WARNING); Plugins::add("Skel"); CorePlugin::loadConfig(); $cli = new Cli($_SERVER['argv']); Plugins::dispatchAll("cli", $cli); $cli->handle($cli->getCommand(), $cli->getArguments()); Output::finish();
<?php Plugins::add(["plugin1", "syslog"]);