You are here

function ContentExport::exportBase in Content Export YAML 8

2 calls to ContentExport::exportBase()
ContentExport::export in src/ContentExport.php
ContentExport::exportWithPath in src/ContentExport.php

File

src/ContentExport.php, line 281

Class

ContentExport
Created by PhpStorm. User: USER Date: 11/13/18 Time: 2:04 PM

Namespace

Drupal\content_export_yaml

Code

function exportBase($id, $entity, $export_path) {
  if (is_object($id)) {
    $item = $id;
  }
  else {
    $item = \Drupal::entityTypeManager()
      ->getStorage($entity)
      ->load($id);
  }
  if (is_object($item)) {
    $yaml_content = $this
      ->parserYAMLObject($item);
    if ($export_path) {
      $export_path = DRUPAL_ROOT . '/' . $export_path;
      $final_path = $export_path . '/' . $entity . '/' . $item
        ->bundle();
      $status = $this
        ->generateFile($final_path, $item
        ->id(), $yaml_content);

      //@todo move to manager_content_export_yaml

      // if($status){
      //   $dbstatus = $this->db->is_exist($item->id(),$entity,$item->bundle());
      //   if(empty($dbstatus)){
      //     $fields = array(
      //       'entity_id'=> $item->id() ,
      //       'entity_type' => $entity,
      //       'bundle' => $item->bundle(),
      //       'label' => $item->label(),
      //       'file' => $themes_str_path.'/'.$entity.'/'.$item->bundle().'/'.$item->id().'.yml'
      //     );
      //     $this->db->insert($fields);
      //   }
      // }
      return $status;
    }
    else {
      $this->logger
        ->error('Path directory empty ');
      \Drupal::messenger()
        ->addMessage(t('Path directory empty.'), 'error');
      return FALSE;
    }
  }
  return FALSE;
}