/** * Reader object initialization * * @return Magento_Acl_Config_Reader */ protected function _getReader() { if (null === $this->_reader) { $aclResourceFiles = $this->_getAclResourceFiles(); $this->_reader = $this->_config->getModelInstance('Magento_Acl_Config_Reader', $aclResourceFiles); } return $this->_reader; }
/** * Get argument handler factory by given type * @param string $type * @return Mage_Core_Model_Layout_Argument_HandlerFactoryInterface * @throws InvalidArgumentException */ public function getArgumentHandlerFactoryByType($type) { if (false == is_string($type)) { throw new InvalidArgumentException('Passed invalid argument handler type'); } if (!isset($this->_handlerFactories[$type])) { throw new InvalidArgumentException('Argument handler ' . $type . ' is not exists'); } /** @var $handlerFactory Mage_Core_Model_Layout_Argument_HandlerFactoryInterface */ $handlerFactory = $this->_objectFactory->getModelInstance($this->_handlerFactories[$type]); return $handlerFactory; }
/** * Apply all updater to value * * @param mixed $value * @param array $updaters * @throws InvalidArgumentException * @return mixed */ public function applyUpdaters($value, array $updaters = array()) { foreach ($updaters as $updater) { /** @var Mage_Core_Model_Layout_Argument_UpdaterInterface $updaterInstance */ $updaterInstance = $this->_objectFactory->getModelInstance($updater); if (false === $updaterInstance instanceof Mage_Core_Model_Layout_Argument_UpdaterInterface) { throw new InvalidArgumentException($updater . ' should implement Mage_Core_Model_Layout_Argument_UpdaterInterface'); } $value = $updaterInstance->update($value); } return $value; }
/** * Build Access Control List * * @return Magento_Acl * @throws LogicException */ public function getAcl() { if (!$this->_acl) { try { $acl = $this->_objectFactory->getModelInstance('Magento_Acl'); $this->_objectFactory->getModelInstance($this->_getLoaderClass('resource'))->populateAcl($acl); $this->_objectFactory->getModelInstance($this->_getLoaderClass('role'))->populateAcl($acl); $this->_objectFactory->getModelInstance($this->_getLoaderClass('rule'))->populateAcl($acl); $this->_acl = $acl; } catch (Exception $e) { throw new LogicException('Could not create acl object: ' . $e->getMessage()); } } return $this->_acl; }
/** * Add list of nodes and their children to acl * * @param Magento_Acl $acl * @param DOMNodeList $resources * @param Magento_Acl_Resource $parent */ protected function _addResourceTree(Magento_Acl $acl, DOMNodeList $resources, Magento_Acl_Resource $parent = null) { /** @var $resourceConfig DOMElement */ foreach ($resources as $resourceConfig) { if (!$resourceConfig instanceof DOMElement) { continue; } /** @var $resource Magento_Acl_Resource */ $resource = $this->_objectFactory->getModelInstance('Magento_Acl_Resource', $resourceConfig->getAttribute('id')); $acl->addResource($resource, $parent); if ($resourceConfig->hasChildNodes()) { $this->_addResourceTree($acl, $resourceConfig->childNodes, $resource); } } }
/** * Load system configuration * * @return Mage_Backend_Model_Config_Structure */ public function getConfiguration() { if ($this->_cache->canUse('config')) { $cache = $this->_cache->load(self::CACHE_SYSTEM_CONFIGURATION_STRUCTURE); if ($cache) { return unserialize($cache); } } $fileNames = $this->_appConfig->getModuleConfigurationFiles('adminhtml' . DIRECTORY_SEPARATOR . 'system.xml'); $config = $this->_appConfig->getModelInstance('Mage_Backend_Model_Config_Structure', array('sourceFiles' => $fileNames)); if ($this->_cache->canUse('config')) { $this->_cache->save(serialize($config), self::CACHE_SYSTEM_CONFIGURATION_STRUCTURE, array(Mage_Core_Model_Config::CACHE_TAG)); } return $config; }
/** * Get argument updater instance * * @return Mage_Core_Model_Layout_Argument_Updater */ protected function _getArgumentUpdater() { if (null === $this->_argumentUpdater) { $this->_argumentUpdater = $this->_objectFactory->getModelInstance('Mage_Core_Model_Layout_Argument_Updater', array('objectFactory' => $this->_objectFactory)); } return $this->_argumentUpdater; }
/** * Get Captcha * * @param string $formId * @return Mage_Captcha_Model_Interface */ public function getCaptcha($formId) { if (!array_key_exists($formId, $this->_captcha)) { $type = ucfirst($this->getConfigNode('type')); if (!$type) { $type = self::DEFAULT_CAPTCHA_TYPE; } $this->_captcha[$formId] = $this->_config->getModelInstance('Mage_Captcha_Model_' . $type, array('params' => array('formId' => $formId, 'helper' => $this))); } return $this->_captcha[$formId]; }
/** * @return DOMDocument */ protected function _getDom() { $mergedConfigXml = $this->_loadCache(); if ($mergedConfigXml) { $mergedConfig = new DOMDocument(); $mergedConfig->loadXML($mergedConfigXml); } else { $fileList = $this->getMenuConfigurationFiles(); $mergedConfig = $this->_appConfig->getModelInstance('Mage_Backend_Model_Menu_Config_Menu', $fileList)->getMergedConfig(); $this->_saveCache($mergedConfig->saveXML()); } return $mergedConfig; }
/** * Return formatted config data for specified path prefix * * @param string $path Config path prefix * @param bool $full Simple config structure or not * @return array */ protected function _getPathConfig($path, $full = true) { $configDataCollection = $this->_objectFactory->getModelInstance('Mage_Core_Model_Config_Data')->getCollection()->addScopeFilter($this->getScope(), $this->getScopeId(), $path); $config = array(); foreach ($configDataCollection as $data) { if ($full) { $config[$data->getPath()] = array('path' => $data->getPath(), 'value' => $data->getValue(), 'config_id' => $data->getConfigId()); } else { $config[$data->getPath()] = $data->getValue(); } } return $config; }
/** * Create menu item from array * * @param array $data * @return Mage_Backend_Model_Menu_Item */ public function createFromArray(array $data = array()) { $module = 'Mage_Backend_Helper_Data'; if (isset($data['module'])) { $module = $data['module']; } $data['module'] = isset($this->_helpers[$module]) ? $this->_helpers[$module] : Mage::helper($module); $data['acl'] = $this->_acl; $data['appConfig'] = $this->_appConfig; $data['storeConfig'] = $this->_storeConfig; $data['menuFactory'] = $this->_menuFactory; $data['urlModel'] = $this->_urlModel; $data['validator'] = $this->_validator; return $this->_objectFactory->getModelInstance('Mage_Backend_Model_Menu_Item', $data); }
public function getModelInstance($modelClass = '', $constructArguments = array()) { if ($classObj = $this->modelMocks[$modelClass]) { return clone $classObj; } $modelName = $this->getModelClassName($modelClass); if (!$this->getDisableDoubles()) { $mockClassName = str_replace('_Model_', '_Test_Double_Model_', $modelName); if (class_exists($mockClassName)) { $obj = new $mockClassName($constructArguments); return $obj; } } if ($modelName == 'Mage_Core_Model_Resource') { $obj = new Codex_Xtest_Model_Core_Resource($constructArguments); return $obj; } return parent::getModelInstance($modelClass, $constructArguments); }
/** * Get menu filter iterator * * @param Mage_Backend_Model_Menu $menu menu model * @return Mage_Backend_Model_Menu_Filter_Iterator */ protected function _getMenuIterator(Mage_Backend_Model_Menu $menu) { return $this->_objectFactory->getModelInstance('Mage_Backend_Model_Menu_Filter_Iterator', $menu->getIterator()); }
/** * Overriden for test case model instance creation mocking * * (non-PHPdoc) * @see Mage_Core_Model_Config::getModelInstance() */ public function getModelInstance($modelClass = '', $constructArguments = array()) { if (!isset($this->_replaceInstanceCreation['model'][$modelClass])) { return parent::getModelInstance($modelClass, $constructArguments); } return $this->_replaceInstanceCreation['model'][$modelClass]; }
public function create() { return $this->_objectFactory->getModelInstance('Mage_Core_Model_Resource_Transaction'); }
public function testGetModelInstance() { $this->assertInstanceOf('Mage_Core_Model_Config', $this->_model->getModelInstance('Mage_Core_Model_Config')); }