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

[generate:plugin:views:field] overwrites <module-name>.views.inc #3882

Closed
com2 opened this issue May 2, 2018 · 4 comments
Closed

[generate:plugin:views:field] overwrites <module-name>.views.inc #3882

com2 opened this issue May 2, 2018 · 4 comments

Comments

@com2
Copy link

com2 commented May 2, 2018

Problem/Motivation

After using generate:plugin:views:field to generate the first, I wanted also to add a second field. Apparently this is not supported because I saw in modules/custom/my_module/my_module.views.inc only the last field defined. As Drupal 8 beginner I am not sure if I am right, but I think it should append a second field in stead of overwriting the previous. Or at least it could politely give a warning that a second field is not supported.

How to reproduce

Generate a module and then two views field plugins:

drupal generate:module --module="My Module" --machine-name=my_module --module-path=modules/custom --description="My Module description" --core=8.x --package=Other
drupal generate:plugin:views:field --module=my_module --class=my_first_field_class --title="My first field title" --description="My first field description"
drupal generate:plugin:views:field --module=my_module --class=my_second_field_class --title="My second field title" --description="My second field description"

Details:

  • Drupal 8.5.3
  • Console 1.8.0
@LOBsTerr LOBsTerr added the bug label May 2, 2018
@LOBsTerr
Copy link
Member

LOBsTerr commented May 3, 2018

@com2 I have checked the version 1.8.0 (the latest one). We append code to [module].view.inc file the code each time the command [generate:plugin:views:field] is executed.

$this->renderFile(
            'module/module.views.inc.twig',
            $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.views.inc',
            $parameters,
            FILE_APPEND
        );

and normally then you need to merge it manually.

Anyway, I think it would be nice to have opportunity to add multiple fields

@LOBsTerr
Copy link
Member

LOBsTerr commented May 3, 2018

@com2 I didn't mention that if you have already views data hook implemented, we have a check and it will show the warning

[WARNING] The hook views data was already implemented in module "sdsd". Please, merge the code manually

@LOBsTerr
Copy link
Member

LOBsTerr commented May 3, 2018

pr - #3883
translations pr - hechoendrupal/drupal-console-en#208

@enzolutions
Copy link
Contributor

Thanks @LOBsTerr

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

3 participants