<?php
namespace SabaiApps\Directories\Component\PaymentGateway\CSVImporter;

use SabaiApps\Directories\Component\CSV\Importer\AbstractImporter;
use SabaiApps\Directories\Component\Entity\Model\Field;

class PlanCSVImporter extends AbstractImporter {

	public function csvImporterColumns( Field $field ) {
		return array(
			'plan_type'     => __( 'Plan type', 'directories-pro' ),
			'active'        => __( 'Active', 'directories-pro' ),
			'featured'      => __( 'Featured', 'directories-pro' ),
			'display_order' => __( 'Display order', 'directories-pro' ),
			'content_name'  => __( 'Content type', 'directories-pro' ),
			'data'          => __( 'Extra data', 'directories-pro' ),
		);
	}

	public function csvImporterDoImport( Field $field, array $settings, $column, $value, &$formStorage, array &$logs ) {
		if ( in_array( $column, array( 'data' ) ) ) {
			$value = @unserialize( $value );
			if ( ! is_array( $value ) ) {
				$value = array();
			}
		}
		return array( array( $column => $value ) );
	}
}
