109 public function get()
223 if (!isset($this->elementEntityProcessor)) {
224 $this->elementEntityProcessor = GeneralUtility::makeInstance(ElementEntityProcessor::class);
225 $this->elementEntityProcessor->setWorkspace($this->
getWorkspace());
252 foreach ($this->commandMap as $table => $liveIdCollection) {
253 foreach ($liveIdCollection as $liveId => $commandCollection) {
254 foreach ($commandCollection as $command => $properties) {
255 if ($command ===
'version' && isset($properties[
'action']) && $properties[
'action'] ===
'swap') {
257 call_user_func_array([$this, $callbackMethod], array_merge($arguments, [$table, $liveId, $properties]));
275 if ($this->workspacesSwapMode ===
'any' || $this->workspacesSwapMode ===
'pages') {
291 $extendedCommandMap = [];
294 if ($this->workspacesSwapMode ===
'any' || $this->workspacesSwapMode ===
'pages' && $table ===
'pages') {
297 foreach ($elementList as $elementTable => $elementIdArray) {
298 foreach ($elementIdArray as $elementIds) {
299 $extendedCommandMap[$elementTable][$elementIds[0]][
'version'] = array_merge($properties, [
'swapWith' => $elementIds[1]]);
302 if (!empty($elementList)) {
303 $this->
remove($table, $liveId,
'version');
320 if ($this->workspacesSwapMode ===
'any' || $this->workspacesSwapMode ===
'pages' && $table ===
'pages') {
323 foreach ($elementList as $elementTable => $elementIdArray) {
324 foreach ($elementIdArray as $elementIds) {
325 $dependency->
addElement($elementTable, $elementIds[1], [
'liveId' => $elementIds[0],
'properties' => array_merge($properties, [
'swapWith' => $elementIds[1]])]);
328 if (empty($elementList)) {
329 $dependency->
addElement($table, $properties[
'swapWith'], [
'liveId' => $liveId,
'properties' => $properties]);
342 foreach ($this->commandMap as $table => $versionIdCollection) {
343 foreach ($versionIdCollection as $versionIdList => $commandCollection) {
344 foreach ($commandCollection as $command => $properties) {
345 if ($command ===
'version' && isset($properties[
'action']) && $properties[
'action'] ===
'setStage') {
347 call_user_func_array([$this, $callbackMethod], array_merge($arguments, [$table, $versionIdList, $properties]));
364 if ($this->workspacesChangeStageMode ===
'any' || $this->workspacesChangeStageMode ===
'pages') {
381 $extendedCommandMap = [];
382 $versionIds = GeneralUtility::trimExplode(
',', $versionIdList,
true);
383 $elementList = [$table => $versionIds];
384 if ($this->workspacesChangeStageMode ===
'any' || $this->workspacesChangeStageMode ===
'pages') {
385 if (count($versionIds) === 1) {
387 $workspaceId = $workspaceRecord[
't3ver_wsid'];
391 if ($table ===
'pages') {
393 $livePageIds = $versionIds;
396 } elseif ($this->workspacesChangeStageMode ===
'any') {
404 foreach ($elementList as $elementTable => $elementIds) {
405 foreach ($elementIds as $elementId) {
406 $extendedCommandMap[$elementTable][$elementId][
'version'] = $properties;
409 foreach ($versionIds as $versionId) {
410 $this->
remove($table, $versionId,
'version');
425 $dependency->
addElement($table, $versionId, [
'versionId' => $versionId,
'properties' => $properties]);
438 foreach ($this->commandMap as $table => $versionIdCollection) {
439 foreach ($versionIdCollection as $versionId => $commandCollection) {
440 foreach ($commandCollection as $command => $properties) {
441 if ($command ===
'version' && isset($properties[
'action']) && ($properties[
'action'] ===
'clearWSID' || $properties[
'action'] ===
'flush')) {
442 $dependency->
addElement($table, $versionId, [
'versionId' => $versionId,
'properties' => $properties]);
458 protected function explodeSetStage($table, $versionIdList, array $properties)
460 $extractedCommandMap = [];
461 $versionIds = GeneralUtility::trimExplode(
',', $versionIdList,
true);
462 if (count($versionIds) > 1) {
463 foreach ($versionIds as $versionId) {
464 if (isset($this->commandMap[$table][$versionId][
'version'])) {
465 throw new \RuntimeException(
'Command map for [' . $table .
'][' . $versionId .
'][version] was already set.', 1289391048);
467 $extractedCommandMap[$table][$versionId][
'version'] = $properties;
468 $this->
remove($table, $versionId,
'version');
483 $transformDependentElementsToUseLiveId = $this->
getScopeData($scope, self::KEY_TransformDependentElementsToUseLiveId);
486 if ($transformDependentElementsToUseLiveId) {
491 foreach ($outerMostParents as $outerMostParent) {
493 if ($transformDependentElementsToUseLiveId) {
498 $intersectingElements = array_intersect_key($dependentElements, $elementsToBeVersioned);
499 if (!empty($intersectingElements)) {
500 $this->
update(current($intersectingElements), $dependentElements, $scope);
514 $orderedCommandMap = [];
515 $commonProperties = [];
516 if ($this->
getScopeData($scope, self::KEY_GetCommonPropertiesCallback)) {
520 foreach ($elements as $element) {
521 $table = $element->getTable();
523 $this->
remove($table, $id,
'version');
524 if ($element->isInvalid()) {
527 $orderedCommandMap[$table][$id][
'version'] = $commonProperties;
528 if ($this->
getScopeData($scope, self::KEY_GetElementPropertiesCallback)) {
529 $orderedCommandMap[$table][$id][
'version'] = array_merge($commonProperties, $this->
processCallback($this->
getScopeData($scope, self::KEY_GetElementPropertiesCallback), [$element]));
564 protected function remove($table, $id, $command =
null)
566 if (is_string($command)) {
567 unset($this->commandMap[$table][$id][$command]);
569 unset($this->commandMap[$table][$id]);
592 return $element->
getId();
604 'swapWith' => $element->
getId()
616 $commonSwapProperties = [];
618 if (isset($elementProperties[
'action'])) {
619 $commonSwapProperties[
'action'] = $elementProperties[
'action'];
621 return $commonSwapProperties;
632 $commonSwapProperties = [];
634 if (isset($elementProperties[
'action'])) {
635 $commonSwapProperties[
'action'] = $elementProperties[
'action'];
637 if (isset($elementProperties[
'swapIntoWS'])) {
638 $commonSwapProperties[
'swapIntoWS'] = $elementProperties[
'swapIntoWS'];
640 if (isset($elementProperties[
'comment'])) {
641 $commonSwapProperties[
'comment'] = $elementProperties[
'comment'];
643 if (isset($elementProperties[
'notificationAlternativeRecipients'])) {
644 $commonSwapProperties[
'notificationAlternativeRecipients'] = $elementProperties[
'notificationAlternativeRecipients'];
647 return $commonSwapProperties;
669 $commonSetStageProperties = [];
671 if (isset($elementProperties[
'stageId'])) {
672 $commonSetStageProperties[
'stageId'] = $elementProperties[
'stageId'];
674 if (isset($elementProperties[
'comment'])) {
675 $commonSetStageProperties[
'comment'] = $elementProperties[
'comment'];
677 if (isset($elementProperties[
'action'])) {
678 $commonSetStageProperties[
'action'] = $elementProperties[
'action'];
680 if (isset($elementProperties[
'notificationAlternativeRecipients'])) {
681 $commonSetStageProperties[
'notificationAlternativeRecipients'] = $elementProperties[
'notificationAlternativeRecipients'];
683 return $commonSetStageProperties;
694 $dependency = GeneralUtility::makeInstance(DependencyResolver::class);
697 if ($this->
getScopeData($scope, self::KEY_ElementConstructCallback)) {
700 if ($this->
getScopeData($scope, self::KEY_ElementCreateChildReferenceCallback)) {
703 if ($this->
getScopeData($scope, self::KEY_ElementCreateParentReferenceCallback)) {
717 self::SCOPE_WorkspacesSwap => [
721 self::KEY_GetElementPropertiesCallback =>
'getElementSwapPropertiesCallback',
722 self::KEY_GetCommonPropertiesCallback =>
'getCommonSwapPropertiesCallback',
724 self::KEY_ElementConstructCallback =>
'createNewDependentElementCallback',
726 self::KEY_ElementCreateChildReferenceCallback =>
'createNewDependentElementChildReferenceCallback',
727 self::KEY_ElementCreateParentReferenceCallback =>
'createNewDependentElementParentReferenceCallback',
729 self::KEY_UpdateGetIdCallback =>
'getElementLiveIdCallback',
731 self::KEY_TransformDependentElementsToUseLiveId => true
734 self::SCOPE_WorkspacesSetStage => [
738 self::KEY_GetElementPropertiesCallback =>
'getElementSetStagePropertiesCallback',
739 self::KEY_GetCommonPropertiesCallback =>
'getCommonSetStagePropertiesCallback',
741 self::KEY_ElementConstructCallback =>
null,
743 self::KEY_ElementCreateChildReferenceCallback =>
'createNewDependentElementChildReferenceCallback',
744 self::KEY_ElementCreateParentReferenceCallback =>
'createNewDependentElementParentReferenceCallback',
746 self::KEY_UpdateGetIdCallback =>
'getElementIdCallback',
748 self::KEY_TransformDependentElementsToUseLiveId => false
751 self::SCOPE_WorkspacesClear => [
755 self::KEY_GetElementPropertiesCallback =>
null,
756 self::KEY_GetCommonPropertiesCallback =>
'getCommonClearPropertiesCallback',
758 self::KEY_ElementConstructCallback =>
null,
760 self::KEY_ElementCreateChildReferenceCallback =>
'createClearDependentElementChildReferenceCallback',
761 self::KEY_ElementCreateParentReferenceCallback =>
'createClearDependentElementParentReferenceCallback',
763 self::KEY_UpdateGetIdCallback =>
'getElementIdCallback',
765 self::KEY_TransformDependentElementsToUseLiveId => false
780 if (!isset($this->scopes[$scope])) {
781 throw new \RuntimeException(
'Scope "' . $scope .
'" is not defined.', 1289342187);
783 return $this->scopes[$scope][$key];
795 return GeneralUtility::makeInstance(
796 EventCallback::class,
812 return call_user_func_array([$this, $method], $callbackArguments);