/** * @inheritdoc */ public function run() { if (Yii::$app->user->isGuest || $this->space->isMember()) { return; } // Add class for javascript handling $this->followOptions['class'] .= ' followSpaceButton'; $this->unfollowOptions['class'] .= ' unfollowSpaceButton'; // Hide inactive button if ($this->space->isFollowedByUser()) { $this->followOptions['style'] .= ' display:none;'; } else { $this->unfollowOptions['style'] .= ' display:none;'; } // Add UserId Buttons $this->followOptions['data-spaceid'] = $this->space->id; $this->unfollowOptions['data-spaceid'] = $this->space->id; $this->view->registerJsFile('@web/resources/space/followButton.js'); return Html::a($this->unfollowLabel, $this->space->createUrl('/space/space/unfollow'), $this->unfollowOptions) . Html::a($this->followLabel, $this->space->createUrl('/space/space/follow'), $this->followOptions); }