Skip to content

Commit e5c79a1

Browse files
committed
formcontrol
1 parent 549f18e commit e5c79a1

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/Generator/FileGenerator.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,26 @@ private static function addService(string $filename, string $config, string $cla
7777
break;
7878
}
7979
}
80+
81+
public static function getLatteTemplate(string $control, ?string $title = 'Control', ?string $icon = 'user')
82+
{
83+
return <<<DOC
84+
<div class="row">
85+
<div class="col-12">
86+
<div class="ws__card">
87+
<div class="ws__card-head">
88+
<i class="ws__card-icon">
89+
<i class="fa-solid fa-$icon"></i>
90+
</i>
91+
<p>$title</p>
92+
</div>
93+
<div class="ws__card-body">
94+
{control $control}
95+
</div>
96+
</div>
97+
</div>
98+
</div>
99+
100+
DOC;
101+
}
80102
}

src/Generator/Generators/FormControl.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,20 @@ public static function generate(string $name, ?string $entity = null): FileObjec
6565
$class->addMethod('render')
6666
->setReturnType('void')
6767
->addBody('$this->template->setTranslator($this->translator);')
68-
->addBody('$this->template->setFile(dirname($this->getReflection()->getFileName()) . \'/templates/'.lcfirst($name).'FormControl.latte\');')
68+
->addBody('$this->template->setFile(dirname(self::getReflection()->getFileName()) . \'/templates/'.lcfirst($name).'FormControl.latte\');')
6969
->addBody('$this->template->render();');
7070

7171
return new FileObject(self::DIR_PATH . ($entity ? "$entity/" : ''), $name.'FormControl', $file, $entity);
7272
}
7373

7474
public static function generateTemplate(string $name, ?string $entity = null): void
7575
{
76-
$dir = self::DIR_PATH.($entity ? "$entity/" : '/').'templates/';
76+
$dir = self::DIR_PATH.($entity ? "$entity/" : '').'templates/';
7777
if (!FileGenerator::folderExist($dir)) {
7878
mkdir($dir, 0777, true);
7979
}
8080

81-
file_put_contents($dir . lcfirst($name.'FormControl.latte'), '{form ' . lcfirst($name.'Form') . '}'.PHP_EOL.'{/form}'.PHP_EOL);
81+
file_put_contents($dir . lcfirst($name.'FormControl.latte'), FileGenerator::getLatteTemplate(lcfirst($name.'Form'), $name));
8282
}
8383

8484
private static function getFullClass(string $name, ?string $entity = null, bool $factory = false)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy