Skip to content

Commit

Permalink
Merge pull request #255 from BitBagCommerce/feature/op-291-code-style
Browse files Browse the repository at this point in the history
OP-291/Code style
  • Loading branch information
senghe authored Jun 19, 2024
2 parents ec5ddcd + 76e9b83 commit eebee9c
Show file tree
Hide file tree
Showing 49 changed files with 775 additions and 663 deletions.
6 changes: 3 additions & 3 deletions features/creating_new_wishlist.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Feature: Creating a new wishlist
@ui @javascript
Scenario: Creating a new wishlist
When I go to "/wishlists"
When I press "create_new_wishlist_button"
And I fill in "create_new_wishlist_name" with "WishlistName"
Then I press "create_new_wishlist_save"
When I open modal to create new wishlist
And I set new wishlist name "WishlistName"
Then I save new wishlist modal
Then I should wait for one second
Then I should be on "/wishlists"
And I should have 1 wishlists
6 changes: 3 additions & 3 deletions features/editing_name_of_wishlist.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Feature: Editing wishlists name
And the store has a wishlist named "Wishlist1"
When I go to "/wishlists"
Then I should see "Wishlist1"
When I press "wishlist-edit-button-Wishlist1"
And I fill in "edit_wishlist_name" with "Wishlist2"
When I press "edit_wishlist_save"
When I edit "Wishlist1"
And I edit wishlist name "Wishlist2"
When I save edit wishlist modal
Then I go to "/wishlists"
And I should see "Wishlist2"
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public function it_creates_new_wishlist_for_guest(
$wishlistRepository->findAllByAnonymous('token')->willReturn([]);

$newWishlist->setToken('token')->shouldBeCalled();
$newWishlist->setName('New wishlist')->shouldBeCalled();
$channelRepository->findOneByCode('test_channel_code')->willReturn($channel);
$newWishlist->setChannel($channel)->shouldBeCalled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use BitBag\SyliusWishlistPlugin\Command\Wishlist\ExportSelectedProductsFromWishlistToPdfInterface;
use BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist\ExportSelectedProductsFromWishlistToPdfHandler;
use BitBag\SyliusWishlistPlugin\Services\Exporter\WishlistToPdfExporterInterface;
use BitBag\SyliusWishlistPlugin\Exporter\WishlistToPdfExporterInterface;
use Doctrine\Common\Collections\Collection;
use PhpSpec\ObjectBehavior;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

declare(strict_types=1);

namespace spec\BitBag\SyliusWishlistPlugin\Services\Exporter;
namespace spec\BitBag\SyliusWishlistPlugin\Exporter;

use BitBag\SyliusWishlistPlugin\Exporter\DomPdfWishlistExporter;
use BitBag\SyliusWishlistPlugin\Exporter\DomPdfWishlistExporterInterface;
use BitBag\SyliusWishlistPlugin\Factory\DomPdfFactoryInterface;
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModelInterface;
use BitBag\SyliusWishlistPlugin\Services\Exporter\DomPdfWishlistExporter;
use BitBag\SyliusWishlistPlugin\Services\Exporter\DomPdfWishlistExporterInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Dompdf\Dompdf;
use PhpSpec\ObjectBehavior;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

declare(strict_types=1);

namespace spec\BitBag\SyliusWishlistPlugin\Services\Generator;
namespace spec\BitBag\SyliusWishlistPlugin\Generator;

use BitBag\SyliusWishlistPlugin\Command\Wishlist\WishlistItemInterface;
use BitBag\SyliusWishlistPlugin\Generator\ModelCreator;
use BitBag\SyliusWishlistPlugin\Generator\ModelCreatorInterface;
use BitBag\SyliusWishlistPlugin\Model\Factory\VariantPdfModelFactoryInterface;
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModelInterface;
use BitBag\SyliusWishlistPlugin\Resolver\VariantImageToDataUriResolverInterface;
use BitBag\SyliusWishlistPlugin\Services\Generator\ModelCreator;
use BitBag\SyliusWishlistPlugin\Services\Generator\ModelCreatorInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\OrderBundle\Controller\AddToCartCommandInterface;
use Sylius\Component\Core\Model\OrderItemInterface;
Expand Down
2 changes: 1 addition & 1 deletion spec/Processor/VariantPdfModelProcessorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
namespace spec\BitBag\SyliusWishlistPlugin\Processor;

use BitBag\SyliusWishlistPlugin\Command\Wishlist\WishlistItem;
use BitBag\SyliusWishlistPlugin\Generator\ModelCreatorInterface;
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModelInterface;
use BitBag\SyliusWishlistPlugin\Processor\VariantPdfModelProcessor;
use BitBag\SyliusWishlistPlugin\Processor\VariantPdfModelProcessorInterface;
use BitBag\SyliusWishlistPlugin\Services\Generator\ModelCreatorInterface;
use Doctrine\Common\Collections\ArrayCollection;
use PhpSpec\ObjectBehavior;

Expand Down
16 changes: 10 additions & 6 deletions src/CommandHandler/Wishlist/CreateNewWishlistHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ public function __invoke(CreateNewWishlist $createNewWishlist): void
$wishlist->setChannel($channel);
}

