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

Improve Express Form controller #7014

Merged
merged 9 commits into from
Nov 8, 2018

Conversation

a3020
Copy link
Contributor

@a3020 a3020 commented Aug 28, 2018

PR:

  • Remove unused imports, unused variables
  • Improve a few if/else statements
  • Use app container instead of Core facade
  • Use Request object instead of e.g. Page::getCurrentPage()
  • Use ::class to make FQNs resolve
  • Remove unused (protected) entityManger property
  • Use Checker class import instead of the Permissions alias
  • Add a few docblocks (where it makes sense to have them)
  • Move the view method to the top, because that's where you'd expect it

I consider this as a first round of optimization / code clean up...

Ref #4723

@a3020 a3020 force-pushed the improve_express_form_controller branch from 72f4463 to 5c23665 Compare September 23, 2018 12:17
@a3020
Copy link
Contributor Author

a3020 commented Oct 11, 2018

If someone could review these commits, I'd be really thankful!

/**
* @return array [
* Key: string, asset type
* Value: string, the URL of the asset
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will return Value: array of strings

Copy link
Contributor

@wordish wordish left a comment

Choose a reason for hiding this comment

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

Nice refactor and code cleanup.

@@ -514,7 +510,7 @@ public function save($data)
$key->setAttributeType($type);
$settings = $control->getAttributeKey()->getAttributeKeySettings();
$settings->setAttributeKey($key);
$settings = $settings->mergeAndPersist($entityManager);
$settings->mergeAndPersist($entityManager);
Copy link
Member

Choose a reason for hiding this comment

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

You sure about this change? mergeAndPersist specifically returns a value that is now merged in the entity manager:

$detachedEntity = unserialize($serializedEntity); // some detached entity
$entity = $em->merge($detachedEntity);

Please change this pull request so that it only makes the obvious changes like removing needless facades, actual code styling cleanup, and removing unused imports, etc... Anything else and you might be misunderstanding what the original code does.

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 removed it because $settings isn't used later on in the code (afaik). I'll add it back if that's what you prefer.

@aembler aembler merged commit d39bd7e into concretecms:develop Nov 8, 2018
@a3020 a3020 deleted the improve_express_form_controller branch November 8, 2018 17:32
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.

3 participants