Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
Zend_Config_Writer_FileAbstract Class Reference
Inheritance diagram for Zend_Config_Writer_FileAbstract:
Zend_Config_Writer Zend_Config_Writer_Ini Zend_Config_Writer_Json Zend_Config_Writer_Xml Zend_Config_Writer_Yaml

Public Member Functions

 setFilename ($filename)
 
 setExclusiveLock ($exclusiveLock)
 
 write ($filename=null, Zend_Config $config=null, $exclusiveLock=null)
 
 render ()
 
- Public Member Functions inherited from Zend_Config_Writer
 __construct (array $options=null)
 
 setConfig (Zend_Config $config)
 
 setOptions (array $options)
 
 write ()
 

Protected Attributes

 $_filename = null
 
 $_exclusiveLock = false
 
- Protected Attributes inherited from Zend_Config_Writer
 $_skipOptions
 
 $_config = null
 

Detailed Description

Definition at line 33 of file FileAbstract.php.

Member Function Documentation

◆ render()

render ( )

Render a Zend_Config into a config file string.

Since
1.10
Todo:
For 2.0 this should be redone into an abstract method.
Returns
string

Definition at line 130 of file FileAbstract.php.

131  {
132  return "";
133  }

◆ setExclusiveLock()

setExclusiveLock (   $exclusiveLock)

Set wether to exclusively lock the file or not

Parameters
boolean$exclusiveLock
Returns
Zend_Config_Writer_Array

Definition at line 68 of file FileAbstract.php.

69  {
70  $this->_exclusiveLock = $exclusiveLock;
71 
72  return $this;
73  }

◆ setFilename()

setFilename (   $filename)

Set the target filename

Parameters
string$filename
Returns
Zend_Config_Writer_Array

Definition at line 55 of file FileAbstract.php.

56  {
57  $this->_filename = $filename;
58 
59  return $this;
60  }

◆ write()

write (   $filename = null,
Zend_Config  $config = null,
  $exclusiveLock = null 
)

Write configuration to file.

Parameters
string$filename
Zend_Config$config
bool$exclusiveLock
Returns
void

Definition at line 83 of file FileAbstract.php.

84  {
85  if ($filename !== null) {
86  $this->setFilename($filename);
87  }
88 
89  if ($config !== null) {
90  $this->setConfig($config);
91  }
92 
93  if ($exclusiveLock !== null) {
94  $this->setExclusiveLock($exclusiveLock);
95  }
96 
97  if ($this->_filename === null) {
98  #require_once 'Zend/Config/Exception.php';
99  throw new Zend_Config_Exception('No filename was set');
100  }
101 
102  if ($this->_config === null) {
103  #require_once 'Zend/Config/Exception.php';
104  throw new Zend_Config_Exception('No config was set');
105  }
106 
107  $configString = $this->render();
108 
109  $flags = 0;
110 
111  if ($this->_exclusiveLock) {
112  $flags |= LOCK_EX;
113  }
114 
115  $result = @file_put_contents($this->_filename, $configString, $flags);
116 
117  if ($result === false) {
118  #require_once 'Zend/Config/Exception.php';
119  throw new Zend_Config_Exception('Could not write to file "' . $this->_filename . '"');
120  }
121  }
$config
Definition: fraud_order.php:17
setConfig(Zend_Config $config)
Definition: Writer.php:66

Field Documentation

◆ $_exclusiveLock

$_exclusiveLock = false
protected

Definition at line 47 of file FileAbstract.php.

◆ $_filename

$_filename = null
protected

Definition at line 40 of file FileAbstract.php.


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