Passed
Push — master ( c4c0f1...e1851e )
by Anthony
03:02
created
Service/Version.php 1 patch
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -12,159 +12,159 @@
 block discarded – undo
12 12
 
13 13
 class Version
14 14
 {
15
-    /**
16
-     * @var EntityManagerInterface
17
-     */
18
-    private $em;
19
-
20
-    /**
21
-     * @var HttpClientInterface
22
-     */
23
-    private $client;
24
-
25
-    /**
26
-     * @var \PiouPiou\RibsAdminBundle\Entity\Version
27
-     */
28
-    private $version_entity;
29
-
30
-    /**
31
-     * Version constructor.
32
-     * @param EntityManagerInterface $em
33
-     * @param HttpClientInterface $client
34
-     */
35
-    public function __construct(EntityManagerInterface $em, HttpClientInterface $client)
36
-    {
37
-        $this->em = $em;
38
-        $this->client = $client;
39
-    }
40
-
41
-    /**
42
-     * @param \PiouPiou\RibsAdminBundle\Entity\Version $version
43
-     */
44
-    public function setVersionEntity(\PiouPiou\RibsAdminBundle\Entity\Version $version) {
45
-        $this->version_entity = $version;
46
-    }
47
-
48
-    /**
49
-     * @return mixed|null
50
-     * @throws ClientExceptionInterface
51
-     * @throws RedirectionExceptionInterface
52
-     * @throws ServerExceptionInterface
53
-     * @throws TransportExceptionInterface
54
-     */
55
-    private function getComposerLockJson()
56
-    {
57
-        if ($this->version_entity && !$this->version_entity->isIsLocal()) {
58
-            $response = $this->client->request("GET", $this->version_entity->getComposerLockUrl());
59
-            $composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null;
60
-        } else {
61
-            $composer_lock = file_get_contents('../composer.lock');
62
-        }
63
-
64
-        if ($composer_lock) {
65
-            return json_decode($composer_lock, true);
66
-        }
67
-
68
-        return null;
69
-    }
70
-
71
-    /**
72
-     * @param $package_name
73
-     * @return mixed|null
74
-     * @throws ClientExceptionInterface
75
-     * @throws RedirectionExceptionInterface
76
-     * @throws ServerExceptionInterface
77
-     * @throws TransportExceptionInterface
78
-     */
79
-    private function getPackage($package_name)
80
-    {
81
-        $composer_lock = $this->getComposerLockJson();
82
-        if ($composer_lock) {
83
-            $packages = $composer_lock["packages"];
84
-            $key = array_search($package_name, array_column($packages, 'name'));
85
-
86
-            if ($key) {
87
-                return $packages[$key];
88
-            }
89
-        }
90
-
91
-        return null;
92
-    }
93
-
94
-    /**
95
-     * @param $package_name
96
-     * @return mixed|null
97
-     */
98
-    public function getVersion($package_name)
99
-    {
100
-        return $this->getPackage($package_name) ? $this->getPackage($package_name)["version"] : null;
101
-    }
102
-
103
-    /**
104
-     * @param $package_name
105
-     * @return mixed|null
106
-     * @throws Exception
107
-     */
108
-    public function getVersionDate($package_name)
109
-    {
110
-        $string_date = $this->getPackage($package_name) ? explode("T", $this->getPackage($package_name)["time"])[0] : null;
111
-        $version_date = null;
112
-
113
-        if ($string_date) {
114
-            $version_date = new \DateTime($string_date);
115
-        }
116
-
117
-        return $version_date;
118
-    }
119
-
120
-    /**
121
-     * @param $package_name
122
-     * @return false|int|string|null
123
-     * @throws ClientExceptionInterface
124
-     * @throws RedirectionExceptionInterface
125
-     * @throws ServerExceptionInterface
126
-     * @throws TransportExceptionInterface
127
-     */
128
-    public function getLastPackagistVersion($package_name)
129
-    {
130
-        if (!strpos($package_name, "/")) {
131
-            return false;
132
-        }
133
-
134
-        $packgist_url = "https://repo.packagist.org/p/".$package_name.".json";
135
-
136
-        $response = $this->client->request("GET", $packgist_url);
137
-
138
-        if ($response->getStatusCode() == 200) {
139
-            $content = json_decode($response->getContent(), true);
140
-            if (is_array($content) && $content["packages"] && $content["packages"][$package_name]) {
141
-                return array_key_first($content["packages"][$package_name]);
142
-            }
143
-        }
144
-    }
145
-
146
-    /**
147
-     * @param $package_name
148
-     * @throws Exception
149
-     */
150
-    public function save($package_name)
151
-    {
152
-        $version = $this->em->getRepository(\PiouPiou\RibsAdminBundle\Entity\Version::class)->findOneBy(["package_name" => $package_name]);
153
-
154
-        if (!$version) {
155
-            $version = new \PiouPiou\RibsAdminBundle\Entity\Version();
156
-            $version->setProjectName($package_name);
157
-            $version->setPackageName($package_name);
158
-            $version->setProjectUrl($package_name);
159
-            $version->setCheckVersionUrl($package_name);
160
-        }
161
-
162
-        $version->setVersion($this->getVersion($package_name));
163
-        $version->setVersionDate($this->getVersionDate($package_name));
164
-        $version->setLastPackagistVersion($this->getLastPackagistVersion($package_name));
165
-        $version->setLastCheck(new \DateTime());
166
-
167
-        $this->em->persist($version);
168
-        $this->em->flush();
169
-    }
15
+				/**
16
+				 * @var EntityManagerInterface
17
+				 */
18
+				private $em;
19
+
20
+				/**
21
+				 * @var HttpClientInterface
22
+				 */
23
+				private $client;
24
+
25
+				/**
26
+				 * @var \PiouPiou\RibsAdminBundle\Entity\Version
27
+				 */
28
+				private $version_entity;
29
+
30
+				/**
31
+				 * Version constructor.
32
+				 * @param EntityManagerInterface $em
33
+				 * @param HttpClientInterface $client
34
+				 */
35
+				public function __construct(EntityManagerInterface $em, HttpClientInterface $client)
36
+				{
37
+								$this->em = $em;
38
+								$this->client = $client;
39
+				}
40
+
41
+				/**
42
+				 * @param \PiouPiou\RibsAdminBundle\Entity\Version $version
43
+				 */
44
+				public function setVersionEntity(\PiouPiou\RibsAdminBundle\Entity\Version $version) {
45
+								$this->version_entity = $version;
46
+				}
47
+
48
+				/**
49
+				 * @return mixed|null
50
+				 * @throws ClientExceptionInterface
51
+				 * @throws RedirectionExceptionInterface
52
+				 * @throws ServerExceptionInterface
53
+				 * @throws TransportExceptionInterface
54
+				 */
55
+				private function getComposerLockJson()
56
+				{
57
+								if ($this->version_entity && !$this->version_entity->isIsLocal()) {
58
+												$response = $this->client->request("GET", $this->version_entity->getComposerLockUrl());
59
+												$composer_lock = $response->getStatusCode() == 200 ? $response->getContent() : null;
60
+								} else {
61
+												$composer_lock = file_get_contents('../composer.lock');
62
+								}
63
+
64
+								if ($composer_lock) {
65
+												return json_decode($composer_lock, true);
66
+								}
67
+
68
+								return null;
69
+				}
70
+
71
+				/**
72
+				 * @param $package_name
73
+				 * @return mixed|null
74
+				 * @throws ClientExceptionInterface
75
+				 * @throws RedirectionExceptionInterface
76
+				 * @throws ServerExceptionInterface
77
+				 * @throws TransportExceptionInterface
78
+				 */
79
+				private function getPackage($package_name)
80
+				{
81
+								$composer_lock = $this->getComposerLockJson();
82
+								if ($composer_lock) {
83
+												$packages = $composer_lock["packages"];
84
+												$key = array_search($package_name, array_column($packages, 'name'));
85
+
86
+												if ($key) {
87
+																return $packages[$key];
88
+												}
89
+								}
90
+
91
+								return null;
92
+				}
93
+
94
+				/**
95
+				 * @param $package_name
96
+				 * @return mixed|null
97
+				 */
98
+				public function getVersion($package_name)
99
+				{
100
+								return $this->getPackage($package_name) ? $this->getPackage($package_name)["version"] : null;
101
+				}
102
+
103
+				/**
104
+				 * @param $package_name
105
+				 * @return mixed|null
106
+				 * @throws Exception
107
+				 */
108
+				public function getVersionDate($package_name)
109
+				{
110
+								$string_date = $this->getPackage($package_name) ? explode("T", $this->getPackage($package_name)["time"])[0] : null;
111
+								$version_date = null;
112
+
113
+								if ($string_date) {
114
+												$version_date = new \DateTime($string_date);
115
+								}
116
+
117
+								return $version_date;
118
+				}
119
+
120
+				/**
121
+				 * @param $package_name
122
+				 * @return false|int|string|null
123
+				 * @throws ClientExceptionInterface
124
+				 * @throws RedirectionExceptionInterface
125
+				 * @throws ServerExceptionInterface
126
+				 * @throws TransportExceptionInterface
127
+				 */
128
+				public function getLastPackagistVersion($package_name)
129
+				{
130
+								if (!strpos($package_name, "/")) {
131
+												return false;
132
+								}
133
+
134
+								$packgist_url = "https://repo.packagist.org/p/".$package_name.".json";
135
+
136
+								$response = $this->client->request("GET", $packgist_url);
137
+
138
+								if ($response->getStatusCode() == 200) {
139
+												$content = json_decode($response->getContent(), true);
140
+												if (is_array($content) && $content["packages"] && $content["packages"][$package_name]) {
141
+																return array_key_first($content["packages"][$package_name]);
142
+												}
143
+								}
144
+				}
145
+
146
+				/**
147
+				 * @param $package_name
148
+				 * @throws Exception
149
+				 */
150
+				public function save($package_name)
151
+				{
152
+								$version = $this->em->getRepository(\PiouPiou\RibsAdminBundle\Entity\Version::class)->findOneBy(["package_name" => $package_name]);
153
+
154
+								if (!$version) {
155
+												$version = new \PiouPiou\RibsAdminBundle\Entity\Version();
156
+												$version->setProjectName($package_name);
157
+												$version->setPackageName($package_name);
158
+												$version->setProjectUrl($package_name);
159
+												$version->setCheckVersionUrl($package_name);
160
+								}
161
+
162
+								$version->setVersion($this->getVersion($package_name));
163
+								$version->setVersionDate($this->getVersionDate($package_name));
164
+								$version->setLastPackagistVersion($this->getLastPackagistVersion($package_name));
165
+								$version->setLastCheck(new \DateTime());
166
+
167
+								$this->em->persist($version);
168
+								$this->em->flush();
169
+				}
170 170
 }
Please login to merge, or discard this patch.
Service/AccessRights.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	private $module;
45 45
 
46
-    /**
47
-     * @var Api
48
-     */
49
-    private $api;
46
+				/**
47
+				 * @var Api
48
+				 */
49
+				private $api;
50 50
 	
51 51
 	/**
52 52
 	 * @var User
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 	/** @var TokenStorageInterface */
57 57
 	private $token_storage;
58 58
 
59
-    /**
60
-     * AccessRights constructor.
61
-     * @param ContainerInterface $container
62
-     * @param RouterInterface $router
63
-     * @param SessionInterface $session
64
-     * @param RequestStack $request
65
-     * @param TokenStorageInterface $tokenStorage
66
-     * @param Globals $globals
67
-     * @param ModuleService $module
68
-     * @param Api $api
69
-     */
59
+				/**
60
+				 * AccessRights constructor.
61
+				 * @param ContainerInterface $container
62
+				 * @param RouterInterface $router
63
+				 * @param SessionInterface $session
64
+				 * @param RequestStack $request
65
+				 * @param TokenStorageInterface $tokenStorage
66
+				 * @param Globals $globals
67
+				 * @param ModuleService $module
68
+				 * @param Api $api
69
+				 */
70 70
 	public function __construct(ContainerInterface $container, RouterInterface $router, SessionInterface $session, RequestStack $request, TokenStorageInterface $tokenStorage, Globals $globals, ModuleService $module, Api $api)
71 71
 	{
72 72
 		$this->container = $container;
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 		$this->api = $api;
79 79
 		$this->token_storage = $tokenStorage;
80 80
 		if ($this->token_storage->getToken() && is_object($this->token_storage->getToken()->getUser()) && $this->token_storage->getToken()->getUser()->getUser()) {
81
-            $this->user = $this->token_storage->getToken()->getUser()->getUser();
82
-        }
81
+												$this->user = $this->token_storage->getToken()->getUser()->getUser();
82
+								}
83 83
 	}
84 84
 	
85 85
 	public function onKernelController()
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 		$modules_rights = $this->module->getModuleRights();
99 99
 		$ribs_admin_rights = (object)array_merge((array)$ribs_admin_rights, (array)$modules_rights);
100 100
 
101
-        if ($this->testIsOpenUrl($route)) {
102
-            return;
103
-        }
101
+								if ($this->testIsOpenUrl($route)) {
102
+												return;
103
+								}
104 104
 
105 105
 		if ($admin_page == "ribsadmin" && !$api && strpos($route, "login") === false && strpos($route, "register") === false) {
106 106
 			//redirection if user not connected
@@ -124,25 +124,25 @@  discard block
 block discarded – undo
124 124
 			
125 125
 			throw new AccessDeniedException("No access");
126 126
 		} else if ($api && strpos($route, "login") === false && strpos($route, "register") === false) {
127
-            if ($this->api->userIslogged($this->request->getCurrentRequest()->get("infos"), $this->request->getCurrentRequest()->get("token")) === false) {
128
-                throw new AccessDeniedException("User is not connected");
129
-            }
130
-        }
127
+												if ($this->api->userIslogged($this->request->getCurrentRequest()->get("infos"), $this->request->getCurrentRequest()->get("token")) === false) {
128
+																throw new AccessDeniedException("User is not connected");
129
+												}
130
+								}
131 131
 	}
132 132
 
133 133
 	private function testIsOpenUrl($route)
134
-    {
135
-        $open_urls = json_decode(file_get_contents($this->globals->getBaseBundlePath() . "/Resources/json/ribsadmin_open_url.json"), true);
134
+				{
135
+								$open_urls = json_decode(file_get_contents($this->globals->getBaseBundlePath() . "/Resources/json/ribsadmin_open_url.json"), true);
136 136
 
137
-        if ($open_urls && $open_urls["items"] && in_array($route, $open_urls["items"])) {
138
-            return true;
139
-        }
137
+								if ($open_urls && $open_urls["items"] && in_array($route, $open_urls["items"])) {
138
+												return true;
139
+								}
140 140
 
141
-        return false;
142
-    }
141
+								return false;
142
+				}
143 143
 	
144 144
 	/**
145
-     * function that allow to test a right directly in the view
145
+	 * function that allow to test a right directly in the view
146 146
 	 * @param string $right
147 147
 	 * @return bool
148 148
 	 */
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 		
154 154
 		$all_rights = array_merge($user_rights, $list_rights);
155 155
 
156
-        if (in_array("*", $all_rights)) {
157
-            return true;
158
-        }
156
+								if (in_array("*", $all_rights)) {
157
+												return true;
158
+								}
159 159
 
160 160
 		if (in_array($right, $all_rights)) {
161 161
 			return true;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	}
166 166
 	
167 167
 	/**
168
-     * test if route_right is found in users rights
168
+	 * test if route_right is found in users rights
169 169
 	 * @param array $route_right
170 170
 	 * @return bool
171 171
 	 */
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 		$all_rights = array_merge($user_rights, $list_rights);
178 178
 
179 179
 		if (in_array("*", $all_rights)) {
180
-		    return true;
181
-        }
180
+						return true;
181
+								}
182 182
 
183 183
 		foreach ($all_rights as $right) {
184 184
 			if (in_array($right, $route_right)) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	}
191 191
 	
192 192
 	/**
193
-     * function that search if the right contain an url or more
193
+	 * function that search if the right contain an url or more
194 194
 	 * @param $needle
195 195
 	 * @param $haystack
196 196
 	 * @return bool|mixed
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	}
215 215
 	
216 216
 	/**
217
-     * function that retun a array that contain all user rights or empty array if no right found
217
+	 * function that retun a array that contain all user rights or empty array if no right found
218 218
 	 * @return array
219 219
 	 */
220 220
 	private function getUserRights(): array
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	}
230 230
 	
231 231
 	/**
232
-     * function that retun a array that contain all rights of rattached list right of the current user
232
+	 * function that retun a array that contain all rights of rattached list right of the current user
233 233
 	 * @return array
234 234
 	 */
235 235
 	private function getRightsListOfUser(): array
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
 		
97 97
 		$ribs_admin_rights = json_decode(file_get_contents($this->globals->getBaseBundlePath() . "/Resources/json/ribsadmin_rights.json"));
98 98
 		$modules_rights = $this->module->getModuleRights();
99
-		$ribs_admin_rights = (object)array_merge((array)$ribs_admin_rights, (array)$modules_rights);
99
+		$ribs_admin_rights = (object) array_merge((array) $ribs_admin_rights, (array) $modules_rights);
100 100
 
