-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Samuel Heinz
committed
Apr 30, 2018
0 parents
commit 56bde8d
Showing
22 changed files
with
893 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
# CSS-Files | ||
[*.css] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# HTML-Files | ||
[*.html] | ||
indent_style = tab | ||
indent_size = 2 | ||
|
||
# TMPL-Files | ||
[*.tmpl] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# SCSS-Files | ||
[*.scss] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# JS-Files | ||
[*.js] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# JSON-Files | ||
[*.json] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# PHP-Files | ||
[*.php] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# ReST-Files | ||
[*.rst] | ||
indent_style = space | ||
indent_size = 3 | ||
|
||
# MD-Files | ||
[*.md] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
# YAML-Files | ||
[{*.yaml,*.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# package.json | ||
# .travis.yml | ||
# bower.json | ||
[{package.json,.travis.yml,bower.json}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# TypoScript | ||
[*.ts] | ||
indent_style = space | ||
indent_size = 2 | ||
[*.typoscript] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
# XLF-Files | ||
[*.xlf] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# SQL-Files | ||
[*.sql] | ||
indent_style = tab | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*~ | ||
*.bak | ||
*.swp | ||
.DS_Store | ||
Thumbs.db | ||
nbproject | ||
*.idea | ||
*.project | ||
.buildpath | ||
.settings | ||
.TemporaryItems | ||
.webprj | ||
.cache | ||
.php_cs.cache | ||
.sass-cache | ||
.session | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
namespace T3premium\FemanagerCleverreach\CleverReach; | ||
|
||
use T3premium\FemanagerCleverreach\Tools\Rest; | ||
|
||
class Api | ||
{ | ||
/** | ||
* @var \T3premium\FemanagerCleverreach\Service\ConfigurationService | ||
* @inject | ||
*/ | ||
protected $configurationService; | ||
|
||
/** | ||
* @var Rest | ||
*/ | ||
protected $rest; | ||
|
||
public function connect() | ||
{ | ||
|
||
if ($this->rest !== null) { | ||
return; | ||
} | ||
|
||
$this->rest = new Rest($this->configurationService->getRestUrl()); | ||
|
||
// Get CleverReach connection data of typoscript | ||
$token = $this->rest->post('/login', | ||
[ | ||
'client_id' => $this->configurationService->getClientId(), | ||
'login' => $this->configurationService->getClientLogin(), | ||
'password' => $this->configurationService->getClientPassword() | ||
] | ||
); | ||
$this->rest->setAuthMode('bearer', $token); | ||
} | ||
|
||
/** | ||
* Adds new receiver CleverReach. Ignores, if already in list. | ||
* | ||
* @param array $receivers | ||
* @param int $groupId | ||
* @return mixed | ||
*/ | ||
public function addReceiversToGroup($receivers, $groupId = null) | ||
{ | ||
// Connect to CleverReach REST API | ||
$this->connect(); | ||
|
||
if ($groupId === null || $groupId === '') { | ||
$groupId = $this->configurationService->getGroupId(); | ||
} | ||
|
||
$return = $this->rest->post('/groups/' . $groupId . '/receivers', | ||
$receivers | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
namespace T3premium\FemanagerCleverreach\Finisher; | ||
|
||
use In2code\Femanager\Domain\Model\User; | ||
use In2code\Femanager\Finisher\AbstractFinisher; | ||
|
||
/** | ||
* Class CleverReachFinisher | ||
* | ||
* @package T3premium\FemanagerCleverreach\Finisher | ||
*/ | ||
class CleverReachFinisher extends AbstractFinisher | ||
{ | ||
|
||
/** | ||
* @var \T3premium\FemanagerCleverreach\CleverReach\Api | ||
* @inject | ||
*/ | ||
protected $api; | ||
|
||
/** | ||
* @var User | ||
*/ | ||
protected $user; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $configuration; | ||
|
||
/** | ||
* CrFinisher | ||
* | ||
* @return void | ||
*/ | ||
public function crFinisher() | ||
{ | ||
|
||
$receivers[] = array( | ||
"email" => $this->user->getEmail(), | ||
"firstname" => $this->user->getFirstName(), | ||
"lastname" => $this->user->getLastName(), | ||
"registered" => strtotime("now"), | ||
"activated" => strtotime("now"), | ||
); | ||
|
||
// Add new receiver to CleverReach | ||
$this->api->addReceiversToGroup($receivers,$groupId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
namespace T3premium\FemanagerCleverreach\Service; | ||
|
||
/** | ||
* Class ConfigurationService | ||
*/ | ||
class ConfigurationService { | ||
|
||
|
||
/** | ||
* @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface | ||
* @inject | ||
*/ | ||
protected $objectManager; | ||
|
||
|
||
public function getConfiguration() { | ||
/** | ||
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface | ||
* $configurationManager | ||
*/ | ||
$configurationManager = $this->objectManager->get('TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface'); | ||
$settings = $configurationManager->getConfiguration( | ||
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT, | ||
'femanager' | ||
); | ||
return $settings['plugin.']['tx_femanager.']['settings.']['finishers.']['100.']['config.']; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getRestUrl() { | ||
|
||
$config = $this->getConfiguration(); | ||
return $config['restUrl']; | ||
|
||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getClientId() { | ||
|
||
$config = $this->getConfiguration(); | ||
return (int)$config['clientId']; | ||
|
||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getClientLogin() { | ||
$config = $this->getConfiguration(); | ||
return $config['clientLogin']; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getClientPassword() { | ||
$config = $this->getConfiguration(); | ||
return $config['clientPassword']; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getGroupId() { | ||
$config = $this->getConfiguration(); | ||
return (int)$config['groupId']; | ||
} | ||
} |
Oops, something went wrong.