/**
  * Run installation in context of the specified admin user
  *
  * @param $userName
  * @param array $modules
  * @return void
  * @throws \Exception
  */
 public function run($userName, array $modules = [])
 {
     set_time_limit(0);
     /** @var \Magento\User\Model\User $user */
     $user = $this->userFactory->create()->loadByUsername($userName);
     if (!$user->getId()) {
         throw new \Exception('Invalid admin user provided');
     }
     $this->state->start();
     $this->session->setUser($user);
     $this->deploy->run();
     $resources = $this->initResources($modules);
     $this->state->clearErrorFlag();
     try {
         foreach ($this->moduleList->getNames() as $moduleName) {
             if (isset($resources[$moduleName])) {
                 $resourceType = $resources[$moduleName];
                 $this->setupFactory->create($resourceType)->run();
                 $this->postInstaller->addModule($moduleName);
             }
         }
         $this->session->unsUser();
         $this->postInstaller->run();
         $this->state->finish();
     } catch (\Exception $e) {
         $this->state->setError();
         $this->logger->log($e->getMessage());
     }
 }
Beispiel #2
0
 /**
  * Run installation in context of the specified admin user
  *
  * @param \Magento\User\Model\User $adminUser
  * @throws \Exception
  *
  * @return void
  */
 public function run(\Magento\User\Model\User $adminUser)
 {
     set_time_limit(3600);
     if (!$adminUser || !$adminUser->getId()) {
         throw new \Exception('Invalid admin user provided');
     }
     $this->session->setUser($adminUser);
     $this->deploy->run();
     $resources = $this->initResources();
     foreach ($this->moduleList->getNames() as $moduleName) {
         if (isset($resources[$moduleName])) {
             $resourceType = $resources[$moduleName];
             $this->setupFactory->create($resourceType)->run();
             $this->postInstaller->addModule($moduleName);
         }
     }
     $this->session->unsUser();
     $this->postInstaller->run();
 }
Beispiel #3
0
 /**
  * @expectedException \LogicException
  * @expectedExceptionMessage \Not\Valid\Setup\Model is not a \Magento\Framework\Module\Updater\SetupInterface
  */
 public function testCreateThrowsExceptionIfSetupModelIsNotValid()
 {
     $model = new SetupFactory($this->objectManagerMock, ['module_setup' => '\\Not\\Valid\\Setup\\Model']);
     $model->create('module_setup', 'module');
 }