Answer the question
In order to leave comments, you need to log in
Why doesn't the dependency container see the parameter?
Exception 'yii\base\InvalidConfigException' with message 'Missing required parameter "location" when instantiating "shop\manage\payment\cloudPayments\CloudPaymentsPaymentCreator".'
get()
\Yii::$container->get($class, [], $params);
$params
:array(1) {
["location"]=>
string(2) "EU"
}
CloudPaymentsPaymentCreator
:class CloudPaymentsPaymentCreator implements PaymentCreator
{
const LOCATION_USA = "USA";
const LOCATION_EU = "EU";
private $location;
public function __construct($location)
{
$this->location = $location;
}
public static function create($method)
{
foreach (self::$map as $receiptMethod => $classParams) {
if ($method === $receiptMethod) {
/**
* @var $class
* @var $params
*/
extract(self::prepareParams($classParams));
echo "\n\n";
var_dump($params);
echo "\n";
return \Yii::$container->get($class, [], $params);
}
}
throw new \DomainException("Unsupported payment system");
}
protected static function prepareParams($classParams)
{
return is_array($classParams) ? $classParams : ['class' => $classParams, 'params' => []];
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question