Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FileAbstract.php
Go to the documentation of this file.
1 <?php
22 #require_once "Zend/Config/Writer.php";
23 
34 {
40  protected $_filename = null;
41 
47  protected $_exclusiveLock = false;
48 
55  public function setFilename($filename)
56  {
57  $this->_filename = $filename;
58 
59  return $this;
60  }
61 
68  public function setExclusiveLock($exclusiveLock)
69  {
70  $this->_exclusiveLock = $exclusiveLock;
71 
72  return $this;
73  }
74 
83  public function write($filename = null, Zend_Config $config = null, $exclusiveLock = null)
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  }
122 
130  public function render()
131  {
132  return "";
133  }
134 }
$config
Definition: fraud_order.php:17
write($filename=null, Zend_Config $config=null, $exclusiveLock=null)
setConfig(Zend_Config $config)
Definition: Writer.php:66