/** @var WishlistInterface $newWishlist */
foreach ($wishlists as $newWishlist) {
if (!$this->wishlistNameChecker->check((string) $newWishlist->getName(), $createNewWishlist->getName())) {
$wishlist->setName($createNewWishlist->getName());
} else {
throw new WishlistNameIsTakenException();
if (0 === count($wishlists)) {
$wishlist->setName($createNewWishlist->getName());
} else {
/** @var WishlistInterface $newWishlist */
foreach ($wishlists as $newWishlist) {
if (!$this->wishlistNameChecker->check((string) $newWishlist->getName(), $createNewWishlist->getName())) {
$wishlist->setName($createNewWishlist->getName());
} else {
throw new WishlistNameIsTakenException();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace BitBag\SyliusWishlistPlugin\CommandHandler\Wishlist;

use BitBag\SyliusWishlistPlugin\Command\Wishlist\ExportSelectedProductsFromWishlistToPdfInterface;
use BitBag\SyliusWishlistPlugin\Services\Exporter\WishlistToPdfExporterInterface;
use BitBag\SyliusWishlistPlugin\Exporter\WishlistToPdfExporterInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler]
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Action/CreateNewWishlistAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ public function __invoke(Request $request): Response
try {
if (null !== $channel) {
$createNewWishlist = new CreateNewWishlist($wishlistName, $channel->getCode());
$this->commandBus->dispatch($createNewWishlist);
} else {
$createNewWishlist = new CreateNewWishlist($wishlistName, null);
$this->commandBus->dispatch($createNewWishlist);
}
$this->commandBus->dispatch($createNewWishlist);

/** @var Session $session */
$session = $this->requestStack->getSession();
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/BitBagSyliusWishlistExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

final class BitBagSyliusWishlistExtension extends AbstractResourceExtension implements PrependExtensionInterface
{
Expand All @@ -25,9 +25,9 @@ final class BitBagSyliusWishlistExtension extends AbstractResourceExtension impl
public function load(array $config, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $config);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$this->registerResources('bitbag_sylius_wishlist_plugin', 'doctrine/orm', $config['resources'], $container);
$loader->load('services.yml');
$loader->load('services.xml');
$container->setParameter('bitbag_sylius_wishlist_plugin.parameters.wishlist_cookie_token', $config['wishlist_cookie_token']);
$container->setParameter('bitbag_sylius_wishlist_plugin.parameters.allowed_mime_types', $config['allowed_mime_types']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

declare(strict_types=1);

namespace BitBag\SyliusWishlistPlugin\Services\Exporter;
namespace BitBag\SyliusWishlistPlugin\Exporter;

use BitBag\SyliusWishlistPlugin\Factory\DomPdfFactoryInterface;
use Doctrine\Common\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

declare(strict_types=1);

namespace BitBag\SyliusWishlistPlugin\Services\Exporter;
namespace BitBag\SyliusWishlistPlugin\Exporter;

use Doctrine\Common\Collections\Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

declare(strict_types=1);

namespace BitBag\SyliusWishlistPlugin\Services\Exporter;
namespace BitBag\SyliusWishlistPlugin\Exporter;

use BitBag\SyliusWishlistPlugin\Processor\VariantPdfModelProcessorInterface;
use Doctrine\Common\Collections\Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

declare(strict_types=1);

namespace BitBag\SyliusWishlistPlugin\Services\Exporter;
namespace BitBag\SyliusWishlistPlugin\Exporter;

use Doctrine\Common\Collections\Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

declare(strict_types=1);

namespace BitBag\SyliusWishlistPlugin\Services\Generator;
namespace BitBag\SyliusWishlistPlugin\Generator;

use BitBag\SyliusWishlistPlugin\Command\Wishlist\WishlistItemInterface;
use BitBag\SyliusWishlistPlugin\Model\Factory\VariantPdfModelFactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

declare(strict_types=1);

namespace BitBag\SyliusWishlistPlugin\Services\Generator;
namespace BitBag\SyliusWishlistPlugin\Generator;

use BitBag\SyliusWishlistPlugin\Command\Wishlist\WishlistItemInterface;
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModelInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Processor/VariantPdfModelProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace BitBag\SyliusWishlistPlugin\Processor;

use BitBag\SyliusWishlistPlugin\Command\Wishlist\WishlistItem;
use BitBag\SyliusWishlistPlugin\Generator\ModelCreatorInterface;
use BitBag\SyliusWishlistPlugin\Model\VariantPdfModel;
use BitBag\SyliusWishlistPlugin\Services\Generator\ModelCreatorInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
grid-area: image;
width: 75%;
height: 75%;

img {
margin-bottom: 24px;
}
}

&-name {
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
imports:
- { resource: "@BitBagSyliusWishlistPlugin/Resources/config/services.yml" }
- { resource: "@BitBagSyliusWishlistPlugin/Resources/config/services.xml" }
- { resource: "@BitBagSyliusWishlistPlugin/Resources/config/resources.yml" }
10 changes: 10 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">

<imports>
<import resource="services/**/*.xml"/>
</imports>
</container>
Loading

0 comments on commit eebee9c

Please sign in to comment.