The best way to approach it would be something like this:
class Child extends Parent {
public function run($args)
{
// Child specific code
// Call the parent's run function
parent::run($args); // Note: parent here does not refer to a class parent, it's a PHP keyword which means the parent class
}
}
class Parent extends CConsoleCommand {
public function run($args)
{
$this->sendExecutionStatusEmail();
}
public function sendExecutionStatusEmail()
{
// Something here
}
}
Edit
Or what you could do is write some functionality into the parent run function that checks for the existence of a function and calls it before triggering the e-mail. Something like:
class Child extends Parent {
public function yourMethodName()
{
// Do something
}
}
class Parent extends CConsoleCommand {
public function run($args)
{
// If the method yourMethodName exists on 'this' object
if (method_exists($this, 'yourMethodName'))
{
// Call it
$this->yourMethodName();
}
// The rest of your code
$this->sendExecutionStatusEmail();
}
public function sendExecutionStatusEmail()
{
// Something here
}
}
This way you can create a method that matches yourMethodName
on the child class and when the run method is called (Which will be inherited from the parent), yourMethodName
will be called if it exists.