Skip to content

Commit

Permalink
Merge pull request #767 from core23/revert/PR#646
Browse files Browse the repository at this point in the history
Revert: Use the page name if the page has no SEO title (#646)
  • Loading branch information
OskarStark authored Jan 16, 2017
2 parents 150cf92 + 5446c18 commit 041e17a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Page/Service/DefaultPageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ protected function updateSeoPage(PageInterface $page)
return;
}

$this->seoPage->setTitle($page->getTitle() ?: $page->getName());
if (!$this->seoPage->getTitle()) {
$this->seoPage->setTitle($page->getTitle() ?: $page->getName());
}

if ($page->getMetaDescription()) {
$this->seoPage->addMeta('name', 'description', $page->getMetaDescription());
Expand Down
3 changes: 2 additions & 1 deletion Tests/Page/Service/DefaultPageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public function testExecute()

// mock a page instance
$page = $this->getMock('Sonata\PageBundle\Model\PageInterface');
$page->expects($this->any())->method('getTitle')->will($this->returnValue('page title'));
$this->seoPage->expects($this->once())->method('getTitle')->will($this->returnValue(null));
$page->expects($this->once())->method('getTitle')->will($this->returnValue('page title'));
$page->expects($this->atLeastOnce())->method('getMetaDescription')->will($this->returnValue('page meta description'));
$page->expects($this->atLeastOnce())->method('getMetaKeyword')->will($this->returnValue('page meta keywords'));
$page->expects($this->once())->method('getTemplateCode')->will($this->returnValue('template code'));
Expand Down

0 comments on commit 041e17a

Please sign in to comment.