Skip to content

Commit

Permalink
Add page to PagePartEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny van Wijk committed Apr 18, 2024
1 parent 54d6143 commit 032bdfa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/Kunstmaan/PagePartBundle/Event/PagePartEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Kunstmaan\PagePartBundle\Event;

use Kunstmaan\PagePartBundle\Helper\HasPagePartsInterface;
use Kunstmaan\PagePartBundle\Helper\PagePartInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\EventDispatcher\Event;
Expand All @@ -18,9 +19,12 @@ final class PagePartEvent extends Event
*/
private $response;

public function __construct(PagePartInterface $pagePart)
private ?HasPagePartsInterface $page;

public function __construct(PagePartInterface $pagePart, ?HasPagePartsInterface $page = null)
{
$this->pagePart = $pagePart;
$this->page = $page;
}

public function getPagePart(): PagePartInterface
Expand All @@ -42,4 +46,14 @@ public function setResponse(Response $response)
{
$this->response = $response;
}

public function getPage(): ?HasPagePartsInterface
{
return $this->page;
}

public function setPage(?HasPagePartsInterface $page): void
{
$this->page = $page;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function persist(Request $request)
}

if (isset($pagePart)) {
$this->container->get('event_dispatcher')->dispatch(new PagePartEvent($pagePart), Events::POST_PERSIST);
$this->container->get('event_dispatcher')->dispatch(new PagePartEvent($pagePart, $this->page), Events::POST_PERSIST);
}
}
}
Expand Down

0 comments on commit 032bdfa

Please sign in to comment.