|
- <?php
-
-
-
- namespace common\components ;
-
- use domain\User\User\User;
-
- class View extends \yii\web\View
- {
- use BusinessLogicTrait;
-
- var $title ;
- var $icon;
- var $page_title ;
- var $buttons ;
- var $metaRefresh = false;
-
- public function getLogic()
- {
- return \Yii::$app->logic;
- }
-
- public function setIcon($icon)
- {
- $this->icon = $icon;
- }
-
- public function getIcon()
- {
- return $this->icon;
- }
-
- public function setTitle($title, $page_title = '')
- {
- $this->title = $title ;
- if(strlen($page_title)) {
- $this->page_title = $page_title ;
- }
- else {
- $this->page_title = $title ;
- }
- }
-
- public function getTitle()
- {
- return $this->title ;
- }
-
- public function setPageTitle($page_title)
- {
- $this->page_title = $page_title ;
- }
-
- public function getPageTitle()
- {
- return $this->page_title ;
- }
-
- public function getControllerAction()
- {
- return \Yii::$app->controller->id.'/'.\Yii::$app->controller->action->id ;
- }
-
- public function addBreadcrumb($breadcrumb)
- {
- $this->params['breadcrumbs'][] = $breadcrumb ;
- }
-
- public function addButton($button)
- {
- $this->buttons[] = $button ;
- }
-
- public function setMeta($name, $content)
- {
- \Yii::$app->view->registerMetaTag([
- 'name' => $name,
- 'content' => $content
- ]);
- }
-
- public function setMetaRefresh(bool $active)
- {
- $this->metaRefresh = $active;
- }
-
- public function getUrlManagerFrontend()
- {
- return \Yii::$app->urlManagerFrontend;
- }
-
- public function getUrlManagerProducer()
- {
- return \Yii::$app->urlManagerProducer;
- }
-
- public function getUrlManagerBackend()
- {
- return \Yii::$app->urlManagerBackend;
- }
-
- public function getUserCurrent(): ?User
- {
- return \Yii::$app->user->identity;
- }
- }
|