I have a block php file. Block File Code:
<?php
namespace Vendor\SampleModule1\Block;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Vendor\SampleModule1\Model\ResrouceModel\Item\Collection;
use Vendor\SampleModule1\Model\ResrouceModel\Item\CollectionFactory;
class Hello extends Template
{
private $collectionFactory;
public function __construct(
Context $context,
CollectionFactory $collectionFactory,
array $data =[]
)
{
$this->collectionFactory = $collectionFactory;
parent::__construct($context, $data);
}
/**
* @return \Vendor\SampleModule1\Model\Item[]
*/
public function getItems()
{
return $this->collectionFactory->create()->getItems();
}
}
When I try to see the view the error is
Fatal error: Uncaught TypeError: Argument 1 passed to Vendor\SampleModule1\Block\Hello::__construct() must be an instance of Magento\Framework\View\Element\Template\Context, instance of Magento\Framework\ObjectManager\ObjectManager given ....
How is that possible ? ? ?
var/generation
folder?