Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Design Class Reference
Inheritance diagram for Design:
AbstractModel IdentityInterface DesignInterface DataObject

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, \Magento\Framework\Stdlib\DateTime $dateTime, AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[], SerializerInterface $serializer=null)
 
 loadChange ($storeId, $date=null)
 
 changeDesign (\Magento\Framework\View\DesignInterface $packageInto)
 
 getIdentities ()
 
- 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)
 
- Public Member Functions inherited from DesignInterface
 changeDesign (\Magento\Framework\View\DesignInterface $packageInto)
 

Data Fields

const CACHE_TAG = 'CORE_DESIGN'
 

Protected Member Functions

 _construct ()
 
- 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

 $_eventPrefix = 'core_design'
 
 $_cacheTag = self::CACHE_TAG
 
 $_localeDate
 
 $_dateTime
 
- 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

- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Design settings change model

@method int getStoreId() @method \Magento\Theme\Model\Design setStoreId(int $value) @method string getDesign() @method \Magento\Theme\Model\Design setDesign(string $value) @method string getDateFrom() @method \Magento\Theme\Model\Design setDateFrom(string $value) @method string getDateTo() @method \Magento\Theme\Model\Design setDateTo(string $value)

Definition at line 27 of file Design.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\Registry  $registry,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface  $localeDate,
\Magento\Framework\Stdlib\DateTime  $dateTime,
AbstractResource  $resource = null,
\Magento\Framework\Data\Collection\AbstractDb  $resourceCollection = null,
array  $data = [],
SerializerInterface  $serializer = null 
)
Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
\Magento\Framework\Stdlib\DateTime\TimezoneInterface$localeDate
\Magento\Framework\Stdlib\DateTime$dateTime
AbstractResource$resource
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data
SerializerInterface$serializer

Definition at line 75 of file Design.php.

84  {
85  $this->_localeDate = $localeDate;
86  $this->_dateTime = $dateTime;
87  $this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
88  parent::__construct($context, $registry, $resource, $resourceCollection, $data);
89  }
$resource
Definition: bulk.php:12
$dateTime

Member Function Documentation

◆ _construct()

_construct ( )
protected

Initialize resource model

Returns
void

Definition at line 96 of file Design.php.

97  {
98  $this->_init(\Magento\Theme\Model\ResourceModel\Design::class);
99  }

◆ changeDesign()

changeDesign ( \Magento\Framework\View\DesignInterface  $packageInto)

Apply design change from self data into specified design package instance

Parameters
\Magento\Framework\View\DesignInterface$packageInto
Returns
$this

Definition at line 139 of file Design.php.

140  {
141  $design = $this->getDesign();
142  if ($design) {
143  $packageInto->setDesignTheme($design);
144  }
145  return $this;
146  }

◆ getIdentities()

getIdentities ( )

Get identities

Returns
array

Implements IdentityInterface.

Definition at line 153 of file Design.php.

154  {
155  return [self::CACHE_TAG . '_' . $this->getId()];
156  }

◆ loadChange()

loadChange (   $storeId,
  $date = null 
)

Load custom design settings for specified store and date

Parameters
string$storeId
string | null$date
Returns
$this

Implements DesignInterface.

Definition at line 108 of file Design.php.

109  {
110  if ($date === null) {
111  $date = $this->_dateTime->formatDate($this->_localeDate->scopeTimeStamp($storeId), false);
112  }
113 
114  $changeCacheId = 'design_change_' . md5($storeId . $date);
115  $result = $this->_cacheManager->load($changeCacheId);
116  if ($result === false) {
117  $result = $this->getResource()->loadChange($storeId, $date);
118  if (!$result) {
119  $result = [];
120  }
121  $this->_cacheManager->save($this->serializer->serialize($result), $changeCacheId, [self::CACHE_TAG], 86400);
122  } else {
123  $result = $this->serializer->unserialize($result);
124  }
125 
126  if ($result) {
127  $this->setData($result);
128  }
129 
130  return $this;
131  }

Field Documentation

◆ $_cacheTag

$_cacheTag = self::CACHE_TAG
protected

Definition at line 48 of file Design.php.

◆ $_dateTime

$_dateTime
protected

Definition at line 58 of file Design.php.

◆ $_eventPrefix

$_eventPrefix = 'core_design'
protected

Definition at line 39 of file Design.php.

◆ $_localeDate

$_localeDate
protected

Definition at line 53 of file Design.php.

◆ CACHE_TAG

const CACHE_TAG = 'CORE_DESIGN'

Cache tag

Definition at line 32 of file Design.php.


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