metadata = $metadata; $this->injectableFactory = $injectableFactory; } /** * Create an ownership checker. * * @throws NotImplemented */ public function create(string $scope, AclManager $aclManager): OwnershipChecker { $className = $this->getClassName($scope); $bindingContainer = $this->createBindingContainer($aclManager); return $this->injectableFactory->createWithBinding($className, $bindingContainer); } private function getClassName(string $scope): string { $className = $this->metadata->get(['aclDefs', $scope, 'ownershipCheckerClassName']); if ($className) { return $className; } if (!$this->metadata->get(['scopes', $scope])) { throw new NotImplemented(); } return $this->defaultClassName; } private function createBindingContainer(AclManager $aclManager): BindingContainer { $bindingData = new BindingData(); $binder = new Binder($bindingData); $binder->bindCallback( AclManager::class, function () use ($aclManager): AclManager { return $aclManager; } ); return new BindingContainer($bindingData); } }