1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Setup\Model;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
/**
* License file reader
*
* @package Magento\Setup\Model
*/
class License
{
/**
* Default License File location
*
* @var string
*/
const DEFAULT_LICENSE_FILENAME = 'LICENSE.txt';
/**
* License File location
*
* @var string
*/
const LICENSE_FILENAME = 'LICENSE_EE.txt';
/**
* Directory that contains license file
*
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
*/
private $dir;
/**
* Constructor
*
* @param Filesystem $filesystem
*/
public function __construct(Filesystem $filesystem)
{
$this->dir = $filesystem->getDirectoryRead(DirectoryList::ROOT);
}
/**
* Returns contents of License file.
*
* @return string|boolean
*/
public function getContents()
{
if ($this->dir->isFile(self::LICENSE_FILENAME)) {
return $this->dir->readFile(self::LICENSE_FILENAME);
} elseif ($this->dir->isFile(self::DEFAULT_LICENSE_FILENAME)) {
return $this->dir->readFile(self::DEFAULT_LICENSE_FILENAME);
} else {
return false;
}
}
}