// Set new image and extension if necessary
if (!
empty($mediaManagerData)) { $bannerModel->
setImage($mediaManagerData);
} // Strip full qualified url
$mediaService =
$this->
get(MediaServiceInterface::
class);
$bannerModel->
setImage($mediaService->
normalize($bannerModel->
getImage()));
// Write model to db
try { $this->
get('models'
)->
persist($bannerModel);
$this->
get('models'
)->
flush();
$params['id'
] =
$bannerModel->
getId();
$this->
View()->
assign(['success' => 'true', 'data' =>
$params]);
} catch (Exception
$e) { $errorMsg =
$e->
getMessage();
$this->
View()->
assign(['success' => 'false', 'errorMsg' =>
$errorMsg]);
} } /**
* Method to delete a banner. It takes either a single ID or an array of IDs to determine the banners to delete.
* If there is no ID parameter given, it will look if there is a parameter banners available
*
* e.g. id=1 or banners[[id => 1], [id => 2], [id => 3]]
*/