Issues (68)

src/Aimeos/Shop/Command/JobsCommand.php (1 issue)

Labels
1
<?php
2
3
/**
4
 * @license MIT, http://opensource.org/licenses/MIT
5
 * @copyright Aimeos (aimeos.org), 2015-2016
6
 * @package laravel
7
 * @subpackage Command
8
 */
9
10
11
namespace Aimeos\Shop\Command;
12
13
use Illuminate\Console\Command;
14
use Symfony\Component\Console\Input\InputArgument;
15
16
17
/**
18
 * Command for executing the Aimeos job controllers
19
 * @package laravel
20
 * @subpackage Command
21
 */
22
class JobsCommand extends AbstractCommand
23
{
24
	/**
25
	 * The name and signature of the console command.
26
	 *
27
	 * @var string
28
	 */
29
	protected $signature = 'aimeos:jobs
30
		{jobs : One or more job controller names like "admin/job customer/email/watch"}
31
		{site? : Site codes to execute the jobs for like "default unittest" (none for all)}
32
	';
33
34
	/**
35
	 * The console command description.
36
	 *
37
	 * @var string
38
	 */
39
	protected $description = 'Executes the job controllers';
40
41
42
	/**
43
	 * Execute the console command.
44
	 *
45
	 * @return mixed
46
	 */
47
	public function handle()
48
	{
49
		$aimeos = $this->getLaravel()->make( 'aimeos' )->get();
50
		$context = $this->getContext();
51
52
		$process = $context->getProcess();
53
		$jobs = explode( ' ', $this->argument( 'jobs' ) );
54
		$localeManager = \Aimeos\MShop::create( $context, 'locale' );
55
56
		foreach( $this->getSiteItems( $context, $this->argument( 'site' ) ) as $siteItem )
57
		{
58
			$localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false );
0 ignored issues
show
The method bootstrap() 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\MShop\Locale\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\MAdmin\Cache\Manager\Standard or Aimeos\MAdmin\Cache\Manager\None 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 ignore-call  annotation

58
			/** @scrutinizer ignore-call */ 
59
   $localeItem = $localeManager->bootstrap( $siteItem->getCode(), '', '', false );
Loading history...
59
			$localeItem->setLanguageId( null );
60
			$localeItem->setCurrencyId( null );
61
62
			$context->setLocale( $localeItem );
63
64
			$this->info( sprintf( 'Executing the Aimeos jobs for "%s"', $siteItem->getCode() ) );
65
66
			foreach( $jobs as $jobname )
67
			{
68
				$fcn = function( $context, $aimeos, $jobname ) {
69
					\Aimeos\Controller\Jobs::create( $context, $aimeos, $jobname )->run();
70
				};
71
72
				$process->start( $fcn, [$context, $aimeos, $jobname], true );
73
			}
74
		}
75
76
		$process->wait();
77
	}
78
79
80
	/**
81
	 * Returns a context object
82
	 *
83
	 * @return \Aimeos\MShop\Context\Item\Standard Context object
84
	 */
85
	protected function getContext()
86
	{
87
		$lv = $this->getLaravel();
88
		$aimeos = $lv->make( 'aimeos' )->get();
89
		$context = $lv->make( 'aimeos.context' )->get( false, 'command' );
90
91
		$tmplPaths = $aimeos->getCustomPaths( 'controller/jobs/templates' );
92
		$view = $lv->make( 'aimeos.view' )->create( $context, $tmplPaths );
93
94
		$langManager = \Aimeos\MShop::create( $context, 'locale/language' );
95
		$langids = array_keys( $langManager->searchItems( $langManager->createSearch( true ) ) );
96
		$i18n = $lv->make( 'aimeos.i18n' )->get( $langids );
97
98
		$context->setEditor( 'aimeos:jobs' );
99
		$context->setView( $view );
100
		$context->setI18n( $i18n );
101
102
		return $context;
103
	}
104
}
105