Take a look at JControllerAdmin what is used to extend your controller.
In __construct
function on line 62 unpublish
is set to use publish
function. So there is no function like unpublish
.
And in publish
function you can get task name with $task = $this->getTask();
.
Possible values are publish
, unpublish
, archive
, trash
and report
. So you can compare, if it is publish
or unpublish
and make actions based on that.
Your function could look like this:
public function publish()
{
$task = $this->getTask();
// Do your custom actions
if($task == 'unpublish'){
// Do something on unpublishing item(s)
}else if($task == 'publish'){
// Do something on publishing item(s)
}
// Call parent function, so item(s) will get published/unpublished like they are used to
parent::publish();
}