ReferenceStorage.php in Bibliography & Citation 2.0.x
File
modules/bibcite_entity/src/ReferenceStorage.php
View source
<?php
namespace Drupal\bibcite_entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
class ReferenceStorage extends SqlContentEntityStorage {
protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = []) {
$citekey = NULL;
if ($citekey_item = $entity
->get('bibcite_citekey')
->get(0)) {
$citekey = $citekey_item
->getValue();
}
if (!$citekey && $entity
->isNew()) {
$entity->bibcite_citekey = $entity
->generateCitekey();
}
return parent::saveToDedicatedTables($entity, $update, $names);
}
public function getCustomTableMapping(ContentEntityTypeInterface $entity_type, array $storage_definitions, $prefix = '') {
$prefix = $prefix ?: ($this->temporary ? 'tmp_' : '');
return ReferenceDefaultTableMapping::create($entity_type, $storage_definitions, $prefix);
}
}