class OfficialFacebookPixelOptions in Official Facebook Pixel 8
Same name and namespace in other branches
- 7 src/OfficialFacebookPixelOptions.php \Drupal\official_facebook_pixel\OfficialFacebookPixelOptions
Class OfficialFacebookPixelOptions.
@package Drupal\official_facebook_pixel
Hierarchy
- class \Drupal\official_facebook_pixel\OfficialFacebookPixelOptions
Expanded class hierarchy of OfficialFacebookPixelOptions
3 files declare their use of OfficialFacebookPixelOptions
- OfficialFacebookPixelInjection.php in src/
OfficialFacebookPixelInjection.php - Contains \Drupal\official_facebook_pixel \OfficialFacebookPixelInjection.
- OfficialFacebookPixelSettingsForm.php in src/
Form/ OfficialFacebookPixelSettingsForm.php - Contains \Drupal\official_facebook_pixel\Form \OfficialFacebookPixelSettingsForm.
- official_facebook_pixel.module in ./
official_facebook_pixel.module - Contains official_facebook_pixel.module.
File
- src/
OfficialFacebookPixelOptions.php, line 30 - Contains \Drupal\official_facebook_pixel \OfficialFacebookPixelOptions.
Namespace
Drupal\official_facebook_pixelView source
class OfficialFacebookPixelOptions {
private static $instance = null;
private $options = array();
private $userInfo = array();
private $versionInfo = array();
public static function getInstance() {
if (is_null(self::$instance)) {
self::$instance = new OfficialFacebookPixelOptions();
}
return self::$instance;
}
public function __construct() {
$this
->setOptions();
$this
->setUserInfo();
$this
->setVersionInfo();
}
public function getOptions() {
return $this->options;
}
private function setOptions() {
$config = \Drupal::config(OfficialFacebookPixelConfig::CONFIG_NAME);
$this->options = array(
OfficialFacebookPixelConfig::FORM_PIXEL_KEY => $config
->get(OfficialFacebookPixelConfig::FORM_PIXEL_KEY),
OfficialFacebookPixelConfig::FORM_PII_KEY => $config
->get(OfficialFacebookPixelConfig::FORM_PII_KEY),
);
}
public function getPixelId() {
return $this->options[OfficialFacebookPixelConfig::FORM_PIXEL_KEY];
}
public function getUsePii() {
return $this->options[OfficialFacebookPixelConfig::FORM_PII_KEY];
}
public function getUserInfo() {
return $this->userInfo;
}
public function setUserInfo() {
$user = \Drupal::currentUser();
$use_pii = $this
->getUsePii();
if (0 === $user
->id() || $use_pii !== 1) {
// User not logged in or admin chose not to send PII.
$this->userInfo = array();
}
else {
$this->userInfo = array_filter(array(
// Keys documented in
// https://developers.facebook.com/docs/facebook-pixel/pixel-with-ads/conversion-tracking#advanced_match
'em' => $user
->getEmail(),
), function ($value) {
return $value !== null && $value !== '';
});
}
}
public function getVersionInfo() {
return $this->versionInfo;
}
public function setVersionInfo() {
$this->versionInfo = array(
'source' => OfficialFacebookPixelConfig::SOURCE_8,
'version' => \Drupal::VERSION,
);
}
public function getAgentString() {
return sprintf('%s-%s', $this->versionInfo['source'], $this->versionInfo['version']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
OfficialFacebookPixelOptions:: |
private static | property | ||
OfficialFacebookPixelOptions:: |
private | property | ||
OfficialFacebookPixelOptions:: |
private | property | ||
OfficialFacebookPixelOptions:: |
private | property | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
public static | function | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
private | function | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
public | function | ||
OfficialFacebookPixelOptions:: |
public | function |