Code Duplication    Length = 24-24 lines in 2 locations

src/Collection.php 2 locations

@@ 299-322 (lines=24) @@
296
     *
297
     * @return bool True if ALL navigation filtering succeeded or there was no filtering at all otherwise false
298
     */
299
    protected function applyNavigationFilter(&$filteredIds = array())
300
    {
301
        // Iterate all applied navigation filters
302
        foreach ($this->navigation as $navigation) {
303
            // Create navigation-material query
304
            $this->query->entity('\samson\activerecord\structurematerial')
305
                ->where('StructureID', $navigation)
306
                ->where('Active', 1)
307
                ->groupBy('MaterialID');
308
309
            if (null !== $filteredIds) {
310
                $this->query->where('MaterialID', $filteredIds);
311
            }
312
313
            // Perform request to get next portion of filtered material identifiers
314
            if (!$this->query->fields('MaterialID', $filteredIds)) {
315
                // This filter applying failed
316
                return false;
317
            }
318
        }
319
320
        // We have no navigation collection filters
321
        return true;
322
    }
323
324
    /**
325
     * Try to get all material identifiers filtered by additional field
@@ 332-355 (lines=24) @@
329
     *
330
     * @return bool True if ALL field filtering succeeded or there was no filtering at all otherwise false
331
     */
332
    protected function applyFieldFilter(&$filteredIds = array())
333
    {
334
        // Iterate all applied field filters
335
        foreach ($this->field as $field) {
336
            // Create material-field query
337
            $this->query->entity('\samson\activerecord\materialfield')
338
                ->where('FieldID', $field[0]->id)
339
                ->whereCondition($field[1])
340
                ->groupBy('MaterialID');
341
342
            if (null !== $filteredIds) {
343
                $this->query->where('MaterialID', $filteredIds);
344
            }
345
346
            // Perform request to get next portion of filtered material identifiers
347
            if (!$this->query->fields('MaterialID', $filteredIds)) {
348
                // This filter applying failed
349
                return false;
350
            }
351
        }
352
353
        // We have no field collection filters
354
        return true;
355
    }
356
357
    /**
358
     * Try to find all materials which have fields similar to search strings