I am trying to find the correct place in my code to place database-reading code, and the correct way to pass the data that's been read in the database to the receiving object. Below is my code. Note the $metaData
variable. That is the variable in question (it receives data from DB, and it is later passed to the receiving object).
class Controller
{
// generages PDF with data placed in specific areas of PDF
public function generateOutline($outputData)
{
// PDF library engine
$pdfEngine = new PdfEngine();
// Doctrine ORM Database Connector
$em = DoctrineConnector::getEntityManager();
// object containing metadata describing where to place data for $outputData
$metaData = $em->getRepository(Metadata::class)->findAll();
//method that places $outputData as described by $metaData
$pdfEngine->generateOutline($metaData, $outputData);
}
}
// part of View, because PDF is displayed to us
class PdfEngine
{
public function generateOutline(Metadata $metaData, array $data)
{
$this->placeTextOnPdf($metaData, $data);
}
}
Question...
I am having trouble figuring out where to place $metaData
constructs.
You see. .. $metaData
is the one variable being read from a database (in my code)
Can I place Database into View? Not really. View should not concern itself with details of the database.
Can I place Database into Controller? Not really it should be "skinny controller, fat model"
DO I perchance place it into Model? Where is the model what is it, where do I place my code?