Posts

Showing posts from December, 2020

Redirect examples - Drupal 8

  Ex : use Symfony \ Component \ HttpFoundation \ RedirectResponse ; // Redirect to specific route or URL. return new RedirectResponse ( \ Drupal :: url ( 'user.page' ) ) ; return new RedirectResponse ( \ Drupal :: url ( 'locale.translate_status' , [ ] , [ 'absolute' = > TRUE ] ) ) ; return new RedirectResponse ( \ Drupal :: url ( '<front>' , [ ] , [ 'absolute' = > TRUE ] ) ) ; return new RedirectResponse ( Url :: fromRoute ( 'system.modules_uninstall' ) - > setAbsolute ( ) - > toString ( ) ) ; return new RedirectResponse ( Url :: fromRoute ( '<current>' ) - > toString ( ) ) ; // Redirect to external URL. use Drupal \ Core \ Routing \ TrustedRedirectResponse ; return new TrustedRedirectResponse ( 'http://www.google.com/' ) ; // If you have extended ControllerBase class or use Drupal\Core\Routing\UrlGeneratorTrait; return $this - > redirect ( '...

Drupal logger

    \Drupal::logger('content_entity_example')->notice('Source data:: %source_data',     array(         '%source_data' => print_r($source_data, TRUE),     ));