Code Duplication    Length = 25-26 lines in 2 locations

src/Collection.php 2 locations

@@ 284-309 (lines=26) @@
281
     * @param array $filteredIds Collection of filtered material identifiers
282
     * @return bool True if ALL navigation filtering succeeded or there was no filtering at all otherwise false
283
     */
284
    protected function applyNavigationFilter(& $filteredIds = array())
285
    {
286
        // Iterate all applied navigation filters
287
        foreach ($this->navigation as $navigation) {
288
            // Create navigation-material query
289
            $this->query->className('structurematerial')
290
291
                ->cond('StructureID', $navigation)
292
                ->cond('Active', 1)
293
                ->group_by('MaterialID')
294
            ;
295
296
            if (isset($filteredIds)) {
297
                $this->query->cond('MaterialID', $filteredIds);
298
            }
299
300
            // Perform request to get next portion of filtered material identifiers
301
            if (!$this->query->fields('MaterialID', $filteredIds)) {
302
                // This filter applying failed
303
                return false;
304
            }
305
        }
306
307
        // We have no navigation collection filters
308
        return true;
309
    }
310
311
    /**
312
     * Try to get all material identifiers filtered by additional field
@@ 318-342 (lines=25) @@
315
     * @param array $filteredIds Collection of filtered material identifiers
316
     * @return bool True if ALL field filtering succeeded or there was no filtering at all otherwise false
317
     */
318
    protected function applyFieldFilter(& $filteredIds = array())
319
    {
320
        // Iterate all applied field filters
321
        foreach ($this->field as $field) {
322
            // Create material-field query
323
            $this->query->className('materialfield')
324
                ->cond('FieldID', $field[0]->id)
325
                ->cond($field[1])
326
                ->group_by('MaterialID')
327
            ;
328
329
            if (isset($filteredIds)) {
330
                $this->query->cond('MaterialID', $filteredIds);
331
            }
332
333
            // Perform request to get next portion of filtered material identifiers
334
            if (!$this->query->fields('MaterialID', $filteredIds)) {
335
                // This filter applying failed
336
                return false;
337
            }
338
        }
339
340
        // We have no field collection filters
341
        return true;
342
    }
343
344
    /**
345
     * Try to find all materials which have fields similar to search strings