Implement caching for feature collections (#30) and maps (#4).

This commit is contained in:
David Molineus
2016-10-06 15:47:33 +02:00
parent 2e5139a756
commit 8c24f5e735
16 changed files with 398 additions and 75 deletions

View File

@@ -11,10 +11,8 @@
namespace Netzmacht\Contao\Leaflet\Dca;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Mapper\MapMapper;
use Netzmacht\Contao\Leaflet\Model\LayerModel;
use Netzmacht\Contao\Leaflet\Model\MapModel;
use Netzmacht\Contao\Toolkit\Dca\Callback\CallbackFactory;
use Netzmacht\LeafletPHP\Value\LatLng;
/**
@@ -24,6 +22,35 @@ use Netzmacht\LeafletPHP\Value\LatLng;
*/
class LeafletCallbacks
{
/**
* File system.
*
* @var \Files
*/
private $fileSystem;
/**
* LeafletCallbacks constructor.
*
* @param \Files $fileSystem File system.
*/
public function __construct(\Files $fileSystem)
{
$this->fileSystem = $fileSystem;
}
/**
* Generate the callback definition.
*
* @param string $methodName Callback method name.
*
* @return callable
*/
public static function callback($methodName)
{
return CallbackFactory::service('leaflet.dca.common', $methodName);
}
/**
* Create the zoom range.
*
@@ -75,4 +102,18 @@ class LeafletCallbacks
return $options;
}
/**
* Clear the leaflet cache.
*
* @param mixed $value Value when used as save_callback.
*
* @return mixed
*/
public function clearCache($value = null)
{
$this->fileSystem->rrdir('system/cache/leaflet', true);
return $value;
}
}