Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
/public/sitemap*.xml

# PHP-CS-Fixer
/.php_cs
/.php_cs.cache
/.php-cs-fixer.php
/.php-cs-fixer.cache

# composer
/vendor/
Expand Down
24 changes: 8 additions & 16 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,40 @@
<?php

$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder)
->in([
__DIR__ . '/app',
__DIR__ . '/src',
])

->exclude([

])

// do not fix views
->notName('*.html.php')

// using notPath instead of exclude here as they can be nested (install-profiles)
->notPath('/var\/config/')
->notPath('/var\/classes/')
;

// do not enable self_accessor as it breaks pimcore models relying on get_called_class()
return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config)
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],

// keep aligned = and => operators as they are: do not force aligning, but do not remove it
'binary_operator_spaces' => ['align_double_arrow' => null, 'align_equals' => null],
'binary_operator_spaces' => ['operators' => ['=' => null, '=>' => null]],

'blank_line_before_return' => true,
'blank_line_before_statement' => ['statements' => ['return']],
'encoding' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'lowercase_cast' => true,
'magic_constant_casing' => true,
'method_argument_space' => ['ensure_fully_multiline' => false],
'method_separation' => true,
'method_argument_space' => ['on_multiline' => 'ignore'],
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'native_function_casing' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_short_bool_cast' => true,
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DefaultController extends BaseController
* @Route("/examples", name="examples")
*
* @param Request $request
*
* @return Response
*/
public function examplesAction(Request $request)
Expand All @@ -38,6 +39,7 @@ public function examplesAction(Request $request)
* @Template
*
* @param Request $request
*
* @return array
*/
public function defaultAction(Request $request)
Expand Down
21 changes: 11 additions & 10 deletions src/Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function checkoutPaymentAction(Factory $factory, BreadcrumbHelperService
$paymentProvider = $checkoutManager->getPayment();

$SDKUrl = '';
if($paymentProvider instanceof PayPalSmartPaymentButton) {
if ($paymentProvider instanceof PayPalSmartPaymentButton) {
$SDKUrl = $paymentProvider->buildPaymentSDKLink();
}

Expand All @@ -77,24 +77,25 @@ public function checkoutPaymentAction(Factory $factory, BreadcrumbHelperService
*/
public function startPaymentAction(Request $request, Factory $factory, LoggerInterface $logger)
{
$cartManager = $factory->getCartManager();
$cart = $cartManager->getOrCreateCartByName('cart');
$cartManager = $factory->getCartManager();
$cart = $cartManager->getOrCreateCartByName('cart');

$checkoutManager = Factory::getInstance()->getCheckoutManager($cart);
$paymentInformation = $checkoutManager->initOrderPayment();
$order = $paymentInformation->getObject();
$checkoutManager = Factory::getInstance()->getCheckoutManager($cart);
$paymentInformation = $checkoutManager->initOrderPayment();
$order = $paymentInformation->getObject();

$config = [
$config = [
'return_url' => '',
'cancel_url' => 'https://demo.pimcore.fun/payment-error',
'OrderDescription' => 'My Order ' . $order->getOrdernumber() . ' at pimcore.org',
'InternalPaymentId' => $paymentInformation->getInternalPaymentId()
];

$paymentConfig = new AbstractRequest($config);
$paymentConfig = new AbstractRequest($config);

$response = $checkoutManager->startOrderPaymentWithPaymentProvider($paymentConfig);

$response = $checkoutManager->startOrderPaymentWithPaymentProvider($paymentConfig);
return new \Symfony\Component\HttpFoundation\JsonResponse($response->getJsonString(), 200, [], true);
return new \Symfony\Component\HttpFoundation\JsonResponse($response->getJsonString(), 200, [], true);
}

/**
Expand Down
56 changes: 26 additions & 30 deletions src/Controller/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ class ProductController extends BaseController
* @param Request $request
* @param AbstractObject $object
* @param UrlSlug $urlSlug
*
* @return Response
*/
public function productDetailSlugAction(Request $request, AbstractObject $object, UrlSlug $urlSlug) {
public function productDetailSlugAction(Request $request, AbstractObject $object, UrlSlug $urlSlug)
{
return $this->forward('App\Controller\ProductController::detailAction', ['product' => $object]);
}

Expand All @@ -78,8 +80,7 @@ public function detailAction(
SegmentTrackingHelperService $segmentTrackingHelperService,
Concrete $product,
ProductLinkGenerator $productLinkGenerator
)
{
) {
if (!(
$product && ($product->isPublished() && (($product instanceof Car && $product->getObjectType() == Car::OBJECT_TYPE_ACTUAL_CAR) || $product instanceof AccessoryPart) || $this->verifyPreviewRequest($request, $product))
)
Expand All @@ -89,8 +90,9 @@ public function detailAction(

//redirect to main url
$generatorUrl = $productLinkGenerator->generate($product);
if($generatorUrl != $request->getPathInfo()) {
if ($generatorUrl != $request->getPathInfo()) {
$queryString = $request->getQueryString();

return $this->redirect($generatorUrl . ($queryString ? '?' . $queryString : ''));
}

Expand All @@ -107,7 +109,6 @@ public function detailAction(
$trackingManager->trackProductView($product);

if ($product instanceof Car) {

foreach ($product->getAccessories() as $accessory) {
$trackingManager->trackProductImpression($accessory, 'crosssells');
}
Expand All @@ -118,13 +119,13 @@ public function detailAction(
// get all compatible products
$productList = $ecommerceFactory->getIndexService()->getProductListForCurrentTenant();
$productList->setVariantMode(ProductListInterface::VARIANT_MODE_VARIANTS_ONLY);
if($productList instanceof DefaultMysql) {
if ($productList instanceof DefaultMysql) {
$productList->addCondition('o_id IN (' . implode(',', $product->getCompatibleToProductIds()) . ')', 'o_id');
} else if($productList instanceof AbstractElasticSearch) {
} elseif ($productList instanceof AbstractElasticSearch) {
$productList->addCondition(['terms' => ['system.o_id' => $product->getCompatibleToProductIds()]], 'o_id');
}

foreach($productList as $compatibleProduct) {
foreach ($productList as $compatibleProduct) {
$trackingManager->trackProductImpression($compatibleProduct, 'crosssells');
}

Expand Down Expand Up @@ -264,7 +265,7 @@ public function searchAction(Request $request, ListHelper $listHelper, Factory $

$term = strip_tags($request->get('term'));

if($productListing instanceof AbstractElasticSearch) {
if ($productListing instanceof AbstractElasticSearch) {

// simple elastic search query - uses multi-match query on all defined search_attributes
// $productListing->addQueryCondition($term);
Expand All @@ -275,22 +276,22 @@ public function searchAction(Request $request, ListHelper $listHelper, Factory $
'function_score' => [
'query' => [
'multi_match' => [
"query" => $term,
"type" => "cross_fields",
"operator" => "and",
"fields" => [
"attributes.name^4",
"attributes.name.analyzed",
"attributes.name.analyzed_ngram",
"attributes.manufacturer_name^3",
"attributes.manufacturer_name.analyzed",
"attributes.manufacturer_name.analyzed_ngram",
"attributes.color",
"attributes.color.analyzed",
"attributes.color.analyzed_ngram",
"attributes.carClass",
"attributes.carClass.analyzed",
"attributes.carClass.analyzed_ngram"
'query' => $term,
'type' => 'cross_fields',
'operator' => 'and',
'fields' => [
'attributes.name^4',
'attributes.name.analyzed',
'attributes.name.analyzed_ngram',
'attributes.manufacturer_name^3',
'attributes.manufacturer_name.analyzed',
'attributes.manufacturer_name.analyzed_ngram',
'attributes.color',
'attributes.color.analyzed',
'attributes.color.analyzed_ngram',
'attributes.carClass',
'attributes.carClass.analyzed',
'attributes.carClass.analyzed_ngram'
]
]
],
Expand All @@ -310,8 +311,6 @@ public function searchAction(Request $request, ListHelper $listHelper, Factory $
];

$productListing->addQueryCondition($query, 'searchTerm');


} else {

//default mysql search query condition - would also work for elastic search in that way
Expand All @@ -322,10 +321,8 @@ public function searchAction(Request $request, ListHelper $listHelper, Factory $
$productListing->addQueryCondition($t);
}
}

}


if (isset($params['autocomplete'])) {
$resultset = [];
$productListing->setLimit(10);
Expand Down Expand Up @@ -360,7 +357,6 @@ public function searchAction(Request $request, ListHelper $listHelper, Factory $
$filterDefinition->getPageLimit()
);


$params['results'] = $paginator;
$params['paginationVariables'] = $paginator->getPaginationData();

Expand Down
2 changes: 2 additions & 0 deletions src/Controller/Web2printController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function defaultAction(Request $request)
/**
*
* @param Request $request
*
* @return Response
*
* @throws \Exception
Expand Down Expand Up @@ -87,6 +88,7 @@ public function containerAction(Request $request)

/**
* @param Request $request
*
* @return Response
*
* @throws \Exception
Expand Down
1 change: 0 additions & 1 deletion src/Document/Areabrick/Blockquote.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function getEditableDialogBoxConfiguration(Editable $area, ?Editable\Area
]
]);


return $config;
}

Expand Down
25 changes: 11 additions & 14 deletions src/Document/Areabrick/PersonalizedProductTeaser.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function action(Info $info)
$allowedSegmentGroups = [SegmentGetter::SEGMENT_GROUP_CAR_CLASS, SegmentGetter::SEGMENT_GROUP_MANUFACTURER];
$segmentCollection = $this->segmentTracker->getFilteredAssignments($this->visitorInfoStorage->getVisitorInfo(), $allowedSegmentGroups, 2);

if(empty($segmentCollection)) {
if (empty($segmentCollection)) {
return;
}

Expand All @@ -98,7 +98,6 @@ public function action(Info $info)
}

$this->addRelationCondition($productList, $values);

}
}

Expand All @@ -112,27 +111,25 @@ public function action(Info $info)
}
}

protected function addRelationCondition(ProductListInterface $productList, $values) {

if($productList instanceof DefaultMysql) {
protected function addRelationCondition(ProductListInterface $productList, $values)
{
if ($productList instanceof DefaultMysql) {
$productList->addRelationCondition('segments', 'dest IN (' . implode(',', $values) . ')');
} else if($productList instanceof AbstractElasticSearch) {
} elseif ($productList instanceof AbstractElasticSearch) {
$productList->addRelationCondition('segments', ['terms' => ['relations.' . 'segments' => $values]]);
} else {
throw new InvalidConfigException("Product List Type not supported");
throw new InvalidConfigException('Product List Type not supported');
}

}

protected function setRandOrderKey(ProductListInterface $productList) {

if($productList instanceof DefaultMysql) {
protected function setRandOrderKey(ProductListInterface $productList)
{
if ($productList instanceof DefaultMysql) {
$productList->setOrderKey('RAND()');
} else if($productList instanceof AbstractElasticSearch) {
} elseif ($productList instanceof AbstractElasticSearch) {
//not possible
} else {
throw new InvalidConfigException("Product List Type not supported");
throw new InvalidConfigException('Product List Type not supported');
}

}
}
3 changes: 1 addition & 2 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ public function registerBundlesToCollection(BundleCollection $collection)

// activate bundle for SSO oauth login/register functionality
if (class_exists('\Http\HttplugBundle\HttplugBundle')) {
$collection->addBundle( new \Http\HttplugBundle\HttplugBundle());
$collection->addBundle(new \Http\HttplugBundle\HttplugBundle());
}
$collection->addBundle(HWIOAuthBundle::class);

}
}
3 changes: 2 additions & 1 deletion src/Model/Product/AccessoryPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function getOSName(): ?string
return $this->getGeneratedName();
}

public function getProductName($language = null) {
public function getProductName($language = null)
{
return
($this->getSeries() ? ($this->getSeries()->getName() . ' ') : '') .
($this->getMainCategory() ? ($this->getMainCategory()->getName($language) . ' ') : '') .
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Product/Car.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public function getOSName(): ?string
return ($this->getManufacturer() ? $this->getManufacturer()->getName() . ' ' : '') . $this->getName();
}

public function getProductName($language = null) {
public function getProductName($language = null)
{
return $this->getName($language);
}

Expand Down Expand Up @@ -178,5 +179,4 @@ public function getColorVariants(): array

return [];
}

}
2 changes: 1 addition & 1 deletion src/Sitemaps/CategoryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class CategoryGenerator extends AbstractElementGenerator
{
function __construct(array $filters = [], array $processors = [])
public function __construct(array $filters = [], array $processors = [])
{
parent::__construct($filters, $processors);
}
Expand Down
Loading