Code Duplication    Length = 19-19 lines in 4 locations

src/Action.php 4 locations

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