[MediaWiki-commits] [Gerrit] Update code examples in docs/hooks.txt - change (mediawiki/core)

2015-03-14 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Update code examples in docs/hooks.txt
..


Update code examples in docs/hooks.txt

Adjust for code convention and wfRunHooks - Hooks::run

Bug: T85588
Change-Id: I0297e389eb761822b0b5b9ea7a0a0a7990790677
---
M docs/hooks.txt
1 file changed, 38 insertions(+), 35 deletions(-)

Approvals:
  TTO: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/hooks.txt b/docs/hooks.txt
index 62285df..9d20fd9 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -34,15 +34,15 @@
 uppercase letters. Currently, in MediaWiki code, we would handle this as 
follows
 (note: not real code, here):
 
-   function showAnArticle($article) {
+   function showAnArticle( $article ) {
global $wgReverseTitle, $wgCapitalizeTitle;
 
-   if ($wgReverseTitle) {
-   wfReverseTitle($article);
+   if ( $wgReverseTitle ) {
+   wfReverseTitle( $article );
}
 
-   if ($wgCapitalizeTitle) {
-   wfCapitalizeTitle($article);
+   if ( $wgCapitalizeTitle ) {
+   wfCapitalizeTitle( $article );
}
 
# code to actually show the article goes here
@@ -52,34 +52,34 @@
 function -- with or without a global variable. For example, someone wanting
 email notification when an article is shown may add:
 
-function showAnArticle($article) {
+function showAnArticle( $article ) {
 global $wgReverseTitle, $wgCapitalizeTitle, $wgNotifyArticle;
 
-   if ($wgReverseTitle) {
-   wfReverseTitle($article);
+   if ( $wgReverseTitle ) {
+   wfReverseTitle( $article );
}
 
-   if ($wgCapitalizeTitle) {
-   wfCapitalizeTitle($article);
+   if ( $wgCapitalizeTitle ) {
+   wfCapitalizeTitle( $article );
}
 
# code to actually show the article goes here
 
-   if ($wgNotifyArticle) {
-   wfNotifyArticleShow($article);
+   if ( $wgNotifyArticle ) {
+   wfNotifyArticleShow( $article );
}
}
 
 Using a hook-running strategy, we can avoid having all this option-specific
 stuff in our mainline code. Using hooks, the function becomes:
 
-   function showAnArticle($article) {
+   function showAnArticle( $article ) {
 
-   if (wfRunHooks('ArticleShow', array($article))) {
+   if ( Hooks::run( 'ArticleShow', array( $article ) ) ) {
 
# code to actually show the article goes here
 
-   wfRunHooks('ArticleShowComplete', array($article));
+   Hooks::run( 'ArticleShowComplete', array( $article ) );
}
}
 
@@ -93,11 +93,11 @@
 deleteAnArticle, exportArticle, etc., we can concentrate it all in an extension
 file:
 
-   function reverseArticleTitle($article) {
+   function reverseArticleTitle( $article ) {
# ...
}
 
-   function reverseForExport($article) {
+   function reverseForExport( $article ) {
# ...
}
 
@@ -139,29 +139,29 @@
 event. All the following are valid ways to define hooks:
 
$wgHooks['EventName'][] = 'someFunction'; # function, no data
-   $wgHooks['EventName'][] = array('someFunction', $someData);
-   $wgHooks['EventName'][] = array('someFunction'); # weird, but OK
+   $wgHooks['EventName'][] = array( 'someFunction', $someData );
+   $wgHooks['EventName'][] = array( 'someFunction' ); # weird, but OK
 
$wgHooks['EventName'][] = $object; # object only
-   $wgHooks['EventName'][] = array($object, 'someMethod');
-   $wgHooks['EventName'][] = array($object, 'someMethod', $someData);
-   $wgHooks['EventName'][] = array($object); # weird but OK
+   $wgHooks['EventName'][] = array( $object, 'someMethod' );
+   $wgHooks['EventName'][] = array( $object, 'someMethod', $someData );
+   $wgHooks['EventName'][] = array( $object ); # weird but OK
 
 When an event occurs, the function (or object method) will be called with the
 optional data provided as well as event-specific parameters. The above examples
 would result in the following code being executed when 'EventName' happened:
 
# function, no data
-   someFunction($param1, $param2)
+   someFunction( $param1, $param2 )
# function with data
-   someFunction($someData, $param1, $param2)
+   someFunction( $someData, $param1, $param2 )
 
# object only
-   $object-onEventName($param1, $param2)
+   $object-onEventName( $param1, $param2 )
# object with method
-   $object-someMethod($param1, $param2)
+   $object-someMethod( 

[MediaWiki-commits] [Gerrit] Update code examples in docs/hooks.txt - change (mediawiki/core)

2015-03-13 Thread Umherirrender (Code Review)
Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/196602

Change subject: Update code examples in docs/hooks.txt
..

Update code examples in docs/hooks.txt

Adjust for code convention and wfRunHooks - Hooks::run

Bug: T85588
Change-Id: I0297e389eb761822b0b5b9ea7a0a0a7990790677
---
M docs/hooks.txt
1 file changed, 36 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/02/196602/1

diff --git a/docs/hooks.txt b/docs/hooks.txt
index 62285df..f761419 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -34,15 +34,15 @@
 uppercase letters. Currently, in MediaWiki code, we would handle this as 
follows
 (note: not real code, here):
 
-   function showAnArticle($article) {
+   function showAnArticle( $article ) {
global $wgReverseTitle, $wgCapitalizeTitle;
 
-   if ($wgReverseTitle) {
-   wfReverseTitle($article);
+   if ( $wgReverseTitle ) {
+   wfReverseTitle( $article );
}
 
-   if ($wgCapitalizeTitle) {
-   wfCapitalizeTitle($article);
+   if ( $wgCapitalizeTitle ) {
+   wfCapitalizeTitle( $article );
}
 
# code to actually show the article goes here
@@ -52,34 +52,34 @@
 function -- with or without a global variable. For example, someone wanting
 email notification when an article is shown may add:
 
-function showAnArticle($article) {
+function showAnArticle( $article ) {
 global $wgReverseTitle, $wgCapitalizeTitle, $wgNotifyArticle;
 
-   if ($wgReverseTitle) {
-   wfReverseTitle($article);
+   if ( $wgReverseTitle ) {
+   wfReverseTitle( $article );
}
 
-   if ($wgCapitalizeTitle) {
-   wfCapitalizeTitle($article);
+   if ( $wgCapitalizeTitle ) {
+   wfCapitalizeTitle( $article );
}
 
# code to actually show the article goes here
 
-   if ($wgNotifyArticle) {
-   wfNotifyArticleShow($article);
+   if ( $wgNotifyArticle ) {
+   wfNotifyArticleShow( $article );
}
}
 
 Using a hook-running strategy, we can avoid having all this option-specific
 stuff in our mainline code. Using hooks, the function becomes:
 
-   function showAnArticle($article) {
+   function showAnArticle( $article ) {
 
-   if (wfRunHooks('ArticleShow', array($article))) {
+   if ( Hooks::run( 'ArticleShow', array( $article ) ) ) {
 
# code to actually show the article goes here
 
-   wfRunHooks('ArticleShowComplete', array($article));
+   Hooks::run( 'ArticleShowComplete', array( $article ) );
}
}
 
@@ -93,11 +93,11 @@
 deleteAnArticle, exportArticle, etc., we can concentrate it all in an extension
 file:
 
-   function reverseArticleTitle($article) {
+   function reverseArticleTitle( $article ) {
# ...
}
 
-   function reverseForExport($article) {
+   function reverseForExport( $article ) {
# ...
}
 
@@ -139,29 +139,29 @@
 event. All the following are valid ways to define hooks:
 
$wgHooks['EventName'][] = 'someFunction'; # function, no data
-   $wgHooks['EventName'][] = array('someFunction', $someData);
-   $wgHooks['EventName'][] = array('someFunction'); # weird, but OK
+   $wgHooks['EventName'][] = array( 'someFunction', $someData );
+   $wgHooks['EventName'][] = array( 'someFunction' ); # weird, but OK
 
$wgHooks['EventName'][] = $object; # object only
-   $wgHooks['EventName'][] = array($object, 'someMethod');
-   $wgHooks['EventName'][] = array($object, 'someMethod', $someData);
-   $wgHooks['EventName'][] = array($object); # weird but OK
+   $wgHooks['EventName'][] = array( $object, 'someMethod' );
+   $wgHooks['EventName'][] = array( $object, 'someMethod', $someData );
+   $wgHooks['EventName'][] = array( $object ); # weird but OK
 
 When an event occurs, the function (or object method) will be called with the
 optional data provided as well as event-specific parameters. The above examples
 would result in the following code being executed when 'EventName' happened:
 
# function, no data
-   someFunction($param1, $param2)
+   someFunction( $param1, $param2 )
# function with data
-   someFunction($someData, $param1, $param2)
+   someFunction( $someData, $param1, $param2 )
 
# object only
-   $object-onEventName($param1, $param2)
+   $object-onEventName( $param1, $param2 )
# object with method
-