array( 'type' => 'string', 'description' => __( 'Free-text search over the name.', 'acrossai-abilities-manager' ), ), 'page' => array( 'type' => 'integer', 'minimum' => 1, 'default' => 1, 'description' => __( '1-based page number.', 'acrossai-abilities-manager' ), ), 'per_page' => array( 'type' => 'integer', 'minimum' => 1, 'maximum' => 100, 'default' => 20, 'description' => __( 'Results per page, maximum 100.', 'acrossai-abilities-manager' ), ), ); } protected function required_input(): array { return array( ); } protected function output_properties(): array { return array( 'organizers' => array( 'type' => 'array' ), 'total' => array( 'type' => 'integer' ), ); } protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true, ); } protected function suggested_abilities(): array { return array( array( 'slug' => 'events/list-events', 'reason' => __( 'Filter events by this organizer once you have its ID.', 'acrossai-abilities-manager' ), ), ); } protected function run( array $input ) { $page = isset( $input['page'] ) ? (int) $input['page'] : 1; $per_page = isset( $input['per_page'] ) ? (int) $input['per_page'] : 20; $search = isset( $input['search'] ) ? (string) $input['search'] : ''; $result = Event_Repository::query_linked( 'organizer', $search, $page, $per_page ); return array( 'organizers' => $result['rows'], 'total' => $result['total'], 'message' => sprintf( /* translators: 1: returned count, 2: total */ __( '%1$d of %2$d organizers.', 'acrossai-abilities-manager' ), count( $result['rows'] ), $result['total'] ), ); } }