Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Dictionary.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Element/Name.php';
25 
26 
28 #require_once 'Zend/Pdf/Element.php';
29 
39 {
46  private $_items = array();
47 
48 
55  public function __construct($val = null)
56  {
57  if ($val === null) {
58  return;
59  } else if (!is_array($val)) {
60  #require_once 'Zend/Pdf/Exception.php';
61  throw new Zend_Pdf_Exception('Argument must be an array');
62  }
63 
64  foreach ($val as $name => $element) {
65  if (!$element instanceof Zend_Pdf_Element) {
66  #require_once 'Zend/Pdf/Exception.php';
67  throw new Zend_Pdf_Exception('Array elements must be Zend_Pdf_Element objects');
68  }
69  if (!is_string($name)) {
70  #require_once 'Zend/Pdf/Exception.php';
71  throw new Zend_Pdf_Exception('Array keys must be strings');
72  }
73  $this->_items[$name] = $element;
74  }
75  }
76 
77 
86  {
87  $this->_items[$name->value] = $val;
88  }
89 
95  public function getKeys()
96  {
97  return array_keys($this->_items);
98  }
99 
100 
107  public function __get($item)
108  {
109  $element = isset($this->_items[$item]) ? $this->_items[$item]
110  : null;
111 
112  return $element;
113  }
114 
121  public function __set($item, $value)
122  {
123  if ($value === null) {
124  unset($this->_items[$item]);
125  } else {
126  $this->_items[$item] = $value;
127  }
128  }
129 
135  public function getType()
136  {
138  }
139 
140 
147  public function toString($factory = null)
148  {
149  $outStr = '<<';
150  $lastNL = 0;
151 
152  foreach ($this->_items as $name => $element) {
153  if (!is_object($element)) {
154  #require_once 'Zend/Pdf/Exception.php';
155  throw new Zend_Pdf_Exception('Wrong data');
156  }
157 
158  if (strlen($outStr) - $lastNL > 128) {
159  $outStr .= "\n";
160  $lastNL = strlen($outStr);
161  }
162 
163  $nameObj = new Zend_Pdf_Element_Name($name);
164  $outStr .= $nameObj->toString($factory) . ' ' . $element->toString($factory) . ' ';
165  }
166  $outStr .= '>>';
167 
168  return $outStr;
169  }
170 
180  public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
181  {
182  if (isset($this->_items['Type'])) {
183  if ($this->_items['Type']->value == 'Pages') {
184  // It's a page tree node
185  // skip it and its children
186  return new Zend_Pdf_Element_Null();
187  }
188 
189  if ($this->_items['Type']->value == 'Page' &&
191  ) {
192  // It's a page node, skip it
193  return new Zend_Pdf_Element_Null();
194  }
195  }
196 
197  $newDictionary = new self();
198  foreach ($this->_items as $key => $value) {
199  $newDictionary->_items[$key] = $value->makeClone($factory, $processed, $mode);
200  }
201 
202  return $newDictionary;
203  }
204 
210  public function setParentObject(Zend_Pdf_Element_Object $parent)
211  {
212  parent::setParentObject($parent);
213 
214  foreach ($this->_items as $item) {
215  $item->setParentObject($parent);
216  }
217  }
218 
226  public function toPhp()
227  {
228  $phpArray = array();
229 
230  foreach ($this->_items as $itemName => $item) {
231  $phpArray[$itemName] = $item->toPhp();
232  }
233 
234  return $phpArray;
235  }
236 }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
const TYPE_DICTIONARY
Definition: Element.php:37
add(Zend_Pdf_Element_Name $name, Zend_Pdf_Element $val)
Definition: Dictionary.php:85
$value
Definition: gender.phtml:16
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
setParentObject(Zend_Pdf_Element_Object $parent)
Definition: Dictionary.php:210
makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
Definition: Dictionary.php:180
const CLONE_MODE_SKIP_PAGES
Definition: Element.php:67
if(!isset($_GET['name'])) $name
Definition: log.php:14
$element
Definition: element.phtml:12