当前位置: 首页>>代码示例>>PHP>>正文


PHP Axis::cache方法代码示例

本文整理汇总了PHP中Axis::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP Axis::cache方法的具体用法?PHP Axis::cache怎么用?PHP Axis::cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Axis的用法示例。


在下文中一共展示了Axis::cache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMethodNames

 /**
  * Retrieve the list of shipping methods of installed shipping modules
  *
  * @static
  * @return array
  */
 public static function getMethodNames()
 {
     if ($methods = Axis::cache()->load('shipping_methods_list')) {
         return $methods;
     }
     $prefix = 'Shipping';
     $modules = Axis::app()->getModules();
     $methods = array();
     foreach ($modules as $code => $path) {
         list($namespace, $moduleName) = explode('_', $code);
         if (substr($moduleName, 0, strlen($prefix)) != $prefix) {
             continue;
         }
         $dir = opendir($path . '/Model');
         while ($fname = readdir($dir)) {
             if (!is_file("{$path}/Model/{$fname}")) {
                 continue;
             }
             list($methodName, $ext) = explode('.', $fname, 2);
             if ($ext != 'php') {
                 continue;
             }
             $methods[$code . '/' . $methodName] = substr($moduleName, strlen($prefix)) . '_' . $methodName;
         }
         closedir($dir);
     }
     Axis::cache()->save($methods, 'shipping_methods_list', array('modules'));
     return $methods;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:35,代码来源:Shipping.php

示例2: getList

 /**
  * Retrieve the list of all boxes, including active cms boxes
  *
  * @param bool $includeCms
  * @return array
  */
 public function getList($includeCms = true)
 {
     $modules = Axis::single('core/module')->getList();
     if (!($boxes = Axis::cache()->load('boxes_list'))) {
         $boxes = array();
         foreach ($modules as $moduleCode => $values) {
             list($namespace, $module) = explode('_', $moduleCode, 2);
             $path = Axis::config()->system->path . '/app/code/' . $namespace . '/' . $module . '/Box';
             if (!is_readable($path)) {
                 continue;
             }
             $dir = opendir($path);
             while ($file = readdir($dir)) {
                 if (!is_readable($path . '/' . $file) || !is_file($path . '/' . $file)) {
                     continue;
                 }
                 $box = substr($file, 0, strpos($file, '.'));
                 if (in_array($box, array('Abstract', 'Block'))) {
                     continue;
                 }
                 $boxes[] = ucwords($namespace . '_' . $module . '_' . $box);
             }
         }
         Axis::cache()->save($boxes, 'boxes_list', array('modules'));
     }
     /* this part is not needed to be cached */
     if ($includeCms && in_array('Axis_Cms', array_keys($modules))) {
         $cmsBoxes = Axis::model('cms/block')->select('*')->where('is_active = 1')->fetchAll();
         foreach ($cmsBoxes as $box) {
             $boxes[] = 'Axis_Cms_Block_' . $box['name'];
         }
     }
     sort($boxes);
     return $boxes;
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:41,代码来源:Box.php

示例3: __call

 /**
  *
  * @param string $methodName
  * @param array $arguments
  * @return mixed
  */
 public function __call($methodName, $arguments)
 {
     $cacheBool1 = $this->_cacheByDefault;
     $cacheBool2 = in_array($methodName, $this->_cachableMethods);
     $cacheBool3 = in_array($methodName, $this->_nonCachedMethods);
     $cache = ($cacheBool1 || $cacheBool2) && !$cacheBool3;
     $box = $this->_getBox();
     if (!$cache) {
         // We do not have not cache
         return call_user_func_array(array($box, $methodName), $arguments);
     }
     /** Get cache instance */
     $cache = Axis::cache();
     $id = $this->_makeId($methodName, $arguments);
     if ($cache->test($id)) {
         // A cache is available
         $result = $cache->load($id);
         $output = $result[0];
         $return = $result[1];
         $box->setFromArray($result[2]);
         //<---
     } else {
         // A cache is not available
         ob_start();
         ob_implicit_flush(false);
         $return = call_user_func_array(array($box, $methodName), $arguments);
         $output = ob_get_contents();
         ob_end_clean();
         $data = array($output, $return, $box->getCacheData());
         //<---
         $cache->save($data, $id, array_merge($this->_tags, array('boxes')), $this->_specificLifetime, $this->_priority);
     }
     echo $output;
     return $return;
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:41,代码来源:Box.php

示例4: getFieldsByKey

 /**
  *
  * @param string $key
  * @param int $siteId[optional]
  * @return array
  */
 public function getFieldsByKey($key, $siteId = 1)
 {
     $hasCache = (bool) Zend_Registry::isRegistered('cache') ? Axis::cache() instanceof Zend_Cache_Core : false;
     if (!$hasCache || !($fields = Axis::cache()->load("config_{$key}_site_{$siteId}"))) {
         $fields = $this->select(array('path', 'config_type', 'model'))->joinInner('core_config_value', 'ccv.config_field_id = ccf.id', 'value')->where('ccf.path LIKE ?', $key . '/%')->where('ccv.site_id IN(?)', array(0, $siteId))->fetchAssoc();
         if ($hasCache) {
             Axis::cache()->save($fields, "config_{$key}_site_{$siteId}", array('config'));
         }
     }
     return $fields;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:17,代码来源:Field.php

示例5: render

 public function render()
 {
     if (!($navigationHtml = Axis::cache()->load($this->getCacheKey()))) {
         $this->_items = array();
         // forward fix
         Axis::dispatch('admin_box_navigation_prepare', $this);
         $this->menu = new Zend_Navigation($this->_items);
         $navigationHtml = parent::render();
         Axis::cache()->save($navigationHtml, $this->getCacheKey(), array('modules'));
     }
     return $navigationHtml;
 }
开发者ID:rguedes,项目名称:axiscommerce,代码行数:12,代码来源:Navigation.php

示例6: _initCache

 protected function _initCache()
 {
     $frontendOptions = array('lifetime' => 864000, 'automatic_serialization' => true);
     $cacheDir = AXIS_ROOT . '/var/cache';
     if (!is_readable($cacheDir)) {
         mkdir($cacheDir, 0777);
     } elseif (!is_writable($cacheDir)) {
         chmod($cacheDir, 0777);
     }
     if (!is_writable($cacheDir)) {
         echo "Cache directory should be writable. Run 'chmod -R 0777 AXIS_ROOT/var'";
         exit;
     }
     $backendOptions = array('cache_dir' => $cacheDir, 'hashed_directory_level' => 1, 'file_name_prefix' => 'axis_cache', 'hashed_directory_umask' => 0777);
     Zend_Registry::set('cache', Zend_Cache::factory('Core', 'Zend_Cache_Backend_File', $frontendOptions, $backendOptions, false, true));
     return Axis::cache();
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:17,代码来源:Install.php

示例7: __construct

 /**
  * Current module
  *
  * @param  array $options
  */
 public function __construct($options = array())
 {
     if (Axis_Area::isInstaller() || !Axis::config('core/translation/autodetect')) {
         self::setCache(Axis::cache());
     }
     $this->_module = $options['module'];
     $locale = $this->getLocale();
     $filename = $this->_getFileName($locale);
     if (!is_readable($filename)) {
         $locale = Axis_Locale::DEFAULT_LOCALE;
         $filename = $this->_getFileName($locale);
     }
     // custom modules can be without translation for default locale
     if (!is_readable($filename)) {
         $filename = $this->_getSafeFileName();
     }
     parent::__construct(array('adapter' => self::AN_CSV, 'content' => $filename, 'locale' => $locale, 'delimiter' => ','));
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:23,代码来源:Translate.php

示例8: __construct

 /**
  * Reads the event config from modules configuration
  * and cache it
  */
 private function __construct()
 {
     if ($result = Axis::cache()->load('module_event_list')) {
         $this->_events = $result;
     } else {
         foreach (Axis::single('core/module')->getConfig() as $code => $config) {
             if (isset($config['events']) && is_array($config['events'])) {
                 foreach ($config['events'] as $eventName => $action) {
                     foreach ($action as $key => $value) {
                         if (!is_array($value) || !count($value)) {
                             continue;
                         }
                         $this->_events[$eventName][] = $value;
                     }
                 }
             }
         }
         Axis::cache()->save($this->_events, 'module_event_list', array('modules'));
     }
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:24,代码来源:Observer.php

示例9: _load

 private function _load($key, $siteId, $default)
 {
     if (null === $siteId) {
         $siteId = Axis::getSiteId();
     }
     $hasCache = (bool) Zend_Registry::isRegistered('cache') ? Axis::cache() instanceof Zend_Cache_Core : false;
     if (!$hasCache || !($dataset = Axis::cache()->load("config_{$key}_site_{$siteId}"))) {
         $dataset = Axis::single('core/config_field')->select(array('path', 'model'))->joinInner('core_config_value', 'ccv.config_field_id = ccf.id', 'value')->where('ccf.path LIKE ?', $key . '/%')->where('ccv.site_id IN(?)', array(0, $siteId))->fetchAssoc();
         if ($hasCache) {
             Axis::cache()->save($dataset, "config_{$key}_site_{$siteId}", array('config'));
         }
     }
     if (!sizeof($dataset)) {
         $this->_data[$key] = $default;
         return;
     }
     $values = array();
     foreach ($dataset as $path => $data) {
         $parts = explode('/', $path);
         $value = $data['value'];
         if (!empty($data['model'])) {
             $class = Axis::getClass($data['model']);
             if (class_exists($class) && in_array('Axis_Config_Option_Encodable_Interface', class_implements($class))) {
                 $value = Axis::single($data['model'])->decode($value);
             }
         }
         $values[$parts[0]][$parts[1]][$parts[2]] = $value;
     }
     foreach ($values as $key => $value) {
         if (is_array($value)) {
             $this->_data[$key] = new self($value, $this->_allowModifications);
         } else {
             $this->_data[$key] = $value;
         }
     }
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:36,代码来源:Config.php

示例10: getMethodNames

 /**
  * Retrieve the list of paymetns methods of installed payment modules
  * @return array
  */
 public static function getMethodNames()
 {
     if ($methods = Axis::cache()->load('payment_methods_list')) {
         return $methods;
     }
     $prefix = 'Payment';
     $modules = Axis::app()->getModules();
     $methods = array();
     foreach ($modules as $code => $path) {
         list($namespace, $moduleName) = explode('_', $code);
         if (substr($moduleName, 0, strlen($prefix)) != $prefix) {
             continue;
         }
         if (!is_dir($path . '/Model')) {
             continue;
         }
         $dir = opendir($path . '/Model');
         while ($fname = readdir($dir)) {
             if (!is_file("{$path}/Model/{$fname}")) {
                 continue;
             }
             list($methodName, $ext) = explode('.', $fname, 2);
             if ($ext != 'php' || $methodName == 'Abstract') {
                 continue;
             }
             $className = $code . '_Model_' . $methodName;
             if (!in_array('Axis_Method_Payment_Model_Abstract', class_parents($className))) {
                 continue;
             }
             $methods[$code . '/' . $methodName] = substr($moduleName, strlen($prefix)) . '_' . $methodName;
         }
         closedir($dir);
     }
     Axis::cache()->save($methods, 'payment_methods_list', array('modules'));
     return $methods;
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:40,代码来源:Payment.php

示例11: _getMethodNames

 /**
  * Return list of order totals
  *
  * @return array
  */
 protected function _getMethodNames()
 {
     if ($methods = Axis::cache()->load('order_total_methods')) {
         return $methods;
     }
     $dirPath = realpath(Axis::config()->system->path . '/app/code/Axis/Checkout/Model/Total');
     $methods = array();
     $skip = array('Abstract');
     $dp = opendir($dirPath);
     while ($fname = readdir($dp)) {
         if (!is_file("{$dirPath}/{$fname}")) {
             continue;
         }
         list($name, $ext) = explode('.', $fname, 2);
         if (in_array($name, $skip) || $ext != 'php') {
             continue;
         }
         $methods[] = $name;
     }
     closedir($dp);
     Axis::cache()->save($methods, 'order_total_methods', array('modules'));
     return $methods;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:28,代码来源:Total.php

示例12: getCurrency

 /**
  * Return Zend_Currency object
  *
  * @param string $code
  * @return Zend_Currency
  */
 public function getCurrency($code = '')
 {
     if (empty($code)) {
         $code = $this->getCode();
     }
     if (!isset($this->_currency[$code])) {
         $options = $this->_getCurrencyOptions($code);
         Zend_Currency::setCache(Axis::cache());
         try {
             $currency = new Zend_Currency($options['currency'], $options['format'] === null ? Axis_Locale::getLocale() : $options['format']);
         } catch (Zend_Currency_Exception $e) {
             Axis::message()->addError($e->getMessage() . ": " . Axis::translate('locale')->__("Try to change the format of this currency to English (United States) - en_US"));
             $options = $this->_getSystemSafeCurrencyOptions();
             $currency = new Zend_Currency($options['currency'], $options['format']);
         }
         $currency->setFormat($options);
         $this->_currency[$code] = $currency;
     }
     return $this->_currency[$code];
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:26,代码来源:Currency.php

示例13: __construct

 public function __construct()
 {
     if ($this->_resources = Axis::cache()->load('axis_acl_resources')) {
         return;
     }
     foreach (Axis::app()->getModules() as $moduleName => $path) {
         if ('Axis_Admin' === $moduleName) {
             $path = $path . '/controllers';
         } else {
             $path = $path . '/controllers/Admin';
         }
         if (!is_dir($path)) {
             continue;
         }
         foreach ($this->_scanDirectory($path) as $file) {
             if (strstr($file, "Controller.php") == false) {
                 continue;
             }
             include_once $file;
         }
     }
     $resource = 'admin';
     $resources = array($resource);
     $camelCaseToDash = new Zend_Filter_Word_CamelCaseToDash();
     foreach (get_declared_classes() as $class) {
         if (!is_subclass_of($class, 'Axis_Admin_Controller_Back')) {
             continue;
         }
         list($module, $controller) = explode('Admin_', $class, 2);
         $module = rtrim($module, '_');
         if (empty($module)) {
             $module = 'Axis_Core';
         } elseif ('Axis' === $module) {
             $module = 'Axis_Admin';
         }
         $module = strtolower($camelCaseToDash->filter($module));
         list($namespace, $module) = explode('_', $module, 2);
         $resource .= '/' . $namespace;
         $resources[$resource] = $resource;
         $resource .= '/' . $module;
         $resources[$resource] = $resource;
         $controller = substr($controller, 0, strpos($controller, "Controller"));
         $controller = strtolower($camelCaseToDash->filter($controller));
         $resource .= '/' . $controller;
         $resources[$resource] = $resource;
         foreach (get_class_methods($class) as $action) {
             if (false == strstr($action, "Action")) {
                 continue;
             }
             $action = substr($action, 0, strpos($action, 'Action'));
             $action = strtolower($camelCaseToDash->filter($action));
             //                $resources[$namespace][$module][$controller][] = $action;
             $resources[$resource . '/' . $action] = $resource . '/' . $action;
         }
         $resource = 'admin';
     }
     asort($resources);
     Axis::cache()->save($resources, 'axis_acl_resources', array('modules'));
     $this->_resources = $resources;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:60,代码来源:Resource.php

示例14: getRoutes

 /**
  * Retrieve array of paths to route files
  *
  * @return array
  */
 public function getRoutes()
 {
     if (!($routes = Axis::cache()->load('routes_list'))) {
         $modules = $this->getModules();
         $routes = array();
         foreach ($modules as $moduleCode => $path) {
             if (file_exists($path . '/etc/routes.php') && is_readable($path . '/etc/routes.php')) {
                 $routes[] = $path . '/etc/routes.php';
             }
         }
         Axis::cache()->save($routes, 'routes_list', array('modules'));
     }
     return $routes;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:19,代码来源:Application.php

示例15: _initCache

 protected function _initCache()
 {
     $this->bootstrap('DbAdapter');
     //create default cache
     $cache = Axis_Core_Model_Cache::getCache();
     //create database metacache
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     //        /**
     //         * Zend_View acceleration
     //         * http://www.web-blog.org.ua/articles/uskoryaem-zend-view
     //         */
     //        $cacheDir = Axis::config()->system->path . '/var/PluginLoader/';
     //        if (!is_readable($cacheDir)) {
     //            mkdir($cacheDir, 0777);
     //        } elseif(!is_writable($cacheDir)) {
     //            chmod($cacheDir, 0777);
     //        }
     //        require_once 'Zend/Loader/PluginLoader.php';
     //        $classFileIncCache = $cacheDir . 'cache.php';
     //        if (file_exists($classFileIncCache))  {
     //            include_once $classFileIncCache;
     //        } else {
     //            file_put_contents($classFileIncCache, "<?php\n");
     //        }
     //        Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     return Axis::cache();
 }
开发者ID:baisoo,项目名称:axiscommerce,代码行数:27,代码来源:Bootstrap.php


注:本文中的Axis::cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。