Exemplo n.º 1
0
 private function generateNoSuchModelException(Entity $entity)
 {
     $className = "NoSuch{$entity->getName()}Exception";
     $content = "<?php\nclass {$className} extends Exception {\n\n}\n?>";
     $destination = "src/exceptions/{$className}.php";
     FileUtil::storeFileContents($destination, $content);
 }
 public function generate(Entity $entity)
 {
     $className = "{$entity->getName()}Persistence";
     $content = "<?php\nclass {$className} extends Persistence {\n\n" . "\tconst TABLE = \"{$entity->getTable()}\";\n\n";
     foreach ($entity->getFinders() as $finder) {
         $content .= $this->generateFinder($finder, $entity);
         $content .= $this->generateDeleteBy($finder, $entity);
     }
     $content .= $this->generateFindByPrimaryKey($entity);
     $content .= $this->generateCreate($entity);
     $content .= $this->generateRemove($entity);
     $content .= $this->generateUpdate($entity);
     $content .= $this->generateFindAll($entity);
     $content .= $this->generateGetCount($entity);
     $content .= $this->generateGetAsObject($entity);
     foreach (Singleton::create("ServiceBuilder")->getOneToManyMappedProperties($entity) as $property) {
         $content .= $this->generateOneToManyFinder($property);
     }
     foreach (Singleton::create("ServiceBuilder")->getManyToManyMappedProperties($entity) as $property) {
         $content .= $this->generateManyToManyFinder($property);
     }
     foreach ($entity->getManyToManyProperties() as $property) {
         $content .= $this->generateManyToManySetter($property);
     }
     $content .= "}\n?>";
     $destination = "src/service/persistence/{$className}.php";
     FileUtil::storeFileContents($destination, $content);
 }
Exemplo n.º 3
0
 public function generate(Entity $entity)
 {
     $className = "{$entity->getName()}Service";
     $destination = "src/impl/service/{$className}.php";
     if (FileUtil::fileExists($destination)) {
         return;
     }
     $content = "<?php\nclass {$className} extends {$className}Base {\n\n}\n?>";
     FileUtil::storeFileContents($destination, $content);
 }
Exemplo n.º 4
0
 public function generate(Entity $entity)
 {
     $className = "{$entity->getName()}Model";
     $content = "<?php\nabstract class {$className} extends Model {\n\n";
     $content .= $this->gettersAndSetters($entity);
     $content .= $this->getOneToManyGetters($entity);
     $content .= $this->getOneToManyMappedGettersSetters($entity);
     $content .= $this->getManyToManyGetters($entity);
     $content .= "}\n?>";
     // Write file to class
     $destination = "src/service/model/{$className}.php";
     FileUtil::storeFileContents($destination, $content);
 }
Exemplo n.º 5
0
 public function generate($entities)
 {
     PrintUtil::log("Generating sql scripts... ");
     $sql = "";
     foreach ($entities as $entity) {
         $sql .= $this->generateSql($entity) . "\n\n";
     }
     foreach (Singleton::create("ServiceBuilder")->getManyToManyMappingTables() as $table => $props) {
         $sql .= $this->generateMappingTable($table, $props);
     }
     FileUtil::storeFileContents("src/sql/tables.sql", $sql);
     $data = FileUtil::fileExists("src/sql/data.sql") ? FileUtil::getFileContents("src/sql/data.sql") : "";
     FileUtil::storeFileContents("src/sql/all.sql", $sql . $data);
     PrintUtil::logln("SQL scripts generated.");
 }
 public function generate(Entity $entity)
 {
     $className = "{$entity->getName()}ServiceBase";
     $content = "<?php\nclass {$className} {\n\n";
     foreach ($entity->getFinders() as $finder) {
         $content .= $this->generateFinder($finder->getMethodSignature());
         $content .= $this->generateDeleteBy($finder->getDeleteByMethodSignature());
     }
     $content .= $this->generateBaseServices($entity);
     foreach (Singleton::create("ServiceBuilder")->getOneToManyMappedProperties($entity) as $property) {
         $content .= $this->generateFinder($property->getFinderSignature());
     }
     foreach (Singleton::create("ServiceBuilder")->getManyToManyMappedProperties($entity) as $property) {
         $content .= $this->generateFinder($property->getFinderSignature());
     }
     foreach ($entity->getManyToManyProperties() as $property) {
         $content .= $this->generateManyToManySetter($property);
     }
     $content .= "}\n?>";
     // Write file to class
     $destination = "src/service/service/{$className}.php";
     FileUtil::storeFileContents($destination, $content);
 }
Exemplo n.º 7
0
 private static function storeAppBeans($appBeans)
 {
     FileUtil::storeFileContents(self::APP_SCOPE_FILE, serialize($appBeans));
 }