Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Asset.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Framework\View;
7 
9 
10 class Asset
11 {
15  private $fileName;
16 
20  private $sourcePath;
21 
25  protected $module;
26 
30  protected $area;
31 
35  protected $theme;
36 
40  protected $locale;
41 
45  private $extension;
46 
56  public function __construct(
57  $fileName,
58  $sourcePath = null,
59  $area = null,
60  $theme = null,
61  $locale = null,
62  $module = null
63  ) {
64  $this->fileName = $fileName;
65  $this->sourcePath = $sourcePath;
66  $this->module = $module;
67  $this->area = $area;
68  $this->theme = $theme;
69  $this->locale = $locale;
70  }
71 
75  public function getFileName()
76  {
77  return $this->fileName;
78  }
79 
83  public function getFileId()
84  {
85  if ($this->getModule()) {
86  return $this->getModule() . Repository::FILE_ID_SEPARATOR . $this->getFileName();
87  }
88  return $this->getFileName();
89  }
90 
94  public function getFilePath()
95  {
96  if ($this->getModule()) {
97  return $this->getModule() . '/' . $this->getFileName();
98  }
99  return $this->getFileName();
100  }
101 
105  public function getSourcePath()
106  {
107  return $this->sourcePath;
108  }
109 
113  public function getModule()
114  {
115  return $this->module;
116  }
117 
121  public function getArea()
122  {
123  return $this->area;
124  }
125 
129  public function getTheme()
130  {
131  return $this->theme;
132  }
133 
137  public function getLocale()
138  {
139  return $this->locale;
140  }
141 
145  public function getExtension()
146  {
147  if (!$this->extension) {
148  $this->extension = strtolower(pathinfo($this->getFileName(), PATHINFO_EXTENSION));
149  }
150  return $this->extension;
151  }
152 }
__construct( $fileName, $sourcePath=null, $area=null, $theme=null, $locale=null, $module=null)
Definition: Asset.php:56