4 * This file is part of the Behat Testwork.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Testwork;
13 use Behat\Testwork\Cli\Application;
14 use Behat\Testwork\ServiceContainer\Configuration\ConfigurationLoader;
15 use Behat\Testwork\ServiceContainer\Extension;
16 use Behat\Testwork\ServiceContainer\ExtensionManager;
19 * Defines the way application is created.
21 * Extend and implement this class to create an entry point for your framework.
23 * @author Konstantin Kudryashov <ever.zet@gmail.com>
25 abstract class ApplicationFactory
28 * Returns application name.
32 abstract protected function getName();
35 * Returns current application version.
39 abstract protected function getVersion();
42 * Returns list of extensions enabled by default.
46 abstract protected function getDefaultExtensions();
49 * Returns the name of configuration environment variable.
53 abstract protected function getEnvironmentVariableName();
56 * Returns user config path.
60 abstract protected function getConfigPath();
63 * Creates application instance.
67 public function createApplication()
69 $configurationLoader = $this->createConfigurationLoader();
70 $extensionManager = $this->createExtensionManager();
72 return new Application($this->getName(), $this->getVersion(), $configurationLoader, $extensionManager);
76 * Creates configuration loader.
78 * @return ConfigurationLoader
80 protected function createConfigurationLoader()
82 return new ConfigurationLoader($this->getEnvironmentVariableName(), $this->getConfigPath());
86 * Creates extension manager.
88 * @return ExtensionManager
90 protected function createExtensionManager()
92 return new ExtensionManager($this->getDefaultExtensions());