Skip to content

Instantly share code, notes, and snippets.

@scottalan
Created July 20, 2016 18:31
Show Gist options
  • Select an option

  • Save scottalan/85027831e1a116716be2c7563a052d7c to your computer and use it in GitHub Desktop.

Select an option

Save scottalan/85027831e1a116716be2c7563a052d7c to your computer and use it in GitHub Desktop.
D8:configFactory - Example
<?php
/**
* Get the names of all categories.

*
* @return array

* A list of existing category IDs.

*/
function wysiwyg_template_category_get_names() {
$names = &drupal_static(__FUNCTION__);
if (!isset($names)) {
$names = array();
$config_names = \Drupal::configFactory()
->listAll('wysiwyg_template_content.category.');
foreach ($config_names as $config_name) {
$id = substr($config_name, strlen('wysiwyg_template_content.category.'));
$names[$id] = $id;
}
}
return $names;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment