Skip to content

Commit

Permalink
Renamed aimeos:cache command to aimeos:clear
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Nov 1, 2019
1 parent 7baff8e commit ba56ee2
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 59 deletions.
55 changes: 5 additions & 50 deletions src/Aimeos/Shop/Command/CacheCommand.php
Expand Up @@ -2,66 +2,21 @@

/**
* @license MIT, http://opensource.org/licenses/MIT
* @copyright Aimeos (aimeos.org), 2015-2016
* @copyright Aimeos (aimeos.org), 2015-2019
* @package laravel
* @subpackage Command
*/


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();
}
}
}
}
67 changes: 67 additions & 0 deletions src/Aimeos/Shop/Command/ClearCommand.php
@@ -0,0 +1,67 @@
<?php

/**
* @license MIT, http://opensource.org/licenses/MIT
* @copyright Aimeos (aimeos.org), 2015-2016
* @package laravel
* @subpackage Command
*/


namespace Aimeos\Shop\Command;

use Symfony\Component\Console\Input\InputArgument;


/**
* Command for clearing the content cache
* @package laravel
* @subpackage Command
*/
class ClearCommand extends AbstractCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'aimeos:clear
{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: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();
}
}
}
9 changes: 0 additions & 9 deletions tests/Command/CacheCommandTest.php

This file was deleted.

9 changes: 9 additions & 0 deletions tests/Command/ClearCommandTest.php
@@ -0,0 +1,9 @@
<?php

class ClearCommandTest extends AimeosTestAbstract
{
public function testSetupCommand()
{
$this->assertEquals(0, $this->artisan('aimeos:clear', array('site' => 'unittest')));
}
}

0 comments on commit ba56ee2

Please sign in to comment.