1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 08:17:12 +02:00

Fix issue suggestion processwire/processwire-issues#13 to move Helloworld example module into its own directory

This commit is contained in:
Ryan Cramer
2016-10-04 09:38:08 -04:00
parent b32857592b
commit e133309068

View File

@@ -31,13 +31,13 @@ class Helloworld extends WireData implements Module {
'title' => 'Hello World', 'title' => 'Hello World',
// version number // version number
'version' => 2, 'version' => 3,
// summary is brief description of what this module is // summary is brief description of what this module is
'summary' => 'An example module used for demonstration purposes. See the /site/modules/Helloworld.module file for details.', 'summary' => 'An example module used for demonstration purposes.',
// Optional URL to more information about the module // Optional URL to more information about the module
'href' => 'http://processwire.com', 'href' => 'https://processwire.com',
// singular=true: indicates that only one instance of the module is allowed. // singular=true: indicates that only one instance of the module is allowed.
// This is usually what you want for modules that attach hooks. // This is usually what you want for modules that attach hooks.
@@ -81,8 +81,11 @@ class Helloworld extends WireData implements Module {
/** /**
* Example1 hooks into the pages->save method and displays a notice every time a page is saved * Example1 hooks into the pages->save method and displays a notice every time a page is saved
* *
* @param HookEvent $event
*
*/ */
public function example1($event) { public function example1($event) {
/** @var Page $page */
$page = $event->arguments[0]; $page = $event->arguments[0];
$this->message("Hello World! You saved {$page->path}."); $this->message("Hello World! You saved {$page->path}.");
} }
@@ -91,9 +94,12 @@ class Helloworld extends WireData implements Module {
/** /**
* Example2 hooks into every page after it's rendered and adds "Hello World" text at the bottom * Example2 hooks into every page after it's rendered and adds "Hello World" text at the bottom
* *
* @param HookEvent $event
*
*/ */
public function example2($event) { public function example2($event) {
/** @var Page $page */
$page = $event->object; $page = $event->object;
// don't add this to the admin pages // don't add this to the admin pages
@@ -106,6 +112,8 @@ class Helloworld extends WireData implements Module {
/** /**
* Example3 adds a 'hello' method (not property) to every page that simply returns "Hello World" * Example3 adds a 'hello' method (not property) to every page that simply returns "Hello World"
* *
* @param HookEvent $event
*
*/ */
public function example3($event) { public function example3($event) {
$event->return = "Hello World"; $event->return = "Hello World";
@@ -114,6 +122,8 @@ class Helloworld extends WireData implements Module {
/** /**
* Example 4 adds a 'hello_world' property (not method) to every page that returns "Hello [user]" * Example 4 adds a 'hello_world' property (not method) to every page that returns "Hello [user]"
* *
* @param HookEvent $event
*
*/ */
public function example4($event) { public function example4($event) {
$event->return = "Hello " . $this->user->name; $event->return = "Hello " . $this->user->name;