Esempio n. 1
0
	/**
	 * Internal function to lookup the saved data for a given component based on its name.
	 *
	 * Will return null if it doesn't exist or an array.
	 *
	 * @param string $componentname The name of the component to lookup
	 *
	 * @return array | null
	 */
	public static function _LookupComponentData($componentname) {
		if (self::$_DBCache === null) {
			self::$_DBCache = array();

			// Try to load the components
			try {
				$res = Core\Datamodel\Dataset::Init()->table('component')->select('*')->execute();
			}
				// But since this function is called during the installer, it might fail... that's acceptable.
			catch (DMI_Exception $e) {
				return false;
			}

			foreach ($res as $r) {
				$n                  = strtolower($r['name']);
				self::$_DBCache[$n] = $r;
			}
		}

		$componentname = strtolower($componentname);

		return (isset(self::$_DBCache[$componentname])) ? self::$_DBCache[$componentname] : null;
	}