Passed
Push — master ( 44197b...b80f78 )
by Anthony
03:11
created
Service/ModuleService.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	}
23 23
 	
24 24
 	/**
25
-     * method that return all infos needed in access right management page
25
+	 * method that return all infos needed in access right management page
26 26
 	 * @return array
27 27
 	 */
28 28
 	public function getAllInfosModules()
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 	
46 46
 	/**
47
-     * function that return all modules rights
47
+	 * function that return all modules rights
48 48
 	 * @return object
49 49
 	 */
50 50
 	public function getModuleRights()
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		foreach ($modules as $module) {
37 37
 			$modules_data[] = [
38 38
 				"name" => $module->getTitle(),
39
-				"rights" => (array)json_decode(file_get_contents($this->globals->getBaseBundlePath($module->getPackageName(), $module->getDevMode()) . "/Resources/json/ribsadmin_rights.json"))
39
+				"rights" => (array) json_decode(file_get_contents($this->globals->getBaseBundlePath($module->getPackageName(), $module->getDevMode()) . "/Resources/json/ribsadmin_rights.json"))
40 40
 			];
41 41
 		}
42 42
 		
@@ -59,6 +59,6 @@  discard block
 block discarded – undo
59 59
 			$rights[] = json_decode(file_get_contents($this->globals->getBaseBundlePath($module->getPackageName(), $module->getDevMode()) . "/Resources/json/ribsadmin_rights.json"));
60 60
 		}
61 61
 		
62
-		return (object)$rights;
62
+		return (object) $rights;
63 63
 	}
64 64
 }
Please login to merge, or discard this patch.
Service/AccessRights.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
 		
80 80
 		$ribs_admin_rights = json_decode(file_get_contents($this->globals->getBaseBundlePath() . "/Resources/json/ribsadmin_rights.json"));
81 81
 		$modules_rights = $this->module->getModuleRights();
82
-		$ribs_admin_rights = (object)array_merge((array)$ribs_admin_rights, (array)$modules_rights);
82
+		$ribs_admin_rights = (object) array_merge((array) $ribs_admin_rights, (array) $modules_rights);
83 83
 		
84 84
 		if ($admin_page == "ribsadmin" && $api !== "api" && strpos($route, "login") === false && strpos($route, "register") === false) {
85 85
 			//redirection if user not connected
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	private $module;
44 44
 
45
-    /**
46
-     * @var Api
47
-     */
48
-    private $api;
45
+				/**
46
+				 * @var Api
47
+				 */
48
+				private $api;
49 49
 	
50 50
 	/**
51 51
 	 * @var User
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 	/** @var TokenStorageInterface */
56 56
 	private $token_storage;
57 57
 
58
-    /**
59
-     * AccessRights constructor.
60
-     * @param ContainerInterface $container
61
-     * @param RouterInterface $router
62
-     * @param SessionInterface $session
63
-     * @param RequestStack $request
64
-     * @param TokenStorageInterface $tokenStorage
65
-     * @param Globals $globals
66
-     * @param ModuleService $module
67
-     * @param Api $api
68
-     */
58
+				/**
59
+				 * AccessRights constructor.
60
+				 * @param ContainerInterface $container
61
+				 * @param RouterInterface $router
62
+				 * @param SessionInterface $session
63
+				 * @param RequestStack $request
64
+				 * @param TokenStorageInterface $tokenStorage
65
+				 * @param Globals $globals
66
+				 * @param ModuleService $module
67
+				 * @param Api $api
68
+				 */
69 69
 	public function __construct(ContainerInterface $container, RouterInterface $router, SessionInterface $session, RequestStack $request, TokenStorageInterface $tokenStorage, Globals $globals, ModuleService $module, Api $api)
70 70
 	{
71 71
 		$this->container = $container;
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 		$this->api = $api;
78 78
 		$this->token_storage = $tokenStorage;
79 79
 		if ($this->token_storage->getToken() && is_object($this->token_storage->getToken()->getUser()) && $this->token_storage->getToken()->getUser()->getUser()) {
80
-            $this->user = $this->token_storage->getToken()->getUser()->getUser();
81
-        }
80
+												$this->user = $this->token_storage->getToken()->getUser()->getUser();
81
+								}
82 82
 	}
83 83
 	
84 84
 	public function onKernelController()
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 			
120 120
 			throw new AccessDeniedException("No access");
