Skip to content

Commit

Permalink
Fixed: Reset failed events button to be hidden if no failed messages …
Browse files Browse the repository at this point in the history
…exists
  • Loading branch information
igormukhingmailcom committed Nov 11, 2021
1 parent 512b1d7 commit 8850bfe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
{# @var \Setono\SyliusFacebookPlugin\Model\PixelInterface data #}

{% import '@SetonoSyliusFacebookPlugin/Admin/Macro/buttons.html.twig' as buttons %}

{% set path = options.link.url|default(path(
options.link.route|default('setono_sylius_facebook_admin_pixel_reset_failed_events'),
options.link.parameters|default({'id': data.id})
)) %}

{{ buttons.resetFailedEvents(
path,
action.label|default('setono_sylius_facebook.ui.reset_failed_events'),
true,
data.id
) }}
{% set failedCount = setono_facebook_events_count_by_state(data, constant('Setono\\SyliusFacebookPlugin\\Model\\PixelEventInterface::STATE_FAILED')) %}
{% if options.visible|default(failedCount > 0) %}
{{ buttons.resetFailedEvents(
path,
action.label|default('setono_sylius_facebook.ui.reset_failed_events'),
true,
data.id
) }}
{% endif %}
6 changes: 6 additions & 0 deletions src/Twig/EventsPushingStatisticsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function getFunctions(): array
{
return [
new TwigFunction('setono_facebook_events_pushing_statistics', [$this, 'getEventsPushingStatistics']),
new TwigFunction('setono_facebook_events_count_by_state', [$this, 'getEventsCountByState']),
];
}

Expand All @@ -43,4 +44,9 @@ public function getEventsPushingStatistics(PixelInterface $pixel): array

return $result;
}

public function getEventsCountByState(PixelInterface $pixel, string $state): int
{
return $this->pixelEventRepository->getCountByPixelAndState($pixel, $state);
}
}

0 comments on commit 8850bfe

Please sign in to comment.