当前位置: 首页>>代码示例>>PHP>>正文


PHP Object::hasData方法代码示例

本文整理汇总了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'));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:ObjectTest.php

示例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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:15,代码来源:Serialized.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:Website.php

示例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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:18,代码来源:Product.php

示例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;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:Store.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:21,代码来源:Sortby.php

示例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;
 }
开发者ID:nja78,项目名称:magento2,代码行数:28,代码来源:Datetime.php

示例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);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:24,代码来源:Config.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:28,代码来源:AbstractResource.php

示例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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:Button.php

示例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;
 }
开发者ID:opexsw,项目名称:magento2,代码行数:14,代码来源:AbstractBackend.php

示例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);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:15,代码来源:Admin.php


注:本文中的Magento\Framework\Object::hasData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。