/** * {@inheritdoc} */ public function __construct(RequestInterface $request, ResourceFieldCollectionInterface $field_definitions, $account, $plugin_id, $resource_path = NULL, array $options = array(), $langcode = NULL) { parent::__construct($request, $field_definitions, $account, $plugin_id, $resource_path, $options, $langcode); if (empty($this->options['urlParams'])) { $this->options['urlParams'] = array('filter' => TRUE, 'sort' => TRUE, 'fields' => TRUE); } }
/** * Constructor. * * @param RequestInterface $request * The request. * @param ResourceFieldCollectionInterface $field_definitions * The field definitions. * @param object $account * The authenticated account. * @param string $plugin_id * The resource ID. * @param string $resource_path * The resource path. * @param array $options * The plugin options for the data provider. * @param string $langcode * (Optional) The entity language code. * @param ResourceInterface $resource * The referenced resource. */ public function __construct(RequestInterface $request, ResourceFieldCollectionInterface $field_definitions, $account, $plugin_id, $resource_path, array $options, $langcode = NULL, ResourceInterface $resource = NULL) { $resource->setRequest($request); $this->resource = $resource; $this->referencedDataProvider = $resource->getDataProvider(); parent::__construct($request, $field_definitions, $account, $plugin_id, $resource_path, $options, $langcode); }
/** * {@inheritdoc} */ public function __construct(RequestInterface $request, ResourceFieldCollectionInterface $field_definitions, $account, $plugin_id, $resource_path = NULL, array $options = array(), $langcode = NULL) { parent::__construct($request, $field_definitions, $account, $plugin_id, $resource_path, $options, $langcode); // Validate keys exist in the plugin's "data provider options". $required_keys = array('tableName', 'idColumn'); $required_callback = function ($required_key) { if (!$this->options[$required_key]) { throw new ServiceUnavailableException(sprintf('%s is missing "%s" property in the "dataProvider" key of the $plugin', get_class($this), $required_key)); } }; array_walk($required_keys, $required_callback); $this->tableName = $this->options['tableName']; $this->idColumn = $this->options['idColumn']; $this->primary = empty($this->options['primary']) ? NULL : ($this->primary = $this->options['primary']); }
/** * Adds query tags and metadata to the EntityFieldQuery. * * @param \EntityFieldQuery $query * The query to enhance. */ protected function addExtraInfoToQuery($query) { parent::addExtraInfoToQuery($query); // The only time you need to add the access tags to a EFQ is when you don't // have fieldConditions. if (empty($query->fieldConditions) && empty($query->order)) { // Add a generic entity access tag to the query. $query->addTag($this->entityType . '_access'); } $query->addMetaData('restful_data_provider', $this); }
/** * Process the filter query string for the relevant sub-query. * * Selects the filters that start with the field name. * * @return array * The processed filters. */ protected function nestedDottedFilters() { $input = $this->getRequest()->getParsedInput(); if (empty($input['filter'])) { return array(); } $output_filters = array(); $filters = $input['filter']; foreach ($filters as $filter_public_name => $filter) { $filter = DataProvider::processFilterInput($filter, $filter_public_name); if (strpos($filter_public_name, $this->getPublicName() . '.') === 0) { // Remove the prefix and add it to the filters for the next request. $new_name = substr($filter_public_name, strlen($this->getPublicName()) + 1); $filter['public_field'] = $new_name; $output_filters[$new_name] = $filter; } } return $output_filters; }
/** * {@inheritdoc} */ public static function processFilterInput($filter, $public_field) { return DataProvider::processFilterInput($filter, $public_field); }