1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Base breadcrumb item locator |
4
|
|
|
* |
5
|
|
|
* @package carbon-breadcrumbs |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Abstract breadcrumb item locator class. |
10
|
|
|
* |
11
|
|
|
* Used as a base for all breadcrumb locator types. |
12
|
|
|
*/ |
13
|
|
|
abstract class Carbon_Breadcrumb_Locator extends Carbon_Breadcrumb_Factory { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Breadcrumb item locator type. |
17
|
|
|
* |
18
|
|
|
* @access protected |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $type = ''; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Breadcrumb item locator subtype. |
25
|
|
|
* |
26
|
|
|
* @access protected |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $subtype = ''; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Build a new breadcrumb item locator of the selected type. |
33
|
|
|
* |
34
|
|
|
* @static |
35
|
|
|
* @access public |
36
|
|
|
* |
37
|
|
|
* @param string $type Type of the breadcrumb item locator. |
38
|
|
|
* @param string $subtype Subtype of the breadcrumb item locator. |
39
|
|
|
* @return Carbon_Breadcrumb_Locator $locator The new breadcrumb item locator. |
40
|
|
|
*/ |
41
|
|
|
public static function factory( $type, $subtype = '' ) { |
42
|
|
|
$class = self::verify_class_name( __CLASS__ . '_' . $type, 'Unexisting breadcrumb locator type: "' . $type . '".' ); |
43
|
|
|
$locator = new $class( $type, $subtype ); |
44
|
|
|
|
45
|
|
|
return $locator; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Constructor. |
50
|
|
|
* |
51
|
|
|
* Creates and configures a new breadcrumb item locator with the provided settings. |
52
|
|
|
* |
53
|
|
|
* @access public |
54
|
|
|
* |
55
|
|
|
* @param string $type Type of the breadcrumb item locator. |
56
|
|
|
* @param string $subtype Subtype of the breadcrumb item locator. |
57
|
|
|
*/ |
58
|
|
|
public function __construct( $type, $subtype ) { |
59
|
|
|
$this->set_type( $type ); |
60
|
|
|
$this->set_subtype( $subtype ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Generate a set of breadcrumb items that found by the current type and the provided subtypes. |
65
|
|
|
* |
66
|
|
|
* @access public |
67
|
|
|
* |
68
|
|
|
* @param array $subtypes The subtypes to generate items for. |
69
|
|
|
* @return array $items The items, generated by this locator. |
70
|
|
|
*/ |
71
|
|
|
public function generate_items_for_subtypes( $subtypes ) { |
72
|
|
|
$all_items = array(); |
73
|
|
|
|
74
|
|
|
foreach ( $subtypes as $subtype ) { |
75
|
|
|
$locator = Carbon_Breadcrumb_Locator::factory( $this->get_type(), $subtype ); |
|
|
|
|
76
|
|
|
if ( $locator->is_included() ) { |
77
|
|
|
$items = $locator->get_items(); |
78
|
|
|
$all_items = array_merge( $all_items, $items ); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $all_items; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Retrieve the type of this locator. |
87
|
|
|
* |
88
|
|
|
* @access public |
89
|
|
|
* |
90
|
|
|
* @return string $type The type of this locator. |
91
|
|
|
*/ |
92
|
|
|
public function get_type() { |
93
|
|
|
return $this->type; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Modify the type of this locator. |
98
|
|
|
* |
99
|
|
|
* @access public |
100
|
|
|
* |
101
|
|
|
* @param string $type The new locator type. |
102
|
|
|
*/ |
103
|
|
|
public function set_type( $type ) { |
104
|
|
|
$this->type = $type; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Retrieve the subtype of this locator. |
109
|
|
|
* |
110
|
|
|
* @access public |
111
|
|
|
* |
112
|
|
|
* @return string $subtype The subtype of this locator. |
113
|
|
|
*/ |
114
|
|
|
public function get_subtype() { |
115
|
|
|
return $this->subtype; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Modify the subtype of this locator. |
120
|
|
|
* |
121
|
|
|
* @access public |
122
|
|
|
* |
123
|
|
|
* @param string $subtype The new locator subtype. |
124
|
|
|
*/ |
125
|
|
|
public function set_subtype( $subtype ) { |
126
|
|
|
$this->subtype = $subtype; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Whether this the items of this locator should be included in the trail. |
131
|
|
|
* |
132
|
|
|
* @abstract |
133
|
|
|
* @access public |
134
|
|
|
*/ |
135
|
|
|
abstract public function is_included(); |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Get the breadcrumb items, found by this locator. |
139
|
|
|
* |
140
|
|
|
* @abstract |
141
|
|
|
* @access public |
142
|
|
|
* |
143
|
|
|
* @param int $priority The priority of the located items. |
144
|
|
|
* @param int $id The ID of the item to get items for. Optional. |
145
|
|
|
*/ |
146
|
|
|
abstract public function get_items( $priority = 1000, $id = 0 ); |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Generate a set of breadcrumb items that found by this locator type and any subtype. |
150
|
|
|
* |
151
|
|
|
* @abstract |
152
|
|
|
* @access public |
153
|
|
|
*/ |
154
|
|
|
abstract public function generate_items(); |
155
|
|
|
|
156
|
|
|
} |
157
|
|
|
|
This check looks for accesses to local static members using the fully qualified name instead of
self::
.While this is perfectly valid, the fully qualified name of
Certificate::TRIPLEDES_CBC
could just as well be replaced byself::TRIPLEDES_CBC
. Referencing local members withself::
assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.