<?php declare(strict_types=1);
namespace App\StartPlatz\Bundle\AlphaBundle\Controller;
use App\StartPlatz\Bundle\AlphaBundle\Entity\Feed;
use App\StartPlatz\Bundle\AlphaBundle\Entity\Page;
use App\StartPlatz\Bundle\MemberBundle\Entity\Member;
use App\StartPlatz\Bundle\MemberBundle\Entity\MemberTeam;
use App\StartPlatz\Bundle\MemberBundle\Entity\Option;
use App\StartPlatz\Bundle\MemberBundle\Entity\Team;
use App\StartPlatz\Bundle\StartupBundle\Entity\Application;
use App\StartPlatz\Bundle\StartupBundle\Entity\Batch;
use App\StartPlatz\Bundle\StartupBundle\Entity\Startup;
use App\StartPlatz\Bundle\StartupBundle\Entity\StartupAttribute;
use App\StartPlatz\Bundle\StartupBundle\Entity\StartupLifecycleEvent;
use App\StartPlatz\Bundle\StartupBundle\Entity\StartupRelevance;
use App\StartPlatz\Bundle\StartupBundle\Form\LivecycleEventType;
use App\StartPlatz\Bundle\WebsiteBundle\Utility\Utility;
use DateTime;
use Eckinox\TinymceBundle\Form\Type\TinymceType;
use Speicher210\CloudinaryBundle\Cloudinary\Api;
use Symfony\Component\HttpFoundation\Response;
use stdClass;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use App\StartPlatz\Bundle\FeedbackBundle\FeedbackService;
use App\StartPlatz\Bundle\StartupBundle\Form\StartupType;
use App\StartPlatz\Bundle\UserBundle\Entity\User;
use App\StartPlatz\Bundle\WebsiteBundle\MenuTranslationService;
use App\StartPlatz\Bundle\MentorsBundle\Service\WordPressMenuService;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class StartupController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly SessionInterface $session,
private readonly FormFactoryInterface $formFactory,
private readonly FeedbackService $feedbackService,
private readonly MenuTranslationService $menuTranslationService,
private readonly Api $cloudinary,
private readonly MailerInterface $mailer,
private readonly WordPressMenuService $wordPressMenuService
) {
}
// NOTE: AcceleratorStartupsIndexAction was moved to AcceleratorStartupController
// Routes: /accelerator/startups and /en/accelerator/startups
#[Route('/x/connect/startups/home', name: 'connect_startup_index')]
/**
* @IsGranted("ROLE_USER")
*/
public function indexStartupsSpconnectAction(Request $request): Response
{
return $this->redirectToRoute('connect_startup_index', $request->query->all(), 301);
}
#[Route('/startups', name: 'homepage_startups_home')]
#[Route('/en/startups', name: 'homepage_startups_home_english')]
#[Route('/fr/startups', name: 'homepage_startups_home_french')]
public function indexStartupsHomepageAction(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$redirectUrl = $request->get('redirect');
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
$orderBy = $templateVars['dimensions'] ?: ['score' => 'DESC'];
// Neue Zeile - Sortierung nach lastModified (neueste zuerst)
$orderBy = $templateVars['dimensions'] ?: ['lastModified' => 'DESC'];
$visibility = 'public';
$criteria = ['visibility' => $visibility] + $templateVars['criteria'];
$lang = Utility::getLangByPathInfo($request->getPathInfo());
$teamId = 0;
if ($user = $this->getUser()) {
$teamId = $user->getMemberId();
$this->entityManager->getRepository(User::class)->writeActivity($user);
}
$total = $this->entityManager->getRepository(Startup::class)->countByCriteria($criteria, $teamId);
if ($total > 2560) {
$limit = 2560;
} else {
$limit = $total ?: 1;
}
if (!$page = $request->get('page')) {
$page = 1;
}
$startups = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria, $teamId, $orderBy, $page, $limit);
// UP-024: startplatz field removed from Startup entity
$startupsExtern = [];
$rheinlandPitchBatches = [];
$rheinlandPitchWinnerApplications = [];
$rheinlandPitchWinnerStartups = [];
if (array_key_exists("rheinlandPitchBestResult", $criteria)) {
/*
* now use a totally different logic
* first we find all rheinlandPitchBatches
* then we find all winnerApplications
* then we find all related startups
*/
$rheinlandPitchBatches = $this->entityManager->getRepository(Batch::class)->findBy(['programId'=>1,'focusStatus'=>['4_past','3_previous','2_current']], ['pitchDate'=>'DESC']);
$rheinlandPitchWinnerApplications = $this->entityManager->getRepository(Application::class)->findBy(['programId'=>1,'pitchPosition'=>1], ['batchId'=>'DESC']);
$rheinlandPitchWinnerStartupIds = array_map(fn (Application $entity) => $entity->getStartupId(), $rheinlandPitchWinnerApplications);
$rheinlandPitchWinnerStartups = $this->entityManager->getRepository(Startup::class)->findBy(['id'=>$rheinlandPitchWinnerStartupIds]);
$rheinlandPitchWinnerStartupIds = array_map(fn (Startup $entity) => $entity->getId(), $rheinlandPitchWinnerStartups);
$rheinlandPitchWinnerStartups = array_combine($rheinlandPitchWinnerStartupIds, $rheinlandPitchWinnerStartups);
}
$parentPageSlug = "startups";
if (!$parentPage = $this->entityManager->getRepository(Page::class)->findOneBy(['slug' => $parentPageSlug])) {
$parentPage = new Page();
$parentPage->setTitle('Die STARTPLATZ Startups');
$parentPage->setTeaser('Die erfolgreichen Startups starten hier durch');
$parentPage->setDescription('Page Description');
}
$acceleratorCurrentBatchNumber = $this->entityManager->getRepository(Option::class)->getAcceleratorCurrentBatchNumber();
$startupsCurrentBatch = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria + ['batch' => $acceleratorCurrentBatchNumber], $teamId, $orderBy, 1, 128);
$startupsLastBatch = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria + ['batch' => $acceleratorCurrentBatchNumber -1 ], $teamId, $orderBy, 1, 128);
$startupsBatch20 = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria + ['batch' => $acceleratorCurrentBatchNumber -2], $teamId, $orderBy, 1, 128);
// UP-024: startplatz field removed from Startup entity - these sections now empty
$startupsSpCgn = [];
$startupsSpDus = [];
$startupsAlumni = [];
// UP-024: pitchNumber, rheinlandPitch, rheinlandPitchBestResult fields removed from Startup entity
$startupsRheinlandPitch = [];
// Use findCurrentRheinlandPitchStartups() which queries via Application/Batch instead:
// $startupsRheinlandPitch = $this->entityManager->getRepository(Startup::class)->findCurrentRheinlandPitchStartups('2_current');
$startupsGruenderstipendium = [];
$startupsGruenderstipendium = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria + ['gsStatus' => ['funded','recommended']], $teamId, $orderBy, 1, 1280);
$startupsGruenderstipendiumAlumni = [];
$startupsGruenderstipendiumAlumni = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria + ['gsStatus' => ['alumni']], $teamId, $orderBy, 1, 1280);
$industries = $this->entityManager->getRepository(Startup::class)->getAggregateByGroup('industry', $criteria);
// get teamIds
$teamIds = array_map(fn ($entity) => $entity['teamId'], $startups);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsCurrentBatch);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsLastBatch);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsBatch20);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsSpCgn);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsSpDus);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsAlumni);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsExtern);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsRheinlandPitch);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsGruenderstipendium);
$teamIds = $teamIds + array_map(fn ($entity) => $entity['teamId'], $startupsGruenderstipendiumAlumni);
$teams = $this->entityManager->getRepository(Team::class)->findBy(['id'=>$teamIds]);
$teamIds = array_map(fn ($entity) => $entity->getId(), $teams);
$teams = array_combine($teamIds, $teams);
return $this->render('@StartPlatzAlphaBundle/Startup/index.startups.homepage.html.twig', [
'startups' => $startups,
'startupsCurrentBatch' => $startupsCurrentBatch,
'startupsLastBatch' => $startupsLastBatch,
'startupsBatch20' => $startupsBatch20,
'startupsSpCgn' => $startupsSpCgn,
'startupsSpDus' => $startupsSpDus,
'startupsAlumni' => $startupsAlumni,
'startupsExtern' => $startupsExtern,
'startupsRheinlandPitch' => $startupsRheinlandPitch,
'startupsGruenderstipendium' => $startupsGruenderstipendium,
'startupsGruenderstipendiumAlumni' => $startupsGruenderstipendiumAlumni,
'teams' => $teams,
'currentBatchNumber' => $acceleratorCurrentBatchNumber,
'industries' => $industries,
'parentPage' => $parentPage,
'pageType' => 'startup',
'topic' => 'deepTech',
'lang' => $lang,
'rheinlandPitchBatches' => $rheinlandPitchBatches,
'rheinlandPitchWinnerApplications' => $rheinlandPitchWinnerApplications,
'rheinlandPitchWinnerStartups' => $rheinlandPitchWinnerStartups,
'maxPages' => ceil($total / $limit),
'thisPage' => $page,
'total' => $total,
'limit' => $limit,
'criteria' => $criteria,
'visibility' => $visibility,
'templateVars' => $templateVars,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'website_startups_list', 'parameters' => $templateVars])),
]);
}
#[Route('/x/startups/industries/list', name: 'x_startups_industries_list')]
public function listIndustriesAjaxAction(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
$currentCriteria = $templateVars['criteria'];
if (isset($templateVars['criteria']['industry'])) {
unset($templateVars['criteria']['industry']);
}
if (isset($templateVars['criteria']['isBookmarked'])) {
unset($templateVars['criteria']['isBookmarked']);
}
if (!$source = $request->get('source')) {
$visibility = 'sp-connect';
$targetPath = "connect_startup_index";
} else {
$visibility = 'public';
$targetPath = "homepage_startups_home";
}
$criteria = ['visibility' => $visibility, 'status' => 'active', 'team' => 'exists'] + $templateVars['criteria'];
if ($user = $this->getUser()) {
$teamId = $user->getMemberId();
} else {
$teamId = 0;
}
$industries = $this->entityManager->getRepository(Startup::class)->findIndustries($criteria, $teamId);
return $this->render('@StartPlatzAlpha/Default/list.startupIndustries.modal.html.twig', [
'title' => "Available Industries",
'industries' => $industries,
'targetPath' => $targetPath,
'currentCriteria' => $currentCriteria,
'templateVars' => $templateVars,
'redirectUrl' => $request->get('redirect'),
]);
}
#[Route('/x/startups/tags/list', name: 'x_startups_tags_list')]
public function listTagsAjaxAction(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
$currentCriteria = $templateVars['criteria'];
if (isset($templateVars['criteria']['tags'])) {
unset($templateVars['criteria']['tags']);
}
if (isset($templateVars['criteria']['isBookmarked'])) {
unset($templateVars['criteria']['isBookmarked']);
}
if (!$source = $request->get('source')) {
$visibility = 'sp-connect';
$targetPath = "connect_startup_index";
} else {
$visibility = 'public';
$targetPath = "homepage_startups_home";
}
$criteria = ['visibility' => $visibility, 'status' => 'active', 'team' => 'exists'] + $templateVars['criteria'];
if ($user = $this->getUser()) {
$teamId = $user->getMemberId();
} else {
$teamId = 0;
}
$entities = $this->entityManager->getRepository(Startup::class)->findTags($criteria, $teamId);
return $this->render('@StartPlatzAlpha/Default/list.tags.modal.html.twig', [
'title' => "Tags",
'entities' => $entities,
'btnClass' => "btn-outline-info",
'targetEntity' => "tags",
'targetPath' => $targetPath,
'currentCriteria' => $currentCriteria,
'templateVars' => $templateVars,
'redirect' => $redirect,
'redirectUrl' => $request->get('redirect'),
]);
}
#[Route('/x/startups/filter/rheinland-pitch', name: 'x_startups_filter_rheinland-pitch')]
public function selectFilterRheinlandPitchAction(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
if (!$source = $request->get('source')) {
$visibility = 'sp-connect';
$targetPath = "connect_startup_index";
} else {
$visibility = 'public';
$targetPath = "homepage_startups_home";
}
$criteria = ['visibility' => $visibility, 'status' => 'active', 'team' => 'exists'] + $templateVars['criteria'];
if ($user = $this->getUser()) {
$teamId = $user->getMemberId();
} else {
$teamId = 0;
}
$filter = $request->get('filter');
// UP-024: rheinlandPitchStatus, rheinlandPitchBestResult fields removed from Startup entity
$group1 = "";
$aggregates1 = [];
$group2 = "";
$aggregates2 = [];
// batches
$aggregatesBatches = $this->entityManager->getRepository(Startup::class)->findApplicationsByProgramId(1);
return $this->render('@StartPlatzAlpha/Default/list.rheinland-pitch.modal.html.twig', [
'title' => "Set Filter on {$filter}",
'btnClass' => "btn-outline-info",
'group1' => $group1,
'group2' => $group2,
'aggregates1' => $aggregates1,
'aggregates2' => $aggregates2,
'aggregatesBatches' => $aggregatesBatches,
'targetPath' => $targetPath,
'templateVars' => $templateVars,
'redirect' => $redirect,
'redirectUrl' => $request->get('redirect'),
]);
}
#[Route('/x/startups/filter', name: 'x_startups_filter')]
public function selectFilterAction(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
if (!$source = $request->get('source')) {
$visibility = 'sp-connect';
} else {
$visibility = 'public';
}
if (!$targetPath = $request->get('targetPath')) {
if ($visibility == 'sp-connect') {
$targetPath = "connect_startup_index";
} else {
$targetPath = "homepage_startups_home";
}
}
$criteria = ['visibility' => $visibility, 'status' => 'active', 'team' => 'exists'] + $templateVars['criteria'];
if ($user = $this->getUser()) {
$teamId = $user->getMemberId();
} else {
$teamId = 0;
}
$group = $request->get('filter');
$aggregates = $this->entityManager->getRepository(Startup::class)->getAggregateByGroup($group, $criteria);
$group2 = "";
$aggregates2 = [];
// UP-024: accelerator, batch, batchYear, rheinlandPitch, pitchNumber fields removed from Startup entity
if ($group == 'accelerator') {
$aggregates = []; // Field removed
}
if ($group == 'rheinlandPitch') {
$aggregates = []; // Field removed
}
return $this->render('@StartPlatzAlpha/Default/list.aggregates.modal.html.twig', [
'title' => "Set Filter on {$group}",
'aggregates' => $aggregates,
'btnClass' => "btn-outline-info",
'group' => $group,
'group2' => $group2,
'aggregates2' => $aggregates2,
'targetPath' => $targetPath,
'templateVars' => $templateVars,
'redirect' => $redirect,
'redirectUrl' => $request->get('redirect'),
]);
}
#[Route('/startups-legacy', name: 'extern_startups_home')]
public function indexLegacyAction(Request $request)
{
$member = $this->entityManager->getRepository(Member::class)->findOneBy([]);
$fields = $this->feedbackService->getEntityMethodsArray($member, ['teams']);
$templateVars = $this->entityManager->getRepository(Member::class)->getTemplateVars($request);
if ($user = $this->getUser()) {
$this->entityManager->getRepository(User::class)->writeActivity($user);
}
$metaNameSectionBatch21 = 'website.startups.section.batch21';
$metaNameSectionBatch20 = 'website.startups.section.batch20';
$metaNameSectionBatch19 = 'website.startups.section.batch19';
$metaNameSectionBatch18 = 'website.startups.section.batch18';
$metaNameSectionBatch17 = 'website.startups.section.batch17';
$metaNameSectionKoeln = 'website.startups.section.koeln';
$metaNameSectionDus = 'website.startups.section.dus';
$metaNameSectionAlumni = 'website.startups.section.alumni';
$edit = $request->get('edit');
if (!in_array($edit, ['updateBatch21', 'updateBatch20', 'updateBatch19', 'updateBatch18', 'updateBatch17', 'updateKoeln', 'updateDus', 'updateAlumni'])) {
$edit = null;
}
$sectionBatch21 = $this->getSection($metaNameSectionBatch21);
$sectionBatch20 = $this->getSection($metaNameSectionBatch20);
$sectionBatch19 = $this->getSection($metaNameSectionBatch19);
$sectionBatch18 = $this->getSection($metaNameSectionBatch18);
$sectionBatch17 = $this->getSection($metaNameSectionBatch17);
$sectionKoeln = $this->getSection($metaNameSectionKoeln);
$sectionDus = $this->getSection($metaNameSectionDus);
$sectionAlumni = $this->getSection($metaNameSectionAlumni);
switch ($edit) {
case 'updateBatch21':
$content = $this->transformArrayIntoCsvString($sectionBatch21['content']);
$form = $this->setPlainEditorForm($content);
break;
case 'updateBatch20':
$content = $this->transformArrayIntoCsvString($sectionBatch20['content']);
$form = $this->setPlainEditorForm($content);
break;
case 'updateBatch19':
$content = $this->transformArrayIntoCsvString($sectionBatch19['content']);
$form = $this->setPlainEditorForm($content);
break;
case 'updateBatch18':
$content = $this->transformArrayIntoCsvString($sectionBatch18['content']);
$form = $this->setPlainEditorForm($content);
break;
case 'updateBatch17':
$content = $this->transformArrayIntoCsvString($sectionBatch17['content']);
$form = $this->setPlainEditorForm($content);
break;
case 'updateKoeln':
$content = $this->transformArrayIntoCsvString($sectionKoeln['content']);
$form = $this->setPlainEditorForm($content);
break;
case 'updateDus':
$content = $this->transformArrayIntoCsvString($sectionDus['content']);
$form = $this->setPlainEditorForm($content);
break;
case 'updateAlumni':
$content = $this->transformArrayIntoCsvString($sectionAlumni['content']);
$form = $this->setPlainEditorForm($content);
break;
default:
$content = "";
$form = $this->setEditorForm($content);
}
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$importString = $data['content'];
$rows = explode(PHP_EOL, (string) $importString);
switch ($edit) {
case 'updateBatch21':
$sectionBatch21['content'] = [];
foreach ($rows as $row) {
$sectionBatch21['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionBatch21, null, $sectionBatch21);
break;
case 'updateBatch20':
$sectionBatch20['content'] = [];
foreach ($rows as $row) {
$sectionBatch20['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionBatch20, null, $sectionBatch20);
break;
case 'updateBatch19':
$sectionBatch19['content'] = [];
foreach ($rows as $row) {
$sectionBatch19['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionBatch19, null, $sectionBatch19);
break;
case 'updateBatch18':
$sectionBatch18['content'] = [];
foreach ($rows as $row) {
$sectionBatch18['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionBatch18, null, $sectionBatch18);
break;
case 'updateBatch17':
$sectionBatch17['content'] = [];
foreach ($rows as $row) {
$sectionBatch17['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionBatch17, null, $sectionBatch17);
break;
case 'updateKoeln':
$sectionKoeln['content'] = [];
foreach ($rows as $row) {
$sectionKoeln['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionKoeln, null, $sectionKoeln);
break;
case 'updateDus':
$sectionDus['content'] = [];
foreach ($rows as $row) {
$sectionDus['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionDus, null, $sectionDus);
break;
case 'updateAlumni':
$sectionAlumni['content'] = [];
foreach ($rows as $row) {
$sectionAlumni['content'][] = str_getcsv($row, "\t");
}
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaNameSectionAlumni, null, $sectionAlumni);
break;
}
$this->session->getFlashBag()->add('notice', 'SUCCESS data saved');
}
$sectionBatch21 = $this->getSection($metaNameSectionBatch21);
$sectionBatch20 = $this->getSection($metaNameSectionBatch20);
$sectionBatch19 = $this->getSection($metaNameSectionBatch19);
$sectionBatch18 = $this->getSection($metaNameSectionBatch18);
$sectionBatch17 = $this->getSection($metaNameSectionBatch17);
$sectionKoeln = $this->getSection($metaNameSectionKoeln);
$sectionDus = $this->getSection($metaNameSectionDus);
$sectionAlumni = $this->getSection($metaNameSectionAlumni);
return $this->render('@StartPlatzAlphaBundle/Startup/index.legacy.html.twig', [
'templateVars' => [],
'form' => $form->createView(),
'sectionBatch21' => $sectionBatch21,
'sectionBatch20' => $sectionBatch20,
'sectionBatch19' => $sectionBatch19,
'sectionBatch18' => $sectionBatch18,
'sectionBatch17' => $sectionBatch17,
'sectionKoeln' => $sectionKoeln,
'sectionDus' => $sectionDus,
'sectionAlumni' => $sectionAlumni,
'edit' => $edit,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'extern_startups_home', 'parameters' => []])),
]);
}
#[Route('/startup/{slug}', name: 'homepage_startup_single')]
#[Route('/en/startup/{slug}', name: 'homepage_startup_single_english')]
public function singleAction(Request $request, $slug)
{
$templateVars = $this->entityManager->getRepository(Team::class)->getTemplateVars($request);
/** @var User $user */
if ($user = $this->getUser()) {
$this->entityManager->getRepository(User::class)->writeActivity($user);
}
$id = explode('-', (string) $slug)[0];
$slug = explode('-', (string) $slug)[1];
/** @var Startup $startup */
if (!$startup = $this->entityManager->getRepository(Startup::class)->findOneBy(['id' => $id])) {
$this->session->getFlashBag()->add('notice', 'ERROR slug not found');
return $this->redirect($this->generateUrl('homepage_startups_home'));
}
if (!$team = $this->entityManager->getRepository(Team::class)->findOneBy(['id' => $startup->getTeamId()])) {
$this->session->getFlashBag()->add('notice', 'ERROR insufficient data');
return $this->redirect($this->generateUrl('homepage_startups_home'));
}
$feedItems = [];
$entities = [];
if ($startup->getSlug()) {
// feedTags are expected to be a jsonArray
$feedTags = json_encode([$startup->getSlug()]);
$feedItems = $this->entityManager->getRepository(Feed::class)->findByFeedTag($feedTags);
$entities = $this->entityManager->getRepository(Feed::class)->getEntitiesByFeedItems($feedItems);
}
// rheinlandPitch has programId == 1
$rheinlandPitches = $this->entityManager->getRepository(Application::class)->findApplicationsAndBatchesByStartupIdAndProgramId($id, 1);
$memberTypes = [];
$teamIndustries = [];
$teamIndustryList = "";
$applications = [];
if ($team) {
if ($team->getType() == 'Partner') {
$memberTypes = ['GF', 'AP'];
}
$teamIndustries = $team->getIndustries();
$teamIndustryList = explode("#", (string) $teamIndustries);
// plausibility checks for members of that team
$this->entityManager->getRepository(Member::class)->checkIfDescriptionIsEmptyButMentorProfileIsFilled($team);
$relevantProgramIds = ['1','2','3'];
$applications = $this->entityManager->getRepository(Application::class)->findBy(['teamId'=>$team->getId(),'programId'=>$relevantProgramIds]);
}
$members = $this->entityManager->getRepository(MemberTeam::class)->getTeamMembers($id, $memberTypes);
$allowEdit = false;
$teamMember = false;
if($user) {
$userEmail = $this->getUser()->getEmail();
foreach ($members as $member) {
if ($member['email'] == $userEmail) {
$teamMember = true;
if ($member['type'] == 'AP' || $member['type'] == 'GF') {
$allowEdit = true;
}
}
}
}
// create slugs from team on the fly and from startup, what is stored there
if ($team) {
$slugs[] = Utility::generateSlug($team->getShortName());
}
if ($startup->getSlug()) {
$slugs[] = $startup->getSlug();
}
$feedTags = json_encode(array_values(array_unique($slugs)));
if ($feedTags) {
$feedItems = $this->entityManager->getRepository(Feed::class)->findByFeedTag($feedTags);
$entities = $this->entityManager->getRepository(Feed::class)->getEntitiesByFeedItems($feedItems);
}
$hasVisibleApplication = false;
foreach ($applications as $application) {
if($application->getVisibility() == 'sp-connect') {
$hasVisibleApplication = true;
break;
}
}
$lang = Utility::getLangByPathInfo($request->getPathInfo());
if ($startup->getVisibility() == 'public') {
return $this->render('@StartPlatzAlphaBundle/Startup/single.homepage.html.twig', [
'id' => $id,
'startup' => $startup,
'team' => $team,
'feedItems' => $feedItems,
'entities' => $entities,
'lang' => $lang,
'rheinlandPitches' => $rheinlandPitches,
'redirectUrl' => base64_encode(json_encode(['path' => 'homepage_startup_single', 'parameters' => ['slug' => $id . '-' . $slug]])),
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'applications' => $applications,
'hasVisibleApplication' => $hasVisibleApplication,
'methodsTeam' => $team ? $this->feedbackService->getEntityMethodsArray($team, ['services', 'members']) : [],
'methodsStartup' => $startup ? $this->feedbackService->getEntityMethodsArray($startup, []) : [],
'feedTags' => $feedTags,
'templateVars' => $templateVars,
'queryString' => '',
// 'members' => $members,
'memberTypes' => $memberTypes,
'teamIndustryList' => $teamIndustryList,
'allowEdit' => $allowEdit,
'teamMember' => $teamMember,
'memberTypeLabels' => $this->entityManager->getRepository(MemberTeam::class)->getMemberTypeLabels(),
'currentPath' => '/x/connect/team/{id}',
'backUrl' => $request->get('redirect') ?: base64_encode(json_encode(['path' => 'connect_startup_index', 'parameters' => $templateVars])),
]);
} else {
return $this->render('@StartPlatzAlphaBundle/Startup/single.homepage.sorry.html.twig', [
'lang' => $lang,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'homepage_startup_single', 'parameters' => ['slug' => $id . '-' . $slug]])),
]);
}
}
#[Route('/x/community/startups/home/', name: 'x_startups_home')]
/**
* @IsGranted("ROLE_USER")
*/
public function indexStartupsAction(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$redirectUrl = $request->get('redirect');
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
$orderBy = $templateVars['dimensions'] ?: [];
$visibility = 'sp-connect';
$criteria = ['visibility' => $visibility] + $templateVars['criteria'];
$teamId = 0;
if ($user = $this->getUser()) {
$teamId = $user->getMemberId();
$this->entityManager->getRepository(User::class)->writeActivity($user);
$member = $this->entityManager->getRepository(Member::class)->find($user->getMemberId());
}
$total = $this->entityManager->getRepository(Startup::class)->countByCriteria($criteria, $teamId);
if ($total > 12) {
$limit = 12;
} else {
$limit = $total ?: 1;
}
if (!$page = $request->get('page')) {
$page = 1;
}
$startups = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria, $teamId, $orderBy, $page, $limit);
$lang = $request->get('lang');
if (str_contains((string) $member->getTags(), 'beta')) {
$view = '@StartPlatzAlphaBundle/Startup/Startups__index.twig';
} else {
$view = '@StartPlatzAlphaBundle/Startup/Startups__index_old.twig';
}
return $this->render($view, [
'maxPages' => ceil($total / $limit),
'thisPage' => $page,
'total' => $total,
'criteria' => $criteria,
'visibility' => $visibility,
'templateVars' => $templateVars,
'startups' => $startups,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'website_startups_list', 'parameters' => $templateVars])),
]);
}
#[Route('/startup-database/list/', name: 'website_startups_list')]
#[Route('/startup-database/list/', name: 'extern_startups_list')]
/**
* @IsGranted("ROLE_USER")
*/
public function listAction(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$redirectUrl = $request->get('redirect');
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
$orderBy = $templateVars['dimensions'] ?: [];
$visibility = 'public';
$criteria = ['visibility' => $visibility] + $templateVars['criteria'];
$teamId = 0;
if ($user = $this->getUser()) {
$teamId = $user->getMemberId();
$this->entityManager->getRepository(User::class)->writeActivity($user);
}
$total = $this->entityManager->getRepository(Startup::class)->countByCriteria($criteria, $teamId);
if ($total > 12) {
$limit = 12;
} else {
$limit = $total ?: 1;
}
if (!$page = $request->get('page')) {
$page = 1;
}
$startups = $this->entityManager->getRepository(Startup::class)->findPaginated($criteria, $teamId, $orderBy, $page, $limit);
$lang = $request->get('lang');
$targetPath = $request->server->get('REQUEST_URI');
return $this->render('@StartPlatzAlphaBundle/Startup/list.html.twig', [
'targetPath' => $targetPath,
'lang' => $lang,
'maxPages' => ceil($total / $limit),
'thisPage' => $page,
'total' => $total,
'criteria' => $criteria,
'visibility' => $visibility,
'templateVars' => $templateVars,
'startups' => $startups,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'website_startups_list', 'parameters' => $templateVars])),
]);
}
#[Route('/startup-database/show/{id}/{slug}', name: 'extern_startups_single')]
public function singleExternAction(Request $request, $id, $slug)
{
if ($user = $this->getUser()) {
$this->entityManager->getRepository(User::class)->writeActivity($user);
}
if (!$redirect = json_decode(base64_decode((string) $request->get('redirect')))) {
$redirect = new stdClass();
$redirect->path = 'website_startups_list';
$redirect->parameters = [];
}
$redirectUrl = $request->get('redirect');
if (!$startup = $this->entityManager->getRepository(Startup::class)->findOneBy(['id' => $id, 'visibility' => 'public'])) {
$this->session->getFlashBag()->add('notice', 'ERROR 10 entity not found');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
if ($slug != $startup->getSlug()) {
return $this->redirect($this->generateUrl('extern_startups_single', ['id' => $id, 'slug' => $startup->getSlug(), 'redirect' => $redirectUrl]));
}
$rightToAccessTeam = false;
$team = false;
$memberId = 0;
$teamId = $startup->getTeamId();
if ($user = $this->getUser()) {
$memberId = $user->getMemberId();
if (!$member = $this->entityManager->getRepository(Member::class)->findOneBy(['id' => $memberId])) {
$this->session->getFlashBag()->add('notice', 'ERROR There is a problem with your account please contact support@startplatz.de');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
if ($team = $this->entityManager->getRepository(Team::class)->findOneBy(['id' => $teamId])) {
$rightToAccessTeam = $this->entityManager->getRepository(MemberTeam::class)->checkAccessRight($member, $team);
$team = $this->entityManager->getRepository(Team::class)->checkConsistencyWithStartup($team, $startup);
}
}
// the use of memberId is on purpose
$startupAttributes = $this->entityManager->getRepository(StartupAttribute::class)->findOneBy(['startupId' => $startup->getId(), 'teamId' => $memberId]);
$startupLivecycleEvents = $this->entityManager->getRepository(StartupLifecycleEvent::class)->findBy(['startupId' => $startup->getId()], ['eventDate' => 'ASC']);
$this->entityManager->getRepository(StartupRelevance::class)->updateByUserAction($id, 'click');
$rheinlandPitches = $this->entityManager->getRepository(Application::class)->findBy(['startupId' => $id], ['batchId' => 'DESC']);
return $this->render('@StartPlatzAlphaBundle/Startup/single.extern.twig', [
'templateVars' => [],
'startup' => $startup,
'rightToAccessTeam' => $rightToAccessTeam,
'startupAttributes' => $startupAttributes,
'rheinlandPitches' => $rheinlandPitches,
'startupLivecycleEvents' => $startupLivecycleEvents,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'extern_startups_single', 'parameters' => ['id' => $id, 'slug' => $startup->getSlug()]])),
]);
}
#[Route('/x/community/startup/single/{id}', name: 'x_community_startup_single')]
/**
* @IsGranted("ROLE_USER")
*/
public function singleCommunityAction(Request $request, $id)
{
if ($user = $this->getUser()) {
$this->entityManager->getRepository(User::class)->writeActivity($user);
}
if (!$redirect = json_decode(base64_decode((string) $request->get('redirect')))) {
$redirect = new stdClass();
$redirect->path = 'x_home';
$redirect->parameters = [];
}
$redirectUrl = $request->get('redirect');
if (!$startup = $this->entityManager->getRepository(Startup::class)->findSingleStartupByVisibility($id, 'sp-connect')) {
$this->session->getFlashBag()->add('notice', 'ERROR 20 entity not found');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
$rightToAccessTeam = false;
$team = false;
$memberId = 0;
$teamId = $startup->getTeamId();
if ($user = $this->getUser()) {
$memberId = $user->getMemberId();
if (!$member = $this->entityManager->getRepository(Member::class)->findOneBy(['id' => $memberId])) {
$this->session->getFlashBag()->add('notice', 'ERROR There is a problem with your account please contact support@startplatz.de');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
if ($team = $this->entityManager->getRepository(Team::class)->findOneBy(['id' => $teamId])) {
$rightToAccessTeam = $this->entityManager->getRepository(MemberTeam::class)->checkAccessRight($member, $team);
$team = $this->entityManager->getRepository(Team::class)->checkConsistencyWithStartup($team, $startup);
}
}
// the use of memberId is on purpose
$startupAttributes = $this->entityManager->getRepository(StartupAttribute::class)->findOneBy(['startupId' => $startup->getId(), 'teamId' => $memberId]);
$startupLivecycleEvents = $this->entityManager->getRepository(StartupLifecycleEvent::class)->findBy(['startupId' => $startup->getId()], ['eventDate' => 'ASC']);
$this->entityManager->getRepository(StartupRelevance::class)->updateByUserAction($id, 'click');
$rheinlandPitches = $this->entityManager->getRepository(Application::class)->findBy(['startupId' => $id], ['batchId' => 'DESC']);
$lang = $request->get('lang');
$targetPath = $request->server->get('REQUEST_URI');
return $this->render('@StartPlatzAlphaBundle/Startup/single.sp-connect.html.twig', [
'targetPath' => $targetPath,
'lang' => $lang,
'templateVars' => [],
'startup' => $startup,
'rightToAccessTeam' => $rightToAccessTeam,
'startupAttributes' => $startupAttributes,
'rheinlandPitches' => $rheinlandPitches,
'startupLivecycleEvents' => $startupLivecycleEvents,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'extern_startups_single', 'parameters' => ['id' => $id, 'slug' => $startup->getSlug()]])),
]);
}
#[Route('/allmeda/startups/toggle-ajax/{id}/{field}/{action}', name: 'startup_edit_field_ajax')]
/**
* @IsGranted("ROLE_ADMIN")
*/
public function setToggleAjaxAction($id, $field, $action)
{
$response = $this->entityManager->getRepository(Startup::class)->setField($field, $action, $id);
if (str_starts_with((string) $response, 'field ')) {
$response = "SUCCESS $response";
}
return new Response($response);
}
#[Route('/x/connect/startup/edit/{id}/set-with-data', name: 'x_connect_startup_set_field_ajax_with_data')]
#[Route('/x/connect/startup/edit/{id}/set/{field}/{action}', name: 'x_connect_startup_set_field_ajax')]
/**
* @IsGranted("ROLE_USER")
*/
public function setAjaxAction(Request $request, $id = null, $field = null, $action = null): Response
{
$params = ['id' => $id];
if ($field && $action) {
$params['field'] = $field;
$params['action'] = $action;
return $this->redirectToRoute('connect_startup_set_field_ajax', $params, 301);
}
return $this->redirectToRoute('connect_startup_set_field_data_ajax', $params, 301);
}
#[Route('/x/connect/startup/edit/{id}/{slug}', name: 'x_startup_edit')]
/**
* @IsGranted("ROLE_USER")
*/
public function editStartupAction(Request $request, $id, $slug): Response
{
return $this->redirectToRoute('connect_startup_show', ['id' => $id, 'slug' => $slug, 'redirect' => $request->get('redirect')], 301);
}
private function removeOldResourcesFromCloudinary($uploadTag, $link): void
{
$result = $this->cloudinary->resources_by_tag($uploadTag);
$filter = fn ($res) => $res['secure_url'] != $link;
$oldRefs = array_filter($result['resources'], $filter);
$oldIds = array_map(fn ($res) => $res['public_id'], $oldRefs);
if (!empty($oldIds)) {
$result = $this->cloudinary->delete_resources($oldIds);
}
}
#[Route('/startup-database/edit/{id}/{slug}', name: 'extern_startups_edit')]
/**
* @IsGranted("ROLE_USER")
*/
public function editAction(Request $request, $id, $slug)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$redirectUrl = $request->get('redirect');
/** @var Startup $startup */
if (!$startup = $this->entityManager->getRepository(Startup::class)->findOneBy(['id' => $id])) {
$this->session->getFlashBag()->add('notice', 'ERROR 40 entity not found');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
if ($slug != $startup->getSlug()) {
return $this->redirect($this->generateUrl('extern_startups_single', ['id' => $id, 'slug' => $startup->getSlug(), 'redirect' => $redirectUrl]));
}
$rightToAccessTeam = false;
$team = false;
$memberId = 0;
$teamId = $startup->getTeamId();
/** @var User $user */
if ($user = $this->getUser()) {
$this->entityManager->getRepository(User::class)->writeActivity($user);
$memberId = $user->getMemberId();
if (!$member = $this->entityManager->getRepository(Member::class)->findOneBy(['id' => $memberId])) {
$this->session->getFlashBag()->add('notice', 'ERROR There is a problem with your account please contact support@startplatz.de');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
/** @var Team $team */
if ($team = $this->entityManager->getRepository(Team::class)->findOneBy(['id' => $teamId])) {
$rightToAccessTeam = $this->entityManager->getRepository(MemberTeam::class)->checkAccessRight($member, $team);
}
}
$admin = $user->getIsAdmin();
if (!$rightToAccessTeam and !$admin) {
$this->session->getFlashBag()->add('notice', 'ERROR There is a problem with your account-3 please contact support@startplatz.de');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
// the use of memberId is on purpose
$startupAttributes = $this->entityManager->getRepository(StartupAttribute::class)->findOneBy(['startupId' => $startup->getId(), 'teamId' => $memberId]);
$this->entityManager->getRepository(StartupRelevance::class)->updateByUserAction($id, 'edit');
$rheinlandPitches = $this->entityManager->getRepository(Application::class)->findBy(['startupId' => $id], ['batchId' => 'DESC']);
$fields = Utility::getEntityFieldsArray($startup);
$storedData = Utility::fillDataByObject($startup, $fields);
$industries = $this->entityManager->getRepository(Startup::class)->getListOfIndustries();
$form = $this->createForm(StartupType::class, $startup, ['industries' => $industries, 'editForm' => 'extern']);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$updatedData = Utility::fillDataByObject($startup, $fields);
$differences = array_diff_assoc($updatedData, $storedData);
if ($differences) {
$startup = $this->entityManager->getRepository(Startup::class)->updateByEdit($startup, $differences, $user->getEmail());
if ($team) {
$team = $this->entityManager->getRepository(Team::class)->syncDataWithStartup($team, $startup);
}
}
}
return $this->render('@StartPlatzAlphaBundle/Startup/edit.html.twig', [
'templateVars' => [],
'form' => $form->createView(),
'startup' => $startup,
'rightToAccessTeam' => $rightToAccessTeam,
'startupAttributes' => $startupAttributes,
'rheinlandPitches' => $rheinlandPitches,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'extern_startups_single', 'parameters' => ['id' => $id, 'slug' => $startup->getSlug()]])),
]);
}
#[Route('/startup-database/event/{id}/{slug}/{eventId}', name: 'extern_startups_event')]
/**
* @IsGranted("ROLE_USER")
*/
public function startupLivecycleEventAction(Request $request, $id, $slug, $eventId)
{
$now = new DateTime();
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$redirectUrl = $request->get('redirect');
if (!$startup = $this->entityManager->getRepository(Startup::class)->findOneBy(['id' => $id])) {
$this->session->getFlashBag()->add('notice', 'ERROR 50 entity not found');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
if ($slug != $startup->getSlug()) {
return $this->redirect($this->generateUrl('extern_startups_single', ['id' => $id, 'slug' => $startup->getSlug(), 'redirect' => $redirectUrl]));
}
$rightToAccessTeam = false;
$team = false;
$memberId = 0;
$teamId = $startup->getTeamId();
/** @var User $user */
if ($user = $this->getUser()) {
$this->entityManager->getRepository(User::class)->writeActivity($user);
$memberId = $user->getMemberId();
if (!$member = $this->entityManager->getRepository(Member::class)->findOneBy(['id' => $memberId])) {
$this->session->getFlashBag()->add('notice', 'ERRORThere is a problem with your account please contact support@startplatz.de');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
if ($team = $this->entityManager->getRepository(Team::class)->findOneBy(['id' => $teamId])) {
$rightToAccessTeam = $this->entityManager->getRepository(MemberTeam::class)->checkAccessRight($member, $team);
}
}
$admin = $user->getIsAdmin();
if (!$rightToAccessTeam and !$admin) {
$this->session->getFlashBag()->add('notice', 'ERROR There is a problem with your account-4 please contact support@startplatz.de');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
// the use of memberId is on purpose
$startupAttributes = $this->entityManager->getRepository(StartupAttribute::class)->findOneBy(['startupId' => $startup->getId(), 'teamId' => $memberId]);
$this->entityManager->getRepository(StartupRelevance::class)->updateByUserAction($id, 'edit');
$rheinlandPitches = $this->entityManager->getRepository(Application::class)->findBy(['startupId' => $id], ['batchId' => 'DESC']);
$startupLivecycleEvents = $this->entityManager->getRepository(StartupLifecycleEvent::class)->findBy(['startupId' => $startup->getId()], ['eventDate' => 'ASC']);
if (!$livecycleEvent = $this->entityManager->getRepository(StartupLifecycleEvent::class)->findOneBy(['id' => $eventId])) {
$livecycleEvent = new StartupLifecycleEvent();
$livecycleEvent->setEventDate($now);
$livecycleEvent->setStartupId($id);
}
// set array oldData value, nr, text
$fields = ['eventWhat', 'eventDate', 'linkText', 'link'];
$oldData = $this->getDataAsArray($fields, $livecycleEvent);
$form = $this->createForm(LivecycleEventType::class, $livecycleEvent);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$newData = $this->getDataAsArray($fields, $livecycleEvent);
$differences = array_diff_assoc($newData, $oldData);
if ($differences) {
$livecycleEvent = $this->entityManager->getRepository(StartupLifecycleEvent::class)->updateByEdit($livecycleEvent, $differences, $user->getEmail());
$this->session->getFlashBag()->add('notice', 'SUCCESSData has been saved');
}
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
return $this->render('@StartPlatzAlphaBundle/Startup/editLivecycleEvent.html.twig', [
'templateVars' => [],
'form' => $form->createView(),
'startup' => $startup,
'rightToAccessTeam' => $rightToAccessTeam,
'startupAttributes' => $startupAttributes,
'rheinlandPitches' => $rheinlandPitches,
'livecycleEvent' => $livecycleEvent,
'startupLivecycleEvents' => $startupLivecycleEvents,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'extern_startups_single', 'parameters' => ['id' => $id, 'slug' => $startup->getSlug()]])),
]);
}
#[Route('/startup-database/show-event/{id}/{slug}/{eventId}', name: 'extern_startups_show-event')]
/**
* @IsGranted("ROLE_USER")
*/
public function showStartupLivecycleEventAction(Request $request, $id, $slug, $eventId)
{
$now = new DateTime();
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$redirectUrl = $request->get('redirect');
if (!$startup = $this->entityManager->getRepository(Startup::class)->findOneBy(['id' => $id])) {
$this->session->getFlashBag()->add('notice', 'ERROR 60 entity not found');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
if ($slug != $startup->getSlug()) {
return $this->redirect($this->generateUrl('extern_startups_single', ['id' => $id, 'slug' => $startup->getSlug(), 'redirect' => $redirectUrl]));
}
/** @var User $user */
if (!$user = $this->getUser()) {
$this->session->getFlashBag()->add('notice', 'SUCCESSplease register or login');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
$this->entityManager->getRepository(User::class)->writeActivity($user);
$this->entityManager->getRepository(StartupRelevance::class)->updateByUserAction($id, 'edit');
if (!$startupLivecycleEvent = $this->entityManager->getRepository(StartupLifecycleEvent::class)->findOneBy(['id' => $eventId])) {
$this->session->getFlashBag()->add('notice', 'ERRORError - no event found');
return $this->redirect($this->generateUrl($redirect->path, (array)$redirect->parameters));
}
return $this->render('@StartPlatzAlphaBundle/Startup/showLivecycleEvent.html.twig', [
'templateVars' => [],
'startup' => $startup,
'startupLivecycleEvent' => $startupLivecycleEvent,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'extern_startups_single', 'parameters' => ['id' => $id, 'slug' => $startup->getSlug()]])),
]);
}
private function getDataAsArray($fields, $entity)
{
foreach ($fields as $field) {
$method = 'get' . ucfirst((string) $field);
if (method_exists($entity, $method)) {
if ($entity->$method() instanceof DateTime) {
$data[$field] = $entity->$method()->format('Y-m-d');
} else {
$data[$field] = $entity->$method();
}
} else {
$data[$field] = "";
}
}
return $data;
}
#[Route('/startup-database/get-in-contact/{id}', name: 'extern_startups_get-in-contact')]
public function getInContactAjaxAction(Request $request, $id)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
return $this->render('@StartPlatzAlphaBundle/Startup/modal.register.html.twig', [
'title' => "Get in contact",
'btnClass' => "btn-outline-info",
'id' => $id,
'redirect' => $redirect,
'redirectUrl' => $request->get('redirect'),
]);
}
#[Route('/startup-database/register/{id}', name: 'extern_startups_register')]
public function registerAjaxAction(Request $request, $id)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
return $this->render('@StartPlatzAlphaBundle/Startup/modal.register.html.twig', [
'title' => "Please register",
'btnClass' => "btn-outline-info",
'id' => $id,
'redirect' => $redirect,
'redirectUrl' => $request->get('redirect'),
]);
}
#[Route('/x/community/startups/missions/', name: 'x_startups_missions')]
/**
* @IsGranted("ROLE_USER")
*/
public function indexMissionsForBadge(Request $request)
{
$redirect = json_decode(base64_decode((string) $request->get('redirect')));
$redirectUrl = $request->get('redirect');
$templateVars = $this->entityManager->getRepository(Startup::class)->getTemplateVars($request);
/** @var User $user */
$user = $this->getUser();
$this->entityManager->getRepository(User::class)->writeActivity($user, '/x/community/startups/');
$id = $user->getTeamId();
/** @var Team $team */
$team = $this->entityManager->getRepository(Team::class)->find($id);
if (!$startup = $this->entityManager->getRepository(Startup::class)->findOneBy(['id' => $team->getStartupId()])) {
$startup = new Startup();
} else {
// increase relevance score every time a startup team is shown
$this->entityManager->getRepository(StartupRelevance::class)->updateByUserAction($startup->getId(), 'click');
}
$lang = $request->get('lang');
$view = '@StartPlatzAlphaBundle/Startup/index.missionsForBadge.html.twig';
return $this->render($view, [
'team' => $team,
'startup' => $startup,
'templateVars' => $templateVars,
'backUrl' => $redirectUrl,
'menuLinksAndPhrases' => $this->menuTranslationService->getMenuLinksAndPhrases($request->server->get('REQUEST_URI')),
'redirectUrl' => base64_encode(json_encode(['path' => 'website_startups_list', 'parameters' => $templateVars])),
]);
}
private function setEditorForm($content)
{
return $this->formFactory->createNamedBuilder('editor')
->add(
'content',
TinymceType::class,
[
'label' => 'Content',
'data' => $content,
'required' => false,
]
)
->add('save', SubmitType::class, ['label' => 'Save'])
->getForm();
}
private function setPlainEditorForm($content)
{
return $this->formFactory->createNamedBuilder('editor')
->add(
'content',
TextareaType::class,
[
'label' => 'Content',
'data' => $content,
'attr' => ['rows' => '17', 'cols' => '180'],
'required' => false,
]
)
->add('save', SubmitType::class, ['label' => 'Save'])
->getForm();
}
private function getSection($metaName)
{
if (!$section = $this->entityManager->getRepository(Option::class)->getOptionMetaValue($metaName)) {
$section['fields'] = $this->setSectionFields();
$section['content'][] = [
"https://www.startplatz.de/wp-content/uploads/2012/11/golfpost_225x225.jpg",
"http://www.golfpost.de",
"Golf Post",
"Das Online-Magazin Golf Post ist Vorreiter und inzwischen zur größten unabhängigen Golf-Plattform im deutschsprachigen Raum gereift. Ziel ist es, das elitäre Image des Golfsports zu entstauben.",
"#golfistbesseralsdudenkst #wirsindanders #unsereweltistgrün",
"99999",
];
$this->entityManager->getRepository(Option::class)->setOptionMetaValueJsonEncoded($metaName, null, $section);
}
$section['entities'] = $this->setSectionEntities($section);
return $section;
}
private function setSectionEntities($section)
{
$entities = [];
foreach ($section['content'] as $row) {
if ((is_countable($section['fields']) ? count($section['fields']) : 0) != (is_countable($row) ? count($row) : 0)) {
$i = 0;
foreach ($section['fields'] as $field) {
$entity[$field] = $row[$i] ?? $field;
$i++;
}
$entities[] = $entity;
} else {
$entities[] = array_combine($section['fields'], $row);
}
}
return $entities;
}
private function transformArrayIntoCsvString($rows)
{
$content = '';
foreach ($rows as $row) {
$content .= implode("\t", $row) . PHP_EOL;
}
return $content;
}
private function setSectionFields()
{
$fields = ['logo', 'url', 'name', 'desc', 'tags', 'teamId'];
return $fields;
}
}