Completed
Push — master ( 91372c...57e7bf )
by dima
05:02
created
packages/core/src/Modules/UserList/UserList.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -13,78 +13,78 @@
 block discarded – undo
13 13
 class UserList extends Controllers\ModuleController implements Controllers\ModuleInterface
14 14
 {
15 15
 
16
-	/**
17
-	 *
18
-	 * @var \Core\Models\User\UserRepository 
19
-	 */
20
-	protected $userRepository;
21
-
22
-	protected $request;
23
-
24
-	function __construct(\Core\Models\User\UserRepository $userRepository, Request $request)
25
-	{
26
-		$this->userRepository	= $userRepository;
27
-		$this->request			=  $request;
28
-	}
29
-
30
-	public function process()
31
-	{
16
+    /**
17
+     *
18
+     * @var \Core\Models\User\UserRepository 
19
+     */
20
+    protected $userRepository;
21
+
22
+    protected $request;
23
+
24
+    function __construct(\Core\Models\User\UserRepository $userRepository, Request $request)
25
+    {
26
+        $this->userRepository	= $userRepository;
27
+        $this->request			=  $request;
28
+    }
29
+
30
+    public function process()
31
+    {
32 32
 	
33
-		$this->logger->debug('UserList start');
34
-
35
-		if ($this->request->query->get('fn')=='add') {
36
-			$this->add();
37
-		}
38
-
39
-		$Users = $this->userRepository->findMany();
40
-
41
-		$table	 = Table::create();
42
-		$table->addColNames([0, 1, 2]);
43
-		$table->addClass('table table-striped');
44
-		$table->thead()
45
-				->addRowName('head row')
46
-				->th('head row', 0, 'Id')
47
-				->th('head row', 1, 'Имя')
48
-				->th('head row', 2, 'Email');
49
-		$i		 = 0;
50
-		foreach ($Users as $User) {
51
-			$table->addRow($i)->tdMultiple([
52
-				$User->getId(),
53
-				$User->getName(),
54
-				$User->getEmail()]);
55
-			$i++;
56
-		}
57
-
58
-		return $this->render('default', [
59
-					'table' => $table->render()
60
-		]);
61
-	}
62
-
63
-	protected function add()
64
-	{
65
-
66
-		try {
67
-
68
-			$User = $this->userRepository->build();
69
-			$User->setEmail('[email protected]');
70
-
71
-			if (!$this->userRepository->save($User)) {
72
-				throw new Exception('User not save');
73
-			} else {
74
-				$this->logger->info("Пользователь успешно сохранен!");
75
-			}
76
-		} catch(\Frameworkless\Exceptions\ValidationException $ex) {
77
-
78
-			foreach ($ex->getFailures() as $failure) {
79
-				$this->logger->error("Property " . $failure->getPropertyPath() . ": " . $failure->getMessage() . "\n");
80
-			}
81
-
82
-			$this->logger->info("Произошла ошибка при сохранении пользователя");
83
-		} catch(\Exception $ex) {
84
-
85
-			$this->logger->error("system error:" . $ex->getMessage());
86
-
87
-			$this->logger->info("Произошла ошибка при сохранении пользователя");
88
-		}
89
-	}
33
+        $this->logger->debug('UserList start');
34
+
35
+        if ($this->request->query->get('fn')=='add') {
36
+            $this->add();
37
+        }
38
+
39
+        $Users = $this->userRepository->findMany();
40
+
41
+        $table	 = Table::create();
42
+        $table->addColNames([0, 1, 2]);
43
+        $table->addClass('table table-striped');
44
+        $table->thead()
45
+                ->addRowName('head row')
46
+                ->th('head row', 0, 'Id')
47
+                ->th('head row', 1, 'Имя')
48
+                ->th('head row', 2, 'Email');
49
+        $i		 = 0;
50
+        foreach ($Users as $User) {
51
+            $table->addRow($i)->tdMultiple([
52
+                $User->getId(),
53
+                $User->getName(),
54
+                $User->getEmail()]);
55
+            $i++;
56
+        }
57
+
58
+        return $this->render('default', [
59
+                    'table' => $table->render()
60
+        ]);
61
+    }
62
+
63
+    protected function add()
64
+    {
65
+
66
+        try {
67
+
68
+            $User = $this->userRepository->build();
69
+            $User->setEmail('[email protected]');
70
+
71
+            if (!$this->userRepository->save($User)) {
72
+                throw new Exception('User not save');
73
+            } else {
74
+                $this->logger->info("Пользователь успешно сохранен!");
75
+            }
76
+        } catch(\Frameworkless\Exceptions\ValidationException $ex) {
77
+
78
+            foreach ($ex->getFailures() as $failure) {
79
+                $this->logger->error("Property " . $failure->getPropertyPath() . ": " . $failure->getMessage() . "\n");
80
+            }
81
+
82
+            $this->logger->info("Произошла ошибка при сохранении пользователя");
83
+        } catch(\Exception $ex) {
84
+
85
+            $this->logger->error("system error:" . $ex->getMessage());
86
+
87
+            $this->logger->info("Произошла ошибка при сохранении пользователя");
88
+        }
89
+    }
90 90
 }
