diff --git a/.gitignore b/.gitignore
index f7f8ac3..7ea2c86 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,14 @@
-/.idea/
+/bin/*
+!/bin/.gitkeep
+
/vendor/
+/node_modules/
+/composer.lock
+
+/etc/build/*
+!/etc/build/.gitkeep
+
+/tests/Application/yarn.lock
+
+/.idea/
+/tests/Application/.web-server-pid
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
deleted file mode 100644
index 189333c..0000000
--- a/.gitlab-ci.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-before_script:
- - composer install --no-interaction --prefer-dist --no-scripts
-
-build:
- script:
- - composer validate
- - vendor/bin/phpunit
- cache:
- paths:
- - bin
- - vendor
diff --git a/.travis.yml b/.travis.yml
index dcd85a7..7576d82 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,24 +1,75 @@
language: php
+dist: trusty
+
+sudo: false
+
+php:
+ - 7.1
+ - 7.2
+
cache:
+ yarn: true
directories:
- - bin
- - vendor
+ - ~/.composer/cache/files
+ - $SYLIUS_CACHE_DIR
-php:
- - 7.0
- - 5.6
- - 5.5
+env:
+ global:
+ - SYLIUS_CACHE_DIR=$HOME/.sylius-cache
+ - SYLIUS_BUILD_DIR=etc/build
before_install:
- phpenv config-rm xdebug.ini
- - composer self-update
- - if [[ -z "$GITHUB_OAUTH_TOKEN" ]]; then export GITHUB_OAUTH_TOKEN="66736022ed66ebbb2be87027ed45a24554cc8344"; fi
- - composer config -g github-oauth.github.com "$GITHUB_OAUTH_TOKEN" >/dev/null 2>&1
+ - echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
+ - mkdir -p "${SYLIUS_CACHE_DIR}"
install:
- - composer install --no-interaction --prefer-dist --no-scripts
+ - composer install --no-interaction --prefer-dist
+ - (cd tests/Application && yarn install)
+
+before_script:
+ - (cd tests/Application && bin/console doctrine:database:create --env=test -vvv)
+ - (cd tests/Application && bin/console doctrine:schema:create --env=test -vvv)
+ - (cd tests/Application && bin/console assets:install web --env=test -vvv)
+ - (cd tests/Application && yarn run gulp)
+
+ # Configure display
+ - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1680x1050x16
+ - export DISPLAY=:99
+
+ # Download and configure ChromeDriver
+ - |
+ if [ ! -f $SYLIUS_CACHE_DIR/chromedriver ] || [ "$($SYLIUS_CACHE_DIR/chromedriver --version | grep -c 2.34)" = "0" ]; then
+ curl http://chromedriver.storage.googleapis.com/2.34/chromedriver_linux64.zip > chromedriver.zip
+ unzip chromedriver.zip
+ chmod +x chromedriver
+ mv chromedriver $SYLIUS_CACHE_DIR
+ fi
+
+ # Run ChromeDriver
+ - $SYLIUS_CACHE_DIR/chromedriver > /dev/null 2>&1 &
+
+ # Download and configure Selenium
+ - |
+ if [ ! -f $SYLIUS_CACHE_DIR/selenium.jar ] || [ "$(java -jar $SYLIUS_CACHE_DIR/selenium.jar --version | grep -c 3.4.0)" = "0" ]; then
+ curl http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar > selenium.jar
+ mv selenium.jar $SYLIUS_CACHE_DIR
+ fi
+
+ # Run Selenium
+ - java -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver -jar $SYLIUS_CACHE_DIR/selenium.jar > /dev/null 2>&1 &
+
+ # Run webserver
+ - (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web --env=test --quiet > /dev/null 2>&1 &)
script:
- - composer validate
- - vendor/bin/phpunit
+ - composer validate --strict
+ - bin/phpstan.phar analyse -c phpstan.neon -l max src/
+
+ - bin/phpunit
+ - bin/phpspec run
+ - bin/behat --strict -vvv --no-interaction || bin/behat --strict -vvv --no-interaction --rerun
+
+after_failure:
+ - vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"
diff --git a/Command/CreateInitialCommand.php b/Command/CreateInitialCommand.php
deleted file mode 100644
index 5e159d0..0000000
--- a/Command/CreateInitialCommand.php
+++ /dev/null
@@ -1,58 +0,0 @@
-setName('webburza:sylius-wishlist-bundle:create-initial')
- ->setDescription("Create initial wishlists for existing users.")
- ;
- }
-
- /**
- * @param InputInterface $input
- * @param OutputInterface $output
- *
- * @return void
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $output->writeln('Creating wishlists for existing users...');
-
- /** @var UserRepositoryInterface $userRepository */
- $userRepository = $this->getContainer()->get('sylius.repository.shop_user');
-
- /** @var WishlistRepositoryInterface $wishlistRepository */
- $wishlistRepository = $this->getContainer()->get('webburza_wishlist.repository.wishlist');
-
- /** @var WishlistFactoryInterface $wishlistFactory */
- $wishlistFactory = $this->getContainer()->get('webburza_wishlist.factory.wishlist');
-
- // Get all users
- $users = $userRepository->findAll();
-
- // Keep track of created wishlists
- $createdCount = 0;
-
- // For each user, check if a wishlist exists and create it if not
- foreach ($users as $user) {
- if ($wishlistRepository->getCountForUser($user) == 0) {
- $wishlist = $wishlistFactory->createDefault($user);
- $wishlistRepository->add($wishlist);
- $createdCount++;
- }
- }
-
- $output->writeln('Created '. $createdCount .' wishlists.');
- }
-}
diff --git a/Controller/Account/WishlistController.php b/Controller/Account/WishlistController.php
deleted file mode 100644
index c4a089e..0000000
--- a/Controller/Account/WishlistController.php
+++ /dev/null
@@ -1,190 +0,0 @@
-setContainer($container);
- }
-
- /**
- * @param Request $request
- *
- * @return Response
- */
- public function indexAction(Request $request)
- {
- // Throw 404 if not in multiple wishlist mode
- if (!$this->getParameter('webburza_sylius_wishlist.multiple')) {
- return $this->redirectToRoute('sylius_shop_account_dashboard');
- }
-
- // Get all wishlists for the current user
- $wishlists = $this->get('webburza_wishlist.repository.wishlist')->findBy([
- 'user' => $this->getUser()
- ], [
- 'createdAt' => 'asc'
- ]);
-
- $view = View::create([
- 'wishlists' => $wishlists
- ]);
-
- $view->setTemplate('WebburzaSyliusWishlistBundle:Frontend/Account/Wishlist:index.html.twig');
-
- return $this->handleView($view);
- }
-
- /**
- * @param Request $request
- *
- * @return Response
- */
- public function createAction(Request $request)
- {
- // Throw 404 if not in multiple wishlist mode
- if (!$this->getParameter('webburza_sylius_wishlist.multiple')) {
- throw new NotFoundHttpException();
- }
-
- // Get wishlist form and handle request
- $form = $this->get('form.factory')->create(WishlistType::class);
- $form->handleRequest($request);
-
- if ($form->isSubmitted() && $form->isValid()) {
- /** @var WishlistInterface $wishlist */
- $wishlist = $form->getData();
-
- // Set wishlist user
- $wishlist->setUser($this->getUser());
-
- // Persist changes
- $this->get('webburza_wishlist.repository.wishlist')->add($wishlist);
-
- // If this was an AJAX request, return appropriate response
- if ($request->getRequestFormat() != 'html') {
- return new JsonResponse(null, Response::HTTP_CREATED);
- }
-
- // Set success message
- $this->addFlash(
- 'success',
- $this->get('translator')->trans('webburza_wishlist.flash.updated')
- );
-
- return $this->redirectToRoute('webburza_account_wishlist_edit', [
- 'id' => $wishlist->getId()
- ]);
- }
-
- $view = View::create([
- 'form' => $form->createView()
- ]);
-
- $view->setTemplate('WebburzaSyliusWishlistBundle:Frontend/Account/Wishlist:create.html.twig');
-
- return $this->handleView($view);
- }
-
- /**
- * @param Request $request
- *
- * @return Response
- */
- public function updateAction(Request $request)
- {
- // Get the wishlist
- $wishlist = $this->get('webburza_wishlist.repository.wishlist')->findOneBy([
- 'id' => $request->get('id'),
- 'user' => $this->getUser()
- ]);
-
- if (!$wishlist) {
- throw new NotFoundHttpException();
- }
-
- // Get wishlist form
- $form = $this->get('form.factory')->create(WishlistType::class, $wishlist);
-
- if (in_array($request->getMethod(), ['PUT', 'POST'])) {
- if ($form->handleRequest($request)->isValid()) {
-
- // Persist changes
- $this->get('webburza_wishlist.repository.wishlist')->add($form->getData());
-
- // If this was an AJAX request, return appropriate response
- if ($request->getRequestFormat() != 'html') {
- return new JsonResponse(null, Response::HTTP_OK);
- }
-
- // Set success message
- $this->addFlash(
- 'success',
- $this->get('translator')->trans('webburza_wishlist.flash.updated')
- );
-
- return $this->redirectToRoute('webburza_account_wishlist_edit', [
- 'id' => $wishlist->getId()
- ]);
- }
- }
-
- $view = View::create([
- 'form' => $form->createView(),
- 'wishlist' => $wishlist
- ]);
-
- $view->setTemplate('WebburzaSyliusWishlistBundle:Frontend/Account/Wishlist:update.html.twig');
-
- return $this->handleView($view);
- }
-
- /**
- * @param Request $request
- *
- * @return Response
- */
- public function deleteAction(Request $request)
- {
- $wishlist = $this->get('webburza_wishlist.repository.wishlist')->findOneBy([
- 'id' => $request->get('id'),
- 'user' => $this->getUser()
- ]);
-
- // Throw exception if not found
- if (!$wishlist) {
- throw new NotFoundHttpException();
- }
-
- // Remove the wishlist
- $this->get('webburza_wishlist.repository.wishlist')->remove($wishlist);
-
- // If this was an AJAX request, return appropriate response
- if ($request->getRequestFormat() != 'html') {
- return new JsonResponse(null, Response::HTTP_NO_CONTENT);
- }
-
- // Set success message
- $this->addFlash(
- 'success',
- $this->get('translator')->trans('webburza_wishlist.ui.deleted')
- );
-
- return $this->redirectToRoute('webburza_account_wishlist_index');
- }
-}
diff --git a/Controller/Frontend/WishlistController.php b/Controller/Frontend/WishlistController.php
deleted file mode 100644
index 5103180..0000000
--- a/Controller/Frontend/WishlistController.php
+++ /dev/null
@@ -1,179 +0,0 @@
-setContainer($container);
- }
-
- /**
- * Get a publicly visible wishlist by slug.
- *
- * @param Request $request
- *
- * @return Response
- */
- public function showAction(Request $request)
- {
- /** @var WishlistInterface $wishlist */
- $wishlist = $this->get('webburza_wishlist.repository.wishlist')->findOneBy([
- 'slug' => $request->get('slug')
- ]);
-
- // Check if wishlist exists, and it can be accessed
- if (!($wishlist && $this->userCanAccessWishlist($this->getUser(), $wishlist))) {
- throw new NotFoundHttpException();
- }
-
- $view = View::create($wishlist);
-
- if ($request->getRequestFormat() == 'html') {
- $view->setTemplate('WebburzaSyliusWishlistBundle:Frontend/Wishlist:show.html.twig');
-
- $view->setData([
- 'wishlist' => $wishlist
- ]);
- }
-
- return $this->handleView($view);
- }
-
- /**
- * Get the first publicly visible wishlist for the current user.
- *
- * @param Request $request
- *
- * @return Response
- */
- public function firstAction(Request $request)
- {
- if (!$this->getUser()) {
- throw new NotFoundHttpException();
- }
-
- // Get the first wishlist for the user
- $wishlist =
- $this->get('webburza_wishlist.repository.wishlist')->getFirstForUser($this->getUser());
-
- // Create a wishlist if none exist
- if (!$wishlist) {
- $wishlist = $this->get('webburza_wishlist.factory.wishlist')->createDefault($this->getUser());
- $this->get('webburza_wishlist.repository.wishlist')->add($wishlist);
- }
-
- // If the bundle is configured to work with multiple wishlists
- // Redirect to the current wishlist to update URI
- if ($this->getParameter('webburza_sylius_wishlist.multiple')) {
- return $this->redirectToRoute('webburza_frontend_wishlist_show', [
- 'slug' => $wishlist->getSlug()
- ]);
- }
-
- // If this was an AJAX request, return appropriate response
- if ($request->getRequestFormat() != 'html') {
- return new JsonResponse(['wishlist' => $wishlist], 200);
- }
-
- // Create the view for the wishlist
- $view = View::create([
- 'wishlist' => $wishlist
- ]);
-
- // Set view template
- $view->setTemplate('WebburzaSyliusWishlistBundle:Frontend/Wishlist:show.html.twig');
-
- // Handle the view
- return $this->handleView($view);
- }
-
- /**
- * @param Request $request
- *
- * @return Response
- */
- public function clearAction(Request $request)
- {
- /** @var WishlistInterface $wishlist */
- $wishlist = $this->get('webburza_wishlist.repository.wishlist')->findOneBy([
- 'id' => $request->get('id'),
- 'user' => $this->getUser()
- ]);
-
- // Check if wishlist found
- if (!$wishlist) {
- $this->createNotFoundException();
- }
-
- // Remove each wishlist item
- foreach ($wishlist->getItems() as $wishlistItem) {
- $this->get('webburza_wishlist.repository.wishlist_item')->remove($wishlistItem);
- }
-
- // If this was an AJAX request, return appropriate response
- if ($request->getRequestFormat() != 'html') {
- return new JsonResponse(null, 200);
- }
-
- // Set success message
- $this->addFlash(
- 'success',
- $this->get('translator')->trans('webburza_wishlist.flash.cleared')
- );
-
- return $this->redirectToWishlist($wishlist);
- }
-
- /**
- * Check if a wishlist is publicly available, or the
- * user has special privileges to access it.
- *
- * @param $user
- * @param $wishlist
- *
- * @return bool
- */
- protected function userCanAccessWishlist(
- UserInterface $user = null,
- WishlistInterface $wishlist
- ) {
- return $wishlist->isPublic() || ($user && $user->getId() == $wishlist->getUser()->getId());
- }
-
- /**
- * @param WishlistInterface $wishlist
- *
- * @return RedirectResponse
- */
- protected function redirectToWishlist(WishlistInterface $wishlist)
- {
- // If the bundle is configured to work with a single wishlist,
- // Redirect to the the general route (without a slug)
- if (false == $this->getParameter('webburza_sylius_wishlist.multiple')) {
- return $this->redirectToRoute('webburza_frontend_wishlist_first');
- }
-
- // Redirect back to the wishlist
- return $this->redirectToRoute('webburza_frontend_wishlist_show', [
- 'slug' => $wishlist->getSlug()
- ]);
- }
-
-}
diff --git a/Controller/Frontend/WishlistItemController.php b/Controller/Frontend/WishlistItemController.php
deleted file mode 100644
index e6cf789..0000000
--- a/Controller/Frontend/WishlistItemController.php
+++ /dev/null
@@ -1,241 +0,0 @@
-setContainer($container);
- }
-
- /**
- * This action renders a partial template to be submitted to
- * the default add-to-cart endpoint, as used on product page.
- *
- * @param Request $request
- *
- * @return Response
- */
- public function addToCartAction(Request $request)
- {
- $cart = $this->get('sylius.context.cart')->getCart();
-
- $variant =
- $this->get('sylius.repository.product_variant')->find($request->get('variantId'));
-
- /** @var OrderItemInterface $orderItem */
- $orderItem = $this->get('sylius.factory.order_item')
- ->createForProduct($variant->getProduct());
-
- $addToCartCommand =
- $this->get('sylius.factory.add_to_cart_command')
- ->createWithCartAndCartItem($cart, $orderItem);
-
- $form = $this->get('form.factory')->create(AddToCartType::class, $addToCartCommand, [
- 'product' => $variant->getProduct()
- ]);
-
- $form->get('cartItem')->get('quantity')->setData(1);
-
- if ($form->get('cartItem')->has('variant')) {
- $form->get('cartItem')->get('variant')->setData($variant);
- }
-
- $view = View::create([
- 'product' => $variant->getProduct(),
- 'form' => $form->createView()
- ]);
-
- $view->setTemplate('@WebburzaSyliusWishlist/Frontend/Wishlist/_cartForm.html.twig');
-
- return $this->handleView($view);
- }
-
- /**
- * @param Request $request
- *
- * @return Response
- */
- public function removeAction(Request $request)
- {
- /** @var WishlistItemInterface $wishlistItem */
- $wishlistItem =
- $this->get('webburza_wishlist.repository.wishlist_item')->find($request->get('id'));
-
- // Check if this item belongs to the current customer trying to remove it
- if ($wishlistItem->getWishlist()->getUser() != $this->getUser()) {
- throw $this->createAccessDeniedException();
- }
-
- // Remove the item from the repository
- $this->get('webburza_wishlist.repository.wishlist_item')->remove($wishlistItem);
-
- // If this was an AJAX request, return appropriate response
- if ($request->getRequestFormat() != 'html') {
- return new JsonResponse(null, Response::HTTP_NO_CONTENT);
- }
-
- // Set success message
- $this->addFlash(
- 'success',
- $this->get('translator')->trans('webburza_wishlist.flash.item_removed')
- );
-
- return $this->redirectToWishlist($wishlistItem->getWishlist());
- }
-
- /**
- * Add a wishlist item to a wishlist (create it).
- *
- * @param Request $request
- *
- * @return Response
- */
- public function addAction(Request $request)
- {
- // Get the current user
- if (!($user = $this->getUser())) {
- throw new BadRequestHttpException();
- }
-
- // Get (or create) the wishlist to which the item should be added
- $wishlist = $this->resolveWishlist($request, $user);
-
- // Get the product variant to be added to wishlist
- $productVariant = $this->resolveProductVariant($request);
-
- // Prevent duplicates
- if ($wishlist->contains($productVariant)) {
- // Set flash message
- $this->addFlash(
- 'info',
- $this->get('translator')->trans('webburza_wishlist.flash.already_on_wishlist')
- );
-
- // Redirect back to the wishlist
- return $this->redirectToWishlist($wishlist);
- }
-
- /** @var WishlistItemInterface $wishlistItem */
- $wishlistItem = $this->get('webburza_wishlist.factory.wishlist_item')->createNew();
- $wishlistItem->setProductVariant($productVariant);
-
- $wishlist->addItem($wishlistItem);
-
- // Persist the wishlist item
- $this->get('webburza_wishlist.repository.wishlist_item')->add($wishlistItem);
-
- if ($request->getRequestFormat() != 'html') {
- return new JsonResponse(null, Response::HTTP_CREATED);
- }
-
- // Set success message
- $this->addFlash(
- 'success',
- $this->get('translator')->trans('webburza_wishlist.flash.item_added')
- );
-
- return $this->redirectToWishlist($wishlist);
- }
-
- /**
- * Get the requested wishlist, if any,
- * or the first one for the customer.
- *
- * @param Request $request
- * @param UserInterface $user
- *
- * @return null|WishlistInterface
- */
- protected function resolveWishlist(Request $request, UserInterface $user)
- {
- // Check if a specific wishlist was requested
- if ($wishlistId = $request->get('wishlistId')) {
- $wishlist = $this->get('webburza_wishlist.repository.wishlist')
- ->findOneBy([
- 'id' => $wishlistId,
- 'user' => $user
- ]);
-
- if (!$wishlist) {
- throw new BadRequestHttpException();
- }
-
- return $wishlist;
- }
-
- // If not, get the first wishlist for the customer
- $wishlist = $this->get('webburza_wishlist.repository.wishlist')->getFirstForUser($user);
-
- // If no wishlist found, create a new one
- if (!$wishlist) {
- $wishlist = $this->get('webburza_wishlist.factory.wishlist')->createDefault($user);
- $this->get('webburza_wishlist.repository.wishlist')->add($wishlist);
- }
-
- return $wishlist;
- }
-
- /**
- * @param Request $request
- *
- * @return mixed
- * @throws BadRequestHttpException
- */
- protected function resolveProductVariant(Request $request)
- {
- if ($productVariantId = $request->get('productVariantId')) {
- $productVariant = $this->get('sylius.repository.product_variant')
- ->find($productVariantId);
- } else {
- $productVariant =
- $this->container->get('webburza_wishlist.resolver.product_variant_cart')
- ->resolve($request);
- }
-
- if (!$productVariant) {
- throw new BadRequestHttpException();
- }
-
- return $productVariant;
- }
-
- /**
- * @param WishlistInterface $wishlist
- *
- * @return RedirectResponse
- */
- protected function redirectToWishlist(WishlistInterface $wishlist)
- {
- // If the bundle is configured to work with a single wishlist,
- // Redirect to the the general route (without a slug)
- if (false == $this->getParameter('webburza_sylius_wishlist.multiple')) {
- return $this->redirectToRoute('webburza_frontend_wishlist_first');
- }
-
- // Redirect back to the wishlist
- return $this->redirectToRoute('webburza_frontend_wishlist_show', [
- 'slug' => $wishlist->getSlug()
- ]);
- }
-}
diff --git a/DependencyInjection/WebburzaSyliusWishlistExtension.php b/DependencyInjection/WebburzaSyliusWishlistExtension.php
deleted file mode 100644
index 0d91084..0000000
--- a/DependencyInjection/WebburzaSyliusWishlistExtension.php
+++ /dev/null
@@ -1,27 +0,0 @@
-processConfiguration($configuration, $configs);
-
- // Set config parameters
- $container->setParameter('webburza_sylius_wishlist.multiple', $config['multiple']);
- $container->setParameter('webburza_sylius_wishlist.default_public', $config['default_public']);
-
- $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
- $loader->load('services.yml');
- }
-}
diff --git a/EventListener/MenuBuilderListener.php b/EventListener/MenuBuilderListener.php
deleted file mode 100644
index d3702d3..0000000
--- a/EventListener/MenuBuilderListener.php
+++ /dev/null
@@ -1,26 +0,0 @@
-getMenu();
-
- // Get or create the parent group
- if (null == ($contentMenu = $menu->getChild('customers'))) {
- $contentMenu = $menu->addChild('customers')->setLabel('webburza_wishlist.ui.customer');
- }
-
- // Add 'Wishlists' menu item
- $contentMenu->addChild('webburza_wishlists', ['route' => 'webburza_wishlist_admin_wishlist_index'])
- ->setLabel('webburza_wishlist.ui.wishlists')
- ->setLabelAttribute('icon', 'star');
- }
-}
diff --git a/EventListener/UserListener.php b/EventListener/UserListener.php
deleted file mode 100644
index 9df7ac1..0000000
--- a/EventListener/UserListener.php
+++ /dev/null
@@ -1,68 +0,0 @@
-container = $container;
- $this->wishlistQueue = new ArrayCollection();
- }
-
- /**
- * @param OnFlushEventArgs $event
- */
- public function onFlush(OnFlushEventArgs $event)
- {
- $entities = $event->getEntityManager()->getUnitOfWork()->getScheduledEntityInsertions();
-
- foreach ($entities as $entity) {
- if ($entity instanceof ShopUserInterface) {
- $this->wishlistQueue->add(
- $this->container->get('webburza_wishlist.factory.wishlist')->createDefault($entity)
- );
- }
- }
- }
-
- /**
- * @param PostFlushEventArgs $event
- */
- public function postFlush(PostFlushEventArgs $event)
- {
- if ($this->wishlistQueue->count()) {
- foreach ($this->wishlistQueue as $wishlist) {
- $this->container->get('doctrine.orm.entity_manager')->persist($wishlist);
- }
- $this->wishlistQueue->clear();
-
- $event->getEntityManager()->flush();
- }
- }
-}
diff --git a/Factory/WishlistFactoryInterface.php b/Factory/WishlistFactoryInterface.php
deleted file mode 100644
index e59d3ae..0000000
--- a/Factory/WishlistFactoryInterface.php
+++ /dev/null
@@ -1,17 +0,0 @@
-add('user', UserChoiceType::class, [
- 'label' => 'webburza_wishlist.wishlist.label.user',
- 'required' => true,
- 'constraints' => [
- new NotBlank()
- ]
- ]);
- }
-}
diff --git a/Form/Type/UserChoiceType.php b/Form/Type/UserChoiceType.php
deleted file mode 100644
index 69ba935..0000000
--- a/Form/Type/UserChoiceType.php
+++ /dev/null
@@ -1,67 +0,0 @@
-repository = $repository;
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- if ($options['multiple']) {
- $builder->addModelTransformer(new CollectionToArrayTransformer());
- }
- }
-
- /**
- * {@inheritdoc}
- */
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults([
- 'choices' => function (Options $options) {
- return $this->repository->findAll();
- },
- 'choice_value' => 'id',
- 'choice_label' => 'email'
- ]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function getParent()
- {
- return ChoiceType::class;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getBlockPrefix()
- {
- return 'webburza_wishlist_user_choice';
- }
-}
diff --git a/Model/WishlistInterface.php b/Model/WishlistInterface.php
deleted file mode 100644
index 4e62921..0000000
--- a/Model/WishlistInterface.php
+++ /dev/null
@@ -1,92 +0,0 @@
-
+
+---
+
## Installation
1. require the bundle with Composer:
```bash
- $ composer require webburza/sylius-wishlist-bundle
+ $ composer require webburza/sylius-wishlist-plugin
```
2. enable the bundle in `app/AppKernel.php`:
@@ -20,7 +24,7 @@ to use single or multiple wishlists per user, which can be public or private.
{
$bundles = [
// ...
- new \Webburza\Sylius\WishlistBundle\WebburzaSyliusWishlistBundle(),
+ new \Webburza\SyliusWishlistPlugin\WebburzaSyliusWishlistPlugin(),
// ...
];
}
@@ -30,7 +34,7 @@ to use single or multiple wishlists per user, which can be public or private.
```yaml
imports:
- - { resource: "@WebburzaSyliusWishlistBundle/Resources/config/config.yml" }
+ - { resource: "@WebburzaSyliusWishlistPlugin/Resources/config/config.yml" }
```
Among other things, this provides configuration entries which can then be overriden
@@ -45,22 +49,10 @@ to use single or multiple wishlists per user, which can be public or private.
4. register routes in `app/config/routing.yml`
```yaml
- webburza_wishlist:
- resource: "@WebburzaSyliusWishlistBundle/Resources/config/routing.yml"
-
- webburza_wishlist_front:
- resource: "@WebburzaSyliusWishlistBundle/Resources/config/routingFront.yml"
- prefix: /wishlist
-
- webburza_wishlist_account:
- resource: "@WebburzaSyliusWishlistBundle/Resources/config/routingAccount.yml"
- prefix: /account/wishlists
+ webburza_sylius_wishlist:
+ resource: "@WebburzaSyliusWishlistPlugin/Resources/config/routing.yml"
```
- As you can see, there are three groups of routes, the main resource (administration)
- routes, frontend routes, and user account routes where the user can manage their
- wishlist(s), create new ones, mark them public/private, etc...
-
5. The bundle should now be fully integrated, but it still requires
database tables to be created. For this, we recommend using migrations.
@@ -77,15 +69,7 @@ to use single or multiple wishlists per user, which can be public or private.
6. If you're integrating this bundle into an existing project, your existing
users will not have any wishlists associated. This is not an issue as wishlists
- are automatically created when needed. All new users will automatically have
- a wishlist created for them from the start.
-
- If you want to make sure all your users have wishlists, you can run a command
- which will create initial wishlists for all existing users which do not already have one.
-
- ```bash
- $ bin/console webburza:sylius-wishlist-bundle:create-initial
- ```
+ are automatically created when needed.
## Integration on shop pages
@@ -101,7 +85,7 @@ this implementation is up to you. It can be done in two ways.
next to the 'Add to cart' button in the existing form.
Open the template containing your 'add to cart' form, most likely in:
- `app/Resources/SyliusShopBundle/Resources/views/Product/Show/_addToCart.html.twig`
+ `app/Resources/SyliusShopBundle/views/Product/Show/_addToCart.html.twig`
Find the 'add to cart' button, by default:
```
@@ -110,7 +94,7 @@ this implementation is up to you. It can be done in two ways.
And under it, add the following line.
```
- {% include '@WebburzaSyliusWishlist/Frontend/Shop/_addToWishlist.html.twig' %}
+ {% include '@WebburzaSyliusWishlistPlugin/Shop/Misc/_addToWishlist.html.twig' %}
```
This will include the 'Add to Wishlist' button, and all required functionality.
@@ -126,7 +110,7 @@ this implementation is up to you. It can be done in two ways.
```
$.ajax({
- url: '/wishlist/item/',
+ url: '/wishlist/item',
type: 'POST',
data: {
productVariantId: 123,
@@ -147,25 +131,78 @@ You might also want to feature a badge in your header which links to the wishlis
and shows the current number of items added, similar to the existing cart badge.
To do this, just add this line to the bottom of the same file
-`app/Resources/SyliusShopBundle/Resources/views/Cart/_widget.html.twig`
+`app/Resources/SyliusShopBundle/views/Cart/_widget.html.twig`
```
-{% include '@WebburzaSyliusWishlist/Frontend/Shop/_badge.html.twig' %}
+{% include '@WebburzaSyliusWishlistPlugin/Shop/Misc/_badge.html.twig' %}
```
## Translations and naming
The bundle has multilingual support, and language files can be
overridden as with any other bundle, by creating translation files in the
-`app/Resources/WebburzaSyliusWishlistBundle/translations` directory.
+`app/Resources/WebburzaSyliusWishlistPlugin/translations` directory.
To get started, check the bundle's main language file in:
-[Resources/translations/messages.en.yml](Resources/translations/messages.en.yml)
+[src/Resources/translations/messages.en.yml](src/Resources/translations/messages.en.yml)
+
+## Running and testing the application manually
+
+- Initial installation and fixtures:
+
+ ```bash
+ $ composer install
+
+ $ (cd tests/Application && yarn install)
+ $ (cd tests/Application && yarn run gulp)
+ $ (cd tests/Application && bin/console assets:install web -e dev)
+
+ $ (cd tests/Application && bin/console doctrine:database:create -e dev)
+ $ (cd tests/Application && bin/console doctrine:schema:create -e dev)
+ $ (cd tests/Application && bin/console sylius:fixtures:load -e dev)
+ ```
+
+- Start application:
+
+ ```bash
+ $ (cd tests/Application && bin/console server:start -d web -e dev)
+ ```
+
+- Stop application:
+
+ ```bash
+ $ (cd tests/Application && bin/console server:stop)
+ ```
+
+## Automated tests
+
+ - Behat (non-Javascript scenarios)
+
+ ```bash
+ $ bin/behat --tags="~@javascript"
+ ```
+
+ - Behat (with Javascript scenarios)
+
+ 1. Download [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)
+
+ 2. Run Selenium server with previously downloaded Chromedriver:
+
+ ```bash
+ $ bin/selenium-server-standalone -Dwebdriver.chrome.driver=/path/to/chromedriver
+ ```
+ 3. Run test application's webserver on `localhost:8080`:
+
+ ```bash
+ $ (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web -e test)
+ ```
+
+ 4. Run Behat:
+
+ ```bash
+ $ bin/behat
+ ```
## License
This bundle is available under the [MIT license](LICENSE).
-
-## To-do
-
-- Tests
diff --git a/Repository/WishlistRepositoryInterface.php b/Repository/WishlistRepositoryInterface.php
deleted file mode 100644
index 3d72d0a..0000000
--- a/Repository/WishlistRepositoryInterface.php
+++ /dev/null
@@ -1,32 +0,0 @@
-
- {{ form_errors(form) }}
-
-
-
- {{ form_rest(form) }}
-
-
- {% if form.vars.data.items | length %}
-
-
-
-
-
{{ 'webburza_wishlist.ui.wishlist_items' | trans }}