Core::getDataTypeGroups PHP Method

getDataTypeGroups() public static method

public static getDataTypeGroups ( )
    public static function getDataTypeGroups()
    {
        return self::$dataTypeGroups;
    }

Usage Example

	/**
	 * Returns an array of available, grouped, instantiated Data Type objects.
	 * @param string
	 * @param boolean
	 * @return array
	 */
	public static function getDataTypePlugins($runtimeContext, $installedOnly = true) {
		$allowedDataTypes = array();
		if ($installedOnly) {
			$installedDataTypes = Settings::getSetting("installedDataTypes");
			$allowedDataTypes = explode(",", $installedDataTypes);
		}

		$dataTypesFolder = realpath(__DIR__ . "/../../plugins/dataTypes");
		$dataTypes = array();
		if ($handle = opendir($dataTypesFolder)) {
			while (false !== ($item = readdir($handle))) {
				if ($item == "." || $item == ".." || $item == ".svn") {
					continue;
				}
				if (!empty($allowedDataTypes) && !in_array($item, $allowedDataTypes)) {
					continue;
				}
				if (is_dir("$dataTypesFolder/$item")) {
					$obj = self::instantiateDataType($runtimeContext, $dataTypesFolder, $item);
					if ($obj != null && $obj !== false) {
						$folders = explode(DIRECTORY_SEPARATOR, $dataTypesFolder . DIRECTORY_SEPARATOR . $item);
						$folders = array_reverse($folders);

						$obj->path = "{$folders[2]}/{$folders[1]}/{$folders[0]}";
						$obj->folder = $item;
						$dataTypes[] = $obj;
					}
				}
			}
			closedir($handle);
		}

		// now sort the data type information by field groups first and their order within those
		// field groups
		$dataTypeGroups = Core::getDataTypeGroups();
		$sortedDataTypes = array();
		foreach ($dataTypeGroups as $groupNameKey) {
			$groupTypes = array();
			foreach ($dataTypes as $currDataType) {
				$currFieldGroupKey   = $currDataType->getDataTypeFieldGroup();
				$currFieldGroupOrder = $currDataType->getDataTypeFieldGroupOrder();

				if ($currFieldGroupKey == $groupNameKey) {
					// TODO this prevents two DataTypes using the same order, which leads to accidental bugs
					$groupTypes[$currFieldGroupOrder] = $currDataType;
				}
			}
			ksort($groupTypes, SORT_NUMERIC);
			$sortedDataTypes[$groupNameKey] = array_values($groupTypes);
		}

		return $sortedDataTypes;
	}