Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | namespace AC\Asset; |
---|
4 | |
---|
5 | abstract class Enqueueable { |
---|
6 | |
---|
7 | /** |
---|
8 | * @var string |
---|
9 | */ |
---|
10 | protected $handle; |
---|
11 | |
---|
12 | /** |
---|
13 | * @var Location|null |
---|
14 | */ |
---|
15 | protected $location; |
---|
16 | |
---|
17 | /** |
---|
18 | * @var string[] |
---|
19 | */ |
---|
20 | protected $dependencies; |
---|
21 | |
---|
22 | /** |
---|
23 | * @param $handle |
---|
24 | * @param Location $location |
---|
25 | * @param array $dependencies |
---|
26 | */ |
---|
27 | public function __construct( $handle, Location $location = null, array $dependencies = [] ) { |
---|
28 | $this->handle = $handle; |
---|
29 | $this->location = $location; |
---|
30 | $this->dependencies = $dependencies; |
---|
31 | } |
---|
32 | |
---|
33 | /** |
---|
34 | * @return string |
---|
35 | */ |
---|
36 | public function get_handle() { |
---|
37 | return $this->handle; |
---|
38 | } |
---|
39 | |
---|
40 | /** |
---|
41 | * @return int|null |
---|
42 | */ |
---|
43 | protected function get_version() { |
---|
44 | $path = $this->location->get_path(); |
---|
45 | |
---|
46 | return file_exists( $path ) |
---|
47 | ? filemtime( $path ) |
---|
48 | : null; |
---|
49 | } |
---|
50 | |
---|
51 | /** |
---|
52 | * @return void |
---|
53 | */ |
---|
54 | |
---|
55 | abstract public function register(); |
---|
56 | |
---|
57 | /** |
---|
58 | * @return void |
---|
59 | */ |
---|
60 | |
---|
61 | abstract public function enqueue(); |
---|
62 | |
---|
63 | } |
---|
Note: See
TracBrowser for help on using the repository browser.