Last active
November 19, 2021 13:35
-
-
Save levmyshkin/a4abe17a99909a3e1d2aca63df08ae85 to your computer and use it in GitHub Desktop.
Drupal: Creating pages for a premium account programmatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DrupalBook | |
description: Custom module for learning Drupal | |
type: module | |
core: 8.x | |
core_version_requirement: ^8 || ^9 | |
package: DrupalBook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
access premium pages: | |
title: 'Access Premium pages' | |
description: 'A custom permission for your pages.' | |
restrict access: TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drupalbook.private_content: | |
path: '/private-page' | |
defaults: | |
_controller: '\Drupal\drupalbook\Controller\FirstPageController::privateContent' | |
_title: 'Private content' | |
requirements: | |
_permission: 'access premium pages' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file /modules/custom/drupalbook/src/Controller/FirstPageController.php | |
*/ | |
namespace Drupal\drupalbook\Controller; | |
/** | |
* Provides route responses for the DrupalBook module. | |
*/ | |
class FirstPageController { | |
/** | |
* Returns a private page. | |
* | |
* @return array | |
* A simple renderable array. | |
*/ | |
public function privateContent() { | |
$element = array( | |
'#markup' => 'Private content', | |
); | |
return $element; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment