> $request * @return array|WP_Error */ public function create( WP_REST_Request $request ): array|WP_Error { $fix_request = $this->fix_request_reader->read( $request ); if ( $fix_request instanceof WP_Error ) { return $fix_request; } $targets = $this->fix_targets->find( $fix_request ); if ( array() === $targets ) { return FixErrors::nothing_to_fix(); } $link_ids = array(); foreach ( $targets as $target ) { $link_ids[] = $target->id; } $places_total = $fix_request->action->changes_posts() ? $this->fix_places->count_posts( $link_ids ) : self::NOTHING_DONE; $progress = new FixProgress( FixState::Running, self::NOTHING_DONE, $places_total, self::NOTHING_DONE, self::NOTHING_DONE, array() ); $fix = $this->fix_repository->insert( new Fix( id: self::NOTHING_DONE, action: $fix_request->action, created_at: $this->clock->now(), new_url: $fix_request->new_url, first_url: $targets[0]->url, link_ids: $link_ids, progress: $progress ) ); return $this->fix_presenter->present( $this->fix_runner->next_step( $fix ) ); } }