remove experiment with chaining in the generic setter from the VSEL transformer
This commit is contained in:
parent
ebc8bd4b37
commit
812cbca546
1 changed files with 31 additions and 76 deletions
|
@ -171,82 +171,37 @@ class VS_Event_List extends Event_Transformer {
|
||||||
return $summary;
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Generic setter.
|
// * Transform the WordPress Object into an ActivityPub Object.
|
||||||
*
|
// *
|
||||||
* @param string $key The key to set.
|
// * @return Activitypub\Activity\Event
|
||||||
* @param string $value The value to set.
|
// */
|
||||||
*
|
// public function to_object() {
|
||||||
* @return mixed The value.
|
|
||||||
*/
|
|
||||||
public function set( $key, $value ) {
|
|
||||||
|
|
||||||
if ( ! $this->ap_object->has( $key ) ) {
|
// $this->ap_object = new Event();
|
||||||
return new WP_Error( 'invalid_key', __( 'Invalid key', 'activitypub' ), array( 'status' => 404 ) );
|
// $this->ap_object = parent::to_object();
|
||||||
}
|
|
||||||
|
// $this
|
||||||
$setter_function = 'set_' . $key;
|
// ->set_content()
|
||||||
$getter_function = 'get_' . $key;
|
// ->set_replies()
|
||||||
|
// ->set_content_map()
|
||||||
if ( in_array( $getter_function, get_class_methods( $this ), true ) ) {
|
// ->set_attributed_to()
|
||||||
$this->ap_object->$setter_function( $this->$getter_function() );
|
// ->set_published()
|
||||||
} else {
|
// ->set_start_time()
|
||||||
$this->ap_object->$setter_function( $value );
|
// ->set_end_time()
|
||||||
}
|
// ->set_type()
|
||||||
|
// ->set_category()
|
||||||
return $this;
|
// ->set_attachment()
|
||||||
}
|
// ->set_comments_enabled( true )
|
||||||
|
// ->set_external_participation_url( $this->get_url() )
|
||||||
/**
|
// ->set_status( 'CONFIRMED' )
|
||||||
* Magic function to implement setter
|
// ->set_name( get_the_title( $this->wp_object->ID ) )
|
||||||
*
|
// ->set_is_online( false )
|
||||||
* @param string $method The method name.
|
// ->set_in_language( $this->get_locale() )
|
||||||
* @param string $params The method params.
|
// ->set_actor()
|
||||||
*
|
// ->set_to( array( 'https://www.w3.org/ns/activitystreams#Public' ) )
|
||||||
* @return void|this
|
// ->set_location()
|
||||||
*/
|
// ->set_id();
|
||||||
public function __call( $method, $params ) {
|
// return $this->ap_object;
|
||||||
|
// }
|
||||||
$var = \strtolower( \substr( $method, 4 ) );
|
|
||||||
|
|
||||||
if ( \strncasecmp( $method, 'set', 3 ) === 0 ) {
|
|
||||||
return $this->set( $var, $params[0] );
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: When do we need: call_user_func( array( $activitypub_object, $setter ), $value ).
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the WordPress Object into an ActivityPub Object.
|
|
||||||
*
|
|
||||||
* @return Activitypub\Activity\Event
|
|
||||||
*/
|
|
||||||
public function to_object() {
|
|
||||||
|
|
||||||
$this->ap_object = new Event();
|
|
||||||
|
|
||||||
$this
|
|
||||||
->set_content()
|
|
||||||
->set_content_map()
|
|
||||||
->set_attributed_to()
|
|
||||||
->set_published()
|
|
||||||
->set_start_time()
|
|
||||||
->set_end_time()
|
|
||||||
->set_type()
|
|
||||||
->set_category()
|
|
||||||
->set_attachment()
|
|
||||||
->set_comments_enabled( true )
|
|
||||||
->set_external_participation_url( $this->get_url() )
|
|
||||||
->set_status( 'CONFIRMED' )
|
|
||||||
->set_name( get_the_title( $this->wp_object->ID ) )
|
|
||||||
->set_is_online( false )
|
|
||||||
->set_in_language( $this->get_locale() )
|
|
||||||
->set_actor()
|
|
||||||
->set_to( array( 'https://www.w3.org/ns/activitystreams#Public' ) )
|
|
||||||
->set_location()
|
|
||||||
->set_id();
|
|
||||||
return $this->ap_object;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue