get(E::SHORT_NAME . '_location_types'); // Get location types from database if not in cache if ($locationTypes === NULL) { $locationTypeNames = [ GroupMailingList::getLocationTypeName(), ADGroupMailingList::getLocationTypeName(), EventMailingList::getLocationTypeName(), ]; try { $result = LocationType::get() ->addSelect('id', 'name') ->addWhere('name', 'IN', $locationTypeNames) ->execute() ->getArrayCopy(); $locationTypes = []; foreach ($result as $locationType) { $locationTypes[$locationType['id']] = $locationType['name']; } } catch (\Exception $e) { throw new MailinglistException( E::ts('Could not get location types'), MailinglistException::ERROR_CODE_GET_LOCATION_TYPES_FAILED, ); } // Cache location types \Civi::cache()->set(E::SHORT_NAME . '_location_types', $locationTypes); } return $locationTypes; }