Fixed scope edition
scope edition was erroring bc a wrong api call. Change-Id: If9a17d8fef611fdf2d68d3b39e2742d67e3dd441
This commit is contained in:
parent
dff98a009a
commit
4bf8eced7f
@ -70,4 +70,15 @@ final class CacheApiScopeRepository extends BaseCacheRepository implements IApiS
|
||||
return $this->repository->getAssignableByGroups();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scope_name
|
||||
* @return IApiScope
|
||||
*/
|
||||
public function getFirstByName($scope_name)
|
||||
{
|
||||
return Cache::remember($this->cache_base_key.'_'.$scope_name, $this->cache_minutes_lifetime, function() use($scope_name) {
|
||||
return $this->repository->getFirstByName($scope_name);
|
||||
});
|
||||
}
|
||||
}
|
@ -69,4 +69,13 @@ final class EloquentApiScopeRepository extends AbstractEloquentEntityRepository
|
||||
->where('assigned_by_groups', '=', true)
|
||||
->orderBy('api_id')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scope_name
|
||||
* @return IApiScope
|
||||
*/
|
||||
public function getFirstByName($scope_name)
|
||||
{
|
||||
return $this->entity->where('active', '=', true)->where('name', $scope_name)->first();
|
||||
}
|
||||
}
|
@ -160,7 +160,7 @@ final class ApiScopeService implements IApiScopeService
|
||||
|
||||
if ($param == 'name') {
|
||||
//check if we have a former scope with selected name
|
||||
$former_scope = $this->repository->getByName($params[$param]);
|
||||
$former_scope = $this->repository->getFirstByName($params[$param]);
|
||||
|
||||
if (!is_null($former_scope) && $former_scope->id != $id) {
|
||||
throw new InvalidApiScope(sprintf('scope name %s already exists!', $params[$param]));
|
||||
|
@ -25,6 +25,12 @@ interface IApiScopeRepository extends IBaseRepository
|
||||
*/
|
||||
public function getByName(array $scopes_names);
|
||||
|
||||
/**
|
||||
* @param string $scope_name
|
||||
* @return IApiScope
|
||||
*/
|
||||
public function getFirstByName($scope_name);
|
||||
|
||||
/**
|
||||
* @return IApiScope[]
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user