You are here

function _datalayer_collect_meta_properties in dataLayer 8

Same name and namespace in other branches
  1. 7 datalayer.module \_datalayer_collect_meta_properties()

Collects up meta data for output.

Parameters

string $type: Entity type to collect meta from, defaults to generic.

Return value

array Array of all candidate entity properties.

3 calls to _datalayer_collect_meta_properties()
DatalayerSettingsForm::buildForm in src/Form/DatalayerSettingsForm.php
Form constructor.
datalayer_get_user_data in ./datalayer.module
Return all user data based on configured URL patterns.
_datalayer_get_entity_data in ./datalayer.module
Collect entity data for output and altering.

File

./datalayer.module, line 124
Client-side data space.

Code

function _datalayer_collect_meta_properties($type = '') {
  $hooks = [];
  if (is_string($type) && !empty($type)) {
    $hooks[] = "datalayer_{$type}_meta";
  }
  $hooks[] = 'datalayer_meta';

  // Avoid duplicate builds.
  $properties =& drupal_static(__FUNCTION__ . $type);
  if (!isset($properties)) {
    $properties = [];
    foreach ($hooks as $hook) {
      foreach (\Drupal::moduleHandler()
        ->getImplementations($hook) as $module) {

        // Call modules implementing datalayer_meta() and combine results.
        $properties = array_merge($properties, \Drupal::moduleHandler()
          ->invoke($module, $hook));
      }
      if (!empty($properties)) {
        break;
      }
    }
    \Drupal::moduleHandler()
      ->alter($hooks, $properties);
  }
  return $properties;
}