Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation with info about custom types #5

Closed
JanMikes opened this Issue Mar 18, 2018 · 2 comments

Comments

2 participants
@JanMikes
Copy link

JanMikes commented Mar 18, 2018

Please add example of at least one custom type registered via config.

As i found in ConnectionFactory - https://github.com/nettrine/dbal/blob/master/src/ConnectionFactory.php#L121 from code it seems that syntax is following:

types:
    myType: {class: MyTypeClass}
// same as
    myType:
        class: MyTypeClass

Is that correct?

@f3l1x f3l1x added this to the v0.2 milestone Apr 4, 2018

@f3l1x

This comment has been minimized.

Copy link
Member

f3l1x commented Apr 4, 2018

Resolved in 5c82fc6.
Related: #6


dbal:
    connection:
        types:
            uuid_binary_ordered_time:
                class: Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType
                commented: false

@f3l1x f3l1x closed this Apr 4, 2018

@f3l1x f3l1x added the enhancement label Apr 4, 2018

@JanMikes

This comment has been minimized.

Copy link
Author

JanMikes commented Dec 5, 2018

@f3l1x is there any way that we could write

types:
    MyTypeName: MyTypeClass

instead of

types:
    MyTypeName:
                class: MyTypeClass
                commented: false

I have class like this:

final class EmailAddressType extends StringType
{
	public function convertToPHPValue($value, AbstractPlatform $platform)
	{
		\assert(is_string($value));

		return EmailAddress::fromString($value);
	}


	public function convertToDatabaseValue($value, AbstractPlatform $platform)
	{
		\assert($value instanceof EmailAddress);

		return parent::convertToDatabaseValue($value->toString(), $platform);
	}


	public function requiresSQLCommentHint(AbstractPlatform $platform): bool
	{
		return true;
	}


	public function getName(): string
	{
		return EmailAddress::class;
	}
}

Does it mean that getName() and requiresSQLCommentHint() methods are unused? It seems to me that it is overhead. Just thinking if it could be improved somehow.

Anyways i was thinking if it is possible to create extension which would autoregister all custom types, do you think something like that is possible? If yes i might try that and send PR to this repo, i think it would be awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.