Knp\Bundle\KnpBundlesBundle\Updater\Updater::addBundle PHP Method

addBundle() public method

Add or update a repo
public addBundle ( string $fullName, boolean $updateRepo = true ) : boolean | Bundle
$fullName string A full repo name like KnpLabs/KnpMenuBundle
$updateRepo boolean Whether or not to fetch information
return boolean | Knp\Bundle\KnpBundlesBundle\Entity\Bundle
    public function addBundle($fullName, $updateRepo = true)
    {
        $bundle = $this->bundleManager->createBundle($fullName);
        if (!$bundle) {
            return false;
        }
        if ($updateRepo) {
            $this->updateRepo($bundle);
        }
        return $bundle;
    }

Usage Example

Example #1
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $gitRepoDir = $this->getContainer()->getParameter('knp_bundles.bundles_dir');
     $gitBin = $this->getContainer()->getParameter('knp_bundles.git_bin');
     $em = $this->getContainer()->get('knp_bundles.entity_manager');
     $updater = new Updater($em, $gitRepoDir, $gitBin, $output);
     $updater->setUp();
     $bundles = $updater->addBundle($input->getArgument('bundleName'));
     $em->flush();
 }