From 3a32c8f1cacb9d916b00a68bd0629603ad5519c1 Mon Sep 17 00:00:00 2001 From: JR Tashjian Date: Tue, 30 Jul 2024 09:20:26 -0400 Subject: [PATCH] Use the new FormFactory --- includes/Plugin/Api/FormsController.php | 4 +++- includes/Plugin/PluginServiceProvider.php | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/Plugin/Api/FormsController.php b/includes/Plugin/Api/FormsController.php index 83c8e9e..efe80c8 100644 --- a/includes/Plugin/Api/FormsController.php +++ b/includes/Plugin/Api/FormsController.php @@ -48,7 +48,9 @@ public function create_response_permissions_check( \WP_REST_Request $request ) { */ public function create_response( \WP_REST_Request $request ) { try { - $form = omniform()->get( \OmniForm\Plugin\Form::class )->get_instance( absint( $request->get_param( 'id' ) ) ); + /** @var \OmniForm\Plugin\Form */ // phpcs:ignore + $form = omniform()->get( \OmniForm\Plugin\FormFactory::class ) + ->create_with_id( absint( $request->get_param( 'id' ) ) ); } catch ( \Exception $e ) { return new \WP_Error( 'omniform_not_found', diff --git a/includes/Plugin/PluginServiceProvider.php b/includes/Plugin/PluginServiceProvider.php index fed3b4c..4e8c507 100644 --- a/includes/Plugin/PluginServiceProvider.php +++ b/includes/Plugin/PluginServiceProvider.php @@ -136,7 +136,7 @@ function ( $response_id, $form ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFu 'omniform_form_render', function ( $form_id ) { /** @var \OmniForm\Plugin\Form */ // phpcs:ignore - $form = omniform()->get( \OmniForm\Plugin\Form::class )->get_instance( $form_id ); + $form = omniform()->get( FormFactory::class )->create_with_id( $form_id ); if ( ! $form->is_published() || is_admin() ) { return; @@ -175,7 +175,7 @@ function ( $column_key, $post_id ) { try { /** @var \OmniForm\Plugin\Form */ // phpcs:ignore - $form = omniform()->get( \OmniForm\Plugin\Form::class )->get_instance( $post_id ); + $form = omniform()->get( FormFactory::class )->create_with_id( $post_id ); if ( 'standard' !== $form->get_type() ) { return; @@ -203,7 +203,7 @@ function ( $column_key, $post_id ) { try { /** @var \OmniForm\Plugin\Form */ // phpcs:ignore - $form = omniform()->get( \OmniForm\Plugin\Form::class )->get_instance( $post_id ); + $form = omniform()->get( FormFactory::class )->create_with_id( $post_id ); if ( 'standard' !== $form->get_type() ) { return; @@ -297,7 +297,7 @@ function ( $column_key, $post_id ) { try { /** @var \OmniForm\Plugin\Form */ // phpcs:ignore - $form = omniform()->get( \OmniForm\Plugin\Form::class )->get_instance( $form_id ); + $form = omniform()->get( FormFactory::class )->create_with_id( $form_id ); } catch ( \Exception $e ) { echo esc_html( $e->getMessage() ); return;