Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
AbstractArchive Class Reference
Inheritance diagram for AbstractArchive:
Bz Gz Tar Zip Tar

Public Member Functions

 getFilename ($source, $withExtension=false)
 

Protected Member Functions

 _writeFile ($destination, $data)
 
 _readFile ($source)
 

Detailed Description

Definition at line 14 of file AbstractArchive.php.

Member Function Documentation

◆ _readFile()

_readFile (   $source)
protected

Read data from file. If file can't be opened, throw to exception.

Parameters
string$source
Returns
string
Exceptions

Definition at line 40 of file AbstractArchive.php.

41  {
42  $data = '';
45  if ($data === false) {
46  throw new \Magento\Framework\Exception\LocalizedException(
47  new \Magento\Framework\Phrase("Can't get contents from: %1", [$source])
48  );
49  }
50  }
51  return $data;
52  }
$source
Definition: source.php:23

◆ _writeFile()

_writeFile (   $destination,
  $data 
)
protected

Write data to file. If file can't be opened - throw exception

Parameters
string$destination
string$data
Returns
true
Exceptions

Definition at line 24 of file AbstractArchive.php.

25  {
26  $destination = trim($destination);
27  if (false === file_put_contents($destination, $data)) {
28  throw new \Exception("Can't write to file: " . $destination);
29  }
30  return true;
31  }

◆ getFilename()

getFilename (   $source,
  $withExtension = false 
)

Get file name from source (URI) without last extension.

Parameters
string$source
bool$withExtension
Returns
string

Definition at line 61 of file AbstractArchive.php.

62  {
63  $file = str_replace(dirname($source) . '/', '', $source);
64  if (!$withExtension) {
65  $file = substr($file, 0, strrpos($file, '.'));
66  }
67  return $file;
68  }
$source
Definition: source.php:23

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