Skip to content
Snippets Groups Projects
Commit 4aa3289c authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Typo + baseobject get automatically actors properties at first access attempt

parent b0cdc61f
Branches
Tags
No related merge requests found
......@@ -73,7 +73,7 @@ class Base
return $value;
if (array_key_exists('type', $value)) {
$type = '\\Patbator\\Activitystreams\\Model\\' . $value['type'];
$type = '\\Patbator\\ActivityStreams\\Model\\' . $value['type'];
$model = new $type();
unset($value['type']);
$model->fromArray($value);
......
......@@ -4,6 +4,8 @@ namespace Patbator\ActivityStreams\Model;
class BaseObject extends Base
{
protected $_actor_attribs;
public function __construct()
{
$this->_attribs = [
......@@ -39,17 +41,34 @@ class BaseObject extends Base
'mediaType' => null,
'duration' => null,
];
$this->_actor_attribs = [
'inbox', 'outbox', 'following', 'followers', 'liked',
'streams', 'preferredUsername', 'endpoints', 'proxyUrl',
'oautAuthorizationEndpoint', 'oauthTokenEndpoint',
'provideClientKey', 'signClientKey',
'sharedInbox'
];
}
public function __call($name, $args=[])
{
if (
in_array($name, $this->_actor_attribs)
&& !array_key_exists($name, $this->_attribs)
)
$this->asActor();
return parent::__call($name, $args);
}
public function asActor() {
foreach(['inbox', 'outbox', 'following', 'followers', 'liked',
'streams', 'preferredUsername', 'endpoints', 'proxyUrl',
'oautAuthorizationEndpoint', 'oauthTokenEndpoint',
'provideClientKey', 'signClientKey',
'sharedInbox'] as $attrib)
$this->_attribs[$attrib] = null;
public function asActor()
{
foreach($this->_actor_attribs as $attrib)
$this->_attribs[$attrib] = null;
return $this;
return $this;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment