Documentation

YamlDriver extends YamlDriver
in package

Wrapper class for Doctrine YAML Driver

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Thomas Däppen thomas.daeppen@comvation.com

version
4.0.0
subpackage

core_model

Table of Contents

Constants

ENUM_CLASS_PREFIX  = '\Cx\Core\Model\Data\Enum\\'

Properties

$enumClasses  : array<string|int, mixed>

Methods

getElement()  : mixed
{@inheritdoc}
loadMetadataForClass()  : mixed
{@inheritdoc}
registerKnownEnumTypes()  : mixed
Registers all known ENUM types to Doctrine If this method is called before $cx->getDb() has been called you must specify $connection
reverseLookupEnumType()  : string
Resolves a database field type to the correct (internal) ENUM type This is used to make schema-tool:update work as expected
createCustomEnumTypeClass()  : mixed
Creates a new class for a custom ENUM type
getEnumClassName()  : string
Returns the custom ENUM type class name
getEnumClassNamespace()  : string
Returns the custom ENUM type namespace
getEnumFileName()  : string
Returns the custom ENUM file name
getEnumTypeName()  : string
Returns the custom ENUM type name (Doctrine type name)
getInfoFromFileName()  : array<string|int, mixed>
Returns an array with component, entity and field name
handleCustomEnumTypeClass()  : mixed
handleCustomEnumTypeClasses()  : string
Makes ENUM types work in doctrine
registerCustomEnumType()  : mixed
Registers a custom ENUM type for Doctrine

Constants

ENUM_CLASS_PREFIX

public string ENUM_CLASS_PREFIX = '\Cx\Core\Model\Data\Enum\\'

Class namespace prefix for custom ENUM type classes

Properties

$enumClasses

protected static array<string|int, mixed> $enumClasses = array()

List of registered custom ENUM type classes

Methods

getElement()

{@inheritdoc}

public getElement(mixed $className[, mixed $raw = false ]) : mixed
Parameters
$className : mixed
$raw : mixed = false

loadMetadataForClass()

{@inheritdoc}

public loadMetadataForClass(mixed $className, ClassMetadata $metadata) : mixed
Parameters
$className : mixed
$metadata : ClassMetadata

registerKnownEnumTypes()

Registers all known ENUM types to Doctrine If this method is called before $cx->getDb() has been called you must specify $connection

public static registerKnownEnumTypes([Connection $connection = null ]) : mixed
Parameters
$connection : Connection = null

(optional) Doctrine connection

reverseLookupEnumType()

Resolves a database field type to the correct (internal) ENUM type This is used to make schema-tool:update work as expected

public static reverseLookupEnumType(mixed $tableName, mixed $columnName, mixed $type) : string
Parameters
$tableName : mixed

string Name of the table

$columnName : mixed

string Name of the database column

$type : mixed
Return values
string

Updated database field type

createCustomEnumTypeClass()

Creates a new class for a custom ENUM type

protected createCustomEnumTypeClass(string $componentName, string $entityName, string $fieldName, array<string|int, mixed> $values) : mixed
Parameters
$componentName : string

Name of the component

$entityName : string

Name of the entity

$fieldName : string

Name of the field

$values : array<string|int, mixed>

Valid values for the ENUM

getEnumClassName()

Returns the custom ENUM type class name

protected static getEnumClassName(string $componentName, string $entityName, string $fieldName) : string
Parameters
$componentName : string

The component name

$entityName : string

The entity name

$fieldName : string

The field name

Return values
string

The custom ENUM type class name

getEnumClassNamespace()

Returns the custom ENUM type namespace

protected static getEnumClassNamespace(string $componentName, string $entityName) : string
Parameters
$componentName : string

The component name

$entityName : string

The entity name

Return values
string

The custom ENUM type classe's namespace

getEnumFileName()

Returns the custom ENUM file name

protected static getEnumFileName(string $componentName, string $entityName, string $fieldName) : string
Parameters
$componentName : string

The component name

$entityName : string

The entity name

$fieldName : string

The field name

Return values
string

The custom ENUM file name

getEnumTypeName()

Returns the custom ENUM type name (Doctrine type name)

protected static getEnumTypeName(string $componentName, string $entityName, string $fieldName) : string
Parameters
$componentName : string

The component name

$entityName : string

The entity name

$fieldName : string

The field name

Return values
string

The custom ENUM type name

getInfoFromFileName()

Returns an array with component, entity and field name

protected static getInfoFromFileName(string $filename) : array<string|int, mixed>
Parameters
$filename : string

Filename to analyze

Return values
array<string|int, mixed>

Info array or empty array if filename is not of an ENUM type

handleCustomEnumTypeClass()

protected handleCustomEnumTypeClass(mixed $componentName, mixed $entityName, mixed $fieldName, mixed &$fieldMapping) : mixed
Parameters
$componentName : mixed
$entityName : mixed
$fieldName : mixed
$fieldMapping : mixed

handleCustomEnumTypeClasses()

Makes ENUM types work in doctrine

protected handleCustomEnumTypeClasses(string $className, string $result) : string

Turns the following YAML mapping: Cx\Type\Component\Model\Entity\Example: type: entity fields: example: type: enum values: ['foo', 'bar'] Into: Cx\Type\Component\Model\Entity\Example: type: entity fields: example: type: enum_component_example_example

Additionally it creates a custom class for this ENUM in core/Model/Data/Enum/ and maps the type to the class.

See also: Customizing in lib/doctrine/Doctrine/ORM/Mapping/Driver/YamlDriver.php

Parameters
$className : string

Class name to get metadata for

$result : string

Result of the YAML parsing so far

Return values
string

Parsed YAML

registerCustomEnumType()

Registers a custom ENUM type for Doctrine

protected static registerCustomEnumType(string $customTypeName, string $customClassName[, mixed $connection = null ]) : mixed
Parameters
$customTypeName : string

Doctrine name for the type

$customClassName : string

Custom ENUM type class name

$connection : mixed = null

        
On this page

Search results