Skip to content
Snippets Groups Projects
Commit 75fe25f8 authored by baldwinlouie's avatar baldwinlouie
Browse files

Issue #3007111 by baldwinlouie: Remove references to entity.*.collection routing

parent 8ff4b360
No related branches found
No related tags found
No related merge requests found
Showing
with 17 additions and 43 deletions
...@@ -106,18 +106,6 @@ entity.aws_cloud_instance.canonical: ...@@ -106,18 +106,6 @@ entity.aws_cloud_instance.canonical:
requirements: requirements:
_entity_access: 'aws_cloud_instance.view' _entity_access: 'aws_cloud_instance.view'
entity.aws_cloud_instance.collection:
path: '/clouds/aws_cloud/{cloud_context}/instance'
defaults:
_entity_list: 'aws_cloud_instance'
_title: 'AWS Cloud Instance'
requirements:
# Use custom access that will check for cloud_context and the desired permission.
# Desired permission is passed as an option in the "perm" variable
_custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
options:
perm: 'list aws cloud instance'
entity.aws_cloud_instance.edit_form: entity.aws_cloud_instance.edit_form:
path: '/clouds/aws_cloud/{cloud_context}/instance/{aws_cloud_instance}/edit' path: '/clouds/aws_cloud/{cloud_context}/instance/{aws_cloud_instance}/edit'
defaults: defaults:
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
namespace Drupal\aws_cloud\Form\Ec2; namespace Drupal\aws_cloud\Form\Ec2;
use Drupal\Core\Datetime\Element\Datetime; use Drupal\Core\Datetime\Element\Datetime;
use Drupal\Core\Datetime\Entity\DateFormat;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\Core\Datetime\Entity\DateFormat;
/** /**
* Form controller for the CloudScripting entity edit forms. * Form controller for the CloudScripting entity edit forms.
...@@ -214,6 +214,10 @@ class InstanceEditForm extends AwsCloudContentForm { ...@@ -214,6 +214,10 @@ class InstanceEditForm extends AwsCloudContentForm {
$this->awsEc2Service->setCloudContext($this->entity->get('cloud_context')->value); $this->awsEc2Service->setCloudContext($this->entity->get('cloud_context')->value);
$this->awsEc2Service->createTags($params); $this->awsEc2Service->createTags($params);
// set the redirect url to the listing page
$form_state->setRedirect('view.aws_instances.page_1', ['cloud_context' => $this->entity->cloud_context()]);
} }
} }
<?php <?php
namespace Drupal\aws_cloud\Form\Ec2; namespace Drupal\aws_cloud\Form\Ec2;
use Drupal\Core\Form\FormStateInterface;
use Drupal\aws_cloud\Entity\Ec2\Instance; use Drupal\aws_cloud\Entity\Ec2\Instance;
use Drupal\Core\Form\FormStateInterface;
/** /**
* Starts a stopped AWS Instance * Starts a stopped AWS Instance
...@@ -53,7 +53,8 @@ class InstanceStartForm extends AwsDeleteForm { ...@@ -53,7 +53,8 @@ class InstanceStartForm extends AwsDeleteForm {
$this->messenger->addMessage($message); $this->messenger->addMessage($message);
} }
$form_state->setRedirectUrl($this->getCancelUrl()); $form_state->setRedirect('view.aws_instances.page_1', ['cloud_context' => $this->entity->cloud_context()]);
} }
} }
\ No newline at end of file
<?php <?php
namespace Drupal\aws_cloud\Form\Ec2; namespace Drupal\aws_cloud\Form\Ec2;
use Drupal\Core\Form\FormStateInterface;
use Drupal\aws_cloud\Entity\Ec2\Instance; use Drupal\aws_cloud\Entity\Ec2\Instance;
use Drupal\Core\Form\FormStateInterface;
/** /**
* Stops an AWS Instance. This form confirms with the user if they really * Stops an AWS Instance. This form confirms with the user if they really
...@@ -54,7 +54,8 @@ class InstanceStopForm extends AwsDeleteForm { ...@@ -54,7 +54,8 @@ class InstanceStopForm extends AwsDeleteForm {
$this->messenger->addMessage($message); $this->messenger->addMessage($message);
} }
$form_state->setRedirectUrl($this->getCancelUrl()); $form_state->setRedirect('view.aws_instances.page_1', ['cloud_context' => $this->entity->cloud_context()]);
} }
} }
\ No newline at end of file
...@@ -50,6 +50,7 @@ class KeyPairDeleteForm extends AwsDeleteForm { ...@@ -50,6 +50,7 @@ class KeyPairDeleteForm extends AwsDeleteForm {
$this->messenger->addError($message); $this->messenger->addError($message);
} }
$form_state->setRedirectUrl($this->getCancelUrl()); $form_state->setRedirect('entity.aws_cloud_key_pair.canonical', ['cloud_context' => $entity->cloud_context(), 'aws_cloud_key_pair' => $entity->id()]);
} }
} }
...@@ -49,7 +49,6 @@ class NetworkInterfaceDeleteForm extends AwsDeleteForm { ...@@ -49,7 +49,6 @@ class NetworkInterfaceDeleteForm extends AwsDeleteForm {
]); ]);
$this->messenger->addError($message); $this->messenger->addError($message);
} }
$form_state->setRedirect('view.aws_network_interfaces.page_1', ['cloud_context' => $entity->cloud_context()]);
$form_state->setRedirectUrl($this->getCancelUrl());
} }
} }
...@@ -106,7 +106,6 @@ class SecurityGroupCreateForm extends AwsCloudContentForm { ...@@ -106,7 +106,6 @@ class SecurityGroupCreateForm extends AwsCloudContentForm {
&& ($entity->setGroupId($result['GroupId'])) && ($entity->setGroupId($result['GroupId']))
&& ($entity->save())) { && ($entity->save())) {
$status = 'status';
$message = $this->t('The @label "@group_name" has been created.', [ $message = $this->t('The @label "@group_name" has been created.', [
'@label' => $entity->getEntityType()->getLabel(), '@label' => $entity->getEntityType()->getLabel(),
'@group_name' => $entity->group_name(), '@group_name' => $entity->group_name(),
......
...@@ -50,6 +50,6 @@ class SecurityGroupDeleteForm extends AwsDeleteForm { ...@@ -50,6 +50,6 @@ class SecurityGroupDeleteForm extends AwsDeleteForm {
$this->messenger->addError($message); $this->messenger->addError($message);
} }
$form_state->setRedirectUrl($this->getCancelUrl()); $form_state->setRedirect('view.aws_security_group.page_1', ['cloud_context' => $entity->cloud_context()]);
} }
} }
...@@ -49,7 +49,7 @@ class VolumeDeleteForm extends AwsDeleteForm { ...@@ -49,7 +49,7 @@ class VolumeDeleteForm extends AwsDeleteForm {
]); ]);
$this->messenger->addError($message); $this->messenger->addError($message);
} }
$form_state->setRedirect('view.aws_volume.page_1', ['cloud_context' => $entity->cloud_context()]);
$form_state->setRedirectUrl($this->getCancelUrl());
} }
} }
...@@ -65,22 +65,13 @@ class CloudContentDeleteForm extends ContentEntityConfirmFormBase { ...@@ -65,22 +65,13 @@ class CloudContentDeleteForm extends ContentEntityConfirmFormBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getCancelUrl() { public function getCancelUrl() {
return $this->entity->toUrl('canonical', ['cloud_context', $this->entity->cloud_context()]);
$entity = $this->entity;
$url = $entity->urlInfo('collection');
if (method_exists($entity, 'cloud_context')) {
$url->setRouteParameter('cloud_context', $entity->cloud_context());
}
return $url;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getConfirmText() { public function getConfirmText() {
return t('Delete'); return t('Delete');
} }
......
...@@ -109,16 +109,6 @@ class CloudContentForm extends ContentEntityForm { ...@@ -109,16 +109,6 @@ class CloudContentForm extends ContentEntityForm {
} }
drupal_set_message($message, $status); drupal_set_message($message, $status);
if (method_exists($entity, 'cloud_context')) {
$form_state->setRedirectUrl($entity
->urlInfo('collection')
->setRouteParameter('cloud_context', $entity->cloud_context()));
}
else {
$form_state->setRedirectUrl($entity
->urlInfo('collection'));
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment