0

i have this error after i run the s:d:c command. It show the error happend with my DataProvider and Controller files. HOw to fix this and i really need a suggestions.

Errors during compilation:
Rakuten\MemberCard\Model\Config\DataProvider
Incompatible argument type: Required type: string. 
Actual type: \Rakuten\MemberCard\Model\Config\name; File: 
/var/www/html/rakuten_magento/app/code/Rakuten/MemberCard/Model/Config/DataProvider.php

Rakuten\MemberCard\Controller\Adminhtml\Card\Index
Incompatible argument type: Required type: \Magento\Backend\App\Action\Context. 
Actual type: \Magento\Framework\App\Action\Context; File: 
/var/www/html/rakuten_magento/app/code/Rakuten/MemberCard/Controller/Adminhtml/Card/Index.php

DataProvider file:

<?php

namespace Rakuten\MemberCard\Model\Config;

use Rakuten\MemberCard\Model\CardFactory;
use Rakuten\MemberCard\Model\ResourceModel\Card\CollectionFactory;

class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
{
    /**
     * @var
     */
    protected $_loadedData;

    /**
     * @var
     */
    protected $collection;

    /**
     * DataProvider constructor.
     * @param $name
     * @param $primaryFieldName
     * @param $requestFieldName
     * @param CollectionFactory $collectionFactory
     * @param array $meta
     * @param array $data
     */
    public function __construct(
        $name,
        $primaryFieldName,
        $requestFieldName,
        CollectionFactory $collectionFactory,
        array $meta = [],
        array $data = [])
    {
        $this->collection = $collectionFactory->create();
        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
    }

    /**
     * @return array
     */
    public function getData()
    {
        if (isset($this->_loadedData)) {
            return $this->_loadedData;
        }
        $items = $this->collection->getItems();
        foreach ($items as $item) {
            $this->_loadedData[$item->getId()] = $item->getData();
        }
        return $this->_loadedData;
    }
}

2
  • For second one file you've used \Magento\Framework\App\Action\Context instead of \Magento\Backend\App\Action\Context. With first one - please provide file content to determine exact error Jul 20, 2022 at 8:08
  • thank you for your answer, i have added the DataProvider content
    – KAITO_3SS
    Jul 20, 2022 at 8:19

1 Answer 1

0

Your issue is related to bad PHPDoc block

You need to update it like

    /**
     * @param string $name
     * @param string $primaryFieldName
     * @param string $requestFieldName
     * @param CollectionFactory $collectionFactory
     * @param array $meta
     * @param array $data
     */
1
  • That was easy, thank for your help
    – KAITO_3SS
    Jul 20, 2022 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.