Skip to content

Commit

Permalink
Merge pull request #115 from ctidigital/configurator-3.x
Browse files Browse the repository at this point in the history
Configurator 3
  • Loading branch information
paulpartington-cti authored Jan 20, 2020
2 parents ce00f41 + 6270399 commit 1044a8a
Show file tree
Hide file tree
Showing 87 changed files with 1,896 additions and 2,191 deletions.
28 changes: 15 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dist: trusty
language: php
php:
- 7.0
- 7.1
- 7.2
- 7.3
services:
- mysql
sudo: required
Expand All @@ -11,32 +11,34 @@ env:
- TEST_SUITE=unit
- TEST_SUITE=phpcs
- TEST_SUITE=configurator
MAGE_VERSION=2.1.15
MAGE_VERSION=2.2.5
- TEST_SUITE=configurator
MAGE_VERSION=2.2.4
MAGE_VERSION=2.3.1
- TEST_SUITE=configurator
MAGE_VERSION=2.2.5
MAGE_VERSION=2.3.2
- TEST_SUITE=configurator
MAGE_VERSION=2.2.6
MAGE_VERSION=2.3.3

matrix:
allow_failures:
- php: 7.0
- env: TEST_SUITE=configurator MAGE_VERSION=2.1.15
- php: 7.2
- env: TEST_SUITE=configurator MAGE_VERSION=2.2.5
- env: TEST_SUITE=configurator MAGE_VERSION=2.3.1
- env: TEST_SUITE=configurator MAGE_VERSION=2.3.2

before_install:
- echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then composer require magento/framework:~101.0.0; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/framework:~101.0.0; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/module-catalog:~102.0.0; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/zendframework1:~1.13.0; fi"
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then composer require magento/framework:^102.0.3; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/framework:^102.0.3; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/module-catalog; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer require magento/zendframework1; fi"
install:
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then composer install --prefer-dist; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then composer install --prefer-dist; fi"
before_script:
- sh -c "if [ '$TEST_SUITE' = 'configurator' ]; then ./Test/Integration/setup-magento.sh $MAGE_VERSION; fi"
script:
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then php vendor/bin/phpcs --standard=PSR2 Model/ Console/ Test/ Component/ Api/ Exception/; fi"
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then php vendor/bin/phpcs --standard=vendor/magento/magento-coding-standard/Magento2/ruleset.xml Model/ Console/ Test/ Component/ Api/ Exception/; fi"
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then php vendor/bin/phpmd Model/,Console/,Test/,Component/,Api/,Exception/ text cleancode,codesize,controversial,design,naming,unusedcode; fi"
- sh -c "if [ '$TEST_SUITE' = 'phpcs' ]; then php vendor/bin/phpcpd Model/ Console/ Test/ Component/ Api/ Exception/; fi"
- sh -c "if [ '$TEST_SUITE' = 'unit' ]; then php vendor/bin/phpunit --coverage-clover build/logs/clover.xml Test/Unit/; fi"
Expand Down
22 changes: 22 additions & 0 deletions Api/ComponentInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace CtiDigital\Configurator\Api;

interface ComponentInterface
{
/**
* @param array $data
* @return void
*/
public function execute($data);

/**
* @return string
*/
public function getAlias();

/**
* @return string
*/
public function getDescription();
}
17 changes: 17 additions & 0 deletions Api/ComponentListInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace CtiDigital\Configurator\Api;

interface ComponentListInterface
{
/**
* @param $componentAlias
* @return ComponentInterface|bool
*/
public function getComponent($componentAlias);

/**
* @return ComponentInterface[]
*/
public function getAllComponents();
}
7 changes: 7 additions & 0 deletions Api/FileComponentInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace CtiDigital\Configurator\Api;

interface FileComponentInterface extends ComponentInterface
{

}
42 changes: 29 additions & 13 deletions Component/AdminRoles.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
namespace CtiDigital\Configurator\Component;

use CtiDigital\Configurator\Api\ComponentInterface;
use CtiDigital\Configurator\Exception\ComponentException;
use CtiDigital\Configurator\Api\LoggerInterface;
use Magento\Authorization\Model\RoleFactory;
use Magento\Framework\ObjectManagerInterface;
use Magento\Authorization\Model\RulesFactory;
use CtiDigital\Configurator\Api\LoggerInterface;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
use CtiDigital\Configurator\Exception\ComponentException;

