Skip to content

Commit

Permalink
fix for twig 3.0 and symfony 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandOrientedTmp committed May 29, 2020
1 parent dbf0ec0 commit dba6bfd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
6 changes: 1 addition & 5 deletions src/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function index(Request $request) {
* @Route("/{name}/edit", name="effiana_config_settings_edit")
* @Route("/add", name="effiana_config_settings_add")
*/
public function edit(?string $name, Request $request)
public function edit(SettingsFlow $flow, ?string $name, Request $request)
{
$flashBag = $this->get('session')->getFlashBag();
/** @var EntityManager $em */
Expand All @@ -73,10 +73,6 @@ public function edit(?string $name, Request $request)
}

if($setting instanceof Setting) {

/** @var SettingsFlow $flow */
$flow = $this->get(SettingsFlow::class);

$flow->bind($setting);
// form of the current step
$form = $flow->createForm();
Expand Down
39 changes: 24 additions & 15 deletions src/DependencyInjection/EffianaConfigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

/**
Expand All @@ -15,23 +16,31 @@
* @copyright 2011-2019 Christian Raue
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class EffianaConfigExtension extends Extension {
class EffianaConfigExtension extends Extension implements PrependExtensionInterface
{

/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container) {
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), $configs);
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('controller.xml');
$loader->load('form.xml');
$loader->load('twig.xml');
$loader->load('util.xml');

$container->setParameter('effiana_config.db_driver.' . $config['db_driver'], true);
$container->setParameter('effiana_config.entity_name', $config['entity_name']);
}

$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('controller.xml');
$loader->load('form.xml');
$loader->load('twig.xml');
$loader->load('util.xml');
}
/**
* {@inheritDoc}
*/
public function prepend(ContainerBuilder $container)
{
$config = $this->processConfiguration(new Configuration(), $container->getExtensionConfig($this->getAlias()));

$container->setParameter('effiana_config.db_driver.' . $config['db_driver'], true);
$container->setParameter('effiana_config.entity_name', $config['entity_name']);

}
}
6 changes: 4 additions & 2 deletions src/Resources/config/controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="Effiana\ConfigBundle\Controller\SettingsController" class="Effiana\ConfigBundle\Controller\SettingsController" autowire="true" autoconfigure="true">
<argument>%effiana_config.entity_name%</argument>
<service id="Effiana\ConfigBundle\Controller\SettingsController" class="Effiana\ConfigBundle\Controller\SettingsController">
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
<tag name="controller.service_arguments"/>
</service>
</services>
Expand Down

0 comments on commit dba6bfd

Please sign in to comment.