/** * Return entity instance. * * @param $id * @return null|Cmd */ private function findEntity($id) { $collection = $this->context->getCmdCollection(); if (!$collection->has($id)) { $this->context->getLogger()->debug('Cmd instance for ID: ' . $id . ' not found. Perform initialization.'); $cmd = new Cmd(); $collection->set($id, $cmd); } return $collection->get($id); }