public function PublishedFilter::filter in Replication 8
Same name and namespace in other branches
- 8.2 src/Plugin/ReplicationFilter/PublishedFilter.php \Drupal\replication\Plugin\ReplicationFilter\PublishedFilter::filter()
Filter the given entity.
Parameters
EntityInterface $entity: The entity to filter.
Return value
bool Return TRUE if it should be included, else FALSE.
Overrides ReplicationFilterInterface::filter
File
- src/
Plugin/ ReplicationFilter/ PublishedFilter.php, line 69
Class
- PublishedFilter
- Provides a filter for published entities.
Namespace
Drupal\replication\Plugin\ReplicationFilterCode
public function filter(EntityInterface $entity) {
// @todo handle translations?
// @todo is there an easier way to tell if an entity is published?
$definition = $this->entityTypeManager
->getDefinition($entity
->getEntityTypeId());
if ($definition
->hasKey('status')) {
$field_name = $definition
->getKey('status');
$field_definition = $entity
->getFieldDefinition($field_name);
$property = $field_definition
->getFieldStorageDefinition()
->getMainPropertyName();
return (bool) $entity
->get($field_name)->{$property};
}
// Determine what to do with entities without a 'status' field.
$configuration = $this
->getConfiguration();
return $configuration['include_unpublishable_entities'];
}