/** * @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]; }
/** * Test exception */ public function testException() { $this->setExpectedException('InvalidArgumentException'); $command = CountData::getModel(CountData::TYPE_PROFILER)->setData(1)->getCount(); }