forked from thenbsp/wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.php
More file actions
31 lines (25 loc) · 761 Bytes
/
Event.php
File metadata and controls
31 lines (25 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace Thenbsp\Wechat\Event;
use Thenbsp\Wechat\Message\Entity;
use Thenbsp\Wechat\Bridge\XmlResponse;
use Doctrine\Common\Collections\ArrayCollection;
abstract class Event extends ArrayCollection
{
/**
* response message entity
*/
public function setResponse(Entity $entity)
{
$body = $entity->getBody();
$body['ToUserName'] = $this['FromUserName'];
$body['FromUserName'] = $this['ToUserName'];
$body['MsgType'] = $entity->getType();
$body['CreateTime'] = time();
$response = new XmlResponse($body);
$response->send();
}
/**
* check event options is valid
*/
abstract public function isValid();
}