use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\ContentEntityForm;
-use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Flood\FloodInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Constructs a MessageForm object.
*
- * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
- * The entity manager.
+ * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
+ * The entity repository.
* @param \Drupal\Core\Flood\FloodInterface $flood
* The flood control mechanism.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* @param \Drupal\Component\Datetime\TimeInterface $time
* The time service.
*/
- public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatterInterface $date_formatter, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
- parent::__construct($entity_manager, $entity_type_bundle_info, $time);
+ public function __construct(EntityRepositoryInterface $entity_repository, FloodInterface $flood, LanguageManagerInterface $language_manager, MailHandlerInterface $mail_handler, DateFormatterInterface $date_formatter, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
+ parent::__construct($entity_repository, $entity_type_bundle_info, $time);
$this->flood = $flood;
$this->languageManager = $language_manager;
$this->mailHandler = $mail_handler;
*/
public static function create(ContainerInterface $container) {
return new static(
- $container->get('entity.manager'),
+ $container->get('entity.repository'),
$container->get('flood'),
$container->get('language_manager'),
$container->get('contact.mail_handler'),
'#theme_wrappers' => ['container__preview'],
'#attributes' => ['class' => ['preview']],
];
- $form['preview']['message'] = $this->entityManager->getViewBuilder('contact_message')->view($message, 'full');
+ $form['preview']['message'] = $this->entityTypeManager->getViewBuilder('contact_message')->view($message, 'full');
}
$form['name'] = [
$this->flood->register('contact', $this->config('contact.settings')->get('flood.interval'));
if ($submission_message = $contact_form->getMessage()) {
- drupal_set_message($submission_message);
+ $this->messenger()->addStatus($submission_message);
}
// To avoid false error messages caused by flood control, redirect away from