本文整理汇总了PHP中Magento\Framework\Object::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::getData方法的具体用法?PHP Object::getData怎么用?PHP Object::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postRequest
/**
* Post request into gateway
*
* @param Object $request
* @param ConfigInterface $config
*
* @return Object
* @throws \Exception
*/
public function postRequest(Object $request, ConfigInterface $config)
{
$result = new Object();
$clientConfig = ['maxredirects' => 5, 'timeout' => 30, 'verifypeer' => $config->getValue('verify_peer')];
if ($config->getValue('use_proxy')) {
$clientConfig['proxy'] = $config->getValue('proxy_host') . ':' . $config->getValue('proxy_port');
$clientConfig['httpproxytunnel'] = true;
$clientConfig['proxytype'] = CURLPROXY_HTTP;
}
/** @var ZendClient $client */
$client = $this->httpClientFactory->create();
$client->setUri((bool) $config->getValue('sandbox_flag') ? $config->getValue('transaction_url_test_mode') : $config->getValue('transaction_url'));
$client->setConfig($clientConfig);
$client->setMethod(\Zend_Http_Client::POST);
$client->setParameterPost($request->getData());
$client->setHeaders(['X-VPS-VIT-CLIENT-CERTIFICATION-ID' => '33baf5893fc2123d8b191d2d011b7fdc', 'X-VPS-Request-ID' => $this->mathRandom->getUniqueHash(), 'X-VPS-CLIENT-TIMEOUT' => 45]);
$client->setUrlEncodeBody(false);
try {
$response = $client->request();
$responseArray = [];
parse_str(strstr($response->getBody(), 'RESULT'), $responseArray);
$result->setData(array_change_key_case($responseArray, CASE_LOWER));
$result->setData('result_code', $result->getData('result'));
} catch (\Exception $e) {
$result->addData(['response_code' => -1, 'response_reason_code' => $e->getCode(), 'response_reason_text' => $e->getMessage()]);
throw $e;
} finally {
$this->logger->debug(['request' => $request->getData(), 'result' => $result->getData()], (array) $config->getValue('getDebugReplacePrivateDataKeys'), (bool) $config->getValue('debug'));
}
return $result;
}
示例2: render
/**
* {@inheritdoc}
*/
public function render(\Magento\Framework\Object $row)
{
if (!$row->getData($this->getColumn()->getIndex())) {
return null;
}
return '<a title="' . __('Edit Store') . '"
href="' . $this->getUrl('adminhtml/*/editGroup', ['group_id' => $row->getGroupId()]) . '">' . $this->escapeHtml($row->getData($this->getColumn()->getIndex())) . '</a>';
}
示例3: handle
/**
* {inheritdoc}
*/
public function handle(InfoInterface $payment, Object $response)
{
$importObject = [];
foreach ($this->fieldsToHandle as $field) {
if ($response->getData($field)) {
$importObject[$field] = $response->getData($field);
}
}
$this->paypalInfoManager->importToPayment($importObject, $payment);
}
示例4: handle
/**
* {inheritdoc}
*/
public function handle(InfoInterface $payment, Object $response)
{
if (!in_array($response->getData('result'), [Payflowpro::RESPONSE_CODE_DECLINED_BY_FILTER, Payflowpro::RESPONSE_CODE_FRAUDSERVICE_FILTER])) {
return;
}
$fraudMessages = ['RESPMSG' => $response->getData(self::RESPONSE_MESSAGE)];
if ($response->getData(self::FRAUD_RULES_XML)) {
$fraudMessages = array_merge($fraudMessages, $this->getFraudRulesDictionary($response->getData(self::FRAUD_RULES_XML)));
}
$this->paypalInfoManager->importToPayment([Info::FRAUD_FILTERS => array_merge($fraudMessages, (array) $payment->getAdditionalInformation(Info::FRAUD_FILTERS))], $payment);
}
示例5: _unserialize
/**
* Try to unserialize the attribute value
*
* @param \Magento\Framework\Object $object
* @return $this
*/
protected function _unserialize(\Magento\Framework\Object $object)
{
$attrCode = $this->getAttribute()->getAttributeCode();
if ($object->getData($attrCode)) {
try {
$unserialized = unserialize($object->getData($attrCode));
$object->setData($attrCode, $unserialized);
} catch (\Exception $e) {
$object->unsetData($attrCode);
}
}
return $this;
}
示例6: 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');
}
示例7: 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;
}
示例8: 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;
}
示例9: 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();
}
示例10: 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);
}
}
}
示例11: _beforeSave
/**
* Prepare data before save
*
* @param \Magento\Framework\Object $object
* @return $this
*/
protected function _beforeSave($object)
{
if (!$object->getData($this->getAttribute()->getAttributeCode())) {
$object->setData($this->getAttribute()->getAttributeCode(), $this->_storeManager->getStore()->getId());
}
return $this;
}
示例12: 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;
}
示例13: render
/**
* Renders grid column
*
* @param \Magento\Framework\Object $row
* @return string
*/
public function render(\Magento\Framework\Object $row)
{
$html = '<input type="text" ';
$html .= 'name="' . $this->getColumn()->getId() . '" ';
$html .= 'value="' . $row->getData($this->getColumn()->getIndex()) . '"';
$html .= 'class="input-text ' . $this->getColumn()->getInlineCss() . '"/>';
return $html;
}
示例14: render
/**
* Renders grid column
*
* @param \Magento\Framework\Object $row
* @return string
*/
public function render(\Magento\Framework\Object $row)
{
if ($data = $row->getData($this->getColumn()->getIndex())) {
$format = $this->_getFormat();
return \IntlDateFormatter::formatObject($this->_localeDate->date(new \DateTime($data)), $format);
}
return $this->getColumn()->getDefault();
}
示例15: beforeSave
/**
* Set attribute default value if value empty
*
* @param \Magento\Framework\Object $object
* @return $this
*/
public function beforeSave($object)
{
$attributeCode = $this->getAttribute()->getName();
if ($object->getData('use_config_' . $attributeCode)) {
$object->setData($attributeCode, '');
}
return $this;
}