-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into add/wp-phpunit-integration-tests
- Loading branch information
Showing
11 changed files
with
231 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
inc/Integrations/Google/Sheets/GoogleSheetsIntegration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace RemoteDataBlocks\Integrations\Google\Sheets; | ||
|
||
use RemoteDataBlocks\WpdbStorage\DataSourceCrud; | ||
|
||
class GoogleSheetsIntegration { | ||
public static function init(): void { | ||
add_action( 'init', [ __CLASS__, 'register_blocks' ], 10, 0 ); | ||
} | ||
|
||
public static function register_blocks(): void { | ||
$data_source_configs = DataSourceCrud::get_configs_by_service( | ||
REMOTE_DATA_BLOCKS_GOOGLE_SHEETS_SERVICE | ||
); | ||
|
||
foreach ( $data_source_configs as $config ) { | ||
$data_source = GoogleSheetsDataSource::from_array( $config ); | ||
self::register_block_for_google_sheets_data_source( $data_source ); | ||
self::register_loop_block_for_google_sheets_data_source( $data_source ); | ||
} | ||
} | ||
|
||
public static function register_block_for_google_sheets_data_source( | ||
GoogleSheetsDataSource $data_source, | ||
array $block_overrides = [] | ||
): void { | ||
register_remote_data_block( | ||
array_merge( | ||
[ | ||
'title' => $data_source->get_display_name(), | ||
'render_query' => [ | ||
'query' => $data_source->___temp_get_query(), | ||
], | ||
'selection_queries' => [ | ||
[ | ||
'query' => $data_source->___temp_get_list_query(), | ||
'type' => 'list', | ||
], | ||
], | ||
], | ||
$block_overrides | ||
) | ||
); | ||
} | ||
|
||
public static function register_loop_block_for_google_sheets_data_source( | ||
GoogleSheetsDataSource $data_source, | ||
array $block_overrides = [] | ||
): void { | ||
register_remote_data_block( | ||
array_merge( | ||
[ | ||
'title' => sprintf( '%s Loop', $data_source->get_display_name() ), | ||
'render_query' => [ | ||
'loop' => true, | ||
'query' => $data_source->___temp_get_list_query(), | ||
], | ||
], | ||
$block_overrides | ||
) | ||
); | ||
} | ||
} |
Oops, something went wrong.