Commit e8645c94 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Add event to remove location if lat and lng not set

parent 77e831c2
Pipeline #9837 passed with stages
in 3 minutes and 28 seconds
<?php
namespace T3o\T3orgLayout\Event;
/*
* This file is part of a TYPO3 extension.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
class ModifyDetailViewVariablesEvent
{
public function __invoke(\DERHANSEN\SfEventMgt\Event\ModifyDetailViewVariablesEvent $event): void
{
/** @var \DERHANSEN\SfEventMgt\Domain\Model\Event $eventModel */
$eventModel = $event->getVariables()['event'];
// Remove location if one used without lat and lng configuration
if ($eventModel->getLocation() && (int)$eventModel->getLocation()->getLatitude() === 0 && (int)$eventModel->getLocation()->getLongitude() === 0) {
$eventModel->setLocation(null);
}
$event->setVariables(['event' => $eventModel]);
}
}
services:
T3o\T3orgLayout\Event\ModifyDetailViewVariablesEvent:
tags:
- name: event.listener
identifier: 'ModifyDetailViewVariablesEvent'
event: DERHANSEN\SfEventMgt\Event\ModifyDetailViewVariablesEvent
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment