ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
【Drupal简易模块hello】 hello.info.yml: ``` name: Hello type: module description: Hello demo module. core: 8.x ``` hello.routing.yml: ``` hello.url: path: '/say_hello' defaults: _title: 'Hello Title' _controller: '\Drupal\hello\Controller\HelloController::content' requirements: _permission: 'access content' ``` src/Controller/HelloController.php: ``` <?php /** * @file * Contains \Drupal\hello\Controller. */ namespace Drupal\hello\Controller; use Drupal\Core\Controller\ControllerBase; class HelloController extends ControllerBase { public function content() { return array( '#markup' => '' . t('Hello there!') . '', ); } } ``` 【有Configure和Permissions的Drupal简易模块demo】 hello.info.yml: ``` name: Hello type: module description: Hello demo module. configure: hello.url core: 8.x ``` hello.routing.yml: ``` hello.url: path: '/say_hello' defaults: _title: 'Hello Title' _controller: '\Drupal\hello\Controller\HelloController::content' requirements: _permission: 'access content' ``` hello.permissions.yml: ``` permission demo 1: title: 'permission demo 1' permission demo 2: title: 'permission demo 2' permission demo 3: title: 'permission demo 3' ``` src/Controller/HelloController.php: ``` <?php /** * @file * Contains \Drupal\hello\Controller. */ namespace Drupal\hello\Controller; use Drupal\Core\Controller\ControllerBase; class HelloController extends ControllerBase { public function content() { return array( '#markup' => '' . t('Hello there!') . '', ); } } ``` 123