Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Persistent_Block_Form_Remember
  • Mage_Persistent_Block_Header_Additional
  • Mage_Persistent_Helper_Data
  • Mage_Persistent_Helper_Session
  • Mage_Persistent_IndexController
  • Mage_Persistent_Model_Observer
  • Mage_Persistent_Model_Observer_Session
  • Mage_Persistent_Model_Persistent_Config
  • Mage_Persistent_Model_Resource_Session
  • Mage_Persistent_Model_Session
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Persistent
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: 
 28: /**
 29:  * Persistent Config Model
 30:  *
 31:  * @category   Mage
 32:  * @package    Mage_Persistent
 33:  * @author     Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Persistent_Model_Persistent_Config
 36: {
 37:     /**
 38:      * XML config instance for Persistent mode
 39:      * @var null|Varien_Simplexml_Element
 40:      */
 41:     protected $_xmlConfig = null;
 42: 
 43:     /**
 44:      * Path to config file
 45:      *
 46:      * @var string
 47:      */
 48:     protected $_configFilePath;
 49: 
 50:     /**
 51:      * Set path to config file that should be loaded
 52:      *
 53:      * @param string $path
 54:      * @return Mage_Persistent_Model_Persistent_Config
 55:      */
 56:     public function setConfigFilePath($path)
 57:     {
 58:         $this->_configFilePath = $path;
 59:         $this->_xmlConfig = null;
 60:         return $this;
 61:     }
 62: 
 63:     /**
 64:      * Load persistent XML config
 65:      *
 66:      * @return Varien_Simplexml_Element
 67:      * @throws Mage_Core_Exception
 68:      */
 69:     public function getXmlConfig()
 70:     {
 71:         if (is_null($this->_xmlConfig)) {
 72:             $filePath = $this->_configFilePath;
 73:             if (!is_file($filePath) || !is_readable($filePath)) {
 74:                 Mage::throwException(Mage::helper('persistent')->__('Cannot load configuration from file %s.', $filePath));
 75:             }
 76:             $xml = file_get_contents($filePath);
 77:             $this->_xmlConfig = new Varien_Simplexml_Element($xml);
 78:         }
 79:         return $this->_xmlConfig;
 80:     }
 81: 
 82:     /**
 83:      * Retrieve instances that should be emulated by persistent data
 84:      *
 85:      * @return array
 86:      */
 87:     public function collectInstancesToEmulate()
 88:     {
 89:         $config = $this->getXmlConfig()->asArray();
 90:         return $config['instances'];
 91:     }
 92: 
 93:     /**
 94:      * Run all methods declared in persistent configuration
 95:      *
 96:      * @return Mage_Persistent_Model_Persistent_Config
 97:      */
 98:     public function fire()
 99:     {
100:         foreach ($this->collectInstancesToEmulate() as $type => $elements) {
101:             if (!is_array($elements)) {
102:                 continue;
103:             }
104:             foreach ($elements as $info) {
105:                 switch ($type) {
106:                     case 'blocks':
107:                         $this->fireOne($info, Mage::getSingleton('core/layout')->getBlock($info['name_in_layout']));
108:                         break;
109:                 }
110:             }
111:         }
112:         return $this;
113:     }
114: 
115:     /**
116:      * Run one method by given method info
117:      *
118:      * @param array $info
119:      * @param bool $instance
120:      * @return Mage_Persistent_Model_Persistent_Config
121:      */
122:     public function fireOne($info, $instance = false)
123:     {
124:         if (!$instance
125:             || (isset($info['block_type']) && !($instance instanceof $info['block_type']))
126:             || !isset($info['class'])
127:             || !isset($info['method'])
128:         ) {
129:             return $this;
130:         }
131:         $object     = Mage::getModel($info['class']);
132:         $method     = $info['method'];
133: 
134:         if (method_exists($object, $method)) {
135:             $object->$method($instance);
136:         } elseif (Mage::getIsDeveloperMode()) {
137:             Mage::throwException('Method "' . $method.'" is not defined in "' . get_class($object) . '"');
138:         }
139: 
140:         return $this;
141:     }
142: }
143: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0