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
15be04b5
Unverified
Commit
15be04b5
authored
Sep 18, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding method to mark multiple pages as online/offline
parent
9d5bcad6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
18 deletions
+75
-18
CachePageDecorator.php
Modules/Page/Repositories/Cache/CachePageDecorator.php
+29
-6
EloquentPageRepository.php
...les/Page/Repositories/Eloquent/EloquentPageRepository.php
+27
-8
PageRepository.php
Modules/Page/Repositories/PageRepository.php
+19
-4
No files found.
Modules/Page/Repositories/Cache/CachePageDecorator.php
View file @
15be04b5
...
@@ -5,6 +5,7 @@ namespace Modules\Page\Repositories\Cache;
...
@@ -5,6 +5,7 @@ namespace Modules\Page\Repositories\Cache;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Modules\Core\Repositories\Cache\BaseCacheDecorator
;
use
Modules\Core\Repositories\Cache\BaseCacheDecorator
;
use
Modules\Page\Entities\Page
;
use
Modules\Page\Repositories\PageRepository
;
use
Modules\Page\Repositories\PageRepository
;
class
CachePageDecorator
extends
BaseCacheDecorator
implements
PageRepository
class
CachePageDecorator
extends
BaseCacheDecorator
implements
PageRepository
...
@@ -92,24 +93,46 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
...
@@ -92,24 +93,46 @@ class CachePageDecorator extends BaseCacheDecorator implements PageRepository
}
}
/**
/**
* @param
int $pageId
* @param
Page $page
* @return mixed
* @return mixed
*/
*/
public
function
markAsOnlineInAllLocales
(
int
$pageId
)
public
function
markAsOnlineInAllLocales
(
Page
$page
)
{
{
$this
->
clearCache
();
$this
->
clearCache
();
return
$this
->
repository
->
markAsOnlineInAllLocales
(
$page
Id
);
return
$this
->
repository
->
markAsOnlineInAllLocales
(
$page
);
}
}
/**
/**
* @param
int $pageId
* @param
Page $page
* @return mixed
* @return mixed
*/
*/
public
function
markAsOfflineInAllLocales
(
int
$pageId
)
public
function
markAsOfflineInAllLocales
(
Page
$page
)
{
{
$this
->
clearCache
();
$this
->
clearCache
();
return
$this
->
repository
->
markAsOfflineInAllLocales
(
$pageId
);
return
$this
->
repository
->
markAsOfflineInAllLocales
(
$page
);
}
/**
* @param array $pageIds [int]
* @return mixed
*/
public
function
markMultipleAsOnlineInAllLocales
(
array
$pageIds
)
{
$this
->
clearCache
();
return
$this
->
repository
->
markMultipleAsOnlineInAllLocales
(
$pageIds
);
}
/**
* @param array $pageIds [int]
* @return mixed
*/
public
function
markMultipleAsOfflineInAllLocales
(
array
$pageIds
)
{
$this
->
clearCache
();
return
$this
->
repository
->
markMultipleAsOfflineInAllLocales
(
$pageIds
);
}
}
}
}
Modules/Page/Repositories/Eloquent/EloquentPageRepository.php
View file @
15be04b5
...
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Builder;
...
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Builder;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Mcamara\LaravelLocalization\LaravelLocalization
;
use
Mcamara\LaravelLocalization\LaravelLocalization
;
use
Modules\Core\Repositories\Eloquent\EloquentBaseRepository
;
use
Modules\Core\Repositories\Eloquent\EloquentBaseRepository
;
use
Modules\Page\Entities\Page
;
use
Modules\Page\Events\PageIsCreating
;
use
Modules\Page\Events\PageIsCreating
;
use
Modules\Page\Events\PageIsUpdating
;
use
Modules\Page\Events\PageIsUpdating
;
use
Modules\Page\Events\PageWasCreated
;
use
Modules\Page\Events\PageWasCreated
;
...
@@ -174,13 +175,11 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
...
@@ -174,13 +175,11 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
}
}
/**
/**
* @param
int $pageId
* @param
Page $page
* @return mixed
* @return mixed
*/
*/
public
function
markAsOnlineInAllLocales
(
int
$pageId
)
public
function
markAsOnlineInAllLocales
(
Page
$page
)
{
{
$page
=
$this
->
find
(
$pageId
);
$data
=
[];
$data
=
[];
foreach
(
app
(
LaravelLocalization
::
class
)
->
getSupportedLocales
()
as
$locale
=>
$supportedLocale
)
{
foreach
(
app
(
LaravelLocalization
::
class
)
->
getSupportedLocales
()
as
$locale
=>
$supportedLocale
)
{
$data
[
$locale
]
=
[
'status'
=>
1
];
$data
[
$locale
]
=
[
'status'
=>
1
];
...
@@ -190,13 +189,11 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
...
@@ -190,13 +189,11 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
}
}
/**
/**
* @param
int $pageId
* @param
Page $page
* @return mixed
* @return mixed
*/
*/
public
function
markAsOfflineInAllLocales
(
int
$pageId
)
public
function
markAsOfflineInAllLocales
(
Page
$page
)
{
{
$page
=
$this
->
find
(
$pageId
);
$data
=
[];
$data
=
[];
foreach
(
app
(
LaravelLocalization
::
class
)
->
getSupportedLocales
()
as
$locale
=>
$supportedLocale
)
{
foreach
(
app
(
LaravelLocalization
::
class
)
->
getSupportedLocales
()
as
$locale
=>
$supportedLocale
)
{
$data
[
$locale
]
=
[
'status'
=>
0
];
$data
[
$locale
]
=
[
'status'
=>
0
];
...
@@ -204,4 +201,26 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
...
@@ -204,4 +201,26 @@ class EloquentPageRepository extends EloquentBaseRepository implements PageRepos
return
$this
->
update
(
$page
,
$data
);
return
$this
->
update
(
$page
,
$data
);
}
}
/**
* @param array $pageIds [int]
* @return mixed
*/
public
function
markMultipleAsOnlineInAllLocales
(
array
$pageIds
)
{
foreach
(
$pageIds
as
$pageId
)
{
$this
->
markAsOnlineInAllLocales
(
$this
->
find
(
$pageId
));
}
}
/**
* @param array $pageIds [int]
* @return mixed
*/
public
function
markMultipleAsOfflineInAllLocales
(
array
$pageIds
)
{
foreach
(
$pageIds
as
$pageId
)
{
$this
->
markAsOfflineInAllLocales
(
$this
->
find
(
$pageId
));
}
}
}
}
Modules/Page/Repositories/PageRepository.php
View file @
15be04b5
...
@@ -5,6 +5,7 @@ namespace Modules\Page\Repositories;
...
@@ -5,6 +5,7 @@ namespace Modules\Page\Repositories;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Contracts\Pagination\LengthAwarePaginator
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Modules\Core\Repositories\BaseRepository
;
use
Modules\Core\Repositories\BaseRepository
;
use
Modules\Page\Entities\Page
;
interface
PageRepository
extends
BaseRepository
interface
PageRepository
extends
BaseRepository
{
{
...
@@ -35,14 +36,28 @@ interface PageRepository extends BaseRepository
...
@@ -35,14 +36,28 @@ interface PageRepository extends BaseRepository
public
function
serverPaginationFilteringFor
(
Request
$request
)
:
LengthAwarePaginator
;
public
function
serverPaginationFilteringFor
(
Request
$request
)
:
LengthAwarePaginator
;
/**
/**
* @param
int $pageId
* @param
Page $page
* @return mixed
* @return mixed
* @internal param int $pageId
*/
*/
public
function
markAsOnlineInAllLocales
(
int
$pageId
);
public
function
markAsOnlineInAllLocales
(
Page
$page
);
/**
/**
* @param
int $pageId
* @param
array $pageIds[int]
* @return mixed
* @return mixed
*/
*/
public
function
markAsOfflineInAllLocales
(
int
$pageId
);
public
function
markMultipleAsOnlineInAllLocales
(
array
$pageIds
);
/**
* @param Page $page
* @return mixed
* @internal param int $pageId
*/
public
function
markAsOfflineInAllLocales
(
Page
$page
);
/**
* @param array $pageIds[int]
* @return mixed
*/
public
function
markMultipleAsOfflineInAllLocales
(
array
$pageIds
);
}
}
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