-
Notifications
You must be signed in to change notification settings - Fork 3
/
ExtractStatusStrategies.php
64 lines (56 loc) · 1.29 KB
/
ExtractStatusStrategies.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
64
<?php
namespace Pickle;
use MediaWiki\Logger\LoggerFactory;
/**
* Strategies to find an extract status strategy
* This is a factory for the extracted statuses implemented as a common set of strategies. The
* entries will be found according to the current result.
*
* @ingroup Extensions
*/
class ExtractStatusStrategies extends Strategies {
/**
* Who (am I)
*
* @return class
*/
public static function who() {
return __CLASS__;
}
/**
* Configure the strategies
*
* @return true
*/
public static function init() {
global $wgPickleExtractStatus;
$results = self::getInstance();
foreach ( $wgPickleExtractStatus as $struct ) {
$results->register( $struct );
}
return true;
}
/**
* Checks if the string has any of the strategies stored patterns
*
* @param string $str used as key
* @return string
*/
public function find( $str ) {
if ( $this->isEmpty() ) {
self::init();
}
foreach ( $this->instances as $strategy ) {
$state = $strategy->checkState( $str );
if ( is_bool( $state ) ? $state : true ) {
LoggerFactory::getInstance( 'Pickle' )
->debug( 'Found extract status strategy: {name}',
array_merge(
[ 'method' => __METHOD__ ],
$strategy->cloneOpts() ?: [] ) );
return $strategy;
}
}
return null;
}
}