Example #1
0
 /**
  * Returns the manager the controller is using.
  *
  * @return \Aimeos\MShop\Common\Manager\Iface Manager object
  */
 protected function getManager()
 {
     if ($this->manager === null) {
         $this->manager = \Aimeos\MAdmin\Cache\Manager\Factory::createManager($this->getContext());
     }
     return $this->manager;
 }
Example #2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $this->context = \TestHelperMShop::getContext();
     $this->mock = $this->getMockBuilder('\\Aimeos\\MW\\Cache\\DB')->disableOriginalConstructor()->getMock();
     $manager = $this->getMockBuilder('\\Aimeos\\MAdmin\\Cache\\Manager\\Standard')->setConstructorArgs(array($this->context))->getMock();
     $manager->expects($this->once())->method('getCache')->will($this->returnValue($this->mock));
     $name = 'MAdminCacheProxyDefaultTest';
     $this->context->getConfig()->set('madmin/cache/manager/name', $name);
     \Aimeos\MAdmin\Cache\Manager\Factory::injectManager('\\Aimeos\\MAdmin\\Cache\\Manager\\' . $name, $manager);
     $this->object = new \Aimeos\MAdmin\Cache\Proxy\Standard($this->context);
 }
Example #3
0
 /**
  * Executes the job controllers.
  *
  * @param InputInterface $input Input object
  * @param OutputInterface $output Output object
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $context = $this->getContainer()->get('aimeos_context')->get(false);
     $context->setEditor('aimeos:cache');
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     foreach ($this->getSiteItems($context, $input) 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);
         $output->writeln(sprintf('Clearing the Aimeos cache for site <info>%1$s</info>', $siteItem->getCode()));
         \Aimeos\MAdmin\Cache\Manager\Factory::createManager($lcontext)->getCache()->flush();
     }
 }
Example #4
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $context = $this->getLaravel()->make('Aimeos\\Shop\\Base\\Context')->get(false, 'command');
     $context->setEditor('aimeos:cache');
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     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\Cache\Manager\Factory::createManager($lcontext)->getCache()->flush();
     }
 }
Example #5
0
 /**
  * Adds the cache test data.
  *
  * @throws \Aimeos\MW\Setup\Exception If a required ID is not available
  */
 private function addCacheTestData()
 {
     $manager = \Aimeos\MAdmin\Cache\Manager\Factory::createManager($this->additional, 'Standard');
     $ds = DIRECTORY_SEPARATOR;
     $path = __DIR__ . $ds . 'data' . $ds . 'cache.php';
     if (($testdata = (include $path)) == false) {
         throw new \Aimeos\MShop\Exception(sprintf('No file "%1$s" found for cache domain', $path));
     }
     $item = $manager->createItem();
     foreach ($testdata['cache'] as $dataset) {
         $item->setId($dataset['id']);
         $item->setValue($dataset['value']);
         $item->setTimeExpire($dataset['expire']);
         $item->setTags($dataset['tags']);
         $manager->saveItem($item, false);
     }
 }
Example #6
0
 /**
  * Executes the job.
  *
  * @throws \Aimeos\Controller\Jobs\Exception If an error occurs
  */
 public function run()
 {
     \Aimeos\MAdmin\Cache\Manager\Factory::createManager($this->getContext())->getCache()->cleanup();
 }
Example #7
0
 public function testCreateManagerNotExisting()
 {
     $this->setExpectedException('\\Aimeos\\MShop\\Exception');
     \Aimeos\MAdmin\Cache\Manager\Factory::createManager(\TestHelperMShop::getContext(), 'unknown');
 }
Example #8
0
 /**
  * Returns the cache object or creates a new one if it doesn't exist yet.
  *
  * @return \Aimeos\MW\Cache\Iface Cache object
  */
 protected function getObject()
 {
     if (!isset($this->object)) {
         $this->object = \Aimeos\MAdmin\Cache\Manager\Factory::createManager($this->context)->getCache();
     }
     return $this->object;
 }
Example #9
0
 /**
  * Removes the cached data for the given sites
  *
  * @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 clear(\Aimeos\MShop\Context\Item\Iface $ctx, array $siteItems)
 {
     $localeManager = \Aimeos\MShop\Factory::createManager($ctx, 'locale');
     foreach ($siteItems as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $ctx;
         $lcontext->setLocale($localeItem);
         $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($lcontext);
         $lcontext->setCache($cache);
         printf("Clearing the Aimeos cache for site \"%1\$s\"\n", $siteItem->getCode());
         \Aimeos\MAdmin\Cache\Manager\Factory::createManager($lcontext)->getCache()->flush();
     }
 }