Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Allows glob path in assets configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
neilime authored Mar 2, 2018
1 parent 51a5ce7 commit 5fc04a6
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/AssetsBundle/AssetFile/AssetFilesConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public function addAssetFile(\AssetsBundle\AssetFile\AssetFile $oAssetFile)
return $this;
}


/**
* @param array $aAssetFileOptions
* @return \AssetsBundle\AssetFile\AssetFilesConfiguration
Expand Down Expand Up @@ -162,15 +163,34 @@ public function addAssetFileFromOptions(array $aAssetFileOptions)

// Retrieve asset file realpath
$sAssetRealPath = $this->getOptions()->getRealPath($aAssetFileOptions['asset_file_path'])? : $aAssetFileOptions['asset_file_path'];

return $this->getAssetFileFromFilePath($oAssetFile, $sAssetRealPath);
}

/**
* @param \AssetsBundle\AssetFile\AssetFile $oAssetFile
* @param type $sAssetRealPath
* @return \AssetsBundle\AssetFile\AssetFilesConfiguration
*/
public function getAssetFileFromFilePath(\AssetsBundle\AssetFile\AssetFile $oAssetFile, $sAssetRealPath)
{
if (is_dir($sAssetRealPath)) {
foreach ($this->getAssetFilesPathFromDirectory($sAssetRealPath, $oAssetFile->getAssetFileType()) as $sChildAssetRealPath) {
$oNewAssetFile = clone $oAssetFile;
$this->addAssetFile($oNewAssetFile->setAssetFilePath($sChildAssetRealPath));
$this->getAssetFileFromFilePath($oAssetFile, $sChildAssetRealPath);
}
return $this;
}
// Handle path with wildcard
elseif (strpos($sAssetRealPath, '*') !== false) {
$oGlobIterator = new \GlobIterator($sAssetRealPath);
foreach ($oGlobIterator as $oItem) {
$this->getAssetFileFromFilePath($oAssetFile, $oItem->key());
}
return $this;
}

return $this->addAssetFile($oAssetFile->setAssetFilePath($sAssetRealPath));
$oNewAssetFile = clone $oAssetFile;
return $this->addAssetFile($oNewAssetFile->setAssetFilePath($sAssetRealPath));
}

/**
Expand Down

0 comments on commit 5fc04a6

Please sign in to comment.