gollumsf/doctrine-enum

An enum type for Doctrine MYSQL

v1.1.6 2022-05-19 08:38 UTC

This package is auto-updated.

Last update: 2024-11-19 13:40:09 UTC


README

An anum type for Doctrine MYSQL

Installation:

composer require gollumsf/doctrine-enum

Configuration:

doctrine:
    dbal:
        types:
            enum_my_type:  App\Doctrine\MyTypeEnum

Usage:

namespace App\Doctrine;

use GollumSF\Doctrine\EnumType;
use App\Entity\MyType;

class MyTypeEnum extends EnumType {
	
	public function getEnum(): string {
		return MyType::class;
	}
}

namespace App\Entity;

use GollumSF\Enum\Enum;
use Doctrine\ORM\Mapping as ORM;

class MyType extends Enum {
	const VALUE1 = 'VALUE1';
	const VALUE2 = 'VALUE2';
	const VALUE3 = 'VALUE3';
}

/**
 * @ORM\Entity()
 */
class Entity {
	
	/**
	 * @ORM\Column(type="enum_my_type")
	 * @var int
	 */
	private $enum;
	
	/////////
	// ... //
	/////////
	
}