-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.php
79 lines (66 loc) · 1.75 KB
/
install.php
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Codeigniter asset versioning installer
*
* @author Roland Oduberu <https://github.com/roliod>
* @license MIT License
* @copyright 2018 Roland Oduberu
* @link https://github.com/roliod/codeigniter-asset-versioning/releases
*/
$installer = new Installer();
$installer->install();
class Installer
{
public $helper_to_path;
public $library_to_path;
public $helper_from_path;
public $library_form_path;
public function __construct()
{
$this->library_to_path = "application/libraries/asset.php";
$this->helper_to_path = "application/helpers/asset_helper.php";
$this->library_form_path = "vendor/roliod/codeigniter-asset-versioning/src/libraries/asset.php";
$this->helper_from_path = "vendor/roliod/codeigniter-asset-versioning/src/helpers/asset_helper.php";
}
public function install()
{
$this->copy_helper();
$this->copy_library();
}
public function copy_helper()
{
if ($this->exists($this->helper_to_path)) {
return $this;
}
$this->copy_file($this->helper_from_path, $this->helper_to_path);
return $this;
}
public function copy_library()
{
if ($this->exists($this->library_to_path)) {
return $this;
}
$this->copy_file($this->library_form_path, $this->library_to_path);
return $this;
}
/**
* Check if file exists
*
* @param string $file path
* @return bool
*/
public function exists($path)
{
return (bool) file_exists($path);
}
/**
* Recursive Copy
*
* @param string $src
* @param string $dst
*/
public function copy_file($from, $to)
{
copy($from, $to);
}
}