CommentTranslationController.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * @file
  4. * Definition of Drupal\comment\CommentTranslationController.
  5. */
  6. namespace Drupal\comment;
  7. use Drupal\Core\Entity\EntityInterface;
  8. use Drupal\translation_entity\EntityTranslationControllerNG;
  9. /**
  10. * Defines the translation controller class for comments.
  11. */
  12. class CommentTranslationController extends EntityTranslationControllerNG {
  13. /**
  14. * Overrides EntityTranslationController::getAccess().
  15. */
  16. public function getAccess(EntityInterface $entity, $op) {
  17. switch ($op) {
  18. case 'view':
  19. return user_access('access comments');
  20. case 'update':
  21. return comment_access('edit', $entity);
  22. case 'delete':
  23. return user_access('administer comments');
  24. case 'create':
  25. return user_access('post comments');
  26. }
  27. return parent::getAccess($entity, $op);
  28. }
  29. /**
  30. * Overrides EntityTranslationController::entityFormTitle().
  31. */
  32. protected function entityFormTitle(EntityInterface $entity) {
  33. return t('Edit comment @subject', array('@subject' => $entity->label()));
  34. }
  35. }