Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
b2ac7514
Unverified
Commit
b2ac7514
authored
Oct 16, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Generating hooking into the loading of translations for VueJs
parent
895aa02b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
0 deletions
+25
-0
EntityGenerator.php
...s/Workshop/Scaffold/Module/Generators/EntityGenerator.php
+13
-0
module-service-provider.stub
...rkshop/Scaffold/Module/stubs/module-service-provider.stub
+5
-0
translations-append.stub
...s/Workshop/Scaffold/Module/stubs/translations-append.stub
+2
-0
ModuleScaffoldTest.php
Modules/Workshop/Tests/ModuleScaffoldTest.php
+5
-0
No files found.
Modules/Workshop/Scaffold/Module/Generators/EntityGenerator.php
View file @
b2ac7514
...
...
@@ -63,6 +63,7 @@ class EntityGenerator extends Generator
$this
->
appendResourceRoutesToRoutesFileFor
(
$entity
);
$this
->
appendPermissionsFor
(
$entity
);
$this
->
appendSidebarLinksFor
(
$entity
);
$this
->
appendBackendTranslations
(
$entity
);
}
}
...
...
@@ -242,6 +243,18 @@ class EntityGenerator extends Generator
$this
->
finder
->
put
(
$this
->
getModulesPath
(
"Events/Handlers/Register
{
$this
->
name
}
Sidebar.php"
),
$sidebarComposerContent
);
}
/**
* @param string $entity
*/
private
function
appendBackendTranslations
(
$entity
)
{
$moduleProviderContent
=
$this
->
finder
->
get
(
$this
->
getModulesPath
(
"Providers/
{
$this
->
name
}
ServiceProvider.php"
));
$translations
=
$this
->
getContentForStub
(
'translations-append.stub'
,
$entity
);
$moduleProviderContent
=
str_replace
(
'// append translations'
,
$translations
,
$moduleProviderContent
);
$this
->
finder
->
put
(
$this
->
getModulesPath
(
"Providers/
{
$this
->
name
}
ServiceProvider.php"
),
$moduleProviderContent
);
}
/**
* Generate a filled sidebar view composer
* Or an empty one of no entities
...
...
Modules/Workshop/Scaffold/Module/stubs/module-service-provider.stub
View file @
b2ac7514
...
...
@@ -5,6 +5,7 @@ namespace Modules\$MODULE$\Providers;
use
Illuminate\Support\ServiceProvider
;
use
Modules\Core\Traits\CanPublishConfiguration
;
use
Modules\Core\Events\BuildingSidebar
;
use
Modules\Core\Events\LoadingBackendTranslations
;
use
Modules
\
$MODULE
$
\Events\Handlers
\
$SIDEBAR_LISTENER_NAME
$
;
class
$
MODULE
$ServiceProvider
extends
ServiceProvider
...
...
@@ -26,6 +27,10 @@ class $MODULE$ServiceProvider extends ServiceProvider
{
$this
->
registerBindings
();
$this
->
app
[
'events'
]
->
listen
(
BuildingSidebar
::
class
,
$SIDEBAR_LISTENER_NAME
$
::
class
);
$this
->
app
[
'events'
]
->
listen
(
LoadingBackendTranslations
::
class
,
function
(
LoadingBackendTranslations
$event
)
{
// append translations
});
}
public
function
boot
()
...
...
Modules/Workshop/Scaffold/Module/stubs/translations-append.stub
0 → 100644
View file @
b2ac7514
$event->load('$PLURAL_LOWERCASE_CLASS_NAME$', array_dot(trans('$LOWERCASE_MODULE_NAME$::$PLURAL_LOWERCASE_CLASS_NAME$')));
// append translations
Modules/Workshop/Tests/ModuleScaffoldTest.php
View file @
b2ac7514
...
...
@@ -287,6 +287,11 @@ class ModuleScaffoldTest extends BaseTestCase
'$this->app[\'events\']->listen(BuildingSidebar::class, '
.
$sidebarEventListenerName
.
'::class);'
),
'Sidebar event handler was not present'
);
$this
->
assertTrue
(
str_contains
(
$file
,
'$this->app[\'events\']->listen(LoadingBackendTranslations::class,'
),
'Translations registering was not present'
);
$this
->
cleanUp
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment