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


PHP DataObject::hasData方法代码示例

本文整理汇总了PHP中Magento\Framework\DataObject::hasData方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::hasData方法的具体用法?PHP DataObject::hasData怎么用?PHP DataObject::hasData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\DataObject的用法示例。


在下文中一共展示了DataObject::hasData方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testHasData

 /**
  * Tests \Magento\Framework\DataObject->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:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:ObjectTest.php

示例2: beforeSave

 /**
  * Serialize before saving
  *
  * @param \Magento\Framework\DataObject $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:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:Serialized.php

示例3: beforeSave

 /**
  * Before save
  *
  * @param \Magento\Framework\DataObject $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:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Website.php

示例4: __get

 /**
  * @param string $key
  * @return mixed
  */
 public function __get($key)
 {
     if (isset($this->aliasMap[$key])) {
         return $this->__get($this->aliasMap[$key]);
     }
     if (!$this->cache->hasData($key)) {
         $value = $this->wrap($this->loadData($key));
         $this->cache->setData($key, $value);
     }
     return $this->cache->getData($key);
 }
开发者ID:owebia,项目名称:magento2-module-advanced-setting-core,代码行数:15,代码来源:AbstractWrapper.php

示例5: _beforeSave

 /**
  * {@inheritdoc}
  */
 protected function _beforeSave(DataObject $post)
 {
     /** @var \Mirasvit\Blog\Model\Post $post */
     if (!$post->hasData('type')) {
         $post->setData('type', \Mirasvit\Blog\Model\Post::TYPE_POST);
     }
     if (!$post->getData('url_key')) {
         $post->setData('url_key', $this->filter->translitUrl($post->getName()));
     }
     $this->saveImage($post);
     return parent::_beforeSave($post);
 }
开发者ID:mirasvit,项目名称:module-blog,代码行数:15,代码来源:Post.php

示例6: beforeSave

 /**
  * Before save
  *
  * @param \Magento\Framework\DataObject $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:kidaa30,项目名称:magento2-platformsh,代码行数:19,代码来源:Store.php

示例7: displayPriceAttribute

 /**
  * Display price attribute value in base order currency and in place order currency
  *
  * @param   \Magento\Framework\DataObject $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:razbakov,项目名称:magento2,代码行数:23,代码来源:Admin.php

示例8: beforeSave

 /**
  * Before Attribute Save Process
  *
  * @param \Magento\Framework\DataObject $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:pradeep-wagento,项目名称:magento2,代码行数:21,代码来源:Sortby.php

示例9: getWidgetWindowUrl

 /**
  * Return Widgets Insertion Plugin Window URL
  *
  * @param \Magento\Framework\DataObject $config Editor element config
  * @return string
  */
 public function getWidgetWindowUrl($config)
 {
     $params = [];
     $skipped = is_array($config->getData('skip_widgets')) ? $config->getData('skip_widgets') : [];
     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:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:Config.php

示例10: 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\DataObject $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:pradeep-wagento,项目名称:magento2,代码行数:28,代码来源:Datetime.php

示例11: _prepareDataForTable

 /**
  * Prepare data for passed table
  *
  * @param DataObject $object
  * @param string $table
  * @return array
  */
 protected function _prepareDataForTable(DataObject $object, $table)
 {
     $data = [];
     $fields = $this->getConnection()->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->getConnection()->prepareColumnValue($fields[$field], $fieldValue);
                 } elseif (!empty($fields[$field]['NULLABLE'])) {
                     $data[$field] = null;
                 }
             }
         }
     }
     return $data;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:28,代码来源:AbstractResource.php

示例12: beforeSave

 /**
  * Before save method
  *
  * @param \Magento\Framework\DataObject $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:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:AbstractBackend.php

示例13: _isConfigBasedIntegration

 /**
  * Determine whether current integration came from config file
  *
  * @param \Magento\Framework\DataObject $row
  * @return bool
  */
 protected function _isConfigBasedIntegration(DataObject $row)
 {
     return $row->hasData(Integration::SETUP_TYPE) && $row->getData(Integration::SETUP_TYPE) == Integration::TYPE_CONFIG;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:Button.php


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