Last active
November 9, 2017 14:52
-
-
Save silasrm/f183a12affd13431a2c0 to your computer and use it in GitHub Desktop.
Listener de upload para OneupUploaderBundle que integra com Plupload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Meu\AppBundle\EventListener; | |
| use Oneup\UploaderBundle\Event\PostPersistEvent; | |
| class UploadListener | |
| { | |
| protected $service; | |
| public function __construct($service) | |
| { | |
| $this->service = $service; | |
| } | |
| public function onUpload(PostPersistEvent $event) | |
| { | |
| $response = $event->getResponse(); | |
| $result = $this->service->process($event->getFile()); | |
| $response['success'] = true; | |
| if($result === false) { | |
| throw new \Exception('Arquivo não processado!'); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" ?> | |
| <container xmlns="http://symfony.com/schema/dic/services" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | |
| <services> | |
| <service id="meu_app.upload_listener" class="Meu\AppBundle\EventListener\UploadListener"> | |
| <argument type="service" id="meu_app.services.fotos" /> | |
| <tag name="kernel.event_listener" event="oneup_uploader.post_persist.fotos" method="onUpload" /> | |
| </service> | |
| </services> | |
| </container> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment