Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e078515

Browse files
author
Alexandre
committed
first
1 parent cec768d commit e078515

30 files changed

Lines changed: 579 additions & 0 deletions

.gitmodules

Whitespace-only changes.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Alexandre Le Borgne
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Whitespace-only changes.

assets/js/collection-widget.js

Whitespace-only changes.

public/js/collection-widget.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
jQuery(document).ready(function () {
2+
jQuery('.add-another-collection-widget').click(function (e) {
3+
e.preventDefault();
4+
var list = jQuery(jQuery(this).attr('data-list'));
5+
// Try to find the counter of the list
6+
var counter = list.data('widget-counter') | list.children().length;
7+
// If the counter does not exist, use the length of the list
8+
if (!counter) { counter = list.children().length; }
9+
10+
// grab the prototype template
11+
var newWidget = list.attr('data-prototype');
12+
// replace the "__name__" used in the id and name of the prototype
13+
// with a number that's unique to your emails
14+
// end name attribute looks like name="contact[emails][2]"
15+
newWidget = newWidget.replace(/__name__/g, counter);
16+
// Increase the counter
17+
counter++;
18+
// And store it, the length cannot be used if deleting widgets is allowed
19+
list.data(' widget-counter', counter);
20+
21+
// create a new list element and add it to the list
22+
var newElem = jQuery(list.attr('data-widget-tags')).html(newWidget);
23+
newElem.appendTo(list);
24+
});
25+
});

src/Command/CreateUserCommand.php

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Alexandre
5+
* Date: 01/05/2018
6+
* Time: 15:21
7+
*/
8+
9+
namespace App\Command;
10+
11+
12+
use App\Security\User;
13+
use Doctrine\ORM\EntityManagerInterface;
14+
use Symfony\Component\Console\Command\Command;
15+
use Symfony\Component\Console\Input\InputArgument;
16+
use Symfony\Component\Console\Input\InputInterface;
17+
use Symfony\Component\Console\Output\OutputInterface;
18+
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
19+
use Symfony\Component\Validator\Validator\ValidatorInterface;
20+
21+
class CreateUserCommand extends Command
22+
{
23+
private $em;
24+
/**
25+
* @var UserPasswordEncoderInterface
26+
*/
27+
private $passwordEncoder;
28+
/**
29+
* @var ValidatorInterface
30+
*/
31+
private $validator;
32+
33+
public function __construct(EntityManagerInterface $em,
34+
UserPasswordEncoderInterface $passwordEncoder,
35+
ValidatorInterface $validator)
36+
{
37+
parent::__construct();
38+
$this->em = $em;
39+
$this->passwordEncoder = $passwordEncoder;
40+
$this->validator = $validator;
41+
}
42+
43+
protected function configure()
44+
{
45+
$this
46+
// the name of the command (the part after "bin/console")
47+
->setName('app:create-user')
48+
49+
// the short description shown while running "php bin/console list"
50+
->setDescription('Creates a new user.')
51+
52+
// the full command description shown when running the command with
53+
// the "--help" option
54+
->setHelp('This command allows you to create a user...')
55+
->addArgument('username', InputArgument::REQUIRED, 'The username of the user.')
56+
->addArgument('password', InputArgument::REQUIRED, 'The password of the user.')
57+
;
58+
}
59+
60+
protected function execute(InputInterface $input, OutputInterface $output)
61+
{
62+
// outputs multiple lines to the console (adding "\n" at the end of each line)
63+
$output->writeln([
64+
'User Creator',
65+
'============',
66+
'',
67+
]);
68+
69+
// outputs a message followed by a "\n"
70+
$output->writeln('Whoa!');
71+
72+
// outputs a message without adding a "\n" at the end of the line
73+
$output->write('You are about to ');
74+
$output->write('create a user.');
75+
76+
do {
77+
$output->writeln('Username: '.$input->getArgument('username'));
78+
$output->writeln('Password: '.$input->getArgument('password'));
79+
80+
$user = new User();
81+
$user->setUsername($input->getArgument('username'));
82+
$user->setPlainPassword($input->getArgument('password'));
83+
84+
$password = $this->passwordEncoder->encodePassword($user, $user->getPlainPassword());
85+
$user->setPassword($password);
86+
87+
$errors = $this->validator->validate($user);
88+
if (count($errors) > 0) {
89+
/*
90+
* Uses a __toString method on the $errors variable which is a
91+
* ConstraintViolationList object. This gives us a nice string
92+
* for debugging.
93+
*/
94+
$errorsString = (string)$errors;
95+
$output->writeln('Errors: '.$errorsString);
96+
}
97+
98+
} while(count($errors));
99+
100+
$this->em->persist($user);
101+
$this->em->flush();
102+
}
103+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Alexandre
5+
* Date: 28/04/2018
6+
* Time: 16:14
7+
*/
8+
9+
namespace App\Controller;
10+
11+
12+
class ClientController
13+
{
14+
15+
}

src/Controller/DemoController.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Alexandre
5+
* Date: 21/04/2018
6+
* Time: 18:33
7+
*/
8+
9+
namespace App\Controller;
10+
11+
12+
class DemoController
13+
{
14+
15+
}

src/Controller/OAuthController.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Alexandre
5+
* Date: 29/04/2018
6+
* Time: 18:48
7+
*/
8+
9+
namespace App\Controller;
10+
11+
12+
class OAuthController
13+
{
14+
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: Alexandre
5+
* Date: 01/05/2018
6+
* Time: 18:13
7+
*/
8+
9+
namespace App\Controller;
10+
11+
12+
class SecurityController
13+
{
14+
15+
}

0 commit comments

Comments
 (0)