S
S
Sergey Beloventsev2018-10-02 13:00:44
Yii
Sergey Beloventsev, 2018-10-02 13:00:44

What am I doing wrong with the dependency container?

This is how I set it in the bootstrap file

class DependencySetUp implements BootstrapInterface
{
    public function bootstrap($app)
    {
        $container = \Yii::$container;

        $container->setSingleton(FieldConfig::class,[],[
           CompanyFieldService::getCompanyField(),
           CompanyFieldService::getCompanyFieldPK()
        ]);

    }
}

like this in the model
public function getCompanyFields()
    {
        return $this->hasMany(
            $this->сompanyField,
            ['field_config_id' => $this->companyFieldPK]
        );
    }

this is how it is implemented in the CompanyFieldService service
public static function getCompanyField()
    {
        return CompanyField::class;
    }

    public static function getCompanyFieldPK()
    {
        return current(CompanyField::primaryKey());
    }

but i get an error
Getting unknown property: common\modules\Main\Entities\FieldConfig::companyField

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question