Skip to content

Replace a symbol with an image from a controller

kayzore edited this page Nov 24, 2016 · 3 revisions

Replace a symbol with an image from a controller

<?php
// getting the smiley service :

$smileyService = $this->container->get('kay_smiley.smiley');

/*
checkSmiley function replaces all symbols in img marked :
$message is a string var contain "Hello World :)"
*/
$textFormat = $smileyService->checkSmiley($message);
// $textFormat contain now "Hello World <img src="/bundles/kaysmiley/images/happy1.png" class="kaySmileyImg">"


// If you want to get all symbols in json format :
$smileyService->getSmileyListJson($message);

Clone this wiki locally