Skip to content

Instantly share code, notes, and snippets.

View jhedstrom's full-sized avatar

Jonathan Hedstrom jhedstrom

  • Phase2
  • Portland, OR
View GitHub Profile
<?php
namespace Drupal\my_module\Form;
use Drupal\Core\Datetime\Element\Datetime;
use Drupal\Core\Form\FormStateInterface;
/**
* Utility functions and static callbacks for MY MODULE module.
*/
@jhedstrom
jhedstrom / ExternalRedirect.php
Created April 22, 2022 15:38
Redirect canonical node page
<?php
namespace Drupal\mymodule\EventSubscriber;
use Drupal\mymodule\ExternalRedirectHelper;
use Drupal\Core\Routing\TrustedRedirectResponse;
use Drupal\node\NodeInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;