66 lines
1.4 KiB
PHP
66 lines
1.4 KiB
PHP
<?php
|
|
namespace frontend\components;
|
|
|
|
use Yii;
|
|
use common\models\Order;
|
|
use yii\helpers\Html;
|
|
|
|
class FrontendMenuStructure{
|
|
|
|
public $menuItems;
|
|
|
|
public function FrontendMenuStructure(){
|
|
$this->menuItems = [];
|
|
}
|
|
|
|
protected function can($authItem){
|
|
$result = false;
|
|
if (\Yii::$app->user->can($authItem)) {
|
|
$result = true;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
protected function isLogged(){
|
|
return !Yii::$app->user->isGuest;
|
|
}
|
|
|
|
|
|
protected function addRecepcio(){
|
|
if ( $this->isLogged() ){
|
|
$this->menuItems[] = ['label' => 'Recepcio', 'url' => ['/customer/reception'] ];
|
|
$this->menuItems[] = ['label' => 'Kassza',
|
|
'items' => [
|
|
['label' => 'Account states', 'url' => ['/account-state/index'] ],
|
|
['label' => 'Open account state', 'url' => ['/account-state/open'] ],
|
|
['label' => 'Close account state', 'url' => ['/account-state/close'] ],
|
|
]
|
|
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
protected function addLoginMainMenu(){
|
|
if (Yii::$app->user->isGuest) {
|
|
$mainMenuItem= ['label' => 'Login', 'url' => ['/site/login']];
|
|
} else {
|
|
$mainMenuItem= [
|
|
'label' => 'Kijelentkezés (' . Yii::$app->user->identity->username . ')',
|
|
'url' => ['/site/logout'],
|
|
'linkOptions' => ['data-method' => 'post']
|
|
];
|
|
}
|
|
$this->menuItems[] = $mainMenuItem;
|
|
}
|
|
|
|
|
|
public function run(){
|
|
$this->addRecepcio();
|
|
$this->addLoginMainMenu();
|
|
return $this->menuItems;
|
|
}
|
|
|
|
|
|
} |