Skip to content
Snippets Groups Projects

Issue #3258323: After the model name is set the page-title isn't updated after the initial save of a new model

Merged Issue #3258323: After the model name is set the page-title isn't updated after the initial save of a new model
Merged Jürgen Haas requested to merge issue/eca-3258323:3258323-after-the-model into 1.0.x
@@ -4,9 +4,11 @@ namespace Drupal\eca\Controller;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\MessageCommand;
use Drupal\Core\Ajax\RedirectCommand;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Url;
use Drupal\eca\Service\Modellers;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -72,6 +74,11 @@ class EcaController extends ControllerBase {
if ($modeller = $this->modellerServices->getModeller($modeller_id)) {
try {
$modeller->save($this->request->getContent());
$referrer = $this->request->server->get('HTTP_REFERER');
$editUrl = Url::fromRoute('entity.eca.edit_form', ['eca' => strtolower($modeller->getId())], ['absolute' => TRUE])->toString();
if ($referrer !== $editUrl) {
$response->addCommand(new RedirectCommand($editUrl));
}
$message = new MessageCommand('Successfully saved the model.', NULL, [
'type' => 'status',
]);
Loading