本文整理汇总了PHP中Assetic\Asset\AssetInterface::getSourceDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetInterface::getSourceDirectory方法的具体用法?PHP AssetInterface::getSourceDirectory怎么用?PHP AssetInterface::getSourceDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assetic\Asset\AssetInterface
的用法示例。
在下文中一共展示了AssetInterface::getSourceDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterDump
/**
* Apply a filter on file dump.
*
* @param \Assetic\Asset\AssetInterface $asset
* @return void
*/
public function filterDump(AssetInterface $asset)
{
// Using getSourceDirectory
// instead of getSourceRoot
// Since relative paths are based on the sourceDirectory...
$this->assetDirectory = $this->realPath($asset->getSourceDirectory());
$content = $asset->getContent();
// Spin through the symlinks and normalize them. We'll first unset the original
// symlink so that it doesn't clash with the new symlinks once they are added
// back in.
foreach ($this->symlinks as $link => $target) {
unset($this->symlinks[$link]);
if ($link == '//') {
$link = $this->documentRoot;
} else {
$link = str_replace('//', $this->documentRoot . '/', $link);
}
$link = strtr($link, '/', DIRECTORY_SEPARATOR);
$this->symlinks[$link] = $this->realPath($target);
}
$content = $this->trimUrls($content);
$content = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/', array($this, 'processUriCallback'), $content);
$content = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array($this, 'processUriCallback'), $content);
$asset->setContent($content);
}
示例2: filterLoad
public function filterLoad(AssetInterface $asset)
{
$sassProcessArgs = array();
if (null !== $this->nodePath) {
$sassProcessArgs[] = $this->nodePath;
}
$sassProcessArgs[] = $this->sassPath;
$pb = $this->createProcessBuilder($sassProcessArgs);
if ($dir = $asset->getSourceDirectory()) {
$pb->add('--include-path')->add($dir);
}
if ($this->style) {
$pb->add('--output-style')->add($this->style);
}
if ($this->sourceMap) {
$pb->add('--source-map');
}
if ($this->debugInfo) {
$pb->add('--source-comments');
}
foreach ($this->loadPaths as $loadPath) {
$pb->add('--include-path')->add($loadPath);
}
// input
$pb->add($input = tempnam(sys_get_temp_dir(), 'assetic_sass'));
file_put_contents($input, $asset->getContent());
$pb->add('--stdout');
$proc = $pb->getProcess();
$code = $proc->run();
unlink($input);
if (0 !== $code) {
throw FilterException::fromProcess($proc)->setInput($asset->getContent());
}
$asset->setContent($proc->getOutput());
}
示例3: getSourceDirectory
/**
* {@inheritdoc}
*/
public function getSourceDirectory()
{
if (!$this->innerAsset) {
$this->createInnerAsset();
}
return $this->innerAsset->getSourceDirectory();
}
示例4: filterLoad
public function filterLoad(AssetInterface $asset)
{
$pce = new CssEmbed();
if ($dir = $asset->getSourceDirectory()) {
$pce->setRootDir($dir);
}
$asset->setContent($pce->embedString($asset->getContent()));
}
示例5: filterDump
/**
* Filters an asset just before it's dumped.
*
* @param AssetInterface $asset
*/
public function filterDump(AssetInterface $asset)
{
$this->dispatch(new LoadThemeVariables($variables = new Collection()));
$compiler = new Compiler();
if ($dir = $asset->getSourceDirectory()) {
$compiler->addImportPath($dir);
}
$compiler->setVariables($variables->all());
$asset->setContent($this->parser->parse($compiler->compile($asset->getContent())));
}
示例6: filterLoad
public function filterLoad(AssetInterface $asset)
{
$sass = new \Sass();
$includePaths = array_merge(array($asset->getSourceDirectory()), $this->includePaths);
$sass->setIncludePath(implode(':', $includePaths));
if ($this->outputStyle) {
$sass->setStyle($this->outputStyle);
}
$css = $sass->compile($asset->getContent());
$asset->setContent($css);
}
示例7: filterDump
public function filterDump(AssetInterface $asset)
{
$filters = $this->filters;
$plugins = $this->plugins;
if (isset($filters['ImportImports']) && true === $filters['ImportImports']) {
if ($dir = $asset->getSourceDirectory()) {
$filters['ImportImports'] = array('BasePath' => $dir);
} else {
unset($filters['ImportImports']);
}
}
$asset->setContent(\CssMin::minify($asset->getContent(), $filters, $plugins));
}
示例8: filterDump
/**
* Filters an asset just before it's dumped.
*
* @param AssetInterface $asset
*/
public function filterDump(AssetInterface $asset)
{
$compiler = new \lessc();
$this->dispatch(new LoadThemeVariables($variables = new Collection()));
$compiler->setVariables($variables->all());
if ($dir = $asset->getSourceDirectory()) {
$compiler->importDir = $dir;
}
foreach ($this->loadPaths as $loadPath) {
$compiler->addImportDir($loadPath);
}
$asset->setContent($compiler->parse($this->parser->parse($asset->getContent())));
}
示例9: filterLoad
public function filterLoad(AssetInterface $asset)
{
$lc = new \scssc();
if ($this->compass) {
new \scss_compass($lc);
}
if ($dir = $asset->getSourceDirectory()) {
$lc->addImportPath($dir);
}
foreach ($this->importPaths as $path) {
$lc->addImportPath($path);
}
$asset->setContent($lc->compile($asset->getContent()));
}
示例10: filterLoad
public function filterLoad(AssetInterface $asset)
{
$source = $asset->getSourceDirectory() . path('ds') . $asset->getSourcePath();
$sourceHash = sha1($source . filemtime($source));
$input = path('tmp') . $sourceHash . '.less.tmp';
if (!is_file($input)) {
$content = $asset->getContent();
/**
* Fix ../ and similar urls.
*/
$sourceDir = $asset->getSourceDirectory();
$rootDir = path('root');
/**
* Source dir is always longer than root dir.
* Dir diff will be prepended to urls.
*/
$dirDiff = str_replace($rootDir, path('ds'), $sourceDir);
/**
* Make replacement.
*/
$content = preg_replace_callback('/url\\(([\\s])?([\\"|\'])?(.*?)([\\"|\'])?([\\s])?\\)/i', function ($matches) use($sourceDir, $rootDir, $dirDiff) {
$value = $matches[0];
/**
* We have to move $dots times towards root.
*/
if ($dots = substr_count($value, '../')) {
/**
* We have to move $dots times towards root.
*/
$resourcePath = realpath($sourceDir . path('ds') . str_repeat('..' . path('ds'), $dots));
$relativeDir = str_replace($rootDir, path('ds'), $resourcePath) . path('ds');
$urlPart = strpos($value, 'url("') !== false ? 'url("' : (strpos($value, 'url(\'') !== false ? 'url(\'' : 'url(');
$value = str_replace($urlPart, $urlPart . $relativeDir, str_replace('../', '', $value));
}
/**
* We have to simply prepend path.
*/
if (strpos($value, 'url("') !== false && strpos($value, 'url("/)') === false || strpos($value, 'url(\'') !== false && strpos($value, 'url(\'/') === false) {
$value = str_replace(['url("', 'url(\''], ['url("' . $dirDiff . '/', 'url(\'' . $dirDiff . '/'], $value);
}
return $value;
}, $content);
} else {
$content = file_get_contents($input);
}
$asset->setContent($content);
}
示例11: filterLoad
public function filterLoad(AssetInterface $asset)
{
$sc = new \scssc();
if ($this->compass) {
new \scss_compass($sc);
}
if ($dir = $asset->getSourceDirectory()) {
$sc->addImportPath($dir);
}
foreach ($this->importPaths as $path) {
$sc->addImportPath($path);
}
foreach ($this->customFunctions as $name => $callable) {
$sc->registerFunction($name, $callable);
}
$asset->setContent($sc->compile($asset->getContent()));
}
示例12: filterLoad
public function filterLoad(AssetInterface $asset)
{
$lc = new \lessc();
if ($dir = $asset->getSourceDirectory()) {
$lc->importDir = $dir;
}
foreach ($this->loadPaths as $loadPath) {
$lc->addImportDir($loadPath);
}
if ($this->formatter) {
$lc->setFormatter($this->formatter);
}
if (null !== $this->preserveComments) {
$lc->setPreserveComments($this->preserveComments);
}
$asset->setContent($lc->parse($asset->getContent(), $this->presets));
}
示例13: filterLoad
public function filterLoad(AssetInterface $asset)
{
$filePath = $asset->getSourceRoot() . DS . $asset->getSourcePath();
Tlog::getInstance()->addDebug("Starting CSS processing: {$filePath}...");
$importDirs = [];
if ($dir = $asset->getSourceDirectory()) {
$importDirs[$dir] = '';
}
foreach ($this->loadPaths as $loadPath) {
$importDirs[$loadPath] = '';
}
$options = ['cache_dir' => $this->cacheDir, 'relativeUrls' => false, 'compress' => true, 'import_dirs' => $importDirs];
$css_file_name = \Less_Cache::Get([$filePath => ''], $options);
$content = @file_get_contents($this->cacheDir . DS . $css_file_name);
if ($content === false) {
$content = '';
Tlog::getInstance()->warning("Compilation of {$filePath} did not generate an output file.");
}
$asset->setContent($content);
Tlog::getInstance()->addDebug("CSS processing done.");
}
示例14: filterLoad
public function filterLoad(AssetInterface $asset)
{
$lc = new \lessc();
if ($dir = $asset->getSourceDirectory()) {
$lc->importDir = $dir;
}
foreach ($this->loadPaths as $loadPath) {
$lc->addImportDir($loadPath);
}
foreach ($this->customFunctions as $name => $callable) {
$lc->registerFunction($name, $callable);
}
if ($this->formatter) {
$lc->setFormatter($this->formatter);
}
if (null !== $this->preserveComments) {
$lc->setPreserveComments($this->preserveComments);
}
if (method_exists($lc, 'setOptions') && count($this->options) > 0) {
$lc->setOptions($this->options);
}
$asset->setContent($lc->parse($asset->getContent(), $this->presets));
}
示例15: filterLoad
/**
* {@inheritdoc}
*/
public function filterLoad(AssetInterface $asset)
{
static $format = <<<'EOF'
var stylus = require('stylus');
var sys = require(process.binding('natives').util ? 'util' : 'sys');
stylus(%s, %s)%s.render(function(e, css){
if (e) {
throw e;
}
sys.print(css);
process.exit(0);
});
EOF;
// parser options
$parserOptions = array();
if ($dir = $asset->getSourceDirectory()) {
$parserOptions['paths'] = array($dir);
$parserOptions['filename'] = basename($asset->getSourcePath());
}
if (null !== $this->compress) {
$parserOptions['compress'] = $this->compress;
}
$pb = $this->createProcessBuilder();
$pb->add($this->nodeBin)->add($input = FilesystemUtils::createTemporaryFile('stylus'));
file_put_contents($input, sprintf($format, json_encode($asset->getContent()), json_encode($parserOptions), $this->useNib ? '.use(require(\'nib\')())' : ''));
$proc = $pb->getProcess();
$code = $proc->run();
unlink($input);
if (0 !== $code) {
throw FilterException::fromProcess($proc)->setInput($asset->getContent());
}
$asset->setContent($proc->getOutput());
}