/** * Apply given bundle * * @param string $bundle Bundle name, URI or filename * * @return \Phrozn\Bundle */ public function applyBundle($bundle) { $bundle = new Bundle($bundle, $this->getConfig()); $bundleId = $bundle->getInfo('id'); $registry = $this->getRegistryContainer(); if ($registry->isInstalled($bundleId)) { throw new \Exception(sprintf('Bundle "%s" is already installed.', $bundleId)); } // install $bundle->extractTo($this->getProjectPath()); // persist list of installed bundles $registry->markAsInstalled($bundleId, $bundle->getFiles()); }
public function testExtractByName() { $bundlesConfig = dirname(__FILE__) . '/../../configs/bundles.yml'; $path = new ProjectPath(dirname(__FILE__) . '/Bundle/project/'); $bundle = new Bundle('test', new Config($bundlesConfig)); @unlink($path . '/plugins/Processor/Test.php'); @unlink($path . '/plugins/Site/View/Test.php'); $this->assertFalse(file_exists($path . '/plugins/Processor/Test.php')); $this->assertFalse(file_exists($path . '/plugins/Site/View/Test.php')); $bundle->extractTo($path); $this->assertTrue(file_exists($path . '/plugins/Processor/Test.php')); $this->assertTrue(file_exists($path . '/plugins/Site/View/Test.php')); @unlink($path . '/plugins/Processor/Test.php'); @unlink($path . '/plugins/Site/View/Test.php'); }