Skip to content

Commit

Permalink
Remove the cached provider functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Jan 9, 2023
1 parent 43146ee commit b8da614
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 176 deletions.
14 changes: 0 additions & 14 deletions src/DependencyInjection/Compiler/RegisterProvidersPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Setono\SyliusPickupPointPlugin\DependencyInjection\Compiler;

use InvalidArgumentException;
use Setono\SyliusPickupPointPlugin\Provider\CachedProvider;
use Setono\SyliusPickupPointPlugin\Provider\LocalProvider;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -21,7 +20,6 @@ public function process(ContainerBuilder $container): void
}

$registry = $container->getDefinition('setono_sylius_pickup_point.registry.provider');
$cacheEnabled = $container->getParameter('setono_sylius_pickup_point.cache.enabled') === true;
$localEnabled = $container->getParameter('setono_sylius_pickup_point.local') === true;

$typeToLabelMap = [];
Expand All @@ -33,18 +31,6 @@ public function process(ContainerBuilder $container): void

$typeToLabelMap[$attributes['code']] = $attributes['label'];

if ($cacheEnabled) {
$decoratedId = $id;
$id .= '.cached'; // overwrite the id
$cachedDefinition = new Definition(CachedProvider::class, [
new Reference('setono_sylius_pickup_point.cache'),
new Reference($id . '.inner'),
]);
$cachedDefinition->setDecoratedService($decoratedId, null, 256);

$container->setDefinition($id, $cachedDefinition);
}

if ($localEnabled) {
$decoratedId = $id;
$id .= '.local'; // overwrite the id
Expand Down
11 changes: 0 additions & 11 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->addDefaultsIfNotSet()
->children()
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
->arrayNode('cache')
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')
->defaultFalse()
->end()
->scalarNode('pool')
->defaultNull()
->end()
->end()
->end()
->booleanNode('local')
->defaultValue(true)
->info('Whether to use the local database when timeouts occur in third party HTTP calls. Remember to run the setono-sylius-pickup-point:load-pickup-points command periodically to populate the local database with pickup points')
Expand Down
16 changes: 0 additions & 16 deletions src/DependencyInjection/SetonoSyliusPickupPointExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use LogicException;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
Expand All @@ -28,21 +27,6 @@ public function load(array $configs, ContainerBuilder $container): void
$bundles = $container->hasParameter('kernel.bundles') ? $container->getParameter('kernel.bundles') : [];
Assert::isArray($bundles);

$cacheEnabled = $config['cache']['enabled'];
if ($cacheEnabled) {
if (!interface_exists(AdapterInterface::class)) {
throw new LogicException('Using cache is only supported when symfony/cache is installed.');
}

if (null === $config['cache']['pool']) {
throw new LogicException('You should specify pool in order to use cache for pickup point providers.');
}

$container->setAlias('setono_sylius_pickup_point.cache', $config['cache']['pool']);
}

$container->setParameter('setono_sylius_pickup_point.cache.enabled', $cacheEnabled);

if ($config['providers']['faker']) {
if ('prod' === $container->getParameter('kernel.environment')) {
throw new LogicException("You can't use faker provider in production environment.");
Expand Down
132 changes: 0 additions & 132 deletions src/Provider/CachedProvider.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ framework:
adapter: cache.app

setono_sylius_pickup_point:
cache:
enabled: true
pool: setono_sylius_pickup_point.provider_cache_pool
local: true
providers:
faker: true
Expand Down

0 comments on commit b8da614

Please sign in to comment.