Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| factory | |
0.00% |
0 / 11 |
|
0.00% |
0 / 3 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| set_environment | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |||
| 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\install\helper\iohandler; |
| 15 | |
| 16 | use phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception; |
| 17 | |
| 18 | /** |
| 19 | * Input-output handler factory |
| 20 | */ |
| 21 | class factory |
| 22 | { |
| 23 | /** |
| 24 | * @var \Symfony\Component\DependencyInjection\ContainerInterface |
| 25 | */ |
| 26 | protected $container; |
| 27 | |
| 28 | /** |
| 29 | * @var string|null |
| 30 | */ |
| 31 | protected $environment; |
| 32 | |
| 33 | /** |
| 34 | * Constructor |
| 35 | * |
| 36 | * @param \Symfony\Component\DependencyInjection\ContainerInterface $container Dependency injection container |
| 37 | */ |
| 38 | public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container) |
| 39 | { |
| 40 | $this->container = $container; |
| 41 | $this->environment = null; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @param string $environment The name of the input-output handler to use |
| 46 | */ |
| 47 | public function set_environment($environment) |
| 48 | { |
| 49 | $this->environment = $environment; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Factory getter for iohandler |
| 54 | * |
| 55 | * @return \phpbb\install\helper\iohandler\iohandler_interface|null |
| 56 | * |
| 57 | * @throws iohandler_not_implemented_exception |
| 58 | * When the specified iohandler_interface does not exists |
| 59 | */ |
| 60 | public function get() |
| 61 | { |
| 62 | switch ($this->environment) |
| 63 | { |
| 64 | case 'ajax': |
| 65 | return $this->container->get('installer.helper.iohandler_ajax'); |
| 66 | |
| 67 | case 'nojs': |
| 68 | // @todo replace this |
| 69 | return $this->container->get('installer.helper.iohandler_ajax'); |
| 70 | |
| 71 | case 'cli': |
| 72 | return $this->container->get('installer.helper.iohandler_cli'); |
| 73 | |
| 74 | default: |
| 75 | throw new iohandler_not_implemented_exception(); |
| 76 | } |
| 77 | } |
| 78 | } |