-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Dispatch an event when an image is resized #5
Conversation
Coverage decreased (-0.7%) to 94.541% when pulling 70d20e79f29e35477e9e3440972d7bee375ac24d on feature/event-listener into 21636e8 on master. |
* | ||
* @param ImageInterface $image | ||
*/ | ||
public function setResizedImage(ImageInterface $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.
I think we should allow null
here too, so that an event listener can remove a resized image that a previous event listener added.
LGTM. I added some comments and I think we should add |
ResizeCalculatorInterface $calculator, | ||
Filesystem $filesystem, | ||
$path, | ||
EventDispatcher $eventDispatcher |
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.
How about making the event dispatcher optional and set it via a setEventDispatcher
method?
I have updated everything according to your comments. Also, I have moved the event dispatcher routines to the top of the |
9da7109
to
eb196f3
Compare
@@ -18,7 +18,8 @@ | |||
"require-dev": { | |||
"friendsofphp/php-cs-fixer": "~1.8", | |||
"phpunit/phpunit": "~4.5", | |||
"satooshi/php-coveralls": "~0.6" | |||
"satooshi/php-coveralls": "~0.6", | |||
"symfony/event-dispatcher": "~2.8|~3.0" |
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.
Shouldn’t it go into "require"
? We are using the interface which could change in a major version.
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.
But the event dispatcher is now optional, isn't it?
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.
Yes, but we have to ensure the correct version of the interface we are using. The library might be incompatible with EventDispatcherInterface
version 4.0.
Merged in 5410142 |
This PR adds the
contao.image.resize_image
event, which is dispatched when an image is resized (Resizer::executeResize
).I have chosen
resize_image
instead of justresize
so the class is calledResizeImageEvent
instead ofResizeEvent
and the constant is calledContaoImageEvents::RESIZE_IMAGE
instead ofContaoImageEvents::RESIZE
. I can change this though if you want.