-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SonataIntegrationBundle] Integrate entity-migrator
- Loading branch information
Showing
12 changed files
with
204 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Sonata\Admin; | ||
|
||
use App\Entity\UserMigration; | ||
use Draw\Bundle\SonataIntegrationBundle\EntityMigrator\Admin\BaseEntityMigrationAdmin; | ||
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; | ||
|
||
#[AutoconfigureTag( | ||
name: 'sonata.admin', | ||
attributes: [ | ||
...BaseEntityMigrationAdmin::ADMIN, | ||
'model_class' => UserMigration::class, | ||
'label' => 'User Migration', | ||
] | ||
)] | ||
class UserMigrationAdmin extends BaseEntityMigrationAdmin | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/sonata-integration-bundle/EntityMigrator/Admin/BaseEntityMigrationAdmin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Draw\Bundle\SonataIntegrationBundle\EntityMigrator\Admin; | ||
|
||
use Sonata\AdminBundle\Admin\AbstractAdmin; | ||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
use Sonata\AdminBundle\Route\RouteCollectionInterface; | ||
use Sonata\AdminBundle\Show\ShowMapper; | ||
|
||
abstract class BaseEntityMigrationAdmin extends AbstractAdmin | ||
{ | ||
public const ADMIN = [ | ||
'manager_type' => 'orm', | ||
'pager_type' => 'simple', | ||
'group' => 'Entity Migrator', | ||
'icon' => 'fas fa-cogs', | ||
]; | ||
|
||
protected function configureListFields(ListMapper $list): void | ||
{ | ||
$list | ||
->addIdentifier('id') | ||
->add('entity') | ||
->add('migration') | ||
->add('state'); | ||
} | ||
|
||
protected function configureShowFields(ShowMapper $show): void | ||
{ | ||
$show | ||
->add('id') | ||
->add('entity') | ||
->add('migration') | ||
->add('state') | ||
->add( | ||
'transitionLogs', | ||
fieldDescriptionOptions: [ | ||
'template' => '@DrawSonataIntegration/EntityMigrator/BaseEntityMigration/show_transition_logs.html.twig', | ||
] | ||
) | ||
->add('createdAt'); | ||
} | ||
|
||
protected function configureRoutes(RouteCollectionInterface $collection): void | ||
{ | ||
$collection | ||
->remove('edit'); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
packages/sonata-integration-bundle/EntityMigrator/Admin/MigrationAdmin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Draw\Bundle\SonataIntegrationBundle\EntityMigrator\Admin; | ||
|
||
use Sonata\AdminBundle\Admin\AbstractAdmin; | ||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
use Sonata\AdminBundle\Route\RouteCollectionInterface; | ||
use Sonata\AdminBundle\Show\ShowMapper; | ||
|
||
class MigrationAdmin extends AbstractAdmin | ||
{ | ||
protected function configureListFields(ListMapper $list): void | ||
{ | ||
$list | ||
->addIdentifier('id') | ||
->add('name') | ||
->add('state'); | ||
} | ||
|
||
protected function configureShowFields(ShowMapper $show): void | ||
{ | ||
$show | ||
->add('id') | ||
->add('name') | ||
->add('state'); | ||
} | ||
|
||
protected function configureRoutes(RouteCollectionInterface $collection): void | ||
{ | ||
$collection | ||
->remove('edit') | ||
->remove('create') | ||
->remove('delete'); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...-bundle/Resources/views/EntityMigrator/BaseEntityMigration/show_transition_logs.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends '@SonataAdmin/CRUD/base_show_field.html.twig' %} | ||
|
||
{% block field %} | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Created By</th> | ||
<th>From</th> | ||
<th>Transition</th> | ||
<th>To</th> | ||
<th>Created At</th> | ||
<th>Delay</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for entry in value %} | ||
<tr> | ||
<td>{{ entry['createdBy'] }}</td> | ||
<td>{{ entry['from'] }}</td> | ||
<td>{{ entry['transition'] }}</td> | ||
<td>{{ entry['to'] }}</td> | ||
<td>{{ entry['createdAt']|date }}</td> | ||
<td> | ||
{% if previousCreatedAt is defined %} | ||
{{ entry['createdAt']|date('U') - previousCreatedAt|date('U') }} seconds | ||
{% endif %} | ||
</td> | ||
</tr> | ||
{% set previousCreatedAt = entry['createdAt'] %} | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters