示例#1
0
 /**
  *  Ethna_ViewClassのコンストラクタ
  *
  *  @access public
  *  @param  string  $forward_name   ビューに関連付けられている遷移名
  *  @param  string  $forward_path   ビューに関連付けられているテンプレートファイル名
  */
 public function __construct(ContainerInterface $container, Ethna_ActionForm $action_form, $forward_name, $forward_path)
 {
     $this->container = $container;
     $this->container->view = $this;
     $this->config = $this->container->getConfig();
     $this->i18n = $this->container->getI18N();
     $this->logger = $this->container->getLogger();
     $this->plugin = $this->container->getPlugin();
     $this->action_error = $this->container->getActionError();
     $this->ae = $this->action_error;
     $this->action_form = $action_form;
     $this->af = $action_form;
     $this->session = $this->container->getSession();
     $this->forward_name = $forward_name;
     $this->forward_path = $forward_path;
     foreach (array_keys($this->helper_action_form) as $action) {
         $this->addActionFormHelper($action);
     }
 }
示例#2
0
文件: Kernel.php 项目: dqneo/ethnam
 /**
  *  フレームワークの処理を実行する(WWW)
  *
  *  引数$default_action_nameに配列が指定された場合、その配列で指定された
  *  アクション以外は受け付けない(指定されていないアクションが指定された
  *  場合、配列の先頭で指定されたアクションが実行される)
  *
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) : Response
 {
     $default_action_name = $this->default_action_name;
     self::$instance = $this;
     Ethna::setErrorCallback(array($this, 'handleError'));
     $this->container = new Ethna_Container(BASE, $this->directory, $this->class, $this->appid, $this->locale, $this->sessionName);
     $this->directory = $this->container->getDirectories();
     $config = $this->container->getConfig();
     $url = $config->get('url');
     if (empty($url)) {
         $url = Ethna_Util::getUrlFromRequestUri();
         $config->set('url', $url);
     }
     $this->container->url = $url;
     $plugin = $this->container->getPlugin();
     $this->logger = $this->container->getLogger();
     $plugin->setLogger($this->logger);
     $this->logger->begin();
     $actionDir = $this->directory['action'] . "/";
     $default_form_class = $this->class['form'];
     $actionResolverClass = $this->class['action_resolver'];
     /** @var Ethna_ActionResolver $actionResolver */
     $actionResolver = new $actionResolverClass($this->container->getAppId(), $this->logger, $default_form_class, $actionDir);
     $this->container->setActionResolver($actionResolver);
     // アクション名の取得
     $action_name = $actionResolver->resolveActionName($request, $default_action_name);
     $this->container->setCurrentActionName($action_name);
     $this->container->getSession()->restore();
     $i18n = $this->container->getI18N();
     $i18n->setLanguage($this->locale);
     // アクションフォーム初期化
     // フォーム定義、フォーム値設定
     $action_form = $actionResolver->newActionForm($action_name, $this->container);
     $this->container->setActionForm($action_form);
     $viewResolver = new Ethna_ViewResolver($this->container, $this->logger, $this->container->getViewdir(), $this->container->getAppId(), $this->class['view']);
     $callable = $actionResolver->getController($request, $action_name, $this->container, $action_form, $viewResolver);
     $arguments = [$request];
     $response = call_user_func_array($callable, $arguments);
     return $response;
 }