mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 04:30:08 +02:00
Fixed some deprecations.
This commit is contained in:
parent
4fa8eef1bf
commit
5fd608f42a
59 changed files with 202 additions and 165 deletions
|
@ -52,9 +52,9 @@ class AttachmentVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
return $this->resolver->inherit($user, 'parts_attachments', $attribute) ?? false;
|
||||
}
|
||||
|
@ -62,12 +62,12 @@ class AttachmentVoter extends ExtendedVoter
|
|||
/**
|
||||
* Determines if the attribute and subject are supported by this voter.
|
||||
*
|
||||
* @param string $attribute An attribute
|
||||
* @param string $attribute An attribute
|
||||
* @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type
|
||||
*
|
||||
* @return bool True if the attribute and subject are supported, false otherwise
|
||||
*/
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports(string $attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, Attachment::class, true)) {
|
||||
return in_array($attribute, $this->resolver->listOperationsForPermission('parts_attachments'), false);
|
||||
|
|
|
@ -92,7 +92,7 @@ abstract class ExtendedVoter extends Voter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
*/
|
||||
abstract protected function voteOnUser($attribute, $subject, User $user): bool;
|
||||
abstract protected function voteOnUser(string $attribute, $subject, User $user): bool;
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ class GroupVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
return $this->resolver->inherit($user, 'groups', $attribute) ?? false;
|
||||
}
|
||||
|
@ -61,12 +61,12 @@ class GroupVoter extends ExtendedVoter
|
|||
/**
|
||||
* Determines if the attribute and subject are supported by this voter.
|
||||
*
|
||||
* @param string $attribute An attribute
|
||||
* @param string $attribute An attribute
|
||||
* @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type
|
||||
*
|
||||
* @return bool True if the attribute and subject are supported, false otherwise
|
||||
*/
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports(string $attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, Group::class, true)) {
|
||||
return $this->resolver->isValidOperation('groups', $attribute);
|
||||
|
|
|
@ -37,12 +37,12 @@ class LabelProfileVoter extends ExtendedVoter
|
|||
'revert_element' => 'revert_element',
|
||||
];
|
||||
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
return $this->resolver->inherit($user, 'labels', self::MAPPING[$attribute]) ?? false;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
if ($subject instanceof LabelProfile) {
|
||||
if (!isset(self::MAPPING[$attribute])) {
|
||||
|
|
|
@ -49,7 +49,7 @@ class LogEntryVoter extends ExtendedVoter
|
|||
{
|
||||
public const ALLOWED_OPS = ['read', 'delete'];
|
||||
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
if ('delete' === $attribute) {
|
||||
return $this->resolver->inherit($user, 'system', 'delete_logs') ?? false;
|
||||
|
@ -70,7 +70,7 @@ class LogEntryVoter extends ExtendedVoter
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
if ($subject instanceof AbstractLogEntry) {
|
||||
return in_array($subject, static::ALLOWED_OPS, true);
|
||||
|
|
|
@ -33,7 +33,7 @@ class OrderdetailVoter extends ExtendedVoter
|
|||
*/
|
||||
protected const PART_PERMS = ['show_history', 'revert_element'];
|
||||
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
if (in_array($attribute, self::PART_PERMS, true)) {
|
||||
return $this->resolver->inherit($user, 'parts', $attribute) ?? false;
|
||||
|
@ -42,7 +42,7 @@ class OrderdetailVoter extends ExtendedVoter
|
|||
return $this->resolver->inherit($user, 'parts_orderdetails', $attribute) ?? false;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, Orderdetail::class, true)) {
|
||||
return in_array($attribute, array_merge(
|
||||
|
|
|
@ -33,7 +33,7 @@ class PartLotVoter extends ExtendedVoter
|
|||
*/
|
||||
protected const PART_PERMS = ['show_history', 'revert_element'];
|
||||
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
if (in_array($attribute, self::PART_PERMS, true)) {
|
||||
return $this->resolver->inherit($user, 'parts', $attribute) ?? false;
|
||||
|
@ -42,7 +42,7 @@ class PartLotVoter extends ExtendedVoter
|
|||
return $this->resolver->inherit($user, 'parts_lots', $attribute) ?? false;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, PartLot::class, true)) {
|
||||
return in_array($attribute, array_merge(
|
||||
|
|
|
@ -54,7 +54,7 @@ class PartVoter extends ExtendedVoter
|
|||
{
|
||||
public const READ = 'read';
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, Part::class, true)) {
|
||||
//Check if a sub permission should be checked -> $attribute has format name.edit
|
||||
|
@ -71,7 +71,7 @@ class PartVoter extends ExtendedVoter
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
//Check for sub permissions
|
||||
if (false !== strpos($attribute, '.')) {
|
||||
|
|
|
@ -55,9 +55,9 @@ class PermissionVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
$attribute = ltrim($attribute, '@');
|
||||
[$perm, $op] = explode('.', $attribute);
|
||||
|
@ -68,12 +68,12 @@ class PermissionVoter extends ExtendedVoter
|
|||
/**
|
||||
* Determines if the attribute and subject are supported by this voter.
|
||||
*
|
||||
* @param string $attribute An attribute
|
||||
* @param string $attribute An attribute
|
||||
* @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type
|
||||
*
|
||||
* @return bool True if the attribute and subject are supported, false otherwise
|
||||
*/
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports(string $attribute, $subject): bool
|
||||
{
|
||||
//Check if the attribute has the form @permission.operation
|
||||
if (preg_match('#^@\\w+\\.\\w+$#', $attribute)) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class PricedetailVoter extends ExtendedVoter
|
|||
*/
|
||||
protected const PART_PERMS = ['show_history', 'revert_element'];
|
||||
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
if (in_array($attribute, self::PART_PERMS, true)) {
|
||||
return $this->resolver->inherit($user, 'parts', $attribute) ?? false;
|
||||
|
@ -42,7 +42,7 @@ class PricedetailVoter extends ExtendedVoter
|
|||
return $this->resolver->inherit($user, 'parts_prices', $attribute) ?? false;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports($attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, Pricedetail::class, true)) {
|
||||
return in_array($attribute, array_merge(
|
||||
|
|
|
@ -72,12 +72,12 @@ class StructureVoter extends ExtendedVoter
|
|||
/**
|
||||
* Determines if the attribute and subject are supported by this voter.
|
||||
*
|
||||
* @param string $attribute An attribute
|
||||
* @param string $attribute An attribute
|
||||
* @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type
|
||||
*
|
||||
* @return bool True if the attribute and subject are supported, false otherwise
|
||||
*/
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports(string $attribute, $subject): bool
|
||||
{
|
||||
if (is_object($subject) || is_string($subject)) {
|
||||
$permission_name = $this->instanceToPermissionName($subject);
|
||||
|
@ -121,9 +121,9 @@ class StructureVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
$permission_name = $this->instanceToPermissionName($subject);
|
||||
//Just resolve the permission
|
||||
|
|
|
@ -50,12 +50,12 @@ class UserVoter extends ExtendedVoter
|
|||
/**
|
||||
* Determines if the attribute and subject are supported by this voter.
|
||||
*
|
||||
* @param string $attribute An attribute
|
||||
* @param string $attribute An attribute
|
||||
* @param mixed $subject The subject to secure, e.g. an object the user wants to access or any other PHP type
|
||||
*
|
||||
* @return bool True if the attribute and subject are supported, false otherwise
|
||||
*/
|
||||
protected function supports($attribute, $subject)
|
||||
protected function supports(string $attribute, $subject): bool
|
||||
{
|
||||
if (is_a($subject, User::class, true)) {
|
||||
return in_array($attribute, array_merge(
|
||||
|
@ -72,9 +72,9 @@ class UserVoter extends ExtendedVoter
|
|||
* Similar to voteOnAttribute, but checking for the anonymous user is already done.
|
||||
* The current user (or the anonymous user) is passed by $user.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param string $attribute
|
||||
*/
|
||||
protected function voteOnUser($attribute, $subject, User $user): bool
|
||||
protected function voteOnUser(string $attribute, $subject, User $user): bool
|
||||
{
|
||||
//Check if the checked user is the user itself
|
||||
if (($subject instanceof User) && $subject->getID() === $user->getID() &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue