Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Agreement Class Reference
Inheritance diagram for Agreement:
AbstractExtensibleModel AgreementInterface AbstractModel CustomAttributesDataInterface ExtensibleDataInterface DataObject ExtensibleDataInterface

Public Member Functions

 validateData ($agreementData)
 
 beforeSave ()
 
 getAgreementId ()
 
 setAgreementId ($id)
 
 getName ()
 
 setName ($name)
 
 getContent ()
 
 setContent ($content)
 
 getContentHeight ()
 
 setContentHeight ($height)
 
 getCheckboxText ()
 
 setCheckboxText ($text)
 
 getIsActive ()
 
 setIsActive ($status)
 
 getIsHtml ()
 
 setIsHtml ($isHtml)
 
 getMode ()
 
 setMode ($mode)
 
 getExtensionAttributes ()
 
 setExtensionAttributes (\Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface $extensionAttributes)
 
- Public Member Functions inherited from AbstractExtensibleModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getCustomAttributes ()
 
 getCustomAttribute ($attributeCode)
 
 setCustomAttributes (array $attributes)
 
 setCustomAttribute ($attributeCode, $attributeValue)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 setId ($value)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from AbstractExtensibleModel
 filterCustomAttributes ($data)
 
 initializeCustomAttributes ()
 
 convertCustomAttributeValues (array &$customAttributes)
 
 getCustomAttributesCodes ()
 
 _setExtensionAttributes (\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
 
 _getExtensionAttributes ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $allowedCssUnits = ['px', 'pc', 'pt', 'ex', 'em', 'mm', 'cm', 'in', '%']
 
- Protected Attributes inherited from AbstractExtensibleModel
 $extensionAttributesFactory
 
 $extensionAttributes
 
 $customAttributeFactory
 
 $customAttributesCodes = null
 
 $customAttributesChanged = false
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Data Fields inherited from CustomAttributesDataInterface
const CUSTOM_ATTRIBUTES = 'custom_attributes'
 
- Data Fields inherited from ExtensibleDataInterface
const EXTENSION_ATTRIBUTES_KEY = 'extension_attributes'
 
- Data Fields inherited from AgreementInterface
const AGREEMENT_ID = 'agreement_id'
 
const NAME = 'name'
 
const CONTENT = 'content'
 
const CONTENT_HEIGHT = 'content_height'
 
const CHECKBOX_TEXT = 'checkbox_text'
 
const IS_ACTIVE = 'is_active'
 
const IS_HTML = 'is_html'
 
const MODE = 'mode'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Definition at line 10 of file Agreement.php.

Member Function Documentation

◆ _construct()

_construct ( )
protected
Returns
void @codeCoverageIgnore

Definition at line 23 of file Agreement.php.

24  {
25  $this->_init(\Magento\CheckoutAgreements\Model\ResourceModel\Agreement::class);
26  }

◆ beforeSave()

beforeSave ( )

Processing object before save data

Returns
$this

Definition at line 51 of file Agreement.php.

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  }

◆ getAgreementId()

getAgreementId ( )

#- Returns the agreement ID.

Returns
int Agreement ID.

Implements AgreementInterface.

Definition at line 72 of file Agreement.php.

73  {
74  return $this->getData(self::AGREEMENT_ID);
75  }

◆ getCheckboxText()

getCheckboxText ( )

Returns the agreement checkbox text.

Returns
string Agreement checkbox text.

Implements AgreementInterface.

Definition at line 136 of file Agreement.php.

137  {
138  return $this->getData(self::CHECKBOX_TEXT);
139  }

◆ getContent()

getContent ( )

Returns the agreement content.

Returns
string Agreement content.

Implements AgreementInterface.

Definition at line 104 of file Agreement.php.

105  {
106  return $this->getData(self::CONTENT);
107  }

◆ getContentHeight()

getContentHeight ( )

Returns the agreement content height, which is an optional CSS property.

Returns
string|null Agreement content height. Otherwise, null.

Implements AgreementInterface.

Definition at line 120 of file Agreement.php.

121  {
122  return $this->getData(self::CONTENT_HEIGHT);
123  }

◆ getExtensionAttributes()

getExtensionAttributes ( )

{Retrieve existing extension attributes object or create a new one.

Returns
\Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface|null
}

Returns
\Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface|null

Implements AgreementInterface.

Definition at line 202 of file Agreement.php.

◆ getIsActive()

getIsActive ( )

Returns the agreement status.

Returns
bool Agreement status. @SuppressWarnings(PHPMD.BooleanGetMethodName)

Implements AgreementInterface.

Definition at line 152 of file Agreement.php.

153  {
154  return $this->getData(self::IS_ACTIVE);
155  }

◆ getIsHtml()

getIsHtml ( )

Returns the agreement content type.

Returns
bool * true - HTML.
  • false - plain text. @SuppressWarnings(PHPMD.BooleanGetMethodName)

Implements AgreementInterface.

Definition at line 168 of file Agreement.php.

169  {
170  return $this->getData(self::IS_HTML);
171  }

◆ getMode()

getMode ( )

Returns the agreement applied mode.

Returns
int

Implements AgreementInterface.

Definition at line 184 of file Agreement.php.

185  {
186  return $this->getData(self::MODE);
187  }

◆ getName()

getName ( )

Returns the agreement name.

Returns
string Agreement name.

Implements AgreementInterface.

Definition at line 88 of file Agreement.php.

89  {
90  return $this->getData(self::NAME);
91  }

◆ setAgreementId()

setAgreementId (   $id)

Sets the agreement ID.

Parameters
int$id
Returns
$this

Implements AgreementInterface.

Definition at line 80 of file Agreement.php.

81  {
82  return $this->setData(self::AGREEMENT_ID, $id);
83  }
$id
Definition: fieldset.phtml:14

◆ setCheckboxText()

setCheckboxText (   $text)

Sets the agreement checkbox text.

Parameters
string$text
Returns
$this

Implements AgreementInterface.

Definition at line 144 of file Agreement.php.

145  {
146  return $this->setData(self::CHECKBOX_TEXT, $text);
147  }
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43

◆ setContent()

setContent (   $content)

Sets the agreement content.

Parameters
string$content
Returns
$this

Implements AgreementInterface.

Definition at line 112 of file Agreement.php.

113  {
114  return $this->setData(self::CONTENT, $content);
115  }

◆ setContentHeight()

setContentHeight (   $height)

Sets the agreement content height, which is an optional CSS property.

Parameters
string | null$height
Returns
$this

Implements AgreementInterface.

Definition at line 128 of file Agreement.php.

129  {
130  return $this->setData(self::CONTENT_HEIGHT, $height);
131  }

◆ setExtensionAttributes()

setExtensionAttributes ( \Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface  $extensionAttributes)

{Set an extension attributes object.

Parameters
\Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface$extensionAttributes
Returns
$this
}

Parameters
\Magento\CheckoutAgreements\Api\Data\AgreementExtensionInterface$extensionAttributes
Returns
$this

Implements AgreementInterface.

Definition at line 213 of file Agreement.php.

215  {
217  }
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)

◆ setIsActive()

setIsActive (   $status)

Sets the agreement status.

Parameters
bool$status
Returns
$this

Implements AgreementInterface.

Definition at line 160 of file Agreement.php.

161  {
162  return $this->setData(self::IS_ACTIVE, $status);
163  }
$status
Definition: order_status.php:8

◆ setIsHtml()

setIsHtml (   $isHtml)

Sets the agreement content type.

  • true - HTML
  • false - plain text
Parameters
bool$isHtml
Returns
$this

Implements AgreementInterface.

Definition at line 176 of file Agreement.php.

177  {
178  return $this->setData(self::IS_HTML, $isHtml);
179  }

◆ setMode()

setMode (   $mode)

Sets the agreement applied mode.

Parameters
int$mode
Returns
$this

Implements AgreementInterface.

Definition at line 192 of file Agreement.php.

193  {
194  return $this->setData(self::MODE, $mode);
195  }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15

◆ setName()

setName (   $name)

Sets the agreement name.

Parameters
string$name
Returns
$this

Implements AgreementInterface.

Definition at line 96 of file Agreement.php.

97  {
98  return $this->setData(self::NAME, $name);
99  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ validateData()

validateData (   $agreementData)
Parameters
\Magento\Framework\DataObject$agreementData
Returns
array|bool

Definition at line 32 of file Agreement.php.

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  }
$errors
Definition: overview.phtml:9

Field Documentation

◆ $allowedCssUnits

$allowedCssUnits = ['px', 'pc', 'pt', 'ex', 'em', 'mm', 'cm', 'in', '%']
protected

Definition at line 17 of file Agreement.php.


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