Please anyone see my code and resolve this issue
Fatal error: Uncaught TypeError: Argument 1 passed to
MyClass::__construct() must implement interface
Magento\Framework\Session\SessionManagerInterface, none given, called
in
/home/dukaania/public_html/testing2/vendor/magento/module-checkout/view/frontend/templates/cart/shipping.phtml
on line 132 and defined in
/home/dukaania/public_html/testing2/vendor/magento/module-checkout/view/frontend/templates/cart/shipping.phtml:109
Stack trace: #0
use Magento\Framework\Session\SessionManagerInterface as CoreSession;
class MyClass
{
protected $_coreSession;
public function __construct(CoreSession $coreSession)
{
$this->_coreSession = $coreSession;
}
public function setValue($total_cost){
$this->_coreSession->start();
$this->_coreSession->setMessage($total_cost);
}
public function getValue(){
$this->_coreSession->start();
return $this->_coreSession->getMessage();
}
}
$myclas = new MyClass();
$myclas.setValue($total_cost);
echo $myclas.getValue();
Best Answer
You issue at
$myclas = new MyClass();
To initialize this class you have to use the object manager or have to inject that class to your class.