Code Duplication    Length = 23-23 lines in 2 locations

src/Action.php 2 locations

@@ 71-93 (lines=23) @@
68
     * @param string $confirm
69
     * @return string
70
     */
71
    public static function deleteIBlockElement($template, $element, $confirm = null)
72
    {
73
        $confirm = $confirm ?: Loc::getMessage('ARRILOT_BITRIX_HERMITAGE_DELETE_IBLOCK_ELEMENT_CONFIRM');
74
75
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
76
            return '';
77
        }
78
79
        if (is_numeric($element)) {
80
            $element = static::prepareIBlockElementArrayById($element);
81
        }
82
83
        if (!$element["IBLOCK_ID"] || !$element['ID']) {
84
            throw new InvalidArgumentException('Element must include ID and IBLOCK_ID');
85
        }
86
    
87
        $buttons = static::getIBlockElementPanelButtons($element);
88
        $link = $buttons["edit"]["delete_element"]["ACTION_URL"];
89
90
        $template->AddDeleteAction('iblock_element_' . $element['ID'], $link, CIBlock::GetArrayByID($element["IBLOCK_ID"], "ELEMENT_DELETE"), array("CONFIRM" => $confirm));
91
92
        return static::areaForIBlockElement($template, $element);
93
    }
94
95
    /**
96
     * @param CBitrixComponentTemplate $template
@@ 150-172 (lines=23) @@
147
     * @param string $confirm
148
     * @return string
149
     */
150
    public static function deleteIBlockSection($template, $section, $confirm = null)
151
    {
152
        $confirm = $confirm ?: Loc::getMessage("ARRILOT_BITRIX_HERMITAGE_DELETE_IBLOCK_SECTION_CONFIRM");
153
154
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
155
            return '';
156
        }
157
158
        if (is_numeric($section)) {
159
            $section = static::prepareIBlockSectionArrayById($section);
160
        }
161
162
        if (!$section["IBLOCK_ID"] || !$section['ID']) {
163
            throw new InvalidArgumentException('Section must include ID and IBLOCK_ID');
164
        }
165
    
166
        $buttons = static::getIBlockSectionPanelButtons($section);
167
        $link = $buttons["edit"]["delete_section"]["ACTION_URL"];
168
169
        $template->AddDeleteAction('iblock_section_' . $section['ID'], $link, CIBlock::GetArrayByID($section["IBLOCK_ID"], "SECTION_DELETE"), array("CONFIRM" => $confirm));
170
171
        return static::areaForIBlockSection($template, $section);
172
    }
173
174
    /**
175
     * @param CBitrixComponentTemplate $template