本文整理汇总了PHP中SplSubject::getEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP SplSubject::getEvent方法的具体用法?PHP SplSubject::getEvent怎么用?PHP SplSubject::getEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplSubject
的用法示例。
在下文中一共展示了SplSubject::getEvent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Receive update from subject
*
* @param SplSubject $subject Subject observed that contains event to write
*
* @return void
*/
public function update(SplSubject $subject)
{
$this->subject = $subject;
$event = $subject->getEvent();
// delegate to right event implementation
call_user_func(array($this, $event->getName()), $event);
}
示例2: update
/**
* Receive update from subject
*
* @param SplSubject $subject Subject observed that contains event to write
*
* @return void
*/
public function update(SplSubject $subject)
{
$this->subject = $subject;
$event = $subject->getEvent();
// delegate to right event implementation
$data = call_user_func(array($this, $event->getName()), $event);
error_log(sprintf('%s [%s] %s %s', strftime($this->timeFormat, $data['timestamp']), $data['level'], $data['message'], PHP_EOL), 3, $this->destFile);
}
示例3: update
/**
* Receive update from subject
*
* @param SplSubject $subject Subject observed that contains event to write
*
* @return void
*/
public function update(SplSubject $subject)
{
$this->subject = $subject;
$event = $subject->getEvent();
// delegate to right event implementation
$data = call_user_func(array($this, $event->getName()), $event);
if (empty($data)) {
return;
}
$this->growl->publish($data['name'], $data['title'], $data['description'], $data['options']);
}
示例4: update
/**
* Method to trigger events.
* The method first generates the even from the argument array. Then it unsets the argument
* since the argument has no bearing on the event handler.
* If the method exists it is called and returns its return value. If it does not exist it
* returns null.
*
* @param array &$args Arguments
*
* @return mixed Routine return value
*/
public function update(SplSubject $subject)
{
// get the event and args from the subject (dispatcher) to use in the plugin
$event = $subject->getEvent();
$args = $subject->getArgs();
/*
* If the method to handle an event exists, call it and return its value
* If it does not exist, return null.
*/
if (method_exists($this, $event)) {
return call_user_func_array(array($this, $event), $args);
} else {
return null;
}
}