Revision: Thu, 18 Apr 2024 09:24:13 GMT

Customize Schema Defaults

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

php
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:

php
[
    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