Skip to content

Commit

Permalink
NEXT-10854 support custom cache folders (shopware#152)
Browse files Browse the repository at this point in the history
* NEXT-10854 - Support custom cache folders
  • Loading branch information
yannick80 committed Sep 17, 2020
1 parent ff0cded commit 34484cb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
15 changes: 15 additions & 0 deletions changelog/_unreleased/2020-09-17-support-custom-cache-folders.md
@@ -0,0 +1,15 @@
---
title: Support custom cache folders
issue: NEXT-10854
author: Yann Karl
author_email: y.karl@webweit.de
author_github: @yannick80
---
# Core
* Changed property name `cacheDir` to `projectDir`, updated write path for `dump` in `src/Core/Framework/Plugin/BundleConfigDumper.php`
* Changed parameter from `%kernel.cache_dir%` to `%kernel.project_dir%` in service description for `BundleConfigDumper` in `src/Core/Framework/DependencyInjection/plugin.xml`
___
# Storefront
* Changed property name `cacheDir` to `projectDir`, updated write path for `execute` in `src/Storefront/Theme/Command/ThemeDumpCommand.php`
* Changed parameter `%kernel.cache_dir%` to `%kernel.project_dir%` in service description for `ThemeDumpCommand` in `src/Storefront/DependencyInjection/theme.xml`
* Changed parameter `kernel.cache_dir` to `kernel.project_dir` for `testExecuteShouldResolveThemeInheritanceChainAndConsiderThemeIdArgument` in `src/Storefront/Test/Theme/Command/ThemeDumpCommandTest.php`
2 changes: 1 addition & 1 deletion src/Core/Framework/DependencyInjection/plugin.xml
Expand Up @@ -21,7 +21,7 @@

<service id="Shopware\Core\Framework\Plugin\BundleConfigDumper">
<argument type="service" id="Shopware\Core\Framework\Plugin\BundleConfigGenerator" />
<argument>%kernel.cache_dir%</argument>
<argument>%kernel.project_dir%</argument>

<tag name="kernel.event_subscriber" />
</service>
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Framework/Plugin/BundleConfigDumper.php
Expand Up @@ -16,14 +16,14 @@ class BundleConfigDumper implements EventSubscriberInterface
/**
* @var string
*/
private $cacheDir;
private $projectDir;

public function __construct(
BundleConfigGeneratorInterface $bundleConfigGenerator,
string $cacheDir
string $projectDir
) {
$this->bundleConfigGenerator = $bundleConfigGenerator;
$this->cacheDir = $cacheDir;
$this->projectDir = $projectDir;
}

public static function getSubscribedEvents(): array
Expand All @@ -39,7 +39,7 @@ public function dump(): void
$config = $this->bundleConfigGenerator->getConfig();

file_put_contents(
$this->cacheDir . '/../../plugins.json',
$this->projectDir . '/var/plugins.json',
json_encode($config, JSON_PRETTY_PRINT)
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Storefront/DependencyInjection/theme.xml
Expand Up @@ -138,7 +138,7 @@
<argument type="service" id="Shopware\Storefront\Theme\StorefrontPluginRegistry"/>
<argument type="service" id="Shopware\Storefront\Theme\ThemeFileResolver"/>
<argument type="service" id="theme.repository"/>
<argument>%kernel.cache_dir%</argument>
<argument>%kernel.project_dir%</argument>

<tag name="console.command"/>
</service>
Expand Down
2 changes: 1 addition & 1 deletion src/Storefront/Test/Theme/Command/ThemeDumpCommandTest.php
Expand Up @@ -30,7 +30,7 @@ public function testExecuteShouldResolveThemeInheritanceChainAndConsiderThemeIdA
$this->getPluginRegistryMock(),
$themeFileResolverMock,
$this->getContainer()->get('theme.repository'),
$this->getContainer()->getParameter('kernel.cache_dir')
$this->getContainer()->getParameter('kernel.project_dir')
);

$commandTester = new CommandTester($themeDumpCommand);
Expand Down
8 changes: 4 additions & 4 deletions src/Storefront/Theme/Command/ThemeDumpCommand.php
Expand Up @@ -38,7 +38,7 @@ class ThemeDumpCommand extends Command
/**
* @var string
*/
private $cacheDir;
private $projectDir;

/**
* @var Context
Expand All @@ -54,14 +54,14 @@ public function __construct(
StorefrontPluginRegistryInterface $pluginRegistry,
ThemeFileResolver $themeFileResolver,
EntityRepositoryInterface $themeRepository,
string $cacheDir
string $projectDir
) {
parent::__construct();

$this->pluginRegistry = $pluginRegistry;
$this->themeFileResolver = $themeFileResolver;
$this->themeRepository = $themeRepository;
$this->cacheDir = $cacheDir;
$this->projectDir = $projectDir;
$this->context = Context::createDefaultContext();
}

Expand Down Expand Up @@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$dump['basePath'] = $themeConfig->getBasePath();

file_put_contents(
$this->cacheDir . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'theme-files.json',
$this->projectDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'theme-files.json',
json_encode($dump, JSON_PRETTY_PRINT)
);

Expand Down

0 comments on commit 34484cb

Please sign in to comment.