trait DataFetcherTrait in Typed Data API enhancements 8
Helper for classes that need the data fetcher object.
Hierarchy
- trait \Drupal\typed_data\DataFetcherTrait
File
- src/
DataFetcherTrait.php, line 8
Namespace
Drupal\typed_dataView source
trait DataFetcherTrait {
/**
* The data fetcher.
*
* @var \Drupal\typed_data\DataFetcherInterface
*/
protected $dataFetcher;
/**
* Sets the data fetcher.
*
* @param \Drupal\typed_data\DataFetcherInterface $data_fetcher
* The data fetcher.
*
* @return $this
*/
public function setDataFetcher(DataFetcherInterface $data_fetcher) {
$this->dataFetcher = $data_fetcher;
return $this;
}
/**
* Gets the data fetcher.
*
* @return \Drupal\typed_data\DataFetcherInterface
* The data fetcher.
*/
public function getDataFetcher() {
if (empty($this->dataFetcher)) {
$this->dataFetcher = \Drupal::service('typed_data.data_fetcher');
}
return $this->dataFetcher;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DataFetcherTrait:: |
protected | property | The data fetcher. | |
DataFetcherTrait:: |
public | function | Gets the data fetcher. | |
DataFetcherTrait:: |
public | function | Sets the data fetcher. |