121 121
 		} else if ($api === "api" && strpos($route, "login") === false && strpos($route, "register") === false) {
122
-            if ($this->api->userIslogged($this->request->getCurrentRequest()->get("infos"), $this->request->getCurrentRequest()->get("token")) === false) {
123
-                throw new AccessDeniedException("User is not connected");
124
-            }
125
-        }
122
+												if ($this->api->userIslogged($this->request->getCurrentRequest()->get("infos"), $this->request->getCurrentRequest()->get("token")) === false) {
123
+																throw new AccessDeniedException("User is not connected");
124
+												}
125
+								}
126 126
 	}
127 127
 	
128 128
 	/**
129
-     * function that allow to test a right directly in the view
129
+	 * function that allow to test a right directly in the view
130 130
 	 * @param string $right
131 131
 	 * @return bool
132 132
 	 */
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 		
138 138
 		$all_rights = array_merge($user_rights, $list_rights);
139 139
 
140
-        if (in_array("*", $all_rights)) {
141
-            return true;
142
-        }
140
+								if (in_array("*", $all_rights)) {
141
+												return true;
142
+								}
143 143
 
144 144
 		if (in_array($right, $all_rights)) {
145 145
 			return true;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	}
150 150
 	
151 151
 	/**
152
-     * test if route_right is found in users rights
152
+	 * test if route_right is found in users rights
153 153
 	 * @param array $route_right
154 154
 	 * @return bool
155 155
 	 */
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 		$all_rights = array_merge($user_rights, $list_rights);
162 162
 
163 163
 		if (in_array("*", $all_rights)) {
164
-		    return true;
165
-        }
164
+						return true;
165
+								}
166 166
 
167 167
 		foreach ($all_rights as $right) {
168 168
 			if (in_array($right, $route_right)) {
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	}
175 175
 	
176 176
 	/**
177
-     * function that search if the right contain an url or more
177
+	 * function that search if the right contain an url or more
178 178
 	 * @param $needle
179 179
 	 * @param $haystack
180 180
 	 * @return bool|mixed
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	}
199 199
 	
200 200
 	/**
201
-     * function that retun a array that contain all user rights or empty array if no right found
201
+	 * function that retun a array that contain all user rights or empty array if no right found
202 202
 	 * @return array
203 203
 	 */
204 204
 	private function getUserRights(): array
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	}
214 214
 	
215 215
 	/**
216
-     * function that retun a array that contain all rights of rattached list right of the current user
216
+	 * function that retun a array that contain all rights of rattached list right of the current user
217 217
 	 * @return array
218 218
 	 */
219 219
 	private function getRightsListOfUser(): array
Please login to merge, or discard this patch.
Service/Jwt.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 class Jwt
8 8
 {
9 9
 	/**
10
-     * encode an array in jwt
10
+	 * encode an array in jwt
11 11
 	 * @param array $values
12 12
 	 * @param string $token
13 13
 	 * @return string
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	}
19 19
 	
20 20
 	/**
21
-     * encode a jwt in array
21
+	 * encode a jwt in array
22 22
 	 * @param string $encoded_json
23 23
 	 * @param string $token
24 24
 	 * @return bool|object
Please login to merge, or discard this patch.
Command/ImportModuleCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
         $output->writeln("Start composer require " . $pacakge_name);
51 51
 
52 52
         $process = new Process("composer require " . $pacakge_name);
53
-        $process->run(function ($type, $buffer) {
53
+        $process->run(function($type, $buffer) {
54 54
             echo $buffer;
55 55
         });
56 56
 
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -13,64 +13,64 @@
 block discarded – undo
13 13
 
14 14
 class ImportModuleCommand extends Command
15 15
 {
16
-    private $em;
16
+				private $em;
17 17
 
18
-    /**
19
-     * ImportModuleCommand constructor.
20
-     * @param EntityManagerInterface $em
21
-     * @param string|null $name
22
-     */
23
-    public function __construct(EntityManagerInterface $em, string $name = null)
24
-    {
25
-        parent::__construct($name);
26
-        $this->em = $em;
27
-    }
18
+				/**
19
+				 * ImportModuleCommand constructor.
20
+				 * @param EntityManagerInterface $em
21
+				 * @param string|null $name
22
+				 */
23
+				public function __construct(EntityManagerInterface $em, string $name = null)
24
+				{
25
+								parent::__construct($name);
26
+								$this->em = $em;
27
+				}
28 28
 
29
-    protected function configure()
30
-    {
31
-        $this
32
-            ->setName('ribsadmin:import-module')
33
-            ->setDescription('Import a module in ribs admin')
34
-            ->addArgument(
35
-                'package-name',
36
-                InputArgument::REQUIRED,
37
-                'Name of composer package to import'
38
-            )
39
-            ->addArgument(
40
-                'module-name',
41
-                InputArgument::REQUIRED,
42
-                'Name of package to display in app'
43
-            )
44
-        ;
45
-    }
29
+				protected function configure()
30
+				{
31
+								$this
32
+												->setName('ribsadmin:import-module')
33
+												->setDescription('Import a module in ribs admin')
34
+												->addArgument(
35
+																'package-name',
36
+																InputArgument::REQUIRED,
37
+																'Name of composer package to import'
38
+												)
39
+												->addArgument(
40
+																'module-name',
41
+																InputArgument::REQUIRED,
42
+																'Name of package to display in app'
43
+												)
44
+								;
45
+				}
46 46
 
47
-    protected function execute(InputInterface $input, OutputInterface $output)
48
-    {
49
-        $pacakge_name = $input->getArgument('package-name');
50
-        $output->writeln("Start composer require " . $pacakge_name);
47
+				protected function execute(InputInterface $input, OutputInterface $output)
48
+				{
49
+								$pacakge_name = $input->getArgument('package-name');
50
+								$output->writeln("Start composer require " . $pacakge_name);
51 51
 
52
-        $process = new Process("composer require " . $pacakge_name);
53
-        $process->run(function ($type, $buffer) {
54
-            echo $buffer;
55
-        });
52
+								$process = new Process("composer require " . $pacakge_name);
53
+								$process->run(function ($type, $buffer) {
54
+												echo $buffer;
55
+								});
56 56
 
57
-        if (!$process->isSuccessful()) {
58
-            throw new ProcessFailedException($process);
59
-        }
57
+								if (!$process->isSuccessful()) {
58
+												throw new ProcessFailedException($process);
59
+								}
60 60
 
61
-        $output->writeln("End composer require " . $pacakge_name);
62
-        $output->writeln("Start insertion of module in database " . $pacakge_name);
61
+								$output->writeln("End composer require " . $pacakge_name);
62
+								$output->writeln("Start insertion of module in database " . $pacakge_name);
63 63
 
64
-        $module = new Module();
65
-        $module->setPackageName($pacakge_name);
66
-        $module->setTitle($input->getArgument('module-name'));
67
-        $module->setActive(false);
68
-        $module->setDisplayed(true);
69
-        $this->em->persist($module);
70
-        $this->em->flush();
64
+								$module = new Module();
65
+								$module->setPackageName($pacakge_name);
66
+								$module->setTitle($input->getArgument('module-name'));
67
+								$module->setActive(false);
68
+								$module->setDisplayed(true);
69
+								$this->em->persist($module);
70
+								$this->em->flush();
71 71
 
72
-        $output->writeln("Installation of " . $pacakge_name . " is finished. You have now to configure this module in your administration interface");
72
+								$output->writeln("Installation of " . $pacakge_name . " is finished. You have now to configure this module in your administration interface");
73 73
 
74
-        return 0;
75
-    }
74
+								return 0;
75
+				}
76 76
 }
Please login to merge, or discard this patch.
RibsAdminBundle.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@
 block discarded – undo
7 7
 
8 8
 class RibsAdminBundle extends Bundle
9 9
 {
10
-    public function getContainerExtension()
11
-    {
12
-        return new RibsAdminExtension();
13
-    }
10
+				public function getContainerExtension()
11
+				{
12
+								return new RibsAdminExtension();
13
+				}
14 14
 }
Please login to merge, or discard this patch.
Command/CreateAdminCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
         $account->setPassword($temp_password);
81 81
         $account->setUser($user);
82 82
         $account->setEmail($email);
83
-        $account->setUsername(substr($firstname, 0, 1).".".$lastname);
83
+        $account->setUsername(substr($firstname, 0, 1) . "." . $lastname);
84 84
         $this->em->persist($account);
85 85
 
86 86
         $this->em->flush();
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -13,80 +13,80 @@
 block discarded – undo
13 13
 
14 14
 class CreateAdminCommand extends Command
15 15
 {
16
-    /** @var EntityManagerInterface */
17
-    private $em;
16
+				/** @var EntityManagerInterface */
17
+				private $em;
18 18
 
19
-    /** @var UserPasswordEncoderInterface */
20
-    private $passwordEncoder;
19
+				/** @var UserPasswordEncoderInterface */
20
+				private $passwordEncoder;
21 21
 
22
-    /**
23
-     * CreateAdminCommand constructor.
24
-     * @param EntityManagerInterface $em
25
-     * @param UserPasswordEncoderInterface $passwordEncoder
26
-     * @param string|null $name
27
-     */
28
-    public function __construct(EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, string $name = null)
29
-    {
30
-        parent::__construct($name);
31
-        $this->em = $em;
32
-        $this->passwordEncoder = $passwordEncoder;
33
-    }
22
+				/**
23
+				 * CreateAdminCommand constructor.
24
+				 * @param EntityManagerInterface $em
25
+				 * @param UserPasswordEncoderInterface $passwordEncoder
26
+				 * @param string|null $name
27
+				 */
28
+				public function __construct(EntityManagerInterface $em, UserPasswordEncoderInterface $passwordEncoder, string $name = null)
29
+				{
30
+								parent::__construct($name);
31
+								$this->em = $em;
32
+								$this->passwordEncoder = $passwordEncoder;
33
+				}
34 34
 
35
-    protected function configure()
36
-    {
37
-        $this
38
-            ->setName('ribsadmin:create-admin')
39
-            ->setDescription('Create an admin in ribs admin')
40
-            ->addArgument(
41
-                'firstname',
42
-                InputArgument::REQUIRED,
43
-                'Firstname of admin to create'
44
-            )
45
-            ->addArgument(
46
-                'lastname',
47
-                InputArgument::REQUIRED,
48
-                'Lastname of admin to create'
49
-            )
50
-            ->addArgument(
51
-                'email',
52
-                InputArgument::REQUIRED,
53
-                'email of admin to create'
54
-            )
55
-            ->addArgument(
56
-                'password',
57
-                InputArgument::REQUIRED,
58
-                'password of admin to create'
59
-            )
60
-        ;
61
-    }
35
+				protected function configure()
36
+				{
37
+								$this
38
+												->setName('ribsadmin:create-admin')
39
+												->setDescription('Create an admin in ribs admin')
40
+												->addArgument(
41
+																'firstname',
42
+																InputArgument::REQUIRED,
43
+																'Firstname of admin to create'
44
+												)
45
+												->addArgument(
46
+																'lastname',
47
+																InputArgument::REQUIRED,
48
+																'Lastname of admin to create'
49
+												)
50
+												->addArgument(
51
+																'email',
52
+																InputArgument::REQUIRED,
53
+																'email of admin to create'
54
+												)
55
+												->addArgument(
56
+																'password',
57
+																InputArgument::REQUIRED,
58
+																'password of admin to create'
59
+												)
60
+								;
61
+				}
62 62
 
63
-    protected function execute(InputInterface $input, OutputInterface $output)
64
-    {
65
-        $firstname = $input->getArgument('firstname');
66
-        $lastname = $input->getArgument('lastname');
67
-        $email = $input->getArgument('email');
68
-        $password = $input->getArgument('password');
63
+				protected function execute(InputInterface $input, OutputInterface $output)
64
+				{
65
+								$firstname = $input->getArgument('firstname');
66
+								$lastname = $input->getArgument('lastname');
67
+								$email = $input->getArgument('email');
68
+								$password = $input->getArgument('password');
69 69
 
70
-        $output->writeln("Create admin " . $firstname . " " . $lastname);
70
+								$output->writeln("Create admin " . $firstname . " " . $lastname);
71 71
 
72
-        $user = new User();
73
-        $user->setFirstname($firstname);
74
-        $user->setLastname($lastname);
75
-        $user->setAccessRights("*");
76
-        $this->em->persist($user);
72
+								$user = new User();
73
+								$user->setFirstname($firstname);
74
+								$user->setLastname($lastname);
75
+								$user->setAccessRights("*");
76
+								$this->em->persist($user);
77 77
 
78
-        $account = new Account();
79
-        $temp_password = $this->passwordEncoder->encodePassword($account, $password);
80
-        $account->setPassword($temp_password);
81
-        $account->setUser($user);
82
-        $account->setEmail($email);
83
-        $account->setUsername(substr($firstname, 0, 1).".".$lastname);
84
-        $this->em->persist($account);
78
+								$account = new Account();
79
+								$temp_password = $this->passwordEncoder->encodePassword($account, $password);
80
+								$account->setPassword($temp_password);
81
+								$account->setUser($user);
82
+								$account->setEmail($email);
83
+								$account->setUsername(substr($firstname, 0, 1).".".$lastname);
84
+								$this->em->persist($account);
85 85
 
86
-        $this->em->flush();
86
+								$this->em->flush();
87 87
 
88
-        $output->writeln("End Create admin " . $firstname . " " . $lastname);
88
+								$output->writeln("End Create admin " . $firstname . " " . $lastname);
89 89
 
90
-        return 0;
91
-    }
90
+								return 0;
91
+				}
92 92
 }
