-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[RW-245] Fix job import
- Loading branch information
Showing
9 changed files
with
843 additions
and
279 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
html/modules/custom/reliefweb_import/reliefweb_import.module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Module file for the job importer. | ||
*/ | ||
|
||
use Drupal\Core\Entity\EntityInterface; | ||
use Drupal\reliefweb_entities\Entity\Job; | ||
|
||
/** | ||
* Implements hook_ENTITY_TYPE_presave() for node. | ||
*/ | ||
function reliefweb_import_node_presave(EntityInterface $entity) { | ||
// @todo remove when removing `reliefweb_migrate`. | ||
if (!empty($entity->_is_migrating)) { | ||
return; | ||
} | ||
if ($entity instanceof Job && !empty($entity->_is_importing)) { | ||
$status = $entity->getModerationStatus(); | ||
|
||
// Set the status to draft/on-hold if there were validation errors. | ||
if ($status !== 'refused' && !empty($entity->_import_errors)) { | ||
$status = \Drupal::state()->get('reliefweb_import_status_when_errors', 'draft'); | ||
$entity->setModerationStatus($status); | ||
} | ||
|
||
// Set the revision user to the System user to differentiate modifications | ||
// made via the UI from automated ones. We need to do that here so that | ||
// the Job::preSave() uses the user associated with the import feed when | ||
// determining the status to use based on the user posting rights. | ||
$entity->setRevisionUserId(2); | ||
} | ||
} |
Oops, something went wrong.