/** * Return an array all the Provider objects supplied by extensions, * optionally filtered by a given `$type`. * * @since Symphony 2.3 * @todo Add information about the possible types * @param string $type * This will only return Providers of this type. If null, which is * default, all providers will be returned. * @return array * An array of objects */ public static function getProvidersOf($type = null) { // Loop over all extensions and build an array of providable objects if (empty(self::$_providers)) { self::$_providers = array(); foreach (self::listInstalledHandles() as $handle) { $obj = self::getInstance($handle); if (!method_exists($obj, 'providerOf')) { continue; } $providers = $obj->providerOf(); if (empty($providers)) { continue; } // For each of the matching objects (by $type), resolve the object path self::$_providers = array_merge_recursive(self::$_providers, $obj->providerOf()); } } // Return an array of objects if (is_null($type)) { return self::$_providers; } if (!isset(self::$_providers[$type])) { return array(); } return self::$_providers[$type]; }