<?php
interface MakeMeCMS_Listener_interface {
public function __construct($method, $args);
public function setFeedback($arg, $type);
}
class MakeMeCMS_Listener implements MakeMeCMS_Listener_interface {
private $_feedback;
private $_type;
public function __construct($method, $args) {
if(method_exists($this, $method)) {
if($args != '') {
if(preg_match('#\,#', $args)) {
$args = explode(',', $args);
}
$this->$method($args);
}
else {
$this->$method();
}
}
}
public function setFeedback($arg,$type) {
$this->_feedback = $arg;
$this->_type = $type;
}
public function feedback() {
return $this->_feedback;
}
private function test(array $args) {
$string = '';
foreach($args as $arg) {
$string .= $arg.' ';
}
$this->setFeedback($string, 'text/plain');
}
}
class myAddon_Listener extends MakeMeCMS_Listener implements MakeMeCMS_Listener_interface {
public function __construct($method, $args) {
}
public function setFeedback($arg, $type) {
parent::setFeedback($arg, $type);
}
private function test2() {
echo('Hello World!');
}
}
$listener = new MakeMeCMS_Listener('test', 'foo,bar');
echo($listener->feedback());
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- foo bar
preferences:
159.3 ms | 404 KiB | 197 Q