本文整理汇总了PHP中Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface::extractExtensionAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP JoinProcessorInterface::extractExtensionAttributes方法的具体用法?PHP JoinProcessorInterface::extractExtensionAttributes怎么用?PHP JoinProcessorInterface::extractExtensionAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface
的用法示例。
在下文中一共展示了JoinProcessorInterface::extractExtensionAttributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateWithArray
/**
* Populate data object using data in array format.
*
* @param mixed $dataObject
* @param array $data
* @param string $interfaceName
* @return $this
*/
public function populateWithArray($dataObject, array $data, $interfaceName)
{
if ($dataObject instanceof ExtensibleDataInterface) {
$data = $this->joinProcessor->extractExtensionAttributes(get_class($dataObject), $data);
}
$this->_setDataValues($dataObject, $data, $interfaceName);
return $this;
}
示例2: _fetchAll
/**
* Fetch collection data
*
* @param Select $select
* @return array
*/
protected function _fetchAll(Select $select)
{
$data = $this->_fetchStrategy->fetchAll($select, $this->_bindParams);
if ($this->extensionAttributesJoinProcessor) {
foreach ($data as $key => $dataItem) {
$data[$key] = $this->extensionAttributesJoinProcessor->extractExtensionAttributes($this->_itemObjectClass, $dataItem);
}
}
return $data;
}
示例3: getList
/**
* {@inheritdoc}
*/
public function getList(SearchCriteriaInterface $searchCriteria)
{
$searchResults = $this->searchResultsFactory->create();
$searchResults->setSearchCriteria($searchCriteria);
/** @var \Magento\Customer\Model\Resource\Group\Collection $collection */
$collection = $this->groupFactory->create()->getCollection();
$groupInterfaceName = 'Magento\\Customer\\Api\\Data\\GroupInterface';
$this->extensionAttributesJoinProcessor->process($collection, $groupInterfaceName);
$collection->addTaxClass();
//Add filters from root filter group to the collection
/** @var FilterGroup $group */
foreach ($searchCriteria->getFilterGroups() as $group) {
$this->addFilterGroupToCollection($group, $collection);
}
$sortOrders = $searchCriteria->getSortOrders();
/** @var \Magento\Framework\Api\SortOrder $sortOrder */
if ($sortOrders) {
foreach ($searchCriteria->getSortOrders() as $sortOrder) {
$field = $this->translateField($sortOrder->getField());
$collection->addOrder($field, $sortOrder->getDirection() == SearchCriteriaInterface::SORT_ASC ? 'ASC' : 'DESC');
}
} else {
// set a default sorting order since this method is used constantly in many
// different blocks
$field = $this->translateField('id');
$collection->addOrder($field, 'ASC');
}
$collection->setCurPage($searchCriteria->getCurrentPage());
$collection->setPageSize($searchCriteria->getPageSize());
/** @var \Magento\Customer\Api\Data\GroupInterface[] $groups */
$groups = [];
/** @var \Magento\Customer\Model\Group $group */
foreach ($collection as $group) {
/** @var \Magento\Customer\Api\Data\GroupInterface $groupDataObject */
$groupDataObject = $this->groupDataFactory->create()->setId($group->getId())->setCode($group->getCode())->setTaxClassId($group->getTaxClassId())->setTaxClassName($group->getTaxClassName());
$data = $group->getData();
$data = $this->extensionAttributesJoinProcessor->extractExtensionAttributes($groupInterfaceName, $data);
if (isset($data[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]) && $data[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY] instanceof GroupExtensionInterface) {
$groupDataObject->setExtensionAttributes($data[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
}
$groups[] = $groupDataObject;
}
$searchResults->setTotalCount($collection->getSize());
return $searchResults->setItems($groups);
}