Skip to content
Snippets Groups Projects

3280310 retrieve all customer field data

3 files
+ 119
50
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -3,6 +3,7 @@
namespace Drupal\cds_example_data\Plugin\CustomerDataStorage;
use Drupal\cds\CustomerDataStoragePluginBase;
use Drupal\cds\CustomerDataStoragePluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
/**
@@ -18,6 +19,42 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
class ExampleData extends CustomerDataStoragePluginBase {
use StringTranslationTrait;
/**
* The customer to retrieve the data from.
*
* @var array
*/
protected $customer;
/**
* {@inheritdoc}
*/
public function addSegment(string $segment) {
// Do nothing.
}
/**
* {@inheritdoc}
*/
public function getAllFields(): array {
return [
'email' => 'E-mail',
'phone' => 'Phone',
'firstName' => 'First name',
'lastName' => 'Last name',
];
}
/**
* {@inheritdoc}
*/
public function getAllSegments(): array {
return [
'foodlover' => $this->t('Food Lover'),
'musiclover' => $this->t('Music Lover'),
];
}
/**
* {@inheritdoc}
*/
@@ -40,25 +77,6 @@ class ExampleData extends CustomerDataStoragePluginBase {
}
}
/**
* {@inheritdoc}
*/
public function setField(string $field, string $data) {
// Do nothing.
}
/**
* {@inheritdoc}
*/
public function getAllFields(): array {
return [
'email' => $this->t('E-mail'),
'phone' => $this->t('Phone'),
'firstName' => $this->t('First name'),
'lastName' => $this->t('Last name'),
];
}
/**
* {@inheritdoc}
*/
@@ -69,20 +87,19 @@ class ExampleData extends CustomerDataStoragePluginBase {
}
/**
* {@inheritdoc}
* {@inheritDoc}
*/
public function addSegment(string $segment) {
public function setCustomer(string $customer_id): CustomerDataStoragePluginInterface {
// Do nothing.
return $this;
}
/**
* {@inheritdoc}
*/
public function getAllSegments(): array {
return [
'foodlover' => $this->t('Food Lover'),
'musiclover' => $this->t('Music Lover'),
];
public function setField(string $field, string $data): CustomerDataStoragePluginInterface {
// Do nothing.
return $this;
}
}
Loading