how can I fix this error ?
**Circular dependency**:
Heckfy\Health\Model\Metrics\CalculateOrders\Metric depends on Heckfy\Health\Model\Metrics\CalculateOrders\Metric
and vice versa
I have class metric manager where I try to init my metric object like this:
$this->metric = $this->objectManager->create('Heckfy\Health\Model\Metrics\CalculateOrders\Metric');
I guess the problem in my metric class:
class Metric extends AbstractMetric
{
public $collectionFactory;
public function __construct(
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $collectionFactory
)
{
$this->collectionFactory = $collectionFactory;
}
}
Because without constructor it works well. I tried debug it and found this part of code inside method create().
if (isset($this->creationStack[$requestedType])) {
$lastFound = end($this->creationStack);
$this->creationStack = [];
throw new \LogicException("Circular dependency: {$requestedType} depends on {$lastFound} and vice versa.");
}
Looks like magento already init this class and put it to $this->creationStack. But how?
What I am doing wrong ?