REST_Containers_Controller::prepare_links( awsmug\Torro_Forms\DB_Objects\Containers\Container $container )

Prepares links for the request.

Description

Parameters

$container

(awsmug\Torro_Forms\DB_Objects\Containers\Container) (Required) Container object.

Return

(array) Links for the given container.

Source

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

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

		if ( ! empty( $container->form_id ) ) {
			$links['parent_form'] = array(
				'href' => rest_url( trailingslashit( sprintf( '%s/%s', $this->namespace, 'forms' ) ) . $container->form_id ),
			);
		}

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

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

		$links['element_choices'] = array(
			'href'       => add_query_arg( array(
				'container_id' => $container->$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(
				'container_id' => $container->$primary_property,
				'per_page'     => 250,
			), rest_url( sprintf( '%s/%s', $this->namespace, 'element_settings' ) ) ),
			'embeddable' => true,
		);

		return $links;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.