本文整理汇总了PHP中Magento\Framework\Object类的典型用法代码示例。如果您正苦于以下问题:PHP Object类的具体用法?PHP Object怎么用?PHP Object使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getChildOrderIds
/**
* Return recurring payment child Orders Ids
*
*
* @param \Magento\Framework\Object $object
* @return array
*/
public function getChildOrderIds($object)
{
$adapter = $this->_getReadAdapter();
$bind = array(':payment_id' => $object->getId());
$select = $adapter->select()->from(array('main_table' => $this->getTable('recurring_payment_order')), array('order_id'))->where('payment_id=:payment_id');
return $adapter->fetchCol($select, $bind);
}
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Payment.php
示例17: beforeSave
/**
* Set new increment id
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
if (!$object->getId()) {
$this->getAttribute()->getEntity()->setNewIncrementId($object);
}
return $this;
}
开发者ID:aiesh,项目名称:magento2,代码行数:13,代码来源:Increment.php
示例18: formatValue
/**
* Format total value based on order currency
*
* @param \Magento\Framework\Object $total
* @return string
*/
public function formatValue($total)
{
if (!$total->getIsFormated()) {
return $this->_adminHelper->displayPrices($this->getOrder(), $total->getBaseValue(), $total->getValue());
}
return $total->getValue();
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Totals.php
示例19: getValue
/**
* Retrieve attribute value
*
* @param \Magento\Framework\Object $object
* @return mixed
*/
public function getValue(\Magento\Framework\Object $object)
{
$value = $object->getData($this->getAttribute()->getAttributeCode());
if (in_array($this->getConfigField('input'), ['select', 'boolean'])) {
$valueOption = $this->getOption($value);
if (!$valueOption) {
$opt = $this->_attrBooleanFactory->create();
$options = $opt->getAllOptions();
if ($options) {
foreach ($options as $option) {
if ($option['value'] == $value) {
$valueOption = $option['label'];
}
}
}
}
$value = $valueOption;
} elseif ($this->getConfigField('input') == 'multiselect') {
$value = $this->getOption($value);
if (is_array($value)) {
$value = implode(', ', $value);
}
}
return $value;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:31,代码来源:AbstractFrontend.php
示例20: aroundGetItemQty
/**
* Get item qty
*
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
* @param callable $proceed
* @param \Magento\Framework\Object $item
*
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGetItemQty(\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject, \Closure $proceed, \Magento\Framework\Object $item)
{
if ($item->getProduct()->getTypeId() == \Magento\GroupedProduct\Model\Product\Type\Grouped::TYPE_CODE) {
return '';
}
return $proceed($item);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:Sidebar.php
注:本文中的Magento\Framework\Object类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论