Skip to content

Commit

Permalink
phpcs fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
torotil committed Apr 18, 2018
1 parent 8cd1fd2 commit 29b5d11
Showing 1 changed file with 60 additions and 26 deletions.
86 changes: 60 additions & 26 deletions modules/campaignion_supporter/src/Supporter.php
Expand Up @@ -2,52 +2,79 @@

namespace Drupal\campaignion_supporter;

use \Drupal\campaignion\ContactTypeInterface;
use \Drupal\campaignion\CRM\Import\Field;
use \Drupal\campaignion\CRM\ImporterBase;
use Drupal\campaignion\ContactTypeInterface;
use Drupal\campaignion\CRM\Import\Field\Address;
use Drupal\campaignion\CRM\Import\Field\Date;
use Drupal\campaignion\CRM\Import\Field\EmailBulk;
use Drupal\campaignion\CRM\Import\Field\Field;
use Drupal\campaignion\CRM\Import\Field\Name;
use Drupal\campaignion\CRM\Import\Field\Phone;
use Drupal\campaignion\CRM\ImporterBase;

use \Drupal\campaignion\CRM\Export\SingleValueField;
use \Drupal\campaignion\CRM\Export\WrapperField;
use \Drupal\campaignion\CRM\Export\MappedWrapperField;
use \Drupal\campaignion\CRM\Export\AddressField;
use \Drupal\campaignion\CRM\Export\DateField;
use \Drupal\campaignion\CRM\Export\KeyedField;
use \Drupal\campaignion\CRM\Export\TagField;
use \Drupal\campaignion\CRM\Export\TagsField;
use \Drupal\campaignion\CRM\ExporterBase;
use Drupal\campaignion\CRM\Export\SingleValueField;
use Drupal\campaignion\CRM\Export\WrapperField;
use Drupal\campaignion\CRM\Export\MappedWrapperField;
use Drupal\campaignion\CRM\Export\AddressField;
use Drupal\campaignion\CRM\Export\DateField;
use Drupal\campaignion\CRM\Export\KeyedField;
use Drupal\campaignion\CRM\Export\TagField;
use Drupal\campaignion\CRM\Export\TagsField;
use Drupal\campaignion\CRM\ExporterBase;

/**
* Contact-type for the "contact" contact-type.
*/
class Supporter implements ContactTypeInterface {
public function __construct() {}

/**
* Get a new contact-type instance.
*/
public function __construct() {
}

/**
* Create an importer for this contact-type.
*
* @param string $type
* The type of the importer. Usually importers are named by their source.
*/
public function importer($type) {
$mappings = array(
new Field\Name('first_name'),
new Field\Name('last_name'),
new Name('first_name'),
new Name('last_name'),
);
if ($type == 'campaignion_action_taken') {
$mappings = array_merge($mappings, array(
new Field\Field('field_gender', 'gender'),
new Field\Field('field_salutation', 'salutation'),
new Field\Field('field_title', 'title'),
new Field\Date('field_date_of_birth', 'date_of_birth'),
new Field\Address('field_address', array(
new Field('field_gender', 'gender'),
new Field('field_salutation', 'salutation'),
new Field('field_title', 'title'),
new Date('field_date_of_birth', 'date_of_birth'),
new Address('field_address', array(
'thoroughfare' => 'street_address',
'premise' => 'street_address_2',
'postal_code' => ['zip_code', 'postcode'],
'locality' => 'city',
'administrative_area' => 'state',
'country' => 'country',
)),
new Field\Phone('field_phone_number', 'phone_number'),
new Field\Phone('field_phone_number', 'mobile_number'),
new Field\EmailBulk('redhen_contact_email', 'email', 'email_newsletter'),
new Field\Field('field_direct_mail_newsletter', 'direct_mail_newsletter'),
new Field\Field('field_preferred_language', 'language'),
new Phone('field_phone_number', 'phone_number'),
new Phone('field_phone_number', 'mobile_number'),
new EmailBulk('redhen_contact_email', 'email', 'email_newsletter'),
new Field('field_direct_mail_newsletter', 'direct_mail_newsletter'),
new Field('field_preferred_language', 'language'),
));
}
return new ImporterBase($mappings);
}

/**
* Create an exporter for this contact-type.
*
* @param string $type
* The type of the exporter. Usually exporters are named by their target.
* @param string $language
* Language used for translated values.
*/
public function exporter($type, $language) {
$map = array();
$salutation_map = [
Expand Down Expand Up @@ -77,6 +104,7 @@ public function exporter($type, $language) {
$map['source'] = new TagField('source_tag');
$map['tags'] = new TagsField('supporter_tags', TRUE);
break;

case 'mailchimp':
$map['EMAIL'] = new WrapperField('email');
$map['FNAME'] = new SingleValueField('first_name');
Expand All @@ -97,6 +125,7 @@ public function exporter($type, $language) {
$map['SOURCE'] = new TagField('source_tag');
$map['TAGS'] = new TagsField('supporter_tags', TRUE);
break;

case 'dadiapi':
$map['email'] = new WrapperField('email');
$map['vorname'] = new SingleValueField('first_name');
Expand All @@ -110,6 +139,7 @@ public function exporter($type, $language) {
$map['plz'] = new KeyedField('field_address', 'postal_code');
$map['ort'] = new KeyedField('field_address', 'locality');
break;

case 'campaignion_manage':
$address_mapping = array(
'street' => 'thoroughfare',
Expand All @@ -119,6 +149,7 @@ public function exporter($type, $language) {
'city' => 'locality',
'region' => 'administrative_area',
);

$map['redhen_contact_email'] = new WrapperField('email');
$map['field_salutation'] = new MappedWrapperField('field_salutation', $salutation_map, FALSE);
$map['first_name'] = new SingleValueField('first_name');
Expand All @@ -134,10 +165,11 @@ public function exporter($type, $language) {
$map['field_phone_number'] = new WrapperField('field_phone_number');
$map['field_direct_mail_newsletter'] = new WrapperField('field_direct_mail_newsletter');
$map['field_social_network_links'] = new WrapperField('field_social_network_links');
$map['source_tag'] = new TagField('source_tag');
$map['source_tag'] = new TagField('source_tag');
$map['supporter_tags'] = new TagsField('supporter_tags');
$map['field_preferred_language'] = new WrapperField('field_preferred_language');
break;

case 'optivo':
$map['email'] = new WrapperField('email');
$map['anrede'] = new MappedWrapperField('field_salutation', $salutation_map, FALSE);
Expand All @@ -157,6 +189,7 @@ public function exporter($type, $language) {
$map['source'] = new TagField('source_tag');
$map['tags'] = new TagsField('supporter_tags', TRUE);
break;

case 'dotmailer':
$map['salutation'] = new MappedWrapperField('field_salutation', $salutation_map, FALSE);
$map['firstname'] = new SingleValueField('first_name');
Expand All @@ -179,4 +212,5 @@ public function exporter($type, $language) {
return new ExporterBase($map);
}
}

}

0 comments on commit 29b5d11

Please sign in to comment.