public static function enabled($addon_key = null, $key = null) {
        // Lazy build the enabled array.
        if (self::$enabled === null) {
            // Make sure the enabled addons have been added first.
            if (self::$enabledKeys === null) {
                throw new \Exception("Addons::boostrap() must be called before Addons::enabled() can be called.", 500);
            }

            if (self::$all !== null || self::$sharedEnvironment) {
                // Build the enabled array by filtering the all array.
                self::$enabled = array();
                foreach (self::all() as $key => $row) {
                    if (isset($key, self::$enabledKeys)) {
                        self::$enabled[$key] = $row;
                    }
                }
            } else {
                // Build the enabled array by walking the addons.
                self::$enabled = static::cacheGet('addons-enabled', function () {
                    return static::scanAddons(null, self::$enabledKeys);
                });
            }
        }

        // The array should be built now return the addon.
        if ($addon_key === null) {
            return self::$enabled;
        } else {
            $addon = val(strtolower($addon_key), self::$enabled);
            if ($addon && $key) {
                return val($key, $addon);
            } elseif ($addon) {
                return $addon;
            } else {
                return null;
            }
        }
    }
public static function enabled($addon_key = null, $key = null) {
        // Lazy build the enabled array.
        if (self::$enabled === null) {
            // Make sure the enabled addons have been added first.
            if (self::$enabledKeys === null) {
                throw new \Exception("Addons::boostrap() must be called before Addons::enabled() can be called.", 500);
            }

            if (self::$all !== null || self::$sharedEnvironment) {
                // Build the enabled array by filtering the all array.
                self::$enabled = array();
                foreach (self::all() as $key => $row) {
                    if (isset($key, self::$enabledKeys)) {
                        self::$enabled[$key] = $row;
                    }
                }
            } else {
                // Build the enabled array by walking the addons.
                self::$enabled = static::cacheGet('addons-enabled', function () {
                    return static::scanAddons(null, self::$enabledKeys);
                });
            }
        }

        // The array should be built now return the addon.
        if ($addon_key === null) {
            return self::$enabled;
        } else {
            $addon = val(strtolower($addon_key), self::$enabled);
            if ($addon && $key) {
                return val($key, $addon);
            } elseif ($addon) {
                return $addon;
            } else {
                return null;
            }
        }
    }
public static function enabled ( $ addon_key = null , $ key = null ) { // Lazy build the enabled array. if ( self :: $ enabled === null ) { // Make sure the enabled addons have been added first. if ( self :: $ enabledKeys === null ) { throw new \ Exception ( "Addons::boostrap() must be called before Addons::enabled() can be called." , 500 ) ; } if ( self :: $ all !== null || self :: $ sharedEnvironment ) { // Build the enabled array by filtering the all array. self :: $ enabled = array ( ) ; foreach ( self :: all ( ) as $ key => $ row ) { if ( isset ( $ key , self :: $ enabledKeys ) ) { self :: $ enabled [ $ key ] = $ row ; } } } else { // Build the enabled array by walking the addons. self :: $ enabled = static :: cacheGet ( 'addons-enabled' , function ( ) { return static :: scanAddons ( null , self :: $ enabledKeys ) ; } ) ; } } // The array should be built now return the addon. if ( $ addon_key === null ) { return self :: $ enabled ; } else { $ addon = val ( strtolower ( $ addon_key ) , self :: $ enabled ) ; if ( $ addon && $ key ) { return val ( $ key , $ addon ) ; } elseif ( $ addon ) { return $ addon ; } else { return null ; } } }
Get all of the enabled addons or a single addon from the enabled list.

@param string $addon_key If you supply an addon key then only that addon will be returned.
@param string $key Supply one of the Addons::K_* constants to get a specific key from the addon.
@return array Returns the addon with the given key or all enabled addons if no key is passed.
@throws \Exception Throws an exception if {@link Addons::bootstrap()} hasn't been called yet.
Get all of the enabled addons or a single addon from the enabled list .