Skip to content

Commit

Permalink
Merge pull request #9 from thorau/feature/fix-deprecations-of-event-d…
Browse files Browse the repository at this point in the history
…ispatching

fixed deprecations of event dispatching
  • Loading branch information
bresam authored May 3, 2021
2 parents 34139b5 + fe8e9ee commit 0bf0a9f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/Helper/AbstractHelper.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Ivory\GoogleMap\Helper;

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;

/**
* @author GeLo <[email protected]>
Expand Down Expand Up @@ -41,6 +42,6 @@ public function getEventDispatcher()
*/
public function setEventDispatcher($eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
}
}
2 changes: 1 addition & 1 deletion src/Helper/ApiHelper.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ApiHelper extends AbstractHelper
*/
public function render(array $objects)
{
$this->getEventDispatcher()->dispatch(ApiEvents::JAVASCRIPT, $event = new ApiEvent($objects));
$this->getEventDispatcher()->dispatch($event = new ApiEvent($objects), ApiEvents::JAVASCRIPT);

return $event->getCode();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/PlaceAutocompleteHelper.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function renderJavascript(Autocomplete $autocomplete)
*/
private function doRender(Autocomplete $autocomplete, $eventName)
{
$this->getEventDispatcher()->dispatch($eventName, $event = new PlaceAutocompleteEvent($autocomplete));
$this->getEventDispatcher()->dispatch($event = new PlaceAutocompleteEvent($autocomplete), $eventName);

return $event->getCode();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/StaticMapHelper.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function setChannel($channel)
*/
public function render(Map $map)
{
$this->getEventDispatcher()->dispatch(StaticMapEvents::HTML, $event = new StaticMapEvent($map));
$this->getEventDispatcher()->dispatch($event = new StaticMapEvent($map), StaticMapEvents::HTML);

$query = preg_replace('/(%5B[0-9]+%5D)+=/', '=', http_build_query($event->getParameters(), '', '&'));
$url = 'https://maps.googleapis.com/maps/api/staticmap?'.$query;
Expand Down
7 changes: 5 additions & 2 deletions src/Helper/Subscriber/Image/StaticSubscriber.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Ivory\GoogleMap\Helper\Subscriber\DelegateSubscriberInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;

/**
* @author GeLo <[email protected]>
Expand All @@ -26,11 +27,13 @@ class StaticSubscriber implements DelegateSubscriberInterface
*/
public function handle(Event $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$dispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);

$delegates = static::getDelegatedSubscribedEvents();

if (isset($delegates[$eventName])) {
if (isset($delegates[$eventName]) && $dispatcher !== null) {
foreach ($delegates[$eventName] as $delegate) {
$eventDispatcher->dispatch($delegate, $event);
$dispatcher->dispatch($event, $delegate);
}
}
}
Expand Down

0 comments on commit 0bf0a9f

Please sign in to comment.