wp-pay-gateways /
mollie
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * CLI |
||
| 4 | * |
||
| 5 | * @author Pronamic <[email protected]> |
||
| 6 | * @copyright 2005-2020 Pronamic |
||
| 7 | * @license GPL-3.0-or-later |
||
| 8 | * @package Pronamic\WordPress\Pay\Mollie |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Pronamic\WordPress\Pay\Gateways\Mollie; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Title: CLI |
||
| 15 | * Description: |
||
| 16 | * Copyright: 2005-2020 Pronamic |
||
| 17 | * Company: Pronamic |
||
| 18 | * |
||
| 19 | * @author Remco Tolsma |
||
| 20 | * @version 3.0.0 |
||
| 21 | * @since 3.0.0 |
||
| 22 | * @link https://github.com/woocommerce/woocommerce/blob/3.9.0/includes/class-wc-cli.php |
||
| 23 | */ |
||
| 24 | class CLI { |
||
| 25 | /** |
||
| 26 | * Construct CLI. |
||
| 27 | */ |
||
| 28 | public function __construct() { |
||
| 29 | \WP_CLI::add_command( 'pronamic-pay mollie organizations synchronize', function( $args, $assoc_args ) { |
||
|
0 ignored issues
–
show
|
|||
| 30 | $this->wp_cli_organizations_synchronize( $args, $assoc_args ); |
||
| 31 | } ); |
||
| 32 | |||
| 33 | \WP_CLI::add_command( 'pronamic-pay mollie customers synchronize', function( $args, $assoc_args ) { |
||
| 34 | $this->wp_cli_customers_synchronize( $args, $assoc_args ); |
||
| 35 | } ); |
||
| 36 | |||
| 37 | \WP_CLI::add_command( 'pronamic-pay mollie customers connect-wp-users', function( $args, $assoc_args ) { |
||
| 38 | $this->wp_cli_customers_connect_wp_users( $args, $assoc_args ); |
||
| 39 | } ); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * CLI organizations synchronize. |
||
| 44 | * |
||
| 45 | * @link https://docs.mollie.com/reference/v2/organizations-api/current-organization |
||
| 46 | */ |
||
| 47 | public function wp_cli_organizations_synchronize( $args, $assoc_args ) { |
||
| 48 | \WP_CLI::error( 'Command not implemented yet.' ); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * CLI customers synchronize. |
||
| 53 | * |
||
| 54 | * @link https://docs.mollie.com/reference/v2/customers-api/list-customers |
||
| 55 | */ |
||
| 56 | public function wp_cli_customers_synchronize( $args, $assoc_args ) { |
||
| 57 | \WP_CLI::error( 'Command not implemented yet.' ); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * CLI connect Mollie customers to WordPress users. |
||
| 62 | * |
||
| 63 | * @link https://docs.mollie.com/reference/v2/customers-api/list-customers |
||
| 64 | * @link https://make.wordpress.org/cli/handbook/internal-api/wp-cli-add-command/ |
||
| 65 | * @link https://developer.wordpress.org/reference/classes/wpdb/query/ |
||
| 66 | * @param array $args Arguments. |
||
| 67 | * @param array $assoc_args Associative arguments. |
||
| 68 | */ |
||
| 69 | public function wp_cli_customers_connect_wp_users( $args, $assoc_args ) { |
||
| 70 | global $wpdb; |
||
| 71 | |||
| 72 | $query = " |
||
| 73 | INSERT IGNORE INTO $wpdb->pronamic_pay_mollie_customer_users ( |
||
| 74 | customer_id, |
||
| 75 | user_id |
||
| 76 | ) |
||
| 77 | SELECT |
||
| 78 | mollie_customer.id AS mollie_customer_id, |
||
| 79 | wp_user.ID AS wp_user_id |
||
| 80 | FROM |
||
| 81 | $wpdb->pronamic_pay_mollie_customers AS mollie_customer |
||
| 82 | INNER JOIN |
||
| 83 | $wpdb->users AS wp_user |
||
| 84 | ON mollie_customer.email = wp_user.user_email |
||
| 85 | ; |
||
| 86 | "; |
||
| 87 | |||
| 88 | $result = $wpdb->query( $query ); |
||
| 89 | |||
| 90 | if ( false === $result ) { |
||
| 91 | \WP_CLI::error( |
||
| 92 | sprintf( |
||
| 93 | 'Database error: %s.', |
||
| 94 | $wpdb->last_error |
||
| 95 | ) |
||
| 96 | ); |
||
| 97 | } |
||
| 98 | |||
| 99 | \WP_CLI::log( |
||
| 100 | sprintf( |
||
| 101 | 'Connected %d users and Mollie customers.', |
||
| 102 | $result |
||
| 103 | ) |
||
| 104 | ); |
||
| 105 | } |
||
| 106 | } |
||
| 107 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths