@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | private $term_converter; |
| 36 | 36 | |
| 37 | - public function __construct( $main_jsonld, $post_converter, $term_converter ) { |
|
| 37 | + public function __construct($main_jsonld, $post_converter, $term_converter) { |
|
| 38 | 38 | $this->main_jsonld = $main_jsonld; |
| 39 | 39 | $this->post_converter = $post_converter; |
| 40 | 40 | $this->term_converter = $term_converter; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function set_main_jsonld( $main_jsonld ) { |
|
| 43 | + public function set_main_jsonld($main_jsonld) { |
|
| 44 | 44 | $this->main_jsonld = $main_jsonld; |
| 45 | 45 | } |
| 46 | 46 | |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return Graph |
| 55 | 55 | */ |
| 56 | - public function add_references( $refs ) { |
|
| 57 | - Assertions::is_array( $refs ); |
|
| 56 | + public function add_references($refs) { |
|
| 57 | + Assertions::is_array($refs); |
|
| 58 | 58 | |
| 59 | - foreach ( $refs as $ref ) { |
|
| 60 | - $this->referenced_content_ids[] = Wordpress_Content_Id::create_post( $ref ); |
|
| 59 | + foreach ($refs as $ref) { |
|
| 60 | + $this->referenced_content_ids[] = Wordpress_Content_Id::create_post($ref); |
|
| 61 | 61 | } |
| 62 | 62 | return $this; |
| 63 | 63 | } |
@@ -73,22 +73,22 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return Graph |
| 75 | 75 | */ |
| 76 | - public function add_required_reference_infos( $references_infos ) { |
|
| 76 | + public function add_required_reference_infos($references_infos) { |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @var $required_references array<\Wordlift_Property_Entity_Reference> |
| 80 | 80 | */ |
| 81 | 81 | $required_references = array_filter( |
| 82 | 82 | $references_infos, |
| 83 | - function ( $item ) { |
|
| 84 | - return isset( $item['reference'] ) && |
|
| 83 | + function($item) { |
|
| 84 | + return isset($item['reference']) && |
|
| 85 | 85 | $item['reference'] instanceof \Wordlift_Property_Entity_Reference && |
| 86 | 86 | // Check that the reference is required |
| 87 | 87 | $item['reference']->get_required(); |
| 88 | 88 | } |
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | - foreach ( $required_references as $data ) { |
|
| 91 | + foreach ($required_references as $data) { |
|
| 92 | 92 | $required_reference = $data['reference']; |
| 93 | 93 | $this->referenced_content_ids[] = new Wordpress_Content_Id( |
| 94 | 94 | $required_reference->get_id(), |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return Graph |
| 106 | 106 | */ |
| 107 | - public function add_relations( $relations ) { |
|
| 107 | + public function add_relations($relations) { |
|
| 108 | 108 | |
| 109 | - foreach ( $relations->toArray() as $relation ) { |
|
| 109 | + foreach ($relations->toArray() as $relation) { |
|
| 110 | 110 | |
| 111 | 111 | $this->referenced_content_ids[] = $relation->get_object(); |
| 112 | 112 | |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | * @param $context int |
| 123 | 123 | * @return array|bool |
| 124 | 124 | */ |
| 125 | - private function expand( $content_id, $context ) { |
|
| 125 | + private function expand($content_id, $context) { |
|
| 126 | 126 | $object_id = $content_id->get_id(); |
| 127 | 127 | $object_type = $content_id->get_type(); |
| 128 | 128 | |
| 129 | - if ( $object_type === Object_Type_Enum::POST ) { |
|
| 130 | - return $this->expand_post( $object_id ); |
|
| 131 | - } elseif ( $object_type === Object_Type_Enum::TERM ) { |
|
| 132 | - return $this->expand_term( $object_id, $context ); |
|
| 129 | + if ($object_type === Object_Type_Enum::POST) { |
|
| 130 | + return $this->expand_post($object_id); |
|
| 131 | + } elseif ($object_type === Object_Type_Enum::TERM) { |
|
| 132 | + return $this->expand_term($object_id, $context); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | return false; |
@@ -141,22 +141,22 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @return array |
| 143 | 143 | */ |
| 144 | - public function render( $context ) { |
|
| 144 | + public function render($context) { |
|
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * This is possible because the toString() method of |
| 148 | 148 | * Wordpress_Content_Id is used to get the unique value. |
| 149 | 149 | */ |
| 150 | - $unique_content_ids = array_unique( $this->referenced_content_ids, SORT_STRING ); |
|
| 150 | + $unique_content_ids = array_unique($this->referenced_content_ids, SORT_STRING); |
|
| 151 | 151 | |
| 152 | - $result = array( $this->main_jsonld ); |
|
| 152 | + $result = array($this->main_jsonld); |
|
| 153 | 153 | |
| 154 | - foreach ( $unique_content_ids as $unique_content_id ) { |
|
| 155 | - $result[] = $this->expand( $unique_content_id, $context ); |
|
| 154 | + foreach ($unique_content_ids as $unique_content_id) { |
|
| 155 | + $result[] = $this->expand($unique_content_id, $context); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | // Filter out the false and empty results. |
| 159 | - return array_filter( $result ); |
|
| 159 | + return array_filter($result); |
|
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
@@ -165,11 +165,11 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return false|mixed |
| 167 | 167 | */ |
| 168 | - public function expand_post( $object_id ) { |
|
| 169 | - if ( get_post_status( $object_id ) !== 'publish' || \Wordlift_Entity_Type_Service::get_instance()->has_entity_type( |
|
| 168 | + public function expand_post($object_id) { |
|
| 169 | + if (get_post_status($object_id) !== 'publish' || \Wordlift_Entity_Type_Service::get_instance()->has_entity_type( |
|
| 170 | 170 | $object_id, |
| 171 | 171 | 'http://schema.org/Article' |
| 172 | - ) ) { |
|
| 172 | + )) { |
|
| 173 | 173 | return false; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $reference_info = array(); |
| 178 | 178 | $relations = new Relations(); |
| 179 | 179 | |
| 180 | - return $this->post_converter->convert( $object_id, $references, $reference_info, $relations ); |
|
| 180 | + return $this->post_converter->convert($object_id, $references, $reference_info, $relations); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -186,13 +186,13 @@ discard block |
||
| 186 | 186 | * |
| 187 | 187 | * @return false|mixed |
| 188 | 188 | */ |
| 189 | - public function expand_term( $object_id, $context ) { |
|
| 189 | + public function expand_term($object_id, $context) { |
|
| 190 | 190 | // Skip the Uncategorized term. |
| 191 | - if ( 1 === $object_id ) { |
|
| 191 | + if (1 === $object_id) { |
|
| 192 | 192 | return false; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - return current( $this->term_converter->get( $object_id, $context ) ); |
|
| 195 | + return current($this->term_converter->get($object_id, $context)); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | } |