<?php
namespace AclInlineCkEditorBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Pimcore\Model\WebsiteSetting;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class DefaultController extends Controller
{
/**
* @Route("/")
*/
public function indexAction()
{
return $this->redirectToRoute("pimcore_admin_index");
}
/**
* @Route("/replaceTextConfig", name="replace_text_config", methods={"GET"})
*/
public function replaceTextAction()
{
$replaceSettings = WebsiteSetting::getByName('replaceValue', null);
if (!$replaceSettings) {
return $this->json([]);
}
$formattedValues = [];
if ($values = $replaceSettings->getData()) {
$a = explode(',', $values);
foreach ($a as $result) {
$b = explode('-', $result);
$key = $this->transformUnicode(trim($b[0]));
if (count($b) > 1) {
$value = $b[1];
} else {
$value = "";
}
$formattedValues[$key] = $value;
}
}
return $this->json($formattedValues);
}
public function transformUnicode(string $data): ?string
{
$newChar = "%" . str_replace("+", "", $data);
$newChar = strtolower($newChar);
$newChar = preg_replace('/%u([0-9A-F]+)/', '&#x$1;', $newChar);
return html_entity_decode($newChar, ENT_COMPAT, 'UTF-8');
}
}