Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monnaies-locales
kohinos
Commits
4fb9e8da
Commit
4fb9e8da
authored
May 20, 2019
by
Julien Jorry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix user group
parent
051e9a34
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
5 deletions
+23
-5
services.yaml
config/services.yaml
+6
-1
Usergroup.php
src/Entity/Usergroup.php
+2
-3
GeolocListener.php
src/EventListener/GeolocListener.php
+15
-1
No files found.
config/services.yaml
View file @
4fb9e8da
...
@@ -122,9 +122,14 @@ services:
...
@@ -122,9 +122,14 @@ services:
tags
:
tags
:
-
{
name
:
form.type_extension
,
extended_type
:
Symfony\Component\Form\Extension\Core\Type\HiddenType
}
-
{
name
:
form.type_extension
,
extended_type
:
Symfony\Component\Form\Extension\Core\Type\HiddenType
}
App\EventListener\GeolocListener
:
app.listener.geoloc.preupdate
:
class
:
App\EventListener\GeolocListener
tags
:
tags
:
-
{
name
:
doctrine.event_listener
,
event
:
preUpdate
}
-
{
name
:
doctrine.event_listener
,
event
:
preUpdate
}
app.listener.geoloc.postPersist
:
class
:
App\EventListener\GeolocListener
tags
:
-
{
name
:
doctrine.event_listener
,
event
:
postPersist
}
mlc.user.listener
:
mlc.user.listener
:
class
:
App\EventListener\UserListener
class
:
App\EventListener\UserListener
...
...
src/Entity/Usergroup.php
View file @
4fb9e8da
<?php
<?php
namespace
App\Entity
;
namespace
App\Entity
;
use
FOS\UserBundle\Model\
Group
as
BaseGroup
;
use
Sonata\UserBundle\Entity\Base
Group
as
BaseGroup
;
use
Doctrine\ORM\Mapping
as
ORM
;
use
Doctrine\ORM\Mapping
as
ORM
;
/**
/**
* @ORM\Entity
* @ORM\Entity
()
* @ORM\Table(name="usergroup")
* @ORM\Table(name="usergroup")
*/
*/
class
Usergroup
extends
BaseGroup
class
Usergroup
extends
BaseGroup
...
...
src/EventListener/GeolocListener.php
View file @
4fb9e8da
...
@@ -6,19 +6,33 @@ use App\Entity\EntityTrait\GeolocEntityTrait;
...
@@ -6,19 +6,33 @@ use App\Entity\EntityTrait\GeolocEntityTrait;
use
App\Entity\Geoloc
;
use
App\Entity\Geoloc
;
use
App\Entity\Prestataire
;
use
App\Entity\Prestataire
;
use
App\Entity\User
;
use
App\Entity\User
;
use
Doctrine\Common\Persistence\Event\LifecycleEventArgs
;
use
Doctrine\ORM\Event\PreUpdateEventArgs
;
use
Doctrine\ORM\Event\PreUpdateEventArgs
;
use
Geocoder\Provider\Nominatim\Nominatim
;
use
Geocoder\Provider\Nominatim\Nominatim
;
use
Geocoder\Query\GeocodeQuery
;
use
Geocoder\Query\GeocodeQuery
;
class
GeolocListener
class
GeolocListener
{
{
public
function
postPersist
(
LifecycleEventArgs
$eventArgs
)
{
$entity
=
$eventArgs
->
getObject
();
$this
->
updateGeoLoc
(
$entity
);
}
public
function
preUpdate
(
PreUpdateEventArgs
$eventArgs
)
public
function
preUpdate
(
PreUpdateEventArgs
$eventArgs
)
{
{
$entity
=
$eventArgs
->
getEntity
();
$entity
=
$eventArgs
->
getEntity
();
if
(
!
(
$entity
instanceof
Geoloc
)
||
(
$entity
instanceof
Geoloc
)
&&
!
(
$eventArgs
->
hasChangedField
(
'adresse'
)
||
$eventArgs
->
hasChangedField
(
'cpostal'
)
||
$eventArgs
->
hasChangedField
(
'ville'
)
||
$eventArgs
->
hasChangedField
(
'lat'
)
||
$eventArgs
->
hasChangedField
(
'lon'
)))
{
if
(
!
(
$entity
instanceof
Geoloc
)
||
(
$entity
instanceof
Geoloc
)
&&
!
(
$eventArgs
->
hasChangedField
(
'adresse'
)
||
$eventArgs
->
hasChangedField
(
'cpostal'
)
||
$eventArgs
->
hasChangedField
(
'ville'
)
||
$eventArgs
->
hasChangedField
(
'lat'
)
||
$eventArgs
->
hasChangedField
(
'lon'
)))
{
return
;
return
;
}
}
$this
->
updateGeoLoc
(
$entity
);
}
private
function
updateGeoLoc
(
$entity
)
{
if
(
!
$entity
instanceof
Geoloc
)
{
return
;
}
// GEOCODING ADDRESS :
// GEOCODING ADDRESS :
$httpClient
=
new
\Http\Adapter\Guzzle6\Client
();
$httpClient
=
new
\Http\Adapter\Guzzle6\Client
();
$provider
=
Nominatim
::
withOpenStreetMapServer
(
$httpClient
,
'Mozilla/5.0'
);
$provider
=
Nominatim
::
withOpenStreetMapServer
(
$httpClient
,
'Mozilla/5.0'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment