function handlersFunctionList($handler) { if (array_key_exists($handler, $this->specialHandlers)) { return false; } App::import('Lib', 'ClassCollection'); $class = ClassCollection::getClass("handler", $handler); if ($class) { $ignorePaterns = array('/^_/', '/_form$/', '/^(?P<parent>.*)_log$/', '/_deconstruct$/'); $methods = get_class_methods($class); $fromParent = get_class_methods("handler"); $methods = array_diff($methods, $fromParent); $list = array(); foreach ($methods as $method) { foreach ($ignorePaterns as $patern) { if (preg_match($patern, $method, $matches)) { if (!empty($matches['parent'])) { $method = $matches['parent']; continue 1; } continue 2; } } $list[$method] = Inflector::humanize(Inflector::underscore($method)); } } return $list; }
function getTargetHandlers($named = false) { App::import('Lib', 'ClassCollection'); App::import('Lib', 'SetMulti'); $class = ClassCollection::getClass('handler', 'Skills'); $methods = get_class_methods($class); $targetHandlers = SetMulti::pregFilter('/^target\\w*$/', $methods); //debug($targetHandlers); if ($named) { $list = array(); foreach ($targetHandlers as $handler) { $list[$handler] = Inflector::humanize(Inflector::underscore($handler)); } $targetHandlers = $list; } return $targetHandlers; }
function admin_method_form($name, $prefix) { $this->layout = 'ajax'; App::import('Lib', 'Shop.ClassCollection'); $class = ClassCollection::getClass('promo', $name); $method = new $class(); if (method_exists($method, 'beforeForm')) { $method->beforeForm($this); } $this->set('method', $method); $this->set('prefix', $prefix); }
function getMethods($data = null) { $methods = array(); $methodsOpts = array(); if (empty($data)) { $data = $this->data; } if (!isset($data['ShopPromo'])) { $data = array('ShopPromo' => $data); } if (!empty($data['ShopPromo']['cond'])) { foreach ($data['ShopPromo']['cond'] as $pos => $name) { $opt = array('name' => $name, 'params' => array()); if (!empty($data['ShopPromo']['cond_params'][$pos])) { $opt['params'] = $data['ShopPromo']['cond_params'][$pos]; } $methodsOpts[] = $opt; } } if (!empty($data['ShopPromo']['method'])) { $methodsOpts[] = array('name' => $data['ShopPromo']['method'], 'params' => !empty($data['ShopPromo']['method_params']) ? $data['ShopPromo']['method_params'] : array()); } App::import('Lib', 'Shop.ClassCollection'); foreach ($methodsOpts as $opt) { $class = ClassCollection::getClass('promo', $opt['name']); $method = new $class($data, $opt['params']); $methods[] = $method; } return $methods; }