Revision: Tue, 16 Aug 2022 19:49:12 GMT

Customize Schema Defaults

You can set default Repository, Mapper, Source or Scope for all entity classes

use Cycle\ORM\Factory;
use Cycle\ORM\ORM;
use Cycle\ORM\Schema;

$orm = new ORM(
    (new Factory($dbal))->withDefaultSchemaClasses([
        SchemaInterface::REPOSITORY => MyRepository::class,
        SchemaInterface::SOURCE => MySource::class,
        SchemaInterface::MAPPER => MyMapper::class,
        SchemaInterface::SCOPE => MyScope::class,
        SchemaInterface::TYPECAST_HANDLER => [
            \Cycle\ORM\Parser\Typecast::class,
            UuidTypecast::class,
        ],
    ])
);

You can change any of these values, if you want.

By default, this config has the following values:

[
    SchemaInterface::REPOSITORY => \Cycle\ORM\Select\Repository::class,
    SchemaInterface::SOURCE => \Cycle\ORM\Select\Source::class,
    SchemaInterface::MAPPER => \Cycle\ORM\Mapper\Mapper::class,
    SchemaInterface::SCOPE => null,
    SchemaInterface::TYPECAST_HANDLER => null,
]
Edit this page