public function MyFavController::remove in Favorites 8.2
Remove a favorite.
1 string reference to 'MyFavController::remove'
File
- src/
Controller/ MyFavController.php, line 74 - Contains Drupal\favorites\Controller\MyFavController.
Class
- MyFavController
- Class MyFavController.
Namespace
Drupal\favorites\ControllerCode
public function remove($fid) {
$favorite = FavoriteStorage::getFav($fid);
$access = \Drupal::currentUser()
->hasPermission('manage favorites') && $this->account
->id() == $favorite->uid;
if ($access) {
FavoriteStorage::deleteFavorite($fid);
$options = array(
'list' => 'del-' . $fid,
);
return new JsonResponse($options);
}
}