{{ form_row(form.status) }}
diff --git a/Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisManager.php b/Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisManager.php
index e80058421..dcf1ec2ab 100644
--- a/Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisManager.php
+++ b/Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisManager.php
@@ -126,19 +126,23 @@ public function buildUrl($id)
$reference = $this->repository->findById($id);
$locale = $this->repository->findValueForId('locale', $id);
$url = '';
- // while the reference has a slug
- while (isset($reference['slug']) && $reference['slug'] != '') {
- // Build url
- if ($url != '') {
- $url = $reference['slug'].'/'.$url;
- } else {
- $url = $reference['slug'];
- }
- // Set reference with the parent
- if ($parentId = $reference['parent']) {
- $reference = $this->repository->findById($parentId);
- } else {
- $reference = [];
+ if (null !== $reference['permalink'] && '' !== $reference['permalink']) {
+ $url = $reference['permalink'];
+ } else {
+ // while the reference has a slug (parent loop)
+ while (isset($reference['slug']) && $reference['slug'] != '') {
+ // Build url
+ if ($url != '') {
+ $url = $reference['slug'].'/'.$url;
+ } else {
+ $url = $reference['slug'];
+ }
+ // Set reference with the parent
+ if ($parentId = $reference['parent']) {
+ $reference = $this->repository->findById($parentId);
+ } else {
+ $reference = [];
+ }
}
}
// set the new url
diff --git a/Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php b/Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php
index 2a8bec4fd..5e30f4c5c 100644
--- a/Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php
+++ b/Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php
@@ -53,7 +53,7 @@ public function findReferenceByView(View $view)
* @param $url
* @param $locale
*
- * @return mixed|null
+ * @return ViewReference|null
*/
public function getReferenceByUrl($url, $locale)
{
diff --git a/Bundle/ViewReferenceBundle/ViewReference/ViewReference.php b/Bundle/ViewReferenceBundle/ViewReference/ViewReference.php
index 13ed6ce48..2afb080dc 100644
--- a/Bundle/ViewReferenceBundle/ViewReference/ViewReference.php
+++ b/Bundle/ViewReferenceBundle/ViewReference/ViewReference.php
@@ -8,6 +8,7 @@ class ViewReference
protected $locale;
protected $name;
protected $slug;
+ protected $permalink;
/**
* @var string built by ViewReferenceCacheRepo
*/
@@ -121,6 +122,22 @@ public function setSlug($slug)
$this->slug = $slug;
}
+ /**
+ * @return mixed
+ */
+ public function getPermalink()
+ {
+ return $this->permalink;
+ }
+
+ /**
+ * @param mixed $permalink
+ */
+ public function setPermalink($permalink)
+ {
+ $this->permalink = $permalink;
+ }
+
/**
* @return string
*/
diff --git a/Tests/Features/Page/create.feature b/Tests/Features/Page/create.feature
index 9d4c33a06..809016235 100644
--- a/Tests/Features/Page/create.feature
+++ b/Tests/Features/Page/create.feature
@@ -31,3 +31,29 @@ Feature: Create a page
And I wait 5 seconds
Then the url should match "/en/anoth"
And I should see "Successfully modified page"
+
+ @alice(Template)
+ Scenario: I can define a permalink for a page which is not already in use
+ Given the following Page:
+ | currentLocale | name | slug | parent | template |
+ | en | anakin skywalker | anakin-skywalker | home | base |
+ | en | luke skywalker | luke-skywalker | anakin-skywalker | base |
+ | en | contact page | contact | home | base |
+ And I am on "/en/anakin-skywalker/luke-skywalker"
+ And I open the settings menu
+ And I should see "UPDATE"
+ Then I fill in "page_settings_translations_en_permalink" with "anakin-skywalker"
+ And I submit the widget
+ And I wait 5 seconds
+ Then the url should match "/en/anakin-skywalker/luke-skywalker"
+ And I should see "The url is already in use"
+ When I fill in "page_settings_translations_en_permalink" with "contact"
+ And I submit the widget
+ And I wait 5 seconds
+ Then the url should match "/en/anakin-skywalker/luke-skywalker"
+ And I should see "The url is already in use"
+ Then I fill in "page_settings_translations_en_permalink" with "amazing-luke-skywalker"
+ And I submit the widget
+ And I wait 5 seconds
+ Then the url should match "/en/amazing-luke-skywalker"
+ And I should see "Successfully modified page"