本文整理汇总了PHP中Magento\Framework\Model\AbstractExtensibleModel类的典型用法代码示例。如果您正苦于以下问题:PHP AbstractExtensibleModel类的具体用法?PHP AbstractExtensibleModel怎么用?PHP AbstractExtensibleModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractExtensibleModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCustomAttributesToModel
/**
* @param string[] $attributesAsArray
* @param \Magento\Framework\Model\AbstractExtensibleModel $model
* @return \Magento\Framework\Api\AttributeInterface[]
*/
protected function addCustomAttributesToModel($attributesAsArray, $model)
{
$addedAttributes = [];
foreach ($attributesAsArray as $attributeCode => $attributeValue) {
$addedAttributes[$attributeCode] = new AttributeValue([AttributeValue::ATTRIBUTE_CODE => $attributeCode, AttributeValue::VALUE => $attributeValue]);
}
$model->setData(array_merge($model->getData(), [\Magento\Framework\Api\CustomAttributesDataInterface::CUSTOM_ATTRIBUTES => $addedAttributes]));
return $addedAttributes;
}
示例2: afterSave
/**
* After save process
*
* @return $this
*/
public function afterSave()
{
parent::afterSave();
$this->_getResource()->saveLabel($this);
$this->_getResource()->savePrices($this);
return $this;
}
示例3: beforeSave
/**
* Processing object before save data
*
* @return $this
*/
public function beforeSave()
{
if (!$this->getAttributeGroupCode()) {
$groupName = $this->getAttributeGroupName();
if ($groupName) {
$this->setAttributeGroupCode(trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($groupName)), '-'));
}
}
return parent::beforeSave();
}
示例4: beforeSave
/**
* Processing object before save data
*
* @return $this
*/
public function beforeSave()
{
if ($this->getContentHeight() == 0) {
$this->setContentHeight('');
//converting zero Content-Height
}
if ($this->getContentHeight() && !preg_match('/(' . implode("|", $this->allowedCssUnits) . ')/', $this->getContentHeight())) {
$contentHeight = $this->getContentHeight() . 'px';
//setting default units for Content-Height
$this->setContentHeight($contentHeight);
}
return parent::beforeSave();
}
示例5: getData
/**
* Retrieve data
*
* @param string $key
* @param mixed $index
* @return mixed
*/
public function getData($key = '', $index = null)
{
if ('cc_number' === $key) {
if (empty($this->_data['cc_number']) && !empty($this->_data['cc_number_enc'])) {
$this->_data['cc_number'] = $this->decrypt($this->getCcNumberEnc());
}
}
if ('cc_cid' === $key) {
if (empty($this->_data['cc_cid']) && !empty($this->_data['cc_cid_enc'])) {
$this->_data['cc_cid'] = $this->decrypt($this->getCcCidEnc());
}
}
return parent::getData($key, $index);
}
示例6: beforeSave
/**
* Processing object before save data
*
* @return $this
*/
public function beforeSave()
{
if (!$this->getAttributeGroupCode()) {
$groupName = $this->getAttributeGroupName();
if ($groupName) {
$attributeGroupCode = trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($groupName)), '-');
if (empty($attributeGroupCode)) {
// in the following code md5 is not used for security purposes
$attributeGroupCode = md5($groupName);
}
$this->setAttributeGroupCode($attributeGroupCode);
}
}
return parent::beforeSave();
}
示例7: beforeDelete
/**
* Validate tax class can be deleted
*
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function beforeDelete()
{
$this->checkClassCanBeDeleted();
return parent::beforeDelete();
}
示例8: __construct
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory
* @param AttributeValueFactory $customAttributeFactory
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
*/
public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
{
$this->_storeManager = $storeManager;
parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, $data);
$this->setIncludePath();
}
示例9: afterDelete
/**
* Rewrite in order to clear configuration cache
*
* @return $this
*/
public function afterDelete()
{
$this->_storeManager->reinitStores();
parent::afterDelete();
return $this;
}
示例10: __wakeup
/**
* @inheritdoc
*/
public function __wakeup()
{
parent::__wakeup();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$this->metadataPool = $objectManager->get(MetadataPool::class);
}
示例11: afterSave
/**
* @return \Magento\Framework\Model\AbstractModel
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function afterSave()
{
$this->getValueInstance()->unsetValues();
if (is_array($this->getData('values'))) {
foreach ($this->getData('values') as $value) {
$this->getValueInstance()->addValue($value);
}
$this->getValueInstance()->setOption($this)->saveValues();
} elseif ($this->getGroupByType($this->getType()) == self::OPTION_GROUP_SELECT) {
throw new LocalizedException(__('Select type options required values rows.'));
}
return parent::afterSave();
}
示例12: afterDelete
/**
* Rewrite in order to clear configuration cache
*
* @return $this
*/
public function afterDelete()
{
parent::afterDelete();
$this->_configCacheType->clean();
return $this;
}
示例13: __construct
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param ExtensionAttributesFactory $extensionFactory
* @param AttributeValueFactory $customAttributeFactory
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param StockConfigurationInterface $stockConfiguration
* @param StockRegistryInterface $stockRegistry
* @param StockItemRepositoryInterface $stockItemRepository
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\Db $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Customer\Model\Session $customerSession, \Magento\Store\Model\StoreManagerInterface $storeManager, StockConfigurationInterface $stockConfiguration, StockRegistryInterface $stockRegistry, StockItemRepositoryInterface $stockItemRepository, \Magento\Framework\Model\Resource\AbstractResource $resource = null, \Magento\Framework\Data\Collection\Db $resourceCollection = null, array $data = [])
{
parent::__construct($context, $registry, $extensionFactory, $customAttributeFactory, $resource, $resourceCollection, $data);
$this->customerSession = $customerSession;
$this->storeManager = $storeManager;
$this->stockConfiguration = $stockConfiguration;
$this->stockRegistry = $stockRegistry;
$this->stockItemRepository = $stockItemRepository;
}
示例14: beforeDelete
/**
* @return $this
*/
public function beforeDelete()
{
$this->_configDataResource->clearScopeData(\Magento\Store\Model\ScopeInterface::SCOPE_STORES, $this->getStoreIds());
return parent::beforeDelete();
}
示例15: __wakeup
/**
* @inheritdoc
*/
public function __wakeup()
{
parent::__wakeup();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$this->_eavConfig = $objectManager->get(\Magento\Eav\Model\Config::class);
$this->_eavTypeFactory = $objectManager->get(\Magento\Eav\Model\Entity\TypeFactory::class);
$this->_storeManager = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class);
$this->_resourceHelper = $objectManager->get(\Magento\Eav\Model\ResourceModel\Helper::class);
$this->_universalFactory = $objectManager->get(\Magento\Framework\Validator\UniversalFactory::class);
$this->optionDataFactory = $objectManager->get(\Magento\Eav\Api\Data\AttributeOptionInterfaceFactory::class);
$this->dataObjectProcessor = $objectManager->get(\Magento\Framework\Reflection\DataObjectProcessor::class);
$this->dataObjectHelper = $objectManager->get(\Magento\Framework\Api\DataObjectHelper::class);
}