diff --git a/core/modules/trash/src/Controller/TrashController.php b/core/modules/trash/src/Controller/TrashController.php index 42d9165..d2eea4f 100644 --- a/core/modules/trash/src/Controller/TrashController.php +++ b/core/modules/trash/src/Controller/TrashController.php @@ -4,13 +4,12 @@ use Drupal\content_moderation\ModerationInformationInterface; use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Url; -use Drupal\Core\Datetime\DateFormatter; -use Drupal\multiversion\MultiversionManagerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; class TrashController extends ControllerBase { @@ -76,7 +75,7 @@ public function summary() { return [ '#theme' => 'item_list', '#items' => $items, - '#title' => 'Trash bins' + '#title' => 'Trash bins', ]; } @@ -99,24 +98,30 @@ public function entityList($entity_type_id = NULL) { $links = [ 'restore' => [ 'title' => 'Restore', - 'url' => Url::fromRoute('restore.form', ['entity_type_id' => $entity->getEntityTypeId(), 'entity_id' => $entity->id()]), + 'url' => Url::fromRoute('restore.form', [ + 'entity_type_id' => $entity->getEntityTypeId(), + 'entity_id' => $entity->id(), + ]), ], 'purge' => [ 'title' => 'Purge', - 'url' => Url::fromRoute('purge.form', ['entity_type_id' => $entity->getEntityTypeId(), 'entity_id' => $entity->id()]), + 'url' => Url::fromRoute('purge.form', [ + 'entity_type_id' => $entity->getEntityTypeId(), + 'entity_id' => $entity->id(), + ]), ], ]; $id = $entity->id(); $rows[$id] = []; $rows[$id]['id'] = $id; $rows[$id]['label'] = [ - 'data' => [ - '#type' => 'link', - '#title' => $entity->label(), - '#access' => $entity->access('view'), - '#url' => $entity->urlInfo(), - ], - ]; + 'data' => [ + '#type' => 'link', + '#title' => $entity->label(), + '#access' => $entity->access('view'), + '#url' => $entity->urlInfo(), + ], + ]; if (in_array($entity_type_id, ['node', 'comment'])) { $rows[$id]['created'] = $this->dateFormatter->format($entity->getCreatedTime(), 'short'); @@ -124,21 +129,21 @@ public function entityList($entity_type_id = NULL) { $rows[$id]['owner'] = $entity->getOwner()->label(); } $rows[$id]['operations'] = [ - 'data' => [ - '#type' => 'operations', - '#links' => $links, - ], - ]; + 'data' => [ + '#type' => 'operations', + '#links' => $links, + ], + ]; } } $entity_types = $this->getModeratedEntityTypes(); - return array( + return [ '#type' => 'table', '#header' => $this->header($entity_type_id), '#rows' => $rows, '#empty' => $this->t('The @label trash is empty.', ['@label' => $entity_types[$entity_type_id]->get('label')]), - ); + ]; } protected function loadEntities($entity_type_id = NULL) { @@ -153,30 +158,30 @@ protected function loadEntities($entity_type_id = NULL) { } } - protected function header($entity_type_id = null) { + protected function header($entity_type_id = NULL) { $header = []; $header['id'] = [ - 'data' => $this->t('Id'), - ]; + 'data' => $this->t('Id'), + ]; $header['label'] = [ - 'data' => $this->t('Name'), - ]; + 'data' => $this->t('Name'), + ]; if (in_array($entity_type_id, ['node', 'comment'])) { $header['created'] = [ - 'data' => $this->t('Created'), - 'field' => 'created', - 'specifier' => 'created', - 'class' => array(RESPONSIVE_PRIORITY_LOW), - ]; + 'data' => $this->t('Created'), + 'field' => 'created', + 'specifier' => 'created', + 'class' => [RESPONSIVE_PRIORITY_LOW], + ]; $header['changed'] = [ - 'data' => $this->t('Updated'), - 'field' => 'changed', - 'specifier' => 'changed', - 'class' => array(RESPONSIVE_PRIORITY_LOW), - ]; + 'data' => $this->t('Updated'), + 'field' => 'changed', + 'specifier' => 'changed', + 'class' => [RESPONSIVE_PRIORITY_LOW], + ]; $header['owner'] = [ - 'data' => $this->t('Owner'), - ]; + 'data' => $this->t('Owner'), + ]; } $header['operations'] = t('Operations'); return $header; @@ -188,4 +193,5 @@ protected function getModeratedEntityTypes() { return $this->moderationInformation->canModerateEntitiesOfEntityType($entity_type); }); } + } diff --git a/core/modules/trash/src/Controller/TrashDeleteController.php b/core/modules/trash/src/Controller/TrashDeleteController.php index 2e0bd19..e19e6ce 100644 --- a/core/modules/trash/src/Controller/TrashDeleteController.php +++ b/core/modules/trash/src/Controller/TrashDeleteController.php @@ -5,9 +5,9 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Url; +use Symfony\Component\DependencyInjection\ContainerInterface; class TrashDeleteController extends ControllerBase { @@ -64,10 +64,15 @@ public function entityDelete() { $content_moderation_state = reset($content_moderation_states); $content_moderation_state->moderation_state->target_id = 'archived'; if ($content_moderation_state->save()) { - drupal_set_message(t('The @entity %label has been moved to the trash.', ['@entity' => $entity->getEntityType()->get('label'), '%label' => $entity->label()])); + drupal_set_message(t('The @entity %label has been moved to the trash.', [ + '@entity' => $entity->getEntityType() + ->get('label'), + '%label' => $entity->label(), + ])); } } - return $this->redirect($this->getRedirectUrl($entity)->getRouteName(),$this->getRedirectUrl($entity)->getRouteParameters()); + return $this->redirect($this->getRedirectUrl($entity) + ->getRouteName(), $this->getRedirectUrl($entity)->getRouteParameters()); } /** diff --git a/core/modules/trash/src/Form/PurgeForm.php b/core/modules/trash/src/Form/PurgeForm.php index 650d392..367b5b5 100644 --- a/core/modules/trash/src/Form/PurgeForm.php +++ b/core/modules/trash/src/Form/PurgeForm.php @@ -32,7 +32,7 @@ public static function create(ContainerInterface $container) { } /** - * Constructor. + * Constructs a new PurgeForm. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. @@ -81,7 +81,7 @@ public function getCancelUrl() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $entity_id = NULL) { - /** @var \Drupal\multiversion\Entity\Storage\ContentEntityStorageInterface $storage */ + /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */ $storage = $this->entityTypeManager->getStorage($entity_type_id); if (!$this->entity = $storage->load($entity_id)) { @@ -110,7 +110,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message(t('The @entity "@label" has been purged.', [ '@entity' => $this->entity->getEntityType()->get('label'), - '@label' => $this->entity->label() + '@label' => $this->entity->label(), ])); $form_state->setRedirect('trash.entity_list', ['entity_type_id' => $entity_type_id]); diff --git a/core/modules/trash/src/Form/RestoreForm.php b/core/modules/trash/src/Form/RestoreForm.php index 7f70036..748bb33 100644 --- a/core/modules/trash/src/Form/RestoreForm.php +++ b/core/modules/trash/src/Form/RestoreForm.php @@ -32,7 +32,7 @@ public static function create(ContainerInterface $container) { } /** - * Constructor. + * Constructs a new RestoreForm. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. @@ -56,18 +56,22 @@ public function getQuestion() { } /** - * {@inheritdoc} - */ - public function getDescription() { - return $this->t('The @entity "@label" will be restored.', ['@entity' => $this->entity->getEntityType()->get('label'), '@label' => $this->entity->label()]); - } + * {@inheritdoc} + */ + public function getDescription() { + return $this->t('The @entity "@label" will be restored.', [ + '@entity' => $this->entity->getEntityType() + ->get('label'), + '@label' => $this->entity->label(), + ]); + } /** - * {@inheritdoc} - */ - public function getConfirmText() { - return $this->t('Restore'); - } + * {@inheritdoc} + */ + public function getConfirmText() { + return $this->t('Restore'); + } /** * {@inheritdoc} @@ -81,7 +85,7 @@ public function getCancelUrl() { */ public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL, $entity_id = NULL) { if (!empty($entity_type_id)) { - /** @var \Drupal\multiversion\Entity\Storage\ContentEntityStorageInterface $storage */ + /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */ $storage = $this->entityTypeManager->getStorage($entity_type_id); if (!$this->entity = $storage->load($entity_id)) { @@ -106,13 +110,17 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $content_moderation_states = $this->entityTypeManager ->getStorage('content_moderation_state') ->loadByProperties([ - 'content_entity_type_id' => $this->entity->getEntityTypeId(), - 'content_entity_id' => $this->entity->id(), - ]); + 'content_entity_type_id' => $this->entity->getEntityTypeId(), + 'content_entity_id' => $this->entity->id(), + ]); $content_moderation_state = reset($content_moderation_states); $content_moderation_state->moderation_state->target_id = 'draft'; if ($content_moderation_state->save()) { - drupal_set_message(t('The @entity "@label" has been restored.', ['@entity' => $this->entity->getEntityType()->get('label'), '@label' => $this->entity->label()])); + drupal_set_message(t('The @entity "@label" has been restored.', [ + '@entity' => $this->entity->getEntityType() + ->get('label'), + '@label' => $this->entity->label(), + ])); $form_state->setRedirect('trash.entity_list', ['entity_type_id' => $this->entity->getEntityTypeId()]); } } diff --git a/core/modules/trash/src/Plugin/Derivative/TrashLocalTasks.php b/core/modules/trash/src/Plugin/Derivative/TrashLocalTasks.php index a745a40..6f99167 100644 --- a/core/modules/trash/src/Plugin/Derivative/TrashLocalTasks.php +++ b/core/modules/trash/src/Plugin/Derivative/TrashLocalTasks.php @@ -6,7 +6,6 @@ use Drupal\content_moderation\ModerationInformationInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; -use Drupal\multiversion\MultiversionManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -16,11 +15,15 @@ class TrashLocalTasks extends DeriverBase implements ContainerDeriverInterface { /** + * The Entity Type Manager service. + * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** + * The moderation information service. + * * @var \Drupal\content_moderation\ModerationInformationInterface */ protected $moderationInformation; @@ -29,7 +32,9 @@ class TrashLocalTasks extends DeriverBase implements ContainerDeriverInterface { * Constructs a TrashLocalTasks object. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * Entity type manager service. * @param \Drupal\content_moderation\ModerationInformationInterface $moderation_information + * The moderation information service. */ public function __construct(EntityTypeManagerInterface $entity_type_manager, ModerationInformationInterface $moderation_information) { $this->entityTypeManager = $entity_type_manager; @@ -55,7 +60,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives["trash_$entity_type_id"]['title'] = $entity_type->get('label'); $this->derivatives["trash_$entity_type_id"]['route_name'] = 'trash.entity_list'; $this->derivatives["trash_$entity_type_id"]['parent_id'] = 'trash.default'; - $this->derivatives["trash_$entity_type_id"]['route_parameters'] = array('entity_type_id' => $entity_type_id); + $this->derivatives["trash_$entity_type_id"]['route_parameters'] = ['entity_type_id' => $entity_type_id]; } return $this->derivatives; } diff --git a/core/modules/trash/src/Routing/RouteSubscriber.php b/core/modules/trash/src/Routing/RouteSubscriber.php index 995d796..c6f06ff 100644 --- a/core/modules/trash/src/Routing/RouteSubscriber.php +++ b/core/modules/trash/src/Routing/RouteSubscriber.php @@ -9,25 +9,31 @@ use Symfony\Component\Routing\RouteCollection; /** - * Subscriber for Multiversion UI routes. + * Subscriber for Trash routes. */ class RouteSubscriber extends RouteSubscriberBase { /** + * The Entity Type Manager service. + * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** + * The moderation information service. + * * @var \Drupal\content_moderation\ModerationInformationInterface */ protected $moderationInformation; /** - * Constructs a TrashLocalTasks object. + * Constructs a RouteSubscriber object. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * Entity type manager service. * @param \Drupal\content_moderation\ModerationInformationInterface $moderation_information + * The moderation information service. */ public function __construct(EntityTypeManagerInterface $entity_type_manager, ModerationInformationInterface $moderation_information) { $this->entityTypeManager = $entity_type_manager; diff --git a/core/modules/trash/trash.links.task.yml b/core/modules/trash/trash.links.task.yml index 926073f..c3b6691 100644 --- a/core/modules/trash/trash.links.task.yml +++ b/core/modules/trash/trash.links.task.yml @@ -5,4 +5,4 @@ trash.default: weight: 100 trash.local_tasks: deriver: 'Drupal\trash\Plugin\Derivative\TrashLocalTasks' - weight: 100 \ No newline at end of file + weight: 100