Code Duplication    Length = 30-30 lines in 2 locations

Core/Executor/ContentManager.php 1 location

@@ 285-314 (lines=30) @@
282
     * @return ContentCollection
283
     * @throws \Exception
284
     */
285
    protected function matchContents($action)
286
    {
287
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
288
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
289
        }
290
291
        // Backwards compat
292
        if (!isset($this->dsl['match'])) {
293
            if (isset($this->dsl['object_id'])) {
294
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
295
            } elseif (isset($this->dsl['remote_id'])) {
296
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
297
            }
298
        }
299
300
        $match = $this->dsl['match'];
301
302
        // convert the references passed in the match
303
        foreach ($match as $condition => $values) {
304
            if (is_array($values)) {
305
                foreach ($values as $position => $value) {
306
                    $match[$condition][$position] = $this->referenceResolver->resolveReference($value);
307
                }
308
            } else {
309
                $match[$condition] = $this->referenceResolver->resolveReference($values);
310
            }
311
        }
312
313
        return $this->contentMatcher->match($match);
314
    }
315
316
    /**
317
     * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings.

Core/Executor/LocationManager.php 1 location

@@ 244-273 (lines=30) @@
241
     * @return ContentCollection
242
     * @throws \Exception
243
     */
244
    protected function matchContents($action)
245
    {
246
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
247
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
248
        }
249
250
        // Backwards compat
251
        if (!isset($this->dsl['match'])) {
252
            if (isset($this->dsl['object_id'])) {
253
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
254
            } elseif (isset($this->dsl['remote_id'])) {
255
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
256
            }
257
        }
258
259
        $match = $this->dsl['match'];
260
261
        // convert the references passed in the match
262
        foreach ($match as $condition => $values) {
263
            if (is_array($values)) {
264
                foreach ($values as $position => $value) {
265
                    $match[$condition][$position] = $this->referenceResolver->resolveReference($value);
266
                }
267
            } else {
268
                $match[$condition] = $this->referenceResolver->resolveReference($values);
269
            }
270
        }
271
272
        return $this->contentMatcher->matchContent($match);
273
    }
274
275
    public function getSortField($newValue, $currentValue = null)
276
    {