Skip to content

Commit 6c6ac5b

Browse files
author
symfony-flex-server[bot]
authored
Merge pull request #503
2 parents 7e853d9 + 98798d9 commit 6c6ac5b

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import { HydraAdmin } from '@api-platform/admin';
4+
5+
const entrypoint = document.getElementById('api-entrypoint').innerText;
6+
7+
ReactDOM.render(<HydraAdmin entrypoint={entrypoint}/>, document.getElementById('api-platform-admin'));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
admin:
2+
path: /admin
3+
controller: Symfony\Bundle\FrameworkBundle\Controller\TemplateController
4+
defaults:
5+
template: admin.html.twig
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"copy-from-recipe": {
3+
"assets/": "assets/",
4+
"config/": "%CONFIG_DIR%/",
5+
"templates/": "templates/"
6+
},
7+
"aliases": ["api-admin", "api-platform-admin", "react-admin"]
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<bg=blue;fg=white> </>
2+
<bg=blue;fg=white> To finish the install </>
3+
<bg=blue;fg=white> </>
4+
5+
* Your admin is almost ready:
6+
1. Install the JavaScript dependencies by running <comment>yarn add @api-platform/admin @babel/preset-react</comment>
7+
2. Edit <comment>webpack.config.js</comment> and <info>uncomment</info> the following lines:
8+
9+
Encore
10+
// ...
11+
.enableReactPreset()
12+
.addEntry('admin', './assets/js/admin.js')
13+
14+
* Mark entities you want in the admin with the <comment>@ApiResource</comment> annotation, it appears in the admin!
15+
16+
* Using MakerBundle? Try <info>php bin/console make:entity --api-resource</info>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{% extends 'base.html.twig' %}
2+
3+
{% block title %}API Platform Admin{% endblock %}
4+
5+
{% block body %}<div id="api-platform-admin"></div>{% endblock %}
6+
7+
{% block javascripts %}
8+
<script type="text/plain" id="api-entrypoint">{{ path('api_entrypoint') }}</script>
9+
{{ encore_entry_script_tags('admin') }}
10+
{% endblock %}

symfony/webpack-encore-bundle/1.0/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ Encore
4646

4747
// uncomment if you're having problems with a jQuery plugin
4848
//.autoProvidejQuery()
49+
50+
// uncomment if you use API Platform Admin (composer req api-admin)
51+
//.enableReactPreset()
52+
//.addEntry('admin', './assets/js/admin.js')
4953
;
5054

5155
module.exports = Encore.getWebpackConfig();

0 commit comments

Comments
 (0)