mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
allow users to override template factory options and styles
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
return array(
|
||||
'default' => 'template',
|
||||
|
||||
'root_script' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@0.4.0/dist/flasher.min.js',
|
||||
'root_script' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@0.5.0/dist/flasher.min.js',
|
||||
|
||||
'template_factory' => array(
|
||||
'default' => 'tailwindcss',
|
||||
|
||||
@@ -106,13 +106,13 @@ class Laravel implements ServiceProviderInterface
|
||||
$templates = $app['flasher.config']->get('template_factory.templates', array());
|
||||
foreach ($templates as $template => $factory) {
|
||||
if (isset($factory['scripts'])) {
|
||||
$resourceManager->addScripts('template_' . $template, $factory['scripts']);
|
||||
$resourceManager->addScripts('template.' . $template, $factory['scripts']);
|
||||
}
|
||||
if (isset($factory['styles'])) {
|
||||
$resourceManager->addStyles('template_' . $template, $factory['styles']);
|
||||
$resourceManager->addStyles('template.' . $template, $factory['styles']);
|
||||
}
|
||||
if (isset($factory['options'])) {
|
||||
$resourceManager->addOptions('template_' . $template, $factory['options']);
|
||||
$resourceManager->addOptions('template.' . $template, $factory['options']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ final class ResourceManager implements ResourceManagerInterface
|
||||
|
||||
$envelope->withStamp(new TemplateStamp($compiled));
|
||||
|
||||
return 'template_' . $view;
|
||||
return 'template.' . $view;
|
||||
}
|
||||
|
||||
private function getTemplateAdapter($handler)
|
||||
|
||||
@@ -29,7 +29,7 @@ final class Configuration implements ConfigurationInterface
|
||||
->defaultValue('template')
|
||||
->end()
|
||||
->scalarNode('root_script')
|
||||
->defaultValue('https://cdn.jsdelivr.net/npm/@flasher/flasher@0.4.0/dist/flasher.min.js')
|
||||
->defaultValue('https://cdn.jsdelivr.net/npm/@flasher/flasher@0.5.0/dist/flasher.min.js')
|
||||
->end()
|
||||
->arrayNode('root_scripts')
|
||||
->prototype('scalar')->end()
|
||||
|
||||
@@ -47,13 +47,13 @@ final class FlasherExtension extends Extension
|
||||
$responseManager = $container->getDefinition('flasher.resource_manager');
|
||||
foreach ($config['template_factory']['templates'] as $template => $factory) {
|
||||
if (isset($factory['scripts'])) {
|
||||
$responseManager->addMethodCall('addScripts', array('template_' . $template, $factory['scripts']));
|
||||
$responseManager->addMethodCall('addScripts', array('template.' . $template, $factory['scripts']));
|
||||
}
|
||||
if (isset($factory['styles'])) {
|
||||
$responseManager->addMethodCall('addStyles', array('template_' . $template, $factory['styles']));
|
||||
$responseManager->addMethodCall('addStyles', array('template.' . $template, $factory['styles']));
|
||||
}
|
||||
if (isset($factory['options'])) {
|
||||
$responseManager->addMethodCall('addOptions', array('template_' . $template, $factory['options']));
|
||||
$responseManager->addMethodCall('addOptions', array('template.' . $template, $factory['options']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class ConfigurationTest extends TestCase
|
||||
|
||||
$expected = array(
|
||||
'default' => 'template',
|
||||
'root_script' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@0.4.0/dist/flasher.min.js',
|
||||
'root_script' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@0.5.0/dist/flasher.min.js',
|
||||
'root_scripts' => array(),
|
||||
'template_factory' => array(
|
||||
'default' => 'tailwindcss',
|
||||
|
||||
Reference in New Issue
Block a user