resume/src/Sikofitt/Controller/ResumeControllerProvider.php

146 lines
3.6 KiB
PHP

<?php
/*
* This file is part of Resume.PHP.
*
* (copyleft) R. Eric Wheeler <sikofitt@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sikofitt\Controller;
use ReCaptcha\ReCaptcha;
use Silex\Api\ControllerProviderInterface;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
/**
* Class ResumeControllerProvider
* @package Sikofitt\Controller
*/
class ResumeControllerProvider implements ControllerProviderInterface
{
/**
* @var object
*/
private $resumeData;
/**
* @param Application $app
* @return mixed
*/
public function connect(Application $app)
{
$this->resumeData = $app->decodeFile(
$app->getDataDirectory() . '/resume.json',
$app->getDataDirectory() . '/schema/schema.v1.json'
);
$controllers = $app['controllers_factory'];
$controllers->get('/', function (Request $request) use ($app) {
return $app['twig']->render('resume.html.twig', [
'fullData' => $this->resumeData,
'basics' => $this->getResumeBasics(),
'work' => $this->getResumeWork(),
'volunteer' => $this->getResumeVolunteer(),
'education' => $this->getResumeEducation(),
'awards' => $this->getResumeAwards(),
'publications' => $this->getResumePublications(),
'skills' => $this->getResumeSkills(),
'languages' => $this->getResumeLanguages(),
'interests' => $this->getResumeInterests(),
'references' => $this->getResumeReferences(),
]);
});
return $controllers;
}
/**
* @return null
*/
public function getResumeBasics()
{
return (isset($this->resumeData->basics) && count($this->resumeData->basics) > 0) ? $this->resumeData->basics : null;
}
/**
* @return null
*/
public function getResumeWork()
{
return (isset($this->resumeData->work) && count($this->resumeData->work) > 0) ? $this->resumeData->work : null;
}
/**
* @return null
*/
public function getResumeVolunteer()
{
return (isset($this->resumeData->volunteer) && count($this->resumeData->volunteer) > 0) ? $this->resumeData->volunteer : null;
}
/**
* @return null
*/
public function getResumeEducation()
{
return (isset($this->resumeData->education) && count($this->resumeData->education) > 0) ? $this->resumeData->education : null;
}
/**
* @return null
*/
public function getResumeAwards()
{
return (isset($this->resumeData->awards) && count($this->resumeData->awards) > 0) ? $this->resumeData->awards : null;
}
/**
* @return null
*/
public function getResumePublications()
{
return (isset($this->resumeData->publications) && count($this->resumeData->publications) > 0) ? $this->resumeData->publications : null;
}
/**
* @return null
*/
public function getResumeSkills()
{
return (isset($this->resumeData->skills) && count($this->resumeData->skills) > 0) ? $this->resumeData->skills : null;
}
/**
* @return null
*/
public function getResumeLanguages()
{
return (isset($this->resumeData->languages) && count($this->resumeData->languages) > 0) ? $this->resumeData->languages : null;
}
/**
* @return null
*/
public function getResumeInterests()
{
return (isset($this->resumeData->interests) && count($this->resumeData->interests) > 0) ? $this->resumeData->interests : null;
}
/**
* @return null
*/
public function getResumeReferences()
{
return (isset($this->resumeData->references) && count($this->resumeData->references) > 0) ? $this->resumeData->references : null;
}
}