I am trying to understand functionality of plugin method. for that i have created a custom module and i added below code in di.xml
and model class code is
namespace AdhikariStudyPluginModel;
class StudyPlugin extends MagentoFrameworkModelAbstractModel
{
public function getName($name){
return $name;
}
}
after that my plugin method code is
namespace AdhikariStudyPluginPluginModel;
class StudyPlugin
{
public function beforeGetName(AdhikariStudyPluginModelStudyPlugin $subject, $name){
die('hello');
return ['(' . 'My name is '.$name . ')'];
}
}
and at last i have created a block class and below is the code of that block class.
namespace AdhikariStudyPluginBlockStudyPlugin;
use MagentoFrameworkViewElementTemplate;
class PluginBlock extends Template
{
public function __construct(
TemplateContext $context,
AdhikariStudyPluginModelStudyPlugin $studyPlugin,
array $data = []
) {
parent::__construct($context, $data);
$this->_studyPlugin = $studyPlugin;
}
public function getName($name){
return $this->_studyPlugin->getName($name);
}
}
but when i include that block in homepage and call block function getName(‘hello’); it doesn’t code in before plugin method. but i calls model class method getName($name) and return value.
can someone please help me to understand the workflow of this or if i am doing some mistake..