Please login to merge, or discard this patch.
packages/core/src/Models/User/User.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,6 +16,6 @@
 block discarded – undo
16 16
 class User extends BaseUser
17 17
 {
18 18
 
19
-	use \Frameworkless\ValidatorTrait;
19
+    use \Frameworkless\ValidatorTrait;
20 20
 
21 21
 }
Please login to merge, or discard this patch.
app/ValidatorTrait.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,26 +15,26 @@
 block discarded – undo
15 15
  */
16 16
 trait ValidatorTrait
17 17
 {
18
-	/**
19
-	 * Symfony\Component\Validator\Validator\RecursiveValidator
20
-	 * @var type 
21
-	 */
22
-	protected $validator;
18
+    /**
19
+     * Symfony\Component\Validator\Validator\RecursiveValidator
20
+     * @var type 
21
+     */
22
+    protected $validator;
23 23
 			
24 24
     function __construct()
25
-	{
26
-		$this->validator = new RecursiveValidator(
25
+    {
26
+        $this->validator = new RecursiveValidator(
27 27
             new ExecutionContextFactory(new IdentityTranslator()),
28 28
             new LazyLoadingMetadataFactory(new StaticMethodLoader()),
29 29
             new ConstraintValidatorFactory()
30 30
         );
31
-	}
31
+    }
32 32
 	
33
-	public function preSave(\Propel\Runtime\Connection\ConnectionInterface $con = null)
34
-	{
33
+    public function preSave(\Propel\Runtime\Connection\ConnectionInterface $con = null)
34
+    {
35 35
         if (!$result = $this->validate($this->validator)) {
36 36
             throw new ValidationException($this->getValidationFailures(),"Validation error");
37 37
         }     		
38
-		return $result;
39
-	}	
38
+        return $result;
39
+    }	
40 40
 }
Please login to merge, or discard this patch.
app/Controllers/IndexController.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,37 +7,37 @@
 block discarded – undo
7 7
 
8 8
 class IndexController extends BaseController {
9 9
 
10
-	protected $userListModule;
11
-
12
-	/**
13
-	 * IndexController, constructed by container
14
-	 *
15
-	 * @param Twig_Environment $twig
16
-	 */
17
-	public function __construct( UserList $userListModule) {
18
-
19
-		$this->userListModule = $userListModule;
20
-	}
21
-
22
-	/**
23
-	 * Return index page (/)
24
-	 *
25
-	 * @param array $args
26
-	 * @return Response
27
-	 */
28
-	public function get($args) {
10
+    protected $userListModule;
11
+
12
+    /**
13
+     * IndexController, constructed by container
14
+     *
15
+     * @param Twig_Environment $twig
16
+     */
17
+    public function __construct( UserList $userListModule) {
18
+
19
+        $this->userListModule = $userListModule;
20
+    }
21
+
22
+    /**
23
+     * Return index page (/)
24
+     *
25
+     * @param array $args
26
+     * @return Response
27
+     */
28
+    public function get($args) {
29 29
 		
30
-		$result = \App::getModule(UserList::class,[
31
-					"limit" => 2
32
-				]);
30
+        $result = \App::getModule(UserList::class,[
31
+                    "limit" => 2
32
+                ]);
33 33
 		
34
-		$result .= \App::getModule(UserList::class,[
35
-					"limit" => 1
36
-				]);
34
+        $result .= \App::getModule(UserList::class,[
35
+                    "limit" => 1
36
+                ]);
37 37
 		
38
-		return $this->render('pages/index.html.twig', [
39
-				"content" => $result,
40
-		]);
41
-	}
38
+        return $this->render('pages/index.html.twig', [
39
+                "content" => $result,
40
+        ]);
41
+    }
42 42
 
43 43
 }
Please login to merge, or discard this patch.
bootstrap/container.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -25,36 +25,36 @@  discard block
 block discarded – undo
25 25
  * set Monolog
26 26
  */
27 27
 $container->share(Monolog\Logger::class)
28
-		->withArgument('myLogger')
29
-		;
28
+        ->withArgument('myLogger')
29
+        ;
30 30
 
31 31
 /**
32 32
  * set Propel2 Logger
33 33
  */
34 34
 Propel\Runtime\Propel::getServiceContainer()->setLogger('defaultLogger', 
35
-		(new Monolog\Logger('defaultLogger'))
36
-			->pushHandler(new Monolog\Handler\StreamHandler('php://stderr'))
37
-		);
35
+        (new Monolog\Logger('defaultLogger'))
36
+            ->pushHandler(new Monolog\Handler\StreamHandler('php://stderr'))
37
+        );
38 38
 
39 39
 /**
40 40
  * set Debug bar
41 41
  */
42 42
 $container->share(DebugBar\StandardDebugBar::class)
