/** * Returns the manager the controller is using. * * @return MShop_Common_Manager_Interface Manager object */ protected function _getManager() { if ($this->_manager === null) { $this->_manager = MAdmin_Cache_Manager_Factory::createManager($this->_getContext()); } return $this->_manager; }
/** * 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 = TestHelper::getContext(); $this->_mock = $this->getMockBuilder('MW_Cache_DB')->disableOriginalConstructor()->getMock(); $manager = $this->getMockBuilder('MAdmin_Cache_Manager_Default')->setConstructorArgs(array($this->_context))->getMock(); $manager->expects($this->once())->method('getCache')->will($this->returnValue($this->_mock)); $name = 'MAdminCacheProxyDefaultTest'; $this->_context->getConfig()->set('classes/cache/manager/name', $name); MAdmin_Cache_Manager_Factory::injectManager('MAdmin_Cache_Manager_' . $name, $manager); $this->_object = new MAdmin_Cache_Proxy_Default($this->_context); }
/** * 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 = \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 \MAdmin_Cache_Proxy_Default($lcontext); $lcontext->setCache($cache); $output->writeln(sprintf('Clearing the Aimeos cache for site <info>%1$s</info>', $siteItem->getCode())); \MAdmin_Cache_Manager_Factory::createManager($lcontext)->getCache()->flush(); } }
/** * Clears the content cache * * @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 cacheCommand($sites = '') { $context = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Context')->get(); $context->setEditor('aimeos:cache'); $localeManager = \MShop_Locale_Manager_Factory::createManager($context); foreach ($this->getSiteItems($context, $sites) as $siteItem) { $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); $lcontext = clone $context; $lcontext->setLocale($localeItem); $cache = new \MAdmin_Cache_Proxy_Default($lcontext); $lcontext->setCache($cache); $this->outputFormatted('Clearing the Aimeos cache for site <b>%s</b>', array($siteItem->getCode())); \MAdmin_Cache_Manager_Factory::createManager($lcontext)->getCache()->flush(); } }
/** * Execute the console command. * * @return mixed */ public function fire() { $context = $this->getLaravel()->make('Aimeos\\Shop\\Base\\Context')->get(false); $context->setEditor('aimeos:cache'); $localeManager = \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 \MAdmin_Cache_Proxy_Default($lcontext); $lcontext->setCache($cache); $this->info(sprintf('Clearing the Aimeos cache for site "%1$s"', $siteItem->getCode())); \MAdmin_Cache_Manager_Factory::createManager($lcontext)->getCache()->flush(); } }
/** * Adds the cache test data. * * @throws MW_Setup_Exception If a required ID is not available */ private function _addCacheTestData() { $manager = MAdmin_Cache_Manager_Factory::createManager($this->_additional, 'Default'); $ds = DIRECTORY_SEPARATOR; $path = dirname(__FILE__) . $ds . 'data' . $ds . 'cache.php'; if (($testdata = (include $path)) == false) { throw new 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); } }
/** * Returns the cache object or creates a new one if it doesn't exist yet. * * @return MW_Cache_Interface Cache object */ protected function _getObject() { if (!isset($this->_object)) { $this->_object = MAdmin_Cache_Manager_Factory::createManager($this->_context)->getCache(); } return $this->_object; }
public function testCreateManagerNotExisting() { $this->setExpectedException('MShop_Exception'); MAdmin_Cache_Manager_Factory::createManager(TestHelper::getContext(), 'notexist'); }
/** * Initializes the cache controller. * * @param MShop_Context_Item_Interface $context MShop context object */ public function __construct(MShop_Context_Item_Interface $context) { parent::__construct($context, 'Admin_Cache'); $this->_manager = MAdmin_Cache_Manager_Factory::createManager($context); }
/** * Executes the job. * * @throws Controller_Jobs_Exception If an error occurs */ public function run() { MAdmin_Cache_Manager_Factory::createManager($this->_getContext())->getCache()->cleanup(); }