Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions EditInPlace/Activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public function setSession(Session $session): void
/**
* Get session based on availability.
*/
private function getSession(): Session
private function getSession(): ?Session
{
$session = $this->session;
if (null === $session) {
if (null === $session && $this->requestStack->getCurrentRequest()->hasSession()) {
$session = $this->requestStack->getSession();
}

Expand All @@ -65,23 +65,27 @@ private function getSession(): Session
*/
public function activate(): void
{
$this->getSession()->set(self::KEY, true);
if (null !== $this->getSession()) {
$this->getSession()->set(self::KEY, true);
}
}

/**
* Disable the Edit In Place mode.
*/
public function deactivate(): void
{
$this->getSession()->remove(self::KEY);
if (null !== $this->getSession()) {
$this->getSession()->remove(self::KEY);
}
}

/**
* {@inheritdoc}
*/
public function checkRequest(Request $request = null): bool
{
if (!$this->getSession()->has(self::KEY)) {
if (null === $this->getSession() || !$this->getSession()->has(self::KEY)) {
return false;
}

Expand Down