'Обычный' ]; } public function getTypeString() { return 'temp'; } public function getMapType() { return static::MAP_TYPE_POINT; } /** * is_planned like getMapView() * * @return string */ public function getMapColor() { $color = static::MAP_COLOR_GREEN; if ($this->source == self::SOURCE_VOTING) { $color = static::MAP_COLOR_GREEN; } elseif ($this->source == self::SOURCE_MINZHKH) { $color = static::MAP_COLOR_ORANGE; } return $color; } public function getMapCoordinates() { return json_decode($this->coordinates); } /** * is_planned reversed because of strange draft =) * * @return array */ public function getMapView() { return [ 'id' => $this->id, 'name' => $this->name, 'coordinates' => $this->coordinates, 'area_id' => $this->area_id, 'is_repaired' => $this->is_repaired, 'is_planned' => !$this->is_planned, ]; } public function getMapTabs() { $tabName = $this->is_planned ? "tab-0" : "tab-1"; return $tabName; } public function __toString() { return $this->name; } public function canComment($user) { // if ($user->isGuest) { // return true; // } // //// $comments = $user->identity->getComments($this)->entity($this)->count(); // // $commentsNum = Comment::find()->where([ // 'entity_class' => 'common\models\Yard', // 'user_id' => $user->id, // 'is_deleted' => 0, // ])->count(); // // // return $commentsNum <= 0; return false; } public function comment($user, $comment) { $cookies = Yii::$app->request->cookies; $answerRadio = $cookies->getValue('answer_radio', 'test'); return Comment::addWithAdditionalParams($this, $user, $comment, $answerRadio); } public function canVoteAnswer($user, $answer = false) { return false; } public function canVoteComment($user, $comment = false) { if (!$comment) { return true; } if (Yii::$app->voteCache->get(static::tableName() . '_' . $user->id . '_' . $comment->id) == false) { Yii::$app->voteCache->set(static::tableName() . '_' . $user->id . '_' . $comment->id, true); return true; } return false; } public function showAnswers($user) { return false; } public function showComments($user) { return true; } public function showAnswersCount($user) { return false; } public function showCommentsCount($user) { return true; } public function voteAnswer($user, $answer) { return false; } public function voteComment($user, $comment) { $comment->vote(); } public function getCommentsCount() { return Comment::find()->entityClass($this)->active()->count(); } public function getRepairedCount() { return self::find()->repaired()->count(); } public function getEntityName() { return [ 1 => 'Двор', 2 => 'Двора', 5 => 'Дворов', ]; } public function getCardText() { if ($this->is_repaired) { return $this->name; } else { return "Двор по адресу $this->name включен в план благоустройства на 2018 год."; } } public function getTexts() { return [ 'act_files' => 'Документы, подтверждающие уборку:', 'source_files' => 'Фото участка:', 'result_files' => 'Фото объекта после выполнения работ:', // 'comment_popup' => 'Спасибо, Ваш комментарий добавлен! Призывайте друзей и соседей оставлять комментарии и замечания о качестве выполненного ремонта на портале Добродел!', 'comment_popup' => 'Спасибо, Ваш комментарий добавлен! Призывайте друзей и соседей голосовать за Ваш двор на портале Добродел!', ]; } /** * Get number of not empty comments * * @param $id * @return int */ public function getFilledCommentsCount($id) { return (int)Comment::find()->entityClass($this)->notEmpty()->active()->andWhere(['entity_id' => $id])->count(); } public function showFilledCommentsCount() { return true; } public function getPopupTexts() { $popups = []; $popups['guest_comment'] = ""; $popups['entity_change'] = ""; $popups['area_change'] = ""; $popups['main_change'] = ""; $popups['success_comment'] = ""; return $popups; } }
An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in /srv/sites/api/common/models/Yard.php on line 1. in /srv/sites/api/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /srv/sites/api/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#1 /srv/sites/api/vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response->send()
#2 /srv/sites/api/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\base\UnknownClassException))
#3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\base\UnknownClassException))
#4 {main}
Previous exception:
yii\base\UnknownClassException: Unable to find 'common\models\Yard' in file: /srv/sites/api/common/models/Yard.php. Namespace missing? in /srv/sites/api/vendor/yiisoft/yii2/BaseYii.php:296
Stack trace:
#0 [internal function]: yii\BaseYii::autoload('common\\models\\Y...')
#1 /srv/sites/api/frontend/controllers/SiteController.php(346): spl_autoload_call('common\\models\\Y...')
#2 /srv/sites/api/frontend/controllers/SiteController.php(134): frontend\controllers\SiteController->dvorRender()
#3 [internal function]: frontend\controllers\SiteController->actionIndex()
#4 /srv/sites/api/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#5 /srv/sites/api/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#6 /srv/sites/api/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('', Array)
#7 /srv/sites/api/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('', Array)
#8 /srv/sites/api/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#9 /srv/sites/api/frontend/web/index.php(17): yii\base\Application->run()
#10 {main}