Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
242
Issues
242
List
Boards
Labels
Service Desk
Milestones
Merge Requests
30
Merge Requests
30
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
43da7da4
Commit
43da7da4
authored
1 hour ago
by
Guy Thouret
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat) Pass the entity to be modified by reference to make interfaces cleaner -
#616
parent
f3ecf79a
chore/616-propogate-props
1 merge request
!303
WIP: Propogate Properties when entities get updated
Pipeline
#78721930
failed with stages
in 4 minutes and 10 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
14 deletions
+19
-14
PropogateBlogProperties.php
Core/Blogs/Delegates/PropogateBlogProperties.php
+3
-5
Manager.php
Core/Blogs/Manager.php
+9
-1
PropogateProperties.php
Core/Entities/PropogateProperties.php
+4
-6
Properties.php
Core/Entities/Propogator/Properties.php
+3
-2
No files found.
Core/Blogs/Delegates/PropogateBlogProperties.php
View file @
43da7da4
...
...
@@ -9,7 +9,7 @@ class PropogateBlogProperties extends Properties
{
protected
$actsOnSubtype
=
'blog'
;
public
function
toActivity
(
$from
,
Activity
$to
)
:
Activity
public
function
toActivity
(
$from
,
Activity
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
getTitle
(),
$to
->
get
(
'title'
)))
{
$to
->
set
(
'title'
,
$from
->
getTitle
());
...
...
@@ -27,12 +27,10 @@ class PropogateBlogProperties extends Properties
if
(
$this
->
valueHasChanged
(
$from
->
getIconUrl
(),
$to
->
get
(
'thumbnail_src'
)))
{
$to
->
set
(
'thumbnail_src'
,
$from
->
getIconUrl
());
}
return
$to
;
}
public
function
fromActivity
(
Activity
$from
,
$to
)
public
function
fromActivity
(
Activity
$from
,
&
$to
)
:
void
{
return
$to
;
// TODO: Implement fromActivity() method.
}
}
This diff is collapsed.
Click to expand it.
Core/Blogs/Manager.php
View file @
43da7da4
...
...
@@ -9,6 +9,7 @@
namespace
Minds\Core\Blogs
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Entities\PropogateProperties
;
use
Minds\Core\Security\Spam
;
class
Manager
...
...
@@ -31,6 +32,9 @@ class Manager
/** @var Delegates\Search */
protected
$search
;
/** @var PropogateProperties */
protected
$propogateProperties
;
/**
* Manager constructor.
* @param null $repository
...
...
@@ -39,6 +43,7 @@ class Manager
* @param null $feeds
* @param null $spam
* @param null $search
* @param PropogateProperties $propogateProperties
* @throws \Exception
*/
public
function
__construct
(
...
...
@@ -47,7 +52,8 @@ class Manager
$slug
=
null
,
$feeds
=
null
,
$spam
=
null
,
$search
=
null
$search
=
null
,
PropogateProperties
$propogateProperties
=
null
)
{
$this
->
repository
=
$repository
?:
new
Repository
();
...
...
@@ -56,6 +62,7 @@ class Manager
$this
->
feeds
=
$feeds
?:
new
Delegates\Feeds
();
$this
->
spam
=
$spam
?:
Di
::
_
()
->
get
(
'Security\Spam'
);
$this
->
search
=
$search
?:
new
Delegates\Search
();
$this
->
propogateProperties
=
$propogateProperties
??
Di
::
_
()
->
get
(
'PropogateProperties'
);
}
/**
...
...
@@ -171,6 +178,7 @@ class Manager
}
$this
->
paywallReview
->
queue
(
$blog
);
$this
->
propogateProperties
->
toActivities
(
$blog
);
}
return
$saved
;
...
...
This diff is collapsed.
Click to expand it.
Core/Entities/PropogateProperties.php
View file @
43da7da4
...
...
@@ -55,7 +55,7 @@ class PropogateProperties
foreach
(
$this
->
propogators
as
$propogator
)
{
if
(
$propogator
->
willActOnEntity
(
$attachment
))
{
$
attachment
=
$
propogator
->
fromActivity
(
$activity
,
$attachment
);
$propogator
->
fromActivity
(
$activity
,
$attachment
);
$this
->
changed
|=
$propogator
->
changed
();
}
}
...
...
@@ -69,7 +69,7 @@ class PropogateProperties
{
$activities
=
$this
->
getActivitiesForEntity
(
$entity
->
getGuid
());
foreach
(
$activities
as
$activity
)
{
$
activity
=
$
this
->
propogateToActivity
(
$entity
,
$activity
);
$this
->
propogateToActivity
(
$entity
,
$activity
);
if
(
$this
->
changed
)
{
$this
->
save
->
setEntity
(
$activity
)
->
save
();
}
...
...
@@ -91,16 +91,14 @@ class PropogateProperties
return
$activities
;
}
public
function
propogateToActivity
(
$entity
,
Activity
$activity
)
:
Activity
public
function
propogateToActivity
(
$entity
,
Activity
&
$activity
)
:
void
{
$this
->
changed
=
false
;
foreach
(
$this
->
propogators
as
$propogator
)
{
if
(
$propogator
->
willActOnEntity
(
$entity
))
{
$
activity
=
$
propogator
->
toActivity
(
$entity
,
$activity
);
$propogator
->
toActivity
(
$entity
,
$activity
);
$this
->
changed
|=
$propogator
->
changed
();
}
}
return
$activity
;
}
}
This diff is collapsed.
Click to expand it.
Core/Entities/Propogator/Properties.php
View file @
43da7da4
...
...
@@ -41,6 +41,7 @@ abstract class Properties
return
$this
->
changed
;
}
abstract
public
function
toActivity
(
$from
,
Activity
$to
)
:
Activity
;
abstract
public
function
fromActivity
(
Activity
$from
,
$to
);
abstract
public
function
toActivity
(
$from
,
Activity
&
$to
)
:
void
;
abstract
public
function
fromActivity
(
Activity
$from
,
&
$to
)
:
void
;
}
This diff is collapsed.
Click to expand it.
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