J'essaye d'implémenter postgis pour Doctrine afin de pouvoir utiliser les typé géométrie de postgre dans mon projet. Du coup j'ai suivi la doc sur github : https://github.com/jsor/doctrine-postgis
90% de la doc est faites et comprise mais c'est pour la partie eventListenenr. N'ayant jamais fait ça je ne comprend pas comment ça marche, même en suivant le doc Symfony je comprend pas comment intégrer postgis.
Après, je ne sais pas si mon problème vient de là mais quand j'essaye un bin/console doctrine:schema:update --force j'ai l'erreur suivante :
SQLSTATE[42883]: Undefined function: 7 ERROR: function postgis_lib_version() does not exist
LINE 1: SELECT PostGIS_Lib_Version()
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Et j'ai cette erreur trois fois parce que j'ai trois entité qui utilise le type géométrie de postgis
Juste au cas où j'a fait un eventSuscrber :
<?php
namespace App\EventSubscriber;
use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use App\Entity\Geoptic\Cible;
use App\Entity\Geoptic\Ciblegeocodee;
use App\Entity\Geoptic\Iris;
use Doctrine\ORM\Events;
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber;
class PostGIS_Lib_VersionSubscriber implements EventSubscriber
{
public function getSubscribedEvents()
{
return [
Events::postPersist,
Events::postUpdate,
];
}
public function postUpdate(LifecycleEventArgs $args)
{
$this->index($args);
}
public function postPersist(LifecycleEventArgs $args)
{
$this->index($args);
}
public function index(LifecycleEventArgs $args)
{
$entity = $args->getObject();
// perhaps you only want to act on some "Product" entity
if ($entity instanceof Cible) {
$entityManager = $args->getObjectManager();
// ... do something with the Product
$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
}
}
}
et un EventListener :
<?php
namespace App\EventListener;
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use App\Entity\Geoptic\Cible;
use App\Entity\Geoptic\Ciblegeocodee;
use App\Entity\Geoptic\Iris;
use Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber;
class PostGIS_Lib_VersionListener
{
public function postPersist(LifecycleEventArgs $args)
{
$entity = $args->getObject();
// only act on some "Product" entity
if (!$entity instanceof Cible || !$entity instanceof Ciblegeocodee || !$entity instanceof Iris) {
return;
}
$entityManager = $args->getObjectManager();
// La doc github dit $connexion mais je ne sait pas à quoi correspond cette variable
$connection->getEventManager()->addEventSubscriber(new DBALSchemaEventSubscriber());
}
}
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.