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


PHP Framework\Object类代码示例

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


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

示例1: render

 /**
  * Renders grid column
  *
  * @param \Magento\Framework\Object $row
  * @return string
  */
 public function render(\Magento\Framework\Object $row)
 {
     //@todo: check this logic manually
     if ($data = $row->getData($this->getColumn()->getIndex())) {
         switch ($this->getColumn()->getPeriodType()) {
             case 'month':
                 $dateFormat = 'yyyy-MM';
                 break;
             case 'year':
                 $dateFormat = 'yyyy';
                 break;
             default:
                 $dateFormat = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT;
                 break;
         }
         $format = $this->_getFormat();
         try {
             $data = $this->getColumn()->getGmtoffset() ? \IntlDateFormatter::formatObject($this->_localeDate->date(new \DateTime($data)), $format) : \IntlDateFormatter::formatObject($this->_localeDate->date(new \DateTime($data), null, false), $format);
         } catch (\Exception $e) {
             $data = $this->getColumn()->getTimezone() ? \IntlDateFormatter::formatObject($this->_localeDate->date(new \DateTime($data)), $format) : \IntlDateFormatter::formatObject($this->_localeDate->date(new \DateTime($data), null, false), $format);
         }
         return $data;
     }
     return $this->getColumn()->getDefault();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:Date.php

示例2: afterSave

 /**
  * After save
  *
  * @param \Magento\Framework\Object $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\Core\Model\File\Uploader */
         $uploader = $this->_fileUploaderFactory->create(array('fileId' => $this->getAttribute()->getName()));
         $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'));
         $uploader->setAllowRenameFiles(true);
         $uploader->setFilesDispersion(true);
     } catch (\Exception $e) {
         return $this;
     }
     $path = $this->_filesystem->getDirectoryRead(\Magento\Framework\App\Filesystem::MEDIA_DIR)->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:aiesh,项目名称:magento2,代码行数:32,代码来源:Image.php

示例3: render

 /**
  * Render minimal price for downloadable products
  *
  * @param \Magento\Framework\Object $row
  * @return string
  */
 public function render(\Magento\Framework\Object $row)
 {
     if ($row->getTypeId() == 'downloadable') {
         $row->setPrice($row->getPrice());
     }
     return parent::render($row);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Price.php

示例4: render

 /**
  * Render a grid cell as options
  *
  * @param \Magento\Framework\Object $row
  * @return string|void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function render(\Magento\Framework\Object $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:shabbirvividads,项目名称:magento2,代码行数:35,代码来源:Options.php

示例5: render

 /**
  * Render grid column
  *
  * @param \Magento\Framework\Object $row
  * @return string
  */
 public function render(\Magento\Framework\Object $row)
 {
     $actions = [];
     $actions[] = ['url' => $this->getUrl('adminhtml/*/preview', ['id' => $row->getId()]), 'popup' => true, 'caption' => __('Preview')];
     $this->getColumn()->setActions($actions);
     return parent::render($row);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Action.php

示例6: initialize

 /**
  * Set order state and status
  *
  * @param string $paymentAction
  * @param \Magento\Framework\Object $stateObject
  * @return void
  */
 public function initialize($paymentAction, $stateObject)
 {
     $state = $this->getConfigData('order_status');
     $stateObject->setState($state);
     $stateObject->setStatus($state);
     $stateObject->setIsNotified(false);
 }
开发者ID:marcinNS,项目名称:magento2-samples,代码行数:14,代码来源:Payinstore.php

示例7: afterSave

 /**
  * Method is invoked after save
  *
  * @param \Magento\Framework\Object $object
  * @return \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
  */
 public function afterSave($object)
 {
     if ($object->getOrderItem()) {
         $object->getOrderItem()->save();
     }
     return parent::beforeSave($object);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Item.php

示例8: render

 /**
  * Renders Purchases value
  *
  * @param \Magento\Framework\Object $row
  * @return string
  */
 public function render(\Magento\Framework\Object $row)
 {
     if (($value = $row->getData($this->getColumn()->getIndex())) > 0) {
         return $value;
     }
     return __('Unlimited');
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Purchases.php

示例9: _getParentTransactionId

 /**
  * Get payflow transaction id from parent transaction
  *
  * @param \Magento\Framework\Object $payment
  * @return string
  */
 protected function _getParentTransactionId(\Magento\Framework\Object $payment)
 {
     if ($payment->getParentTransactionId()) {
         return $payment->getTransaction($payment->getParentTransactionId())->getAdditionalInformation(self::TRANSPORT_PAYFLOW_TXN_ID);
     }
     return $payment->getParentTransactionId();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Pro.php

示例10: beforeSave

 /**
  * We need reset attribute set id to attribute after related simple product was saved
  *
  * @param \Magento\Catalog\Model\Resource\Product $subject
  * @param \Magento\Framework\Object $object
  * @return void
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeSave(\Magento\Catalog\Model\Resource\Product $subject, \Magento\Framework\Object $object)
 {
     /** @var \Magento\Catalog\Model\Product $object */
     if ($object->getTypeId() == Configurable::TYPE_CODE) {
         $object->getTypeInstance()->getSetAttributes($object);
     }
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:16,代码来源:Product.php

示例11: processTaxData

 /**
  * @param \Magento\Framework\Object $observer
  * @return \Magento\Quote\Model\Quote\Item
  */
 public function processTaxData($observer)
 {
     /** @var  \Magento\Quote\Model\Quote\Item $item */
     $item = $observer->getEvent()->getItem();
     $item->setRowTotal($this->getRowTotal($item))->setRowTotalInclTax($this->getRowTotalInclTax($item))->setPrice($this->getUnitDisplayPriceExclTax($item))->setPriceInclTax($this->getUnitDisplayPriceInclTax($item));
     return $item;
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:11,代码来源:Item.php

示例12: validate

 /**
  * Validate
  *
  * @param \Magento\Framework\Object $object Quote
  * @return bool
  */
 public function validate(\Magento\Framework\Object $object)
 {
     $all = $this->getAggregator() === 'all';
     $true = (bool) $this->getValue();
     $found = false;
     foreach ($object->getAllItems() as $item) {
         $found = $all;
         foreach ($this->getConditions() as $cond) {
             $validated = $cond->validate($item);
             if ($all && !$validated || !$all && $validated) {
                 $found = $validated;
                 break;
             }
         }
         if ($found && $true || !$true && $found) {
             break;
         }
     }
     // found an item and we're looking for existing one
     if ($found && $true) {
         return true;
     } elseif (!$found && !$true) {
         // not found and we're making sure it doesn't exist
         return true;
     }
     return false;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:33,代码来源:Found.php

示例13: afterSave

 /**
  * Save uploaded file and set its name to category
  *
  * @param \Magento\Framework\Object $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:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:Image.php

示例14: displayPrices

 /**
  * Get "double" prices html (block with base and place currency)
  *
  * @param   \Magento\Framework\Object $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:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:Admin.php

示例15: getUrl

 /**
  * Create url for passed item using passed url model
  * @param \Magento\Framework\Object $item
  * @return string
  */
 public function getUrl($item)
 {
     if ($this->_authorization->isAllowed('Magento_Customer::manage') && $item->getCustomerId()) {
         return parent::getUrl($item);
     }
     return false;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:12,代码来源:UrlGenerator.php


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