tuscanicz/doctrine-enum-oracle

Doctrine type for Enum data type in Oracle.

1.0.2 2017-06-22 15:17 UTC

This package is auto-updated.

Last update: 2024-11-27 08:24:32 UTC


README

An abstract class defining a new Doctrine type for Enum data type in Oracle.

Has dependency on tuscanicz/enum and Doctrine 2 doctrine/orm.

How to use

Prepare a new Enum using tuscanicz/enum:

<?php

namespace MyApp\Enum;

use Enum\AbstractEnum;

class MyExampleEnum extends AbstractEnum
{
    const MY_EXAMPLE_ENUM_FIRST = 'first';
    const MY_EXAMPLE_ENUM_SECOND = 'second';
    const MY_EXAMPLE_ENUM_THIRD = 'third';
}

Create a new Type MyExampleType into MyApp\Component\Doctrine\Type namespace and extending the AbstractEnumType:

<?php

namespace MyApp\Component\Doctrine\Type;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use DoctrineEnumOracle\AbstractEnumType;
use MyApp\Enum\MyExampleEnum;

class MyExampleType extends AbstractEnumType
{
    public function getEnumClassName()
    {
        return MyExampleEnum::class;
    }
}

How to use it with Symfony

Configure a new type (config.yml):

doctrine:
    dbal:
        types:
            MyExampleType: 'MyApp\Component\Doctrine\Type\MyExampleType'

How to use it with Zend Framework

Configure a new type (config.php):

'doctrine' => [
    'configuration' => [
        'orm_default' => [
            'types' => [
                'my_example_type' => 'MyApp\Component\Doctrine\Type\MyExampleType',
            ]
            ...
        ]
        ...
    ]
    ...
]

That's all!

Now you can try to generate a new migration or schema diff.