<?php
namespace App\EventListener;
use App\Controller\Page\ApplicantController;
use App\Controller\Page\AppointmentController;
use App\Controller\Page\BlogPostController;
use App\Controller\Page\BlogPostsController;
use App\Controller\Page\CompaniesController;
use App\Controller\Page\CompanyController;
use App\Controller\Page\ContactController;
use App\Controller\Page\ElementController;
use App\Controller\Page\EmployeeController;
use App\Controller\Page\EventController;
use App\Controller\Page\EventRegistrationController;
use App\Controller\Page\EventsController;
use App\Controller\Page\JobAlertController;
use App\Controller\Page\NewsletterController;
use App\Controller\Page\OptionController;
use App\Controller\Page\OrderController;
use App\Controller\Page\OrderSnippetController;
use App\Controller\Page\PortfolioController;
use App\Controller\Page\PortfoliosController;
use App\Controller\Page\ProductController;
use App\Controller\Page\ProductsController;
use App\Controller\Page\ReviewController;
use App\Controller\Page\ReviewsController;
use App\Controller\Page\SearchController;
use App\Controller\Page\TestimonialController;
use App\Controller\Page\User\MobilityController;
use App\Controller\Page\VacanciesController;
use App\Controller\Page\VacancyController;
use App\Entity\ApplicantForm;
use App\Entity\Grid;
use App\Entity\Head;
use App\Entity\Option;
use App\Entity\OptionValue;
use App\Entity\Page;
use App\Entity\Route;
use App\Entity\Site;
use App\Event\SiteCreatedEvent;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment as TwigEnvironment;
use Twig\Error\LoaderError as Twig_Error_Loader;
use Twig\Error\RuntimeError as Twig_Error_Runtime;
use Twig\Error\SyntaxError as Twig_Error_Syntax;
class SiteListener
{
public const SYSTEM_PAGE_TEMPLATE_BOXED = 'pages/system_page.html.twig';
public const SYSTEM_PAGE_TEMPLATE_EMPTY = 'pages/system_page_empty.html.twig';
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var SerializerInterface
*/
private $serializer;
/**
* @var RouterInterface
*/
private $router;
/**
* @var Twig_Environment
*/
private $twig;
/**
* @var TranslatorInterface
*/
private $translator;
/**
* @var string
*/
private $locale;
/**
* @var string
*/
private $locales;
/**
* @var Site|null
*/
private $site;
protected string $projectDir;
/**
* @var array
*/
private $routes;
public function __construct(
RouterInterface $router,
TwigEnvironment $twig,
TranslatorInterface $translator,
string $locale
) {
$this->serializer = new Serializer([new ObjectNormalizer()], [new JsonEncoder()]);
$this->router = $router;
$this->twig = $twig;
$this->translator = $translator;
$this->locale = $locale;
$this->locales = array_diff(['nl', 'en', 'de', 'fr', 'pl', 'ro', 'es', 'da', 'sv'], [$locale]);
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
public function onPageCreate(SiteCreatedEvent $event)
{
$this->routes = require_once __DIR__.'/../../app/page_routes.php';
$output = $event->getOutput();
$this->entityManager = $event->getEntityManager();
$this->createWebring($output);
$headerNavigation = $this->createHeaderNavigation($output);
$repository = $this->createRepository($output);
$this->createFooterNavigation($output);
$this->createFooterBottomNavigation($output);
$this->createHomepage($output, $headerNavigation);
$this->createGrid($output);
$this->createUserLoginPage($output, $repository);
$this->createAppointmentThanksPage($output, $repository);
$this->createBlog($output, $headerNavigation);
$this->createEvent($output, $headerNavigation, $repository);
$this->createJobAlert($output, $headerNavigation);
$this->createOrder($output, $repository);
$this->createSample($output, $repository);
$this->createPortfolio($output, $headerNavigation);
$this->createProduct($output, $headerNavigation);
$this->createReview($headerNavigation);
$this->createNewsletter($output, $repository);
$this->add404Page($output, $repository);
$this->add500Page($output, $repository);
$this->createTestimonial($output, $repository);
$this->createCompany($output, $headerNavigation);
$this->createEmployees($repository);
$this->createVacancy($output, $headerNavigation);
$this->createContact($output, $headerNavigation);
$this->createSearch($output, $headerNavigation);
$this->createJobProfile($output);
$this->createEmployeeOverviewPage();
$this->createTestimonialOverviewPage();
$this->createOption($output);
$this->createElementOverview();
}
/**
* @param bool $showInMenu
*
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*
* @return Page
*/
private function createPage(
string $title,
?string $placeholder = null,
$showInMenu = true,
?Page $parent = null,
bool $deleteable = false,
?string $type = null,
?string $alias = null,
?string $feature = null,
?string $systemPageTemplate = self::SYSTEM_PAGE_TEMPLATE_BOXED
) {
$body = '';
if ($placeholder) {
$body = $this->twig->render($systemPageTemplate, [
'placeholder' => $placeholder,
]);
}
$page = (new Page())
->setTitle($this->translator->trans($title, [], 'pages', $this->locale))
->setBody($body)
->setShowInMenu($showInMenu)
->setParent($parent)
->setTranslatableLocale($this->locale)
->setDeletable($deleteable)
;
if ($type) {
$page->setType($type);
}
if ($alias) {
$page->setAlias($alias);
}
if ($feature) {
$page->setFeature($feature);
}
$this->entityManager->persist($page);
$this->entityManager->flush();
if (!$placeholder) {
return $page;
}
foreach ($this->locales as $locale) {
$page->setTranslatableLocale($locale);
$page->setTitle('en' === $locale ? $title : $this->translator->trans($title, [], 'pages', $locale));
$page->setBody($body);
$this->entityManager->persist($page);
$this->entityManager->flush();
}
return $page;
}
private function createRoute(
string $name,
array $staticPrefix,
array $defaults,
Page $page,
?string $variablePattern = null,
?array $requirements = null
) {
$route = (new Route())
->setName($name)
->setStaticPrefix($staticPrefix)
->setDefaults($defaults)
->setPage($page)
;
if ($variablePattern) {
$route->setVariablePattern($variablePattern);
}
if ($requirements) {
$route->setRequirements($requirements);
}
$this->entityManager->persist($route);
$this->entityManager->flush();
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
public function createReview(Page $parent)
{
$reviewsPage = $this->createPage(
'Reviews',
'{reviews}',
true,
$parent,
false,
null,
null,
FeatureFlagListener::FEATURE_REVIEW
);
$this->createRoute(
'review_index',
$this->routes['review_index'] ?? ['nl' => '/reviews'],
['_controller' => ReviewsController::class.':indexAction'],
$reviewsPage
);
$this->createRoute(
'review_form',
$this->routes['review_form'] ?? ['nl' => '/reviews/formulier'],
['_controller' => ReviewsController::class.':formAction'],
$this->createPage(
'Review form',
'{review_form}',
false,
$reviewsPage,
false,
null,
null,
FeatureFlagListener::FEATURE_REVIEW
)
);
$this->createRoute(
'review_form_confirmation',
$this->routes['review_form_confirmation'] ?? ['nl' => '/reviews/form/bedankt'],
['_controller' => ReviewsController::class.':formConfirmAction'],
$this->createPage(
'Review thanks',
'{review_form_thanks}',
false,
$reviewsPage,
false,
null,
null,
FeatureFlagListener::FEATURE_REVIEW
)
);
$this->createRoute(
'review_detail',
$this->routes['review_detail'] ?? ['nl' => '/review'],
['_controller' => ReviewController::class.':detailAction'],
$this->createPage(
'Review detail',
'{review}',
false,
$reviewsPage,
false,
null,
null,
FeatureFlagListener::FEATURE_REVIEW
)
);
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*
* @return Page
*/
public function createWebring(OutputInterface $output)
{
$webRing = $this->createPage(
'Webring',
null,
false,
null,
false,
'container',
'webring'
);
$output->writeln('Created webring container');
return $webRing;
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*
* @return Page
*/
public function createRepository(OutputInterface $output)
{
$repository = $this->createPage(
'Repository',
null,
false,
null,
false,
'container',
'repository'
);
$output->writeln('Created repository container');
return $repository;
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*
* @return Page
*/
public function createHeaderNavigation(OutputInterface $output)
{
$headerNavigation = $this->createPage(
'Header navigation',
null,
false,
null,
false,
'container',
'header_navigation'
);
$output->writeln('Created header navigation container');
return $headerNavigation;
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*
* @return Page
*/
private function createFooterNavigation(OutputInterface $output)
{
$footerNavigation = $this->createPage(
'Footer navigation',
null,
false,
null,
false,
'container',
'footer_navigation'
);
$output->writeln('Created footer navigation container');
return $footerNavigation;
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*
* @return Page
*/
private function createFooterBottomNavigation(OutputInterface $output)
{
$footerBottomNavigation = $this->createPage(
'Footer bottom navigation',
null,
false,
null,
false,
'container',
'footer_bottom_navigation'
);
$output->writeln('Created footer bottom navigation container');
return $footerBottomNavigation;
}
private function createGrid(OutputInterface $output)
{
$heads = [
(new Head())->setName('Eigenschap'),
(new Head())->setName('Waarde'),
];
$grid = (new Grid())->setName('Default');
foreach ($heads as $head) {
$grid->addHead($head);
}
$this->entityManager->persist($grid);
$this->entityManager->flush();
$output->writeln('Created default Grid');
$this->entityManager->flush();
$output->writeln('Added default Grid for Product Grid');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createUserLoginPage(OutputInterface $output, Page $repository)
{
$this->createRoute(
Route::ALIAS_PREFIX.'user_login',
$this->routes[Route::ALIAS_PREFIX.'user_login'] ?? ['nl' => '/frontend/user/login'],
[],
$this->createPage('Frontend User login', '{user_login}', true, $repository, false)
);
$output->writeln('Created user login page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createAppointmentThanksPage(OutputInterface $output, Page $headerNavigation)
{
$this->createRoute(
'appointment_thanks',
$this->routes['appointment_thanks'] ?? ['nl' => '/afspraak/bedankt'],
['_controller' => AppointmentController::class.':thanksAction'],
$this->createPage('Appointment thanks', '{appointment_thanks}', false, $headerNavigation, false)
);
$output->writeln('Created appointment thanks page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createBlog(OutputInterface $output, Page $headerNavigation)
{
$page = $this->createPage(
'Blogs',
'{blogs}',
true,
$headerNavigation,
false,
null,
null,
FeatureFlagListener::FEATURE_BLOG
);
$output->writeln('Created blog overview page');
$this->createRoute(
'blogs',
$this->routes['blogs'] ?? ['nl' => '/blogs'],
['_controller' => BlogPostsController::class.':indexAction'],
$page
);
$this->createRoute(
'blogs_with_filters',
$this->routes['blogs'] ?? ['nl' => '/blogs'],
['_controller' => BlogPostsController::class.':indexAction'],
$page,
'/{filters}',
['filters' => '.+']
);
$page = $this->createPage(
'Blog detail',
'{blog}',
false,
$page,
false,
null,
null,
FeatureFlagListener::FEATURE_BLOG
);
$output->writeln('Created blog detail page');
$this->createRoute(
'blog_detail',
$this->routes['blog_detail'] ?? ['nl' => '/blog'],
['_controller' => BlogPostController::class.':detailAction'],
$page,
'/{id}/{slug}',
['id' => '\d+']
);
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createEvent(OutputInterface $output, Page $headerNavigation, Page $repository)
{
$page = $this->createPage('Events', '{events}', false, $headerNavigation);
$output->writeln('Created events overview page');
$this->createRoute(
'events',
$this->routes['events'] ?? ['nl' => '/evenementen'],
['_controller' => EventsController::class.':indexAction'],
$page
);
$this->createRoute(
'events_with_filter',
$this->routes['events'] ?? ['nl' => '/evenementen'],
['_controller' => EventsController::class.':indexAction'],
$page,
'/filter/{filters}',
['filters' => '.+']
);
$output->writeln('Created events with filter page');
$this->createRoute(
'event_detail',
$this->routes['event_detail'] ?? ['nl' => '/evenement'],
['_controller' => EventController::class.':detailAction'],
$this->createPage('Event detail', '{event}', true, $page),
'/{id}/{slug}',
['id' => '\d+']
);
$output->writeln('Created event detail page');
$this->createRoute(
'registration',
$this->routes['registration'] ?? ['nl' => '/registratie'],
['_controller' => EventRegistrationController::class.':registrationAction'],
$this->createPage('Registration', '{registration}', false, $repository),
'/{id}/{slug}',
['id' => '\d+']
);
$output->writeln('Created registration detail page');
$this->createRoute(
'registration_thanks',
$this->routes['registration_thanks'] ?? ['nl' => '/registratie/bedankt'],
['_controller' => EventRegistrationController::class.':thanksRegistrationAction'],
$this->createPage('Registration thanks', '{registration_thanks}', false, $repository)
);
$output->writeln('Created registration thanks page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createJobAlert(OutputInterface $output, Page $headerNavigation)
{
$jobAlertPage = $this->createPage('Jobalert', '{jobalert_form}', true, $headerNavigation);
$this->createRoute(
'jobalert',
$this->routes['jobalert'] ?? ['nl' => '/jobalert'],
['_controller' => JobAlertController::class.':indexAction'],
$jobAlertPage
);
$output->writeln('Created jobalert page');
$this->createRoute(
'jobalert_thanks',
$this->routes['jobalert_thanks'] ?? ['nl' => '/jobalert/bedankt'],
['_controller' => JobAlertController::class.':thanksAction'],
$this->createPage('JobAlert thanks', '{jobalert_thanks}', false, $jobAlertPage)
);
$output->writeln('Created jobalert thanks page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createOrder(OutputInterface $output, Page $headerNavigation)
{
$this->createRoute(
'order_thanks',
$this->routes['order_thanks'] ?? ['nl' => '/bestelling/bedankt'],
['_controller' => OrderController::class.':thanksInvoiceAction'],
$this->createPage('Order thanks', '{order_thanks}', false, $headerNavigation)
);
$output->writeln('Created order thanks page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createSample(OutputInterface $output, Page $headerNavigation)
{
$this->createRoute(
'request_sample',
$this->routes['request_sample'] ?? ['nl' => '/bestelling/sample-aanvraag'],
['_controller' => OrderSnippetController::class.':requestSampleAction'],
$this->createPage('Request a sample', '{request_sample}', false, $headerNavigation),
'/{id}'
);
$output->writeln('Created request sample page');
$this->createRoute(
'sample_thanks',
$this->routes['sample_thanks'] ?? ['nl' => '/bestelling/sample-bedankt'],
['_controller' => OrderController::class.':thanksSampleAction'],
$this->createPage(
'Thank you for requesting a sample',
'{sample_thanks}',
false,
$headerNavigation
)
);
$output->writeln('Created sample thanks page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createPortfolio(OutputInterface $output, Page $repository)
{
$portfoliosPage = $this->createPage('Portfolio', '{portfolios}', false, $repository);
$this->createRoute(
'portfolios',
$this->routes['portfolios'] ?? ['nl' => '/portfolios'],
['_controller' => PortfoliosController::class.':indexAction'],
$portfoliosPage
);
$output->writeln('Created portfolio overview page');
$this->createRoute(
'portfolio_detail',
$this->routes['portfolio_detail'] ?? ['nl' => '/portfolio'],
['_controller' => PortfolioController::class.':detailAction'],
$this->createPage('Portfolio detail', '{portfolio}', false, $portfoliosPage),
'/{id}/{slug}',
['id' => '\d+']
);
$output->writeln('Created portfolio detail page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createProduct(OutputInterface $output, Page $repository)
{
$productsPage = $this->createPage(
'Products',
'{products}',
true,
$repository,
false,
null,
null,
FeatureFlagListener::FEATURE_PRODUCT
);
$this->createRoute(
'products',
$this->routes['products'] ?? ['nl' => '/producten'],
['_controller' => ProductsController::class.':indexAction'],
$productsPage
);
$this->createRoute(
'products_with_filter',
$this->routes['products'] ?? ['nl' => '/producten'],
['_controller' => ProductsController::class.':indexAction'],
$productsPage,
'/{filters}',
['filters' => '.+']
);
$output->writeln('Created vacancy page');
$productDetailPage = $this->createPage(
'Product detail',
'{product}',
false,
$productsPage,
false,
null,
null,
FeatureFlagListener::FEATURE_PRODUCT
);
$this->createRoute(
'product_detail',
$this->routes['product_detail'] ?? ['nl' => '/product'],
['_controller' => ProductController::class.':detailAction'],
$productDetailPage,
'/{id}/{slug}'
);
$this->createRoute(
'product_detail_without_slug',
$this->routes['product_detail'] ?? ['nl' => '/product'],
['_controller' => ProductController::class.':detailAction'],
$productDetailPage,
'/{id}'
);
$output->writeln('Created vacancy detail page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createContact(OutputInterface $output, Page $parent)
{
$contactPage = $this->createPage('Contact', '{contact_form}', true, $parent);
$this->createRoute(
'contact',
$this->routes['contact'] ?? ['nl' => 'contact'],
['_controller' => ContactController::class.':indexAction'],
$contactPage
);
$output->writeln('Created contact page');
$this->createRoute(
'contact_thanks',
$this->routes['contact_thanks'] ?? ['nl' => '/contact/bedankt'],
['_controller' => ContactController::class.':thankAction'],
$this->createPage('Contact thanks', '{contact_thanks}', false, $contactPage)
);
$output->writeln('Created contact thanks page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createNewsletter(OutputInterface $output, Page $headerNavigation)
{
$this->createRoute(
'newsletter_subscribe',
$this->routes['newsletter_subscribe'] ?? ['nl' => '/nieuwsbrief/aanmelden'],
['_controller' => NewsletterController::class.':subscribeAction'],
$this->createPage(
'Subscribed to our newsletter',
'{newsletter_subscribe}',
false,
$headerNavigation
),
'/{email}'
);
$output->writeln('Newsletter Subscribed page is created');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createHomepage(OutputInterface $output, Page $parent)
{
$this->createRoute(
'homepage',
$this->routes['homepage'] ?? ['nl' => '/'],
[],
$this->createPage(
'Homepage',
'Welkom',
true,
$parent,
false,
null,
Page::ALIAS_HOMEPAGE
)
);
$output->writeln('Created homepage page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function add404Page(OutputInterface $output, Page $repository)
{
$this->createRoute(
'404_page',
$this->routes['404_page'] ?? ['nl' => '/404'],
[],
$this->createPage(
'404 page',
'This page cannot be displayed',
false,
$repository,
false,
null,
'404_page'
)
);
$output->writeln('Created 404 page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function add500Page(OutputInterface $output, Page $repository)
{
$this->createRoute(
'500_page',
$this->routes['500_page'] ?? ['nl' => '/500'],
[],
$this->createPage(
'500 page',
'Sorry, we had some technical problems during your last operation.',
false,
$repository,
false,
null,
'500_page'
)
);
$output->writeln('Created 500 page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createTestimonial(OutputInterface $output, Page $headerNavigation)
{
$this->createRoute(
'testimonial_detail',
$this->routes['testimonial_detail'] ?? ['nl' => '/testimonial'],
['_controller' => TestimonialController::class.':detailAction'],
$this->createPage('Testimonial detail', '{testimonial}', false, $headerNavigation),
'/{id}/{slug}'
);
$output->writeln('Created testimonial detail page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createOption(OutputInterface $output)
{
$educationOption = new Option();
$educationOption
->setTitle('Opleiding')
->addValue((new OptionValue())->setValue('Elementair'))
->addValue((new OptionValue())->setValue('MAVO'))
->addValue((new OptionValue())->setValue('HAVO'))
->addValue((new OptionValue())->setValue('VWO'))
->addValue((new OptionValue())->setValue('VMBO'))
->addValue((new OptionValue())->setValue('MBO'))
->addValue((new OptionValue())->setValue('HBO'))
->addValue((new OptionValue())->setValue('WO'))
;
$this->entityManager->persist($educationOption);
$this->entityManager->flush();
$regionOption = new Option();
$regionOption
->setTitle('Regio')
->addValue((new OptionValue())->setValue('Drenthe'))
->addValue((new OptionValue())->setValue('Flevoland'))
->addValue((new OptionValue())->setValue('Friesland'))
->addValue((new OptionValue())->setValue('Gelderland'))
->addValue((new OptionValue())->setValue('Groningen'))
->addValue((new OptionValue())->setValue('Limburg'))
->addValue((new OptionValue())->setValue('Noord-Brabant'))
->addValue((new OptionValue())->setValue('Noord-Holland'))
->addValue((new OptionValue())->setValue('Overijssel'))
->addValue((new OptionValue())->setValue('Utrecht'))
->addValue((new OptionValue())->setValue('Zeeland'))
->addValue((new OptionValue())->setValue('Zuid-Holland'))
;
$this->entityManager->persist($regionOption);
$this->entityManager->flush();
$disciplineOption = new Option();
$disciplineOption
->setTitle('Vakgebied')
->addValue((new OptionValue())->setValue('Front-end development'))
->addValue((new OptionValue())->setValue('Back-end development'))
->addValue((new OptionValue())->setValue('Projectmanagement'))
->addValue((new OptionValue())->setValue('Online marketing'))
->addValue((new OptionValue())->setValue('Design'))
->addValue((new OptionValue())->setValue('Administratief'))
->addValue((new OptionValue())->setValue('Sales'))
;
$this->entityManager->persist($disciplineOption);
$this->entityManager->flush();
$output->writeln('Created options');
$optionDetailPage = $this->createPage(
'Option detail',
'{option}',
false,
null,
false,
null,
null,
null,
self::SYSTEM_PAGE_TEMPLATE_EMPTY
);
$this->createRoute(
'option_detail',
$this->routes['option_detail'] ?? ['nl' => '/option'],
['_controller' => OptionController::class.':detailAction'],
$optionDetailPage,
'/{optionSlug}/{optionValueSlug}'
);
$output->writeln('Created option option detail page');
$optionsOptionDetailPage = $this->createPage(
'Options option detail',
'{option}',
false,
null,
false,
null,
null,
null,
self::SYSTEM_PAGE_TEMPLATE_EMPTY
);
$this->createRoute(
'options_option_detail',
$this->routes['options_option_detail'] ?? ['nl' => '/options'],
['_controller' => OptionController::class.':optionDetail'],
$optionsOptionDetailPage,
'/{subOptions}'
);
$output->writeln('Created options option detail page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createVacancy(OutputInterface $output, Page $headerNavigation)
{
$applicantFormFields = [
[
'type' => 'text',
'required' => true,
'label' => 'Voornaam',
'className' => 'form-control',
'name' => 'firstname',
],
[
'type' => 'text',
'required' => true,
'label' => 'Achternaam',
'className' => 'form-control',
'name' => 'lastname',
],
[
'type' => 'text',
'required' => true,
'label' => 'Stad',
'className' => 'form-control',
'name' => 'city',
'maxlength' => 15,
],
[
'type' => 'text',
'required' => true,
'label' => 'Telefoonnummer',
'className' => 'form-control',
'name' => 'phone',
'maxlength' => 15,
],
[
'type' => 'text',
'required' => true,
'label' => 'E-mailadres',
'className' => 'form-control',
'name' => 'email',
'maxlength' => 100,
],
[
'type' => 'textarea',
'required' => true,
'label' => 'Motivatie',
'className' => 'form-control',
'name' => 'motivation',
'rows' => 20,
],
[
'type' => 'file',
'required' => true,
'label' => 'CV Uploaden',
'className' => 'form-control',
'name' => 'CVFile',
],
];
$forms = $this->entityManager->getRepository(ApplicantForm::class)->findAll();
if (empty($forms)) {
$applicantForm = (new ApplicantForm())
->setTitle('Default')
->setDefault(true)
->setFields(json_encode($applicantFormFields))
;
$this->entityManager->persist($applicantForm);
$this->entityManager->flush();
}
$vacanciesPage = $this->createPage('Vacancies', '{vacancies}', true, $headerNavigation, false, false, null, FeatureFlagListener::FEATURE_VACANCY);
$vacancyApplyPage = $this->createPage('Applicant form', '{vacancy_apply}', false, $vacanciesPage);
$this->createRoute(
'vacancy_apply',
$this->routes['vacancy_apply'] ?? ['nl' => '/vacature-solliciteren'],
['_controller' => ApplicantController::class.':formAction'],
$vacancyApplyPage,
'/{id}'
);
$output->writeln('Created vacancy apply page');
$this->createRoute(
'vacancy_apply_thanks',
$this->routes['vacancy_apply_thanks'] ?? ['nl' => '/vacature-solliciteren-bedankt'],
['_controller' => 'App\Controller\Page\ApplicantController'.':thanksAction', 'id' => null],
$this->createPage('Thank you for applying', '{vacancy_apply_thanks}', false, $vacancyApplyPage),
'/{id}'
);
$output->writeln('Created vacancy apply thanks page');
$this->createRoute(
'vacancies',
$this->routes['vacancies'] ?? ['nl' => '/vacatures'],
['_controller' => VacanciesController::class.':indexAction'],
$vacanciesPage
);
$this->createRoute(
'vacancies_with_filter',
$this->routes['vacancies'] ?? ['nl' => '/vacatures'],
['_controller' => VacanciesController::class.':indexAction'],
$vacanciesPage,
'/{filters}',
['filters' => '.+']
);
$output->writeln('Created vacancy page');
$vacancyDetailPage = $this->createPage('Vacancy detail', '{vacancy}', false, $vacanciesPage);
$this->createRoute(
'vacancy_detail',
$this->routes['vacancy_detail'] ?? ['nl' => '/vacature'],
['_controller' => VacancyController::class.':detailAction'],
$vacancyDetailPage,
'/{id}/{slug}',
['id' => '\d+']
);
$this->createRoute(
'vacancy_detail_without_slug',
$this->routes['vacancy_detail'] ?? ['nl' => '/vacature'],
['_controller' => VacancyController::class.':detailAction'],
$vacancyDetailPage,
'/{id}',
['id' => '\d+']
);
$output->writeln('Created vacancy detail page');
$this->createRoute(
'favorites',
$this->routes['favorites'],
['_controller' => VacanciesController::class.':favoritesOverviewAction'],
$this->createPage('Favorites', '{favorites}', false, $headerNavigation)
);
$output->writeln('Created favorites overview page');
$vacancyCreatePage = $this->createPage('Vacancy create', '{vacancy_create}', false, $headerNavigation);
$this->createRoute(
'vacancy_create_without_account',
$this->routes['vacancy_create_without_account'] ?? ['nl' => '/vacature-aanmaken'],
['_controller' => VacancyController::class.':create'],
$vacancyCreatePage
);
$output->writeln('Created vacancy create page');
$this->createRoute(
'vacancy_create_without_account_thanks',
$this->routes['vacancy_create_without_account_thanks'] ?? ['nl' => '/vacature-aanmaken-bedankt'],
[],
$this->createPage('Thank you for creating a vacancy', null, false, $vacancyCreatePage)
);
$output->writeln('Created vacancy create thanks page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createCompany(OutputInterface $output, Page $parent)
{
$companiesPage = $this->createPage('Companies', '{companies}', false, $parent);
$this->createRoute(
'companies',
$this->routes['companies'] ?? ['nl' => '/bedrijven'],
['_controller' => CompaniesController::class.':indexAction'],
$companiesPage
);
$output->writeln('Created company page');
$this->createRoute(
'company_with_filter',
$this->routes['companies'] ?? ['nl' => '/bedrijven'],
['_controller' => CompanyController::class.':indexAction'],
$companiesPage,
'/{filters}',
['filters' => '.+']
);
$output->writeln('Created company page wih filter');
$companyDetailPage = $this->createPage(
'Company detail',
'{company}',
false,
$companiesPage
);
$this->createRoute(
'company_detail',
$this->routes['company_detail'] ?? ['nl' => '/bedrijf'],
['_controller' => CompanyController::class.':detailAction'],
$companyDetailPage,
'/{id}/{slug}'
);
$this->createRoute(
'company_detail_without_slug',
$this->routes['company_detail'] ?? ['nl' => '/bedrijf'],
['_controller' => CompanyController::class.':detailAction'],
$companyDetailPage,
'/{id}'
);
$output->writeln('Created company detail page');
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createEmployees(Page $parent)
{
$employeeDetailPage = $this->createPage('Employee detail', '{employee}', false, $parent);
$this->createRoute(
'employee_detail',
$this->routes['employee_detail'] ?? ['nl' => 'medewerker'],
['_controller' => EmployeeController::class.':detailAction'],
$employeeDetailPage,
'/{id}/{slug}'
);
}
/**
* @throws Twig_Error_Loader
* @throws Twig_Error_Runtime
* @throws Twig_Error_Syntax
*/
private function createSearch(OutputInterface $output, Page $headerNavigation)
{
$searchPage = $this->createPage('Zoekresultaten', '{search_results}', false, $headerNavigation);
$this->createRoute(
'search',
$this->routes['search'] ?? ['nl' => '/zoeken'],
['_controller' => SearchController::class.':searchAction'],
$searchPage
);
$output->writeln('Created search page');
}
private function createJobProfile(OutputInterface $output)
{
$profilesPage = $this->createPage('Profielen', '{job_profiles}', false, null, false, null, null, FeatureFlagListener::FEATURE_MOBILITY_PLATFORM);
$staticPrefixes = $this->routes['job_profiles'] ?? ['nl' => '/'];
$this->createRoute(
'job_profiles',
$staticPrefixes,
['_controller' => MobilityController::class.':jobProfiles'],
$profilesPage
);
$this->createRoute(
'job_profiles_with_filter',
$staticPrefixes,
['_controller' => MobilityController::class.':jobProfiles'],
$profilesPage,
'/{filters}',
['filters' => '.+']
);
$profilePage = $this->createPage('Profiel', '{job_profile}', false, null, false, null, null, FeatureFlagListener::FEATURE_MOBILITY_PLATFORM);
$this->createRoute(
'job_profile',
$this->routes['job_profile'] ?? ['nl' => '/user/mobility/profiel'],
['_controller' => MobilityController::class.':jobProfile'],
$profilePage,
'/{id}'
);
}
public function createEmployeeOverviewPage()
{
$employeeOverviewPage = $this->createPage('Employees', '{employees}', false);
$this->createRoute(
'employees',
$this->routes['employees'] ?? ['nl' => '/medewerkers'],
['_controller' => EmployeeController::class.':index'],
$employeeOverviewPage,
);
}
public function createTestimonialOverviewPage()
{
$testimonialOverviewPage = $this->createPage('Testimonials', '{testimonials}', false);
$this->createRoute(
'testimonials',
$this->routes['testimonials'] ?? ['nl' => '/getuigenissen'],
['_controller' => TestimonialController::class.':index'],
$testimonialOverviewPage,
);
}
private function createElementOverview(): void
{
$elementOverviewPage = $this->createPage('Elements', '{elements}', false);
$this->createRoute(
'elements',
$this->routes['elements'] ?? ['nl' => '/elements'],
['_controller' => ElementController::class.':index'],
$elementOverviewPage,
);
}
}