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( "Could not get location types: {$e->getMessage()}", MailinglistException::ERROR_CODE_GET_LOCATION_TYPES_FAILED, ); } // Cache location types \Civi::cache()->set(E::SHORT_NAME . '_location_types', $locationTypes); } return $locationTypes; } /** * Get a user ID of the current session. * * @return int */ function getSessionUser(): int { $session = \CRM_Core_Session::singleton(); return (int) $session->get('userID'); }