We will get the layout and generate into the application
directory.

@param $layout

@return bool
774411
public function generateLayout($layout)
    {
        $layout = Inflector::toDirectorySeparator($layout);

        $file = $this->getViewTemplatePath().$layout.DS.$this->viewLayoutName();
        $appViewPath = '';
        $appViewPath = $this->command->applicationDir.DS.'Views'.DS;

        $this->hasDirectory($appViewPath);
        $this->hasDirectory($appViewPath.'layouts');
        $this->hasDirectory($appViewPath.DS.$layout);

        file_exists($file) or die("Base layout stub file doesn't exists in Cygnite Core");

        $layoutFile = $appViewPath.$layout.DS.$this->viewLayoutName();

        if ($this->layoutType == 'php') {
            $layoutFile = str_replace('.stub', EXT, $layoutFile);
        } else {
            $layoutFile = str_replace('.stub', '.twig', $layoutFile);
        }

        if (file_exists($layoutFile)) {
            echo "\n Layout file already exists in $layoutFile directory \n";

            return true;
        }

        /*read operation ->*/
        // Open the file to get existing content
        $fileContent = file_get_contents($file);

        $handle = null;

        $handle = fopen($layoutFile, 'w') or die('Cannot open file:  '.$layoutFile);

        fwrite($handle, $fileContent);
        fclose($handle);
    }
397357
public function buildPermissionsIndex(MenuLayoutDataInterface $layout)
    {
        $this->permissionsIndex = new PermissionsIndexData;
        $this->permissions      = [];

        $this->compileIndexForLayoutLayer($layout->layout());

        $this->permissions = array_unique($this->permissions);
        $this->permissionsIndex->permissions = $this->permissions;

        return $this->permissionsIndex;
    }
60509
public function setLayout($layout)
	{
		if (strpos($layout, ':') === false)
		{
			$this->_layout = $layout;
		}
		else
		{
			// Convert parameter to array based on :
			$temp = explode(':', $layout);
			$this->_layout = $temp[1];

			// Set layout template
			$this->_layoutTemplate = $temp[0];
		}

		return $this;
	}
778777
public function setLayout( $template )
	{
		$template = str_replace( get_stylesheet_directory().'/templates/', '', $template );
		$this->template = UtilityFacade::trimRight( $template, '.php' );
		return $this->get( apply_filters( 'castor/templates/layout', 'layouts/default' ));
	}
703959
public function getLayoutFile($controller,$layoutName)
	{
		$moduleViewPath=$basePath=$this->getViewPath();
		$module=$controller->getModule();
		if(empty($layoutName))
		{
			while($module!==null)
			{
				if($module->layout===false)
					return false;
				if(!empty($module->layout))
					break;
				$module=$module->getParentModule();
			}
			if($module===null)
				$layoutName=Yii::app()->layout;
			else
			{
				$layoutName=$module->layout;
				$moduleViewPath.='/'.$module->getId();
			}
		}
		elseif($module!==null)
			$moduleViewPath.='/'.$module->getId();

		return $controller->resolveViewFile($layoutName,$moduleViewPath.'/layouts',$basePath,$moduleViewPath);
	}
956747
public function save(Layout $layout)
    {
        $archiveDir = $this->getUploadDir().'/archives';
        $templateDir = $this->getUploadDir().'/templates';
        $tmpDir = $this->getUploadDir().'/tmp/'.time();

        // Copy the archive to the archive directory
        $file = $layout->getFile()->move(
            $archiveDir,
            $layout->getFile()->getClientOriginalName()
        );

        // Extract the archive
        $zip = new \ZipArchive();
        $zip->open($archiveDir.'/'.$layout->getFile()->getClientOriginalName());
        $zip->extractTo($tmpDir);
        $zip->close();

        $config = $this->readConfiguration($tmpDir);

        $this->om->beginTransaction();
        try {
            $id = $this->getUniqueId($layout);

            $this->saveInDb(
                $config['label'],
                'uploads/' . $id . '/' . $config['templateName'],
                '/bundles/canaltpmtt/img/uploads/' . $id . '/' . $config['previewFileName'],
                $config['orientation'],
                isset($config['pageSize']) ? $config['pageSize'] : Layout::PAGE_SIZE_A4
            );

            // Move the assets
            $this->moveFiles(array('*.png', '*.jpg'), $tmpDir, $templateDir . '/img/' . $id);
            $this->moveFiles('*.twig', $tmpDir, $templateDir . '/twig/' . $id);
            $this->moveFiles('*.css', $tmpDir, $templateDir . '/css/' . $id, false);

            // If the layout has a fonts directory, we copy this directory to the css one.
            if ($fontsDirs = $this->getDirectories($tmpDir, 'fonts')) {
                $this->filesystem->remove($templateDir . '/css/' . $id . '/fonts');
                $this->filesystem->rename(current($fontsDirs), $templateDir . '/css/' . $id . '/fonts', true);
            }

            // Remove the tmp directory
            $this->filesystem->remove($tmpDir);
            $this->om->commit();
        } catch (\Exception $e) {
            $this->om->rollback();
            throw $e;
        }
    }
