hotfix: phpcs error: introduce getter function for wp_post in the transformer
Some checks failed
Unit Testing / phpunit (7.3) (push) Waiting to run
Unit Testing / phpunit (7.4) (push) Waiting to run
Unit Testing / phpunit (8.0) (push) Waiting to run
Unit Testing / phpunit (8.1) (push) Waiting to run
Unit Testing / phpunit (8.2) (push) Waiting to run
Unit Testing / phpunit (latest) (push) Waiting to run
PHP_CodeSniffer / phpcs (push) Successful in 4m19s
Unit Testing / phpunit (5.6, 6.2) (push) Failing after 4m26s
Unit Testing / phpunit (7.0) (push) Failing after 4m54s
Unit Testing / phpunit (7.2) (push) Has been cancelled
Some checks failed
Unit Testing / phpunit (7.3) (push) Waiting to run
Unit Testing / phpunit (7.4) (push) Waiting to run
Unit Testing / phpunit (8.0) (push) Waiting to run
Unit Testing / phpunit (8.1) (push) Waiting to run
Unit Testing / phpunit (8.2) (push) Waiting to run
Unit Testing / phpunit (latest) (push) Waiting to run
PHP_CodeSniffer / phpcs (push) Successful in 4m19s
Unit Testing / phpunit (5.6, 6.2) (push) Failing after 4m26s
Unit Testing / phpunit (7.0) (push) Failing after 4m54s
Unit Testing / phpunit (7.2) (push) Has been cancelled
This commit is contained in:
parent
225e06dfec
commit
1efbb4dcd0
2 changed files with 15 additions and 8 deletions
|
@ -28,6 +28,15 @@ abstract class Base {
|
||||||
*/
|
*/
|
||||||
protected $wp_post;
|
protected $wp_post;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter function for this wp_post.
|
||||||
|
*
|
||||||
|
* @return WP_post This WordPress Post object.
|
||||||
|
*/
|
||||||
|
protected function get_wp_post() {
|
||||||
|
return $this->wp_post;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign WP_Post Object to a specific transformer instance.
|
* Assign WP_Post Object to a specific transformer instance.
|
||||||
*
|
*
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Post extends Base {
|
||||||
return $object_type;
|
return $object_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the WP_Post object to an ActivityPub Object
|
* Transforms the WP_Post object to an ActivityPub Object
|
||||||
*
|
*
|
||||||
* @see \Activitypub\Activity\Base_Object
|
* @see \Activitypub\Activity\Base_Object
|
||||||
|
@ -116,20 +116,18 @@ class Post extends Base {
|
||||||
* @return \Activitypub\Activity\Base_Object The ActivityPub Object
|
* @return \Activitypub\Activity\Base_Object The ActivityPub Object
|
||||||
*/
|
*/
|
||||||
public function transform() {
|
public function transform() {
|
||||||
if ( ! $this->wp_post ) {
|
$object = new Base_Objet();
|
||||||
return;
|
$wp_post = $this->get_wp_post();
|
||||||
}
|
|
||||||
$object = new Base_Object();
|
|
||||||
|
|
||||||
$object->set_id( $this->get_id() );
|
$object->set_id( $this->get_id() );
|
||||||
$object->set_url( $this->get_url() );
|
$object->set_url( $this->get_url() );
|
||||||
$object->set_type( $this->get_object_type() );
|
$object->set_type( $this->get_object_type() );
|
||||||
|
|
||||||
$published = \strtotime( $this->$wp_post->post_date_gmt );
|
$published = \strtotime( $wp_post->post_date_gmt );
|
||||||
|
|
||||||
$object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) );
|
$object->set_published( \gmdate( 'Y-m-d\TH:i:s\Z', $published ) );
|
||||||
|
|
||||||
$updated = \strtotime( $this->$wp_post->post_modified_gmt );
|
$updated = \strtotime( $wp_post->post_modified_gmt );
|
||||||
|
|
||||||
if ( $updated > $published ) {
|
if ( $updated > $published ) {
|
||||||
$object->set_updated( \gmdate( 'Y-m-d\TH:i:s\Z', $updated ) );
|
$object->set_updated( \gmdate( 'Y-m-d\TH:i:s\Z', $updated ) );
|
||||||
|
@ -138,7 +136,7 @@ class Post extends Base {
|
||||||
$object->set_attributed_to( $this->get_attributed_to() );
|
$object->set_attributed_to( $this->get_attributed_to() );
|
||||||
$object->set_content( $this->get_content() );
|
$object->set_content( $this->get_content() );
|
||||||
$object->set_content_map( $this->get_content_map );
|
$object->set_content_map( $this->get_content_map );
|
||||||
$path = sprintf( 'users/%d/followers', intval( $this->$wp_post->post_author ) );
|
$path = sprintf( 'users/%d/followers', intval( $wp_post->post_author ) );
|
||||||
|
|
||||||
$object->set_to(
|
$object->set_to(
|
||||||
array(
|
array(
|
||||||
|
|
Loading…
Reference in a new issue