|
|
|
|
|
|
|
|
#Laclic LcAdminBundle |
|
|
|
|
|
|
|
|
# Laclic LcAdminBundle |
|
|
|
|
|
|
|
|
Administration basé sur EasyAdmin 3. Développé par <a href="https://www.laclic.fr">la Clic!</a> |
|
|
|
|
|
|
|
|
Administration basé sur EasyAdmin 3. Développé par <a href="https://www.laclic.fr">la Clic!</a> |
|
|
|
|
|
|
|
|
Require : |
|
|
Require : |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- EasyAdmin > 5.3 |
|
|
- EasyAdmin > 5.3 |
|
|
- FOS/Ckeditor-bundle: "^2.2", |
|
|
- 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 . |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 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\AdminBundle\LcAdminBundle::class => ['all' => true], |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `services.yaml` et ajouter : |
|
|
|
|
|
```` |
|
|
|
|
|
Lc\AdminBundle\: |
|
|
|
|
|
resource: '../Lc/AdminBundle/' |
|
|
|
|
|
exclude: |
|
|
|
|
|
- '../Lc/AdminBundle/DependencyInjection/' |
|
|
|
|
|
- '../Lc/AdminBundle/Entity/' |
|
|
|
|
|
- '../Lc/AdminBundle/Kernel.php' |
|
|
|
|
|
- '../Lc/AdminBundle/Tests/' |
|
|
|
|
|
```` |
|
|
|
|
|
et |
|
|
|
|
|
```` |
|
|
|
|
|
Lc\AdminBundle\Controller\: |
|
|
|
|
|
resource: '../Lc/AdminBundle/Controller/' |
|
|
|
|
|
tags: ['controller.service_arguments'] |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `packages/security.yml` |
|
|
|
|
|
```` |
|
|
|
|
|
guard: |
|
|
|
|
|
authenticators: |
|
|
|
|
|
- Lc\AdminBundle\Authenticator\LoginFormAuthenticator |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `packages/doctrine.yaml` |
|
|
|
|
|
```` |
|
|
|
|
|
resolve_target_entities: |
|
|
|
|
|
Lc\AdminBundle\IModel\User\UserInterface: App\Entity\User |
|
|
|
|
|
```` |
|
|
|
|
|
- Modifier `routes.yaml` |
|
|
|
|
|
```` |
|
|
|
|
|
login: |
|
|
|
|
|
path: /login |
|
|
|
|
|
controller: Lc\AdminBundle\Controller\Admin\SecurityController::login |
|
|
|
|
|
logout: |
|
|
|
|
|
path: /logout |
|
|
|
|
|
controller: Lc\AdminBundle\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\AdminBundle\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\AdminBundle\Controller\Admin\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\AdminBundle\IModel\User\UserInterface; |
|
|
|
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; |
|
|
|
|
|
use Lc\AdminBundle\Model\User\User as LcUserModel; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @ORM\Entity(repositoryClass="Lc\AdminBundle\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\AdminBundle\IModel\Cms\ImageInterface; |
|
|
|
|
|
use Lc\AdminBundle\Model\Cms\AbstractDocument; |
|
|
|
|
|
use Lc\AdminBundle\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\AdminBundle\Repository\BaseRepository; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @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 BaseRepository |
|
|
|
|
|
{ |
|
|
|
|
|
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/ |
|
|
|
|
|
|
|
|
|
|
|
|