900268
static function LayoutTemplate(Layout $layout)
    {
        $folder = Path::Combine(PHINE_PATH, 'App/Phine/LayoutTemplates');
        $file = Path::Combine($folder, $layout->GetName());
        return Path::AddExtension($file, 'phtml');
    }
212728
public function renderContent($layout = null, $title = null)
    {
        if ($this->hasSourceComponent()) {
            return $this->SourceComponent()->renderContent($layout, $title);
        }
        
        return parent::renderContent($layout, $title);
    }
804475
public function generate() {
		$layout = $this->getTheme().'_layout';
		$layout = THEMES_ROOT.'/'.$this->getTheme()."/$layout.phtml";

		global $content;
		try {
			Router::start();

			$content = Router::getContent();

			if (!file_exists($layout)) { die("layout: $layout  not found"); }
		} catch (\Exception $exception) {
			$content = (new ExceptionGenerator($exception))->get();
		}

		if ($layout != 'no_layout') {
			require $layout;
		}
	}
1218880
public function template($template = false, $layout = null)
    {
        if ($template === false) {
            return [
                'template' => $this->_template,
                'layout' => $this->_layout,
            ];
        }
        $this->_template = $template;
        if ($layout !== null) {
            $this->_layout = $layout;
        }

        return $this;
    }
502823
public function view($layout='default', $name='')
	{
		$view = new View(array(
			'folder'  => $this->_type,
			'element' => $this->_name,
			'name'    => ($name   ?: $this->_name),
			'layout'  => ($layout ?: 'default')
		));
		return $view;
	}
1270773
public function setContent($layout)
	{
		$content = '';

		$state_array = $this->getStateArray();
		foreach($state_array as $state_key => $state)
		{
			$content.=$state->getForm();
		}
		$layout->content = $content;
	}
1349061
protected function _prepareLayout()
    {
        $this->removeButton('add');
        $this->_addButton('add_new', array(
            'label' => $this->__('Generate Schedule'),
            'onclick' => "setLocation('{$this->getUrl('*/*/generateSchedule')}')",
        ));
        $this->_addButton('configure', array(
            'label' => $this->__('Cron Configuration'),
            'onclick' => "setLocation('{$this->getUrl('adminhtml/system_config/edit', array('section' => 'system'))}#system_cron')",
        ));
        return parent::_prepareLayout();
    }
1142140
public function updateLayout(Layout $layout): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_layout')
            ->set('type', ':type')
            ->set('name', ':name')
            ->set('description', ':description')
            ->set('created', ':created')
            ->set('modified', ':modified')
            ->set('shared', ':shared')
            ->set('main_locale', ':main_locale')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $layout->id, Type::INTEGER)
            ->setParameter('type', $layout->type, Type::STRING)
            ->setParameter('name', $layout->name, Type::STRING)
            ->setParameter('description', $layout->description, Type::STRING)
            ->setParameter('created', $layout->created, Type::INTEGER)
            ->setParameter('modified', $layout->modified, Type::INTEGER)
            ->setParameter('shared', $layout->shared, Type::BOOLEAN)
            ->setParameter('main_locale', $layout->mainLocale, Type::STRING);

        $this->applyStatusCondition($query, $layout->status);

        $query->execute();
    }
536701
protected function questions_recode_layout($layout) {
        // Extracts question id from sequence
        if ($questionids = explode(',', $layout)) {
            foreach ($questionids as $id => $questionid) {
                if ($questionid) { // If it is zero then this is a pagebreak, don't translate
                    $newquestionid = $this->get_mappingid('question', $questionid);
                    $questionids[$id] = $newquestionid;
                }
            }
        }
        return implode(',', $questionids);
    }
29103
protected function setupLayout($layout = null)
    {
        $this->layout = !is_null($layout) ? $layout : $this->layout;
        if ($this->layout && is_string($this->layout) && view()->exists($this->layout)) {
            $this->layout = view($this->layout);
        }
    }
404867
private function setCacheCompiler($f, $layout=false)
	{
        $viewCompiler = new viewCompiler($this);
        $viewCompiler->content = file_get_contents($f);

		if($layout === true) {
			return $viewCompiler->runCompiler([
				'renderCompiler',
				'startLayoutSectionCompiler',
				'echoCompiler'
			]);
		} else {
			return $viewCompiler->runCompiler(['startLayoutSectionCompiler'], true);
		}
	}