function __construct() { $this->handler = hwcli_instance('HWCLI_ImportActions_ActionHandler'); $this->load_plugin_setting_from_cli(); //register activation hook register_activation_hook(__FILE__, array($this, '_plugin_activate')); }
function __construct() { $this->actionHandler = hwcli_instance('HWCLI_ImportActions_ActionHandler'); }
/** * @param $handler * @param $action * @throws Exception */ private function _execute($handler, $action) { if (is_array($action)) { foreach ($action as $_action) { $object = $this->_execute($handler, $_action); } return isset($object) ? $object : null; } if (is_string($action) && strpos($action, 'action_') === false) { throw new Exception(sprintf(__('%s is not an correct action.'), $action)); } if ($handler == '') { if ($this->_default && method_exists($this->_default, $action)) { call_user_func(array($this->_default, $action)); return; } } else { $handler = ucfirst($handler); $handler_w = explode('_', $handler); $handler = ''; foreach ($handler_w as $w) { $handler .= ucfirst($w); } $handler_class = "HWCLI_ImportActions_{$handler}"; $handler_object = hwcli_instance($handler_class); if (method_exists($handler_object, $action)) { $handler_object->{$action}(); return $handler_object; } } throw new Exception(sprintf(__('action %s does not exist for %s'), $action, $handler)); }