Please login to merge, or discard this patch.
Service/Globals.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
 	 */
12 12
 	private $container;
13 13
 
14
-    /**
15
-     * Globals constructor.
16
-     * @param ContainerInterface $container
17
-     */
18
-    public function __construct(ContainerInterface $container)
14
+				/**
15
+				 * Globals constructor.
16
+				 * @param ContainerInterface $container
17
+				 */
18
+				public function __construct(ContainerInterface $container)
19 19
 	{
20 20
 		$this->container = $container;
21 21
 	}
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
 		return $package_name;
39 39
 	}
40 40
 
41
-    /**
42
-     * this method send base bundle path related to ribs-admin
43
-     * @param string|null $package
44
-     * @param bool $dev_mode
45
-     * @return string
46
-     */
41
+				/**
42
+				 * this method send base bundle path related to ribs-admin
43
+				 * @param string|null $package
44
+				 * @param bool $dev_mode
45
+				 * @return string
46
+				 */
47 47
 	public function getBaseBundlePath(string $package = "piou-piou/ribs-admin-bundle", bool $dev_mode = false): string
48 48
 	{
49 49
 		$path = $this->container->get('kernel')->getProjectDir();
50 50
 
51
-        $dev_mode = $package === "piou-piou/ribs-admin-bundle" ? $this->container->getParameter("ribs_admin")["dev_mode"] : $dev_mode;
51
+								$dev_mode = $package === "piou-piou/ribs-admin-bundle" ? $this->container->getParameter("ribs_admin")["dev_mode"] : $dev_mode;
52 52
 
53 53
 		if ($dev_mode === true) {
54 54
 			$package = "/lib/".$this->getPackageDevName($package);
55 55
 		} else {
56
-            $package = "/vendor/" . $package;
57
-        }
56
+												$package = "/vendor/" . $package;
57
+								}
58 58
 		
59 59
 		return $path . $package;
60 60
 	}
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
         $dev_mode = $package === "piou-piou/ribs-admin-bundle" ? $this->container->getParameter("ribs_admin")["dev_mode"] : $dev_mode;
52 52
 
53 53
 		if ($dev_mode === true) {
54
-			$package = "/lib/".$this->getPackageDevName($package);
54
+			$package = "/lib/" . $this->getPackageDevName($package);
55 55
 		} else {
56 56
             $package = "/vendor/" . $package;
57 57
         }
Please login to merge, or discard this patch.
Repository/AccountTokenRepository.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@
 block discarded – undo
8 8
 
9 9
 class AccountTokenRepository extends EntityRepository
