public function __construct($plugin_path) { if (!is_string($plugin_path) && empty(CommonHelpers::strim($plugin_path))) { throw new ArgException(ArgException::INVALID_PARAMETER_TYPE, [__('Inproper type of parameter', PluginDataSet::load()->plugin_name)]); } $this->_plugin_path = $plugin_path; }
public static function activate($plugin_parent = "") { $init = new self(CommonHelpers::strim($plugin_parent)); if (!empty($init->parent_plugin)) { $init->checkPlugin(); } PluginMigration::load()->up(); }
private function loadExtlib($lib) { $extPath = explode('/', $lib['src']); $name = array_pop($extPath); if (Http::load()->isValid($extPath)) { // return local path to the downloaded file return CommonHelpers::loadFile($lib['src'], $name); } else { throw new HTTPException(HTTPException::NOT_FOUND, [$extPath]); } }
/** * MGPLN costructor * @access public * @param string $name The string used to uniquely identify this plugin. * @param string $version To identify the version of the plugin */ public function __construct($name = 'megaforms', $version = 'beta') { PluginDataSet::load()->version = CommonHelpers::strim($version); PluginDataSet::load()->plugin_name = CommonHelpers::strim($name); PluginDataSet::load()->plugin_path = plugin_dir_path(__DIR__); PluginDataSet::load()->plugin_url = plugin_dir_url(__DIR__); PluginDataSet::load()->vendor_path = PluginDataSet::load()->plugin_path . 'Vendor/'; PluginDataSet::load()->libs_path = PluginDataSet::load()->vendor_path . 'Libs/'; PluginDataSet::load()->views_path = PluginDataSet::load()->vendor_path . 'Views/'; PluginDataSet::load()->uploads_path = PluginDataSet::load()->vendor_path . 'data/.uploads/'; /** object PluginDataSet */ PluginDataSet::load()->checkDependencies(); I18n::load()->setUp(); }
/** * @param $menu_slug * @param string $submenu_slug * @return bool */ public function menu_slug_exists($menu_slug, $submenu_slug = '') { if (array_key_exists($menu_slug, $this->_settings)) { if (strlen(CommonHelpers::strim($submenu_slug)) > 0) { foreach ($this->_settings[$menu_slug] as $submenu_page) { if (array_key_exists($submenu_slug, $submenu_page)) { return true; } } return false; } return true; } return false; }
/** * Get column values from associative array * @param array $columns * @return string * @throws ArgException */ private function parseValues(array $columns) { if (CommonHelpers::isAssoc($columns)) { return ltrim(',', implode(',', array_values($columns))); } else { throw new ArgException(ArgException::INVALID_PARAMETER_TYPE, ['associative array given']); } }
/** * @param $queryHashes * @return array|null * @throws DbException * @throws MigrationException */ public function commit($queryHashes) { if (is_array($queryHashes)) { $queryResults = []; $queryHashes = CommonHelpers::trim_values($queryHashes); foreach ($queryHashes as $index => $hash) { if (!empty($hash) && is_string($hash)) { $queryResults[$hash] = $this->doQuery($hash); } else { throw new MigrationException("Undefined query hash"); } } return $queryResults; } else { if (is_string($queryHashes)) { $queryHashes = CommonHelpers::strim($queryHashes); return $this->doQuery($queryHashes); } else { throw new MigrationException("Undefined type of query hash"); // @TODO: refactor Exception structure for derived class from Db } } }