I
I
IvanN7772018-05-17 08:06:52
Doctrine ORM
IvanN777, 2018-05-17 08:06:52

The doctrine does not work due to the fact that I read and write properties through __call (), can I somehow get around this?

I don't have Symfony, there is something similar https://symfony.com/doc/current/components/propert...

static $fields = [
        'id', 'code', 'fullName', 'number', 'color',
        'series', 'weight', 'volume', 'status', 'specStatus', 'type', 'urgency'
    ];
    public function __call($nameFunction, $arguments)
    {
        if (strlen($nameFunction) < 4):
            return;
        endif;
        $prefix = substr($nameFunction, 0, 3);
        $name = lcfirst(substr($nameFunction, 3, strlen($nameFunction) - 3));
        $inFields =  array_search($name, self::$fields);
        if ($prefix == 'get'):
            if ($inFields):
                return $this->$name;
            endif;
        endif;
        if ($prefix == 'set'):
            if ($inFields):
                $value = $arguments[0];
                $this->$name = $value;
            endif;
        endif;
    }

It normally receives values ​​and writes, but with the association of OneToMany and . etc. it produces emptiness.
Breaks on Proxy.
How to get around this problem, I really don’t want to write setters and I don’t want to use an annotation (a comment should be a comment).
And I'm too lazy to write functions in yaml))

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