10 10
 {
11
-    /**
12
-     * method to find UserToken to archive
13
-     * @param int $max_inactivation_days
14
-     * @return mixed
15
-     * @throws Exception
16
-     */
17
-    public function findByExpiredToken(int $max_inactivation_days)
18
-    {
19
-        $now = new \DateTime();
20
-        $now->sub(new \DateInterval("P" . $max_inactivation_days . "D"));
11
+				/**
12
+				 * method to find UserToken to archive
13
+				 * @param int $max_inactivation_days
14
+				 * @return mixed
15
+				 * @throws Exception
16
+				 */
17
+				public function findByExpiredToken(int $max_inactivation_days)
18
+				{
19
+								$now = new \DateTime();
20
+								$now->sub(new \DateInterval("P" . $max_inactivation_days . "D"));
21 21
 
22
-        $query = $this->getEntityManager()->createQuery("SELECT u FROM App:AccountToken u WHERE
22
+								$query = $this->getEntityManager()->createQuery("SELECT u FROM App:AccountToken u WHERE
23 23
 			u.endToken < :max_inactivation_days
24 24
 		");
25 25
 
26
-        $query->setParameter("max_inactivation_days", $now, Type::DATETIME);
26
+								$query->setParameter("max_inactivation_days", $now, Type::DATETIME);
27 27
 
28
-        return $query->getResult();
29
-    }
28
+								return $query->getResult();
29
+				}
30 30
 }
Please login to merge, or discard this patch.
Service/Api.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -23,192 +23,192 @@
 block discarded – undo
23 23
 
24 24
 class Api
25 25
 {
26
-    /**
27
-     * @var ContainerInterface
28
-     */
29
-    private $container;
30
-
31
-    /**
32
-     * @var EntityManagerInterface
33
-     */
34
-    private $em;
35
-
36
-    /**
37
-     * @var SessionInterface
38
-     */
39
-    private $session;
40
-
41
-    /**
42
-     * @var Account
43
-     */
44
-    private $account;
45
-
46
-    /**
47
-     * @var Request|null
48
-     */
49
-    private $request;
50
-
51
-    /**
52
-     * Api constructor.
53
-     * @param ContainerInterface $container
54
-     * @param EntityManagerInterface $em
55
-     * @param SessionInterface $session
56
-     * @param RequestStack $request_stack
57
-     */
58
-    public function __construct(ContainerInterface $container, EntityManagerInterface $em, SessionInterface $session, RequestStack $request_stack)
59
-    {
60
-        $this->container = $container;
61
-        $this->em = $em;
62
-        $this->session = $session;
63
-        $this->request = $request_stack->getCurrentRequest();
64
-    }
65
-
66
-    /**
67
-     * this method is used to test jwt and if the account is ok else send false
68
-     * @param string $infos_jwt
69
-     * @param string $token
70
-     * @return bool
71
-     * @throws Exception
72
-     */
73
-    public function userIslogged(string $infos_jwt, string $token): bool
74
-    {
75
-        $em = $this->em;
76
-        $jwt = Jwt::decode($infos_jwt, $token);
77
-
78
-        if ($jwt === false) {
79
-            return false;
80
-        }
81
-
82
-        $account_token_search = [
83
-            "token" => $token,
84
-            "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
85
-            "ip" => $this->request->server->get("REMOTE_ADDR")
86
-        ];
87
-        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$this->request->server->get("HTTP_USER_AGENT"))||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($this->request->server->get("HTTP_USER_AGENT"),0,4))) {
88
-            $account_token_search = [
89
-                "token" => $token,
90
-                "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
91
-            ];
92
-        }
93
-
94
-        $account_token = $em->getRepository(AccountToken::class)->findOneBy($account_token_search);
95
-
96
-        if (!$account_token) {
97
-            return false;
98
-        }
99
-
100
-        $this->account = $em->getRepository(Account::class)->findOneBy([
101
-            "id" => $account_token->getAccount()->getId(),
102
-            "isActive" => true,
103
-        ]);
104
-
105
-        if (!$this->account) {
106
-            return false;
107
-        }
108
-
109
-        $this->account->setLastConnection(new \DateTime());
110
-        $em->persist($this->account);
111
-        $em->flush();
112
-
113
-        $this->getToken($this->account);
114
-        $this->session->set("jwt_infos", $jwt);
115
-        $this->session->set("account", $this->account);
116
-        $this->session->set("account_token", $account_token);
117
-
118
-        return true;
119
-    }
120
-
121
-    /**
122
-     * method that return the token for a account
123
-     * @param Account $account
124
-     * @return string
125
-     * @throws Exception
126
-     */
127
-    public function getToken(Account $account): string
128
-    {
129
-        $account_token = $this->em->getRepository(AccountToken::class)->findOneBy([
130
-            "account" => $account,
131
-            "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
132
-            "ip" => $this->request->server->get("REMOTE_ADDR")
133
-        ]);
134
-
135
-        $token = $account_token ? $account_token->getToken() : null;
136
-        $now = new \DateTime();
137
-
138
-        if ($token === null || $account_token->getEndToken() < $now) {
139
-            return $this->setToken($account, $account_token);
140
-        }
141
-
142
-        return $token;
143
-    }
144
-
145
-    /**
146
-     * @param Account $account
147
-     * @param $account_token
148
-     * @return string
149
-     * method that set a token for the account
150
-     * @throws Exception
151
-     */
152
-    public function setToken(Account $account, $account_token): string
153
-    {
154
-        $token = $this->generateToken();
155
-        $now = new \DateTime();
156
-        $end_token = $now->add(new \DateInterval("PT".$this->container->getParameter("ribs_admin")["api_token_duration"]."M"));
157
-
158
-        if (!$account_token) {
159
-            $account_token = new AccountToken();
160
-        }
161
-
162
-        $account_token->setToken($token);
163
-        $account_token->setUserAgent($this->request->server->get("HTTP_USER_AGENT"));
164
-        $account_token->setIp($this->request->server->get("REMOTE_ADDR"));
165
-        $account_token->setEndToken($end_token);
166
-        $account_token->setAccount($account);
167
-        $this->em->persist($account_token);
168
-        $this->em->flush();
169
-
170
-        $this->account = $account;
171
-        $this->session->set("account", $this->account);
172
-        $this->session->set("account_token", $account_token);
173
-
174
-        return $token;
175
-    }
176
-
177
-    /**
178
-     * generate a token for api
179
-     * @param int $length
180
-     * @return string
181
-     */
182
-    public function generateToken(int $length = 200): string
183
-    {
184
-        $string = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
185
-        $token = "";
186
-        srand((double)microtime() * 1000000);
187
-        for ($i = 0; $i < $length; $i++) {
188
-            $token .= $string[rand() % strlen($string)];
189
-        }
190
-
191
-        return $token;
192
-    }
193
-
194
-    /**
195
-     * method that encode an object to a json
196
-     * @param $object
197
-     * @param string $type
198
-     * @return mixed
199
-     * @throws ExceptionInterface
200
-     * @throws AnnotationException
201
-     */
202
-    public function serializeObject($object, $type = "json")
203
-    {
204
-        $classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
205
-        $serializer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer($classMetadataFactory)], [new XmlEncoder(), new JsonEncoder()]);
206
-
207
-        return $serializer->normalize($object, $type, [
208
-            'circular_reference_handler' => function ($object) {
209
-                return $object->getId();
210
-            },
211
-            'groups' => 'main'
212
-        ]);
213
-    }
26
+				/**
27
+				 * @var ContainerInterface
28
+				 */
29
+				private $container;
30
+
31
+				/**
32
+				 * @var EntityManagerInterface
33
+				 */
34
+				private $em;
35
+
36
+				/**
37
+				 * @var SessionInterface
38
+				 */
39
+				private $session;
40
+
41
+				/**
42
+				 * @var Account
43
+				 */
44
+				private $account;
45
+
46
+				/**
47
+				 * @var Request|null
48
+				 */
49
+				private $request;
50
+
51
+				/**
52
+				 * Api constructor.
53
+				 * @param ContainerInterface $container
54
+				 * @param EntityManagerInterface $em
55
+				 * @param SessionInterface $session
56
+				 * @param RequestStack $request_stack
57
+				 */
58
+				public function __construct(ContainerInterface $container, EntityManagerInterface $em, SessionInterface $session, RequestStack $request_stack)
59
+				{
60
+								$this->container = $container;
61
+								$this->em = $em;
62
+								$this->session = $session;
63
+								$this->request = $request_stack->getCurrentRequest();
64
+				}
65
+
66
+				/**
67
+				 * this method is used to test jwt and if the account is ok else send false
68
+				 * @param string $infos_jwt
69
+				 * @param string $token
70
+				 * @return bool
71
+				 * @throws Exception
72
+				 */
73
+				public function userIslogged(string $infos_jwt, string $token): bool
74
+				{
75
+								$em = $this->em;
76
+								$jwt = Jwt::decode($infos_jwt, $token);
77
+
78
+								if ($jwt === false) {
79
+												return false;
80
+								}
81
+
82
+								$account_token_search = [
83
+												"token" => $token,
84
+												"userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
85
+												"ip" => $this->request->server->get("REMOTE_ADDR")
86
+								];
87
+								if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$this->request->server->get("HTTP_USER_AGENT"))||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($this->request->server->get("HTTP_USER_AGENT"),0,4))) {
88
+												$account_token_search = [
89
+																"token" => $token,
90
+																"userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
91
+												];
92
+								}
93
+
94
+								$account_token = $em->getRepository(AccountToken::class)->findOneBy($account_token_search);
95
+
96
+								if (!$account_token) {
97
+												return false;
98
+								}
99
+
100
+								$this->account = $em->getRepository(Account::class)->findOneBy([
101
+												"id" => $account_token->getAccount()->getId(),
102
+												"isActive" => true,
103
+								]);
104
+
105
+								if (!$this->account) {
106
+												return false;
107
+								}
108
+
109
+								$this->account->setLastConnection(new \DateTime());
110
+								$em->persist($this->account);
111
+								$em->flush();
112
+
113
+								$this->getToken($this->account);
114
+								$this->session->set("jwt_infos", $jwt);
115
+								$this->session->set("account", $this->account);
116
+								$this->session->set("account_token", $account_token);
117
+
118
+								return true;
119
+				}
120
+
121
+				/**
122
+				 * method that return the token for a account
123
+				 * @param Account $account
124
+				 * @return string
125
+				 * @throws Exception
126
+				 */
127
+				public function getToken(Account $account): string
128
+				{
129
+								$account_token = $this->em->getRepository(AccountToken::class)->findOneBy([
130
+												"account" => $account,
131
+												"userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
132
+												"ip" => $this->request->server->get("REMOTE_ADDR")
133
+								]);
134
+
135
+								$token = $account_token ? $account_token->getToken() : null;
136
+								$now = new \DateTime();
137
+
138
+								if ($token === null || $account_token->getEndToken() < $now) {
139
+												return $this->setToken($account, $account_token);
140
+								}
141
+
142
+								return $token;
143
+				}
144
+
145
+				/**
146
+				 * @param Account $account
147
+				 * @param $account_token
148
+				 * @return string
149
+				 * method that set a token for the account
150
+				 * @throws Exception
151
+				 */
152
+				public function setToken(Account $account, $account_token): string
153
+				{
154
+								$token = $this->generateToken();
155
+								$now = new \DateTime();
156
+								$end_token = $now->add(new \DateInterval("PT".$this->container->getParameter("ribs_admin")["api_token_duration"]."M"));
157
+
158
+								if (!$account_token) {
159
+												$account_token = new AccountToken();
160
+								}
161
+
162
+								$account_token->setToken($token);
163
+								$account_token->setUserAgent($this->request->server->get("HTTP_USER_AGENT"));
164
+								$account_token->setIp($this->request->server->get("REMOTE_ADDR"));
165
+								$account_token->setEndToken($end_token);
166
+								$account_token->setAccount($account);
167
+								$this->em->persist($account_token);
168
+								$this->em->flush();
169
+
170
+								$this->account = $account;
171
+								$this->session->set("account", $this->account);
172
+								$this->session->set("account_token", $account_token);
173
+
174
+								return $token;
175
+				}
176
+
177
+				/**
178
+				 * generate a token for api
179
+				 * @param int $length
180
+				 * @return string
181
+				 */
182
+				public function generateToken(int $length = 200): string
183
+				{
184
+								$string = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
185
+								$token = "";
186
+								srand((double)microtime() * 1000000);
187
+								for ($i = 0; $i < $length; $i++) {
188
+												$token .= $string[rand() % strlen($string)];
189
+								}
190
+
191
+								return $token;
192
+				}
193
+
194
+				/**
195
+				 * method that encode an object to a json
196
+				 * @param $object
197
+				 * @param string $type
198
+				 * @return mixed
199
+				 * @throws ExceptionInterface
200
+				 * @throws AnnotationException
201
+				 */
202
+				public function serializeObject($object, $type = "json")
203
+				{
204
+								$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
205
+								$serializer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer($classMetadataFactory)], [new XmlEncoder(), new JsonEncoder()]);
206
+
207
+								return $serializer->normalize($object, $type, [
208
+												'circular_reference_handler' => function ($object) {
209
+																return $object->getId();
210
+												},
211
+												'groups' => 'main'
212
+								]);
213
+				}
214 214
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
85 85
             "ip" => $this->request->server->get("REMOTE_ADDR")
86 86
         ];
87
-        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$this->request->server->get("HTTP_USER_AGENT"))||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($this->request->server->get("HTTP_USER_AGENT"),0,4))) {
87
+        if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $this->request->server->get("HTTP_USER_AGENT")) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($this->request->server->get("HTTP_USER_AGENT"), 0, 4))) {
88 88
             $account_token_search = [
89 89
                 "token" => $token,
90 90
                 "userAgent" => $this->request->server->get("HTTP_USER_AGENT"),
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     {
154 154
         $token = $this->generateToken();
155 155
         $now = new \DateTime();
156
-        $end_token = $now->add(new \DateInterval("PT".$this->container->getParameter("ribs_admin")["api_token_duration"]."M"));
156
+        $end_token = $now->add(new \DateInterval("PT" . $this->container->getParameter("ribs_admin")["api_token_duration"] . "M"));
157 157
 
158 158
         if (!$account_token) {
159 159
             $account_token = new AccountToken();
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     {
184 184
         $string = "abcdefghijklmnopqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789";
185 185
         $token = "";
186
-        srand((double)microtime() * 1000000);
186
+        srand((double) microtime() * 1000000);
187 187
         for ($i = 0; $i < $length; $i++) {
188 188
             $token .= $string[rand() % strlen($string)];
189 189
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $serializer = new Serializer([new DateTimeNormalizer(), new ObjectNormalizer($classMetadataFactory)], [new XmlEncoder(), new JsonEncoder()]);
206 206
 
207 207
         return $serializer->normalize($object, $type, [
208
-            'circular_reference_handler' => function ($object) {
208
+            'circular_reference_handler' => function($object) {
209 209
                 return $object->getId();
210 210
             },
211 211
             'groups' => 'main'
Please login to merge, or discard this patch.