本文整理汇总了PHP中Magento\Framework\DataObject::getDescription方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::getDescription方法的具体用法?PHP DataObject::getDescription怎么用?PHP DataObject::getDescription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\DataObject
的用法示例。
在下文中一共展示了DataObject::getDescription方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
$dots = '';
if (strlen($row->getDescription()) > 512) {
$dots = ' . . . ';
}
return '<span class="grid-row-title">' . $row->getTitle() . '</span>' . ($row->getDescription() ? '<br />' . substr($row->getDescription(), 0, 512) . $dots : '');
}
示例2: render
/**
* Renders grid column
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function render(\Magento\Framework\DataObject $row)
{
return '<span class="grid-row-title">' . $row->getTitle() . '</span>' . ($row->getDescription() ? '<br />' . $row->getDescription() : '');
}
示例3: _addField
/**
* Add field to Options form based on parameter configuration
*
* @param \Magento\Framework\DataObject $parameter
* @return \Magento\Framework\Data\Form\Element\AbstractElement
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _addField($parameter)
{
$form = $this->getForm();
$fieldset = $this->getMainFieldset();
//$form->getElement('options_fieldset');
// prepare element data with values (either from request of from default values)
$fieldName = $parameter->getKey();
$data = ['name' => $form->addSuffixToName($fieldName, 'parameters'), 'label' => __($parameter->getLabel()), 'required' => $parameter->getRequired(), 'class' => 'widget-option', 'note' => __($parameter->getDescription())];
if ($values = $this->getWidgetValues()) {
$data['value'] = isset($values[$fieldName]) ? $values[$fieldName] : '';
} else {
$data['value'] = $parameter->getValue();
//prepare unique id value
if ($fieldName == 'unique_id' && $data['value'] == '') {
$data['value'] = md5(microtime(1));
}
}
// prepare element dropdown values
if ($values = $parameter->getValues()) {
// dropdown options are specified in configuration
$data['values'] = [];
foreach ($values as $option) {
$data['values'][] = ['label' => __($option['label']), 'value' => $option['value']];
}
// otherwise, a source model is specified
} elseif ($sourceModel = $parameter->getSourceModel()) {
$data['values'] = $this->_sourceModelPool->get($sourceModel)->toOptionArray();
}
// prepare field type or renderer
$fieldRenderer = null;
$fieldType = $parameter->getType();
// hidden element
if (!$parameter->getVisible()) {
$fieldType = 'hidden';
// just an element renderer
} elseif ($fieldType && $this->_isClassName($fieldType)) {
$fieldRenderer = $this->getLayout()->createBlock($fieldType);
$fieldType = $this->_defaultElementType;
}
// instantiate field and render html
$field = $fieldset->addField($this->getMainFieldsetHtmlId() . '_' . $fieldName, $fieldType, $data);
if ($fieldRenderer) {
$field->setRenderer($fieldRenderer);
}
// extra html preparations
if ($helper = $parameter->getHelperBlock()) {
$helperBlock = $this->getLayout()->createBlock($helper->getType(), '', ['data' => $helper->getData()]);
if ($helperBlock instanceof \Magento\Framework\DataObject) {
$helperBlock->setConfig($helper->getData())->setFieldsetId($fieldset->getId())->prepareElementHtml($field);
}
}
// dependencies from other fields
$dependenceBlock = $this->getChildBlock('form_after');
$dependenceBlock->addFieldMap($field->getId(), $fieldName);
if ($parameter->getDepends()) {
foreach ($parameter->getDepends() as $from => $row) {
$values = isset($row['values']) ? array_values($row['values']) : (string) $row['value'];
$dependenceBlock->addFieldDependence($fieldName, $from, $values);
}
}
return $field;
}
示例4: _parseItemDescription
/**
* Parse item description
*
* @param \Magento\Framework\DataObject $item
* @return array
*/
protected function _parseItemDescription($item)
{
$matches = [];
$description = $item->getDescription();
if (preg_match_all('/<li.*?>(.*?)<\\/li>/i', $description, $matches)) {
return $matches[1];
}
return [$description];
}