Code Duplication    Length = 34-34 lines in 2 locations

Core/Executor/LocationManager.php 1 location

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

Core/Executor/ContentManager.php 1 location

@@ 211-244 (lines=34) @@
208
     * @return ContentCollection
209
     * @throws \Exception
210
     */
211
    protected function matchContents($action)
212
    {
213
        if (!isset($this->dsl['object_id']) && !isset($this->dsl['remote_id']) && !isset($this->dsl['match'])) {
214
            throw new \Exception("The ID or remote ID of an object or a Match Condition is required to $action a new location.");
215
        }
216
217
        // Backwards compat
218
        if (!isset($this->dsl['match'])) {
219
            if (isset($this->dsl['object_id'])) {
220
                $this->dsl['match'] = array('content_id' => $this->dsl['object_id']);
221
            } elseif (isset($this->dsl['remote_id'])) {
222
                $this->dsl['match'] = array('content_remote_id' => $this->dsl['remote_id']);
223
            }
224
        }
225
226
        $match = $this->dsl['match'];
227
228
        // convert the references passed in the match
229
        foreach ($match as $condition => $values) {
230
            if (is_array($values)) {
231
                foreach ($values as $position => $value) {
232
                    if ($this->referenceResolver->isReference($value)) {
233
                        $match[$condition][$position] = $this->referenceResolver->getReferenceValue($value);
234
                    }
235
                }
236
            } else {
237
                if ($this->referenceResolver->isReference($values)) {
238
                    $match[$condition] = $this->referenceResolver->getReferenceValue($values);
239
                }
240
            }
241
        }
242
243
        return $this->contentMatcher->match($match);
244
    }
245
246
    /**
247
     * Helper function to set the fields of a ContentCreateStruct based on the DSL attribute settings.