Skip to content

Instantly share code, notes, and snippets.

@pedrorocha-net
Last active August 14, 2016 22:06
Show Gist options
  • Save pedrorocha-net/4ebbb7a6d8cf30e6c031 to your computer and use it in GitHub Desktop.
Save pedrorocha-net/4ebbb7a6d8cf30e6c031 to your computer and use it in GitHub Desktop.
Example of page route in Drupal, with the Cool module
<?php
namespace Drupal\my_page\PageControllers;
class MyPage implements \Drupal\cool\Controllers\PageController {
public static function accessCallback() {
return TRUE;
}
public static function getDefinition() {
return array(
'title' => t('My page')
);
}
public static function getPath() {
return 'my-page-url';
}
public static function pageCallback() {
return '<h1>' . t('This is my new page!') . '</h1>';
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment