浏览代码

Instalation de LcAdminBundle

develop
Fab 3 年前
父节点
当前提交
54fc1494a0
共有 43 个文件被更改,包括 820 次插入1952 次删除
  1. +9
    -0
      .gitignore
  2. +1
    -0
      .idea/laclic.iml
  3. +49
    -32
      .idea/workspace.xml
  4. +2
    -1
      composer.json
  5. +664
    -643
      composer.lock
  6. +15
    -14
      config/bundles.php
  7. +1
    -1
      config/packages/doctrine.yaml
  8. +1
    -1
      config/packages/security.yaml
  9. +2
    -2
      config/routes.yaml
  10. +10
    -0
      config/services.yaml
  11. +0
    -31
      migrations/Version20201222170752.php
  12. +0
    -31
      migrations/Version20201222184037.php
  13. +0
    -33
      migrations/Version20201222234607.php
  14. +0
    -31
      migrations/Version20201224104808.php
  15. +37
    -0
      migrations/Version20210321140455.php
  16. +0
    -138
      src/Command/CreateUserCommand.php
  17. +0
    -22
      src/Controller/Admin/AbstractCrudController.php
  18. +3
    -52
      src/Controller/Admin/DashboardController.php
  19. +1
    -2
      src/Controller/Admin/PageCrudController.php
  20. +0
    -71
      src/Controller/Admin/SecurityController.php
  21. +4
    -4
      src/Entity/Page.php
  22. +15
    -154
      src/Entity/User.php
  23. +0
    -9
      src/IModel/BlameableInterface.php
  24. +0
    -11
      src/IModel/ImageInterface.php
  25. +0
    -10
      src/IModel/SeoInterface.php
  26. +0
    -8
      src/IModel/SluggableInterface.php
  27. +0
    -8
      src/IModel/SortableInterface.php
  28. +0
    -8
      src/IModel/StatusInterface.php
  29. +0
    -9
      src/IModel/TimestampableInterface.php
  30. +0
    -22
      src/IModel/TreeInterface.php
  31. +0
    -8
      src/IModel/UserInterface.php
  32. +0
    -78
      src/Model/AbstractDocumentEntity.php
  33. +0
    -51
      src/Model/BlameableTrait.php
  34. +0
    -52
      src/Model/ImageTrait.php
  35. +0
    -63
      src/Model/SeoTrait.php
  36. +0
    -27
      src/Model/SluggableTrait.php
  37. +0
    -34
      src/Model/SortableTrait.php
  38. +0
    -25
      src/Model/StatusTrait.php
  39. +0
    -46
      src/Model/TimestampableTrait.php
  40. +0
    -11
      src/Model/TreeTrait.php
  41. +6
    -35
      src/Repository/PageRepository.php
  42. +0
    -67
      src/Repository/UserRepository.php
  43. +0
    -107
      src/Security/LoginFormAuthenticator.php

+ 9
- 0
.gitignore 查看文件

@@ -1,10 +1,16 @@

###> symfony/framework-bundle ###
/.php-version
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/public/uploads/
/public/userfiles/*
/public/robots.txt
/public/assets/.sass-cache/
/public/media/cache/
/var/
/vendor/
###< symfony/framework-bundle ###
@@ -14,3 +20,6 @@
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

/Lc/*
/.idea/*

+ 1
- 0
.idea/laclic.iml 查看文件

@@ -5,6 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="App\" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="App\Tests\" />
<sourceFolder url="file://$MODULE_DIR$/Lc" isTestSource="false" packagePrefix="Lc\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/service-contracts" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/serializer" />

+ 49
- 32
.idea/workspace.xml 查看文件

@@ -2,36 +2,48 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="6c084521-9606-4ed0-8fb0-1d6c8abbf313" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/public/assets/img/laclic.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/readme.md" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Command/CreateUserCommand.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Controller/Admin/AbstractCrudController.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/BlameableInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/ImageInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/SeoInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/SluggableInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/SortableInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/StatusInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/TimestampableInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/TreeInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/IModel/UserInterface.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/AbstractDocumentEntity.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/BlameableTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/ImageTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/SeoTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/SluggableTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/SortableTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/StatusTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/TimestampableTrait.php" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Model/TreeTrait.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.env" beforeDir="false" afterPath="$PROJECT_DIR$/.env" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/laclic.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/laclic.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/composer.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/bundles.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/bundles.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/packages/doctrine.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config/packages/doctrine.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/packages/security.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config/packages/security.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/routes.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config/routes.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/symfony.lock" beforeDir="false" afterPath="$PROJECT_DIR$/symfony.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/services.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/config/services.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/migrations/Version20201222170752.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/migrations/Version20201222184037.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/migrations/Version20201222234607.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/migrations/Version20201224104808.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Command/CreateUserCommand.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/Admin/AbstractCrudController.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/Admin/DashboardController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/Admin/DashboardController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/Admin/PageCrudController.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Controller/Admin/PageCrudController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Controller/Admin/SecurityController.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/Page.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/Page.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Entity/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Entity/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/BlameableInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/ImageInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/SeoInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/SluggableInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/SortableInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/StatusInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/TimestampableInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/TreeInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/IModel/UserInterface.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/AbstractDocumentEntity.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/BlameableTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/ImageTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/SeoTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/SluggableTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/SortableTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/StatusTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/TimestampableTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Model/TreeTrait.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/PageRepository.php" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/PageRepository.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/UserRepository.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Security/LoginFormAuthenticator.php" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -172,7 +184,7 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/config/packages" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/Lc/AdminBundle/Repository" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="nodejs_package_manager_path" value="npm" />
@@ -180,15 +192,18 @@
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/config/packages" />
<recent name="$PROJECT_DIR$/src/Controller/Admin" />
<recent name="$PROJECT_DIR$/src/Entity" />
<recent name="$PROJECT_DIR$/src/IModel" />
<recent name="$PROJECT_DIR$/src/Model" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle/Repository" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle/Event" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle/IModel" />
<recent name="$PROJECT_DIR$" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src" />
<recent name="$PROJECT_DIR$/src/Controller/Admin" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle/Repository/User" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle/Model/Cms" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle/IModel/User" />
<recent name="$PROJECT_DIR$/Lc/AdminBundle/IModel/Cms" />
</key>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
@@ -205,6 +220,8 @@
<workItem from="1608803957962" duration="6833000" />
<workItem from="1610017072502" duration="1791000" />
<workItem from="1610099290999" duration="602000" />
<workItem from="1614182219217" duration="1832000" />
<workItem from="1616330933788" duration="12871000" />
</task>
<servers />
</component>

+ 2
- 1
composer.json 查看文件

@@ -63,7 +63,8 @@
},
"autoload": {
"psr-4": {
"App\\": "src/"
"App\\": "src/",
"Lc\\": "Lc/"
}
},
"autoload-dev": {

+ 664
- 643
composer.lock
文件差异内容过多而无法显示
查看文件


+ 15
- 14
config/bundles.php 查看文件

@@ -1,18 +1,19 @@
<?php

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
Lc\AdminBundle\LcAdminBundle::class => ['all' => true],
];

+ 1
- 1
config/packages/doctrine.yaml 查看文件

@@ -17,4 +17,4 @@ doctrine:
prefix: 'App\Entity'
alias: App
resolve_target_entities:
App\IModel\UserInterface: App\Entity\User
Lc\AdminBundle\IModel\User\UserInterface: App\Entity\User

+ 1
- 1
config/packages/security.yaml 查看文件

@@ -20,7 +20,7 @@ security:
provider: app_user_provider
guard:
authenticators:
- App\Security\LoginFormAuthenticator
- Lc\AdminBundle\Authenticator\LoginFormAuthenticator
logout:
path: logout
# where to redirect after logout

+ 2
- 2
config/routes.yaml 查看文件

@@ -7,7 +7,7 @@ lc_admin_dashboard:
controller: App\Controller\Admin\DashboardController::index
login:
path: /login
controller: App\Controller\Admin\SecurityController::login
controller: Lc\AdminBundle\Controller\Admin\SecurityController::login
logout:
path: /logout
controller: App\Controller\Admin\SecurityController::logout
controller: Lc\AdminBundle\Admin\SecurityController::logout

+ 10
- 0
config/services.yaml 查看文件

@@ -20,6 +20,13 @@ services:
- '../src/Entity/'
- '../src/Kernel.php'
- '../src/Tests/'
Lc\AdminBundle\:
resource: '../Lc/AdminBundle/'
exclude:
- '../Lc/AdminBundle/DependencyInjection/'
- '../Lc/AdminBundle/Entity/'
- '../Lc/AdminBundle/Kernel.php'
- '../Lc/AdminBundle/Tests/'

# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
@@ -27,5 +34,8 @@ services:
resource: '../src/Controller/'
tags: ['controller.service_arguments']

Lc\AdminBundle\Controller\:
resource: '../Lc/AdminBundle/Controller/'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones

+ 0
- 31
migrations/Version20201222170752.php 查看文件

@@ -1,31 +0,0 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201222170752 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, lastname VARCHAR(255) DEFAULT NULL, firstname VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE user');
}
}

+ 0
- 31
migrations/Version20201222184037.php 查看文件

@@ -1,31 +0,0 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201222184037 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user ADD is_verified TINYINT(1) NOT NULL');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user DROP is_verified');
}
}

+ 0
- 33
migrations/Version20201222234607.php 查看文件

@@ -1,33 +0,0 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201222234607 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE page (id INT AUTO_INCREMENT NOT NULL, created_by_id INT NOT NULL, updated_by_id INT NOT NULL, title VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, dev_alias VARCHAR(255) DEFAULT NULL, meta_title VARCHAR(255) DEFAULT NULL, meta_description LONGTEXT DEFAULT NULL, old_urls LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', slug VARCHAR(255) NOT NULL, position DOUBLE PRECISION NOT NULL, status DOUBLE PRECISION NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_140AB620B03A8386 (created_by_id), INDEX IDX_140AB620896DBBDE (updated_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE page ADD CONSTRAINT FK_140AB620B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE page ADD CONSTRAINT FK_140AB620896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE page');
}
}

+ 0
- 31
migrations/Version20201224104808.php 查看文件

@@ -1,31 +0,0 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201224104808 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE page ADD image VARCHAR(255) DEFAULT NULL');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE page DROP image');
}
}

+ 37
- 0
migrations/Version20210321140455.php 查看文件

@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210321140455 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE page (id INT AUTO_INCREMENT NOT NULL, created_by_id INT NOT NULL, updated_by_id INT NOT NULL, title VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, meta_title VARCHAR(255) DEFAULT NULL, meta_description LONGTEXT DEFAULT NULL, old_urls LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\', slug VARCHAR(255) NOT NULL, position DOUBLE PRECISION NOT NULL, status DOUBLE PRECISION NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, dev_alias VARCHAR(255) DEFAULT NULL, image VARCHAR(255) DEFAULT NULL, INDEX IDX_140AB620B03A8386 (created_by_id), INDEX IDX_140AB620896DBBDE (updated_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, lastname VARCHAR(255) DEFAULT NULL, firstname VARCHAR(255) DEFAULT NULL, is_verified TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE page ADD CONSTRAINT FK_140AB620B03A8386 FOREIGN KEY (created_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE page ADD CONSTRAINT FK_140AB620896DBBDE FOREIGN KEY (updated_by_id) REFERENCES user (id)');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE page DROP FOREIGN KEY FK_140AB620B03A8386');
$this->addSql('ALTER TABLE page DROP FOREIGN KEY FK_140AB620896DBBDE');
$this->addSql('DROP TABLE page');
$this->addSql('DROP TABLE user');
}
}

+ 0
- 138
src/Command/CreateUserCommand.php 查看文件

@@ -1,138 +0,0 @@
<?php

namespace App\Command;

// Adapter App\Entity\User selon la classe réelle de votre utilisateur
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;

class CreateUserCommand extends Command
{
private $passwordEncoder;
private $entityManager;

public function __construct(UserPasswordEncoderInterface $passwordEncoder, EntityManagerInterface $entityManager)
{
parent::__construct();

$this->passwordEncoder = $passwordEncoder;
$this->entityManager = $entityManager;
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('user:create')
->setDescription('Create a user.')
->setDefinition(array(
new InputArgument('email', InputArgument::REQUIRED, 'The email'),
new InputArgument('password', InputArgument::REQUIRED, 'The password'),
new InputArgument('role', InputArgument::REQUIRED, 'ROLE'),
))
->setHelp(<<<'EOT'
The <info>user:create</info> command creates a user:

<info>php %command.full_name% romaric@netinfluence.ch</info>

This interactive shell will ask you for a password.

You can create a super admin via the super-admin flag:

<info>php %command.full_name% admin --super-admin</info>
EOT
);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$email = $input->getArgument('email');
$password = $input->getArgument('password');
$role = $input->getArgument('role');

$user = (new User())
->setEmail($email)
->setRoles(array($role))
;

$password = $this->passwordEncoder->encodePassword($user, $password);

$user->setPassword($password);

$this->entityManager->persist($user);
$this->entityManager->flush();

$output->writeln(sprintf('Created user <comment>%s</comment>', $email));
return Command::SUCCESS;
}

/**
* {@inheritdoc}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$questions = array();

if (!$input->getArgument('email')) {
$question = new Question('Email : ');
$question->setValidator(function ($password) {
if (empty($password)) {
throw new \Exception('Email can not be empty');
}

return $password;
});
$questions['email'] = $question;
}

if (!$input->getArgument('password')) {
$question = new Question('Password : ');
$question->setValidator(function ($password) {
if (empty($password)) {
throw new \Exception('Password can not be empty');
}

return $password;
});
$question->setHidden(true);
$questions['password'] = $question;
}

if (!$input->getArgument('role')) {
$question = new Question('Rôle [admin/superadmin/user] : ');
$question->setValidator(function ($role) {
if ($role == 'admin') {
$role = 'ROLE_ADMIN';
}else if ($role == 'superadmin') {
$role = 'ROLE_SUPER_ADMIN';
}else if ($role == 'user') {
$role = 'ROLE_USER';
}else{
throw new \Exception('Choose a role');

}
return $role;
});
$questions['role'] = $question;
}



foreach ($questions as $name => $question) {
$answer = $this->getHelper('question')->ask($input, $output, $question);
$input->setArgument($name, $answer);
}
}
}

+ 0
- 22
src/Controller/Admin/AbstractCrudController.php 查看文件

@@ -1,22 +0,0 @@
<?php

namespace App\Controller\Admin;

use App\Entity\Page;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController as ModelAbstractCrudController;

abstract class AbstractCrudController extends ModelAbstractCrudController
{

/*
public function configureFields(string $pageName): iterable
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
}
*/
}

+ 3
- 52
src/Controller/Admin/DashboardController.php 查看文件

@@ -2,59 +2,10 @@

namespace App\Controller\Admin;

use App\Entity\Page;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractDashboardController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DashboardController extends AbstractDashboardController
{

public function index(): Response
{
return parent::index();
}

public function configureDashboard(): Dashboard
{
return Dashboard::new()
// the name visible to end users
->setTitle('LA CLIC !')
// you can include HTML contents too (e.g. to link to an image)
->setTitle('<img src="assets/img/laclic.png" width="100px">')
// the path defined in this method is passed to the Twig asset() function
->setFaviconPath('favicon.svg')
// the domain used by default is 'messages'
->setTranslationDomain('lcadmin');
}

public function configureCrud(): Crud
{
$crud = Crud::new();
return $crud
->addFormTheme('@FOSCKEditor/Form/ckeditor_widget.html.twig');
}
use Lc\AdminBundle\Controller\Admin\DashboardController as LcDashboardController;

public function configureMenuItems(): iterable
{
return [
MenuItem::linkToDashboard('Tableau de bord', 'fa fa-home'),
MenuItem::linkToCrud('Pages', 'fa fa-tags', Page::class),


/*
MenuItem::section('Blog'),
MenuItem::linkToCrud('Categories', 'fa fa-tags', Category::class),
MenuItem::linkToCrud('Blog Posts', 'fa fa-file-text', BlogPost::class),

MenuItem::section('Users'),
MenuItem::linkToCrud('Comments', 'fa fa-comment', Comment::class),
MenuItem::linkToCrud('Users', 'fa fa-user', User::class),*/
class DashboardController extends LcDashboardController
{

//MenuItem::linkToLogout('Déconnexion', 'fa fa-exit'),
];
}
}

+ 1
- 2
src/Controller/Admin/PageCrudController.php 查看文件

@@ -3,12 +3,11 @@
namespace App\Controller\Admin;

use App\Entity\Page;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\AdminBundle\Controller\Admin\AbstractCrudController;

class PageCrudController extends AbstractCrudController
{

+ 0
- 71
src/Controller/Admin/SecurityController.php 查看文件

@@ -1,71 +0,0 @@
<?php

namespace App\Controller\Admin;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

class SecurityController extends AbstractController
{

public function login(AuthenticationUtils $authenticationUtils): Response
{
if ($this->getUser()) {
return $this->redirectToRoute('lc_');
}

// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();

return $this->render('@EasyAdmin/page/login.html.twig', [
// parameters usually defined in Symfony login forms
'error' => $error,
'last_username' => $lastUsername,

// OPTIONAL parameters to customize the login form:

// the translation_domain to use (define this option only if you are
// rendering the login template in a regular Symfony controller; when
// rendering it from an EasyAdmin Dashboard this is automatically set to
// the same domain as the rest of the Dashboard)
'translation_domain' => 'admin',

// the title visible above the login form (define this option only if you are
// rendering the login template in a regular Symfony controller; when rendering
// it from an EasyAdmin Dashboard this is automatically set as the Dashboard title)
'page_title' => '<img src="assets/img/laclic.png" >',

// the string used to generate the CSRF token. If you don't define
// this parameter, the login form won't include a CSRF token
'csrf_token_intention' => 'authenticate',

// the URL users are redirected to after the login (default: '/admin')
'target_path' => $this->generateUrl('lc_admin_dashboard'),

// the label displayed for the username form field (the |trans filter is applied to it)
'username_label' => 'Your username',

// the label displayed for the password form field (the |trans filter is applied to it)
'password_label' => 'Your password',

// the label displayed for the Sign In form button (the |trans filter is applied to it)
'sign_in_label' => 'Log in',

// the 'name' HTML attribute of the <input> used for the username field (default: '_username')
'username_parameter' => 'email',

// the 'name' HTML attribute of the <input> used for the password field (default: '_password')
'password_parameter' => 'password',
]);
}


public function logout()
{
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
}

+ 4
- 4
src/Entity/Page.php 查看文件

@@ -2,16 +2,16 @@

namespace App\Entity;

use App\IModel\ImageInterface;
use App\Model\AbstractDocumentEntity;
use App\Model\ImageTrait;
use App\Repository\PageRepository;
use Doctrine\ORM\Mapping as ORM;
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 AbstractDocumentEntity implements ImageInterface
class Page extends AbstractDocument implements ImageInterface
{
use ImageTrait;


+ 15
- 154
src/Entity/User.php 查看文件

@@ -2,166 +2,27 @@

namespace App\Entity;

use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Lc\AdminBundle\IModel\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Lc\AdminBundle\Model\User\User as LcUserModel;

/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Entity(repositoryClass="Lc\AdminBundle\Repository\User\UserRepository")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/
class User implements UserInterface
class User extends LcUserModel implements UserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;

public function getId(): ?int
{
return $this->id;
}

/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;

/**
* @ORM\Column(type="json")
*/
private $roles = [];

/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lastname;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $firstname;

/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;

public function getId(): ?int
{
return $this->id;
}

public function getEmail(): ?string
{
return $this->email;
}

public function setEmail(string $email): self
{
$this->email = $email;

return $this;
}

/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}

/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';

return array_unique($roles);
}

public function setRoles(array $roles): self
{
$this->roles = $roles;

return $this;
}

/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}

public function setPassword(string $password): self
{
$this->password = $password;

return $this;
}

/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}

/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}

public function getLastname(): ?string
{
return $this->lastname;
}

public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;

return $this;
}

public function getFirstname(): ?string
{
return $this->firstname;
}

public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;

return $this;
}

public function isVerified(): bool
{
return $this->isVerified;
}

public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;

return $this;
}
}

+ 0
- 9
src/IModel/BlameableInterface.php 查看文件

@@ -1,9 +0,0 @@
<?php

namespace App\IModel;

interface BlameableInterface
{

}

+ 0
- 11
src/IModel/ImageInterface.php 查看文件

@@ -1,11 +0,0 @@
<?php

namespace App\IModel;


interface ImageInterface
{



}

+ 0
- 10
src/IModel/SeoInterface.php 查看文件

@@ -1,10 +0,0 @@
<?php

namespace App\IModel;

interface SeoInterface
{



}

+ 0
- 8
src/IModel/SluggableInterface.php 查看文件

@@ -1,8 +0,0 @@
<?php

namespace App\IModel;

interface SluggableInterface
{

}

+ 0
- 8
src/IModel/SortableInterface.php 查看文件

@@ -1,8 +0,0 @@
<?php

namespace App\IModel;

interface SortableInterface
{

}

+ 0
- 8
src/IModel/StatusInterface.php 查看文件

@@ -1,8 +0,0 @@
<?php

namespace App\IModel;

interface StatusInterface
{

}

+ 0
- 9
src/IModel/TimestampableInterface.php 查看文件

@@ -1,9 +0,0 @@
<?php

namespace App\IModel;

interface TimestampableInterface
{


}

+ 0
- 22
src/IModel/TreeInterface.php 查看文件

@@ -1,22 +0,0 @@
<?php

namespace App\IModel;

interface TreeInterface
{
/**
* Retourne le parent d'une entité
*
* @return entity
*/
public function getParent();


/**
* Retourne les enfants d'une entité
*
* @return entity
*/

public function getChildrens();
}

+ 0
- 8
src/IModel/UserInterface.php 查看文件

@@ -1,8 +0,0 @@
<?php

namespace App\IModel;

interface UserInterface
{

}

+ 0
- 78
src/Model/AbstractDocumentEntity.php 查看文件

@@ -1,78 +0,0 @@
<?php

namespace App\Model;

use App\IModel\BlameableInterface;
use App\IModel\SeoInterface;
use App\IModel\SluggableInterface;
use App\IModel\SortableInterface;
use App\IModel\TimestampableInterface;
use App\IModel\StatusInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\MappedSuperclass
*/
abstract class AbstractDocumentEntity implements BlameableInterface, SeoInterface, SluggableInterface, SortableInterface, StatusInterface, TimestampableInterface
{

use BlameableTrait;
use SeoTrait;
use SluggableTrait;
use SortableTrait;
use StatusTrait;
use TimestampableTrait;

/**
* @ORM\Column(type="string", length=255)
*/
protected $title;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $description;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $devAlias;


public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}


public function getDescription(): ?string
{
return $this->description;
}

public function setDescription(?string $description): self
{
$this->description = $description;

return $this;
}

public function getDevAlias(): ?string
{
return $this->devAlias;
}

public function setDevAlias(?string $devAlias): self
{
$this->devAlias = $devAlias;

return $this;
}

}

+ 0
- 51
src/Model/BlameableTrait.php 查看文件

@@ -1,51 +0,0 @@
<?php

namespace App\Model;

use App\IModel\UserInterface;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

trait BlameableTrait
{

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
protected $updatedBy;


public function getCreatedBy(): ?UserInterface
{
return $this->createdBy;
}

public function setCreatedBy(?UserInterface $createdBy): self
{
$this->createdBy = $createdBy;

return $this;
}

public function getUpdatedBy(): ?UserInterface
{
return $this->updatedBy;
}

public function setUpdatedBy(?UserInterface $updatedBy): self
{
$this->updatedBy = $updatedBy;

return $this;
}

}

+ 0
- 52
src/Model/ImageTrait.php 查看文件

@@ -1,52 +0,0 @@
<?php

namespace App\Model;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;

trait ImageTrait
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $image;

/* /**
* @Vich\UploadableField(mapping="images", fileNameProperty="image")
* @var File
*/
//protected $imageFile;*/
/*
public function setImageFile(File $image = null)
{
$this->imageFile = $image;

// VERY IMPORTANT:
// It is required that at least one field changes if you are using Doctrine,
// otherwise the event listeners won't be called and the file is lost
if ($image) {
// if 'updatedAt' is not defined in your entity, use another property
$this->updatedAt = new \DateTime('now');
}
}

public function getImageFile()
{
return $this->imageFile;
}*/

