Skip to content

Commit

Permalink
chore: Update code style fixer tools
Browse files Browse the repository at this point in the history
  • Loading branch information
mitelg committed Jan 17, 2024
1 parent 72cf628 commit 6682c07
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
use Shopware\Bundle\SearchBundleDBAL\PartialFacetHandlerInterface;
use Shopware\Bundle\SearchBundleDBAL\QueryBuilder;
use Shopware\Bundle\SearchBundleDBAL\QueryBuilderFactoryInterface;
use Shopware\Bundle\StoreFrontBundle\Struct;
use Shopware\Bundle\StoreFrontBundle\Struct\ShopContextInterface;

class ProductAttributeFacetHandler implements PartialFacetHandlerInterface
Expand Down Expand Up @@ -136,7 +135,7 @@ private function createValueListFacetResult(
QueryBuilder $query,
ProductAttributeFacet $facet,
Criteria $criteria,
Struct\ShopContextInterface $context
ShopContextInterface $context
): ?FacetResultInterface {
$sqlField = 'productAttribute.' . $facet->getField();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ManufacturerGateway implements ManufacturerGatewayInterface
public function __construct(
Connection $connection,
FieldHelper $fieldHelper,
Hydrator\ManufacturerHydrator $manufacturerHydrator,
ManufacturerHydrator $manufacturerHydrator,
MediaServiceInterface $mediaService
) {
$this->connection = $connection;
Expand Down
55 changes: 30 additions & 25 deletions engine/Shopware/Components/Api/Resource/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,23 @@
namespace Shopware\Components\Api\Resource;

use Exception;
use Shopware\Components\Api\Exception as ApiException;
use Shopware\Components\Api\Exception\NotFoundException;
use Shopware\Components\Api\Exception\ParameterMissingException;
use Shopware\Components\Api\Exception\ValidationException;
use Shopware\Components\Model\ModelManager;
use Shopware\Models\Country\Country as CountryModel;
use Shopware\Models\Payment\Payment as PaymentModel;
use Shopware\Models\Payment\Repository;
use Shopware\Models\Plugin\Plugin;
use Shopware\Models\Shop\Shop as ShopModel;

/**
* Payment API Resource
*/
class PaymentMethods extends Resource
{
/**
* @return \Shopware\Models\Payment\Repository
* @return Repository
*/
public function getRepository()
{
Expand All @@ -45,8 +50,8 @@ public function getRepository()
/**
* @param int $id
*
* @throws \Shopware\Components\Api\Exception\ParameterMissingException
* @throws \Shopware\Components\Api\Exception\NotFoundException
* @throws ParameterMissingException
* @throws NotFoundException
*
* @return array|PaymentModel
*/
Expand All @@ -55,7 +60,7 @@ public function getOne($id)
$this->checkPrivilege('read');

if (empty($id)) {
throw new ApiException\ParameterMissingException('id');
throw new ParameterMissingException('id');
}

$filters = [['property' => 'payment.id', 'expression' => '=', 'value' => $id]];
Expand All @@ -65,7 +70,7 @@ public function getOne($id)
$payment = $query->getOneOrNullResult($this->getResultMode());

if (!$payment) {
throw new ApiException\NotFoundException(sprintf('Payment by id %d not found', $id));
throw new NotFoundException(sprintf('Payment by id %d not found', $id));
}

return $payment;
Expand Down Expand Up @@ -96,7 +101,7 @@ public function getList($offset = 0, $limit = 25, array $filter = [], array $ord
}

/**
* @throws \Shopware\Components\Api\Exception\ValidationException
* @throws ValidationException
* @throws Exception
*
* @return PaymentModel
Expand All @@ -116,7 +121,7 @@ public function create(array $params)
$violations = $this->getManager()->validate($payment);

if ($violations->count() > 0) {
throw new ApiException\ValidationException($violations);
throw new ValidationException($violations);
}

$this->getManager()->persist($payment);
Expand All @@ -128,9 +133,9 @@ public function create(array $params)
/**
* @param int $id
*
* @throws \Shopware\Components\Api\Exception\ValidationException
* @throws \Shopware\Components\Api\Exception\NotFoundException
* @throws \Shopware\Components\Api\Exception\ParameterMissingException
* @throws ValidationException
* @throws NotFoundException
* @throws ParameterMissingException
*
* @return PaymentModel
*/
Expand All @@ -139,14 +144,14 @@ public function update($id, array $params)
$this->checkPrivilege('update');

if (empty($id)) {
throw new ApiException\ParameterMissingException('id');
throw new ParameterMissingException('id');
}

/** @var PaymentModel|null $payment */
$payment = $this->getRepository()->find($id);

if (!$payment) {
throw new ApiException\NotFoundException(sprintf('Payment by id "%d" not found', $id));
throw new NotFoundException(sprintf('Payment by id "%d" not found', $id));
}

$params = $this->preparePaymentData($params);
Expand All @@ -155,7 +160,7 @@ public function update($id, array $params)

$violations = $this->getManager()->validate($payment);
if ($violations->count() > 0) {
throw new ApiException\ValidationException($violations);
throw new ValidationException($violations);
}

$this->flush();
Expand All @@ -166,8 +171,8 @@ public function update($id, array $params)
/**
* @param int $id
*
* @throws \Shopware\Components\Api\Exception\ParameterMissingException
* @throws \Shopware\Components\Api\Exception\NotFoundException
* @throws ParameterMissingException
* @throws NotFoundException
*
* @return PaymentModel
*/
Expand All @@ -176,14 +181,14 @@ public function delete($id)
$this->checkPrivilege('delete');

if (empty($id)) {
throw new ApiException\ParameterMissingException('id');
throw new ParameterMissingException('id');
}

/** @var PaymentModel|null $payment */
$payment = $this->getRepository()->find($id);

if (!$payment) {
throw new ApiException\NotFoundException("Payment by id $id not found");
throw new NotFoundException("Payment by id $id not found");
}

$this->getManager()->remove($payment);
Expand All @@ -195,7 +200,7 @@ public function delete($id)
/**
* @param array $params
*
* @throws ApiException\NotFoundException
* @throws NotFoundException
*
* @return array
*/
Expand Down Expand Up @@ -226,9 +231,9 @@ protected function preparePaymentData($params)

if (isset($params['countries'])) {
foreach ($params['countries'] as &$country) {
$countryModel = $this->getContainer()->get(\Shopware\Components\Model\ModelManager::class)->find(CountryModel::class, $country['countryId']);
$countryModel = $this->getContainer()->get(ModelManager::class)->find(CountryModel::class, $country['countryId']);
if (!$countryModel) {
throw new ApiException\NotFoundException(sprintf('Country by id %d not found', $country['countryId']));
throw new NotFoundException(sprintf('Country by id %d not found', $country['countryId']));
}

$country = $countryModel;
Expand All @@ -239,9 +244,9 @@ protected function preparePaymentData($params)

if (isset($params['shops'])) {
foreach ($params['shops'] as &$shop) {
$shopModel = $this->getContainer()->get(\Shopware\Components\Model\ModelManager::class)->find(\Shopware\Models\Shop\Shop::class, $shop['shopId']);
$shopModel = $this->getContainer()->get(ModelManager::class)->find(ShopModel::class, $shop['shopId']);
if (!$shopModel) {
throw new ApiException\NotFoundException(sprintf('Shop by id %d not found', $shop['shopId']));
throw new NotFoundException(sprintf('Shop by id %d not found', $shop['shopId']));
}

$shop = $shopModel;
Expand All @@ -251,9 +256,9 @@ protected function preparePaymentData($params)
}

if (isset($params['pluginId'])) {
$params['plugin'] = $this->getContainer()->get(\Shopware\Components\Model\ModelManager::class)->find(Plugin::class, $params['pluginId']);
$params['plugin'] = $this->getContainer()->get(ModelManager::class)->find(Plugin::class, $params['pluginId']);
if (empty($params['plugin'])) {
throw new ApiException\NotFoundException(sprintf('plugin by id %s not found', $params['pluginId']));
throw new NotFoundException(sprintf('plugin by id %s not found', $params['pluginId']));
}
}

Expand Down
Loading

0 comments on commit 6682c07

Please sign in to comment.