|
|
|
|
|
|
|
|
|
|
|
# Laclic SovBundle |
|
|
|
|
|
|
|
|
|
|
|
Administration basé sur EasyAdmin 3. Développé par <a href="https://www.laclic.fr">la Clic!</a> |
|
|
|
|
|
|
|
|
|
|
|
Require : |
|
|
|
|
|
|
|
|
|
|
|
- Symfony > 5.3 |
|
|
|
|
|
- EasyAdmin > 5.3 |
|
|
|
|
|
- FOS/Ckeditor-bundle: "^2.2", |
|
|
|
|
|
|
|
|
|
|
|
## Instalation en version développement sur un projet : |
|
|
|
|
|
|
|
|
|
|
|
Si tu démarres un nouveau projet il te suffit de cloner le projet : https://gitea.laclic.fr/Laclic/DefaultProjectSf5 |
|
|
|
|
|
|
|
|
|
|
|
- À la racine de ton projet créer un dossier Lc/AdminBundle/ |
|
|
|
|
|
- Dans le dossier Lc/AdminBundle : |
|
|
|
|
|
``` |
|
|
|
|
|
git clone https://gitea.laclic.fr/Laclic/AdminBundle.git . |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
- Initialisation : |
|
|
|
|
|
- Création des entités de base, créer une entité User.php et File.php, ajouter dans la configuration de doctrine les lignes suivantes |
|
|
|
|
|
``` |
|
|
|
|
|
doctrine: |
|
|
|
|
|
orm: |
|
|
|
|
|
resolve_target_entities: |
|
|
|
|
|
Lc\SovBundle\IModel\User\UserInterface: App\Entity\User |
|
|
|
|
|
Lc\SovBundle\Doctrine\Extension\FileInterface: App\Entity\File |
|
|
|
|
|
#... |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
- Instalation ckeditor |
|
|
|
|
|
`php bin/console ckeditor:install` |
|
|
|
|
|
`php bin/console assets:install public |
|
|
|
|
|
- Créer la config fos_ckeditor.yaml |
|
|
|
|
|
``` |
|
|
|
|
|
fos_ck_editor: |
|
|
|
|
|
input_sync: true |
|
|
|
|
|
default_config: base_config |
|
|
|
|
|
configs: |
|
|
|
|
|
base_config: |
|
|
|
|
|
filebrowserBrowseRoute: file_manager |
|
|
|
|
|
filebrowserBrowseRouteParameters: |
|
|
|
|
|
conf: default |
|
|
|
|
|
module: ckeditor |
|
|
|
|
|
format_tags: 'p;h2;h3' |
|
|
|
|
|
toolbar: |
|
|
|
|
|
- { name: "styles", items: ['Bold', 'Italic','Underline', 'Strike']} |
|
|
|
|
|
- { name: "paragraph", items: ['Format', 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote'] } |
|
|
|
|
|
- { name: "link", items: [ 'Link', 'Unlink'] } |
|
|
|
|
|
- {name: 'insert', items: [ 'Image' ]} |
|
|
|
|
|
- {name: 'document', items: [ 'Source' ]} |
|
|
|
|
|
simple_config: |
|
|
|
|
|
toolbar: |
|
|
|
|
|
- { items: ['Bold', 'Italic', 'Underline', 'Colors', 'Source'] } |
|
|
|
|
|
twig: |
|
|
|
|
|
form_themes: |
|
|
|
|
|
- '@FOSCKEditor/Form/ckeditor_widget.html.twig' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
``` |
|
|
|
|
|
- Créer la config artgris_file_manager.yaml |
|
|
|
|
|
``` |
|
|
|
|
|
artgris_file_manager: |
|
|
|
|
|
conf: |
|
|
|
|
|
default: |
|
|
|
|
|
dir: "../public/uploads" |
|
|
|
|
|
type: 'image' |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- Enjoy ! |
|
|
|
|
|
|
|
|
|
|
|
### Pour les projet Aquarium, Laclic, Le plat pentu (et peut être d'autres) suit cette préocédure : |
|
|
|
|
|
|
|
|
|
|
|
- Compare ton .gitignore avec le gitignore de DefaultProjectSf5 et ajoute les lignes manquantes |
|
|
|
|
|
|
|
|
|
|
|
- Modifier composer.json dans “autoload” ajouter : |
|
|
|
|
|
```` |
|
|
|
|
|
"autoload": { |
|
|
|
|
|
"psr-4": { |
|
|
|
|
|
"App\\": "src/", |
|
|
|
|
|
"Lc\\": "Lc/" |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
```` |
|
|
|
|
|
- Dans le dossier `config` de ton projet : |
|
|
|
|
|
- Modifier `bundles.php` et ajouter : |
|
|
|
|
|
```` |
|
|
|
|
|
Lc\SovBundle\SovBundle::class => ['all' => true], |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `services.yaml` et ajouter : |
|
|
|
|
|
```` |
|
|
|
|
|
Lc\SovBundle\: |
|
|
|
|
|
resource: '../Lc/AdminBundle/' |
|
|
|
|
|
exclude: |
|
|
|
|
|
- '../Lc/AdminBundle/DependencyInjection/' |
|
|
|
|
|
- '../Lc/AdminBundle/Entity/' |
|
|
|
|
|
- '../Lc/AdminBundle/Kernel.php' |
|
|
|
|
|
- '../Lc/AdminBundle/Tests/' |
|
|
|
|
|
```` |
|
|
|
|
|
et |
|
|
|
|
|
```` |
|
|
|
|
|
Lc\SovBundle\Controller\: |
|
|
|
|
|
resource: '../Lc/AdminBundle/Controller/' |
|
|
|
|
|
tags: ['controller.service_arguments'] |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `packages/security.yml` |
|
|
|
|
|
```` |
|
|
|
|
|
guard: |
|
|
|
|
|
authenticators: |
|
|
|
|
|
- Lc\SovBundle\Authenticator\LoginFormAuthenticator |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `packages/doctrine.yaml` |
|
|
|
|
|
```` |
|
|
|
|
|
resolve_target_entities: |
|
|
|
|
|
Lc\SovBundle\IModel\User\UserInterface: App\Entity\User |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `routes.yaml` |
|
|
|
|
|
```` |
|
|
|
|
|
login: |
|
|
|
|
|
path: /login |
|
|
|
|
|
controller: Lc\SovBundle\Controller\Admin\SecurityController::login |
|
|
|
|
|
logout: |
|
|
|
|
|
path: /logout |
|
|
|
|
|
controller: Lc\SovBundle\Admin\SecurityController::logout |
|
|
|
|
|
```` |
|
|
|
|
|
|
|
|
|
|
|
- Dans le dossier `src/` de ton projet : |
|
|
|
|
|
- Supprimer `Controller/Admin/SecurityController.php`. |
|
|
|
|
|
- Supprimer `Controller/Admin/AbstractCrudController.php`. |
|
|
|
|
|
- Modifier l'en tête de `Controller/Admin/DashboardController.php`. |
|
|
|
|
|
```` |
|
|
|
|
|
use Lc\SovBundle\Controller\Admin\DashboardController as LcDashboardController; |
|
|
|
|
|
|
|
|
|
|
|
class DashboardController extends LcDashboardController |
|
|
|
|
|
{ |
|
|
|
|
|
// ... le code spécifique |
|
|
|
|
|
} |
|
|
|
|
|
```` |
|
|
|
|
|
|
|
|
|
|
|
- Modifier l'en tête des controllers. Exemple `Controller/Admin/PageCrudController.php`. |
|
|
|
|
|
```` |
|
|
|
|
|
use Lc\SovBundle\Controller\AbstractAdminController as AbstractCrudController; |
|
|
|
|
|
|
|
|
|
|
|
class PageCrudController extends AbstractCrudController |
|
|
|
|
|
{ |
|
|
|
|
|
// ... le code spécifique |
|
|
|
|
|
} |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `Entity/User.php`. |
|
|
|
|
|
```` |
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
namespace App\Entity; |
|
|
|
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
|
use Lc\SovBundle\Model\User\UserInterface; |
|
|
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
|
|
|
|
|
use Lc\SovBundle\Model\User\User as LcUserModel; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @ORM\Entity(repositoryClass="Lc\SovBundle\Repository\User\UserRepository") |
|
|
|
|
|
* @UniqueEntity(fields={"email"}, message="There is already an account with this email") |
|
|
|
|
|
*/ |
|
|
|
|
|
class User extends LcUserModel implements UserInterface |
|
|
|
|
|
{ |
|
|
|
|
|
/** |
|
|
|
|
|
* @ORM\Id |
|
|
|
|
|
* @ORM\GeneratedValue |
|
|
|
|
|
* @ORM\Column(type="integer") |
|
|
|
|
|
*/ |
|
|
|
|
|
private $id; |
|
|
|
|
|
|
|
|
|
|
|
public function getId(): ?int |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->id; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier les entités pour que les Use pointe dans AdminBundle exemple avec `Entity/Page.php`. |
|
|
|
|
|
```` |
|
|
|
|
|
use Lc\SovBundle\Doctrine\Extension\ImageInterface; |
|
|
|
|
|
use Lc\SovBundle\Model\Cms\AbstractDocument; |
|
|
|
|
|
use Lc\SovBundle\Model\Cms\ImageTrait; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @ORM\Entity(repositoryClass=PageRepository::class) |
|
|
|
|
|
*/ |
|
|
|
|
|
class Page extends AbstractDocument implements ImageInterface |
|
|
|
|
|
{ |
|
|
|
|
|
use ImageTrait; |
|
|
|
|
|
|
|
|
|
|
|
// ... le code spécifique |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
```` |
|
|
|
|
|
|
|
|
|
|
|
- Modifier les repository pour qu'il fonctionne avec AdminBundle exemple avec `Repository/PageRepository.php.php`. |
|
|
|
|
|
```` |
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
namespace App\Repository; |
|
|
|
|
|
|
|
|
|
|
|
use App\Entity\Page; |
|
|
|
|
|
use Lc\SovBundle\Repository\RepositoryAbstract; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @method Page|null find($id, $lockMode = null, $lockVersion = null) |
|
|
|
|
|
* @method Page|null findOneBy(array $criteria, array $orderBy = null) |
|
|
|
|
|
* @method Page[] findAll() |
|
|
|
|
|
* @method Page[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
|
|
|
|
*/ |
|
|
|
|
|
class PageRepository extends RepositoryAbstract |
|
|
|
|
|
{ |
|
|
|
|
|
public function getInterfaceClass() |
|
|
|
|
|
{ |
|
|
|
|
|
return Page::class; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ... le code spécifique |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
```` |
|
|
|
|
|
- Supprimer `Repository/UserRepository.php.php`. |
|
|
|
|
|
Sauf si il contient des fonctions autres que `__contruct()` et `upgradePassword-()` |
|
|
|
|
|
Si c'est le cas le réécrire en faisant un extends de UserRepository dans AdminBundle |
|
|
|
|
|
|
|
|
|
|
|
- Faire un `composer install` |
|
|
|
|
|
- Tester l'application connectes toi à l'admin, édites un doc ou deux |
|
|
|
|
|
- Si tout est ok tu peux supprimer les dossiers : |
|
|
|
|
|
```` |
|
|
|
|
|
src/IModel/ |
|
|
|
|
|
src/Model/ |
|
|
|
|
|
src/Security/ |
|
|
|
|
|
src/Command/ |
|
|
|
|
|
|
|
|
|
|
|
|