Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
URI.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Element/Dictionary.php';
25 #require_once 'Zend/Pdf/Element/Name.php';
26 #require_once 'Zend/Pdf/Element/String.php';
27 #require_once 'Zend/Pdf/Element/Boolean.php';
28 
29 
31 #require_once 'Zend/Pdf/Action.php';
32 
33 
45 {
53  public function __construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions)
54  {
55  parent::__construct($dictionary, $processedActions);
56 
57  if ($dictionary->URI === null) {
58  #require_once 'Zend/Pdf/Exception.php';
59  throw new Zend_Pdf_Exception('URI action dictionary entry is required');
60  }
61  }
62 
70  protected static function _validateUri($uri)
71  {
72  $scheme = parse_url((string)$uri, PHP_URL_SCHEME);
73  if ($scheme === false || $scheme === null) {
74  #require_once 'Zend/Pdf/Exception.php';
75  throw new Zend_Pdf_Exception('Invalid URI');
76  }
77  }
78 
86  public static function create($uri, $isMap = false)
87  {
88  self::_validateUri($uri);
89 
90  $dictionary = new Zend_Pdf_Element_Dictionary();
91  $dictionary->Type = new Zend_Pdf_Element_Name('Action');
92  $dictionary->S = new Zend_Pdf_Element_Name('URI');
93  $dictionary->Next = null;
94  $dictionary->URI = new Zend_Pdf_Element_String($uri);
95  if ($isMap) {
96  $dictionary->IsMap = new Zend_Pdf_Element_Boolean(true);
97  }
98 
99  return new Zend_Pdf_Action_URI($dictionary, new SplObjectStorage());
100  }
101 
108  public function setUri($uri)
109  {
110  $this->_validateUri($uri);
111 
112  $this->_actionDictionary->touch();
113  $this->_actionDictionary->URI = new Zend_Pdf_Element_String($uri);
114 
115  return $this;
116  }
117 
123  public function getUri()
124  {
125  return $this->_actionDictionary->URI->value;
126  }
127 
139  public function setIsMap($isMap)
140  {
141  $this->_actionDictionary->touch();
142 
143  if ($isMap) {
144  $this->_actionDictionary->IsMap = new Zend_Pdf_Element_Boolean(true);
145  } else {
146  $this->_actionDictionary->IsMap = null;
147  }
148 
149  return $this;
150  }
151 
162  public function getIsMap()
163  {
164  return $this->_actionDictionary->IsMap !== null &&
165  $this->_actionDictionary->IsMap->value;
166  }
167 }
static create($uri, $isMap=false)
Definition: URI.php:86
static _validateUri($uri)
Definition: URI.php:70
__construct(Zend_Pdf_Element $dictionary, SplObjectStorage $processedActions)
Definition: URI.php:53
setIsMap($isMap)
Definition: URI.php:139