From ba56ee298db8b1c42f954a77f6b12c638f918abd Mon Sep 17 00:00:00 2001 From: Andreas Date: Fri, 1 Nov 2019 13:01:11 +0100 Subject: [PATCH] Renamed aimeos:cache command to aimeos:clear --- src/Aimeos/Shop/Command/CacheCommand.php | 55 ++----------------- src/Aimeos/Shop/Command/ClearCommand.php | 67 ++++++++++++++++++++++++ tests/Command/CacheCommandTest.php | 9 ---- tests/Command/ClearCommandTest.php | 9 ++++ 4 files changed, 81 insertions(+), 59 deletions(-) create mode 100644 src/Aimeos/Shop/Command/ClearCommand.php delete mode 100644 tests/Command/CacheCommandTest.php create mode 100644 tests/Command/ClearCommandTest.php diff --git a/src/Aimeos/Shop/Command/CacheCommand.php b/src/Aimeos/Shop/Command/CacheCommand.php index dfecc4bb..f389c2fa 100644 --- a/src/Aimeos/Shop/Command/CacheCommand.php +++ b/src/Aimeos/Shop/Command/CacheCommand.php @@ -2,7 +2,7 @@ /** * @license MIT, http://opensource.org/licenses/MIT - * @copyright Aimeos (aimeos.org), 2015-2016 + * @copyright Aimeos (aimeos.org), 2015-2019 * @package laravel * @subpackage Command */ @@ -10,58 +10,13 @@ namespace Aimeos\Shop\Command; -use Symfony\Component\Console\Input\InputArgument; - /** - * Command for clearing the content cache + * Stub for aimeos:cache (now aimeos:clear) + * * @package laravel * @subpackage Command */ -class CacheCommand extends AbstractCommand +class CacheCommand extends ClearCommand { - /** - * The name and signature of the console command. - * - * @var string - */ - protected $signature = 'aimeos:cache - {site? : Site codes to clear the Aimeos content cache for like "default unittest" (none for all)} - '; - - /** - * The console command description. - * - * @var string - */ - protected $description = 'Clears the content cache'; - - - /** - * Execute the console command. - * - * @return mixed - */ - public function handle() - { - $context = $this->getLaravel()->make( 'Aimeos\Shop\Base\Context' )->get( false, 'command' ); - $context->setEditor( 'aimeos:cache' ); - - $localeManager = \Aimeos\MShop::create( $context, 'locale' ); - - foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem ) - { - $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); - - $lcontext = clone $context; - $lcontext->setLocale( $localeItem ); - - $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext ); - $lcontext->setCache( $cache ); - - $this->info( sprintf( 'Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode() ) ); - - \Aimeos\MAdmin::create( $lcontext, 'cache' )->getCache()->clear(); - } - } -} +} \ No newline at end of file diff --git a/src/Aimeos/Shop/Command/ClearCommand.php b/src/Aimeos/Shop/Command/ClearCommand.php new file mode 100644 index 00000000..e40ef53d --- /dev/null +++ b/src/Aimeos/Shop/Command/ClearCommand.php @@ -0,0 +1,67 @@ +getLaravel()->make( 'Aimeos\Shop\Base\Context' )->get( false, 'command' ); + $context->setEditor( 'aimeos:clear' ); + + $localeManager = \Aimeos\MShop::create( $context, 'locale' ); + + foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem ) + { + $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); + + $lcontext = clone $context; + $lcontext->setLocale( $localeItem ); + + $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext ); + $lcontext->setCache( $cache ); + + $this->info( sprintf( 'Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode() ) ); + + \Aimeos\MAdmin::create( $lcontext, 'cache' )->getCache()->clear(); + } + } +} diff --git a/tests/Command/CacheCommandTest.php b/tests/Command/CacheCommandTest.php deleted file mode 100644 index b1a52c50..00000000 --- a/tests/Command/CacheCommandTest.php +++ /dev/null @@ -1,9 +0,0 @@ -assertEquals(0, $this->artisan('aimeos:cache', array('site' => 'unittest'))); - } -} diff --git a/tests/Command/ClearCommandTest.php b/tests/Command/ClearCommandTest.php new file mode 100644 index 00000000..ea09d7b3 --- /dev/null +++ b/tests/Command/ClearCommandTest.php @@ -0,0 +1,9 @@ +assertEquals(0, $this->artisan('aimeos:clear', array('site' => 'unittest'))); + } +}