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


PHP Action::getUniqueId方法代码示例

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


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

示例1: isActive

 /**
  * Returns a value indicating whether the filer is active for the given action.
  * @param \yii\base\Action $action the action being filtered
  * @return boolean whether the filer is active for the given action.
  */
 protected function isActive($action)
 {
     if ($action->getUniqueId() === Yii::$app->getErrorHandler()->errorAction) {
         return false;
     }
     return parent::isActive($action);
 }
开发者ID:apurey,项目名称:cmf,代码行数:12,代码来源:AccessControl.php

示例2: matchActionAccess

 /**
  * check the permission, if we rewrite and controller, the controller id and module id is not changed
  * @param \yii\base\Action $action
  * @param \yii\web\User $user
  * @param \yii\web\Request $request
  * @return bool
  */
 public function matchActionAccess($action, $user, $request)
 {
     if ($user->getIsGuest()) {
         return false;
     }
     /** @var \core\auth\Module $authModule */
     $authModule = \Yii::$app->getModule('core_auth');
     foreach ($authModule->getAdmins() as $key => $admin) {
         if ($user->getIdentity()->username == $admin['username']) {
             return true;
         }
     }
     if ($action->controller->module instanceof Application) {
         $key = 'default' . '_' . $action->controller->id . '_' . $action->id;
     } else {
         $key = $action->getUniqueId();
         $key = explode('/', $key);
         array_shift($key);
         $key = implode('_', $key);
     }
     $key = lcfirst(implode('', array_map(function ($k) {
         return ucfirst($k);
     }, explode('-', $key))));
     return $user->can($key, $this->params);
 }
开发者ID:yinheark,项目名称:yincart2,代码行数:32,代码来源:ActionAccessRule.php

示例3: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * You may override this method to do last-minute preparation for the action.
  * @param Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     if (!$this->enabled) {
         return true;
     }
     $this->cache = Instance::ensure($this->cache, Cache::className());
     $properties = [];
     foreach (['cache', 'duration', 'dependency', 'variations'] as $name) {
         $properties[$name] = $this->{$name};
     }
     $id = $this->varyByRoute ? $action->getUniqueId() : __CLASS__;
     $response = Yii::$app->getResponse();
     ob_start();
     ob_implicit_flush(false);
     if ($this->view->beginCache($id, $properties)) {
         $response->on(Response::EVENT_AFTER_SEND, [$this, 'cacheResponse']);
         return true;
     } else {
         $data = $this->cache->get($this->calculateCacheKey());
         if (is_array($data)) {
             $this->restoreResponse($response, $data);
         }
         $response->content = ob_get_clean();
         return false;
     }
 }
开发者ID:albertinho88,项目名称:jlweb,代码行数:32,代码来源:PageCache.php

示例4: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * You may override this method to do last-minute preparation for the action.
  * @param Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     $properties = [];
     foreach (['cache', 'duration', 'dependency', 'variations', 'enabled'] as $name) {
         $properties[$name] = $this->{$name};
     }
     $id = $this->varyByRoute ? $action->getUniqueId() : __CLASS__;
     ob_start();
     ob_implicit_flush(false);
     if ($this->view->beginCache($id, $properties)) {
         return true;
     } else {
         Yii::$app->getResponse()->content = ob_get_clean();
         return false;
     }
 }
开发者ID:sanggabee,项目名称:hellomedia-yii-basic,代码行数:22,代码来源:PageCache.php

示例5: getActionLogCategory

 /**
  * @param Action $action
  *
  * @return string
  */
 private function getActionLogCategory(Action $action)
 {
     return $this->actionCategoryPrefix . $action->getUniqueId();
 }
开发者ID:sp-niemand,项目名称:yii2-pinba,代码行数:9,代码来源:ApplicationProfilingBehavior.php

示例6: beforeAction

 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * You may override this method to do last-minute preparation for the action.
  * @param Action $action the action to be executed.
  * @return boolean whether the action should continue to be executed.
  */
 public function beforeAction($action)
 {
     $properties = [];
     foreach (['cache', 'duration', 'dependency', 'variations', 'enabled'] as $name) {
         $properties[$name] = $this->{$name};
     }
     $id = $this->varyByRoute ? $action->getUniqueId() : __CLASS__;
     // Disable layout, cache only action result
     $controller = $action->controller;
     $this->_controllerLayout = $controller->layout;
     $controller->layout = false;
     ob_start();
     ob_implicit_flush(false);
     if ($this->view->beginCache($id, $properties)) {
         return true;
     } else {
         $actionContent = ob_get_clean();
         $controller->layout = $this->_controllerLayout;
         Yii::$app->getResponse()->content = $controller->renderContent($actionContent);
         return false;
     }
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:28,代码来源:ActionCache.php

示例7: isAllowedAction

 /**
  * Returns a value indicating whether a current url exists in the `allowActions` list.
  *
  * @param Action $action
  *
  * @return bool
  */
 private function isAllowedAction($action)
 {
     if ($this->owner instanceof Module) {
         $ownerId = $this->owner->getUniqueId();
         $id = $action->getUniqueId();
         if (!empty($ownerId) && strpos($id, $ownerId . '/') === 0) {
             $id = substr($id, strlen($ownerId) + 1);
         }
     } else {
         $id = $action->id;
     }
     foreach ($this->allowActions as $route) {
         if (substr($route, -1) === '*') {
             $route = rtrim($route, '*');
             if ($route === '' || strpos($id, $route) === 0) {
                 return true;
             }
         } else {
             if ($id === $route) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:yii2mod,项目名称:yii2-rbac,代码行数:32,代码来源:AccessControl.php


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