Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert: Use the page name if the page has no SEO title (#646) #767

Merged
merged 2 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
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
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