public function beforeAction() { $this->contexts = Contexts::instance(); $this->reqCon = RequestContext::instance(); $this->sesCon = SessionContext::instance(); $this->em = Zool::app()->em; }
public function resolveFromContext($name, $default = null) { $value = $this->getContext($name); if (is_null($value)) { $value = Contexts::instance()->get($name, $default); } return is_null($value) ? $default : $value; }
public function init() { $this->valueBindScope = Contexts::instance()->getVariableContext($this->valueBind); $form = $this->getFormParent(); $form->registerElement($this); $this->bindPropertyToAttribute('id'); parent::init(); }
public function save($id) { $em = Zool::app()->entityManager; $estate = $em->find('app\\model\\Estate', $id); list($y, $m, $d) = explode('-', Contexts::instance()->get('estate_created')); SessionContext::instance()->set('created_msg', Contexts::instance()->get('estate_created')); $estate->name = Contexts::instance()->get('estate_name'); $date = new \DateTime(); $date->setDate($y, $m, $d); $estate->created = $date; $em->persist($estate); $em->flush(); }
public function run() { // TODO better method handlin $object = Contexts::instance()->get($this->object); if ($object != null) { if ($object instanceof ZController) { $object->beforeAction(); } return call_user_func_array(array($object, $this->method), $this->params); } else { throw new ZExpressionException($this->object . ' cannot resolved from any context.'); } }
public function __construct($config = array()) { parent::__construct($config); set_error_handler(array($this, 'errorHandler')); set_exception_handler(array($this, 'exceptionHandler')); $asp = isset($_GET['asp']) ? $_GET['asp'] : 'xul'; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $reRender = isset($_REQUEST['reRender']) ? $_REQUEST['reRender'] : null; $zoolForm = isset($_REQUEST['zoolForm']) ? $_REQUEST['zoolForm'] : null; Annotations::$config['cachePath'] = APP_PATH . '/runtime'; // Zool specific annotations Annotations::getManager()->registry['scope'] = 'Annotation\\Standard\\ScopeAnnotation'; Annotations::getManager()->registry['method'] = 'Annotation\\Standard\\MethodAnnotation'; // obtaining the entity manager $em = $this->entityManager; if ($asp == 'xul') { $this->viewProvider = new ZXulViewProvider(); } else { $this->viewProvider = new ZWebViewProvider(); } /** * Input value binding */ if ($zoolForm !== null && is_array($zoolForm)) { foreach ($zoolForm as $key => $value) { list($var, $scope) = explode(':', $key, 2); try { if ($scope == UNSPECIFIED_SCOPE) { $scope = EVENT_SCOPE; } Contexts::instance()->setToContext($scope, $var, $value); } catch (ZException $e) { throw new ZException($e->getMessage()); } } } if ($action !== null) { $methodExpression = PageContext::instance()->get($action); if ($methodExpression instanceof ZMethodExpression) { $methodExpression->run(); } // there is no outputing } EventContext::instance()->reset(); if ($reRender !== null) { $this->viewProvider->handleReRender(); } if ($action !== null || $reRender !== null) { die; } }