-
-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #250 Adding a make:user command (weaverryan)
This PR was squashed before being merged into the 1.0-dev branch (closes #250). Discussion ---------- Adding a make:user command Hi guys! My latest experiment π¨π»βπ¬! **User is an Entity** <img width="1277" alt="screen shot 2018-08-28 at 2 16 20 pm" src="https://user-images.githubusercontent.com/121003/44742077-faa57d80-aacc-11e8-8f73-acce0b669c7a.png"> **User is a Model Class** <img width="1278" alt="screen shot 2018-08-28 at 2 11 38 pm" src="https://user-images.githubusercontent.com/121003/44742324-98994800-aacd-11e8-8ddd-8e52310dc61a.png"> This walks people through some of the most confusing parts of starting with Symfony's security so that they can get straight to writing authenticators. A) It can generate an **entity or non-entity** `User` class B) It sets up your **`User::getUsername()` method correctly**, which can be confusing... because often you don't have a username (e.g. you have an email) C) It correctly **fills in `getSalt()` and `getPassword()`** based on whether or not your app actually *needs* to check passwords D) It **updates** the `providers` and `encoders` sections in **`security.yaml` file without losing formatting or comments**. If this process fails (it's not perfect), the command will tell you exactly what YAML to update. It defaults to using `argon2i` when the system supports it. Example generated `User` class source: `tests/Security/fixtures/expected/*` Example generated `security.yaml` source: `tests/Security/yaml_fixtures/expected_user_class/`* I'd love to have feedback from people trying it. You should be able to switch to the `dev-make-user` branch of this repository to get it. Cheers! Commits ------- c5fb5df more phpcs fixing 603a815 reducing length of unique field to avoid index length problems f6e273a Not requiring \in_array() style on generated code 23116fa bumping MySQL sever_version to 5.6 to fix Travis & JSON fields 3a40c86 updating to latest phpcs c44b1d5 Getting info about cs problems 93a846d Adding make:user command
- Loading branch information
Showing
98 changed files
with
4,278 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony MakerBundle package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\MakerBundle\Doctrine; | ||
|
||
use Symfony\Bundle\MakerBundle\Generator; | ||
use Symfony\Bundle\MakerBundle\Util\ClassNameDetails; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class EntityClassGenerator | ||
{ | ||
private $generator; | ||
|
||
public function __construct(Generator $generator) | ||
{ | ||
$this->generator = $generator; | ||
} | ||
|
||
public function generateEntityClass(ClassNameDetails $entityClassDetails, bool $apiResource): string | ||
{ | ||
$repoClassDetails = $this->generator->createClassNameDetails( | ||
$entityClassDetails->getRelativeName(), | ||
'Repository\\', | ||
'Repository' | ||
); | ||
|
||
$entityPath = $this->generator->generateClass( | ||
$entityClassDetails->getFullName(), | ||
'doctrine/Entity.tpl.php', | ||
[ | ||
'repository_full_class_name' => $repoClassDetails->getFullName(), | ||
'api_resource' => $apiResource, | ||
] | ||
); | ||
|
||
$entityAlias = strtolower($entityClassDetails->getShortName()[0]); | ||
$this->generator->generateClass( | ||
$repoClassDetails->getFullName(), | ||
'doctrine/Repository.tpl.php', | ||
[ | ||
'entity_full_class_name' => $entityClassDetails->getFullName(), | ||
'entity_class_name' => $entityClassDetails->getShortName(), | ||
'entity_alias' => $entityAlias, | ||
] | ||
); | ||
|
||
return $entityPath; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony MakerBundle package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\MakerBundle\Doctrine; | ||
|
||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; | ||
use Doctrine\ORM\Mapping\Column; | ||
use Symfony\Bundle\MakerBundle\DependencyBuilder; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class ORMDependencyBuilder | ||
{ | ||
/** | ||
* Central method to add dependencies needed for Doctrine ORM. | ||
* | ||
* @param DependencyBuilder $dependencies | ||
*/ | ||
public static function buildDependencies(DependencyBuilder $dependencies) | ||
{ | ||
$classes = [ | ||
// guarantee DoctrineBundle | ||
DoctrineBundle::class, | ||
// guarantee ORM | ||
Column::class, | ||
]; | ||
|
||
foreach ($classes as $class) { | ||
$dependencies->addClassDependency( | ||
$class, | ||
'orm' | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.