You are here

static function Recipe::FindObjects in Realistic Dummy Content 8

1 call to Recipe::FindObjects()
Recipe::Run in api/src/recipes/Recipe.php

File

api/src/recipes/Recipe.php, line 25
Define autoload class.

Class

Recipe

Namespace

Drupal\realistic_dummy_content_api\recipes

Code

static function FindObjects() {
  $objects = array();

  // We need to cycle through all active modules and look for those
  // which contain a class module_name_realistic_dummy_content_recipe
  // in the file realistic_dummy_content/recipe/module_name.recipe.inc
  $moduleHandler = \Drupal::moduleHandler();
  $modules = $moduleHandler
    ->getModuleList();
  foreach ($modules as $module) {
    $candidate = $module . '_realistic_dummy_content_recipe';
    if (module_load_include('inc', $module, 'realistic_dummy_content/recipe/' . $module . '.recipe') && class_exists($candidate)) {
      $objects[] = new $candidate();
    }
  }
  return $objects;
}