Exemple #1
0
 function execute()
 {
     $logger = $this->getLogger();
     $path = Path::get_home_flavor_path();
     $logger->info("Creating {$path} ...");
     Helper::mktree($path);
     $logger->info("Creating flavors/...");
     Helper::mktree('flavors');
     $logger->info("Done");
 }
 function installFlavor($flavor)
 {
     if (isset($this->installed[$flavor->getName()])) {
         return;
     }
     $logger = $this->getLogger();
     $homePath = Path::get_home_flavor_path();
     Helper::mktree($homePath);
     $logger->info("Installing " . $flavor->getName() . "...");
     Helper::copy_dir($flavor->__toString(), $homePath . DIRECTORY_SEPARATOR . $flavor->getName(), function ($target) use($logger) {
         $logger->info("Installing " . $target, 1);
     });
     // get dependencies
     $generator = $flavor->getGenerator();
     $depGenerators = $generator->getDependencies();
     foreach ($depGenerators as $depGenerator) {
         $this->installFlavor($depGenerator->getFlavor());
     }
 }
Exemple #3
0
 function execute()
 {
     $logger = $this->getLogger();
     $logger->info('Available flavors:');
     $paths = Path::get_flavor_paths();
     foreach ($paths as $path) {
         if (!file_exists($path)) {
             continue;
         }
         if ($handle = opendir($path)) {
             while (false !== ($entry = readdir($handle))) {
                 if ($entry == '.' || $entry == '..') {
                     continue;
                 }
                 $logger->info(sprintf("%-10s  %s", $entry, $path), 1);
             }
             closedir($handle);
         }
     }
 }
Exemple #4
0
 /**
  * generate new flavor 
  *
  * @param string $name flavor name, lower case, alphabets
  * @param string $path your code base path
  */
 public function generate($name, $codeBasePath = null)
 {
     if (preg_match('/\\W/', $name)) {
         throw new Exception("{$name} is not a valid flavor name");
     }
     $paths = Path::get_flavor_paths();
     foreach ($paths as $path) {
         if (file_exists($path)) {
             $flavor = new FlavorDirectory($path . DIRECTORY_SEPARATOR . $name);
             $resourceDir = $flavor->getResourceDir();
             $this->createDir($resourceDir);
             if ($codeBasePath) {
                 if (!file_exists($codeBasePath)) {
                     throw new Exception("{$codeBasePath} doesn't exist.");
                 }
                 $codeBasePath = realpath($codeBasePath) ?: $codeBasePath;
                 $this->copyDir($codeBasePath, $resourceDir);
             }
             $this->render('Generator.php.twig', $flavor->getGeneratorClassFile(), array('name' => $name));
             $this->getLogger()->info('Done');
             exit(0);
         }
     }
 }
Exemple #5
0
 function __construct($dirs = null)
 {
     /* get default flavor paths */
     $this->dirs = $dirs ? (array) $dirs : Path::get_flavor_paths();
 }