You are here

public function UnitsEntityTranslationHandler::__construct in Units of Measurement 7.2

Same name and namespace in other branches
  1. 7 includes/UnitsEntityTranslationHandler.class.inc \UnitsEntityTranslationHandler::__construct()

Initializes an instance of the translation handler.

Parameters

$entity_type: The type of the entity being wrapped.

$entity_info: The entity information for the entity being wrapped.

$entity: The entity being wrapped.

Overrides EntityTranslationDefaultHandler::__construct

File

includes/UnitsEntityTranslationHandler.class.inc, line 13
Definition of UnitsEntityTranslationHandler class.

Class

UnitsEntityTranslationHandler
Entity translation class for units of measurement.

Code

public function __construct($entity_type, $entity_info, $entity) {

  // Alter the entity info here and substitute the measure %load with its
  // real value.
  foreach ($entity_info['translation']['entity_translation']['path schemes'] as $k => $v) {
    foreach (array(
      'base path',
      'view path',
      'edit path',
      'translate path',
    ) as $key) {
      $value = explode('/', $v[$key]);
      $value[$entity_info['translation']['entity_translation']['bundle argument']] = arg($entity_info['translation']['entity_translation']['bundle argument']);
      $entity_info['translation']['entity_translation']['path schemes'][$k][$key] = implode('/', $value);
    }
  }
  parent::__construct($entity_type, $entity_info, $entity);
}