Code Duplication    Length = 15-15 lines in 2 locations

plugins/Field/src/Controller/FileHandlerController.php 1 location

@@ 109-123 (lines=15) @@
106
     * @throws \Cake\Network\Exception\NotFoundException When invalid attribute name
107
     *  is given
108
     */
109
    protected function _getInstance($name)
110
    {
111
        $this->loadModel('Field.FieldInstances');
112
        $instance = $this->FieldInstances
113
            ->find()
114
            ->contain(['EavAttribute'])
115
            ->where(['EavAttribute.name' => $name])
116
            ->first();
117
118
        if (!$instance) {
119
            $this->_error(__d('field', 'Invalid field instance.'), 504);
120
        }
121
122
        return $instance;
123
    }
124
125
    /**
126
     * Sends a JSON message error.

plugins/Field/src/Controller/ImageHandlerController.php 1 location

@@ 164-178 (lines=15) @@
161
     * @throws \Cake\Network\Exception\NotFoundException When invalid attribute name
162
     *  is given
163
     */
164
    protected function _getInstance($name)
165
    {
166
        $this->loadModel('Field.FieldInstances');
167
        $instance = $this->FieldInstances
168
            ->find()
169
            ->contain(['EavAttribute'])
170
            ->where(['EavAttribute.name' => $name])
171
            ->first();
172
173
        if (!$instance) {
174
            $this->_error(__d('field', 'Invalid field instance.'), 504);
175
        }
176
177
        return $instance;
178
    }
179
180
    /**
181
     * Sends a JSON message error.