Skip to content

Commit

Permalink
Merge pull request #17 from delyriand/feature/recurrence-event-shippi…
Browse files Browse the repository at this point in the history
…ng-method

Add shipping method in Recurrence event object
  • Loading branch information
delyriand authored Jul 6, 2022
2 parents 9ea90bb + 4d17d6b commit 99a84aa
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-

- name: Composer v2
run: sudo composer self-update --2
- name: Update Composer
run: sudo composer self-update

- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}
Expand All @@ -72,6 +72,7 @@ jobs:
- name: Setup some requirements
working-directory: ./sylius
run: |
composer config --no-plugins allow-plugins true
composer config repositories.plugin '{"type": "path", "url": "../plugin/"}'
composer config extra.symfony.allow-contrib true
composer config secure-http false
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ setup_application:
(cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint
$(MAKE) ${APP_DIR}/.php-version
$(MAKE) ${APP_DIR}/php.ini
(cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true)
(cd ${APP_DIR} && ${COMPOSER} install --no-interaction)
$(MAKE) apply_dist
(cd ${APP_DIR} && ${COMPOSER} require --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev")
Expand Down
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,13 @@
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config": {
"allow-plugins": {
"symfony/thanks": true,
"symfony/flex": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true
}
}
}
11 changes: 10 additions & 1 deletion src/Event/RecurrenceGenerationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@

namespace MonsieurBiz\SyliusShippingSlotPlugin\Event;

use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodInterface;
use Recurr\Recurrence;
use Symfony\Contracts\EventDispatcher\Event;

final class RecurrenceGenerationEvent extends Event
{
private array $recurrences;

public function __construct(array $recurrences)
private ?ShippingMethodInterface $shippingMethod;

public function __construct(array $recurrences, ?ShippingMethodInterface $shippingMethod = null)
{
$this->recurrences = $recurrences;
$this->shippingMethod = $shippingMethod;
}

/**
Expand All @@ -37,4 +41,9 @@ public function setRecurrences(array $recurrences): void
{
$this->recurrences = $recurrences;
}

public function getShippingMethod(): ?ShippingMethodInterface
{
return $this->shippingMethod;
}
}
2 changes: 1 addition & 1 deletion src/Generator/SlotGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function generateCalendarEvents(
return [];
}
$recurrences = $shippingSlotConfig->getRecurrences($startDate, $endDate, $this->getCartPreparationDelay());
$event = new RecurrenceGenerationEvent($recurrences);
$event = new RecurrenceGenerationEvent($recurrences, $shippingMethod);
$this->eventDispatcher->dispatch($event);
$recurrences = $event->getRecurrences();

Expand Down

0 comments on commit 99a84aa

Please sign in to comment.