Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Repository 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 Repository, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 31 | class Repository implements RepositoryInterface |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * Repository Handler object. |
||
| 35 | * |
||
| 36 | * @var \eZ\Publish\SPI\Persistence\Handler |
||
| 37 | */ |
||
| 38 | protected $persistenceHandler; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Instance of main Search Handler. |
||
| 42 | * |
||
| 43 | * @var \eZ\Publish\SPI\Search\Handler |
||
| 44 | */ |
||
| 45 | protected $searchHandler; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @deprecated since 6.6, to be removed. Current user handling is moved to PermissionResolver. |
||
| 49 | * |
||
| 50 | * Currently logged in user object if already loaded. |
||
| 51 | * |
||
| 52 | * @var \eZ\Publish\API\Repository\Values\User\User|null |
||
| 53 | */ |
||
| 54 | protected $currentUser; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @deprecated since 6.6, to be removed. Current user handling is moved to PermissionResolver. |
||
| 58 | * |
||
| 59 | * Currently logged in user reference for permission purposes. |
||
| 60 | * |
||
| 61 | * @var \eZ\Publish\API\Repository\Values\User\UserReference |
||
| 62 | */ |
||
| 63 | protected $currentUserRef; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Instance of content service. |
||
| 67 | * |
||
| 68 | * @var \eZ\Publish\API\Repository\ContentService |
||
| 69 | */ |
||
| 70 | protected $contentService; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Instance of section service. |
||
| 74 | * |
||
| 75 | * @var \eZ\Publish\API\Repository\SectionService |
||
| 76 | */ |
||
| 77 | protected $sectionService; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Instance of role service. |
||
| 81 | * |
||
| 82 | * @var \eZ\Publish\API\Repository\RoleService |
||
| 83 | */ |
||
| 84 | protected $roleService; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Instance of search service. |
||
| 88 | * |
||
| 89 | * @var \eZ\Publish\API\Repository\SearchService |
||
| 90 | */ |
||
| 91 | protected $searchService; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Instance of user service. |
||
| 95 | * |
||
| 96 | * @var \eZ\Publish\API\Repository\UserService |
||
| 97 | */ |
||
| 98 | protected $userService; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Instance of language service. |
||
| 102 | * |
||
| 103 | * @var \eZ\Publish\API\Repository\LanguageService |
||
| 104 | */ |
||
| 105 | protected $languageService; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Instance of location service. |
||
| 109 | * |
||
| 110 | * @var \eZ\Publish\API\Repository\LocationService |
||
| 111 | */ |
||
| 112 | protected $locationService; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Instance of Trash service. |
||
| 116 | * |
||
| 117 | * @var \eZ\Publish\API\Repository\TrashService |
||
| 118 | */ |
||
| 119 | protected $trashService; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Instance of content type service. |
||
| 123 | * |
||
| 124 | * @var \eZ\Publish\API\Repository\ContentTypeService |
||
| 125 | */ |
||
| 126 | protected $contentTypeService; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Instance of object state service. |
||
| 130 | * |
||
| 131 | * @var \eZ\Publish\API\Repository\ObjectStateService |
||
| 132 | */ |
||
| 133 | protected $objectStateService; |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Instance of field type service. |
||
| 137 | * |
||
| 138 | * @var \eZ\Publish\API\Repository\FieldTypeService |
||
| 139 | */ |
||
| 140 | protected $fieldTypeService; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Instance of FieldTypeRegistry. |
||
| 144 | * |
||
| 145 | * @var \eZ\Publish\Core\Repository\Helper\FieldTypeRegistry |
||
| 146 | */ |
||
| 147 | private $fieldTypeRegistry; |
||
| 148 | |||
| 149 | /** |
||
| 150 | * Instance of NameableFieldTypeRegistry. |
||
| 151 | * |
||
| 152 | * @var \eZ\Publish\Core\Repository\Helper\NameableFieldTypeRegistry |
||
| 153 | */ |
||
| 154 | private $nameableFieldTypeRegistry; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Instance of name schema resolver service. |
||
| 158 | * |
||
| 159 | * @var \eZ\Publish\Core\Repository\Helper\NameSchemaService |
||
| 160 | */ |
||
| 161 | protected $nameSchemaService; |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Instance of relation processor service. |
||
| 165 | * |
||
| 166 | * @var \eZ\Publish\Core\Repository\Helper\RelationProcessor |
||
| 167 | */ |
||
| 168 | protected $relationProcessor; |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Instance of URL alias service. |
||
| 172 | * |
||
| 173 | * @var \eZ\Publish\Core\Repository\URLAliasService |
||
| 174 | */ |
||
| 175 | protected $urlAliasService; |
||
| 176 | |||
| 177 | /** |
||
| 178 | * Instance of URL wildcard service. |
||
| 179 | * |
||
| 180 | * @var \eZ\Publish\Core\Repository\URLWildcardService |
||
| 181 | */ |
||
| 182 | protected $urlWildcardService; |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Instance of URL service. |
||
| 186 | * |
||
| 187 | * @var \eZ\Publish\Core\Repository\URLService |
||
| 188 | */ |
||
| 189 | protected $urlService; |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Instance of Bookmark service. |
||
| 193 | * |
||
| 194 | * @var \eZ\Publish\API\Repository\BookmarkService |
||
| 195 | */ |
||
| 196 | protected $bookmarkService; |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Instance of Notification service. |
||
| 200 | * |
||
| 201 | * @var \eZ\Publish\API\Repository\NotificationService |
||
| 202 | */ |
||
| 203 | protected $notificationService; |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Instance of User Preference service. |
||
| 207 | * |
||
| 208 | * @var \eZ\Publish\API\Repository\UserPreferenceService |
||
| 209 | */ |
||
| 210 | protected $userPreferenceService; |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Service settings, first level key is service name. |
||
| 214 | * |
||
| 215 | * @var array |
||
| 216 | */ |
||
| 217 | protected $serviceSettings; |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Instance of role service. |
||
| 221 | * |
||
| 222 | * @var \eZ\Publish\Core\Repository\Helper\LimitationService |
||
| 223 | */ |
||
| 224 | protected $limitationService; |
||
| 225 | |||
| 226 | /** @var \eZ\Publish\Core\Repository\Helper\RoleDomainMapper */ |
||
| 227 | protected $roleDomainMapper; |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Instance of domain mapper. |
||
| 231 | * |
||
| 232 | * @var \eZ\Publish\Core\Repository\Helper\DomainMapper |
||
| 233 | */ |
||
| 234 | protected $domainMapper; |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Instance of content type domain mapper. |
||
| 238 | * |
||
| 239 | * @var \eZ\Publish\Core\Repository\Helper\ContentTypeDomainMapper |
||
| 240 | */ |
||
| 241 | protected $contentTypeDomainMapper; |
||
| 242 | |||
| 243 | /** |
||
| 244 | * Instance of permissions-resolver and -criterion resolver. |
||
| 245 | * |
||
| 246 | * @var \eZ\Publish\API\Repository\PermissionCriterionResolver|\eZ\Publish\API\Repository\PermissionResolver |
||
| 247 | */ |
||
| 248 | protected $permissionsHandler; |
||
| 249 | |||
| 250 | /** @var \eZ\Publish\Core\Search\Common\BackgroundIndexer|null */ |
||
| 251 | protected $backgroundIndexer; |
||
| 252 | |||
| 253 | /** @var \Psr\Log\LoggerInterface */ |
||
| 254 | private $logger; |
||
| 255 | |||
| 256 | /** |
||
| 257 | * Constructor. |
||
| 258 | * |
||
| 259 | * Construct repository object with provided storage engine |
||
| 260 | * |
||
| 261 | * @param \eZ\Publish\SPI\Persistence\Handler $persistenceHandler |
||
| 262 | * @param \eZ\Publish\SPI\Search\Handler $searchHandler |
||
| 263 | * @param \eZ\Publish\Core\Search\Common\BackgroundIndexer $backgroundIndexer |
||
| 264 | * @param \eZ\Publish\Core\Repository\Helper\RelationProcessor $relationProcessor |
||
| 265 | * @param array $serviceSettings |
||
| 266 | * @param \eZ\Publish\API\Repository\Values\User\UserReference|null $user |
||
| 267 | * @param \Psr\Log\LoggerInterface|null $logger |
||
| 268 | */ |
||
| 269 | public function __construct( |
||
| 319 | |||
| 320 | /** |
||
| 321 | * @deprecated since 6.6, to be removed. Use PermissionResolver::getCurrentUserReference() instead. |
||
| 322 | * |
||
| 323 | * Get current user. |
||
| 324 | * |
||
| 325 | * Loads the full user object if not already loaded, if you only need to know user id use {@see getCurrentUserReference()} |
||
| 326 | * |
||
| 327 | * @return \eZ\Publish\API\Repository\Values\User\User |
||
| 328 | */ |
||
| 329 | public function getCurrentUser() |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @deprecated since 6.6, to be removed. Use PermissionResolver::getCurrentUserReference() instead. |
||
| 342 | * |
||
| 343 | * Get current user reference. |
||
| 344 | * |
||
| 345 | * @since 5.4.5 |
||
| 346 | * @return \eZ\Publish\API\Repository\Values\User\UserReference |
||
| 347 | */ |
||
| 348 | public function getCurrentUserReference() |
||
| 352 | |||
| 353 | /** |
||
| 354 | * @deprecated since 6.6, to be removed. Use PermissionResolver::setCurrentUserReference() instead. |
||
| 355 | * |
||
| 356 | * Sets the current user to the given $user. |
||
| 357 | * |
||
| 358 | * @param \eZ\Publish\API\Repository\Values\User\UserReference $user |
||
| 359 | * |
||
| 360 | * @throws InvalidArgumentValue If UserReference does not contain a id |
||
| 361 | */ |
||
| 362 | public function setCurrentUser(APIUserReference $user) |
||
| 379 | |||
| 380 | /** |
||
| 381 | * {@inheritdoc} |
||
| 382 | */ |
||
| 383 | public function sudo(callable $callback, RepositoryInterface $outerRepository = null) |
||
| 384 | { |
||
| 385 | return $this->getPermissionResolver()->sudo($callback, $outerRepository ?? $this); |
||
| 386 | } |
||
| 387 | |||
| 388 | /** |
||
| 389 | * @deprecated since 6.6, to be removed. Use PermissionResolver::hasAccess() instead. |
||
| 390 | * |
||
| 391 | * Check if user has access to a given module / function. |
||
| 392 | * |
||
| 393 | * Low level function, use canUser instead if you have objects to check against. |
||
| 394 | * |
||
| 395 | * @param string $module |
||
| 396 | * @param string $function |
||
| 397 | * @param \eZ\Publish\API\Repository\Values\User\UserReference $user |
||
| 398 | * |
||
| 399 | * @return bool|array Bool if user has full or no access, array if limitations if not |
||
| 400 | */ |
||
| 401 | public function hasAccess($module, $function, APIUserReference $user = null) |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @deprecated since 6.6, to be removed. Use PermissionResolver::canUser() instead. |
||
| 408 | * |
||
| 409 | * Check if user has access to a given action on a given value object. |
||
| 410 | * |
||
| 411 | * Indicates if the current user is allowed to perform an action given by the function on the given |
||
| 412 | * objects. |
||
| 413 | * |
||
| 414 | * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If any of the arguments are invalid |
||
| 415 | * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If value of the LimitationValue is unsupported |
||
| 416 | * |
||
| 417 | * @param string $module The module, aka controller identifier to check permissions on |
||
| 418 | * @param string $function The function, aka the controller action to check permissions on |
||
| 419 | * @param \eZ\Publish\API\Repository\Values\ValueObject $object The object to check if the user has access to |
||
| 420 | * @param mixed $targets The location, parent or "assignment" value object, or an array of the same |
||
| 421 | * |
||
| 422 | * @return bool |
||
| 423 | */ |
||
| 424 | public function canUser($module, $function, ValueObject $object, $targets = null) |
||
| 440 | |||
| 441 | /** |
||
| 442 | * Get Content Service. |
||
| 443 | * |
||
| 444 | * Get service object to perform operations on Content objects and it's aggregate members. |
||
| 445 | * |
||
| 446 | * @return \eZ\Publish\API\Repository\ContentService |
||
| 447 | */ |
||
| 448 | public function getContentService() |
||
| 449 | { |
||
| 450 | if ($this->contentService !== null) { |
||
| 451 | return $this->contentService; |
||
| 452 | } |
||
| 453 | |||
| 454 | $this->contentService = new ContentService( |
||
| 455 | $this, |
||
| 456 | $this->persistenceHandler, |
||
| 457 | $this->getDomainMapper(), |
||
| 458 | $this->getRelationProcessor(), |
||
| 459 | $this->getNameSchemaService(), |
||
| 460 | $this->getFieldTypeRegistry(), |
||
| 461 | $this->serviceSettings['content'] |
||
| 462 | ); |
||
| 463 | |||
| 464 | return $this->contentService; |
||
| 465 | } |
||
| 466 | |||
| 467 | /** |
||
| 468 | * Get Content Language Service. |
||
| 469 | * |
||
| 470 | * Get service object to perform operations on Content language objects |
||
| 471 | * |
||
| 472 | * @return \eZ\Publish\API\Repository\LanguageService |
||
| 473 | */ |
||
| 474 | public function getContentLanguageService() |
||
| 488 | |||
| 489 | /** |
||
| 490 | * Get Content Type Service. |
||
| 491 | * |
||
| 492 | * Get service object to perform operations on Content Type objects and it's aggregate members. |
||
| 493 | * ( Group, Field & FieldCategory ) |
||
| 494 | * |
||
| 495 | * @return \eZ\Publish\API\Repository\ContentTypeService |
||
| 496 | */ |
||
| 497 | View Code Duplication | public function getContentTypeService() |
|
| 498 | { |
||
| 499 | if ($this->contentTypeService !== null) { |
||
| 500 | return $this->contentTypeService; |
||
| 501 | } |
||
| 502 | |||
| 503 | $this->contentTypeService = new ContentTypeService( |
||
| 504 | $this, |
||
| 505 | $this->persistenceHandler->contentTypeHandler(), |
||
| 506 | $this->persistenceHandler->userHandler(), |
||
| 507 | $this->getDomainMapper(), |
||
| 508 | $this->getContentTypeDomainMapper(), |
||
| 509 | $this->getFieldTypeRegistry(), |
||
| 510 | $this->serviceSettings['contentType'] |
||
| 511 | ); |
||
| 512 | |||
| 513 | return $this->contentTypeService; |
||
| 514 | } |
||
| 515 | |||
| 516 | /** |
||
| 517 | * Get Content Location Service. |
||
| 518 | * |
||
| 519 | * Get service object to perform operations on Location objects and subtrees |
||
| 520 | * |
||
| 521 | * @return \eZ\Publish\API\Repository\LocationService |
||
| 522 | */ |
||
| 523 | public function getLocationService() |
||
| 524 | { |
||
| 525 | if ($this->locationService !== null) { |
||
| 526 | return $this->locationService; |
||
| 527 | } |
||
| 528 | |||
| 529 | $this->locationService = new LocationService( |
||
| 530 | $this, |
||
| 531 | $this->persistenceHandler, |
||
| 532 | $this->getDomainMapper(), |
||
| 533 | $this->getNameSchemaService(), |
||
| 534 | $this->getPermissionCriterionResolver(), |
||
| 535 | $this->serviceSettings['location'], |
||
| 536 | $this->logger |
||
| 537 | ); |
||
| 538 | |||
| 539 | return $this->locationService; |
||
| 540 | } |
||
| 541 | |||
| 542 | /** |
||
| 543 | * Get Content Trash service. |
||
| 544 | * |
||
| 545 | * Trash service allows to perform operations related to location trash |
||
| 546 | * (trash/untrash, load/list from trash...) |
||
| 547 | * |
||
| 548 | * @return \eZ\Publish\API\Repository\TrashService |
||
| 549 | */ |
||
| 550 | public function getTrashService() |
||
| 551 | { |
||
| 552 | if ($this->trashService !== null) { |
||
| 553 | return $this->trashService; |
||
| 554 | } |
||
| 555 | |||
| 556 | $this->trashService = new TrashService( |
||
| 557 | $this, |
||
| 558 | $this->persistenceHandler, |
||
| 559 | $this->getNameSchemaService(), |
||
| 560 | $this->getPermissionCriterionResolver(), |
||
| 561 | $this->serviceSettings['trash'] |
||
| 562 | ); |
||
| 563 | |||
| 564 | return $this->trashService; |
||
| 565 | } |
||
| 566 | |||
| 567 | /** |
||
| 568 | * Get Content Section Service. |
||
| 569 | * |
||
| 570 | * Get Section service that lets you manipulate section objects |
||
| 571 | * |
||
| 572 | * @return \eZ\Publish\API\Repository\SectionService |
||
| 573 | */ |
||
| 574 | public function getSectionService() |
||
| 575 | { |
||
| 576 | if ($this->sectionService !== null) { |
||
| 577 | return $this->sectionService; |
||
| 578 | } |
||
| 579 | |||
| 580 | $this->sectionService = new SectionService( |
||
| 581 | $this, |
||
| 582 | $this->persistenceHandler->sectionHandler(), |
||
| 583 | $this->persistenceHandler->locationHandler(), |
||
| 584 | $this->getPermissionCriterionResolver(), |
||
| 585 | $this->serviceSettings['section'] |
||
| 586 | ); |
||
| 587 | |||
| 588 | return $this->sectionService; |
||
| 589 | } |
||
| 590 | |||
| 591 | /** |
||
| 592 | * Get User Service. |
||
| 593 | * |
||
| 594 | * Get service object to perform operations on Users and UserGroup |
||
| 595 | * |
||
| 596 | * @return \eZ\Publish\API\Repository\UserService |
||
| 597 | */ |
||
| 598 | public function getUserService() |
||
| 599 | { |
||
| 600 | if ($this->userService !== null) { |
||
| 601 | return $this->userService; |
||
| 602 | } |
||
| 603 | |||
| 604 | $this->userService = new UserService( |
||
| 605 | $this, |
||
| 606 | $this->persistenceHandler->userHandler(), |
||
| 607 | $this->persistenceHandler->locationHandler(), |
||
| 608 | $this->serviceSettings['user'] |
||
| 609 | ); |
||
| 610 | |||
| 611 | return $this->userService; |
||
| 612 | } |
||
| 613 | |||
| 614 | /** |
||
| 615 | * Get URLAliasService. |
||
| 616 | * |
||
| 617 | * @return \eZ\Publish\API\Repository\URLAliasService |
||
| 618 | */ |
||
| 619 | public function getURLAliasService() |
||
| 620 | { |
||
| 621 | if ($this->urlAliasService !== null) { |
||
| 622 | return $this->urlAliasService; |
||
| 623 | } |
||
| 624 | |||
| 625 | $this->urlAliasService = new URLAliasService( |
||
| 626 | $this, |
||
| 627 | $this->persistenceHandler->urlAliasHandler(), |
||
| 628 | $this->getNameSchemaService(), |
||
| 629 | $this->getPermissionResolver(), |
||
| 630 | $this->serviceSettings['urlAlias'] |
||
| 631 | ); |
||
| 632 | |||
| 633 | return $this->urlAliasService; |
||
| 634 | } |
||
| 635 | |||
| 636 | /** |
||
| 637 | * Get URLWildcardService. |
||
| 638 | * |
||
| 639 | * @return \eZ\Publish\API\Repository\URLWildcardService |
||
| 640 | */ |
||
| 641 | public function getURLWildcardService() |
||
| 642 | { |
||
| 643 | if ($this->urlWildcardService !== null) { |
||
| 644 | return $this->urlWildcardService; |
||
| 645 | } |
||
| 646 | |||
| 647 | $this->urlWildcardService = new URLWildcardService( |
||
| 648 | $this, |
||
| 649 | $this->persistenceHandler->urlWildcardHandler(), |
||
| 650 | $this->getPermissionResolver(), |
||
| 651 | $this->serviceSettings['urlWildcard'] |
||
| 652 | ); |
||
| 653 | |||
| 654 | return $this->urlWildcardService; |
||
| 655 | } |
||
| 656 | |||
| 657 | /** |
||
| 658 | * Get URLService. |
||
| 659 | * |
||
| 660 | * @return \eZ\Publish\API\Repository\URLService |
||
| 661 | */ |
||
| 662 | public function getURLService() |
||
| 663 | { |
||
| 664 | if ($this->urlService !== null) { |
||
| 665 | return $this->urlService; |
||
| 666 | } |
||
| 667 | |||
| 668 | $this->urlService = new URLService( |
||
| 669 | $this, |
||
| 670 | $this->persistenceHandler->urlHandler(), |
||
| 671 | $this->getPermissionResolver() |
||
| 672 | ); |
||
| 673 | |||
| 674 | return $this->urlService; |
||
| 675 | } |
||
| 676 | |||
| 677 | /** |
||
| 678 | * Get BookmarkService. |
||
| 679 | * |
||
| 680 | * @return \eZ\Publish\API\Repository\BookmarkService |
||
| 681 | */ |
||
| 682 | public function getBookmarkService() |
||
| 693 | |||
| 694 | /** |
||
| 695 | * Get UserPreferenceService. |
||
| 696 | * |
||
| 697 | * @return \eZ\Publish\API\Repository\UserPreferenceService |
||
| 698 | */ |
||
| 699 | public function getUserPreferenceService() |
||
| 710 | |||
| 711 | /** |
||
| 712 | * Get ObjectStateService. |
||
| 713 | * |
||
| 714 | * @return \eZ\Publish\API\Repository\ObjectStateService |
||
| 715 | */ |
||
| 716 | public function getObjectStateService() |
||
| 730 | |||
| 731 | /** |
||
| 732 | * Get RoleService. |
||
| 733 | * |
||
| 734 | * @return \eZ\Publish\API\Repository\RoleService |
||
| 735 | */ |
||
| 736 | public function getRoleService() |
||
| 752 | |||
| 753 | /** |
||
| 754 | * Get LimitationService. |
||
| 755 | * |
||
| 756 | * @return \eZ\Publish\Core\Repository\Helper\LimitationService |
||
| 757 | */ |
||
| 758 | protected function getLimitationService() |
||
| 768 | |||
| 769 | /** |
||
| 770 | * Get RoleDomainMapper. |
||
| 771 | * |
||
| 772 | * @return \eZ\Publish\Core\Repository\Helper\RoleDomainMapper |
||
| 773 | */ |
||
| 774 | protected function getRoleDomainMapper() |
||
| 784 | |||
| 785 | /** |
||
| 786 | * Get SearchService. |
||
| 787 | * |
||
| 788 | * @return \eZ\Publish\API\Repository\SearchService |
||
| 789 | */ |
||
| 790 | public function getSearchService() |
||
| 807 | |||
| 808 | /** |
||
| 809 | * Get FieldTypeService. |
||
| 810 | * |
||
| 811 | * @return \eZ\Publish\API\Repository\FieldTypeService |
||
| 812 | */ |
||
| 813 | public function getFieldTypeService() |
||
| 823 | |||
| 824 | /** |
||
| 825 | * Get PermissionResolver. |
||
| 826 | * |
||
| 827 | * @return \eZ\Publish\API\Repository\PermissionResolver |
||
| 828 | */ |
||
| 829 | public function getPermissionResolver() |
||
| 833 | |||
| 834 | /** |
||
| 835 | * @return Helper\FieldTypeRegistry |
||
| 836 | */ |
||
| 837 | protected function getFieldTypeRegistry() |
||
| 847 | |||
| 848 | /** |
||
| 849 | * @return Helper\NameableFieldTypeRegistry |
||
| 850 | */ |
||
| 851 | protected function getNameableFieldTypeRegistry() |
||
| 861 | |||
| 862 | /** |
||
| 863 | * Get NameSchemaResolverService. |
||
| 864 | * |
||
| 865 | * |
||
| 866 | * @todo Move out from this & other repo instances when services becomes proper services in DIC terms using factory. |
||
| 867 | * |
||
| 868 | * @internal |
||
| 869 | * @private |
||
| 870 | * |
||
| 871 | * @return \eZ\Publish\Core\Repository\Helper\NameSchemaService |
||
| 872 | */ |
||
| 873 | public function getNameSchemaService() |
||
| 888 | |||
| 889 | /** |
||
| 890 | * @return \eZ\Publish\API\Repository\NotificationService |
||
| 891 | */ |
||
| 892 | public function getNotificationService(): NotificationServiceInterface |
||
| 905 | |||
| 906 | /** |
||
| 907 | * Get RelationProcessor. |
||
| 908 | * |
||
| 909 | * |
||
| 910 | * @todo Move out from this & other repo instances when services becomes proper services in DIC terms using factory. |
||
| 911 | * |
||
| 912 | * @return \eZ\Publish\Core\Repository\Helper\RelationProcessor |
||
| 913 | */ |
||
| 914 | protected function getRelationProcessor() |
||
| 918 | |||
| 919 | /** |
||
| 920 | * Get Content Domain Mapper. |
||
| 921 | * |
||
| 922 | * @todo Move out from this & other repo instances when services becomes proper services in DIC terms using factory. |
||
| 923 | * |
||
| 924 | * @return \eZ\Publish\Core\Repository\Helper\DomainMapper |
||
| 925 | */ |
||
| 926 | View Code Duplication | protected function getDomainMapper() |
|
| 927 | { |
||
| 928 | if ($this->domainMapper !== null) { |
||
| 929 | return $this->domainMapper; |
||
| 930 | } |
||
| 931 | |||
| 932 | $this->domainMapper = new Helper\DomainMapper( |
||
| 933 | $this->persistenceHandler->contentHandler(), |
||
| 934 | $this->persistenceHandler->locationHandler(), |
||
| 935 | $this->persistenceHandler->contentTypeHandler(), |
||
| 936 | $this->getContentTypeDomainMapper(), |
||
| 937 | $this->persistenceHandler->contentLanguageHandler(), |
||
| 938 | $this->getFieldTypeRegistry() |
||
| 939 | ); |
||
| 940 | |||
| 941 | return $this->domainMapper; |
||
| 942 | } |
||
| 943 | |||
| 944 | /** |
||
| 945 | * Get ContentType Domain Mapper. |
||
| 946 | * |
||
| 947 | * @todo Move out from this & other repo instances when services becomes proper services in DIC terms using factory. |
||
| 948 | * |
||
| 949 | * @return \eZ\Publish\Core\Repository\Helper\ContentTypeDomainMapper |
||
| 950 | */ |
||
| 951 | protected function getContentTypeDomainMapper() |
||
| 965 | |||
| 966 | /** |
||
| 967 | * Get PermissionCriterionResolver. |
||
| 968 | * |
||
| 969 | * @todo Move out from this & other repo instances when services becomes proper services in DIC terms using factory. |
||
| 970 | * |
||
| 971 | * @return \eZ\Publish\API\Repository\PermissionCriterionResolver |
||
| 972 | */ |
||
| 973 | protected function getPermissionCriterionResolver() |
||
| 977 | |||
| 978 | /** |
||
| 979 | * @return \eZ\Publish\API\Repository\PermissionCriterionResolver|\eZ\Publish\API\Repository\PermissionResolver |
||
| 980 | */ |
||
| 981 | protected function getCachedPermissionsResolver() |
||
| 1001 | |||
| 1002 | /** |
||
| 1003 | * Begin transaction. |
||
| 1004 | * |
||
| 1005 | * Begins an transaction, make sure you'll call commit or rollback when done, |
||
| 1006 | * otherwise work will be lost. |
||
| 1007 | */ |
||
| 1008 | public function beginTransaction() |
||
| 1012 | |||
| 1013 | /** |
||
| 1014 | * Commit transaction. |
||
| 1015 | * |
||
| 1016 | * Commit transaction, or throw exceptions if no transactions has been started. |
||
| 1017 | * |
||
| 1018 | * @throws RuntimeException If no transaction has been started |
||
| 1019 | */ |
||
| 1020 | public function commit() |
||
| 1028 | |||
| 1029 | /** |
||
| 1030 | * Rollback transaction. |
||
| 1031 | * |
||
| 1032 | * Rollback transaction, or throw exceptions if no transactions has been started. |
||
| 1033 | * |
||
| 1034 | * @throws RuntimeException If no transaction has been started |
||
| 1035 | */ |
||
| 1036 | public function rollback() |
||
| 1044 | } |
||
| 1045 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: