Mongolid\Manager::registerSchema PHP Method

registerSchema() public method

Allow document Schemas to be registered for later use.
public registerSchema ( Schema $schema ) : void
$schema Mongolid\Schema\Schema Schema being registered.
return void
    public function registerSchema(Schema $schema)
    {
        $this->schemas[$schema->entityClass] = $schema;
    }

Usage Example

Example #1
0
 public function testShouldGetDataMapperForEntitiesWithRegisteredSchemas()
 {
     // Arrange
     $manager = new Manager();
     $schema = m::mock(Schema::class);
     $dataMapper = m::mock(DataMapper::class)->makePartial();
     $schema->entityClass = 'Bacon';
     // Act
     Ioc::instance(DataMapper::class, $dataMapper);
     // Assert
     $manager->registerSchema($schema);
     $result = $manager->getMapper('Bacon');
     $this->assertEquals($dataMapper, $result);
     $this->assertAttributeEquals($schema, 'schema', $result);
 }