コード例 #1
0
ファイル: form1.php プロジェクト: tbl0605/PHPYAM
 public function create()
 {
     Assert::isTrue(IntelliForm::submitted(true), 'The form was not submitted.');
     Assert::isTrue($this->checkFormValues() && $this->processForm(), 'The form data has not been processed correctly.');
     // Back to homepage...
     $this->getRouter()->forward(DEFAULT_CONTROLLER, DEFAULT_ACTION);
 }
コード例 #2
0
ファイル: Router.php プロジェクト: tbl0605/PHPYAM
 /**
  * (non-PHPdoc)
  *
  * @see \PHPYAM\core\interfaces\IRouter::call()
  */
 public final function call($urlController, $urlAction, array $urlParameters = array())
 {
     Assert::isTrue(is_string($urlController), StringUtils::gettext('The parameter %s is not of type string.'), $urlController);
     Assert::isTrue(is_string($urlAction), StringUtils::gettext('The parameter %s is not of type string.'), $urlAction);
     if ($this->isResource(SYS_APP . '/controllers', $urlController)) {
         // If so, then load this file and create this controller.
         // Example: if controller would be "car", then this line would translate into: $controller = new car($this);
         $this->loadResource(SYS_APP . '/controllers', $urlController);
         $controller = null;
         // Check for class: does such a class exist (and does it have a callable constructor)?
         if (method_exists($urlController, '__construct') && is_callable(array($urlController, '__construct'), true)) {
             // Call the class constructor and pass the reference to this router object.
             $controller = new $urlController($this);
         }
         // Check for method: does such a method exist (and is it callable) in the controller?
         if (is_object($controller) && method_exists($controller, $urlAction) && is_callable(array($controller, $urlAction))) {
             // Call the method and pass the arguments to it.
             $controller->{$urlAction}($urlParameters);
             return;
         }
     }
     // Invalid URL.
     throw new RouterException(StringUtils::gettext('URL is invalid.'));
 }