function _entity_translation_process_path_schemes in Entity Translation 7
Processes the given path schemes and fill-in default values.
2 calls to _entity_translation_process_path_schemes()
- entity_translation_admin_form in ./
entity_translation.admin.inc - Builder function for the entity translation settings form.
- entity_translation_entity_info_alter in ./
entity_translation.module - Implements hook_entity_info_alter().
File
- ./
entity_translation.module, line 140
Code
function _entity_translation_process_path_schemes($entity_type, &$et_info) {
$path_scheme_keys = array_flip(array(
'base path',
'view path',
'edit path',
'translate path',
'path wildcard',
'admin theme',
'edit tabs',
));
// Insert the default path scheme into the 'path schemes' array and remove
// respective elements from the entity_translation info array.
$default_scheme = array_intersect_key($et_info, $path_scheme_keys);
if (!empty($default_scheme)) {
$et_info['path schemes']['default'] = $default_scheme;
$et_info = array_diff_key($et_info, $path_scheme_keys);
}
// If no base path is provided we default to the common "node/%node"
// pattern.
if (empty($et_info['path schemes']['default']['base path'])) {
$et_info['path schemes']['default']['base path'] = "{$entity_type}/%{$entity_type}";
}
foreach ($et_info['path schemes'] as $delta => $scheme) {
// If there is a base path, then we automatically create the other path
// elements based on the base path.
if (!empty($scheme['base path'])) {
$view_path = $scheme['base path'];
$edit_path = $scheme['base path'] . '/edit';
$translate_path = $scheme['base path'] . '/translate';
$et_info['path schemes'][$delta] += array(
'view path' => $view_path,
'edit path' => $edit_path,
'translate path' => $translate_path,
);
}
// Merge in default values for other scheme elements.
$et_info['path schemes'][$delta] += array(
'admin theme' => TRUE,
'path wildcard' => "%{$entity_type}",
'edit tabs' => TRUE,
);
}
}