Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CommentLazyBuilders | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| renderForm | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\crm\Service; |
| 6 | |
| 7 | use Drupal\comment\CommentLazyBuilders as BaseCommentLazyBuilders; |
| 8 | use Drupal\comment\CommentManagerInterface; |
| 9 | use Drupal\Core\Entity\EntityFormBuilderInterface; |
| 10 | use Drupal\Core\Entity\EntityTypeManagerInterface; |
| 11 | use Drupal\Core\Extension\ModuleHandlerInterface; |
| 12 | use Drupal\Core\Render\RendererInterface; |
| 13 | use Drupal\Core\Session\AccountInterface; |
| 14 | use Drupal\Core\Path\CurrentPathStack; |
| 15 | use Drupal\Core\Url; |
| 16 | |
| 17 | /** |
| 18 | * Custom comment lazy builders. |
| 19 | */ |
| 20 | class CommentLazyBuilders extends BaseCommentLazyBuilders { |
| 21 | |
| 22 | /** |
| 23 | * The path current service. |
| 24 | * |
| 25 | * @var \Drupal\Core\Path\CurrentPathStack |
| 26 | */ |
| 27 | protected $pathCurrent; |
| 28 | |
| 29 | /** |
| 30 | * Constructs a new CommentLazyBuilders object. |
| 31 | * |
| 32 | * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager |
| 33 | * The entity type manager service. |
| 34 | * @param \Drupal\Core\Entity\EntityFormBuilderInterface $entity_form_builder |
| 35 | * The entity form builder service. |
| 36 | * @param \Drupal\Core\Session\AccountInterface $current_user |
| 37 | * The current logged in user. |
| 38 | * @param \Drupal\comment\CommentManagerInterface $comment_manager |
| 39 | * The comment manager service. |
| 40 | * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler |
| 41 | * The module handler service. |
| 42 | * @param \Drupal\Core\Render\RendererInterface $renderer |
| 43 | * The renderer service. |
| 44 | * @param \Drupal\Core\Path\CurrentPathStack $path_current |
| 45 | * The path current service. |
| 46 | */ |
| 47 | public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFormBuilderInterface $entity_form_builder, AccountInterface $current_user, CommentManagerInterface $comment_manager, ModuleHandlerInterface $module_handler, RendererInterface $renderer, CurrentPathStack $path_current) { |
| 48 | parent::__construct($entity_type_manager, $entity_form_builder, $current_user, $comment_manager, $module_handler, $renderer); |
| 49 | $this->pathCurrent = $path_current; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * {@inheritdoc} |
| 54 | */ |
| 55 | public function renderForm($commented_entity_type_id, $commented_entity_id, $field_name, $comment_type_id) { |
| 56 | $form = parent::renderForm($commented_entity_type_id, $commented_entity_id, $field_name, $comment_type_id); |
| 57 | |
| 58 | $current_path = $this->pathCurrent->getPath(); |
| 59 | $form['#action'] = Url::fromUserInput($form['#action'], [ |
| 60 | 'query' => [ |
| 61 | 'destination' => $current_path, |
| 62 | 'crm_contact' => $commented_entity_id, |
| 63 | ], |
| 64 | ])->toString(); |
| 65 | |
| 66 | return $form; |
| 67 | } |
| 68 | |
| 69 | } |