Code Duplication    Length = 20-21 lines in 2 locations

src/Action.php 2 locations

@@ 44-63 (lines=20) @@
41
     * @param $element
42
     * @return string
43
     */
44
    public static function editIBlockElement($template, $element)
45
    {
46
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
47
            return '';
48
        }
49
50
        if (is_numeric($element)) {
51
            $element = static::prepareIBlockElementArrayById($element);
52
        }
53
        if (!$element["IBLOCK_ID"] || !$element['ID']) {
54
            throw new InvalidArgumentException('Element must include ID and IBLOCK_ID');
55
        }
56
57
        $buttons = static::getIBlockElementPanelButtons($element);
58
        $link = $buttons["edit"]["edit_element"]["ACTION_URL"];
59
60
        $template->AddEditAction('iblock_element_' . $element['ID'], $link, CIBlock::GetArrayByID($element["IBLOCK_ID"], "ELEMENT_EDIT"));
61
62
        return static::areaForIBlockElement($template, $element);
63
    }
64
65
    /**
66
     * @param CBitrixComponentTemplate $template
@@ 122-142 (lines=21) @@
119
     * @param $section
120
     * @return string
121
     */
122
    public static function editIBlockSection($template, $section)
123
    {
124
        if (!$GLOBALS['APPLICATION']->GetShowIncludeAreas()) {
125
            return '';
126
        }
127
128
        if (is_numeric($section)) {
129
            $section = static::prepareIBlockSectionArrayById($section);
130
        }
131
132
        if (!$section["IBLOCK_ID"] || !$section['ID']) {
133
            throw new InvalidArgumentException('Section must include ID and IBLOCK_ID');
134
        }
135
    
136
        $buttons = static::getIBlockSectionPanelButtons($section);
137
        $link = $buttons["edit"]["edit_section"]["ACTION_URL"];
138
139
        $template->AddEditAction('iblock_section_' . $section['ID'], $link, CIBlock::GetArrayByID($section["IBLOCK_ID"], "SECTION_EDIT"));
140
141
        return static::areaForIBlockSection($template, $section);
142
    }
143
144
    /**
145
     * @param CBitrixComponentTemplate $template