Created
November 10, 2014 15:55
-
-
Save dogawaf/284f348547a8537b6df5 to your computer and use it in GitHub Desktop.
FLOW - delete image resource
This file contains 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 ACME\Admin\Controller; | |
use TYPO3\Flow\Annotations as Flow; | |
/** | |
* Class ContentController | |
*/ | |
class ContentController extends \TYPO3\Flow\Mvc\Controller\ActionController | |
{ | |
/** | |
* @Flow\Inject | |
* @var \ACME\Admin\Domain\Repository\ContentRepository | |
*/ | |
protected $contentRepository; | |
/** | |
* @Flow\Inject | |
* @var \TYPO3\Flow\Resource\ResourceManager | |
*/ | |
protected $resourceManager; | |
/** | |
* Mise à jour d'une actualité | |
* | |
* @param \ACME\Admin\Domain\Model\Content $content | |
* @param bool $deleteImageFile | |
* @return void | |
*/ | |
public function updateNewsAction(Content $content, $deleteImageFile = FALSE) | |
{ | |
if ($deleteImageFile === TRUE) { | |
$this->resourceManager->deleteResource($content->getImageFile()->getResource()); | |
$content->setImageFile(NULL); | |
} | |
$this->contentRepository->update($content); | |
$this->redirect('indexNews'); | |
} | |
/** | |
* Suppression d'une actualité | |
* | |
* @param Content $content | |
* @return void | |
*/ | |
public function deleteNewsAction(Content $content) | |
{ | |
if ($content->getImageFile() !== NULL) { | |
$this->resourceManager->deleteResource($content->getImageFile()->getResource()); | |
} | |
$this->contentRepository->remove($content); | |
$this->redirect('indexNews'); | |
} | |
} |
This file contains 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
<div class="row"> | |
<div class="col-md-12"> | |
<div class="portlet box blue"> | |
<div class="portlet-title"> | |
<div class="caption"> | |
Image de fond | |
</div> | |
</div> | |
<div class="portlet-body"> | |
<f:if condition="{content.imageFile}"> | |
<div class="thumbnail"> | |
<m:image image="{content.imageFile}" | |
maximumWidth="400" | |
maximumHeight="200" | |
alt=""/> | |
<div class="caption"> | |
<p>Taille réelle : {content.imageFile.width}x{content.imageFile.height}</p> | |
<label><f:form.checkbox name="deleteImageFile" value="TRUE"/> Supprimer</label> | |
</div> | |
</div> | |
</f:if> | |
<div class="fileinput fileinput-new" data-provides="fileinput"> | |
<span class="btn default btn-file"> | |
<span class="fileinput-new">Sélectionnez un fichier </span> | |
<span class="fileinput-exists">Changer </span> | |
<f:form.upload property="imageFile.resource"/> | |
</span> | |
<span class="fileinput-filename"></span> | |
<a href="#" class="close fileinput-exists" data-dismiss="fileinput"></a> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment