2

遇到了一些障碍,我找不到任何支持文档。我的用例相当简单。该Application模块有应该进入头部的javascript,而我的其他模块之一Foo也有应该进入头部的脚本。我认为这个 Assetic 模块可以解决这个问题。这是我推断的:

应用程序配置

/**
 * Assetic
 */
'assetic_configuration' => array(

    'buildOnRequest'    => true,
    'cacheEnabled'      => false,
    'webPath'           => realpath('public/assets'),
    'basePath'          => 'assets',


     'default' => array(

        'assets' => array(
            '@base_css',
            '@head_js',
        ),

        'options' => array(
            'mixin' => true,
        ),
    ),

     'modules' => array(

        'application' => array(

            # module root path for yout css and js files
            'root_path' => __DIR__ . '/../assets',

            # collection of assets
            'collections' => array(

                'base_css' => array(
                    'assets' => array(
                        'css/*.css',
                    ),
                    'filters' => array(),
                    'options' => array(),
                ),

                'head_js' => array(
                    'assets' => array(
                        'js/*.js',
                    ),
                    'filters' => array(),
                ),

                'base_images' => array(
                    'assets'=> array(
                        'images/*.png',
                    ),
                    'options' => array(
                        'move_raw' => true,
                    )
                ),
            ),
        ),
    ),
),

然后在我的 Foo 模块中......

Foo 模块配置

/**
 * Assetic
 */
'assetic_configuration' => array(

     'default' => array(
        'assets' => array(
            '@base_css',
            '@head_js',
        ),

        'options' => array(
            'mixin' => true,
        ),
    ),


    'modules' => array(

        'foo' => array(

            # module root path for yout css and js files
            'root_path' => __DIR__ . '/../assets',

            # collection of assets
            'collections' => array(

                'base_css' => array(
                    'assets' => array(
                        'css/*.css'
                    ),
                    'filters' => array(),
                    'options' => array(),
                ),

                'head_js' => array(
                    'assets' => array(
                        'js/*.js' // relative to 'root_path'
                    ),
                    'filters' => array(),
                    'options' => array(),
                ),

                'base_images' => array(
                    'assets'=> array(
                        'images/*.png'
                    ),
                    'options' => array(
                        'move_raw' => true,
                    )
                ),
            ),
        ),
    ),
),

不幸的是,有了这个配置,只有 Foo 模块的 javascript 进入了 head_js.js。我感觉就像米尔顿在里面的那个表情包,“我被告知会有资产合并!” :)

感谢您提供任何帮助。

谢谢!

4

1 回答 1

5

好的 - 我已经想通了。希望有一天这对其他人有所帮助。我上面提到的配置密钥并不是不准确的——但是——当考虑到一个秘密的未记录的特性时,它们没有被正确地设计;必须打开源代码才能了解在资产包中包含“head”这个词实际上会自动将它加载到 head 中。最后,这是一个不错的功能,但当您不知道时,它确实令人头疼。

于 2013-08-23T16:18:49.743 回答