1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Field Collection Item translation handler for the Entity Translation module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Field Collection Item translation handler.
|
10
|
*
|
11
|
* Overrides default behaviours for Field Collection Item properties.
|
12
|
*/
|
13
|
class EntityTranslationFieldCollectionItemHandler extends EntityTranslationDefaultHandler {
|
14
|
|
15
|
/**
|
16
|
* {@inheritdoc}
|
17
|
*/
|
18
|
public function __construct($entity_type, $entity_info, $entity) {
|
19
|
parent::__construct('field_collection_item', $entity_info, $entity);
|
20
|
|
21
|
// Initialize the path scheme for the current bundle, unless we are dealing
|
22
|
// with the "default" bundle.
|
23
|
if ($this->bundle != $entity_info['translation']['entity_translation']['default_scheme']) {
|
24
|
$this->setPathScheme($this->bundle);
|
25
|
}
|
26
|
}
|
27
|
|
28
|
/**
|
29
|
* {@inheritdoc}
|
30
|
*/
|
31
|
public function getAccess($op) {
|
32
|
return entity_access($op, 'field_collection_item', $this->entity);
|
33
|
}
|
34
|
|
35
|
/**
|
36
|
* {@inheritdoc}
|
37
|
*/
|
38
|
public function getLanguage() {
|
39
|
// Do not use $this->entity->langcode() as this will finally call
|
40
|
// field_collection_entity_language() which again calls us!
|
41
|
// If the current field is untranslatable, try inherit the host entity
|
42
|
// language.
|
43
|
if (($host_entity_type = $this->entity->hostEntityType()) && entity_translation_enabled($host_entity_type) && ($host_entity = $this->entity->hostEntity())) {
|
44
|
$handler = $this->factory->getHandler($host_entity_type, $host_entity);
|
45
|
$langcode = $handler->getLanguage();
|
46
|
}
|
47
|
// If the host entity is not translatable, use the default language
|
48
|
// fallback.
|
49
|
else {
|
50
|
$langcode = parent::getLanguage();
|
51
|
}
|
52
|
return $langcode;
|
53
|
}
|
54
|
|
55
|
}
|