UserFileStorage.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @package Grav\Common\Flex
  5. *
  6. * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
  7. * @license MIT License; see LICENSE file for details.
  8. */
  9. namespace Grav\Common\Flex\Types\Users\Storage;
  10. use Grav\Framework\Flex\Storage\FileStorage;
  11. /**
  12. * Class UserFileStorage
  13. * @package Grav\Common\Flex\Types\Users\Storage
  14. */
  15. class UserFileStorage extends FileStorage
  16. {
  17. /**
  18. * {@inheritdoc}
  19. * @see FlexStorageInterface::getMediaPath()
  20. */
  21. public function getMediaPath(string $key = null): ?string
  22. {
  23. // There is no media support for file storage (fallback to common location).
  24. return null;
  25. }
  26. /**
  27. * Prepares the row for saving and returns the storage key for the record.
  28. *
  29. * @param array $row
  30. */
  31. protected function prepareRow(array &$row): void
  32. {
  33. parent::prepareRow($row);
  34. $access = $row['access'] ?? [];
  35. unset($row['access']);
  36. if ($access) {
  37. $row['access'] = $access;
  38. }
  39. }
  40. }