initial commit
This commit is contained in:
88
vendor/symfony/maker-bundle/templates/crud/controller/Controller.tpl.php
vendored
Normal file
88
vendor/symfony/maker-bundle/templates/crud/controller/Controller.tpl.php
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
<?= "<?php\n" ?>
|
||||
|
||||
namespace <?= $class_data->getNamespace() ?>;
|
||||
|
||||
<?= $class_data->getUseStatements(); ?>
|
||||
|
||||
#[Route('<?= $route_path ?>')]
|
||||
<?= $class_data->getClassDeclaration() ?>
|
||||
|
||||
{
|
||||
<?= $generator->generateRouteForControllerMethod('', sprintf('%s_index', $route_name), ['GET']) ?>
|
||||
<?php if (isset($repository_full_class_name)): ?>
|
||||
public function index(<?= $repository_class_name ?> $<?= $repository_var ?>): Response
|
||||
{
|
||||
return $this->render('<?= $templates_path ?>/index.html.twig', [
|
||||
'<?= $entity_twig_var_plural ?>' => $<?= $repository_var ?>->findAll(),
|
||||
]);
|
||||
}
|
||||
<?php else: ?>
|
||||
public function index(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$<?= $entity_var_plural ?> = $entityManager
|
||||
->getRepository(<?= $entity_class_name ?>::class)
|
||||
->findAll();
|
||||
|
||||
return $this->render('<?= $templates_path ?>/index.html.twig', [
|
||||
'<?= $entity_twig_var_plural ?>' => $<?= $entity_var_plural ?>,
|
||||
]);
|
||||
}
|
||||
<?php endif ?>
|
||||
|
||||
<?= $generator->generateRouteForControllerMethod('/new', sprintf('%s_new', $route_name), ['GET', 'POST']) ?>
|
||||
public function new(Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$<?= $entity_var_singular ?> = new <?= $entity_class_name ?>();
|
||||
$form = $this->createForm(<?= $form_class_name ?>::class, $<?= $entity_var_singular ?>);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->persist($<?= $entity_var_singular ?>);
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('<?= $route_name ?>_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('<?= $templates_path ?>/new.html.twig', [
|
||||
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}', $entity_identifier), sprintf('%s_show', $route_name), ['GET']) ?>
|
||||
public function show(<?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response
|
||||
{
|
||||
return $this->render('<?= $templates_path ?>/show.html.twig', [
|
||||
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
|
||||
]);
|
||||
}
|
||||
|
||||
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}/edit', $entity_identifier), sprintf('%s_edit', $route_name), ['GET', 'POST']) ?>
|
||||
public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$form = $this->createForm(<?= $form_class_name ?>::class, $<?= $entity_var_singular ?>);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$entityManager->flush();
|
||||
|
||||
return $this->redirectToRoute('<?= $route_name ?>_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
|
||||
return $this->render('<?= $templates_path ?>/edit.html.twig', [
|
||||
'<?= $entity_twig_var_singular ?>' => $<?= $entity_var_singular ?>,
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}', $entity_identifier), sprintf('%s_delete', $route_name), ['POST']) ?>
|
||||
public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($this->isCsrfTokenValid('delete'.$<?= $entity_var_singular ?>->get<?= ucfirst($entity_identifier) ?>(), $request->getPayload()->getString('_token'))) {
|
||||
$entityManager->remove($<?= $entity_var_singular ?>);
|
||||
$entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('<?= $route_name ?>_index', [], Response::HTTP_SEE_OTHER);
|
||||
}
|
||||
}
|
||||
4
vendor/symfony/maker-bundle/templates/crud/templates/_delete_form.tpl.php
vendored
Normal file
4
vendor/symfony/maker-bundle/templates/crud/templates/_delete_form.tpl.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<form method="post" action="{{ path('<?= $route_name ?>_delete', {'<?= $entity_identifier ?>': <?= $entity_twig_var_singular ?>.<?= $entity_identifier ?>}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ <?= $entity_twig_var_singular ?>.<?= $entity_identifier ?>) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
||||
4
vendor/symfony/maker-bundle/templates/crud/templates/_form.tpl.php
vendored
Normal file
4
vendor/symfony/maker-bundle/templates/crud/templates/_form.tpl.php
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
||||
11
vendor/symfony/maker-bundle/templates/crud/templates/edit.tpl.php
vendored
Normal file
11
vendor/symfony/maker-bundle/templates/crud/templates/edit.tpl.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?= $helper->getHeadPrintCode('Edit '.$entity_class_name) ?>
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit <?= $entity_class_name ?></h1>
|
||||
|
||||
{{ include('<?= $templates_path ?>/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('<?= $route_name ?>_index') }}">back to list</a>
|
||||
|
||||
{{ include('<?= $templates_path ?>/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
35
vendor/symfony/maker-bundle/templates/crud/templates/index.tpl.php
vendored
Normal file
35
vendor/symfony/maker-bundle/templates/crud/templates/index.tpl.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?= $helper->getHeadPrintCode($entity_class_name.' index'); ?>
|
||||
|
||||
{% block body %}
|
||||
<h1><?= $entity_class_name ?> index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($entity_fields as $field): ?>
|
||||
<th><?= ucfirst($field['fieldName']) ?></th>
|
||||
<?php endforeach; ?>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for <?= $entity_twig_var_singular ?> in <?= $entity_twig_var_plural ?> %}
|
||||
<tr>
|
||||
<?php foreach ($entity_fields as $field): ?>
|
||||
<td>{{ <?= $helper->getEntityFieldPrintCode($entity_twig_var_singular, $field) ?> }}</td>
|
||||
<?php endforeach; ?>
|
||||
<td>
|
||||
<a href="{{ path('<?= $route_name ?>_show', {'<?= $entity_identifier ?>': <?= $entity_twig_var_singular ?>.<?= $entity_identifier ?>}) }}">show</a>
|
||||
<a href="{{ path('<?= $route_name ?>_edit', {'<?= $entity_identifier ?>': <?= $entity_twig_var_singular ?>.<?= $entity_identifier ?>}) }}">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="<?= (count($entity_fields) + 1) ?>">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('<?= $route_name ?>_new') }}">Create new</a>
|
||||
{% endblock %}
|
||||
9
vendor/symfony/maker-bundle/templates/crud/templates/new.tpl.php
vendored
Normal file
9
vendor/symfony/maker-bundle/templates/crud/templates/new.tpl.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?= $helper->getHeadPrintCode('New '.$entity_class_name) ?>
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new <?= $entity_class_name ?></h1>
|
||||
|
||||
{{ include('<?= $templates_path ?>/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('<?= $route_name ?>_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
22
vendor/symfony/maker-bundle/templates/crud/templates/show.tpl.php
vendored
Normal file
22
vendor/symfony/maker-bundle/templates/crud/templates/show.tpl.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?= $helper->getHeadPrintCode($entity_class_name) ?>
|
||||
|
||||
{% block body %}
|
||||
<h1><?= $entity_class_name ?></h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<?php foreach ($entity_fields as $field): ?>
|
||||
<tr>
|
||||
<th><?= ucfirst($field['fieldName']) ?></th>
|
||||
<td>{{ <?= $helper->getEntityFieldPrintCode($entity_twig_var_singular, $field) ?> }}</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('<?= $route_name ?>_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('<?= $route_name ?>_edit', {'<?= $entity_identifier ?>': <?= $entity_twig_var_singular ?>.<?= $entity_identifier ?>}) }}">edit</a>
|
||||
|
||||
{{ include('<?= $templates_path ?>/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
123
vendor/symfony/maker-bundle/templates/crud/test/Test.EntityManager.tpl.php
vendored
Normal file
123
vendor/symfony/maker-bundle/templates/crud/test/Test.EntityManager.tpl.php
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
<?= "<?php\n" ?>
|
||||
<?php use Symfony\Bundle\MakerBundle\Str; ?>
|
||||
|
||||
namespace <?= $namespace ?>;
|
||||
|
||||
<?= $class_data->getUseStatements(); ?>
|
||||
|
||||
<?= $class_data->getClassDeclaration() ?>
|
||||
|
||||
{
|
||||
private KernelBrowser $client;
|
||||
private EntityManagerInterface $manager;
|
||||
private EntityRepository $<?= lcfirst($entity_var_singular); ?>Repository;
|
||||
private string $path = '<?= $route_path; ?>/';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->client = static::createClient();
|
||||
$this->manager = static::getContainer()->get('doctrine')->getManager();
|
||||
$this-><?= lcfirst($entity_var_singular); ?>Repository = $this->manager->getRepository(<?= $entity_class_name; ?>::class);
|
||||
|
||||
foreach ($this-><?= lcfirst($entity_var_singular); ?>Repository->findAll() as $object) {
|
||||
$this->manager->remove($object);
|
||||
}
|
||||
|
||||
$this->manager->flush();
|
||||
}
|
||||
|
||||
public function testIndex(): void
|
||||
{
|
||||
$this->client->followRedirects();
|
||||
$crawler = $this->client->request('GET', $this->path);
|
||||
|
||||
self::assertResponseStatusCodeSame(200);
|
||||
self::assertPageTitleContains('<?= ucfirst($entity_var_singular); ?> index');
|
||||
|
||||
// Use the $crawler to perform additional assertions e.g.
|
||||
// self::assertSame('Some text on the page', $crawler->filter('.p')->first()->text());
|
||||
}
|
||||
|
||||
public function testNew(): void
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$this->client->request('GET', sprintf('%snew', $this->path));
|
||||
|
||||
self::assertResponseStatusCodeSame(200);
|
||||
|
||||
$this->client->submitForm('Save', [
|
||||
<?php foreach ($form_fields as $form_field => $typeOptions): ?>
|
||||
'<?= $form_field_prefix; ?>[<?= $form_field; ?>]' => 'Testing',
|
||||
<?php endforeach; ?>
|
||||
]);
|
||||
|
||||
self::assertResponseRedirects($this->path);
|
||||
|
||||
self::assertSame(1, $this-><?= lcfirst($entity_var_singular); ?>Repository->count([]));
|
||||
}
|
||||
|
||||
public function testShow(): void
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$fixture = new <?= $entity_class_name; ?>();
|
||||
<?php foreach ($form_fields as $form_field => $typeOptions): ?>
|
||||
$fixture->set<?= ucfirst($form_field); ?>('My Title');
|
||||
<?php endforeach; ?>
|
||||
|
||||
$this->manager->persist($fixture);
|
||||
$this->manager->flush();
|
||||
|
||||
$this->client->request('GET', sprintf('%s%s', $this->path, $fixture->getId()));
|
||||
|
||||
self::assertResponseStatusCodeSame(200);
|
||||
self::assertPageTitleContains('<?= ucfirst($entity_var_singular); ?>');
|
||||
|
||||
// Use assertions to check that the properties are properly displayed.
|
||||
}
|
||||
|
||||
public function testEdit(): void
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$fixture = new <?= $entity_class_name; ?>();
|
||||
<?php foreach ($form_fields as $form_field => $typeOptions): ?>
|
||||
$fixture->set<?= ucfirst($form_field); ?>('Value');
|
||||
<?php endforeach; ?>
|
||||
|
||||
$this->manager->persist($fixture);
|
||||
$this->manager->flush();
|
||||
|
||||
$this->client->request('GET', sprintf('%s%s/edit', $this->path, $fixture->getId()));
|
||||
|
||||
$this->client->submitForm('Update', [
|
||||
<?php foreach ($form_fields as $form_field => $typeOptions): ?>
|
||||
'<?= $form_field_prefix; ?>[<?= $form_field; ?>]' => 'Something New',
|
||||
<?php endforeach; ?>
|
||||
]);
|
||||
|
||||
self::assertResponseRedirects('<?= $route_path; ?>/');
|
||||
|
||||
$fixture = $this-><?= lcfirst($entity_var_singular); ?>Repository->findAll();
|
||||
|
||||
<?php foreach ($form_fields as $form_field => $typeOptions): ?>
|
||||
self::assertSame('Something New', $fixture[0]->get<?= ucfirst($form_field); ?>());
|
||||
<?php endforeach; ?>
|
||||
}
|
||||
|
||||
public function testRemove(): void
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$fixture = new <?= $entity_class_name; ?>();
|
||||
<?php foreach ($form_fields as $form_field => $typeOptions): ?>
|
||||
$fixture->set<?= ucfirst($form_field); ?>('Value');
|
||||
<?php endforeach; ?>
|
||||
|
||||
$this->manager->persist($fixture);
|
||||
$this->manager->flush();
|
||||
|
||||
$this->client->request('GET', sprintf('%s%s', $this->path, $fixture->getId()));
|
||||
$this->client->submitForm('Delete');
|
||||
|
||||
self::assertResponseRedirects('<?= $route_path; ?>/');
|
||||
self::assertSame(0, $this-><?= lcfirst($entity_var_singular); ?>Repository->count([]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user