public function OnlyOne::getContentTypesList in Allow a content type only once (Only One) 8
Returns a content type label list.
Return value
array An associative array with the content type machine name as key and it label as value.
Overrides OnlyOneInterface::getContentTypesList
1 call to OnlyOne::getContentTypesList()
- OnlyOne::addAditionalInfoToContentTypes in src/
OnlyOne.php - Add additional information to the content types.
File
- src/
OnlyOne.php, line 108
Class
- OnlyOne
- Class OnlyOne.
Namespace
Drupal\onlyoneCode
public function getContentTypesList() {
// Looking for all the content types, as the content types are only
// accesibles through the entity_type.manager service we can't use a
// LEFT JOIN in only one query as is posible in Drupal 7
// (See Drupal 7 module version).
// @see http://drupal.stackexchange.com/q/233214/28275
$content_types = $this->entityTypeManager
->getStorage('node_type')
->loadMultiple();
// Creating an array with all content types.
$content_types_list_label = [];
foreach ($content_types as $content_type) {
$content_types_list_label[$content_type
->id()] = $content_type
->label();
}
return $content_types_list_label;
}