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( |
||
|
0 ignored issues
–
show
|
|||
| 30 | 'pronamic-pay mollie organizations synchronize', |
||
| 31 | function( $args, $assoc_args ) { |
||
| 32 | $this->wp_cli_organizations_synchronize( $args, $assoc_args ); |
||
| 33 | } |
||
| 34 | ); |
||
| 35 | |||
| 36 | \WP_CLI::add_command( |
||
| 37 | 'pronamic-pay mollie customers synchronize', |
||
| 38 | function( $args, $assoc_args ) { |
||
| 39 | $this->wp_cli_customers_synchronize( $args, $assoc_args ); |
||
| 40 | } |
||
| 41 | ); |
||
| 42 | |||
| 43 | \WP_CLI::add_command( |
||
| 44 | 'pronamic-pay mollie customers connect-wp-users', |
||
| 45 | function( $args, $assoc_args ) { |
||
| 46 | $this->wp_cli_customers_connect_wp_users( $args, $assoc_args ); |
||
| 47 | } |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * CLI organizations synchronize. |
||
| 53 | * |
||
| 54 | * @link https://docs.mollie.com/reference/v2/organizations-api/current-organization |
||
| 55 | * @param array $args Arguments. |
||
| 56 | * @param array $assoc_args Associative arguments. |
||
| 57 | */ |
||
| 58 | public function wp_cli_organizations_synchronize( $args, $assoc_args ) { |
||
| 59 | \WP_CLI::error( 'Command not implemented yet.' ); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * CLI customers synchronize. |
||
| 64 | * |
||
| 65 | * @link https://docs.mollie.com/reference/v2/customers-api/list-customers |
||
| 66 | * @param array $args Arguments. |
||
| 67 | * @param array $assoc_args Associative arguments. |
||
| 68 | */ |
||
| 69 | public function wp_cli_customers_synchronize( $args, $assoc_args ) { |
||
| 70 | \WP_CLI::error( 'Command not implemented yet.' ); |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * CLI connect Mollie customers to WordPress users. |
||
| 75 | * |
||
| 76 | * @link https://docs.mollie.com/reference/v2/customers-api/list-customers |
||
| 77 | * @link https://make.wordpress.org/cli/handbook/internal-api/wp-cli-add-command/ |
||
| 78 | * @link https://developer.wordpress.org/reference/classes/wpdb/query/ |
||
| 79 | * @param array $args Arguments. |
||
| 80 | * @param array $assoc_args Associative arguments. |
||
| 81 | */ |
||
| 82 | public function wp_cli_customers_connect_wp_users( $args, $assoc_args ) { |
||
| 83 | global $wpdb; |
||
| 84 | |||
| 85 | $query = " |
||
| 86 | INSERT IGNORE INTO $wpdb->pronamic_pay_mollie_customer_users ( |
||
| 87 | customer_id, |
||
| 88 | user_id |
||
| 89 | ) |
||
| 90 | SELECT |
||
| 91 | mollie_customer.id AS mollie_customer_id, |
||
| 92 | wp_user.ID AS wp_user_id |
||
| 93 | FROM |
||
| 94 | $wpdb->pronamic_pay_mollie_customers AS mollie_customer |
||
| 95 | INNER JOIN |
||
| 96 | $wpdb->users AS wp_user |
||
| 97 | ON mollie_customer.email = wp_user.user_email |
||
| 98 | ; |
||
| 99 | "; |
||
| 100 | |||
| 101 | $result = $wpdb->query( $query ); |
||
| 102 | |||
| 103 | if ( false === $result ) { |
||
| 104 | \WP_CLI::error( |
||
| 105 | sprintf( |
||
| 106 | 'Database error: %s.', |
||
| 107 | $wpdb->last_error |
||
| 108 | ) |
||
| 109 | ); |
||
| 110 | } |
||
| 111 | |||
| 112 | \WP_CLI::log( |
||
| 113 | sprintf( |
||
| 114 | 'Connected %d users and Mollie customers.', |
||
| 115 | $result |
||
| 116 | ) |
||
| 117 | ); |
||
| 118 | } |
||
| 119 | } |
||
| 120 |
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