-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathCallbackEndpoint.php
More file actions
60 lines (51 loc) · 1.39 KB
/
CallbackEndpoint.php
File metadata and controls
60 lines (51 loc) · 1.39 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Muffin\Webservice\Test\test_app\Model\Endpoint;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Muffin\Webservice\Connection;
use Muffin\Webservice\Model\Endpoint;
class CallbackEndpoint extends Endpoint
{
/**
* Test afterSave Callback
* @param Event $event
* @param EntityInterface $entity
* @param \ArrayObject $options
* @return bool|EntityInterface
*/
public function afterSave(Event $event, EntityInterface $entity, \ArrayObject $options)
{
if ($entity->get('title')) {
$entity->set('title', 'Loads of sun');
}
return $entity;
}
/**
* Test beforeDelete Callback
* @param Event $event
* @param EntityInterface $entity
* @return EntityInterface
*/
public function beforeDelete(Event $event, EntityInterface $entity)
{
$entity = $this->get(5);
if ($entity->get('title')) {
$entity->set('title', 'I love fun');
}
return $entity;
}
/**
* Test afterDelete Callback
* @param Event $event
* @param EntityInterface $entity
* @return EntityInterface
*/
public function afterDelete(Event $event, EntityInterface $entity)
{
$entity = $this->get(6);
if ($entity->get('title')) {
$entity->set('title', 'I need fun');
}
return $entity;
}
}