Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| provider | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| find | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
0 | |||
| getIterator | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\extension; |
| 15 | |
| 16 | /** |
| 17 | * Provides a set of items found in extensions. |
| 18 | * |
| 19 | * This abstract class is essentially a wrapper around item-specific |
| 20 | * finding logic. It handles storing the extension manager via constructor |
| 21 | * for the finding logic to use to find the items, and provides an |
| 22 | * iterator interface over the items found by the finding logic. |
| 23 | * |
| 24 | * Items could be anything, for example template paths or cron task names. |
| 25 | * Derived classes completely define what the items are. |
| 26 | */ |
| 27 | abstract class provider implements \IteratorAggregate |
| 28 | { |
| 29 | /** |
| 30 | * Array holding all found items |
| 31 | * @var array|null |
| 32 | */ |
| 33 | protected $items = null; |
| 34 | |
| 35 | /** |
| 36 | * An extension manager to search for items in extensions |
| 37 | * @var \phpbb\extension\manager |
| 38 | */ |
| 39 | protected $extension_manager; |
| 40 | |
| 41 | /** |
| 42 | * Constructor. Loads all available items. |
| 43 | * |
| 44 | * @param \phpbb\extension\manager $extension_manager phpBB extension manager |
| 45 | */ |
| 46 | public function __construct(\phpbb\extension\manager $extension_manager) |
| 47 | { |
| 48 | $this->extension_manager = $extension_manager; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Finds items using the extension manager. |
| 53 | * |
| 54 | * @return array List of task names |
| 55 | */ |
| 56 | abstract protected function find(); |
| 57 | |
| 58 | /** |
| 59 | * Retrieve an iterator over all items |
| 60 | * |
| 61 | * @return \ArrayIterator An iterator for the array of template paths |
| 62 | */ |
| 63 | public function getIterator(): \ArrayIterator |
| 64 | { |
| 65 | if ($this->items === null) |
| 66 | { |
| 67 | $this->items = $this->find(); |
| 68 | } |
| 69 | |
| 70 | return new \ArrayIterator($this->items); |
| 71 | } |
| 72 | } |