commit
a086eeb286
|
@ -12,7 +12,6 @@ class AppKernel extends Kernel
|
|||
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
||||
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||
new Symfony\Bundle\MonologBundle\MonologBundle(),
|
||||
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
|
||||
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
|
||||
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
|
||||
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
|
||||
|
@ -24,8 +23,8 @@ class AppKernel extends Kernel
|
|||
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
|
||||
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
|
||||
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
|
||||
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
|
||||
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
|
||||
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
|
||||
}
|
||||
|
||||
return $bundles;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
*/
|
||||
class Version20150302205121 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
@ -50,7 +50,7 @@ class Version20150302205121 extends AbstractMigration
|
|||
}
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
*/
|
||||
class Version20150302213116 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Version20150302213116 extends AbstractMigration
|
|||
$this->addSql('RENAME TABLE paste TO copypastes');
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
*/
|
||||
class Version20150302223210 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
@ -24,7 +24,7 @@ class Version20150302223210 extends AbstractMigration
|
|||
$this->addSql('CREATE INDEX IDX_DBA4BEBE82F1BAF4 ON copypastes (language_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
|
@ -10,12 +10,12 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
*/
|
||||
class Version20150303224825 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('UPDATE copypastes SET secret=NULL WHERE secret=\'\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('UPDATE copypastes SET secret=\'\' WHERE secret=NULL');
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
|
@ -10,13 +10,13 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
*/
|
||||
class Version20150305184842 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('UPDATE copypastes SET date_expire=NULL WHERE date_expire=\'0000-00-00 00:00:00\'');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('UPDATE copypastes SET date_expire=\'0000-00-00 00:00:00\' WHERE date_expire=NULL');
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Application\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Migrations\AbstractMigration;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,7 @@ use Doctrine\DBAL\Schema\Schema;
|
|||
*/
|
||||
class Version20150316014139 extends AbstractMigration
|
||||
{
|
||||
public function up(Schema $schema)
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
@ -21,7 +21,7 @@ class Version20150316014139 extends AbstractMigration
|
|||
$this->addSql('CREATE INDEX idx_preferred ON languages (is_preferred)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema)
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||
|
||||
|
|
6
app/Resources/views/Paste/new.html.twig
Normal file
6
app/Resources/views/Paste/new.html.twig
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
{# This form recieves form_create object from current context #}
|
||||
{% include 'Form/form_paste_create.html.twig' %}
|
||||
{% endblock %}
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '::base.html.twig' %}
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="paste container-fluid">
|
||||
|
@ -66,7 +66,7 @@
|
|||
</div>
|
||||
<div role="tabpanel" class="tab-pane" id="tab-paste-edit">
|
||||
{# This form recieves form_create object from current context #}
|
||||
{% include 'SkobkinCopyPasteBundle:Form:form_paste_create.html.twig' %}
|
||||
{% include 'Form/form_paste_create.html.twig' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,4 +1,4 @@
|
|||
{% extends '::layout.html.twig' -%}
|
||||
{% extends 'layout.html.twig' -%}
|
||||
|
||||
{%- block css -%}
|
||||
{{- parent() -}}
|
||||
|
@ -20,7 +20,7 @@
|
|||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="{{ path('copypaste_new') }}">{{ 'header_title' | trans }}</a>
|
||||
<a class="navbar-brand" href="{{ path('paste_new') }}">{{ 'header_title' | trans }}</a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
|
@ -28,7 +28,7 @@
|
|||
<ul class="nav navbar-nav">
|
||||
{% block header_menu_left_items %}
|
||||
<li{% if app.request.attributes.get('_route') == 'copypaste_new' %} class="active"{% endif %}>
|
||||
<a href="{{ path('copypaste_new') }}"><span class="glyphicon glyphicon-plus-sign"></span> {{ 'header_menu_add' | trans }}</a>
|
||||
<a href="{{ path('paste_new') }}"><span class="glyphicon glyphicon-plus-sign"></span> {{ 'header_menu_add' | trans }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{#{{ path('about') }}#}"><span class="glyphicon glyphicon-info-sign"></span> {{ 'header_menu_about' | trans }}</a>
|
||||
|
@ -46,7 +46,7 @@
|
|||
{%- endblock -%}
|
||||
|
||||
{%- block sidebar -%}
|
||||
{{ render(controller('SkobkinCopyPasteBundle:CopyPaste:sidebar')) }}
|
||||
{{ render(controller('Skobkin\\Bundle\\CopyPasteBundle\\Controller\\PasteController::sidebarAction')) }}
|
||||
{%- endblock -%}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="panel-heading">{{ 'sidebar_title' | trans() }}</div>
|
||||
<ul class="list-group">
|
||||
{% for paste in pastes %}
|
||||
<a href="{{ path('copypaste_show_public', {'id': paste.id}) }}" class="list-group-item">
|
||||
<a href="{{ path('paste_show_public', {'id': paste.id}) }}" class="list-group-item">
|
||||
#{{ paste.id }} - {% if paste.author %}{{ paste.author }}{% else %}anonymous{% endif %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
|
|
@ -389,7 +389,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
{
|
||||
/* mandatory requirements follow */
|
||||
|
||||
$installedPhpVersion = phpversion();
|
||||
$installedPhpVersion = PHP_VERSION;
|
||||
$requiredPhpVersion = $this->getPhpRequiredVersion();
|
||||
|
||||
$this->addRecommendation(
|
||||
|
@ -448,15 +448,8 @@ class SymfonyRequirements extends RequirementCollection
|
|||
}
|
||||
|
||||
if (false !== $requiredPhpVersion && version_compare($installedPhpVersion, $requiredPhpVersion, '>=')) {
|
||||
$timezones = array();
|
||||
foreach (DateTimeZone::listAbbreviations() as $abbreviations) {
|
||||
foreach ($abbreviations as $abbreviation) {
|
||||
$timezones[$abbreviation['timezone_id']] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->addRequirement(
|
||||
isset($timezones[@date_default_timezone_get()]),
|
||||
in_array(@date_default_timezone_get(), DateTimeZone::listIdentifiers(), true),
|
||||
sprintf('Configured default timezone "%s" must be supported by your installation of PHP', @date_default_timezone_get()),
|
||||
'Your default timezone is not supported by PHP. Check for typos in your <strong>php.ini</strong> file and have a look at the list of deprecated timezones at <a href="http://php.net/manual/en/timezones.others.php">http://php.net/manual/en/timezones.others.php</a>.'
|
||||
);
|
||||
|
@ -633,12 +626,6 @@ class SymfonyRequirements extends RequirementCollection
|
|||
'Install and enable the <strong>mbstring</strong> extension.'
|
||||
);
|
||||
|
||||
$this->addRecommendation(
|
||||
function_exists('iconv'),
|
||||
'iconv() should be available',
|
||||
'Install and enable the <strong>iconv</strong> extension.'
|
||||
);
|
||||
|
||||
$this->addRecommendation(
|
||||
function_exists('utf8_decode'),
|
||||
'utf8_decode() should be available',
|
||||
|
@ -737,7 +724,7 @@ class SymfonyRequirements extends RequirementCollection
|
|||
'Install and/or enable a <strong>PHP accelerator</strong> (highly recommended).'
|
||||
);
|
||||
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||
if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
|
||||
$this->addRecommendation(
|
||||
$this->getRealpathCacheSize() >= 5 * 1024 * 1024,
|
||||
'realpath_cache_size should be at least 5M in php.ini',
|
||||
|
@ -780,7 +767,11 @@ class SymfonyRequirements extends RequirementCollection
|
|||
{
|
||||
$size = ini_get('realpath_cache_size');
|
||||
$size = trim($size);
|
||||
$unit = strtolower(substr($size, -1, 1));
|
||||
$unit = '';
|
||||
if (!ctype_digit($size)) {
|
||||
$unit = strtolower(substr($size, -1, 1));
|
||||
$size = (int) substr($size, 0, -1);
|
||||
}
|
||||
switch ($unit) {
|
||||
case 'g':
|
||||
return $size * 1024 * 1024 * 1024;
|
||||
|
|
|
@ -13,17 +13,21 @@ framework:
|
|||
form: ~
|
||||
csrf_protection: ~
|
||||
validation: { enable_annotations: true }
|
||||
templating:
|
||||
engines: ['twig']
|
||||
#assets_version: SomeVersionScheme
|
||||
default_locale: "%locale%"
|
||||
#serializer: { enable_annotations: true }
|
||||
default_locale: '%locale%'
|
||||
trusted_hosts: ~
|
||||
trusted_proxies: ~
|
||||
session:
|
||||
# handler_id set to null will use default session handler from php.ini
|
||||
handler_id: ~
|
||||
fragments: ~
|
||||
http_method_override: true
|
||||
assets: ~
|
||||
php_errors:
|
||||
log: true
|
||||
|
||||
sensio_framework_extra:
|
||||
router:
|
||||
annotations: false
|
||||
|
||||
# Twig Configuration
|
||||
twig:
|
||||
|
@ -31,7 +35,7 @@ twig:
|
|||
strict_variables: "%kernel.debug%"
|
||||
form_themes:
|
||||
- 'bootstrap_3_layout.html.twig'
|
||||
- 'SkobkinCopyPasteBundle:Form:fields.html.twig'
|
||||
- 'Form/fields.html.twig'
|
||||
|
||||
# Doctrine Configuration
|
||||
doctrine:
|
||||
|
@ -60,10 +64,3 @@ doctrine_migrations:
|
|||
table_name: migration_versions
|
||||
name: Application Migrations
|
||||
|
||||
# Swiftmailer Configuration
|
||||
swiftmailer:
|
||||
transport: "%mailer_transport%"
|
||||
host: "%mailer_host%"
|
||||
username: "%mailer_user%"
|
||||
password: "%mailer_password%"
|
||||
spool: { type: memory }
|
||||
|
|
|
@ -40,6 +40,3 @@ monolog:
|
|||
#chromephp:
|
||||
# type: chromephp
|
||||
# level: info
|
||||
|
||||
#swiftmailer:
|
||||
# delivery_address: me@example.com
|
||||
|
|
|
@ -18,6 +18,3 @@ framework:
|
|||
web_profiler:
|
||||
toolbar: false
|
||||
intercept_redirects: false
|
||||
|
||||
swiftmailer:
|
||||
disable_delivery: true
|
||||
|
|
|
@ -9,11 +9,6 @@ parameters:
|
|||
# You should uncomment this if you want use pdo_sqlite
|
||||
# database_path: "%kernel.root_dir%/data.db3"
|
||||
|
||||
mailer_transport: smtp
|
||||
mailer_host: 127.0.0.1
|
||||
mailer_user: ~
|
||||
mailer_password: ~
|
||||
|
||||
locale: en
|
||||
|
||||
# A secret key that's used to generate certain security-related tokens
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
skobkin_copy_paste:
|
||||
resource: "@SkobkinCopyPasteBundle/Resources/config/routing.yml"
|
||||
prefix: /
|
||||
paste_show_public:
|
||||
path: /{id}
|
||||
defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::showAction', secret: null }
|
||||
requirements:
|
||||
id: \d+
|
||||
|
||||
paste_show_private:
|
||||
path: /{id}/{secret}
|
||||
defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::showAction' }
|
||||
requirements:
|
||||
id: \d+
|
||||
secret: \w{16}
|
||||
|
||||
paste_new:
|
||||
path: /
|
||||
defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::newAction' }
|
||||
|
||||
paste_create:
|
||||
path: /create
|
||||
defaults: { _controller: 'Skobkin\Bundle\CopyPasteBundle\Controller\PasteController::createAction' }
|
||||
methods: POST
|
|
@ -4,6 +4,27 @@ parameters:
|
|||
# parameter_name: value
|
||||
|
||||
services:
|
||||
# service_name:
|
||||
# class: AppBundle\Directory\ClassName
|
||||
# arguments: ["@another_service_name", "plain_value", "%parameter_name%"]
|
||||
# default configuration for services in *this* file
|
||||
_defaults:
|
||||
# automatically injects dependencies in your services
|
||||
autowire: true
|
||||
# automatically registers your services as commands, event subscribers, etc.
|
||||
autoconfigure: true
|
||||
# this means you cannot fetch services directly from the container via $container->get()
|
||||
# if you need to do this, you can override this setting on individual services
|
||||
public: false
|
||||
|
||||
# makes classes in src/AppBundle available to be used as services
|
||||
# this creates a service per class whose id is the fully-qualified class name
|
||||
Skobkin\Bundle\CopyPasteBundle\:
|
||||
resource: '../../src/Skobkin/Bundle/CopyPasteBundle/*'
|
||||
# you can exclude directories or files
|
||||
# but if a service is unused, it's removed anyway
|
||||
exclude: '../../src/Skobkin/Bundle/CopyPasteBundle/{DataFixtures,DependencyInjection,Entity,Repository,Tests}'
|
||||
|
||||
# controllers are imported separately to make sure they're public
|
||||
# and have a tag that allows actions to type-hint services
|
||||
Skobkin\Bundle\CopyPasteBundle\Controller\:
|
||||
resource: '../../src/Skobkin/Bundle/CopyPasteBundle/Controller'
|
||||
public: true
|
||||
tags: ['controller.service_arguments']
|
||||
|
|
|
@ -4,15 +4,14 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
// if you don't want to setup permissions the proper way, just uncomment the following PHP line
|
||||
// read http://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
||||
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
||||
// for more information
|
||||
umask(0002);
|
||||
set_time_limit(0);
|
||||
/** @var Composer\Autoload\ClassLoader $loader */
|
||||
$loader = require __DIR__.'/../app/autoload.php';
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
$input = new ArgvInput();
|
||||
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
|
||||
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
|
||||
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev', true);
|
||||
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption('--no-debug', true) && $env !== 'prod';
|
||||
if ($debug) {
|
||||
Debug::enable();
|
||||
}
|
||||
|
|
|
@ -7,28 +7,23 @@
|
|||
"psr-4": { "": "src/" },
|
||||
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"minimum-stability": "stable",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"symfony/symfony": "3.2.*",
|
||||
"php": ">=7.1.0",
|
||||
"symfony/symfony": "^3.4",
|
||||
"doctrine/orm": "^2.5",
|
||||
"doctrine/doctrine-bundle": "^1.4",
|
||||
"symfony/swiftmailer-bundle": "^2.3",
|
||||
"symfony/monolog-bundle": "~2.11.3",
|
||||
"symfony/polyfill-apcu": "^1.0",
|
||||
"symfony/monolog-bundle": "^3.1",
|
||||
"sensio/distribution-bundle": "^5.0",
|
||||
"sensio/framework-extra-bundle": "^3.0.2",
|
||||
"incenteev/composer-parameter-handler": "~2.0",
|
||||
"incenteev/composer-parameter-handler": "^2.0",
|
||||
"doctrine/doctrine-fixtures-bundle": "^2.2",
|
||||
"theodordiaconu/geshi": "dev-master",
|
||||
"theodordiaconu/geshi-bundle" : "dev-master",
|
||||
"doctrine/doctrine-migrations-bundle": "^1.0",
|
||||
"doctrine/doctrine-migrations-bundle": "^2.0",
|
||||
"doctrine/annotations": "^1.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"sensio/generator-bundle": "^3.0",
|
||||
"symfony/phpunit-bridge": "^3.0",
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},"require-dev": {
|
||||
"symfony/web-server-bundle": "^3.4"
|
||||
},
|
||||
"scripts": {
|
||||
"symfony-scripts": [
|
||||
|
@ -47,7 +42,8 @@
|
|||
]
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
"bin-dir": "bin",
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"symfony-app-dir": "app",
|
||||
|
|
2896
composer.lock
generated
2896
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Skobkin\Bundle\CopyPasteBundle\Controller;
|
||||
|
||||
use DT\Bundle\GeshiBundle\Highlighter\HighlighterInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -9,14 +10,9 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||
use \Symfony\Component\Form\Form;
|
||||
use Skobkin\Bundle\CopyPasteBundle\Entity\Copypaste;
|
||||
use Skobkin\Bundle\CopyPasteBundle\Form\CopypasteType;
|
||||
use DT\Bundle\GeshiBundle\Highlighter\GeshiHighlighter;
|
||||
use \GeSHi\GeSHi;
|
||||
|
||||
/**
|
||||
* Copypaste controller.
|
||||
*
|
||||
*/
|
||||
class CopypasteController extends Controller
|
||||
class PasteController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -58,9 +54,9 @@ class CopypasteController extends Controller
|
|||
$em->flush();
|
||||
|
||||
if ($paste->isPrivate()) {
|
||||
return $this->redirect($this->generateUrl('copypaste_show_private', ['id' => $paste->getId(), 'secret' => $paste->getSecret()]));
|
||||
return $this->redirect($this->generateUrl('paste_show_private', ['id' => $paste->getId(), 'secret' => $paste->getSecret()]));
|
||||
} else {
|
||||
return $this->redirect($this->generateUrl('copypaste_show_public', ['id' => $paste->getId()]));
|
||||
return $this->redirect($this->generateUrl('paste_show_public', ['id' => $paste->getId()]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +73,7 @@ class CopypasteController extends Controller
|
|||
private function createCreateForm(Copypaste $entity)
|
||||
{
|
||||
$form = $this->createForm(CopypasteType::class, $entity, [
|
||||
'action' => $this->generateUrl('copypaste_create'),
|
||||
'action' => $this->generateUrl('paste_create'),
|
||||
'method' => 'POST',
|
||||
]);
|
||||
|
||||
|
@ -96,7 +92,7 @@ class CopypasteController extends Controller
|
|||
$paste = new Copypaste();
|
||||
$createForm = $this->createCreateForm($paste);
|
||||
|
||||
return $this->render('SkobkinCopyPasteBundle:Copypaste:new.html.twig', [
|
||||
return $this->render('Paste/new.html.twig', [
|
||||
'entity' => $paste,
|
||||
'form_create' => $createForm->createView(),
|
||||
]);
|
||||
|
@ -107,12 +103,12 @@ class CopypasteController extends Controller
|
|||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function showAction($id, $secret)
|
||||
public function showAction(int $id, ?string $secret, HighlighterInterface $highlighter)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
/* @var $paste Copypaste */
|
||||
$paste = $em->getRepository('SkobkinCopyPasteBundle:Copypaste')->findOneBy([
|
||||
$paste = $em->getRepository(Copypaste::class)->findOneBy([
|
||||
'id' =>$id,
|
||||
'secret' => $secret
|
||||
]);
|
||||
|
@ -123,15 +119,12 @@ class CopypasteController extends Controller
|
|||
|
||||
$editForm = $this->createCreateForm($paste);
|
||||
|
||||
/* @var $highlighter GeshiHighlighter */
|
||||
$highlighter = $this->get('dt_geshi.highlighter');
|
||||
|
||||
$highlightedCode = $highlighter->highlight($paste->getText(), $paste->getLanguage()->getCode(), function(GeSHi $geshi) {
|
||||
$geshi->set_header_type(GESHI_HEADER_PRE);
|
||||
$geshi->enable_line_numbers(GESHI_NO_LINE_NUMBERS);
|
||||
});
|
||||
|
||||
return $this->render('SkobkinCopyPasteBundle:Copypaste:show.html.twig', [
|
||||
return $this->render('Paste/show.html.twig', [
|
||||
'paste' => $paste,
|
||||
'highlighted_text' => $highlightedCode,
|
||||
'form_create' => $editForm->createView(),
|
||||
|
@ -147,15 +140,13 @@ class CopypasteController extends Controller
|
|||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$pastes = $em->getRepository('SkobkinCopyPasteBundle:Copypaste')->findBy(
|
||||
$pastes = $em->getRepository(Copypaste::class)->findBy(
|
||||
['secret' => null],
|
||||
['id' => 'DESC'],
|
||||
// @todo move to the config
|
||||
15
|
||||
);
|
||||
|
||||
return $this->render('::sidebar.html.twig', ['pastes' => $pastes]);
|
||||
return $this->render('sidebar.html.twig', ['pastes' => $pastes]);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -78,13 +78,13 @@ class LoadLanguages implements FixtureInterface, ContainerAwareInterface
|
|||
foreach ($finder as $file) {
|
||||
$output->writeln($file->getRelativePathname() . ' found. Parsing...');
|
||||
|
||||
include $geshiPath . DIRECTORY_SEPARATOR .$file->getRelativePathname();
|
||||
include $geshiPath.DIRECTORY_SEPARATOR.$file->getRelativePathname();
|
||||
|
||||
$language = new Language();
|
||||
$language
|
||||
->setName($language_data['LANG_NAME'])
|
||||
->setCode(basename($file->getRelativePathname(), '.php'))
|
||||
->setEnabled(true)
|
||||
->setIsEnabled(true)
|
||||
;
|
||||
|
||||
$output->write('---> "' . $language->getName() . '"');
|
||||
|
|
|
@ -23,6 +23,5 @@ class SkobkinCopyPasteExtension extends Extension
|
|||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('services.yml');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ namespace Skobkin\Bundle\CopyPasteBundle\Entity;
|
|||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* @ORM\Table(name="languages", indexes={
|
||||
* @ORM\Index(name="idx_enabled", columns={"is_enabled"}),
|
||||
* @ORM\Index(name="idx_preferred", columns={"is_preferred"}),
|
||||
|
@ -53,14 +51,7 @@ class Language
|
|||
*/
|
||||
private $isEnabled;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getId()
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
@ -70,91 +61,48 @@ class Language
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Lang
|
||||
*/
|
||||
public function setName($name)
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set code
|
||||
*
|
||||
* @param string $code
|
||||
* @return Lang
|
||||
*/
|
||||
public function setCode($code)
|
||||
public function setCode($code): self
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set isEnabled
|
||||
*
|
||||
* @param boolean $isEnabled
|
||||
* @return Lang
|
||||
*/
|
||||
public function setIsEnabled($isEnabled)
|
||||
public function setIsEnabled($isEnabled): self
|
||||
{
|
||||
$this->isEnabled = $isEnabled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get isEnabled
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getIsEnabled()
|
||||
public function getIsEnabled(): bool
|
||||
{
|
||||
return $this->isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get isPreferred
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function getIsPreferred()
|
||||
function getIsPreferred(): bool
|
||||
{
|
||||
return $this->isPreferred;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set isPreferred
|
||||
*
|
||||
* @param boolean $isPreferred
|
||||
*/
|
||||
function setIsPreferred($isPreferred)
|
||||
function setIsPreferred(bool $isPreferred): self
|
||||
{
|
||||
$this->isPreferred = $isPreferred;
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
skobkin_copy_paste:
|
||||
resource: "@SkobkinCopyPasteBundle/Resources/config/routing/copypaste.yml"
|
||||
prefix: /
|
|
@ -1,21 +0,0 @@
|
|||
copypaste_show_public:
|
||||
path: /{id}
|
||||
defaults: { _controller: "SkobkinCopyPasteBundle:Copypaste:show", secret: null }
|
||||
requirements:
|
||||
id: \d+
|
||||
|
||||
copypaste_show_private:
|
||||
path: /{id}/{secret}
|
||||
defaults: { _controller: "SkobkinCopyPasteBundle:Copypaste:show" }
|
||||
requirements:
|
||||
id: \d+
|
||||
secret: \w{16}
|
||||
|
||||
copypaste_new:
|
||||
path: /
|
||||
defaults: { _controller: "SkobkinCopyPasteBundle:Copypaste:new" }
|
||||
|
||||
copypaste_create:
|
||||
path: /create
|
||||
defaults: { _controller: "SkobkinCopyPasteBundle:Copypaste:create" }
|
||||
methods: POST
|
|
@ -1 +0,0 @@
|
|||
services:
|
|
@ -1,6 +0,0 @@
|
|||
{% extends '::base.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
{# This form recieves form_create object from current context #}
|
||||
{% include 'SkobkinCopyPasteBundle:Form:form_paste_create.html.twig' %}
|
||||
{% endblock %}
|
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
/** @var \Composer\Autoload\ClassLoader $loader */
|
||||
$loader = require __DIR__.'/../app/autoload.php';
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
include_once __DIR__.'/../var/bootstrap.php.cache';
|
||||
include_once __DIR__.'/../app/bootstrap.php.cache';
|
||||
}
|
||||
$kernel = new AppKernel('prod', false);
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
|
|
|
@ -1,28 +1,25 @@
|
|||
<?php
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
// If you don't want to setup permissions the proper way, just uncomment the following PHP line
|
||||
// read http://symfony.com/doc/current/book/installation.html#checking-symfony-application-configuration-and-setup
|
||||
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup
|
||||
// for more information
|
||||
umask(0002);
|
||||
// This check prevents access to debug front controllers that are deployed by accident to production servers.
|
||||
// Feel free to remove this, extend it, or make something more sophisticated.
|
||||
if (isset($_SERVER['HTTP_CLIENT_IP'])
|
||||
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', 'fe80::1', '::1']) || php_sapi_name() === 'cli-server')
|
||||
|| !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], true) || PHP_SAPI === 'cli-server')
|
||||
) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
|
||||
}
|
||||
/**
|
||||
* @var Composer\Autoload\ClassLoader $loader
|
||||
*/
|
||||
//$loader = require __DIR__.'/../app/autoload.php';
|
||||
$loader = require_once __DIR__.'/../app/autoload.php';
|
||||
require_once __DIR__.'/../app/AppKernel.php';
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
Debug::enable();
|
||||
$kernel = new AppKernel('dev', true);
|
||||
//$kernel->loadClassCache();
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$kernel->loadClassCache();
|
||||
}
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
|
|
Loading…
Reference in a new issue