| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class factory |
||
| 13 | { |
||
| 14 | /** @var array */ |
||
| 15 | private $comment_types; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Constructor |
||
| 19 | * |
||
| 20 | * @param \phpbb\di\service_collection $types Service Collection |
||
| 21 | */ |
||
| 22 | public function __construct(\phpbb\di\service_collection $types) |
||
| 23 | { |
||
| 24 | $this->register_comment_types($types); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Register available content views |
||
| 29 | * @param \phpbb\di\service_collection $views |
||
| 30 | */ |
||
| 31 | protected function register_comment_types(\phpbb\di\service_collection $types) |
||
| 32 | { |
||
| 33 | $this->comment_types = array(); |
||
| 34 | foreach ($types as $service => $driver) |
||
| 35 | { |
||
| 36 | $this->comment_types[$service] = $driver; |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Get comment type |
||
| 42 | * |
||
| 43 | * @param string $service_name |
||
| 44 | * @return null|\blitze\content\services\comments\comments_interface |
||
| 45 | */ |
||
| 46 | public function get($service_name) |
||
| 47 | { |
||
| 48 | return isset($this->comment_types[$service_name]) ? $this->comment_types[$service_name] : null; |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Get available comment types |
||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | public function get_all_types() |
||
| 64 | } |
||
| 65 | } |
||
| 66 |