Example #1
0
 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;
 }
Example #2
0
 /**
  * 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']);
         }
     }
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * 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
     }
 }
Example #5
0
 /**
  * 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;
     }
 }
Example #6
0
 /**
  * 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);
 }
Example #7
0
 /**
  * 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);
 }
Example #8
0
 /**
  * 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();
         }
     }
 }
Example #9
0
 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);
 }
Example #10
0
 /**
  * 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);
 }
Example #11
0
/**
 * 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();
};
Example #12
0
 /**
  * Save registry
  *
  * @param array $registry Registry
  *
  * @return void
  */
 protected function saveRegistry(array $registry)
 {
     \XLite\Core\Database::getCacheDriver()->save(static::REGISTRY_CELL, serialize($registry));
 }
Example #13
0
 /**
  * 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);
 }
Example #14
0
 /**
  * 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;
 }
Example #15
0
 /**
  * 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();
 }