43
-		->withMethodCall("addCollector",[
44
-			new DebugBar\Bridge\Twig\TwigCollector(
45
-					new DebugBar\Bridge\Twig\TraceableTwigEnvironment(
46
-							$container->get(Twig_Environment::class),
47
-							new DebugBar\DataCollector\TimeDataCollector
48
-							)
49
-					)
50
-		])
51
-		->withMethodCall("addCollector",[
52
-			new DebugBar\Bridge\Propel2Collector(Propel\Runtime\Propel::getConnection())
53
-		])	
54
-		->withMethodCall("addCollector",[
55
-			new \DebugBar\Bridge\MonologCollector($container->get(Monolog\Logger::class))
56
-		])
57
-		;
43
+        ->withMethodCall("addCollector",[
44
+            new DebugBar\Bridge\Twig\TwigCollector(
45
+                    new DebugBar\Bridge\Twig\TraceableTwigEnvironment(
46
+                            $container->get(Twig_Environment::class),
47
+                            new DebugBar\DataCollector\TimeDataCollector
48
+                            )
49
+                    )
50
+        ])
51
+        ->withMethodCall("addCollector",[
52
+            new DebugBar\Bridge\Propel2Collector(Propel\Runtime\Propel::getConnection())
53
+        ])	
54
+        ->withMethodCall("addCollector",[
55
+            new \DebugBar\Bridge\MonologCollector($container->get(Monolog\Logger::class))
56
+        ])
57
+        ;
58 58
 ;
59 59
 
60 60
 
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
  */
64 64
 
65 65
 $container->inflector(Psr\Log\LoggerAwareInterface::class)
66
-          ->invokeMethod('setLogger', [$container->get(Monolog\Logger::class)]);
66
+            ->invokeMethod('setLogger', [$container->get(Monolog\Logger::class)]);
67 67
 
68 68
 $container->inflector(Frameworkless\Controllers\PageInterface::class)
69
-          ->invokeMethod('setTwig', [$container->get(Twig_Environment::class)])
70
-		  ->invokeMethod('setDebugbar', [$container->get(DebugBar\StandardDebugBar::class)])
71
-		;
69
+            ->invokeMethod('setTwig', [$container->get(Twig_Environment::class)])
70
+            ->invokeMethod('setDebugbar', [$container->get(DebugBar\StandardDebugBar::class)])
71
+        ;
72 72
 
73 73
 
74 74
 App::getInstance()->import("DI", $container);
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
bootstrap/common.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -3,45 +3,45 @@
 block discarded – undo
3 3
 class App
4 4
 {
5 5
 
6
-	private $settings = array();
6
+    private $settings = array();
7 7
 	
8
-	private static $_instance = null;
9
-
10
-	private function __construct()
11
-	{
12
-		// приватный конструктор ограничивает реализацию getInstance ()
13
-	}
14
-
15
-	protected function __clone()
16
-	{
17
-		// ограничивает клонирование объекта
18
-	}
19
-
20
-	static function getModule($name, array $params = [])
21
-	{
22
-		$DI = self::getInstance()->load("DI");
23
-		$debugbar = $DI->get(DebugBar\StandardDebugBar::class);
24
-		$debugbar['time']->startMeasure($name, 'Load module ' . $name);
25
-		$result = $DI->get($name)->process();	
26
-		$debugbar['time']->stopMeasure($name);
27
-		return $result;
28
-	}
29
-
30
-	static public function getInstance()
31
-	{
32
-		if (is_null(self::$_instance)) {
33
-			self::$_instance = new self();
34
-		}
35
-		return self::$_instance;
36
-	}
37
-
38
-	public function import($key,$value)
39
-	{
40
-		$this->settings[$key] = $value;
41
-	}
42
-
43
-	public function load($key)
44
-	{
45
-		return $this->settings[$key];
46
-	}
8
+    private static $_instance = null;
9
+
10
+    private function __construct()
11
+    {
12
+        // приватный конструктор ограничивает реализацию getInstance ()
13
+    }
14
+
15
+    protected function __clone()
16
+    {
17
+        // ограничивает клонирование объекта
18
+    }
19
+
20
+    static function getModule($name, array $params = [])
21
+    {
22
+        $DI = self::getInstance()->load("DI");
23
+        $debugbar = $DI->get(DebugBar\StandardDebugBar::class);
24
+        $debugbar['time']->startMeasure($name, 'Load module ' . $name);
25
+        $result = $DI->get($name)->process();	
26
+        $debugbar['time']->stopMeasure($name);
27
+        return $result;
28
+    }
29
+
30
+    static public function getInstance()
31
+    {
32
+        if (is_null(self::$_instance)) {
33
+            self::$_instance = new self();
34
+        }
35
+        return self::$_instance;
36
+    }
37
+
38
+    public function import($key,$value)
39
+    {
40
+        $this->settings[$key] = $value;
41
+    }
42
+
43
+    public function load($key)
44
+    {
45
+        return $this->settings[$key];
46
+    }
47 47
 }
Please login to merge, or discard this patch.