ResourceLoaderFilePath.php 2.0 KB

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