-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Lazy loader of asset package file for improve performances
- Loading branch information
1 parent
1199bad
commit b87d885
Showing
5 changed files
with
630 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,310 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Fxp Composer Asset Plugin package. | ||
* | ||
* (c) François Pluchino <francois.pluchino@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Fxp\Composer\AssetPlugin\Package; | ||
|
||
use Composer\Package\CompletePackage; | ||
use Fxp\Composer\AssetPlugin\Package\Loader\LazyLoaderInterface; | ||
|
||
/** | ||
* The lazy loading complete package. | ||
* | ||
* @author François Pluchino <francois.pluchino@gmail.com> | ||
*/ | ||
class LazyCompletePackage extends CompletePackage implements LazyPackageInterface | ||
{ | ||
/** | ||
* @var LazyLoaderInterface | ||
*/ | ||
protected $lazyLoader; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getTransportOptions() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getTransportOptions(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getTargetDir() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getTargetDir(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getExtra() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getExtra(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getBinaries() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getBinaries(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getInstallationSource() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getInstallationSource(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getReleaseDate() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getReleaseDate(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getRequires() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getRequires(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getConflicts() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getConflicts(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getDevRequires() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getDevRequires(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getSuggests() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getSuggests(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getAutoload() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getAutoload(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getDevAutoload() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getDevAutoload(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getIncludePaths() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getIncludePaths(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getNotificationUrl() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getNotificationUrl(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getArchiveExcludes() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getArchiveExcludes(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getScripts() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getScripts(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getRepositories() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getRepositories(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getLicense() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getLicense(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getKeywords() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getKeywords(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getAuthors() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getAuthors(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getDescription() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getDescription(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getHomepage() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getHomepage(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getSupport() | ||
{ | ||
$this->initialize(); | ||
|
||
return parent::getSupport(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setLoader(LazyLoaderInterface $lazyLoader) | ||
{ | ||
$this->lazyLoader = $lazyLoader; | ||
} | ||
|
||
/** | ||
* Initialize the package. | ||
*/ | ||
protected function initialize() | ||
{ | ||
if (!$this->lazyLoader) { | ||
return; | ||
} | ||
|
||
$real = $this->lazyLoader->load($this); | ||
$this->lazyLoader = null; | ||
|
||
if (false === $real) { | ||
return; | ||
} | ||
|
||
$this->type = $real->getType(); | ||
$this->transportOptions = $real->getTransportOptions(); | ||
$this->targetDir = $real->getTargetDir(); | ||
$this->extra = $real->getExtra(); | ||
$this->binaries = $real->getBinaries(); | ||
$this->installationSource = $real->getInstallationSource(); | ||
$this->releaseDate = $real->getReleaseDate(); | ||
$this->requires = $real->getRequires(); | ||
$this->conflicts = $real->getConflicts(); | ||
$this->provides = $real->getProvides(); | ||
$this->replaces = $real->getReplaces(); | ||
$this->devRequires = $real->getDevRequires(); | ||
$this->suggests = $real->getSuggests(); | ||
$this->autoload = $real->getAutoload(); | ||
$this->devAutoload = $real->getDevAutoload(); | ||
$this->includePaths = $real->getIncludePaths(); | ||
$this->notificationUrl = $real->getNotificationUrl(); | ||
$this->archiveExcludes = $real->getArchiveExcludes(); | ||
$this->scripts = $real->getScripts(); | ||
$this->repositories = $real->getRepositories(); | ||
$this->license = $real->getLicense(); | ||
$this->keywords = $real->getKeywords(); | ||
$this->authors = $real->getAuthors(); | ||
$this->description = $real->getDescription(); | ||
$this->homepage = $real->getHomepage(); | ||
$this->support = $real->getSupport(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Fxp Composer Asset Plugin package. | ||
* | ||
* (c) François Pluchino <francois.pluchino@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Fxp\Composer\AssetPlugin\Package; | ||
|
||
use Composer\Package\CompletePackageInterface; | ||
use Fxp\Composer\AssetPlugin\Package\Loader\LazyLoaderInterface; | ||
|
||
/** | ||
* Interface for lazy loading package. | ||
* | ||
* @author François Pluchino <francois.pluchino@gmail.com> | ||
*/ | ||
interface LazyPackageInterface extends CompletePackageInterface | ||
{ | ||
/** | ||
* Sets the lazy loader. | ||
* | ||
* @param LazyLoaderInterface $lazyLoader | ||
*/ | ||
public function setLoader(LazyLoaderInterface $lazyLoader); | ||
} |
Oops, something went wrong.