ResourceLoaderFilePath.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. * http://www.gnu.org/copyleft/gpl.html
  17. *
  18. * @file
  19. */
  20. /**
  21. * An object to represent a path to a JavaScript/CSS file, along with a remote
  22. * and local base path, for use with ResourceLoaderFileModule.
  23. *
  24. * @ingroup ResourceLoader
  25. * @since 1.17
  26. */
  27. class ResourceLoaderFilePath {
  28. /** @var string Local base path */
  29. protected $localBasePath;
  30. /** @var string Remote base path */
  31. protected $remoteBasePath;
  32. /**
  33. * @var string Path to the file
  34. */
  35. protected $path;
  36. /**
  37. * @param string $path Path to the file.
  38. * @param string $localBasePath Base path to prepend when generating a local path.
  39. * @param string $remoteBasePath Base path to prepend when generating a remote path.
  40. */
  41. public function __construct( $path, $localBasePath, $remoteBasePath ) {
  42. $this->path = $path;
  43. $this->localBasePath = $localBasePath;
  44. $this->remoteBasePath = $remoteBasePath;
  45. }
  46. /**
  47. * @return string
  48. */
  49. public function getLocalPath() {
  50. return "{$this->localBasePath}/{$this->path}";
  51. }
  52. /**
  53. * @return string
  54. */
  55. public function getRemotePath() {
  56. return "{$this->remoteBasePath}/{$this->path}";
  57. }
  58. /**
  59. * @return string
  60. */
  61. public function getLocalBasePath() {
  62. return $this->localBasePath;
  63. }
  64. /**
  65. * @return string
  66. */
  67. public function getRemoteBasePath() {
  68. return $this->remoteBasePath;
  69. }
  70. /**
  71. * @return string
  72. */
  73. public function getPath() {
  74. return $this->path;
  75. }
  76. }