You are here

function units_ui_entity_info_alter in Units of Measurement 7.2

Same name and namespace in other branches
  1. 7 units_ui.module \units_ui_entity_info_alter()

Implements hook_entity_info_alter().

Add UI controller info to entity types 'units_measure' and 'units_unit' and alter access callback to one provided by units_ui module, which respects permissions defined in units_ui module.

File

./units_ui.module, line 40
Provide UI for managing available units and conversions between them.

Code

function units_ui_entity_info_alter(&$entity_info) {
  $entity_info['units_unit']['admin ui'] = array(
    'path' => 'units-ui/%units_measure_machine_name',
    // This number denotes what position in path the bundle argument is
    // located at.
    'path bundle argument position' => 1,
    'file' => 'units_ui.pages.inc',
    'controller class' => 'UnitsUnitUIController',
  );
  $entity_info['units_unit']['access callback'] = 'units_ui_entity_access';

  // For each bundle we add ability to manage fields via Field API.
  if (isset($entity_info['units_unit']['bundles'])) {
    foreach ($entity_info['units_unit']['bundles'] as $bundle => $bundle_info) {
      $entity_info['units_unit']['bundles'][$bundle]['admin'] = array(
        'path' => 'admin/structure/units-measure/manage/%units_measure_machine_name',
        'real path' => 'admin/structure/units-measure/manage/' . $bundle,
        'bundle argument' => 4,
      );
    }
  }
  $entity_info['units_unit']['translation'] = array(
    'entity_translation' => array(
      'class' => 'UnitsEntityTranslationHandler',
      'base path' => $entity_info['units_unit']['admin ui']['path'] . '/manage/%units_unit_machine_name',
      'path wildcard' => '%units_unit_machine_name',
      // This is a custom property from Units UI module that will be used in
      // its UnitsEntityTranslationHandler class.
      'bundle argument' => 1,
    ),
  );
  $entity_info['units_measure']['admin ui'] = array(
    'path' => 'admin/structure/units-measure',
    'file' => 'units_ui.pages.inc',
    'controller class' => 'UnitsMeasureUIController',
  );
  $entity_info['units_measure']['access callback'] = 'units_ui_entity_access';
}