-
Notifications
You must be signed in to change notification settings - Fork 120
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
Error using --providerList and possible fix #265
Comments
Can you try
usually Yii CLI applications should parse a comma separated list as an array. |
Thanks for the quick reply @schmunk42 ! I think I tried that already but to be sure I just tried that again and get the same error. If I add my code in it works, but in saying that I haven't successfully got the date time callback to work. At the moment just outputting text field still. Maybe my addition is screwing it up? Will keep looking into it |
It looks like the one (1) provider in the options is treated as a string rather than an array. With your check it would (also) not be added to the provider list. For debugging: Could you add another provider as a second element? A fix could be to cast the option into an array, but this could also be a framework issue (CC: @cebe) |
Thanks. I tried this:
and it still didn't work. also tried it like:
To get around it I did what you suggested and did this before the for loop:
|
Still can't get the DateTimeProvider working. Traced it back to this in DateTimeProvider.php
the columnNames array is empty. Im setting it like the instructions say:
Can't see anywhere in the code where columnNames actually gets set? |
Looks good. the check should be here:
|
If I put a var_dump($this->columnNames); above the switch it prints out an empty array for every field. so it never makes it into that section of the case. When I said "Can't see anywhere in the code where columnNames actually gets set?" i meant I can't see where $this->columnNames gets the array from the bootstrap but I think its me not understanding DI. Need to do a bit more reading on it. |
Where you use use DI? Can be done in the config i.e. |
Since I’m finding the columnName property is empty In the DateTimeProvider I’m trying to understand where the values in the columnName array in bootstrap.php get loaded into the DateTimeProvider object.
|
Can you post the file where you are setting it? Can be done in several places. |
Thanks. bootstrap.php has:
and giiant.php has
will do some extra logging now and see what it shows. |
Where is |
Im using the advanced template. Running it from the console using
So in answer to your question I believe the yii command does this: `
defined('YII_DEBUG') or define('YII_DEBUG', true); require DIR . '/vendor/autoload.php'; So done some more digging into a few of the issues:
This forces an input like this:
or like:
doesn't work, should be: (notice the \yii added in)
just before the switch here:
widget began to generate when I did this. Looking into why its not being passed in correctly. |
Found the issue for why the columnName was not being passed into the DateTimeProvider..missing a freaking backslash! I noticed in ProviderTrait.php it calls this:
Made me thing that if the $class value didn't match exactly it would fail. Checked my code and my bootstrap had no backslash:
but my --providerList did:
added a \ to the bootstrap and it worked....as long as I applied changes 1 and 2 in my last post. |
Might be better this use So, is this still and issue with giiant or was it only DI? |
Thanks for the response schmunk42. I believe there are a few issues with Giiant.
doesn't work. Maybe the external library has changed its structure. It should be:
above this line: yii2-giiant/src/generators/crud/Generator.php Line 315 in 3d00e9c
Is it possible to add these changes to the code? I'm having issues with custom templates for crud and schema with models but will start another thread on these issues. |
actually adding
messes up if you are using the Gii web form. This works:
|
Hmm, wouldn't this break, when using a real array via DI in a config, since an array would be exploded? We should have tests for all cases, CLI, DI, Web with one and multiple items. |
Hi,
when I run this command:
./yii gii/giiant-crud --modelClass='common\models\MyModel' --enablePjax=1 --tidyOutput=1 --controllerClass='backend\controllers\MyModelController' --indexWidgetType='grid' --searchModelClass='common\models\MyModelSearch' --viewPath='@backend/views' --baseControllerClass='backend\controllers\base\BaseController' --accessFilter=0 --enableI18N=0 --indexWidgetType='grid' --providerList=['\schmunk42\giiant\generators\crud\providers\extensions\DateTimeProvider'] --overwriteControllerClass=0
I get the following error:
If found that if I change line 62 to the following it fixes it.
if ($this->providerList && is_array($this->providerList)) {
Seems it was trying to loop over a non array. I don't know the code super well so if this isn't breaking anything else could it be added to the source?
Thanks,
The text was updated successfully, but these errors were encountered: