Skip to content

Commit

Permalink
Correction dans la détection du service de template.
Browse files Browse the repository at this point in the history
  • Loading branch information
noelma committed Oct 24, 2020
1 parent c33182b commit 545fcfe
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 32 deletions.
18 changes: 10 additions & 8 deletions core/modules/FileManager/Services/HookApp.php
Expand Up @@ -16,15 +16,17 @@ public function __construct($core)

public function hookResponseAfter($request, &$response)
{
if ($response instanceof \SoosyzeCore\Template\Services\Templating) {
$vendor = $this->core->getPath('modules', 'modules/core', false);
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script src="' . $vendor . '/FileManager/Assets/script.js"></script>';
if (!($response instanceof \SoosyzeCore\Template\Services\Templating)) {
return;
}

$styles = $response->getBlock('this')->getVar('styles');
$styles .= '<link rel="stylesheet" href="' . $vendor . '/FileManager/Assets/style.css">' . PHP_EOL;
$vendor = $this->core->getPath('modules', 'modules/core', false);
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script src="' . $vendor . '/FileManager/Assets/script.js"></script>';

$response->view('this', [ 'scripts' => $script, 'styles' => $styles ]);
}
$styles = $response->getBlock('this')->getVar('styles');
$styles .= '<link rel="stylesheet" href="' . $vendor . '/FileManager/Assets/style.css">' . PHP_EOL;

$response->view('this', [ 'scripts' => $script, 'styles' => $styles ]);
}
}
15 changes: 8 additions & 7 deletions core/modules/Menu/Services/HookApp.php
Expand Up @@ -26,9 +26,11 @@ public function hookResponseAfter($request, &$response)

public function hookMenuShowResponseAfter($request, &$response)
{
if ($response instanceof \SoosyzeCore\Template\Services\Templating) {
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script>
if (!($response instanceof \SoosyzeCore\Template\Services\Templating)) {
return;
}
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script>
$().ready(function () {
var nestedSortables = [].slice.call($(\'.nested-sortable\'));
Expand Down Expand Up @@ -62,9 +64,8 @@ function render(idMenu) {
});
</script>';

$response->view('this', [
'scripts' => $script
]);
}
$response->view('this', [
'scripts' => $script
]);
}
}
28 changes: 16 additions & 12 deletions core/modules/Node/Services/HookApp.php
Expand Up @@ -16,12 +16,14 @@ public function __construct($core)

public function hookResponseAfter($request, &$response)
{
if ($response instanceof \SoosyzeCore\Template\Services\Templating) {
$vendor = $this->core->getPath('modules', 'modules/core', false) . '/Node/Assets/script.js';
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script src="' . $vendor . '"></script>';
$response->view('this', [ 'scripts' => $script ]);
if (!($response instanceof \SoosyzeCore\Template\Services\Templating)) {
return;
}

$vendor = $this->core->getPath('modules', 'modules/core', false) . '/Node/Assets/script.js';
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script src="' . $vendor . '"></script>';
$response->view('this', [ 'scripts' => $script ]);
}

public function hookNodeShowResponseAfter($response, $node)
Expand Down Expand Up @@ -50,9 +52,12 @@ public function hookNodeShowResponseAfter($response, $node)

public function hookNodeEditResponseAfter($request, &$response)
{
if ($response instanceof \SoosyzeCore\Template\Services\Templating) {
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script>
if (!($response instanceof \SoosyzeCore\Template\Services\Templating)) {
return;
}

$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script>
$().ready(function () {
var nestedSortables = [].slice.call($(\'.nested-sortable\'));
Expand Down Expand Up @@ -85,9 +90,8 @@ function render(idMenu) {
});
</script>';

$response->view('this', [
'scripts' => $script
]);
}
$response->view('this', [
'scripts' => $script
]);
}
}
4 changes: 4 additions & 0 deletions core/modules/Node/Services/HookMenu.php
Expand Up @@ -195,6 +195,10 @@ public function hookUpdateValid($validator, $id)

public function getForm($request, &$response)
{
if (!($response instanceof \SoosyzeCore\Template\Services\Templating)) {
return;
}

$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script>
function toggle (id) {
Expand Down
4 changes: 4 additions & 0 deletions core/modules/Trumbowyg/Services/Trumbowyg.php
Expand Up @@ -17,6 +17,10 @@ public function __construct($core, $router)

public function getEditor($request, &$response)
{
if (!($response instanceof \SoosyzeCore\Template\Services\Templating)) {
return;
}

$vendor = $this->core->getPath('modules', 'core/modules', false) . '/Trumbowyg/vendor/';
$script = $response->getBlock('this')->getVar('scripts');
$style = $response->getBlock('this')->getVar('styles');
Expand Down
12 changes: 7 additions & 5 deletions core/modules/User/Services/User.php
Expand Up @@ -407,11 +407,13 @@ public function hookResponseBefore(&$request, &$response)

public function hookResponseAfter($request, &$response)
{
if ($response instanceof \SoosyzeCore\Template\Services\Templating) {
$vendor = $this->core->getPath('modules', 'modules/core', false) . '/User/Assets/js/script.js';
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script src="' . $vendor . '"></script>';
$response->view('this', [ 'scripts' => $script ]);
if (!($response instanceof \SoosyzeCore\Template\Services\Templating)) {
return;
}

$vendor = $this->core->getPath('modules', 'modules/core', false) . '/User/Assets/js/script.js';
$script = $response->getBlock('this')->getVar('scripts');
$script .= '<script src="' . $vendor . '"></script>';
$response->view('this', [ 'scripts' => $script ]);
}
}

0 comments on commit 545fcfe

Please sign in to comment.