示例#1
0
 /**
  * Builds the migrations from the file system
  *
  * @throws \Bytepark\Component\Migration\Exception\UnitIsAlreadyPresentException
  * @throws \InvalidArgumentException
  *
  * @param \FilesystemIterator $directory
  */
 protected function buildMigrations(\FilesystemIterator $directory)
 {
     foreach ($directory as $fileInfo) {
         /* @var $fileInfo \SplFileInfo */
         if ($fileInfo->isFile() && $fileInfo->getExtension() === $this->extension) {
             $migration = UnitOfWorkFactory::buildFromSplFileInfo($fileInfo);
             $this->add($migration);
         }
     }
 }
示例#2
0
 /**
  * Recursive build of the migrations
  *
  * Recursion ends when files are located in the given filesystem iterator.
  * Otherwise the recursion steps into the directory.
  *
  * @param \FilesystemIterator $directory The directory to build from
  *
  * @throws \Bytepark\Component\Migration\Exception\UnitIsAlreadyPresentException
  * @throws \InvalidArgumentException
  */
 private function buildFromSubDirectory(\FilesystemIterator $directory)
 {
     /* @var $fileInfo \SplFileInfo */
     foreach ($directory as $fileInfo) {
         if ($fileInfo->isDir()) {
             $subDirectory = new \FilesystemIterator($fileInfo->getRealPath());
             $this->buildFromSubDirectory($subDirectory);
         } elseif ($fileInfo->isFile() && $fileInfo->getExtension() === $this->extension) {
             $migration = UnitOfWorkFactory::buildFromSplFileInfo($fileInfo);
             $this->add($migration);
         }
     }
 }