###> symfony/framework-bundle ### | ###> symfony/framework-bundle ### | ||||
/.php-version | |||||
/.env.local | /.env.local | ||||
/.env.local.php | /.env.local.php | ||||
/.env.*.local | /.env.*.local | ||||
/config/secrets/prod/prod.decrypt.private.php | /config/secrets/prod/prod.decrypt.private.php | ||||
/public/bundles/ | /public/bundles/ | ||||
/public/uploads/ | |||||
/public/userfiles/* | |||||
/public/robots.txt | |||||
/public/assets/.sass-cache/ | |||||
/public/media/cache/ | |||||
/var/ | /var/ | ||||
/vendor/ | /vendor/ | ||||
###< symfony/framework-bundle ### | ###< symfony/framework-bundle ### | ||||
.phpunit.result.cache | .phpunit.result.cache | ||||
/phpunit.xml | /phpunit.xml | ||||
###< symfony/phpunit-bridge ### | ###< symfony/phpunit-bridge ### | ||||
/Lc/* | |||||
/.idea/* |
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" /> | <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" /> | ||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="App\" /> | <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$/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/service-contracts" /> | ||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" /> | <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" /> | ||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/serializer" /> | <excludeFolder url="file://$MODULE_DIR$/vendor/symfony/serializer" /> |
<project version="4"> | <project version="4"> | ||||
<component name="ChangeListManager"> | <component name="ChangeListManager"> | ||||
<list default="true" id="6c084521-9606-4ed0-8fb0-1d6c8abbf313" name="Default Changelist" comment=""> | <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.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$/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/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/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/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$/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> | </list> | ||||
<option name="SHOW_DIALOG" value="false" /> | <option name="SHOW_DIALOG" value="false" /> | ||||
<option name="HIGHLIGHT_CONFLICTS" value="true" /> | <option name="HIGHLIGHT_CONFLICTS" value="true" /> | ||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> | <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> | ||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> | <property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> | ||||
<property name="WebServerToolWindowFactoryState" value="false" /> | <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_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> | ||||
<property name="nodejs_npm_path_reset_for_default_project" value="true" /> | <property name="nodejs_npm_path_reset_for_default_project" value="true" /> | ||||
<property name="nodejs_package_manager_path" value="npm" /> | <property name="nodejs_package_manager_path" value="npm" /> | ||||
</component> | </component> | ||||
<component name="RecentsManager"> | <component name="RecentsManager"> | ||||
<key name="CopyFile.RECENT_KEYS"> | <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> | ||||
<key name="MoveFile.RECENT_KEYS"> | <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> | </key> | ||||
</component> | </component> | ||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> | <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> | ||||
<workItem from="1608803957962" duration="6833000" /> | <workItem from="1608803957962" duration="6833000" /> | ||||
<workItem from="1610017072502" duration="1791000" /> | <workItem from="1610017072502" duration="1791000" /> | ||||
<workItem from="1610099290999" duration="602000" /> | <workItem from="1610099290999" duration="602000" /> | ||||
<workItem from="1614182219217" duration="1832000" /> | |||||
<workItem from="1616330933788" duration="12871000" /> | |||||
</task> | </task> | ||||
<servers /> | <servers /> | ||||
</component> | </component> |
}, | }, | ||||
"autoload": { | "autoload": { | ||||
"psr-4": { | "psr-4": { | ||||
"App\\": "src/" | |||||
"App\\": "src/", | |||||
"Lc\\": "Lc/" | |||||
} | } | ||||
}, | }, | ||||
"autoload-dev": { | "autoload-dev": { |
<?php | <?php | ||||
return [ | 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], | |||||
]; | ]; |
prefix: 'App\Entity' | prefix: 'App\Entity' | ||||
alias: App | alias: App | ||||
resolve_target_entities: | resolve_target_entities: | ||||
App\IModel\UserInterface: App\Entity\User | |||||
Lc\AdminBundle\IModel\User\UserInterface: App\Entity\User |
provider: app_user_provider | provider: app_user_provider | ||||
guard: | guard: | ||||
authenticators: | authenticators: | ||||
- App\Security\LoginFormAuthenticator | |||||
- Lc\AdminBundle\Authenticator\LoginFormAuthenticator | |||||
logout: | logout: | ||||
path: logout | path: logout | ||||
# where to redirect after logout | # where to redirect after logout |
controller: App\Controller\Admin\DashboardController::index | controller: App\Controller\Admin\DashboardController::index | ||||
login: | login: | ||||
path: /login | path: /login | ||||
controller: App\Controller\Admin\SecurityController::login | |||||
controller: Lc\AdminBundle\Controller\Admin\SecurityController::login | |||||
logout: | logout: | ||||
path: /logout | path: /logout | ||||
controller: App\Controller\Admin\SecurityController::logout | |||||
controller: Lc\AdminBundle\Admin\SecurityController::logout |
- '../src/Entity/' | - '../src/Entity/' | ||||
- '../src/Kernel.php' | - '../src/Kernel.php' | ||||
- '../src/Tests/' | - '../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 | # controllers are imported separately to make sure services can be injected | ||||
# as action arguments even if you don't extend any base controller class | # as action arguments even if you don't extend any base controller class | ||||
resource: '../src/Controller/' | resource: '../src/Controller/' | ||||
tags: ['controller.service_arguments'] | tags: ['controller.service_arguments'] | ||||
Lc\AdminBundle\Controller\: | |||||
resource: '../Lc/AdminBundle/Controller/' | |||||
tags: ['controller.service_arguments'] | |||||
# add more service definitions when explicit configuration is needed | # add more service definitions when explicit configuration is needed | ||||
# please note that last definitions always *replace* previous ones | # please note that last definitions always *replace* previous ones |
<?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'); | |||||
} | |||||
} |
<?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'); | |||||
} | |||||
} |
<?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'); | |||||
} | |||||
} |
<?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'); | |||||
} | |||||
} |
<?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'); | |||||
} | |||||
} |
<?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); | |||||
} | |||||
} | |||||
} |
<?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'), | |||||
]; | |||||
} | |||||
*/ | |||||
} |
namespace App\Controller\Admin; | 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'), | |||||
]; | |||||
} | |||||
} | } |
namespace App\Controller\Admin; | namespace App\Controller\Admin; | ||||
use App\Entity\Page; | 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\ChoiceField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField; | use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||||
use Lc\AdminBundle\Controller\Admin\AbstractCrudController; | |||||
class PageCrudController extends AbstractCrudController | class PageCrudController extends AbstractCrudController | ||||
{ | { |
<?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.'); | |||||
} | |||||
} |
namespace App\Entity; | namespace App\Entity; | ||||
use App\IModel\ImageInterface; | |||||
use App\Model\AbstractDocumentEntity; | |||||
use App\Model\ImageTrait; | |||||
use App\Repository\PageRepository; | use App\Repository\PageRepository; | ||||
use Doctrine\ORM\Mapping as ORM; | 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) | * @ORM\Entity(repositoryClass=PageRepository::class) | ||||
*/ | */ | ||||
class Page extends AbstractDocumentEntity implements ImageInterface | |||||
class Page extends AbstractDocument implements ImageInterface | |||||
{ | { | ||||
use ImageTrait; | use ImageTrait; | ||||
namespace App\Entity; | namespace App\Entity; | ||||
use App\Repository\UserRepository; | |||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\AdminBundle\IModel\User\UserInterface; | |||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | 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") | * @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; | |||||
} | |||||
} | } |
<?php | |||||
namespace App\IModel; | |||||
interface BlameableInterface | |||||
{ | |||||
} |
<?php | |||||
namespace App\IModel; | |||||
interface ImageInterface | |||||
{ | |||||
} |
<?php | |||||
namespace App\IModel; | |||||
interface SeoInterface | |||||
{ | |||||
} |
<?php | |||||
namespace App\IModel; | |||||
interface SluggableInterface | |||||
{ | |||||
} |
<?php | |||||
namespace App\IModel; | |||||
interface SortableInterface | |||||
{ | |||||
} |
<?php | |||||
namespace App\IModel; | |||||
interface StatusInterface | |||||
{ | |||||
} |
<?php | |||||
namespace App\IModel; | |||||
interface TimestampableInterface | |||||
{ | |||||
} |
<?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(); | |||||
} |
<?php | |||||
namespace App\IModel; | |||||
interface UserInterface | |||||
{ | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?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; | |||||
} | |||||
} |
<?php | |||||
namespace App\Model; | |||||
use Doctrine\Common\Collections\ArrayCollection; | |||||
use Doctrine\ORM\Mapping as ORM; | |||||
trait TreeTrait | |||||
{ | |||||
} |
namespace App\Repository; | namespace App\Repository; | ||||
use App\Entity\Page; | 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) | * @method Page|null find($id, $lockMode = null, $lockVersion = null) | ||||
* @method Page[] findAll() | * @method Page[] findAll() | ||||
* @method Page[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | * @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() | |||||
; | |||||
} | |||||
*/ | |||||
} | } |
<?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() | |||||
; | |||||
} | |||||
*/ | |||||
} |
<?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); | |||||
} | |||||
} |