You are here

public function ApiBase::getUrl in FormAssembly 8

Utility method to prepare a getUrl object.

Segment values:

  • base
  • api
  • forms

Non-matching segments are passed through as arbitrary paths.

Parameters

string $segment: A string key to indicate which path to use.

Return value

\Drupal\Core\Url A url object configured for the proper endpoint.

4 calls to ApiBase::getUrl()
ApiMarkup::getFormMarkup in src/ApiMarkup.php
Retrieve the HTML for a FormAssembly form.
ApiMarkup::getNextForm in src/ApiMarkup.php
Get the HTML for a FormAssembly next path using returned tfa_next value.
ApiSync::getAdminForms in src/ApiSync.php
Helper method for getting forms from the admin index.
ApiSync::getStandardForms in src/ApiSync.php
Helper method for getting forms from the standard index.

File

src/ApiBase.php, line 96

Class

ApiBase
Base class for Api Objects.

Namespace

Drupal\formassembly

Code

public function getUrl($segment) {
  $options = [];

  // Init the path array.
  $paths = [
    'base' => '',
    'api' => $this->isAdmin ? $this::ADMIN_API_PATH : $this::API_PATH,
  ];

  // Define commonly used methods:
  $paths['forms'] = $paths['api'] . '/forms/index.json';
  $path = isset($paths[$segment]) ? $paths[$segment] : $segment;
  $oauth_config = $this->configFactory
    ->get('formassembly.api.oauth');
  $base = $oauth_config
    ->get('endpoint');
  return Url::fromUri($base . $path, $options);
}