protected function EntityProcessorBase::entitySaveAccess in Feeds 8.3
1 call to EntityProcessorBase::entitySaveAccess()
- EntityProcessorBase::process in src/
Feeds/ Processor/ EntityProcessorBase.php - Processes the results from a parser.
File
- src/
Feeds/ Processor/ EntityProcessorBase.php, line 616
Class
- EntityProcessorBase
- Defines a base entity processor.
Namespace
Drupal\feeds\Feeds\ProcessorCode
protected function entitySaveAccess(EntityInterface $entity) {
// No need to authorize.
if (!$this->configuration['authorize'] || !$entity instanceof EntityOwnerInterface) {
return;
}
// If the uid was mapped directly, rather than by email or username, it
// could be invalid.
$account = $entity
->getOwner();
if (!$account) {
$owner_id = $entity
->getOwnerId();
if ($owner_id == 0) {
// We don't check access for anonymous users.
return;
}
throw new EntityAccessException($this
->t('Invalid user with ID %uid mapped to %label.', [
'%uid' => $owner_id,
'%label' => $entity
->label(),
]));
}
// We don't check access for anonymous users.
if ($account
->isAnonymous()) {
return;
}
$op = $entity
->isNew() ? 'create' : 'update';
// Access granted.
if ($entity
->access($op, $account)) {
return;
}
$args = [
'%name' => $account
->getDisplayName(),
'@op' => $op,
'@bundle' => $this
->getItemLabelPlural(),
];
throw new EntityAccessException($this
->t('User %name is not authorized to @op @bundle.', $args));
}