Skip to content
This repository has been archived by the owner. It is now read-only.

Allow to change default translation model namespace from config file #508

Merged
merged 5 commits into from Aug 7, 2018

Conversation

@ahmed-aliraqi
Copy link
Contributor

commented Aug 6, 2018

No description provided.

.gitignore Outdated
@@ -1,3 +1,4 @@
.idea/

This comment has been minimized.

Copy link
@Gummibeer

Gummibeer Aug 6, 2018

Collaborator

This isn't project related and should be done in your local global .gitignore file.
https://stackoverflow.com/a/7335487/4907524

*/
public function getTranslationModelNamespace()
{
return config('translatable.translation_model_namespace', 'App');

This comment has been minimized.

Copy link
@Gummibeer

Gummibeer Aug 6, 2018

Collaborator

This changes the default logic and is BC.
I won't merge this feature if it's BC because it's too specific.

To solve this the default config value should be null als fallback it should use the namespace of get_class().

Atm it will also work, by default, if model namespace is moved into App\Models or anywhere else. After this change I have to adjust the config to keep this running. That's why I want to keep the default behavior and just add the option to adjust the namespace.

| application, set this to 'App\Translations'.
|
*/
'translation_model_namespace' => 'App',

This comment has been minimized.

Copy link
@Gummibeer

Gummibeer Aug 6, 2018

Collaborator

Should be null by default

|
| Defines the default 'Translation' class namespace. For example, if
| you want to use App\Translations\CountryTranslation instead of App\CountryTranslation
| application, set this to 'App\Translations'.

This comment has been minimized.

Copy link
@Gummibeer

Gummibeer Aug 6, 2018

Collaborator

application doesn't makes sense here!?

@@ -23,6 +23,8 @@ public function setUp()
parent::setUp();
App::make('config')->set('translatable.translation_model_namespace', 'Dimsav\Translatable\Test\Model');

This comment has been minimized.

Copy link
@Gummibeer

Gummibeer Aug 6, 2018

Collaborator

I know that it's in a lot of places in unittests but can you please switch to $this->app->make('config') instead of the Facade.

@@ -16,6 +16,15 @@ public function test_it_finds_the_default_translation_class()
$country->getTranslationModelNameDefault());
}
public function test_it_finds_the_translation_class_with_namespace_set()
{
App::make('config')->set('translatable.translation_model_namespace', 'App\Models\Translations');

This comment has been minimized.

Copy link
@Gummibeer

Gummibeer Aug 6, 2018

Collaborator

$this->app->make('config')

@ahmed-aliraqi

This comment has been minimized.

Copy link
Contributor Author

commented Aug 6, 2018

thanks @Gummibeer 👍

@Gummibeer Gummibeer added the feature label Aug 6, 2018

@Gummibeer

This comment has been minimized.

Copy link
Collaborator

commented Aug 6, 2018

If @dimsav approves this I will put it into v9.1.0 #509

@dimsav

This comment has been minimized.

Copy link
Owner

commented Aug 6, 2018

@Gummibeer sure
Nice work @ahmed-aliraqi !

@Gummibeer

This comment has been minimized.

Copy link
Collaborator

commented Aug 6, 2018

Will merge this tomorrow, add it to changelog and release v9.1.0 after a long time as next Minor release! 😊🎉

@Gummibeer Gummibeer merged commit b1aa31a into dimsav:master Aug 7, 2018

1 check passed

continuous-integration/styleci/pr The analysis has passed
Details

Gummibeer added a commit that referenced this pull request Aug 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.