Mage_Api_Model_Config Class Reference

Inheritance diagram for Mage_Api_Model_Config:

Varien_Simplexml_Config

List of all members.

Public Member Functions

 __construct ($sourceData=null)
 getAdapters ()
 getActiveAdapters ()
 getHandlers ()
 getResources ()
 getResourcesAlias ()
 loadAclResources (Mage_Api_Model_Acl $acl, $resource=null, $parentName=null)
 getAclAssert ($name='')
 getAclPrivilegeSet ($name='')
 getFaults ($resourceName=null)
 getCache ()

Public Attributes

const CACHE_TAG = 'config_api'

Protected Member Functions

 _construct ()
 _loadCache ($id)
 _saveCache ($data, $id, $tags=array(), $lifetime=false)
 _removeCache ($id)


Detailed Description

Definition at line 34 of file Config.php.


Constructor & Destructor Documentation

__construct ( sourceData = null  ) 

Constructor

See also:
Varien_Simplexml_Config

Reimplemented from Varien_Simplexml_Config.

Definition at line 43 of file Config.php.

00044     {
00045         $this->setCacheId('config_api');
00046         $this->setCacheTags(array(self::CACHE_TAG));
00047 
00048         parent::__construct($sourceData);
00049         $this->_construct();
00050     }


Member Function Documentation

_construct (  )  [protected]

Init configuration for webservices api

Returns:
Mage_Api_Model_Config

Definition at line 57 of file Config.php.

00058     {
00059         if (Mage::app()->useCache('config_api')) {
00060             if ($this->loadCache()) {
00061                 return $this;
00062             }
00063         }
00064 
00065         $config = Mage::getConfig()->loadModulesConfiguration('api.xml');
00066         $this->setXml($config->getNode('api'));
00067 
00068         if (Mage::app()->useCache('config_api')) {
00069             $this->saveCache();
00070         }
00071         return $this;
00072     }

_loadCache ( id  )  [protected]

Enter description here...

Parameters:
string $id
Returns:
boolean

Reimplemented from Varien_Simplexml_Config.

Definition at line 259 of file Config.php.

00260     {
00261         return Mage::app()->loadCache($id);
00262     }

_removeCache ( id  )  [protected]

Enter description here...

Todo:
check this, as there are no caches that implement remove() method
Parameters:
string $id
Returns:
unknown

Reimplemented from Varien_Simplexml_Config.

Definition at line 269 of file Config.php.

00270     {
00271         return Mage::app()->removeCache($id);
00272     }

_saveCache ( data,
id,
tags = array(),
lifetime = false 
) [protected]

Enter description here...

Parameters:
string $data
string $id
array $tags
int|boolean $lifetime
Returns:
boolean

Reimplemented from Varien_Simplexml_Config.

Definition at line 264 of file Config.php.

00265     {
00266         return Mage::app()->saveCache($data, $id, $tags, $lifetime);
00267     }

getAclAssert ( name = ''  ) 

Get acl assert config

Parameters:
string $name
Returns:
Mage_Core_Model_Config_Element|boolean

Definition at line 188 of file Config.php.

00189     {
00190         $asserts = $this->getNode('acl/asserts');
00191         if (''===$name) {
00192             return $asserts;
00193         }
00194 
00195         if (isset($asserts->$name)) {
00196             return $asserts->$name;
00197         }
00198 
00199         return false;
00200     }

getAclPrivilegeSet ( name = ''  ) 

Retrieve privilege set by name

Parameters:
string $name
Returns:
Mage_Core_Model_Config_Element|boolean

Definition at line 208 of file Config.php.

00209     {
00210         $sets = $this->getNode('acl/privilegeSets');
00211         if (''===$name) {
00212             return $sets;
00213         }
00214 
00215         if (isset($sets->$name)) {
00216             return $sets->$name;
00217         }
00218 
00219         return false;
00220     }

getActiveAdapters (  ) 

Retrieve active adapters

Returns:
array

Definition at line 97 of file Config.php.

00098     {
00099         $adapters = array();
00100         foreach ($this->getAdapters() as $adapterName => $adapter) {
00101             if (!isset($adapter->active) || $adapter->active == '0') {
00102                 continue;
00103             }
00104 
00105             if (isset($adapter->required) && isset($adapter->required->extensions)) {
00106                 foreach ($adapter->required->extensions->children() as $extension=>$data) {
00107                     if (!extension_loaded($extension)) {
00108                         continue;
00109                     }
00110                 }
00111             }
00112 
00113             $adapters[$adapterName] = $adapter;
00114         }
00115 
00116         return $adapters;
00117     }

getAdapters (  ) 

Retrieve all adapters

Returns:
array

Definition at line 79 of file Config.php.

00080     {
00081         $adapters = array();
00082         foreach ($this->getNode('adapters')->children() as $adapterName => $adapter) {
00083             /* @var $adapter Varien_SimpleXml_Element */
00084             if (isset($adapter->use)) {
00085                 $adapter = $this->getNode('adapters/' . (string) $adapter->use);
00086             }
00087             $adapters[$adapterName] = $adapter;
00088         }
00089         return $adapters;
00090     }

getCache (  ) 

Retrieve cache object

Returns:
Zend_Cache_Frontend_File

Reimplemented from Varien_Simplexml_Config.

Definition at line 254 of file Config.php.

00255     {
00256         return Mage::app()->getCache();
00257     }

getFaults ( resourceName = null  ) 

Definition at line 222 of file Config.php.

00223     {
00224         if (is_null($resourceName)
00225             || !isset($this->getResources()->$resourceName)
00226             || !isset($this->getResources()->$resourceName->faults)) {
00227             $faultsNode = $this->getNode('faults');
00228         } else {
00229             $faultsNode = $this->getResources()->$resourceName->faults;
00230         }
00231         /* @var $faultsNode Varien_Simplexml_Element */
00232 
00233         $translateModule = 'api';
00234         if (isset($faultsNode['module'])) {
00235            $translateModule = (string) $faultsNode['module'];
00236         }
00237 
00238         $faults = array();
00239         foreach ($faultsNode->children() as $faultName => $fault) {
00240             $faults[$faultName] = array(
00241                 'code'    => (string) $fault->code,
00242                 'message' => Mage::helper($translateModule)->__((string)$fault->message)
00243             );
00244         }
00245 
00246         return $faults;
00247     }

getHandlers (  ) 

Retrieve handlers

Returns:
Varien_Simplexml_Element

Definition at line 124 of file Config.php.

00125     {
00126         return $this->getNode('handlers')->children();
00127     }

getResources (  ) 

Retrieve resources

Returns:
Varien_Simplexml_Element

Definition at line 134 of file Config.php.

00135     {
00136         return $this->getNode('resources')->children();
00137     }

getResourcesAlias (  ) 

Retrieve resources alias

Returns:
Varien_Simplexml_Element

Definition at line 144 of file Config.php.

00145     {
00146         return $this->getNode('resources_alias')->children();
00147     }

loadAclResources ( Mage_Api_Model_Acl acl,
resource = null,
parentName = null 
)

Load Acl resources from config

Parameters:
Mage_Api_Model_Acl $acl
Mage_Core_Model_Config_Element $resource
string $parentName
Returns:
Mage_Api_Model_Config

Definition at line 158 of file Config.php.

00159     {
00160         $resourceName = null;
00161         if (is_null($resource)) {
00162             $resource = $this->getNode('acl/resources');
00163         } else {
00164             $resourceName = (is_null($parentName) ? '' : $parentName.'/').$resource->getName();
00165             $acl->add(Mage::getModel('api/acl_resource', $resourceName), $parentName);
00166         }
00167 
00168         $children = $resource->children();
00169 
00170         if (empty($children)) {
00171             return $this;
00172         }
00173 
00174         foreach ($children as $res) {
00175             if ($res->getName() != 'title' && $res->getName() != 'sort_order') {
00176                 $this->loadAclResources($acl, $res, $resourceName);
00177             }
00178         }
00179         return $this;
00180     }


Member Data Documentation

const CACHE_TAG = 'config_api'

Definition at line 36 of file Config.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:32 2009 for Magento by  doxygen 1.5.8