Skip to content

Commit

Permalink
Do not auto-align assignments to the right-most level (#114)
Browse files Browse the repository at this point in the history
* Standardize on a single space after assignments.
Do not auto-align equal signs in assignment statements to the right-most subsequent one.
Also, do not right-align associative arrays.

* autoformat operator spacing

* Revert "autoformat operator spacing"

This reverts commit e8c4f34.

* reapply the results of composer phpcs-fix

* Fix alignment

---------

Co-authored-by: chriszarate <[email protected]>
  • Loading branch information
jblz and chriszarate authored Oct 28, 2024
1 parent 589820c commit 4a35702
Show file tree
Hide file tree
Showing 78 changed files with 894 additions and 882 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
class InteractivityStore {
public static function get_map_interactive_context( WP_Block $block ): array {
$query_context = [
'blockName' => $block->context[ BlockBindings::$context_name ]['blockName'],
'blockName' => $block->context[ BlockBindings::$context_name ]['blockName'],
'queryInput' => $block->context[ BlockBindings::$context_name ]['queryInput'],
];
$response = BlockBindings::execute_query( $query_context, 'GET Map Coordinates' );
$coordinates = array_map( function ( $value ) {
$response = BlockBindings::execute_query( $query_context, 'GET Map Coordinates' );
$coordinates = array_map( function ( $value ) {
$result = $value['result'];
return [
'name' => $result['map_name']['value'],
'x' => $result['x']['value'],
'y' => $result['y']['value'],
'x' => $result['x']['value'],
'y' => $result['y']['value'],
];
}, $response['results'] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public function get_input_schema(): array {

public function get_output_schema(): array {
return [
'root_path' => '$.records[*]',
'root_path' => '$.records[*]',
'is_collection' => true,
'mappings' => [
'id' => [
'mappings' => [
'id' => [
'name' => 'Location ID',
'path' => '$.id',
'type' => 'id',
Expand All @@ -28,17 +28,17 @@ public function get_output_schema(): array {
'path' => '$.fields.Name',
'type' => 'string',
],
'title' => [
'title' => [
'name' => 'Name',
'path' => '$.fields.Name',
'type' => 'string',
],
'x' => [
'x' => [
'name' => 'x',
'path' => '$.fields.x',
'type' => 'string',
],
'y' => [
'y' => [
'name' => 'y',
'path' => '$.fields.y',
'type' => 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public function get_input_schema(): array {

public function get_output_schema(): array {
return [
'root_path' => '$.records[*]',
'root_path' => '$.records[*]',
'is_collection' => true,
'mappings' => [
'id' => [
'mappings' => [
'id' => [
'name' => 'Map ID',
'path' => '$.id',
'type' => 'id',
Expand Down
6 changes: 3 additions & 3 deletions example/airtable/elden-ring-map/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
require_once __DIR__ . '/inc/queries/class-airtable-elden-ring-list-maps-query.php';

function register_airtable_elden_ring_map_block() {
$block_name = 'Elden Ring Location';
$block_name = 'Elden Ring Location';
$access_token = \RemoteDataBlocks\Example\get_access_token( 'airtable_elden_ring' );

if ( empty( $access_token ) ) {
Expand All @@ -20,8 +20,8 @@ function register_airtable_elden_ring_map_block() {
}

$elden_ring_data_source = AirtableDataSource::create( $access_token, 'appqI3sJ9R2NcML8Y', [], 'Elden Ring Locations' );
$list_locations_query = new AirtableEldenRingListLocationsQuery( $elden_ring_data_source );
$list_maps_query = new AirtableEldenRingListMapsQuery( $elden_ring_data_source );
$list_locations_query = new AirtableEldenRingListLocationsQuery( $elden_ring_data_source );
$list_maps_query = new AirtableEldenRingListMapsQuery( $elden_ring_data_source );

register_remote_data_block( $block_name, $list_locations_query );
register_remote_data_list_query( $block_name, $list_maps_query );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ class AirtableGetEventQuery extends HttpQueryContext {
public function get_input_schema(): array {
return [
'record_id' => [
'name' => 'Record ID',
'name' => 'Record ID',
'overrides' => [
[
'target' => 'utm_content',
'type' => 'query_var',
'type' => 'query_var',
],
],
'type' => 'id',
'type' => 'id',
],
];
}

public function get_output_schema(): array {
return [
'is_collection' => false,
'mappings' => [
'id' => [
'mappings' => [
'id' => [
'name' => 'Record ID',
'path' => '$.id',
'type' => 'id',
],
'title' => [
'title' => [
'name' => 'Title',
'path' => '$.fields.Activity',
'type' => 'string',
Expand All @@ -39,7 +39,7 @@ public function get_output_schema(): array {
'path' => '$.fields.Location',
'type' => 'string',
],
'type' => [
'type' => [
'name' => 'Type',
'path' => '$.fields.Type',
'type' => 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
class AirtableListEventsQuery extends HttpQueryContext {
public function get_output_schema(): array {
return [
'root_path' => '$.records[*]',
'root_path' => '$.records[*]',
'is_collection' => true,
'mappings' => [
'mappings' => [
'record_id' => [
'name' => 'Record ID',
'path' => '$.id',
'type' => 'id',
],
'title' => [
'title' => [
'name' => 'Title',
'path' => '$.fields.Activity',
'type' => 'string',
],
'location' => [
'location' => [
'name' => 'Location',
'path' => '$.fields.Location',
'type' => 'string',
],
'type' => [
'type' => [
'name' => 'Type',
'path' => '$.fields.Type',
'type' => 'string',
Expand Down
6 changes: 3 additions & 3 deletions example/airtable/events/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
require_once __DIR__ . '/inc/queries/class-airtable-list-events-query.php';

function register_airtable_events_block() {
$block_name = 'Conference Event';
$block_name = 'Conference Event';
$access_token = \RemoteDataBlocks\Example\get_access_token( 'airtable_events' );

$airtable_data_source = AirtableDataSource::create( $access_token, 'appVQ2PAl95wQSo9S', [], 'Conference Events' );
$airtable_get_event_query = new AirtableGetEventQuery( $airtable_data_source );
$airtable_data_source = AirtableDataSource::create( $access_token, 'appVQ2PAl95wQSo9S', [], 'Conference Events' );
$airtable_get_event_query = new AirtableGetEventQuery( $airtable_data_source );
$airtable_list_events_query = new AirtableListEventsQuery( $airtable_data_source );

register_remote_data_block( $block_name, $airtable_get_event_query );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public function get_input_schema(): array {
'name' => 'File Path',
'type' => 'string',
],
'sha' => [
'sha' => [
'name' => 'SHA',
'type' => 'string',
],
'size' => [
'size' => [
'name' => 'Size',
'type' => 'number',
],
'url' => [
'url' => [
'name' => 'URL',
'type' => 'string',
],
Expand All @@ -29,28 +29,28 @@ public function get_input_schema(): array {
public function get_output_schema(): array {
return [
'is_collection' => false,
'mappings' => [
'mappings' => [
'file_content' => [
'name' => 'File Content',
'path' => '$.content',
'type' => 'html',
],
'file_path' => [
'file_path' => [
'name' => 'File Path',
'path' => '$.path',
'type' => 'string',
],
'sha' => [
'sha' => [
'name' => 'SHA',
'path' => '$.sha',
'type' => 'string',
],
'size' => [
'size' => [
'name' => 'Size',
'path' => '$.size',
'type' => 'number',
],
'url' => [
'url' => [
'name' => 'URL',
'path' => '$.url',
'type' => 'string',
Expand Down Expand Up @@ -80,11 +80,11 @@ public function get_request_headers( array $input_variables ): array {

public function process_response( string $html_response_data, array $input_variables ): array {
return [
'content' => $html_response_data,
'content' => $html_response_data,
'file_path' => $input_variables['file_path'],
'sha' => $input_variables['sha'],
'size' => $input_variables['size'],
'url' => $input_variables['url'],
'sha' => $input_variables['sha'],
'size' => $input_variables['size'],
'url' => $input_variables['url'],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ public function get_input_schema(): array {

public function get_output_schema(): array {
return [
'root_path' => sprintf( '$.tree[?(@.path =~ /\\.%s$/)]', ltrim( $this->file_extension, '.' ) ),
'root_path' => sprintf( '$.tree[?(@.path =~ /\\.%s$/)]', ltrim( $this->file_extension, '.' ) ),
'is_collection' => true,
'mappings' => [
'mappings' => [
'file_path' => [
'name' => 'File Path',
'path' => '$.path',
'type' => 'string',
],
'sha' => [
'sha' => [
'name' => 'SHA',
'path' => '$.sha',
'type' => 'string',
],
'size' => [
'size' => [
'name' => 'Size',
'path' => '$.size',
'type' => 'number',
],
'url' => [
'url' => [
'name' => 'URL',
'path' => '$.url',
'type' => 'string',
Expand Down
8 changes: 4 additions & 4 deletions example/github/remote-data-blocks/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

function register_github_file_as_html_block() {
$repo_owner = 'Automattic';
$repo_name = 'remote-data-blocks';
$branch = 'trunk';
$repo_name = 'remote-data-blocks';
$branch = 'trunk';

$block_name = sprintf( 'GitHub File As HTML (%s/%s)', $repo_owner, $repo_name );

$github_data_source = GitHubDataSource::create( $repo_owner, $repo_name, $branch );
$github_data_source = GitHubDataSource::create( $repo_owner, $repo_name, $branch );
$github_get_file_as_html_query = new GitHubGetFileAsHtmlQuery( $github_data_source );
$github_get_list_files_query = new GitHubListFilesQuery( $github_data_source, '.md' );
$github_get_list_files_query = new GitHubListFilesQuery( $github_data_source, '.md' );

register_remote_data_block( $block_name, $github_get_file_as_html_query );
register_remote_data_list_query( $block_name, $github_get_list_files_query );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,43 @@ class GetWesterosHousesQuery extends HttpQueryContext {
public function get_input_schema(): array {
return [
'row_id' => [
'name' => 'Row ID',
'name' => 'Row ID',
'overrides' => [
[
'target' => 'utm_content',
'type' => 'query_var',
'type' => 'query_var',
],
],
'type' => 'id',
'type' => 'id',
],
];
}

public function get_output_schema(): array {
return [
'is_collection' => false,
'mappings' => [
'row_id' => [
'mappings' => [
'row_id' => [
'name' => 'Row ID',
'path' => '$.RowId',
'type' => 'id',
],
'house' => [
'house' => [
'name' => 'House',
'path' => '$.House',
'type' => 'string',
],
'seat' => [
'seat' => [
'name' => 'Seat',
'path' => '$.Seat',
'type' => 'string',
],
'region' => [
'region' => [
'name' => 'Region',
'path' => '$.Region',
'type' => 'string',
],
'words' => [
'words' => [
'name' => 'Words',
'path' => '$.Words',
'type' => 'string',
Expand All @@ -72,14 +72,14 @@ public function get_endpoint( array $input_variables ): string {

public function process_response( string $raw_response_data, array $input_variables ): string|array|object|null {
$parsed_response_data = json_decode( $raw_response_data, true );
$selected_row = null;
$row_id = $input_variables['row_id'];
$selected_row = null;
$row_id = $input_variables['row_id'];

if ( isset( $parsed_response_data['values'] ) && is_array( $parsed_response_data['values'] ) ) {
$raw_selected_row = $parsed_response_data['values'][ $row_id ];
if ( is_array( $raw_selected_row ) ) {
$selected_row = array_combine( self::COLUMNS, $raw_selected_row );
$selected_row = array_combine( self::COLUMNS, $selected_row );
$selected_row = array_combine( self::COLUMNS, $raw_selected_row );
$selected_row = array_combine( self::COLUMNS, $selected_row );
$selected_row['RowId'] = $row_id;
}
}
Expand Down
Loading

0 comments on commit 4a35702

Please sign in to comment.