Code Duplication    Length = 19-19 lines in 4 locations

src/Action.php 4 locations

@@ 37-55 (lines=19) @@
34
     * @param CBitrixComponentTemplate $template
35
     * @param $element
36
     */
37
    public static function editIBlockElement($template, $element)
38
    {
39
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
40
            return;
41
        }
42
43
        if (is_numeric($element)) {
44
            $element = static::prepareIBlockElementArrayById($element);
45
        }
46
47
        if (!$element["IBLOCK_ID"] || !$element['ID']) {
48
            throw new InvalidArgumentException('Element must include ID and IBLOCK_ID');
49
        }
50
51
        $buttons = static::getIBlockElementPanelButtons($element);
52
        $link = $buttons["edit"]["edit_element"]["ACTION_URL"];
53
54
        $template->AddEditAction('iblock_element_' . $element['ID'], $link, CIBlock::GetArrayByID($element["IBLOCK_ID"], "ELEMENT_EDIT"));
55
    }
56
    
57
    /**
58
     * @param CBitrixComponentTemplate $template
@@ 62-80 (lines=19) @@
59
     * @param $element
60
     * @param string $confirm
61
     */
62
    public static function deleteIBlockElement($template, $element, $confirm = 'Вы уверены, что хотите удалить элемент?')
63
    {
64
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
65
            return;
66
        }
67
68
        if (is_numeric($element)) {
69
            $element = static::prepareIBlockElementArrayById($element);
70
        }
71
72
        if (!$element["IBLOCK_ID"] || !$element['ID']) {
73
            throw new InvalidArgumentException('Element must include ID and IBLOCK_ID');
74
        }
75
    
76
        $buttons = static::getIBlockElementPanelButtons($element);
77
        $link = $buttons["edit"]["delete_element"]["ACTION_URL"];
78
79
        $template->AddDeleteAction('iblock_element_' . $element['ID'], $link, CIBlock::GetArrayByID($element["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => $confirm));
80
    }
81
82
    /**
83
     * @param CBitrixComponentTemplate $template
@@ 96-114 (lines=19) @@
93
     * @param CBitrixComponentTemplate $template
94
     * @param $section
95
     */
96
    public static function editIBlockSection($template, $section)
97
    {
98
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
99
            return;
100
        }
101
102
        if (is_numeric($section)) {
103
            $section = static::prepareIBlockSectionArrayById($section);
104
        }
105
106
        if (!$section["IBLOCK_ID"] || !$section['ID']) {
107
            throw new InvalidArgumentException('Section must include ID and IBLOCK_ID');
108
        }
109
    
110
        $buttons = static::getIBlockSectionPanelButtons($section);
111
        $link = $buttons["edit"]["edit_section"]["ACTION_URL"];
112
113
        $template->AddEditAction('iblock_section_' . $section['ID'], $link, CIBlock::GetArrayByID($section["IBLOCK_ID"], "SECTION_EDIT"));
114
    }
115
116
    /**
117
     * @param CBitrixComponentTemplate $template
@@ 121-139 (lines=19) @@
118
     * @param $section
119
     * @param string $confirm
120
     */
121
    public static function deleteIBlockSection($template, $section, $confirm = 'Вы уверены, что хотите удалить раздел?')
122
    {
123
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
124
            return;
125
        }
126
127
        if (is_numeric($section)) {
128
            $section = static::prepareIBlockSectionArrayById($section);
129
        }
130
131
        if (!$section["IBLOCK_ID"] || !$section['ID']) {
132
            throw new InvalidArgumentException('Section must include ID and IBLOCK_ID');
133
        }
134
    
135
        $buttons = static::getIBlockSectionPanelButtons($section);
136
        $link = $buttons["edit"]["delete_section"]["ACTION_URL"];
137
138
        $template->AddDeleteAction('iblock_section_' . $section['ID'], $link, CIBlock::GetArrayByID($section["IBLOCK_ID"], "SECTION_DELETE"), array("CONFIRM" => $confirm));
139
    }
140
141
    /**
142
     * @param CBitrixComponentTemplate $template