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

Public Member Functions

 setNestSeparator ($separator)
 
 setRenderWithoutSections ($withoutSections=true)
 
 render ()
 
- Public Member Functions inherited from Zend_Config_Writer_FileAbstract
 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 Member Functions

 _addBranch (Zend_Config $config, $parents=array())
 
 _prepareValue ($value)
 
 _sortRootElements (Zend_Config $config)
 

Protected Attributes

 $_nestSeparator = '.'
 
 $_renderWithoutSections = false
 
- Protected Attributes inherited from Zend_Config_Writer_FileAbstract
 $_filename = null
 
 $_exclusiveLock = false
 
- Protected Attributes inherited from Zend_Config_Writer
 $_skipOptions
 
 $_config = null
 

Detailed Description

Definition at line 33 of file Ini.php.

Member Function Documentation

◆ _addBranch()

_addBranch ( Zend_Config  $config,
  $parents = array() 
)
protected

Add a branch to an INI string recursively

Parameters
Zend_Config$config
Returns
void

Definition at line 124 of file Ini.php.

125  {
126  $iniString = '';
127 
128  foreach ($config as $key => $value) {
129  $group = array_merge($parents, array($key));
130 
131  if ($value instanceof Zend_Config) {
132  $iniString .= $this->_addBranch($value, $group);
133  } else {
134  $iniString .= implode($this->_nestSeparator, $group)
135  . ' = '
136  . $this->_prepareValue($value)
137  . "\n";
138  }
139  }
140 
141  return $iniString;
142  }
$config
Definition: fraud_order.php:17
$group
Definition: sections.phtml:16
_prepareValue($value)
Definition: Ini.php:150
$value
Definition: gender.phtml:16
_addBranch(Zend_Config $config, $parents=array())
Definition: Ini.php:124

◆ _prepareValue()

_prepareValue (   $value)
protected

Prepare a value for INI

Parameters
mixed$value
Returns
string
See also
Zend_Config_Exception

Definition at line 150 of file Ini.php.

151  {
152  if (is_integer($value) || is_float($value)) {
153  return $value;
154  } elseif (is_bool($value)) {
155  return ($value ? 'true' : 'false');
156  } elseif (strpos($value, '"') === false) {
157  return '"' . $value . '"';
158  } else {
160  #require_once 'Zend/Config/Exception.php';
161  throw new Zend_Config_Exception('Value can not contain double quotes "');
162  }
163  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$value
Definition: gender.phtml:16

◆ _sortRootElements()

_sortRootElements ( Zend_Config  $config)
protected

Root elements that are not assigned to any section needs to be on the top of config.

See also
http://framework.zend.com/issues/browse/ZF-6289
Parameters
Zend_Config
Returns
Zend_Config

Definition at line 173 of file Ini.php.

174  {
175  $configArray = $config->toArray();
176  $sections = array();
177 
178  // remove sections from config array
179  foreach ($configArray as $key => $value) {
180  if (is_array($value)) {
181  $sections[$key] = $value;
182  unset($configArray[$key]);
183  }
184  }
185 
186  // readd sections to the end
187  foreach ($sections as $key => $value) {
188  $configArray[$key] = $value;
189  }
190 
191  return new Zend_Config($configArray);
192  }
$config
Definition: fraud_order.php:17
$value
Definition: gender.phtml:16

◆ render()

render ( )

Render a Zend_Config into a INI config string.

Since
1.10
Returns
string

Definition at line 83 of file Ini.php.

84  {
85  $iniString = '';
86  $extends = $this->_config->getExtends();
87  $sectionName = $this->_config->getSectionName();
88 
89  if($this->_renderWithoutSections == true) {
90  $iniString .= $this->_addBranch($this->_config);
91  } else if (is_string($sectionName)) {
92  $iniString .= '[' . $sectionName . ']' . "\n"
93  . $this->_addBranch($this->_config)
94  . "\n";
95  } else {
96  $config = $this->_sortRootElements($this->_config);
97  foreach ($config as $sectionName => $data) {
98  if (!($data instanceof Zend_Config)) {
99  $iniString .= $sectionName
100  . ' = '
101  . $this->_prepareValue($data)
102  . "\n";
103  } else {
104  if (isset($extends[$sectionName])) {
105  $sectionName .= ' : ' . $extends[$sectionName];
106  }
107 
108  $iniString .= '[' . $sectionName . ']' . "\n"
109  . $this->_addBranch($data)
110  . "\n";
111  }
112  }
113  }
114 
115  return $iniString;
116  }
$config
Definition: fraud_order.php:17
_prepareValue($value)
Definition: Ini.php:150
_sortRootElements(Zend_Config $config)
Definition: Ini.php:173
_addBranch(Zend_Config $config, $parents=array())
Definition: Ini.php:124

◆ setNestSeparator()

setNestSeparator (   $separator)

Set the nest separator

Parameters
string$filename
Returns
Zend_Config_Writer_Ini

Definition at line 55 of file Ini.php.

56  {
57  $this->_nestSeparator = $separator;
58 
59  return $this;
60  }

◆ setRenderWithoutSections()

setRenderWithoutSections (   $withoutSections = true)

Set if rendering should occour without sections or not.

If set to true, the INI file is rendered without sections completely into the global namespace of the INI file.

Parameters
bool$withoutSections
Returns
Zend_Config_Writer_Ini

Definition at line 71 of file Ini.php.

72  {
73  $this->_renderWithoutSections = (bool)$withoutSections;
74  return $this;
75  }

Field Documentation

◆ $_nestSeparator

$_nestSeparator = '.'
protected

Definition at line 40 of file Ini.php.

◆ $_renderWithoutSections

$_renderWithoutSections = false
protected

Definition at line 47 of file Ini.php.


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