Puli\Manager\Repository\RepositoryManagerImpl::buildRepository PHP Метод

buildRepository() публичный Метод

public buildRepository ( )
    public function buildRepository()
    {
        $this->assertMappingsLoaded();
        if ($this->dispatcher->hasListeners(PuliEvents::PRE_BUILD_REPOSITORY)) {
            $event = new BuildRepositoryEvent($this);
            $this->dispatcher->dispatch(PuliEvents::PRE_BUILD_REPOSITORY, $event);
            if ($event->isBuildSkipped()) {
                return;
            }
        }
        $this->populateRepository()->execute();
        if ($this->dispatcher->hasListeners(PuliEvents::POST_BUILD_REPOSITORY)) {
            $this->dispatcher->dispatch(PuliEvents::POST_BUILD_REPOSITORY, new BuildRepositoryEvent($this));
        }
    }

Usage Example

 public function testPreBuildRepositoryEventSupportsSkipping()
 {
     $testResource = new FileResource(__FILE__);
     $this->initEnvironment($this->homeDir, $this->rootDir, false);
     $this->initDefaultManager();
     $this->packageFile1->addPathMapping(new PathMapping('/path', 'resources'));
     $this->repo->expects($this->never())->method('add');
     $this->dispatcher->addListener(PuliEvents::PRE_BUILD_REPOSITORY, function (BuildRepositoryEvent $event) {
         $event->skipBuild();
     });
     $this->dispatcher->addListener(PuliEvents::POST_BUILD_REPOSITORY, function (BuildRepositoryEvent $event) use($testResource) {
         // The post event is not executed if the build is skipped
         $event->getRepositoryManager()->getRepository()->add('/post', $testResource);
     });
     $this->manager->buildRepository();
 }