Back to Access class

Method preload

public static bool
preload
(mixed $assetTypes = 'components', mixed $reload = false)
Method to preload the Rules object for the given asset type.
Parameters
  • int|string|array $assetTypes The type or name of the asset (e.g. 'com_content.article', 'com_menus.menu.2'). Also accepts the asset id. An array of asset type or a special 'components' string to load all component assets.
  • bool $reload Set to true to reload from database.
Returns
  • bool True on success.
Since
  • 1.6
-
  • This method will return void in 4.0.
Class: Access
Project: Joomla

Method preload - Source code

/**
 * Method to preload the Rules object for the given asset type.
 *
 * @param   integer|string|array  $assetTypes  The type or name of the asset (e.g. 'com_content.article', 'com_menus.menu.2').
 *                                             Also accepts the asset id. An array of asset type or a special
 *                                             'components' string to load all component assets.
 * @param   boolean               $reload      Set to true to reload from database.
 *
 * @return  boolean  True on success.
 *
 * @since   1.6
 * @note    This method will return void in 4.0.
 */
public static function preload($assetTypes = 'components', $reload = false)
{
    // If sent an asset id, we first get the asset type for that asset id.
    if (is_numeric($assetTypes)) {
        $assetTypes = self::getAssetType($assetTypes);
    }
    // Check for default case:
    $isDefault = \is_string($assetTypes) && \in_array($assetTypes, array('components', 'component'));
    // Preload the rules for all of the components.
    if ($isDefault) {
        self::preloadComponents();
        return true;
    }
    // If we get to this point, this is a regular asset type and we'll proceed with the preloading process.
    if (!\is_array($assetTypes)) {
        $assetTypes = (array) $assetTypes;
    }
    foreach ($assetTypes as $assetType) {
        self::preloadPermissions($assetType, $reload);
    }
    return true;
}