2017 © Pedro PelĂĄez
 

library integer

Enumeration type for Doctrine - integers only

image

doctrineum/integer

Enumeration type for Doctrine - integers only

  • Wednesday, July 18, 2018
  • by jaroslavtyc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6,021 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 15 Versions
  • 4 % Grown

The README.md

Doctrine Integer enum

Build Status Test Coverage License, (*1)

About

Adds Enum to Doctrine ORM (can be used as a @Column(type="integer_enum"))., (*2)

Usage

<?php

use Doctrine\ORM\Mapping as ORM;
use Doctrineum\Integer\IntegerEnum;

/**
 * @ORM\Entity()
 */
class Journey
{
    /**
     * @var int
     * @ORM\Id() @ORM\GeneratedValue(strategy="AUTO") @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @var IntegerEnum
     * @ORM\Column(type="integer_enum")
     */
    private $distanceInKm;

    public function __construct(IntegerEnum $distanceInKm)
    {
        $this->distanceInKm = $distanceInKm;
    }

    /**
     * @return IntegerEnum
     */
    public function getDistanceInKm()
    {
        return $this->distanceInKm;
    }
}

$toSun = new Journey(IntegerEnum::getEnum(152100000));

/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager->persist($toSun);
$entityManager->flush();
$entityManager->clear();

/** @var Journey[] $StarTracks */
$StarTracks = $entityManager->createQuery(
    "SELECT j FROM Journey j WHERE j.distanceInKm >= 1000000"
)->getResult();

var_dump($StarTracks[0]->getDistanceInKm()->getValue()); // 152100000;

Installation

Add it to your list of Composer dependencies (or by manual edit your composer.json, the require section), (*3)

composer require jaroslavtyc/doctrineum-integer

Doctrine integration

Register new DBAL type:, (*4)

<?php

use Doctrineum\Integer\IntegerEnumType;

IntegerEnumType::registerSelf();

When using Symfony with Doctrine you can do the same as above by configuration:, (*5)

# app/config/config.yml

# Doctrine Configuration
doctrine:
    dbal:
        # ...
        mapping_types:
            integer_enum: integer_enum
        types:
            integer_enum: Doctrineum\Integer\IntegerEnumType

The Versions

18/07 2018
19/02 2017

3.0.x-dev

3.0.9999999.9999999-dev

Enumeration type for Doctrine - integers only

  Sources   Download

MIT

The Requires

 

The Development Requires

19/02 2017
19/02 2017
04/08 2015

2.0.x-dev

2.0.9999999.9999999-dev

Enumeration type for Doctrine - integers only

  Sources   Download

MIT

The Requires

 

The Development Requires

04/08 2015

2.3.0

2.3.0.0

Enumeration type for Doctrine - integers only

  Sources   Download

MIT

The Requires

 

The Development Requires

03/08 2015

2.2.0

2.2.0.0

Enumeration type for Doctrine - integers only

  Sources   Download

MIT

The Requires

 

The Development Requires

21/07 2015

2.1.2

2.1.2.0

Enumeration type for Doctrine - integers only

  Sources   Download

MIT

The Requires

 

The Development Requires