public function generateLayout($layoutName, Site $site = null, $extension = self::EXTENSION) { $data = $this->layoutConfig[$layoutName]; $uid = $this->uidGenerator->generateUid($layoutName, $data, $site); // @todo this should be done from a manager not directly instantiating an instance $layout = new Layout($uid); // @todo warning when setting data other values are set to null! if (array_key_exists('columns', $data)) { $layout->setData($this->computeColumns($data['columns'])); } else { throw new \Exception('Layout ' . $layout->getLabel() . ' definition needs columns'); } $layout->setPicPath($layout->getUid() . '.png'); if ($site !== null) { $layout->setSite($site); } if (array_key_exists('label', $data) && $data['label'] !== null) { $layout->setLabel($data['label']); } else { $layout->setLabel(basename($layoutName, '.' . self::EXTENSION)); } if (array_key_exists('template', $data) && !empty($data['template'])) { $this->computeTemplate($layout, $data['template']); } else { // @todo improve $layout->setPath($layoutName . '.html.twig'); } return $layout; }