LazyRecord\Schema\SchemaGenerator::generateCollectionClass PHP Метод

generateCollectionClass() публичный Метод

Generate collection class from a schema object.
public generateCollectionClass ( DeclareSchema $schema ) : array
$schema DeclareSchema
Результат array class name, class file path
    public function generateCollectionClass(DeclareSchema $schema)
    {
        $cTemplate = CollectionClassFactory::create($schema);
        return $this->updateClassFile($cTemplate, $schema, false);
    }

Usage Example

Пример #1
0
 public function testSchemaGenerator()
 {
     $g = new SchemaGenerator($this->config, $this->logger);
     $g->setForceUpdate(true);
     $schemas = $this->getModels();
     foreach ($schemas as $schema) {
         if ($result = $g->generateCollectionClass($schema)) {
             list($class, $file) = $result;
             ok($class);
             ok($file);
             path_ok($file);
             $this->syntaxTest($file);
         }
         if ($classMap = $g->generate(array($schema))) {
             foreach ($classMap as $class => $file) {
                 ok($class);
                 ok($file);
                 path_ok($file, $file);
                 // $this->syntaxTest($file);
                 require_once $file;
             }
         }
         $pk = $schema->findPrimaryKey();
         $this->assertNotNull($pk, "Find primary key from " . get_class($schema));
         $model = $schema->newModel();
         $this->assertNotNull($model);
         $collection = $schema->newCollection();
         $this->assertNotNull($collection);
     }
 }