当前位置: 首页>>代码示例>>PHP>>正文


PHP AssetInterface::getSourcePath方法代码示例

本文整理汇总了PHP中Assetic\Asset\AssetInterface::getSourcePath方法的典型用法代码示例。如果您正苦于以下问题:PHP AssetInterface::getSourcePath方法的具体用法?PHP AssetInterface::getSourcePath怎么用?PHP AssetInterface::getSourcePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Assetic\Asset\AssetInterface的用法示例。


在下文中一共展示了AssetInterface::getSourcePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param  \Assetic\Asset\AssetInterface  $asset
  * @return void
  */
 public function filterLoad(AssetInterface $asset)
 {
     $max_nesting_level = ini_get('xdebug.max_nesting_level');
     $memory_limit = ini_get('memory_limit');
     if ($max_nesting_level && $max_nesting_level < 200) {
         ini_set('xdebug.max_nesting_level', 200);
     }
     if ($memory_limit && $memory_limit < 256) {
         ini_set('memory_limit', '256M');
     }
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $dirs = array();
     $lc = new \Less_Parser(array('compress' => true));
     if ($root && $path) {
         $dirs[] = dirname($root . '/' . $path);
     }
     foreach ($this->loadPaths as $loadPath) {
         $dirs[] = $loadPath;
     }
     $lc->SetImportDirs($dirs);
     $url = parse_url($this->getRequest()->getUriForPath(''));
     $absolutePath = str_replace(public_path(), '', $root);
     if (isset($url['path'])) {
         $absolutePath = $url['path'] . $absolutePath;
     }
     $lc->parseFile($root . '/' . $path, $absolutePath);
     $asset->setContent($lc->getCss());
 }
开发者ID:cartalyst,项目名称:assetic-filters,代码行数:35,代码来源:LessphpFilter.php

示例2: dump

 public function dump(AssetInterface $asset)
 {
     $writer = new \Assetic\AssetWriter(sys_get_temp_dir(), $this->container->getParameter('assetic.variables'));
     $ref = new \ReflectionMethod($writer, 'getCombinations');
     $ref->setAccessible(true);
     $name = $asset->getSourcePath();
     $type = substr($name, strrpos($name, '.') + 1);
     switch ($type) {
         case 'coffee':
             $asset->ensureFilter($this->container->get('assetic.filter.coffee'));
             $type = 'js';
             break;
         case 'less':
             $asset->ensureFilter($this->container->get('assetic.filter.less'));
             $type = 'css';
             break;
     }
     $combinations = $ref->invoke($writer, $asset->getVars());
     $asset->setValues($combinations[0]);
     $asset->load();
     $content = $asset->getContent();
     // because the assetic cssrewrite makes bullshit here, we need to reimplement the filter
     if ($type === 'css') {
         $content = $this->cssFilter($content, '/' . dirname($asset->getSourcePath()));
     }
     return $content;
 }
开发者ID:roomthirteen,项目名称:Room13AsseticServerBundle,代码行数:27,代码来源:DumpAssetCommand.php

示例3: filterDump

    /**
     * {@inheritdoc}
     */
    public function filterDump(AssetInterface $asset)
    {
        if (preg_match('/\\.yfp\\.js$/', $asset->getSourcePath())) {
            $content = $asset->getContent();
            preg_match('/(\\w+)\\.yfp\\.js$/', $asset->getSourcePath(), $matches);
            if (isset($matches[1])) {
                $name = $matches[1];
                $pluginName = str_replace(' ', '', ucwords(strtr($matches[1], '_-', '  ')));
                $config = [];
                if ($this->parameterBag->has("ynlo.js_plugin.{$name}")) {
                    $config = $this->parameterBag->get("ynlo.js_plugin.{$name}");
                }
                $jsonConfig = json_encode($config, JSON_FORCE_OBJECT);
                $autoRegister = null;
                if (strpos($content, "YnloFramework.register('{$pluginName}')") === false && strpos($content, "YnloFramework.register(\"{$pluginName}\\')") === false) {
                    $autoRegister = "\nYnloFramework.register('{$pluginName}');";
                }
                $settings = <<<JAVASCRIPT
{$autoRegister}
YnloFramework.{$pluginName}.config = \$.extend({}, YnloFramework.{$pluginName}.config, {$jsonConfig});

JAVASCRIPT;
                $asset->setContent($content . $settings);
            }
        }
    }
开发者ID:ynloultratech,项目名称:framework,代码行数:29,代码来源:FrameworkPluginSettingsDumper.php

示例4: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterLoad(AssetInterface $asset)
 {
     if ($this->str_endswith($asset->getSourcePath(), ['.less'])) {
         $file = Less_Cache::Get([$asset->getSourceRoot() . DIRECTORY_SEPARATOR . $asset->getSourcePath() => '/'], $this->options);
         if (is_readable($this->options['cache_dir'] . DIRECTORY_SEPARATOR . $file)) {
             $asset->setContent(file_get_contents($this->options['cache_dir'] . DIRECTORY_SEPARATOR . $file));
         }
     }
 }
开发者ID:zae,项目名称:larattic,代码行数:14,代码来源:LessCacheFilter.php

示例5: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterLoad(AssetInterface $asset)
 {
     $parser = clone $this->parser;
     $parser->SetOptions($this->options);
     if ($this->str_endswith($asset->getSourcePath(), ['.less'])) {
         $parser->parseFile($asset->getSourceRoot() . DIRECTORY_SEPARATOR . $asset->getSourcePath());
         $asset->setContent($parser->getCss());
     }
 }
开发者ID:zae,项目名称:larattic,代码行数:14,代码来源:LessFilter.php

示例6: filterLoad

 /**
  * Filters an asset after it has been loaded.
  *
  * @param AssetInterface $asset An asset
  */
 public function filterLoad(AssetInterface $asset)
 {
     if ($this->str_endswith($asset->getSourcePath(), ['.js'])) {
         $moduleName = basename($asset->getSourcePath(), '.js');
         $delivery = $this->delivery->create(['includes' => [$asset->getSourceRoot()]]);
         $delivery->addModule($moduleName);
         $delivery->setMainModule($moduleName);
         $asset->setContent($delivery->getOutput());
     }
 }
开发者ID:zae,项目名称:larattic,代码行数:15,代码来源:CommonJSFilter.php

示例7: rewrite

 /**
  * @param mixed[]        $reference
  * @param AssetInterface $asset
  *
  * @return string
  */
 public function rewrite(array $reference, AssetInterface $asset)
 {
     if (!$this->isRewritable($reference['url'], $asset->getSourcePath(), $asset->getTargetPath())) {
         return $reference[0];
     }
     $absoluteSourcePath = $this->getAssetPath(dirname($this->createAssetPath($asset->getSourceRoot(), $asset->getSourcePath())), parse_url($reference['url'])['path']);
     $webTargetPath = $this->createAssetPath($this->rewriteDirectory, $this->namer->name($absoluteSourcePath, $asset));
     $absoluteTargetPath = $this->webDirectory . $webTargetPath;
     $this->filesystem->{$this->strategy}($absoluteSourcePath, $absoluteTargetPath, true);
     return str_replace($reference['url'], $this->packages->getUrl($webTargetPath), $reference[0]);
 }
开发者ID:blazarecki,项目名称:lug,代码行数:17,代码来源:CssRewriter.php

示例8: filterDump

    /**
     * {@inheritdoc}
     */
    public function filterDump(AssetInterface $asset)
    {
        if (preg_match('/pace_settings\\.js$/', $asset->getSourcePath())) {
            $ajax = $this->config['pace']['ajax'] ? 'true' : 'false';
            $document = $this->config['pace']['document'] ? 'true' : 'false';
            $eventLag = $this->config['pace']['eventLag'] ? 'true' : 'false';
            $restartOnPushState = $this->config['pace']['restartOnPushState'] ? 'true' : 'false';
            $restartOnRequestAfter = $this->config['pace']['restartOnRequestAfter'] ? 'true' : 'false';
            $settings = <<<JAVASCRIPT
var paceOptions = {
  ajax: {$ajax}, 
  document: {$document}, 
  eventLag: {$eventLag},
  restartOnPushState: {$restartOnPushState},
  restartOnRequestAfter: {$restartOnRequestAfter},
};
if (typeof requirejs !== 'undefined'){
    require(['pace'], function (pace) {
      pace.start();
    });
}

JAVASCRIPT;
            $asset->setContent($settings);
        }
    }
开发者ID:ynloultratech,项目名称:framework,代码行数:29,代码来源:PaceSettingsDumper.php

示例9: filterDump

    /**
     * {@inheritdoc}
     */
    public function filterDump(AssetInterface $asset)
    {
        if (preg_match('/jquery_plugins_overrides\\.js$/', $asset->getSourcePath())) {
            $content = '';
            foreach (AssetRegistry::getAssets() as $module) {
                if ($module instanceof JavascriptModule && $module->getJqueryPlugins()) {
                    $name = $module->getModuleName();
                    foreach ($module->getJqueryPlugins() as $method) {
                        $script = <<<JAVASCRIPT
//Override {$name} plugin to load with RequireJs
\$.fn.{$method} = function () {
    var element = \$(this);
    var args = arguments;
    require(['{$name}'], function (module) {
        return element.each(function () {
            \$.fn.{$method}.apply(element,args);
        });
    });
    
    return element;
};

JAVASCRIPT;
                        $content .= $script;
                    }
                    $asset->setContent($content);
                }
            }
        }
    }
开发者ID:ynloultratech,项目名称:framework,代码行数:33,代码来源:JqueryPluginOverride.php

示例10: filterDump

    /**
     * {@inheritdoc}
     */
    public function filterDump(AssetInterface $asset)
    {
        if (preg_match('/require_js_config\\.js$/', $asset->getSourcePath())) {
            $config = ['baseUrl' => '/', 'waitSeconds' => false, 'paths' => [], 'shim' => []];
            foreach (AssetRegistry::getAssets() as $module) {
                if ($module instanceof JavascriptModule) {
                    $path = array_key_value($this->config, 'cdn') && $module->getCdn() ? $module->getCdn() : $module->getPath();
                    $config['paths'][$module->getModuleName()] = preg_replace('/\\.js$/', '', $path);
                    if ($module->getDependencies()) {
                        $config['shim'][$module->getModuleName()]['deps'] = $module->getDependencies();
                    }
                    if ($module->getExports()) {
                        $config['shim'][$module->getModuleName()]['exports'] = $module->getExports();
                    }
                    if ($module->getInit()) {
                        $config['shim'][$module->getModuleName()]['init'] = '{function}' . $module->getInit() . '{/function}';
                    }
                }
            }
            $configJson = json_encode($config, JSON_UNESCAPED_SLASHES);
            $configJs = str_replace(['"{function}', '{/function}"', '\\"'], ['function(){', '}', '"'], $configJson);
            $content = <<<EOS
require.config({$configJs});
EOS;
            $asset->setContent($content);
        }
    }
开发者ID:ynloultratech,项目名称:framework,代码行数:30,代码来源:RequireJsConfigDumper.php

示例11: hashAsset

 /**
  * Update a given hash with the sha1 hash of an individual asset
  *
  * @param AssetInterface $asset
  * @param $hash
  */
 protected function hashAsset(AssetInterface $asset, $hash)
 {
     $sourcePath = $asset->getSourcePath();
     $sourceRoot = $asset->getSourceRoot();
     $data = $sourcePath && $sourceRoot && file_exists($sourceRoot . "/" . $sourcePath) ? hash_file('sha1', $sourceRoot . "/" . $sourcePath) : $sourcePath;
     hash_update($hash, $data);
 }
开发者ID:course-hero,项目名称:assetic-filehash-buster,代码行数:13,代码来源:FilehashCacheBustingWorker.php

