Skip to content

Commit 70f0f0e

Browse files
authored
Merge pull request #24 from Extendas/version-update
Version update
2 parents 485ef5a + c2855e1 commit 70f0f0e

7 files changed

Lines changed: 173 additions & 187 deletions

File tree

DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
1717
*/
1818
public function getConfigTreeBuilder()
1919
{
20-
$treeBuilder = new TreeBuilder();
21-
$rootNode = $treeBuilder->root('ali_datatable');
20+
$treeBuilder = new TreeBuilder('ali_datatable');
21+
$rootNode = $treeBuilder->getRootNode();
2222

2323
$rootNode
2424
->children()

EventListener/DatatableListener.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\HttpFoundation\Request;
1515
use Symfony\Component\HttpFoundation\Response;
1616
use Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag;
17-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
17+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1818
use Symfony\Component\HttpKernel\KernelEvents;
1919
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
2020
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -32,10 +32,10 @@ class DatatableListener implements EventSubscriberInterface
3232
/**
3333
* On kernel response event
3434
*
35-
* @param FilterResponseEvent $event
35+
* @param ResponseEvent $event
3636
* @return void|null
3737
*/
38-
public function onKernelResponse(FilterResponseEvent $event)
38+
public function onKernelResponse(ResponseEvent $event)
3939
{
4040
$response = $event->getResponse();
4141
$request = $event->getRequest();
@@ -58,32 +58,39 @@ public function onKernelResponse(FilterResponseEvent $event)
5858
protected function _injectDatatableScript(Response $response, Request $request)
5959
{
6060
$content = $response->getContent();
61+
if (!is_string($content))
62+
{
63+
return;
64+
}
6165
$pos_body = strripos($content, '</body>');
6266
if (!$pos_body)
6367
{
6468
return;
6569
}
6670
$session = $request->getSession();
67-
$dom = '<script id="alidatatable-scripts" type="text/javascript">';
71+
$dom = '<script id="alidatatable-scripts" type="text/javascript" nonce="CQp8HV9whIqW2xhqCXCJNWj0K1DvzmFC">';
6872
$pos_container = strripos($content, 'alidatatable-scripts');
69-
$sess_dta = $session->get('datatable',array());
73+
$sess_dta = $session->get('datatable', []);
7074
$dta_script = null;
7175
if ($sess_dta)
7276
{
73-
array_walk($sess_dta, function(&$part, &$key) {
74-
$part = trim(preg_replace('/\s\s+/', ' ', $part));
77+
array_walk($sess_dta, function($part, $key) use (&$sess_dta) {
78+
$sess_dta[$key] = trim(preg_replace('/\s\s+/', ' ', $part));
7579
});
7680
$dta_script = implode("\n", $sess_dta);
7781
}
78-
$session->set('datatable', array());
82+
$session->set('datatable', []);
7983
if (!$pos_container)
8084
{
8185
$dta_container = $dom;
8286
$content = substr_replace($content, $dta_container . '</script>', $pos_body, 0);
8387
$response->setContent($content);
8488
}
8589
$pos_dta = strripos($content, $dom);
86-
$content = substr_replace($content, $dta_script, $pos_dta + strlen($dom), 0);
90+
if ($dta_script)
91+
{
92+
$content = substr_replace($content, $dta_script, $pos_dta + strlen($dom), 0);
93+
}
8794
$response->setContent($content);
8895
}
8996

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{% spaceless %}
1+
{% apply spaceless %}
22
{% if single_entity is defined and single_entity is not null and path_name is not defined %}
33
{{ single_entity }}
44
{% elseif single_entity is defined and single_entity is not null %}
55
<a data-id="{{ single_entity.id }}" data-title="{{ single_entity }}" data-url="{{ path(path_name, {'id': single_entity.id}) }}" href="{{ path(path_name, {'id': single_entity.id}) }}">{{ single_entity }}</a>
66
{% endif %}
7-
{% endspaceless %}
7+
{% endapply %}

Resources/views/Renderers/_entity.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% spaceless %}
1+
{% apply spaceless %}
22
{% if entity is not defined %}
33
missing parameters for rendering entity ({% if entity is not defined %}entity{% endif %})
44
{% else %}
@@ -17,4 +17,4 @@
1717
{% endembed %}
1818
{% endif %}
1919
{% endif %}
20-
{% endspaceless %}
20+
{% endapply %}

Util/Exceptions/UnableToUseCustomJoinAsObjectFieldException.php renamed to Util/Exceptions/CustomJoinFieldException.php

File renamed without changes.

0 commit comments

Comments
 (0)