@@ -14,125 +14,125 @@ |
||
14 | 14 | |
15 | 15 | class UploaderController extends AbstractController |
16 | 16 | { |
17 | - /** |
|
18 | - * @Route("/upload", name="ribsadmin_upload") |
|
19 | - * @param Request $request |
|
20 | - * @param ParameterBagInterface $parameter |
|
21 | - * @return JsonResponse |
|
22 | - * @throws Exception |
|
23 | - */ |
|
24 | - public function upload(Request $request, ParameterBagInterface $parameter): JsonResponse |
|
25 | - { |
|
26 | - $success = false; |
|
27 | - $new_filename = null; |
|
28 | - $file = null; |
|
29 | - $upload_dir = null; |
|
30 | - |
|
31 | - if ($request->files && $request->files->has("file")) { |
|
32 | - $upload_dir = $parameter->get("ribs_admin.upload_dir"); |
|
33 | - /** @var UploadedFile $file */ |
|
34 | - $file = $request->files->get("file"); |
|
35 | - $date = new \DateTime(); |
|
36 | - $extension = explode(".", $file->getFilename()); |
|
37 | - $new_filename = uniqid() . "-" . $date->getTimestamp() . "." . end($extension); |
|
38 | - |
|
39 | - if (!is_dir($upload_dir)) { |
|
40 | - $this->createRecursiveDirFromRoot($upload_dir); |
|
41 | - } |
|
42 | - |
|
43 | - if ($file->move($upload_dir, $new_filename)) { |
|
44 | - $success = true; |
|
45 | - } |
|
46 | - } |
|
47 | - |
|
48 | - return new JsonResponse([ |
|
49 | - "original_filename" => $file ? $file->getClientOriginalName() : null, |
|
50 | - "new_filename" => $new_filename, |
|
51 | - "file_path" => $upload_dir . "/" . $new_filename, |
|
52 | - "success" => $success |
|
53 | - ]); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @Route("/delete-uploaded-file", name="ribsadmin_delete_uploaded_file") |
|
58 | - * @param Request $request |
|
59 | - * @param ParameterBagInterface $parameter |
|
60 | - * @return JsonResponse |
|
61 | - */ |
|
62 | - public function deleteUploadedFile(Request $request, ParameterBagInterface $parameter): JsonResponse |
|
63 | - { |
|
64 | - $success = false; |
|
65 | - if ($request->get("file_path") && $request->get("file_name")) { |
|
66 | - $fs = new Filesystem(); |
|
67 | - $upload_dir = $parameter->get("ribs_admin.upload_dir"); |
|
68 | - |
|
69 | - if (is_file($request->get("file_path"))) { |
|
70 | - $fs->remove($request->get("file_path")); |
|
71 | - } elseif (is_file($upload_dir . "/" . $request->get("file_name"))) { |
|
72 | - $fs->remove($upload_dir . "/" . $request->get("file_name")); |
|
73 | - } |
|
74 | - $success = true; |
|
75 | - } |
|
76 | - |
|
77 | - return new JsonResponse([ |
|
78 | - "success" => $success |
|
79 | - ]); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @Route("/retrieve-uploaded-files", name="ribsadmin_retrieve_uploaded_file") |
|
84 | - * @param Request $request |
|
85 | - * @param ParameterBagInterface $parameter |
|
86 | - * @return JsonResponse |
|
87 | - */ |
|
88 | - public function retrieveUploadedFile(Request $request, ParameterBagInterface $parameter): JsonResponse |
|
89 | - { |
|
90 | - $success = true; |
|
91 | - $fs = new Filesystem(); |
|
92 | - $finder = new Finder(); |
|
93 | - $finder->files()->in($parameter->get("ribs_admin.upload_dir")); |
|
94 | - $files = []; |
|
95 | - $index = 0; |
|
96 | - |
|
97 | - foreach ($finder as $file) { |
|
98 | - $files[] = [ |
|
99 | - "file_path" => $parameter->get("ribs_admin.base_upload_url") . $file->getFilename(), |
|
100 | - "filename" => $file->getFilename(), |
|
101 | - "index" => $index |
|
102 | - ]; |
|
103 | - |
|
104 | - $index++; |
|
105 | - } |
|
106 | - |
|
107 | - return new JsonResponse([ |
|
108 | - "success" => $success, |
|
109 | - "files" => $files |
|
110 | - ]); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * method that create a tree of folders on each slash |
|
115 | - * @param $path |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - private function createRecursiveDirFromRoot($path) |
|
119 | - { |
|
120 | - $fs = new Filesystem(); |
|
121 | - $new_path = $path; |
|
122 | - $folders = explode("/", $path); |
|
123 | - |
|
124 | - foreach ($folders as $index => $folder) { |
|
125 | - $new_path .= $folder; |
|
126 | - |
|
127 | - if (!$fs->exists($new_path)) { |
|
128 | - $fs->mkdir($new_path); |
|
129 | - } |
|
130 | - |
|
131 | - if ($index + 1 < count($folders)) { |
|
132 | - $new_path .= "/"; |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - return $new_path; |
|
137 | - } |
|
17 | + /** |
|
18 | + * @Route("/upload", name="ribsadmin_upload") |
|
19 | + * @param Request $request |
|
20 | + * @param ParameterBagInterface $parameter |
|
21 | + * @return JsonResponse |
|
22 | + * @throws Exception |
|
23 | + */ |
|
24 | + public function upload(Request $request, ParameterBagInterface $parameter): JsonResponse |
|
25 | + { |
|
26 | + $success = false; |
|
27 | + $new_filename = null; |
|
28 | + $file = null; |
|
29 | + $upload_dir = null; |
|
30 | + |
|
31 | + if ($request->files && $request->files->has("file")) { |
|
32 | + $upload_dir = $parameter->get("ribs_admin.upload_dir"); |
|
33 | + /** @var UploadedFile $file */ |
|
34 | + $file = $request->files->get("file"); |
|
35 | + $date = new \DateTime(); |
|
36 | + $extension = explode(".", $file->getFilename()); |
|
37 | + $new_filename = uniqid() . "-" . $date->getTimestamp() . "." . end($extension); |
|
38 | + |
|
39 | + if (!is_dir($upload_dir)) { |
|
40 | + $this->createRecursiveDirFromRoot($upload_dir); |
|
41 | + } |
|
42 | + |
|
43 | + if ($file->move($upload_dir, $new_filename)) { |
|
44 | + $success = true; |
|
45 | + } |
|
46 | + } |
|
47 | + |
|
48 | + return new JsonResponse([ |
|
49 | + "original_filename" => $file ? $file->getClientOriginalName() : null, |
|
50 | + "new_filename" => $new_filename, |
|
51 | + "file_path" => $upload_dir . "/" . $new_filename, |
|
52 | + "success" => $success |
|
53 | + ]); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @Route("/delete-uploaded-file", name="ribsadmin_delete_uploaded_file") |
|
58 | + * @param Request $request |
|
59 | + * @param ParameterBagInterface $parameter |
|
60 | + * @return JsonResponse |
|
61 | + */ |
|
62 | + public function deleteUploadedFile(Request $request, ParameterBagInterface $parameter): JsonResponse |
|
63 | + { |
|
64 | + $success = false; |
|
65 | + if ($request->get("file_path") && $request->get("file_name")) { |
|
66 | + $fs = new Filesystem(); |
|
67 | + $upload_dir = $parameter->get("ribs_admin.upload_dir"); |
|
68 | + |
|
69 | + if (is_file($request->get("file_path"))) { |
|
70 | + $fs->remove($request->get("file_path")); |
|
71 | + } elseif (is_file($upload_dir . "/" . $request->get("file_name"))) { |
|
72 | + $fs->remove($upload_dir . "/" . $request->get("file_name")); |
|
73 | + } |
|
74 | + $success = true; |
|
75 | + } |
|
76 | + |
|
77 | + return new JsonResponse([ |
|
78 | + "success" => $success |
|
79 | + ]); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @Route("/retrieve-uploaded-files", name="ribsadmin_retrieve_uploaded_file") |
|
84 | + * @param Request $request |
|
85 | + * @param ParameterBagInterface $parameter |
|
86 | + * @return JsonResponse |
|
87 | + */ |
|
88 | + public function retrieveUploadedFile(Request $request, ParameterBagInterface $parameter): JsonResponse |
|
89 | + { |
|
90 | + $success = true; |
|
91 | + $fs = new Filesystem(); |
|
92 | + $finder = new Finder(); |
|
93 | + $finder->files()->in($parameter->get("ribs_admin.upload_dir")); |
|
94 | + $files = []; |
|
95 | + $index = 0; |
|
96 | + |
|
97 | + foreach ($finder as $file) { |
|
98 | + $files[] = [ |
|
99 | + "file_path" => $parameter->get("ribs_admin.base_upload_url") . $file->getFilename(), |
|
100 | + "filename" => $file->getFilename(), |
|
101 | + "index" => $index |
|
102 | + ]; |
|
103 | + |
|
104 | + $index++; |
|
105 | + } |
|
106 | + |
|
107 | + return new JsonResponse([ |
|
108 | + "success" => $success, |
|
109 | + "files" => $files |
|
110 | + ]); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * method that create a tree of folders on each slash |
|
115 | + * @param $path |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + private function createRecursiveDirFromRoot($path) |
|
119 | + { |
|
120 | + $fs = new Filesystem(); |
|
121 | + $new_path = $path; |
|
122 | + $folders = explode("/", $path); |
|
123 | + |
|
124 | + foreach ($folders as $index => $folder) { |
|
125 | + $new_path .= $folder; |
|
126 | + |
|
127 | + if (!$fs->exists($new_path)) { |
|
128 | + $fs->mkdir($new_path); |
|
129 | + } |
|
130 | + |
|
131 | + if ($index + 1 < count($folders)) { |
|
132 | + $new_path .= "/"; |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + return $new_path; |
|
137 | + } |
|
138 | 138 | } |
@@ -13,120 +13,120 @@ |
||
13 | 13 | |
14 | 14 | class AccessRightsController extends AbstractController |
15 | 15 | { |
16 | - /** |
|
17 | - * @Route("/access-rights-management/", name="ribsadmin_access_rights") |
|
18 | - * @return Response |
|
19 | - */ |
|
20 | - public function list(): Response |
|
21 | - { |
|
22 | - $em = $this->getDoctrine()->getManager(); |
|
23 | - $acces_right = $em->getRepository("RibsAdminBundle:AccessRight")->findAll(); |
|
24 | - |
|
25 | - return $this->render("@RibsAdmin/access-rights/list.html.twig", [ |
|
26 | - "access_right" => $acces_right |
|
27 | - ]); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * @Route("/access-rights-management/create/", name="ribsadmin_access_rights_create") |
|
32 | - * @Route("/access-rights-management/show/{guid}", name="ribsadmin_access_rights_show") |
|
33 | - * @Route("/access-rights-management/edit/{guid}", name="ribsadmin_access_rights_edit") |
|
34 | - * @param Request $request |
|
35 | - * @param Globals $globals |
|
36 | - * @param ModuleService $module |
|
37 | - * @param string|null $guid |
|
38 | - * @return Response |
|
39 | - */ |
|
40 | - public function edit(Request $request, Globals $globals, ModuleService $module, string $guid = null): Response |
|
41 | - { |
|
42 | - $em = $this->getDoctrine()->getManager(); |
|
43 | - $list_rights_user = []; |
|
44 | - $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
45 | - |
|
46 | - if ($guid === null) { |
|
47 | - $access_right = new AccessRight(); |
|
48 | - } else { |
|
49 | - $access_right = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]); |
|
50 | - $list_rights_user = explode(",", $access_right->getAccessRights()); |
|
51 | - } |
|
52 | - |
|
53 | - $admins = $em->getRepository("RibsAdminBundle:User")->findBy(["admin" => true, "archived" => false]); |
|
54 | - |
|
55 | - $form = $this->createForm("PiouPiou\RibsAdminBundle\Form\AccessRight", $access_right, ["disabled" => $disabled_form]); |
|
56 | - $form->handleRequest($request); |
|
57 | - |
|
58 | - if ($form->isSubmitted() && $form->isValid()) { |
|
59 | - return $this->handleEditForm($request, $access_right); |
|
60 | - } |
|
61 | - |
|
62 | - return $this->render("@RibsAdmin/access-rights/edit.html.twig", [ |
|
63 | - "access_right" => $access_right, |
|
64 | - "form" => $form->createView(), |
|
65 | - "form_errors" => $form->getErrors(), |
|
66 | - "list_rights_user" => $list_rights_user, |
|
67 | - "admins" => $admins, |
|
68 | - "ribs_admin_rights" => json_decode(file_get_contents($globals->getBaseBundlePath() . "/Resources/json/ribsadmin_rights.json")), |
|
69 | - "modules" => $module->getAllInfosModules(), |
|
70 | - "disabled_form" => $disabled_form |
|
71 | - ]); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @Route("/access-rights-management/delete/{guid}", name="ribsadmin_access_rights_delete") |
|
76 | - * @param string $guid |
|
77 | - * @return RedirectResponse function that delete an access right list |
|
78 | - */ |
|
79 | - public function delete(string $guid): RedirectResponse |
|
80 | - { |
|
81 | - $em = $this->getDoctrine()->getManager(); |
|
82 | - $list = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]); |
|
83 | - |
|
84 | - if ($list) { |
|
85 | - foreach ($list->getUsers() as $user) { |
|
86 | - $user->setAccessRightList(null); |
|
87 | - } |
|
88 | - |
|
89 | - $em->remove($list); |
|
90 | - $em->flush(); |
|
91 | - |
|
92 | - $this->addFlash("success-flash", "The right list was deleted"); |
|
93 | - } else { |
|
94 | - $this->addFlash("error-flash", "The right list wasn't found"); |
|
95 | - } |
|
96 | - |
|
97 | - return $this->redirectToRoute("ribsadmin_access_rights"); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @param Request $request |
|
102 | - * @param AccessRight $access_right |
|
103 | - * @return RedirectResponse function that handle the form request |
|
104 | - */ |
|
105 | - private function handleEditForm(Request $request, AccessRight $access_right): RedirectResponse |
|
106 | - { |
|
107 | - $em = $this->getDoctrine()->getManager(); |
|
108 | - |
|
109 | - if ($request->get("right") === null) { |
|
110 | - $rights = ""; |
|
111 | - } else { |
|
112 | - $rights = implode(",", $request->get("right")); |
|
113 | - } |
|
114 | - |
|
115 | - $access_right->setAccessRights($rights); |
|
116 | - $em->persist($access_right); |
|
117 | - $em->flush(); |
|
118 | - |
|
119 | - $em->getRepository("RibsAdminBundle:AccessRight")->deleteAllUsersList($access_right); |
|
120 | - $admins = $request->get("admins"); |
|
121 | - |
|
122 | - if ($admins !== null) { |
|
123 | - foreach ($admins as $admin) { |
|
124 | - $em->getRepository("RibsAdminBundle:AccessRight")->setAccessRightListUser($access_right->getId(), $admin); |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - $this->addFlash("success-flash", "The right list was correctly edited"); |
|
129 | - |
|
130 | - return $this->redirectToRoute("ribsadmin_access_rights"); |
|
131 | - } |
|
16 | + /** |
|
17 | + * @Route("/access-rights-management/", name="ribsadmin_access_rights") |
|
18 | + * @return Response |
|
19 | + */ |
|
20 | + public function list(): Response |
|
21 | + { |
|
22 | + $em = $this->getDoctrine()->getManager(); |
|
23 | + $acces_right = $em->getRepository("RibsAdminBundle:AccessRight")->findAll(); |
|
24 | + |
|
25 | + return $this->render("@RibsAdmin/access-rights/list.html.twig", [ |
|
26 | + "access_right" => $acces_right |
|
27 | + ]); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * @Route("/access-rights-management/create/", name="ribsadmin_access_rights_create") |
|
32 | + * @Route("/access-rights-management/show/{guid}", name="ribsadmin_access_rights_show") |
|
33 | + * @Route("/access-rights-management/edit/{guid}", name="ribsadmin_access_rights_edit") |
|
34 | + * @param Request $request |
|
35 | + * @param Globals $globals |
|
36 | + * @param ModuleService $module |
|
37 | + * @param string|null $guid |
|
38 | + * @return Response |
|
39 | + */ |
|
40 | + public function edit(Request $request, Globals $globals, ModuleService $module, string $guid = null): Response |
|
41 | + { |
|
42 | + $em = $this->getDoctrine()->getManager(); |
|
43 | + $list_rights_user = []; |
|
44 | + $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
45 | + |
|
46 | + if ($guid === null) { |
|
47 | + $access_right = new AccessRight(); |
|
48 | + } else { |
|
49 | + $access_right = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]); |
|
50 | + $list_rights_user = explode(",", $access_right->getAccessRights()); |
|
51 | + } |
|
52 | + |
|
53 | + $admins = $em->getRepository("RibsAdminBundle:User")->findBy(["admin" => true, "archived" => false]); |
|
54 | + |
|
55 | + $form = $this->createForm("PiouPiou\RibsAdminBundle\Form\AccessRight", $access_right, ["disabled" => $disabled_form]); |
|
56 | + $form->handleRequest($request); |
|
57 | + |
|
58 | + if ($form->isSubmitted() && $form->isValid()) { |
|
59 | + return $this->handleEditForm($request, $access_right); |
|
60 | + } |
|
61 | + |
|
62 | + return $this->render("@RibsAdmin/access-rights/edit.html.twig", [ |
|
63 | + "access_right" => $access_right, |
|
64 | + "form" => $form->createView(), |
|
65 | + "form_errors" => $form->getErrors(), |
|
66 | + "list_rights_user" => $list_rights_user, |
|
67 | + "admins" => $admins, |
|
68 | + "ribs_admin_rights" => json_decode(file_get_contents($globals->getBaseBundlePath() . "/Resources/json/ribsadmin_rights.json")), |
|
69 | + "modules" => $module->getAllInfosModules(), |
|
70 | + "disabled_form" => $disabled_form |
|
71 | + ]); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @Route("/access-rights-management/delete/{guid}", name="ribsadmin_access_rights_delete") |
|
76 | + * @param string $guid |
|
77 | + * @return RedirectResponse function that delete an access right list |
|
78 | + */ |
|
79 | + public function delete(string $guid): RedirectResponse |
|
80 | + { |
|
81 | + $em = $this->getDoctrine()->getManager(); |
|
82 | + $list = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]); |
|
83 | + |
|
84 | + if ($list) { |
|
85 | + foreach ($list->getUsers() as $user) { |
|
86 | + $user->setAccessRightList(null); |
|
87 | + } |
|
88 | + |
|
89 | + $em->remove($list); |
|
90 | + $em->flush(); |
|
91 | + |
|
92 | + $this->addFlash("success-flash", "The right list was deleted"); |
|
93 | + } else { |
|
94 | + $this->addFlash("error-flash", "The right list wasn't found"); |
|
95 | + } |
|
96 | + |
|
97 | + return $this->redirectToRoute("ribsadmin_access_rights"); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @param Request $request |
|
102 | + * @param AccessRight $access_right |
|
103 | + * @return RedirectResponse function that handle the form request |
|
104 | + */ |
|
105 | + private function handleEditForm(Request $request, AccessRight $access_right): RedirectResponse |
|
106 | + { |
|
107 | + $em = $this->getDoctrine()->getManager(); |
|
108 | + |
|
109 | + if ($request->get("right") === null) { |
|
110 | + $rights = ""; |
|
111 | + } else { |
|
112 | + $rights = implode(",", $request->get("right")); |
|
113 | + } |
|
114 | + |
|
115 | + $access_right->setAccessRights($rights); |
|
116 | + $em->persist($access_right); |
|
117 | + $em->flush(); |
|
118 | + |
|
119 | + $em->getRepository("RibsAdminBundle:AccessRight")->deleteAllUsersList($access_right); |
|
120 | + $admins = $request->get("admins"); |
|
121 | + |
|
122 | + if ($admins !== null) { |
|
123 | + foreach ($admins as $admin) { |
|
124 | + $em->getRepository("RibsAdminBundle:AccessRight")->setAccessRightListUser($access_right->getId(), $admin); |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + $this->addFlash("success-flash", "The right list was correctly edited"); |
|
129 | + |
|
130 | + return $this->redirectToRoute("ribsadmin_access_rights"); |
|
131 | + } |
|
132 | 132 | } |
@@ -12,129 +12,129 @@ |
||
12 | 12 | |
13 | 13 | class AccountsController extends AbstractController |
14 | 14 | { |
15 | - /** |
|
16 | - * @Route("/accounts/", name="ribsadmin_accounts") |
|
17 | - * @return Response |
|
18 | - */ |
|
19 | - public function list(): Response |
|
20 | - { |
|
21 | - $em = $this->getDoctrine()->getManager(); |
|
22 | - $current_account = $this->getUser()->getUser(); |
|
23 | - |
|
24 | - $users = $em->getRepository("RibsAdminBundle:Account")->findAllUserArchived($current_account); |
|
25 | - $users_archived = $em->getRepository("RibsAdminBundle:Account")->findAllUserArchived($current_account, true); |
|
26 | - |
|
27 | - return $this->render('@RibsAdmin/accounts/list.html.twig', [ |
|
28 | - "users" => $users, |
|
29 | - "users_archived" => $users_archived |
|
30 | - ]); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @Route("/accounts/create/", name="ribsadmin_accounts_create") |
|
35 | - * @Route("/accounts/show/{guid}", name="ribsadmin_accounts_show") |
|
36 | - * @Route("/accounts/edit/{guid}", name="ribsadmin_accounts_edit") |
|
37 | - * @param Request $request |
|
38 | - * @param string|null $guid |
|
39 | - * @return Response |
|
40 | - */ |
|
41 | - public function edit(Request $request, string $guid = null): Response |
|
42 | - { |
|
43 | - $em = $this->getDoctrine()->getManager(); |
|
44 | - $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
45 | - |
|
46 | - if ($guid === null) { |
|
47 | - $account = new Account(); |
|
48 | - $old_password = null; |
|
49 | - $user = null; |
|
50 | - } else { |
|
51 | - $user = $em->getRepository(User::class)->findOneBy(["guid" => $guid]); |
|
52 | - $account = $em->getRepository(Account::class)->findOneBy(["user" => $user->getId()]); |
|
53 | - $old_password = $account->getPassword(); |
|
54 | - } |
|
55 | - |
|
56 | - $form = $this->createForm("PiouPiou\RibsAdminBundle\Form\Account", $account, ["disabled" => $disabled_form]); |
|
57 | - |
|
58 | - $form->handleRequest($request); |
|
59 | - |
|
60 | - if ($form->isSubmitted() && $form->isValid()) { |
|
61 | - /** |
|
62 | - * @var Account |
|
63 | - */ |
|
64 | - $data = $form->getData(); |
|
65 | - |
|
66 | - $account_exist = $em->getRepository(Account::class)->findOneBy(["username" => $data->getUsername()]); |
|
67 | - |
|
68 | - if ($account_exist && $account_exist === $account) { |
|
69 | - $account_exist = null; |
|
70 | - } |
|
71 | - |
|
72 | - if (!$account_exist) { |
|
73 | - if ($guid === null) { |
|
74 | - $temp_password = $this->get("security.password_encoder")->encodePassword($data, $form->get("password")->getData()); |
|
75 | - $data->setPassword($temp_password); |
|
76 | - } else if ($form->get("password")->getData()) { |
|
77 | - $temp_password = $this->get("security.password_encoder")->encodePassword($data, $form->get("password")->getData()); |
|
78 | - $data->setPassword($temp_password); |
|
79 | - } else { |
|
80 | - $data->setPassword($old_password); |
|
81 | - } |
|
82 | - |
|
83 | - $em->persist($data); |
|
84 | - $em->flush(); |
|
85 | - |
|
86 | - $username = $data->getUser()->getFirstName() . " " . $data->getUser()->getLastName(); |
|
87 | - |
|
88 | - if ($guid === null) { |
|
89 | - $this->addFlash("success-flash", "the account of " . $username . " was created"); |
|
90 | - } else { |
|
91 | - $this->addFlash("success-flash", "the account of " . $username . " was edited"); |
|
92 | - } |
|
93 | - |
|
94 | - return $this->redirectToRoute("ribsadmin_accounts"); |
|
95 | - } else { |
|
96 | - $this->addFlash("error-flash", "An account with username " . $data->getUsername() . " already exist"); |
|
97 | - return $this->redirectToRoute($request->get("_route"), ["guid" => $guid]); |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - return $this->render("@RibsAdmin/accounts/edit.html.twig", [ |
|
102 | - "form" => $form->createView(), |
|
103 | - "form_errors" => $form->getErrors(), |
|
104 | - "user" => $user, |
|
105 | - "disabled_form" => $disabled_form |
|
106 | - ]); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * method to disable or enable a user |
|
111 | - * @Route("/accounts/archive/{guid}/{activate}", name="ribsadmin_accounts_archive") |
|
112 | - * @param string $guid |
|
113 | - * @param bool $activate |
|
114 | - * @return RedirectResponse |
|
115 | - */ |
|
116 | - public function archive(string $guid, bool $activate = false): RedirectResponse |
|
117 | - { |
|
118 | - $em = $this->getDoctrine()->getManager(); |
|
119 | - |
|
120 | - $user = $em->getRepository("RibsAdminBundle:User")->findOneBy(["guid" => $guid]); |
|
121 | - |
|
122 | - if ($user) { |
|
123 | - if ($activate === true) { |
|
124 | - $user->setArchived(false); |
|
125 | - $word = "activated"; |
|
126 | - } else { |
|
127 | - $user->setArchived(true); |
|
128 | - $word = "disabled"; |
|
129 | - } |
|
130 | - |
|
131 | - $em->persist($user); |
|
132 | - $em->flush(); |
|
133 | - |
|
134 | - $this->addFlash("success-flash", "The user " . $user->getFirstname() . " " . $user->getLastname() . |
|
135 | - " was " . $word . " sucessfuly"); |
|
136 | - } |
|
137 | - |
|
138 | - return $this->redirectToRoute("ribsadmin_accounts"); |
|
139 | - } |
|
15 | + /** |
|
16 | + * @Route("/accounts/", name="ribsadmin_accounts") |
|
17 | + * @return Response |
|
18 | + */ |
|
19 | + public function list(): Response |
|
20 | + { |
|
21 | + $em = $this->getDoctrine()->getManager(); |
|
22 | + $current_account = $this->getUser()->getUser(); |
|
23 | + |
|
24 | + $users = $em->getRepository("RibsAdminBundle:Account")->findAllUserArchived($current_account); |
|
25 | + $users_archived = $em->getRepository("RibsAdminBundle:Account")->findAllUserArchived($current_account, true); |
|
26 | + |
|
27 | + return $this->render('@RibsAdmin/accounts/list.html.twig', [ |
|
28 | + "users" => $users, |
|
29 | + "users_archived" => $users_archived |
|
30 | + ]); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @Route("/accounts/create/", name="ribsadmin_accounts_create") |
|
35 | + * @Route("/accounts/show/{guid}", name="ribsadmin_accounts_show") |
|
36 | + * @Route("/accounts/edit/{guid}", name="ribsadmin_accounts_edit") |
|
37 | + * @param Request $request |
|
38 | + * @param string|null $guid |
|
39 | + * @return Response |
|
40 | + */ |
|
41 | + public function edit(Request $request, string $guid = null): Response |
|
42 | + { |
|
43 | + $em = $this->getDoctrine()->getManager(); |
|
44 | + $disabled_form = strpos($request->get("_route"), "_show") ? true : false; |
|
45 | + |
|
46 | + if ($guid === null) { |
|
47 | + $account = new Account(); |
|
48 | + $old_password = null; |
|
49 | + $user = null; |
|
50 | + } else { |
|
51 | + $user = $em->getRepository(User::class)->findOneBy(["guid" => $guid]); |
|
52 | + $account = $em->getRepository(Account::class)->findOneBy(["user" => $user->getId()]); |
|
53 | + $old_password = $account->getPassword(); |
|
54 | + } |
|
55 | + |
|
56 | + $form = $this->createForm("PiouPiou\RibsAdminBundle\Form\Account", $account, ["disabled" => $disabled_form]); |
|
57 | + |
|
58 | + $form->handleRequest($request); |
|
59 | + |
|
60 | + if ($form->isSubmitted() && $form->isValid()) { |
|
61 | + /** |
|
62 | + * @var Account |
|
63 | + */ |
|
64 | + $data = $form->getData(); |
|
65 | + |
|
66 | + $account_exist = $em->getRepository(Account::class)->findOneBy(["username" => $data->getUsername()]); |
|
67 | + |
|
68 | + if ($account_exist && $account_exist === $account) { |
|
69 | + $account_exist = null; |
|
70 | + } |
|
71 | + |
|
72 | + if (!$account_exist) { |
|
73 | + if ($guid === null) { |
|
74 | + $temp_password = $this->get("security.password_encoder")->encodePassword($data, $form->get("password")->getData()); |
|
75 | + $data->setPassword($temp_password); |
|
76 | + } else if ($form->get("password")->getData()) { |
|
77 | + $temp_password = $this->get("security.password_encoder")->encodePassword($data, $form->get("password")->getData()); |
|
78 | + $data->setPassword($temp_password); |
|
79 | + } else { |
|
80 | + $data->setPassword($old_password); |
|
81 | + } |
|
82 | + |
|
83 | + $em->persist($data); |
|
84 | + $em->flush(); |
|
85 | + |
|
86 | + $username = $data->getUser()->getFirstName() . " " . $data->getUser()->getLastName(); |
|
87 | + |
|
88 | + if ($guid === null) { |
|
89 | + $this->addFlash("success-flash", "the account of " . $username . " was created"); |
|
90 | + } else { |
|
91 | + $this->addFlash("success-flash", "the account of " . $username . " was edited"); |
|
92 | + } |
|
93 | + |
|
94 | + return $this->redirectToRoute("ribsadmin_accounts"); |
|
95 | + } else { |
|
96 | + $this->addFlash("error-flash", "An account with username " . $data->getUsername() . " already exist"); |
|
97 | + return $this->redirectToRoute($request->get("_route"), ["guid" => $guid]); |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + return $this->render("@RibsAdmin/accounts/edit.html.twig", [ |
|
102 | + "form" => $form->createView(), |
|
103 | + "form_errors" => $form->getErrors(), |
|
104 | + "user" => $user, |
|
105 | + "disabled_form" => $disabled_form |
|
106 | + ]); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * method to disable or enable a user |
|
111 | + * @Route("/accounts/archive/{guid}/{activate}", name="ribsadmin_accounts_archive") |
|
112 | + * @param string $guid |
|
113 | + * @param bool $activate |
|
114 | + * @return RedirectResponse |
|
115 | + */ |
|
116 | + public function archive(string $guid, bool $activate = false): RedirectResponse |
|
117 | + { |
|
118 | + $em = $this->getDoctrine()->getManager(); |
|
119 | + |
|
120 | + $user = $em->getRepository("RibsAdminBundle:User")->findOneBy(["guid" => $guid]); |
|
121 | + |
|
122 | + if ($user) { |
|
123 | + if ($activate === true) { |
|
124 | + $user->setArchived(false); |
|
125 | + $word = "activated"; |
|
126 | + } else { |
|
127 | + $user->setArchived(true); |
|
128 | + $word = "disabled"; |
|
129 | + } |
|
130 | + |
|
131 | + $em->persist($user); |
|
132 | + $em->flush(); |
|
133 | + |
|
134 | + $this->addFlash("success-flash", "The user " . $user->getFirstname() . " " . $user->getLastname() . |
|
135 | + " was " . $word . " sucessfuly"); |
|
136 | + } |
|
137 | + |
|
138 | + return $this->redirectToRoute("ribsadmin_accounts"); |
|
139 | + } |
|
140 | 140 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | $old_password = $account->getPassword(); |
54 | 54 | } |
55 | 55 | |
56 | - $form = $this->createForm("PiouPiou\RibsAdminBundle\Form\Account", $account, ["disabled" => $disabled_form]); |
|
56 | + $form = $this->createForm("PiouPiou\RibsAdminBundle\Form\Account", $account, ["disabled" => $disabled_form]); |
|
57 | 57 | |
58 | 58 | $form->handleRequest($request); |
59 | 59 |
@@ -7,38 +7,38 @@ |
||
7 | 7 | |
8 | 8 | class NavigationRepository extends EntityRepository |
9 | 9 | { |
10 | - /** |
|
11 | - * function that return all navigation links of pages and modules |
|
12 | - * @return array |
|
13 | - * @throws DBALException |
|
14 | - */ |
|
15 | - public function findAllNavigation(): array |
|
16 | - { |
|
17 | - $query = $this->getEntityManager()->getConnection()->prepare("SELECT p.url, p.title, p.title_tag FROM navigation n |
|
10 | + /** |
|
11 | + * function that return all navigation links of pages and modules |
|
12 | + * @return array |
|
13 | + * @throws DBALException |
|
14 | + */ |
|
15 | + public function findAllNavigation(): array |
|
16 | + { |
|
17 | + $query = $this->getEntityManager()->getConnection()->prepare("SELECT p.url, p.title, p.title_tag FROM navigation n |
|
18 | 18 | LEFT JOIN page p ON n.id_page = p.id AND p.displayed = 1 |
19 | 19 | LEFT JOIN module m ON n.id_module = m.id AND m.displayed = 1 |
20 | 20 | ORDER BY n.order ASC |
21 | 21 | "); |
22 | 22 | |
23 | - $query->execute(); |
|
23 | + $query->execute(); |
|
24 | 24 | |
25 | - return $query->fetchAll(\PDO::FETCH_ASSOC); |
|
26 | - } |
|
25 | + return $query->fetchAll(\PDO::FETCH_ASSOC); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * function that return all navigation links of pages |
|
30 | - * @return array |
|
31 | - * @throws DBALException |
|
32 | - */ |
|
33 | - public function findAllNavigationPage(): array |
|
34 | - { |
|
35 | - $query = $this->getEntityManager()->getConnection()->prepare("SELECT p.id, p.url, p.title, p.title_tag FROM navigation n |
|
28 | + /** |
|
29 | + * function that return all navigation links of pages |
|
30 | + * @return array |
|
31 | + * @throws DBALException |
|
32 | + */ |
|
33 | + public function findAllNavigationPage(): array |
|
34 | + { |
|
35 | + $query = $this->getEntityManager()->getConnection()->prepare("SELECT p.id, p.url, p.title, p.title_tag FROM navigation n |
|
36 | 36 | INNER JOIN page p ON n.id_page = p.id AND p.displayed = 1 |
37 | 37 | ORDER BY n.order ASC |
38 | 38 | "); |
39 | 39 | |
40 | - $query->execute(); |
|
40 | + $query->execute(); |
|
41 | 41 | |
42 | - return $query->fetchAll(\PDO::FETCH_ASSOC); |
|
43 | - } |
|
42 | + return $query->fetchAll(\PDO::FETCH_ASSOC); |
|
43 | + } |
|
44 | 44 | } |
@@ -8,28 +8,28 @@ |
||
8 | 8 | |
9 | 9 | class PageController extends AbstractController |
10 | 10 | { |
11 | - /** |
|
12 | - * @Route("/contents", name="ribsadmin_contents") |
|
13 | - * @return Response |
|
14 | - */ |
|
15 | - public function index(): Response |
|
16 | - { |
|
17 | - $navigation = $this->getDoctrine()->getManager()->getRepository("RibsAdminBundle:Navigation")->findAllNavigationPage(); |
|
11 | + /** |
|
12 | + * @Route("/contents", name="ribsadmin_contents") |
|
13 | + * @return Response |
|
14 | + */ |
|
15 | + public function index(): Response |
|
16 | + { |
|
17 | + $navigation = $this->getDoctrine()->getManager()->getRepository("RibsAdminBundle:Navigation")->findAllNavigationPage(); |
|
18 | 18 | |
19 | - return $this->render('@RibsAdmin/page/index.html.twig', ["navigation" => $navigation]); |
|
20 | - } |
|
19 | + return $this->render('@RibsAdmin/page/index.html.twig', ["navigation" => $navigation]); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @Route("/contents/edit-page/{page_id}", name="ribsadmin_contents_edit_page") |
|
24 | - * @param int $page_id |
|
25 | - * @return Response |
|
26 | - */ |
|
27 | - public function editPage(int $page_id): Response |
|
28 | - { |
|
29 | - $em = $this->getDoctrine()->getManager(); |
|
30 | - $navigation = $em->getRepository("RibsAdminBundle:Navigation")->findAllNavigationPage(); |
|
31 | - $page = $em->getRepository("RibsAdminBundle:Page")->find($page_id); |
|
22 | + /** |
|
23 | + * @Route("/contents/edit-page/{page_id}", name="ribsadmin_contents_edit_page") |
|
24 | + * @param int $page_id |
|
25 | + * @return Response |
|
26 | + */ |
|
27 | + public function editPage(int $page_id): Response |
|
28 | + { |
|
29 | + $em = $this->getDoctrine()->getManager(); |
|
30 | + $navigation = $em->getRepository("RibsAdminBundle:Navigation")->findAllNavigationPage(); |
|
31 | + $page = $em->getRepository("RibsAdminBundle:Page")->find($page_id); |
|
32 | 32 | |
33 | - return $this->render('@RibsAdmin/page/edit-page.html.twig', ["navigation" => $navigation, "page" => $page]); |
|
34 | - } |
|
33 | + return $this->render('@RibsAdmin/page/edit-page.html.twig', ["navigation" => $navigation, "page" => $page]); |
|
34 | + } |
|
35 | 35 | } |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | |
11 | 11 | class Version extends AbstractType |
12 | 12 | { |
13 | - /** |
|
14 | - * @param FormBuilderInterface $builder |
|
15 | - * @param array $options |
|
16 | - */ |
|
13 | + /** |
|
14 | + * @param FormBuilderInterface $builder |
|
15 | + * @param array $options |
|
16 | + */ |
|
17 | 17 | public function buildForm(FormBuilderInterface $builder, array $options) |
18 | 18 | { |
19 | 19 | $builder |
@@ -25,23 +25,23 @@ discard block |
||
25 | 25 | "label" => "Project url", |
26 | 26 | "required" => true |
27 | 27 | ]) |
28 | - ->add("packageName", TextType::class, [ |
|
29 | - "label" => "Package name", |
|
30 | - "required" => true |
|
31 | - ]) |
|
32 | - ->add("checkVersionUrl", TextType::class, [ |
|
33 | - "label" => "Check version url", |
|
34 | - "required" => true |
|
35 | - ]) |
|
36 | - ->add('submit', SubmitType::class, [ |
|
37 | - 'label' => 'Validate', |
|
38 | - 'attr' => [] |
|
39 | - ]); |
|
28 | + ->add("packageName", TextType::class, [ |
|
29 | + "label" => "Package name", |
|
30 | + "required" => true |
|
31 | + ]) |
|
32 | + ->add("checkVersionUrl", TextType::class, [ |
|
33 | + "label" => "Check version url", |
|
34 | + "required" => true |
|
35 | + ]) |
|
36 | + ->add('submit', SubmitType::class, [ |
|
37 | + 'label' => 'Validate', |
|
38 | + 'attr' => [] |
|
39 | + ]); |
|
40 | 40 | } |
41 | 41 | |
42 | - /** |
|
43 | - * @param OptionsResolver $resolver |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @param OptionsResolver $resolver |
|
44 | + */ |
|
45 | 45 | public function configureOptions(OptionsResolver $resolver) |
46 | 46 | { |
47 | 47 | $resolver->setDefaults([ |
@@ -12,134 +12,134 @@ |
||
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 | - * Version constructor. |
|
27 | - * @param EntityManagerInterface $em |
|
28 | - * @param HttpClientInterface $client |
|
29 | - */ |
|
30 | - public function __construct(EntityManagerInterface $em, HttpClientInterface $client) |
|
31 | - { |
|
32 | - $this->em = $em; |
|
33 | - $this->client = $client; |
|
34 | - } |
|
35 | - |
|
36 | - /** |
|
37 | - * @return mixed|null |
|
38 | - */ |
|
39 | - private function getComposerLockJson() |
|
40 | - { |
|
41 | - $composer_lock = file_get_contents('../composer.lock'); |
|
42 | - |
|
43 | - if ($composer_lock) { |
|
44 | - return json_decode($composer_lock, true); |
|
45 | - } |
|
46 | - |
|
47 | - return null; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @param $package_name |
|
52 | - * @return mixed|null |
|
53 | - */ |
|
54 | - private function getPackage($package_name) |
|
55 | - { |
|
56 | - $composer_lock = $this->getComposerLockJson(); |
|
57 | - if ($composer_lock) { |
|
58 | - $packages = $composer_lock["packages"]; |
|
59 | - $key = array_search($package_name, array_column($packages, 'name')); |
|
60 | - |
|
61 | - if ($key) { |
|
62 | - return $packages[$key]; |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - return null; |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * @param $package_name |
|
71 | - * @return mixed|null |
|
72 | - */ |
|
73 | - public function getVersion($package_name) |
|
74 | - { |
|
75 | - return $this->getPackage($package_name) ? $this->getPackage($package_name)["version"] : null; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param $package_name |
|
80 | - * @return mixed|null |
|
81 | - * @throws Exception |
|
82 | - */ |
|
83 | - public function getVersionDate($package_name) |
|
84 | - { |
|
85 | - $string_date = $this->getPackage($package_name) ? explode("T", $this->getPackage($package_name)["time"])[0] : null; |
|
86 | - $version_date = null; |
|
87 | - |
|
88 | - if ($string_date) { |
|
89 | - $version_date = new \DateTime($string_date); |
|
90 | - } |
|
91 | - |
|
92 | - return $version_date; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @param $package_name |
|
97 | - * @return false|int|string|null |
|
98 | - * @throws ClientExceptionInterface |
|
99 | - * @throws RedirectionExceptionInterface |
|
100 | - * @throws ServerExceptionInterface |
|
101 | - * @throws TransportExceptionInterface |
|
102 | - */ |
|
103 | - public function getLastPackagistVersion($package_name) |
|
104 | - { |
|
105 | - if (!strpos($package_name, "/")) { |
|
106 | - return false; |
|
107 | - } |
|
108 | - |
|
109 | - $packgist_url = "https://repo.packagist.org/p/".$package_name.".json"; |
|
110 | - |
|
111 | - $response = $this->client->request("GET", $packgist_url); |
|
112 | - |
|
113 | - if ($response->getStatusCode() == 200) { |
|
114 | - $content = json_decode($response->getContent(), true); |
|
115 | - if (is_array($content) && $content["packages"] && $content["packages"][$package_name]) { |
|
116 | - return array_key_first($content["packages"][$package_name]); |
|
117 | - } |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @param $package_name |
|
123 | - * @throws Exception |
|
124 | - */ |
|
125 | - public function save($package_name) |
|
126 | - { |
|
127 | - $version = $this->em->getRepository(\PiouPiou\RibsAdminBundle\Entity\Version::class)->findOneBy(["package_name" => $package_name]); |
|
128 | - |
|
129 | - if (!$version) { |
|
130 | - $version = new \PiouPiou\RibsAdminBundle\Entity\Version(); |
|
131 | - $version->setProjectName($package_name); |
|
132 | - $version->setPackageName($package_name); |
|
133 | - $version->setProjectUrl($package_name); |
|
134 | - $version->setCheckVersionUrl($package_name); |
|
135 | - } |
|
136 | - |
|
137 | - $version->setVersion($this->getVersion($package_name)); |
|
138 | - $version->setVersionDate($this->getVersionDate($package_name)); |
|
139 | - $version->setLastPackagistVersion($this->getLastPackagistVersion($package_name)); |
|
140 | - $version->setLastCheck(new \DateTime()); |
|
141 | - |
|
142 | - $this->em->persist($version); |
|
143 | - $this->em->flush(); |
|
144 | - } |
|
15 | + /** |
|
16 | + * @var EntityManagerInterface |
|
17 | + */ |
|
18 | + private $em; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var HttpClientInterface |
|
22 | + */ |
|
23 | + private $client; |
|
24 | + |
|
25 | + /** |
|
26 | + * Version constructor. |
|
27 | + * @param EntityManagerInterface $em |
|
28 | + * @param HttpClientInterface $client |
|
29 | + */ |
|
30 | + public function __construct(EntityManagerInterface $em, HttpClientInterface $client) |
|
31 | + { |
|
32 | + $this->em = $em; |
|
33 | + $this->client = $client; |
|
34 | + } |
|
35 | + |
|
36 | + /** |
|
37 | + * @return mixed|null |
|
38 | + */ |
|
39 | + private function getComposerLockJson() |
|
40 | + { |
|
41 | + $composer_lock = file_get_contents('../composer.lock'); |
|
42 | + |
|
43 | + if ($composer_lock) { |
|
44 | + return json_decode($composer_lock, true); |
|
45 | + } |
|
46 | + |
|
47 | + return null; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @param $package_name |
|
52 | + * @return mixed|null |
|
53 | + */ |
|
54 | + private function getPackage($package_name) |
|
55 | + { |
|
56 | + $composer_lock = $this->getComposerLockJson(); |
|
57 | + if ($composer_lock) { |
|
58 | + $packages = $composer_lock["packages"]; |
|
59 | + $key = array_search($package_name, array_column($packages, 'name')); |
|
60 | + |
|
61 | + if ($key) { |
|
62 | + return $packages[$key]; |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + return null; |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * @param $package_name |
|
71 | + * @return mixed|null |
|
72 | + */ |
|
73 | + public function getVersion($package_name) |
|
74 | + { |
|
75 | + return $this->getPackage($package_name) ? $this->getPackage($package_name)["version"] : null; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param $package_name |
|
80 | + * @return mixed|null |
|
81 | + * @throws Exception |
|
82 | + */ |
|
83 | + public function getVersionDate($package_name) |
|
84 | + { |
|
85 | + $string_date = $this->getPackage($package_name) ? explode("T", $this->getPackage($package_name)["time"])[0] : null; |
|
86 | + $version_date = null; |
|
87 | + |
|
88 | + if ($string_date) { |
|
89 | + $version_date = new \DateTime($string_date); |
|
90 | + } |
|
91 | + |
|
92 | + return $version_date; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @param $package_name |
|
97 | + * @return false|int|string|null |
|
98 | + * @throws ClientExceptionInterface |
|
99 | + * @throws RedirectionExceptionInterface |
|
100 | + * @throws ServerExceptionInterface |
|
101 | + * @throws TransportExceptionInterface |
|
102 | + */ |
|
103 | + public function getLastPackagistVersion($package_name) |
|
104 | + { |
|
105 | + if (!strpos($package_name, "/")) { |
|
106 | + return false; |
|
107 | + } |
|
108 | + |
|
109 | + $packgist_url = "https://repo.packagist.org/p/".$package_name.".json"; |
|
110 | + |
|
111 | + $response = $this->client->request("GET", $packgist_url); |
|
112 | + |
|
113 | + if ($response->getStatusCode() == 200) { |
|
114 | + $content = json_decode($response->getContent(), true); |
|
115 | + if (is_array($content) && $content["packages"] && $content["packages"][$package_name]) { |
|
116 | + return array_key_first($content["packages"][$package_name]); |
|
117 | + } |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @param $package_name |
|
123 | + * @throws Exception |
|
124 | + */ |
|
125 | + public function save($package_name) |
|
126 | + { |
|
127 | + $version = $this->em->getRepository(\PiouPiou\RibsAdminBundle\Entity\Version::class)->findOneBy(["package_name" => $package_name]); |
|
128 | + |
|
129 | + if (!$version) { |
|
130 | + $version = new \PiouPiou\RibsAdminBundle\Entity\Version(); |
|
131 | + $version->setProjectName($package_name); |
|
132 | + $version->setPackageName($package_name); |
|
133 | + $version->setProjectUrl($package_name); |
|
134 | + $version->setCheckVersionUrl($package_name); |
|
135 | + } |
|
136 | + |
|
137 | + $version->setVersion($this->getVersion($package_name)); |
|
138 | + $version->setVersionDate($this->getVersionDate($package_name)); |
|
139 | + $version->setLastPackagistVersion($this->getLastPackagistVersion($package_name)); |
|
140 | + $version->setLastCheck(new \DateTime()); |
|
141 | + |
|
142 | + $this->em->persist($version); |
|
143 | + $this->em->flush(); |
|
144 | + } |
|
145 | 145 | } |
@@ -106,7 +106,7 @@ |
||
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | |
109 | - $packgist_url = "https://repo.packagist.org/p/".$package_name.".json"; |
|
109 | + $packgist_url = "https://repo.packagist.org/p/" . $package_name . ".json"; |
|
110 | 110 | |
111 | 111 | $response = $this->client->request("GET", $packgist_url); |
112 | 112 |
@@ -14,111 +14,111 @@ |
||
14 | 14 | |
15 | 15 | class VersionController extends AbstractController |
16 | 16 | { |
17 | - /** |
|
18 | - * @Route("/versions/", name="ribsadmin_versions") |
|
19 | - * @param EntityManagerInterface $em |
|
20 | - * @return Response |
|
21 | - */ |
|
22 | - public function index(EntityManagerInterface $em): Response |
|
23 | - { |
|
24 | - $versions = $em->getRepository(Version::class)->findAll(); |
|
17 | + /** |
|
18 | + * @Route("/versions/", name="ribsadmin_versions") |
|
19 | + * @param EntityManagerInterface $em |
|
20 | + * @return Response |
|
21 | + */ |
|
22 | + public function index(EntityManagerInterface $em): Response |
|
23 | + { |
|
24 | + $versions = $em->getRepository(Version::class)->findAll(); |
|
25 | 25 | |
26 | - return $this->render("@RibsAdmin/versions/list.html.twig", ["verions" => $versions]); |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * @Route("/versions/create/", name="ribsadmin_versions_create") |
|
31 | - * @Route("/versions/show/{guid}", name="ribsadmin_versions_show") |
|
32 | - * @Route("/versions/edit/{guid}", name="ribsadmin_versions_edit") |
|
33 | - * @param Request $request |
|
34 | - * @param EntityManagerInterface $em |
|
35 | - * @param string|null $guid |
|
36 | - * @return Response |
|
37 | - */ |
|
38 | - public function edit(Request $request, EntityManagerInterface $em, string $guid = null): Response |
|
39 | - { |
|
40 | - if (!$guid) { |
|
41 | - $version = new Version(); |
|
42 | - $text = "created"; |
|
43 | - } else { |
|
44 | - $version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]); |
|
45 | - $text = "edited"; |
|
46 | - } |
|
47 | - |
|
48 | - $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Version::class, $version); |
|
49 | - $form->handleRequest($request); |
|
50 | - |
|
51 | - if ($form->isSubmitted() && $form->isValid()) { |
|
52 | - /** @var Version $data */ |
|
53 | - $data = $form->getData(); |
|
54 | - $em->persist($data); |
|
55 | - $em->flush(); |
|
56 | - $this->addFlash("success-flash", "Version " . $data->getProjectName() . " was " . $text); |
|
57 | - |
|
58 | - return $this->redirectToRoute("ribsadmin_versions"); |
|
59 | - } |
|
60 | - |
|
61 | - return $this->render("@RibsAdmin/versions/edit.html.twig", [ |
|
62 | - "form" => $form->createView(), |
|
63 | - "form_errors" => $form->getErrors(), |
|
64 | - "version" => $version |
|
65 | - ]); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @Route("/versions/delete/{guid}", name="ribsadmin_versions_delete") |
|
70 | - * @param EntityManagerInterface $em |
|
71 | - * @param string $guid |
|
72 | - * @return RedirectResponse |
|
73 | - */ |
|
74 | - public function delete(EntityManagerInterface $em, string $guid): RedirectResponse |
|
75 | - { |
|
76 | - $version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]); |
|
77 | - |
|
78 | - if ($version) { |
|
79 | - $em->remove($version); |
|
80 | - $em->flush(); |
|
81 | - $this->addFlash("success-flash", "The project version was deleted"); |
|
82 | - } else { |
|
83 | - $this->addFlash("error-flash", "The project version was not found"); |
|
84 | - } |
|
85 | - |
|
86 | - return $this->redirectToRoute("ribsadmin_versions"); |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @Route("/versions/update/{guid}", name="ribsadmin_versions_update") |
|
91 | - * @param EntityManagerInterface $em |
|
92 | - * @param \PiouPiou\RibsAdminBundle\Service\Version $version |
|
93 | - * @param string $guid |
|
94 | - * @return RedirectResponse |
|
95 | - */ |
|
96 | - public function updateVersion(EntityManagerInterface $em, \PiouPiou\RibsAdminBundle\Service\Version $version, string $guid): RedirectResponse |
|
97 | - { |
|
98 | - $version_entity = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]); |
|
99 | - |
|
100 | - if ($version_entity) { |
|
101 | - $version->save($version_entity->getPackageName()); |
|
102 | - |
|
103 | - $this->addFlash("success-flash", "The project version was updated"); |
|
104 | - } else { |
|
105 | - $this->addFlash("error-flash", "The project version was not found"); |
|
106 | - } |
|
107 | - |
|
108 | - return $this->redirectToRoute("ribsadmin_versions"); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @Route("/versions/send-version/{package_name}", name="ribsadmin_versions_send", requirements={"package_name"=".+"}) |
|
113 | - * @param \PiouPiou\RibsAdminBundle\Service\Version $version |
|
114 | - * @param string $package_name |
|
115 | - * @return mixed|null |
|
116 | - */ |
|
117 | - public function sendPackageInformations(\PiouPiou\RibsAdminBundle\Service\Version $version, string $package_name): JsonResponse |
|
118 | - { |
|
119 | - return new JsonResponse([ |
|
120 | - "version" => $version->getVersion($package_name), |
|
121 | - "version_date" => $version->getVersionDate($package_name) |
|
122 | - ]); |
|
123 | - } |
|
26 | + return $this->render("@RibsAdmin/versions/list.html.twig", ["verions" => $versions]); |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * @Route("/versions/create/", name="ribsadmin_versions_create") |
|
31 | + * @Route("/versions/show/{guid}", name="ribsadmin_versions_show") |
|
32 | + * @Route("/versions/edit/{guid}", name="ribsadmin_versions_edit") |
|
33 | + * @param Request $request |
|
34 | + * @param EntityManagerInterface $em |
|
35 | + * @param string|null $guid |
|
36 | + * @return Response |
|
37 | + */ |
|
38 | + public function edit(Request $request, EntityManagerInterface $em, string $guid = null): Response |
|
39 | + { |
|
40 | + if (!$guid) { |
|
41 | + $version = new Version(); |
|
42 | + $text = "created"; |
|
43 | + } else { |
|
44 | + $version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]); |
|
45 | + $text = "edited"; |
|
46 | + } |
|
47 | + |
|
48 | + $form = $this->createForm(\PiouPiou\RibsAdminBundle\Form\Version::class, $version); |
|
49 | + $form->handleRequest($request); |
|
50 | + |
|
51 | + if ($form->isSubmitted() && $form->isValid()) { |
|
52 | + /** @var Version $data */ |
|
53 | + $data = $form->getData(); |
|
54 | + $em->persist($data); |
|
55 | + $em->flush(); |
|
56 | + $this->addFlash("success-flash", "Version " . $data->getProjectName() . " was " . $text); |
|
57 | + |
|
58 | + return $this->redirectToRoute("ribsadmin_versions"); |
|
59 | + } |
|
60 | + |
|
61 | + return $this->render("@RibsAdmin/versions/edit.html.twig", [ |
|
62 | + "form" => $form->createView(), |
|
63 | + "form_errors" => $form->getErrors(), |
|
64 | + "version" => $version |
|
65 | + ]); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @Route("/versions/delete/{guid}", name="ribsadmin_versions_delete") |
|
70 | + * @param EntityManagerInterface $em |
|
71 | + * @param string $guid |
|
72 | + * @return RedirectResponse |
|
73 | + */ |
|
74 | + public function delete(EntityManagerInterface $em, string $guid): RedirectResponse |
|
75 | + { |
|
76 | + $version = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]); |
|
77 | + |
|
78 | + if ($version) { |
|
79 | + $em->remove($version); |
|
80 | + $em->flush(); |
|
81 | + $this->addFlash("success-flash", "The project version was deleted"); |
|
82 | + } else { |
|
83 | + $this->addFlash("error-flash", "The project version was not found"); |
|
84 | + } |
|
85 | + |
|
86 | + return $this->redirectToRoute("ribsadmin_versions"); |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @Route("/versions/update/{guid}", name="ribsadmin_versions_update") |
|
91 | + * @param EntityManagerInterface $em |
|
92 | + * @param \PiouPiou\RibsAdminBundle\Service\Version $version |
|
93 | + * @param string $guid |
|
94 | + * @return RedirectResponse |
|
95 | + */ |
|
96 | + public function updateVersion(EntityManagerInterface $em, \PiouPiou\RibsAdminBundle\Service\Version $version, string $guid): RedirectResponse |
|
97 | + { |
|
98 | + $version_entity = $em->getRepository(Version::class)->findOneBy(["guid" => $guid]); |
|
99 | + |
|
100 | + if ($version_entity) { |
|
101 | + $version->save($version_entity->getPackageName()); |
|
102 | + |
|
103 | + $this->addFlash("success-flash", "The project version was updated"); |
|
104 | + } else { |
|
105 | + $this->addFlash("error-flash", "The project version was not found"); |
|
106 | + } |
|
107 | + |
|
108 | + return $this->redirectToRoute("ribsadmin_versions"); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @Route("/versions/send-version/{package_name}", name="ribsadmin_versions_send", requirements={"package_name"=".+"}) |
|
113 | + * @param \PiouPiou\RibsAdminBundle\Service\Version $version |
|
114 | + * @param string $package_name |
|
115 | + * @return mixed|null |
|
116 | + */ |
|
117 | + public function sendPackageInformations(\PiouPiou\RibsAdminBundle\Service\Version $version, string $package_name): JsonResponse |
|
118 | + { |
|
119 | + return new JsonResponse([ |
|
120 | + "version" => $version->getVersion($package_name), |
|
121 | + "version_date" => $version->getVersionDate($package_name) |
|
122 | + ]); |
|
123 | + } |
|
124 | 124 | } |
@@ -15,269 +15,269 @@ |
||
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 | - * @return int |
|
95 | - */ |
|
96 | - public function getId(): int |
|
97 | - { |
|
98 | - return $this->id; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * @param int $id |
|
103 | - * @return Version |
|
104 | - */ |
|
105 | - public function setId(int $id): self |
|
106 | - { |
|
107 | - $this->id = $id; |
|
108 | - |
|
109 | - return $this; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * @return string |
|
114 | - */ |
|
115 | - public function getProjectName(): ?string |
|
116 | - { |
|
117 | - return $this->project_name; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * @param string $project_name |
|
122 | - * @return Version |
|
123 | - */ |
|
124 | - public function setProjectName(string $project_name): self |
|
125 | - { |
|
126 | - $this->project_name = $project_name; |
|
127 | - |
|
128 | - return $this; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function getPackageName(): ?string |
|
135 | - { |
|
136 | - return $this->package_name; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param string $package_name |
|
141 | - * @return Version |
|
142 | - */ |
|
143 | - public function setPackageName(string $package_name): self |
|
144 | - { |
|
145 | - $this->package_name = $package_name; |
|
146 | - |
|
147 | - return $this; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @return string |
|
152 | - */ |
|
153 | - public function getProjectUrl(): ?string |
|
154 | - { |
|
155 | - return $this->project_url; |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * @param string $project_url |
|
160 | - * @return Version |
|
161 | - */ |
|
162 | - public function setProjectUrl(string $project_url): self |
|
163 | - { |
|
164 | - $this->project_url = $project_url; |
|
165 | - |
|
166 | - return $this; |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function getVersion(): ?string |
|
173 | - { |
|
174 | - return $this->version; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param string $version |
|
179 | - * @return Version |
|
180 | - */ |
|
181 | - public function setVersion(string $version): self |
|
182 | - { |
|
183 | - $this->version = $version; |
|
184 | - |
|
185 | - return $this; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function getLastPackagistVersion(): ?string |
|
192 | - { |
|
193 | - return $this->last_packagist_version; |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * @param string $last_packagist_version |
|
198 | - * @return Version |
|
199 | - */ |
|
200 | - public function setLastPackagistVersion(string $last_packagist_version): self |
|
201 | - { |
|
202 | - $this->last_packagist_version = $last_packagist_version; |
|
203 | - |
|
204 | - return $this; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * @return DateTime |
|
209 | - */ |
|
210 | - public function getVersionDate(): ?DateTime |
|
211 | - { |
|
212 | - return $this->version_date; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * @param DateTime $version_date |
|
217 | - * @return Version |
|
218 | - */ |
|
219 | - public function setVersionDate(DateTime $version_date): self |
|
220 | - { |
|
221 | - $this->version_date = $version_date; |
|
222 | - |
|
223 | - return $this; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * @return DateTime |
|
228 | - */ |
|
229 | - public function getLastCheck(): ?DateTime |
|
230 | - { |
|
231 | - return $this->last_check; |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * @param DateTime $last_check |
|
236 | - * @return Version |
|
237 | - */ |
|
238 | - public function setLastCheck(DateTime $last_check): self |
|
239 | - { |
|
240 | - $this->last_check = $last_check; |
|
241 | - |
|
242 | - return $this; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * @return string |
|
247 | - */ |
|
248 | - public function getMode(): ?string |
|
249 | - { |
|
250 | - return $this->mode; |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * @param string $mode |
|
255 | - * @return Version |
|
256 | - */ |
|
257 | - public function setMode(string $mode): self |
|
258 | - { |
|
259 | - $this->mode = $mode; |
|
260 | - |
|
261 | - return $this; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * @return string |
|
266 | - */ |
|
267 | - public function getCheckVersionUrl(): ?string |
|
268 | - { |
|
269 | - return $this->check_version_url; |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * @param string $check_version_url |
|
274 | - * @return Version |
|
275 | - */ |
|
276 | - public function setCheckVersionUrl(string $check_version_url): self |
|
277 | - { |
|
278 | - $this->check_version_url = $check_version_url; |
|
279 | - |
|
280 | - return $this; |
|
281 | - } |
|
91 | + private $check_version_url; |
|
92 | + |
|
93 | + /** |
|
94 | + * @return int |
|
95 | + */ |
|
96 | + public function getId(): int |
|
97 | + { |
|
98 | + return $this->id; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * @param int $id |
|
103 | + * @return Version |
|
104 | + */ |
|
105 | + public function setId(int $id): self |
|
106 | + { |
|
107 | + $this->id = $id; |
|
108 | + |
|
109 | + return $this; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * @return string |
|
114 | + */ |
|
115 | + public function getProjectName(): ?string |
|
116 | + { |
|
117 | + return $this->project_name; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * @param string $project_name |
|
122 | + * @return Version |
|
123 | + */ |
|
124 | + public function setProjectName(string $project_name): self |
|
125 | + { |
|
126 | + $this->project_name = $project_name; |
|
127 | + |
|
128 | + return $this; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function getPackageName(): ?string |
|
135 | + { |
|
136 | + return $this->package_name; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param string $package_name |
|
141 | + * @return Version |
|
142 | + */ |
|
143 | + public function setPackageName(string $package_name): self |
|
144 | + { |
|
145 | + $this->package_name = $package_name; |
|
146 | + |
|
147 | + return $this; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @return string |
|
152 | + */ |
|
153 | + public function getProjectUrl(): ?string |
|
154 | + { |
|
155 | + return $this->project_url; |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * @param string $project_url |
|
160 | + * @return Version |
|
161 | + */ |
|
162 | + public function setProjectUrl(string $project_url): self |
|
163 | + { |
|
164 | + $this->project_url = $project_url; |
|
165 | + |
|
166 | + return $this; |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function getVersion(): ?string |
|
173 | + { |
|
174 | + return $this->version; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param string $version |
|
179 | + * @return Version |
|
180 | + */ |
|
181 | + public function setVersion(string $version): self |
|
182 | + { |
|
183 | + $this->version = $version; |
|
184 | + |
|
185 | + return $this; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function getLastPackagistVersion(): ?string |
|
192 | + { |
|
193 | + return $this->last_packagist_version; |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * @param string $last_packagist_version |
|
198 | + * @return Version |
|
199 | + */ |
|
200 | + public function setLastPackagistVersion(string $last_packagist_version): self |
|
201 | + { |
|
202 | + $this->last_packagist_version = $last_packagist_version; |
|
203 | + |
|
204 | + return $this; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * @return DateTime |
|
209 | + */ |
|
210 | + public function getVersionDate(): ?DateTime |
|
211 | + { |
|
212 | + return $this->version_date; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * @param DateTime $version_date |
|
217 | + * @return Version |
|
218 | + */ |
|
219 | + public function setVersionDate(DateTime $version_date): self |
|
220 | + { |
|
221 | + $this->version_date = $version_date; |
|
222 | + |
|
223 | + return $this; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * @return DateTime |
|
228 | + */ |
|
229 | + public function getLastCheck(): ?DateTime |
|
230 | + { |
|
231 | + return $this->last_check; |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * @param DateTime $last_check |
|
236 | + * @return Version |
|
237 | + */ |
|
238 | + public function setLastCheck(DateTime $last_check): self |
|
239 | + { |
|
240 | + $this->last_check = $last_check; |
|
241 | + |
|
242 | + return $this; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * @return string |
|
247 | + */ |
|
248 | + public function getMode(): ?string |
|
249 | + { |
|
250 | + return $this->mode; |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * @param string $mode |
|
255 | + * @return Version |
|
256 | + */ |
|
257 | + public function setMode(string $mode): self |
|
258 | + { |
|
259 | + $this->mode = $mode; |
|
260 | + |
|
261 | + return $this; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * @return string |
|
266 | + */ |
|
267 | + public function getCheckVersionUrl(): ?string |
|
268 | + { |
|
269 | + return $this->check_version_url; |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * @param string $check_version_url |
|
274 | + * @return Version |
|
275 | + */ |
|
276 | + public function setCheckVersionUrl(string $check_version_url): self |
|
277 | + { |
|
278 | + $this->check_version_url = $check_version_url; |
|
279 | + |
|
280 | + return $this; |
|
281 | + } |
|
282 | 282 | } |
283 | 283 |