示例12: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->tscBin) : array($this->tscBin));
     if ($sourcePath = $asset->getSourcePath()) {
         $templateName = basename($sourcePath);
     } else {
         $templateName = 'asset';
     }
     $inputDirPath = FilesystemUtils::createThrowAwayDirectory('typescript_in');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName . '.ts';
     $outputPath = FilesystemUtils::createTemporaryFile('typescript_out');
     file_put_contents($inputPath, $asset->getContent());
     $pb->add($inputPath)->add('--out')->add($outputPath);
     $proc = $pb->getProcess();
     $code = $proc->run();
     unlink($inputPath);
     rmdir($inputDirPath);
     if (0 !== $code) {
         if (file_exists($outputPath)) {
             unlink($outputPath);
         }
         throw FilterException::fromProcess($proc)->setInput($asset->getContent());
     }
     if (!file_exists($outputPath)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $compiledJs = file_get_contents($outputPath);
     unlink($outputPath);
     $asset->setContent($compiledJs);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:30,代码来源:TypeScriptFilter.php

示例13: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->emberBin) : array($this->emberBin));
     if ($sourcePath = $asset->getSourcePath()) {
         $templateName = basename($sourcePath);
     } else {
         throw new \LogicException('The embed-precompile filter requires that assets have a source path set');
     }
     $inputDirPath = FilesystemUtils::createThrowAwayDirectory('ember_in');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName;
     $outputPath = FilesystemUtils::createTemporaryFile('ember_out');
     file_put_contents($inputPath, $asset->getContent());
     $pb->add($inputPath)->add('-f')->add($outputPath);
     $process = $pb->getProcess();
     $returnCode = $process->run();
     unlink($inputPath);
     rmdir($inputDirPath);
     if (127 === $returnCode) {
         throw new \RuntimeException('Path to node executable could not be resolved.');
     }
     if (0 !== $returnCode) {
         if (file_exists($outputPath)) {
             unlink($outputPath);
         }
         throw FilterException::fromProcess($process)->setInput($asset->getContent());
     }
     if (!file_exists($outputPath)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $compiledJs = file_get_contents($outputPath);
     unlink($outputPath);
     $asset->setContent($compiledJs);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:33,代码来源:EmberPrecompileFilter.php

示例14: doDump

 /**
  * Performs the asset dump.
  *
  * @param AssetInterface  $asset  An asset
  * @param OutputInterface $stdout The command output
  *
  * @throws RuntimeException If there is a problem writing the asset
  */
 private function doDump(AssetInterface $asset, OutputInterface $stdout)
 {
     $combinations = VarUtils::getCombinations($asset->getVars(), $this->getContainer()->getParameter('assetic.variables'));
     foreach ($combinations as $combination) {
         $asset->setValues($combination);
         // resolve the target path
         $target = rtrim($this->basePath, '/') . '/' . $asset->getTargetPath();
         $target = str_replace('_controller/', '', $target);
         $target = VarUtils::resolve($target, $asset->getVars(), $asset->getValues());
         if (!is_dir($dir = dirname($target))) {
             $stdout->writeln(sprintf('<comment>%s</comment> <info>[dir+]</info> %s', date('H:i:s'), $dir));
             if (false === @mkdir($dir, 0777, true)) {
                 throw new \RuntimeException('Unable to create directory ' . $dir);
             }
         }
         $stdout->writeln(sprintf('<comment>%s</comment> <info>[file+]</info> %s', date('H:i:s'), $target));
         if (OutputInterface::VERBOSITY_VERBOSE <= $stdout->getVerbosity()) {
             if ($asset instanceof AssetCollectionInterface) {
                 foreach ($asset as $leaf) {
                     $root = $leaf->getSourceRoot();
                     $path = $leaf->getSourcePath();
                     $stdout->writeln(sprintf('        <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]'));
                 }
             } else {
                 $root = $asset->getSourceRoot();
                 $path = $asset->getSourcePath();
                 $stdout->writeln(sprintf('        <comment>%s/%s</comment>', $root ?: '[unknown root]', $path ?: '[unknown path]'));
             }
         }
         if (false === @file_put_contents($target, $asset->dump())) {
             throw new \RuntimeException('Unable to write file ' . $target);
         }
     }
 }
开发者ID:fotomerchant,项目名称:AsseticBundle,代码行数:42,代码来源:AbstractCommand.php

示例15: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $pb = $this->createProcessBuilder($this->nodeBin ? array($this->nodeBin, $this->emberBin) : array($this->emberBin));
     $templateName = basename($asset->getSourcePath());
     $inputDirPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('input_dir');
     $inputPath = $inputDirPath . DIRECTORY_SEPARATOR . $templateName;
     $outputPath = tempnam(sys_get_temp_dir(), 'output');
     mkdir($inputDirPath);
     file_put_contents($inputPath, $asset->getContent());
     $pb->add($inputPath)->add('-f')->add($outputPath);
     if ($this->includeBaseDir) {
         $pb->add('-b')->add($inputDirPath . DIRECTORY_SEPARATOR);
     }
     $process = $pb->getProcess();
     $returnCode = $process->run();
     unlink($inputPath);
     rmdir($inputDirPath);
     if (127 === $returnCode) {
         throw new \RuntimeException('Path to node executable could not be resolved.');
     }
     if (0 !== $returnCode) {
         if (file_exists($outputPath)) {
             unlink($outputPath);
         }
         throw FilterException::fromProcess($process)->setInput($asset->getContent());
     }
     if (!file_exists($outputPath)) {
         throw new \RuntimeException('Error creating output file.');
     }
     $compiledJs = file_get_contents($outputPath);
     unlink($outputPath);
     $asset->setContent($compiledJs);
 }
开发者ID:gsomoza,项目名称:TimeTracking,代码行数:33,代码来源:EmberPrecompileFilter.php


注:本文中的Assetic\Asset\AssetInterface::getSourcePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。