1 | <?php |
||||
2 | |||||
3 | /** |
||||
4 | * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
||||
5 | * @copyright Aimeos (aimeos.org), 2016 |
||||
6 | * @package Slim |
||||
7 | * @subpackage Command |
||||
8 | */ |
||||
9 | |||||
10 | namespace Aimeos\Slim\Command; |
||||
11 | |||||
12 | |||||
13 | /** |
||||
14 | * Aimeos cache command class |
||||
15 | * |
||||
16 | * @package Slim |
||||
17 | * @subpackage Command |
||||
18 | */ |
||||
19 | class Cache extends Base implements Iface |
||||
20 | { |
||||
21 | /** |
||||
22 | * Returns the command usage and options |
||||
23 | * |
||||
24 | * @return string Command usage and options |
||||
25 | */ |
||||
26 | public static function usage() : string |
||||
27 | { |
||||
28 | return "Usage: php cache.php [--extdir=<path>]* [--config=<path>|<file>]* [\"sitecode1 [sitecode2]*\"]\n"; |
||||
29 | } |
||||
30 | |||||
31 | |||||
32 | /** |
||||
33 | * Executes the command |
||||
34 | * |
||||
35 | * @param array $argv Associative array from $_SERVER['argv'] |
||||
36 | */ |
||||
37 | public static function run( array $argv ) |
||||
38 | { |
||||
39 | array_shift( $argv ); |
||||
40 | $options = self::getOptions( $argv ); |
||||
41 | $sites = array_shift( $argv ); |
||||
42 | |||||
43 | $extdirs = ( isset( $options['extdir'] ) ? (array) $options['extdir'] : array() ); |
||||
44 | $aimeos = new \Aimeos\Bootstrap( $extdirs ); |
||||
45 | |||||
46 | $ctx = self::getContext( $aimeos->getConfigPaths(), $options ); |
||||
47 | $siteItems = self::getSiteItems( $ctx, $sites ); |
||||
48 | |||||
49 | self::clear( $ctx, $siteItems ); |
||||
50 | } |
||||
51 | |||||
52 | |||||
53 | /** |
||||
54 | * Returns a new context object |
||||
55 | * |
||||
56 | * @param array $confPaths List of configuration paths from the bootstrap object |
||||
57 | * @param array $options Associative list of configuration options as key/value pairs |
||||
58 | * @return \Aimeos\MShop\Context\Item\Iface Context object |
||||
59 | */ |
||||
60 | protected static function getContext( array $confPaths, array $options ) : \Aimeos\MShop\Context\Item\Iface |
||||
61 | { |
||||
62 | $config = array(); |
||||
63 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
||||
64 | |||||
65 | if( isset( $options['config'] ) ) |
||||
66 | { |
||||
67 | foreach( (array) $options['config'] as $path ) |
||||
68 | { |
||||
69 | if( is_file( $path ) ) { |
||||
70 | $config = array_replace_recursive( $config, require $path ); |
||||
71 | } else { |
||||
72 | $confPaths[] = $path; |
||||
73 | } |
||||
74 | } |
||||
75 | } |
||||
76 | |||||
77 | $conf = new \Aimeos\MW\Config\PHPArray( $config, $confPaths ); |
||||
78 | $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
||||
79 | |||||
80 | if( ( $cfg = $conf->get( 'command' ) ) !== null ) { |
||||
81 | $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf, $cfg ); |
||||
82 | } |
||||
83 | |||||
84 | $ctx->setConfig( $conf ); |
||||
85 | |||||
86 | |||||
87 | $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
||||
88 | $ctx->setDatabaseManager( $dbm ); |
||||
89 | |||||
90 | $logger = new \Aimeos\MW\Logger\Errorlog( \Aimeos\MW\Logger\Base::INFO ); |
||||
91 | $ctx->setLogger( $logger ); |
||||
92 | |||||
93 | return $ctx; |
||||
94 | } |
||||
95 | |||||
96 | |||||
97 | /** |
||||
98 | * Removes the cached data for the given sites |
||||
99 | * |
||||
100 | * @param \Aimeos\MShop\Context\Item\Iface $ctx Context object |
||||
101 | * @param \Aimeos\Map $siteItems List of site items implementing \Aimeos\MShop\Locale\Site\Iface |
||||
102 | */ |
||||
103 | protected static function clear( \Aimeos\MShop\Context\Item\Iface $ctx, \Aimeos\Map $siteItems ) |
||||
104 | { |
||||
105 | $localeManager = \Aimeos\MShop::create( $ctx, 'locale' ); |
||||
106 | |||||
107 | foreach( $siteItems as $siteItem ) |
||||
108 | { |
||||
109 | $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false ); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
110 | |||||
111 | $lcontext = clone $ctx; |
||||
112 | $lcontext->setLocale( $localeItem ); |
||||
113 | |||||
114 | $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $lcontext ); |
||||
115 | $lcontext->setCache( $cache ); |
||||
116 | |||||
117 | printf( "Clearing the Aimeos cache for site \"%1\$s\"\n", $siteItem->getCode() ); |
||||
118 | |||||
119 | \Aimeos\MAdmin::create( $lcontext, 'cache' )->getCache()->clear(); |
||||
0 ignored issues
–
show
The method
getCache() does not exist on Aimeos\MShop\Common\Manager\Iface . It seems like you code against a sub-type of Aimeos\MShop\Common\Manager\Iface such as Aimeos\MAdmin\Cache\Manager\Iface or Aimeos\MShop\Common\Manager\Decorator\Base or Aimeos\MShop\Service\Manager\Lists\Type\Standard or Aimeos\MShop\Price\Manager\Standard or Aimeos\MShop\Attribute\Manager\Type\Standard or Aimeos\MShop\Price\Manager\Lists\Type\Standard or Aimeos\MShop\Media\Manager\Type\Standard or Aimeos\MShop\Coupon\Manager\Code\Standard or Aimeos\MShop\Order\Manager\Base\Coupon\Standard or Aimeos\MShop\Index\Manager\DBBase or Aimeos\MShop\Product\Manager\Standard or Aimeos\MShop\Index\Manager\Standard or Aimeos\MShop\Index\Manager\Attribute\Standard or Aimeos\MShop\Index\Manager\Text\Standard or Aimeos\MShop\Index\Manager\Supplier\Standard or Aimeos\MShop\Index\Manager\Catalog\Standard or Aimeos\MShop\Index\Manager\Price\Standard or Aimeos\MShop\Supplier\Manager\Standard or Aimeos\MShop\Price\Manager\Property\Type\Standard or Aimeos\MShop\Customer\Manager\Property\Standard or Aimeos\MShop\Order\Manager\Base\Service\Standard or Aimeos\MShop\Order\Manager\Base\Standard or Aimeos\MShop\Price\Manager\Lists\Standard or Aimeos\MShop\Supplier\Manager\Lists\Type\Standard or Aimeos\MShop\Order\Manag...vice\Attribute\Standard or Aimeos\MShop\Service\Manager\Lists\Standard or Aimeos\MShop\Tag\Manager\Type\Standard or Aimeos\MShop\Text\Manager\Lists\Standard or Aimeos\MShop\Price\Manager\Type\Standard or Aimeos\MShop\Locale\Manager\Currency\Standard or Aimeos\MShop\Order\Manag...duct\Attribute\Standard or Aimeos\MShop\Media\Manager\Lists\Type\Standard or Aimeos\MShop\Catalog\Manager\Lists\Standard or Aimeos\MShop\Tag\Manager\Standard or Aimeos\MShop\Coupon\Manager\Standard or Aimeos\MShop\Attribute\Manager\Standard or Aimeos\MShop\Attribute\M...\Property\Type\Standard or Aimeos\MShop\Service\Manager\Type\Standard or Aimeos\MShop\Product\Manager\Lists\Standard or Aimeos\MShop\Customer\Ma...\Property\Type\Standard or Aimeos\MShop\Order\Manager\Standard or Aimeos\MShop\Customer\Manager\Standard or Aimeos\MShop\Media\Manager\Standard or Aimeos\MShop\Customer\Manager\Lists\Type\Standard or Aimeos\MShop\Attribute\Manager\Lists\Standard or Aimeos\MShop\Product\Man...\Property\Type\Standard or Aimeos\MShop\Media\Manager\Lists\Standard or Aimeos\MShop\Plugin\Manager\Standard or Aimeos\MShop\Order\Manager\Base\Address\Standard or Aimeos\MShop\Catalog\Manager\Standard or Aimeos\MShop\Locale\Manager\Site\Standard or Aimeos\MShop\Product\Manager\Type\Standard or Aimeos\MShop\Supplier\Manager\Lists\Standard or Aimeos\MShop\Stock\Manager\Type\Standard or Aimeos\MShop\Text\Manager\Standard or Aimeos\MAdmin\Job\Manager\Standard or Aimeos\MShop\Customer\Manager\Group\Standard or Aimeos\MShop\Product\Manager\Lists\Type\Standard or Aimeos\MShop\Text\Manager\Lists\Type\Standard or Aimeos\MShop\Text\Manager\Type\Standard or Aimeos\MShop\Order\Manager\Status\Standard or Aimeos\MShop\Supplier\Manager\Address\Standard or Aimeos\MShop\Customer\Manager\Address\Standard or Aimeos\MShop\Plugin\Manager\Type\Standard or Aimeos\MShop\Stock\Manager\Standard or Aimeos\MShop\Stock\Manager\Nolimit or Aimeos\MShop\Attribute\Manager\Property\Standard or Aimeos\MShop\Subscription\Manager\Standard or Aimeos\MShop\Media\Manager\Property\Type\Standard or Aimeos\MShop\Product\Manager\Property\Standard or Aimeos\MShop\Locale\Manager\Language\Standard or Aimeos\MShop\Media\Manager\Property\Standard or Aimeos\MShop\Service\Manager\Standard or Aimeos\MShop\Attribute\Manager\Lists\Type\Standard or Aimeos\MAdmin\Log\Manager\Standard or Aimeos\MShop\Locale\Manager\Standard or Aimeos\MShop\Order\Manager\Base\Product\Standard or Aimeos\MShop\Price\Manager\Property\Standard or Aimeos\MShop\Customer\Manager\Lists\Standard or Aimeos\MShop\Catalog\Manager\Lists\Type\Standard .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
120 | } |
||||
121 | } |
||||
122 | } |