Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

222 lines
5.0KB

  1. <?php
  2. /*
  3. * This file is part of the Fxp Composer Asset Plugin package.
  4. *
  5. * (c) François Pluchino <francois.pluchino@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Fxp\Composer\AssetPlugin\Package;
  11. use Composer\Package\CompletePackage;
  12. use Fxp\Composer\AssetPlugin\Package\Loader\LazyLoaderInterface;
  13. /**
  14. * Abstract class for the lazy loading complete package.
  15. *
  16. * @author François Pluchino <francois.pluchino@gmail.com>
  17. */
  18. abstract class AbstractLazyCompletePackage extends CompletePackage implements LazyPackageInterface
  19. {
  20. /**
  21. * @var LazyLoaderInterface
  22. */
  23. protected $lazyLoader;
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function getAutoload()
  28. {
  29. $this->initialize();
  30. return parent::getAutoload();
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function getDevAutoload()
  36. {
  37. $this->initialize();
  38. return parent::getDevAutoload();
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function getIncludePaths()
  44. {
  45. $this->initialize();
  46. return parent::getIncludePaths();
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function getNotificationUrl()
  52. {
  53. $this->initialize();
  54. return parent::getNotificationUrl();
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function getArchiveExcludes()
  60. {
  61. $this->initialize();
  62. return parent::getArchiveExcludes();
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function getScripts()
  68. {
  69. $this->initialize();
  70. return parent::getScripts();
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function getRepositories()
  76. {
  77. $this->initialize();
  78. return parent::getRepositories();
  79. }
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function getLicense()
  84. {
  85. $this->initialize();
  86. return parent::getLicense();
  87. }
  88. /**
  89. * {@inheritdoc}
  90. */
  91. public function getKeywords()
  92. {
  93. $this->initialize();
  94. return parent::getKeywords();
  95. }
  96. /**
  97. * {@inheritdoc}
  98. */
  99. public function getAuthors()
  100. {
  101. $this->initialize();
  102. return parent::getAuthors();
  103. }
  104. /**
  105. * {@inheritdoc}
  106. */
  107. public function getDescription()
  108. {
  109. $this->initialize();
  110. return parent::getDescription();
  111. }
  112. /**
  113. * {@inheritdoc}
  114. */
  115. public function getHomepage()
  116. {
  117. $this->initialize();
  118. return parent::getHomepage();
  119. }
  120. /**
  121. * {@inheritdoc}
  122. */
  123. public function getSupport()
  124. {
  125. $this->initialize();
  126. return parent::getSupport();
  127. }
  128. /**
  129. * {@inheritdoc}
  130. */
  131. public function setLoader(LazyLoaderInterface $lazyLoader)
  132. {
  133. $this->lazyLoader = $lazyLoader;
  134. }
  135. /**
  136. * Initialize the package.
  137. */
  138. protected function initialize()
  139. {
  140. if (!$this->lazyLoader) {
  141. return;
  142. }
  143. $real = $this->lazyLoader->load($this);
  144. $this->lazyLoader = null;
  145. if (false === $real) {
  146. $this->version = '-9999999.9999999.9999999.9999999';
  147. return;
  148. }
  149. $this->type = $real->getType();
  150. $this->transportOptions = $real->getTransportOptions();
  151. $this->targetDir = $real->getTargetDir();
  152. $this->extra = $real->getExtra();
  153. $this->binaries = $real->getBinaries();
  154. $this->installationSource = $real->getInstallationSource();
  155. $this->sourceType = $real->getSourceType();
  156. $this->sourceUrl = $real->getSourceUrl();
  157. $this->sourceReference = $real->getSourceReference();
  158. $this->sourceMirrors = $real->getSourceMirrors();
  159. $this->distType = $real->getDistType();
  160. $this->distUrl = $real->getDistUrl();
  161. $this->distReference = $real->getDistReference();
  162. $this->distSha1Checksum = $real->getDistSha1Checksum();
  163. $this->distMirrors = $real->getDistMirrors();
  164. $this->releaseDate = $real->getReleaseDate();
  165. $this->requires = $real->getRequires();
  166. $this->conflicts = $real->getConflicts();
  167. $this->provides = $real->getProvides();
  168. $this->replaces = $real->getReplaces();
  169. $this->devRequires = $real->getDevRequires();
  170. $this->suggests = $real->getSuggests();
  171. $this->autoload = $real->getAutoload();
  172. $this->devAutoload = $real->getDevAutoload();
  173. $this->includePaths = $real->getIncludePaths();
  174. $this->notificationUrl = $real->getNotificationUrl();
  175. $this->archiveExcludes = $real->getArchiveExcludes();
  176. $this->scripts = $real->getScripts();
  177. $this->repositories = $real->getRepositories();
  178. $this->license = $real->getLicense();
  179. $this->keywords = $real->getKeywords();
  180. $this->authors = $real->getAuthors();
  181. $this->description = $real->getDescription();
  182. $this->homepage = $real->getHomepage();
  183. $this->support = $real->getSupport();
  184. }
  185. }