Code Duplication    Length = 25-26 lines in 2 locations

src/Collection.php 2 locations

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