/**
  * Constructor.
  *
  * @param array           $repoConfig
  * @param IOInterface     $io
  * @param Config          $config
  * @param EventDispatcher $dispatcher
  * @param array           $drivers
  */
 public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $dispatcher = null, array $drivers = null)
 {
     $drivers = $drivers ?: Assets::getVcsDrivers();
     $assetType = substr($repoConfig['type'], 0, strpos($repoConfig['type'], '-'));
     $assetType = Assets::createType($assetType);
     $repoConfig['asset-type'] = $assetType->getName();
     $repoConfig['filename'] = $assetType->getFilename();
     $this->assetType = $assetType;
     $this->dispatcher = $dispatcher;
     $this->filter = isset($repoConfig['vcs-package-filter']) && $repoConfig['vcs-package-filter'] instanceof VcsPackageFilter ? $repoConfig['vcs-package-filter'] : null;
     parent::__construct($repoConfig, $io, $config, $dispatcher, $drivers);
 }
 /**
  * Constructor.
  *
  * @param array           $repoConfig
  * @param IOInterface     $io
  * @param Config          $config
  * @param EventDispatcher $eventDispatcher
  */
 public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null)
 {
     $repoConfig = array_merge($repoConfig, array('url' => $this->getUrl()));
     $this->repositoryManager = $repoConfig['repository-manager'];
     parent::__construct($repoConfig, $io, $config, $eventDispatcher);
     $this->assetType = Assets::createType($this->getType());
     $this->lazyProvidersUrl = $this->getPackageUrl();
     $this->providersUrl = $this->lazyProvidersUrl;
     $this->searchUrl = $this->getSearchUrl();
     $this->hasProviders = true;
     $this->rm = $repoConfig['repository-manager'];
     $this->packageFilter = isset($repoConfig['vcs-package-filter']) ? $repoConfig['vcs-package-filter'] : null;
     $this->repos = array();
     $this->searchable = (bool) $this->getOption($repoConfig['asset-options'], 'searchable', true);
     $this->fallbackProviders = false;
 }
Пример #3
0
 public function testCreationOfBowerAsset()
 {
     $type = Assets::createType('bower');
     $this->assertInstanceOf('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface', $type);
 }
Пример #4
0
 /**
  * @param $type
  *
  * @dataProvider getAssetTypes
  */
 public function testInvalidTag($type)
 {
     $assetType = Assets::createType($type);
     $this->assertFalse(Validator::validateTag('version', $assetType));
 }
Пример #5
0
 /**
  * Check if the package is a asset package.
  *
  * @param PackageInterface $package The package instance
  *
  * @return bool
  */
 protected static function isAsset(PackageInterface $package)
 {
     foreach (Assets::getTypes() as $type) {
         $type = Assets::createType($type);
         if ($package->getType() === $type->getComposerType()) {
             return true;
         }
     }
     return false;
 }
Пример #6
0
 /**
  * Adds asset installers.
  *
  * @param Composer    $composer
  * @param IOInterface $io
  */
 public static function addInstallers(Composer $composer, IOInterface $io)
 {
     $im = $composer->getInstallationManager();
     $im->addInstaller(new BowerInstaller($io, $composer, Assets::createType('bower')));
     $im->addInstaller(new AssetInstaller($io, $composer, Assets::createType('npm')));
 }