Skip to content

Commit

Permalink
Merge pull request Sylius#7346 from NeverResponse/locale/remove-toggl…
Browse files Browse the repository at this point in the history
…eability

[Locale] Removed enable/disable functionality
  • Loading branch information
michalmarcinkowski committed Jan 31, 2017
2 parents 6999e13 + 1f45982 commit b703c99
Show file tree
Hide file tree
Showing 57 changed files with 76 additions and 682 deletions.
2 changes: 2 additions & 0 deletions UPGRADE.md
Expand Up @@ -80,6 +80,8 @@ After:

### Locale / LocaleBundle

* `Locale` model's `$enabled` field has been removed along with all logic depending on it.

### Mailer / MailerBundle

### MoneyBundle
Expand Down
34 changes: 34 additions & 0 deletions app/migrations/Version20170124221955.php
@@ -0,0 +1,34 @@
<?php

namespace Sylius\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20170124221955 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE sylius_locale DROP enabled');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE sylius_locale ADD enabled TINYINT(1) NOT NULL');
}
}
4 changes: 2 additions & 2 deletions docs/book/configuration/locales.rst
Expand Up @@ -51,7 +51,7 @@ The locale context can be injected into any of your services and give you access
Available Locales Provider
--------------------------

The Locale Provider service (``sylius.locale_provider``) is responsible for returning all languages available for the current user. By default, it filters out all disabled locales.
The Locale Provider service (``sylius.locale_provider``) is responsible for returning all languages available for the current user. By default, returns all configured locales.
You can easily modify this logic by overriding this service.

.. code-block:: php
Expand All @@ -67,7 +67,7 @@ You can easily modify this logic by overriding this service.
}
}
To get all languages configured in the store, including the disabled ones, use the locales repository:
To get all languages configured in the store, regardless of your availability logic, use the locales repository:

.. code-block:: php
Expand Down
2 changes: 1 addition & 1 deletion docs/components/Locale/basic_usage.rst
Expand Up @@ -21,7 +21,7 @@ The **LocaleProvider** allows you to get all available locales.
$localeProvider = new LocaleProvider($locales);
$localeProvider->getAvailableLocalesCodes() //Output will be a collection of all enabled locales
$localeProvider->getAvailableLocalesCodes() //Output will be a collection of available locales
$localeProvider->isLocaleAvailable('en') //It will check if that locale is enabled
.. note::
Expand Down
4 changes: 2 additions & 2 deletions docs/components/Locale/interfaces.rst
Expand Up @@ -12,8 +12,8 @@ LocaleInterface
This interface should be implemented by models representing a single **Locale**.

.. note::
This interface extends :ref:`component_resource_model_code-aware-interface`,
:ref:`component_resource_model_timestampable-interface` and :ref:`component_resource_model_toggleable-interface`.
This interface extends :ref:`component_resource_model_code-aware-interface` and
:ref:`component_resource_model_timestampable-interface`.

For more detailed information go to `Sylius API LocaleInterface`_.

Expand Down
2 changes: 0 additions & 2 deletions docs/components/Locale/models.rst
Expand Up @@ -17,8 +17,6 @@ Locale has the following properties:
+-------------+-----------------------------------------+
| code | Locale's code |
+-------------+-----------------------------------------+
| enabled | Indicates whether locale is available |
+-------------+-----------------------------------------+
| createdAt | Date when locale was created |
+-------------+-----------------------------------------+
| updatedAt | Date of last change |
Expand Down
15 changes: 4 additions & 11 deletions features/admin/switching_admins_locale.feature
Expand Up @@ -6,9 +6,8 @@ Feature: Switching locales on admin's panel

Background:
Given the store operates on a single channel
And that channel allows to shop using "English (United States)", "Spanish (Mexico)" and "Portuguese (Brazil)" locales
And that channel allows to shop using "English (United States)" and "Spanish (Mexico)" locales
And it uses the "English (United States)" locale by default
And the locale "Portuguese (Brazil)" is disabled
And I am logged in as an administrator
And I am using "English (United States)" locale for my panel

Expand All @@ -18,12 +17,6 @@ Feature: Switching locales on admin's panel
When I set my locale to "Spanish (Mexico)"
Then I should be viewing the administration panel in "Spanish (Mexico)"

@ui
Scenario: Admin's panel can be viewed in a disabled locale
Given I am editing my details
When I set my locale to "Portuguese (Brazil)"
Then I should be viewing the administration panel in "Portuguese (Brazil)"

@ui
Scenario: Changing my preferred language to a locale that does not exist in the store
Given the locale "French (France)" does not exist in the store
Expand All @@ -34,7 +27,7 @@ Feature: Switching locales on admin's panel
@ui
Scenario: Changing panel's locale doesn't change shop's locale
Given I am editing my details
When I set my locale to "Portuguese (Brazil)"
When I set my locale to "Spanish (Mexico)"
Then I should still shop using the "English (United States)" locale

@ui
Expand All @@ -47,6 +40,6 @@ Feature: Switching locales on admin's panel
Scenario: Locales are saved per each admin's preference
Given I am using "Spanish (Mexico)" locale for my panel
And there is an administrator "admin@example.com" identified by "sylius"
And this administrator is using "Portuguese (Brazil)" locale
And this administrator is using "French (France)" locale
When this administrator logs in using "sylius" password
Then they should be viewing the administration panel in "Portuguese (Brazil)"
Then they should be viewing the administration panel in "French (France)"
Expand Up @@ -16,10 +16,3 @@ Feature: Channel independent translatable entities locales
When I want to create a new translatable entity
Then I should be able to translate it in "English (United States)"
And I should be able to translate it in "German (Germany)"

@ui
Scenario: Using all locales to translate an entity
Given the store has disabled locale "Polish (Poland)"
When I want to create a new translatable entity
Then I should be able to translate it in "English (United States)"
And I should be able to translate it in "Polish (Poland)"
38 changes: 0 additions & 38 deletions features/locale/handling_disabled_locales.feature

This file was deleted.

26 changes: 0 additions & 26 deletions features/locale/managing_locales/editing_locale.feature

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions features/locale/managing_locales/toggling_locale.feature

This file was deleted.

13 changes: 0 additions & 13 deletions src/Sylius/Behat/Context/Setup/LocaleContext.php
Expand Up @@ -91,19 +91,6 @@ public function theStoreHasLocale($localeCode)
$this->saveLocale($locale);
}

/**
* @Given the store has disabled locale :localeCode
* @Given the locale :localeCode is disabled (as well)
* @Given the locale :localeCode gets disabled
*/
public function theStoreHasDisabledLocale($localeCode)
{
$locale = $this->provideLocale($localeCode);
$locale->disable();

$this->saveLocale($locale);
}

/**
* @Given the locale :localeCode does not exist in the store
*/
Expand Down

0 comments on commit b703c99

Please sign in to comment.