-
Notifications
You must be signed in to change notification settings - Fork 3
/
InvokeSubpageStrategies.php
63 lines (55 loc) · 1.25 KB
/
InvokeSubpageStrategies.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Pickle;
use MediaWiki\Logger\LoggerFactory;
/**
* Strategies to find an invoke subpage strategy
* This is a factory for the invoke subpages implemented as a common set of strategies. The
* entries will be found according to the title.
*
* @ingroup Extensions
*/
class InvokeSubpageStrategies extends Strategies {
/**
* Who (am I)
*
* @return class
*/
public static function who() {
return __CLASS__;
}
/**
* Configure the strategies
*
* @return true
*/
public static function init() {
global $wgPickleInvokeSubpage;
$results = self::getInstance();
foreach ( $wgPickleInvokeSubpage as $struct ) {
$results->register( $struct );
}
return true;
}
/**
* Checks if the string has any of the strategies stored patterns
*
* @param Title $title used as key
* @return string
*/
public function find( \Title $title ) {
if ( $this->isEmpty() ) {
self::init();
}
foreach ( $this->instances as $strategy ) {
if ( $strategy->checkSubpageType( $title ) ) {
LoggerFactory::getInstance( 'Pickle' )
->debug( 'Found invoke subpage strategy: {name}',
array_merge(
[ 'method' => __METHOD__ ],
$strategy->cloneOpts() ?: [] ) );
return $strategy;
}
}
return null;
}
}