Example #1
0
 /**
  * gets the policy rules; if one matches to the current request, it will be executed
  *
  * @access public
  * @return void
  */
 public function __construct()
 {
     Event::RUN('mvc.policy.before');
     Event::BIND('mvc.error', function ($mPackage) {
         \MVC\Error::addERROR($mPackage);
     });
     $aPolicy = $this->getPolicyRuleOnCurrentRequest();
     if (!empty($aPolicy)) {
         foreach ($aPolicy as $sPolicy) {
             if ('' !== $sPolicy) {
                 // execute policy
                 if (call_user_func($sPolicy) === FALSE) {
                     \MVC\Event::RUN('mvc.error', "Policy could not be executed: " . $sPolicy);
                 }
             }
         }
     }
     Event::RUN('mvc.policy.after');
 }
Example #2
0
 /**
  * Destructor; 
  * runs Event mvc.controller.destruct
  * 
  * @access public
  * @return void
  */
 public function __destruct()
 {
     Event::RUN('mvc.controller.destruct');
 }
Example #3
0
 /**
  * Destructor; 
  * runs Event mvc.application.destruct
  * 
  * @access public
  * @return void
  */
 public function __destruct()
 {
     Event::RUN('mvc.application.destruct');
 }
Example #4
0
 /**
  * Stops any further execution: exits the script.<br />
  * Shows a Message from where the STOP command was called (default).
  * 
  * @access public
  * @static
  * @staticvar type $iCount
  * @param string $sData
  * @param boolean $bOccurrence show occurrence of STOP true|FALSE
  * @return void
  */
 public static function STOP($sData = '', $bOccurrence = true)
 {
     static $iCount;
     $iCount++;
     // source
     $aBacktrace = self::PREPAREBACKTRACEARRAY(debug_backtrace());
     ob_start();
     var_dump($sData);
     $mData = ob_get_contents();
     ob_end_clean();
     // output CLI
     if (isset($GLOBALS['argc'])) {
         $sConsultation = "\n---STOP-------------------------";
         $sConsultation .= "\nStopped at:";
         $sConsultation .= "\nFile:\t\t\t" . $aBacktrace['sFile'] . "";
         $sConsultation .= "\nLine:\t\t\t" . $aBacktrace['sLine'] . "";
         $sConsultation .= "\nClass::function:\t" . $aBacktrace['sClass'] . '::' . $aBacktrace['sFunction'] . "\n";
         echo $bOccurrence === true ? $sConsultation : '';
         if (isset($sData) && !empty($sData)) {
             echo $bOccurrence === true ? "\nData:\n" : '';
             echo $mData . "\n";
         }
         echo "\n---/STOP------------------------\n\n";
     } else {
         // show source
         $sConsultation = '<table style="padding:5px 0 2px 10px;background-color:white;color:red;width:100%;-moz-border-radius:20px; border-radius: 20px;" cellpadding="0" cellspacing="0">';
         $sConsultation .= '<tr><td><b><span style="font-size:10px;">' . $iCount . '</span></b></td><td></td></tr>';
         $sConsultation .= '<tr><td><b><span style="font-size:10px;">File:</span></b></td><td><span style="font-size:10px;">' . $aBacktrace['sFile'] . '</span></td></tr>';
         $sConsultation .= '<tr><td><b><span style="font-size:10px;">Line:</span></b></td><td><span style="font-size:10px;">' . $aBacktrace['sLine'] . '</span></td></tr>';
         $sConsultation .= '<tr><td><b><span style="font-size:10px;">Class/Method:</span></b></td><td><span style="font-size:10px;">' . $aBacktrace['sClass'] . '::' . $aBacktrace['sFunction'] . '</span></td></tr>';
         $sConsultation .= '</table>';
         // display
         echo '<div style="padding:10px;z-index:10000;position:fixed;top:10px;left:10px;background-color:red;color:white;border:2px solid gray;width:400px;height:auto;overflow:auto;-moz-border-radius:20px; border-radius: 20px;"><b>';
         echo $bOccurrence === true ? '<h1 style="font-size:20px;">STOP</h1><p>Stopped at:</p>' . $sConsultation : '';
         if (isset($sData) && !empty($sData)) {
             echo $bOccurrence === true ? '<h2>Data</h2><p>' : '';
             echo '<pre style="font-size:10px;overflow:auto;max-height:300px;background-color:transparent;color:#fff;border: none;">' . $mData . '</pre></p>';
         }
         echo '</b></div>';
     }
     Event::RUN('mvc.helper.stop', $aBacktrace);
     exit;
 }
Example #5
0
 /**
  * prepares query vars for usage
  * 
  * @access public
  * @return \MVC\Request
  */
 public function prepareQueryVarsForUsage()
 {
     $aFallback = self::URLQUERYTOARRAY(Registry::get('MVC_ROUTING_FALLBACK'));
     if (array_key_exists('GET', $this->_aQueryVar)) {
         // add standard module if missing
         if (!array_key_exists(Registry::get('MVC_GET_PARAM_MODULE'), $this->_aQueryVar['GET']) || $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_MODULE')] == '') {
             $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_MODULE')] = $aFallback[Registry::get('MVC_GET_PARAM_MODULE')];
         }
         // add standard constroller if missing
         if (!array_key_exists(Registry::get('MVC_GET_PARAM_C'), $this->_aQueryVar['GET']) || $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_C')] == '') {
             $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_C')] = $aFallback[Registry::get('MVC_GET_PARAM_C')];
         }
         // add standard method if missing
         if (!array_key_exists(Registry::get('MVC_GET_PARAM_M'), $this->_aQueryVar['GET']) || $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_M')] == '') {
             $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_M')] = $aFallback[Registry::get('MVC_GET_PARAM_M')];
         }
     } else {
         $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_MODULE')] = $aFallback[Registry::get('MVC_GET_PARAM_MODULE')];
         $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_C')] = $aFallback[Registry::get('MVC_GET_PARAM_C')];
         $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_M')] = $aFallback[Registry::get('MVC_GET_PARAM_M')];
     }
     // capitals at beginning
     $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_MODULE')] = ucfirst($this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_MODULE')]);
     $this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_C')] = ucfirst($this->_aQueryVar['GET'][Registry::get('MVC_GET_PARAM_C')]);
     Event::RUN('mvc.request.prepared');
     return $this;
 }
Example #6
0
 /**
  * runs event 'mvc.reflex.destruct'
  * 
  * @access public
  * @return void
  */
 public function __destruct()
 {
     Event::RUN('mvc.reflex.destruct');
 }