return NULL;
}
if (!$this->tableName) {
- // If we are just loading this table we will do some validation.
- // In the case of viewing historical jobs the table could have
- // been deleted so we check that when we first load it.
- if (strpos($tableName, 'civicrm_tmp_') !== 0
- || !CRM_Utils_Rule::alphanumeric($tableName)) {
- // The table name is generated and stored by code, not users so it
- // should be safe - but a check seems prudent all the same.
- throw new CRM_Core_Exception('Table cannot be deleted');
- }
- if (!CRM_Core_DAO::singleValueQuery('SHOW TABLES LIKE %1', [1 => [$tableName, 'String']])) {
- throw new CRM_Import_Exception_ImportTableUnavailable('table deleted');
- }
$this->tableName = $tableName;
}
return $this->tableName;
--- /dev/null
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Import;
+
+/**
+ * Code shared by Import Save/Update actions.
+ */
+trait ImportSaveTrait {
+
+ /**
+ * @inheritDoc
+ */
+ protected function write(array $items) {
+ $userJobID = str_replace('Import_', '', $this->_entityName);
+ foreach ($items as &$item) {
+ $item['_user_job_id'] = (int) $userJobID;
+ }
+ return parent::write($items);
+ }
+
+}
--- /dev/null
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Api4\Import;
+
+use Civi\Api4\Generic\DAOCreateAction;
+
+class Import extends DAOCreateAction {
+
+ use ImportSaveTrait;
+
+}