You are here

public static function ResourceField::create in RESTful 7.2

Factory.

Parameters

array $field: Contains the field values.

RequestInterface $request: The request.

Return value

ResourceFieldInterface The created field

Throws

ServerConfigurationException

Overrides ResourceFieldInterface::create

3 calls to ResourceField::create()
LoginCookie__1_0::loginAndRespondWithCookie in src/Plugin/resource/LoginCookie__1_0.php
Login a user and return a JSON along with the authentication cookie.
ResourceFieldCollection::__construct in src/Plugin/resource/Field/ResourceFieldCollection.php
Constructor.
ResourceFieldResource::create in src/Plugin/resource/Field/ResourceFieldResource.php
Factory.
2 methods override ResourceField::create()
ResourceFieldDbColumn::create in src/Plugin/resource/Field/ResourceFieldDbColumn.php
Factory.
ResourceFieldKeyValue::create in src/Plugin/resource/Field/ResourceFieldKeyValue.php
Factory.

File

src/Plugin/resource/Field/ResourceField.php, line 46
Contains \Drupal\restful\Plugin\resource\ResourceField.

Class

ResourceField

Namespace

Drupal\restful\Plugin\resource\Field

Code

public static function create(array $field, RequestInterface $request = NULL) {
  $request = $request ?: restful()
    ->getRequest();
  if ($class_name = static::fieldClassName($field)) {
    if ($class_name != get_called_class() && $class_name != '\\' . get_called_class()) {

      // Call the create factory in the derived class.
      return call_user_func_array(array(
        $class_name,
        'create',
      ), array(
        $field,
        $request,
        new static($field, $request),
      ));
    }
  }

  // If no other class was found, then use the current one.
  $resource_field = new static($field, $request);
  $resource_field
    ->addDefaults();
  return $resource_field;
}