I'm new to Magento and working on upgrading an existing project to 2.4.3. When running php -dmemory_limit=5G bin/magento setup:di:compile
I'm encountering an error:
Incompatible argument type: Required type: \Aheadworks\Blog\Api\CategoryManagementInterface. Actual type: array; File:
No line number is provided. I've seen in other posts that this can be related to types not being declared in the comments, but I believe all my types are declared. What could be going wrong?
<?php declare(strict_types=1);
namespace X\Blog\Block\Sidebar;
use Aheadworks\Blog\Api\CategoryRepositoryInterface;
use Aheadworks\Blog\Api\Data\CategoryInterface;
use Aheadworks\Blog\Block\Sidebar\Category as AwCategory;
use Aheadworks\Blog\Model\Config;
use Aheadworks\Blog\Model\Url;
use Aheadworks\Blog\Model\Source\Category\Status as CategoryStatus;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\View\Element\Template\Context;
/**
* Class Category
*/
class Category extends AwCategory
{
const CURRENT_CSS_CLASS = 'current';
/**
* @var CategoryRepositoryInterface
*/
private $categoryRepository;
/**
* @var SearchCriteriaBuilder
*/
private $searchCriteriaBuilder;
/**
* @var StoreManagerInterface
*/
private $storeManager;
/**
* @param Context $context
* @param CategoryRepositoryInterface $categoryRepository
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param Config $config
* @param Url $url
* @param array $data
*/
public function __construct(
Context $context,
CategoryRepositoryInterface $categoryRepository,
SearchCriteriaBuilder $searchCriteriaBuilder,
Config $config,
Url $url,
array $data = []
) {
$this->categoryRepository = $categoryRepository;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->storeManager = $context->getStoreManager();
parent::__construct(
$context,
$categoryRepository,
$searchCriteriaBuilder,
$config,
$url,
$data
);
}
/**
* Retrieve Siblings categories
*
* @return CategoryInterface[]
*/
public function getSiblingsCategories()
{
$parentCategoryId = $this->getParentCategoryId();
$this->searchCriteriaBuilder
->addFilter(CategoryInterface::STATUS, CategoryStatus::ENABLED)
->addFilter(CategoryInterface::STORE_IDS, $this->storeManager->getStore()->getId())
->addFilter(CategoryInterface::PARENT_ID, $parentCategoryId)
->addSortOrder(
new SortOrder(
[
SortOrder::FIELD => CategoryInterface::SORT_ORDER,
SortOrder::DIRECTION => SortOrder::SORT_ASC
]
)
);
return $this->categoryRepository->getList($this->searchCriteriaBuilder->create())->getItems();
}
/**
* Get Parent Category Id
*
* @return int|null
*/
public function getParentCategoryId()
{
$currentCategory = $this->getCurrentCategory();
return $currentCategory ? $currentCategory->getParentId() : null;
}
/**
* Get additional css class for category item
*
* @param int $categoryItemIndex
* @param int $categoryId
*
* @return string
*/
public function getAdditionalClass($categoryItemIndex, $categoryId = 0)
{
$cssClasses = [];
$categoryLimit = $this->getNumCategoriesToDisplay();
$currentCategory = $this->getCurrentCategory();
if ($categoryLimit > 0 && $categoryItemIndex > $categoryLimit) {
$cssClasses []= self::HIDE_CSS_CLASS;
}
if ($categoryLimit > 0 && $categoryItemIndex == $categoryLimit) {
$cssClasses []= self::SHADED_CSS_CLASS;
}
if ($categoryId && $currentCategory && $currentCategory->getId() == $categoryId) {
$cssClasses []= self::CURRENT_CSS_CLASS;
}
return implode(' ', $cssClasses);
}
}