1

i would like make copy if i add and edit News.

class News extends BaseNews
{
    public function postSave(){

        $copy = new CopyNews($this);
        $copy->save();
    }

    public function save(Doctrine_Connection $conn = null)
    {
      return parent::save($conn);  
    }
}

but i have error:

Strict Standards: Declaration of News::postSave() should be compatible with that of Doctrine_Record::postSave() in ...

How can i make this?

2 Answers 2

1

All pre- and post- methods receive $event as a parameter. You should rewrite the method as

 public function postSave(Doctrine_Event $event){
    $copy = new CopyNews($event->getInvoker());
    $copy->save();
 }
Sign up to request clarification or add additional context in comments.

1 Comment

further i have error Strict Standards: Declaration of News::postSave() should be compatible with that of Doctrine_Record::postSave() in
1

All you need is within doctrine

$copy = $this->copy()

... and it's documentation :

http://www.doctrine-project.org/documentation/manual/1_2/en/component-overview:record:getting-object-copy

2 Comments

Strict Standards: Declaration of News::postSave() should be compatible with that of Doctrine_Record::postSave() AGAIN
Maybe, but that's a problem of your function definition. This is from Doctrine_Record API documentation: public function postSave(mixed $event) (doctrine-project.org/api/orm/1.2/doctrine/…) @Darhazer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.