updrade with rector

This commit is contained in:
tracer 2022-05-03 14:52:04 +02:00
parent d1e613ecc6
commit 6e30560cb9
135 changed files with 5609 additions and 4008 deletions

8
.env
View File

@ -15,7 +15,7 @@
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=cd0ae68f915f2a06b82007f2906e54e8
APP_SECRET=06f6b2aee3d5d74c8ce1db7d26a1dd5e
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
@ -30,3 +30,9 @@ DATABASE_URL="mysql://24unix:24.unix@127.0.0.1:3306/24unix"
###> symfony/mailer ###
MAILER_DSN=smtp://localhost
###< symfony/mailer ###
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=false
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ yarn-error.log
###> liip/imagine-bundle ###
/public/media/cache/
###< liip/imagine-bundle ###
/tools/php-cs-fixer/vendor/

1
.php-cs-fixer.cache Normal file

File diff suppressed because one or more lines are too long

10
.php-cs-fixer.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(dirs: __DIR__ . '/src');
$config = new PhpCsFixer\Config();
return $config->setRules(rules: [
'@Symfony' => true,
'yoda_style' => false,
])
->setFinder(finder: $finder);

View File

@ -1,23 +0,0 @@
/*
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
require('bootstrap');
require('bootstrap/js/dist/popover');
/*
$(document).ready(function() {
$('[data-toggle="dropdown"]').popover();
});
*/
//require('@fortawesome/fontawesome-free/css/all.min.css');
//require('@fortawesome/fontawesome-free/js/all.js');
require('fork-awesome/scss/fork-awesome.scss');
import './styles/app.scss';

11
assets/bootstrap.js vendored
View File

@ -1,11 +0,0 @@
import { startStimulusApp } from '@symfony/stimulus-bridge';
// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true,
/\.(j|t)sx?$/
));
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);

View File

@ -1,4 +0,0 @@
{
"controllers": [],
"entrypoints": []
}

View File

@ -1,16 +0,0 @@
import { Controller } from 'stimulus';
/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -1,29 +1,60 @@
// assets/js/app.js
const $ = require('jquery');
require('bootstrap');
globalThis.__VUE_OPTIONS_API__ = true;
globalThis.__VUE_PROD_DEVTOOLS__ = true;
import '../styles/app.scss';
// Matomo
let _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function () {
const u = "https://analytics.24unix.net/";
_paq.push(["setTrackerUrl", u + "matomo.php"]);
_paq.push(["setSiteId", "1"]);
const d = document, g = d.createElement("script"), s = d.getElementsByTagName("script")[0];
g.async = true;
g.src = u + "matomo.js";
s.parentNode.insertBefore(g, s);
})();
// End Matomo Code
import "../styles/app.scss";
require("fork-awesome/scss/fork-awesome.scss");
/*
require('@fortawesome/fontawesome-free/css/all.min.css');
require('@fortawesome/fontawesome-free/js/all.js');
*/
// CKEditor
//require '@'
import '../styles/ckeditor.css';
import "../styles/ckeditor.css"
require('@fortawesome/fontawesome-free/css/all.min.css');
require('@fortawesome/fontawesome-free/js/all.js');
import Vue from "vue"
import { BootstrapVue, IconsPlugin, NavbarPlugin } from "bootstrap-vue"
import VueRouter from 'vue-router'
import router from '@/router'
import MainPage from "@/pages/main"
Vue.use(BootstrapVue)
Vue.use(VueRouter)
Vue.use(IconsPlugin)
Vue.use(NavbarPlugin)
Vue.config.productionTip = false;
new Vue({
router,
render: (h) => h(MainPage)
})
.$mount("#app")
window.Dropzone = require('@symfony/ux-dropzone/dist/controller');
Dropzone.autodiscover = false;
/*
initializeDropzone();
function initializeDropzone()
{
let formElement = document.querySelector('js-dropzone');
}
*/

View File

@ -0,0 +1,53 @@
<template>
<div v-if="isLoading" class="circle">
<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
<span class="sr-only">Loading </span>
</div>
<div v-else>
<b-link class="align-left blog-details" :to="'/profile/' + author.username">
<img class="article-author-img rounded-circle"
:src="'build/images/' + author.avatar"
alt="profile"></b-link>
<b-link :to="'/profile/' + author.username">
{{ author.username }}
</b-link>
</div>
</template>
<script>
import axios from "axios";
export default {
name: "Author",
data: () => ({
author: null,
isLoading: true
}),
props: ["authorIri"],
mounted() {
this.getAuthor();
},
methods: {
getAuthor() {
console.log("here" + this.authorIri);
axios
.get(this.authorIri)
.then(response => {
console.log("response");
console.log(response);
this.author = response.data;
console.log(this.author);
this.isLoading = false;
})
.catch(error => {
console.log(error);
});
console.log(this.author);
}
}
};
</script>

View File

@ -0,0 +1,11 @@
<template>
<div>
404 Not Found
</div>
</template>
<script>
export default {
name: "NotFound"
}
</script>

View File

@ -0,0 +1,62 @@
<template>
<div v-if="!isLoading">
<div id="edit-wrapper">
<div class="editor mt-2">
<VueEditor v-model="page.content"></VueEditor>
</div>
<b-button @click="saveContent" class="mt-3 mb-2">Save</b-button>
</div>
</div>
<div v-else>
<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
<span class="sr-only">Loading </span></div>
</template>
<script>
import axios from "axios";
// Basic Use - Covers most scenarios
import { VueEditor } from "vue2-editor";
export default {
name: 'PagesEdit',
components: {
VueEditor
},
data: () => ({
page: null,
isLoading: true
}),
methods: {
saveContent() {
console.log(this.page)
axios
.put('/api/pages/' + this.page.id, this.page)
.then(response => {
console.log("resp:" + response)
})
}
},
beforeMount() {
const slug = this.$route.params.slug
console.log("slug: " + slug)
axios
.get('/api/pages?slug=' + slug)
.then(response => {
this.page = response.data['hydra:member'][0]
this.isLoading = false
})
},
}
</script>
<style>
.ql-container {
height: 800px !important;
overflow-y: scroll;
}
</style>

View File

@ -0,0 +1,89 @@
<template>
<div v-if="isLoading" class="circle">
<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
<span class="sr-only">Loading </span>
</div>
<div v-else class="container-fluid">
<div class="row">
<h2 class="mt-2">This is an overview of my current public (and open source) projects.</h2>
<!-- projects List -->
<div class="col-sm-12">
<b-col v-for="project in projects" :key="project.id">
<div class="project-container bg-dark my-4">
<div class="row">
<div class="col-sm-3">
<b-link :to="'/projects/' + project.name">
<img v-if="project.teaserImage"
class="blog-img"
:src="'/uploads/projects/' + project.teaserImage"
alt="Teaser">
<img v-else
class="blog-img"
src="/build/images/24unix/24_logo_bg_96x96.png"
alt="Teaser">
</b-link>
<br>
<div>
<b-col v-for="developer in project.developer" :key="developer">
<author :author-iri="developer"></author>
</b-col>
</div>
</div>
<div class="col-sm-8 mt-2">
<b-link to="project.name">
<div class="article-title d-inline-block pl-3 align-middle">
<h2 v-html="project.name"></h2>
</div>
</b-link>
<br>
<div class="blog-teaser mb-2 pb-2 text-xl-start">
<span v-html="project.description"></span>
<br>
<br>
started: <span v-html="project.createdAt"></span>
</div>
</div>
</div>
</div>
</b-col>
</div>
<div class="text-xl-start">
<b-link to="/add"><i class="fa fa-plus-circle"></i></b-link>
</div>
</div>
</div>
</template>
<script>
import axios from "axios";
import Author from "@/components/Author";
export default {
name: "ProjectsList",
data: () => ({
projects: null,
isLoading: true
}),
mounted() {
this.getProjects();
},
components: {
Author
},
methods: {
getProjects() {
axios
.get("/api/projects")
.then(response => (this.projects = response.data["hydra:member"]));
this.isLoading = false;
console.log(this.projects);
}
}
};
</script>

View File

@ -0,0 +1,27 @@
<template>
<b-container fluid class="col sidenav-left box text-start" id="main-menu">
<ul>
<li>
<i class="fa fa-lg fa-fw fa-file-code-o" aria-hidden="true"></i>&nbsp
<b-link to="/projects">Projects</b-link>
</li>
<li>
<i class="fa fa-lg fa-fw fa-gitea" aria-hidden="true"></i>&nbsp;
<b-link href="https://git.24unix.net" target="_blank">Gitea</b-link>&nbsp<i class="fa fa-external-link" aria-hidden="true"></i>
</li>
<li>
<i class="fa fa-lg fa-fw fa-nextcloud" aria-hidden="true"></i>&nbsp;
<a href="//cloud.24unix.net" target="_blank">NextCloud</a>&nbsp;<i class="fa fa-external-link" aria-hidden="true"></i>
</li>
</ul>
<!-- <a href="//pastebin.24unix.net">pastebin.24unix.net</a>-->
</b-container>
</template>
<script>
export default {
name: "Sidebar"
}
</script>

View File

@ -0,0 +1,37 @@
<template>
<footer class="dark fixed-bottom"> <!-- :class="['bd-footer', 'text-muted']"> -->
<b-container class="mt-5">
<b-row class="justify-content-center">
<b-col class="text-center">
<div>powered by
<b-link to="/" class="d-inline-block mx-auto"><img src="/build/images/Spookie/spookie_64x64.png" alt="Spookie"></b-link>
</div>
</b-col>
<b-col cols="auto" md="4" class="text-left">
<div id="legal">
<h5 class="bd-text-purple-bright mb-1 mt-3">Legal</h5>
<ul class="list-unstyled ml-3">
<li><b-link to="/pages/imprint">Imprint</b-link></li>
<li><b-link to="/pages/privacy-policy">Privacy Policy</b-link></li>
</ul>
</div>
</b-col>
</b-row>
</b-container>
</footer>
</template>
<script>
export default {
name: "Footer"
}
</script>
<style type="scss">
footer {
color: lightgray;
background: #0e0e10;
}
</style>

View File

@ -0,0 +1,12 @@
<template>
<div></div>
</template>
<script>
export default {
name: 'HandleLogout'
}
</script>

View File

@ -1,88 +0,0 @@
<template>
<header>
<b-nav class="navbar navbar-expand-md navbar-dark fixed-top navbar-top">
<!-- <nav class="navbar navbar-expand-md navbar-dark fixed-top navbar-top {{ is_granted('ROLE_PREVIOUS_ADMIN') ? 'bg-warning' : 'bg-dark' }}"> -->
<!-- <a class="navbar-brand" href=" {{ path('app_main') }} -->
<!-- <a class="navbar-brand" href="{{ path('app_main') }}"> -->
<!-- <img src="{{ asset('build/images/24unix/24_logo_bg_64x64.png') }}" alt="24unix.net" id="site-logo"> -->
<!-- </a> -->
<button class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#CollapsingNavbar">
&#9776;
</button>
<div class="collapse navbar-collapse" id="CollapsingNavbar">
<ul class="navbar-nav ms-auto">
{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
<li class="align-bottom">
<!-- <a class="dropdown-item" href="{{ path('app_main', { '_switch_user': '_exit'}) }}">Exit -->
<!--Impersonation</a>-->
</li>
{% endif %}
<!--
<li>
<form class="d-flex">
<input class="form-control me-2 my-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn" type="submit">Search</button>
</form>
</li>
-->
{% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
<li class="nav-item dropdown me-auto">
<button type="button" id="navbar-dropdown" data-bs-target="#dropdown-menu"
data-bs-toggle="dropdown"
class="btn btn-primary dropdown-toggle ml-auto mb-2 button-login">
<span v-if="user">
{{ user.username }}
</span>
</button>
<div class="dropdown-menu dropdown-menu-dark dropdown-menu-end" id="dropdown-menu"
aria-labelledby="navbar-dropdown">
<!-- <a class="dropdown-item" -->
<!-- href="{{ path('app_profile_edit', { 'username': app.user.username }) }}"> -->
<span class="fa fa-lg fa-fw fa-user" aria-hidden="true"></span>
<!--Profile</a>-->
<a class="dropdown-item" href="#">
<span class="fa fa-lg fa-fw fa-wrench" aria-hidden="true"></span>
Settings</a>
<div class="dropdown-divider"></div>
{% if is_granted('ROLE_ADMIN') %}
<!-- <a class="dropdown-item" href="{{ path('app_list_user') }}">
<span class="fa fa-lg fa-fw fa-users" aria-hidden="true"></span>
Users
</a>
<a class="dropdown-item" href="{{ path('admin') }}">
<span class="fa fa-lg fa-fw fa-cog" aria-hidden="true"></span>
Administration
</a>
<div class="dropdown-divider"></div>
{% endif %}
<a class="dropdown-item" href="{{ path('app_logout') }}">
<span class="fa fa-lg fa-fw fa-sign-out" aria-hidden="true"></span>&nbsp;
Logout
</a>-->
</div>
</li>
{% else %}
<li class="nav-item">
<!-- <a class="btn btn-primary button-login" href="{{ path('app_login') }}" role="button"
id="buttonLogin">
<span class="fa fa-sign-in fa-lg fa-fw" aria-hidden="true"></span>Log In
</a>-->
</li>
{% endif %}
</ul>
</div>
</b-nav>
</header>
</template>
<script>
export default {
name: 'Header',
props: ['user']
}
</script>

View File

@ -0,0 +1,71 @@
<template>
<form v-on:submit.prevent="handleSubmit">
<div v-if="error" class="alert alert-danger">
{{ error }}
</div>
<div class="form-group">
<label for="exampleInputEmail1">Username</label>
<input type="text" v-model="username" class="form-control" id="username"
aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" v-model="password" class="form-control"
id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">I like cheese</label>
</div>
<button type="submit" class="btn btn-primary" v-bind:class="{ disabled: isLoading }">Log in</button>
</form>
</template>
<script>
import axios from 'axios';
export default {
name: 'Login',
data() {
return {
username: '',
password: '',
error: '',
isLoading: false
}
},
props: ['user'],
methods: {
handleSubmit() {
console.log("handle submit");
this.isLoading = true
this.error = ''
axios
.post('/login', {
username: this.username,
password: this.password
})
.then(response => {
console.log(response.headers);
this.$emit('user-authenticated', response.headers.location);
this.username = '';
this.password = '';
}).catch(error => {
console.log(error.response.data);
if (error.response.data.error) {
this.error = error.response.data.error
} else {
this.error = 'Unknown error'
}
}).finally(() => {
this.isLoading = false;
})
},
},
}
</script>
<style scoped lang="scss">
</style>

View File

@ -0,0 +1,70 @@
<template>
<b-navbar toggleable="lg" type="dark" variant="dark" fixed="top">
<b-navbar-brand to="/">
<img src="/build/images/24unix/24_logo_bg_96x96.png" alt="24unix.net" id="site-logo">
</b-navbar-brand>
<b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
<b-collapse id="nav-collapse" is-nav>
<!--
<b-nav-form>
<b-form-input size="sm" class="mr-sm-2" placeholder="Search"></b-form-input>
<b-button size="sm" class="my-2 my-sm-0" type="submit">Search</b-button>
</b-nav-form>
-->
<!--
<b-nav-item-dropdown text="Lang" right>
<b-dropdown-item href="#">EN</b-dropdown-item>
<b-dropdown-item href="#">ES</b-dropdown-item>
<b-dropdown-item href="#">RU</b-dropdown-item>
<b-dropdown-item href="#">FA</b-dropdown-item>
</b-nav-item-dropdown>
-->
<b-navbar-nav class="ml-auto mr-5">
<b-button v-if="!isLoggedIn" to="/form_login">Login</b-button>
<b-dropdown v-else id="dropdown" :text="user.username" class="m-md-2" type="dark">
<b-dropdown-item to="/profile">
<span class="fa fa-lg fa-fw fa-user" aria-hidden="true"></span>&nbsp;Profile
</b-dropdown-item>
<b-dropdown-item>
<span class="fa fa-lg fa-fw fa-wrench" aria-hidden="true"></span>&nbsp;Settings
</b-dropdown-item>
<b-dropdown-divider></b-dropdown-divider>
<b-dropdown-item @click="logout">
<span class="fa fa-lg fa-fw fa-sign-out" aria-hidden="true"></span>&nbsp;Logout
</b-dropdown-item>
</b-dropdown>
</b-navbar-nav>
</b-collapse>
</b-navbar>
</template>
<script>
import axios from "axios";
export default {
name: "Navbar",
props: ["user"],
computed: {
isLoggedIn() {
return !!this.user;
}
},
methods: {
logout() {
console.log("logout");
axios
.get("/logout")
.then(this.$emit("invalidate-user"));
}
}
};
</script>
<style>
</style>

View File

@ -0,0 +1,48 @@
<template>
<div>
<h2 v-if="page" v-html="page.name"></h2>
<div v-if="page" v-html="page.content"></div>
<b-button :to="editTarget" variant="outline"><i class="fa fa-2x fa-fw fa-edit"></i></b-button>
<hr>
</div>
</template>
<script>
import axios from 'axios';
export default {
name: "Pages",
data: () => ({
page: null
}),
watch: {
$route() {
console.log("watch called")
this.getPagesDetails()
}
},
beforeMount() {
this.getPagesDetails()
},
methods: {
getPagesDetails() {
const slug = this.$route.params.slug
console.log("slug: " + slug)
axios
.get('/api/pages?slug=' + slug)
.then(response => (this.page = response.data['hydra:member'][0]))
}
},
computed: {
editTarget() {
if (this.page) {
return "/pages/edit/" + this.page.slug
}
}
}
}
</script>

View File

@ -0,0 +1,12 @@
<template>
<div>
Profile
</div>
</template>
<script>
export default {
name: 'Profile'
}
</script>

View File

@ -0,0 +1,16 @@
<template>
<div class="d-flex flex-column justify-content-between mt-2 mb-2">
<div></div>
<div>
<span v-html="quote"></span>
</div>
</div>
</template>
<script>
export default {
name: 'Quote',
props: ['quote']
}
</script>

66
assets/js/pages/main.vue Normal file
View File

@ -0,0 +1,66 @@
<template>
<div>
<nav-bar :user="user" v-on:invalidate-user="onInvalidateUser"></nav-bar>
<b-container fluid class="mt-5 main-content">
<b-row>
<div class="col-2">
<sidebar></sidebar>
</div>
<div class="col-9 box">
<router-view v-on:user-authenticated="onUserAuthenticated" :quote="quote"></router-view>
</div>
<div class="col mt-2">
</div>
</b-row>
</b-container>
<footer-component></footer-component>
</div>
</template>
<script>
import axios from 'axios';
import NavBar from '@/components/navbar'
import Sidebar from "@/components/Sidebar";
import FooterComponent from '@/components/footer'
export default {
name: 'Main',
components: {
Sidebar,
NavBar,
FooterComponent
},
methods: {
onUserAuthenticated(userUri) {
console.log("authenticated")
axios
.get(userUri)
.then(response => (this.user = response.data))
this.$router.push('/')
},
onInvalidateUser() {
console.log("invalidated")
this.user = null;
}
},
data() {
return {
user: null,
quote: null
}
},
mounted() {
if (window.user) {
this.user = window.user
}
if (window.quote) {
this.quote = window.quote
}
}
}
</script>

44
assets/js/router.js Normal file
View File

@ -0,0 +1,44 @@
import Router from 'vue-router'
import LoginForm from '@/components/login'
import Quotes from "@/components/quotes";
import Pages from "@/components/pages";
import PagesEdit from "@/components/PagesEdit";
import ProjectsList from "@/components/ProjectsList";
import Profile from "@/components/profile";
import NotFound from "@/components/NotFound"
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'Home',
component: Quotes
},
{
path: '/form_login',
name: 'LoginForm',
component: LoginForm,
},
{
path: '/projects',
component: ProjectsList
},
{
path: '/pages/:slug',
component: Pages
},
{
path: '/pages/edit/:slug',
component: PagesEdit
},
{
path: '/profile',
component: Profile
},
{
path: '*',
component: NotFound
}
]
})

View File

@ -15,6 +15,14 @@
}
html, body{
margin: 0;
padding: 0;
background: black;
background: linear-gradient(90deg, rgba(14,14,16,1) 0%, rgba(255,128,64,1) 35%, rgba(14,14,16,1) 100%);
}
// customize some Bootstrap variables
@ -25,15 +33,39 @@ $border-primary: #FF8040;
$dropdown-dark-bg: black;
$dropdown-dark-link-color: $primary;
$dropdown-dark-border-color: $primary;
$jet-black: #0e0e10;
$mango: #FF8040;
// the ~ allows you to reference things in node_modules
@import "~bootstrap/scss/bootstrap";
@import 'bootstrap/dist/css/bootstrap.css';
@import 'bootstrap-vue/dist/bootstrap-vue.css';
a:link { text-decoration: none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:active { text-decoration: none; }
.wrapper {
clear: both;
position: sticky;
top: 0;
}
a:link {
text-decoration: none;
color: $mango;
}
a:visited {
text-decoration: none;
color: $mango;
}
a:hover {
text-decoration: none;
color: $mango;
}
a:active {
text-decoration: none;
color: $mango;
}
body {
@ -72,6 +104,13 @@ body {
}
}
.navbar {
opacity: 0.9;
}
footer {
opacity: 0.9;
}
.navbar-top {
border-bottom-width: 1px;
@ -97,20 +136,10 @@ body {
}
@include media-breakpoint-down(sm) {
.dropdown-toggle:after {
content: none;
}
#dropdown-menu {
display: block;
}
}
@include media-breakpoint-up(md) {
.navbar {
padding-left: 100px;
padding-right: 100px;
}
.display-wrapper {
text-align: left;
width: 90%;
margin: 0 auto 150px;
}
@ -118,16 +147,20 @@ body {
margin-top: 25px;
}
.main-content {
}
.box {
border-width: 1px;
border-style: solid;
border-color: $primary;
border-radius: 10px;
padding: 15px;
background-image: url('../images/bg.jpeg');
background-position: center;
color: lightgray;
background: black;
align-content: center;
margin-bottom: 200px;
margin: 15px 15px 20px;
height: auto;
}
/* BlogPosts */
@ -183,6 +216,16 @@ body {
}
.circle {
position:fixed;
width:500px;
height:600px;
margin:-300px auto auto -250px;
top:50%;
left:50%;
text-align:center;
}
.teaser-image {
object-fit: contain;
width: 800px;
@ -190,6 +233,11 @@ body {
margin: 7px;
}
.project-container {
border-radius: 5px;
}
.blog-img {
height: 100px;
width: 100px;

View File

@ -7,16 +7,21 @@
"php": ">=8.0.2",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^2.6",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.6",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.11",
"easycorp/easyadmin-bundle": "^4.0",
"friendsofsymfony/ckeditor-bundle": "^2.4",
"knplabs/knp-time-bundle": "^1.18",
"league/commonmark": "^2.3",
"nelmio/cors-bundle": "^2.2",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.4",
"rector/rector": "^0.12.21",
"sensio/framework-extra-bundle": "^6.1",
"sunrise/slugger": "^2.1",
"symfony/asset": "6.0.*",
"symfony/console": "6.0.*",
"symfony/doctrine-messenger": "6.0.*",
@ -83,7 +88,8 @@
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"ckeditor:install": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"

1206
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -15,4 +15,7 @@ return [
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
];

View File

@ -0,0 +1,8 @@
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
patch_formats:
json: ['application/merge-patch+json']
swagger:
versions: [3]
show_webby: false

View File

@ -1,3 +0,0 @@
framework:
assets:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'

View File

@ -1,19 +0,0 @@
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]

View File

@ -1,6 +0,0 @@
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler: { only_exceptions: false }

View File

@ -0,0 +1,5 @@
# Read the documentation: https://symfony.com/doc/current/bundles/FOSCKEditorBundle/index.html
twig:
form_themes:
- '@FOSCKEditor/Form/ckeditor_widget.html.twig'

View File

@ -0,0 +1,10 @@
nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null

View File

@ -1,8 +0,0 @@
# As of Symfony 5.1, deprecations are logged in the dedicated "deprecation" channel when it exists
#monolog:
# channels: [deprecation]
# handlers:
# deprecation:
# type: stream
# channels: [deprecation]
# path: php://stderr

View File

@ -1,20 +0,0 @@
doctrine:
orm:
auto_generate_proxy_classes: false
metadata_cache_driver:
type: pool
pool: doctrine.system_cache_pool
query_cache_driver:
type: pool
pool: doctrine.system_cache_pool
result_cache_driver:
type: pool
pool: doctrine.result_cache_pool
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system

View File

@ -1,17 +0,0 @@
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]

View File

@ -1,3 +0,0 @@
framework:
router:
strict_requirements: null

View File

@ -1,4 +0,0 @@
#webpack_encore:
# Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
# Available in version 1.2
#cache: true

View File

@ -1,2 +0,0 @@
symfonycasts_reset_password:
request_password_repository: App\Repository\ResetPasswordRequestRepository

View File

@ -1,15 +1,15 @@
security:
enable_authenticator_manager: true
hide_user_not_found: false
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
role_hierarchy:
ROLE_ADMIN: [ROLE_ALLOWED_TO_SWITCH]
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
App\Entity\User:
algorithm: auto
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
app_user_provider:
entity:
@ -22,21 +22,22 @@ security:
main:
lazy: true
provider: app_user_provider
custom_authenticator: App\Security\LoginFormAuthenticator
logout: true
# custom_authenticator: App\Security\LoginFormAuthenticator
json_login:
check_path: app_login
username_path: username
password_path: password
logout:
path: app_logout
switch_user: true
remember_me:
secret: '%kernel.secret%'
signature_properties: [password]
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall
# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true
# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/profile/edit, roles: ROLE_USER }
@ -44,10 +45,6 @@ security:
when@test:
security:
password_hashers:
# By default, password hashers are resource intensive and take time. This is
# important to generate secure password hashes. In tests however, secure hashes
# are not important, waste resources and increase test times. The following
# reduces the work factor to the lowest possible values.
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
algorithm: auto
cost: 4 # Lowest possible value for bcrypt

View File

@ -1,4 +0,0 @@
doctrine:
dbal:
# "TEST_TOKEN" is typically set by ParaTest
dbname: 'main_test%env(default::TEST_TOKEN)%'

View File

@ -1,4 +0,0 @@
framework:
test: true
session:
storage_id: session.storage.mock_file

View File

@ -1,12 +0,0 @@
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug

View File

@ -1,2 +0,0 @@
twig:
strict_variables: true

View File

@ -1,3 +0,0 @@
framework:
validation:
not_compromised_password: false

View File

@ -1,6 +0,0 @@
web_profiler:
toolbar: false
intercept_redirects: false
framework:
profiler: { collect: false }

View File

@ -1,2 +0,0 @@
#webpack_encore:
# strict_mode: false

View File

@ -1,5 +1,7 @@
twig:
default_path: '%kernel.project_dir%/templates'
form_themes:
- '@FOSCKEditor/Form/ckeditor_widget.html.twig'
when@test:
twig:

View File

@ -1,7 +0,0 @@
controllers:
resource: ../../src/Controller/
type: annotation
kernel:
resource: ../../src/Kernel.php
type: annotation

View File

@ -0,0 +1,4 @@
api_platform:
resource: .
type: api_platform
prefix: /api

View File

@ -1,3 +0,0 @@
_errors:
resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
prefix: /_error

View File

@ -1,7 +0,0 @@
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler

View File

@ -1,31 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210530154026 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, first_name VARCHAR(255) DEFAULT NULL, last_name VARCHAR(255) DEFAULT NULL, email VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, last_login_at DATETIME DEFAULT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE user');
}
}

View File

@ -1,41 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210530161844 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE blog (id INT AUTO_INCREMENT NOT NULL, author_id INT NOT NULL, edited_by_id INT DEFAULT NULL, title VARCHAR(255) NOT NULL, teaser LONGTEXT DEFAULT NULL, teaser_image VARCHAR(255) DEFAULT NULL, content LONGTEXT NOT NULL, created_at DATETIME NOT NULL, edited_at DATETIME DEFAULT NULL, edit_reason VARCHAR(255) DEFAULT NULL, INDEX IDX_C0155143F675F31B (author_id), INDEX IDX_C0155143DD7B2EBC (edited_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE blog_section (blog_id INT NOT NULL, section_id INT NOT NULL, INDEX IDX_C185C76CDAE07E97 (blog_id), INDEX IDX_C185C76CD823E37A (section_id), PRIMARY KEY(blog_id, section_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE section (id INT AUTO_INCREMENT NOT NULL, title VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, teaser_image VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE blog ADD CONSTRAINT FK_C0155143F675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE blog ADD CONSTRAINT FK_C0155143DD7B2EBC FOREIGN KEY (edited_by_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE blog_section ADD CONSTRAINT FK_C185C76CDAE07E97 FOREIGN KEY (blog_id) REFERENCES blog (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE blog_section ADD CONSTRAINT FK_C185C76CD823E37A FOREIGN KEY (section_id) REFERENCES section (id) ON DELETE CASCADE');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE blog_section DROP FOREIGN KEY FK_C185C76CDAE07E97');
$this->addSql('ALTER TABLE blog_section DROP FOREIGN KEY FK_C185C76CD823E37A');
$this->addSql('DROP TABLE blog');
$this->addSql('DROP TABLE blog_section');
$this->addSql('DROP TABLE section');
}
}

View File

@ -1,34 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210530162315 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE comment (id INT AUTO_INCREMENT NOT NULL, blog_id INT NOT NULL, author_id INT NOT NULL, edited_by_id INT DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, content LONGTEXT NOT NULL, created_at DATETIME NOT NULL, edited_at DATETIME DEFAULT NULL, edit_reason VARCHAR(255) DEFAULT NULL, INDEX IDX_9474526CDAE07E97 (blog_id), INDEX IDX_9474526CF675F31B (author_id), INDEX IDX_9474526CDD7B2EBC (edited_by_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526CDAE07E97 FOREIGN KEY (blog_id) REFERENCES blog (id)');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526CF675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526CDD7B2EBC FOREIGN KEY (edited_by_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE comment');
}
}

View File

@ -1,31 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210601114523 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE blog ADD slug VARCHAR(255) NOT NULL, CHANGE title title VARCHAR(255) DEFAULT NULL, CHANGE content content LONGTEXT DEFAULT NULL, CHANGE created_at created_at DATETIME DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE blog DROP slug, CHANGE title title VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE content content LONGTEXT CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE created_at created_at DATETIME NOT NULL');
}
}

View File

@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210609175005 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE reset_password_request (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, selector VARCHAR(20) NOT NULL, hashed_token VARCHAR(100) NOT NULL, requested_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', expires_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_7CE748AA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE reset_password_request');
}
}

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210530183330 extends AbstractMigration
final class Version20220412144008 extends AbstractMigration
{
public function getDescription(): string
{
@ -20,12 +20,12 @@ final class Version20210530183330 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user ADD is_verified TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE user ADD avatar VARCHAR(255) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE user DROP is_verified');
$this->addSql('ALTER TABLE `user` DROP avatar');
}
}

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220423085724 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE pages (id INT AUTO_INCREMENT NOT NULL, owner_id INT NOT NULL, name VARCHAR(255) NOT NULL, content LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_2074E5757E3C61F9 (owner_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE pages ADD CONSTRAINT FK_2074E5757E3C61F9 FOREIGN KEY (owner_id) REFERENCES `user` (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE pages');
}
}

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210614155532 extends AbstractMigration
final class Version20220424100610 extends AbstractMigration
{
public function getDescription(): string
{
@ -20,12 +20,12 @@ final class Version20210614155532 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE UNIQUE INDEX UNIQ_C0155143989D9B62 ON blog (slug)');
$this->addSql('ALTER TABLE pages ADD slug VARCHAR(255) NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX UNIQ_C0155143989D9B62 ON blog');
$this->addSql('ALTER TABLE pages DROP slug');
}
}

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210610182614 extends AbstractMigration
final class Version20220425082917 extends AbstractMigration
{
public function getDescription(): string
{
@ -20,18 +20,12 @@ final class Version20210610182614 extends AbstractMigration
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE `sessions` (
`sess_id` VARBINARY(128) NOT NULL PRIMARY KEY,
`sess_data` BLOB NOT NULL,
`sess_lifetime` INTEGER UNSIGNED NOT NULL,
`sess_time` INTEGER UNSIGNED NOT NULL,
INDEX `sessions_sess_lifetime_idx` (`sess_lifetime`)
) COLLATE utf8mb4_bin, ENGINE = InnoDB;');
$this->addSql('ALTER TABLE user ADD created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', ADD modified_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\'');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE `user` DROP created_at, DROP modified_at');
}
}

View File

@ -1,8 +1,6 @@
{
"devDependencies": {
"@hotwired/stimulus": "^3.0.0",
"@popperjs/core": "^2.11.5",
"@symfony/stimulus-bridge": "^3.0.0",
"@symfony/webpack-encore": "^1.7.0",
"core-js": "^3.0.0",
"file-loader": "^6.0.0",
@ -11,7 +9,8 @@
"regenerator-runtime": "^0.13.2",
"sass": "^1.50.0",
"sass-loader": "^12.0.0",
"stimulus": "^3.0.1",
"vue-loader": "^15",
"webpack-manifest-plugin": "^5.0.0",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
@ -24,8 +23,17 @@
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.1.1",
"bootstrap": "^5.1.3",
"axios": "^0.27.1",
"bootstrap": "4.6",
"bootstrap-vue": "^2.22.0",
"ckeditor": "^4.12.1",
"ckeditor4": "^4.18.0",
"fork-awesome": "^1.2.0",
"less": "^4.1.2"
"less": "^4.1.2",
"popper.js": "^1.16.1",
"vue": "^2.5",
"vue-router": "3",
"vue-template-compiler": "^2.6.14",
"vue2-editor": "^2.10.3"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 KiB

21
rector.php Normal file
View File

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths(paths: [
__DIR__ . '/src'
]);
// register a single rule
$rectorConfig->rule(rectorClass: InlineConstructorDefaultToPropertyRector::class);
// define sets of rules
// $rectorConfig->sets([
// LevelSetList::UP_TO_PHP_80
// ]);
};

View File

@ -1,39 +0,0 @@
<?php
namespace App\Controller\Admin;
use App\Entity\Blog;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\SlugField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
/**
* Class BlogCrudController
* @package App\Controller\Admin
*/
class BlogCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Blog::class;
}
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('author')
->autocomplete(),
TextField::new('title'),
SlugField::new('slug')
->setTargetFieldName('title'),
TextEditorField::new('teaser'),
TextEditorField::new('content'),
DateTimeField::new('createdAt'),
AssociationField::new('editedBy')
->autocomplete()
];
}
}

View File

@ -1,39 +0,0 @@
<?php
namespace App\Controller\Admin;
use App\Entity\Comment;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
/**
* Class CommentCrudController
* @package App\Controller\Admin
*/
class CommentCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Comment::class;
}
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('author')
->autocomplete(),
AssociationField::new('blog')
->autocomplete(),
TextField::new('title'),
TextEditorField::new('content'),
DateTimeField::new('createdAt'),
AssociationField::new('editedBy')
->autocomplete(),
DateTimeField::new('editedAt'),
];
}
}

View File

@ -2,6 +2,7 @@
namespace App\Controller\Admin;
use App\Entity\Pages;
use App\Entity\Projects;
use App\Entity\Quotes;
use App\Entity\User;
@ -18,50 +19,45 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\User\UserInterface;
/**
*
*/
class DashboardController extends AbstractDashboardController
{
#[isGranted(data: 'ROLE_ADMIN')]
#[Route(path: '/admin', name: 'admin')]
public function index(): Response
{
//return parent::index();
return $this->render(view: 'admin/index.html.twig');
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
->setTitle(title: '24unix Admin');
}
public function configureMenuItems(): iterable
{
yield MenuItem::linkToUrl(label: 'Homepage', icon: 'fa fa-home', url: $this->generateUrl(route: 'app_main'));
yield MenuItem::linkToDashboard(label: 'Dashboard', icon: 'fa fa-dashboard');
yield MenuItem::linkToCrud(label: 'Projects', icon: 'fa fa-file-code-o', entityFqcn: Projects::class);
yield MenuItem::linkToCrud(label: 'Users', icon: 'fa fa-users', entityFqcn: User::class);
yield MenuItem::linkToCrud(label: 'Quotes', icon: 'fa fa-quote-left', entityFqcn: Quotes::class);
}
public function configureUserMenu(UserInterface $user): UserMenu
{
if (!$user instanceof User) {
throw new Exception(message: 'Wrong User!');
}
return parent::configureUserMenu(user: $user)
->setAvatarUrl(url: $user->getAvatar());
}
public function configureActions(): Actions
{
return parent::configureActions()
->add(pageName: Crud::PAGE_INDEX, actionNameOrObject: Action::DETAIL);
}
#[isGranted(data: 'ROLE_ADMIN')]
#[Route(path: '/admin', name: 'admin')]
public function index(): Response
{
// return parent::index();
return $this->render(view: 'admin/index.html.twig');
}
public function configureDashboard(): Dashboard
{
return Dashboard::new()
->setTitle(title: '24unix Admin');
}
public function configureMenuItems(): iterable
{
yield MenuItem::linkToUrl(label: 'Homepage', icon: 'fa fa-home', url: $this->generateUrl(route: 'app_main'));
yield MenuItem::linkToDashboard(label: 'Dashboard', icon: 'fa fa-dashboard');
yield MenuItem::linkToCrud(label: 'Users', icon: 'fa fa-users', entityFqcn: User::class);
yield MenuItem::linkToCrud(label: 'Projects', icon: 'fa fa-file-code-o', entityFqcn: Projects::class);
yield MenuItem::linkToCrud(label: 'Pages', icon: 'fa fa-newspaper-o', entityFqcn: Pages::class);
yield MenuItem::linkToCrud(label: 'Quotes', icon: 'fa fa-quote-left', entityFqcn: Quotes::class);
}
public function configureUserMenu(UserInterface $user): UserMenu
{
if (!$user instanceof User) {
throw new Exception(message: 'Wrong User!');
}
return parent::configureUserMenu(user: $user)
->setAvatarUrl(url: 'build/images/'.$user->getAvatar());
}
public function configureActions(): Actions
{
return parent::configureActions()
->add(pageName: Crud::PAGE_INDEX, actionNameOrObject: Action::DETAIL);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Controller\Admin;
use App\Entity\Pages;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\CodeEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
class PagesCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Pages::class;
}
public function configureFields(string $pageName): iterable
{
yield IdField::new(propertyName: 'id')
->onlyOnIndex();
yield TextField::new(propertyName: 'name');
yield AssociationField::new(propertyName: 'owner');
// yield CodeEditorField::new(propertyName: 'content')
yield TextareaField::new(propertyName: 'content')
->onlyOnForms();
}
}

View File

@ -8,27 +8,23 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
/**
*
*/
class ProjectsCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Projects::class;
}
public function configureFields(string $pageName): iterable
{
yield IdField::new(propertyName: 'id')
->onlyOnIndex();
yield TextField::new(propertyName: 'name');
yield TextField::new(propertyName: 'description');
yield TextField::new(propertyName: 'description');
yield ImageField::new(propertyName: 'teaserImage')
->setBasePath(path: 'uploads/projects')
->setUploadDir(uploadDirPath: 'public/uploads/projects')
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
}
public static function getEntityFqcn(): string
{
return Projects::class;
}
public function configureFields(string $pageName): iterable
{
yield IdField::new(propertyName: 'id')
->onlyOnIndex();
yield TextField::new(propertyName: 'name');
yield TextField::new(propertyName: 'description');
yield TextField::new(propertyName: 'description');
yield ImageField::new(propertyName: 'teaserImage')
->setBasePath(path: 'uploads/projects')
->setUploadDir(uploadDirPath: 'public/uploads/projects')
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
}
}

View File

@ -8,23 +8,20 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
/**
*
*/
class QuotesCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Quotes::class;
}
public function configureFields(string $pageName): iterable
{
yield IdField::new(propertyName: 'id')
->onlyOnIndex();
yield TextField::new(propertyName: 'quote')
->onlyOnIndex();
yield TextEditorField::new(propertyName: 'quote')
->onlyOnForms();
}
public static function getEntityFqcn(): string
{
return Quotes::class;
}
public function configureFields(string $pageName): iterable
{
yield IdField::new(propertyName: 'id')
->onlyOnIndex();
yield TextField::new(propertyName: 'quote')
->onlyOnIndex();
yield TextEditorField::new(propertyName: 'quote')
->onlyOnForms();
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace App\Controller\Admin;
use App\Entity\Section;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
/**
* Class SectionCrudController
* @package App\Controller\Admin
*/
class SectionCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return Section::class;
}
/*
public function configureFields(string $pageName): iterable
{
return [
IdField::new('id'),
TextField::new('title'),
TextEditorField::new('description'),
];
}
*/
}

View File

@ -10,9 +10,6 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
/**
*
*/
class UserCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
@ -22,20 +19,20 @@ class UserCrudController extends AbstractCrudController
public function configureFields(string $pageName): iterable
{
yield IdField::new(propertyName: 'id')
->onlyOnIndex();
yield TextField::new(propertyName: 'firstName');
yield TextField::new(propertyName: 'lastName');
yield EmailField::new(propertyName: 'email');
yield ImageField::new(propertyName: 'avatar')
->setBasePath(path: 'uploads/avatars')
->setUploadDir(uploadDirPath: 'public/uploads/avatars')
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
$roles = ['ROLE_FOUNDER', 'ROLE_ADMIN', 'ROLE_MODERATOR', 'ROLE_USER'];
yield ChoiceField::new(propertyName: 'roles')
->setChoices(choiceGenerator: array_combine(keys: $roles, values: $roles))
->allowMultipleChoices()
->renderExpanded()
->renderAsBadges();
yield IdField::new(propertyName: 'id')
->onlyOnIndex();
yield TextField::new(propertyName: 'firstName');
yield TextField::new(propertyName: 'lastName');
yield EmailField::new(propertyName: 'email');
yield ImageField::new(propertyName: 'avatar')
->setBasePath(path: 'uploads/avatars')
->setUploadDir(uploadDirPath: 'public/uploads/avatars')
->setUploadedFileNamePattern(patternOrCallable: '[timestamp]-[slug].[extension]');
$roles = ['ROLE_FOUNDER', 'ROLE_ADMIN', 'ROLE_MODERATOR', 'ROLE_USER'];
yield ChoiceField::new(propertyName: 'roles')
->setChoices(choiceGenerator: array_combine(keys: $roles, values: $roles))
->allowMultipleChoices()
->renderExpanded()
->renderAsBadges();
}
}

View File

@ -1,97 +0,0 @@
<?php
namespace App\Controller;
use App\Entity\Blog;
use App\Form\BlogFormType;
use App\Repository\BlogRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class BlogController
* @package App\Controller
*/
class BlogController extends AbstractController
{
#[Route('/', name: 'blogs')]
public function index(BlogRepository $blogRepository): Response
{
return $this->render('blog/index.html.twig', [
'blogs' => $blogRepository->findAll()
]);
}
/**
* @param $slug
* @param \App\Repository\BlogRepository $blogRepository
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route('/blog_show/{slug}', name: 'blog')]
public function show($slug, BlogRepository $blogRepository): Response
{
return $this->render('blog/show.html.twig', [
'blog' => $blogRepository->findOneBy(['slug' => $slug])
]);
}
/**
* @param \Doctrine\ORM\EntityManagerInterface $entityManager
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
#[Route('/blog/new', name: 'blog_new')]
public function new(EntityManagerInterface $entityManager, Request $request): RedirectResponse|Response
{
$form = $this->createForm(BlogFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$blog = $form->getData();
$entityManager->persist($blog);
$entityManager->flush();
return $this->redirectToRoute('blogs');
}
return $this->render('blog/new.html.twig', [
'blogForm' => $form->createView(),
]);
}
/**
* @param \App\Entity\Blog $blog
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
#[Route('/blog/edit/{id}', name: 'blog_edit')]
public function edit(Blog $blog, Request $request): Response|RedirectResponse
{
$form = $this->createForm(BlogFormType::class, $blog);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$blog = $form->getData();
//$blog->setAuthor($this->getUser());
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($blog);
$entityManager->flush();
return $this->redirectToRoute('blogs');
}
return $this->render('blog/new.html.twig', [
'blogForm' => $form->createView(),
]);
}
}

View File

@ -0,0 +1,33 @@
<?php
// src/Controller/FrontendController.php
namespace App\Controller;
use App\Repository\QuotesRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
/**
*
*/
class FrontendController extends AbstractController
{
/**
* @throws \Exception
*/
#[Route(path: '/', name: 'app_main')]
#[Route(path: '/{route}', name: 'vue_pages', requirements: ['route' => '^(?!.*_wdt|_profiler|login|logout).+'] )]
public function quote(SerializerInterface $serializer, QuotesRepository $quotesRepository): Response
{
$quote = $quotesRepository->findOneRandom();
return $this->render(view: 'base.html.twig', parameters: [
'user' => $serializer->serialize(data: $this->getUser(), format: 'jsonld'),
'quote' => json_encode(value: $quote->getQuote())
]);
}
}

View File

@ -1,29 +0,0 @@
<?php
// src/Controller/LuckyController.php
namespace App\Controller;
use App\Repository\QuotesRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
*
*/
class MainController extends AbstractController
{
/**
* @throws \Exception
*/
#[Route(path: '/', name: 'app_main')]
public function quote(QuotesRepository $quotesRepository): Response
{
$quote = $quotesRepository->findOneRandom();
return $this->render(view: 'base.html.twig', parameters: [
'quote' => $quote->getQuote()
]);
}
}

View File

@ -2,28 +2,29 @@
namespace App\Controller;
use App\Entity\Pages;
use App\Repository\PagesRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
*
*/
class PagesController extends AbstractController
{
#[Route(path: '/imprint', name: 'app_imprint')]
public function imprint(): Response
#[Route(path: '/pages/{name}', name: 'pages_display')]
public function display(PagesRepository $pagesRepository, string $name): Response
{
return $this->render(view: 'pages/imprint.html.twig', parameters: [
'controller_name' => 'PagesController',
$page = $pagesRepository->findOneBy([
'slug' => $name,
]);
if (!$page) {
$page = new Pages();
$page->setName(name: 'Not Found');
$page->setContent(content: 'The requested page was not found.');
}
return $this->render(view: 'pages/display.html.twig', parameters: [
'page' => $page,
]);
}
#[Route(path: '/privacy', name: 'app_privacy')]
public function privacy(): Response
{
return $this->render(view: 'pages/privacy.html.twig', parameters: [
'controller_name' => 'PagesController',
]);
}
}

View File

@ -2,36 +2,33 @@
namespace App\Controller;
use App\Repository\ProjectsRepository;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use App\Repository\ProjectsRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
*
*/
class ProjectsController extends AbstractController
{
#[Route(path: '/projects/{name}', name: 'app_projects')]
public function index(ProjectsRepository $projectsRepository, string $name = ''): Response
{
if ($name == '') {
return $this->render(view: 'projects/index.html.twig', parameters: [
'projects' => $projectsRepository->findAll()
]);
} else {
if ($project = $projectsRepository->findOneByName(value: $name)) {
$readMe = file_get_contents(filename: $project->getURL() . '/raw/branch/master/README.md');
//$parsedReadMe = $markdownParser->transformMarkdown(text: $readMe);
return $this->render(view: 'projects/show.html.twig', parameters: [
'project' => $project,
'readme' => $readMe
]);
} else {
throw $this->createNotFoundException();
}
}
}
#[Route(path: '/projects/{name}', name: 'app_projects')]
public function index(ProjectsRepository $projectsRepository, string $name = ''): Response
{
if ($name == '') {
return $this->render(view: 'projects/index.html.twig', parameters: [
'projects' => $projectsRepository->findAll(),
]);
} else {
if ($project = $projectsRepository->findOneByName(value: $name)) {
$readMe = file_get_contents(filename: $project->getURL().'/raw/branch/master/README.md');
// $parsedReadMe = $markdownParser->transformMarkdown(text: $readMe);
return $this->render(view: 'projects/show.html.twig', parameters: [
'project' => $project,
'readme' => $readMe,
]);
} else {
throw $this->createNotFoundException();
}
}
}
}

View File

@ -1,98 +0,0 @@
<?php
namespace App\Controller;
use App\Entity\User;
use App\Form\RegistrationFormType;
use App\Security\EmailVerifier;
use App\Repository\UserRepository;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mime\Address;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
/**
* Class RegistrationController
* @package App\Controller
*/
class RegistrationController extends AbstractController
{
private $emailVerifier;
public function __construct(EmailVerifier $emailVerifier)
{
$this->emailVerifier = $emailVerifier;
}
#[Route('/register', name: 'app_register')]
public function register(Request $request, UserPasswordHasherInterface $passwordHasher): Response
{
$user = new User();
$form = $this->createForm(RegistrationFormType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// hash the plain password
$user->setPassword(
$passwordHasher->hashPassword(
$user,
$form->get('plainPassword')->getData()
)
);
$entityManager = $this->getDoctrine()->getManager();
$entityManager->persist($user);
$entityManager->flush();
// generate a signed url and email it to the user
$this->emailVerifier->sendEmailConfirmation('app_verify_email', $user,
(new TemplatedEmail())
->from(new Address('tracer@24unix.net', '24unix'))
->to($user->getEmail())
->subject('Please Confirm your Email')
->htmlTemplate('registration/confirmation_email.html.twig')
);
// do anything else you need here, like send an email
return $this->redirectToRoute('blogs');
}
return $this->render('security/register.html.twig', [
'registrationForm' => $form->createView(),
]);
}
#[Route('/verify/email', name: 'app_verify_email')]
public function verifyUserEmail(Request $request, UserRepository $userRepository): Response
{
$id = $request->get('id');
if ($id === null) {
return $this->redirectToRoute('app_login');
}
$user = $userRepository->find($id);
if ($user === null) {
return $this->redirectToRoute('app_login');
}
// validate email confirmation link, sets User::isVerified=true and persists
try {
$this->emailVerifier->handleEmailConfirmation($request, $user);
} catch (VerifyEmailExceptionInterface $exception) {
$this->addFlash('verify_email_error', $exception->getReason());
return $this->redirectToRoute('app_login');
}
// @TODO Change the redirect on success and handle or remove the flash message in your templates
$this->addFlash('success', 'Your email address has been verified.');
return $this->redirectToRoute('blogs');
}
}

View File

@ -1,179 +0,0 @@
<?php
namespace App\Controller;
use App\Entity\User;
use App\Form\ChangePasswordFormType;
use App\Form\ResetPasswordRequestFormType;
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use SymfonyCasts\Bundle\ResetPassword\Controller\ResetPasswordControllerTrait;
use SymfonyCasts\Bundle\ResetPassword\Exception\ResetPasswordExceptionInterface;
use SymfonyCasts\Bundle\ResetPassword\ResetPasswordHelperInterface;
/**
* Class ResetPasswordController
* @package App\Controller
*/
#[Route('/reset-password')]
class ResetPasswordController extends AbstractController
{
use ResetPasswordControllerTrait;
private $resetPasswordHelper;
public function __construct(ResetPasswordHelperInterface $resetPasswordHelper)
{
$this->resetPasswordHelper = $resetPasswordHelper;
}
/**
* Display & process form to request a password reset.
*/
#[Route('', name: 'app_forgot_password_request')]
public function request(Request $request, MailerInterface $mailer): Response
{
$form = $this->createForm(ResetPasswordRequestFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
return $this->processSendingPasswordResetEmail(
$form->get('email')->getData(),
$mailer
);
}
return $this->render('security/request.html.twig', [
'requestForm' => $form->createView(),
]);
}
/**
* Confirmation page after a user has requested a password reset.
*/
#[Route('/check-email', name: 'app_check_email')]
public function checkEmail(): Response
{
// Generate a fake token if the user does not exist or someone hit this page directly.
// This prevents exposing whether or not a user was found with the given email address or not
if (null === ($resetToken = $this->getTokenObjectFromSession())) {
$resetToken = $this->resetPasswordHelper->generateFakeResetToken();
}
return $this->render('security/check_email.html.twig', [
'resetToken' => $resetToken,
]);
}
/**
* Validates and process the reset URL that the user clicked in their email.
*/
#[Route('/reset/{token}', name: 'app_reset_password')]
public function reset(Request $request, UserPasswordHasherInterface $passwordHasher, string $token = null): Response
{
if ($token) {
// We store the token in session and remove it from the URL, to avoid the URL being
// loaded in a browser and potentially leaking the token to 3rd party JavaScript.
$this->storeTokenInSession($token);
return $this->redirectToRoute('app_reset_password');
}
$token = $this->getTokenFromSession();
if ($token === null) {
throw $this->createNotFoundException('No reset password token found in the URL or in the session.');
}
try {
$user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
} catch (ResetPasswordExceptionInterface $e) {
$this->addFlash('reset_password_error', sprintf(
'There was a problem validating your reset request - %s',
$e->getReason()
));
return $this->redirectToRoute('app_forgot_password_request');
}
// The token is valid; allow the user to change their password.
$form = $this->createForm(ChangePasswordFormType::class);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// A password reset token should be used only once, remove it.
$this->resetPasswordHelper->removeResetRequest($token);
// Hash the plain password, and set it.
/*
** @var PasswordAuthenticatedUserInterface $user
*/
$hashedPassword = $passwordHasher->hashPassword(
$user,
$form->get('plainPassword')->getData()
);
$user->setPassword($hashedPassword);
$this->getDoctrine()->getManager()->flush();
// The session is cleaned up after the password has been changed.
$this->cleanSessionAfterReset();
return $this->redirectToRoute('blogs');
}
return $this->render('security/reset.html.twig', [
'resetForm' => $form->createView(),
]);
}
private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse
{
$user = $this->getDoctrine()->getRepository(User::class)->findOneBy([
'email' => $emailFormData,
]);
// Do not reveal whether a user account was found or not.
if (!$user) {
return $this->redirectToRoute('app_check_email');
}
try {
$resetToken = $this->resetPasswordHelper->generateResetToken($user);
} catch (ResetPasswordExceptionInterface $e) {
// If you want to tell the user why a reset email was not sent, uncomment
// the lines below and change the redirect to 'app_forgot_password_request'.
// Caution: This may reveal if a user is registered or not.
//
// $this->addFlash('reset_password_error', sprintf(
// 'There was a problem handling your password reset request - %s',
// $e->getReason()
// ));
return $this->redirectToRoute('app_check_email');
}
$email = (new TemplatedEmail())
->from(new Address('tracer@24unix.net', '24unix.net'))
->to($user->getEmail())
->subject('Your password reset request')
->htmlTemplate('security/email.html.twig')
->context([
'resetToken' => $resetToken,
]);
$mailer->send($email);
// Store the token object in session for retrieval in check-email route.
$this->setTokenObjectInSession($resetToken);
return $this->redirectToRoute('app_check_email');
}
}

View File

@ -2,21 +2,44 @@
namespace App\Controller;
use ApiPlatform\Core\Api\IriConverterInterface;
use App\Entity\User;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
/**
*
*/
class SecurityController extends AbstractController
{
#[Route(path: '/login', name: 'app_login')]
public function login(AuthenticationUtils $authenticationUtils): Response
#[Route(path: '/login', name: 'app_login')] // *** method post
public function login(AuthenticationUtils $authenticationUtils, IriConverterInterface $iriConverter): Response
{
if (!$this->isGranted(attribute: 'IS_AUTHENTICATED_FULLY')) {
return $this->json(data: [
'error' => 'Invalid login request'
], status: 400);
}
/** @var User $user */
$user = $this->getUser() ?? null;
return new Response(content: null, status: 204, headers: [
'Location' => $iriConverter->getIriFromItem(item: $user)
]);
}
/*
return $this->render(view: 'security/login.html.twig', parameters: [
'error' => $authenticationUtils->getLastAuthenticationError(),
'last_username' => $authenticationUtils->getLastUsername(),
]);
*
}
/**

View File

@ -11,65 +11,78 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
/**
* Class UserController
* @package App\Controller
* Class UserController.
*/
class UserController extends AbstractController
{
/**
* @param \App\Repository\UserRepository $userRepository
* @param string $userName
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route(path: '/profile/edit/{username}', name: 'app_profile_edit')]
public function editProfile(UserRepository $userRepository, string $username = ''): Response
{
/** var User $user */
if ($username === '') {
if ($this->isGranted(attribute: 'ROLE_USER')) {
$user = $this->getUser();
} else {
throw new AccessDeniedException(message: 'You need to be logged in.');
}
} else {
if ($this->isGranted(attribute: 'ROLE_ADMIN')) {
$user = $userRepository->findOneBy([
"username" => $username
]);
}
}
if (isset($user)) {
return $this->render(view: 'user/edit_profile.html.twig', parameters: [
'user' => $user,
]);
} else {
throw new UserNotFoundException();
}
}
/**
* @param \App\Repository\UserRepository $userRepository
* @param string $username
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route(path: '/profile/{username}', name: 'app_profile')]
public function showProfile(UserRepository $userRepository, string $username = ''): Response
{
/** var User $user */
if ($username === '') {
$user = $this->getUser();
} else {
$user = $userRepository->findOneBy([
"username" => $username
]);
}
return $this->render(view: 'user/show_profile.html.twig', parameters: [
'user' => $user,
]);
}
/**
* @param \App\Repository\UserRepository $userRepository
* @param string $userName
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route(path: '/profile/edit/{username}', name: 'app_profile_edit')]
public function editProfile(UserRepository $userRepository, string $username = ''): Response
{
/* var User $user */
if ($username === '') {
if ($this->isGranted(attribute: 'ROLE_USER')) {
$user = $this->getUser();
} else {
throw new AccessDeniedException(message: 'You need to be logged in.');
}
} else {
if ($this->isGranted(attribute: 'ROLE_ADMIN')) {
$user = $userRepository->findOneBy([
'username' => $username,
]);
}
}
if (isset($user)) {
return $this->render(view: 'user/edit_profile.html.twig', parameters: [
'user' => $user,
]);
} else {
throw new UserNotFoundException();
}
}
/**
* @param \App\Repository\UserRepository $userRepository
* @param string $username
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route(path: '/profile/{username}', name: 'app_profile')]
public function showProfile(UserRepository $userRepository, string $username = ''): Response
{
/* var User $user */
if ($username === '') {
$user = $this->getUser();
} else {
$user = $userRepository->findOneBy([
'username' => $username,
]);
}
return $this->render(view: 'user/show_profile.html.twig', parameters: [
'user' => $user,
]);
}
/**
* @param \App\Repository\UserRepository $userRepository
*
* @return \Symfony\Component\HttpFoundation\Response
*/
#[Route(path: '/list_users/', name: 'app_list_user')]
public function listUsers(UserRepository $userRepository): Response
{
$users = $userRepository->findAll();
return $this->render(view: 'user/list_users.html.twig', parameters: [
'users' => $users,
]);
}
}

View File

@ -1,299 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\BlogRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JetBrains\PhpStorm\Pure;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\String\Slugger\SluggerInterface;
/**
* @ORM\Entity(repositoryClass=BlogRepository::class)
* @ORM\HasLifecycleCallbacks()
* @UniqueEntity("slug")
*/
class Blog
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $teaser;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $teaserImage;
/**
* @ORM\Column(type="text")
*/
private ?string $content;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="blogs")
* @ORM\JoinColumn(nullable=false)
*/
private ?User $author;
/**
* @ORM\ManyToMany(targetEntity=Section::class, inversedBy="blogs")
*/
private $section;
/**
* @ORM\Column(type="datetime")
*/
private ?\DateTimeInterface $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTimeInterface $editedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private ?User $editedBy;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $editReason;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="blog")
*/
private $comments;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $slug;
#[Pure]
public function __construct()
{
$this->section = new ArrayCollection();
$this->comments = new ArrayCollection();
}
/**
* @return null|string
*/
public function __toString()
{
return $this->title;
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getTeaser(): ?string
{
return $this->teaser;
}
public function setTeaser(?string $teaser): self
{
$this->teaser = $teaser;
return $this;
}
public function getTeaserImage(): ?string
{
return $this->teaserImage;
}
public function setTeaserImage(?string $teaserImage): self
{
$this->teaserImage = $teaserImage;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
/**
* @return Collection|Section[]
*/
public function getSection(): Collection
{
return $this->section;
}
public function addSection(Section $section): self
{
if (!$this->section->contains($section)) {
$this->section[] = $section;
}
return $this;
}
public function removeSection(Section $section): self
{
$this->section->removeElement($section);
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getEditedAt(): ?\DateTimeInterface
{
return $this->editedAt;
}
public function setEditedAt(?\DateTimeInterface $editedAt): self
{
$this->editedAt = $editedAt;
return $this;
}
public function getEditedBy(): ?User
{
return $this->editedBy;
}
public function setEditedBy(?User $editedBy): self
{
$this->editedBy = $editedBy;
return $this;
}
public function getEditReason(): ?string
{
return $this->editReason;
}
public function setEditReason(?string $editReason): self
{
$this->editReason = $editReason;
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setBlog($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getBlog() === $this) {
$comment->setBlog(null);
}
}
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @ORM\PrePersist
*/
public function onPrePersist()
{
$this->createdAt = new \DateTime();
}
/**
* @param SluggerInterface $slugger
*/
public function computeSlug(SluggerInterface $slugger)
{
$this->slug = $slugger->slug($this->title);
}
}

View File

@ -1,162 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\CommentRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CommentRepository::class)
*/
class Comment
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Blog::class, inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $blog;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="text")
*/
private $content;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $author;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $editedAt;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $editedBy;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $editReason;
public function getId(): ?int
{
return $this->id;
}
public function getBlog(): ?Blog
{
return $this->blog;
}
public function setBlog(?Blog $blog): self
{
$this->blog = $blog;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getEditedAt(): ?\DateTimeInterface
{
return $this->editedAt;
}
public function setEditedAt(?\DateTimeInterface $editedAt): self
{
$this->editedAt = $editedAt;
return $this;
}
public function getEditedBy(): ?User
{
return $this->editedBy;
}
public function setEditedBy(?User $editedBy): self
{
$this->editedBy = $editedBy;
return $this;
}
public function getEditReason(): ?string
{
return $this->editReason;
}
public function setEditReason(?string $editReason): self
{
$this->editReason = $editReason;
return $this;
}
}

152
src/Entity/Pages.php Normal file
View File

@ -0,0 +1,152 @@
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Repository\PagesRepository;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
use Sunrise\Slugger\Slugger;
#[ORM\Entity(repositoryClass: PagesRepository::class), ORM\HasLifecycleCallbacks]
#[ApiResource]
#[ApiFilter(filterClass: SearchFilter::class, properties: ['slug' => 'exact'])]
class Pages
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $name;
#[ORM\Column(type: 'text')]
private $content;
#[ORM\Column(type: 'datetime_immutable')]
private $createdAt;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private $modifiedAt;
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'pages')]
#[ORM\JoinColumn(nullable: false)]
private $owner;
#[ORM\Column(type: 'string', length: 255)]
private $slug;
/**
* @param $id
*/
/* public function __construct(String $name = '', String $content = '')
{
$this->name = $name;
$this->content = $content;
$owner = $userRepository->findOneBy(['username' => 'tracer']);
$this->owner = $owner;
}
*/
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt(): ?DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getModifiedAt(): ?DateTimeImmutable
{
return $this->modifiedAt;
}
public function setModifiedAt(?DateTimeImmutable $modifiedAt): self
{
$this->modifiedAt = $modifiedAt;
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
#[ORM\PrePersist]
public function onPrePersist(): void
{
$slugger = new Slugger();
$slug = $slugger->slugify(string: $this->name);
$this->slug = $slug;
$this->createdAt = new DateTimeImmutable(datetime: 'now');
}
#[ORM\PreUpdate]
public function onPreUpdate(): void
{
$slugger = new Slugger();
$slug = $slugger->slugify(string: $this->name);
$this->slug = $slug;
$this->modifiedAt = new DateTimeImmutable(datetime: 'now');
}
}

View File

@ -2,15 +2,14 @@
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\ProjectsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
*
*/
#[ORM\Entity(repositoryClass: ProjectsRepository::class)]
#[ApiResource]
class Projects
{
#[ORM\Id]
@ -40,16 +39,16 @@ class Projects
{
$this->developer = new ArrayCollection();
}
/**
* @return null|string
*/
public function __toString()
{
return $this->name;
}
public function getId(): ?int
/**
* @return string|null
*/
public function __toString()
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}

View File

@ -2,10 +2,12 @@
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\QuotesRepository;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: QuotesRepository::class)]
#[ApiResource]
class Quotes
{
#[ORM\Id]

View File

@ -1,45 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\ResetPasswordRequestRepository;
use Doctrine\ORM\Mapping as ORM;
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordRequestInterface;
use SymfonyCasts\Bundle\ResetPassword\Model\ResetPasswordRequestTrait;
/**
* @ORM\Entity(repositoryClass=ResetPasswordRequestRepository::class)
*/
class ResetPasswordRequest implements ResetPasswordRequestInterface
{
use ResetPasswordRequestTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private $user;
public function __construct(object $user, \DateTimeInterface $expiresAt, string $selector, string $hashedToken)
{
$this->user = $user;
$this->initialize($expiresAt, $selector, $hashedToken);
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): object
{
return $this->user;
}
}

View File

@ -1,114 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\SectionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SectionRepository::class)
*/
class Section
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $teaserImage;
/**
* @ORM\ManyToMany(targetEntity=Blog::class, mappedBy="section")
*/
private $blogs;
public function __construct()
{
$this->blogs = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getTeaserImage(): ?string
{
return $this->teaserImage;
}
public function setTeaserImage(?string $teaserImage): self
{
$this->teaserImage = $teaserImage;
return $this;
}
/**
* @return Collection|Blog[]
*/
public function getBlogs(): Collection
{
return $this->blogs;
}
public function addBlog(Blog $blog): self
{
if (!$this->blogs->contains($blog)) {
$this->blogs[] = $blog;
$blog->addSection($this);
}
return $this;
}
public function removeBlog(Blog $blog): self
{
if ($this->blogs->removeElement($blog)) {
$blog->removeSection($this);
}
return $this;
}
}

View File

@ -2,224 +2,304 @@
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Repository\UserRepository;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use PhpParser\Node\Scalar\String_;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
*
* => ["security" => "is_granted('ROLE_ADMIN') or object.owner == user"]
*/
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
#[ORM\Entity(repositoryClass: UserRepository::class), ORM\HasLifecycleCallbacks]
#[ApiResource(
collectionOperations: ['get', 'post'],
itemOperations : ['get'],
attributes : ['security' => 'is_granted("ROLE_USER")']
)]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 180, unique: true)]
private string $username;
#[ORM\Column(type: 'json')]
private array $roles = [];
#[ORM\Column(type: 'string')]
private string $password;
private string $plainPassword;
#[ORM\Column(type: 'string', length: 255)]
private string $email;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $firstName = '';
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $lastName = '';
#[ORM\ManyToMany(targetEntity: Projects::class, mappedBy: 'developer')]
private $projects;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $avatar;
public function __construct()
{
$this->projects = new ArrayCollection();
}
/**
* @return null|string
*/
public function __toString()
{
return $this->username;
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return string
*/
public function getPlainPassword(): string
{
return $this->plainPassword;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return $this->username;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique(array: $roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
$this->plainPassword = '';
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* @param string $plainPassword
*/
public function setPlainPassword(string $plainPassword): void
{
$this->plainPassword = $plainPassword;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
/**
* @return Collection<int, Projects>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Projects $project): self
{
if (!$this->projects->contains(element: $project)) {
$this->projects[] = $project;
$project->addDeveloper(developer: $this);
}
return $this;
}
public function removeProject(Projects $project): self
{
if ($this->projects->removeElement(element: $project)) {
$project->removeDeveloper(developer: $this);
}
return $this;
}
public function getAvatar(): string
{
return $this->avatar ?? '';
}
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private int $id;
#[ORM\Column(type: 'string', length: 180, unique: true)]
private string $username;
#[ORM\Column(type: 'json')]
private array $roles = [];
#[ORM\Column(type: 'string')]
private string $password;
private string $plainPassword;
#[ORM\Column(type: 'string', length: 255)]
private string $email;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $firstName = '';
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $lastName = '';
#[ORM\ManyToMany(targetEntity: Projects::class, mappedBy: 'developer')]
private $projects;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $avatar;
#[ORM\OneToMany(mappedBy: 'owner', targetEntity: Pages::class)]
private $pages;
#[ORM\Column(type: 'datetime_immutable')]
private $createdAt;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private $modifiedAt;
public function __construct()
{
$this->projects = new ArrayCollection();
$this->pages = new ArrayCollection();
}
/**
* @return string|null
*/
public function __toString()
{
return $this->username;
}
public function getId(): ?int
{
return $this->id;
}
public function getPlainPassword(): string
{
return $this->plainPassword;
}
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return $this->username;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique(array: $roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
$this->plainPassword = '';
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function setPlainPassword(string $plainPassword): void
{
$this->plainPassword = $plainPassword;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
/**
* @return Collection<int, Projects>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Projects $project): self
{
if (!$this->projects->contains(element: $project)) {
$this->projects[] = $project;
$project->addDeveloper(developer: $this);
}
return $this;
}
public function removeProject(Projects $project): self
{
if ($this->projects->removeElement(element: $project)) {
$project->removeDeveloper(developer: $this);
}
return $this;
}
public function getAvatar(): string
{
return $this->avatar ?? '';
}
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
/**
* @return Collection<int, Pages>
*/
public function getPages(): Collection
{
return $this->pages;
}
public function addPage(Pages $page): self
{
if (!$this->pages->contains($page)) {
$this->pages[] = $page;
$page->setOwner($this);
}
return $this;
}
public function removePage(Pages $page): self
{
if ($this->pages->removeElement($page)) {
// set the owning side to null (unless already changed)
if ($page->getOwner() === $this) {
$page->setOwner(null);
}
}
return $this;
}
public function getCreatedAt(): ?DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getModifiedAt(): ?DateTimeImmutable
{
return $this->modifiedAt;
}
public function setModifiedAt(?DateTimeImmutable $modifiedAt): self
{
$this->modifiedAt = $modifiedAt;
return $this;
}
public function getAvatarUri()
{
return 'avatar';
}
#[ORM\PrePersist]
public function onPrePersist(): void
{
$this->createdAt = new DateTimeImmutable(datetime: 'now');
}
#[ORM\PreUpdate]
public function onPreUpdate(): void
{
$this->modifiedAt = new DateTimeImmutable(datetime: 'now');
}
}

View File

@ -1,43 +0,0 @@
<?php
namespace App\EntityListener;
use App\Entity\Blog;
use Doctrine\ORM\Event\LifecycleEventArgs;
use JetBrains\PhpStorm\NoReturn;
use Symfony\Component\String\Slugger\SluggerInterface;
/**
* Class BlogEntityListener
* @package App\EntityListener
*/
class BlogEntityListener
{
private SluggerInterface $slugger;
public function __construct(SluggerInterface $slugger)
{
$this->slugger = $slugger;
}
/**
* @param \App\Entity\Blog $blog
* @param \Doctrine\ORM\Event\LifecycleEventArgs $title
*/
#[NoReturn]
public function prePersist(Blog $blog, LifecycleEventArgs $title)
{
$blog->computeSlug($this->slugger);
}
/**
* @param \App\Entity\Blog $blog
* @param \Doctrine\ORM\Event\LifecycleEventArgs $title
*/
#[NoReturn]
public function preUpdate(Blog $blog, LifecycleEventArgs $title)
{
//dd($title);
$blog->computeSlug($this->slugger);
}
}

View File

@ -1,40 +0,0 @@
<?php
namespace App\Form;
use App\Entity\Blog;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Class BlogFormType
* @package App\Form
*/
class BlogFormType extends \Symfony\Component\Form\AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title')
->add('teaser')
->add('content')
->add('author');
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Blog::class
]);
}
}

View File

@ -1,55 +0,0 @@
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* Class ChangePasswordFormType
* @package App\Form
*/
class ChangePasswordFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('plainPassword', RepeatedType::class, [
'type' => PasswordType::class,
'first_options' => [
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least {{ limit }} characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
'label' => 'New password',
],
'second_options' => [
'attr' => ['autocomplete' => 'new-password'],
'label' => 'Repeat Password',
],
'invalid_message' => 'The password fields must match.',
// Instead of being set onto the object directly,
// this is read and hashed in the controller
'mapped' => false,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([]);
}
}

View File

@ -1,68 +0,0 @@
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\IsTrue;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
/**
* Class RegistrationFormType
* @package App\Form
*/
class RegistrationFormType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username')
->add('agreeTerms', CheckboxType::class, [
'mapped' => false,
'constraints' => [
new IsTrue([
'message' => 'You should agree to our terms.',
]),
],
])
->add('plainPassword', PasswordType::class, [
// instead of being set onto the object directly,
// this is read and hashed in the controller
'mapped' => false,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least {{ limit }} characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
])
->add('firstName')
->add('lastName')
->add('email', EmailType::class);
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;
class ResetPasswordRequestFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email', EmailType::class, [
'attr' => ['autocomplete' => 'email'],
'constraints' => [
new NotBlank([
'message' => 'Please enter your email',
]),
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([]);
}
}

View File

@ -1,50 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\Blog;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Blog|null find($id, $lockMode = null, $lockVersion = null)
* @method Blog|null findOneBy(array $criteria, array $orderBy = null)
* @method Blog[] findAll()
* @method Blog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class BlogRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Blog::class);
}
// /**
// * @return Blog[] Returns an array of Blog objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('b')
->andWhere('b.exampleField = :val')
->setParameter('val', $value)
->orderBy('b.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Blog
{
return $this->createQueryBuilder('b')
->andWhere('b.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

View File

@ -1,50 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\Comment;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @method Comment|null find($id, $lockMode = null, $lockVersion = null)
* @method Comment|null findOneBy(array $criteria, array $orderBy = null)
* @method Comment[] findAll()
* @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class CommentRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Comment::class);
}
// /**
// * @return Comment[] Returns an array of Comment objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->orderBy('c.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Comment
{
return $this->createQueryBuilder('c')
->andWhere('c.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

Some files were not shown because too many files have changed in this diff Show More