Code Duplication    Length = 26-26 lines in 3 locations

Core/Executor/LocationManager.php 1 location

@@ 202-227 (lines=26) @@
199
     * @return ContentCollection
200
     * @throws \Exception
201
     */
202
    protected function matchLocations($action)
203
    {
204
        if (!isset($this->dsl['location_id'])&& !isset($this->dsl['match'])) {
205
            throw new \Exception("The ID or a Match Condition is required to $action a location.");
206
        }
207
208
        // Backwards compat
209
        if (!isset($this->dsl['match'])) {
210
            $this->dsl['match'] = array('location_id' => $this->dsl['location_id']);
211
        }
212
213
        $match = $this->dsl['match'];
214
215
        // convert the references passed in the match
216
        foreach ($match as $condition => $values) {
217
            if (is_array($values)) {
218
                foreach ($values as $position => $value) {
219
                    $match[$condition][$position] = $this->referenceResolver->resolveReference($value);
220
                }
221
            } else {
222
                $match[$condition] = $this->referenceResolver->resolveReference($values);
223
            }
224
        }
225
226
        return $this->locationMatcher->match($match);
227
    }
228
229
    /**
230
     * @param int|string|array $locationKey

Core/Executor/ContentTypeManager.php 1 location

@@ 219-244 (lines=26) @@
216
     * @return RoleCollection
217
     * @throws \Exception
218
     */
219
    protected function matchContentTypes($action)
220
    {
221
        if (!isset($this->dsl['identifier']) && !isset($this->dsl['match'])) {
222
            throw new \Exception("The identifier of a contenttype or a match condition is required to $action it.");
223
        }
224
225
        // Backwards compat
226
        if (!isset($this->dsl['match'])) {
227
            $this->dsl['match'] = array('identifier' => $this->dsl['identifier']);
228
        }
229
230
        $match = $this->dsl['match'];
231
232
        // convert the references passed in the match
233
        foreach ($match as $condition => $values) {
234
            if (is_array($values)) {
235
                foreach ($values as $position => $value) {
236
                $match[$condition][$position] = $this->referenceResolver->resolveReference($value);
237
                }
238
            } else {
239
                $match[$condition] = $this->referenceResolver->resolveReference($values);
240
            }
241
        }
242
243
        return $this->contentTypeMatcher->match($match);
244
    }
245
246
    /**
247
     * Sets references to object attributes

Core/Executor/RoleManager.php 1 location

@@ 137-162 (lines=26) @@
134
     * @return RoleCollection
135
     * @throws \Exception
136
     */
137
    protected function matchRoles($action)
138
    {
139
        if (!isset($this->dsl['name']) && !isset($this->dsl['match'])) {
140
            throw new \Exception("The name of a role or a match condition is required to $action it.");
141
        }
142
143
        // Backwards compat
144
        if (!isset($this->dsl['match'])) {
145
            $this->dsl['match'] = array('identifier' => $this->dsl['name']);
146
        }
147
148
        $match = $this->dsl['match'];
149
150
        // convert the references passed in the match
151
        foreach ($match as $condition => $values) {
152
            if (is_array($values)) {
153
                foreach ($values as $position => $value) {
154
                    $match[$condition][$position] = $this->referenceResolver->resolveReference($value);
155
                }
156
            } else {
157
                $match[$condition] = $this->referenceResolver->resolveReference($values);
158
            }
159
        }
160
161
        return $this->roleMatcher->match($match);
162
    }
163
164
    /**
165
     * Set references to object attributes to be retrieved later.