Exemple #1
0
 public function testCreateWithDispatcher()
 {
     $config = new Config();
     $dispatcher = new EventDispatcher();
     $context = new Context(null, $config, null, $dispatcher);
     $this->assertSame($dispatcher, $context->getEventDispatcher());
 }
 /**
  * Creates the context.
  *
  * @param string|null                   $homeDir        The path to the
  *                                                      home directory or
  *                                                      `null` if none
  *                                                      exists.
  * @param string                        $rootDir        The path to the
  *                                                      project's root
  *                                                      directory.
  * @param Config                        $config         The configuration.
  * @param RootModuleFile                $rootModuleFile The root module
  *                                                      file.
  * @param ConfigFile|null               $configFile     The configuration
  *                                                      file or `null` if
  *                                                      none exists.
  * @param EventDispatcherInterface|null $dispatcher     The event
  *                                                      dispatcher.
  * @param string                        $env            The environment
  *                                                      that Puli is
  *                                                      running in.
  */
 public function __construct($homeDir, $rootDir, Config $config, RootModuleFile $rootModuleFile, ConfigFile $configFile = null, EventDispatcherInterface $dispatcher = null, $env = Environment::DEV)
 {
     Assert::directory($rootDir, 'The root directory %s is not a directory.');
     Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
     parent::__construct($homeDir, $config, $configFile, $dispatcher);
     $this->rootDir = Path::canonicalize($rootDir);
     $this->rootModuleFile = $rootModuleFile;
     $this->env = $env;
 }
Exemple #3
0
 private function activatePlugins()
 {
     foreach ($this->context->getRootPackageFile()->getPluginClasses() as $pluginClass) {
         $this->validatePluginClass($pluginClass);
         /** @var PuliPlugin $plugin */
         $plugin = new $pluginClass();
         $plugin->activate($this);
     }
 }
 /**
  * Creates the configuration manager.
  *
  * @param Context           $context           The global context.
  * @param ConfigFileStorage $configFileStorage The configuration file storage.
  */
 public function __construct(Context $context, ConfigFileStorage $configFileStorage)
 {
     $this->context = $context;
     $this->configFileStorage = $configFileStorage;
     $this->configFile = $context->getConfigFile();
 }