public function defaultAction()
 {
     $options = array();
     $parser = $this->_readCommandLineRequest();
     try {
         $result = $parser->parse();
         $options = $result->options;
     } catch (Exception $exc) {
         $parser->displayError($exc->getMessage());
     }
     if ($options['clearcache']) {
         if (__ModelProxy::getInstance()->clearCache()) {
             echo "Cache cleared!\n";
         }
     } else {
         if ($options['info']) {
             $this->_printLionInfo();
         } else {
             if ($options['bootstrap']) {
                 if (__ModelProxy::getInstance()->doBootstrap(APP_DIR)) {
                     echo "Bootstrap completed!\n";
                 }
             } else {
                 $parser->displayUsage();
             }
         }
     }
 }
 public function bootstrap_form_submit(__UIEvent &$event)
 {
     if (__ModelProxy::getInstance()->doBootstrap(APP_DIR)) {
         $uri = __UriFactory::getInstance()->createUri()->setRoute('lion')->setController('bootstrap')->setAction('success');
         __FrontController::getInstance()->redirect($uri);
     }
 }
 public function clearAction()
 {
     __ApplicationContext::getInstance()->getSession()->destroy();
     __ModelProxy::getInstance()->clearCache();
     $mav = new __ModelAndView('confirmation');
     $mav->title = 'Cache cleared!';
     return $mav;
 }
 /**
  * This method return a singleton reference to the current instance
  *
  * @return __ModelProxy A singleton reference to the current __ModelProxy
  */
 public static function &getInstance()
 {
     if (self::$_instance == null) {
         // Use "Lazy initialization"
         self::$_instance = new __ModelProxy();
     }
     return self::$_instance;
 }
Example #5
0
 /**
  * The hello world action. It just put the message 'Hello world'
  * in a __ModelAndView instance and returns it.
  * 
  */
 public function helloWorldAction()
 {
     //create a new __ModelAndView instance
     $model_and_view = new __ModelAndView();
     //get the 'Hello world' message from the model:
     $model_and_view->hello_world_message = __ModelProxy::getInstance()->getHelloWorldString();
     //returns the __ModelAndView
     return $model_and_view;
 }
 public function login_form_submit(__UIEvent &$event)
 {
     $login = $this->getComponent('login')->getValue();
     $password = $this->getComponent('password')->getValue();
     //authenticate the user:
     $user = __ModelProxy::getInstance()->logon($login, $password);
     //if authentication success
     if ($user != null) {
         //redirect the user to the private page:
         __FrontController::getInstance()->redirect('protectedPage.action');
     }
 }
 public function login_form_submit(__UIEvent &$event)
 {
     //retrieve the login and password from
     //the components:
     $login = $this->getComponent('login')->getValue();
     $password = $this->getComponent('password')->getValue();
     //try to authenticate the user:
     if (__ModelProxy::getInstance()->logon($login, $password)) {
         //redirect the user to the private page:
         $private_page_uri = __UriFactory::getInstance()->createUri()->setRoute('default')->setController('protectedPage');
         __FrontController::getInstance()->forward($private_page_uri);
     } else {
         $this->getComponent('error_label')->setText('Wrong username or password');
     }
 }
 protected function _resolveAndCallRemoteService(__IRequest &$request)
 {
     $return_value = null;
     $request = __FrontController::getInstance()->getRequest();
     if ($request->hasParameter('service_name')) {
         $service_name = $request->getParameter('service_name');
         $model_proxy = __ModelProxy::getInstance();
         if ($model_proxy->isRemoteService($service_name)) {
             $model_service = $model_proxy->getModelService($service_name);
             $return_value = $model_service->callAsRemoteService($request);
         } else {
             throw __ExceptionFactory::getInstance()->createException('Service ' . $service_name . ' is not declared as remote');
         }
     }
     return $return_value;
 }
 public function defaultAction()
 {
     if (__ModelProxy::getInstance()->prepareAndValidateBootstrapEnvironment(APP_DIR) && __ModelProxy::getInstance()->doBootstrap(APP_DIR)) {
         echo "Congratullations, bootstrap done successfully!\n";
     }
 }
<?php

//retrieve all the invoices:
$invoices = __ModelProxy::getInstance()->getAllInvoices();
//retrieve a concrete invoice:
$invoice = __ModelProxy::getInstance()->getInvoice($invoice_id);
//save an invoice:
__ModelProxy::getInstance()->saveInvoice($invoice);