mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Taxon] Remove unneeded permalink property
This commit is contained in:
parent
98b10e971e
commit
5f09c09b45
31 changed files with 36 additions and 187 deletions
|
|
@ -18,11 +18,11 @@ Feature: Adding a new taxon
|
|||
And the "T-Shirts" taxon should appear in the registry
|
||||
|
||||
@ui
|
||||
Scenario: Adding a new taxon with permalink and description
|
||||
Scenario: Adding a new taxon with slug and description
|
||||
Given I want to create a new taxon
|
||||
When I specify its code as "category"
|
||||
And I name it "Category" in "English (United States)"
|
||||
And I specify its permalink as "category" in "English (United States)"
|
||||
And I specify its slug as "category" in "English (United States)"
|
||||
And I describe it as "Main taxonomy for products." in "English (United States)"
|
||||
And I add it
|
||||
Then I should be notified that it has been successfully created
|
||||
|
|
|
|||
|
|
@ -26,22 +26,12 @@ Feature: Editing a taxon
|
|||
Then I should be notified that it has been successfully edited
|
||||
And this taxon description should be "Main taxonomy for stickers"
|
||||
|
||||
@ui
|
||||
Scenario: Changing permalink
|
||||
Given I want to modify the "T-Shirts" taxon
|
||||
When I rename it to "Stickers" in "English (United States)"
|
||||
And I change its description to "Main taxonomy for stickers" in "English (United States)"
|
||||
And I change its permalink to "stickers" in "English (United States)"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
And this taxon permalink should be "stickers"
|
||||
|
||||
@ui
|
||||
Scenario: Changing parent taxon
|
||||
Given I want to modify the "T-Shirts" taxon
|
||||
When I rename it to "Stickers" in "English (United States)"
|
||||
And I change its description to "Main taxonomy for stickers" in "English (United States)"
|
||||
And I change its permalink to "stickers" in "English (United States)"
|
||||
And I change its slug to "stickers" in "English (United States)"
|
||||
And I change its parent taxon to "Accessories"
|
||||
And I save my changes
|
||||
Then I should be notified that it has been successfully edited
|
||||
|
|
|
|||
|
|
@ -131,22 +131,6 @@ final class ManagingTaxonsContext implements Context
|
|||
$this->updatePage->describeItAs($description, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I specify its permalink as :permalink in :language
|
||||
*/
|
||||
public function iSpecifyItsPermalinkAs($permalink, $language)
|
||||
{
|
||||
$this->createPage->specifyPermalink($permalink, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I change its permalink to :permalink in :language
|
||||
*/
|
||||
public function iChangeItsPermalinkToIn($permalink, $language)
|
||||
{
|
||||
$this->updatePage->specifyPermalink($permalink, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I describe it as :description in :language
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ final class ProductContext implements Context
|
|||
*/
|
||||
public function iCheckListOfProductsForTaxon(TaxonInterface $taxon)
|
||||
{
|
||||
$this->taxonShowPage->open(['permalink' => $taxon->getPermalink()]);
|
||||
$this->taxonShowPage->open(['slug' => $taxon->getSlug()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -295,7 +295,7 @@ final class ProductContext implements Context
|
|||
{
|
||||
$sorting = ['createdAt' => 'oldest' === $sortDirection ? 'asc' : 'desc'];
|
||||
|
||||
$this->taxonShowPage->open(['permalink' => $taxon->getPermalink(), 'sorting' => $sorting]);
|
||||
$this->taxonShowPage->open(['slug' => $taxon->getSlug(), 'sorting' => $sorting]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -108,14 +108,6 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
$this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_name', $languageCode), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function specifyPermalink($permalink, $languageCode)
|
||||
{
|
||||
$this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_permalink', $languageCode), $permalink);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -210,7 +202,7 @@ JS;
|
|||
'images' => '#sylius_taxon_images',
|
||||
'name' => '#sylius_taxon_translations_en_US_name',
|
||||
'parent' => '#sylius_taxon_parent',
|
||||
'permalink' => '#sylius_taxon_translations_en_US_permalink',
|
||||
'slug' => '#sylius_taxon_translations_en_US_slug',
|
||||
'tree' => '.ui.list',
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,12 +70,6 @@ interface CreatePageInterface extends BaseCreatePageInterface
|
|||
*/
|
||||
public function specifyCode($code);
|
||||
|
||||
/**
|
||||
* @param string $permalink
|
||||
* @param string $languageCode
|
||||
*/
|
||||
public function specifyPermalink($permalink, $languageCode);
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param string $code
|
||||
|
|
|
|||
|
|
@ -49,14 +49,6 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
$this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_name', $languageCode), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function specifyPermalink($permalink, $languageCode)
|
||||
{
|
||||
$this->getDocument()->fillField(sprintf('sylius_taxon_translations_%s_permalink', $languageCode), $permalink);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -194,7 +186,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
'images' => '#sylius_taxon_images',
|
||||
'name' => '#sylius_taxon_translations_en_US_name',
|
||||
'parent' => '#sylius_taxon_parent',
|
||||
'permalink' => '#sylius_taxon_translations_en_US_permalink',
|
||||
'slug' => '#sylius_taxon_translations_en_US_slug',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,12 +42,6 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
|
|||
*/
|
||||
public function nameIt($name, $languageCode);
|
||||
|
||||
/**
|
||||
* @param string $permalink
|
||||
* @param string $languageCode
|
||||
*/
|
||||
public function specifyPermalink($permalink, $languageCode);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
</div>
|
||||
<div class="content{% if 0 == loop.index0 %} active{% endif %}">
|
||||
{{ form_row(translationForm.name) }}
|
||||
{{ form_row(translationForm.permalink) }}
|
||||
{{ form_row(translationForm.description) }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
# (c) Paweł Jędrzejewski
|
||||
|
||||
sylius_shop_taxon_show:
|
||||
path: /taxons/{permalink}
|
||||
path: /taxons/{slug}
|
||||
methods: [GET]
|
||||
defaults:
|
||||
_controller: sylius.controller.taxon:showAction
|
||||
_sylius:
|
||||
template: SyliusShopBundle:Taxon:show.html.twig
|
||||
repository:
|
||||
method: findOneByPermalink
|
||||
arguments: [$permalink]
|
||||
method: findOneBySlug
|
||||
arguments: [$slug]
|
||||
requirements:
|
||||
permalink: .+
|
||||
slug: .+
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
{{ sylius_grid_render_filter(products, filter) }}
|
||||
{% endfor %}
|
||||
<button type="submit" class="ui primary icon labeled button"><i class="search icon"></i> {{ 'sylius.ui.search'|trans }}</button>
|
||||
<a href="{{ path('sylius_shop_taxon_show', { 'permalink': app.request.query.get('permalink') }) }}" class="ui negative icon labeled button">
|
||||
<a href="{{ path('sylius_shop_taxon_show', { 'slug': app.request.query.get('slug') }) }}" class="ui negative icon labeled button">
|
||||
<i class="cancel icon"></i> {{ 'sylius.ui.clear'|trans }}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{% set definition = resources.definition %}
|
||||
|
||||
{% set oldest_first_path = path('sylius_shop_taxon_show', {'sorting': {'createdAt': 'asc'}, 'permalink': resources.parameters.get('permalink')}) %}
|
||||
{% set newest_first_path = path('sylius_shop_taxon_show', {'sorting': {'createdAt': 'desc'}, 'permalink': resources.parameters.get('permalink')}) %}
|
||||
{% set oldest_first_path = path('sylius_shop_taxon_show', {'sorting': {'createdAt': 'asc'}, 'slug': resources.parameters.get('slug')}) %}
|
||||
{% set newest_first_path = path('sylius_shop_taxon_show', {'sorting': {'createdAt': 'desc'}, 'slug': resources.parameters.get('slug')}) %}
|
||||
|
||||
{% if app.request.query.get('sorting') is empty or app.request.basePath == newest_first_path %}
|
||||
{% set current_sorting_label = 'sylius.ui.newest_first'|trans|lower %}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@
|
|||
{% set parents = taxon.parents|reverse %}
|
||||
|
||||
{% for parent in parents %}
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': parent.permalink}) }}" class="section">{{ parent.name }}</a>
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': parent.slug}) }}" class="section">{{ parent.name }}</a>
|
||||
<div class="divider"> / </div>
|
||||
{% endfor %}
|
||||
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': taxon.permalink}) }}" class="section">{{ taxon.name }}</a>
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': taxon.slug}) }}" class="section">{{ taxon.name }}</a>
|
||||
<div class="divider"> / </div>
|
||||
{% endif %}
|
||||
<div class="section">{{ product.name }}</div>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
{% set parents = taxon.parents|reverse %}
|
||||
|
||||
{% for parent in parents %}
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': parent.permalink}) }}" class="section">{{ parent.name }}</a>
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': parent.slug}) }}" class="section">{{ parent.name }}</a>
|
||||
<div class="divider"> / </div>
|
||||
{% endfor %}
|
||||
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': taxon.permalink}) }}" class="section">{{ taxon.name }}</a>
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': taxon.slug}) }}" class="section">{{ taxon.name }}</a>
|
||||
<div class="divider"> / </div>
|
||||
{% endif %}
|
||||
<div class="active section">{{ product.name }}</div>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<a href="{{ path('sylius_shop_homepage') }}" class="section">{{ 'sylius.ui.home'|trans }}</a>
|
||||
<div class="divider"> / </div>
|
||||
{% for parent in parents %}
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': parent.permalink}) }}" class="section">{{ parent.name }}</a>
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': parent.slug}) }}" class="section">{{ parent.name }}</a>
|
||||
<div class="divider"> / </div>
|
||||
{% endfor %}
|
||||
<div class="active section">{{ taxon.name }}</div>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<div class="ui fluid vertical menu">
|
||||
<div class="header item">{{ taxon.name }}</div>
|
||||
{% if taxon.parent is not empty %}
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': taxon.parent.permalink}) }}" class="item">
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': taxon.parent.slug}) }}" class="item">
|
||||
<i class="up arrow icon"></i> {{ 'sylius.ui.go_level_up'|trans }}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% for child in taxon.children %}
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': child.permalink}) }}" class="item">{{ child.name }}</a>
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': child.slug}) }}" class="item">{{ child.name }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'permalink': taxon.permalink}) }}" class="item">{{ taxon.name }}</a>
|
||||
<a href="{{ path('sylius_shop_taxon_show', {'slug': taxon.slug}) }}" class="item">{{ taxon.name }}</a>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
{
|
||||
'code': taxon.code,
|
||||
'template': '@SyliusShop/Product/Grid/_default.html.twig',
|
||||
'permalink': app.request.attributes.get('permalink'),
|
||||
'slug': app.request.attributes.get('slug'),
|
||||
'sorting': app.request.query.get('sorting'),
|
||||
'criteria': app.request.query.get('criteria')
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -93,13 +93,13 @@ class TaxonRepository extends EntityRepository implements TaxonRepositoryInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findOneByPermalink($permalink)
|
||||
public function findOneBySlug($slug)
|
||||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->addSelect('translation')
|
||||
->leftJoin('o.translations', 'translation')
|
||||
->where('translation.permalink = :permalink')
|
||||
->setParameter('permalink', $permalink)
|
||||
->where('translation.slug = :slug')
|
||||
->setParameter('slug', $slug)
|
||||
->orderBy('o.position')
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ class TaxonTranslationType extends AbstractResourceType
|
|||
->add('name', 'text', [
|
||||
'label' => 'sylius.form.taxon.name',
|
||||
])
|
||||
->add('permalink', 'text', [
|
||||
->add('slug', 'text', [
|
||||
'required' => false,
|
||||
'label' => 'sylius.form.taxon.permalink',
|
||||
'label' => 'sylius.form.taxon.slug',
|
||||
])
|
||||
->add('description', 'textarea', [
|
||||
'required' => false,
|
||||
|
|
|
|||
|
|
@ -26,9 +26,6 @@
|
|||
<field name="slug" column="slug" type="string" unique="true">
|
||||
<gedmo:slug fields="name" unique="true" />
|
||||
</field>
|
||||
<field name="permalink" column="permalink" type="string" unique="true">
|
||||
<gedmo:slug fields="name" unique="true" />
|
||||
</field>
|
||||
<field name="description" column="description" type="string" />
|
||||
<field name="left" column="tree_left" type="int">
|
||||
<gedmo:tree-left />
|
||||
|
|
|
|||
|
|
@ -25,21 +25,9 @@
|
|||
<field name="slug" column="slug" type="string" unique="false">
|
||||
<gedmo:slug fields="name" unique="false" />
|
||||
</field>
|
||||
<field name="permalink" column="permalink" type="string" unique="false">
|
||||
<gedmo:slug fields="name" unique="false" >
|
||||
<gedmo:handler class="Sylius\Bundle\ResourceBundle\GedmoHandler\TranslationSlugHandler">
|
||||
<gedmo:handler-option name="relationField" value="translatable"/>
|
||||
<gedmo:handler-option name="relationParentRelationField" value="parent"/>
|
||||
<gedmo:handler-option name="parentFieldMethod" value="getPermalink"/>
|
||||
<gedmo:handler-option name="locale" value="locale"/>
|
||||
<gedmo:handler-option name="translate" value="translate"/>
|
||||
<gedmo:handler-option name="separator" value="/"/>
|
||||
</gedmo:handler>
|
||||
</gedmo:slug>
|
||||
</field>
|
||||
<field name="description" column="description" type="text" nullable="true" />
|
||||
<unique-constraints>
|
||||
<unique-constraint columns="locale,permalink" name="permalink_uidx" />
|
||||
<unique-constraint columns="locale,slug" name="slug_uidx" />
|
||||
</unique-constraints>
|
||||
</mapped-superclass>
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@
|
|||
</property>
|
||||
<constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
|
||||
<option name="fields">
|
||||
<value>locale</value>
|
||||
<value>permalink</value>
|
||||
<value>locale</value>
|
||||
<value>slug</value>
|
||||
</option>
|
||||
<option name="message">sylius.permalink.unique</option>
|
||||
<option name="message">sylius.slug.unique</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</class>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ sylius:
|
|||
description: Description
|
||||
name: Name
|
||||
parent: Parent
|
||||
permalink: Permalink
|
||||
slug: Slug
|
||||
taxonomy:
|
||||
name: Name
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ final class TaxonTranslationTypeSpec extends ObjectBehavior
|
|||
;
|
||||
|
||||
$builder
|
||||
->add('permalink', 'text', Argument::any())
|
||||
->add('slug', 'text', Argument::any())
|
||||
->shouldBeCalled()
|
||||
->willReturn($builder)
|
||||
;
|
||||
|
|
|
|||
|
|
@ -236,34 +236,6 @@ class Taxon implements TaxonInterface
|
|||
$this->translate()->setSlug($slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPermalink()
|
||||
{
|
||||
$permalink = $this->translate()->getPermalink();
|
||||
|
||||
if (null !== $permalink) {
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
if (null === $this->parent) {
|
||||
return $this->getSlug();
|
||||
}
|
||||
|
||||
$this->setPermalink($permalink = $this->parent->getPermalink().'/'.$this->getSlug());
|
||||
|
||||
return $permalink;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPermalink($permalink)
|
||||
{
|
||||
$this->translate()->setPermalink($permalink);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -33,11 +33,6 @@ class TaxonTranslation extends AbstractTranslation implements TaxonTranslationIn
|
|||
*/
|
||||
protected $slug;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $permalink;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -91,22 +86,6 @@ class TaxonTranslation extends AbstractTranslation implements TaxonTranslationIn
|
|||
$this->slug = $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPermalink()
|
||||
{
|
||||
return $this->permalink;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setPermalink($permalink)
|
||||
{
|
||||
$this->permalink = $permalink;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,16 +29,6 @@ interface TaxonTranslationInterface extends SlugAwareInterface, ResourceInterfac
|
|||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPermalink();
|
||||
|
||||
/**
|
||||
* @param string $permalink
|
||||
*/
|
||||
public function setPermalink($permalink);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -62,11 +62,11 @@ interface TaxonRepositoryInterface extends RepositoryInterface
|
|||
public function findNodesTreeSorted();
|
||||
|
||||
/**
|
||||
* @param string $permalink
|
||||
* @param string $slug
|
||||
*
|
||||
* @return TaxonInterface|null
|
||||
*/
|
||||
public function findOneByPermalink($permalink);
|
||||
public function findOneBySlug($slug);
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
|
|
|
|||
|
|
@ -147,17 +147,6 @@ final class TaxonSpec extends ObjectBehavior
|
|||
$this->getSlug()->shouldReturn('t-shirts');
|
||||
}
|
||||
|
||||
function it_has_no_permalink_by_default()
|
||||
{
|
||||
$this->getPermalink()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_permalink_is_mutable()
|
||||
{
|
||||
$this->setPermalink('woman-clothing');
|
||||
$this->getPermalink()->shouldReturn('woman-clothing');
|
||||
}
|
||||
|
||||
function it_initializes_child_taxon_collection_by_default()
|
||||
{
|
||||
$this->getChildren()->shouldHaveType(Collection::class);
|
||||
|
|
|
|||
|
|
@ -73,15 +73,4 @@ final class TaxonTranslationSpec extends ObjectBehavior
|
|||
$this->setSlug('t-shirts');
|
||||
$this->getSlug()->shouldReturn('t-shirts');
|
||||
}
|
||||
|
||||
function it_has_no_permalink_by_default()
|
||||
{
|
||||
$this->getPermalink()->shouldReturn(null);
|
||||
}
|
||||
|
||||
function its_permalink_is_mutable()
|
||||
{
|
||||
$this->setPermalink('woman-clothing');
|
||||
$this->getPermalink()->shouldReturn('woman-clothing');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue