Esempio n. 1
1
 /**
  * Получение меню
  * @return array
  */
 public function getData($active)
 {
     if ($active != null) {
         self::$data['menu']['active'] = $active;
     }
     // Берем список проектов пользователя
     if (\Yii::$app->cache->exists('project:user:'******'project:user:'******'staff_id' => \Yii::$app->user->id])->all();
         \Yii::$app->cache->set('project:user:'******'id');
     // Получение списка профайлеров по проектам
     $command = new ListProfiler\command\GetProfilerList();
     $command->setClassModel('app\\models\\amop\\models\\ListProfiler');
     $profiler = $command->setData($idProject)->execute();
     // Формирование списка профайлеров для меню
     foreach ($profiler as $valueProfiler) {
         $profilerMenu = ['label' => $valueProfiler['message'], 'name' => "profiler_" . $valueProfiler['id'], 'class' => "profiler_" . $valueProfiler['id'], 'icon_class' => 'fa fa-cube', 'badges' => ['class' => "label pull-right bg-red"], 'url' => '/profiler/detail/' . $valueProfiler['id']];
         self::$data['menu']['item'][1]['item'][] = $profilerMenu;
     }
     // Формирование списка проектов для меню
     foreach ($project as $value) {
         self::$data['menu']['item'][0]['item'][] = ['label' => $value->title, 'name' => "project_" . $value->id, 'icon_class' => 'fa fa-cube', 'url' => '/project/detail/' . $value->id];
     }
     self::$data['user']['data']['avatar'] = \Yii::$app->user->getIdentity()->avatar;
     self::$data['user']['data']['name'] = \Yii::$app->user->getIdentity()->name;
     self::$data['user']['data']['surname'] = \Yii::$app->user->getIdentity()->surname;
     return self::$data;
 }
Esempio n. 2
0
 /**
  * Тестирование выполнения команды
  */
 public function testExecute()
 {
     $fixture = $this->getFixture('list')->data;
     $this->specifyConfig()->cloneOnly('components');
     $redisMock = $this->getMockBuilder('\\yii\\redis\\Connection')->setMethods(['hexists', 'hget', 'multi', 'exec', 'hset', 'expire'])->getMock();
     $redisMock->expects($this->any())->method('multi')->will($this->returnValue(1));
     $redisMock->expects($this->any())->method('exec')->will($this->returnValue(1));
     $redisMock->expects($this->any())->method('hset')->will($this->returnValue(1));
     $redisMock->expects($this->any())->method('expire')->will($this->returnValue(1));
     $this->specify('test get from cache', function () use($redisMock, $fixture) {
         $redisMock->expects($this->any())->method('hexists')->will($this->returnValue(1));
         $redisMock->expects($this->any())->method('hget')->will($this->returnValue(Json::encode($fixture)));
         \Yii::$app->set('redis', $redisMock);
         $command = new GetProfilerList();
         $command->setClassModel('app\\models\\amop\\models\\ListProfiler');
         $result = $command->setData([0])->execute();
         $this->assertSame($result, $fixture, 'test get from cache failed');
     });
 }
Esempio n. 3
0
 /**
  * @return array
  */
 public function actionCount()
 {
     $result = ['profiler' => ['total' => false, 'item' => []]];
     // Берем список проектов пользователя
     if (\Yii::$app->cache->exists('project:user:'******'project:user:'******'staff_id' => \Yii::$app->user->id])->all();
         \Yii::$app->cache->set('project:user:'******'id');
     // Получение списка профайлеров по проектам
     $command = new ListProfiler\command\GetProfilerList();
     $command->setClassModel('app\\models\\amop\\models\\ListProfiler');
     $profiler = $command->setData($idProject)->execute();
     $idProfiler = ArrayHelper::getColumn($profiler, 'id');
     // Получаем список новых элементов для профайлеров
     $countProfiler = CountData::getModel(CountData::TYPE_PROFILER)->setData(function () use($idProfiler) {
         return LastActiveDate::getModel(LastActiveDate::TYPE_PROFILER)->setData($idProfiler)->setUserId(\Yii::$app->user->id)->get();
     })->getCount();
     $result['profiler']['item'] = $countProfiler;
     $countProfiler ? $result['profiler']['total'] = 'new' : ($result['profiler']['total'] = false);
     return ['status' => 200, 'result' => $result];
 }