本文整理汇总了PHP中Magento\Framework\Object::hasData方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::hasData方法的具体用法?PHP Object::hasData怎么用?PHP Object::hasData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::hasData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHasData
/**
* Tests \Magento\Framework\Object->hasData()
*/
public function testHasData()
{
$this->assertFalse($this->_object->hasData());
$this->assertFalse($this->_object->hasData('key'));
$this->_object->setData('key', 'value');
$this->assertTrue($this->_object->hasData('key'));
}
示例2: beforeSave
/**
* Serialize before saving
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
// parent::beforeSave() is not called intentionally
$attrCode = $this->getAttribute()->getAttributeCode();
if ($object->hasData($attrCode)) {
$object->setData($attrCode, serialize($object->getData($attrCode)));
}
return $this;
}
示例3: beforeSave
/**
* Before save
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
if ($object->getId()) {
return $this;
}
if (!$object->hasData('website_id')) {
$object->setData('website_id', $this->_storeManager->getStore()->getWebsiteId());
}
return $this;
}
示例4: validate
/**
* Validate product attribute value for condition
*
* @param \Magento\Framework\Object $object
* @return bool
*/
public function validate(\Magento\Framework\Object $object)
{
$attrCode = $this->getAttribute();
if ('category_ids' == $attrCode) {
return $this->validateAttribute($object->getAvailableInCategories());
}
$oldAttrValue = $object->hasData($attrCode) ? $object->getData($attrCode) : null;
$this->_setAttributeValue($object);
$result = $this->validateAttribute($object->getData($this->getAttribute()));
$this->_restoreOldAttrValue($object, $oldAttrValue);
return (bool) $result;
}
示例5: beforeSave
/**
* Before save
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
if ($object->getId()) {
return $this;
}
if (!$object->hasStoreId()) {
$object->setStoreId($this->_storeManager->getStore()->getId());
}
if (!$object->hasData('created_in')) {
$object->setData('created_in', $this->_storeManager->getStore($object->getStoreId())->getName());
}
return $this;
}
示例6: beforeSave
/**
* Before Attribute Save Process
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getName();
if ($attributeCode == 'available_sort_by') {
$data = $object->getData($attributeCode);
if (!is_array($data)) {
$data = [];
}
$object->setData($attributeCode, join(',', $data));
}
if (!$object->hasData($attributeCode)) {
$object->setData($attributeCode, false);
}
return $this;
}
示例7: beforeSave
/**
* Formatting date value before save
*
* Should set (bool, string) correct type for empty value from html form,
* necessary for further process, else date string
*
* @param \Magento\Framework\Object $object
* @throws \Magento\Framework\Exception\LocalizedException
* @return $this
*/
public function beforeSave($object)
{
$attributeName = $this->getAttribute()->getName();
$_formated = $object->getData($attributeName . '_is_formated');
if (!$_formated && $object->hasData($attributeName)) {
try {
$value = $this->formatDate($object->getData($attributeName));
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('Invalid date'));
}
if (is_null($value)) {
$value = $object->getData($attributeName);
}
$object->setData($attributeName, $value);
$object->setData($attributeName . '_is_formated', true);
}
return $this;
}
示例8: getWidgetWindowUrl
/**
* Return Widgets Insertion Plugin Window URL
*
* @param \Magento\Framework\Object $config Editor element config
* @return string
*/
public function getWidgetWindowUrl($config)
{
$params = array();
$skipped = is_array($config->getData('skip_widgets')) ? $config->getData('skip_widgets') : array();
if ($config->hasData('widget_filters')) {
$all = $this->_widgetFactory->create()->getWidgets();
$filtered = $this->_widgetFactory->create()->getWidgets($config->getData('widget_filters'));
foreach ($all as $code => $widget) {
if (!isset($filtered[$code])) {
$skipped[] = $widget['@']['type'];
}
}
}
if (count($skipped) > 0) {
$params['skip_widgets'] = $this->encodeWidgetsToQuery($skipped);
}
return $this->_backendUrl->getUrl('adminhtml/widget/index', $params);
}
示例9: _prepareDataForTable
/**
* Prepare data for passed table
*
* @param \Magento\Framework\Object $object
* @param string $table
* @return array
*/
protected function _prepareDataForTable(\Magento\Framework\Object $object, $table)
{
$data = [];
$fields = $this->_getWriteAdapter()->describeTable($table);
foreach (array_keys($fields) as $field) {
if ($object->hasData($field)) {
$fieldValue = $object->getData($field);
if ($fieldValue instanceof \Zend_Db_Expr) {
$data[$field] = $fieldValue;
} else {
if (null !== $fieldValue) {
$fieldValue = $this->_prepareTableValueForSave($fieldValue, $fields[$field]['DATA_TYPE']);
$data[$field] = $this->_getWriteAdapter()->prepareColumnValue($fields[$field], $fieldValue);
} elseif (!empty($fields[$field]['NULLABLE'])) {
$data[$field] = null;
}
}
}
}
return $data;
}
示例10: _isConfigBasedIntegration
/**
* Determine whether current integration came from config file
*
* @param \Magento\Framework\Object $row
* @return bool
*/
protected function _isConfigBasedIntegration(Object $row)
{
return $row->hasData(Integration::SETUP_TYPE) && $row->getData(Integration::SETUP_TYPE) == Integration::TYPE_CONFIG;
}
示例11: beforeSave
/**
* Before save method
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
$attrCode = $this->getAttribute()->getAttributeCode();
if (!$object->hasData($attrCode) && $this->getDefaultValue()) {
$object->setData($attrCode, $this->getDefaultValue());
}
return $this;
}
示例12: displayPriceAttribute
/**
* Display price attribute value in base order currency and in place order currency
*
* @param \Magento\Framework\Object $dataObject
* @param string $code
* @param bool $strong
* @param string $separator
* @return string
*/
public function displayPriceAttribute($dataObject, $code, $strong = false, $separator = '<br/>')
{
// Fix for 'bs_customer_bal_total_refunded' attribute
$baseValue = $dataObject->hasData('bs_' . $code) ? $dataObject->getData('bs_' . $code) : $dataObject->getData('base_' . $code);
return $this->displayPrices($dataObject, $baseValue, $dataObject->getData($code), $strong, $separator);
}