Skip to content

Commit f64d443

Browse files
author
Cari Spruiell
committed
MAGETWO-33456: [Code Quality] Improve Code Structuring
- Initial implementation
1 parent 93eab13 commit f64d443

File tree

231 files changed

+1220
-1280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+1220
-1280
lines changed

Diff for: app/code/Magento/ConfigurableProduct/Model/OptionRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public function save($productSku, \Magento\ConfigurableProduct\Api\Data\OptionIn
240240
*
241241
* @param string $productSku
242242
* @return \Magento\Catalog\Model\Product
243-
* @throws InputException
243+
* @throws \Magento\Webapi\Exception
244244
*/
245245
private function getProduct($productSku)
246246
{

Diff for: app/code/Magento/Integration/Model/Manager.php renamed to app/code/Magento/Integration/Model/ConfigBasedIntegrationManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Class to manage integrations installed from config file
1212
*
1313
*/
14-
class Manager
14+
class ConfigBasedIntegrationManager
1515
{
1616
/**
1717
* Integration service

Diff for: app/code/Magento/Integration/Helper/Validator.php renamed to app/code/Magento/Integration/Model/CredentialsValidator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Integration\Helper;
7+
namespace Magento\Integration\Model;
88

99
use Magento\Framework\Exception\InputException;
1010

1111
/**
1212
* Validator Helper for user credentials
1313
*/
14-
class Validator
14+
class CredentialsValidator
1515
{
1616
/**
1717
* Validate user credentials
@@ -21,7 +21,7 @@ class Validator
2121
* @throws InputException
2222
* @return void
2323
*/
24-
public function validateCredentials($username, $password)
24+
public function validate($username, $password)
2525
{
2626
$exception = new InputException();
2727
if (!is_string($username) || strlen($username) == 0) {

Diff for: app/code/Magento/Integration/Model/Integration/Factory.php renamed to app/code/Magento/Integration/Model/IntegrationFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* Copyright © 2015 Magento. All rights reserved.
66
* See COPYING.txt for license details.
77
*/
8-
namespace Magento\Integration\Model\Integration;
8+
namespace Magento\Integration\Model;
99

10-
class Factory
10+
class IntegrationFactory
1111
{
1212
/**
1313
* @var \Magento\Framework\ObjectManagerInterface

Diff for: app/code/Magento/Integration/Model/Oauth/Consumer/Factory.php renamed to app/code/Magento/Integration/Model/Oauth/ConsumerFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* Copyright © 2015 Magento. All rights reserved.
66
* See COPYING.txt for license details.
77
*/
8-
namespace Magento\Integration\Model\Oauth\Consumer;
8+
namespace Magento\Integration\Model\Oauth;
99

10-
class Factory
10+
class ConsumerFactory
1111
{
1212
/**
1313
* @var \Magento\Framework\ObjectManagerInterface

Diff for: app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Generator implements NonceGeneratorInterface
1616
protected $_oauthHelper;
1717

1818
/**
19-
* @var \Magento\Integration\Model\Oauth\Nonce\Factory
19+
* @var \Magento\Integration\Model\Oauth\NonceFactory
2020
*/
2121
protected $_nonceFactory;
2222

@@ -37,13 +37,13 @@ class Generator implements NonceGeneratorInterface
3737

3838
/**
3939
* @param \Magento\Framework\Oauth\Helper\Oauth $oauthHelper
40-
* @param \Magento\Integration\Model\Oauth\Nonce\Factory $nonceFactory
40+
* @param \Magento\Integration\Model\Oauth\NonceFactory $nonceFactory
4141
* @param \Magento\Framework\Stdlib\DateTime\DateTime $date
4242
* @param int $nonceLength - Length of the generated nonce
4343
*/
4444
public function __construct(
4545
\Magento\Framework\Oauth\Helper\Oauth $oauthHelper,
46-
\Magento\Integration\Model\Oauth\Nonce\Factory $nonceFactory,
46+
\Magento\Integration\Model\Oauth\NonceFactory $nonceFactory,
4747
\Magento\Framework\Stdlib\DateTime\DateTime $date,
4848
$nonceLength = \Magento\Framework\Oauth\Helper\Oauth::LENGTH_NONCE
4949
) {

Diff for: app/code/Magento/Integration/Model/Oauth/Nonce/Factory.php renamed to app/code/Magento/Integration/Model/Oauth/NonceFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Integration\Model\Oauth\Nonce;
6+
namespace Magento\Integration\Model\Oauth;
77

88
/**
99
* Nonce builder factory.
1010
*/
11-
class Factory
11+
class NonceFactory
1212
{
1313
/**
1414
* @var \Magento\Framework\ObjectManagerInterface

Diff for: app/code/Magento/Integration/Model/Oauth/Token.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Token extends \Magento\Framework\Model\AbstractModel
6666
protected $_oauthData;
6767

6868
/**
69-
* @var \Magento\Integration\Model\Oauth\Consumer\Factory
69+
* @var \Magento\Integration\Model\Oauth\ConsumerFactory
7070
*/
7171
protected $_consumerFactory;
7272

@@ -93,7 +93,7 @@ class Token extends \Magento\Framework\Model\AbstractModel
9393
* @param \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory $keyLengthFactory
9494
* @param \Magento\Framework\Url\Validator $urlValidator
9595
* @param \Magento\Framework\Stdlib\DateTime $dateTime
96-
* @param \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory
96+
* @param \Magento\Integration\Model\Oauth\ConsumerFactory $consumerFactory
9797
* @param \Magento\Integration\Helper\Oauth\Data $oauthData
9898
* @param OauthHelper $oauthHelper
9999
* @param \Magento\Framework\Model\Resource\AbstractResource $resource
@@ -107,7 +107,7 @@ public function __construct(
107107
\Magento\Integration\Model\Oauth\Consumer\Validator\KeyLengthFactory $keyLengthFactory,
108108
\Magento\Framework\Url\Validator $urlValidator,
109109
\Magento\Framework\Stdlib\DateTime $dateTime,
110-
\Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory,
110+
\Magento\Integration\Model\Oauth\ConsumerFactory $consumerFactory,
111111
\Magento\Integration\Helper\Oauth\Data $oauthData,
112112
OauthHelper $oauthHelper,
113113
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
@@ -243,11 +243,10 @@ public function createRequestToken($entityId, $callbackUrl)
243243
/**
244244
* Get string representation of token
245245
*
246-
* @param string $format
247246
* @return string
248247
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
249248
*/
250-
public function toString($format = '')
249+
public function __toString()
251250
{
252251
return http_build_query(['oauth_token' => $this->getToken(), 'oauth_token_secret' => $this->getSecret()]);
253252
}

Diff for: app/code/Magento/Integration/Model/Oauth/Token/Provider.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class Provider implements TokenProviderInterface
1414
{
1515
/**
16-
* @var \Magento\Integration\Model\Oauth\Consumer\Factory
16+
* @var \Magento\Integration\Model\Oauth\ConsumerFactory
1717
*/
1818
protected $_consumerFactory;
1919

@@ -28,12 +28,12 @@ class Provider implements TokenProviderInterface
2828
protected $logger;
2929

3030
/**
31-
* @param \Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory
31+
* @param \Magento\Integration\Model\Oauth\ConsumerFactory $consumerFactory
3232
* @param \Magento\Integration\Model\Oauth\TokenFactory $tokenFactory
3333
* @param \Psr\Log\LoggerInterface $logger
3434
*/
3535
public function __construct(
36-
\Magento\Integration\Model\Oauth\Consumer\Factory $consumerFactory,
36+
\Magento\Integration\Model\Oauth\ConsumerFactory $consumerFactory,
3737
\Magento\Integration\Model\Oauth\TokenFactory $tokenFactory,
3838
\Psr\Log\LoggerInterface $logger
3939
) {

Diff for: app/code/Magento/Integration/Model/Resource/Setup.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
*/
66
namespace Magento\Integration\Model\Resource;
77

8-
use Magento\Integration\Model\Manager;
8+
use Magento\Integration\Model\ConfigBasedIntegrationManager;
99

1010
/**
1111
* Resource Setup Model
1212
*/
1313
class Setup extends \Magento\Framework\Module\DataSetup
1414
{
1515
/**
16-
* @var Manager
16+
* @var ConfigBasedIntegrationManager
1717
*/
1818
protected $_integrationManager;
1919

@@ -22,15 +22,15 @@ class Setup extends \Magento\Framework\Module\DataSetup
2222
*
2323
* @param \Magento\Framework\Module\Setup\Context $context
2424
* @param string $resourceName
25-
* @param Manager $integrationManager
25+
* @param ConfigBasedIntegrationManager $integrationManager
2626
* @param string $moduleName
2727
* @param string $connectionName
2828
*
2929
*/
3030
public function __construct(
3131
\Magento\Framework\Module\Setup\Context $context,
3232
$resourceName,
33-
Manager $integrationManager,
33+
ConfigBasedIntegrationManager $integrationManager,
3434
$moduleName = 'Magento_Integration',
3535
$connectionName = \Magento\Framework\Module\Updater\SetupInterface::DEFAULT_SETUP_CONNECTION
3636
) {

Diff for: app/code/Magento/Integration/Service/V1/AdminTokenService.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use Magento\Framework\Exception\AuthenticationException;
1010
use Magento\Framework\Exception\LocalizedException;
11-
use Magento\Integration\Helper\Validator;
11+
use Magento\Integration\Model\CredentialsValidator;
1212
use Magento\Integration\Model\Oauth\Token as Token;
1313
use Magento\Integration\Model\Oauth\TokenFactory as TokenModelFactory;
1414
use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory as TokenCollectionFactory;
@@ -35,7 +35,7 @@ class AdminTokenService implements AdminTokenServiceInterface
3535
private $userModel;
3636

3737
/**
38-
* @var \Magento\Integration\Helper\Validator
38+
* @var \Magento\Integration\Model\CredentialsValidator
3939
*/
4040
private $validatorHelper;
4141

@@ -52,13 +52,13 @@ class AdminTokenService implements AdminTokenServiceInterface
5252
* @param TokenModelFactory $tokenModelFactory
5353
* @param UserModel $userModel
5454
* @param TokenCollectionFactory $tokenModelCollectionFactory
55-
* @param \Magento\Integration\Helper\Validator $validatorHelper
55+
* @param \Magento\Integration\Model\CredentialsValidator $validatorHelper
5656
*/
5757
public function __construct(
5858
TokenModelFactory $tokenModelFactory,
5959
UserModel $userModel,
6060
TokenCollectionFactory $tokenModelCollectionFactory,
61-
Validator $validatorHelper
61+
CredentialsValidator $validatorHelper
6262
) {
6363
$this->tokenModelFactory = $tokenModelFactory;
6464
$this->userModel = $userModel;
@@ -71,7 +71,7 @@ public function __construct(
7171
*/
7272
public function createAdminAccessToken($username, $password)
7373
{
74-
$this->validatorHelper->validateCredentials($username, $password);
74+
$this->validatorHelper->validate($username, $password);
7575
try {
7676
$this->userModel->login($username, $password);
7777
if (!$this->userModel->getId()) {

Diff for: app/code/Magento/Integration/Service/V1/CustomerTokenService.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use Magento\Customer\Api\AccountManagementInterface;
1010
use Magento\Framework\Exception\LocalizedException;
11-
use Magento\Integration\Helper\Validator;
11+
use Magento\Integration\Model\CredentialsValidator;
1212
use Magento\Integration\Model\Oauth\Token as Token;
1313
use Magento\Integration\Model\Oauth\TokenFactory as TokenModelFactory;
1414
use Magento\Integration\Model\Resource\Oauth\Token\CollectionFactory as TokenCollectionFactory;
@@ -30,7 +30,7 @@ class CustomerTokenService implements CustomerTokenServiceInterface
3030
private $accountManagement;
3131

3232
/**
33-
* @var \Magento\Integration\Helper\Validator
33+
* @var \Magento\Integration\Model\CredentialsValidator
3434
*/
3535
private $validatorHelper;
3636

@@ -47,13 +47,13 @@ class CustomerTokenService implements CustomerTokenServiceInterface
4747
* @param TokenModelFactory $tokenModelFactory
4848
* @param AccountManagementInterface $accountManagement
4949
* @param TokenCollectionFactory $tokenModelCollectionFactory
50-
* @param \Magento\Integration\Helper\Validator $validatorHelper
50+
* @param \Magento\Integration\Model\CredentialsValidator $validatorHelper
5151
*/
5252
public function __construct(
5353
TokenModelFactory $tokenModelFactory,
5454
AccountManagementInterface $accountManagement,
5555
TokenCollectionFactory $tokenModelCollectionFactory,
56-
Validator $validatorHelper
56+
CredentialsValidator $validatorHelper
5757
) {
5858
$this->tokenModelFactory = $tokenModelFactory;
5959
$this->accountManagement = $accountManagement;
@@ -66,7 +66,7 @@ public function __construct(
6666
*/
6767
public function createCustomerAccessToken($username, $password)
6868
{
69-
$this->validatorHelper->validateCredentials($username, $password);
69+
$this->validatorHelper->validate($username, $password);
7070
$customerDataObject = $this->accountManagement->authenticate($username, $password);
7171
return $this->tokenModelFactory->create()->createCustomerToken($customerDataObject->getId())->getToken();
7272
}

Diff for: app/code/Magento/Integration/Service/V1/Integration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Integration\Service\V1;
77

88
use Magento\Integration\Model\Integration as IntegrationModel;
9-
use Magento\Integration\Model\Integration\Factory as IntegrationFactory;
9+
use Magento\Integration\Model\IntegrationFactory;
1010
use Magento\Integration\Service\V1\OauthInterface as IntegrationOauthService;
1111

1212
/**

Diff for: app/code/Magento/Integration/Service/V1/Oauth.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Magento\Framework\Oauth\Helper\Oauth as OauthHelper;
99
use Magento\Integration\Helper\Oauth\Data as IntegrationOauthHelper;
1010
use Magento\Integration\Model\Oauth\Consumer as ConsumerModel;
11-
use Magento\Integration\Model\Oauth\Consumer\Factory as ConsumerFactory;
11+
use Magento\Integration\Model\Oauth\ConsumerFactory;
1212
use Magento\Integration\Model\Oauth\Token as OauthTokenModel;
1313
use Magento\Integration\Model\Oauth\TokenFactory as TokenFactory;
1414
use Magento\Integration\Model\Oauth\Token\Provider as TokenProvider;

Diff for: app/code/Magento/Webapi/Block/Adminhtml/Integration/Activate/Permissions/Tab/Webapi.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements
2828
/** @var \Magento\Integration\Helper\Data */
2929
protected $_integrationData;
3030

31-
/** @var WebapiHelper */
32-
protected $_webapiHelper;
31+
/** @var \Magento\Webapi\Model\Soap\Config */
32+
protected $_config;
3333

3434
/** @var \Magento\Core\Helper\Data */
3535
protected $_coreHelper;
@@ -44,7 +44,7 @@ class Webapi extends \Magento\Backend\Block\Widget\Form\Generic implements
4444
* @param \Magento\Framework\Acl\RootResource $rootResource
4545
* @param \Magento\Framework\Acl\Resource\ProviderInterface $resourceProvider
4646
* @param \Magento\Integration\Helper\Data $integrationData
47-
* @param \Magento\Webapi\Helper\Data $webapiData
47+
* @param \Magento\Webapi\Model\Soap\Config $config
4848
* @param array $data
4949
*/
5050
public function __construct(
@@ -55,13 +55,13 @@ public function __construct(
5555
\Magento\Framework\Acl\RootResource $rootResource,
5656
\Magento\Framework\Acl\Resource\ProviderInterface $resourceProvider,
5757
\Magento\Integration\Helper\Data $integrationData,
58-
\Magento\Webapi\Helper\Data $webapiData,
58+
\Magento\Webapi\Model\Soap\Config $config,
5959
array $data = []
6060
) {
6161
$this->_rootResource = $rootResource;
6262
$this->_resourceProvider = $resourceProvider;
6363
$this->_integrationData = $integrationData;
64-
$this->_webapiHelper = $webapiData;
64+
$this->_config = $config;
6565
$this->_coreHelper = $coreHelper;
6666
parent::__construct($context, $registry, $formFactory, $data);
6767
}
@@ -75,7 +75,7 @@ public function __construct(
7575
protected function _construct()
7676
{
7777
parent::_construct();
78-
$this->_selectedResources = $this->_webapiHelper->getSelectedResources();
78+
$this->_selectedResources = $this->_config->getSelectedResources();
7979
}
8080

8181
/**

Diff for: app/code/Magento/Webapi/Model/PathProcessor.php renamed to app/code/Magento/Webapi/Controller/PathProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright © 2015 Magento. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7-
namespace Magento\Webapi\Model;
7+
namespace Magento\Webapi\Controller;
88

99
use Magento\Framework\Exception\NoSuchEntityException;
1010

0 commit comments

Comments
 (0)