Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

public function Html::import

Implements TMGMTFileExportInterface::import().

Overrides FormatInterface::import

File

translators/tmgmt_file/src/Plugin/tmgmt_file/Format/Html.php, line 62

Class

Html
Export into HTML.

Namespace

Drupal\tmgmt_file\Plugin\tmgmt_file\Format

Code

public function import($imported_file, $is_file = TRUE) {
  $dom = new \DOMDocument();
  $is_file ? $dom
    ->loadHTMLFile($imported_file) : $dom
    ->loadHTML($imported_file);
  $xml = simplexml_import_dom($dom);
  $data = array();
  foreach ($xml
    ->xpath("//div[@class='atom']") as $atom) {

    // Assets are our strings (eq fields in nodes).
    $key = $this
      ->decodeIdSafeBase64((string) $atom['id']);
    $data[$key]['#text'] = (string) $atom;
  }
  return \Drupal::service('tmgmt.data')
    ->unflatten($data);
}