101 101
         if ($this->testIsOpenUrl($route)) {
102 102
             return;
Please login to merge, or discard this patch.
Form/Version.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -11,10 +11,10 @@  discard block
 block discarded – undo
11 11
 
12 12
 class Version extends AbstractType
13 13
 {
14
-    /**
15
-     * @param FormBuilderInterface $builder
16
-     * @param array $options
17
-     */
14
+				/**
15
+				 * @param FormBuilderInterface $builder
16
+				 * @param array $options
17
+				 */
18 18
 	public function buildForm(FormBuilderInterface $builder, array $options)
19 19
 	{
20 20
 		$builder
@@ -26,34 +26,34 @@  discard block
 block discarded – undo
26 26
 				"label" => "Project url",
27 27
 				"required" => true
28 28
 			])
29
-            ->add("packageName", TextType::class, [
30
-                "label" => "Package name",
31
-                "required" => true
32
-            ])
33
-            ->add("checkVersionUrl", TextType::class, [
34
-                "label" => "Check version url",
35
-                "required" => true
36
-            ])
37
-            ->add("composerLockUrl", TextType::class, [
38
-                "label" => "Check composer.lock url",
39
-                "required" => true
40
-            ])
41
-            ->add('isLocal', CheckboxType::class, [
42
-                'label' => 'Is local project',
43
-                'attr' => [
44
-                    'class' => 'ribs-checkbox switched'
45
-                ],
46
-                'required' => false
47
-            ])
48
-            ->add('submit', SubmitType::class, [
49
-                'label' => 'Validate',
50
-                'attr' => []
51
-            ]);
29
+												->add("packageName", TextType::class, [
30
+																"label" => "Package name",
31
+																"required" => true
32
+												])
33
+												->add("checkVersionUrl", TextType::class, [
34
+																"label" => "Check version url",
35
+																"required" => true
36
+												])
37
+												->add("composerLockUrl", TextType::class, [
38
+																"label" => "Check composer.lock url",
39
+																"required" => true
40
+												])
41
+												->add('isLocal', CheckboxType::class, [
42
+																'label' => 'Is local project',
43
+																'attr' => [
44
+																				'class' => 'ribs-checkbox switched'
45
+																],
46
+																'required' => false
47
+												])
48
+												->add('submit', SubmitType::class, [
49
+																'label' => 'Validate',
50
+																'attr' => []
51
+												]);
52 52
 	}
53 53
 
54
-    /**
55
-     * @param OptionsResolver $resolver
56
-     */
54
+				/**
55
+				 * @param OptionsResolver $resolver
56
+				 */
57 57
 	public function configureOptions(OptionsResolver $resolver)
58 58
 	{
59 59
 		$resolver->setDefaults([
Please login to merge, or discard this patch.
Controller/VersionController.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -15,135 +15,135 @@
 block discarded – undo
15 15
 
16 16
 class VersionController extends AbstractController
17 17
 {
18
-    /**
19
-     * @Route("/versions/", name="ribsadmin_versions")
20
-     * @param EntityManagerInterface $em
21
-     * @return Response
22
-     */
23
-    public function index(EntityManagerInterface $em): Response
24
-    {
25
-        $versions = $em->getRepository(Version::class)->findAll();
18
+				/**
19
+				 * @Route("/versions/", name="ribsadmin_versions")
20
+				 * @param EntityManagerInterface $em
21
+				 * @return Response
22
+				 */
23
+				public function index(EntityManagerInterface $em): Response
24
+				{
25
+								$versions = $em->getRepository(Version::class)->findAll();
26 26
         
27
-        return $this->render("@RibsAdmin/versions/list.html.twig", ["verions" => $versions]);
28
-    }
29
-
30
-    /**
31
-     * @Route("/versions/create/", name="ribsadmin_versions_create")
32
-     * @Route("/versions/show/{guid}", name="ribsadmin_versions_show")
33
-     * @Route("/versions/edit/{guid}", name="ribsadmin_versions_edit")
34
-     * @param Request $request
35
-     * @param EntityManagerInterface $em
36
-     * @param string|null $guid
37
-     * @return Response
38
-     */
39
-    public function edit(Request $request, EntityManagerInterface $em, string $guid = null): Response
40
-    {
41
-        if (!$guid) {
42
-            $version = new Version();
43
-            $text = "created";
44
-        } else {
45
-            $version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]);
46
-            $text = "edited";
47
-        }
48
-
49
-        $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Version::class, $version);
50
-        $form->handleRequest($request);
51
-
52
-        if ($form->isSubmitted() && $form->isValid()) {
53
-            /** @var Version $data */
54
-            $data = $form->getData();
55
-            $em->persist($data);
56
-            $em->flush();
57
-            $this->addFlash("success-flash", "Version " . $data->getProjectName() . " was " . $text);
58
-
59
-            return $this->redirectToRoute("ribsadmin_versions");
60
-        }
61
-
62
-        return $this->render("@RibsAdmin/versions/edit.html.twig", [
63
-            "form" => $form->createView(),
64
-            "form_errors" => $form->getErrors(),
65
-            "version" => $version
66
-        ]);
67
-    }
68
-
69
-    /**
70
-     * @Route("/versions/delete/{guid}", name="ribsadmin_versions_delete")
71
-     * @param EntityManagerInterface $em
72
-     * @param string $guid
73
-     * @return RedirectResponse
74
-     */
75
-    public function delete(EntityManagerInterface $em, string $guid): RedirectResponse
76
-    {
77
-        $version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]);
78
-
79
-        if ($version) {
80
-            $em->remove($version);
81
-            $em->flush();
82
-            $this->addFlash("success-flash", "The project version was deleted");
83
-        } else {
84
-            $this->addFlash("error-flash", "The project version was not found");
85
-        }
86
-
87
-        return $this->redirectToRoute("ribsadmin_versions");
88
-    }
89
-
90
-    /**
91
-     * @Route("/versions/update/{guid}", name="ribsadmin_versions_update")
92
-     * @param EntityManagerInterface $em
93
-     * @param \PiouPiou\RibsAdminBundle\Service\Version $version
94
-     * @param string $guid
95
-     * @return RedirectResponse
96
-     */
97
-    public function updateVersion(EntityManagerInterface $em, \PiouPiou\RibsAdminBundle\Service\Version $version, string $guid): RedirectResponse
98
-    {
99
-        $version_entity = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]);
100
-
101
-        if ($version_entity) {
102
-            $version->setVersionEntity($version_entity);
103
-            $version->save($version_entity->getPackageName());
104
-
105
-            $this->addFlash("success-flash", "The project version was updated");
106
-        } else {
107
-            $this->addFlash("error-flash", "The project version was not found");
108
-        }
109
-
110
-        return $this->redirectToRoute("ribsadmin_versions");
111
-    }
112
-
113
-    /**
114
-     * @Route("/versions/send-version/{package_name}", name="ribsadmin_versions_send", requirements={"package_name"=".+"})
115
-     * @param EntityManagerInterface $em
116
-     * @param \PiouPiou\RibsAdminBundle\Service\Version $version
117
-     * @param string $package_name
118
-     * @return mixed|null
119
-     * @throws Exception
120
-     */
121
-    public function sendPackageInformations(EntityManagerInterface $em, \PiouPiou\RibsAdminBundle\Service\Version $version, string $package_name): JsonResponse
122
-    {
123
-        $version_entity = $em->getRepository(Version::class)->findOneBy(["package_name" => $package_name]);
124
-
125
-        if ($version_entity) {
126
-            $version->setVersionEntity($version_entity);
127
-        }
128
-
129
-        return new JsonResponse([
130
-            "version" => $version->getVersion($package_name),
131
-            "version_date" => $version->getVersionDate($package_name)
132
-        ]);
133
-    }
134
-
135
-    /**
136
-     * @Route("/versions/send-composer-lock/", name="ribsadmin_versions_send_composer_lock")
137
-     * @return JsonResponse
138
-     */
139
-    public function sendComposerJson(): JsonResponse
140
-    {
141
-        $composer_lock = file_get_contents('../composer.lock');
142
-
143
-        if ($composer_lock) {
144
-            $composer_lock = json_decode($composer_lock);
145
-        }
146
-
147
-        return new JsonResponse($composer_lock);
148
-    }
27
+								return $this->render("@RibsAdmin/versions/list.html.twig", ["verions" => $versions]);
28
+				}
29
+
30
+				/**
31
+				 * @Route("/versions/create/", name="ribsadmin_versions_create")
32
+				 * @Route("/versions/show/{guid}", name="ribsadmin_versions_show")
33
+				 * @Route("/versions/edit/{guid}", name="ribsadmin_versions_edit")
34
+				 * @param Request $request
35
+				 * @param EntityManagerInterface $em
36
+				 * @param string|null $guid
37
+				 * @return Response
38
+				 */
39
+				public function edit(Request $request, EntityManagerInterface $em, string $guid = null): Response
40
+				{
41
+								if (!$guid) {
42
+												$version = new Version();
43
+												$text = "created";
44
+								} else {
45
+												$version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]);
46
+												$text = "edited";
47
+								}
48
+
49
+								$form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Version::class, $version);
50
+								$form->handleRequest($request);
51
+
52
+								if ($form->isSubmitted() && $form->isValid()) {
53
+												/** @var Version $data */
54
+												$data = $form->getData();
55
+												$em->persist($data);
56
+												$em->flush();
57
+												$this->addFlash("success-flash", "Version " . $data->getProjectName() . " was " . $text);
58
+
59
+												return $this->redirectToRoute("ribsadmin_versions");
60
+								}
61
+
62
+								return $this->render("@RibsAdmin/versions/edit.html.twig", [
63
+												"form" => $form->createView(),
64
+												"form_errors" => $form->getErrors(),
65
+												"version" => $version
66
+								]);
67
+				}
68
+
69
+				/**
70
+				 * @Route("/versions/delete/{guid}", name="ribsadmin_versions_delete")
71
+				 * @param EntityManagerInterface $em
72
+				 * @param string $guid
73
+				 * @return RedirectResponse
74
+				 */
75
+				public function delete(EntityManagerInterface $em, string $guid): RedirectResponse
76
+				{
77
+								$version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]);
78
+
79
+								if ($version) {
80
+												$em->remove($version);
81
+												$em->flush();
82
+												$this->addFlash("success-flash", "The project version was deleted");
83
+								} else {
84
+												$this->addFlash("error-flash", "The project version was not found");
85
+								}
86
+
87
+								return $this->redirectToRoute("ribsadmin_versions");
88
+				}
89
+
90
+				/**
91
+				 * @Route("/versions/update/{guid}", name="ribsadmin_versions_update")
92
+				 * @param EntityManagerInterface $em
93
+				 * @param \PiouPiou\RibsAdminBundle\Service\Version $version
94
+				 * @param string $guid
95
+				 * @return RedirectResponse
96
+				 */
97
+				public function updateVersion(EntityManagerInterface $em, \PiouPiou\RibsAdminBundle\Service\Version $version, string $guid): RedirectResponse
98
+				{
99
+								$version_entity = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]);
100
+
101
+								if ($version_entity) {
102
+												$version->setVersionEntity($version_entity);
103
+												$version->save($version_entity->getPackageName());
104
+
105
+												$this->addFlash("success-flash", "The project version was updated");
106
+								} else {
107
+												$this->addFlash("error-flash", "The project version was not found");
108
+								}
109
+
110
+								return $this->redirectToRoute("ribsadmin_versions");
111
+				}
112
+
113
+				/**
114
+				 * @Route("/versions/send-version/{package_name}", name="ribsadmin_versions_send", requirements={"package_name"=".+"})
115
+				 * @param EntityManagerInterface $em
116
+				 * @param \PiouPiou\RibsAdminBundle\Service\Version $version
117
+				 * @param string $package_name
118
+				 * @return mixed|null
119
+				 * @throws Exception
120
+				 */
121
+				public function sendPackageInformations(EntityManagerInterface $em, \PiouPiou\RibsAdminBundle\Service\Version $version, string $package_name): JsonResponse
122
+				{
123
+								$version_entity = $em->getRepository(Version::class)->findOneBy(["package_name" => $package_name]);
124
+
125
+								if ($version_entity) {
126
+												$version->setVersionEntity($version_entity);
127
+								}
128
+
129
+								return new JsonResponse([
130
+												"version" => $version->getVersion($package_name),
131
+												"version_date" => $version->getVersionDate($package_name)
132
+								]);
133
+				}
134
+
135
+				/**
136
+				 * @Route("/versions/send-composer-lock/", name="ribsadmin_versions_send_composer_lock")
137
+				 * @return JsonResponse
138
+				 */
139
+				public function sendComposerJson(): JsonResponse
140
+				{
141
+								$composer_lock = file_get_contents('../composer.lock');
142
+
143
+								if ($composer_lock) {
144
+												$composer_lock = json_decode($composer_lock);
145
+								}
146
+
147
+								return new JsonResponse($composer_lock);
148
+				}
149 149
 }
Please login to merge, or discard this patch.
Entity/Version.php 1 patch
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -15,326 +15,326 @@
 block discarded – undo
15 15
  */
16 16
 class Version
17 17
 {
18
-    use GuidTrait;
19
-    use CreatedUpdatedTrait;
20
-
21
-    /**
22
-     * @var integer
23
-     *
24
-     * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
25
-     * @ORM\Id
26
-     * @ORM\GeneratedValue(strategy="IDENTITY")
27
-     */
28
-    private $id;
29
-
30
-    /**
31
-     * @var string
32
-     *
33
-     * @ORM\Column(name="project_name", type="string", length=255, nullable=false)
34
-     */
35
-    private $project_name;
36
-
37
-    /**
38
-     * @var string
39
-     *
40
-     * @ORM\Column(name="package_name", type="string", length=255, nullable=false)
41
-     */
42
-    private $package_name;
43
-
44
-    /**
45
-     * @var string
46
-     *
47
-     * @ORM\Column(name="project_url", type="string", length=255, nullable=false)
48
-     */
49
-    private $project_url;
50
-
51
-    /**
52
-     * @var string
53
-     *
54
-     * @ORM\Column(name="version", type="string", length=255, nullable=true)
55
-     */
56
-    private $version;
57
-
58
-    /**
59
-     * @var string
60
-     *
61
-     * @ORM\Column(name="last_packagist_version", type="string", length=255, nullable=true)
62
-     */
63
-    private $last_packagist_version;
64
-
65
-    /**
66
-     * @var DateTime
67
-     *
68
-     * @ORM\Column(name="version_date", type="date", nullable=true)
69
-     */
70
-    private $version_date;
71
-
72
-    /**
73
-     * @var DateTime
74
-     *
75
-     * @ORM\Column(name="last_check", type="datetime", nullable=true)
76
-     */
77
-    private $last_check;
78
-
79
-    /**
80
-     * @var string
81
-     *
82
-     * @ORM\Column(name="mode", type="string", length=255, nullable=true)
83
-     */
84
-    private $mode;
18
+				use GuidTrait;
19
+				use CreatedUpdatedTrait;
20
+
21
+				/**
22
+				 * @var integer
23
+				 *
24
+				 * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
25
+				 * @ORM\Id
26
+				 * @ORM\GeneratedValue(strategy="IDENTITY")
27
+				 */
28
+				private $id;
29
+
30
+				/**
31
+				 * @var string
32
+				 *
33
+				 * @ORM\Column(name="project_name", type="string", length=255, nullable=false)
34
+				 */
35
+				private $project_name;
36
+
37
+				/**
38
+				 * @var string
39
+				 *
40
+				 * @ORM\Column(name="package_name", type="string", length=255, nullable=false)
41
+				 */
42
+				private $package_name;
43
+
44
+				/**
45
+				 * @var string
46
+				 *
47
+				 * @ORM\Column(name="project_url", type="string", length=255, nullable=false)
48
+				 */
49
+				private $project_url;
50
+
51
+				/**
52
+				 * @var string
53
+				 *
54
+				 * @ORM\Column(name="version", type="string", length=255, nullable=true)
55
+				 */
56
+				private $version;
57
+
58
+				/**
59
+				 * @var string
60
+				 *
61
+				 * @ORM\Column(name="last_packagist_version", type="string", length=255, nullable=true)
62
+				 */
63
+				private $last_packagist_version;
64
+
65
+				/**
66
+				 * @var DateTime
67
+				 *
68
+				 * @ORM\Column(name="version_date", type="date", nullable=true)
69
+				 */
70
+				private $version_date;
71
+
72
+				/**
73
+				 * @var DateTime
74
+				 *
75
+				 * @ORM\Column(name="last_check", type="datetime", nullable=true)
76
+				 */
77
+				private $last_check;
78
+
79
+				/**
80
+				 * @var string
81
+				 *
82
+				 * @ORM\Column(name="mode", type="string", length=255, nullable=true)
83
+				 */
84
+				private $mode;
85 85
 	
86 86
 	/**
87 87
 	 * @var string
88 88
 	 *
89 89
 	 * @ORM\Column(name="check_version_url", type="string", length=255, nullable=false)
90 90
 	 */
91
-    private $check_version_url;
92
-
93
-    /**
94
-     * @var string
95
-     *
96
-     * @ORM\Column(name="composer_lock_url", type="string", length=255, nullable=false)
97
-     */
98
-    private $composer_lock_url;
99
-
100
-    /**
101
-     * @var boolean
102
-     *
103
-     * @ORM\Column(name="is_local", type="boolean", nullable=false, options={"default": false}))
104
-     */
105
-    private $is_local;
106
-
107
-    /**
108
-     * @return int
109
-     */
110
-    public function getId(): int
111
-    {
112
-        return $this->id;
113
-    }
114
-
115
-    /**
116
-     * @param int $id
117
-     * @return Version
118
-     */
119
-    public function setId(int $id): self
120
-    {
121
-        $this->id = $id;
122
-
123
-        return $this;
124
-    }
125
-
126
-    /**
127
-     * @return string
128
-     */
129
-    public function getProjectName(): ?string
130
-    {
131
-        return $this->project_name;
132
-    }
133
-
134
-    /**
135
-     * @param string $project_name
136
-     * @return Version
137
-     */
138
-    public function setProjectName(string $project_name): self
139
-    {
140
-        $this->project_name = $project_name;
141
-
142
-        return $this;
143
-    }
144
-
145
-    /**
146
-     * @return string
147
-     */
148
-    public function getPackageName(): ?string
149
-    {
150
-        return $this->package_name;
151
-    }
152
-
153
-    /**
154
-     * @param string $package_name
155
-     * @return Version
156
-     */
157
-    public function setPackageName(string $package_name): self
158
-    {
159
-        $this->package_name = $package_name;
160
-
161
-        return $this;
162
-    }
163
-
164
-    /**
165
-     * @return string
166
-     */
167
-    public function getProjectUrl(): ?string
168
-    {
169
-        return $this->project_url;
170
-    }
171
-
172
-    /**
173
-     * @param string $project_url
174
-     * @return Version
175
-     */
176
-    public function setProjectUrl(string $project_url): self
177
-    {
178
-        $this->project_url = $project_url;
179
-
180
-        return $this;
181
-    }
182
-
183
-    /**
184
-     * @return string
185
-     */
186
-    public function getVersion(): ?string
187
-    {
188
-        return $this->version;
189
-    }
190
-
191
-    /**
192
-     * @param string $version
193
-     * @return Version
194
-     */
195
-    public function setVersion(string $version): self
196
-    {
197
-        $this->version = $version;
198
-
199
-        return $this;
200
-    }
201
-
202
-    /**
203
-     * @return string
204
-     */
205
-    public function getLastPackagistVersion(): ?string
206
-    {
207
-        return $this->last_packagist_version;
208
-    }
209
-
210
-    /**
211
-     * @param string $last_packagist_version
212
-     * @return Version
213
-     */
214
-    public function setLastPackagistVersion(string $last_packagist_version): self
215
-    {
216
-        $this->last_packagist_version = $last_packagist_version;
217
-
218
-        return $this;
219
-    }
220
-
221
-    /**
222
-     * @return DateTime
223
-     */
224
-    public function getVersionDate(): ?DateTime
225
-    {
226
-        return $this->version_date;
227
-    }
228
-
229
-    /**
230
-     * @param DateTime $version_date
231
-     * @return Version
232
-     */
233
-    public function setVersionDate(DateTime $version_date): self
234
-    {
235
-        $this->version_date = $version_date;
236
-
237
-        return $this;
238
-    }
239
-
240
-    /**
241
-     * @return DateTime
242
-     */
243
-    public function getLastCheck(): ?DateTime
244
-    {
245
-        return $this->last_check;
246
-    }
247
-
248
-    /**
249
-     * @param DateTime $last_check
250
-     * @return Version
251
-     */
252
-    public function setLastCheck(DateTime $last_check): self
253
-    {
254
-        $this->last_check = $last_check;
255
-
256
-        return $this;
257
-    }
258
-
259
-    /**
260
-     * @return string
261
-     */
262
-    public function getMode(): ?string
263
-    {
264
-        return $this->mode;
265
-    }
266
-
267
-    /**
268
-     * @param string $mode
269
-     * @return Version
270
-     */
271
-    public function setMode(string $mode): self
272
-    {
273
-        $this->mode = $mode;
274
-
275
-        return $this;
276
-    }
277
-
278
-    /**
279
-     * @return string
280
-     */
281
-    public function getCheckVersionUrl(): ?string
282
-    {
283
-        return $this->check_version_url;
284
-    }
285
-
286
-    /**
287
-     * @param string $check_version_url
288
-     * @return Version
289
-     */
290
-    public function setCheckVersionUrl(string $check_version_url): self
291
-    {
292
-        $this->check_version_url = $check_version_url;
293
-
294
-        return $this;
295
-    }
296
-
297
-    /**
298
-     * @return string
299
-     */
300
-    public function getComposerLockUrl(): ?string
301
-    {
302
-        return $this->composer_lock_url;
303
-    }
304
-
305
-    /**
306
-     * @param string $composer_lock_url
307
-     * @return Version
308
-     */
309
-    public function setComposerLockUrl(string $composer_lock_url): self
310
-    {
311
-        $this->composer_lock_url = $composer_lock_url;
312
-
313
-        return $this;
314
-    }
315
-
316
-    /**
317
-     * @return bool
318
-     */
319
-    public function isIsLocal(): bool
320
-    {
321
-        return $this->is_local;
322
-    }
323
-
324
-    /**
325
-     * @param bool $is_local
326
-     * @return Version
327
-     */
328
-    public function setIsLocal(bool $is_local): self
329
-    {
330
-        $this->is_local = $is_local;
331
-
332
-        return $this;
333
-    }
334
-
335
-    public function getFormattedIsLocal()
336
-    {
337
-        return $this->isIsLocal() ? "Yes" : "No";
338
-    }
91
+				private $check_version_url;
92
+
93
+				/**
94
+				 * @var string
95
+				 *
96
+				 * @ORM\Column(name="composer_lock_url", type="string", length=255, nullable=false)
97
+				 */
98
+				private $composer_lock_url;
99
+
100
+				/**
101
+				 * @var boolean
102
+				 *
103
+				 * @ORM\Column(name="is_local", type="boolean", nullable=false, options={"default": false}))
104
+				 */
105
+				private $is_local;
106
+
107
+				/**
108
+				 * @return int
109
+				 */
110
+				public function getId(): int
111
+				{
112
+								return $this->id;
113
+				}
114
+
115
+				/**
116
+				 * @param int $id
117
+				 * @return Version
118
+				 */
119
+				public function setId(int $id): self
120
+				{
121
+								$this->id = $id;
122
+
123
+								return $this;
124
+				}
125
+
126
+				/**
127
+				 * @return string
128
+				 */
129
+				public function getProjectName(): ?string
130
+				{
131
+								return $this->project_name;
132
+				}
133
+
134
+				/**
135
+				 * @param string $project_name
136
+				 * @return Version
137
+				 */
138
+				public function setProjectName(string $project_name): self
139
+				{
140
+								$this->project_name = $project_name;
141
+
142
+								return $this;
143
+				}
144
+
145
+				/**
146
+				 * @return string
147
+				 */
148
+				public function getPackageName(): ?string
149
+				{
150
+								return $this->package_name;
151
+				}
152
+
153
+				/**
154
+				 * @param string $package_name
155
+				 * @return Version
156
+				 */
157
+				public function setPackageName(string $package_name): self
158
+				{
159
+								$this->package_name = $package_name;
160
+
161
+								return $this;
162
+				}
163
+
164
+				/**
165
+				 * @return string
166
+				 */
167
+				public function getProjectUrl(): ?string
168
+				{
169
+								return $this->project_url;
170
+				}
171
+
172
+				/**
173
+				 * @param string $project_url
174
+				 * @return Version
175
+				 */
176
+				public function setProjectUrl(string $project_url): self
177
+				{
178
+								$this->project_url = $project_url;
179
+
180
+								return $this;
181
+				}
182
+
183
+				/**
184
+				 * @return string
185
+				 */
186
+				public function getVersion(): ?string
187
+				{
188
+								return $this->version;
189
+				}
190
+
191
+				/**
192
+				 * @param string $version
193
+				 * @return Version
194
+				 */
195
+				public function setVersion(string $version): self
196
+				{
197
+								$this->version = $version;
198
+
199
+								return $this;
200
+				}
201
+
202
+				/**
203
+				 * @return string
204
+				 */
205
+				public function getLastPackagistVersion(): ?string
206
+				{
207
+								return $this->last_packagist_version;
208
+				}
209
+
210
+				/**
211
+				 * @param string $last_packagist_version
212
+				 * @return Version
213
+				 */
214
+				public function setLastPackagistVersion(string $last_packagist_version): self
215
+				{
216
+								$this->last_packagist_version = $last_packagist_version;
217
+
218
+								return $this;
219
+				}
220
+
221
+				/**
222
+				 * @return DateTime
223
+				 */
224
+				public function getVersionDate(): ?DateTime
225
+				{
226
+								return $this->version_date;
227
+				}
228
+
229
+				/**
230
+				 * @param DateTime $version_date
231
+				 * @return Version
232
+				 */
233
+				public function setVersionDate(DateTime $version_date): self
234
+				{
235
+								$this->version_date = $version_date;
236
+
237
+								return $this;
238
+				}
239
+
240
+				/**
241
+				 * @return DateTime
242
+				 */
243
+				public function getLastCheck(): ?DateTime
244
+				{
245
+								return $this->last_check;
246
+				}
247
+
248
+				/**
249
+				 * @param DateTime $last_check
250
+				 * @return Version
251
+				 */
252
+				public function setLastCheck(DateTime $last_check): self
253
+				{
254
+								$this->last_check = $last_check;
255
+
256
+								return $this;
257
+				}
258
+
259
+				/**
260
+				 * @return string
261
+				 */
262
+				public function getMode(): ?string
263
+				{
264
+								return $this->mode;
265
+				}
266
+
267
+				/**
268
+				 * @param string $mode
269
+				 * @return Version
270
+				 */
271
+				public function setMode(string $mode): self
272
+				{
273
+								$this->mode = $mode;
274
+
275
+								return $this;
276
+				}
277
+
278
+				/**
279
+				 * @return string
280
+				 */
281
+				public function getCheckVersionUrl(): ?string
282
+				{
283
+								return $this->check_version_url;
284
+				}
285
+
286
+				/**
287
+				 * @param string $check_version_url
288
+				 * @return Version
289
+				 */
290
+				public function setCheckVersionUrl(string $check_version_url): self
291
+				{
292
+								$this->check_version_url = $check_version_url;
293
+
294
+								return $this;
295
+				}
296
+
297
+				/**
298
+				 * @return string
299
+				 */
300
+				public function getComposerLockUrl(): ?string
301
+				{
302
+								return $this->composer_lock_url;
303
+				}
304
+
305
+				/**
306
+				 * @param string $composer_lock_url
307
+				 * @return Version
308
+				 */
309
+				public function setComposerLockUrl(string $composer_lock_url): self
310
+				{
311
+								$this->composer_lock_url = $composer_lock_url;
312
+
313
+								return $this;
314
+				}
315
+
316
+				/**
317
+				 * @return bool
318
+				 */
319
+				public function isIsLocal(): bool
320
+				{
321
+								return $this->is_local;
322
+				}
323
+
324
+				/**
325
+				 * @param bool $is_local
326
+				 * @return Version
327
+				 */
328
+				public function setIsLocal(bool $is_local): self
329
+				{
330
+								$this->is_local = $is_local;
331
+
332
+								return $this;
333
+				}
334
+
335
+				public function getFormattedIsLocal()
336
+				{
337
+								return $this->isIsLocal() ? "Yes" : "No";
338
+				}
339 339
 }
340 340
 
Please login to merge, or discard this patch.