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
f592b7cc
Unverified
Commit
f592b7cc
authored
Sep 18, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding method to mark all given pageid as offline
parent
5aed1196
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
0 deletions
+68
-0
CachePageDecorator.php
Modules/Page/Repositories/Cache/CachePageDecorator.php
+11
-0
EloquentPageRepository.php
...les/Page/Repositories/Eloquent/EloquentPageRepository.php
+16
-0
PageRepository.php
Modules/Page/Repositories/PageRepository.php
+6
-0
EloquentPageRepositoryTest.php
Modules/Page/Tests/EloquentPageRepositoryTest.php
+35
-0
No files found.
Modules/Page/Repositories/Cache/CachePageDecorator.php
View file @
f592b7cc
...
...
@@ -101,4 +101,15 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
$this
->
markAsOnlineInAllLocales
(
$pageId
);
}
/**
* @param int $pageId
* @return mixed
*/
public
function
markAsOfflineInAllLocales
(
int
$pageId
)
{
$this
->
clearCache
();
$this
->
markAsOfflineInAllLocales
(
$pageId
);
}
}
Modules/Page/Repositories/Eloquent/EloquentPageRepository.php
View file @
f592b7cc
...
...
@@ -188,4 +188,20 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
return
$this
->
update
(
$page
,
$data
);
}
/**
* @param int $pageId
* @return mixed
*/
public
function
markAsOfflineInAllLocales
(
int
$pageId
)
{
$page
=
$this
->
find
(
$pageId
);
$data
=
[];
foreach
(
app
(
LaravelLocalization
::
class
)
->
getSupportedLocales
()
as
$locale
=>
$supportedLocale
)
{
$data
[
$locale
]
=
[
'status'
=>
0
];
}
return
$this
->
update
(
$page
,
$data
);
}
}
Modules/Page/Repositories/PageRepository.php
View file @
f592b7cc
...
...
@@ -39,4 +39,10 @@ interface PageRepository extends BaseRepository
* @return mixed
*/
public
function
markAsOnlineInAllLocales
(
int
$pageId
);
/**
* @param int $pageId
* @return mixed
*/
public
function
markAsOfflineInAllLocales
(
int
$pageId
);
}
Modules/Page/Tests/EloquentPageRepositoryTest.php
View file @
f592b7cc
...
...
@@ -199,6 +199,17 @@ class EloquentPageRepositoryTest extends BasePageTest
$this
->
assertTrue
(
$page
->
translate
(
'fr'
)
->
status
);
}
/** @test */
public
function
it_can_mark_page_as_offline_in_all_locales
()
{
$page
=
$this
->
createRandomOnlinePage
();
$page
=
$this
->
page
->
markAsOfflineInAllLocales
(
$page
->
id
);
$this
->
assertFalse
(
$page
->
translate
(
'en'
)
->
status
);
$this
->
assertFalse
(
$page
->
translate
(
'fr'
)
->
status
);
}
private
function
createPage
()
{
return
$this
->
page
->
create
([
...
...
@@ -235,4 +246,28 @@ class EloquentPageRepositoryTest extends BasePageTest
return
$this
->
page
->
create
(
$data
);
}
private
function
createRandomOnlinePage
()
{
$faker
=
\Faker\Factory
::
create
();
$data
=
[
'is_home'
=>
0
,
'template'
=>
'default'
,
'en'
=>
[
'status'
=>
1
,
'title'
=>
$faker
->
name
,
'slug'
=>
$faker
->
slug
,
'body'
=>
$faker
->
paragraph
(),
],
'fr'
=>
[
'status'
=>
1
,
'title'
=>
$faker
->
name
,
'slug'
=>
$faker
->
slug
,
'body'
=>
$faker
->
paragraph
(),
],
];
return
$this
->
page
->
create
(
$data
);
}
}
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