Skip to content

Commit 3627d7e

Browse files
authored
Merge pull request #273 from 4c0n/feature/allow-for-setting-page-title
Adding option to set the page title
2 parents 3cd4671 + 8bd5d9e commit 3627d7e

24 files changed

Lines changed: 118 additions & 2 deletions

features/admin/adding_page.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ Feature: Adding new page
88
Given the store operates on a single channel in "United States"
99
And I am logged in as an administrator
1010

11+
@ui @javascript @title
12+
Scenario: Adding page with title
13+
When I go to the create page page
14+
And I fill the code with "page_with_title"
15+
And I fill the slug with "page_with_title"
16+
And I fill the name with "page_with_title"
17+
And I fill the content with "This is a page with a title set by us."
18+
And I add it
19+
Then I should be notified that the page has been created
20+
1121
@ui @javascript
1222
Scenario: Adding page
1323
When I go to the create page page

features/shop/displaying_page.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,24 @@ Feature: Displaying pages
4848
And I should also see "iPhone 8" and "iPhone X" products associated with this page
4949
And I should also see "Blog" and "General" sections associated with this page
5050
And I should also see page image
51+
52+
@ui @javascript @title
53+
Scenario: Displaying page with title
54+
Given there is a page in the store
55+
And this page has "some_page_with_title" code
56+
And this page has "some_page_with_title" name
57+
And this page also has "some_page_with_title" slug
58+
And this page also has "Lorem ipsum" content
59+
And this page also has "title" title
60+
When I go to this page
61+
Then I should see page title "title"
62+
63+
@ui @javascript @title
64+
Scenario: Displaying page with default title
65+
Given there is a page in the store
66+
And this page has "title" code
67+
And this page has "Title" name
68+
And this page also has "title" slug
69+
And this page also has "Lorem ipsum" content
70+
When I go to this page
71+
Then I should see page title "Sylius"

spec/Entity/PageTranslationSpec.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,8 @@ function it_allows_access_via_properties(PageImageInterface $pageImage): void
6565

6666
$this->setDescriptionWhenLinked('description linked');
6767
$this->getDescriptionWhenLinked()->shouldReturn('description linked');
68+
69+
$this->setTitle('title');
70+
$this->getTitle()->shouldReturn('title');
6871
}
6972
}

src/Entity/Page.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ public function setImage(?ImageInterface $image): void
156156
$this->getPageTranslation()->setImage($image);
157157
}
158158

159+
public function getTitle(): ?string
160+
{
161+
return $this->getPageTranslation()->getTitle();
162+
}
163+
164+
public function setTitle(?string $title): void
165+
{
166+
$this->getPageTranslation()->setTitle($title);
167+
}
168+
159169
/**
160170
* @return PageTranslationInterface|TranslationInterface|null
161171
*/

src/Entity/PageInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@ public function setBreadcrumb(?string $breadcrumb): void;
6363
public function getDescriptionWhenLinked(): ?string;
6464

6565
public function setDescriptionWhenLinked(?string $descriptionWhenLinked): void;
66+
67+
public function getTitle(): ?string;
68+
69+
public function setTitle(?string $title): void;
6670
}

src/Entity/PageTranslation.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class PageTranslation extends AbstractTranslation implements PageTranslationInte
4646
/** @var string */
4747
protected $breadcrumb;
4848

49+
/** @var string */
50+
protected $title;
51+
4952
public function getId(): ?int
5053
{
5154
return $this->id;
@@ -144,4 +147,14 @@ public function setMetaDescription(?string $metaDescription): void
144147
{
145148
$this->metaDescription = $metaDescription;
146149
}
150+
151+
public function getTitle(): ?string
152+
{
153+
return $this->title;
154+
}
155+
156+
public function setTitle(?string $title): void
157+
{
158+
$this->title = $title;
159+
}
147160
}

src/Entity/PageTranslationInterface.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@ public function setMetaDescription(?string $metaDescription): void;
5252
public function getImage(): ?PageImageInterface;
5353

5454
public function setImage(?PageImageInterface $image): void;
55+
56+
public function getTitle(): ?string;
57+
58+
public function setTitle(?string $title): void;
5559
}

src/Form/Type/Translation/PageTranslationType.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5555
'required' => false,
5656
])
5757
->add('content', WysiwygType::class)
58+
->add('title', TextType::class, [
59+
'label' => 'bitbag_sylius_cms_plugin.ui.title',
60+
'required' => false,
61+
])
5862
;
5963
}
6064

src/Resources/config/doctrine/PageTranslation.orm.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ BitBag\SyliusCmsPlugin\Entity\PageTranslation:
4343
column: content
4444
type: text
4545
nullable: true
46+
title:
47+
column: title
48+
type: string
49+
nullable: true
4650
oneToOne:
4751
image:
4852
targetEntity: BitBag\SyliusCmsPlugin\Entity\PageImageInterface

src/Resources/translations/messages.cs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ bitbag_sylius_cms_plugin:
22
ui:
33
blocks: Bloky
44
pages: Stránky
5+
title: Titul
56
cms:
67
content_management: Obsahový management
78
cms: Obsahový management

0 commit comments

Comments
 (0)