Files
Smart-Farm/app/farm/server/Land.php
2025-12-22 14:32:54 +08:00

68 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace app\farm\server;
use app\shop\model\BargainRecord;
use think\App;
use work;
class Land
{
public $_observer = [];
public function __construct() {
}
/**
* @purpose: 添加观察者
* @param string $key 给所添加的观察者的一个唯一 key方便从注册树中移除观察者
* @param Observer $observer 观察者对象
* @return mixed
*/
public function addObserver( $observer)
{
$this->_observer[] = $observer;
}
/**
* @purpose: 从注册树中移除观察者
* @param string $key 给所添加的观察者的一个唯一 key方便从注册树中移除观察者
* @return mixed
*/
public function removeObserver($key)
{
unset($this->_observer[$key]);
}
/**
* @purpose: 广播通知以注册的观察者,对注册树进行遍历,让每个对象实现其接口提供的操作
* @return mixed
*/
public function notify($id,$data)
{
if(!empty($this->_observer)){
foreach ($this->_observer as $observer) {
$data[] = $observer->eventLand($id,$data);
}
}
return !empty($data)?$data:[];
}
}