public function Flow::canPullEntity in CMS Content Sync 8
Same name and namespace in other branches
- 2.0.x src/Entity/Flow.php \Drupal\cms_content_sync\Entity\Flow::canPullEntity()
Ask this Flow whether or not it can push the provided entity.
Parameters
string $entity_type_name:
string $bundle_name:
string $reason:
string $action:
bool $strict: If asking for DEPENDENCY as a $reason, then $strict will NOT include a Flow that pulls AUTOMATICALLY
Return value
bool
File
- src/
Entity/ Flow.php, line 629
Class
- Flow
- Defines the "Content Sync - Flow" entity.
Namespace
Drupal\cms_content_sync\EntityCode
public function canPullEntity($entity_type_name, $bundle_name, $reason, $action = SyncIntent::ACTION_CREATE, $strict = false) {
$config = $this
->getEntityTypeConfig($entity_type_name, $bundle_name);
if (empty($config) || self::HANDLER_IGNORE == $config['handler']) {
return false;
}
if (PullIntent::PULL_DISABLED == $config['import']) {
return false;
}
if (SyncIntent::ACTION_DELETE == $action && !boolval($config['import_deletion_settings']['import_deletion'])) {
return false;
}
// If any handler is available, we can pull this entity.
if (PullIntent::PULL_FORCED == $reason) {
return true;
}
// Flows that pull automatically can also handle referenced entities.
if (PullIntent::PULL_AUTOMATICALLY == $config['import']) {
if (PullIntent::PULL_AS_DEPENDENCY == $reason && !$strict) {
return true;
}
}
// Once pulled manually, updates will arrive automatically.
if (PullIntent::PULL_AUTOMATICALLY == $reason && PullIntent::PULL_MANUALLY == $config['import']) {
if (SyncIntent::ACTION_UPDATE == $action || SyncIntent::ACTION_DELETE == $action) {
return true;
}
}
return $config['import'] == $reason;
}