setName() 공개 메소드

Set name
public setName ( $name )
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var SolrIndexer $indexer */
     $indexer = $this->getContainer()->get('knp_bundles.indexer.solr');
     /** @var EntityManager $em */
     $em = $this->getContainer()->get('doctrine')->getManager();
     /** @var \Solarium_Client $solarium */
     $solarium = $this->getContainer()->get('solarium.client');
     /** @var EntityRepository $repository */
     $repository = $em->getRepository('KnpBundlesBundle:Bundle');
     $query = $solarium->createSelect();
     $query->setFields(array('name', 'ownerName'));
     try {
         $hasMoreResults = true;
         $page = 1;
         while ($hasMoreResults) {
             $paginator = new Pagerfanta(new SolariumAdapter($solarium, $query));
             $paginator->setMaxPerPage(50)->setCurrentPage($page, false, true);
             foreach ($paginator as $bundle) {
                 $entity = $repository->findOneBy(array('name' => $bundle['name']));
                 if (!$entity) {
                     $entity = new Bundle();
                     $entity->setName($bundle['name']);
                     $entity->setOwnerName($bundle['ownerName']);
                     $indexer->deleteBundlesIndexes($entity);
                     $output->writeln(sprintf('The bundle "%s" was deleted from solr index.', $entity->getFullName()));
                 }
             }
             $hasMoreResults = $paginator->getNbResults() == 50;
             $page++;
         }
     } catch (\Solarium_Client_HttpException $e) {
         throw new \Exception('Seems that our search engine is currently offline. Please check later.');
     }
 }
예제 #2
0
 /**
  * @test
  */
 public function shouldNotCreateNewRepoWhenExists()
 {
     $bundle = new BundleEntity();
     $bundle->setOwnerName('KnpLabs');
     $bundle->setName('KnpBundles');
     $expectedDir = $this->getExpectedDir();
     $this->createRepoInExpectedLocation();
     $repoManager = $this->getRepoManager();
     $repoManager->expects($this->never())->method('cloneRepo');
     $this->assertTrue(is_dir($expectedDir));
     $this->assertInstanceOf('Knp\\Bundle\\KnpBundlesBundle\\Git\\Repo', $repoManager->getRepo($bundle));
 }
예제 #3
0
 /**
  * @param string $name
  *
  * @return Bundle
  */
 private function createEmptyBundle($name)
 {
     $bundle = new Bundle();
     $bundle->setName($name);
     return $bundle;
 }