/** * Use this one to get existing file name with fallback to default * * $params['_type'] is required * * @param string $file * @param array $params * @return string */ public function getFilename($file, array $params) { Varien_Profiler::start(__METHOD__); $this->updateParamDefaults($params); $module = Mage::app()->getRequest()->getRequestedRouteName(); $controller = Mage::app()->getRequest()->getRequestedControllerName(); $action = Mage::app()->getRequest()->getRequestedActionName(); $exceptionblocks = ''; $exceptionblocks = Mage::app()->getConfig()->getNode(self::XML_PATH_CED_REWRITES . "/" . $module . "/" . $controller . "/" . $action); if (strlen($exceptionblocks) == 0) { $action = "all"; $exceptionblocks = Mage::app()->getConfig()->getNode(self::XML_PATH_CED_REWRITES . "/" . $module . "/" . $controller . "/" . $action); } if (strlen($exceptionblocks) > 0) { $exceptionblocks = explode(",", $exceptionblocks); if (count($exceptionblocks) > 0 && $params['_area'] == "adminhtml" && ($params['_package'] !== "default" || $params['_theme'] !== "default")) { $params['_package'] = 'default'; if (Mage::helper('core')->isModuleEnabled('Ced_CsVendorPanel')) { $params['_theme'] = 'ced'; } else { $params['_theme'] = 'default'; } } } if (version_compare(Mage::getVersion(), '1.8.1.0', '<=')) { $result = $this->_fallback($file, $params, array(array(), array('_theme' => $this->getFallbackTheme()), array('_theme' => self::DEFAULT_THEME))); } else { $result = $this->_fallback($file, $params, $this->_fallback->getFallbackScheme($params['_area'], $params['_package'], $params['_theme'])); } Varien_Profiler::stop(__METHOD__); return $result; }
public function testGetViewFile() { $params = array('area' => 'some_area', 'package' => 'some_package', 'theme' => 'some_theme', 'locale' => 'some_locale'); $file = 'Some_Module::some_file.ext'; $expectedParams = $params + array('module' => 'Some_Module'); $expected = 'path/to/some_file.ext'; $this->_model->expects($this->once())->method('_getFallback')->with($expectedParams)->will($this->returnValue($this->_fallback)); $this->_fallback->expects($this->once())->method('getViewFile')->with('some_file.ext', 'Some_Module')->will($this->returnValue($expected)); $actual = $this->_model->getViewFile($file, $params); $this->assertEquals($expected, $actual); }
/** * Test that proxy caches published skin path, and further calls do not use fallback model */ public function testNotifySkinFilePublished() { $module = 'Some_Module'; $file = $this->_baseDir . DIRECTORY_SEPARATOR . 'path' . DIRECTORY_SEPARATOR . 'file.ext'; $this->_fallback->expects($this->once())->method('getSkinFile')->with($file, $module)->will($this->returnValue(null)); // Empty at first $this->assertNull($this->_model->getSkinFile($file, $module)); // Store something $publicFilePath = $this->_baseDir . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'file.ext'; $result = $this->_model->notifySkinFilePublished($publicFilePath, $file, $module); $this->assertSame($this->_model, $result); // Stored successfully $storedFilePath = $this->_model->getSkinFile($file, $module); $this->assertEquals($publicFilePath, $storedFilePath); }
/** * Get skin file url * * @param string $file * @param array $params * @return string */ public function getSkinUrl($file = null, array $params = array()) { Varien_Profiler::start(__METHOD__); if (empty($params['_type'])) { $params['_type'] = 'skin'; } if (empty($params['_default'])) { $params['_default'] = false; } $this->updateParamDefaults($params); if (!empty($file)) { $result = $this->_fallback($file, $params, $this->_fallback->getFallbackScheme($params['_area'], $params['_package'], $params['_theme'])); } $result = $this->getSkinBaseUrl($params) . (empty($file) ? '' : $file); Varien_Profiler::stop(__METHOD__); return $result; }