mirror of
https://github.com/symfony/recipes.git
synced 2026-09-11 15:16:30 +03:00
Add a recipe for API Platform Admin
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { HydraAdmin } from '@api-platform/admin';
|
||||
|
||||
const entrypoint = document.getElementById('api-entrypoint').innerText;
|
||||
|
||||
ReactDOM.render(<HydraAdmin entrypoint={entrypoint}/>, document.getElementById('api-platform-admin'));
|
||||
@@ -0,0 +1,5 @@
|
||||
admin:
|
||||
path: /admin
|
||||
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
|
||||
defaults:
|
||||
template: admin.html.twig
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"copy-from-recipe": {
|
||||
"assets/": "assets/",
|
||||
"config/": "%CONFIG_DIR%/",
|
||||
"templates/": "templates/"
|
||||
},
|
||||
"aliases": ["api-admin", "api-platform-admin", "react-admin"]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<bg=blue;fg=white> </>
|
||||
<bg=blue;fg=white> To finish the install </>
|
||||
<bg=blue;fg=white> </>
|
||||
|
||||
* Your admin is almost ready:
|
||||
1. Install the JavaScript dependencies by running <comment>yarn add @api-platform/admin</comment>
|
||||
2. Go in <comment>webpack.config.js</comment> and <info>uncomment</info> the following lines:
|
||||
|
||||
Encore
|
||||
// ...
|
||||
.enableReactPreset()
|
||||
.addEntry('admin', './assets/js/admin.js')
|
||||
|
||||
* Mark any entity with the <comment>@ApiResource</comment> annotation, it appears in the admin!
|
||||
|
||||
* Using MakerBundle? Try <info>php bin/console make:entity --api-resource</info>
|
||||
@@ -0,0 +1,10 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}API Platform Admin{% endblock %}
|
||||
|
||||
{% block body %}<div id="api-platform-admin"></div>{% endblock %}
|
||||
|
||||
{% block javascripts %}
|
||||
<script type="text/plain" id="api-entrypoint">{{ path('api_entrypoint') }}</script>
|
||||
{{ encore_entry_script_tags('admin') }}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user