예제 #1
0
 /**
  * Sets vcs type repositories.
  *
  * @param RepositoryManager $rm
  */
 public static function setVcsTypeRepositories(RepositoryManager $rm)
 {
     foreach (Assets::getTypes() as $assetType) {
         foreach (Assets::getVcsRepositoryDrivers() as $driverType => $repositoryClass) {
             $rm->setRepositoryClass($assetType . '-' . $driverType, $repositoryClass);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public static function create(RepositoryManager $rm, VcsPackageFilter $filter, array $extra)
 {
     foreach (Assets::getDefaultRegistries() as $assetType => $registryClass) {
         $config = AssetPlugin::createRepositoryConfig($rm, $filter, $extra, $assetType);
         $rm->setRepositoryClass($assetType, $registryClass);
         $rm->addRepository($rm->createRepository($assetType, $config));
     }
 }
 /**
  * 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;
 }
예제 #5
0
 public function testCreationOfBowerAsset()
 {
     $type = Assets::createType('bower');
     $this->assertInstanceOf('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface', $type);
 }
예제 #6
0
 /**
  * @param $type
  *
  * @dataProvider getAssetTypes
  */
 public function testInvalidTag($type)
 {
     $assetType = Assets::createType($type);
     $this->assertFalse(Validator::validateTag('version', $assetType));
 }
예제 #7
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;
 }
예제 #8
0
 /**
  * Check if url is supported by vcs drivers.
  *
  * @param string $url The url
  *
  * @return bool
  */
 protected static function hasUrlDependencySupported($url)
 {
     $io = new NullIO();
     $config = new Config();
     /* @var VcsDriverInterface $driver */
     foreach (Assets::getVcsDrivers() as $driver) {
         $supported = $driver::supports($io, $config, $url);
         if ($supported) {
             return true;
         }
     }
     return false;
 }
예제 #9
0
    /**
     * Adds asset installers.
     *
     * @param Composer    $composer
     * @param IOInterface $io
     */
    protected 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')));
    }