Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Static Protected Attributes
Size Class Reference

Public Member Functions

 getPostMaxSize ()
 
 getUploadMaxSize ()
 
 getMaxFileSizeInMb ($precision=0, $mode=\PHP_ROUND_HALF_DOWN)
 
 getFileSizeInMb ($fileSize, $precision=0, $mode=\PHP_ROUND_HALF_DOWN)
 
 getMaxFileSize ()
 
 convertSizeToInteger ($size)
 

Protected Member Functions

 _iniGet ($param)
 

Static Protected Attributes

static $_maxFileSize = -1
 

Detailed Description

@api

Since
100.0.2

Definition at line 16 of file Size.php.

Member Function Documentation

◆ _iniGet()

_iniGet (   $param)
protected

Gets the value of a configuration option

string $param The configuration option name string

Definition at line 124 of file Size.php.

125  {
126  return trim(ini_get($param));
127  }

◆ convertSizeToInteger()

convertSizeToInteger (   $size)

Converts a ini setting to a integer value

Deprecated:
100.1.0 Please use \Magento\Framework\Convert\DataSize
Parameters
string$size
Returns
integer

Definition at line 112 of file Size.php.

113  {
114  return $this->getDataSize()->convertSizeToBytes($size);
115  }

◆ getFileSizeInMb()

getFileSizeInMb (   $fileSize,
  $precision = 0,
  $mode = \PHP_ROUND_HALF_DOWN 
)

Get file size in megabytes

Parameters
int$fileSize
int$precision
int$mode
Returns
float

Definition at line 73 of file Size.php.

74  {
75  return round($fileSize / (1024 * 1024), $precision, $mode);
76  }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15

◆ getMaxFileSize()

getMaxFileSize ( )

Get the maximum file size of the a form in bytes

Returns
integer

Definition at line 83 of file Size.php.

84  {
85  if (self::$_maxFileSize < 0) {
86  $postMaxSize = $this->getDataSize()->convertSizeToBytes($this->getPostMaxSize());
87  $uploadMaxSize = $this->getDataSize()->convertSizeToBytes($this->getUploadMaxSize());
88  $min = max($postMaxSize, $uploadMaxSize);
89 
90  if ($postMaxSize > 0) {
91  $min = min($min, $postMaxSize);
92  }
93 
94  if ($uploadMaxSize > 0) {
95  $min = min($min, $uploadMaxSize);
96  }
97 
98  self::$_maxFileSize = $min;
99  }
100 
101  return self::$_maxFileSize;
102  }

◆ getMaxFileSizeInMb()

getMaxFileSizeInMb (   $precision = 0,
  $mode = \PHP_ROUND_HALF_DOWN 
)

Get max file size in megabytes

Parameters
int$precision
int$mode
Returns
float

Definition at line 60 of file Size.php.

61  {
62  return $this->getFileSizeInMb($this->getMaxFileSize(), $precision, $mode);
63  }
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15
getFileSizeInMb($fileSize, $precision=0, $mode=\PHP_ROUND_HALF_DOWN)
Definition: Size.php:73

◆ getPostMaxSize()

getPostMaxSize ( )

Get post max size

Returns
string

Definition at line 38 of file Size.php.

39  {
40  return $this->_iniGet('post_max_size');
41  }

◆ getUploadMaxSize()

getUploadMaxSize ( )

Get upload max size

Returns
string

Definition at line 48 of file Size.php.

49  {
50  return $this->_iniGet('upload_max_filesize');
51  }

Field Documentation

◆ $_maxFileSize

$_maxFileSize = -1
staticprotected

Definition at line 31 of file Size.php.


The documentation for this class was generated from the following file: