WIP
This commit is contained in:
parent
6c6d9076a8
commit
d9a1beae5c
2 changed files with 14 additions and 6 deletions
|
@ -93,6 +93,12 @@ class Event extends Base_Object {
|
||||||
*/
|
*/
|
||||||
protected $status;
|
protected $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO this seems to not be a default property of an Object but needed by mobilizon TODO:
|
||||||
|
*/
|
||||||
|
protected $actor;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @context https://joinmobilizon.org/ns#externalParticipationUrl
|
* @context https://joinmobilizon.org/ns#externalParticipationUrl
|
||||||
* @var string
|
* @var string
|
||||||
|
|
|
@ -10,9 +10,12 @@ use Activitypub\Transformer\Attachment;
|
||||||
*/
|
*/
|
||||||
class Factory {
|
class Factory {
|
||||||
const DEFAULT_TRANSFORMER_MAPPING = array(
|
const DEFAULT_TRANSFORMER_MAPPING = array(
|
||||||
'post' => 'activitypub/post',
|
'WP_Post' => array(
|
||||||
'page' => 'activitypub/post',
|
'post' => 'activitypub/post',
|
||||||
'attachment' => 'activitypub/attachment',
|
'page' => 'activitypub/post',
|
||||||
|
'attachment' => 'activitypub/attachment',
|
||||||
|
),
|
||||||
|
'WP_Comment' => 'activitypub/comment'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -252,7 +255,7 @@ class Factory {
|
||||||
return $transformer;
|
return $transformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use default transformer
|
// Use the built-in transformers.
|
||||||
switch ( get_class( $object ) ) {
|
switch ( get_class( $object ) ) {
|
||||||
case 'WP_Post':
|
case 'WP_Post':
|
||||||
if ( 'attachment' === $object->post_type ) {
|
if ( 'attachment' === $object->post_type ) {
|
||||||
|
@ -283,13 +286,12 @@ class Factory {
|
||||||
case 'WP_Post':
|
case 'WP_Post':
|
||||||
$post_type = get_post_type( $object );
|
$post_type = get_post_type( $object );
|
||||||
$transformer_mapping = \get_option( 'activitypub_transformer_mapping', self::DEFAULT_TRANSFORMER_MAPPING );
|
$transformer_mapping = \get_option( 'activitypub_transformer_mapping', self::DEFAULT_TRANSFORMER_MAPPING );
|
||||||
$transformer_name = $transformer_mapping[ $post_type ];
|
$transformer_name = $transformer_mapping[ 'WP_Post' ][ $post_type ];
|
||||||
if ( $transformer_name ) {
|
if ( $transformer_name ) {
|
||||||
$transformer_class = $this->get_transformer_class( $transformer_name );
|
$transformer_class = $this->get_transformer_class( $transformer_name );
|
||||||
} else {
|
} else {
|
||||||
return self::get_default_transformer( $object );
|
return self::get_default_transformer( $object );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $transformer_class ) {
|
if ( $transformer_class ) {
|
||||||
return new $transformer_class( $object );
|
return new $transformer_class( $object );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue