use events for budget calculation (#2544)

This commit is contained in:
Kevin Papst
2021-04-29 11:50:48 +02:00
committed by GitHub
parent bb94b11e37
commit e4b176a4d5
30 changed files with 384 additions and 92 deletions

View File

@@ -10,6 +10,7 @@
namespace App\Controller;
use App\Activity\ActivityService;
use App\Activity\ActivityStatisticService;
use App\Configuration\SystemConfiguration;
use App\Entity\Activity;
use App\Entity\ActivityRate;
@@ -114,7 +115,7 @@ final class ActivityController extends AbstractController
* @Route(path="/{id}/details", name="activity_details", methods={"GET", "POST"})
* @Security("is_granted('view', activity)")
*/
public function detailsAction(Activity $activity, TeamRepository $teamRepository, ActivityRateRepository $rateRepository)
public function detailsAction(Activity $activity, TeamRepository $teamRepository, ActivityRateRepository $rateRepository, ActivityStatisticService $statisticService)
{
$event = new ActivityMetaDefinitionEvent($activity);
$this->dispatcher->dispatch($event);
@@ -132,7 +133,7 @@ final class ActivityController extends AbstractController
}
if ($this->isGranted('budget', $activity)) {
$stats = $this->repository->getActivityStatistics($activity);
$stats = $statisticService->getActivityStatistics($activity);
}
if ($this->isGranted('permissions', $activity) || $this->isGranted('details', $activity) || $this->isGranted('view_team')) {
@@ -308,9 +309,9 @@ final class ActivityController extends AbstractController
* @Route(path="/{id}/delete", name="admin_activity_delete", methods={"GET", "POST"})
* @Security("is_granted('delete', activity)")
*/
public function deleteAction(Activity $activity, Request $request)
public function deleteAction(Activity $activity, Request $request, ActivityStatisticService $statisticService)
{
$stats = $this->repository->getActivityStatistics($activity);
$stats = $statisticService->getActivityStatistics($activity);
$deleteForm = $this->createFormBuilder(null, [
'attr' => [

View File

@@ -10,6 +10,7 @@
namespace App\Controller;
use App\Configuration\SystemConfiguration;
use App\Customer\CustomerStatisticService;
use App\Entity\Customer;
use App\Entity\CustomerComment;
use App\Entity\CustomerRate;
@@ -268,7 +269,7 @@ final class CustomerController extends AbstractController
* @Route(path="/{id}/details", name="customer_details", methods={"GET", "POST"})
* @Security("is_granted('view', customer)")
*/
public function detailsAction(Customer $customer, TeamRepository $teamRepository, CustomerRateRepository $rateRepository)
public function detailsAction(Customer $customer, TeamRepository $teamRepository, CustomerRateRepository $rateRepository, CustomerStatisticService $statisticService)
{
$event = new CustomerMetaDefinitionEvent($customer);
$this->dispatcher->dispatch($event);
@@ -295,7 +296,7 @@ final class CustomerController extends AbstractController
}
if ($this->isGranted('budget', $customer)) {
$stats = $this->repository->getCustomerStatistics($customer);
$stats = $statisticService->getCustomerStatistics($customer);
}
if ($this->isGranted('comments', $customer)) {
@@ -370,9 +371,9 @@ final class CustomerController extends AbstractController
* @Route(path="/{id}/delete", name="admin_customer_delete", methods={"GET", "POST"})
* @Security("is_granted('delete', customer)")
*/
public function deleteAction(Customer $customer, Request $request)
public function deleteAction(Customer $customer, Request $request, CustomerStatisticService $statisticService)
{
$stats = $this->repository->getCustomerStatistics($customer);
$stats = $statisticService->getCustomerStatistics($customer);
$deleteForm = $this->createFormBuilder(null, [
'attr' => [

View File

@@ -30,6 +30,7 @@ use App\Form\Toolbar\ProjectToolbarForm;
use App\Form\Type\ProjectType;
use App\Project\ProjectDuplicationService;
use App\Project\ProjectService;
use App\Project\ProjectStatisticService;
use App\Repository\ActivityRepository;
use App\Repository\ProjectRateRepository;
use App\Repository\ProjectRepository;
@@ -291,7 +292,7 @@ final class ProjectController extends AbstractController
* @Route(path="/{id}/details", name="project_details", methods={"GET", "POST"})
* @Security("is_granted('view', project)")
*/
public function detailsAction(Project $project, TeamRepository $teamRepository, ProjectRateRepository $rateRepository)
public function detailsAction(Project $project, TeamRepository $teamRepository, ProjectRateRepository $rateRepository, ProjectStatisticService $statisticService)
{
$event = new ProjectMetaDefinitionEvent($project);
$this->dispatcher->dispatch($event);
@@ -312,7 +313,7 @@ final class ProjectController extends AbstractController
}
if ($this->isGranted('budget', $project)) {
$stats = $this->repository->getProjectStatistics($project);
$stats = $statisticService->getProjectStatistics($project);
}
if ($this->isGranted('comments', $project)) {
@@ -414,9 +415,9 @@ final class ProjectController extends AbstractController
* @Route(path="/{id}/delete", name="admin_project_delete", methods={"GET", "POST"})
* @Security("is_granted('delete', project)")
*/
public function deleteAction(Project $project, Request $request)
public function deleteAction(Project $project, Request $request, ProjectStatisticService $statisticService)
{
$stats = $this->repository->getProjectStatistics($project);
$stats = $statisticService->getProjectStatistics($project);
$deleteForm = $this->createFormBuilder(null, [
'attr' => [

View File

@@ -10,9 +10,9 @@
namespace App\Controller\Reporting;
use App\Controller\AbstractController;
use App\Project\ProjectStatisticService;
use App\Reporting\ProjectInactive\ProjectInactiveForm;
use App\Reporting\ProjectInactive\ProjectInactiveQuery;
use App\Reporting\ProjectStatisticService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

View File

@@ -10,7 +10,7 @@
namespace App\Controller\Reporting;
use App\Controller\AbstractController;
use App\Reporting\ProjectStatisticService;
use App\Project\ProjectStatisticService;
use App\Reporting\ProjectView\ProjectViewForm;
use App\Reporting\ProjectView\ProjectViewQuery;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;