views:

165

answers:

2

Working in a symfony model, I want to override a function and call the overridden function from within the overriding one, along the lines of

class MyClass extends BaseMyClass {

  function setMyProperty($p) {
    parent::setMyProperty($p);
    //do some other stuff
  }

}

This is resulting in a segmentation fault. I don't want to alter the parent class - it's been generated by symfony, and may feasibly be overwritten in the future if the model is rebuilt. This seems like something that should be straightforward, but I'm struggling to find the solution. Thanks for any advice

A: 

I've managed to find a solution to my own question on the symfony project forum.

I can't call the overridden function because it doesn't exist. Though it exists enough for me to override it.

Using

$this->_set('my_property', $p);

Works where

parent::setMyProperty($p);

Causes the error.

Note that

$this->setMyProperty($p);

Works fine in my class if the method has not been overridden.

paddymcc
A: 

Since you saw the problem, I guess you should mark it as answered to remove it from the unanswered list.

Hanseh
oooppzz, sorry, I was planning to add it as a comment. new user error.
Hanseh
I couldn't mark it as solved until 2 days after I posted the solution. Slipped my mind over the weekend - thanks for the reminder.
paddymcc
my pleasure. I was intrigue by the question and did not notice that you already had a solution that's why I made a reminder. :D
Hanseh