Quantcast
Viewing all articles
Browse latest Browse all 11

Par : YoGis

To Jeppe,
I would like to add support for geometry_columns. I added the following in my bundle :

use Doctrine\DBAL\Types\Type;
class geolocHelloBundle extends Bundle
{
public function boot()
{ Type::addType(‘geometry’, ‘geoloc\HelloBundle\ORM\GeometryType’);
$em = $this->container->get(‘doctrine.orm.default_entity_manager’);
$conn = $em->getConnection();
$conn->getDatabasePlatform()->registerDoctrineTypeMapping(‘geometry’, ‘geometry’);
}
}

and the following GeometryType.php

namespace Doctrine\DBAL\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
class Geometry extends Type
{
const geometry = 'geometry';
public function getName()
{
return self::geometry;
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return $platform->getDoctrineTypeMapping('geometry');
}
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return ($value === null) ? null : base64_encode($value);
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return ($value === null) ? null : base64_decode($value);
}
}

But when I try to read db schema :

php app/console doctrine:mapping:convert yml ./src/geoloc/HelloBundle/Resources/config/doctrine/metadata/orm --from-database --force --verbose
[ErrorException]
Notice: Use of undefined constant ‘Geometry’ - assumed '‘Geometry’' in /var/www/Symfony/src/geoloc/HelloBundle/geolocHelloBundle.php line 23

Can You be more precise on how to enable geometry (postgres) type support ?


Viewing all articles
Browse latest Browse all 11

Trending Articles