mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-02 04:53:56 +01:00
Rework libraries handling so that libraries don't have to be ported to contao 4.4 only yet.
This commit is contained in:
95
src/Frontend/Assets/LibrariesConfiguration.php
Normal file
95
src/Frontend/Assets/LibrariesConfiguration.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Leaflet maps for Contao CMS.
|
||||
*
|
||||
* @package contao-leaflet-maps
|
||||
* @author David Molineus <david.molineus@netzmacht.de>
|
||||
* @copyright 2016-2017 netzmacht David Molineus. All rights reserved.
|
||||
* @license LGPL-3.0 https://github.com/netzmacht/contao-leaflet-maps/blob/master/LICENSE
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Netzmacht\Contao\Leaflet\Frontend\Assets;
|
||||
|
||||
use Contao\CoreBundle\Framework\ContaoFrameworkInterface as ContaoFramework;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Class LibrariesConfiguration
|
||||
*
|
||||
* @package Netzmacht\Contao\Leaflet\Frontend\Assets
|
||||
*/
|
||||
class LibrariesConfiguration implements \IteratorAggregate, \ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @var ContaoFramework
|
||||
*/
|
||||
private $framework;
|
||||
|
||||
/**
|
||||
* LibrariesConfiguration constructor.
|
||||
*
|
||||
* @param ContaoFramework $framework
|
||||
*/
|
||||
public function __construct(ContaoFramework $framework)
|
||||
{
|
||||
$this->framework = $framework;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
public function getIterator()
|
||||
{
|
||||
$this->framework->initialize();
|
||||
|
||||
return new \ArrayIterator($GLOBALS['LEAFLET_LIBRARIES']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
$this->framework->initialize();
|
||||
|
||||
return isset($GLOBALS['LEAFLET_LIBRARIES'][$offset]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $GLOBALS['LEAFLET_LIBRARIES'][$offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
$GLOBALS['LEAFLET_LIBRARIES'][$offset] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
unset($GLOBALS['LEAFLET_LIBRARIES'][$offset]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user