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:block] #3860

Closed
novia713 opened this issue Apr 10, 2018 · 8 comments
Closed

[generate:plugin:block] #3860

novia713 opened this issue Apr 10, 2018 · 8 comments

Comments

@novia713
Copy link
Contributor

novia713 commented Apr 10, 2018

after wizard generation a block with a form inside, drupalconsole does not generate the block and appears this error

[ERROR] <em class="placeholder">Warning</em>: array_flip(): Can only flip STRING and INTEGER values! in <em
         class="placeholder">Drupal\Console\Core\Style\DrupalStyle-&gt;choiceNoList()</em> (line <em
         class="placeholder">62</em> of <em
         class="placeholder">/home/www-data/html/anav/vendor/drupal/console-core/src/Style/DrupalStyle.php</em>). <pre
         class="backtrace">Drupal\Console\Core\Style\DrupalStyle-&gt;choiceNoList(&#039;Enter the theme region to render
         the Plugin Block.&#039;, Array, &#039;&#039;, 1) (Line: 273)
         Drupal\Console\Command\Generate\PluginBlockCommand-&gt;interact(Object, Object) (Line: 249)
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 859)
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 206)
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 125)
         Symfony\Component\Console\Application-&gt;run() (Line: 89)
         require(&#039;/home/www-data/html/anav/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)
         </pre>

this happened with DrupalConsole 1.6.1, with 1.8 it works well

@LOBsTerr
Copy link
Member

@novia713 Can you explain what we can do here if it works in the latest version?

@aurmil
Copy link

aurmil commented Aug 6, 2018

got this error in the same case:

vendor/bin/drupal generate:plugin:block

 [ERROR] <em class="placeholder">Warning</em>: array_flip(): Can only flip STRING and INTEGER values! in <em
         class="placeholder">Drupal\Console\Core\Style\DrupalStyle-&gt;choiceNoList()</em> (line <em
         class="placeholder">62</em> of <em
         class="placeholder">/vagrant/vendor/drupal/console-core/src/Style/DrupalStyle.php</em>). <pre
         class="backtrace">Drupal\Console\Core\Style\DrupalStyle-&gt;choiceNoList(&#039;Enter the theme region to render
         the Plugin Block.&#039;, Array, &#039;&#039;, 1) (Line: 273)
         Drupal\Console\Command\Generate\PluginBlockCommand-&gt;interact(Object, Object) (Line: 236)
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 964)
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 248)
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)
         Symfony\Component\Console\Application-&gt;run() (Line: 89)
         require(&#039;/vagrant/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)
         </pre>

written 16 times, then:

[ERROR] <em class="placeholder">Warning</em>: Invalid argument supplied for foreach() in <em
         class="placeholder">Drupal\Console\Generator\PluginBlockGenerator-&gt;generate()</em> (line <em
         class="placeholder">42</em> of <em
         class="placeholder">/vagrant/vendor/drupal/console/src/Generator/PluginBlockGenerator.php</em>). <pre
         class="backtrace">Drupal\Console\Generator\PluginBlockGenerator-&gt;generate(Array) (Line: 206)
         Drupal\Console\Command\Generate\PluginBlockCommand-&gt;execute(Object, Object) (Line: 251)
         Symfony\Component\Console\Command\Command-&gt;run(Object, Object) (Line: 964)
         Symfony\Component\Console\Application-&gt;doRunCommand(Object, Object, Object) (Line: 248)
         Symfony\Component\Console\Application-&gt;doRun(Object, Object) (Line: 185)
         Drupal\Console\Core\Application-&gt;doRun(Object, Object) (Line: 64)
         Drupal\Console\Application-&gt;doRun(Object, Object) (Line: 148)
         Symfony\Component\Console\Application-&gt;run() (Line: 89)
         require(&#039;/vagrant/vendor/drupal/console/bin/drupal.php&#039;) (Line: 4)
         </pre>

Block file was generated

Drupal 8.5.6
Drupal Console version 1.8.0

@smalot
Copy link
Contributor

smalot commented Sep 11, 2018

I encountered the same issue with Drupal 8.6.1 and Drupal Console 1.8.0

[ERROR] <em class="placeholder">Warning</em>: array_flip(): Can only flip STRING and INTEGER values! in <em class="placeholder">Drupal\Console\Core\Style\DrupalStyle-&gt;choiceNoList()</em> (line <em class="placeholder">62</em> of <em class="placeholder">/data/www/hubside--hubside/vendor/drupal/console-core/src/Style/DrupalStyle.php</em>).

The error is displayed after generating resulting file.
Everything seems to work and the block is correctly displayed, but it is really strange

@LOBsTerr
Copy link
Member

Can you please help? Enable the learning mode and follow the steps to reproduce the issue. Then just copy the command generated for me

@LOBsTerr
Copy link
Member

OK, I have found the issue - #3959

@LOBsTerr
Copy link
Member

LOBsTerr commented Apr 6, 2019

It has been merged

@jdanaher-shine
Copy link

I received an error after generating a block. Here are the steps plus error message:

`// Welcome to the Drupal Plugin Block generator
Enter the module name [admin_toolbar]:

react_datepicker

Enter the plugin class name [DefaultBlock]:

ReactDatepickerBlock

Enter the plugin label [React datepicker block]:

Enter the plugin id [react_datepicker_block]:

Enter the theme region to render the Plugin Block. []:

sidebar

Do you want to load services from the container? (yes/no) [no]:

You can add input fields to create special configurations in the block.
This is optional, press enter to continue
Do you want to generate a form structure? (yes/no) [yes]:

no

Do you want to generate a themeable template? (yes/no) [no]:

yes

Do you want proceed with the operation? (yes/no) [yes]:

// cache:rebuild

Rebuilding cache(s), wait a moment please.

[OK] Done clearing cache(s).

Generated or updated files
Generation path: /var/www/html/web
1 - modules/custom/react_datepicker/src/Plugin/Block/ReactDatepickerBlock.php
2 - modules/custom/react_datepicker/react_datepicker.module
3 - modules/custom/react_datepicker/templates/react-datepicker-block.html.twig

Generated lines: 60

[ERROR] Warning: Invalid argument supplied for foreach() in Drupal\Console\Generator\PluginBlockGenerator->generate() (line 46 of /var/www/html/vendor/drupal/console/src/Generator/PluginBlockGenerator.php).

Drupal\Console\Generator\PluginBlockGenerator->generate(Array) (Line: 215)
Drupal\Console\Command\Generate\PluginBlockCommand->execute(Object, Object) (Line: 255)
Symfony\Component\Console\Command\Command->run(Object, Object) (Line: 1001)
Symfony\Component\Console\Application->doRunCommand(Object, Object, Object) (Line: 255)
Symfony\Component\Console\Application->doRun(Object, Object) (Line: 188)
Drupal\Console\Core\Application->doRun(Object, Object) (Line: 64)
Drupal\Console\Application->doRun(Object, Object) (Line: 148)
Symfony\Component\Console\Application->run() (Line: 89)
require('/var/www/html/vendor/drupal/console/bin/drupal.php') (Line: 4)
`

@ipwa
Copy link

ipwa commented Nov 24, 2020

@jdanaher-shine I think the problem is answering no in 'Do you want to generate a form structure?'. If you answer yes and define at least a field for title you will not get the error.

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

6 participants