我在运行时遇到以下错误
php bin / magento setup:di:compile
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');
}
}
请告诉我如何解决此问题。
答案 0 :(得分:0)
检查类的构造:AuthorCollection。似乎它不支持; \ Magento的\店\型号\ StoreManagerInterface;但需要一个\ Magento \ Framework \ DB \ Adapter \ AdapterInterface对象。所以当你调用类AuthorCollection的构造时,你应该使用完全相同的类型
分享你的班级AuthorCollection所以我可以帮助你