Code Duplication    Length = 34-34 lines in 2 locations

Core/Executor/ContentManager.php 1 location

@@ 189-222 (lines=34) @@
186
     * @return ContentCollection
187
     * @throws \Exception
188
     */
189
    protected function matchContents($action)
190
    {
191
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
192
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
193
        }
194
195
        // Backwards compat
196
        if (!isset($this->dsl['match'])) {
197
            if (isset($this->dsl['object_id'])) {
198
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
199
            } elseif (isset($this->dsl['remote_id'])) {
200
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
201
            }
202
        }
203
204
        $match = $this->dsl['match'];
205
206
        // convert the references passed in the match
207
        foreach ($match as $condition => $values) {
208
            if (is_array($values)) {
209
                foreach ($values as $position => $value) {
210
                    if ($this->referenceResolver->isReference($value)) {
211
                        $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value);
212
                    }
213
                }
214
            } else {
215
                if ($this->referenceResolver->isReference($values)) {
216
                    $match[$condition] = $this->referenceResolver->getReferenceValue($values);
217
                }
218
            }
219
        }
220
221
        return $this->contentMatcher->match($match);
222
    }
223
224
    /**
225
     * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings.

Core/Executor/LocationManager.php 1 location

@@ 220-253 (lines=34) @@
217
     * @return ContentCollection
218
     * @throws \Exception
219
     */
220
    protected function matchContents($action)
221
    {
222
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
223
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
224
        }
225
226
        // Backwards compat
227
        if (!isset($this->dsl['match'])) {
228
            if (isset($this->dsl['object_id'])) {
229
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
230
            } elseif (isset($this->dsl['remote_id'])) {
231
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
232
            }
233
        }
234
235
        $match = $this->dsl['match'];
236
237
        // convert the references passed in the match
238
        foreach ($match as $condition => $values) {
239
            if (is_array($values)) {
240
                foreach ($values as $position => $value) {
241
                    if ($this->referenceResolver->isReference($value)) {
242
                        $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value);
243
                    }
244
                }
245
            } else {
246
                if ($this->referenceResolver->isReference($values)) {
247
                    $match[$condition] = $this->referenceResolver->getReferenceValue($values);
248
                }
249
            }
250
        }
251
252
        return $this->contentMatcher->matchContent($match);
253
    }
254
255
    protected function getSortField($currentValue = null)
256
    {