-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Enable images for Taxonomy/Taxon #92
Conversation
@@ -78,17 +78,20 @@ liip_doctrine_cache: | |||
|
|||
knp_gaufrette: | |||
adapters: | |||
variant_image: | |||
sylius_image: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Nice work Piotr! I'll review this soon - the build is failing, on every page so perhaps there is some configuration bug. Thanks! |
} | ||
} | ||
else { | ||
if (null === $subject->getId()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if
can be merged with elseif
below, and probably as replacement for else
line above.
@pjedrzejewski so remove image for Taxonomy - we must use image from root Taxon,you agree? |
foreach ($variant->getImages() as $image) { | ||
if (null === $image->getId()) { | ||
$this->uploader->upload($image); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} elseif (null === $subject->getId() || (($subject instanceof TaxonInterface || $subject instanceof TaxonomyInterface) && $subject->hasFile())) {
$this->uploader->upload($subject);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pjedrzejewski TBH. I didn't check code in such details =) Just looked at how it looks etc. =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pjedrzejewski maybe this is a good time to create SyliusFileUploader? Universal tool that handle file uploading with doctrine entities?
@Antek88 Yes, exactly! For taxonomy we will simply use And btw. the |
To upload image for root taxon on Taxonomy form, you can simply change the |
@pjedrzejewski @stloyd ping |
throw new \InvalidArgumentException('TaxonomyInterface expected.'); | ||
} | ||
|
||
if ($subject->getRoot()->hasImageFile()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if root
is empty? (not sure it's possible =)) Or what if file is already uploaded in root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root
is always created:
$this->setRoot(new Taxon());
if file already exist uploader firstly remove file and upload new:
if (null !== $image->getImagePath()) {
$this->remove($image->getImagePath());
}
Only problems I see is the removing typehint (maybe there is a reason but I'm pretty sure we should do it, maybe change the interface) and that during rebase, you reverted some other PR's. |
@@ -161,6 +161,9 @@ public function createTaxonomiesMenu(Request $request) | |||
|
|||
foreach ($taxonomies as $taxonomy) { | |||
$child = $menu->addChild($taxonomy->getName(), $childOptions); | |||
if ($taxonomy->getRoot()->getPath()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO you should add hasPath()
as you already have hasFile()
method, or at least use variable here to avoid twice get*
call (same below).
…image" This reverts commit 284b0d0a2a448b11ca9b9fef1a6d5d9638ca4320, reversing changes made to 553eea88539ffd170228e12793e60beabf3a95f3.
@pjedrzejewski ping, tests fixed 😄 |
</many-to-one> | ||
</entity> | ||
|
||
</doctrine-mapping> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to re-define this if we add image only to taxon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this because in DefaultTaxonomy (Taxonomies bundle) class we have:
$this->setRoot(new DefaultTaxon());
and after remove Taxonomy mapping from core bundle i have error when creating new taxonomy:
[Doctrine\ORM\ORMException]
Found entity of type Sylius\Bundle\TaxonomiesBundle\Entity\DefaultTaxon on association Sylius\Bundle\TaxonomiesBundle\Entity\DefaultTaxonom
y#root, but expecting Sylius\Bundle\CoreBundle\Entity\Taxon
Enable images for Taxonomy/Taxon
Woohoo, thank you Piotr! Great work! 👍 |
[CJMAX-82] Added more fields to Customer
See #83
Any comments welcome :)