Skip to content

Commit

Permalink
Pass also an original object to DisplayEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
chives committed Dec 7, 2017
1 parent 2fc586a commit 652c2b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Admin/Display/Context/DisplayContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public function setElement(Element $element): void

protected function createEvent(Request $request): AdminEvent
{
$this->display = $this->element->createDisplay($this->getObject($request));
$object = $this->getObject($request);
$this->display = $this->element->createDisplay($object);

return new DisplayEvent($this->element, $request, $this->display);
return new DisplayEvent($this->element, $request, $this->display, $object);
}

protected function getSupportedRoute(): string
Expand Down
16 changes: 15 additions & 1 deletion Event/DisplayEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,29 @@ class DisplayEvent extends AdminEvent
*/
private $display;

public function __construct(Element $element, Request $request, Display $display)
/**
* @var mixed
*/
private $object;

public function __construct(Element $element, Request $request, Display $display, $object)
{
parent::__construct($element, $request);

$this->display = $display;
$this->object = $object;
}

public function getDisplay(): Display
{
return $this->display;
}

/**
* @return mixed
*/
public function getObject()
{
return $this->object;
}
}

0 comments on commit 652c2b7

Please sign in to comment.