You are here

public function ServicesContentTypeNegotiator::getCanonicalPathMatches in Services 7.3

Preg match canonical path to split it to clean path and extension.

Parameters

string $canonical_path: Canonical path with extension.

Return value

array Array of matches.

2 calls to ServicesContentTypeNegotiator::getCanonicalPathMatches()
ServicesContentTypeNegotiator::getParsedCanonicalPath in servers/rest_server/includes/ServicesContentTypeNegotiator.inc
Parse canonical path. It may have extension in the end (example node/1.json). This function returns canonical path without extension.
ServicesContentTypeNegotiator::getResponseFormatFromURL in servers/rest_server/includes/ServicesContentTypeNegotiator.inc
Retrieve formatter from URL. If format is in the path, we remove it from $canonical_path.

File

servers/rest_server/includes/ServicesContentTypeNegotiator.inc, line 50

Class

ServicesContentTypeNegotiator
Class used to do Content Type negotiation.

Code

public function getCanonicalPathMatches($canonical_path) {
  $matches = array();
  if (preg_match('/^(.+)\\.([^\\.^\\/]+)$/', $canonical_path, $matches)) {
    return $matches;
  }
  return array(
    '',
    $canonical_path,
    '',
  );
}