我想使用存根文件中的(preg_match)从特定模式生成不超过n级的部分和子部分文件。让我们假设已生成带有布局文件的布局目录。我搜索了样式并制作了部分布局。如果现有文件中有部分样式,我想生成高达N级的子部分文件
到目前为止,我已经做到了
public function handle()
{
$input = $this->getCommandInput();
$path = $this->getDestenationPath($input->layoutDirectory);
$destenationFile = $path . $input->layoutFileName;
if ($this->alreadyExists($destenationFile)) {
$this->error('The layout already exists! To override the existing file, use --force option.');
return false;
}
$stubName = $input->withoutValidation ? 'layout' : 'layout-with-validation';
$stub= $this->getStubContent($stubName, $this->getTemplateName());
$this->replaceApplicationName($stub, $input->appName)
->createFile($destenationFile, $stub)
->info('A Layout with Following Partials Have Been Crafted !');
//generating partials//
$partials=$this->replacePartialName($stub);
foreach ($partials as $partial){
print_r($partial);
$partialContent=$this->getStubContent($partial);
print_r($partialContent);
$header=$this->replacePartialName($partialContent);
print_r($header);
$fileExtension=Helpers::postFixWith(trim($partial) ?: $partial, '.blade.php');
$destenation=$this->getDestenationPath($input->layoutDirectory).$fileExtension;
$this->replaceApplicationName($partialContent, $input->appName)
->createFile($destenation, $partialContent)
->info($partial.'.blade.php');
}
}