class SocialPostAlbumAjaxCommentsController in Open Social 10.1.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_post/modules/social_post_album/src/Controller/SocialPostAlbumAjaxCommentsController.php \Drupal\social_post_album\Controller\SocialPostAlbumAjaxCommentsController
- 10.0.x modules/social_features/social_post/modules/social_post_album/src/Controller/SocialPostAlbumAjaxCommentsController.php \Drupal\social_post_album\Controller\SocialPostAlbumAjaxCommentsController
- 10.2.x modules/social_features/social_post/modules/social_post_album/src/Controller/SocialPostAlbumAjaxCommentsController.php \Drupal\social_post_album\Controller\SocialPostAlbumAjaxCommentsController
Controller routines for AJAX comments routes.
Hierarchy
- class \Drupal\social_ajax_comments\Controller\AjaxCommentsController extends \Drupal\ajax_comments\Controller\AjaxCommentsController
- class \Drupal\social_post_album\Controller\SocialPostAlbumAjaxCommentsController
Expanded class hierarchy of SocialPostAlbumAjaxCommentsController
2 files declare their use of SocialPostAlbumAjaxCommentsController
- RouteSubscriber.php in modules/
social_features/ social_post/ modules/ social_post_album/ src/ Routing/ RouteSubscriber.php - social_post_album.module in modules/
social_features/ social_post/ modules/ social_post_album/ social_post_album.module - The Social post album module.
File
- modules/
social_features/ social_post/ modules/ social_post_album/ src/ Controller/ SocialPostAlbumAjaxCommentsController.php, line 13
Namespace
Drupal\social_post_album\ControllerView source
class SocialPostAlbumAjaxCommentsController extends AjaxCommentsController {
/**
* The suffix for wrapper identifier of the comments section.
*/
const WRAPPER_ID_SUFFIX = '-modal';
/**
* {@inheritdoc}
*/
public function socialAdd(Request $request, EntityInterface $entity, $field_name, $pid = NULL) {
$this->clearTempStore = FALSE;
$response = parent::socialAdd($request, $entity, $field_name, $pid);
if ($this->errors !== 0) {
if ($this->errors !== NULL) {
$this->tempStore
->deleteAll();
}
return $response;
}
$comment = $this
->entityTypeManager()
->getStorage('comment')
->create([
'entity_id' => $entity
->id(),
'pid' => $pid,
'entity_type' => $entity
->getEntityTypeId(),
'field_name' => $field_name,
]);
$form = $this
->entityFormBuilder()
->getForm($comment);
$this->tempStore
->setSelector('form_html_id', $form['#attributes']['id']);
$field = $this
->renderCommentField($entity, $field_name);
$field['#attributes']['id'] .= self::WRAPPER_ID_SUFFIX;
$selectors = $this->tempStore
->getSelectors($request);
$response
->addCommand(new ReplaceCommand($selectors['wrapper_html_id'] . self::WRAPPER_ID_SUFFIX, $field), TRUE);
$this->tempStore
->deleteAll();
return $response;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AjaxCommentsController:: |
protected | property | TRUE if temporary storage should be cleared. | |
AjaxCommentsController:: |
protected | property | The number of errors. | |
AjaxCommentsController:: |
protected | property | The parent comment's comment ID. | |
AjaxCommentsController:: |
protected | function | ||
AjaxCommentsController:: |
public | function | Cancel handler for the cancel form. | |
SocialPostAlbumAjaxCommentsController:: |
public | function |
Builds ajax response for adding a new comment without a parent comment. Overrides AjaxCommentsController:: |
|
SocialPostAlbumAjaxCommentsController:: |
constant | The suffix for wrapper identifier of the comments section. |