| @@ 58-79 (lines=22) @@ | ||
| 55 | * @return bool|array True if field entities has been found and $return is passed |
|
| 56 | * or collection of identifiers if only two parameters is passed. |
|
| 57 | */ |
|
| 58 | public static function idsByNavigationID( |
|
| 59 | QueryInterface $query, |
|
| 60 | $navigationID, |
|
| 61 | &$return = array(), |
|
| 62 | $materialIDs = null |
|
| 63 | ) { |
|
| 64 | // Prepare query |
|
| 65 | $query->entity(CMS::FIELD_NAVIGATION_RELATION_ENTITY) |
|
| 66 | ->where('StructureID', $navigationID) |
|
| 67 | ->where('Active', 1); |
|
| 68 | ||
| 69 | // Add material identifier filter if passed |
|
| 70 | if (isset($materialIDs)) { |
|
| 71 | $query->where('MaterialID', $materialIDs); |
|
| 72 | } |
|
| 73 | ||
| 74 | // Perform database query and get only material identifiers collection |
|
| 75 | $return = $query->fields('FieldID'); |
|
| 76 | ||
| 77 | // If only one argument is passed - return null, otherwise bool |
|
| 78 | return func_num_args() > 2 ? sizeof($return) : $return; |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * Get current entity instances collection by navigation identifier. |
|
| @@ 91-112 (lines=22) @@ | ||
| 88 | * @return bool|array True if material entities has been found and $return is passed |
|
| 89 | * or collection of identifiers if only two parameters is passed. |
|
| 90 | */ |
|
| 91 | public static function idsByNavigationID( |
|
| 92 | QueryInterface $query, |
|
| 93 | $navigationID, |
|
| 94 | &$return = array(), |
|
| 95 | $materialIDs = null |
|
| 96 | ) { |
|
| 97 | // Prepare query |
|
| 98 | $query->entity(CMS::MATERIAL_NAVIGATION_RELATION_ENTITY) |
|
| 99 | ->where('StructureID', $navigationID) |
|
| 100 | ->where('Active', 1); |
|
| 101 | ||
| 102 | // Add material identifier filter if passed |
|
| 103 | if (isset($materialIDs)) { |
|
| 104 | $query->where('MaterialID', $materialIDs); |
|
| 105 | } |
|
| 106 | ||
| 107 | // Perform database query and get only material identifiers collection |
|
| 108 | $return = $query->fields('MaterialID'); |
|
| 109 | ||
| 110 | // If only one argument is passed - return null, otherwise bool |
|
| 111 | return func_num_args() > 2 ? sizeof($return) : $return; |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Get current entity instances collection by their identifiers. |
|