Automattic\WooCommerce\Admin\RemoteInboxNotifications
RemoteInboxNotificationsDataSourcePoller::validate_action
Validate the action.
Method of the class: RemoteInboxNotificationsDataSourcePoller{}
No Hooks.
Returns
true|false. The result of the validation.
Usage
// private - for code of main (parent) class only $result = $this->validate_action( $action, $url );
- $action(object) (required)
- The action to validate.
- $url(string) (required)
- The url of the feed containing the action (for error reporting).
RemoteInboxNotificationsDataSourcePoller::validate_action() RemoteInboxNotificationsDataSourcePoller::validate action code WC 10.8.1
private function validate_action( $action, $url ) {
$logger = self::get_logger();
$logger_context = array( 'source' => $url );
if ( ! isset( $action->locales ) || ! is_array( $action->locales ) ) {
$logger->error(
'Action is invalid because it has empty or missing locales in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
if ( null === SpecRunner::get_action_locale( $action->locales ) ) {
$logger->error(
'Action is invalid because the locale could not be retrieved in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
if ( ! isset( $action->name ) ) {
$logger->error(
'Action is invalid because the name is missing in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
if ( ! isset( $action->status ) ) {
$logger->error(
'Action is invalid because the status is missing in feed',
$logger_context
);
// phpcs:ignore
$logger->error( print_r( $action, true ), $logger_context );
return false;
}
return true;
}