Eric and Katrina first met online in 2014. After texting back and forth for a week they finally met in
persion at a little coffee shop in Oakland on July 23, 2014. Eric was shy and Katrina was nervous, but somehow they found enough
to talk about to agree to a second date where they continued to bond over coffee, cigarettes, and zombie movies.
In August 2016 they packed everything into a couple of crates and moved up north to Portland, Oregon. After six months of the both of them working from home,
they realized that they were still madly in love (despite seeing each other all day, every day.) So on February 6, 2017 Eric proposed to Katrina.
On May 12, 2017 they will both say "yes" and live happily ever after til death do they part.
diff --git a/app/Resources/views/social_login.html.twig b/app/Resources/views/social_login.html.twig
index 27c98e0..95be003 100644
--- a/app/Resources/views/social_login.html.twig
+++ b/app/Resources/views/social_login.html.twig
@@ -1,21 +1,22 @@
-{% if(not is_granted('IS_AUTHENTICATED_FULLY')) %}
-
+{% if not is_granted('IS_AUTHENTICATED_FULLY') %}
+
+
-
+
-
-
+
+
-
+
{% endif %}
\ No newline at end of file
diff --git a/app/Resources/views/user/index.html.twig b/app/Resources/views/user/index.html.twig
deleted file mode 100644
index a8e1fc6..0000000
--- a/app/Resources/views/user/index.html.twig
+++ /dev/null
@@ -1,4 +0,0 @@
-{% extends 'base.html.twig' %}
-{% block body %}
-{{ dump(app.session.get('user')) }}
-{% endblock %}
diff --git a/app/Resources/views/user/logout.html.twig b/app/Resources/views/user/logout.html.twig
deleted file mode 100644
index c7da610..0000000
--- a/app/Resources/views/user/logout.html.twig
+++ /dev/null
@@ -1,7 +0,0 @@
-{% extends 'base.html.twig' %}
-{% block body %}
-
You have been successfully logged out.
-
- You can log in again by going to the login page.
-
-{% endblock %}
\ No newline at end of file
diff --git a/app/Resources/views/user_registered.txt.twig.html.twig b/app/Resources/views/user_registered.txt.twig.html.twig
index 4f15832..3e4761f 100644
--- a/app/Resources/views/user_registered.txt.twig.html.twig
+++ b/app/Resources/views/user_registered.txt.twig.html.twig
@@ -1,19 +1,19 @@
{% block body_text %}
{% autoescape false %}
-Heyo!,
+Heyo!
-{{ user.name }} has registered a new account.
+{{ user.name }} has registered a new account with the email {{ user.email }} and is bringing {% if user.rsvp.guests != 0 %}{{ user.rsvp.guests - 1 }}{% else %}0{% endif %} guests with them.
-Info,
-
-Email : {{ user.email }}
-Guests: {{ user.rsvp.guests }}
{% if user.comment is not null %}
-Comment :
+{{ user.name }} wants you to know -
{{ user.comment }}
{% endif %}
+{% if resourceOwner is defined and resourceOwner is not null %}
+{{ user.name }} connected with {{ resourceOwner|capitalize }}
+{% endif %}
+
Love,
Your website ❤
diff --git a/app/config/config.yml b/app/config/config.yml
index 5e2b5f7..c3df565 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -49,6 +49,9 @@ framework:
twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
+ form_themes:
+ # other form themes
+ - 'VichUploaderBundle:Form:fields.html.twig'
# Doctrine Configuration
doctrine:
@@ -126,7 +129,6 @@ swiftmailer:
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
- delivery_addresses: ['eric@rewiv.com']
sender_address: 'noreply@doughnutwedding.com'
hwi_oauth:
@@ -148,10 +150,6 @@ hwi_oauth:
type: amazon
client_id: 'amzn1.application-oa2-client.15f87b8a4f23465b9022ba0a3f55610d'
client_secret: '84d6f402c53386ae0f196062945f217dcc56e7b7122cffb76c95b6a5775d22e0'
- instagram:
- type: instagram
- client_id: '70e7edd280834c429d49f985ff308230'
- client_secret: '9c405020a3ef412086032a4514909705'
twitter:
type: twitter
client_id: 'YmXGQN2Az0eTlkwJrnaO2wR9r'
@@ -170,7 +168,6 @@ hwi_oauth:
google: googleId
facebook: facebookId
amazon: amazonId
- instagram: instagramId
twitter: twitterId
yahoo: yahooId
# if you want to use 'connect' and do not use the FOSUB integration, configure these separately
@@ -219,12 +216,23 @@ knp_gaufrette:
assets:
adapter: assets
alias: cloud_assets
+
vich_uploader:
db_driver: orm
- storage: gaufrette
mappings:
gallery_image:
- upload_destination: cloud
- uri_prefix: /
+ namer:
+ service: vich_uploader.namer_hash
+ options:
+ length: 32
+ algorithm: 'sha3-512'
+ delete_on_update: true
+ delete_on_remove: true
+
sikofitt_doughnut_wedding:
max_rsvps: ~
+
+white_october_pagerfanta:
+ exceptions_strategy:
+ out_of_range_page: ~
+ not_valid_current_page: ~
\ No newline at end of file
diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml
index c126e55..c1addb4 100644
--- a/app/config/config_dev.yml
+++ b/app/config/config_dev.yml
@@ -36,6 +36,17 @@ monolog:
#chromephp:
# type: chromephp
# level: info
+vich_uploader:
+ storage: gaufrette
+ mappings:
+ gallery_image:
+ upload_destination: cloud
+ uri_prefix: /
+ #storage: file_system
+ #mappings:
+ # gallery_image:
+ # uri_prefix: /images/gallery
+ # upload_destination: '%kernel.root_dir%/../web/images/gallery'
swiftmailer:
transport: null
diff --git a/app/config/config_prod.yml b/app/config/config_prod.yml
index 6dcdec9..d9b71e1 100644
--- a/app/config/config_prod.yml
+++ b/app/config/config_prod.yml
@@ -5,11 +5,41 @@ monolog:
handlers:
main:
type: fingers_crossed
- action_level: error
+ action_level: notice
handler: redis
console:
type: console
redis:
type: service
id: snc_redis.monolog.handler
- level: debug
+ level: notice
+ mail:
+ type: fingers_crossed
+ # 500 errors are logged at the critical level
+ action_level: error
+ excluded_404s:
+ - ^/
+ # to also log 400 level errors (but not 404's):
+ # action_level: error
+ #excluded_404s:
+ # - ^/
+ handler: deduplicated
+ deduplicated:
+ type: deduplication
+ handler: swift
+ swift:
+ type: swift_mailer
+ from_email: 'action@doughnutwedding.com'
+ to_email: ['sikofitt@gmail.com','katrina.a.johnson@gmail.com']
+ # or list of recipients
+ # to_email: ['dev1@example.com', 'dev2@example.com', ...]
+ subject: 'An Error Occurred! %%message%%'
+ level: error
+ formatter: monolog.formatter.html
+ content_type: text/html
+vich_uploader:
+ storage: gaufrette
+ mappings:
+ gallery_image:
+ upload_destination: cloud
+ uri_prefix: /
\ No newline at end of file
diff --git a/app/config/easy_admin.yml b/app/config/easy_admin.yml
index ef40bac..5e96441 100644
--- a/app/config/easy_admin.yml
+++ b/app/config/easy_admin.yml
@@ -1,17 +1,37 @@
easy_admin:
+ site_name: Doughnut Wedding
design:
- form_theme: 'vertical'
+ form_theme: 'horizontal'
entities:
- Contact:
- class: Sikofitt\DoughnutWeddingBundle\Entity\Contact
- list:
- actions: ['show','edit','delete']
- fields: ['userid','email','name','comment','createdAt']
+ ImageComments:
+ class: Sikofitt\DoughnutWeddingBundle\Entity\ImageComment
+ disabled_actions: ['new']
User:
class: Sikofitt\DoughnutWeddingBundle\Entity\User
list:
actions: ['show','edit','delete']
fields: ['name','username','email','enabled','lastLogin','rsvp']
+ edit:
+ fields:
+ - name
+ - username
+ - email
+ - { property: rsvp, type_options: { disabled: true } }
+ - comment
+ - images
+ - enabled
+ - lastLogin
+ - confirmationToken
+ - passwordRequestedAt
+ - roles
+ - created
+ - updated
+ - facebookId
+ - googleId
+ - amazonId
+ - instagramId
+ - twitterId
+ - yahooId
show:
fields:
- name
@@ -34,20 +54,26 @@ easy_admin:
- yahooId
Rsvp:
class: Sikofitt\DoughnutWeddingBundle\Entity\Rsvp
- Image:
+ Contact:
+ class: Sikofitt\DoughnutWeddingBundle\Entity\Contact
+ list:
+ actions: ['show','edit','delete']
+ fields: ['userid','email','name','comment','createdAt']
+ Images:
class: Sikofitt\DoughnutWeddingBundle\Entity\Image
image_base_path: 'https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/gallery/'
list:
actions: ['show','delete']
fields:
- { property: 'imageName', label: 'Image', type: 'image', base_path: 'https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/gallery/' }
-
+ - description
- category
- tags
- user
form:
fields:
- { property: 'imageFile', type: 'vich_image', base_path: 'https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/gallery/' }
+ - description
- { property: tags, type: 'collection'}
- category
- user
diff --git a/app/config/routing.yml b/app/config/routing.yml
index c5ee747..2cf24cd 100644
--- a/app/config/routing.yml
+++ b/app/config/routing.yml
@@ -2,54 +2,63 @@ hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
+
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /connect
+
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /connect
+
facebook_login:
path: /login/callback/facebook
+
google_login:
path: /login/callback/google
+
twitter_login:
path: /login/callback/twitter
-instagram_login:
- path: /login/callback/instagram
+
amazon_login:
path: /login/callback/amazon
+
yahoo_login:
path: /login/callback/yahoo
+
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
-#paths
-# /login
-# /login_check
-# /logout
+
+
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /user/profile
+
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
+
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
+
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /user/profile
+
easy_admin_bundle:
resource: "@EasyAdminBundle/Controller/"
type: annotation
prefix: /admin
+
sikofitt_doughnut_wedding:
resource: "@SikofittDoughnutWeddingBundle/Controller/"
type: annotation
diff --git a/app/config/security.yml b/app/config/security.yml
index 27aea2c..a73c302 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -35,7 +35,6 @@ security:
facebook: /login/callback/facebook
google: /login/callback/google
twitter: /login/callback/twitter
- instagram: /login/callback/instagram
amazon: /login/callback/amazon
yahoo: /login/callback/yahoo
login_path: /login
diff --git a/app/config/services.yml b/app/config/services.yml
index 674ff13..6b7946e 100644
--- a/app/config/services.yml
+++ b/app/config/services.yml
@@ -23,12 +23,17 @@ services:
arguments: ['@security.token_storage', '@router']
tags:
- { name: kernel.event_listener, event: kernel.request }
+ doughnutwedding.event.redirect_from_hwi_connect_page:
+ class: Sikofitt\DoughnutWeddingBundle\EventListener\RedirectFromHwiConnectPageEvent
+ arguments: ['@router', '@service_container']
+ tags:
+ - { name: kernel.event_listener, event: kernel.request }
doughnutwedding.event.redirect_user_after_register_event:
class: Sikofitt\DoughnutWeddingBundle\EventListener\RedirectOnUserRegisterListener
arguments: ['@service_container']
tags:
- - { name: kernel.event_listener, event: fos_user.registration.confirmed }
- { name: kernel.event_listener, event: fos_user.registration.completed }
+ - { name: kernel.event_listener, event: security.interactive_login }
doughnutwedding.google_cloud_storage.service:
class: \Google_Service_Storage
factory: ['Sikofitt\DoughnutWeddingBundle\Factory\GoogleCloudStorageServiceFactory', createGoogleCloudService]
@@ -45,4 +50,11 @@ services:
- { name: kernel.event_listener, event: kernel.response }
doughnutwedding.security.access_denied_handler:
class: Sikofitt\DoughnutWeddingBundle\Security\AccessDeniedHandler
- arguments: ['@router', '@monolog.logger']
\ No newline at end of file
+ arguments: ['@router', '@monolog.logger']
+ doughnutwedding.uikit.template:
+ class: Sikofitt\DoughnutWeddingBundle\Pager\View\UIkitTemplate
+ pagerfanta.view.default:
+ class: Pagerfanta\View\DefaultView
+ arguments: ['@doughnutwedding.uikit.template']
+ public: false
+ tags: [{ name: pagerfanta.view, alias: default }]
\ No newline at end of file
diff --git a/build/images/yahoo2.svg b/build/images/yahoo2.svg
new file mode 100644
index 0000000..9ad44dd
--- /dev/null
+++ b/build/images/yahoo2.svg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:806dc0af681d43dd94bf783335f3e6de6bdf769e4f882b513a106696c69cca82
+size 763
diff --git a/build/less/doughnut.less b/build/less/doughnut.less
index 55bbbac..0ea725f 100644
--- a/build/less/doughnut.less
+++ b/build/less/doughnut.less
@@ -1,6 +1,6 @@
@import "../../vendor/bower/uikit/src/less/uikit.less";
@import "../../vendor/bower/uikit/src/less/components/variables.less";
-
+@import url('https://fonts.googleapis.com/css?family=Sigmar+One');
//@global-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
//@global-font-size: 16px;
@global-font-family: 'Raleway', sans-serif;
@@ -8,18 +8,69 @@
@base-body-font-family: 'Raleway', sans-serif;
@base-heading-font-family: 'Raleway', sans-serif;
@base-heading-text-transform: uppercase;
+@button-text-transform:capitalize;
@base-body-font-weight: 200;
@base-heading-font-weight: 300;
@form-background: #ffffff;
-@global-link-color: #90d5c1;
+@global-link-color: #5fbabd;
@base-link-color: @global-link-color;
@base-link-hover-color: darken(@base-link-color, 20%);
-@button-primary-background: #90d5c1;
+@button-primary-background: #9dd3d5;
@button-primary-color: #333;
+@text-primary-color: @button-primary-background;
@button-primary-hover-color: darken(@button-primary-color, 10%);
@button-primary-hover-background: darken(@button-primary-background, 10%);
-.uk-login-container {
+@button-danger-background: #fa6581;
+@button-danger-color: #333;
+@button-danger-hover-color: darken(@button-danger-color, 10%);
+@button-danger-hover-background: darken(@button-danger-background, 10%);
+blockquote p {
+
+}
+
+blockquote footer:before {
+ content: "— ";
+}
+.uk-404 {
+ font-family: 'Sigmar One', cursive;
+ line-height:0;
+ &.uk-doughnut {
+ @media(min-width: @breakpoint-small-max) {
+ font-size: 10rem;
+ }
+ @media(max-width: @breakpoint-small) {
+ font-size: 5rem;
+ }
+ .uk-spin {
+ @media(min-width: @breakpoint-small-max) {
+ width: 128px;
+ height: 128px;
+ }
+ @media(max-width: @breakpoint-small) {
+ width: 64px;
+ height:64px;
+ }
+ background-image:url(https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/doughnut_404.png)
+ }
+ }
+}
+
+@-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
+@-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
+@keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } }
+
+.uk-spin {
+ position: relative;
+ top: 0%;
+ left: 0%;
+ margin:0px 12px;
+ -webkit-animation:spin 1.5s linear infinite;
+ -moz-animation:spin 1.5s linear infinite;
+ animation:spin 1.5s linear infinite;
+
+}
+.uk-login-container {
.uk-navbar {
.uk-navbar-nav {
li {
@@ -37,7 +88,7 @@ label.required:after {
color: @form-danger-color;
font-size: @global-large-font-size;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
- font-weight: bol
+ font-weight: bold
}
.uk-home {
@@ -63,22 +114,22 @@ label.required:after {
.uk-our-story-home {
height:465px !important;
- background-image: url('/images/home_our_story_1.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_our_story_1.jpg');
&:hover {
- background-image: url('/images/home_our_story_2.jpg')
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_our_story_2.jpg')
}
}
// photo
// location
.uk-photo-home {
- background-image: url('/images/home_photo_2.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_photo_2.jpg');
&:hover {
- background-image: url('/images/home_photo_1.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_photo_1.jpg');
}
}
.uk-location-home {
margin-bottom:15px !important;
- background-image: url('/images/home_location.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_location.jpg');
transition-duration: .3s;
transition-timing-function: ease-out;
transition-property: filter;
@@ -90,15 +141,15 @@ label.required:after {
}
.uk-doughnut-rsvp {
margin-bottom:15px !important;
- background-image: url('/images/home_doughnut_1.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_doughnut_1.jpg');
&:hover {
- background-image: url('/images/home_doughnut_2.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_doughnut_2.jpg');
}
}
.uk-doughnut-get-in-touch-home {
- background-image: url('/images/home_doughnut_2.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_doughnut_2.jpg');
&:hover {
- background-image: url('/images/home_doughnut_1.jpg');
+ background-image: url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_doughnut_1.jpg');
}
}
@@ -106,7 +157,39 @@ label.required:after {
}
}
+.uk-icon.uk-icon-facebook {
+ color: #3b5998;
+}
+.uk-icon.uk-icon-google {
+ color: #d50f25;
+}
+.uk-icon.uk-icon-twitter {
+ color: #1da1f2;
+}
+.uk-icon.uk-icon-yahoo {
+ color: #7b0099;
+ /*color: #720e9e;*/
+}
+.uk-icon.uk-icon-amazon {
+ color: #ff9900;
+}
+.uk-preload {
+ background-repeat: no-repeat;
+ background-position-x: -9999px;
+ background-position-y: -9999px;
+ .our-story {
+ background-image:url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_our_story_2.jpg');
+ }
+ .photo-gallery {
+ background-image:url('https://storage.googleapis.com/zgluzzkwodfky2m0ytbhmjhmmzqzntq2ngy3ndjmntyxmzg4/assets/home_photo_1.jpg');
+ }
+
+}
+.uk-registration-connect a,
+.uk-doughnut-main-nav li a {
+ font-weight:bold !important;
+}
.uk-input,
.uk-select,
.uk-textarea {
diff --git a/composer.json b/composer.json
index 89a63d2..112d8f0 100644
--- a/composer.json
+++ b/composer.json
@@ -55,7 +55,8 @@
"tedivm/stash-bundle": "^0.6.2",
"twig/extensions": "^1.4",
"twig/twig": "^1.0||^2.0",
- "vich/uploader-bundle": "^1.5"
+ "vich/uploader-bundle": "^1.5",
+ "white-october/pagerfanta-bundle": "^1.0"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^2.3",
diff --git a/email/doughnut_wedding.html b/email/doughnut_wedding.html
index 6031d72..c329bc4 100644
--- a/email/doughnut_wedding.html
+++ b/email/doughnut_wedding.html
@@ -1,248 +1,377 @@
-
+
-
Eric and Katrina's Doughnut Wedding!
-
-
-
-
-
-
-
-
+
Eric and Katrina's Doughnut Wedding!
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Controller/DefaultController.php b/src/Sikofitt/DoughnutWeddingBundle/Controller/DefaultController.php
index 8cd1934..fb4ade0 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Controller/DefaultController.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Controller/DefaultController.php
@@ -45,18 +45,20 @@ class DefaultController extends Controller
if (null !== $this->getUser()) {
$parameters['hide_social'] = true;
}
+
return $this->render('default/index.html.twig', $parameters);
}
- /**
- * @Route("/our_story")
- *
- * @param \Symfony\Component\HttpFoundation\Request $request
- *
- * @return Response
- */
- public function ourStoryAction(Request $request) {
- return $this->render('our_story.html.twig');
+ /**
+ * @Route("/our_story")
+ *
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ *
+ * @return Response
+ */
+ public function ourStoryAction(Request $request): Response
+ {
+ return $this->render('our_story.html.twig');
}
/**
@@ -66,19 +68,22 @@ class DefaultController extends Controller
*
* @return Response
*/
- public function locationAction(Request $request) {
+ public function locationAction(Request $request): Response
+ {
return $this->render('location.html.twig');
}
/**
* @Route("/get_in_touch")
+ *
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function contactAction(Request $request) : Response {
+ public function contactAction(Request $request): Response
+ {
$contact = new Contact();
- if(null !== $this->getUser()) {
+ if (null !== $this->getUser()) {
$contact
->setName($this->getUser()->getName())
->setEmail($this->getUser()->getEmail())
@@ -88,13 +93,11 @@ class DefaultController extends Controller
$form = $this->get('form.factory')->create(ContactFormType::class, $contact);
-
- if($request->isMethod('POST')) {
+ if ($request->isMethod('POST')) {
$form->handleRequest($request);
- if($form->isValid() && $form->isSubmitted()) {
+ if ($form->isValid() && $form->isSubmitted()) {
$em = $this->get('doctrine.orm.entity_manager');
/** @var Contact $data */
-
$data = $form->getData();
$data->setCreatedAt(new \DateTime('now'));
@@ -102,11 +105,11 @@ class DefaultController extends Controller
$em->persist($data);
$em->flush();
- $responseMessage[] = 'Thank you for your message ' . $data->getName() . '!';
+ $responseMessage[] = 'Thank you for your message '.$data->getName().'!';
$email = $data->getEmail();
- if( null !== $email ) {
+ if (null !== $email) {
$responseMessage[] = sprintf('We will respond to you at %s as soon as possible.', $email);
} else {
$email = 'no-reply@doughnutwedding.com';
@@ -129,6 +132,5 @@ class DefaultController extends Controller
}
return $this->render('form/contact.html.twig', ['form' => $form->createView()]);
-
}
}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Controller/GalleryController.php b/src/Sikofitt/DoughnutWeddingBundle/Controller/GalleryController.php
index 1063df8..4714354 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Controller/GalleryController.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Controller/GalleryController.php
@@ -20,11 +20,21 @@
namespace Sikofitt\DoughnutWeddingBundle\Controller;
+use Pagerfanta\Adapter\ArrayAdapter;
+use Pagerfanta\Pagerfanta;
+use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sikofitt\DoughnutWeddingBundle\Entity\Image;
+use Sikofitt\DoughnutWeddingBundle\Entity\ImageComment;
use Sikofitt\DoughnutWeddingBundle\Form\GalleryUploadType;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Vich\UploaderBundle\Form\Type\VichImageType;
+use Symfony\Component\HttpFoundation\JsonResponse;
+use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
+use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Component\Security\Csrf\CsrfToken;
/**
* Class ImageController.
@@ -35,44 +45,213 @@ class GalleryController extends Controller
{
/**
* @Route("/")
+ * @Method({"GET"})
*/
- public function indexAction()
+ public function indexAction(Request $request) : Response
{
- $images = $this->get('doctrine.orm.default_entity_manager')->getRepository('SikofittDoughnutWeddingBundle:Image')->findAll();
- return $this->render('SikofittDoughnutWeddingBundle:Image:index.html.twig', ['images' => $images]);
+ $images = $this->get('doctrine.orm.default_entity_manager')->getRepository('SikofittDoughnutWeddingBundle:Image')->findAll();
+
+ $chunks = array_chunk($images, 12);
+ $adapter = new ArrayAdapter($images);
+ $pager = new Pagerfanta($adapter);
+ $pager->setMaxPerPage(12);
+
+ return $this->render('SikofittDoughnutWeddingBundle:Image:index.html.twig', [
+ 'images' => $chunks[0] ?? $images,
+ 'pager' => $pager,
+ ]);
+ }
+
+ /**
+ * @Route("/page/{number}", defaults={"number":1}, name="gallery_page_view", requirements={"number":"\d+"})
+ *
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * @param int $number
+ *
+ * @return Response
+ */
+ public function pageAction(Request $request, int $number)
+ {
+ $images = $this->get('doctrine.orm.default_entity_manager')->getRepository('SikofittDoughnutWeddingBundle:Image')->findAll();
+
+ $adapter = new ArrayAdapter($images);
+ $pager = new Pagerfanta($adapter);
+ $chunks = array_chunk($images, 12);
+ $pager->setMaxPerPage(12);
+ $pager->setCurrentPage($number);
+
+ return $this->render('SikofittDoughnutWeddingBundle:Image:index.html.twig', ['images' => $chunks[$number - 1], 'pager' => $pager]);
}
/**
* @Route("/upload")
*/
- public function uploadAction()
+ public function uploadAction(Request $request, Response $response = null)
{
- if(false === $this->isGranted('IS_AUTHENTICATED_FULLY')) {
- $this->addFlash('error', 'You must be logged in to upload photos.');
- }
- $form = $this->get('form.factory')->create(GalleryUploadType::class, new Image());
+ if (false === $this->isGranted('IS_AUTHENTICATED_FULLY')) {
+ $this->addFlash('error', 'You must be logged in to upload photos.');
+ }
+
+ $image = new Image();
+ $image->setUser($request->getSession()->get('user'));
+ $form = $this->get('form.factory')->create(GalleryUploadType::class, $image);
+ $form->handleRequest($request);
+ if ($form->isSubmitted() && $form->isValid()) {
+ /** @var \Sikofitt\DoughnutWeddingBundle\Entity\User $user */
+ $user = $this->getUser();
+ $image->setUser($user);
+
+ $em = $this->get('doctrine.orm.entity_manager');
+ $em->persist($image);
+ $em->flush();
+
+ $baseName = $image->getImageFile()->getBasename('.'.$image->getImageFile()->getExtension());
+
+ return new RedirectResponse($this->get('router')->generate('view_gallery_image_by_hash', ['imageHash' => $baseName]));
+ }
+
return $this->render('SikofittDoughnutWeddingBundle:Image:upload.html.twig', [
- 'form' => $form->createView()
+ 'form' => $form->createView(),
]);
}
/**
- * @Route("/tag")
+ * @Route("/ajax")
+ * @Method({"POST"})
*/
- public function tagAction()
+ public function ajaxCommentAction(Request $request): JsonResponse
{
- return $this->render('SikofittDoughnutWeddingBundle:Image:tag.html.twig', [
- // ...
+ if (false === $request->getSession()->has('_security_secured_area')) {
+ return new JsonResponse(['status' => 403, 'message' => 'You must be logged in to post a comment'], 403);
+ }
+ /** @var \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $data */
+ $data = unserialize($request->getSession()->get('_security_secured_area'), [TokenInterface::class]);
+
+ $tokenManager = $this->get('security.csrf.token_manager');
+ $fileName = $request->request->get('file');
+
+ $token = $request->request->get('_token');
+ $csrfToken = new CsrfToken($fileName, $token);
+
+ if (false === $tokenManager->isTokenValid($csrfToken)) {
+ return new JsonResponse(['status' => Response::HTTP_EXPECTATION_FAILED, 'message' => 'Invalid Token'], Response::HTTP_EXPECTATION_FAILED);
+ }
+ $em = $this->get('doctrine.orm.entity_manager');
+ $user = $em
+ ->getRepository('SikofittDoughnutWeddingBundle:User')
+ ->findOneBy(['id' => $data->getUser()->getId()]);
+
+ $comment = $request->request->get('comment');
+ $fileId = $request->request->get('id');
+
+ $image = $em
+ ->getRepository('SikofittDoughnutWeddingBundle:Image')
+ ->findOneBy(['id' => $fileId]);
+
+ $newComment = new ImageComment();
+ $newComment->setUser($user)
+ ->setComment($comment)
+ ->setImage($image)
+ ->setIsChild(false)
+ ->setCreated(new \DateTime('now'))
+ ->setChildComments(null);
+ $em->persist($newComment);
+ $em->flush();
+
+ $commentHtml = $this->renderView('gallery_comment.html.twig', ['comment' => $newComment]);
+
+ return new JsonResponse([
+ 'id' => $user->getId(),
+ 'name' => $user->getName(),
+ 'date_short' => date('m/d/y').' at '.date('g:ia'),
+ 'date_long' => date('l F jS, Y').' at '.date('g:ia'),
+ 'status' => Response::HTTP_OK,
+ 'html' => $commentHtml,
]);
}
/**
- * @Route("/category")
+ * @Route("/{imageHash}", name="view_gallery_image_by_hash", requirements={"imageHash":"\w{32,32}"})
+ * @Method({"GET","HEAD"})
+ *
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * @param string $imageHash
+ *
+ * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
+ *
+ * @return Response
*/
- public function categoryAction()
+ public function viewImageAction(Request $request, string $imageHash): ?Response
{
- return $this->render('SikofittDoughnutWeddingBundle:Image:category.html.twig', [
- // ...
- ]);
+ $image = $this
+ ->get('doctrine.orm.entity_manager')
+ ->createQueryBuilder()
+ ->select('i')
+ ->from('Sikofitt\DoughnutWeddingBundle\Entity\Image', 'i')
+ ->where('i.imageName LIKE :imageHash')
+ ->setParameter('imageHash', $imageHash.'%')
+ ->getQuery()->getOneOrNullResult();
+ if (null !== $image) {
+ return $this->render('@SikofittDoughnutWedding/Image/view_image.html.twig',
+ ['image' => $image]);
+ }
+
+ throw new NotFoundHttpException();
+ }
+
+ /**
+ * @Route("/tag/{tag}/{number}", name="gallery_tag_action", defaults={"number":1}, requirements={"number":"\d+"})
+ *
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * @param string $tag
+ * @param int $number
+ *
+ * @return Response
+ */
+ public function tagAction(Request $request, string $tag, int $number): Response
+ {
+ $images = $this
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('SikofittDoughnutWeddingBundle:Image')
+ ->findImageByTag($tag);
+ $adapter = new ArrayAdapter($images);
+ $pager = new Pagerfanta($adapter);
+ $pager->setMaxPerPage(12);
+ $chunks = array_chunk($images, 12);
+
+ return $this
+ ->render('SikofittDoughnutWeddingBundle:Image:index.html.twig', [
+ 'pager' => $pager,
+ 'tag' => $tag,
+ 'images' => $chunks[$number - 1] ?? $images,
+ ]);
+ }
+
+ /**
+ * @Route("/category/{category}/{number}", name="gallery_category_action", defaults={"number":1}, requirements={"number":"\d+"})
+ *
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * @param string $category
+ *
+ * @return Response
+ */
+ public function categoryAction(Request $request, string $category, int $number): Response
+ {
+ $images = $this
+ ->get('doctrine.orm.entity_manager')
+ ->getRepository('SikofittDoughnutWeddingBundle:Image')
+ ->findImageByCategory($category);
+
+ $adapter = new ArrayAdapter($images);
+ $pager = new Pagerfanta($adapter);
+ $pager->setMaxPerPage(12);
+ $chunks = array_chunk($images, 12);
+
+ return $this
+ ->render('SikofittDoughnutWeddingBundle:Image:index.html.twig', [
+ 'pager' => $pager,
+ 'category' => $category,
+ 'images' => $chunks[$number - 1] ?? $images,
+ ]);
}
}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Controller/RsvpController.php b/src/Sikofitt/DoughnutWeddingBundle/Controller/RsvpController.php
deleted file mode 100644
index 8f49ce3..0000000
--- a/src/Sikofitt/DoughnutWeddingBundle/Controller/RsvpController.php
+++ /dev/null
@@ -1,163 +0,0 @@
-.
- */
-
-namespace Sikofitt\DoughnutWeddingBundle\Controller;
-
-use Doctrine\ORM\EntityManager;
-
-use Sikofitt\DoughnutWeddingBundle\Form\RsvpType;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Symfony\Bundle\FrameworkBundle\Tests\Controller\ContainerAwareController;
-use Symfony\Component\Form\FormFactory;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\Routing\Annotation\Route;
-use Symfony\Component\Validator\ConstraintViolationList;
-
-class RsvpController extends Controller
-{
- /**
- * @Route("/rsvp")
- *
- * @param \Symfony\Component\HttpFoundation\Request $request
- *
- * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
- */
- public function indexAction(Request $request)
- {
- /**
- * @var EntityManager $em
- * @var RsvpRepository $rsvpRepo
- * @var UserRepository $userRepo
- */
- $em = $this->get('doctrine.orm.entity_manager');
- $user = $this->getUser();
- $form = $this->get('form.factory')->create(RsvpType::class, $user);
-
-
-
-
-
- if ($request->isMethod('POST')) {
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid()) {
- $user = $form->getData();
- $user->setPassword($user->getPlainPassword());
- /**
- * @var EntityManager $em
- */
-
- $em->persist($user);
- $em->flush();
-
- return $this->render('rsvp_form.html.twig', ['form' => $form->createView()]);
- }
- }
-
- return $this->redirect($this->generateUrl('fos_user_profile_edit'));
-
- }
-
- /**
- * @param \Symfony\Component\HttpFoundation\Request $request
- * @param \Kernel $app
- * @param string $token
- *
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function resetAction(Request $request, \Kernel $app)
- {
- $formFactory = $app->getFormFactory();
- $passwordResetForm = $formFactory
- ->createBuilder(ResetType::class)
- ->getForm();
- $update = false;
- if ($request->isMethod('POST')) {
- $passwordResetForm->handleRequest($request);
- if ($passwordResetForm->isSubmitted() && $passwordResetForm->isValid()) {
- $data = $passwordResetForm->get('email')->getData();
- $update = $app['orm.em']->getRepository('Sikofitt\App\Entity\User')
- ->setResetToken($data);
- } else {
- $data = null;
- }
- } else {
- $data = null;
- }
- /**
- * @var UserRepository $userRepo
- */
- $userRepo = $app['orm.em']->getRepository('Sikofitt\App\Entity\User');
-
- //$emailResult = $userRepo->getEmail($passwordResetForm->get('email'));
- /*if(null === $emailResult) {
- return $app->render('reset_password_confirm.html.twig', [
- 'message' => 'Email was not found in database',
- ]);
- } elseif($emailResult instanceof ConstraintViolationList) {
- return $app->render(
- 'reset_password.html.twig',
- [
- 'form' => $passwordResetForm->createView(),
- 'data' => $data,
- 'email' => $emailResult,
- 'message' => $emailResult,
- ]
- );
- } else {
- return $app->render('reset_password_confirm.html.twig', [
- 'message' => 'Please check your email. A reset request has been sent.',
- ]);
- }*/
- $app->addInfo('Message', 'message 2');
-
- return $app->render(
- 'reset_password.html.twig',
- [
- 'form' => $passwordResetForm->createView(),
- 'data' => $data,
- //'email' => $emailResult,
- ]
- );
- }
-
- public function tokenAction(Request $request, \Kernel $app, string $token = null)
- {
- $user = $app['orm.em']->getRepository('Sikofitt\App\Entity\User')->getUserByToken($token);
-
- if (null === $user) {
- return $app->render('reset_password_token.html.twig', ['token' => ['valid' => false, 'value' => $token]]);
- } else {
- $passwordForm = $app->getFormFactory()->create(ResetPasswordType::class);
- if ($request->isMethod('POST')) {
- $passwordForm->handleRequest($request);
- if ($passwordForm->isValid() && $passwordForm->isSubmitted()) {
- $hash = $app->encodePassword($user, $passwordForm->get('password')->getData());
- $user->setPassword($hash);
- $app['orm.em']->getRepository('Sikofitt\App\Entity\User')->updatePassword($user);
- $app->addSuccess('Successfully changed your password!');
-
- return $app->redirect($app->url('rsvp'));
- }
- }
-
- return $app->render('reset_password_token.html.twig', ['token' => ['valid' => true, 'value' => $token], 'form' => $passwordForm->createView(), 'user' => $user]);
- }
- }
-}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Entity/Contact.php b/src/Sikofitt/DoughnutWeddingBundle/Entity/Contact.php
index c6dd288..996c263 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Entity/Contact.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Entity/Contact.php
@@ -1,11 +1,29 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
- * Contact
+ * Contact.
*
* @ORM\Table(name="contact")
* @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\ContactRepository")
@@ -35,11 +53,11 @@ class Contact
*/
private $name;
- /**
- * @var string
- *
- * @ORM\Column(name="email", type="string", length=255, nullable=true)
- */
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="email", type="string", length=255, nullable=true)
+ */
private $email;
/**
@@ -55,7 +73,6 @@ class Contact
* @ORM\Column(name="comment", type="text")
*/
private $comment;
-
/**
* @var \DateTime
@@ -64,9 +81,8 @@ class Contact
*/
private $createdAt;
-
/**
- * Get id
+ * Get id.
*
* @return int
*/
@@ -76,7 +92,7 @@ class Contact
}
/**
- * Set name
+ * Set name.
*
* @param int $userId
*
@@ -90,7 +106,7 @@ class Contact
}
/**
- * Get name
+ * Get name.
*
* @return string
*/
@@ -100,7 +116,7 @@ class Contact
}
/**
- * Set name
+ * Set name.
*
* @param string $name
*
@@ -114,7 +130,7 @@ class Contact
}
/**
- * Get name
+ * Get name.
*
* @return string
*/
@@ -123,30 +139,32 @@ class Contact
return $this->name;
}
- /**
- * Set Email
- *
- * @param null|string $email
- *
- * @return \Sikofitt\DoughnutWeddingBundle\Entity\Contact
- */
- public function setEmail(?string $email) : Contact {
- $this->email = $email;
+ /**
+ * Set Email.
+ *
+ * @param null|string $email
+ *
+ * @return \Sikofitt\DoughnutWeddingBundle\Entity\Contact
+ */
+ public function setEmail(?string $email): Contact
+ {
+ $this->email = $email;
- return $this;
+ return $this;
}
/**
- * Get Email
- *
- * @return null|string
- */
- public function getEmail() : ?string {
- return $this->email;
+ * Get Email.
+ *
+ * @return null|string
+ */
+ public function getEmail(): ?string
+ {
+ return $this->email;
}
/**
- * Set subject
+ * Set subject.
*
* @param string $subject
*
@@ -160,7 +178,7 @@ class Contact
}
/**
- * Get subject
+ * Get subject.
*
* @return string
*/
@@ -170,7 +188,7 @@ class Contact
}
/**
- * Set comment
+ * Set comment.
*
* @param string $comment
*
@@ -184,7 +202,7 @@ class Contact
}
/**
- * Get comment
+ * Get comment.
*
* @return string
*/
@@ -193,9 +211,8 @@ class Contact
return $this->comment;
}
-
/**
- * Set createdAt
+ * Set createdAt.
*
* @param \DateTime $createdAt
*
@@ -209,7 +226,7 @@ class Contact
}
/**
- * Get createdAt
+ * Get createdAt.
*
* @return \DateTime
*/
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Entity/Image.php b/src/Sikofitt/DoughnutWeddingBundle/Entity/Image.php
index caeca72..bb29904 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Entity/Image.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Entity/Image.php
@@ -1,13 +1,35 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Entity;
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
-use Vich\UploaderBundle\Mapping\Annotation as Vich;
-use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\File;
+use Symfony\Component\HttpFoundation\File\UploadedFile;
+use Vich\UploaderBundle\Mapping\Annotation as Vich;
+
/**
- * Image
+ * Image.
+ *
* @Vich\Uploadable()
* @ORM\Table(name="image")
* @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\ImageRepository")
@@ -24,7 +46,7 @@ class Image
private $id;
/**
- * @var File
+ * @var UploadedFile
*
* @Vich\UploadableField(mapping="gallery_image", fileNameProperty="imageName", size="imageSize")
*/
@@ -44,46 +66,64 @@ class Image
*/
private $user;
- /**
- * @var string
- *
- * @ORM\Column(name="tags", type="json_array", nullable=true, unique=false)
- */
+ /**
+ * @var \Sikofitt\DoughnutWeddingBundle\Entity\ImageComment
+ *
+ * @ORM\OneToMany(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\ImageComment", mappedBy="image", cascade={"remove"})
+ */
+ private $comments;
+
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="tags", type="json_array", nullable=true, unique=false)
+ */
private $tags;
- /**
- * @var string
- *
- * @ORM\Column(name="category", type="string", length=255, nullable=true, unique=false)
- */
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="category", type="string", length=255, nullable=true, unique=false)
+ */
private $category;
- /**
- * @var string
- *
- * @ORM\Column(name="description", type="text", nullable=true, unique=false)
- */
+ /**
+ * @var string
+ *
+ * @ORM\Column(name="description", type="text", nullable=true, unique=false)
+ */
private $description;
- /**
- * @var bool
- *
- * @ORM\Column(name="is_published", type="boolean")
- */
+ /**
+ * @var bool
+ *
+ * @ORM\Column(name="is_published", type="boolean")
+ */
private $isPublished = true;
- /**
- * @var \DateTimeImmutable
- *
- * @ORM\Column(name="updated_at", type="datetime", nullable=true)
- */
- private $updatedAt;
/**
- * Get id
+ * @var \DateTimeImmutable
+ *
+ * @ORM\Column(name="updated_at", type="datetime", nullable=true)
+ */
+ private $updatedAt;
+
+ public function __construct()
+ {
+ $this->comments = new ArrayCollection();
+ }
+
+ public function __toString()
+ {
+ return $this->imageName;
+ }
+
+ /**
+ * Get id.
*
* @return int
*/
- public function getId() : ?int
+ public function getId(): ?int
{
return $this->id;
}
@@ -91,8 +131,9 @@ class Image
/**
* @return string
*/
- public function getDescription(): ?string {
- return $this->description;
+ public function getDescription(): ?string
+ {
+ return $this->description;
}
/**
@@ -100,16 +141,56 @@ class Image
*
* @return Image
*/
- public function setDescription(?string $description): Image {
- $this->description = $description;
- return $this;
+ public function setDescription(?string $description): Image
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ public function getComments(): ?Collection
+ {
+ return $this->comments;
+ }
+
+ /**
+ * @param \Doctrine\Common\Collections\ArrayCollection|null $comments
+ *
+ * @return \Sikofitt\DoughnutWeddingBundle\Entity\Image
+ */
+ public function setComments(?ArrayCollection $comments): Image
+ {
+ $this->comments = $comments;
+
+ return $this;
+ }
+
+ /**
+ * @param \Sikofitt\DoughnutWeddingBundle\Entity\ImageComment|null $comment
+ */
+ public function addComment(ImageComment $comment = null): void
+ {
+ $this->comments[] = $comment;
+ }
+
+ /**
+ * @param \Sikofitt\DoughnutWeddingBundle\Entity\ImageComment|null $comment
+ *
+ * @return \Sikofitt\DoughnutWeddingBundle\Entity\Image
+ */
+ public function removeComment(ImageComment $comment = null): Image
+ {
+ $this->comments->removeElement($comment);
+
+ return $this;
}
/**
* @return bool
*/
- public function isIsPublished(): bool {
- return $this->isPublished;
+ public function isIsPublished(): bool
+ {
+ return $this->isPublished;
}
/**
@@ -117,63 +198,68 @@ class Image
*
* @return Image
*/
- public function setIsPublished(bool $isPublished): Image {
- $this->isPublished = $isPublished;
- return $this;
+ public function setIsPublished(bool $isPublished): Image
+ {
+ $this->isPublished = $isPublished;
+
+ return $this;
}
/**
- * @return \DateTimeImmutable
+ * @return \DateTimeInterface
*/
- public function getUpdatedAt(): ?\DateTimeImmutable {
- return $this->updatedAt;
+ public function getUpdatedAt(): ?\DateTimeInterface
+ {
+ return $this->updatedAt;
}
/**
- * @param \DateTimeImmutable $updatedAt
+ * @param \DateTimeInterface $updatedAt
*
* @return Image
*/
- public function setUpdatedAt(\DateTimeImmutable $updatedAt): Image {
- $this->updatedAt = $updatedAt;
- return $this;
+ public function setUpdatedAt(\DateTimeInterface $updatedAt): Image
+ {
+ $this->updatedAt = $updatedAt;
+
+ return $this;
}
-
/**
- * Set imageFile
+ * Set imageFile.
*
* @param File|UploadedFile $imageFile
*
* @return Image
*/
- public function setImageFile(?File $imageFile) : Image
+ public function setImageFile(?File $imageFile): Image
{
$this->imageFile = $imageFile;
- if($imageFile) {
- $this->updatedAt = new \DateTimeImmutable();
+ if ($imageFile) {
+ $this->updatedAt = new \DateTimeImmutable();
}
+
return $this;
}
/**
- * Get imageFile
+ * Get imageFile.
*
* @return File|null
*/
- public function getImageFile() : ?File
+ public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
- * Set imageName
+ * Set imageName.
*
* @param string $imageName
*
* @return Image
*/
- public function setImageName(string $imageName) : Image
+ public function setImageName(?string $imageName): Image
{
$this->imageName = $imageName;
@@ -181,28 +267,27 @@ class Image
}
/**
- * Get imageName
+ * Get imageName.
*
* @return string
*/
- public function getImageName() : ?string
+ public function getImageName(): ?string
{
- if(null === $this->imageName && null !== $this->imageFile) {
- return $this->imageFile->getFilename();
- }
- return $this->imageName;
+ if (null === $this->imageName && null !== $this->imageFile) {
+ return $this->imageFile->getFilename();
+ }
+ return $this->imageName;
}
-
/**
- * Set user
+ * Set user.
*
* @param User $user
*
* @return Image
*/
- public function setUser(?User $user) : Image
+ public function setUser(?User $user): Image
{
$this->user = $user;
@@ -210,23 +295,23 @@ class Image
}
/**
- * Get user
+ * Get user.
*
* @return User
*/
- public function getUser() : ?User
+ public function getUser(): ?User
{
return $this->user;
}
/**
- * Set tags
+ * Set tags.
*
* @param array $tags
*
* @return Image
*/
- public function setTags($tags) : Image
+ public function setTags($tags): Image
{
$this->tags = $tags;
@@ -234,7 +319,7 @@ class Image
}
/**
- * Get tags
+ * Get tags.
*
* @return array
*/
@@ -244,7 +329,7 @@ class Image
}
/**
- * Set category
+ * Set category.
*
* @param string $category
*
@@ -258,7 +343,7 @@ class Image
}
/**
- * Get category
+ * Get category.
*
* @return string
*/
@@ -266,8 +351,4 @@ class Image
{
return $this->category;
}
- public function __toString() {
- return $this->imageName;
- //return sprintf('
', $this->imageName, $this->imageName);
- }
}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Entity/ImageComment.php b/src/Sikofitt/DoughnutWeddingBundle/Entity/ImageComment.php
index 5692828..68a5768 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Entity/ImageComment.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Entity/ImageComment.php
@@ -1,11 +1,29 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
- * ImageComment
+ * ImageComment.
*
* @ORM\Table(name="image_comment")
* @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\ImageCommentRepository")
@@ -22,16 +40,23 @@ class ImageComment
private $id;
/**
- * @var int
+ * @var \Sikofitt\DoughnutWeddingBundle\Entity\User
*
- * @ORM\Column(name="user", type="integer")
+ * @ORM\ManyToOne(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\User", inversedBy="imageComment")
*/
private $user;
+ /**
+ * @var int
+ *
+ * @ORM\ManyToOne(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\Image", inversedBy="comments", cascade={"persist"})
+ */
+ private $image;
+
/**
* @var string
*
- * @ORM\Column(name="comment", type="text")
+ * @ORM\Column(type="text", name="comment", nullable=false, unique=false)
*/
private $comment;
@@ -49,13 +74,6 @@ class ImageComment
*/
private $created;
- /**
- * @var int
- *
- * @ORM\Column(name="image", type="integer")
- */
- private $image;
-
/**
* @var bool
*
@@ -63,9 +81,8 @@ class ImageComment
*/
private $isChild;
-
/**
- * Get id
+ * Get id.
*
* @return int
*/
@@ -75,13 +92,13 @@ class ImageComment
}
/**
- * Set user
+ * Set user.
*
- * @param integer $user
+ * @param \Sikofitt\DoughnutWeddingBundle\Entity\User|null $user
*
* @return ImageComment
*/
- public function setUser($user)
+ public function setUser(?User $user): ImageComment
{
$this->user = $user;
@@ -89,17 +106,17 @@ class ImageComment
}
/**
- * Get user
+ * Get user.
*
- * @return int
+ * @return \Sikofitt\DoughnutWeddingBundle\Entity\User
*/
- public function getUser()
+ public function getUser(): ?User
{
return $this->user;
}
/**
- * Set comment
+ * Set comment.
*
* @param string $comment
*
@@ -113,7 +130,7 @@ class ImageComment
}
/**
- * Get comment
+ * Get comment.
*
* @return string
*/
@@ -123,9 +140,9 @@ class ImageComment
}
/**
- * Set childComments
+ * Set childComments.
*
- * @param integer $childComments
+ * @param int $childComments
*
* @return ImageComment
*/
@@ -137,7 +154,7 @@ class ImageComment
}
/**
- * Get childComments
+ * Get childComments.
*
* @return int
*/
@@ -147,7 +164,7 @@ class ImageComment
}
/**
- * Set created
+ * Set created.
*
* @param \DateTime $created
*
@@ -161,7 +178,7 @@ class ImageComment
}
/**
- * Get created
+ * Get created.
*
* @return \DateTime
*/
@@ -171,9 +188,9 @@ class ImageComment
}
/**
- * Set image
+ * Set image.
*
- * @param integer $image
+ * @param int $image
*
* @return ImageComment
*/
@@ -185,7 +202,7 @@ class ImageComment
}
/**
- * Get image
+ * Get image.
*
* @return int
*/
@@ -195,9 +212,9 @@ class ImageComment
}
/**
- * Set isChild
+ * Set isChild.
*
- * @param boolean $isChild
+ * @param bool $isChild
*
* @return ImageComment
*/
@@ -209,7 +226,7 @@ class ImageComment
}
/**
- * Get isChild
+ * Get isChild.
*
* @return bool
*/
@@ -218,4 +235,3 @@ class ImageComment
return $this->isChild;
}
}
-
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Entity/Rsvp.php b/src/Sikofitt/DoughnutWeddingBundle/Entity/Rsvp.php
index 7ae08e8..654a960 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Entity/Rsvp.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Entity/Rsvp.php
@@ -75,6 +75,11 @@ class Rsvp
$this->updated = new \DateTime('now');
}
+ public function __toString()
+ {
+ return sprintf('%d guests', $this->guests);
+ }
+
/**
* Get id.
*
@@ -180,8 +185,4 @@ class Rsvp
{
return $this->user;
}
-
- public function __toString() {
- return sprintf('%d guests', $this->guests);
- }
}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Entity/User.php b/src/Sikofitt/DoughnutWeddingBundle/Entity/User.php
index 6f0d78e..656363d 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Entity/User.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Entity/User.php
@@ -22,7 +22,6 @@ namespace Sikofitt\DoughnutWeddingBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
-use Doctrine\ORM\PersistentCollection;
use Symfony\Component\Validator\Constraints as Assert;
/** @noinspection ClassOverridesFieldOfSuperClassInspection */
@@ -33,11 +32,11 @@ use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Entity(repositoryClass="Sikofitt\DoughnutWeddingBundle\Repository\UserRepository")
* @ORM\Table(name="users")
*/
-class User extends \FOS\UserBundle\Model\User {
+class User extends \FOS\UserBundle\Model\User
+{
+ const KATRINA_SIDE = 'Katrina';
- const KATRINA_SIDE = 'Katrina';
-
- const ERIC_SIDE = 'Eric';
+ const ERIC_SIDE = 'Eric';
/**
* @ORM\Id()
@@ -79,6 +78,13 @@ class User extends \FOS\UserBundle\Model\User {
*/
private $images;
+ /**
+ * @var \Sikofitt\DoughnutWeddingBundle\Entity\ImageComment
+ *
+ * @ORM\OneToMany(targetEntity="Sikofitt\DoughnutWeddingBundle\Entity\ImageComment", mappedBy="user")
+ */
+ private $imageComment;
+
/**
* @var string
*
@@ -91,66 +97,100 @@ class User extends \FOS\UserBundle\Model\User {
*/
private $facebookId;
- private $facebookAccessToken;
+ private $facebookAccessToken;
/**
* @ORM\Column(name="google_id", type="string", length=255, nullable=true)
*/
private $googleId;
- private $googleAccessToken;
+ private $googleAccessToken;
/**
* @ORM\Column(name="amazon_id", type="string", length=255, nullable=true)
*/
private $amazonId;
- private $amazonAccessToken;
+ private $amazonAccessToken;
/**
* @ORM\Column(name="instagram_id", type="string", length=255, nullable=true)
*/
private $instagramId;
- private $instagramAccessToken;
+ private $instagramAccessToken;
/**
* @ORM\Column(name="twitter_id", type="string", length=255, nullable=true)
*/
private $twitterId;
- private $twitterAccessToken;
+ private $twitterAccessToken;
/**
* @ORM\Column(name="yahoo_id", type="string", length=255, nullable=true)
*/
private $yahooId;
- private $yahooAccessToken;
+ private $yahooAccessToken;
/**
* User constructor.
*/
- public function __construct() {
- if (NULL === $this->created) {
- $this->created = new \DateTime('now');
- }
- $this->updated = new \DateTime('now');
- parent::__construct();
+ public function __construct()
+ {
+ $this->imageComment = new ArrayCollection();
+ if (null === $this->created) {
+ $this->created = new \DateTime('now');
+ }
+ $this->updated = new \DateTime('now');
+ parent::__construct();
}
- public function getComment() : ?string {
- return $this->comment;
- }
- public function setComment(?string $comment) : User {
- $this->comment = $comment;
- return $this;
- }
+ public function setImageComment($imageComment)
+ {
+ $this->imageComment = $imageComment;
+
+ return $this;
+ }
+
+ public function getImageComment()
+ {
+ return $this->imageComment;
+ }
+
+ public function addImageComment(ImageComment $imageComment)
+ {
+ $imageComment->setUser($this);
+ $this->imageComment[] = $imageComment;
+
+ return $this;
+ }
+
+ public function removeImageComment(ImageComment $imageComment)
+ {
+ $imageComment->setUser(null);
+ $this->imageComment->removeElement($imageComment);
+ }
+
+ public function getComment(): ?string
+ {
+ return $this->comment;
+ }
+
+ public function setComment(?string $comment): User
+ {
+ $this->comment = $comment;
+
+ return $this;
+ }
+
/**
* @return mixed
*/
- public function getAmazonId() : ?string {
- return $this->amazonId;
+ public function getAmazonId(): ?string
+ {
+ return $this->amazonId;
}
/**
@@ -158,17 +198,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setAmazonId(?string $amazonId) : User {
- $this->amazonId = $amazonId;
+ public function setAmazonId(?string $amazonId): User
+ {
+ $this->amazonId = $amazonId;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getAmazonAccessToken() : ?string {
- return $this->amazonAccessToken;
+ public function getAmazonAccessToken(): ?string
+ {
+ return $this->amazonAccessToken;
}
/**
@@ -176,17 +218,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setAmazonAccessToken(?string $amazonAccessToken) : User {
- $this->amazonAccessToken = $amazonAccessToken;
+ public function setAmazonAccessToken(?string $amazonAccessToken): User
+ {
+ $this->amazonAccessToken = $amazonAccessToken;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getFacebookId() : ?string {
- return $this->facebookId;
+ public function getFacebookId(): ?string
+ {
+ return $this->facebookId;
}
/**
@@ -194,17 +238,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setFacebookId(string $facebookId) : User {
- $this->facebookId = $facebookId;
+ public function setFacebookId(string $facebookId): User
+ {
+ $this->facebookId = $facebookId;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getFacebookAccessToken() : ?string {
- return $this->facebookAccessToken;
+ public function getFacebookAccessToken(): ?string
+ {
+ return $this->facebookAccessToken;
}
/**
@@ -212,17 +258,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setFacebookAccessToken(?string $facebookAccessToken) : User {
- $this->facebookAccessToken = $facebookAccessToken;
+ public function setFacebookAccessToken(?string $facebookAccessToken): User
+ {
+ $this->facebookAccessToken = $facebookAccessToken;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getGoogleId() : ?string {
- return $this->googleId;
+ public function getGoogleId(): ?string
+ {
+ return $this->googleId;
}
/**
@@ -230,17 +278,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setGoogleId(?string $googleId) : User {
- $this->googleId = $googleId;
+ public function setGoogleId(?string $googleId): User
+ {
+ $this->googleId = $googleId;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getGoogleAccessToken() : ?string {
- return $this->googleAccessToken;
+ public function getGoogleAccessToken(): ?string
+ {
+ return $this->googleAccessToken;
}
/**
@@ -248,17 +298,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setGoogleAccessToken(?string $googleAccessToken) : User {
- $this->googleAccessToken = $googleAccessToken;
+ public function setGoogleAccessToken(?string $googleAccessToken): User
+ {
+ $this->googleAccessToken = $googleAccessToken;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getInstagramId() : ?string{
- return $this->instagramId;
+ public function getInstagramId(): ?string
+ {
+ return $this->instagramId;
}
/**
@@ -266,17 +318,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setInstagramId(?string $instagramId) : User {
- $this->instagramId = $instagramId;
+ public function setInstagramId(?string $instagramId): User
+ {
+ $this->instagramId = $instagramId;
- return $this;
+ return $this;
}
/**
* @return mixed
*/
- public function getInstagramAccessToken() : ?string {
- return $this->instagramAccessToken;
+ public function getInstagramAccessToken(): ?string
+ {
+ return $this->instagramAccessToken;
}
/**
@@ -284,17 +338,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setInstagramAccessToken(?string $instagramAccessToken) : User {
- $this->instagramAccessToken = $instagramAccessToken;
+ public function setInstagramAccessToken(?string $instagramAccessToken): User
+ {
+ $this->instagramAccessToken = $instagramAccessToken;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getTwitterId() : ?string {
- return $this->twitterId;
+ public function getTwitterId(): ?string
+ {
+ return $this->twitterId;
}
/**
@@ -302,17 +358,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setTwitterId(?string $twitterId) : User {
- $this->twitterId = $twitterId;
+ public function setTwitterId(?string $twitterId): User
+ {
+ $this->twitterId = $twitterId;
- return $this;
+ return $this;
}
/**
* @return mixed
*/
- public function getTwitterAccessToken() {
- return $this->twitterAccessToken;
+ public function getTwitterAccessToken()
+ {
+ return $this->twitterAccessToken;
}
/**
@@ -320,18 +378,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setTwitterAccessToken(?string $twitterAccessToken) : User {
- $this->twitterAccessToken = $twitterAccessToken;
+ public function setTwitterAccessToken(?string $twitterAccessToken): User
+ {
+ $this->twitterAccessToken = $twitterAccessToken;
- return $this;
+ return $this;
}
-
/**
* @return string
*/
- public function getYahooId() : ?string {
- return $this->yahooId;
+ public function getYahooId(): ?string
+ {
+ return $this->yahooId;
}
/**
@@ -339,17 +398,19 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setYahooId(?string $yahooId) : User {
- $this->yahooId = $yahooId;
+ public function setYahooId(?string $yahooId): User
+ {
+ $this->yahooId = $yahooId;
- return $this;
+ return $this;
}
/**
* @return string
*/
- public function getYahooAccessToken() : ?string {
- return $this->yahooAccessToken;
+ public function getYahooAccessToken(): ?string
+ {
+ return $this->yahooAccessToken;
}
/**
@@ -357,10 +418,11 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setYahooAccessToken(?string $yahooAccessToken): User {
- $this->yahooAccessToken = $yahooAccessToken;
+ public function setYahooAccessToken(?string $yahooAccessToken): User
+ {
+ $this->yahooAccessToken = $yahooAccessToken;
- return $this;
+ return $this;
}
/**
@@ -368,8 +430,9 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return string
*/
- public function getName(): ?string {
- return $this->name;
+ public function getName(): ?string
+ {
+ return $this->name;
}
/**
@@ -379,31 +442,33 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setName(string $name): User {
- $this->name = $name;
+ public function setName(string $name): User
+ {
+ $this->name = $name;
- return $this;
+ return $this;
}
- /**
+ /**
* @param string $plainPassword
*
* @return User
*/
- public function setPlainPassword($plainPassword): User {
- $this->plainPassword = $plainPassword;
+ public function setPlainPassword($plainPassword): User
+ {
+ $this->plainPassword = $plainPassword;
- return $this;
+ return $this;
}
-
/**
* Get created.
*
* @return \DateTime
*/
- public function getCreated(): ?\DateTime {
- return $this->created;
+ public function getCreated(): ?\DateTime
+ {
+ return $this->created;
}
/**
@@ -413,10 +478,11 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setCreated(?\DateTime $created): User {
- $this->created = $created;
+ public function setCreated(?\DateTime $created): User
+ {
+ $this->created = $created;
- return $this;
+ return $this;
}
/**
@@ -424,8 +490,9 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return \DateTime
*/
- public function getUpdated(): ?\DateTime {
- return $this->updated;
+ public function getUpdated(): ?\DateTime
+ {
+ return $this->updated;
}
/**
@@ -435,10 +502,11 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setUpdated(?\DateTime $updated): User {
- $this->updated = $updated;
+ public function setUpdated(?\DateTime $updated): User
+ {
+ $this->updated = $updated;
- return $this;
+ return $this;
}
/**
@@ -446,8 +514,9 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return Rsvp
*/
- public function getRsvp(): ?Rsvp {
- return $this->rsvp;
+ public function getRsvp(): ?Rsvp
+ {
+ return $this->rsvp;
}
/**
@@ -457,47 +526,48 @@ class User extends \FOS\UserBundle\Model\User {
*
* @return User
*/
- public function setRsvp(Rsvp $rsvp = NULL) : User {
- $this->rsvp = $rsvp;
+ public function setRsvp(Rsvp $rsvp = null): User
+ {
+ $this->rsvp = $rsvp;
- return $this;
+ return $this;
}
/**
- * Add image
+ * Add image.
*
* @param \Sikofitt\DoughnutWeddingBundle\Entity\Image $image
*
* @return User
*/
- public function addImage(Image $image): User {
- $image->setUser($this);
+ public function addImage(Image $image): User
+ {
+ $image->setUser($this);
- $this->images[] = $image;
+ $this->images[] = $image;
- return $this;
+ return $this;
}
/**
- * Remove image
+ * Remove image.
*
* @param \Sikofitt\DoughnutWeddingBundle\Entity\Image $image
- *
- * @return Void
*/
- public function removeImage(Image $image): void {
- $image->setUser(NULL);
+ public function removeImage(Image $image): void
+ {
+ $image->setUser(null);
- $this->images->removeElement($image);
+ $this->images->removeElement($image);
}
/**
- * Get images
+ * Get images.
*
* @return \Doctrine\Common\Collections\Collection
*/
- public function getImages() {
-
- return $this->images;
+ public function getImages()
+ {
+ return $this->images;
}
}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/EventListener/CheckThatEmailAndUserNameExistOnResetRequest.php b/src/Sikofitt/DoughnutWeddingBundle/EventListener/CheckThatEmailAndUserNameExistOnResetRequest.php
index 127d1fa..1d8209a 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/EventListener/CheckThatEmailAndUserNameExistOnResetRequest.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/EventListener/CheckThatEmailAndUserNameExistOnResetRequest.php
@@ -1,26 +1,32 @@
.
*/
namespace Sikofitt\DoughnutWeddingBundle\EventListener;
-
-use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Event\GetResponseUserEvent;
-use FOS\UserBundle\FOSUserEvents;
use Symfony\Bridge\Twig\TwigEngine;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class CheckThatEmailAndUserNameExistOnResetRequest
{
-
private $router;
private $twig;
@@ -30,14 +36,12 @@ class CheckThatEmailAndUserNameExistOnResetRequest
$this->twig = $twig;
}
- public function onFosuserResettingSendemailInitialize(GetResponseUserEvent $event) {
-
- if(null === $event->getUser()) {
+ public function onFosuserResettingSendemailInitialize(GetResponseUserEvent $event)
+ {
+ if (null === $event->getUser()) {
$email = $event->getRequest()->request->get('username');
- $event->getRequest()->getSession()->getFlashBag()->add('error',sprintf('Invalid email %s.', $email));
+ $event->getRequest()->getSession()->getFlashBag()->add('error', sprintf('Invalid email %s.', $email));
$event->setResponse(new RedirectResponse($this->router->generate('fos_user_resetting_request')));
}
}
-
-
-}
\ No newline at end of file
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/EventListener/NeedToAuthenticateListenerEvent.php b/src/Sikofitt/DoughnutWeddingBundle/EventListener/NeedToAuthenticateListenerEvent.php
index dc2f472..0879b48 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/EventListener/NeedToAuthenticateListenerEvent.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/EventListener/NeedToAuthenticateListenerEvent.php
@@ -1,9 +1,25 @@
.
+ */
namespace Sikofitt\DoughnutWeddingBundle\EventListener;
-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
@@ -13,7 +29,6 @@ use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
*/
class NeedToAuthenticateListenerEvent
{
-
/**
* Adds a flash message for login redirects.
*
@@ -21,29 +36,31 @@ class NeedToAuthenticateListenerEvent
*/
public function onKernelResponse(FilterResponseEvent $event): void
{
- if (
- true === $event
- ->getResponse()
- ->headers
- ->has('location') &&
- false !== strpos($event->getResponse()->headers->get('location'),
- '/login') &&
- true === $event
- ->getRequest()
- ->getSession()
- ->has('_security.secured_area.target_path')
- ) {
- $targetPath = $event
- ->getRequest()
- ->getSession()
- ->get('_security.secured_area.target_path');
- $message = sprintf('You need to login to view %s', $targetPath);
- $event
- ->getRequest()
- ->getSession()
- ->getFlashBag()
- ->add('warning', $message);
- }
+ if (null !== $event->getRequest()->getUser()) {
+ if (
+ true === $event
+ ->getResponse()
+ ->headers
+ ->has('location') &&
+ false !== strpos($event->getResponse()->headers->get('location'),
+ '/login') &&
+ true === $event
+ ->getRequest()
+ ->getSession()
+ ->has('_security.secured_area.target_path')
+ ) {
+ $targetPath = $event
+ ->getRequest()
+ ->getSession()
+ ->get('_security.secured_area.target_path');
+ $message = sprintf('You need to login to view %s', $targetPath);
+ $event
+ ->getRequest()
+ ->getSession()
+ ->getFlashBag()
+ ->add('warning', $message);
+ }
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/EventListener/RedirectFromHwiConnectPageEvent.php b/src/Sikofitt/DoughnutWeddingBundle/EventListener/RedirectFromHwiConnectPageEvent.php
new file mode 100644
index 0000000..9779f52
--- /dev/null
+++ b/src/Sikofitt/DoughnutWeddingBundle/EventListener/RedirectFromHwiConnectPageEvent.php
@@ -0,0 +1,74 @@
+.
+ */
+
+namespace Sikofitt\DoughnutWeddingBundle\EventListener;
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+
+/**
+ * Event listener to redirect /connect to /login.
+ *
+ * Class RedirectFromHwiConnectPageEvent
+ */
+class RedirectFromHwiConnectPageEvent
+{
+ /**
+ * @var \Symfony\Component\Routing\Generator\UrlGeneratorInterface
+ */
+ private $router;
+
+ /**
+ * @var \Symfony\Component\DependencyInjection\ContainerInterface
+ */
+ private $container;
+
+ /**
+ * RedirectFromHwiConnectPageEvent constructor.
+ *
+ * @param \Symfony\Component\Routing\Generator\UrlGeneratorInterface $router
+ * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
+ */
+ public function __construct(UrlGeneratorInterface $router, ContainerInterface $container)
+ {
+ $this->router = $router;
+ $this->container = $container;
+ }
+
+ /**
+ * Since there doesn't seem to be an option to prevent this.
+ * Redirect users to the /login page if they hit /connect.
+ *
+ * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
+ */
+ public function onKernelRequest(GetResponseEvent $event): void
+ {/*
+ $uri = $this->container->get('request_stack')->getCurrentRequest()->getRequestUri();
+ $loginUri = $this->router->generate('fos_user_security_login');
+ $connectRoute = $this->router->generate('hwi_oauth_connect');
+
+ if(0 === (int) strcmp($uri, $connectRoute)) {
+ $event->setResponse(new RedirectResponse($loginUri, 301));
+ }
+*/
+ }
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/EventListener/RedirectOnUserRegisterListener.php b/src/Sikofitt/DoughnutWeddingBundle/EventListener/RedirectOnUserRegisterListener.php
index 0daeeae..35a2489 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/EventListener/RedirectOnUserRegisterListener.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/EventListener/RedirectOnUserRegisterListener.php
@@ -1,52 +1,109 @@
.
*/
namespace Sikofitt\DoughnutWeddingBundle\EventListener;
-
use FOS\UserBundle\Event\FilterUserResponseEvent;
-use FOS\UserBundle\Event\FormEvent;
-use FOS\UserBundle\FOSUserEvents;
-use Symfony\Bridge\Twig\TwigEngine;
+use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Security\Core\User\UserInterface;
+use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
+/**
+ * Class RedirectOnUserRegisterListener.
+ */
class RedirectOnUserRegisterListener
{
-
+ /**
+ * @var \Symfony\Component\DependencyInjection\ContainerInterface
+ */
private $container;
+ /**
+ * RedirectOnUserRegisterListener constructor.
+ *
+ * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
+ */
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
- public function onFosuserRegistrationCompleted(FilterUserResponseEvent $event) {
-
+ /**
+ * @param \FOS\UserBundle\Event\FilterUserResponseEvent $event
+ *
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
+ */
+ public function onFosuserRegistrationCompleted(FilterUserResponseEvent $event): ?RedirectResponse
+ {
$user = $event->getUser();
+ $this->sendRegistrationEmail($user, 'the Default Sign up form');
+ $url = $this
+ ->container
+ ->get('router')
+ ->generate('sikofitt_doughnutwedding_default_index');
+
+ return new RedirectResponse($url);
+ }
+
+ /**
+ * Sends an email if the user has registered with a OAuth
+ * Unfortunately HWIOAuthBundle does not have events, and does not call
+ * the FOSUserBundle register events if using the bridge, so we have to
+ * do it here in the InteractiveLoginEvent listener because it's the only
+ * event HWIOAuthBundle calls.
+ *
+ * @param \Symfony\Component\Security\Http\Event\InteractiveLoginEvent $event
+ */
+ public function onSecurityInteractivelogin(InteractiveLoginEvent $event): void
+ {
+ // Match the registration path so we don't call this on all logins.
+ if (preg_match('/(connect\/registration\/\d+)/', $event->getRequest()->getRequestUri())) {
+ $user = $event->getAuthenticationToken()->getUser();
+ $resourceOwnerName = null;
+ if ($event->getAuthenticationToken() instanceof OAuthToken) {
+ /** @var OAuthToken $token */
+ $token = $event->getAuthenticationToken();
+ $resourceOwnerName = $token->getResourceOwnerName();
+ }
+ $this->sendRegistrationEmail($user, $resourceOwnerName);
+ }
+ }
+
+ /**
+ * @param \Symfony\Component\Security\Core\User\UserInterface $user
+ * @param null|string $resourceOwner
+ */
+ public function sendRegistrationEmail(UserInterface $user, string $resourceOwner = null): void
+ {
$message = new \Swift_Message('[Doughnut Wedding] User registered');
- $body = $this->container->get('twig')->render('user_registered.txt.twig.html.twig', ['user' => $user]);
+ $body = $this->container->get('twig')->render('user_registered.txt.twig.html.twig', ['user' => $user, 'resourceOwner' => $resourceOwner]);
$message
->setFrom(['no-reply@doughnutwedding.com' => '[Doughnut Wedding]'])
->setTo([
- 'katrina.a.johnson@gmail.com' => 'Katrina Johnson',
- 'sikofitt@gmail.com' => 'R. Eric Wheeler'
+ $this->container->getParameter('katrina.email') => 'Katrina Johnson',
+ $this->container->getParameter('eric.email') => 'R. Eric Wheeler',
])->setBody($body);
- $this->container->get('swiftmailer.mailer')->send($message);
- $url = $this->container->get('router')->generate('sikofitt_doughnutwedding_default_index');
- return new RedirectResponse($url);
- }
- public function onKernelRequest(FormEvent $event)
- {
- $url = $this->router->generate('sikofitt_doughnutwedding_default_index');
- $event->setResponse(new RedirectResponse($url));
+ $this->container->get('swiftmailer.mailer')->send($message);
}
-}
\ No newline at end of file
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/EventListener/UserRedirectOnLoggedInListener.php b/src/Sikofitt/DoughnutWeddingBundle/EventListener/UserRedirectOnLoggedInListener.php
index 896c859..56659e8 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/EventListener/UserRedirectOnLoggedInListener.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/EventListener/UserRedirectOnLoggedInListener.php
@@ -62,7 +62,6 @@ class UserRedirectOnLoggedInListener
*/
public function onKernelRequest(GetResponseEvent $event): void
{
-
$token = $this->tokenStorage->getToken();
if (null !== $token) {
@@ -90,7 +89,6 @@ class UserRedirectOnLoggedInListener
*/
private function shouldRedirectRoute(array $routeInformation): bool
{
-
return true === in_array(
$routeInformation['_route'],
$this->getRedirectRoutes(),
@@ -107,9 +105,8 @@ class UserRedirectOnLoggedInListener
return [
'fos_user_security_login',
'fos_user_registration_confirmed',
- 'hwi_oauth_connect',
'fos_user_resetting_request',
- 'fos_user_registration_register'
+ 'fos_user_registration_register',
];
}
}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Factory/GoogleCloudStorageServiceFactory.php b/src/Sikofitt/DoughnutWeddingBundle/Factory/GoogleCloudStorageServiceFactory.php
index 220a44a..36bedf1 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Factory/GoogleCloudStorageServiceFactory.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Factory/GoogleCloudStorageServiceFactory.php
@@ -1,51 +1,65 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Factory;
-use Gaufrette\Exception\FileNotFound;
use Google\Auth\Credentials\ServiceAccountCredentials;
use Google_Service_Storage;
-class GoogleCloudStorageServiceFactory {
- /**
+class GoogleCloudStorageServiceFactory
+{
+ /**
* @param string $credentialFile
* @param string $clientId
* @param string $applicationName
*
- * @return \Google_Service_Storage
* @throws \ErrorException
* @throws \InvalidArgumentException
+ *
+ * @return \Google_Service_Storage
*/
- public static function createGoogleCloudService(string $credentialFile, string $clientId, string $applicationName) : \Google_Service_Storage
+ public static function createGoogleCloudService(string $credentialFile, string $clientId, string $applicationName): \Google_Service_Storage
{
- if(false === file_exists($credentialFile)) {
- throw new \ErrorException(sprintf('File %s does not exist.', $credentialFile));
- }
- if(false === is_readable($credentialFile)) {
- throw new \ErrorException(sprintf('File %s is not readable. Check permissions.', $credentialFile));
- }
+ if (false === file_exists($credentialFile)) {
+ throw new \ErrorException(sprintf('File %s does not exist.', $credentialFile));
+ }
+ if (false === is_readable($credentialFile)) {
+ throw new \ErrorException(sprintf('File %s is not readable. Check permissions.', $credentialFile));
+ }
- $jsonStr = file_get_contents($credentialFile);
- if( null === $credentials = json_decode($jsonStr, true)) {
- throw new \ErrorException('Could not decode google json credentials');
- }
+ $jsonStr = file_get_contents($credentialFile);
+ if (null === $credentials = json_decode($jsonStr, true)) {
+ throw new \ErrorException('Could not decode google json credentials');
+ }
- $client = new \Google_Client();
- $client->setClientId($clientId);
- $client->setApplicationName($applicationName);
+ $client = new \Google_Client();
+ $client->setClientId($clientId);
+ $client->setApplicationName($applicationName);
-
- $cred = ServiceAccountCredentials::makeCredentials(
+ $cred = ServiceAccountCredentials::makeCredentials(
Google_Service_Storage::DEVSTORAGE_FULL_CONTROL,
$credentials
);
- $token = $cred->fetchAuthToken();
- $client->setAccessToken($token);
+ $token = $cred->fetchAuthToken();
+ $client->setAccessToken($token);
-
-
-
- return new \Google_Service_Storage($client);
+ return new \Google_Service_Storage($client);
}
-
-}
\ No newline at end of file
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Form/ChangePasswordFormType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/ChangePasswordFormType.php
index 8b7286b..83dedfa 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Form/ChangePasswordFormType.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Form/ChangePasswordFormType.php
@@ -1,24 +1,37 @@
.
*/
namespace Sikofitt\DoughnutWeddingBundle\Form;
-
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
-class ChangePasswordFormType extends AbstractType {
+class ChangePasswordFormType extends AbstractType
+{
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $builder->remove('current_password');
+ }
- public function buildForm(FormBuilderInterface $builder, array $options) {
- $builder->remove('current_password');
- }
-
- public function getParent() {
- return \FOS\UserBundle\Form\Type\ChangePasswordFormType::class;
- }
-}
\ No newline at end of file
+ public function getParent()
+ {
+ return \FOS\UserBundle\Form\Type\ChangePasswordFormType::class;
+ }
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Form/ContactFormType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/ContactFormType.php
index 713f27d..9ff8ab8 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Form/ContactFormType.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Form/ContactFormType.php
@@ -1,10 +1,27 @@
-.
+ */
namespace Sikofitt\DoughnutWeddingBundle\Form;
-
-use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaType;
-use ReCaptcha\ReCaptcha;
use Sikofitt\DoughnutWeddingBundle\Entity\Contact;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
@@ -17,24 +34,25 @@ use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\NotNull;
-use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrue as RecaptchaTrue;
-/**
- * Class ContactFormType
- */
-class ContactFormType extends AbstractType {
- /**
- * @inheritdoc
+/**
+ * Class ContactFormType.
+ */
+class ContactFormType extends AbstractType
+{
+ /**
+ * {@inheritdoc}
*/
- public function buildForm(FormBuilderInterface $builder, array $options) : void {
- $builder
+ public function buildForm(FormBuilderInterface $builder, array $options): void
+ {
+ $builder
->add('name', TextType::class, [
'label_attr' => [
'class' => 'uk-form-label uk-visible@m',
],
'label' => 'Name',
'attr' => [
- 'class' => 'uk-input uk-form-large uk-margin-small-bottom',
+ 'class' => 'uk-padding-small uk-input uk-form-large uk-margin-small-bottom',
'placeholder' => 'Enter your name',
],
'required' => true,
@@ -42,8 +60,8 @@ class ContactFormType extends AbstractType {
'constraints' => [
new NotBlank(),
new NotNull(),
- new Length(['max' => 255, 'min' => 5])
- ]
+ new Length(['max' => 255, 'min' => 5]),
+ ],
])
->add('email', EmailType::class, [
'label_attr' => [
@@ -51,7 +69,7 @@ class ContactFormType extends AbstractType {
],
'label' => 'Email (Not required)',
'attr' => [
- 'class' => 'uk-input uk-form-large uk-margin-small-bottom',
+ 'class' => 'uk-padding-small uk-input uk-form-large uk-margin-small-bottom',
'placeholder' => 'Email address (not required)',
'autocomplete' => 'off',
'autocorrect' => 'off',
@@ -65,8 +83,8 @@ class ContactFormType extends AbstractType {
'checkMX' => true,
'checkHost' => true,
'strict' => true,
- ])
- ]
+ ]),
+ ],
])
->add('subject', TextType::class, [
'label_attr' => [
@@ -74,16 +92,16 @@ class ContactFormType extends AbstractType {
],
'label' => 'Subject',
'attr' => [
- 'class' => 'uk-input uk-form-large uk-margin-small-bottom',
- 'placeholder' => 'Enter a subject for our comment.',
+ 'class' => 'uk-padding-small uk-input uk-form-large uk-margin-small-bottom',
+ 'placeholder' => 'Enter a subject for your comment.',
],
'required' => true,
'trim' => true,
'constraints' => [
new NotBlank(),
new NotNull(),
- new Length(['max' => 255, 'min' => 5])
- ]
+ new Length(['max' => 255, 'min' => 5]),
+ ],
])
->add('comment', TextareaType::class, [
'label_attr' => [
@@ -93,36 +111,38 @@ class ContactFormType extends AbstractType {
'attr' => [
'rows' => 4,
'class' => 'uk-padding-small uk-textarea uk-form-large uk-margin-medium-bottom',
- 'placeholder' => 'Enter your Comment',
+ 'placeholder' => 'Enter your comment',
],
'required' => true,
'constraints' => [
new NotBlank(),
new NotNull(),
- ]
+ ],
])
->add('submit', SubmitType::class, [
'label' => 'Send',
'attr' => [
- 'class' => 'uk-button uk-button-primary uk-button-large uk-width-1-1@s uk-width-1-3@m'
- ]
+ 'class' => 'uk-button uk-button-primary uk-button-large uk-width-1-1',
+ ],
]);
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*
* @throws \Symfony\Component\OptionsResolver\Exception\AccessException
*/
- public function configureOptions(OptionsResolver $resolver) : void {
- $resolver->setDefault('data_class', Contact::class);
- $resolver->setDefault('attr', ['class' => 'uk-form uk-form-horizontal']);
+ public function configureOptions(OptionsResolver $resolver): void
+ {
+ $resolver->setDefault('data_class', Contact::class);
+ $resolver->setDefault('attr', ['class' => 'uk-form uk-form-horizontal']);
}
/**
- * @inheritdoc
+ * {@inheritdoc}
*/
- public function getBlockPrefix() : ?string {
- return 'sikofitt_doughnut_wedding_contact';
+ public function getBlockPrefix(): ?string
+ {
+ return 'sikofitt_doughnut_wedding_contact';
}
-}
\ No newline at end of file
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Form/GalleryUploadType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/GalleryUploadType.php
index 8d2094a..5bc32db 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Form/GalleryUploadType.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Form/GalleryUploadType.php
@@ -1,31 +1,80 @@
.
*/
namespace Sikofitt\DoughnutWeddingBundle\Form;
-
use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\Extension\Core\Type\CollectionType;
+use Symfony\Component\Form\Extension\Core\Type\TextareaType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Vich\UploaderBundle\Form\Type\VichImageType;
-class GalleryUploadType extends AbstractType {
-
- public function buildForm(FormBuilderInterface $builder, array $options) {
- $builder->add('imageFile', VichImageType::class, [
+class GalleryUploadType extends AbstractType
+{
+ public function buildForm(FormBuilderInterface $builder, array $options)
+ {
+ $builder->add('imageFile', VichImageType::class, [
'label_attr' => [
- 'class' => 'uk-form-label'
+ 'class' => 'uk-form-label uk-hidden',
],
'attr' => [
- 'class' => ''
- ]
+ 'class' => 'uk-padding-small',
+ ],
])
- ->add('description')
- ->add('tags')
- ->add('category');
- }
-}
\ No newline at end of file
+ ->add('description', TextareaType::class, [
+ 'required' => false,
+ 'label' => 'Description of image.',
+ 'attr' => [
+ 'rows' => 4,
+ 'class' => 'uk-textarea uk-form-large uk-padding-small',
+ ],
+ 'label_attr' => [
+ 'class' => 'uk-form-label',
+ ],
+ ])
+ ->add('tags', CollectionType::class, [
+ 'required' => false,
+ 'entry_type' => TextType::class,
+ 'entry_options' => [
+ 'attr' => [
+ 'class' => 'uk-input uk-form-large uk-width-medium',
+ ],
+ ],
+ 'allow_add' => true,
+ 'allow_delete' => true,
+ 'label_attr' => [
+ 'class' => 'uk-form-label',
+ ],
+ 'attr' => [
+ 'class' => 'uk-input uk-form-large uk-padding-small',
+ ],
+ ])
+ ->add('category', TextType::class, [
+ 'required' => false,
+ 'label_attr' => [
+ 'class' => 'uk-form-label',
+ ],
+ 'attr' => [
+ 'class' => 'uk-input uk-form-large uk-padding-small',
+ ],
+ ]);
+ }
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Form/ProfileEditType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/ProfileEditType.php
index 0e34ee2..5eb8740 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Form/ProfileEditType.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Form/ProfileEditType.php
@@ -1,18 +1,27 @@
.
*/
namespace Sikofitt\DoughnutWeddingBundle\Form;
-
-use Symfony\Component\Form\FormEvent;
use FOS\UserBundle\Form\Type\ProfileFormType;
use FOS\UserBundle\Model\UserManager;
-use HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse;
use Sikofitt\DoughnutWeddingBundle\Entity\Rsvp;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
@@ -20,17 +29,19 @@ use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
-use Symfony\Component\OptionsResolver\OptionsResolver;
class ProfileEditType extends AbstractType
{
-private $userManager;
- public function __construct(UserManager $userManager) {
- $this->userManager = $userManager;
- }
+ private $userManager;
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function __construct(UserManager $userManager)
+ {
+ $this->userManager = $userManager;
+ }
+
+ public function buildForm(FormBuilderInterface $builder, array $options)
{
$emailOptions = $builder->get('email')->getOptions();
@@ -66,12 +77,11 @@ private $userManager;
],
]);
- $builder->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) {
-
- $user = $event->getData();
- $user->setUsername($user->getEmail());
- $this->userManager->updateCanonicalFields($user);
- });
+ $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
+ $user = $event->getData();
+ $user->setUsername($user->getEmail());
+ $this->userManager->updateCanonicalFields($user);
+ });
$builder->get('rsvp')
->addModelTransformer(new CallbackTransformer(
function (?Rsvp $rsvp) {
@@ -94,4 +104,4 @@ private $userManager;
{
return ProfileFormType::class;
}
-}
\ No newline at end of file
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Form/RegistrationType.php b/src/Sikofitt/DoughnutWeddingBundle/Form/RegistrationType.php
index 4984906..d8a0132 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Form/RegistrationType.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Form/RegistrationType.php
@@ -20,21 +20,17 @@
namespace Sikofitt\DoughnutWeddingBundle\Form;
-use HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse;
-use Symfony\Component\Form\Extension\Core\Type\NumberType;
-use Symfony\Component\Form\Extension\Core\Type\TextareaType;
-use Symfony\Component\Form\FormEvent;
use FOS\UserBundle\Form\Type\RegistrationFormType;
use FOS\UserBundle\Model\UserManager;
+use HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse;
use Sikofitt\DoughnutWeddingBundle\Entity\Rsvp;
-use Sikofitt\DoughnutWeddingBundle\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
-use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
-use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
-use Symfony\Component\Form\Extension\Core\Type\IntegerType;
+use Symfony\Component\Form\Extension\Core\Type\NumberType;
+use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
@@ -73,13 +69,12 @@ class RegistrationType extends AbstractType
'attr' => [
'rows' => 5,
'class' => 'uk-textarea uk-form-large uk-padding-small',
- 'placeholder' => 'Anything you would like to share with the Bride and Groom?'
- ]
+ 'placeholder' => 'Anything you would like to share with the Bride and Groom?',
+ ],
])
->remove('username');
- $builder->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) {
-
+ $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
$user = $event->getData();
$user->setUsername($user->getEmail());
$this->userManager->updateCanonicalFields($user);
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Pager/View/UIkitTemplate.php b/src/Sikofitt/DoughnutWeddingBundle/Pager/View/UIkitTemplate.php
new file mode 100644
index 0000000..882224c
--- /dev/null
+++ b/src/Sikofitt/DoughnutWeddingBundle/Pager/View/UIkitTemplate.php
@@ -0,0 +1,174 @@
+.
+ */
+
+namespace Sikofitt\DoughnutWeddingBundle\Pager\View;
+
+use Pagerfanta\View\Template\Template;
+
+class UIkitTemplate extends Template
+{
+ protected static $defaultOptions = [
+ 'prev_message' => '← Previous',
+ 'next_message' => 'Next →',
+ 'dots_message' => '…',
+ 'active_suffix' => '',
+ 'css_container_class' => 'uk-pagination uk-flex-center',
+ 'css_prev_class' => 'prev',
+ 'css_next_class' => 'next',
+ 'css_disabled_class' => 'disabled',
+ 'css_dots_class' => 'disabled',
+ 'css_active_class' => 'active',
+ 'rel_previous' => 'prev',
+ 'rel_next' => 'next',
+ ];
+
+ /**
+ * Renders the container for the pagination.
+ *
+ * The %pages% placeholder will be replaced by the rendering of pages
+ *
+ * @return string
+ */
+ public function container()
+ {
+ return sprintf('
', static::$defaultOptions['css_container_class'], '%pages%');
+ }
+
+ /**
+ * Renders a given page.
+ *
+ * @param int $page
+ *
+ * @return string
+ */
+ public function page($page)
+ {
+ if (1 === (int) $page) {
+ return '
'.$page.' ';
+ }
+
+ return '
'.$page.' ';
+ }
+
+ /**
+ * Renders a given page with a specified text.
+ *
+ * @param int $page
+ * @param string $text
+ *
+ * @return string
+ */
+ public function pageWithText($page, $text)
+ {
+ return $this->page($page);
+ }
+
+ /**
+ * Renders the disabled state of the previous page.
+ *
+ * @return string
+ */
+ public function previousDisabled()
+ {
+ return '';
+ }
+
+ /**
+ * Renders the enabled state of the previous page.
+ *
+ * @param int $page
+ *
+ * @return string
+ */
+ public function previousEnabled($page)
+ {
+ if (1 === (int) $page) {
+ return '
Previous';
+ }
+
+ return '
Previous';
+ }
+
+ /**
+ * Renders the disabled state of the next page.
+ *
+ * @return string
+ */
+ public function nextDisabled()
+ {
+ return '';
+ }
+
+ /**
+ * Renders the enabled state of the next page.
+ *
+ * @param int $page
+ *
+ * @return string
+ */
+ public function nextEnabled($page)
+ {
+ return '
Next ';
+ }
+
+ /**
+ * Renders the first page.
+ *
+ * @return string
+ */
+ public function first()
+ {
+ return '';
+ }
+
+ /**
+ * Renders the last page.
+ *
+ * @param int $page
+ *
+ * @return string
+ */
+ public function last($page)
+ {
+ return '';
+ }
+
+ /**
+ * Renders the current page.
+ *
+ * @param int $page
+ *
+ * @return string
+ */
+ public function current($page)
+ {
+ return '
'.$page.' ';
+ }
+
+ /**
+ * Renders the separator between pages.
+ *
+ * @return string
+ */
+ public function separator()
+ {
+ return '
... ';
+ }
+}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Repository/ContactRepository.php b/src/Sikofitt/DoughnutWeddingBundle/Repository/ContactRepository.php
index f5cd007..3e20998 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Repository/ContactRepository.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Repository/ContactRepository.php
@@ -1,9 +1,27 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Repository;
/**
- * ContactRepository
+ * ContactRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCategoryRepository.php b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCategoryRepository.php
index 6425cd2..fb9411a 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCategoryRepository.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCategoryRepository.php
@@ -1,9 +1,27 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Repository;
/**
- * ImageCategoryRepository
+ * ImageCategoryRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCommentRepository.php b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCommentRepository.php
index 543abb2..24ae634 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCommentRepository.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageCommentRepository.php
@@ -1,9 +1,27 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Repository;
/**
- * ImageCommentRepository
+ * ImageCommentRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageRepository.php b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageRepository.php
index 6d4556e..f135f55 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageRepository.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageRepository.php
@@ -1,13 +1,72 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Repository;
+use Doctrine\ORM\EntityRepository;
+use Sikofitt\DoughnutWeddingBundle\Entity\Image;
+
/**
- * ImageRepository
+ * ImageRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
-class ImageRepository extends \Doctrine\ORM\EntityRepository
+class ImageRepository extends EntityRepository
{
+ /**
+ * @param string $tag
+ *
+ * @return array
+ */
+ public function findImageByTag(string $tag): array
+ {
+ $images = $this->getEntityManager()
+ ->createQueryBuilder()
+ ->select('i')
+ ->from(Image::class, 'i')
+ ->where('i.tags LIKE :tag')
+ ->setParameter('tag', '%'.$tag.'%')
+ ->getQuery()->getResult();
+ /**
+ * @var int $key
+ * @var Image $image
+ */
+ foreach ($images as $key => $image) {
+ if (false === in_array($tag, $image->getTags(), true)) {
+ unset($images[$key]);
+ }
+ }
+
+ return $images;
+ }
+
+ public function findImageByCategory(string $category): array
+ {
+ return $this
+ ->getEntityManager()
+ ->createQueryBuilder()
+ ->select('i')
+ ->from(Image::class, 'i')
+ ->where('i.category =:category')
+ ->setParameter('category', $category)
+ ->getQuery()->getResult();
+ }
}
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageTagRepository.php b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageTagRepository.php
index 01d240f..b66d1e2 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageTagRepository.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Repository/ImageTagRepository.php
@@ -1,9 +1,27 @@
.
+ */
+
namespace Sikofitt\DoughnutWeddingBundle\Repository;
/**
- * ImageTagRepository
+ * ImageTagRepository.
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/index.html.twig b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/index.html.twig
index 99478e6..268ae5c 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/index.html.twig
+++ b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/index.html.twig
@@ -1,8 +1,151 @@
{% extends "::base.html.twig" %}
-{% block title %}Gallery{% endblock %}
+{% block title %}{% if category is defined %}{{ category|capitalize }} | {% elseif tag is defined %}{{ tag|capitalize }} | {% endif %}Gallery{% endblock %}
{% block body %}
-
Gallery
+
Gallery
+
+ {% if category is defined %}
+ Viewing images from the category {{ category|capitalize }}
+ {% elseif tag is defined %}
+ Viewing images tagged with {{ tag|capitalize }}
+ {% endif %}
+
+
+ {% if images is not null and images is not empty %}
+ {% for image in images %}
+
+ {% set imageUrl = bucket ~ '/gallery/' ~ vich_uploader_asset(image, 'imageFile')|trim('/', 'left') %}
+
+ {% endfor %}
+ {% else %}
+
+ There are currently no images{% if category is defined %} for category {{ category }} {% elseif tag is defined %} for tag {{ tag }} {% endif %}!
+ {% if is_granted('IS_AUTHENTICATED_FULLY') %}
+
+ Why don't you upload one ?
+
+ {% else %}
+
+ If you login or register you can upload one!
+
+ {% endif %}
+ {% endif %}
+
+
+ {% if pager.count > 12 %}
+ {{ pagerfanta(pager, 'default', { 'omitFirstPage': true}) }}
+ {% endif %}
{% endblock %}
+{% block javascripts %}
+
+{% endblock javascripts %}
\ No newline at end of file
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/upload.html.twig b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/upload.html.twig
index 58f2d30..3def15e 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/upload.html.twig
+++ b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/upload.html.twig
@@ -1,18 +1,70 @@
{% extends "::base.html.twig" %}
-{% block title %}Gallery Upload{% endblock %}
-
+{% block title %}Gallery Upload{% endblock title %}
{% block body %}
+
Upload an Image to the Gallery
{{ form_start(form, {'attr': { 'class': 'uk-form uk-form-horizontal'}}) }}
- {{ form_label(form.imageFile, null, {'label_attr':{'class':'uk-hidden'}}) }}
+ {{ form_label(form.imageFile) }}
+ {{ form_errors(form.imageFile) }}
{{ form_widget(form.imageFile) }}
-
-
Submit
+ {{ form_label(form.description) }}
+
+ {{ form_errors(form.description) }}
+ {{ form_widget(form.description) }}
+
+ {{ form_label(form.category) }}
+
+ {{ form_errors(form.category) }}
+ {{ form_widget(form.category) }}
+
+ {{ form_label(form.tags) }}
+
+
+ {% for tagField in form.tags %}
+
+ {{ form_errors(tagField) }}
+ {{ form_widget(tagField) }}
+
+ {% endfor %}
+ {% do form.tags.setRendered %}
+
+
Add Tag
+
+
Upload
+
+
{{ form_rest(form) }}
{{ form_end(form) }}
-{% endblock %}
+{% endblock body %}
+{% block javascripts %}
+
+{% endblock javascripts %}
\ No newline at end of file
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/view_image.html.twig b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/view_image.html.twig
new file mode 100644
index 0000000..dc87871
--- /dev/null
+++ b/src/Sikofitt/DoughnutWeddingBundle/Resources/views/Image/view_image.html.twig
@@ -0,0 +1,123 @@
+{% extends 'base.html.twig' %}
+
+{% block body %}
+ {% set imageUrl = bucket ~ '/gallery/' ~ vich_uploader_asset(image, 'imageFile')|trim('/', 'left') %}
+
+
+
+
+
+
+ {{ image.description }}
+
+
+
+
+
+
+{% endblock %}
+{% block javascripts %}
+
+{% endblock javascripts %}
\ No newline at end of file
diff --git a/src/Sikofitt/DoughnutWeddingBundle/Security/AccessDeniedHandler.php b/src/Sikofitt/DoughnutWeddingBundle/Security/AccessDeniedHandler.php
index a047403..4fbcb2d 100644
--- a/src/Sikofitt/DoughnutWeddingBundle/Security/AccessDeniedHandler.php
+++ b/src/Sikofitt/DoughnutWeddingBundle/Security/AccessDeniedHandler.php
@@ -1,24 +1,37 @@
.
+ */
namespace Sikofitt\DoughnutWeddingBundle\Security;
-
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
/**
- * Class AccessDeniedHandler
- *
- * @package Sikofitt\DoughnutWeddingBundle\Security
+ * Class AccessDeniedHandler.
*/
class AccessDeniedHandler implements AccessDeniedHandlerInterface
{
-
/**
* @var UrlGeneratorInterface
*/
@@ -30,10 +43,10 @@ class AccessDeniedHandler implements AccessDeniedHandlerInterface
private $logger;
/**
- * Sets up the router
+ * Sets up the router.
*
* @param UrlGeneratorInterface $router
- * @param LoggerInterface $logger
+ * @param LoggerInterface $logger
*/
public function __construct(UrlGeneratorInterface $router, LoggerInterface $logger)
{
@@ -44,13 +57,16 @@ class AccessDeniedHandler implements AccessDeniedHandlerInterface
/**
* Redirects to the login page on access denied failure.
*
- * @param Request $request
+ * @param Request $request
* @param AccessDeniedException $accessDeniedException
*
* @return RedirectResponse
*/
- public function handle(Request $request, AccessDeniedException $accessDeniedException) : RedirectResponse {
- $request->getSession()->getFlashBag()->add('error', $accessDeniedException->getMessage());
+ public function handle(Request $request, AccessDeniedException $accessDeniedException): RedirectResponse
+ {
+ /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
+ $session = $request->getSession();
+ $session->getFlashBag()->add('error', $accessDeniedException->getMessage());
$url = $this->router->generate('fos_user_security_login');
$this->logger->alert($accessDeniedException->getMessage(), [
'code' => $accessDeniedException->getCode(),
@@ -62,6 +78,5 @@ class AccessDeniedHandler implements AccessDeniedHandlerInterface
'X-Denied-Message' => $accessDeniedException->getMessage(),
'X-Denied-Status-Code' => $accessDeniedException->getCode(),
]);
-
}
-}
\ No newline at end of file
+}
+