gollumsf/doctrine-type

Add list of type for doctrine

v1.2.2 2022-05-20 21:58 UTC

This package is auto-updated.

Last update: 2024-11-21 03:09:48 UTC


README

Add list of type for doctrine (metapackage)

Installation:

composer require gollumsf/doctrine-type

Configuration:

doctrine:
    dbal:
        types:
            tinyint:  GollumSF\Doctrine\TinyInt # Add TINYINT type
            array_pipe:  GollumSF\Doctrine\ArrayPipe # Add array pipe transformer [ 'VAL1', 'VAL2' ] => 'VAL1|VAL2'
            enum_my_enum:  App\Doctrine\MyEnum # Add ENUM type (customable by enum)

Usage:

namespace App\Doctrine;

use GollumSF\Doctrine;
use App\Entity\MyEnum as Enum;

class MyEnum extends EnumType {
	
	public function getEnum(): string {
		return Enum::class;
	}
}

namespace App\Entity;

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

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

/**
 * @ORM\Table()
 */
class Entity {
	
	/**
	 * @ORM\Column(type="tinyint")
	 * @var int
	 */
	private $tinyint;
	
	/**
	 * @ORM\Column(type="array_pipe")
	 * @var int
	 */
	private $arrayPipe = [
		'ROLE_EXAMPLE', 'ROLE_USER', 'ROLE_ADMIN'
	];
	// Storage data in database with value: ROLE_EXAMPLE|ROLE_USER|ROLE_ADMIN
	
	/**
	 * @ORM\Column(type="enum_my_enum")
	 * @var int
	 */
	private $enum;
	
	/////////
	// ... //
	/////////
	
}

Single packages: