Пример #1
0
 /**
  * Get an instance of a class based on a class identifier only creating it if it doesn't exist yet.
  *
  * @param   mixed $identifier An ObjectIdentifier, identifier string or object implementing ObjectInterface
  * @param	array $config     An optional associative array of configuration settings.
  * @return	ObjectInterface Return object on success, throws exception on failure
  * @throws	\RuntimeException if the object manager has not been defined.
  * @see 	ObjectInterface
  */
 public final function getObject($identifier, array $config = array())
 {
     if (!isset($this->__object_manager)) {
         throw new \RuntimeException("Failed to call " . get_class($this) . "::getObject(). No object_manager object defined.");
     }
     return $this->__object_manager->getObject($identifier, $config);
 }
Пример #2
0
 /**
  * @private 
  * 
  * flow
  */
 private function flow()
 {
     #Benchmark::start('CON');
     #Benchmark::start('SYS');
     $this->debug = $this->objectManager->getObject('Debug');
     // ---------------------------------------------------------------------------------
     // Filter-/Controller chains instances
     // ---------------------------------------------------------------------------------
     $this->initChains();
     // ---------------------------------------------------------------------------------
     // Controller Rules
     // ---------------------------------------------------------------------------------
     #print_r(NameSpaces::$NSP_Application);
     $this->ControllerRulesClass = NameSpaces::getNamespaceOfClassSpecification('ControllerRules', true);
     if (is_array($this->ControllerRulesClass)) {
         $this->ControllerRules = $this->objectManager->getObject('ControllerRules')->rules();
     }
     // ---------------------------------------------------------------------------------
     // Request
     // GET,POST,FILES,SERVER,HEADER,COOKIE
     // ---------------------------------------------------------------------------------
     // Request auslösen
     $request = $this->objectManager->getObject('Request');
     // ---------------------------------------------------------------------------------
     // ActionController
     // Names from Dispatcher and Router
     //
     // $dispatcher->getControllerName();
     // $dispatcher->getActionName();
     // ---------------------------------------------------------------------------------
     // Dispatcher
     $dispatcher = $this->objectManager->getObject('Dispatcher');
     // flrp (FLOWLite Router Protocol)
     $this->flrp = $this->objectManager->getObject('flrp');
     // Dispatch Controller and Action over Routing
     $dispatcher->dispatchControllerAction($request);
     // get Controller over Protocol FLRP
     $this->controller = $this->flrp->getController();
     // get Action over Protocol FLRP
     $this->action = $this->flrp->getAction();
     // ---------------------------------------------------------------------------------
     // RequestFilters
     // ---------------------------------------------------------------------------------
     // Filter ermitteln (RequestFilter) FilterChain
     $requestFilters = NameSpaces::getNamespaceOfClassSpecification('RequestFilter');
     if (is_array($requestFilters) && count($requestFilters) > 0) {
         // Filter instanzieren
         $this->initRequestFilter($requestFilters);
         // Alle Filter ausführen (Request übergeben)
         $this->requestFilters->execute($request);
     }
     // ---------------------------------------------------------------------------------
     // RequestValidator
     // ---------------------------------------------------------------------------------
     // Validator ermitteln (RequestValidator) ValidatorChain
     $requestValidators = NameSpaces::getNamespaceOfClassSpecification('RequestValidator');
     if (is_array($requestValidators) && count($requestValidators) > 0) {
         // Validator instanzieren
         $this->initRequestValidators($requestValidators);
         // Alle Validatoren ausführen (Request übergeben)
         $this->requestValidators->execute($request);
     }
     // ---------------------------------------------------------------------------------
     // PreController
     // Before Action Controller
     // ---------------------------------------------------------------------------------
     // PreController ermitteln
     $PreControllers = NameSpaces::getNamespaceOfClassSpecification('PreController');
     if (is_array($PreControllers) && count($PreControllers) > 0) {
         // Controller instanzieren
         $this->initPreControllers($PreControllers);
         // Controller ausführen (Request übergeben)
         $this->PreControllers->execute($request);
     }
     // ---------------------------------------------------------------------------------
     // PostController
     // After Action Controller
     // ---------------------------------------------------------------------------------
     // PreController ermitteln
     $PostControllers = NameSpaces::getNamespaceOfClassSpecification('PostController');
     if (is_array($PostControllers) && count($PostControllers) > 0) {
         // Controller instanzieren
         $this->initPostControllers($PostControllers);
     }
     // ---------------------------------------------------------------------------------
     // @@@ ActionController
     // @@@ action with praefix "Action"
     // @@@ run
     // ---------------------------------------------------------------------------------
     // Init Object
     $this->debug->trace('Action Controller: ' . $this->controller, 'FrontController');
     $this->debug->trace('Action : ' . $this->action, 'FrontController');
     // Existiert eine Controller Whitelist
     $ControllerExceptions = $this->objectManager->getObject('ControllerExceptions')->getExceptions();
     // @@@ Check Controller
     // @@@
     // @@@ Ist der Controller innerhalb der Whitelist zu finden (Kann, muss nicht)
     // @@@ Der Controller muss im Namespacebereich der Application gefunden werden.
     // @@@
     #echo $this->controller; echo "<br>";
     #echo $this->action; echo "<br>";
     #Benchmark::stop('CON');
     #echo "CON ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('CON'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
     #print_r(NameSpaces::$NSP_Application);
     #Benchmark::stop('SYS');
     #echo "SYS ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('SYS'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
     if (in_array($this->controller, $ControllerExceptions) || NameSpaces::classExistsInApplication($this->controller)) {
         // Inizialization controller
         $controller = $this->initActionController($this->controller);
         // Action
         $action = trim($this->action) . 'Action';
         #echo $this->controller;
         #echo "<br>";
         #echo $this->action;
         #exit;
         // Call controller and action
         // Check of object
         // Check of callable
         if ($this->isValid($controller) && is_callable(array($controller, $action))) {
             $controller->{$action}();
         } else {
             // Controller nicht gefunden, kein Object oder nicht aufrufbar
             throw new Exception('Controller not callable (' . $this->controller . '->' . $action . ') !', 273562354);
         }
     } else {
         // Controller nicht gefunden
         throw new Exception('Controller or Action not found (' . $this->controller . ') ! ', 273562352);
     }
     // ---------------------------------------------------------------------------------
     // PostController
     // After Action Controller
     // ---------------------------------------------------------------------------------
     if ($this->registry->SystemFrontControllerRepeater === false) {
         if (is_array($PostControllers) && count($PostControllers) > 0) {
             $this->PostControllers->execute($request);
         }
     } else {
         # $this->deletePostControllers($PostControllers);
     }
 }
Пример #3
0
 /**
  * Get an instance of an object identifier
  *
  * @param ObjectIdentifier|string $identifier An ObjectIdentifier or valid identifier string
  * @param array  			      $config     An optional associative array of configuration settings.
  * @return ObjectInterface  Return object on success, throws exception on failure.
  */
 public final function getObject($identifier, array $config = array())
 {
     $result = $this->__object_manager->getObject($identifier, $config);
     return $result;
 }