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
241
Issues
241
List
Boards
Labels
Service Desk
Milestones
Merge Requests
31
Merge Requests
31
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
Compare Revisions
43da7da4122d1b787dc36b17d1a219407777d0a8...555d3a4fcceb9bfe6a9d7e86feecf59a5664eecb
Source
555d3a4fcceb9bfe6a9d7e86feecf59a5664eecb
Select Git revision
...
Target
43da7da4122d1b787dc36b17d1a219407777d0a8
Select Git revision
Compare
Commits (3)
(feat) Tidy interface of PropogateProperties class to a single public function -
#616
· 66727176
Guy Thouret
authored
2 hours ago
66727176
(feat) Refactor code that is propagating properties into the propagation framework -
#616
· 7cea5cdd
Guy Thouret
authored
1 hour ago
7cea5cdd
(chore) Remove duplicate doc blocks for methods that already have their own doc blocks -
#616
· 555d3a4f
Guy Thouret
authored
1 hour ago
555d3a4f
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
169 additions
and
123 deletions
+169
-123
PropogateProperties.php
Core/Blogs/Delegates/PropogateProperties.php
+1
-1
Manager.php
Core/Blogs/Manager.php
+1
-1
Save.php
Core/Entities/Actions/Save.php
+0
-2
PropogateProperties.php
Core/Entities/Delegates/PropogateProperties.php
+27
-0
PropogateProperties.php
Core/Entities/PropogateProperties.php
+14
-4
PropogateProperties.php
Core/Feeds/Delegates/PropogateProperties.php
+27
-0
Manager.php
Core/Feeds/Firehose/Manager.php
+9
-25
PropogateProperties.php
Core/Media/Delegates/PropogateProperties.php
+28
-0
UpdateActivities.php
Core/Media/Delegates/UpdateActivities.php
+0
-39
Feeds.php
Core/Media/Feeds.php
+5
-7
PropogateProperties.php
Core/Permissions/Delegates/PropogateProperties.php
+21
-0
Manager.php
Core/Permissions/Manager.php
+15
-36
Activity.php
Entities/Activity.php
+21
-0
File.php
Entities/File.php
+0
-8
No files found.
Core/Blogs/Delegates/Propogate
Blog
Properties.php
→
Core/Blogs/Delegates/PropogateProperties.php
View file @
555d3a4f
...
...
@@ -5,7 +5,7 @@ namespace Minds\Core\Blogs\Delegates;
use
Minds\Core\Entities\Propogator\Properties
;
use
Minds\Entities\Activity
;
class
Propogate
Blog
Properties
extends
Properties
class
PropogateProperties
extends
Properties
{
protected
$actsOnSubtype
=
'blog'
;
...
...
This diff is collapsed.
Click to expand it.
Core/Blogs/Manager.php
View file @
555d3a4f
...
...
@@ -178,7 +178,7 @@ class Manager
}
$this
->
paywallReview
->
queue
(
$blog
);
$this
->
propogateProperties
->
toActivities
(
$blog
);
$this
->
propogateProperties
->
from
(
$blog
);
}
return
$saved
;
...
...
This diff is collapsed.
Click to expand it.
Core/Entities/Actions/Save.php
View file @
555d3a4f
...
...
@@ -14,8 +14,6 @@ use Minds\Helpers\MagicAttributes;
/**
* Save Action
* @method Save setEntity($entity)
* @method bool save(...$args)
*/
class
Save
{
...
...
This diff is collapsed.
Click to expand it.
Core/Entities/Delegates/PropogateProperties.php
0 → 100644
View file @
555d3a4f
<?php
namespace
Minds\Core\Entities\Delegates
;
use
Minds\Core\Entities\Propogator\Properties
;
use
Minds\Entities\Activity
;
class
PropogateProperties
extends
Properties
{
public
function
toActivity
(
$from
,
Activity
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
getNsfw
(),
$to
->
getNsfw
()))
$to
->
setNsfw
(
$from
->
getNsfw
());
if
(
$this
->
valueHasChanged
(
$from
->
getNsfwLock
(),
$to
->
getNsfwLock
()))
$to
->
setNsfwLock
(
$from
->
getNsfwLock
());
}
public
function
fromActivity
(
Activity
$from
,
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
getNsfw
(),
$to
->
getNsfw
()))
$to
->
setNsfw
(
$from
->
getNsfw
());
if
(
$this
->
valueHasChanged
(
$from
->
getNsfwLock
(),
$to
->
getNsfwLock
()))
$to
->
setNsfwLock
(
$from
->
getNsfwLock
());
}
}
This diff is collapsed.
Click to expand it.
Core/Entities/PropogateProperties.php
View file @
555d3a4f
...
...
@@ -2,13 +2,13 @@
namespace
Minds\Core\Entities
;
use
Minds\Core\Blogs\Delegates\PropogateBlogProperties
;
use
Minds\Core\Data\Call
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Entities\Actions\Save
;
use
Minds\Core\Entities\Propogator\Properties
;
use
Minds\Core\EntitiesBuilder
;
use
Minds\Entities\Activity
;
use
Minds\Core
;
class
PropogateProperties
{
...
...
@@ -34,7 +34,9 @@ class PropogateProperties
protected
function
registerPropogators
()
:
void
{
/* Register PropertyPropogator classes here */
$this
->
addPropogator
(
PropogateBlogProperties
::
class
);
$this
->
addPropogator
(
Core\Blogs\Delegates\PropogateProperties
::
class
);
$this
->
addPropogator
(
Core\Feeds\Delegates\PropogateProperties
::
class
);
$this
->
addPropogator
(
Core\Media\Delegates\PropogateProperties
::
class
);
}
protected
function
addPropogator
(
string
$class
)
:
void
...
...
@@ -46,7 +48,15 @@ class PropogateProperties
$this
->
propogators
[]
=
$obj
;
}
public
function
fromActivity
(
Activity
$activity
)
:
void
public
function
from
(
$entity
)
:
void
{
if
(
$entity
instanceof
Activity
)
$this
->
fromActivity
(
$entity
);
else
$this
->
toActivities
(
$entity
);
}
protected
function
fromActivity
(
Activity
$activity
)
:
void
{
$this
->
changed
=
false
;
$attachment
=
$this
->
entitiesBuilder
->
single
(
$activity
->
get
(
'entity_guid'
));
...
...
@@ -65,7 +75,7 @@ class PropogateProperties
}
}
p
ublic
function
toActivities
(
$entity
)
:
void
p
rotected
function
toActivities
(
$entity
)
:
void
{
$activities
=
$this
->
getActivitiesForEntity
(
$entity
->
getGuid
());
foreach
(
$activities
as
$activity
)
{
...
...
This diff is collapsed.
Click to expand it.
Core/Feeds/Delegates/PropogateProperties.php
0 → 100644
View file @
555d3a4f
<?php
namespace
Minds\Core\Feeds\Delegates
;
use
Minds\Core\Entities\Propogator\Properties
;
use
Minds\Entities\Activity
;
class
PropogateProperties
extends
Properties
{
public
function
toActivity
(
$from
,
Activity
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
getModeratorGuid
(),
$to
->
getModeratorGuid
()))
$to
->
setModeratorGuid
(
$from
->
getModeratorGuid
());
if
(
$this
->
valueHasChanged
(
$from
->
getTimeModerated
(),
$to
->
getModeratorGuid
()))
$to
->
setTimeModerated
(
$from
->
getTimeModerated
());
}
public
function
fromActivity
(
Activity
$from
,
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
getModeratorGuid
(),
$to
->
getModeratorGuid
()))
$to
->
setModeratorGuid
(
$from
->
getModeratorGuid
());
if
(
$this
->
valueHasChanged
(
$from
->
getTimeModerated
(),
$to
->
getModeratorGuid
()))
$to
->
setTimeModerated
(
$from
->
getTimeModerated
());
}
}
This diff is collapsed.
Click to expand it.
Core/Feeds/Firehose/Manager.php
View file @
555d3a4f
...
...
@@ -2,6 +2,7 @@
namespace
Minds\Core\Feeds\Firehose
;
use
Minds\Entities\Activity
;
use
Minds\Entities\User
;
use
Minds\Entities\Entity
;
use
Minds\Core\EntitiesBuilder
;
...
...
@@ -9,6 +10,7 @@ use Minds\Core\Data\Call;
use
Minds\Core\Entities\Actions\Save
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Feeds\Top\Manager
as
TopFeedsManager
;
use
Minds\Core\Entities\PropogateProperties
;
class
Manager
{
...
...
@@ -16,25 +18,21 @@ class Manager
protected
$topFeedsManager
;
/** @var ModerationCache */
protected
$moderationCache
;
/** @var EntitiesBuilder $entitiesBuilder */
protected
$entitiesBuilder
;
/** @var Call */
protected
$db
;
/** @var Save */
protected
$save
;
/** @var PropogateProperties */
protected
$propogateProperties
;
public
function
__construct
(
TopFeedsManager
$topFeedsManager
=
null
,
ModerationCache
$moderationCache
=
null
,
EntitiesBuilder
$entitiesBuilder
=
null
,
Call
$db
=
null
,
Save
$save
=
null
Save
$save
=
null
,
PropogateProperties
$propogateProperties
=
null
)
{
$this
->
topFeedsManager
=
$topFeedsManager
?:
Di
::
_
()
->
get
(
'Feeds\Top\Manager'
);
$this
->
moderationCache
=
$moderationCache
?:
new
ModerationCache
();
$this
->
entitiesBuilder
=
$entitiesBuilder
?:
Di
::
_
()
->
get
(
'EntitiesBuilder'
);
$this
->
db
=
$db
?:
new
Call
(
'entities_by_time'
);
$this
->
save
=
$save
?:
new
Save
();
//Mockable, else instantiate a new one on save.
$this
->
propogateProperties
=
$propogateProperties
??
Di
::
_
()
->
get
(
'PropogateProperties'
);
}
/**
...
...
@@ -79,7 +77,7 @@ class Manager
* Marks an entity as moderated.
*
* @param $entity the entity to mark as moderated, typeless because images do not inherit entity
* @param User $
use
r the moderator
* @param User $
moderato
r the moderator
* @param int $time
*/
public
function
save
(
...
...
@@ -91,22 +89,8 @@ class Manager
$time
=
time
();
}
//Save the entity
$this
->
saveEntity
(
$entity
,
$moderator
,
$time
);
if
(
method_exists
(
$entity
,
'getType'
)
&&
$entity
->
getType
()
==
'activity'
&&
$entity
->
get
(
'entity_guid'
)
)
{
$attachment
=
$this
->
entitiesBuilder
->
single
(
$entity
->
get
(
'entity_guid'
));
$this
->
saveEntity
(
$attachment
,
$moderator
,
$time
);
}
//Moderate parents
foreach
(
$this
->
db
->
getRow
(
'activity:entitylink:'
.
$entity
->
getGUID
())
as
$parentGuid
=>
$ts
)
{
$activity
=
$this
->
entitiesBuilder
->
single
(
$parentGuid
);
$this
->
saveEntity
(
$activity
,
$moderator
,
$time
);
}
$this
->
propogateProperties
->
from
(
$entity
);
}
private
function
saveEntity
(
...
...
This diff is collapsed.
Click to expand it.
Core/Media/Delegates/PropogateProperties.php
0 → 100644
View file @
555d3a4f
<?php
namespace
Minds\Core\Media\Delegates
;
use
Minds\Core\Entities\Propogator\Properties
;
use
Minds\Entities\Activity
;
class
PropogateProperties
extends
Properties
{
protected
$actsOnType
=
'object'
;
protected
$actsOnSubtype
=
[
'image'
,
'video'
];
public
function
toActivity
(
$from
,
Activity
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
title
,
$to
->
getMessage
()))
$to
->
setMessage
(
$from
->
title
);
$fromData
=
$from
->
getActivityParameters
();
$toData
=
$to
->
getCustom
();
if
(
$this
->
valueHasChanged
(
$fromData
[
1
],
$toData
[
1
]))
$to
->
setCustom
(
$fromData
[
0
],
$fromData
[
1
]);
}
public
function
fromActivity
(
Activity
$from
,
&
$to
)
:
void
{
// TODO: Implement fromActivity() method.
}
}
This diff is collapsed.
Click to expand it.
Core/Media/Delegates/UpdateActivities.php
deleted
100644 → 0
View file @
43da7da4
<?php
/**
* @author: eiennohi.
*/
namespace
Minds\Core\Media\Delegates
;
use
Minds\Core\Data\Call
;
use
Minds\Entities\Image
;
use
Minds\Entities\Video
;
class
UpdateActivities
{
/** @var Call */
private
$indexDb
;
private
$entityDb
;
public
function
__construct
(
$indexDb
=
null
,
$entityDb
=
null
)
{
$this
->
indexDb
=
$indexDb
?:
new
Call
(
'entities_by_time'
);
$this
->
entityDb
=
$entityDb
?:
new
Call
(
'entities'
);
}
/**
* @param Image|Video $entity
*/
public
function
updateActivities
(
$entity
)
{
foreach
(
$this
->
indexDb
->
getRow
(
"activity:entitylink:
{
$entity
->
guid
}
"
)
as
$guid
=>
$ts
)
{
$this
->
entityDb
->
insert
(
$guid
,
[
'message'
=>
$entity
->
title
]);
$parameters
=
$entity
->
getActivityParameters
();
$this
->
entityDb
->
insert
(
$guid
,
[
'custom_type'
=>
$parameters
[
0
]]);
$this
->
entityDb
->
insert
(
$guid
,
[
'custom_data'
=>
json_encode
(
$parameters
[
1
])]);
}
}
}
This diff is collapsed.
Click to expand it.
Core/Media/Feeds.php
View file @
555d3a4f
...
...
@@ -5,17 +5,15 @@ namespace Minds\Core\Media;
use
Minds\Core
;
use
Minds\Entities
;
use
Minds\Helpers
;
use
Minds\Core\Media
;
class
Feeds
{
private
$updateActivitiesDelegate
;
protected
$entity
;
protected
$propogateProperties
;
public
function
__construct
(
$updateActivitiesDelegate
=
null
)
public
function
__construct
(
Core\Entities\PropogateProperties
$propogateProperties
=
null
)
{
$this
->
updateActivitiesDelegate
=
$updateActivitiesDelegate
?:
new
Delegates\UpdateActivities
(
);
$this
->
propogateProperties
=
$propogateProperties
??
Core\Di\Di
::
_
()
->
get
(
'PropogateProperties'
);
}
public
function
setEntity
(
$entity
)
...
...
@@ -25,7 +23,7 @@ class Feeds
return
$this
;
}
public
function
createActivity
()
public
function
createActivity
()
:
Entities\Activity
{
if
(
!
$this
->
entity
)
{
throw
new
\Exception
(
'Entity not set'
);
...
...
@@ -54,7 +52,7 @@ class Feeds
throw
new
\Exception
(
'Entity not set'
);
}
$this
->
updateActivitiesDelegate
->
updateActivities
(
$this
->
entity
);
$this
->
propogateProperties
->
from
(
$this
->
entity
);
}
public
function
dispatch
(
array
$targets
=
[])
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Delegates/PropogateProperties.php
0 → 100644
View file @
555d3a4f
<?php
namespace
Minds\Core\Permissions
;
use
Minds\Core\Entities\Propogator\Properties
;
use
Minds\Entities\Activity
;
class
PropogateProperties
extends
Properties
{
public
function
toActivity
(
$from
,
Activity
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
getAllowComments
(),
$to
->
getAllowComments
()))
$to
->
setAllowComments
(
$from
->
getAllowComments
());
}
public
function
fromActivity
(
Activity
$from
,
&
$to
)
:
void
{
if
(
$this
->
valueHasChanged
(
$from
->
getAllowComments
(),
$to
->
getAllowComments
()))
$to
->
setAllowComments
(
$from
->
getAllowComments
());
}
}
This diff is collapsed.
Click to expand it.
Core/Permissions/Manager.php
View file @
555d3a4f
...
...
@@ -3,36 +3,32 @@
namespace
Minds\Core\Permissions
;
use
Minds\Core\Di\Di
;
use
Minds\Core\EntitiesBuilder
;
use
Minds\Core\Data\Call
;
use
Minds\Core\Entities\Actions\Save
;
use
Minds\
Core\Permissions\Permissions
;
use
Minds\
Exceptions\StopEventException
;
class
Manager
{
/** @var EntitiesBuilder $entitiesBuilder */
protected
$entitiesBuilder
;
/** @var Call */
protected
$db
;
/** @var Save */
protected
$save
;
/** @var \Minds\Core\Entities\PropogateProperties */
protected
$propogateProperties
;
public
function
__construct
(
EntitiesBuilder
$entitiesBuilder
=
null
,
Call
$db
=
null
,
Save
$save
=
null
)
Save
$save
=
null
,
\Minds\Core\Entities\PropogateProperties
$propogateProperties
=
null
)
{
$this
->
entitiesBuilder
=
$entitiesBuilder
?:
Di
::
_
()
->
get
(
'EntitiesBuilder'
);
$this
->
db
=
$db
?:
new
Call
(
'entities_by_time'
);
$this
->
save
=
$save
?:
new
Save
();
//Mockable, else instantiate a new one on save.
$this
->
save
=
$save
?:
new
Save
();
$this
->
propogateProperties
=
$propogateProperties
??
Di
::
_
()
->
get
(
'PropogateProperties'
);
}
/**
* Save permissions for an entity and propegate it to linked objects
* @param mixed $entity a minds entity that implements the save function
* @param Permissions $permissions the flag to apply to the entity
*/
/**
* Save permissions for an entity and propagate it to linked objects
* @param mixed $entity a minds entity that implements the save function
* @param Permissions $permissions the flag to apply to the entity
* @throws StopEventException
*/
public
function
save
(
$entity
,
Permissions
$permissions
)
{
$entity
->
setAllowComments
(
$permissions
->
getAllowComments
());
...
...
@@ -41,23 +37,6 @@ class Manager
->
setEntity
(
$entity
)
->
save
();
if
(
method_exists
(
$entity
,
'getType'
)
&&
$entity
->
getType
()
==
'activity'
&&
$entity
->
get
(
'entity_guid'
)
)
{
$attachment
=
$this
->
entitiesBuilder
->
single
(
$entity
->
get
(
'entity_guid'
));
$attachment
->
setAllowComments
(
$permissions
->
getAllowComments
());
$this
->
save
->
setEntity
(
$attachment
)
->
save
();
}
foreach
(
$this
->
db
->
getRow
(
'activity:entitylink:'
.
$entity
->
getGUID
())
as
$parentGuid
=>
$ts
)
{
$activity
=
$this
->
entitiesBuilder
->
single
(
$parentGuid
);
$activity
->
setAllowComments
(
$permissions
->
getAllowComments
());
$this
->
save
->
setEntity
(
$activity
)
->
save
();
}
$this
->
propogateProperties
->
from
(
$entity
);
}
}
This diff is collapsed.
Click to expand it.
Entities/Activity.php
View file @
555d3a4f
...
...
@@ -334,6 +334,15 @@ class Activity extends Entity
return
$this
;
}
/**
* Set the message
* @return string
*/
public
function
getMessage
()
:
string
{
return
$this
->
message
;
}
/**
* Sets the title
* @param string $title
...
...
@@ -431,6 +440,18 @@ class Activity extends Entity
return
$this
;
}
/**
* Get the custom data
* @return array
*/
public
function
getCustom
()
:
array
{
return
[
$this
->
custom_type
,
$this
->
custom_data
];
}
/**
* Set the to_guid
* @param int $guid
...
...
This diff is collapsed.
Click to expand it.
Entities/File.php
View file @
555d3a4f
...
...
@@ -8,14 +8,6 @@ use Minds\Interfaces\Flaggable;
* File Entity
* @todo Do not inherit from ElggFile
* @package Minds\Entities\File
* @method array getExportableValues()
* @method mixed|null getFlag(string $flag)
* @method File setFlag(string $flag, mixed $value)
* @method void save(bool $index)
* @method array getWireTotals()
* @method mixed getWireThreshold()
* @method File setWireThreshold(int $wire_threshold)
* @method int getModeratorGUID()
*/
class
File
extends
\ElggFile
implements
Flaggable
{
...
...
This diff is collapsed.
Click to expand it.