protected function setUpCheckoutViaHTTPS($value) { \XLite\Core\Database::getRepo('\\XLite\\Model\\Config')->createOption(array('category' => 'Security', 'name' => 'customer_security', 'value' => $value ? 'Y' : 'N')); // Reset cache - DO NOT CHANGE! \XLite\Core\Database::getCacheDriver()->deleteAll(); \XLite\Core\Config::getInstance()->Security->customer_security; }
/** * Remove product filter cache * * @param ids IDs OPTIONAL * * @return void */ public function removeProductFilterCache($ids = null) { $cacheDriver = \XLite\Core\Database::getCacheDriver(); if ($ids) { foreach ($ids as $id) { $cacheDriver->delete('ProductFilter_Category_Attributes_' . $id); } } else { $categories = $this->createPureQueryBuilder('c')->select('c.category_id')->getQuery()->getScalarResult(); foreach ($categories as $v) { $cacheDriver->delete('ProductFilter_Category_Attributes_' . $v['category_id']); } } }
/** * Constructor * * @return void */ public function __construct() { $this->em = \XLite\Core\Database::getEM(); $this->translation = \XLite\Core\Translation::getInstance(); $entities = \XLite\Core\Database::getCacheDriver()->fetch('quickEntities'); if (!is_array($entities) || !$entities) { foreach ($this->em->getMetadataFactory()->getAllMetadata() as $md) { if (!$md->isMappedSuperclass && preg_match('/^XLite\\\\(?:Module\\\\([a-z0-9]+)\\\\)?Model\\\\(.+)$/iSs', $md->name, $m)) { $key = ($m[1] ? $m[1] . '\\' : '') . $m[2]; $entities[$key] = $md->name; } } \XLite\Core\Database::getCacheDriver()->save('quickEntities', $entities); } $this->entities = $entities; }
/** * Save data to cache * * @param mixed $data Data * @param string $name Cache cell name * @param array $params Cache cell parameters OPTIONAL * * @return void */ protected function saveToCache($data, $name, array $params = array()) { $cell = $this->getCacheCells($name); if ($cell) { $hash = $this->getCellHash($name, $cell, $params); if ($data instanceof \ArrayAccess) { $this->detachList($data); } elseif ($data instanceof \XLite\Model\AEntity) { $data->detach(); } \XLite\Core\Database::getCacheDriver()->save($this->getCellHash($name, $cell, $params), $data, self::CACHE_DEFAULT_TTL); } else { // TODO - add throw exception } }
/** * Restore substitutonal skins data from cache * * @return void */ protected function restoreSkins() { $driver = \XLite\Core\Database::getCacheDriver(); $data = $driver ? $driver->fetch(get_called_class() . '.SubstitutonalSkins') : null; if ($data && is_array($data)) { $this->resourcesCache = $data; } }
/** * Save data into the cache * * @param string $key Key of a cache cell * @param mixed $data Data object for saving in the cache * * @return void */ protected function saveDataInCache($key, $data) { \XLite\Core\Database::getCacheDriver()->save($this->getKeyHash($key), $data); }
/** * Save attribute options into the cache * * @param mixed $data Data object for saving in the cache * @param integer $lifeTime Cell TTL OPTIONAL * * @return void */ protected function saveAttributeOptionsInCache($data, $lifeTime = 0) { \XLite\Core\Database::getCacheDriver()->save($this->getKeyHash(), $data, $lifeTime); }
/** * Execute some methods * * @param string $type Helper type * * @return void */ public function runHelpers($type) { $path = \Includes\Utils\FileManager::getCanonicalDir($this->getRepositoryPath()); // Helpers must examine itself if the module has been installed previously if ($path) { $helpers = 'post_rebuild' === $type ? $this->postRebuildHelpers : $this->getHelpers($type); $helpers = (array) $helpers; foreach ($helpers as $file) { /** @var \Closure $function */ $function = (require_once $path . $file); $function(); $this->addInfoMessage('Update hook is run: {{type}}:{{file}}', true, array('type' => $this->getActualName(), 'file' => $file)); } if ($helpers) { \XLite\Core\Database::getCacheDriver()->deleteAll(); } } }
public function testSubstituteMultilanguage() { $de = \XLite\Core\Database::getRepo('XLite\\Model\\Language')->findOneBy(array('code' => 'de')); $de->setStatus(2); $en = \XLite\Core\Database::getRepo('XLite\\Model\\Language')->findOneBy(array('code' => 'en')); $en->setStatus(0); \XLite\Core\Database::getEM()->flush(); \XLite\Core\Database::getCacheDriver()->deleteAll(); $this->openAndWait(''); $this->assertElementPresent("//h1[@class='substitutional-test-skin' and text()='WELCOME PAGE DE']", 'test DE substutional template'); $de->setStatus(0); $en->setStatus(2); }
/** * saveDataInCache * * @param string $key Key of a cache cell * @param mixed $data Data object for saving in the cache * * @return void */ protected function saveDataInCache($key, $data) { \XLite\Core\Database::getCacheDriver()->save(md5($key), $data); }
/** * LiteCommerce * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to licensing@litecommerce.com so we can send you a copy immediately. * * PHP version 5.3.0 * * @category LiteCommerce * @author Creative Development LLC <*****@*****.**> * @copyright Copyright (c) 2011-2012 Creative Development LLC <*****@*****.**>. All rights reserved * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * @link http://www.litecommerce.com/ */ return function () { // Apply config changes $repo = \XLite\Core\Database::getRepo('XLite\\Model\\Config'); $option = $repo->findOneBy(array('name' => 'ga_tracking_type')); if ($option) { $option->setType('XLite\\Module\\CDev\\GoogleAnalytics\\View\\FormField\\Select\\TrackingType'); } \XLite\Core\Database::getEM()->flush(); \XLite\Core\Database::getCacheDriver()->deleteAll(); };
/** * Save registry * * @param array $registry Registry * * @return void */ protected function saveRegistry(array $registry) { \XLite\Core\Database::getCacheDriver()->save(static::REGISTRY_CELL, serialize($registry)); }
/** * Save packages in cache * * @param string $key Cache key * @param array $data Data to save in cache * * @return void */ protected function savePackagesInCache($key, $data) { \XLite\Core\Database::getCacheDriver()->save($key, $data); }
/** * Execute some helper methods * Return true if at least one method was executed * * @param string $type Helper type * * @return boolean */ public function runHelpers($type) { $result = false; $path = \Includes\Utils\FileManager::getCanonicalDir($this->getRepositoryPath()); // Helpers must examine itself if the module has been installed previously if ($path) { $helpers = 'post_rebuild' === $type ? $this->postRebuildHelpers : $this->getHelpers($type); $helpers = (array) $helpers; $invokedHooks = \XLite\Upgrade\Cell::getInstance()->getInvokedHooks(); $pendingHooks = \XLite\Upgrade\Cell::getInstance()->getPendingHooks(); foreach ($helpers as $file) { if (isset($invokedHooks[$file])) { // Hook has been invoked earlier, skip... continue; } /** @var \Closure $function */ $function = (require_once $path . $file); // Prepare argument for hook function $suffix = ''; $arg = null; if (!empty($pendingHooks[$file]) && 0 < $pendingHooks[$file]) { $arg = $pendingHooks[$file]; $suffix = sprintf(' (%d)', $arg); } \Includes\Utils\Operator::showMessage(\XLite\Core\Translation::getInstance()->translate('...Invoke {{type}} hook for {{entry}}...', array('type' => $file, 'entry' => addslashes($this->getActualName()) . $suffix))); // Run hook function $hookResult = $function($arg); // Hook has been invoked - return true $result = true; // Save result of hook function \XLite\Upgrade\Cell::getInstance()->addPassedHook($file, intval($hookResult)); $this->addInfoMessage('Update hook is run: {{type}}:{{file}}', true, array('type' => $this->getActualName(), 'file' => $file . $suffix)); if (0 < intval($hookResult)) { \XLite\Upgrade\Cell::getInstance()->setHookRedirect(true); break; } } if ($helpers) { \XLite\Core\Database::getCacheDriver()->deleteAll(); } } return $result; }
/** * Constructor * * @param string $namespace Namesapce * @param \XLite\Core\Cache $driver Driver OPTIONAL * * @return void */ public function __construct($namespace, \XLite\Core\Cache $driver = null) { $this->namespace = $namespace; $this->driver = $driver ?: \XLite\Core\Database::getCacheDriver(); }