writeData() public method

Stores a file in the VFS from raw data.
public writeData ( string $path, string $name, string $data, boolean $autocreate = false )
$path string The path to store the file in.
$name string The filename to use.
$data string The file data.
$autocreate boolean Automatically create directories?
Ejemplo n.º 1
0
 /**
  */
 protected function _set($key, $val, $opts)
 {
     try {
         $this->_vfs->writeData($this->_params['vfspath'], $key, $val, true);
     } catch (Horde_Vfs_Exception $e) {
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 /**
  * Stores user preferences in the backend.
  *
  * @param boolean $defaults  Whether to store the global defaults instead
  *                           of user options. Unused.
  *
  * @throws Sam_Exception
  */
 public function store($defaults = false)
 {
     /* Generate preference file. */
     $output = '# ' . _("SpamAssassin preference file generated by Sam") . ' (' . date('F j, Y, g:i a') . ")\n";
     foreach ($this->_options as $attribute => $value) {
         if (is_array($value)) {
             $output .= $this->_mapAttributeToOption($attribute) . ' ' . trim(implode(' ', $value)) . "\n";
         } else {
             $output .= $this->_mapAttributeToOption($attribute) . ' ' . trim($value) . "\n";
         }
     }
     /* Write preference file. */
     try {
         $this->_vfs->writeData(dirname($this->_params['user_prefs']), basename($this->_params['user_prefs']), $output, true);
     } catch (Horde_Vfs_Exception $e) {
         throw new Sam_Exception($e);
     }
 }