Skip to content

make:crud | Improvements #241

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

Merged
merged 1 commit into from
Dec 13, 2018
Merged

make:crud | Improvements #241

merged 1 commit into from
Dec 13, 2018

Conversation

sadikoff
Copy link
Contributor

@sadikoff sadikoff commented Aug 10, 2018

Added datetimetz, *_immutable, dateinterval and json fileds processing.

closes #234
closes #270

case 'datetime':
$printCode .= ' ? '.$printCode.'|date(\'Y-m-d H:i:s\') : \'\'';
break;
case 'dateinterval':
$printCode .= ' ? '.$printCode.'.format(\'%y years, %m month, %d days\') : \'\'';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about ('%y year(s), %m month(s), %d day(s)') ?

@BackEndTea
Copy link

How about adding new test cases to make sure these behave as intended?
It should be easy enough to add them right here:

public function getEntityFieldPrintCodeTests()

case 'json':
case 'json_array':
$printCode .= ' is iterable ? '.$printCode.'|join(\', \') : '.$printCode;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! From looking at the docs, it seems like the value in this field will always be an array or null. Which case were you covering with the is iterable?

And, because the array can be an associative array, the |join won't look quite right in those cases. We could use dump() WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check it again. I thought there could be string value.

dump() is a good idea, but will it work without debug package?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It believe that it DOES work without debug - it reverts to var_dump(). We can add a json field to our entity in the functional test to be sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you know what? Let's use |json_encode. That will print nicely, and make it very obvious that this is a JSON field. And, it will definitely work :).

@sadikoff if you agree, can you make that change? Also, if you rebase from the latest master, the tests should be closer to passing.

@weaverryan
Copy link
Member

How about adding new test cases to make sure these behave as intended?
It should be easy enough to add them right here:

I agree! And actually, this test could be even a little bit cooler if we actually "rendered" the result through Twig (passing in some real entity object) and asserted the final output (instead of or in addition to asserting the Twig code that should be printed). But... that's not a requirement :).

@sadikoff
Copy link
Contributor Author

c769605 will close #277

@sadikoff sadikoff changed the title Improve fields representation in CRUD make:crud | Improvements Sep 28, 2018
@weaverryan
Copy link
Member

@sadikoff Can you rebase this? I want to make sure the tests pass with the latest changes on master. Also, there are 2 changes in this PR to .travis.yml - do we want those?

@sadikoff
Copy link
Contributor Author

@weaverryan ok, I'll rebase it

P.S. I think travis will be more stable with this changes

@weaverryan
Copy link
Member

Thanks Vladimir!

@weaverryan weaverryan merged commit f8457d5 into symfony:master Dec 13, 2018
weaverryan added a commit that referenced this pull request Dec 13, 2018
This PR was merged into the 1.0-dev branch.

Discussion
----------

make:crud | Improvements

Added datetimetz, *_immutable, dateinterval and json fileds processing.

closes #234
closes #270

Commits
-------

f8457d5 improve make:crud
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

Successfully merging this pull request may close these issues.

make:crud XType (or XController) make:crud does not handle DateInterval objects
3 participants