Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractRepository.php
Go to the documentation of this file.
1 <?php
7 
12 abstract class AbstractRepository implements RepositoryInterface
13 {
17  protected $attributes;
18 
23 
28  public function __construct(
29  \Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository,
30  \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
31  ) {
32  $this->productAttributeRepository = $productAttributeRepository;
33  $this->searchCriteriaBuilder = $searchCriteriaBuilder;
34  }
35 
39  abstract protected function buildSearchCriteria();
40 
44  public function getList()
45  {
46  if (null == $this->attributes) {
47  $this->attributes = $this->productAttributeRepository
48  ->getList($this->buildSearchCriteria())
49  ->getItems();
50  }
51  return $this->attributes;
52  }
53 }
__construct(\Magento\Catalog\Api\ProductAttributeRepositoryInterface $productAttributeRepository, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder)
$productAttributeRepository