-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
b01cc96
commit c8cdb82
Showing
35 changed files
with
2,785 additions
and
10 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
type: module | ||
name: Integration Migrate | ||
description: Contains stand-alone components for Migrate integration. | ||
core: 8.x | ||
package: Integration | ||
|
||
dependencies: | ||
- migrate |
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,165 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\integration\Backend\AbstractBackend. | ||
*/ | ||
|
||
namespace Drupal\integration\Backend; | ||
|
||
use Drupal\integration\Backend\Authentication\AuthenticationInterface; | ||
use Drupal\integration\ConfigurablePluginInterface; | ||
use Drupal\integration\Configuration\AbstractConfiguration; | ||
use Drupal\integration\Exceptions\BackendException; | ||
use Drupal\integration\ResourceSchema\ResourceSchemaFactory; | ||
|
||
/** | ||
* Class AbstractBackend. | ||
* | ||
* @package Drupal\integration\Backend | ||
*/ | ||
abstract class AbstractBackend implements BackendInterface, ConfigurablePluginInterface { | ||
|
||
/** | ||
* Configuration component. | ||
* | ||
* @var Configuration\BackendConfiguration | ||
*/ | ||
private $configuration; | ||
|
||
/** | ||
* Formatter component. | ||
* | ||
* @var Formatter\FormatterInterface | ||
*/ | ||
private $formatter; | ||
|
||
/** | ||
* Authentication component. | ||
* | ||
* @var AuthenticationInterface | ||
*/ | ||
private $authentication; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param Configuration\BackendConfiguration $configuration | ||
* Configuration object. | ||
* @param Formatter\FormatterInterface $formatter | ||
* Formatter object. | ||
* @param AuthenticationInterface $authentication | ||
* Authentication handler object. | ||
*/ | ||
public function __construct(Configuration\BackendConfiguration $configuration, Formatter\FormatterInterface $formatter, AuthenticationInterface $authentication) { | ||
$this->setConfiguration($configuration); | ||
$this->setFormatterHandler($formatter); | ||
$this->setAuthenticationHandler($authentication); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfiguration() { | ||
return $this->configuration; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setConfiguration(AbstractConfiguration $configuration) { | ||
$this->configuration = $configuration; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormatterHandler() { | ||
return isset($this->formatter) ? $this->formatter : ''; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setFormatterHandler(Formatter\FormatterInterface $formatter) { | ||
$this->formatter = $formatter; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAuthenticationHandler() { | ||
return $this->authentication; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setAuthenticationHandler(AuthenticationInterface $authentication) { | ||
$this->authentication = $authentication; | ||
} | ||
|
||
/** | ||
* Set backend setting value given its name and value. | ||
* | ||
* @param string $name | ||
* Plugin setting name. | ||
* @param mixed $value | ||
* Plugin setting value. | ||
* | ||
* @return $this | ||
*/ | ||
public function setBackendSetting($name, $value) { | ||
$this->getConfiguration()->setPluginSetting("backend.$name", $value); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Set resource schemas supported by this backend. | ||
* | ||
* @param string $resource_schema | ||
* Resource schema machine name. | ||
* | ||
* @return $this | ||
*/ | ||
public function setResourceSchema($resource_schema) { | ||
$values = $this->getConfiguration()->getPluginSetting('resource_schemas'); | ||
$values[] = $resource_schema; | ||
$this->getConfiguration()->setPluginSetting('resource_schemas', $values); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Ser resource schema setting. | ||
* | ||
* @param string $resource_schema | ||
* Resource schema machine name. | ||
* @param string $name | ||
* Setting name. | ||
* @param string $value | ||
* Setting name. | ||
* | ||
* @return $this | ||
*/ | ||
public function setResourceSchemaSetting($resource_schema, $name, $value) { | ||
$this->getConfiguration()->setPluginSetting("resource_schema.$resource_schema.$name", $value); | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function validateResourceSchema($machine_name) { | ||
// Load configuration, throws and exception if not found. | ||
ResourceSchemaFactory::getInstance($machine_name); | ||
|
||
$values = $this->getConfiguration()->getPluginSetting('resource_schemas'); | ||
if (!in_array($machine_name, $values)) { | ||
throw new BackendException(t('Resource schema "@machine_name" not supported by "@backend" backend.', [ | ||
'@machine_name' => $machine_name, | ||
'@backend' => $this->getConfiguration()->getMachineName(), | ||
])); | ||
} | ||
} | ||
|
||
} |
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,71 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\integration\Backend\Authentication\AbstractAuthentication. | ||
*/ | ||
|
||
namespace Drupal\integration\Backend\Authentication; | ||
|
||
use Drupal\integration\Configuration\AbstractConfiguration; | ||
|
||
/** | ||
* Class AbstractAuthentication. | ||
* | ||
* @package Drupal\integration\Backend\Authentication | ||
*/ | ||
abstract class AbstractAuthentication implements AuthenticationInterface { | ||
|
||
/** | ||
* Configuration object. | ||
* | ||
* @var AbstractConfiguration | ||
*/ | ||
private $configuration; | ||
|
||
/** | ||
* Context data which will be passed to the authentication callback. | ||
* | ||
* @var array | ||
*/ | ||
private $context; | ||
|
||
/** | ||
* AbstractAuthentication constructor. | ||
* | ||
* @param \Drupal\integration\Configuration\AbstractConfiguration $configuration | ||
* AbstractConfiguration Class instance. | ||
*/ | ||
public function __construct(AbstractConfiguration $configuration) { | ||
$this->configuration = $configuration; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getConfiguration() { | ||
return $this->configuration; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setConfiguration(AbstractConfiguration $configuration) { | ||
$this->configuration = $configuration; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getContext() { | ||
return $this->context; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setContext(array $context) { | ||
$this->context = $context; | ||
} | ||
|
||
} |
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,42 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\integration\Backend\Authentication\AuthenticationInterface. | ||
*/ | ||
|
||
namespace Drupal\integration\Backend\Authentication; | ||
use Drupal\integration\ConfigurablePluginInterface; | ||
|
||
/** | ||
* Interface AuthenticationInterface. | ||
* | ||
* @package Drupal\integration\Backend\Authentication | ||
*/ | ||
interface AuthenticationInterface extends ConfigurablePluginInterface { | ||
|
||
/** | ||
* Authenticates and provides an authentication result. | ||
* | ||
* @return bool | ||
* TRUE if authenticated, FALSE otherwise | ||
*/ | ||
public function authenticate(); | ||
|
||
/** | ||
* Get context data. | ||
* | ||
* @return array | ||
* Context data array. | ||
*/ | ||
public function getContext(); | ||
|
||
/** | ||
* Set context data. | ||
* | ||
* @param array $context | ||
* Context data array. | ||
*/ | ||
public function setContext(array $context); | ||
|
||
} |
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,32 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\integration\Backend\Authentication\HttpAuthentication. | ||
*/ | ||
|
||
namespace Drupal\integration\Backend\Authentication; | ||
|
||
/** | ||
* Class HttpAuthentication. | ||
* | ||
* @package Drupal\integration\Backend\Authentication | ||
*/ | ||
class HttpAuthentication extends AbstractAuthentication { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function authenticate() { | ||
$configuration = $this->getConfiguration(); | ||
$username = $configuration->getComponentSetting('authentication_handler', 'username'); | ||
$password = $configuration->getComponentSetting('authentication_handler', 'password'); | ||
|
||
$context = $this->getContext(); | ||
list($protocol, $uri) = explode('://', $context['url']); | ||
$context['url'] = "$protocol://$username:$password@$uri"; | ||
$this->setContext($context); | ||
return TRUE; | ||
} | ||
|
||
} |
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,24 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains \Drupal\integration\Backend\Authentication\NoAuthentication. | ||
*/ | ||
|
||
namespace Drupal\integration\Backend\Authentication; | ||
|
||
/** | ||
* Class NoAuthentication. | ||
* | ||
* @package Drupal\integration\Backend\Authentication | ||
*/ | ||
class NoAuthentication extends AbstractAuthentication { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function authenticate() { | ||
return TRUE; | ||
} | ||
|
||
} |
Oops, something went wrong.