0

Just got a problem while compiling:

Compilation was started. Area configuration aggregation... 5/9 [=======>-----] 55% 1 min 326.0 MiB In ClassReader.php line 45:

Impossible to process constructor argument Parameter #0 [ Warsaw
\Weather\Model\WeatherDataDBDetails $weatherDataDBDetails ] of Warsaw\Weath
er\Model\CronPostDb class

In ClassReader.php line 34:

Class Warsaw\Weather\Model\WeatherDataDBDetails does not exist

setup:di:compile

I made myself sure if my code (classes name etc.) is write correctly.

    <?php
namespace Warsaw\Weather\Console;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Warsaw\Weather\Model\CronPostDb;
class UpdateWeather extends Command
{
    private CronPostDb $cronPostDb;

    public function __construct(CronPostDb $cronPostDb)
    {

        $this->cronPostDb = $cronPostDb;
        parent::__construct();
    }

    protected function configure()
    {
        $this->setName('example:sayhello');
        $this->setDescription('Demo command line');

        parent::configure();
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->cronPostDb->updateWeather();
    }
}

Another file is :

<?php
declare(strict_types=1);

namespace Warsaw\Weather\Model;

use Warsaw\Weather\Model\WeatherDataDBDetails;


class CronPostDb
{
    private WeatherDataDBDetails $weatherDataDBDetails;

    public function __construct(WeatherDataDBDetails $weatherDataDBDetails)
    {
        $this->weatherDataDBDetails = $weatherDataDBDetails;

    }

    public function updateWeather()
    {
        $this->weatherDataDBDetails->setCity('name');
        $this->weatherDataDBDetails->setTemperature(25);
        $this->weatherDataDBDetails->save();
    }
}

1 Answer 1

0

Okay, I figured it out! So the issue was with name of the class "WeatherDataDBDetails" Magento 2 does not recognize 3 capital letters "DBD"

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.