本文整理汇总了PHP中Magento\Framework\DataObject类的典型用法代码示例。如果您正苦于以下问题:PHP DataObject类的具体用法?PHP DataObject怎么用?PHP DataObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testValidate
/**
* @param string
* @dataProvider validateProvider
*/
public function testValidate($data)
{
$object = new DataObject();
$object->setData($this->attributeName, $data);
$this->assertTrue($this->model->validate($object));
$this->assertTrue($this->model->validate($object));
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:CustomlayoutupdateTest.php
示例2: render
/**
* Render grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
$actions = [];
$actions[] = ['url' => $this->getUrl('adminhtml/*/preview', ['id' => $row->getId()]), 'popup' => true, 'caption' => __('Preview')];
$this->getColumn()->setActions($actions);
return parent::render($row);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Action.php
示例3: afterSave
/**
* After save
*
* @param \Magento\Framework\DataObject $object
* @return $this|void
*/
public function afterSave($object)
{
$value = $object->getData($this->getAttribute()->getName());
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return;
}
try {
/** @var $uploader \Magento\MediaStorage\Model\File\Uploader */
$uploader = $this->_fileUploaderFactory->create(['fileId' => $this->getAttribute()->getName()]);
$uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
$uploader->setAllowRenameFiles(true);
$uploader->setFilesDispersion(true);
} catch (\Exception $e) {
return $this;
}
$path = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath('catalog/product/');
$uploader->save($path);
$fileName = $uploader->getUploadedFileName();
if ($fileName) {
$object->setData($this->getAttribute()->getName(), $fileName);
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
}
return $this;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:32,代码来源:Image.php
示例4: render
/**
* Renders Purchases value
*
* @param \Magento\Framework\DataObject $row
* @return \Magento\Framework\Phrase|string
*/
public function render(\Magento\Framework\DataObject $row)
{
if (($value = $row->getData($this->getColumn()->getIndex())) > 0) {
return $value;
}
return __('Unlimited');
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Purchases.php
示例5: afterSave
/**
* Method is invoked after save
*
* @param \Magento\Framework\DataObject $object
* @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
*/
public function afterSave($object)
{
if ($object->getOrderItem()) {
$object->getOrderItem()->save();
}
return parent::beforeSave($object);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Item.php
示例6: displayPrices
/**
* Get "double" prices html (block with base and place currency)
*
* @param \Magento\Framework\DataObject $dataObject
* @param float $basePrice
* @param float $price
* @param bool $strong
* @param string $separator
* @return string
*/
public function displayPrices($dataObject, $basePrice, $price, $strong = false, $separator = '<br/>')
{
$order = false;
if ($dataObject instanceof \Magento\Sales\Model\Order) {
$order = $dataObject;
} else {
$order = $dataObject->getOrder();
}
if ($order && $order->isCurrencyDifferent()) {
$res = '<strong>';
$res .= $order->formatBasePrice($basePrice);
$res .= '</strong>' . $separator;
$res .= '[' . $order->formatPrice($price) . ']';
} elseif ($order) {
$res = $order->formatPrice($price);
if ($strong) {
$res = '<strong>' . $res . '</strong>';
}
} else {
$res = $this->priceCurrency->format($price);
if ($strong) {
$res = '<strong>' . $res . '</strong>';
}
}
return $res;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:36,代码来源:Admin.php
示例7: afterSave
/**
* Save uploaded file and set its name to category
*
* @param \Magento\Framework\DataObject $object
* @return \Magento\Catalog\Model\Category\Attribute\Backend\Image
*/
public function afterSave($object)
{
$value = $object->getData($this->getAttribute()->getName() . '_additional_data');
// if no image was set - nothing to do
if (empty($value) && empty($_FILES)) {
return $this;
}
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return $this;
}
$path = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath('catalog/category/');
try {
/** @var $uploader \Magento\MediaStorage\Model\File\Uploader */
$uploader = $this->_fileUploaderFactory->create(['fileId' => $this->getAttribute()->getName()]);
$uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
$uploader->setAllowRenameFiles(true);
$result = $uploader->save($path);
$object->setData($this->getAttribute()->getName(), $result['file']);
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
} catch (\Exception $e) {
if ($e->getCode() != \Magento\MediaStorage\Model\File\Uploader::TMP_NAME_EMPTY) {
$this->_logger->critical($e);
}
}
return $this;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:34,代码来源:Image.php
示例8: render
/**
* Render a grid cell as options
*
* @param \Magento\Framework\DataObject $row
* @return string|void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function render(\Magento\Framework\DataObject $row)
{
$options = $this->_getOptions();
$showMissingOptionValues = (bool) $this->getColumn()->getShowMissingOptionValues();
if (!empty($options) && is_array($options)) {
//transform option format
$output = [];
foreach ($options as $option) {
$output[$option['value']] = $option['label'];
}
$value = $row->getData($this->getColumn()->getIndex());
if (is_array($value)) {
$res = [];
foreach ($value as $item) {
if (isset($output[$item])) {
$res[] = $this->escapeHtml($output[$item]);
} elseif ($showMissingOptionValues) {
$res[] = $this->escapeHtml($item);
}
}
return implode(', ', $res);
} elseif (isset($output[$value])) {
return $this->escapeHtml($output[$value]);
} elseif (in_array($value, $output)) {
return $this->escapeHtml($value);
}
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:35,代码来源:Options.php
示例9: beforeSave
/**
* Set new increment id
*
* @param \Magento\Framework\DataObject $object
* @return $this
*/
public function beforeSave($object)
{
if (!$object->getId()) {
$this->getAttribute()->getEntity()->setNewIncrementId($object);
}
return $this;
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Increment.php
示例10: beforeSave
/**
* Performed before data is saved
*
* @param \Magento\Framework\DataObject $object
* @return $this
*/
public function beforeSave($object)
{
if ($object->getShipment()) {
$object->setParentId($object->getShipment()->getId());
}
return parent::beforeSave($object);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Child.php
示例11: render
/**
* Render minimal price for downloadable products
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
if ($row->getTypeId() == 'downloadable') {
$row->setPrice($row->getPrice());
}
return parent::render($row);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Price.php
示例12: render
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
if ($data = $row->getData($this->getColumn()->getIndex())) {
return $this->dateTimeFormatter->formatObject($this->_localeDate->date(new \DateTime($data)), $this->_getFormat());
}
return $this->getColumn()->getDefault();
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:13,代码来源:Date.php
示例13: _prepareArrayRow
/**
* @param \Magento\Framework\DataObject $row
*/
public function _prepareArrayRow(\Magento\Framework\DataObject $row)
{
$options = [];
$options['option_' . $this->_getAttributeRenderer()->calcOptionHash($row->getData('attribute'))] = 'selected="selected"';
$options['option_' . $this->_getDatafieldRenderer()->calcOptionHash($row->getData('datafield'))] = 'selected="selected"';
$row->setData('option_extra_attrs', $options);
}
开发者ID:dotmailer,项目名称:dotmailer-magento2-extension,代码行数:10,代码来源:Customdatafields.php
示例14: render
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function render(\Magento\Framework\DataObject $row)
{
$values = $this->_getValues();
$value = $row->getData($this->getColumn()->getIndex());
$checked = '';
if (is_array($values)) {
$checked = in_array($value, $values) ? ' checked="checked"' : '';
} else {
$checkedValue = $this->getColumn()->getValue();
if ($checkedValue !== null) {
$checked = $value === $checkedValue ? ' checked="checked"' : '';
}
}
$disabled = '';
$disabledValues = $this->getColumn()->getDisabledValues();
if (is_array($disabledValues)) {
$disabled = in_array($value, $disabledValues) ? ' disabled="disabled"' : '';
} else {
$disabledValue = $this->getColumn()->getDisabledValue();
if ($disabledValue !== null) {
$disabled = $value === $disabledValue ? ' disabled="disabled"' : '';
}
}
$this->setDisabled($disabled);
if ($this->getNoObjectId() || $this->getColumn()->getUseIndex()) {
$v = $value;
} else {
$v = $row->getId() != "" ? $row->getId() : $value;
}
return $this->_getCheckboxHtml($v, $checked);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:39,代码来源:Checkbox.php
示例15: beforeSave
/**
* We need reset attribute set id to attribute after related simple product was saved
*
* @param \Magento\Catalog\Model\ResourceModel\Product $subject
* @param \Magento\Framework\DataObject $object
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(\Magento\Catalog\Model\ResourceModel\Product $subject, \Magento\Framework\DataObject $object)
{
/** @var \Magento\Catalog\Model\Product $object */
if ($object->getTypeId() == Configurable::TYPE_CODE) {
$object->getTypeInstance()->getSetAttributes($object);
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:Product.php
示例16: render
public function render(DataObject $row)
{
$storeViewId = $this->getRequest()->getParam('store');
$banner = $this->_bannerFactory->create()->setStoreViewId($storeViewId)->load($row->getId());
$srcImage = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $banner->getImage();
return '<image width="150" height="50" src ="' . $srcImage . '" alt="' . $banner->getImage() . '" >';
}
开发者ID:mrtuvn,项目名称:m2ce.dev,代码行数:7,代码来源:Image.php
示例17: formatValue
/**
* Format total value based on order currency
*
* @param \Magento\Framework\DataObject $total
* @return string
*/
public function formatValue($total)
{
if (!$total->getIsFormated()) {
return $this->_adminHelper->displayPrices($this->getOrder(), $total->getBaseValue(), $total->getValue());
}
return $total->getValue();
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:13,代码来源:Totals.php
示例18: aroundGetItemQty
/**
* Get item qty
*
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
* @param callable $proceed
* @param \Magento\Framework\DataObject $item
*
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGetItemQty(\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, \Closure $proceed, \Magento\Framework\DataObject $item)
{
if ($item->getProduct()->getTypeId() == \Magento\Bundle\Model\Product\Type::TYPE_CODE) {
return '';
}
return $proceed($item);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Sidebar.php
示例19: _beforeSave
/**
* Prepare data before save
*
* @param \Magento\Framework\DataObject $object
* @return $this
*/
protected function _beforeSave($object)
{
if (!$object->getData($this->getAttribute()->getAttributeCode())) {
$object->setData($this->getAttribute()->getAttributeCode(), $this->_storeManager->getStore()->getId());
}
return $this;
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Store.php
示例20: beforeSave
/**
* Method is invoked before save
*
* @param \Magento\Framework\DataObject $object
* @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
*/
public function beforeSave($object)
{
if ($object->getCreditmemo()) {
$object->setParentId($object->getCreditmemo()->getId());
}
return parent::beforeSave($object);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:Child.php
注:本文中的Magento\Framework\DataObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论