本文整理汇总了PHP中yii\web\Controller::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::init方法的具体用法?PHP Controller::init怎么用?PHP Controller::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Controller
的用法示例。
在下文中一共展示了Controller::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
$model = new Category();
$map = ['status' => 1];
$model->getList($map);
}
示例2: init
public function init()
{
parent::init();
if ($user = Yii::$app->getUser()) {
$this->auth_user = $user->identity;
}
}
示例3: init
public function init()
{
parent::init();
$this->titleMeta = Yii::$app->name;
$this->siteNameMeta = Yii::$app->name;
$this->descriptionMeta = Yii::t('app', 'Free classifieds from all over the world !!!');
}
示例4: init
public function init()
{
parent::init();
//CSRF 基于 POST 验证,UEditor 无法添加自定义 POST 数据,同时由于这里不会产生安全问题,故简单粗暴地取消 CSRF 验证。
//如需 CSRF 防御,可以使用 server_param 方法,然后在这里将 Get 的 CSRF 添加到 POST 的数组中。。。
Yii::$app->request->enableCsrfValidation = false;
//当客户使用低版本IE时,会使用swf上传插件,维持认证状态可以参考文档UEditor「自定义请求参数」部分。
//http://fex.baidu.com/ueditor/#server-server_param
//保留UE默认的配置引入方式
if (file_exists(__DIR__ . '/config.json')) {
$CONFIG = json_decode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", '', file_get_contents(__DIR__ . '/config.json')), true);
} else {
$CONFIG = [];
}
if (!is_array($this->config)) {
$this->config = [];
}
if (!is_array($CONFIG)) {
$CONFIG = [];
}
$default = ['imagePathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'scrawlPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'snapscreenPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'catcherPathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}', 'videoPathFormat' => '/upload/video/{yyyy}{mm}{dd}/{time}{rand:8}', 'filePathFormat' => '/upload/file/{yyyy}{mm}{dd}/{rand:8}_{filename}', 'imageManagerListPath' => '/upload/image/', 'fileManagerListPath' => '/upload/file/'];
$this->config = $this->config + $default + $CONFIG;
$this->webroot = Yii::getAlias('@webroot');
if (!is_array($this->thumbnail)) {
$this->thumbnail = false;
}
}
示例5: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if (empty($this->modelTitleForms)) {
$this->modelTitleForms = PhpMorphy::getNeededForms($this->modelTitle);
}
}
示例6: init
public function init()
{
parent::init();
$extJsSrcDir = Yii::getAlias($this->extJsDir);
$extJsSrcExtendDir = Yii::getAlias($this->extJsExtendDir);
$dstDir = Yii::getAlias($this->dstPath);
$extJsDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs';
$extJsExtendDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs-extend';
if (!is_dir($dstDir)) {
if (!is_dir($dstDir)) {
FileHelper::createDirectory($dstDir);
}
}
if (!is_dir($extJsDstDir)) {
symlink($extJsSrcDir, $extJsDstDir);
}
if (!is_dir($extJsExtendDstDir)) {
symlink($extJsSrcExtendDir, $extJsExtendDstDir);
}
$data = DpConfig::find()->all();
$config = [];
foreach ($data as $item) {
$config[$item['name']] = $item['value'];
}
$this->config = $config;
$this->identity = Yii::$app->user->identity;
}
示例7: init
public function init()
{
$this->setRequestParams(Yii::$app->request);
$this->setPageParams($this->requestParams);
$this->setSortParams($this->requestParams);
parent::init();
}
示例8: init
/**
* Initializes the object.
* This method is invoked at the end of the constructor after the object is initialized with the
* given configuration.
*/
public function init()
{
$response = \Yii::$app->response;
$response->format = \yii\web\Response::FORMAT_JSON;
parent::init();
// TODO: Change the autogenerated stub
}
示例9: init
/**
* Creates inherited user account.
*/
public function init()
{
parent::init();
if (!Yii::$app->user->isGuest) {
if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
$user = User::findMe();
if (empty($user)) {
$new = new User();
$new->setScenario('installation');
$new->inherited_id = Yii::$app->user->id;
$new->status = User::STATUS_ACTIVE;
$new->role = User::ROLE_MEMBER;
$new->timezone = User::DEFAULT_TIMEZONE;
if ($new->save()) {
$this->success(Yii::t('podium/flash', Messages::ACCOUNT_INHERITED, ['link' => Html::a(Yii::t('podium/layout', 'Profile'))]));
Cache::clearAfterActivate();
Log::info('Inherited account created', $new->id, __METHOD__);
} else {
throw new Exception(Yii::t('podium/view', Messages::ACCOUNT_INHERITED_ERROR));
}
} elseif ($user->status == User::STATUS_BANNED) {
return $this->redirect(['default/ban']);
}
} else {
$user = Yii::$app->user->identity;
}
if ($user && !empty($user->timezone)) {
Yii::$app->formatter->timeZone = $user->timezone;
}
}
}
示例10: init
public function init()
{
if (Yii::$app->user->isGuest || Yii::$app->user->id > 5) {
die("Доступ закрыт! Вы не являетесь админом.");
}
parent::init();
}
示例11: init
/**
* Init function
*/
public function init()
{
parent::init();
if ($this->userClassName === null) {
$this->userClassName = Yii::$app->getUser()->identityClass;
}
}
示例12: init
public function init()
{
parent::init();
Yii::$app->language = Yii::$app->user->isGuest ? "en-US" : Yii::$app->user->getIdentity()->language;
Yii::$app->formatter->datetimeFormat = Yii::$app->user->isGuest ? "dd/MM/yyyy HH:mm" : Yii::$app->user->getIdentity()->date_format . " " . Yii::$app->user->getIdentity()->time_format;
Yii::$app->formatter->timeZone = Yii::$app->user->isGuest ? 'America/Sao_Paulo' : Yii::$app->user->getIdentity()->time_zone;
}
示例13: init
public function init()
{
parent::init();
$this->modularityService = LuLu::getService('modularity');
$this->rbacService = LuLu::getService('rbac');
$this->taxonomyService = LuLu::getService('taxonomy');
}
示例14: init
/**
* 初始化
* @see \yii\base\Object::init()
*/
public function init()
{
parent::init();
//初始化web目录下的资源路径
$this->baseUrl = Yii::getAlias('@web');
$this->layout = '@app/views/layouts/adminlte_main';
}
示例15: init
/**
* @inheritdoc
*/
public function init()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$this->user_id = $this->module->userId;
$this->notificationClass = $this->module->notificationClass;
parent::init();
}