forked from Snck3rs/contao-leaflet-maps
Avoid array index warning
This commit is contained in:
@@ -18,6 +18,8 @@ use Netzmacht\LeafletPHP\Assets;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
use function array_pad;
|
||||
|
||||
/**
|
||||
* Class RegisterLibrariesPass.
|
||||
*
|
||||
@@ -43,12 +45,12 @@ class RegisterLibrariesPass implements CompilerPassInterface
|
||||
|
||||
foreach ($libraries as $name => $assets) {
|
||||
if (!empty($assets['css'])) {
|
||||
list ($source, $type) = (array) $assets['css'];
|
||||
[$source, $type] = array_pad((array) $assets['css'], 2, null);
|
||||
$definition->addMethodCall('registerStylesheet', [$name, $source, $type ?: Assets::TYPE_FILE]);
|
||||
}
|
||||
|
||||
if (!empty($assets['javascript'])) {
|
||||
list ($source, $type) = (array) $assets['javascript'];
|
||||
[$source, $type] = array_pad((array) $assets['javascript'], 2, null);
|
||||
$definition->addMethodCall('registerJavascript', [$name, $source, $type ?: Assets::TYPE_FILE]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class DataController
|
||||
$filter = null;
|
||||
}
|
||||
|
||||
list($data, $error) = $this->loadData($mapProvider, $input['type'], $input['id'], $filter);
|
||||
[$data, $error] = $this->loadData($mapProvider, $input['type'], $input['id'], $filter);
|
||||
$this->encodeData($input['format'], $data);
|
||||
} catch (\Exception $e) {
|
||||
if ($this->debugMode) {
|
||||
|
||||
@@ -178,8 +178,8 @@ final class GeoJsonListener
|
||||
private function parseModelValue(Model $model, &$property)
|
||||
{
|
||||
if (is_array($property)) {
|
||||
list($property, $type) = $property;
|
||||
$value = $model->$property;
|
||||
[$property, $type] = $property;
|
||||
$value = $model->$property;
|
||||
|
||||
switch ($type) {
|
||||
case 'array':
|
||||
|
||||
@@ -143,12 +143,12 @@ class LoadAssetsListener
|
||||
$assets = $this->libraries[$library];
|
||||
|
||||
if (!empty($assets['css'])) {
|
||||
list ($source, $type) = (array) $assets['css'];
|
||||
[$source, $type] = array_pad((array) $assets['css'], 2, null);
|
||||
$this->assets->addStylesheet($source, $type ?: Assets::TYPE_FILE);
|
||||
}
|
||||
|
||||
if (!empty($assets['javascript'])) {
|
||||
list ($source, $type) = (array) $assets['javascript'];
|
||||
[$source, $type] = array_pad((array) $assets['javascript'], 2, null);
|
||||
$this->assets->addJavascript($source, $type ?: Assets::TYPE_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ final class RegisterLibrariesListener
|
||||
{
|
||||
foreach ($this->libraries as $name => $assets) {
|
||||
if (!empty($assets['css'])) {
|
||||
list ($source, $type) = (array) $assets['css'];
|
||||
[$source, $type] = array_pad((array) $assets['css'], 2, null);
|
||||
$this->leaflet->registerStylesheet($name, $source, $type ?: Assets::TYPE_FILE);
|
||||
}
|
||||
if (!empty($assets['javascript'])) {
|
||||
list ($source, $type) = (array) $assets['javascript'];
|
||||
[$source, $type] = array_pad((array) $assets['javascript'], 2, null);
|
||||
$this->leaflet->registerJavascript($name, $source, $type ?: Assets::TYPE_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user