public static function makeLazy($className, $args, $after = null, $singleton = false) { $callback = Gongo_Fn::papply('Gongo_Locator::make', $className, $args); if (!is_null($after)) { $callback = Gongo_Fn::after($callback, $after); } if ($singleton) { $callback = Gongo_Fn::once($callback); } return self::get('Gongo_Proxy_Lazy', $callback); }
function invoke($arg = null) { if ($this->arity <= 0) { return Gongo_Fn::call($this->callback); } $this->arguments[] = $arg; if ($this->arity <= count($this->arguments)) { return Gongo_Fn::apply($this->callback, $this->arguments); } return array($this, 'invoke'); }
public function __call($method, $args) { if (strpos($method, '_before') === 0 && strlen($method) > 7) { $method = strtolower(substr($method, 7, 1)) . substr($method, 8); list($before) = $args; $callback = isset($this->_____callbacks[$method]) ? $this->_____callbacks[$method] : array($this->_____, $method); return $this->_____callbacks[$method] = Gongo_Fn::before($callback, $before); } else { if (strpos($method, '_after') === 0 && strlen($method) > 6) { $method = strtolower(substr($method, 6, 1)) . substr($method, 7); list($after) = $args; $callback = isset($this->_____callbacks[$method]) ? $this->_____callbacks[$method] : array($this->_____, $method); return $this->_____callbacks[$method] = Gongo_Fn::after($callback, $after); } else { if (strpos($method, '_around') === 0 && strlen($method) > 7) { $method = strtolower(substr($method, 7, 1)) . substr($method, 8); list($around) = $args; $callback = isset($this->_____callbacks[$method]) ? $this->_____callbacks[$method] : array($this->_____, $method); return $this->_____callbacks[$method] = Gongo_Fn::around($callback, $around); } else { if (strpos($method, '_getter') === 0 && strlen($method) > 7) { $property = strtolower(substr($method, 7, 1)) . substr($method, 8); list($around) = $args; if (isset($this->_____getterCallbacks[$property])) { $callback = $this->_____getterCallbacks[$property]; } else { $callback = Gongo_Fn::property($this->_____)->getter($property); } return $this->_____getterCallbacks[$property] = Gongo_Fn::around($callback, $around); } else { if (strpos($method, '_setter') === 0 && strlen($method) > 7) { $property = strtolower(substr($method, 7, 1)) . substr($method, 8); list($around) = $args; if (isset($this->_____setterCallbacks[$property])) { $callback = $this->_____setterCallbacks[$property]; } else { $callback = Gongo_Fn::property($this->_____)->setter($property); } return $this->_____setterCallbacks[$property] = Gongo_Fn::around($callback, $around); } } } } } if (isset($this->_____callbacks[$method])) { return call_user_func_array($this->_____callbacks[$method], $args); } return parent::__call($method, $args); }
public function render($app, $err, $fnCallback = false) { $header = isset($this->httpError[$err]) ? $this->httpError[$err] : "HTTP/1.0 {$err}"; header($header); $output = $fnCallback ? Gongo_Fn::call($fnCallback) : null; if (is_null($output) && Gongo_App::cfg()) { $layout = Gongo_App::cfg()->Error->layout; $context = array(); if ($layout) { $context['layout'] = $layout; } echo $app->render($err, $context, $app->errorTemplate); } else { $output = $output ? $output : $header; echo $output; } die; }
protected function execute($callback, $url, $method) { $method = strtoupper($method); $params = $url->params; $callback = Gongo_Fn::before($callback, Gongo_Fn::quote($this)->setSessionValue); $urlMatch = $this->factory->getObj('Gongo_App_Url_Router', array('-mountPoint' => $url->options->mountPoint)); $this->afterInitUrl($urlMatch); foreach (array('around', 'before', 'after') as $kind) { $callback = $this->setFilterCallback($kind, $callback, $urlMatch); } $this->attach('args', array('Gongo_Bean_ArrayWrapper', $params)); return call_user_func_array($callback, $params); }
public function getNumberOfParameters() { $arity = Gongo_Fn::arity($this->callback); return !is_null($arity) ? $arity - count($this->arguments) : null; }
static function around($callback, $around) { return Gongo_Fn::create($callback)->around($around)->fetch(); }
function around($callback, $around) { return Gongo_Fn::around($callback, $around); }
public function afterInit($sName, $callback) { if (isset($this->components[$sName])) { $this->components[$sName] = Gongo_Fn::after($this->components[$sName], $callback); } }
function setter($property) { return Gongo_Fn::quote($this)->setProperty($property); }