Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Object.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Element.php';
25 
26 
36 {
42  protected $_value;
43 
49  protected $_objNum;
50 
56  protected $_genNum;
57 
63  protected $_factory;
64 
74  public function __construct(Zend_Pdf_Element $val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory)
75  {
76  if ($val instanceof self) {
77  #require_once 'Zend/Pdf/Exception.php';
78  throw new Zend_Pdf_Exception('Object number must not be an instance of Zend_Pdf_Element_Object.');
79  }
80 
81  if ( !(is_integer($objNum) && $objNum > 0) ) {
82  #require_once 'Zend/Pdf/Exception.php';
83  throw new Zend_Pdf_Exception('Object number must be positive integer.');
84  }
85 
86  if ( !(is_integer($genNum) && $genNum >= 0) ) {
87  #require_once 'Zend/Pdf/Exception.php';
88  throw new Zend_Pdf_Exception('Generation number must be non-negative integer.');
89  }
90 
91  $this->_value = $val;
92  $this->_objNum = $objNum;
93  $this->_genNum = $genNum;
94  $this->_factory = $factory;
95 
96  $this->setParentObject($this);
97 
98  $factory->registerObject($this, $objNum . ' ' . $genNum);
99  }
100 
101 
107  public function getFactory()
108  {
109  return $this->_factory;
110  }
111 
117  public function getType()
118  {
119  return $this->_value->getType();
120  }
121 
122 
128  public function getObjNum()
129  {
130  return $this->_objNum;
131  }
132 
133 
139  public function getGenNum()
140  {
141  return $this->_genNum;
142  }
143 
144 
151  public function toString($factory = null)
152  {
153  if ($factory === null) {
154  $shift = 0;
155  } else {
156  $shift = $factory->getEnumerationShift($this->_factory);
157  }
158 
159  return $this->_objNum + $shift . ' ' . $this->_genNum . ' R';
160  }
161 
162 
172  {
173  $shift = $factory->getEnumerationShift($this->_factory);
174 
175  return $this->_objNum + $shift . " " . $this->_genNum . " obj \n"
176  . $this->_value->toString($factory) . "\n"
177  . "endobj\n";
178  }
179 
186  public function __get($property)
187  {
188  return $this->_value->$property;
189  }
190 
197  public function __set($property, $value)
198  {
199  $this->_value->$property = $value;
200  }
201 
209  public function __call($method, $args)
210  {
211  return call_user_func_array(array($this->_value, $method), $args);
212  }
213 
222  public function makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
223  {
224  $id = spl_object_hash($this);
225  if (isset($processed[$id])) {
226  // Do nothing if object is already processed
227  // return it
228  return $processed[$id];
229  }
230 
231  // Create obect with null value and register it in $processed container
232  $processed[$id] = $clonedObject = $factory->newObject(new Zend_Pdf_Element_Null());
233 
234  // Pecursively process actual data
235  $clonedObject->_value = $this->_value->makeClone($factory, $processed, $mode);
236 
237  if ($clonedObject->_value instanceof Zend_Pdf_Element_Null) {
238  // Do not store null objects within $processed container since it may be filtered
239  // by $mode parameter but used in some future pass
240  unset($processed[$id]);
241 
242  // Return direct null object
243  return $clonedObject->_value;
244  }
245 
246  return $clonedObject;
247  }
248 
252  public function touch()
253  {
254  $this->_factory->markAsModified($this);
255  }
256 
262  public function getObject()
263  {
264  return $this;
265  }
266 
270  public function cleanUp()
271  {
272  $this->_value = null;
273  }
274 
280  public function toPhp()
281  {
282  return $this->_value->toPhp();
283  }
284 }
$id
Definition: fieldset.phtml:14
__construct(Zend_Pdf_Element $val, $objNum, $genNum, Zend_Pdf_ElementFactory $factory)
Definition: Object.php:74
__set($property, $value)
Definition: Object.php:197
dump(Zend_Pdf_ElementFactory $factory)
Definition: Object.php:171
$value
Definition: gender.phtml:16
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
$method
Definition: info.phtml:13
setParentObject(Zend_Pdf_Element_Object $parent)
Definition: Element.php:91
makeClone(Zend_Pdf_ElementFactory $factory, array &$processed, $mode)
Definition: Object.php:222
toString($factory=null)
Definition: Object.php:151
__call($method, $args)
Definition: Object.php:209