services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
$images_directory: '%app.images_directory%'
$lang: '%blabalabla%' # Господа, обратите внимание!
В целом, серебряной пули нет
{
"code": 0,
"count": 28,
"items": [
{
"id": 1,
"price": 469,
"name": "黑果越橘桔子奇亚籽",
"old_price": 0,
"image": null,
"description": "奇亚籽,椰子奶,香蕉,桔子,浆果糖浆。配花生和薄荷。"
},
{
"id": 2,
"price": 715,
"name": "FRIDAYS™ 签名汉堡包",
"old_price": 0,
"image": null,
"description": "\"主要由两片小圆面包夹一块牛肉饼,胡椒的培根,干酪组成,配\nFridays™ 特色酱\""
},
{
"id": 4,
"price": 640,
"name": "FRIDAYS™ 芝士汉堡包",
"old_price": 0,
"image": null,
"description": "传统的汉堡包"
}
]
}
/**
* @param string $locale
* @return mixed
*/
public function getAll(string $locale)
{
$manager = $this->getEntityManager();
$rsm = new ResultSetMapping();
$rsm->addScalarResult("id", "id", "integer");
$rsm->addScalarResult("title", "title", "string");
$rsm->addScalarResult("description", "description", "string");
$sql = "select c.id id, ct.content title, ct.content description from categories c left join categories_translations ct on c.id = ct.object_id and ct.locale = :locale";
$query = $manager->createNativeQuery($sql, $rsm);
$query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_FALLBACK, 1);
$query->setParameters([
"locale" => $locale
]);
return $query->getResult(AbstractQuery::HYDRATE_OBJECT);
}