Public Member Functions | |
getResource () | |
load () | |
save () |
Definition at line 35 of file Io.php.
getResource | ( | ) |
Retrieve resource generic method
Reimplemented from Varien_Convert_Adapter_Abstract.
Definition at line 37 of file Io.php.
00038 { 00039 if (!$this->_resource) { 00040 $type = $this->getVar('type', 'file'); 00041 $className = 'Varien_Io_'.ucwords($type); 00042 $this->_resource = new $className(); 00043 try { 00044 $this->_resource->open($this->getVars()); 00045 } catch (Exception $e) { 00046 $this->addException('Error occured during file opening: '.$e->getMessage(), Varien_Convert_Exception::FATAL); 00047 } 00048 } 00049 return $this->_resource; 00050 }
load | ( | ) |
Implements Varien_Convert_Adapter_Interface.
Definition at line 52 of file Io.php.
00053 { 00054 $data = $this->getResource()->read($this->getVar('filename')); 00055 $filename = $this->getResource()->pwd().'/'.$this->getVar('filename'); 00056 if (false===$data) { 00057 $this->addException('Could not load file: '.$filename, Varien_Convert_Exception::FATAL); 00058 } else { 00059 $this->addException('Loaded successfully: '.$filename.' ['.strlen($data).' byte(s)]'); 00060 } 00061 $this->setData($data); 00062 return $this; 00063 }
save | ( | ) |
Implements Varien_Convert_Adapter_Interface.
Definition at line 65 of file Io.php.
00066 { 00067 $data = $this->getData(); 00068 $filename = $this->getResource()->pwd().'/'.$this->getVar('filename'); 00069 $result = $this->getResource()->write($filename, $data, 0777); 00070 if (false===$result) { 00071 $this->addException('Could not save file: '.$filename, Varien_Convert_Exception::FATAL); 00072 } else { 00073 $text = 'Saved successfully: '.$filename.' ['.strlen($data).' byte(s)]'; 00074 if ($this->getVar('link')) { 00075 $text .= ' <a href="'.$this->getVar('link').'" target="_blank">Link</a>'; 00076 } 00077 $this->addException($text); 00078 } 00079 return $this; 00080 }