49 private $whiteListTables = [];
54 private $componentRegistrar;
59 private $elementHistoryFactory;
67 private $tableIndexes;
75 private $destructiveOperations;
89 array $destructiveOperations
92 $this->elementHistoryFactory = $elementHistoryFactory;
93 $this->tableIndexes = $tableIndexes;
94 $this->destructiveOperations = $destructiveOperations;
106 if ($this->changes) {
107 ksort($this->changes);
109 return $this->changes;
121 $tableIndex = $this->tableIndexes[
$table];
122 return $this->changes[$tableIndex][$operation] ?? [];
132 private function getWhiteListTables()
134 if (!$this->whiteListTables) {
136 $whiteListPath =
$path . DIRECTORY_SEPARATOR .
'etc' .
137 DIRECTORY_SEPARATOR .
'db_schema_whitelist.json';
139 if (file_exists($whiteListPath)) {
140 $this->whiteListTables = array_replace_recursive(
141 $this->whiteListTables,
148 return $this->whiteListTables;
165 if (!isset($this->destructiveOperations[$operation])) {
169 $checkResult =
false;
170 $whiteList = $this->getWhiteListTables();
173 $tableNameWithoutPrefix = $object->getTable()->getNameWithoutPrefix();
176 if ($this->isElementHaveAutoGeneratedName($object)) {
178 isset($whiteList[$tableNameWithoutPrefix][
$type][$object->getNameWithoutPrefix()]);
180 $checkResult = isset($whiteList[$tableNameWithoutPrefix][
$type][$object->
getName()]);
183 $checkResult = isset($whiteList[$object->getNameWithoutPrefix()]);
206 public function register(
215 $historyData = [
'new' => $dtoObject,
'old' => $oldDtoObject];
216 $history = $this->elementHistoryFactory->create($historyData);
218 $this->changes[$this->findTableIndex($dtoObject, $operation)][$operation][] = $history;
219 $this->debugChanges[$operation][] = $history;
const GENERATED_WHITELIST_FILE_NAME
elseif(isset( $params[ 'redirect_parent']))
__construct(ComponentRegistrar $componentRegistrar, ElementHistoryFactory $elementHistoryFactory, array $tableIndexes, array $destructiveOperations)
getChange($table, $operation)
canBeRegistered(ElementInterface $object, $operation)