Jaxel
Well-known member
I am populating one of my pages with an entity, where the parameters to this entity are contained in the ParameterBag.
However, if the entity is not found, I would like to still populate the page with relevant data being constructed with the information from the ParameterBag. Doing this allows me to continue using the getter functions I've defined in my entity structure.
Is there a downside to doing this? For instance, is it a significant strain on resources and performance to be creating these entities, only to throw them away on each page load?
However, if the entity is not found, I would like to still populate the page with relevant data being constructed with the information from the ParameterBag. Doing this allows me to continue using the getter functions I've defined in my entity structure.
Is there a downside to doing this? For instance, is it a significant strain on resources and performance to be creating these entities, only to throw them away on each page load?
Code:
$stream = $streamRepo->findStream()
->where('service_id', $params['service_id'])
->where('stream_value1', $params['stream_value1'])
->where('stream_value2', !empty($params['stream_value2']) ? $params['stream_value2'] : '')
->fetchOne();
if (!$stream)
{
$stream = $this->em()->create('EWR\Rio:Stream');
$stream->bulkSet([
'service_id' => $params['service_id'],
'stream_value1' => $params['stream_value1'],
'stream_value2' => !empty($params['stream_value2']) ? $params['stream_value2'] : '',
]);
}