public function getImage(): ?string
{
return $this->image;
}

public function setImage(?string $image): self
{
$this->image = $image;

return $this;
}


}

+ 0
- 63
src/Model/SeoTrait.php 查看文件

@@ -1,63 +0,0 @@
<?php

namespace App\Model;

use Doctrine\ORM\Mapping as ORM;

trait SeoTrait
{
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $metaTitle;


/**
* @ORM\Column(type="text", nullable=true)
*/
protected $metaDescription;


/**
* @var array
* @ORM\Column(type="array", nullable=true)
*/
protected $oldUrls;


public function getMetaTitle(): ?string
{
return $this->metaTitle;
}

public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;

return $this;
}

public function getMetaDescription(): ?string
{
return $this->metaDescription;
}

public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;

return $this;
}

public function setOldUrls($oldUrls): self
{
$this->oldUrls = $oldUrls;

return $this;
}

public function getOldUrls(): ?array
{
return $this->oldUrls;
}
}

+ 0
- 27
src/Model/SluggableTrait.php 查看文件

@@ -1,27 +0,0 @@
<?php

namespace App\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

trait SluggableTrait
{
/**
* @ORM\Column(type="string", length=255)
* @Gedmo\Slug(fields={"title"})
*/
protected $slug;

public function getSlug(): ?string
{
return $this->slug;
}

public function setSlug(?string $slug): self
{
$this->slug = $slug;

return $this;
}
}

+ 0
- 34
src/Model/SortableTrait.php 查看文件

@@ -1,34 +0,0 @@
<?php

namespace App\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;


trait SortableTrait
{
/**
* @var string
* @ORM\Column(type="float")
*/
protected $position = 0;

/**
* @return float
*/
public function getPosition(): float
{
return $this->position;
}

/**
* @param float $position
* @return $this
*/
public function setPosition(float $position): self
{
$this->position = $position;
return $this;
}
}

+ 0
- 25
src/Model/StatusTrait.php 查看文件

@@ -1,25 +0,0 @@
<?php

namespace App\Model;

use Doctrine\ORM\Mapping as ORM;

trait StatusTrait
{
/**
* @ORM\Column(type="float")
*/
protected $status;

public function getStatus(): ?float
{
return $this->status;
}

public function setStatus(float $status): self
{
$this->status = $status;

return $this;
}
}

+ 0
- 46
src/Model/TimestampableTrait.php 查看文件

@@ -1,46 +0,0 @@
<?php

namespace App\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

trait TimestampableTrait
{
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;

/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;

public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}

public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;

return $this;
}

public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}

public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;

return $this;
}

}

+ 0
- 11
src/Model/TreeTrait.php 查看文件

@@ -1,11 +0,0 @@
<?php

namespace App\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

trait TreeTrait
{

}

+ 6
- 35
src/Repository/PageRepository.php 查看文件

@@ -3,8 +3,7 @@
namespace App\Repository;

use App\Entity\Page;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Lc\AdminBundle\Repository\BaseRepository;

/**
* @method Page|null find($id, $lockMode = null, $lockVersion = null)
@@ -12,39 +11,11 @@ use Doctrine\Persistence\ManagerRegistry;
* @method Page[] findAll()
* @method Page[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class PageRepository extends ServiceEntityRepository
class PageRepository extends BaseRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Page::class);
}
public function getInterfaceClass()
{
return Page::class;
}

// /**
// * @return Page[] Returns an array of Page objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?Page
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 67
src/Repository/UserRepository.php 查看文件

@@ -1,67 +0,0 @@
<?php

namespace App\Repository;

use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* @method User|null find($id, $lockMode = null, $lockVersion = null)
* @method User|null findOneBy(array $criteria, array $orderBy = null)
* @method User[] findAll()
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}

/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
}

$user->setPassword($newEncodedPassword);
$this->_em->persist($user);
$this->_em->flush();
}

// /**
// * @return User[] Returns an array of User objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('u')
->andWhere('u.exampleField = :val')
->setParameter('val', $value)
->orderBy('u.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?User
{
return $this->createQueryBuilder('u')
->andWhere('u.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 0
- 107
src/Security/LoginFormAuthenticator.php 查看文件

@@ -1,107 +0,0 @@
<?php

namespace App\Security;

use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator;
use Symfony\Component\Security\Guard\PasswordAuthenticatedInterface;
use Symfony\Component\Security\Http\Util\TargetPathTrait;

class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements PasswordAuthenticatedInterface
{
use TargetPathTrait;

public const LOGIN_ROUTE = 'login';

private $entityManager;
private $urlGenerator;
private $csrfTokenManager;
private $passwordEncoder;

public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager, UserPasswordEncoderInterface $passwordEncoder)
{
$this->entityManager = $entityManager;
$this->urlGenerator = $urlGenerator;
$this->csrfTokenManager = $csrfTokenManager;
$this->passwordEncoder = $passwordEncoder;
}

public function supports(Request $request)
{
return self::LOGIN_ROUTE === $request->attributes->get('_route')
&& $request->isMethod('POST');
}

public function getCredentials(Request $request)
{
$credentials = [
'email' => $request->request->get('email'),
'password' => $request->request->get('password'),
'csrf_token' => $request->request->get('_csrf_token'),
];
$request->getSession()->set(
Security::LAST_USERNAME,
$credentials['email']
);

return $credentials;
}

public function getUser($credentials, UserProviderInterface $userProvider)
{
$token = new CsrfToken('authenticate', $credentials['csrf_token']);
if (!$this->csrfTokenManager->isTokenValid($token)) {
throw new InvalidCsrfTokenException();
}
dump($credentials);
$user = $this->entityManager->getRepository(User::class)->findOneBy(['email' => $credentials['email']]);

if (!$user) {
die('ncncn');
// fail authentication with a custom error
throw new CustomUserMessageAuthenticationException('Email could not be found.');
}

return $user;
}

public function checkCredentials($credentials, UserInterface $user)
{
return $this->passwordEncoder->isPasswordValid($user, $credentials['password']);
}

/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function getPassword($credentials): ?string
{
return $credentials['password'];
}

public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey)
{
if ($targetPath = $this->getTargetPath($request->getSession(), $providerKey)) {
return new RedirectResponse($targetPath);
}

return new RedirectResponse($this->urlGenerator->generate('lc_admin_dashboard'));
}

protected function getLoginUrl()
{
return $this->urlGenerator->generate(self::LOGIN_ROUTE);
}
}

正在加载...
取消
保存