public function warm(Application $application) { parent::warm($application); $fs = new Filesystem(); $schema = $application->getStorage()->getSchema(); $entities = array(); foreach ($this->getClasses('Generator') as $class) { $reflection = Reflection::getReflectionClass($class); if (!$reflection->isAbstract() && $reflection->isSubclassOf('Cti\\Sencha\\Generator\\Generator')) { $entities[] = $reflection->getShortName(); } } foreach ($schema->getModels() as $model) { foreach ($entities as $entity) { if ($model->hasBehaviour('link') && $entity != 'Model' && $entity != 'Editor' || !$model->hasBehaviour('link') && $entity == 'Editor') { continue; } $generator = $this->application->getManager()->create('Cti\\Sencha\\Generator\\' . $entity, array('model' => $model, 'schema' => $schema)); $path = $this->application->getProject()->getPath('build coffee Generated ' . $entity . ' ' . $model->getClassName() . '.coffee'); $code = $generator->getGeneratedCode(); if (!file_exists($path) || md5(file_get_contents($path)) != md5($code)) { $fs->dumpFile($path, $code); } $path = $this->application->getProject()->getPath('build coffee ' . $entity . ' ' . $model->getClassName() . '.coffee'); $code = $generator->getFinalCode(); if (!file_exists($path) || md5(file_get_contents($path)) != md5($code)) { $fs->dumpFile($path, $code); } } echo '- generate ' . $model->getClassName() . PHP_EOL; } $generator = $this->application->getManager()->create('Cti\\Sencha\\Generator\\Master', array('model' => $model)); $path = $this->application->getProject()->getPath('build coffee Generated Master.coffee'); $code = $generator->getGeneratedCode(); if (!file_exists($path) || md5(file_get_contents($path)) != md5($code)) { $fs->dumpFile($path, $code); } $path = $this->application->getProject()->getPath('build coffee Master.coffee'); $code = $generator->getFinalCode(); if (!file_exists($path) || md5(file_get_contents($path)) != md5($code)) { $fs->dumpFile($path, $code); } $finder = new Finder(); $this->getCoffeeCompiler()->setDebug(true); $source = $application->getProject()->getPath('resources coffee'); if (is_dir($source)) { $finder->files()->name("*.coffee")->in($source); foreach ($finder as $file) { $script = substr($file, strlen($source) + 1, -7); echo '- processing ' . $script . '.coffee' . PHP_EOL; $this->getCoffeeCompiler()->build($script); } } }