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

ICanBoogie / Module / 4245494566

pending completion
4245494566

push

github

Olivier Laviale
Resolve templates using Config instead of Collection

115 of 432 relevant lines covered (26.62%)

0.76 hits per line

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

0.0
/lib/Module/Operation/DeleteOperation.php
1
<?php
2

3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
namespace ICanBoogie\Module\Operation;
13

14
use ICanBoogie\ErrorCollection;
15
use ICanBoogie\Module;
16
use ICanBoogie\Operation;
17
use RuntimeException;
18

19
/**
20
 * Deletes a record.
21
 */
22
class DeleteOperation extends Operation
23
{
24
    /**
25
     * Modifies the following controls:
26
     *
27
     * - PERMISSION: MANAGE
28
     * - RECORD: true
29
     * - OWNERSHIP: true
30
     */
31
    protected function get_controls()
32
    {
33
        return [
×
34

35
                self::CONTROL_PERMISSION => Module::PERMISSION_MANAGE,
×
36
                self::CONTROL_RECORD => true,
×
37
                self::CONTROL_OWNERSHIP => true
×
38

39
            ] + parent::get_controls();
×
40
    }
41

42
    /**
43
     * @inheritdoc
44
     */
45
    protected function validate(ErrorCollection $errors)
46
    {
47
        return true;
×
48
    }
49

50
    /**
51
     * Delete the target record.
52
     */
53
    protected function process()
54
    {
55
        $key = $this->key;
×
56
        $record = $this->record;
×
57

58
        if (!$record->delete()) {
×
59
            throw new RuntimeException(
×
60
                $this->format('Unable to delete the record %key from %module.', [
×
61

62
                    'key' => $key,
×
63
                    'module' => $this->module->title
×
64

65
                ])
×
66
            );
×
67
        }
68

69
        if ($this->request['redirect_to']) {
×
70
            $this->response->location = $this->request['redirect_to'];
×
71
        }
72

73
        $this->response->message = $this->format('The record %key has been deleted from %module.', [
×
74

75
            'key' => $key,
×
76
            'module' => $this->module->title
×
77

78
        ]);
×
79

80
        return $key;
×
81
    }
82
}
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

© 2025 Coveralls, Inc