Magento的2:编译不兼容的参数类型时出错
问题描述:
下面我有错误,同时运行Magento的2:编译不兼容的参数类型时出错
PHP斌/ Magento的设置:迪:编译
Errors during compilation:
Ves\Blog\Model\ResourceModel\Author\Grid\Collection
Incompatible argument type: Required type: \Magento\Framework\DB\Adapter\AdapterInterface. Actual type: \Magento\Store\Model\StoreManagerInterface; File:
app/code/Ves/Blog/Model/ResourceModel/Author/Grid/Collection.php
新村/博客/型号/ ResourceModel /作者/表格/ Collection.php
namespace Ves\Blog\Model\ResourceModel\Author\Grid;
use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Search\AggregationInterface;
use Ves\Blog\Model\ResourceModel\Author\Collection as AuthorCollection;
class Collection extends AuthorCollection implements SearchResultInterface
{
protected $aggregations;
public function __construct(
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Store\Model\StoreManagerInterface $storeManager,
$mainTable,
$eventPrefix,
$eventObject,
$resourceModel,
$model = 'Magento\Framework\View\Element\UiComponent\DataProvider\Document',
$connection = null,
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
) {
parent::__construct(
$entityFactory,
$logger,
$fetchStrategy,
$eventManager,
$storeManager,
$connection,
$resource
);
$this->_eventPrefix = $eventPrefix;
$this->_eventObject = $eventObject;
$this->_init($model, $resourceModel);
$this->setMainTable($mainTable);
}
编辑1: \程序\代码\新村\博客\型号\ ResourceModel \作者\ Collection.php
<?php
namespace Ves\Blog\Model\ResourceModel\Author;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
protected function _construct()
{
$this->_init('Ves\Blog\Model\Author', 'Ves\Blog\Model\ResourceModel\Author');
}
}
请让我知道如何解决这个问题。
答
检查类的结构:AuthorCollection。它似乎不支持; \ Magento的\店\型号\ StoreManagerInterface;但需要一个\ Magento \ Framework \ DB \ Adapter \ AdapterInterface对象。所以,当你调用类的构造,AuthorCollection你应该完全一样的类型
共享使用你的类AuthorCollection,所以我可以帮你
与笔者收集更新的问题。 – Palanikumar