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

DDC-557: Custom Mapping Types docs code example is incomplete #5064

Closed
doctrinebot opened this issue Apr 29, 2010 · 2 comments
Closed

DDC-557: Custom Mapping Types docs code example is incomplete #5064

doctrinebot opened this issue Apr 29, 2010 · 2 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user mjh_ca:

\Doctrine\DBAL\Types\Type defines an abstract method getName() however the code example at http://www.doctrine-project.org/documentation/manual/2_0/en/basic-mapping#custom-mapping-types does not include a getName() function:

Fatal error: Class My\Doctrine\DBAL\Types\MyType contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Doctrine\DBAL\Types\Type::getName) in /www/app/lib/My/Doctrine/DBAL/Types/MyType.php

Suggest amending example to:

<?php

namespace My\Project\Types;

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;

/****
 * My custom datatype.
 */
class MyType extends Type
{
    const MYTYPE = 'mytype'; // modify to match your type name

    public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
    {
        // return the SQL used to create your column type. To create a portable column type, use the $platform.
    }

    public function convertToPHPValue($value, AbstractPlatform $platform)
    {
        // This is executed when the value is read from the database. Make your conversions here, optionally using the $platform.
    }

    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        // This is executed when the value is written to the database. Make your conversions here, optionally using the $platform.
    }

    public function getName()
    {
        return self::MYTYPE; // modify to match your constant name
    }
}
@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants