Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend collections from multiple modules #122

Open
Perfect-Web opened this issue Jan 20, 2015 · 3 comments
Open

extend collections from multiple modules #122

Perfect-Web opened this issue Jan 20, 2015 · 3 comments

Comments

@Perfect-Web
Copy link
Contributor

I saw in every example how to define a collection per module.
However when i tried to extend a collection defined in one module with another one from other module, it doesn't work

`

'AsseticBundle' => array(

            'root_path' => getcwd(),

            'collections' => array(

                'head_base_js' => array(
                    'assets' => array(
                        'vendor/jquery/dist/jquery.min.js'

.........

        'Application' => array(
            'root_path' => __DIR__ . '/../assets',
            'collections' => array(
                'head_base_js' => array(
                    'assets' => array(
                        'js/app.js',
                    ),
                ),

.......
`

I have tried multiple combinations, none of which worked.

@widmogrod
Copy link
Owner

Is impossible to merge them like that.
What you could do is to create in each module shared configuration like.

Module A:

return [
  'assetic_configuration' => [
    'modules' => [
      'shared_between' => [
        'collections' => [
          'head_base_js' => [
             'vendor/jquery/dist/jquery.min.js'
          ],
        ],
      ],
      'module_a_specific' => [
        'collections' => [
          'head_base_js' => [/*...*/],
        ],
      ],
    ],
  ],
]

Module B:

return [
  'assetic_configuration' => [
    'modules' => [
      // shared
      'shared_between' => [
        'collections' => [
          'head_base_js' => [
             'js/app.js',
          ],
        ],
      ],
      'module_b_specific' => [
        'collections' => [
          'head_base_js' => [/*...*/],
        ],
      ],
    ],
  ],
]

@Perfect-Web
Copy link
Contributor Author

Ok, but shared_between is relative to what ? could you give more examples or a link to the code so i can understand how this works ?

@widmogrod
Copy link
Owner

Yes, shared_between is relative to that.
When ZF2 merges configs from two modules, it will produce array like this:

eturn [
  'assetic_configuration' => [
    'modules' => [
      'shared_between' => [
        'collections' => [
          'head_base_js' => [
             'vendor/jquery/dist/jquery.min.js',
              'js/app.js',
          ],
        ],
      ],
      'module_a_specific' => [
        'collections' => [
          'head_base_js' => [/*...*/],
        ],
      ],
      'module_b_specific' => [
        'collections' => [
          'head_base_js' => [/*...*/],
        ],
      ],
    ],
  ],
]

I don't have any real world example like this.
You need to understand it by yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants