Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractArchive.php
Go to the documentation of this file.
1 <?php
13 
15 {
24  protected function _writeFile($destination, $data)
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  }
32 
40  protected function _readFile($source)
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  }
53 
61  public function getFilename($source, $withExtension = false)
62  {
63  $file = str_replace(dirname($source) . '/', '', $source);
64  if (!$withExtension) {
65  $file = substr($file, 0, strrpos($file, '.'));
66  }
67  return $file;
68  }
69 }
$source
Definition: source.php:23
getFilename($source, $withExtension=false)