M
M
magary42016-11-03 16:33:40
symfony
magary4, 2016-11-03 16:33:40

How to change class?

the system I am working with returns me an object of the Content type,
this class is hardcoded in logic and there is no way to change it through the configuration parameters,
I need to add a couple of methods of the Content-> getChildren () type to it,
which will make an additional request to the database
I did

class myContent extends Content
{
    public function __construct( $obj )
    {
        foreach ($obj as $key => $value)
        {
            $this->$key = $value;
        }
    }

    public function getChildren()
   { . . .}
}

but I got errors when I pass this object to different methods
- because there are somewhere checks for instanceof
how to solve this problem?
maybe you can just replace the autoload of the original class with mine through the composer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
stormdi, 2016-11-03
@stormdi

в вашем коде нет вызова родительского конструктора, может быть в этом проблема?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question