Skip to content

Instantly share code, notes, and snippets.

@kamil161g
Created January 19, 2019 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamil161g/d8b359a775e3e24996060f292c514ad6 to your computer and use it in GitHub Desktop.
Save kamil161g/d8b359a775e3e24996060f292c514ad6 to your computer and use it in GitHub Desktop.
<?php
namespace App\Services;
use App\Entity\Material;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class MessageGenerator extends AbstractController
{
public function getMaterial()
{
$carbon = $this->getDoctrine()
->getRepository(Material::class)
->findOneBy([
'user' => $this->getUser(),
'category' => 'Carbon'
]);
$stone = $this->getDoctrine()
->getRepository(Material::class)
->findOneBy([
'user' => $this->getUser(),
'category' => 'Stone'
]);
$wood = $this->getDoctrine()
->getRepository(Material::class)
->findOneBy([
'user' => $this->getUser(),
'category' => 'Wood'
]);
$food = $this->getDoctrine()
->getRepository(Material::class)
->findOneBy([
'user' => $this->getUser(),
'category' => 'Food'
]);
$gold = $this->getDoctrine()
->getRepository(Material::class)
->findOneBy([
'user' => $this->getUser(),
'category' => 'Gold'
]);
return [
'carbon' => $carbon,
'stone' => $stone,
'wood' => $wood,
'food' => $food,
'gold' => $gold,
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment