class ReferencePreviewConverter in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/src/ParamConverter/ReferencePreviewConverter.php \Drupal\bibcite_entity\ParamConverter\ReferencePreviewConverter
Provides upcasting for a reference entity in preview.
Hierarchy
- class \Drupal\bibcite_entity\ParamConverter\ReferencePreviewConverter implements ParamConverterInterface
Expanded class hierarchy of ReferencePreviewConverter
1 string reference to 'ReferencePreviewConverter'
- bibcite_entity.services.yml in modules/
bibcite_entity/ bibcite_entity.services.yml - modules/bibcite_entity/bibcite_entity.services.yml
1 service uses ReferencePreviewConverter
File
- modules/
bibcite_entity/ src/ ParamConverter/ ReferencePreviewConverter.php, line 12
Namespace
Drupal\bibcite_entity\ParamConverterView source
class ReferencePreviewConverter implements ParamConverterInterface {
/**
* Stores the tempstore factory.
*
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
*/
protected $tempStoreFactory;
/**
* Constructs a new ReferencePreviewConverter.
*
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
* The factory for the temp store object.
*/
public function __construct(PrivateTempStoreFactory $temp_store_factory) {
$this->tempStoreFactory = $temp_store_factory;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
$store = $this->tempStoreFactory
->get('bibcite_reference_preview');
if ($form_state = $store
->get($value)) {
return $form_state
->getFormObject()
->getEntity();
}
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
if (!empty($definition['type']) && $definition['type'] == 'bibcite_reference_preview') {
return TRUE;
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ReferencePreviewConverter:: |
protected | property | Stores the tempstore factory. | |
ReferencePreviewConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
ReferencePreviewConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
ReferencePreviewConverter:: |
public | function | Constructs a new ReferencePreviewConverter. |