Symfony2 / Doctrine2-spaces: Contains Class Not Defined

I am using https://github.com/djlambert/doctrine2-spatial and I have an error while trying to query using the "contains" function

first, if I put this:

dql:
    numeric_functions:
       Contains:     CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Contains

in orm as in doc ( https://github.com/djlambert/doctrine2-spatial/blob/master/INSTALL.md ), I have this error:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "dql" under "doctrine.orm"

but if I put it under doctrine.orm.entity_managers.default, there is no error, but I still have an error when starting the request, here is my code:

$sql = 'SELECT DemoTadBundle:DeliveryZone dz WHERE Contains(dz.area, :point)'; //dz.area is of type polygon
$converter = new SpatialConverter();
$q = $this->_em->createQuery($sql)->setParameter('point', $converter->convertToDatabaseValue($address->getPoint())); //$address->getPoint returns an CrEOF\Spatial\PHP\Types\Geometry\Point object
return $q->getOneOrNullResult();

and here is the error:

[Semantical Error] line 0, col 41 near 'Contains(dz.area,': Error: Class 'Contains' is not defined.

can someone help me solve this problem?

my symfony version 2.5

thank.

+4
source share
2 answers

, , , config.yml( )

, :)

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        types:
            geometry:   CrEOF\Spatial\DBAL\Types\GeometryType
            point:      CrEOF\Spatial\DBAL\Types\Geometry\PointType
            polygon:    CrEOF\Spatial\DBAL\Types\Geometry\PolygonType
            linestring: CrEOF\Spatial\DBAL\Types\Geometry\LineStringType
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                dql:
                    numeric_functions:
                        Contains: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\Contains
                        AsText: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\AsText
                        AsBinary: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\AsBinary
                        GeomFromText: CrEOF\Spatial\ORM\Query\AST\Functions\MySql\GeomFromText

                auto_mapping: true
                mappings:
                    gedmo_tree:
                        type:       annotation
                        prefix:     Gedmo\Tree\Entity
                        dir:        "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
                        alias:      GedmoTree # this one is optional and will default to the name set for the mapping
                        is_bundle:  false
+3

. , , dql orm, orm - dbal.

0

Source: https://habr.com/ru/post/1546329/


All Articles