CRM_Utils_System_Base defines a great set of key functions that look like they should work in any system.

What is the correct way to access this functionality within an extension?

FYI these are the classes public methods:

addHTMLHead($head) addScript($code, $region) addScriptUrl($url, $region) addStyle($code, $region) addStyleUrl($url, $region) appendBreadCrumb($breadCrumbs) appendCoreResources(&$list) authenticate($name, $password, $loadCMSBootstrap = FALSE, $realPath = NULL) checkPermissionAddUser() clearResourceCache() cmsRootPath() createUser(&$params, $mail) flush() getBestUFID($user = NULL) getBestUFUniqueIdentifier($user = NULL) getDefaultBlockLocation() getDefaultSiteSettings($dir) getLoggedInUfID() getLoggedInUniqueIdentifier() getLoginDestination(&$form) getModules() getTimeZoneOffset() getTimeZoneString() getUFLocale() getUfId($username) getUniqueIdentifierFromUserObject($user) getUser($contactID) getUserIDFromUserObject($user) getUserRecordUrl($contactID) getVersion() isUserLoggedIn() languageNegotiationURL( loadUser($user) logger($message) logout() mapConfigToSSL() outputError($content) permissionDenied() postURL($action) resetBreadCrumb() setMessage($message) setMySQLTimeZone() setTitle($title, $pageTitle = NULL) setUserSession($data) theme(&$content, $print = FALSE, $maintenance = FALSE) updateCMSName($ufID, $email) updateCategories() url($path = NULL, $query = NULL, $absolute = FALSE, $fragment = NULL, $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE) userLoginFinalize($params = array())

(note a few of these are marked as only be called in certain contexts)

3 Answers 3


This base class is not intended to be used by itself, but extended based on the CMS. CiviCRM will automatically give you an instance of the correct object which extends this base class. You can access it via the CRM_Utils_System static methods. For example:



  • Cool @ErichBSchulz don't forget to mark this answer correct.
    – Coleman
    Commented Jan 1, 2017 at 3:36

It's probably easier to answer based on a specific need rather than your more generic "hey, found a stash of toys, can I play with them? ;)"

They are a few that you shouldn't use directly but use the more specific functions, so instead of:

addScript($code, $region)
addScriptUrl($url, $region)
addStyle($code, $region)
addStyleUrl($url, $region)

it's more common/recommended to use CRM_Core_Resources

  • hey thanks @Xavier! good point, but that is one cool box of toys!! I guess I'm hunting for a generic pattern of accessing this interface from the context of an extension author (I wish I'd known about some of them years ago!) Commented Dec 29, 2016 at 12:13

There is this example: CRM/Utils/System.php-1503- /** CRM/Utils/System.php-1504- * Check if user is logged in. CRM/Utils/System.php-1505- * CRM/Utils/System.php-1506- * @return bool CRM/Utils/System.php-1507- */ CRM/Utils/System.php:1508: public static function isUserLoggedIn() { CRM/Utils/System.php-1509- $config = CRM_Core_Config::singleton(); CRM/Utils/System.php:1510: return $config->userSystem->isUserLoggedIn(); CRM/Utils/System.php-1511- }

  • answered my own question as a "best guess" on the basis someone who knows more may wish to post a better answer! Commented Dec 29, 2016 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.