-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Unknown database type point requested, Doctrine\DBAL\Platforms\MySQL80Platform may not support it. #2
Comments
Hi, you need to register geo doctrine types: use Doctrine\DBAL\Types\Type;
use Brick\Geo\Doctrine\Types\PointType;
Type::addType('Point', PointType::class); If you're using Symfony: doctrine:
dbal:
types:
Point: Brick\Geo\Doctrine\Types\PointType
mapping_types:
Point: Point
|
Actually I'll leave this issue open until the README is updated with this info. |
Hello. Thanks for your response.
I just figured that out now and it works.
Thanks again.
…On Fri, Mar 17, 2023, 6:41 PM Benjamin Morel ***@***.***> wrote:
Actually I'll leave this issue open until the README is updated with this
info.
—
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALLH5QTUK63YDBNBNPXR6XTW4SO43ANCNFSM6AAAAAAV6YPUDA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
if you're using Symfony, you can do something like this: <?php declare(strict_types=1);
namespace App\Geometry;
use Brick\Geo\Doctrine\Functions;
use Brick\Geo\Doctrine\Types;
use Brick\Geo\Engine;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Exception as DBALException;
use Symfony\Component\Finder\Finder;
use function Symfony\Component\String\u;
class GeometryDoctrineSetup
{
private const TYPES_PATH = '/vendor/brick/geo-doctrine/src/Types';
private const FUNCTIONS_PATH = '/vendor/brick/geo-doctrine/src/Functions';
private const TYPES_NAMESPACE = 'Brick\\Geo\\Doctrine\\Types\\';
private const FUNCTIONS_NAMESPACE = 'Brick\\Geo\\Doctrine\\Functions\\';
private Engine\GeometryEngine $engine;
public function __construct(private readonly EntityManagerInterface $em, private readonly string $projectDir)
{
}
public function initMappingTypes(): void
{
$finder = new Finder();
$finder->in($this->projectDir.self::TYPES_PATH)->files()->name('*.php');
foreach($finder as $file) {
$name = u($file->getFilenameWithoutExtension())->trimSuffix('Type')->toString();
$class = self::TYPES_NAMESPACE.$file->getFilenameWithoutExtension();
try {
Type::addType($name, $class);
} catch (DBALException $e) {
continue;
}
$this->em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping($name, $name);
}
}
public function initFunctions(): void
{
$finder = new Finder();
$finder->in($this->projectDir.self::FUNCTIONS_PATH)->files()->name('*.php')->notName('Abstract*.php');
foreach($finder as $file) {
$name = sprintf('ST_%s', u($file->getFilenameWithoutExtension())->trimSuffix('Function')->toString());
$class = self::FUNCTIONS_NAMESPACE.$file->getFilenameWithoutExtension();
$this->em->getConfiguration()->addCustomStringFunction($name, $class);
}
}
public function initEngine(): void
{
$this->engine = new Engine\PDOEngine(pdo: $this->em->getConnection()->getNativeConnection(), useProxy: true);
}
public function init(): void
{
$this->initMappingTypes();
$this->initFunctions();
$this->initEngine();
}
public function getEngine(): Engine\GeometryEngine
{
return $this->engine;
}
} and services:
App\Geometry\GeometryDoctrineSetup:
lazy: false
arguments:
$em: '@doctrine.orm.default_entity_manager'
$projectDir: '%kernel.project_dir%'
tags:
- { name: kernel.event_listener , event: kernel.request , method: init , priority: 999 }
- { name: kernel.event_listener , event: console.command , method: init , priority: 999 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please how do I resolve this Issue?
The text was updated successfully, but these errors were encountered: