PostCommentController.php in Open Social 8.5
Same filename and directory in other branches
- 8.9 modules/social_features/social_post/src/Controller/PostCommentController.php
- 8 modules/social_features/social_post/src/Controller/PostCommentController.php
- 8.2 modules/social_features/social_post/src/Controller/PostCommentController.php
- 8.3 modules/social_features/social_post/src/Controller/PostCommentController.php
- 8.4 modules/social_features/social_post/src/Controller/PostCommentController.php
- 8.6 modules/social_features/social_post/src/Controller/PostCommentController.php
- 8.7 modules/social_features/social_post/src/Controller/PostCommentController.php
- 8.8 modules/social_features/social_post/src/Controller/PostCommentController.php
- 10.3.x modules/social_features/social_post/src/Controller/PostCommentController.php
- 10.0.x modules/social_features/social_post/src/Controller/PostCommentController.php
- 10.1.x modules/social_features/social_post/src/Controller/PostCommentController.php
- 10.2.x modules/social_features/social_post/src/Controller/PostCommentController.php
Namespace
Drupal\social_post\ControllerFile
modules/social_features/social_post/src/Controller/PostCommentController.phpView source
<?php
namespace Drupal\social_post\Controller;
use Drupal\social_comment\Controller\SocialCommentController;
use Drupal\Core\Entity\EntityInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Controller routine override to change relevant bits in the password reset.
*/
class PostCommentController extends SocialCommentController {
/**
* {@inheritdoc}
*/
public function getReplyForm(Request $request, EntityInterface $entity, $field_name, $pid = NULL) {
$account = $this
->currentUser();
// The user is not just previewing a comment.
if ($request->request
->get('op') != $this
->t('Preview')) {
// $pid indicates that this is a reply to a comment.
if ($pid) {
// Load the parent comment.
$comment = $this
->entityManager()
->getStorage('comment')
->load($pid);
}
}
if ($entity
->getEntityTypeId() === 'post') {
// Check if the post has been posted in a group.
/* @var \Drupal\social_post\Entity\Post $entity */
$group_id = $entity->field_recipient_group->target_id;
if ($group_id) {
/** @var \Drupal\group\Entity\Group $group */
$group = entity_load('group', $group_id);
if (!$group
->hasPermission('access posts in group', $account) || !$group
->hasPermission('add post entities in group', $account)) {
if (!isset($comment)) {
$comment = NULL;
}
/* @var \Drupal\Core\Url $url*/
if ($url = $entity
->urlInfo('canonical')) {
// Redirect the user to the correct entity.
return $this
->redirectToOriginalEntity($url, $comment, $entity);
}
}
}
}
return parent::getReplyForm($request, $entity, $field_name, $pid);
}
}
Classes
Name![]() |
Description |
---|---|
PostCommentController | Controller routine override to change relevant bits in the password reset. |