addType() public method

public addType ( TypeSchema $schema ) : Builder
$schema TypeSchema
return Builder
Example #1
0
 public function setUp()
 {
     $this->storage = $this->createStorage();
     $hydrator = new DefaultHydrator($this->storage);
     $this->schemaBuilder = new Schema\Builder("inventory");
     $this->schemaBuilder->addType(new Schema\TypeSchema("product", ["sku" => new TextField(), "name" => new TextField()]));
     $this->registry = new MetadataAccessRegistry($this->storage, $this->schemaBuilder, $hydrator);
     $this->storage->alter($this->schemaBuilder->build());
 }
Example #2
0
 public function setUp()
 {
     $this->storage = $this->createStorage();
     $hydrator = new DefaultHydrator($this->storage);
     $this->schemaBuilder = new Schema\Builder("decimal");
     $productSchema = new Schema\TypeSchema("test", ["without_default" => new DecimalField(null, true), "with_default" => new DecimalField(0.0), "with_integer" => new DecimalField(123.0), "with_float" => new DecimalField(123.456, false, ['precision' => 6, 'scale' => 3])]);
     $this->schemaBuilder->addType($productSchema);
     $this->registry = new MetadataAccessRegistry($this->storage, $this->schemaBuilder, $hydrator);
     $this->storage->alter($this->schemaBuilder->build());
 }
Example #3
0
 public function setUp()
 {
     $this->storage = $this->createStorage();
     $hydrator = new DefaultHydrator($this->storage);
     $this->schemaBuilder = new Schema\Builder("map");
     $productSchema = new Schema\TypeSchema("test", ["without_default" => new MapField(), "with_default" => new MapField([])]);
     $this->schemaBuilder->addType($productSchema);
     $this->registry = new MetadataAccessRegistry($this->storage, $this->schemaBuilder, $hydrator);
     $this->storage->alter($this->schemaBuilder->build());
 }
 public function setUp()
 {
     $this->storage = $this->createStorage();
     $hydrator = new DefaultHydrator($this->storage);
     $this->schemaBuilder = new Schema\Builder("association");
     $categorySchema = new Schema\TypeSchema("category", ["name" => new TextField()]);
     $this->schemaBuilder->addType($categorySchema);
     $this->schemaBuilder->addType(new Schema\TypeSchema("product", ["category" => new AssociationField('association', $categorySchema, true)]));
     $this->registry = new MetadataAccessRegistry($this->storage, $this->schemaBuilder, $hydrator);
     $this->storage->alter($this->schemaBuilder->build());
 }
Example #5
0
 public function setUp()
 {
     $this->defaultDate = new \DateTimeImmutable("2004-02-12T15:19:21+00:00");
     $this->storage = $this->createStorage();
     $hydrator = new DefaultHydrator($this->storage);
     $this->schemaBuilder = new Schema\Builder("date");
     $productSchema = new Schema\TypeSchema("test", ["without_default" => new DateTimeField(null, true, [], 'Y-m-d H:i:s'), "with_default" => new DateTimeField($this->defaultDate, true, [], 'Y-m-d H:i:s')]);
     $this->schemaBuilder->addType($productSchema);
     $this->registry = new MetadataAccessRegistry($this->storage, $this->schemaBuilder, $hydrator);
     $this->storage->alter($this->schemaBuilder->build());
 }
Example #6
0
 public function test_changing_default_form_type()
 {
     $this->builder->addType(new Schema\TypeSchema("form", ['text_field' => new Schema\Field\TextField()]));
     $form = $this->factory->create(MetadataType::class, null, ['mao' => $this->registry->getMAO('form'), 'type_forms' => ['text_field' => TextareaType::class]]);
     $this->assertInstanceOf(TextareaType::class, $form->get('text_field')->getConfig()->getType()->getInnerType());
 }
 function let(Storage $storage, Hydrator $hydrator)
 {
     $builder = new Schema\Builder('schema');
     $builder->addType(new TypeSchema("product", ["sku" => new TextField()]));
     $this->beConstructedWith($storage, $builder, $hydrator);
 }