作者:apure
项目:cm
/**
* 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);
}
作者:yinhear
项目:yincart
/**
* 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);
}
作者:lxpg
项目:yii2-ueditor-widge
public function init()
{
//csrf状态
Yii::$app->request->enableCsrfValidation = $this->csrf;
Yii::$app->request->enableCookieValidation = $this->csrf;
//当前目录
$this->currentPath = dirname(__FILE__);
return parent::init();
}
作者:VictorGu
项目:yii2-swagge
/**
* Returns description for method
* @return string
*/
public function description()
{
if (method_exists($this->action, 'description')) {
return $this->action->description();
}
return $this->docBlock ? $this->docBlock->getShortDescription() : '';
}
作者:anl
项目:yii2-helpe
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (!empty($this->data)) {
$this->data = call_user_func($this->data);
}
}
作者:chenkb
项目:yii2-regio
public function init()
{
parent::init();
if (!$this->model) {
throw new InvalidParamException('model不能为null');
}
}
作者:voskobovic
项目:yii2-liqpa
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->callable)) {
throw new InvalidParamException('Param "callable" can not be empty.');
}
}
作者:pjku
项目:kindedito
public function init()
{
//close csrf
Yii::$app->request->enableCsrfValidation = false;
//默认设置
// $this->php_path = dirname(__FILE__) . '/';
$this->php_path = $_SERVER['DOCUMENT_ROOT'] . '/';
$this->php_url = '/';
//根目录路径,可以指定绝对路径,比如 /var/www/attached/
$this->root_path = $this->php_path . 'upload/';
//根目录URL,可以指定绝对路径,比如 http://www.yoursite.com/attached/
$this->root_url = $this->php_url . 'upload/';
//图片扩展名
// $ext_arr = ['gif', 'jpg', 'jpeg', 'png', 'bmp'],
//文件保存目录路径
$this->save_path = $this->php_path . 'upload/';
//文件保存目录URL
$this->save_url = $this->php_url . 'upload/';
//定义允许上传的文件扩展名
// $ext_arr = array(
// 'image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp'),
// 'flash' => array('swf', 'flv'),
// 'media' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'),
// 'file' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'),
// ),
//最大文件大小
$this->max_size = 1000000;
$this->save_path = realpath($this->save_path) . '/';
//load config file
parent::init();
}
作者:AleksandrChernyavenk
项目:yii2-widget-depdro
/**
* @throws InvalidConfigException
*/
public function init()
{
parent::init();
if (!is_callable($this->outputFunction)) {
throw new InvalidConfigException('outputFunction must be callable');
}
}
作者:ramialcheik
项目:quickform
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->modelClass)) {
throw new InvalidConfigException('The "modelClass" property must be set.');
}
}
作者:heartshar
项目:yii2-recovery-password-toolki
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->modelClass == null) {
throw new InvalidConfigException('Param "modelClass" must be contain model name with namespace.');
}
}
作者:2amigo
项目:yii2-file-upload-widge
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
if (!isset($this->ownerLinkTable, $this->className)) {
throw new InvalidConfigException('"ownerLinkTable" and "className" attributes cannot be null');
}
parent::init();
}
作者:2amigo
项目:yii2-grid-view-librar
/**
* @inheritdoc
* @throws \yii\base\InvalidConfigException
*/
public function init()
{
if ($this->modelClass === null) {
throw new InvalidConfigException('"modelClass" cannot be empty.');
}
parent::init();
}
作者:2amigo
项目:yii2-file-upload-widge
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
if (!isset($this->ownerRelation, $this->ownerTable, $this->searchClass, $this->view)) {
throw new InvalidConfigException('"searchClass", "ownerRelation", "ownerTable" and "view" attributes cannot be null');
}
parent::init();
}
作者:webtoolsn
项目:yii2-importe
/**
* @return bool
*/
public function beforeRun()
{
Yii::$app->view->title = 'Update Record';
Yii::$app->view->params['breadcrumbs'][] = ['label' => 'Review Errors', 'url' => ['review-errors', 'id' => Yii::$app->request->get('id')]];
Yii::$app->view->params['breadcrumbs'][] = Yii::$app->view->title;
return parent::beforeRun();
}
作者:phpson
项目:yii2-gtreetabl
protected function afterRun()
{
if (is_callable($this->afterRun)) {
return call_user_func($this->afterRun);
}
parent::afterRun();
}
作者:heartshar
项目:yii2-usefu
/**
* Check if action has valid findModel method
*/
public function init()
{
parent::init();
if (!is_callable($this->findModel)) {
throw new InvalidConfigException('findModel must be set');
}
}
作者:hiqde
项目:hipanel-cor
public function init()
{
parent::init();
foreach ($this->allowedRoutes as &$allowedRoute) {
$allowedRoute = ltrim(Yii::getAlias($allowedRoute), '/');
}
return $this->controller->redirect(Yii::$app->request->getReferrer());
}
作者:kroshili
项目:yii2-yandex-kass
public function init()
{
parent::init();
$this->controller->enableCsrfValidation = false;
Yii::$app->response->setStatusCode(200);
Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
Yii::$app->response->headers->set('Content-Type', 'application/xml; charset=utf-8');
}
作者:legron
项目:yii2-perfect-mone
/**
* @inheritdoc
*/
public function init()
{
$this->api = \Yii::$app->get($this->componentName);
if (!$this->api instanceof Api) {
throw new InvalidConfigException('Invalid PerfectMoney component configuration');
}
parent::init();
}