| Total Complexity | 125 |
| Total Lines | 671 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like CommandContext often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CommandContext, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 84 | class CommandContext |
||
| 85 | { |
||
| 86 | //private final static ContextLogger LOG = ProcessEngineLogger.CONTEXT_LOGGER; |
||
| 87 | |||
| 88 | protected $authorizationCheckEnabled = true; |
||
| 89 | protected $userOperationLogEnabled = true; |
||
| 90 | protected $tenantCheckEnabled = true; |
||
| 91 | protected $restrictUserOperationLogToAuthenticatedUsers; |
||
| 92 | |||
| 93 | protected $transactionContext; |
||
| 94 | protected $sessionFactories = []; |
||
| 95 | protected $sessions = []; |
||
| 96 | protected $sessionList = []; |
||
| 97 | protected $processEngineConfiguration; |
||
| 98 | protected $failedJobCommandFactory; |
||
| 99 | |||
| 100 | protected $currentJob = null; |
||
| 101 | |||
| 102 | protected $commandContextListeners = []; |
||
| 103 | |||
| 104 | protected $operationId; |
||
| 105 | |||
| 106 | public function __construct(ProcessEngineConfigurationImpl $processEngineConfiguration, ?TransactionContextFactory $transactionContextFactory = null) |
||
| 107 | { |
||
| 108 | if ($transactionContextFactory == null) { |
||
| 109 | $transactionContextFactory = $processEngineConfiguration->getTransactionContextFactory(); |
||
|
|
|||
| 110 | } |
||
| 111 | $this->processEngineConfiguration = $processEngineConfiguration; |
||
| 112 | $this->failedJobCommandFactory = $processEngineConfiguration->getFailedJobCommandFactory(); |
||
| 113 | $this->sessionFactories = $processEngineConfiguration->getSessionFactories(); |
||
| 114 | $this->transactionContext = $transactionContextFactory->openTransactionContext($this); |
||
| 115 | $this->restrictUserOperationLogToAuthenticatedUsers = $processEngineConfiguration->isRestrictUserOperationLogToAuthenticatedUsers(); |
||
| 116 | } |
||
| 117 | |||
| 118 | public function performOperation(/*CmmnAtomicOperation*/$executionOperation, /*CaseExecutionEntity*/$execution): void |
||
| 119 | { |
||
| 120 | $targetProcessApplication = $this->getTargetProcessApplication($execution); |
||
| 121 | |||
| 122 | if ($this->requiresContextSwitch($targetProcessApplication)) { |
||
| 123 | $scope = $this; |
||
| 124 | Context::executeWithinProcessApplication(function () use ($scope, $executionOperation, $execution) { |
||
| 125 | $scope->performOperation($executionOperation, $execution); |
||
| 126 | }, $targetProcessApplication, new InvocationContext($execution)); |
||
| 127 | } else { |
||
| 128 | try { |
||
| 129 | Context::setExecutionContext($execution); |
||
| 130 | //LOG.debugExecutingAtomicOperation(executionOperation, execution); |
||
| 131 | $executionOperation->execute($execution); |
||
| 132 | } finally { |
||
| 133 | Context::removeExecutionContext(); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | public function getProcessEngineConfiguration(): ProcessEngineConfigurationImpl |
||
| 139 | { |
||
| 140 | return $this->processEngineConfiguration; |
||
| 141 | } |
||
| 142 | |||
| 143 | protected function getTargetProcessApplication(/*CaseExecutionEntity*/$execution): ProcessApplicationReferenceInterface |
||
| 144 | { |
||
| 145 | return ProcessApplicationContextUtil::getTargetProcessApplication($execution); |
||
| 146 | } |
||
| 147 | |||
| 148 | protected function requiresContextSwitch(ProcessApplicationReferenceInterface $processApplicationReference): bool |
||
| 149 | { |
||
| 150 | return ProcessApplicationContextUtil::requiresContextSwitch($processApplicationReference); |
||
| 151 | } |
||
| 152 | |||
| 153 | public function close(CommandInvocationContext $commandInvocationContext): void |
||
| 154 | { |
||
| 155 | // the intention of this method is that all resources are closed properly, |
||
| 156 | // even |
||
| 157 | // if exceptions occur in close or flush methods of the sessions or the |
||
| 158 | // transaction context. |
||
| 159 | |||
| 160 | try { |
||
| 161 | try { |
||
| 162 | try { |
||
| 163 | if ($commandInvocationContext->getThrowable() == null) { |
||
| 164 | $this->fireCommandContextClose(); |
||
| 165 | $this->flushSessions(); |
||
| 166 | } |
||
| 167 | } catch (\Throwable $exception) { |
||
| 168 | $commandInvocationContext->trySetThrowable($exception); |
||
| 169 | } finally { |
||
| 170 | try { |
||
| 171 | if ($commandInvocationContext->getThrowable() == null) { |
||
| 172 | $this->transactionContext->commit(); |
||
| 173 | } |
||
| 174 | } catch (\Throwable $exception) { |
||
| 175 | if (DbSqlSession::isCrdbConcurrencyConflict($exception)) { |
||
| 176 | //$exception = ProcessEngineLogger.PERSISTENCE_LOGGER.crdbTransactionRetryExceptionOnCommit(exception); |
||
| 177 | } |
||
| 178 | $commandInvocationContext->trySetThrowable($exception); |
||
| 179 | } |
||
| 180 | |||
| 181 | if ($commandInvocationContext->getThrowable() !== null) { |
||
| 182 | // fire command failed (must not fail itself) |
||
| 183 | $this->fireCommandFailed($commandInvocationContext->getThrowable()); |
||
| 184 | |||
| 185 | if ($this->shouldLogCmdException()) { |
||
| 186 | if ($this->shouldLogInfo($commandInvocationContext->getThrowable())) { |
||
| 187 | //LOG.infoException(commandInvocationContext->getThrowable()); |
||
| 188 | } elseif ($this->shouldLogFine($commandInvocationContext->getThrowable())) { |
||
| 189 | //LOG.debugException(commandInvocationContext->getThrowable()); |
||
| 190 | } else { |
||
| 191 | //LOG.errorException(commandInvocationContext->getThrowable()); |
||
| 192 | } |
||
| 193 | } |
||
| 194 | $this->transactionContext->rollback(); |
||
| 195 | } |
||
| 196 | } |
||
| 197 | } catch (\Throwable $exception) { |
||
| 198 | $commandInvocationContext->trySetThrowable($exception); |
||
| 199 | } finally { |
||
| 200 | $this->closeSessions($commandInvocationContext); |
||
| 201 | } |
||
| 202 | } catch (\Throwable $exception) { |
||
| 203 | $commandInvocationContext->trySetThrowable(exception); |
||
| 204 | } |
||
| 205 | |||
| 206 | // rethrow the original exception if there was one |
||
| 207 | $commandInvocationContext->rethrow(); |
||
| 208 | } |
||
| 209 | |||
| 210 | protected function shouldLogInfo(\Throwable $exception): bool |
||
| 211 | { |
||
| 212 | return $exception instanceof TaskAlreadyClaimedException; |
||
| 213 | } |
||
| 214 | |||
| 215 | protected function shouldLogFine(\Throwable $exception): bool |
||
| 216 | { |
||
| 217 | return $exception instanceof OptimisticLockingException || |
||
| 218 | $exception instanceof BadUserRequestException || |
||
| 219 | $exception instanceof AuthorizationException; |
||
| 220 | } |
||
| 221 | |||
| 222 | protected function shouldLogCmdException(): bool |
||
| 223 | { |
||
| 224 | //return ProcessEngineLogger::shouldLogCmdException($processEngineConfiguration); |
||
| 225 | return false; |
||
| 226 | } |
||
| 227 | |||
| 228 | protected function fireCommandContextClose(): void |
||
| 229 | { |
||
| 230 | foreach ($this->commandContextListeners as $listener) { |
||
| 231 | $listener->onCommandContextClose($this); |
||
| 232 | } |
||
| 233 | } |
||
| 234 | |||
| 235 | protected function fireCommandFailed(\Throwable $t): void |
||
| 236 | { |
||
| 237 | foreach ($this->commandContextListeners as $listener) { |
||
| 238 | try { |
||
| 239 | $listener->onCommandFailed($this, $t); |
||
| 240 | } catch (\Throwable $ex) { |
||
| 241 | //LOG.exceptionWhileInvokingOnCommandFailed(t); |
||
| 242 | } |
||
| 243 | } |
||
| 244 | } |
||
| 245 | |||
| 246 | protected function flushSessions(): void |
||
| 247 | { |
||
| 248 | for ($i = 0; $i < count($this->sessionList); $i += 1) { |
||
| 249 | $this->sessionList[$i]->flush(); |
||
| 250 | } |
||
| 251 | } |
||
| 252 | |||
| 253 | protected function closeSessions(CommandInvocationContext $commandInvocationContext): void |
||
| 254 | { |
||
| 255 | foreach ($this->sessionList as $session) { |
||
| 256 | try { |
||
| 257 | $session->close(); |
||
| 258 | } catch (\Throwable $exception) { |
||
| 259 | $commandInvocationContext->trySetThrowable($exception); |
||
| 260 | } |
||
| 261 | } |
||
| 262 | } |
||
| 263 | |||
| 264 | public function getSession($sessionClass) |
||
| 265 | { |
||
| 266 | $session = null; |
||
| 267 | if (array_key_exists($sessionClass, $this->sessions)) { |
||
| 268 | $session = $this->sessions[$sessionClass]; |
||
| 269 | } |
||
| 270 | if ($session == null) { |
||
| 271 | $sessionFactory = null; |
||
| 272 | if (array_key_exists($sessionClass, $this->sessionFactories)) { |
||
| 273 | $sessionFactory = $this->sessionFactories[$sessionClass]; |
||
| 274 | } |
||
| 275 | EnsureUtil::ensureNotNull("no session factory configured for " . $sessionClass, "sessionFactory", $sessionFactory); |
||
| 276 | $session = $sessionFactory->openSession(); |
||
| 277 | $this->sessions[$sessionClass] = $session; |
||
| 278 | array_unshift($this->sessionList, $session); |
||
| 279 | } |
||
| 280 | |||
| 281 | return $session; |
||
| 282 | } |
||
| 283 | |||
| 284 | public function addSession(string $sessionClass, DbSqlSession $session): void |
||
| 285 | { |
||
| 286 | $this->sessions[$sessionClass] = $session; |
||
| 287 | } |
||
| 288 | |||
| 289 | public function getDbEntityManager(): DbEntityManager |
||
| 290 | { |
||
| 291 | return $this->getSession(DbEntityManager::class); |
||
| 292 | } |
||
| 293 | |||
| 294 | public function getDbSqlSession(): DbSqlSession |
||
| 295 | { |
||
| 296 | return $this->getSession(DbSqlSession::class); |
||
| 297 | } |
||
| 298 | |||
| 299 | public function getDeploymentManager(): DeploymentManager |
||
| 300 | { |
||
| 301 | return $this->getSession(DeploymentManager::class); |
||
| 302 | } |
||
| 303 | |||
| 304 | public function getResourceManager(): ResourceManager |
||
| 305 | { |
||
| 306 | return $this->getSession(ResourceManager::class); |
||
| 307 | } |
||
| 308 | |||
| 309 | public function getByteArrayManager(): ByteArrayManager |
||
| 310 | { |
||
| 311 | return $this->getSession(ByteArrayManager::class); |
||
| 312 | } |
||
| 313 | |||
| 314 | public function getProcessDefinitionManager(): ProcessDefinitionManager |
||
| 315 | { |
||
| 316 | return $this->getSession(ProcessDefinitionManager::class); |
||
| 317 | } |
||
| 318 | |||
| 319 | public function getExecutionManager(): ExecutionManager |
||
| 320 | { |
||
| 321 | return $this->getSession(ExecutionManager::class); |
||
| 322 | } |
||
| 323 | |||
| 324 | public function getTaskManager(): TaskManager |
||
| 325 | { |
||
| 326 | return $this->getSession(TaskManager::class); |
||
| 327 | } |
||
| 328 | |||
| 329 | public function getTaskReportManager(): TaskReportManager |
||
| 330 | { |
||
| 331 | return $this->getSession(TaskReportManager::class); |
||
| 332 | } |
||
| 333 | |||
| 334 | public function getMeterLogManager(): MeterLogManager |
||
| 335 | { |
||
| 336 | return $this->getSession(MeterLogManager::class); |
||
| 337 | } |
||
| 338 | |||
| 339 | public function getIdentityLinkManager(): IdentityLinkManager |
||
| 340 | { |
||
| 341 | return $this->getSession(IdentityLinkManager::class); |
||
| 342 | } |
||
| 343 | |||
| 344 | public function getVariableInstanceManager(): VariableInstanceManager |
||
| 345 | { |
||
| 346 | return $this->getSession(VariableInstanceManager::class); |
||
| 347 | } |
||
| 348 | |||
| 349 | public function getHistoricProcessInstanceManager(): HistoricProcessInstanceManager |
||
| 350 | { |
||
| 351 | return $this->getSession(HistoricProcessInstanceManager::class); |
||
| 352 | } |
||
| 353 | |||
| 354 | /*public function getHistoricCaseInstanceManager(): HistoricCaseInstanceManager |
||
| 355 | { |
||
| 356 | return $this->getSession(HistoricCaseInstanceManager::class); |
||
| 357 | }*/ |
||
| 358 | |||
| 359 | public function getHistoricDetailManager(): HistoricDetailManager |
||
| 360 | { |
||
| 361 | return $this->getSession(HistoricDetailManager::class); |
||
| 362 | } |
||
| 363 | |||
| 364 | public function getOperationLogManager(): UserOperationLogManager |
||
| 365 | { |
||
| 366 | return $this->getSession(UserOperationLogManager::class); |
||
| 367 | } |
||
| 368 | |||
| 369 | public function getHistoricVariableInstanceManager(): HistoricVariableInstanceManager |
||
| 370 | { |
||
| 371 | return $this->getSession(HistoricVariableInstanceManager::class); |
||
| 372 | } |
||
| 373 | |||
| 374 | public function getHistoricActivityInstanceManager(): HistoricActivityInstanceManager |
||
| 375 | { |
||
| 376 | return $this->getSession(HistoricActivityInstanceManager::class); |
||
| 377 | } |
||
| 378 | |||
| 379 | public function getHistoricCaseActivityInstanceManager(): HistoricCaseActivityInstanceManager |
||
| 380 | { |
||
| 381 | return $this->getSession(HistoricCaseActivityInstanceManager::class); |
||
| 382 | } |
||
| 383 | |||
| 384 | public function getHistoricTaskInstanceManager(): HistoricTaskInstanceManager |
||
| 385 | { |
||
| 386 | return $this->getSession(HistoricTaskInstanceManager::class); |
||
| 387 | } |
||
| 388 | |||
| 389 | public function getHistoricIncidentManager(): HistoricIncidentManager |
||
| 390 | { |
||
| 391 | return $this->getSession(HistoricIncidentManager::class); |
||
| 392 | } |
||
| 393 | |||
| 394 | public function getHistoricIdentityLinkManager(): HistoricIdentityLinkLogManager |
||
| 395 | { |
||
| 396 | return $this->getSession(HistoricIdentityLinkLogManager::class); |
||
| 397 | } |
||
| 398 | |||
| 399 | public function getJobManager(): JobManager |
||
| 400 | { |
||
| 401 | return $this->getSession(JobManager::class); |
||
| 402 | } |
||
| 403 | |||
| 404 | public function getBatchManager(): BatchManager |
||
| 405 | { |
||
| 406 | return $this->getSession(BatchManager::class); |
||
| 407 | } |
||
| 408 | |||
| 409 | public function getHistoricBatchManager(): HistoricBatchManager |
||
| 410 | { |
||
| 411 | return $this->getSession(HistoricBatchManager::class); |
||
| 412 | } |
||
| 413 | |||
| 414 | public function getJobDefinitionManager(): JobDefinitionManager |
||
| 415 | { |
||
| 416 | return $this->getSession(JobDefinitionManager::class); |
||
| 417 | } |
||
| 418 | |||
| 419 | public function getIncidentManager(): IncidentManager |
||
| 420 | { |
||
| 421 | return $this->getSession(IncidentManager::class); |
||
| 422 | } |
||
| 423 | |||
| 424 | public function getIdentityInfoManager(): IdentityInfoManager |
||
| 425 | { |
||
| 426 | return $this->getSession(IdentityInfoManager::class); |
||
| 427 | } |
||
| 428 | |||
| 429 | public function getAttachmentManager(): AttachmentManager |
||
| 430 | { |
||
| 431 | return $this->getSession(AttachmentManager::class); |
||
| 432 | } |
||
| 433 | |||
| 434 | public function getTableDataManager(): TableDataManager |
||
| 435 | { |
||
| 436 | return $this->getSession(TableDataManager::class); |
||
| 437 | } |
||
| 438 | |||
| 439 | public function getCommentManager(): CommentManager |
||
| 440 | { |
||
| 441 | return $this->getSession(CommentManager::class); |
||
| 442 | } |
||
| 443 | |||
| 444 | public function getEventSubscriptionManager(): EventSubscriptionManager |
||
| 445 | { |
||
| 446 | return $this->getSession(EventSubscriptionManager::class); |
||
| 447 | } |
||
| 448 | |||
| 449 | public function getSessionFactories(): array |
||
| 450 | { |
||
| 451 | return $this->sessionFactories; |
||
| 452 | } |
||
| 453 | |||
| 454 | public function getPropertyManager(): PropertyManager |
||
| 455 | { |
||
| 456 | return $this->getSession(PropertyManager::class); |
||
| 457 | } |
||
| 458 | |||
| 459 | public function getStatisticsManager(): StatisticsManager |
||
| 460 | { |
||
| 461 | return $this->getSession(StatisticsManager::class); |
||
| 462 | } |
||
| 463 | |||
| 464 | public function getHistoricStatisticsManager(): HistoricStatisticsManager |
||
| 465 | { |
||
| 466 | return $this->getSession(HistoricStatisticsManager::class); |
||
| 467 | } |
||
| 468 | |||
| 469 | public function getHistoricJobLogManager(): HistoricJobLogManager |
||
| 470 | { |
||
| 471 | return $this->getSession(HistoricJobLogManager::class); |
||
| 472 | } |
||
| 473 | |||
| 474 | public function getHistoricExternalTaskLogManager(): HistoricExternalTaskLogManager |
||
| 475 | { |
||
| 476 | return $this->getSession(HistoricExternalTaskLogManager::class); |
||
| 477 | } |
||
| 478 | |||
| 479 | public function getHistoricReportManager(): ReportManager |
||
| 480 | { |
||
| 481 | return $this->getSession(ReportManager::class); |
||
| 482 | } |
||
| 483 | |||
| 484 | public function getAuthorizationManager(): AuthorizationManager |
||
| 485 | { |
||
| 486 | return $this->getSession(AuthorizationManager::class); |
||
| 487 | } |
||
| 488 | |||
| 489 | public function getReadOnlyIdentityProvider(): ReadOnlyIdentityProvider |
||
| 490 | { |
||
| 491 | return $this->getSession(ReadOnlyIdentityProvider::class); |
||
| 492 | } |
||
| 493 | |||
| 494 | public function getWritableIdentityProvider(): WritableIdentityProvider |
||
| 495 | { |
||
| 496 | return $this->getSession(WritableIdentityProvider::class); |
||
| 497 | } |
||
| 498 | |||
| 499 | public function getTenantManager(): TenantManager |
||
| 500 | { |
||
| 501 | return $this->getSession(TenantManager::class); |
||
| 502 | } |
||
| 503 | |||
| 504 | public function getSchemaLogManager(): SchemaLogManager |
||
| 505 | { |
||
| 506 | return $this->getSession(SchemaLogManager::class); |
||
| 507 | } |
||
| 508 | |||
| 509 | public function getFormDefinitionManager(): FormDefinitionManager |
||
| 510 | { |
||
| 511 | return $this->getSession(FormDefinitionManager::class); |
||
| 512 | } |
||
| 513 | |||
| 514 | // CMMN ///////////////////////////////////////////////////////////////////// |
||
| 515 | |||
| 516 | /*public CaseDefinitionManager getCaseDefinitionManager() { |
||
| 517 | return $this->getSession(CaseDefinitionManager::class); |
||
| 518 | } |
||
| 519 | |||
| 520 | public CaseExecutionManager getCaseExecutionManager() { |
||
| 521 | return $this->getSession(CaseExecutionManager::class); |
||
| 522 | } |
||
| 523 | |||
| 524 | public CaseSentryPartManager getCaseSentryPartManager() { |
||
| 525 | return $this->getSession(CaseSentryPartManager::class); |
||
| 526 | }*/ |
||
| 527 | |||
| 528 | // DMN ////////////////////////////////////////////////////////////////////// |
||
| 529 | |||
| 530 | /*public DecisionDefinitionManager getDecisionDefinitionManager() { |
||
| 531 | return $this->getSession(DecisionDefinitionManager::class); |
||
| 532 | } |
||
| 533 | |||
| 534 | public DecisionRequirementsDefinitionManager getDecisionRequirementsDefinitionManager() { |
||
| 535 | return $this->getSession(DecisionRequirementsDefinitionManager::class); |
||
| 536 | } |
||
| 537 | |||
| 538 | public HistoricDecisionInstanceManager getHistoricDecisionInstanceManager() { |
||
| 539 | return $this->getSession(HistoricDecisionInstanceManager::class); |
||
| 540 | }*/ |
||
| 541 | |||
| 542 | // Filter //////////////////////////////////////////////////////////////////// |
||
| 543 | |||
| 544 | public function getFilterManager(): FilterManager |
||
| 545 | { |
||
| 546 | return $this->getSession(FilterManager::class); |
||
| 547 | } |
||
| 548 | |||
| 549 | // External Tasks //////////////////////////////////////////////////////////// |
||
| 550 | |||
| 551 | public function getExternalTaskManager(): ExternalTaskManager |
||
| 552 | { |
||
| 553 | return $this->getSession(ExternalTaskManager::class); |
||
| 554 | } |
||
| 555 | |||
| 556 | // getters and setters ////////////////////////////////////////////////////// |
||
| 557 | |||
| 558 | public function registerCommandContextListener(CommandContextListenerInterface $commandContextListener): void |
||
| 559 | { |
||
| 560 | $exists = false; |
||
| 561 | foreach ($this->commandContextListeners as $listener) { |
||
| 562 | if ($listener == $commandContextListener) { |
||
| 563 | $exists = true; |
||
| 564 | } |
||
| 565 | } |
||
| 566 | if (!$exists) { |
||
| 567 | $this->commandContextListeners[] = $commandContextListener; |
||
| 568 | } |
||
| 569 | } |
||
| 570 | |||
| 571 | public function getTransactionContext(): TransactionContextInterface |
||
| 572 | { |
||
| 573 | return $this->transactionContext; |
||
| 574 | } |
||
| 575 | |||
| 576 | public function getSessions(): array |
||
| 577 | { |
||
| 578 | return $this->sessions; |
||
| 579 | } |
||
| 580 | |||
| 581 | public function getFailedJobCommandFactory(): FailedJobCommandFactoryInterface |
||
| 582 | { |
||
| 583 | return $this->failedJobCommandFactory; |
||
| 584 | } |
||
| 585 | |||
| 586 | public function getAuthentication(): Authentication |
||
| 587 | { |
||
| 588 | $identityService = $this->processEngineConfiguration->getIdentityService(); |
||
| 589 | return $identityService->getCurrentAuthentication(); |
||
| 590 | } |
||
| 591 | |||
| 592 | public function runWithoutAuthorization($command, ?CommandContext $commandContext = null) |
||
| 593 | { |
||
| 594 | if (is_callable($command)) { |
||
| 595 | if ($commandContext == null) { |
||
| 596 | $commandContext = Context::getCommandContext(); |
||
| 597 | } |
||
| 598 | $authorizationEnabled = $commandContext->isAuthorizationCheckEnabled(); |
||
| 599 | try { |
||
| 600 | $commandContext->disableAuthorizationCheck(); |
||
| 601 | return $command(); |
||
| 602 | } catch (\Exception $e) { |
||
| 603 | throw new ProcessEngineException($e->getMessage(), $e); |
||
| 604 | } finally { |
||
| 605 | if ($authorizationEnabled) { |
||
| 606 | $commandContext->enableAuthorizationCheck(); |
||
| 607 | } |
||
| 608 | } |
||
| 609 | } elseif ($command instanceof CommandInterface) { |
||
| 610 | $commandContext = Context::getCommandContext(); |
||
| 611 | return $this->runWithoutAuthorization( |
||
| 612 | function () use ($command, $commandContext) { |
||
| 613 | return $command->execute($commandContext); |
||
| 614 | }, |
||
| 615 | $commandContext |
||
| 616 | ); |
||
| 617 | } |
||
| 618 | } |
||
| 619 | |||
| 620 | public function getAuthenticatedUserId(): ?string |
||
| 621 | { |
||
| 622 | $identityService = $this->processEngineConfiguration->getIdentityService(); |
||
| 623 | $currentAuthentication = $identityService->getCurrentAuthentication(); |
||
| 624 | if ($currentAuthentication == null) { |
||
| 625 | return null; |
||
| 626 | } else { |
||
| 627 | return $currentAuthentication->getUserId(); |
||
| 628 | } |
||
| 629 | } |
||
| 630 | |||
| 631 | public function getAuthenticatedGroupIds(): array |
||
| 632 | { |
||
| 633 | $identityService = $this->processEngineConfiguration->getIdentityService(); |
||
| 634 | $currentAuthentication = $identityService->getCurrentAuthentication(); |
||
| 635 | if ($currentAuthentication == null) { |
||
| 636 | return []; |
||
| 637 | } else { |
||
| 638 | return $currentAuthentication->getGroupIds(); |
||
| 639 | } |
||
| 640 | } |
||
| 641 | |||
| 642 | public function enableAuthorizationCheck(): void |
||
| 645 | } |
||
| 646 | |||
| 647 | public function disableAuthorizationCheck(): void |
||
| 648 | { |
||
| 649 | $this->authorizationCheckEnabled = false; |
||
| 650 | } |
||
| 651 | |||
| 652 | public function isAuthorizationCheckEnabled(): bool |
||
| 653 | { |
||
| 654 | return $this->authorizationCheckEnabled; |
||
| 655 | } |
||
| 656 | |||
| 657 | public function setAuthorizationCheckEnabled(bool $authorizationCheckEnabled): void |
||
| 658 | { |
||
| 659 | $this->authorizationCheckEnabled = $authorizationCheckEnabled; |
||
| 660 | } |
||
| 661 | |||
| 662 | public function enableUserOperationLog(): void |
||
| 663 | { |
||
| 664 | $this->userOperationLogEnabled = true; |
||
| 665 | } |
||
| 666 | |||
| 667 | public function disableUserOperationLog(): void |
||
| 668 | { |
||
| 669 | $this->userOperationLogEnabled = false; |
||
| 670 | } |
||
| 671 | |||
| 672 | public function isUserOperationLogEnabled(): bool |
||
| 673 | { |
||
| 674 | return $this->userOperationLogEnabled; |
||
| 675 | } |
||
| 676 | |||
| 677 | public function setLogUserOperationEnabled(bool $userOperationLogEnabled): void |
||
| 678 | { |
||
| 679 | $this->userOperationLogEnabled = $userOperationLogEnabled; |
||
| 680 | } |
||
| 681 | |||
| 682 | public function enableTenantCheck(): void |
||
| 683 | { |
||
| 684 | $this->tenantCheckEnabled = true; |
||
| 685 | } |
||
| 686 | |||
| 687 | public function disableTenantCheck(): void |
||
| 688 | { |
||
| 689 | $this->tenantCheckEnabled = false; |
||
| 690 | } |
||
| 691 | |||
| 692 | public function setTenantCheckEnabled(bool $tenantCheckEnabled): void |
||
| 695 | } |
||
| 696 | |||
| 697 | public function isTenantCheckEnabled(): bool |
||
| 698 | { |
||
| 699 | return $this->tenantCheckEnabled; |
||
| 700 | } |
||
| 701 | |||
| 702 | public function getCurrentJob(): JobEntity |
||
| 703 | { |
||
| 704 | return $this->currentJob; |
||
| 705 | } |
||
| 706 | |||
| 707 | public function setCurrentJob(JobEntity $currentJob): void |
||
| 708 | { |
||
| 709 | $this->currentJob = $currentJob; |
||
| 710 | } |
||
| 711 | |||
| 712 | public function isRestrictUserOperationLogToAuthenticatedUsers(): bool |
||
| 713 | { |
||
| 714 | return $this->restrictUserOperationLogToAuthenticatedUsers; |
||
| 715 | } |
||
| 716 | |||
| 717 | public function setRestrictUserOperationLogToAuthenticatedUsers(bool $restrictUserOperationLogToAuthenticatedUsers): void |
||
| 718 | { |
||
| 719 | $this->restrictUserOperationLogToAuthenticatedUsers = $restrictUserOperationLogToAuthenticatedUsers; |
||
| 720 | } |
||
| 721 | |||
| 722 | public function getOperationId(): ?string |
||
| 723 | { |
||
| 724 | if (!$this->getOperationLogManager()->isUserOperationLogEnabled()) { |
||
| 725 | return null; |
||
| 726 | } |
||
| 727 | if ($this->operationId == null) { |
||
| 728 | $this->operationId = Context::getProcessEngineConfiguration()->getIdGenerator()->getNextId(); |
||
| 729 | } |
||
| 730 | return $this->operationId; |
||
| 731 | } |
||
| 732 | |||
| 733 | public function setOperationId(string $operationId): void |
||
| 734 | { |
||
| 735 | $this->operationId = $operationId; |
||
| 736 | } |
||
| 737 | |||
| 738 | public function getOptimizeManager(): OptimizeManager |
||
| 739 | { |
||
| 740 | return $this->getSession(OptimizeManager::class); |
||
| 741 | } |
||
| 742 | |||
| 743 | public function executeWithOperationLogPrevented(CommandInterface $command): void |
||
| 755 | } |
||
| 756 | } |
||
| 757 | } |
||
| 758 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.