• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / services / 10431165764

14 Aug 2024 03:24PM UTC coverage: 5.16% (-0.05%) from 5.206%
10431165764

push

github

twinh
feat(services): `DestroyAction` 添加 `beforeFind` 和 `afterFind` 事件

0 of 6 new or added lines in 1 file covered. (0.0%)

29 of 562 relevant lines covered (5.16%)

1.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Service/DestroyAction.php
1
<?php
2

3
namespace Miaoxing\Services\Service;
4

5
use Miaoxing\Services\Action\BaseAction;
6
use Wei\BaseController;
7
use Wei\Ret;
8

9
class DestroyAction extends BaseAction
10
{
11
    /**
12
     * @param callable $callable
13
     * @return $this
14
     */
15
    public function beforeFind(callable $callable): self
16
    {
NEW
17
        return $this->on(__FUNCTION__, $callable);
×
18
    }
19

20
    /**
21
     * @param callable $callable
22
     * @return $this
23
     */
24
    public function afterFind(callable $callable): self
25
    {
NEW
26
        return $this->on(__FUNCTION__, $callable);
×
27
    }
28

29
    /**
30
     * @param BaseController $controller
31
     * @return Ret
32
     * @throws \Exception
33
     * @svc
34
     */
35
    protected function exec(BaseController $controller)
36
    {
NEW
37
        $model = $this->convention->createModel($controller);
×
38

NEW
39
        $this->triggerRet('beforeFind', [$model, $this->req]);
×
NEW
40
        $model->findOrFail($this->req['id']);
×
NEW
41
        $this->triggerRet('afterFind', [$model, $this->req]);
×
42

43
        $this->triggerRet('beforeDestroy', [$model, $this->req]);
×
44

45
        // @experimental
46
        if (method_exists($model, 'checkDestroy')) {
×
47
            $ret = $model->checkDestroy();
×
48
            if ($ret->isErr()) {
×
49
                return $ret;
×
50
            }
51
        }
52

53
        $model->destroy();
×
54

55
        $this->trigger('afterDestroy', [$model, $this->req]);
×
56

57
        return $model->toRet();
×
58
    }
59

60
    /**
61
     * @param callable $callable
62
     * @return $this
63
     * @svc
64
     */
65
    protected function beforeDestroy(callable $callable)
66
    {
67
        return $this->on(__FUNCTION__, $callable);
×
68
    }
69

70
    /**
71
     * @param callable $callable
72
     * @return $this
73
     * @svc
74
     */
75
    protected function afterDestroy(callable $callable)
76
    {
77
        return $this->on(__FUNCTION__, $callable);
×
78
    }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc