public function testGetRegisteredAssets()
 {
     $registry = new AssetRegistry($this->container);
     $assets = $registry->getAsseticAssetsArray();
     self::assertContains('bundles/ynloframework/vendor/jquery/jquery.min.js', $assets['all_js']['inputs']);
     self::assertContains('bundles/ynloframework/js/core.yfp.js', $assets['all_js']['inputs']);
     self::assertContains('bundles/ynloadmin/js/admin.yfp.js', $assets['all_js']['inputs']);
     self::assertContains('bundles/ynloframework/vendor/bootstrap/css/bootstrap.min.css', $assets['all_css']['inputs']);
     self::assertContains('bundles/ynloadmin/vendor/admin-lte/css/AdminLTE.min.css', $assets['all_css']['inputs']);
     self::assertContains('bundles/ynloframework/vendor/jquery/jquery.min.js', $assets['jquery']['inputs']);
 }
    /**
     * {@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);
                }
            }
        }
    }
    /**
     * {@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);
        }
    }
 private function processAssetContexts(ContainerBuilder $containerBuilder)
 {
     $config = $this->processConfiguration(new Configuration(), $containerBuilder->getExtensionConfig('ynlo_assets'));
     $exclude = [];
     if ($containerBuilder->hasExtension('ynlo_admin')) {
         $exclude[] = 'bundle_ynlo_admin';
     }
     $defaultContexts = ['app' => ['include' => ['all'], 'exclude' => $exclude]];
     $config['contexts'] = array_merge_recursive($config['contexts'], $defaultContexts);
     foreach ($config['contexts'] as $context => $contextConfig) {
         $context = new AssetContext($context);
         $context->setInclude(array_key_value($contextConfig, 'include', []));
         $context->setExclude(array_key_value($contextConfig, 'exclude', []));
         $context->setOverride(array_key_value($contextConfig, 'override', []));
         if (empty($contextConfig['include'])) {
             $msg = sprintf('The context `%s` don`t have any assets to include.', $context);
             throw new \LogicException($msg);
         }
         AssetRegistry::registerAssetBundle($context->getName(), $context->getAssets());
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $assets = AssetRegistry::getAssets();
     $table = new Table($output);
     $table->setHeaders(['Name', 'Assets', 'RequireJS']);
     $names = array_keys($assets);
     $lastName = array_pop($names);
     foreach ($assets as $name => $namedAsset) {
         if ($namedAsset instanceof AssetBundle) {
             foreach ($namedAsset->getAssets() as $index => $asset) {
                 $table->addRow([$name, $asset->getPath()]);
                 $name = '';
             }
         } else {
             $table->addRow([$namedAsset->getName(), $namedAsset->getPath(), $namedAsset instanceof JavascriptModule ? $namedAsset->getModuleName() : '']);
         }
         if ($name !== $lastName) {
             $table->addRow(new TableSeparator());
         }
     }
     $table->render();
 }
 /**
  * {@inheritdoc}
  */
 public function boot()
 {
     //re-build the registry using a saved parameter
     AssetRegistry::unserialize($this->container->getParameter('ynlo.assets'));
 }