Skip to content

Commit

Permalink
removed necessity of factory
Browse files Browse the repository at this point in the history
  • Loading branch information
othillo committed May 5, 2017
1 parent 5f00e7d commit cf375c5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 77 deletions.
6 changes: 3 additions & 3 deletions DependencyInjection/QandidateToggleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public function load(array $configs, ContainerBuilder $container)

break;
case 'symfony' === $config['persistence']:
$container->setParameter('qandidate.toggle.parameters', $config['toggles']);
$collection = 'factory';
$definition = $container->getDefinition('qandidate.toggle.collection.in_memory');
$definition->setFactory(array(
new Reference('qandidate.toggle.collection.factory.in_memory'),
'getToggles'
new Reference('qandidate.toggle.collection.serializer.in_memory'),
'deserialize'
));
$definition->addArgument($config['toggles']);

$container->setDefinition('qandidate.toggle.collection.factory', $definition);
break;
Expand Down
49 changes: 0 additions & 49 deletions Factory/InMemoryCollectionFactory.php

This file was deleted.

7 changes: 0 additions & 7 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
<parameters>
<parameter key="qandidate.toggle.manager.class">Qandidate\Toggle\ToggleManager</parameter>
<parameter key="qandidate.toggle.collection.in_memory.class">Qandidate\Toggle\ToggleCollection\InMemoryCollection</parameter>
<parameter key="qandidate.toggle.collection.factory.in_memory.class">Qandidate\Bundle\ToggleBundle\Factory\InMemoryCollectionFactory</parameter>
<parameter key="qandidate.toggle.collection.serializer.in_memory.class">Qandidate\Toggle\Serializer\InMemoryCollectionSerializer</parameter>
<parameter key="qandidate.toggle.collection.predis.class">Qandidate\Toggle\ToggleCollection\PredisCollection</parameter>
<parameter key="qandidate.toggle.user_context_factory.class">Qandidate\Bundle\ToggleBundle\Context\UserContextFactory</parameter>
<parameter key="qandidate.toggle.twig_extension.class">Qandidate\Bundle\ToggleBundle\Twig\ToggleTwigExtension</parameter>
<parameter key="qandidate.toggle.toggle.listener.class">Qandidate\Bundle\ToggleBundle\EventListener\ToggleListener</parameter>
<parameter key="qandidate.toggle.context.class">Qandidate\Toggle\Context</parameter>
<parameter key="qandidate.toggle.parameters"></parameter>
</parameters>

<services>
Expand All @@ -23,11 +21,6 @@

<service id="qandidate.toggle.collection.serializer.in_memory" class="%qandidate.toggle.collection.serializer.in_memory.class%" />

<service id="qandidate.toggle.collection.factory.in_memory" class="%qandidate.toggle.collection.factory.in_memory.class%">
<argument>%qandidate.toggle.parameters%</argument>
<argument type="service" id="qandidate.toggle.collection.serializer.in_memory" />
</service>

<service id="qandidate.toggle.manager" class="%qandidate.toggle.manager.class%">
<argument type="service" id="qandidate.toggle.collection" />
</service>
Expand Down
18 changes: 0 additions & 18 deletions Tests/DependencyInjection/QandidateToggleExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,24 +155,6 @@ public function it_aliases_the_context_factory_to_configured_service()
$this->assertContainerBuilderHasAlias('qandidate.toggle.context_factory', 'acme.yolo');
}

/**
* @test
*/
public function it_creates_the_toggle_collection_factory_for_symfony()
{
$this->load([
'persistence' => 'symfony',
]);

$definition = $this->container->getDefinition('qandidate.toggle.collection.factory');
$factory = $definition->getFactory();
$this->assertArrayHasKey(0, $factory);
$this->assertArrayHasKey(1, $factory);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Reference', $factory[0]);
$this->assertSame('qandidate.toggle.collection.factory.in_memory', (string) $factory[0]);
$this->assertSame('getToggles', $factory[1]);
}

/**
* @test
*/
Expand Down

0 comments on commit cf375c5

Please sign in to comment.