PHP code example of wakeapp / dbal-enum-type

1. Go to this page and download the library: Download wakeapp/dbal-enum-type library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wakeapp / dbal-enum-type example snippets


 declare(strict_types=1);

namespace App\AcmeBundle\Entity\Enum;

class LanguageListEnum
{
    public const RU = 'ru';
    public const EN = 'en';
    public const DE = 'de';
}

 declare(strict_types=1);

namespace App\AcmeBundle\Doctrine\DBAL\Types;

use App\AcmeBundle\Entity\Enum\LanguageListEnum;
use Wakeapp\Component\DbalEnumType\Type\AbstractEnumType;

class LanguageListEnumType extends AbstractEnumType
{
    /**
     * {@inheritdoc}
     */
    public static function getEnumClass(): string
    {
        return LanguageListEnum::class;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function getTypeName(): string
    {
        return 'language_list_enum';
    }
}

 declare(strict_types=1);

\Doctrine\DBAL\Types\Type::addType(LanguageListEnumType::getTypeName(), LanguageListEnumType::class);

 declare(strict_types=1);

namespace App\AcmeBundle;

use App\AcmeBundle\Doctrine\DBAL\Types\LanguageListEnumType;
use Doctrine\DBAL\Types\Type;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppAcmeBundleBundle extends Bundle
{
    public function boot()
    {
        Type::addType(LanguageListEnumType::getTypeName(), LanguageListEnumType::class);

        parent::boot();
    }
}