Skip to content
Snippets Groups Projects
Commit 1dc97490 authored by Carlos Romero's avatar Carlos Romero
Browse files

feat: add queries to the title and alt tables

parent a7732143
No related branches found
No related tags found
No related merge requests found
......@@ -247,6 +247,28 @@ class MWD7Node extends Node {
if(isset($data_field['type']) && $data_field["destiny"] != 'none'){
switch ($data_field['type']) {
case 'image':
$new_value = [];
foreach($row->getSourceProperty($field_name) as $key => $value){
$query_uri = $this->select('file_managed', 'fm');
$query_uri->fields('fm', ['uri']);
$query_uri->leftJoin('field_data_field_file_image_alt_text', "ffat", "fm.fid = ffat.entity_id");
$query_uri->fields('ffat', ['field_file_image_alt_text_value']);
$query_uri->leftJoin('field_data_field_file_image_title_text', "fftt", "fm.fid = fftt.entity_id");
$query_uri->fields('fftt', ['field_file_image_title_text_value']);
$query_uri->condition('fm.fid', $value['fid']);
$results = $query_uri->execute()->fetch();
$new_value[$key] = $value;
if ($results["field_file_image_alt_text_value"]) {
$new_value[0]["alt"] = $results["field_file_image_alt_text_value"];
}
if ($results["field_file_image_title_text_value"]) {
$new_value[0]["title"] = $results["field_file_image_title_text_value"];
}
$new_value[$key]['uri'] = $results['uri'];
$new_value[$key]['type'] = $data_field['type'];
}
$row->setSourceProperty($field_name, $new_value);
break;
case 'file':
$new_value = [];
foreach($row->getSourceProperty($field_name) as $key => $value){
......
......@@ -211,6 +211,28 @@ class MWD7ParagraphsItem extends ParagraphsItem {
if(isset($data_field['type']) && $data_field["destiny"] != 'none'){
switch ($data_field['type']) {
case 'image':
$new_value = [];
foreach($row->getSourceProperty($field_name) as $key => $value){
$query_uri = $this->select('file_managed', 'fm');
$query_uri->fields('fm', ['uri']);
$query_uri->leftJoin('field_data_field_file_image_alt_text', "ffat", "fm.fid = ffat.entity_id");
$query_uri->fields('ffat', ['field_file_image_alt_text_value']);
$query_uri->leftJoin('field_data_field_file_image_title_text', "fftt", "fm.fid = fftt.entity_id");
$query_uri->fields('fftt', ['field_file_image_title_text_value']);
$query_uri->condition('fm.fid', $value['fid']);
$results = $query_uri->execute()->fetch();
$new_value[$key] = $value;
if ($results["field_file_image_alt_text_value"]) {
$new_value[0]["alt"] = $results["field_file_image_alt_text_value"];
}
if ($results["field_file_image_title_text_value"]) {
$new_value[0]["title"] = $results["field_file_image_title_text_value"];
}
$new_value[$key]['uri'] = $results['uri'];
$new_value[$key]['type'] = $data_field['type'];
}
$row->setSourceProperty($field_name, $new_value);
break;
case 'file':
$new_value = [];
foreach($row->getSourceProperty($field_name) as $key => $value){
......
......@@ -248,6 +248,28 @@ class MWD7Term extends Term {
if(isset($data_field['type']) && $data_field["destiny"] != 'none'){
switch ($data_field['type']) {
case 'image':
$new_value = [];
foreach($row->getSourceProperty($field_name) as $key => $value){
$query_uri = $this->select('file_managed', 'fm');
$query_uri->fields('fm', ['uri']);
$query_uri->leftJoin('field_data_field_file_image_alt_text', "ffat", "fm.fid = ffat.entity_id");
$query_uri->fields('ffat', ['field_file_image_alt_text_value']);
$query_uri->leftJoin('field_data_field_file_image_title_text', "fftt", "fm.fid = fftt.entity_id");
$query_uri->fields('fftt', ['field_file_image_title_text_value']);
$query_uri->condition('fm.fid', $value['fid']);
$results = $query_uri->execute()->fetch();
$new_value[$key] = $value;
if ($results["field_file_image_alt_text_value"]) {
$new_value[0]["alt"] = $results["field_file_image_alt_text_value"];
}
if ($results["field_file_image_title_text_value"]) {
$new_value[0]["title"] = $results["field_file_image_title_text_value"];
}
$new_value[$key]['uri'] = $results['uri'];
$new_value[$key]['type'] = $data_field['type'];
}
$row->setSourceProperty($field_name, $new_value);
break;
case 'file':
$new_value = [];
foreach($row->getSourceProperty($field_name) as $key => $value){
......
......@@ -220,6 +220,28 @@ class MWD7User extends User {
if(isset($data_field['type']) && $data_field["destiny"] != 'none'){
switch ($data_field['type']) {
case 'image':
$new_value = [];
foreach($row->getSourceProperty($field_name) as $key => $value){
$query_uri = $this->select('file_managed', 'fm');
$query_uri->fields('fm', ['uri']);
$query_uri->leftJoin('field_data_field_file_image_alt_text', "ffat", "fm.fid = ffat.entity_id");
$query_uri->fields('ffat', ['field_file_image_alt_text_value']);
$query_uri->leftJoin('field_data_field_file_image_title_text', "fftt", "fm.fid = fftt.entity_id");
$query_uri->fields('fftt', ['field_file_image_title_text_value']);
$query_uri->condition('fm.fid', $value['fid']);
$results = $query_uri->execute()->fetch();
$new_value[$key] = $value;
if ($results["field_file_image_alt_text_value"]) {
$new_value[0]["alt"] = $results["field_file_image_alt_text_value"];
}
if ($results["field_file_image_title_text_value"]) {
$new_value[0]["title"] = $results["field_file_image_title_text_value"];
}
$new_value[$key]['uri'] = $results['uri'];
$new_value[$key]['type'] = $data_field['type'];
}
$row->setSourceProperty($field_name, $new_value);
break;
case 'file':
$new_value = [];
if($field_name != 'picture'){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment