classFinder = $classFinder; $this->metadata = $metadata; $this->injectableFactory = $injectableFactory; } /** * Create an access checker. * * @throws NotImplemented */ public function create(string $scope, AclManager $aclManager): AccessChecker { $className = $this->getClassName($scope); $bindingContainer = $this->createBindingContainer($aclManager); return $this->injectableFactory->createWithBinding($className, $bindingContainer); } private function getClassName(string $scope): string { $className1 = $this->metadata->get(['aclDefs', $scope, 'accessCheckerClassName']); if ($className1) { return $className1; } if (!$this->metadata->get(['scopes', $scope])) { throw new NotImplemented(); } // For backward compatibility. $className2 = $this->classFinder->find('Acl', $scope); if ($className2) { return $className2; } 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); } }