/**
  * {@inheritdoc}
  */
 function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ClientInterface $http_client)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     $this->method = $configuration['method'];
     $this->url = $configuration['url'];
     $this->httpClient = $http_client;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     $this->file = "/Users/pieter-jandrouillon/Documents/drupalsites/d8/modules/dev/la2015/src/test/test.csv";
     $this->delimiter = ';';
     $this->ids = array('idnr');
     $this->readHeaders();
 }
Exemple #3
0
 public function prepareRow(Row $row)
 {
     // do my row mods here..
     // e.g.
     $temp_title = $row->getSourceProperty("title");
     $row->setSourceProperty("title", strtoupper($temp_title));
     return parent::prepareRow($row);
     // TODO: Change the autogenerated stub
 }
 /**
  * Constructor.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param MigrationInterface $migration
  *   The migration.
  * @param EntityManagerInterface $entity_manager
  *   The entity manager.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     $this->entityManager = $entity_manager;
     list($entity_type_id) = explode('__', $migration->id());
     $entity_type = $entity_manager->getDefinition($entity_type_id);
     $this->entityTypeId = $entity_type_id;
     $this->entityIdKey = $entity_type->getKey('id');
 }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     // Path is required.
     if (empty($this->configuration['path'])) {
         throw new MigrateException('You must declare the "path" to the source CSV file in your source settings.');
     }
     // Identifier field(s) are required.
     if (empty($this->configuration['identifiers'])) {
         throw new MigrateException('You must declare "identifiers" as a unique array of fields in your source settings.');
     }
 }
 public function prepareRow(Row $row)
 {
     // do my row mods here..
     // Bail if this is a non-published recipe
     //$status = $row->getSourceProperty("status");
     //if ($status != 'Published') {
     //  return FALSE;
     //}
     //$title = $row->getSourceProperty("title");
     //$photos = $row->getSourceProperty("photos");
     //$photos = $this->preparePhotos($title, $photos);
     //$row->setSourceProperty("uri", $photos);
     // set created to now..
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, array $namespaces = array())
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     $config_fields = array('path', 'headers', 'fields', 'identifier');
     // Store the configuration data.
     foreach ($config_fields as $config_field) {
         if (isset($configuration[$config_field])) {
             $this->{$config_field} = $configuration[$config_field];
         } else {
             // Throw Exception
             throw new MigrateException('The source configuration must include ' . $config_field . '.');
         }
     }
     // Allow custom reader and client classes to be passed in as configuration settings.
     $this->clientClass = empty($configuration['clientClass']) ? '\\Drupal\\migrate_source_json\\Plugin\\migrate\\JSONClient' : $configuration['clientClass'];
     $this->readerClass = empty($configuration['readerClass']) ? '\\Drupal\\migrate_source_json\\Plugin\\migrate\\JSONReader' : $configuration['readerClass'];
     // Create the JSON reader that will process the request, and pass it configuration.
     $this->reader = new $this->readerClass();
     $this->reader->setConfiguration($configuration);
 }
 public function prepareRow(Row $row)
 {
     // do my row mods here..
     $title = $row->getSourceProperty("title");
     $str = sprintf("Processing: %s", $title);
     drush_print_r($str);
     // Bail if this is a non-published recipe
     $status = $row->getSourceProperty("status");
     if ($status != 'Published') {
         return FALSE;
         // Don't migrate non-published recipes.
     }
     $nutrition = $row->getSourceProperty("basic_nutrition");
     $nutrition_string = $this->prepareNutritionInfo($nutrition);
     $row->setSourceProperty("basic_nutrition", $nutrition_string);
     $ingredients = $row->getSourceProperty("ingredients");
     $ingredients = $this->prepareIngredients($ingredients);
     $row->setSourceProperty("ingredients", $ingredients);
     $title = $row->getSourceProperty("title");
     $photos = $row->getSourceProperty("photos");
     $photos = $this->preparePhotos($title, $photos);
     $row->setSourceProperty("photos", $photos);
     return parent::prepareRow($row);
 }
 public function prepareRow(Row $row)
 {
     // Perform source row modification here.
     // Bail if this is a non-published store
     $status = $row->getSourceProperty("status");
     if ($status != 'OPEN') {
         return FALSE;
     }
     $geo = $row->getSourceProperty("geo_location");
     $x = $geo['coordinates'][0];
     $y = $geo['coordinates'][1];
     $row->setSourceProperty("geox", $x);
     $row->setSourceProperty("geoy", $y);
     $hours = $row->getSourceProperty("hours");
     $row->setSourceProperty("hours", ltrim($hours));
     $country = $row->getSourceProperty("country");
     $country = $this->getIsoCountryCode($country);
     $row->setSourceProperty("country", $country);
     $state = $row->getSourceProperty("state");
     if ($country == "US") {
         $state = $this->getUsaStateCode($state);
         $row->setSourceProperty("state", $state);
     }
     $facebook = $row->getSourceProperty("facebook");
     if (!empty($facebook)) {
         $facebook = "https://www.facebook.com/" . ltrim(trim($facebook));
     }
     $row->setSourceProperty("facebook", $facebook);
     $has_alcohol = $row->getSourceProperty("has_alcohol");
     if (empty($has_alcohol)) {
         $has_alcohol = 0;
         $row->setSourceProperty("has_alcohol", $has_alcohol);
     }
     //TODO: "states" not in USA - ie UK & Canada
     //TODO: lookup region eg. NE in taxonomy and store region actual taxonomy in field_store_region
     $tlc = $row->getSourceProperty("tlc");
     $name = $row->getSourceProperty("name");
     $country = $row->getSourceProperty("country");
     $state = $row->getSourceProperty("state");
     $has_alcohol = $row->getSourceProperty("has_alcohol");
     $str = sprintf("%s: %s %s %s alc:%s", $tlc, $name, $state, $country, $has_alcohol);
     drush_print_r($str);
     return parent::prepareRow($row);
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
 }
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     $this->dataRows = $configuration['data_rows'];
     $this->ids = $configuration['ids'];
 }
 public function prepareRow(Row $row)
 {
     // do my row mods here..
     // Bail if this is a non-published recipe
     //$status = $row->getSourceProperty("status");
     //if ($status != 'Published') {
     //  return FALSE;
     //}
     //$filename = $row->getSourceProperty("filename") ;
     //$str = sprintf("Processing: %s", $filename);
     //drush_print_r($str);
     $uri = $row->getSourceProperty("uri");
     $str = sprintf("Processing: %s", $uri);
     drush_print_r($str);
     return parent::prepareRow($row);
 }
Exemple #13
0
 /**
  * {@inheritdoc}
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
     $this->state = $state;
 }
Exemple #14
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $row->setSourceProperty('uid', 0);
     $email = $row->getSourceProperty('email');
     $user = $this->entityQuery->get('user')->condition('mail', $email)->execute();
     if ($user) {
         $row->setSourceProperty('uid', key($user));
     }
     return parent::prepareRow($row);
 }