本文整理汇总了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);
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例5: getActionLogCategory
/**
* @param Action $action
*
* @return string
*/
private function getActionLogCategory(Action $action)
{
return $this->actionCategoryPrefix . $action->getUniqueId();
}
示例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;
}
}
示例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;
}