Révision a192dc0b
Ajouté par Assos Assos il y a environ 8 ans
drupal7/sites/all/modules/feeds/plugins/FeedsTermProcessor.inc | ||
---|---|---|
31 | 31 |
*/ |
32 | 32 |
protected function newEntity(FeedsSource $source) { |
33 | 33 |
$vocabulary = $this->vocabulary(); |
34 |
$term = new stdClass();
|
|
34 |
$term = parent::newEntity($source);
|
|
35 | 35 |
$term->vid = $vocabulary->vid; |
36 | 36 |
$term->vocabulary_machine_name = $vocabulary->machine_name; |
37 |
|
|
37 | 38 |
return $term; |
38 | 39 |
} |
39 | 40 |
|
41 |
/** |
|
42 |
* Load an existing entity. |
|
43 |
*/ |
|
44 |
protected function entityLoad(FeedsSource $source, $entity_id) { |
|
45 |
$entity = parent::entityLoad($source, $entity_id); |
|
46 |
|
|
47 |
// Avoid missing bundle errors when term has been loaded directly from db. |
|
48 |
if (empty($entity->vocabulary_machine_name) && !empty($entity->vid)) { |
|
49 |
$vocabulary = taxonomy_vocabulary_load($entity->vid); |
|
50 |
$entity->vocabulary_machine_name = ($vocabulary) ? $vocabulary->machine_name : NULL; |
|
51 |
} |
|
52 |
|
|
53 |
return $entity; |
|
54 |
} |
|
55 |
|
|
40 | 56 |
/** |
41 | 57 |
* Validates a term. |
42 | 58 |
*/ |
43 | 59 |
protected function entityValidate($term) { |
60 |
parent::entityValidate($term); |
|
61 |
|
|
44 | 62 |
if (drupal_strlen($term->name) == 0) { |
45 | 63 |
throw new FeedsValidationException(t('Term name missing.')); |
46 | 64 |
} |
... | ... | |
112 | 130 |
|
113 | 131 |
case 'parentguid': |
114 | 132 |
// value is parent_guid field value |
133 |
$parent_tid = 0; |
|
115 | 134 |
$query = db_select('feeds_item') |
116 | 135 |
->fields('feeds_item', array('entity_id')) |
117 | 136 |
->condition('entity_type', $this->entityType()); |
118 |
$parent_tid = $query->condition('guid', $value)->execute()->fetchField(); |
|
119 |
$target_term->parent[] = ($parent_tid) ? $parent_tid : 0; |
|
137 |
$term_ids = array_keys($query->condition('guid', $value)->execute()->fetchAllAssoc('entity_id')); |
|
138 |
if (!empty($term_ids)) { |
|
139 |
$terms = entity_load($this->entityType(), $term_ids); |
|
140 |
foreach ($terms as $term) { |
|
141 |
if ($term->vid == $target_term->vid) { |
|
142 |
$parent_tid = $term->tid; |
|
143 |
break; |
|
144 |
} |
|
145 |
} |
|
146 |
} |
|
147 |
$target_term->parent[] = $parent_tid; |
|
120 | 148 |
break; |
121 | 149 |
|
122 | 150 |
case 'weight': |
Formats disponibles : Unified diff
Weekly update of contrib modules