moved getting EM event into constructor

This commit is contained in:
ruru4143 2024-09-29 13:56:17 +02:00
parent 9be7cb2ce2
commit 1b4642d92e

View file

@ -36,6 +36,20 @@ final class Events_Manager extends Event_Transformer {
*/
protected $em_event;
/**
* Extend the constructor, to also set the Eventsmanager objects.
*
* This is a special class object form The Events Calendar which
* has a lot of useful functions, we make use of our getter functions.
*
* @param WP_Post $wp_object The WordPress object.
* @param string $wp_taxonomy The taxonomy slug of the event post type.
*/
public function __construct( $wp_object, $wp_taxonomy ) {
parent::__construct( $wp_object, $wp_taxonomy );
$this->em_event = new EM_Event( $this->wp_object->ID, 'post_id' );
}
/**
* Returns whether the even is online
*
@ -225,12 +239,7 @@ final class Events_Manager extends Event_Transformer {
* @return Activitypub\Activity\Event
*/
public function to_object(): Event {
$this->em_event = new EM_Event( $this->wp_object->ID, 'post_id' );
$activitypub_object = new Event();
$activitypub_object = $this->transform_object_properties( $activitypub_object );
$activitypub_object->set_external_participation_url( $this->get_url() );
$activitypub_object = parent::to_object();
return $activitypub_object;
}