Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Wishlist-application
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ZAHDI Mohcine
Wishlist-application
Commits
a58adb6b
Commit
a58adb6b
authored
3 months ago
by
mounouar21
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
https://github.com/MohcineProject/Wishlist-application
parents
aed25f23
b350a5e3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Controller/WishlistController.php
+20
-11
20 additions, 11 deletions
src/Controller/WishlistController.php
src/Entity/User.php
+5
-0
5 additions, 0 deletions
src/Entity/User.php
with
25 additions
and
11 deletions
src/Controller/WishlistController.php
+
20
−
11
View file @
a58adb6b
...
@@ -17,8 +17,11 @@ final class WishlistController extends AbstractController
...
@@ -17,8 +17,11 @@ final class WishlistController extends AbstractController
#[Route(name: 'app_wishlist_index', methods: ['GET'])]
#[Route(name: 'app_wishlist_index', methods: ['GET'])]
public
function
getWishLists
(
WishlistRepository
$wishlistRepository
):
Response
public
function
getWishLists
(
WishlistRepository
$wishlistRepository
):
Response
{
{
$user
=
$this
->
getUser
()
;
return
$this
->
render
(
'wishlist/index.html.twig'
,
[
return
$this
->
render
(
'wishlist/index.html.twig'
,
[
'wishlists'
=>
$
wishlistRepository
->
findAll
()
,
'wishlists'
=>
$
user
->
getWishlists
()
->
toArray
()
]);
]);
}
}
...
@@ -26,15 +29,7 @@ final class WishlistController extends AbstractController
...
@@ -26,15 +29,7 @@ final class WishlistController extends AbstractController
public
function
createWishlist
(
Request
$request
,
EntityManagerInterface
$entityManager
):
Response
public
function
createWishlist
(
Request
$request
,
EntityManagerInterface
$entityManager
):
Response
{
{
$wishlist
=
new
Wishlist
();
$wishlist
=
new
Wishlist
();
$name
=
$request
->
get
(
key
:
'name'
);
$form
=
$this
->
createForm
(
WishlistType
::
class
,
$wishlist
);
$wishlist
->
setName
(
name
:
$name
);
$deadline
=
$request
->
get
(
'deadline'
)
;
$wishlist
->
setDeadline
(
$deadline
);
$entityManager
->
persist
(
$wishlist
);
$entityManager
->
flush
();
return
new
Response
(
'wishlist created successfully'
,
Response
::
HTTP_CREATED
)
;
/* $form = $this->createForm(WishlistType::class, $wishlist);
$form
->
handleRequest
(
$request
);
$form
->
handleRequest
(
$request
);
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
if
(
$form
->
isSubmitted
()
&&
$form
->
isValid
())
{
...
@@ -47,7 +42,9 @@ final class WishlistController extends AbstractController
...
@@ -47,7 +42,9 @@ final class WishlistController extends AbstractController
return
$this
->
render
(
'wishlist/new.html.twig'
,
[
return
$this
->
render
(
'wishlist/new.html.twig'
,
[
'wishlist'
=>
$wishlist
,
'wishlist'
=>
$wishlist
,
'form'
=>
$form
,
'form'
=>
$form
,
]); */
]);
}
}
#[Route('/{id}', name: 'app_wishlist_show', methods: ['GET'])]
#[Route('/{id}', name: 'app_wishlist_show', methods: ['GET'])]
...
@@ -94,3 +91,15 @@ final class WishlistController extends AbstractController
...
@@ -94,3 +91,15 @@ final class WishlistController extends AbstractController
}
}
/*
$wishlist = new Wishlist();
$name = $request->get(key: 'name');
$wishlist->setName(name: $name);
$deadline = $request->get('deadline') ;
$wishlist->setDeadline($deadline);
$this->getUser()->addToAuthorWhishlists($wishlist);
$entityManager->persist($wishlist);
$entityManager->persist($this->getUser()) ;
$entityManager->flush(); */
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Entity/User.php
+
5
−
0
View file @
a58adb6b
...
@@ -164,6 +164,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
...
@@ -164,6 +164,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return
$this
->
wishlists
;
return
$this
->
wishlists
;
}
}
public
function
addToAuthorWhishlists
(
Wishlists
$wishlist
){
if
(
!
$this
->
wishlists
->
contains
(
$wishlist
))
{
$this
->
wishlists
[]
=
$wishlist
;
}
}
// public function getInvitations(): Collection
// public function getInvitations(): Collection
// {
// {
// return $this->invitations;
// return $this->invitations;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment