2017 © Pedro PelĂĄez
 

library string

String-only enumeration type and value dependent sub-type for Doctrine

image

doctrineum/string

String-only enumeration type and value dependent sub-type for Doctrine

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

The README.md

Doctrine String enum

Build Status Test Coverage License, (*1)

About

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

Usage

<?php

use Doctrine\ORM\Mapping as ORM;
use Doctrineum\String\StringEnum;

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

    /**
     * @var StringEnum
     * @ORM\Column(type="string_enum")
     */
    private $name;

    public function __construct(StringEnum $name)
    {
        $this->name = $name;
    }

    /**
     * @return StringEnum
     */
    public function getName()
    {
        return $this->name;
    }
}

// ... entity Money using Currency
$trueHero = new Person(StringEnum::getEnum('Don Quixote de La Mancha'));

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

/** @var Currency[] $StarTracks */
$sirs = $entityManager->createQuery(
    "SELECT p FROM Person p WHERE p.name LIKE 'Don %'"
)->getResult();

var_dump($sirs[0]->getName()->getValue()); // 'Don Quixote de La Mancha';

Installation

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

composer require jaroslavtyc/doctrineum-string

Doctrine integration

Register new DBAL type:, (*4)

<?php

use Doctrineum\String\StringEnumType;

StringEnumType::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:
            string_enum: string_enum
        types:
            string_enum: Doctrineum\String\StringEnumType

The Versions

18/07 2018

dev-master

9999999-dev

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum

18/07 2018

2.1.x-dev

2.1.9999999.9999999-dev

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum

18/07 2018

2.1.0

2.1.0.0

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum

19/02 2017

2.0.x-dev

2.0.9999999.9999999-dev

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum

19/02 2017

2.0.1

2.0.1.0

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum

19/02 2017

2.0.0

2.0.0.0

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum

19/02 2017

1.0.x-dev

1.0.9999999.9999999-dev

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum

19/02 2017

1.0.0

1.0.0.0

String-only enumeration type and value dependent sub-type for Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine enum string sub-type value-dependent enum self-typed enum