public function testGetControllers() { $context = \TestHelperJobs::getContext(); $aimeos = \TestHelperJobs::getAimeos(); $list = \Aimeos\Controller\Jobs\Factory::getControllers($context, $aimeos, \TestHelperJobs::getControllerPaths()); $this->assertEquals(0, count($list)); }
public function testGetControllers() { $context = \TestHelper::getContext(); $aimeos = \TestHelper::getAimeos(); $list = \Aimeos\Controller\Jobs\Factory::getControllers($context, $aimeos, \TestHelper::getControllerPaths()); $this->assertGreaterThan(0, count($list)); foreach ($list as $key => $object) { $this->assertInstanceOf('\\Aimeos\\Controller\\Jobs\\Iface', $object); } }
/** * Executes the job controllers. * * @param InputInterface $input Input object * @param OutputInterface $output Output object */ protected function execute(InputInterface $input, OutputInterface $output) { $context = $this->getContext(); $aimeos = $this->getContainer()->get('aimeos')->get(); $jobs = explode(' ', $input->getArgument('jobs')); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); foreach ($this->getSiteItems($context, $input) as $siteItem) { $localeItem = $localeManager->bootstrap($siteItem->getCode(), 'en', '', false); $context->setLocale($localeItem); $output->writeln(sprintf('Executing the Aimeos jobs for "<info>%s</info>"', $siteItem->getCode())); foreach ($jobs as $jobname) { \Aimeos\Controller\Jobs\Factory::createController($context, $aimeos, $jobname)->run(); } } }
/** * Execute the list of jobs for the given sites * * @param array $conf Multi-dimensional array of configuration options * @param array $jobs List of job names * @param string $sites List of site names */ public static function execute(array $conf, array $jobs, $sites) { $aimeos = Aimeos\Base::getAimeos(); $context = self::getContext($conf); $manager = \Aimeos\MShop\Factory::createManager($context, 'locale'); foreach (self::getSiteItems($context, $sites) as $siteItem) { $localeItem = $manager->bootstrap($siteItem->getCode(), '', '', false); $localeItem->setLanguageId(null); $localeItem->setCurrencyId(null); $context->setLocale($localeItem); foreach ($jobs as $jobname) { \Aimeos\Controller\Jobs\Factory::createController($context, $aimeos, $jobname)->run(); } } }
/** * Execute the console command. * * @return mixed */ public function fire() { $aimeos = $this->getLaravel()->make('\\Aimeos\\Shop\\Base\\Aimeos')->get(); $context = $this->getContext(); $jobs = explode(' ', $this->argument('jobs')); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); foreach ($this->getSiteItems($context, $this->argument('site')) as $siteItem) { $localeItem = $localeManager->bootstrap($siteItem->getCode(), 'en', '', false); $context->setLocale($localeItem); $this->info(sprintf('Executing the Aimeos jobs for "%s"', $siteItem->getCode())); foreach ($jobs as $jobname) { \Aimeos\Controller\Jobs\Factory::createController($context, $aimeos, $jobname)->run(); } } }
/** * Removes the cached data for the given sites * * @param \Aimeos\Bootstrap $aimeos Aimeos bootstrap object * @param \Aimeos\MShop\Context\Item\Iface $ctx Context object * @param array $siteItems List of site items implementing \Aimeos\MShop\Locale\Site\Iface */ protected static function execute(\Aimeos\Bootstrap $aimeos, \Aimeos\MShop\Context\Item\Iface $ctx, array $siteItems, $jobs) { $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); foreach ($siteItems as $siteItem) { $localeItem = $localeManager->bootstrap($siteItem->getCode(), 'en', '', false); $localeItem->setLanguageId(null); $localeItem->setCurrencyId(null); $ctx->setLocale($localeItem); printf("Executing the Aimeos jobs for \"%s\"\n", $siteItem->getCode()); foreach ((array) explode(' ', $jobs) as $jobname) { \Aimeos\Controller\Jobs\Factory::createController($ctx, $aimeos, $jobname)->run(); } } }
/** * Executes the Aimeos maintenance jobs * * The Aimeos shop system needs some maintenance tasks that must be * regularly executed. These include * * - admin/cache (remove expired cache entries once a day) * - admin/job (process import/export jobs created in the admin interface every five minutes) * - admin/log (archivate and delete old log entries once a day) * - customer/email/watch (send customers e-mails if their watched products have changed) * - index/rebuild (rebuild the catalog index once a day after midnight) * - index/optimize (optimize the catalog index once a day one hour after the rebuild) * - order/cleanup/unfinished (remove unfinised orders once a day) * - order/cleanup/unfinised (remove unpaid orders once a day) * - order/email/delivery (send delivery status update e-mails to the customers every few hours) * - order/email/payment (send payment status update e-mails to the customers every few hours) * - order/service/async (import batch delivery or payment status updates if necessary) * - order/service/delivery (sends paid orders to the ERP system or logistic partner) * - order/service/payment (captures authorized payments after the configured amount of time automatically) * - product/bought (updates the suggested products based on what other customers bought once a day) * - product/export (export products) * - product/export/sitemap (generate product sitemaps for search engines) * - product/import/csv (import products from CSV files) * * Each of these maintenance tasks must be executed for all shop instances * if you have more than one site in your installation. The sites parameter * should contain a list of site codes in this case. If you only have one * site named "default" then you don't need to specify the site. * * @param string $jobs List of job names separated by a space character like "admin/job catalog/index/rebuild" * @param string $sites List of sites separated by a space character the jobs should be executed for, e.g. "default unittest" * @return void */ public function jobsCommand($jobs, $sites = 'default') { $aimeos = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Aimeos')->get(); $context = $this->getContext(); $jobs = explode(' ', $jobs); $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); foreach ($this->getSiteItems($context, $sites) as $siteItem) { $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); $localeItem->setLanguageId(null); $localeItem->setCurrencyId(null); $context->setLocale($localeItem); $this->outputFormatted('Executing jobs for site <b>%s</b>', array($siteItem->getCode())); foreach ($jobs as $jobname) { $this->outputFormatted(' <b>%s</b>', array($jobname)); \Aimeos\Controller\Jobs\Factory::createController($context, $aimeos, $jobname)->run(); } } }
/** * Returns the HTML code for the controller control. * * @param array $selected List of site codes that were previously selected by the user * @param string|null $filter String that must be part of the controller name * @return string HTML code with <option> tags for the select box */ protected function getControllerOptions(array $selected, $filter = null) { $html = ''; $aimeos = Base::getAimeos(); $context = Scheduler\Base::getContext(); $cntlPaths = $aimeos->getCustomPaths('controller/jobs'); $langid = 'en'; if (isset($GLOBALS['BE_USER']->uc['lang']) && $GLOBALS['BE_USER']->uc['lang'] != '') { $langid = $GLOBALS['BE_USER']->uc['lang']; } $localeItem = \Aimeos\MShop\Factory::createManager($context, 'locale')->createItem(); $localeItem->setLanguageId($langid); $context->setLocale($localeItem); $controllers = \Aimeos\Controller\Jobs\Factory::getControllers($context, $aimeos, $cntlPaths); foreach ($controllers as $name => $controller) { if ($filter !== null && strstr($name, $filter) === false) { continue; } $active = in_array($name, $selected) ? 'selected="selected"' : ''; $title = htmlspecialchars($controller->getDescription(), ENT_QUOTES, 'UTF-8'); $cntl = htmlspecialchars($controller->getName(), ENT_QUOTES, 'UTF-8'); $name = htmlspecialchars($name, ENT_QUOTES, 'UTF-8'); $html .= sprintf('<option value="%1$s" title="%2$s" %3$s>%4$s</option>', $name, $title, $active, $cntl); } return $html; }