Exemplo n.º 1
0
 public function build(\Faker\Io\Io $folder, \Faker\Io\Io $skelton, \Symfony\Component\Console\Output\OutputInterface $output)
 {
     $mode = 0777;
     #check if root folder exists
     if (is_dir($folder->getBase()) === false) {
         throw new FakerException('Root directory does not exist');
     }
     #make config folders
     $config_path = $folder->getBase() . DIRECTORY_SEPARATOR . 'config';
     if (mkdir($config_path, $mode) === TRUE) {
         $output->writeln('<info>Created Config Folder</info>');
         //copy files into it
         $files = $skelton->iterator('config');
         foreach ($files as $file) {
             if ($this->copy($file, $config_path) === TRUE) {
                 $output->writeln('++ Copied ' . basename($file));
             }
         }
     }
     #make template folder
     $template_path = $folder->getBase() . DIRECTORY_SEPARATOR . 'template';
     if (mkdir($template_path, $mode) === TRUE) {
         $output->writeln('<info>Created Template Folder</info>');
         //copy files into it
         $files = $skelton->iterator('template');
         foreach ($files as $file) {
             if ($this->copy($file, $template_path) === TRUE) {
                 $output->writeln('++ Copied ' . basename($file));
             }
         }
     }
     #make extension extension folder
     $extension_path = $folder->getBase() . DIRECTORY_SEPARATOR . 'extension';
     if (mkdir($extension_path, $mode) === TRUE) {
         $output->writeln('<info>Created Extension Folder</info>');
         //copy files into it
         $files = $skelton->iterator('extension');
         foreach ($files as $file) {
             if ($this->copy($file, $extension_path) === TRUE) {
                 $output->writeln('++ Copied ' . basename($file));
             }
         }
     }
     #make dump folder
     $dump_path = $folder->getBase() . DIRECTORY_SEPARATOR . 'dump';
     if (mkdir($dump_path, $mode) === TRUE) {
         $output->writeln('<info>Created Dump Folder</info>');
     }
     #make sources folder
     $sources_path = $folder->getBase() . DIRECTORY_SEPARATOR . 'sources';
     if (mkdir($sources_path, $mode) === TRUE) {
         $output->writeln('<info>Created Sources Folder</info>');
         //copy files into it
         $files = $skelton->iterator('sources');
         foreach ($files as $file) {
             if ($this->copy($file, $sources_path) === TRUE) {
                 $output->writeln('++ Copied ' . basename($file));
             }
         }
     }
 }