当前位置: 首页>>代码示例>>PHP>>正文


PHP Dispatcher::setParam方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\Dispatcher::setParam方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::setParam方法的具体用法?PHP Dispatcher::setParam怎么用?PHP Dispatcher::setParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\Dispatcher的用法示例。


在下文中一共展示了Dispatcher::setParam方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeDispatch

 /**
  * puts any params in the url into an assoc array in the dispatcher
  * for example given this url
  *		/en/employer/profile/edit/id/5/company/6/email/test@test.com
  * then in the controller
  *		$this->dispatcher->getParam('id') = 5
  *		$this->dispatcher->getParam('company') = 6
  *		$this->dispatcher->getParam('email') = test@test.com
  * @param Event $event
  * @param Dispatcher $dispatcher
  */
 public function beforeDispatch(Event $event, Dispatcher $dispatcher)
 {
     $key_params = array();
     $params = $dispatcher->getParams();
     foreach ($params as $number => $value) {
         if ($number & 1) {
             $key_params[$params[$number - 1]] = $value;
         }
     }
     //loop again so we don't overwrite any params named in the route (like 'lang')
     foreach ($key_params as $param => $value) {
         if ($dispatcher->getParam($param) === null) {
             $dispatcher->setParam($param, $value);
         }
     }
 }
开发者ID:mrbubblesort,项目名称:waitlist,代码行数:27,代码来源:Params.php

示例2: action

 /**
  * @param \Phalcon\Events\Event $event
  * @param \Phalcon\Mvc\Dispatcher $dispatcher
  * @param array $params
  * @return mixed
  */
 public function action(Event $event, Dispatcher $dispatcher, $params)
 {
     $controller = $dispatcher->getControllerName();
     $action = $dispatcher->getActionName();
     $key = $controller . '/' . $action;
     // $cname = $dispatcher->getDI()->get(AppConstant::DI_SERVICE_API)->getApiClass($key);
     //非注册Api,不需要做校验
     // if ($cname == null) return;
     $cname = 'Account\\register';
     $c = new \ReflectionClass($cname);
     $object = $c->newInstance();
     //赋值
     $this->arrToObj($object, $params);
     $this->validate($cname, $object);
     $dispatcher->setParam(AppConstant::HTTP_PROTOCOL_DATA, $object);
 }
开发者ID:huxiaohe,项目名称:api-framework,代码行数:22,代码来源:ValidateInterceptor.php

示例3: beforeExecuteRoute

 /**
  * @param Event $event
  * @param Dispatcher $dispatcher
  * @return bool
  */
 public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
 {
     $role = 'guest';
     if ($this->session->has('user_id')) {
         $userId = $this->session->get('user_id');
         if ($userId) {
             $user = User::findFirst($userId);
             if ($user instanceof User) {
                 $role = 'user';
                 $dispatcher->setParam('user', $user);
             }
         }
     }
     $controller = strtolower($dispatcher->getControllerName());
     $action = strtolower($dispatcher->getActionName());
     if (!$this->acl->isAllowed($role, $controller, $action)) {
         $this->session->set('__callback_url', $this->request->getServer('REQUEST_URI'));
         $dispatcher->forward(['controller' => 'auth', 'action' => 'signIn']);
         return false;
     }
     return true;
 }
开发者ID:tankist,项目名称:blog-mvc,代码行数:27,代码来源:Auth.php


注:本文中的Phalcon\Mvc\Dispatcher::setParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。