本文整理汇总了PHP中yii\web\View::className方法的典型用法代码示例。如果您正苦于以下问题:PHP View::className方法的具体用法?PHP View::className怎么用?PHP View::className使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\View
的用法示例。
在下文中一共展示了View::className方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeAction
public function beforeAction($action)
{
// 登录全局View
Event::on(View::className(), View::EVENT_BEFORE_RENDER, function () {
$config = Config::get_config();
Yii::$app->view->params['global_config'] = $config;
Yii::$app->view->title = $config->site_title;
});
$this->trigger(WechatPlatform::EVENT_PLATFORM_DATA);
return parent::beforeAction($action);
}
示例2: testOptions
/**
* @covers \opus\base\behaviors\JsVariablesBehavior::registerJsVariables
* @covers \opus\base\behaviors\JsVariablesBehavior::outputJsVariables
*/
public function testOptions()
{
$return = 'var _var = {"var":"val","0":"otherNamespace"};var _var=_var||{};_var.test="string";_var.testFloat=23.22;_var.testInt=3;_var.testNull=null;_var.testBool=false;_var.testArray={"nested1":"val1"};_var.testObject={"publicParam":"test"};';
$behavior = new JsVariablesBehavior();
$behavior->registerJsVariables($this->getTestData(), '_var', JSON_FORCE_OBJECT);
$behavior->registerJsVariables(['var' => 'val', 'otherNamespace']);
$view = $this->getMock(View::className(), ['registerJs']);
$view->expects($this->once())->method('registerJs')->with($return, View::POS_HEAD);
$event = new Event();
$event->sender = $view;
$behavior->outputJsVariables($event);
}
示例3: bootstrap
public function bootstrap($app)
{
$app->on(Application::EVENT_BEFORE_ACTION, function () use($app) {
if ($app->requestedAction->controller instanceof BackendReviewController) {
/**
* Этот кусок отвечает за добавление пустого submission к отзыву,
* когда отзыв создается в админке
*/
Event::on(Review::className(), ActiveRecord::EVENT_INIT, [ReviewsBehavior::className(), 'handleInit']);
BackendEntityEditFormEvent::on(View::className(), BackendReviewController::BACKEND_REVIEW_EDIT_FORM, [$this, 'renderEditForm']);
}
});
}
示例4: init
/**
* 初始化方法
*
* @return void
* @author
**/
public function init()
{
$this->on('beforeAction', function ($event) {
$deny_uri = ['login', 'js-config', 'registercode', 'findpasswordcode', 'findpasswordcode', 'get-area', 'find-pass'];
if (Yii::$app->getUser()->isGuest) {
$request = Yii::$app->getRequest();
if (!($request->getIsAjax() || $this->_search_values($deny_uri, $request->getUrl()))) {
Yii::$app->getUser()->setReturnUrl($request->getUrl());
}
}
});
// View
Event::on(View::className(), View::EVENT_BEFORE_RENDER, function () {
Yii::setAlias('@staticRoot', YII_ENV_DEV ? "@web/static/promeet" : "@web/static/promeet");
Yii::setAlias('@staticUrl', YII_ENV_DEV ? "@web/static/promeet" : "@web/static/promeet");
Yii::$app->view->title = "创业服务平台";
});
}
示例5: init
/**
* 初始化方法
*
* @return void
* @author
**/
public function init()
{
$this->on('beforeAction', function ($event) {
$deny_uri = ['login', 'js-config', 'registercode', 'findpasswordcode', 'findpasswordcode', 'get-area', 'find-pass'];
if (Yii::$app->getUser()->isGuest) {
$request = Yii::$app->getRequest();
if (!($request->getIsAjax() || $this->_search_values($deny_uri, $request->getUrl()))) {
Yii::$app->getUser()->setReturnUrl($request->getUrl());
}
}
});
// View
Event::on(View::className(), View::EVENT_BEFORE_RENDER, function () {
Yii::$app->view->params['global_user'] = $this->get_user();
Yii::$app->view->params['global_config'] = Config::get_config();
Yii::$app->view->title = $this->config->site_title;
});
}
示例6: createView
/**
* Creates view instance from given configuration.
* @param array $config view configuration.
* @return View view instance.
*/
protected function createView(array $config)
{
if (!array_key_exists('class', $config)) {
$config['class'] = View::className();
}
return Yii::createObject($config);
}
示例7: actionManage
/**
* View, create, or update a tree node via ajax
*
* @return string json encoded response
*/
public function actionManage()
{
Yii::$app->response->format = Response::FORMAT_JSON;
static::checkValidRequest();
$parentKey = $action = null;
$modelClass = '\\kartik\\tree\\models\\Tree';
$isAdmin = $softDelete = $showFormButtons = $showIDAttribute = false;
$currUrl = $nodeView = $formOptions = $formAction = $breadCrumbs = '';
$iconsList = $nodeAddlViews = [];
extract(static::getPostData());
/**
* @var Tree $modelClass
* @var Tree $node
*/
if (!isset($id) || empty($id)) {
$node = new $modelClass();
$node->initDefaults();
} else {
$node = $modelClass::findOne($id);
}
$module = TreeView::module();
$params = $module->treeStructure + $module->dataStructure + ['node' => $node, 'parentKey' => $parentKey, 'action' => $formAction, 'formOptions' => empty($formOptions) ? [] : $formOptions, 'modelClass' => $modelClass, 'currUrl' => $currUrl, 'isAdmin' => $isAdmin, 'iconsList' => $iconsList, 'softDelete' => $softDelete, 'showFormButtons' => $showFormButtons, 'showIDAttribute' => $showIDAttribute, 'nodeView' => $nodeView, 'nodeAddlViews' => $nodeAddlViews, 'breadcrumbs' => empty($breadcrumbs) ? [] : $breadcrumbs];
if (!empty($module->unsetAjaxBundles)) {
Event::on(View::className(), View::EVENT_AFTER_RENDER, function ($e) use($module) {
foreach ($module->unsetAjaxBundles as $bundle) {
unset($e->sender->assetBundles[$bundle]);
}
});
}
$callback = function () use($nodeView, $params) {
return $this->renderAjax($nodeView, ['params' => $params]);
};
return self::process($callback, Yii::t('kvtree', 'Error while viewing the node. Please try again later.'), null);
}
示例8: renderView
public static function renderView($view, $params)
{
/** @var View $viewObj */
$viewObj = Yii::createObject(['class' => View::className()]);
return $viewObj->render($view, $params);
}
示例9: turnOffAssetBundles
public static function turnOffAssetBundles()
{
\yii\base\Event::on(\yii\web\View::className(), \yii\web\View::EVENT_AFTER_RENDER, function ($e) {
$e->sender->assetBundles = [];
});
}
示例10: makePageTitle
private function makePageTitle()
{
Event::on(View::className(), View::EVENT_AFTER_RENDER, function ($event) {
$this->application->view->title = implode(' - ', [$this->application->view->title, \Yii::$app->name]);
});
}