Skip to content

Commit

Permalink
Use the new FormFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtashjian committed Jul 30, 2024
1 parent 7488574 commit 3a32c8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion includes/Plugin/Api/FormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 4 additions & 4 deletions includes/Plugin/PluginServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 3a32c8f

Please sign in to comment.