Hello @Sebastian222
Yes, in Magento 2, you can inject string or number parameters into a class constructor.
Here's an example of how you can define a class with string and number parameters in its constructor:
public function __construct(
\Magento\Framework\App\State $state,
\Magento\Store\Model\App\Emulation $emulation,
\Magento\Framework\ObjectManagerInterface $objectManager,
int $someIntegerValue
){
$this->state = $state;
$this->emulation = $emulation;
$this->objectManager = $objectManager;
$this->numberParam = $someIntegerValue; }
Hope it helps !
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789