class AdminRoles extends YamlComponentAbstract
class AdminRoles implements ComponentInterface
{
protected $alias = 'adminroles';
protected $name = 'Admin Roles';
Expand All @@ -29,31 +29,31 @@ class AdminRoles extends YamlComponentAbstract
*/
protected $rulesFactory;

/**
* @var LoggerInterface
*/
private $log;

/**
* AdminRoles constructor.
* @param LoggerInterface $log
* @param ObjectManagerInterface $objectManager
* @param RoleFactory $roleFactory
* @param RulesFactory $rulesFactory
*/
public function __construct(
LoggerInterface $log,
ObjectManagerInterface $objectManager,
RoleFactory $roleFactory,
RulesFactory $rulesFactory
RulesFactory $rulesFactory,
LoggerInterface $log
) {
parent::__construct($log, $objectManager);

$this->roleFactory = $roleFactory;
$this->rulesFactory = $rulesFactory;
$this->log = $log;
}

/**
* @param $data
*/
protected function processData($data = null)
public function execute($data = null)
{

if (isset($data['adminroles'])) {
foreach ($data['adminroles'] as $role) {
try {
Expand Down Expand Up @@ -128,4 +128,20 @@ private function setResourceIds($role, array $resources = null)
sprintf('Admin Role "%s" Resources are empty, please check your yaml file', $roleName)
);
}

/**
* @return string
*/
public function getAlias()
{
return $this->alias;
}

/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
}
39 changes: 28 additions & 11 deletions Component/AdminUsers.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php
namespace CtiDigital\Configurator\Component;

use Symfony\Component\Yaml\Yaml;
use CtiDigital\Configurator\Api\ComponentInterface;
use Magento\User\Model\UserFactory;
use Magento\Authorization\Model\RoleFactory;
use Magento\Framework\ObjectManagerInterface;
use CtiDigital\Configurator\Api\LoggerInterface;
use CtiDigital\Configurator\Exception\ComponentException;

class AdminUsers extends YamlComponentAbstract
class AdminUsers implements ComponentInterface
{
protected $alias = 'adminusers';
protected $name = 'Admin Users';
Expand All @@ -28,29 +27,31 @@ class AdminUsers extends YamlComponentAbstract
*/
protected $roleFactory;

/**
* @var LoggerInterface
*/
private $log;

/**
* AdminUsers constructor.
* @param LoggerInterface $log
* @param ObjectManagerInterface $objectManager
* @param UserFactory $userFactory
* @param RoleFactory $roleFactory
* @param LoggerInterface $log
*/
public function __construct(
LoggerInterface $log,
ObjectManagerInterface $objectManager,
UserFactory $userFactory,
RoleFactory $roleFactory
RoleFactory $roleFactory,
LoggerInterface $log
) {
parent::__construct($log, $objectManager);

$this->userFactory = $userFactory;
$this->roleFactory = $roleFactory;
$this->log = $log;
}

/**
* @param data
*/
protected function processData($data = null)
public function execute($data = null)
{
//Get Each Role
foreach ($data['adminusers'] as $roleSet) {
Expand Down Expand Up @@ -171,4 +172,20 @@ private function dataValidator($userData)

return true;
}

/**
* @return string
*/
public function getAlias()
{
return $this->alias;
}

/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
}
38 changes: 28 additions & 10 deletions Component/ApiIntegrations.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
namespace CtiDigital\Configurator\Component;

use Magento\Framework\ObjectManagerInterface;
use CtiDigital\Configurator\Api\ComponentInterface;
use Magento\Integration\Model\IntegrationFactory;
use Magento\Integration\Model\Oauth\TokenFactory;
use CtiDigital\Configurator\Api\LoggerInterface;
use Magento\Integration\Model\AuthorizationService;
use Magento\Integration\Api\IntegrationServiceInterface;
use CtiDigital\Configurator\Exception\ComponentException;

class ApiIntegrations extends YamlComponentAbstract
class ApiIntegrations implements ComponentInterface
{
protected $alias = 'apiintegrations';
protected $name = 'Api Integrations';
Expand All @@ -35,35 +35,37 @@ class ApiIntegrations extends YamlComponentAbstract
*/
protected $tokenFactory;

/**
* @var LoggerInterface
*/
protected $log;

/**
* ApiIntegrations constructor.
* @param LoggerInterface $log
* @param ObjectManagerInterface $objectManager
* @param IntegrationFactory $integrationFactory
* @param IntegrationServiceInterface $integrationService
* @param AuthorizationService $authorizationService
* @param TokenFactory $tokenFactory
* @param LoggerInterface $log
*/
public function __construct(
LoggerInterface $log,
ObjectManagerInterface $objectManager,
IntegrationFactory $integrationFactory,
IntegrationServiceInterface $integrationService,
AuthorizationService $authorizationService,
TokenFactory $tokenFactory
TokenFactory $tokenFactory,
LoggerInterface $log
) {
parent::__construct($log, $objectManager);

$this->integrationFactory = $integrationFactory;
$this->integrationService = $integrationService;
$this->authorizationService = $authorizationService;
$this->tokenFactory = $tokenFactory;
$this->log = $log;
}

/**
* @param array $data
*/
protected function processData($data = null)
public function execute($data = null)
{
if (isset($data['apiintegrations'])) {
foreach ($data['apiintegrations'] as $integrationData) {
Expand Down Expand Up @@ -166,4 +168,20 @@ private function activateAndAuthorize($consumerId)
$token->setType('access');
$token->save();
}

/**
* @return string
*/
public function getAlias()
{
return $this->alias;
}

/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
}
Loading

0 comments on commit 1044a8a

Please sign in to comment.