Upgraded to Symfony 2.1-beta2
This commit is contained in:
parent
c1232c9792
commit
bb7aee6fee
10
README.md
10
README.md
@ -26,7 +26,7 @@ http://getcomposer.org/ or just run the following command:
|
||||
|
||||
Then, use the `create-project` command to generate a new Symfony application:
|
||||
|
||||
composer.phar create-project symfony/framework-standard-edition path/to/install
|
||||
php composer.phar create-project symfony/framework-standard-edition path/to/install
|
||||
|
||||
Composer will install Symfony and all its dependencies under the
|
||||
`path/to/install` directory.
|
||||
@ -73,7 +73,7 @@ To see a real-live Symfony page in action, access the following page:
|
||||
|
||||
web/app_dev.php/demo/hello/Fabien
|
||||
|
||||
3) Getting started with Symfony
|
||||
4) Getting started with Symfony
|
||||
-------------------------------
|
||||
|
||||
This distribution is meant to be the starting point for your Symfony
|
||||
@ -98,9 +98,9 @@ playing with it, you can remove it by following these steps:
|
||||
|
||||
* remove the `web/bundles/acmedemo` directory;
|
||||
|
||||
* remove the inclusion of the security configuration in
|
||||
`app/config/config.yml` (remove the `- { resource: security.yml }` line)
|
||||
or tweak the security configuration to fit your needs.
|
||||
* remove the `security.providers`, `security.firewall.login` and
|
||||
`security.firewall.secured_area` entries in the `security.yml` file or
|
||||
tweak the security configuration to fit your needs.
|
||||
|
||||
What's inside?
|
||||
---------------
|
||||
|
@ -14,6 +14,17 @@
|
||||
* It can be a mandatory requirement or an optional recommendation.
|
||||
* There is a special subclass, named PhpIniRequirement, to check a php.ini configuration.
|
||||
*
|
||||
* This file must be compatible with PHP 5.2+.
|
||||
*
|
||||
* ************** CAUTION **************
|
||||
*
|
||||
* DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN BY COMPOSER
|
||||
*
|
||||
* If you want to change this file, edit the one in the
|
||||
* SensioDistributionBundle instead.
|
||||
*
|
||||
* ************** CAUTION **************
|
||||
*
|
||||
* @author Tobias Schultze <http://tobion.de>
|
||||
*/
|
||||
class Requirement
|
||||
@ -386,12 +397,18 @@ class SymfonyRequirements extends RequirementCollection
|
||||
);
|
||||
|
||||
$this->addRequirement(
|
||||
is_dir(__DIR__.'/../vendor/symfony'),
|
||||
is_dir(__DIR__.'/../vendor/composer'),
|
||||
'Vendor libraries must be installed',
|
||||
'Vendor libraries are missing. Install composer following instructions from <a href="http://getcomposer.org/">http://getcomposer.org/</a>. ' .
|
||||
'Then run "<strong>php composer.phar install</strong>" to install them.'
|
||||
);
|
||||
|
||||
$this->addRequirement(
|
||||
file_get_contents(__FILE__) == file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'),
|
||||
'Outdated requirements file',
|
||||
'Your requirements file is outdated. Run composer install and re-check your configuration.'
|
||||
);
|
||||
|
||||
$baseDir = basename(__DIR__);
|
||||
$this->addRequirement(
|
||||
is_writable(__DIR__.'/cache'),
|
||||
@ -413,7 +430,7 @@ class SymfonyRequirements extends RequirementCollection
|
||||
|
||||
if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) {
|
||||
$this->addRequirement(
|
||||
(in_array(date_default_timezone_get(), \DateTimeZone::listIdentifiers())),
|
||||
(in_array(date_default_timezone_get(), DateTimeZone::listIdentifiers())),
|
||||
sprintf('Default timezone is deprecated (%s)', date_default_timezone_get()),
|
||||
'Fix your <strong>php.ini</strong> file (list of deprecated timezones http://us.php.net/manual/en/timezones.others.php).'
|
||||
);
|
||||
|
@ -2,23 +2,7 @@
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
|
||||
if (!$loader = @include __DIR__.'/../vendor/autoload.php') {
|
||||
|
||||
$message = <<< EOF
|
||||
<p>You must set up the project dependencies by running the following commands:</p>
|
||||
<pre>
|
||||
curl -s http://getcomposer.org/installer | php
|
||||
php composer.phar install
|
||||
</pre>
|
||||
|
||||
EOF;
|
||||
|
||||
if (PHP_SAPI === 'cli') {
|
||||
$message = strip_tags($message);
|
||||
}
|
||||
|
||||
die($message);
|
||||
}
|
||||
$loader = require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
// intl
|
||||
if (!function_exists('intl_get_error_code')) {
|
||||
|
@ -72,6 +72,21 @@ interface ContainerInterface
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\DependencyInjection
|
||||
{
|
||||
|
||||
|
||||
interface IntrospectableContainerInterface extends ContainerInterface
|
||||
{
|
||||
|
||||
function initialized($id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\DependencyInjection
|
||||
{
|
||||
|
||||
@ -341,6 +356,23 @@ class Container implements IntrospectableContainerInterface
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\HttpKernel
|
||||
{
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
||||
interface TerminableInterface
|
||||
{
|
||||
|
||||
function terminate(Request $request, Response $response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\HttpKernel
|
||||
{
|
||||
|
||||
@ -419,6 +451,9 @@ interface KernelInterface extends HttpKernelInterface, \Serializable
|
||||
|
||||
|
||||
function getLogDir();
|
||||
|
||||
|
||||
function getCharset();
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,7 +502,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
protected $classes;
|
||||
protected $errorReportingLevel;
|
||||
|
||||
const VERSION = '2.1.0-BETA1';
|
||||
const VERSION = '2.1.0-BETA2';
|
||||
const VERSION_ID = '20100';
|
||||
const MAJOR_VERSION = '2';
|
||||
const MINOR_VERSION = '1';
|
||||
@ -736,6 +771,12 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
}
|
||||
|
||||
|
||||
public function getCharset()
|
||||
{
|
||||
return 'UTF-8';
|
||||
}
|
||||
|
||||
|
||||
protected function initializeBundles()
|
||||
{
|
||||
$this->bundles = array();
|
||||
@ -837,7 +878,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
'kernel.cache_dir' => $this->getCacheDir(),
|
||||
'kernel.logs_dir' => $this->getLogDir(),
|
||||
'kernel.bundles' => $bundles,
|
||||
'kernel.charset' => 'UTF-8',
|
||||
'kernel.charset' => $this->getCharset(),
|
||||
'kernel.container_class' => $this->getContainerClass(),
|
||||
),
|
||||
$this->getEnvParameters()
|
||||
@ -971,177 +1012,6 @@ abstract class Kernel implements KernelInterface, TerminableInterface
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\ClassLoader
|
||||
{
|
||||
|
||||
|
||||
class ClassCollectionLoader
|
||||
{
|
||||
static private $loaded;
|
||||
|
||||
|
||||
static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php')
|
||||
{
|
||||
if (isset(self::$loaded[$name])) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::$loaded[$name] = true;
|
||||
|
||||
if ($adaptive) {
|
||||
$classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());
|
||||
|
||||
$name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5);
|
||||
}
|
||||
|
||||
$cache = $cacheDir.'/'.$name.$extension;
|
||||
|
||||
$reload = false;
|
||||
if ($autoReload) {
|
||||
$metadata = $cacheDir.'/'.$name.$extension.'.meta';
|
||||
if (!is_file($metadata) || !is_file($cache)) {
|
||||
$reload = true;
|
||||
} else {
|
||||
$time = filemtime($cache);
|
||||
$meta = unserialize(file_get_contents($metadata));
|
||||
|
||||
if ($meta[1] != $classes) {
|
||||
$reload = true;
|
||||
} else {
|
||||
foreach ($meta[0] as $resource) {
|
||||
if (!is_file($resource) || filemtime($resource) > $time) {
|
||||
$reload = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$reload && is_file($cache)) {
|
||||
require_once $cache;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$files = array();
|
||||
$content = '';
|
||||
foreach ($classes as $class) {
|
||||
if (!class_exists($class) && !interface_exists($class) && (!function_exists('trait_exists') || !trait_exists($class))) {
|
||||
throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
|
||||
}
|
||||
|
||||
$r = new \ReflectionClass($class);
|
||||
$files[] = $r->getFileName();
|
||||
|
||||
$c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName()));
|
||||
|
||||
if (!$r->inNamespace()) {
|
||||
$c = "\nnamespace\n{\n".self::stripComments($c)."\n}\n";
|
||||
} else {
|
||||
$c = self::fixNamespaceDeclarations('<?php '.$c);
|
||||
$c = preg_replace('/^\s*<\?php/', '', $c);
|
||||
}
|
||||
|
||||
$content .= $c;
|
||||
}
|
||||
|
||||
if (!is_dir(dirname($cache))) {
|
||||
mkdir(dirname($cache), 0777, true);
|
||||
}
|
||||
self::writeCacheFile($cache, '<?php '.$content);
|
||||
|
||||
if ($autoReload) {
|
||||
self::writeCacheFile($metadata, serialize(array($files, $classes)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public function fixNamespaceDeclarations($source)
|
||||
{
|
||||
if (!function_exists('token_get_all')) {
|
||||
return $source;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
$inNamespace = false;
|
||||
$tokens = token_get_all($source);
|
||||
|
||||
for ($i = 0, $max = count($tokens); $i < $max; $i++) {
|
||||
$token = $tokens[$i];
|
||||
if (is_string($token)) {
|
||||
$output .= $token;
|
||||
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
continue;
|
||||
} elseif (T_NAMESPACE === $token[0]) {
|
||||
if ($inNamespace) {
|
||||
$output .= "}\n";
|
||||
}
|
||||
$output .= $token[1];
|
||||
|
||||
while (($t = $tokens[++$i]) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) {
|
||||
$output .= $t[1];
|
||||
}
|
||||
if (is_string($t) && '{' === $t) {
|
||||
$inNamespace = false;
|
||||
--$i;
|
||||
} else {
|
||||
$output = rtrim($output);
|
||||
$output .= "\n{";
|
||||
$inNamespace = true;
|
||||
}
|
||||
} else {
|
||||
$output .= $token[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($inNamespace) {
|
||||
$output .= "}\n";
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
static private function writeCacheFile($file, $content)
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
@chmod($file, 0666 & ~umask());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
|
||||
|
||||
static private function stripComments($source)
|
||||
{
|
||||
if (!function_exists('token_get_all')) {
|
||||
return $source;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
foreach (token_get_all($source) as $token) {
|
||||
if (is_string($token)) {
|
||||
$output .= $token;
|
||||
} elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
$output .= $token[1];
|
||||
}
|
||||
}
|
||||
|
||||
$output = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $output);
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\ClassLoader
|
||||
{
|
||||
|
||||
@ -1155,7 +1025,7 @@ class ApcClassLoader
|
||||
public function __construct($prefix, $classFinder)
|
||||
{
|
||||
if (!extension_loaded('apc')) {
|
||||
throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.');
|
||||
throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.');
|
||||
}
|
||||
|
||||
if (!method_exists($classFinder, 'findFile')) {
|
||||
@ -1242,6 +1112,26 @@ interface BundleInterface extends ContainerAwareInterface
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\DependencyInjection
|
||||
{
|
||||
|
||||
|
||||
abstract class ContainerAware implements ContainerAwareInterface
|
||||
{
|
||||
|
||||
protected $container;
|
||||
|
||||
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Bundle
|
||||
{
|
||||
|
||||
@ -1449,6 +1339,349 @@ class ConfigCache
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Component\HttpKernel
|
||||
{
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
|
||||
class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
{
|
||||
protected $dispatcher;
|
||||
protected $resolver;
|
||||
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
try {
|
||||
return $this->handleRaw($request, $type);
|
||||
} catch (\Exception $e) {
|
||||
if (false === $catch) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $this->handleException($e, $request, $type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function terminate(Request $request, Response $response)
|
||||
{
|
||||
$this->dispatcher->dispatch(KernelEvents::TERMINATE, new PostResponseEvent($this, $request, $response));
|
||||
}
|
||||
|
||||
|
||||
private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
|
||||
{
|
||||
$event = new GetResponseEvent($this, $request, $type);
|
||||
$this->dispatcher->dispatch(KernelEvents::REQUEST, $event);
|
||||
|
||||
if ($event->hasResponse()) {
|
||||
return $this->filterResponse($event->getResponse(), $request, $type);
|
||||
}
|
||||
|
||||
if (false === $controller = $this->resolver->getController($request)) {
|
||||
throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". Maybe you forgot to add the matching route in your routing configuration?', $request->getPathInfo()));
|
||||
}
|
||||
|
||||
$event = new FilterControllerEvent($this, $controller, $request, $type);
|
||||
$this->dispatcher->dispatch(KernelEvents::CONTROLLER, $event);
|
||||
$controller = $event->getController();
|
||||
|
||||
$arguments = $this->resolver->getArguments($request, $controller);
|
||||
|
||||
$response = call_user_func_array($controller, $arguments);
|
||||
|
||||
if (!$response instanceof Response) {
|
||||
$event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
|
||||
$this->dispatcher->dispatch(KernelEvents::VIEW, $event);
|
||||
|
||||
if ($event->hasResponse()) {
|
||||
$response = $event->getResponse();
|
||||
}
|
||||
|
||||
if (!$response instanceof Response) {
|
||||
$msg = sprintf('The controller must return a response (%s given).', $this->varToString($response));
|
||||
|
||||
if (null === $response) {
|
||||
$msg .= ' Did you forget to add a return statement somewhere in your controller?';
|
||||
}
|
||||
throw new \LogicException($msg);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->filterResponse($response, $request, $type);
|
||||
}
|
||||
|
||||
|
||||
private function filterResponse(Response $response, Request $request, $type)
|
||||
{
|
||||
$event = new FilterResponseEvent($this, $request, $type, $response);
|
||||
|
||||
$this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
|
||||
|
||||
return $event->getResponse();
|
||||
}
|
||||
|
||||
|
||||
private function handleException(\Exception $e, $request, $type)
|
||||
{
|
||||
$event = new GetResponseForExceptionEvent($this, $request, $type, $e);
|
||||
$this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event);
|
||||
|
||||
if (!$event->hasResponse()) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->filterResponse($event->getResponse(), $request, $type);
|
||||
} catch (\Exception $e) {
|
||||
return $event->getResponse();
|
||||
}
|
||||
}
|
||||
|
||||
private function varToString($var)
|
||||
{
|
||||
if (is_object($var)) {
|
||||
return sprintf('Object(%s)', get_class($var));
|
||||
}
|
||||
|
||||
if (is_array($var)) {
|
||||
$a = array();
|
||||
foreach ($var as $k => $v) {
|
||||
$a[] = sprintf('%s => %s', $k, $this->varToString($v));
|
||||
}
|
||||
|
||||
return sprintf("Array(%s)", implode(', ', $a));
|
||||
}
|
||||
|
||||
if (is_resource($var)) {
|
||||
return sprintf('Resource(%s)', get_resource_type($var));
|
||||
}
|
||||
|
||||
if (null === $var) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
if (false === $var) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
if (true === $var) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
return (string) $var;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle
|
||||
{
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernel as BaseHttpKernel;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
|
||||
class HttpKernel extends BaseHttpKernel
|
||||
{
|
||||
protected $container;
|
||||
|
||||
private $esiSupport;
|
||||
|
||||
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
|
||||
{
|
||||
parent::__construct($dispatcher, $controllerResolver);
|
||||
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
$request->headers->set('X-Php-Ob-Level', ob_get_level());
|
||||
|
||||
$this->container->enterScope('request');
|
||||
$this->container->set('request', $request, 'request');
|
||||
|
||||
try {
|
||||
$response = parent::handle($request, $type, $catch);
|
||||
} catch (\Exception $e) {
|
||||
$this->container->leaveScope('request');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->container->leaveScope('request');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
public function forward($controller, array $attributes = array(), array $query = array())
|
||||
{
|
||||
$attributes['_controller'] = $controller;
|
||||
$subRequest = $this->container->get('request')->duplicate($query, null, $attributes);
|
||||
|
||||
return $this->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
|
||||
}
|
||||
|
||||
|
||||
public function render($controller, array $options = array())
|
||||
{
|
||||
$options = array_merge(array(
|
||||
'attributes' => array(),
|
||||
'query' => array(),
|
||||
'ignore_errors' => !$this->container->getParameter('kernel.debug'),
|
||||
'alt' => array(),
|
||||
'standalone' => false,
|
||||
'comment' => '',
|
||||
), $options);
|
||||
|
||||
if (!is_array($options['alt'])) {
|
||||
$options['alt'] = array($options['alt']);
|
||||
}
|
||||
|
||||
if (null === $this->esiSupport) {
|
||||
$this->esiSupport = $this->container->has('esi') && $this->container->get('esi')->hasSurrogateEsiCapability($this->container->get('request'));
|
||||
}
|
||||
|
||||
if ($this->esiSupport && (true === $options['standalone'] || 'esi' === $options['standalone'])) {
|
||||
$uri = $this->generateInternalUri($controller, $options['attributes'], $options['query']);
|
||||
|
||||
$alt = '';
|
||||
if ($options['alt']) {
|
||||
$alt = $this->generateInternalUri($options['alt'][0], isset($options['alt'][1]) ? $options['alt'][1] : array(), isset($options['alt'][2]) ? $options['alt'][2] : array());
|
||||
}
|
||||
|
||||
return $this->container->get('esi')->renderIncludeTag($uri, $alt, $options['ignore_errors'], $options['comment']);
|
||||
}
|
||||
|
||||
if ('js' === $options['standalone']) {
|
||||
$uri = $this->generateInternalUri($controller, $options['attributes'], $options['query'], false);
|
||||
$defaultContent = null;
|
||||
|
||||
if ($template = $this->container->getParameter('templating.hinclude.default_template')) {
|
||||
$defaultContent = $this->container->get('templating')->render($template);
|
||||
}
|
||||
|
||||
return $this->renderHIncludeTag($uri, $defaultContent);
|
||||
}
|
||||
|
||||
$request = $this->container->get('request');
|
||||
|
||||
if (0 === strpos($controller, '/')) {
|
||||
$subRequest = Request::create($request->getUriForPath($controller), 'get', array(), $request->cookies->all(), array(), $request->server->all());
|
||||
if ($session = $request->getSession()) {
|
||||
$subRequest->setSession($session);
|
||||
}
|
||||
} else {
|
||||
$options['attributes']['_controller'] = $controller;
|
||||
|
||||
if (!isset($options['attributes']['_format'])) {
|
||||
$options['attributes']['_format'] = $request->getRequestFormat();
|
||||
}
|
||||
|
||||
$options['attributes']['_route'] = '_internal';
|
||||
$subRequest = $request->duplicate($options['query'], null, $options['attributes']);
|
||||
$subRequest->setMethod('GET');
|
||||
}
|
||||
|
||||
$level = ob_get_level();
|
||||
try {
|
||||
$response = $this->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false);
|
||||
|
||||
if (!$response->isSuccessful()) {
|
||||
throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $request->getUri(), $response->getStatusCode()));
|
||||
}
|
||||
|
||||
if (!$response instanceof StreamedResponse) {
|
||||
return $response->getContent();
|
||||
}
|
||||
|
||||
$response->sendContent();
|
||||
} catch (\Exception $e) {
|
||||
if ($options['alt']) {
|
||||
$alt = $options['alt'];
|
||||
unset($options['alt']);
|
||||
$options['attributes'] = isset($alt[1]) ? $alt[1] : array();
|
||||
$options['query'] = isset($alt[2]) ? $alt[2] : array();
|
||||
|
||||
return $this->render($alt[0], $options);
|
||||
}
|
||||
|
||||
if (!$options['ignore_errors']) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
while (ob_get_level() > $level) {
|
||||
ob_get_clean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function generateInternalUri($controller, array $attributes = array(), array $query = array(), $secure = true)
|
||||
{
|
||||
if (0 === strpos($controller, '/')) {
|
||||
return $controller;
|
||||
}
|
||||
|
||||
$path = http_build_query($attributes, '', '&');
|
||||
$uri = $this->container->get('router')->generate($secure ? '_internal' : '_internal_public', array(
|
||||
'controller' => $controller,
|
||||
'path' => $path ?: 'none',
|
||||
'_format' => $this->container->get('request')->getRequestFormat(),
|
||||
));
|
||||
|
||||
if ($queryString = http_build_query($query, '', '&')) {
|
||||
$uri .= '?'.$queryString;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
|
||||
public function renderHIncludeTag($uri, $defaultContent = null)
|
||||
{
|
||||
return sprintf('<hx:include src="%s">%s</hx:include>', $uri, $defaultContent);
|
||||
}
|
||||
|
||||
public function hasEsiSupport()
|
||||
{
|
||||
return $this->esiSupport;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace { return $loader; }
|
||||
|
@ -6,7 +6,6 @@ framework:
|
||||
#esi: ~
|
||||
#translator: { fallback: %locale% }
|
||||
secret: %secret%
|
||||
charset: UTF-8
|
||||
router:
|
||||
resource: "%kernel.root_dir%/config/routing.yml"
|
||||
strict_parameters: %kernel.debug%
|
||||
@ -15,8 +14,8 @@ framework:
|
||||
validation: { enable_annotations: true }
|
||||
templating: { engines: ['twig'] } #assets_version: SomeVersionScheme
|
||||
default_locale: %locale%
|
||||
session:
|
||||
auto_start: true
|
||||
trust_proxy_headers: false # Should Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
|
||||
session: ~
|
||||
|
||||
# Twig Configuration
|
||||
twig:
|
||||
|
@ -1,15 +1,12 @@
|
||||
KekRozsakAdminBundle:
|
||||
resource: "@KekRozsakAdminBundle/Controller/DefaultController.php"
|
||||
type: annotation
|
||||
resource: "@KekRozsakAdminBundle/Controller/"
|
||||
type: annotation
|
||||
|
||||
KekRozsakFrontBundle:
|
||||
resource: "@KekRozsakFrontBundle/Controller/"
|
||||
type: annotation
|
||||
|
||||
KekRozsakSecurityBundle:
|
||||
resource: "@KekRozsakSecurityBundle/Controller/DefaultController.php"
|
||||
type: annotation
|
||||
resource: "@KekRozsakSecurityBundle/Controller/"
|
||||
type: annotation
|
||||
|
||||
KekRozsakFrontBundle_Default:
|
||||
resource: "@KekRozsakFrontBundle/Controller/DefaultController.php"
|
||||
type: annotation
|
||||
|
||||
KekRozsakFrontBundle_Forum:
|
||||
resource: "@KekRozsakFrontBundle/Controller/ForumController.php"
|
||||
type: annotation
|
||||
|
@ -5,7 +5,7 @@ jms_security_extra:
|
||||
security:
|
||||
encoders:
|
||||
Symfony\Component\Security\Core\User\User: plaintext
|
||||
KekRozsak\FrontBundle\Entity\User:
|
||||
KekRozsak\SecurityBundle\Entity\User:
|
||||
id: kek_rozsak_security.encoder.crypt
|
||||
|
||||
role_hierarchy:
|
||||
@ -15,7 +15,7 @@ security:
|
||||
providers:
|
||||
user_db:
|
||||
entity:
|
||||
class: KekRozsak\FrontBundle\Entity\User
|
||||
class: KekRozsak\SecurityBundle\Entity\User
|
||||
property: username
|
||||
|
||||
firewalls:
|
||||
@ -29,6 +29,7 @@ security:
|
||||
|
||||
members:
|
||||
pattern: ^/
|
||||
|
||||
form_login:
|
||||
check_path: /login_check
|
||||
login_path: /login
|
||||
@ -42,7 +43,7 @@ security:
|
||||
- { path: ^/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/cikk/, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/jelentkezes, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/most-varj, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/most_varj, roles: IS_AUTHENTICATED_ANONYMOUSLY }
|
||||
- { path: ^/, roles: [ IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_REMEMBERED ] }
|
||||
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
|
||||
#- { path: ^/_internal/secure, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }
|
||||
|
23
app/upgrade.php
Normal file
23
app/upgrade.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// This script is very conservative in what it uses to avoid breaks at all costs
|
||||
|
||||
use Sensio\Bundle\DistributionBundle\Upgrade\Upgrade;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
|
||||
// We don't use the app autoloader in case it is not up to date
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
$upgrade = new Upgrade();
|
||||
$output = new ConsoleOutput();
|
||||
|
||||
$skeletonDir = __DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton';
|
||||
|
||||
$files = array(
|
||||
__DIR__.'/console' => $skeletonDir.'/app/console',
|
||||
__DIR__.'/autoload.php' => $skeletonDir.'/app/autoload.php',
|
||||
);
|
||||
|
||||
foreach ($files as $file => $skeleton) {
|
||||
$upgrade->outputConsoleDiff($output, $file, $skeleton);
|
||||
}
|
@ -23,17 +23,20 @@
|
||||
"post-install-cmd": [
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets"
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
|
||||
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"symfony-app-dir": "app",
|
||||
"symfony-web-dir": "web"
|
||||
|
52
composer.lock
generated
52
composer.lock
generated
@ -1,5 +1,5 @@
|
||||
{
|
||||
"hash": "60f09c83d9f0891b51ac51941970dcd5",
|
||||
"hash": "ab7ccf177098603cace942212179431f",
|
||||
"packages": [
|
||||
{
|
||||
"package": "doctrine/common",
|
||||
@ -8,17 +8,20 @@
|
||||
{
|
||||
"package": "doctrine/dbal",
|
||||
"version": "2.2.x-dev",
|
||||
"source-reference": "8cc129aa64a8de6447056bce20f0a274fe2a340b"
|
||||
"source-reference": "b961a3fce6bf220f1dca47d7d747b9074bea4730",
|
||||
"commit-date": "1341779435"
|
||||
},
|
||||
{
|
||||
"package": "doctrine/doctrine-bundle",
|
||||
"version": "dev-master",
|
||||
"source-reference": "94951737d6c692500d6b13bb92871935568a4ba5"
|
||||
"source-reference": "c9ea46d1f0c48bb88bb87b44214fe44e03c0c692",
|
||||
"commit-date": "1341405737"
|
||||
},
|
||||
{
|
||||
"package": "doctrine/orm",
|
||||
"version": "2.2.x-dev",
|
||||
"source-reference": "5f66c65c9a8d984899903b54215d0249a45b92d6"
|
||||
"source-reference": "5d2a3bcb3b467f41ee58575764f3ba84937f76e4",
|
||||
"commit-date": "1341676080"
|
||||
},
|
||||
{
|
||||
"package": "jms/aop-bundle",
|
||||
@ -49,7 +52,8 @@
|
||||
{
|
||||
"package": "kriswallsmith/assetic",
|
||||
"version": "dev-master",
|
||||
"source-reference": "d6f89a3170c5280ad554347dc113eb25fdf00ad7"
|
||||
"source-reference": "d6f89a3170c5280ad554347dc113eb25fdf00ad7",
|
||||
"commit-date": "1339515714"
|
||||
},
|
||||
{
|
||||
"package": "monolog/monolog",
|
||||
@ -58,43 +62,50 @@
|
||||
{
|
||||
"package": "sensio/distribution-bundle",
|
||||
"version": "dev-master",
|
||||
"source-reference": "a360ad61fe34206a7295c1ef00b5455b2b2e1071"
|
||||
"source-reference": "9a7dbd867fd5061e4bfd660a175aa66122f53d25",
|
||||
"commit-date": "1341741741"
|
||||
},
|
||||
{
|
||||
"package": "sensio/framework-extra-bundle",
|
||||
"version": "dev-master",
|
||||
"source-reference": "62e41b85947034b0f1dfe31bb8e76920e1488571"
|
||||
"source-reference": "4f54e5d5fb3b54fb107892684018f3704934c48d",
|
||||
"commit-date": "1341126219"
|
||||
},
|
||||
{
|
||||
"package": "sensio/generator-bundle",
|
||||
"version": "dev-master",
|
||||
"source-reference": "43ed45c48db18e4a0e48aec0c098f42e56e22d36"
|
||||
"source-reference": "43ed45c48db18e4a0e48aec0c098f42e56e22d36",
|
||||
"commit-date": "1340138445"
|
||||
},
|
||||
{
|
||||
"package": "swiftmailer/swiftmailer",
|
||||
"version": "dev-master",
|
||||
"alias-pretty-version": "4.1.x-dev",
|
||||
"alias-version": "4.1.9999999.9999999-dev"
|
||||
"alias-pretty-version": "4.2.x-dev",
|
||||
"alias-version": "4.2.9999999.9999999-dev"
|
||||
},
|
||||
{
|
||||
"package": "swiftmailer/swiftmailer",
|
||||
"version": "dev-master",
|
||||
"source-reference": "d57ffdeed664d6061cef0047e1f5d3fc3ee3fb99"
|
||||
"source-reference": "f51b5f33c83b48faea75f1285f99a2e8f1c66f75",
|
||||
"commit-date": "1341746460"
|
||||
},
|
||||
{
|
||||
"package": "symfony/assetic-bundle",
|
||||
"version": "dev-master",
|
||||
"source-reference": "8fe7b898b08103c1d6fce64c3e279a7afd61adfc"
|
||||
"source-reference": "8fe7b898b08103c1d6fce64c3e279a7afd61adfc",
|
||||
"commit-date": "1340234971"
|
||||
},
|
||||
{
|
||||
"package": "symfony/monolog-bundle",
|
||||
"version": "dev-master",
|
||||
"source-reference": "0b5046d3d1ef93cd59ceabfa37de2665f5118c7f"
|
||||
"source-reference": "7fe7f711bb04b86ad7f45a9e11a7f8cbaf9bc1a5",
|
||||
"commit-date": "1341078487"
|
||||
},
|
||||
{
|
||||
"package": "symfony/swiftmailer-bundle",
|
||||
"version": "dev-master",
|
||||
"source-reference": "d05c9c514a631ee688c53c4cc5505da757bd50d3"
|
||||
"source-reference": "e1d413ce27fd1696bdc82ad9525f1b874664530e",
|
||||
"commit-date": "1341509614"
|
||||
},
|
||||
{
|
||||
"package": "symfony/symfony",
|
||||
@ -105,23 +116,26 @@
|
||||
{
|
||||
"package": "symfony/symfony",
|
||||
"version": "dev-master",
|
||||
"source-reference": "v2.1.0-BETA1"
|
||||
"source-reference": "v2.1.0-BETA2",
|
||||
"commit-date": "1341820358"
|
||||
},
|
||||
{
|
||||
"package": "twig/extensions",
|
||||
"version": "dev-master",
|
||||
"source-reference": "feb6d3f10c411e2631997c0a905aa581c80305c1"
|
||||
"source-reference": "feb6d3f10c411e2631997c0a905aa581c80305c1",
|
||||
"commit-date": "1337599699"
|
||||
},
|
||||
{
|
||||
"package": "twig/twig",
|
||||
"version": "dev-master",
|
||||
"alias-pretty-version": "1.8.x-dev",
|
||||
"alias-version": "1.8.9999999.9999999-dev"
|
||||
"alias-pretty-version": "1.9.x-dev",
|
||||
"alias-version": "1.9.9999999.9999999-dev"
|
||||
},
|
||||
{
|
||||
"package": "twig/twig",
|
||||
"version": "dev-master",
|
||||
"source-reference": "4679ad51c5390648b7ea4c8f0ecd2c0c344145ba"
|
||||
"source-reference": "26eb0a2653eade50dffdd31b11ca454232dea8cf",
|
||||
"commit-date": "1341423205"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
namespace KekRozsak\AdminBundle\Controller;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
||||
|
||||
/**
|
||||
* @Route("/admin")
|
||||
@ -11,14 +12,15 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("/jelentkezok", name="KekRozsakAdminBundle_manage_reg")
|
||||
* @Route("/manage_regs", name="KekRozsakAdminBundle_manage_regs")
|
||||
* @Template()
|
||||
*/
|
||||
public function manageRegsAction()
|
||||
{
|
||||
$users = $this->getDoctrine()->getEntityManager()->createQuery('SELECT u FROM KekRozsakFrontBundle:User u WHERE u.acceptedBy IS NULL')->getResult();
|
||||
$users = $this->getDoctrine()->getEntityManager()->createQuery('SELECT u FROM KekRozsakSecurityBundle:User u WHERE u.acceptedBy IS NULL')->getResult();
|
||||
|
||||
return $this->render('KekRozsakAdminBundle:Default:manage_regs.html.twig', array (
|
||||
return array(
|
||||
'users' => $users,
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
KekRozsakAdminBundle_manage_regs:
|
||||
pattern: /jelentkezok
|
||||
defaults:
|
||||
_controller: KekRozsakAdminBundle:Default:manageRegs
|
@ -2,10 +2,12 @@
|
||||
|
||||
namespace KekRozsak\FrontBundle\Controller;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
||||
|
||||
use KekRozsak\FrontBundle\Form\Type\UserType;
|
||||
use KekRozsak\FrontBundle\Entity\UserData;
|
||||
use KekRozsak\SecurityBundle\Form\Type\UserType;
|
||||
|
||||
class DefaultController extends Controller
|
||||
{
|
||||
@ -14,7 +16,7 @@ class DefaultController extends Controller
|
||||
*/
|
||||
public function homepageAction()
|
||||
{
|
||||
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('mainPage' => 1), true, array('createdAt', 'DESC'), 1);
|
||||
$mainPageArticle = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:Article')->findOneBy(array('mainPage' => true), true, array('createdAt', 'DESC'), 1);
|
||||
if (!$mainPageArticle)
|
||||
throw $this->createNotFoundException('A keresett cikk nem létezik!');
|
||||
|
||||
@ -23,6 +25,9 @@ class DefaultController extends Controller
|
||||
|
||||
/**
|
||||
* @Route("/cikk/{articleSlug}", name="KekRozsakFrontBundle_article")
|
||||
* @Template()
|
||||
*
|
||||
* @param string $articleSlug
|
||||
*/
|
||||
public function articleAction($articleSlug)
|
||||
{
|
||||
@ -31,49 +36,43 @@ class DefaultController extends Controller
|
||||
if (!$article)
|
||||
throw $this->createNotFoundException('A keresett cikk nem létezik!');
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Default:article.html.twig', array(
|
||||
'article' => $article
|
||||
));
|
||||
return array(
|
||||
'article' => $article,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/profil", name="KekRozsakFrontBundle_profile_edit")
|
||||
* @Template("KekRozsakFrontBundle:Default:userprofile.html.twig")
|
||||
*/
|
||||
public function profileEditAction()
|
||||
{
|
||||
$user = $this->get('security.context')->getToken()->getUser();
|
||||
$oldPassword = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:User')->findOneById($user->getId())->getPassword();
|
||||
$form = $this->createForm(new UserType(), $user);
|
||||
|
||||
$oldPassword = $user->getPassword();
|
||||
$form = $this->createForm(new UserType(), $user);
|
||||
$saveSuccess = false;
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
$form->bindRequest($request);
|
||||
if ($form->isValid())
|
||||
{
|
||||
if ($user->getPassword() != '')
|
||||
{
|
||||
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->getPassword() == '')
|
||||
$user->setPassword($oldPassword);
|
||||
}
|
||||
if ($user->getUserData()->getUserId() === null)
|
||||
{
|
||||
$user->getUserData()->setUser($user);
|
||||
}
|
||||
else
|
||||
$user->setPassword($this->get('security.encoder_factory')->getEncoder($user)->encodePassword($user->getPassword(), $user->getSalt()));
|
||||
|
||||
$em = $this->getDoctrine()->getEntityManager();
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
// $saveSuccess = true
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Default:userprofile.html.twig', array(
|
||||
return array(
|
||||
'form' => $form->createView(),
|
||||
'saveSuccess' => $saveSuccess,
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
namespace KekRozsak\FrontBundle\Controller;
|
||||
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
|
||||
use KekRozsak\FrontBundle\Entity\ForumPost;
|
||||
use KekRozsak\FrontBundle\Form\Type\ForumPostType;
|
||||
@ -16,40 +17,42 @@ class ForumController extends Controller
|
||||
{
|
||||
/**
|
||||
* @Route("", name="KekRozsakFrontBundle_forum_main")
|
||||
* @Template("KekRozsakFrontBundle:Forum:topic_group_list.html.twig")
|
||||
*/
|
||||
public function mainAction()
|
||||
{
|
||||
// TODO: Protect this controller with roles? It is also defined in security.yml
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
|
||||
|
||||
// TODO: ORDER the topic list by last post date
|
||||
$topicGroups = $groupRepo->findAll();
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Forum:topic_group_list.html.twig', array(
|
||||
return array(
|
||||
'topicGroups' => $topicGroups,
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{topicGroupSlug}", name="KekRozsakFrontBundle_forum_topic_list")
|
||||
* @Template("KekRozsakFrontBundle:Forum:topic_list.html.twig")
|
||||
*/
|
||||
public function topicListAction($topicGroupSlug)
|
||||
{
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
|
||||
|
||||
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
|
||||
throw $this->createNotFoundException('A kért témakör nem létezik!');
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Forum:topic_list.html.twig', array(
|
||||
return array(
|
||||
'topicGroup' => $topicGroup,
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{topicGroupSlug}/{topicSlug}", name="KekRozsakFrontBundle_forum_post_list")
|
||||
* @Template("KekRozsakFrontBundle:Forum:post_list.html.twig")
|
||||
*/
|
||||
public function postListAction($topicGroupSlug, $topicSlug)
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
// Get the topic group based on slug
|
||||
$groupRepo = $this->getDoctrine()->getRepository('KekRozsakFrontBundle:ForumTopicGroup');
|
||||
if (!($topicGroup = $groupRepo->findOneBySlug($topicGroupSlug)))
|
||||
@ -68,6 +71,7 @@ class ForumController extends Controller
|
||||
$post = new ForumPost();
|
||||
$form = $this->createForm(new ForumPostType($topicGroup->getId(), $topic->getId()), $post);
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->getMethod() == 'POST')
|
||||
{
|
||||
$form->bindRequest($request);
|
||||
@ -89,12 +93,11 @@ class ForumController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('KekRozsakFrontBundle:Forum:post_list.html.twig', array(
|
||||
return array(
|
||||
'topicGroup' => $topicGroup,
|
||||
'topic' => $topic,
|
||||
'posts' => $posts,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,9 @@ namespace KekRozsak\FrontBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
use KekRozsak\FrontBundle\Entity\User;
|
||||
use KekRozsak\SecurityBundle\Entity\User;
|
||||
|
||||
/**
|
||||
* KekRozsak\FrontBundle\Entity\Article
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="articles")
|
||||
*/
|
||||
@ -17,23 +16,80 @@ class Article
|
||||
* @var integer $id
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @ORM\Column(type="integer", name="id")
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @ORM\ManyToOne(targetEntity="KekRozsak\SecurityBundle\Entity\User")
|
||||
* @ORM\JoinColumn(name="created_by_id")
|
||||
*/
|
||||
private $createdBy;
|
||||
|
||||
/**
|
||||
* Set createdBy
|
||||
*
|
||||
* @param KekRozsak\SecurityBundle\Entity\User $createdBy
|
||||
* @return Article
|
||||
*/
|
||||
public function setCreatedBy(\KekRozsak\SecurityBundle\Entity\User $createdBy)
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdBy
|
||||
*
|
||||
* @return KekRozsak\SecurityBundle\Entity\User
|
||||
*/
|
||||
public function getCreatedBy()
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var DateTime $createdAt
|
||||
* @ORM\Column(type="datetime", name="created_at", nullable=false)
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* Set createdAt
|
||||
*
|
||||
* @param DateTime $createdAt
|
||||
* @return Article
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdAt
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string $title
|
||||
* @ORM\Column(type="string", length=100, nullable=false)
|
||||
* @ORM\Column(type="string", length=100, nullable=false, unique=true)
|
||||
*/
|
||||
private $title;
|
||||
|
||||
@ -52,7 +108,7 @@ class Article
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
@ -80,7 +136,7 @@ class Article
|
||||
/**
|
||||
* Get slug
|
||||
*
|
||||
* @return string
|
||||
* @return string
|
||||
*/
|
||||
public function getSlug()
|
||||
{
|
||||
@ -88,7 +144,7 @@ class Article
|
||||
}
|
||||
|
||||
/**
|
||||
* @var text $text
|
||||
* @var string $text
|
||||
* @ORM\Column(type="text", nullable=false)
|
||||
*/
|
||||
private $text;
|
||||
@ -96,7 +152,7 @@ class Article
|
||||
/**
|
||||
* Set text
|
||||
*
|
||||
* @param text $text
|
||||
* @param string $text
|
||||
* @return Article
|
||||
*/
|
||||
public function setText($text)
|
||||
@ -108,186 +164,16 @@ class Article
|
||||
/**
|
||||
* Get text
|
||||
*
|
||||
* @return text
|
||||
* return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var string $source
|
||||
* @ORM\Column(type="string", length=255, nullable=true)
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* Set source
|
||||
*
|
||||
* @param string $source
|
||||
* @return Article
|
||||
*/
|
||||
public function setSource($source)
|
||||
{
|
||||
$this->source = $source;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var DateTime $createdAt
|
||||
* @ORM\Column(type="datetime", nullable=false, name="created_at")
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* Set createdAt
|
||||
*
|
||||
* @param DateTime $createdAt
|
||||
* @return Article
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdAt
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var User $createdBy
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="articles")
|
||||
* @ORM\JoinColumn(name="created_by_id", referencedColumnName="id")
|
||||
*/
|
||||
private $createdBy;
|
||||
|
||||
/**
|
||||
* Set createdBy
|
||||
*
|
||||
* @param User $createdBy
|
||||
* @return Article
|
||||
*/
|
||||
public function setCreatedBy(User $createdBy = null)
|
||||
{
|
||||
$this->createdBy = $createdBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get createdBy
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function getCreatedBy()
|
||||
{
|
||||
return $this->createdBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var DateTime $updatedAt
|
||||
* @ORM\Column(type="datetime", nullable=true, name="updated_at")
|
||||
*/
|
||||
private $updatedAt;
|
||||
|
||||
/**
|
||||
* Set updatedAt
|
||||
*
|
||||
* @param DateTime $updatedAt
|
||||
* @return Article
|
||||
*/
|
||||
public function setUpdatedAt(\DateTime $updatedAt)
|
||||
{
|
||||
$this->updatedAt = $updatedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* |