Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Agreement.php
Go to the documentation of this file.
1 <?php
7 
9 
11 {
17  protected $allowedCssUnits = ['px', 'pc', 'pt', 'ex', 'em', 'mm', 'cm', 'in', '%'];
18 
23  protected function _construct()
24  {
25  $this->_init(\Magento\CheckoutAgreements\Model\ResourceModel\Agreement::class);
26  }
27 
32  public function validateData($agreementData)
33  {
34  $errors = [];
35 
36  $contentHeight = $agreementData->getContentHeight();
37  if ($contentHeight !== ''
38  && !preg_match('/^[0-9]*\.*[0-9]+(' . implode("|", $this->allowedCssUnits) . ')?$/', $contentHeight)
39  ) {
40  $errors[] = "Please input a valid CSS-height. For example 100px or 77pt or 20em or .5ex or 50%.";
41  }
42 
43  return (count($errors)) ? $errors : true;
44  }
45 
51  public function beforeSave()
52  {
53  if ($this->getContentHeight() == 0) {
54  $this->setContentHeight(''); //converting zero Content-Height
55  }
56 
57  if ($this->getContentHeight()
58  && !preg_match('/(' . implode("|", $this->allowedCssUnits) . ')/', $this->getContentHeight())
59  ) {
60  $contentHeight = $this->getContentHeight() . 'px'; //setting default units for Content-Height
61  $this->setContentHeight($contentHeight);
62  }
63 
64  return parent::beforeSave();
65  }
66 
67  //@codeCoverageIgnoreStart
68 
72  public function getAgreementId()
73  {
74  return $this->getData(self::AGREEMENT_ID);
75  }
76 
80  public function setAgreementId($id)
81  {
82  return $this->setData(self::AGREEMENT_ID, $id);
83  }
84 
88  public function getName()
89  {
90  return $this->getData(self::NAME);
91  }
92 
96  public function setName($name)
97  {
98  return $this->setData(self::NAME, $name);
99  }
100 
104  public function getContent()
105  {
106  return $this->getData(self::CONTENT);
107  }
108 
112  public function setContent($content)
113  {
114  return $this->setData(self::CONTENT, $content);
115  }
116 
120  public function getContentHeight()
121  {
122  return $this->getData(self::CONTENT_HEIGHT);
123  }
124 
128  public function setContentHeight($height)
129  {
130  return $this->setData(self::CONTENT_HEIGHT, $height);
131  }
132 
136  public function getCheckboxText()
137  {
138  return $this->getData(self::CHECKBOX_TEXT);
139  }
140 
144  public function setCheckboxText($text)
145  {
146  return $this->setData(self::CHECKBOX_TEXT, $text);
147  }
148 
152  public function getIsActive()
153  {
154  return $this->getData(self::IS_ACTIVE);
155  }
156 
160  public function setIsActive($status)
161  {
162  return $this->setData(self::IS_ACTIVE, $status);
163  }
164 
168  public function getIsHtml()
169  {
170  return $this->getData(self::IS_HTML);
171  }
172 
176  public function setIsHtml($isHtml)
177  {
178  return $this->setData(self::IS_HTML, $isHtml);
179  }
180 
184  public function getMode()
185  {
186  return $this->getData(self::MODE);
187  }
188 
192  public function setMode($mode)
193  {
194  return $this->setData(self::MODE, $mode);
195  }
196 
202  public function getExtensionAttributes()
203  {
204  return $this->_getExtensionAttributes();
205  }
206 
213  public function setExtensionAttributes(
214  \Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface $extensionAttributes
215  ) {
216  return $this->_setExtensionAttributes($extensionAttributes);
217  }
218 
219  //@codeCoverageIgnoreEnd
220 }
$id
Definition: fieldset.phtml:14
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
$status
Definition: order_status.php:8
setExtensionAttributes(\Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface $extensionAttributes)
Definition: Agreement.php:213
$errors
Definition: overview.phtml:9
if(!isset($_GET['name'])) $name
Definition: log.php:14