REST_Forms_Controller::prepare_links( awsmug\Torro_Forms\DB_Objects\Forms\Form $form )

Prepares links for the request.

Description

Parameters

$form

(awsmug\Torro_Forms\DB_Objects\Forms\Form) (Required) Form object.

Return

(array) Links for the given form.

Source

File: src/db-objects/forms/rest-forms-controller.php

	protected function prepare_links( $form ) {
		$links = parent::prepare_links( $form );

		$primary_property = $this->manager->get_primary_property();

		$links['containers'] = array(
			'href'       => add_query_arg( array(
				'form_id'  => $form->$primary_property,
				'per_page' => 10,
			), rest_url( sprintf( '%s/%s', $this->namespace, 'containers' ) ) ),
			'embeddable' => true,
		);

		$links['elements'] = array(
			'href'       => add_query_arg( array(
				'form_id'  => $form->$primary_property,
				'per_page' => 50,
			), rest_url( sprintf( '%s/%s', $this->namespace, 'elements' ) ) ),
			'embeddable' => true,
		);

		$links['element_choices'] = array(
			'href'       => add_query_arg( array(
				'form_id'  => $form->$primary_property,
				'per_page' => 250,
			), rest_url( sprintf( '%s/%s', $this->namespace, 'element_choices' ) ) ),
			'embeddable' => true,
		);

		$links['element_settings'] = array(
			'href'       => add_query_arg( array(
				'form_id'  => $form->$primary_property,
				'per_page' => 250,
			), rest_url( sprintf( '%s/%s', $this->namespace, 'element_settings' ) ) ),
			'embeddable' => true,
		);

		$links['submissions'] = array(
			'href' => add_query_arg( 'form_id', $form->$primary_property, rest_url( sprintf( '%s/%s', $this->namespace, 'submissions' ) ) ),
		);

		$links['submission_values'] = array(
			'href' => add_query_arg( 'form_id', $form->$primary_property, rest_url( sprintf( '%s/%s', $this->namespace, 'submission_values' ) ) ),
		);

		return $links;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.