Mercurial > hg > cmmr2012-drupal-site
diff core/modules/node/src/NodeForm.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children | 12f9dff5fda9 |
line wrap: on
line diff
--- a/core/modules/node/src/NodeForm.php Thu Feb 28 11:14:44 2019 +0000 +++ b/core/modules/node/src/NodeForm.php Thu Feb 28 13:11:55 2019 +0000 @@ -4,7 +4,7 @@ use Drupal\Component\Datetime\TimeInterface; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; @@ -35,8 +35,8 @@ /** * Constructs a NodeForm object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository. * @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory * The factory for the temp store object. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info @@ -46,8 +46,8 @@ * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. */ - public function __construct(EntityManagerInterface $entity_manager, PrivateTempStoreFactory $temp_store_factory, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL, AccountInterface $current_user) { - parent::__construct($entity_manager, $entity_type_bundle_info, $time); + public function __construct(EntityRepositoryInterface $entity_repository, PrivateTempStoreFactory $temp_store_factory, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL, AccountInterface $current_user) { + parent::__construct($entity_repository, $entity_type_bundle_info, $time); $this->tempStoreFactory = $temp_store_factory; $this->currentUser = $current_user; } @@ -57,7 +57,7 @@ */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), + $container->get('entity.repository'), $container->get('tempstore.private'), $container->get('entity_type.bundle.info'), $container->get('datetime.time'), @@ -102,7 +102,7 @@ if ($this->operation == 'edit') { $form['#title'] = $this->t('<em>Edit @type</em> @title', [ '@type' => node_get_type_label($node), - '@title' => $node->label() + '@title' => $node->label(), ]); } @@ -217,7 +217,7 @@ public function updateStatus($entity_type_id, NodeInterface $node, array $form, FormStateInterface $form_state) { $element = $form_state->getTriggeringElement(); if (isset($element['#published_status'])) { - $node->setPublished($element['#published_status']); + $element['#published_status'] ? $node->setPublished() : $node->setUnpublished(); } } @@ -285,11 +285,11 @@ if ($insert) { $this->logger('content')->notice('@type: added %title.', $context); - drupal_set_message(t('@type %title has been created.', $t_args)); + $this->messenger()->addStatus($this->t('@type %title has been created.', $t_args)); } else { $this->logger('content')->notice('@type: updated %title.', $context); - drupal_set_message(t('@type %title has been updated.', $t_args)); + $this->messenger()->addStatus($this->t('@type %title has been updated.', $t_args)); } if ($node->id()) { @@ -312,7 +312,7 @@ else { // In the unlikely case something went wrong on save, the node will be // rebuilt and node form redisplayed the same way as in preview. - drupal_set_message(t('The post could not be saved.'), 'error'); + $this->messenger()->addError($this->t('The post could not be saved.')); $form_state->setRebuild(); } }