/** * Returns either all data type definitions, or a specific one. * * @param string|null $type * (optional) If specified, the type whose definition should be returned. * * @return string[][]|string[]|null * If $type was not given, an array containing all data types. Otherwise, * the definition for the given type, or NULL if it is unknown. * * @see \Drupal\search_api\Utility::getDefaultDataTypes() * @see \Drupal\search_api\DataTypePluginManager::getCustomDataTypes() */ public function getDataTypeDefinitions($type = NULL) { if (!isset($this->dataTypes)) { $default_types = Utility::getDefaultDataTypes(); $custom_data_types = []; foreach ($this->getCustomDataTypes() as $name => $custom_data_type) { $custom_data_types[$name] = array('label' => $custom_data_type->label(), 'description' => $custom_data_type->getDescription(), 'fallback' => $custom_data_type->getFallbackType()); } $this->dataTypes = array_merge($default_types, $custom_data_types); } if (isset($type)) { return isset($this->dataTypes[$type]) ? $this->dataTypes[$type] : NULL; } return $this->dataTypes; }