本文整理匯總了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();
}