commerce_amws-8.x-1.x-dev/src/EntitySync/FieldMapping/ExportHandler.php

src/EntitySync/FieldMapping/ExportHandler.php
<?php

namespace Drupal\commerce_amws\EntitySync\FieldMapping;

use Drupal\commerce_amws\Utilities;
use Drupal\Core\Entity\ContentEntityInterface;

/**
 * Handles conversion of fields being exported to Amazon MWS.
 */
class ExportHandler {

  /**
   * Formats the given UNIX timestamp as required by Amazon MWS.
   *
   * @param \Drupal\Core\Entity\ContentEntityInterface $local_entity
   *   The local entity.
   * @param int|string|null $remote_entity_id
   *   The ID of the remote entity that will be updated, or NULL if we are
   *   creating a new one.
   * @param array $field_info
   *   The field info.
   *   See \Drupal\entity_sync\Export\Event\FieldMapping::fieldMapping.
   * @param array $params
   *   An array of custom parameters provided by the synchronization.
   *
   * @return string|null
   *   The formatted date string, or NULL if the requested field is empty.
   *
   * @throws \RuntimeException
   *   If the requested field does not exist on the referenced entity.
   */
  public static function timestampToAmwsDate(
    ContentEntityInterface $local_entity,
    $remote_entity_id,
    array $field_info,
    array $params
  ) {
    $field = $local_entity->get($field_info['machine_name']);
    if ($field->isEmpty()) {
      return;
    }

    return Utilities::timestampToIso8601($field->value);
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc