mirror of
https://github.com/typemill/typemill.git
synced 2025-08-04 21:27:41 +02:00
V 2.9.0 Add event onTwigGlobalsLoaded
This commit is contained in:
@@ -57,7 +57,9 @@ class ControllerApiSystemExtensions extends Controller
|
||||
$license = new License();
|
||||
$urlinfo = $this->c->get('urlinfo');
|
||||
|
||||
if(!$license->checkIfTest($urlinfo))
|
||||
$test = $license->checkIfTest($urlinfo);
|
||||
|
||||
if($license->checkIfTest($urlinfo) !== true)
|
||||
{
|
||||
# checks if license is valid and returns scope
|
||||
$licenseScope = $license->getLicenseScope($urlinfo);
|
||||
|
14
system/typemill/Events/OnTwigGlobalsLoaded.php
Normal file
14
system/typemill/Events/OnTwigGlobalsLoaded.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Typemill\Events;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Event for breadcrumb.
|
||||
*/
|
||||
|
||||
class OnTwigGlobalsLoaded extends BaseEvent
|
||||
{
|
||||
|
||||
}
|
@@ -170,8 +170,8 @@ class License
|
||||
$thishost = parse_url($urlinfo['baseurl'], PHP_URL_HOST);
|
||||
$thishost = str_replace("www.", "", $thishost);
|
||||
$test = substr($thishost, 0, 9);
|
||||
|
||||
if($test == 'localhost' OR $test = '127.0.0.1')
|
||||
|
||||
if($test == 'localhost' OR $test == '127.0.0.1')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ bloxeditor.component('title-component', {
|
||||
methods: {
|
||||
beforeSave()
|
||||
{
|
||||
/* You can do something here before save. Check image and file component */
|
||||
this.$emit('saveBlockEvent');
|
||||
},
|
||||
updatemarkdown(content)
|
||||
|
@@ -52,7 +52,7 @@ const bloxeditor = Vue.createApp({
|
||||
},
|
||||
hideEditor()
|
||||
{
|
||||
this.showblox =false;
|
||||
this.showblox = false;
|
||||
},
|
||||
checkMove(event)
|
||||
{
|
||||
|
@@ -23,6 +23,7 @@ use Typemill\Events\OnSessionSegmentsLoaded;
|
||||
use Typemill\Events\OnRolesPermissionsLoaded;
|
||||
use Typemill\Events\OnResourcesLoaded;
|
||||
use Typemill\Events\OnCspLoaded;
|
||||
use Typemill\Events\OnTwigGlobalsLoaded;
|
||||
use Typemill\Middleware\RemoveCredentialsMiddleware;
|
||||
use Typemill\Middleware\SessionMiddleware;
|
||||
use Typemill\Middleware\OldInputMiddleware;
|
||||
@@ -54,7 +55,6 @@ ini_set('display_errors', $display_errors);
|
||||
ini_set('display_startup_errors', 0);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
|
||||
/****************************
|
||||
* LOAD SETTINGS *
|
||||
****************************/
|
||||
@@ -279,6 +279,14 @@ else
|
||||
|
||||
$timer['session segments'] = microtime(true);
|
||||
|
||||
# initialize globals
|
||||
$TwigGlobals = ['errors' => NULL, 'flash' => NULL, 'assets' => NULL];
|
||||
$TwigGlobals = $dispatcher->dispatch(new OnTwigGlobalsLoaded($TwigGlobals), 'onTwigGlobalsLoaded')->getData();
|
||||
|
||||
# echo '<pre>';
|
||||
# print_r($TwigGlobals);
|
||||
# die();
|
||||
|
||||
/****************************
|
||||
* OTHER CONTAINER ITEMS *
|
||||
****************************/
|
||||
@@ -298,7 +306,7 @@ $container->set('assets', function() use ($assets){ return $assets; });
|
||||
* TWIG TO CONTAINER *
|
||||
****************************/
|
||||
|
||||
$container->set('view', function() use ($settings, $urlinfo, $translations, $dispatcher) {
|
||||
$container->set('view', function() use ($settings, $TwigGlobals, $urlinfo, $translations, $dispatcher) {
|
||||
|
||||
$twig = Twig::create(
|
||||
[
|
||||
@@ -314,10 +322,12 @@ $container->set('view', function() use ($settings, $urlinfo, $translations, $dis
|
||||
'autoescape' => false
|
||||
]
|
||||
);
|
||||
|
||||
$twig->getEnvironment()->addGlobal('errors', NULL);
|
||||
$twig->getEnvironment()->addGlobal('flash', NULL);
|
||||
$twig->getEnvironment()->addGlobal('assets', NULL);
|
||||
|
||||
foreach($TwigGlobals as $name => $feature)
|
||||
{
|
||||
# echo $name . ';';
|
||||
$twig->getEnvironment()->addGlobal($name, $feature);
|
||||
}
|
||||
|
||||
# add extensions
|
||||
$twig->addExtension(new DebugExtension());
|
||||
|
Reference in New Issue
Block a user