public function Reference::cite in Bibliography & Citation 2.0.x
Same name and namespace in other branches
- 8 modules/bibcite_entity/src/Entity/Reference.php \Drupal\bibcite_entity\Entity\Reference::cite()
Render reference entity as citation.
Parameters
string|null $style: Identifier of citation style. Default style will be used if this value is NULL.
Return value
mixed Rendered citation.
Overrides ReferenceInterface::cite
File
- modules/
bibcite_entity/ src/ Entity/ Reference.php, line 106
Class
- Reference
- Defines the Reference entity.
Namespace
Drupal\bibcite_entity\EntityCode
public function cite($style = NULL) {
// @todo Make a better dependency injection.
/** @var \Drupal\bibcite\CitationStylerInterface $styler */
$styler = \Drupal::service('bibcite.citation_styler');
if ($style) {
$styler
->setStyleById($style);
}
$serializer = \Drupal::service('serializer');
$data = $serializer
->normalize($this, 'csl');
return $styler
->render($data);
}