Skip to content

Commit

Permalink
Avoid error when structure is not found (#102)
Browse files Browse the repository at this point in the history
* avoid erro when structure is not found

* fixed error when form is loaded without structure in request

* use property in response
  • Loading branch information
alexander-schranz authored and wachterjohannes committed Oct 20, 2017
1 parent d15223e commit 6873ca2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

## 0.3.2

- HOTFIX #102 Fixed error when form is loaded without structure in request
- HOTFIX #101 Fixed mail receiver for website form
- HOTFIX #100 Add mail configuration to documentation

Expand Down
13 changes: 12 additions & 1 deletion TitleProvider/StructureTitleProvider.php
Expand Up @@ -11,6 +11,7 @@

namespace Sulu\Bundle\FormBundle\TitleProvider;

use Sulu\Component\Content\Compat\StructureInterface;
use Symfony\Component\HttpFoundation\RequestStack;

/**
Expand Down Expand Up @@ -39,6 +40,16 @@ public function getTitle($typeId)
$request = $this->requestStack->getMasterRequest();
$structure = $request->attributes->get('structure');

return $structure->getProperty('title')->getValue();
if (!$structure instanceof StructureInterface || $structure->getUuid() !== $typeId) {
return;
}

$property = $structure->getProperty('title');

if (!$property) {
return;
}

return $property->getValue();
}
}

0 comments on commit 6873ca2

Please sign in to comment.