You are here

public static function Imce::processUserConf in IMCE 8

Same name and namespace in other branches
  1. 8.2 src/Imce.php \Drupal\imce\Imce::processUserConf()

Processes raw profile configuration of a user.

1 call to Imce::processUserConf()
Imce::userConf in src/Imce.php
Returns processed profile configuration for a user.

File

src/Imce.php, line 92

Class

Imce
Imce container class for helper methods.

Namespace

Drupal\imce

Code

public static function processUserConf(array $conf, AccountProxyInterface $user) {

  // Convert MB to bytes.
  $conf['maxsize'] *= 1048576;
  $conf['quota'] *= 1048576;

  // Check php max upload size.
  $phpmaxsize = Environment::getUploadMaxSize();
  if ($phpmaxsize && (!$conf['maxsize'] || $phpmaxsize < $conf['maxsize'])) {
    $conf['maxsize'] = $phpmaxsize;
  }

  // Set root uri and url.
  $conf['root_uri'] = $conf['scheme'] . '://';

  // file_create_url requires a filepath for some schemes like private:// .
  $conf['root_url'] = preg_replace('@/(?:%2E|\\.)$@i', '', file_create_url($conf['root_uri'] . '.'));

  // Convert to relative.
  if (!\Drupal::config('imce.settings')
    ->get('abs_urls')) {
    $conf['root_url'] = file_url_transform_relative($conf['root_url']);
  }
  $conf['token'] = $user
    ->isAnonymous() ? 'anon' : \Drupal::csrfToken()
    ->get('imce');

  // Process folders.
  $conf['folders'] = static::processUserFolders($conf['folders'], $user);

  // Call plugin processors.
  \Drupal::service('plugin.manager.imce.plugin')
    ->processUserConf($conf, $user);
  return $conf;
}