Skip to content

Updated classes and interfaces and marked them as API #32113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 2.5-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/code/Magento/Catalog/Model/Layer/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
*/
namespace Magento\Catalog\Model\Layer;

/**
* Class Resolver
*
* @api
*/
class Resolver
{
const CATALOG_LAYER_CATEGORY = 'category';
Expand All @@ -16,19 +21,19 @@ class Resolver
*
* @var array
*/
protected $layersPool;
private $layersPool;

/**
* Filter factory
*
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;
private $objectManager;

/**
* @var \Magento\Catalog\Model\Layer
*/
protected $layer = null;
private $layer = null;

/**
* @param \Magento\Framework\ObjectManagerInterface $objectManager
Expand Down
37 changes: 19 additions & 18 deletions app/code/Magento/Sales/Setup/SalesSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @codeCoverageIgnore
* @api
*/
class SalesSetup extends EavSetup
{
Expand All @@ -45,12 +46,12 @@ class SalesSetup extends EavSetup
/**
* @var ScopeConfigInterface
*/
protected $config;
private $config;

/**
* @var EncryptorInterface
*/
protected $encryptor;
private $encryptor;

/**
* @var string
Expand Down Expand Up @@ -81,9 +82,9 @@ public function __construct(
/**
* List of entities converted from EAV to flat data structure
*
* @var $_flatEntityTables array
* @var array $flatEntityTables
*/
protected $_flatEntityTables = [
private $flatEntityTables = [
'order' => 'sales_order',
'order_payment' => 'sales_order_payment',
'order_item' => 'sales_order_item',
Expand All @@ -104,17 +105,17 @@ public function __construct(
/**
* List of entities used with separate grid table
*
* @var string[] $_flatEntitiesGrid
* @var string[] $flatEntitiesGrid
*/
protected $_flatEntitiesGrid = ['order', 'invoice', 'shipment', 'creditmemo'];
private $flatEntitiesGrid = ['order', 'invoice', 'shipment', 'creditmemo'];

/**
* Check if table exist for flat entity
*
* @param string $table
* @return bool
*/
protected function _flatTableExist($table)
private function flatTableExist($table)
{
$tablesList = $this->getConnection()
->listTables();
Expand All @@ -135,13 +136,13 @@ protected function _flatTableExist($table)
public function addAttribute($entityTypeId, $code, array $attr)
{
if (isset(
$this->_flatEntityTables[$entityTypeId]
) && $this->_flatTableExist(
$this->_flatEntityTables[$entityTypeId]
$this->flatEntityTables[$entityTypeId]
) && $this->flatTableExist(
$this->flatEntityTables[$entityTypeId]
)
) {
$this->_addFlatAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr);
$this->_addGridAttribute($this->_flatEntityTables[$entityTypeId], $code, $attr, $entityTypeId);
$this->addFlatAttribute($this->flatEntityTables[$entityTypeId], $code, $attr);
$this->addGridAttribute($this->flatEntityTables[$entityTypeId], $code, $attr, $entityTypeId);
} else {
parent::addAttribute($entityTypeId, $code, $attr);
}
Expand All @@ -156,14 +157,14 @@ public function addAttribute($entityTypeId, $code, array $attr)
* @param array $attr
* @return $this
*/
protected function _addFlatAttribute($table, $attribute, $attr)
private function addFlatAttribute($table, $attribute, $attr)
{
$tableInfo = $this->getConnection()
->describeTable($this->getTable($table));
if (isset($tableInfo[$attribute])) {
return $this;
}
$columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
$columnDefinition = $this->getAttributeColumnDefinition($attribute, $attr);
$this->getConnection()->addColumn(
$this->getTable($table),
$attribute,
Expand All @@ -181,10 +182,10 @@ protected function _addFlatAttribute($table, $attribute, $attr)
* @param string $entityTypeId
* @return $this
*/
protected function _addGridAttribute($table, $attribute, $attr, $entityTypeId)
private function addGridAttribute($table, $attribute, $attr, $entityTypeId)
{
if (in_array($entityTypeId, $this->_flatEntitiesGrid) && !empty($attr['grid'])) {
$columnDefinition = $this->_getAttributeColumnDefinition($attribute, $attr);
if (in_array($entityTypeId, $this->flatEntitiesGrid) && !empty($attr['grid'])) {
$columnDefinition = $this->getAttributeColumnDefinition($attribute, $attr);
$this->getConnection()->addColumn(
$this->getTable($table . '_grid'),
$attribute,
Expand All @@ -203,7 +204,7 @@ protected function _addGridAttribute($table, $attribute, $attr, $entityTypeId)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _getAttributeColumnDefinition($code, $data)
private function getAttributeColumnDefinition($code, $data)
{
// Convert attribute type to column info
$data['type'] = isset($data['type']) ? $data['type'] : 'varchar';
Expand Down
91 changes: 74 additions & 17 deletions lib/internal/Magento/Framework/Api/SearchCriteriaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,36 @@

namespace Magento\Framework\Api;

use Magento\Framework\Api\Search\FilterGroup;
use Magento\Framework\Api\Search\FilterGroupBuilder;
use Magento\Framework\Api\SimpleBuilderInterface;

/**
* Builder for SearchCriteria Service Data Object
*
* @api
*/
class SearchCriteriaBuilder extends AbstractSimpleObjectBuilder
class SearchCriteriaBuilder implements SimpleBuilderInterface
{
/**
* @var array
*/
private $data;

/**
* @var FilterGroupBuilder
*/
protected $_filterGroupBuilder;
private $filterGroupBuilder;

/**
* @var FilterBuilder
*/
private $filterBuilder;

/**
* @var \Magento\Framework\Api\FilterBuilder
* @var ObjectFactory
*/
protected $filterBuilder;
private $objectFactory;

/**
* @param ObjectFactory $objectFactory
Expand All @@ -33,11 +47,9 @@ public function __construct(
FilterGroupBuilder $filterGroupBuilder,
FilterBuilder $filterBuilder
) {
parent::__construct(
$objectFactory
);
$this->_filterGroupBuilder = $filterGroupBuilder;
$this->filterGroupBuilder = $filterGroupBuilder;
$this->filterBuilder = $filterBuilder;
$this->objectFactory = $objectFactory;
}

/**
Expand All @@ -49,20 +61,51 @@ public function create()
{
//Initialize with empty array if not set
if (empty($this->data[SearchCriteria::FILTER_GROUPS])) {
$this->_set(SearchCriteria::FILTER_GROUPS, []);
$this->set(SearchCriteria::FILTER_GROUPS, []);
}

$dataObjectType = $this->getDataObjectType();
$dataObject = $this->objectFactory->create($dataObjectType, ['data' => $this->data]);
$this->data = [];

return $dataObject;
}

/**
* Return the Data type class name
*
* @return string
*/
private function getDataObjectType()
{
$dataObjectType = '';
$pattern = '/(?<data_object>.*?)Builder(\\Interceptor)?/';
if (preg_match($pattern, get_class($this), $match)) {
$dataObjectType = $match['data_object'];
}
return parent::create();

return $dataObjectType;
}

/**
* Return data Object data.
*
* @return array
*/
public function getData()
{
return $this->data;
}

/**
* Create a filter group based on the filter array provided and add to the filter groups
*
* @param \Magento\Framework\Api\Filter[] $filter
* @param Filter[] $filter
* @return $this
*/
public function addFilters(array $filter)
{
$this->data[SearchCriteria::FILTER_GROUPS][] = $this->_filterGroupBuilder->setFilters($filter)->create();
$this->data[SearchCriteria::FILTER_GROUPS][] = $this->filterGroupBuilder->setFilters($filter)->create();
return $this;
}

Expand All @@ -86,12 +129,12 @@ public function addFilter($field, $value, $conditionType = 'eq')
/**
* Set filter groups
*
* @param \Magento\Framework\Api\Search\FilterGroup[] $filterGroups
* @param FilterGroup[] $filterGroups
* @return $this
*/
public function setFilterGroups(array $filterGroups)
{
return $this->_set(SearchCriteria::FILTER_GROUPS, $filterGroups);
return $this->set(SearchCriteria::FILTER_GROUPS, $filterGroups);
}

/**
Expand All @@ -117,7 +160,7 @@ public function addSortOrder($sortOrder)
*/
public function setSortOrders(array $sortOrders)
{
return $this->_set(SearchCriteria::SORT_ORDERS, $sortOrders);
return $this->set(SearchCriteria::SORT_ORDERS, $sortOrders);
}

/**
Expand All @@ -128,7 +171,7 @@ public function setSortOrders(array $sortOrders)
*/
public function setPageSize($pageSize)
{
return $this->_set(SearchCriteria::PAGE_SIZE, $pageSize);
return $this->set(SearchCriteria::PAGE_SIZE, $pageSize);
}

/**
Expand All @@ -139,6 +182,20 @@ public function setPageSize($pageSize)
*/
public function setCurrentPage($currentPage)
{
return $this->_set(SearchCriteria::CURRENT_PAGE, $currentPage);
return $this->set(SearchCriteria::CURRENT_PAGE, $currentPage);
}

/**
* Overwrite data in Object.
*
* @param string $key
* @param mixed $value
* @return $this
*/
private function set($key, $value)
{
$this->data[$key] = $value;

return $this;
}
}
Loading