Passed
Push — master ( 420639...4ea9f2 )
by Andreas
11:06
created

midgard_admin_asgard_handler_object_rcs::reply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * @author tarjei huse
4
 * @package midgard.admin.asgard
5
 * @copyright The Midgard Project, http://www.midgard-project.org
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 */
8
9
use Symfony\Component\HttpFoundation\Response;
10
use midgard\portable\api\error\exception as mgd_exception;
11
12
/**
13
 * Simple styling class to make html out of diffs and get a simple way
14
 * to provide rcs functionality
15
 *
16
 * @package midgard.admin.asgard
17
 */
18
class midgard_admin_asgard_handler_object_rcs extends midcom_services_rcs_handler
19
{
20
    use midgard_admin_asgard_handler;
0 ignored issues
show
introduced by
The trait midgard_admin_asgard_handler requires some properties which are not provided by midgard_admin_asgard_handler_object_rcs: $dbclassloader, $dbfactory
Loading history...
21
22
    protected string $style_prefix = 'midgard_admin_asgard_rcs_';
23
24
    protected string $url_prefix = '__mfa/asgard/object/rcs/';
25
26 3
    protected function load_object(string $guid) : midcom_core_dbaobject
27
    {
28
        try {
29 3
            return parent::load_object($guid);
30
        } catch (midcom_error_midgard $e) {
31
            $mgd_exception = $e->getPrevious();
32
            if (   $mgd_exception
33
                && $mgd_exception->getCode() == mgd_exception::OBJECT_DELETED) {
34
                return $this->load_deleted($guid);
35
            }
36
            throw $e;
37
        }
38
    }
39
40
    protected function get_object_url() : string
41
    {
42
        return $this->router->generate('object_open', ['guid' => $this->object->guid]);
43
    }
44
45 3
    protected function get_breadcrumbs() : array
46
    {
47 3
        midgard_admin_asgard_plugin::bind_to_object($this->object, $this->_request_data['handler_id'], $this->_request_data);
48 3
        return midcom_core_context::get()->get_custom_key('midcom.helper.nav.breadcrumb') ?: [];
49
    }
50
51 3
    protected function reply(string $element) : Response
52
    {
53 3
        return $this->get_response($element);
54
    }
55
56
    /**
57
     * Load l10n
58
     */
59 3
    public function _on_initialize()
60
    {
61 3
        midcom::get()->auth->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin');
62 3
        $this->_component = 'midcom.admin.rcs';
63 3
        $this->_request_data['l10n'] = $this->_i18n->get_l10n('midcom.admin.rcs');
64
    }
65
}
66