/** * Determine the base service name for authorization service keys * * @param AuthorizationEntity $entity * @return array */ protected function getBaseServiceNamesFromEntity(AuthorizationEntity $entity) { $services = array_keys($entity->getArrayCopy()); array_walk($services, function (&$serviceName) { $serviceName = preg_replace('/::.*?$/', '', $serviceName); }); return $services; }
protected function mapEntityToConfig(AuthorizationEntity $entity) { $normalized = []; foreach ($entity->getArrayCopy() as $spec => $privileges) { preg_match('/^(?P<service>[^:]+)(::(?P<action>.*))?$/', $spec, $matches); if (!isset($matches['action'])) { $normalized[$matches['service']]['actions']['index'] = $privileges; } elseif (preg_match('/^__(?P<type>collection|entity)__$/', $matches['action'], $actionMatches)) { $type = $actionMatches['type']; $normalized[$matches['service']][$type] = $privileges; } else { $normalized[$matches['service']]['actions'][$matches['action']] = $privileges; } } return $normalized; }