Compare commits

...

62 Commits

Author SHA1 Message Date
Alexey Eschenko 6e7b9d49b3 Merged in composer_update (pull request #10)
composer update. DoctrineCacheBundle removed (Doctrine settings may need adjustments).
2020-04-27 11:20:55 +00:00
Alexey Skobkin d185e75de2
Fixing legacy migration for MySQL strict mode. Doesn't really matter. 2020-04-27 13:33:46 +03:00
Alexey Skobkin c9a67d4fa5
composer update. DoctrineCacheBundle removed (Doctrine settings may need adjustments). 2020-04-27 13:04:49 +03:00
Alexey Eschenko 0599070376 Merged in symfony_upgrade (pull request #9)
composer require symfony/monolog-bundle
2019-01-24 21:37:39 +00:00
Alexey Skobkin 125a453fa2 composer require symfony/monolog-bundle 2019-01-25 00:37:05 +03:00
Alexey Eschenko 8ed402d649 Merged in symfony_upgrade (pull request #8)
Sentry parameters fixed.
2019-01-24 21:29:42 +00:00
Alexey Skobkin a061baec72 Sentry parameters fixed. 2019-01-25 00:29:10 +03:00
Alexey Eschenko bcd38de7f1 Merged in symfony_upgrade (pull request #7)
symfony/dotenv moved to require from require-dev.
2019-01-24 21:17:25 +00:00
Alexey Skobkin 1d6b3c35d5 symfony/dotenv moved to require from require-dev. 2019-01-25 00:14:05 +03:00
Alexey Eschenko c61b2b44af Merged in symfony_upgrade (pull request #6)
Temporarily adding config.platform.php and downgrading ocramius/proxy-manager to 2.1.
2019-01-24 21:08:37 +00:00
Alexey Skobkin 3a770adbc1 Temporarily adding config.platform.php and downgrading ocramius/proxy-manager to 2.1. 2019-01-25 00:05:54 +03:00
Alexey Eschenko 047307b441 Merged in symfony_upgrade (pull request #5)
Symfony upgrade
2019-01-24 20:24:07 +00:00
Alexey Skobkin d7dadacf0b composer require --dev symfony/phpunit-bridge 2019-01-24 23:17:34 +03:00
Alexey Skobkin 4063461347 Doctrine Migrations config fixed. 2019-01-24 23:09:58 +03:00
Alexey Skobkin 13c3f9c660 .gitignore optimized. Ignored files removed from index. 2019-01-24 21:36:25 +03:00
Alexey Skobkin 11b4903cf1 Redundant import removed. 2019-01-20 07:13:52 +03:00
Alexey Skobkin 969fea6eb3 Refactoring for symfony/flex. It finally works. 2019-01-20 07:11:30 +03:00
Alexey Skobkin 713099333c More deps reinstall. 2019-01-20 05:55:58 +03:00
Alexey Skobkin c9047ae0a9 Deps reinstall. Refactoring. 2019-01-20 05:50:09 +03:00
Alexey Skobkin 6a95bbee34 Deps reinstall, config fixes, cleaning. 2019-01-20 05:13:32 +03:00
Alexey Skobkin da13c321fe Symfony update to 4.2 and Flex. File hierarchy updated according to Flex. Deps reinstall and remaining refactoring are needed. 2019-01-20 04:52:57 +03:00
Alexey Skobkin 95c652e4d6 Missing bundle fix in kernel. 2019-01-20 02:42:01 +03:00
Alexey Skobkin c88cad6c14 composer update sensio/framework-extra-bundle (v3.0.29 => v5.2.4) 2019-01-20 02:39:06 +03:00
Alexey Skobkin 50b046978b composer remove sensio/distribution-bundle 2019-01-20 02:33:37 +03:00
Alexey Skobkin 6ab62632a3 composer update ocramius/proxy-manager 2019-01-20 02:32:50 +03:00
Alexey Eschenko 33d0e8032d Merged in sentry_logging (pull request #4)
Sentry logging support added.
2019-01-19 18:56:23 +00:00
Alexey Skobkin 460cb10d71 Sentry logging support added. 2019-01-19 21:54:52 +03:00
Alexey Eschenko a086eeb286 Merged in upgrade (pull request #3)
Upgrade
2019-01-19 18:49:07 +00:00
Alexey Skobkin a5af1ac1f7 Fix LoadLanguages fixture. Language entity refactored. 2019-01-19 21:45:22 +03:00
Alexey Skobkin d1e7b360e9 Migrations up() and down() signatures fixed according to 2.0.0 changes. 2019-01-19 21:38:41 +03:00
Alexey Skobkin 6d7cc2c05d Migrations fixed due to 2.0.0 changes. 2019-01-19 21:35:36 +03:00
Alexey Skobkin 6c2da98b59 Entrypoints updated according to symfony 3.4 state. 2019-01-19 21:32:32 +03:00
Alexey Skobkin b3094fe2cb Swiftmailer config removed from config_dev.yml and config_test.yml. 2019-01-19 21:28:59 +03:00
Alexey Skobkin ba788e7746 Many upgrade changes. Templating system refactored. Routing cleaned out. Many thingls simplified. 2019-01-19 21:26:28 +03:00
Alexey Skobkin 83ac9fda67 composer require php version updated to 7.1.0. 2019-01-19 21:01:34 +03:00
Alexey Skobkin 7f58d12706 CopypasteController removed to PasteController. 2019-01-19 20:59:09 +03:00
Alexey Skobkin 9bdc423af2 composer require symfony/web-server-bundle ^3.4 --dev 2019-01-19 20:52:35 +03:00
Alexey Skobkin 5713af046f composer update symfony/symfony (v3.2.14 => v3.4.21), symfony/polyfill-apcu (v1.10.0), psr/simple-cache (1.0.1), psr/link (1.0.0), psr/container (1.0.0), fig/link-util (1.0.0), doctrine/migrations (v1.5.0 => v2.0.0), doctrine/doctrine-cache-bundle (1.3.2 => 1.3.5), doctrine/doctrine-migrations-bundle (v1.2.1 => v2.0.0), symfony/monolog-bundle (2.11.3 => v3.3.1). 2019-01-19 20:41:26 +03:00
Alexey Skobkin 843c6b154c composer update 2019-01-19 20:36:47 +03:00
Alexey Skobkin 2d763df685 composer update doctrine/orm (also stabilizing package versions and sorting them alphabetically) 2019-01-19 20:34:48 +03:00
Alexey Skobkin ca40acee8b require-dev section removed from composer.json. 2019-01-19 20:25:17 +03:00
Alexey Skobkin 5a819777c3 composer remove symfony/phpunit-bridge phpunit/phpunit 2019-01-19 20:24:49 +03:00
Alexey Skobkin fddc706755 composer remove sensio/generator-bundle 2019-01-19 20:23:33 +03:00
Alexey Skobkin 3341f4fcab composer remove symfony/polyfill-apcu. 2019-01-19 19:48:18 +03:00
Alexey Skobkin 8405a08922 composer remove symfony/swiftmailer-bundle. 2019-01-19 19:46:46 +03:00
Alexey Skobkin 3330c433d4 app/console and web/app.php updated. 2016-12-19 03:36:48 +03:00
Alexey Skobkin fb6344d407 composer update (Symfony 3.2, Doctrine 2.5, etc) 2016-12-19 03:23:45 +03:00
Alexey Skobkin ee887d8528 Fake captcha bug fixed. 2016-12-19 03:23:00 +03:00
Alexey Skobkin ab8c53da07 Application refactoring according to Symfony's UPGRADE-2.8.md 2016-12-19 02:18:28 +03:00
Alexey Skobkin e716460405 composer update (symfony version changed to 2.8.*) 2016-12-19 01:53:59 +03:00
Alexey Skobkin 7879cb1029 composer update. Security updates. 2016-12-19 01:50:16 +03:00
Alexey Skobkin 91628a49da Fix #4. BraincraftedBootstrapBundle removed. Some other dependencies removed too. 2016-12-19 01:37:27 +03:00
Alexey Skobkin 7a53b1c927 Node fix. 2016-12-18 03:17:05 +03:00
Alexey Skobkin b38599c747 Preparing for Codeship CI. 2016-12-18 02:47:53 +03:00
Alexey Skobkin 07126b5586 New form type which is not captcha really. Bugfix for exception. 2015-10-14 06:53:54 +03:00
Alexey Skobkin bec53995a0 new umask(). 2015-10-05 04:50:10 +03:00
Alexey Skobkin 40559e3eab composer update. 2015-10-05 04:44:25 +03:00
Alexey Skobkin 893af94671 Symfony stable branch. 2015-10-05 04:39:12 +03:00
Alexey Skobkin 6819888c24 DoctrineMigrationsBundle composer.json fix. 2015-10-05 04:36:09 +03:00
Alexey Skobkin 3cc51ab872 Composer update (security fix and others). 2015-05-28 04:22:59 +03:00
Alexey Skobkin 434119e083 Small fix. 2015-05-28 04:03:38 +03:00
Alexey Skobkin 3cf28a612f Cron cleaning fix. 2015-03-16 04:06:24 +03:00
112 changed files with 6713 additions and 3269 deletions

21
.env.dist Normal file
View File

@ -0,0 +1,21 @@
# This file is a "template" of which env vars need to be defined for your application
# Copy this file to .env file for development, create environment variables when deploying to production
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=xxx
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS=localhost,example.com
###< symfony/framework-bundle ###
###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL=postgres://$PGUSER:$PGPASSWORD@127.0.0.1:5436/test?application_name=point_tools
###< doctrine/doctrine-bundle ###
###> sentry/sentry-symfony ###
SENTRY_DSN=
###< sentry/sentry-symfony ###

4
.env.test Normal file
View File

@ -0,0 +1,4 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='s$cretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999

29
.gitignore vendored
View File

@ -1,14 +1,19 @@
/web/bundles/
/app/bootstrap.php.cache
/app/cache/*
/app/config/parameters.yml
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
/app/phpunit.xml
/build/
/.idea/
/.env
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/public/bundles/
/var/
/vendor/
/bin/
/composer.phar
###< symfony/framework-bundle ###
/nbproject/
###> symfony/web-server-bundle ###
/.web-server-pid
###< symfony/web-server-bundle ###
###> symfony/phpunit-bridge ###
.phpunit
/phpunit.xml
###< symfony/phpunit-bridge ###

View File

@ -1,17 +1,8 @@
```shell
npm install -g less
```
...
```shell
php app/console braincrafted:bootstrap:install
```
...
[![Codeship Status for skobkin/copypaste2](https://app.codeship.com/projects/7e83eb30-a6de-0134-240b-6af82c0549e8/status?branch=master)](https://app.codeship.com/projects/191097)
[![codecov](https://codecov.io/bb/skobkin/copypaste2/branch/master/graph/badge.svg?token=cRaWwcOWdB)](https://codecov.io/bb/skobkin/copypaste2)
```shell
composer install
php app/console assets:install web --symlink
php app/console assetic:dump
```

View File

@ -1,7 +0,0 @@
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>

View File

@ -1,9 +0,0 @@
<?php
require_once __DIR__.'/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
class AppCache extends HttpCache
{
}

View File

@ -1,40 +0,0 @@
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new DT\Bundle\GeshiBundle\DTGeshiBundle(),
new Braincrafted\Bundle\BootstrapBundle\BraincraftedBootstrapBundle(),
new Skobkin\Bundle\CopyPasteBundle\SkobkinCopyPasteBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}

View File

@ -1,23 +0,0 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20150305184842 extends AbstractMigration
{
public function up(Schema $schema)
{
$this->addSql('UPDATE copypastes SET date_expire=NULL WHERE date_expire=\'0000-00-00 00:00:00\'');
}
public function down(Schema $schema)
{
$this->addSql('UPDATE copypastes SET date_expire=\'0000-00-00 00:00:00\' WHERE date_expire=NULL');
}
}

View File

@ -1,739 +0,0 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Users of PHP 5.2 should be able to run the requirements checks.
* This is why the file and all classes must be compatible with PHP 5.2+
* (e.g. not using namespaces and closures).
*
* ************** CAUTION **************
*
* DO NOT EDIT THIS FILE as it will be overridden by Composer as part of
* the installation/update process. The original file resides in the
* SensioDistributionBundle.
*
* ************** CAUTION **************
*/
/**
* Represents a single PHP requirement, e.g. an installed extension.
* It can be a mandatory requirement or an optional recommendation.
* There is a special subclass, named PhpIniRequirement, to check a php.ini configuration.
*
* @author Tobias Schultze <http://tobion.de>
*/
class Requirement
{
private $fulfilled;
private $testMessage;
private $helpText;
private $helpHtml;
private $optional;
/**
* Constructor that initializes the requirement.
*
* @param bool $fulfilled Whether the requirement is fulfilled
* @param string $testMessage The message for testing the requirement
* @param string $helpHtml The help text formatted in HTML for resolving the problem
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
* @param bool $optional Whether this is only an optional recommendation not a mandatory requirement
*/
public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false)
{
$this->fulfilled = (bool) $fulfilled;
$this->testMessage = (string) $testMessage;
$this->helpHtml = (string) $helpHtml;
$this->helpText = null === $helpText ? strip_tags($this->helpHtml) : (string) $helpText;
$this->optional = (bool) $optional;
}
/**
* Returns whether the requirement is fulfilled.
*
* @return bool true if fulfilled, otherwise false
*/
public function isFulfilled()
{
return $this->fulfilled;
}
/**
* Returns the message for testing the requirement.
*
* @return string The test message
*/
public function getTestMessage()
{
return $this->testMessage;
}
/**
* Returns the help text for resolving the problem
*
* @return string The help text
*/
public function getHelpText()
{
return $this->helpText;
}
/**
* Returns the help text formatted in HTML.
*
* @return string The HTML help
*/
public function getHelpHtml()
{
return $this->helpHtml;
}
/**
* Returns whether this is only an optional recommendation and not a mandatory requirement.
*
* @return bool true if optional, false if mandatory
*/
public function isOptional()
{
return $this->optional;
}
}
/**
* Represents a PHP requirement in form of a php.ini configuration.
*
* @author Tobias Schultze <http://tobion.de>
*/
class PhpIniRequirement extends Requirement
{
/**
* Constructor that initializes the requirement.
*
* @param string $cfgName The configuration name used for ini_get()
* @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false,
or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
* @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
* @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived)
* @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived)
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
* @param bool $optional Whether this is only an optional recommendation not a mandatory requirement
*/
public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false)
{
$cfgValue = ini_get($cfgName);
if (is_callable($evaluation)) {
if (null === $testMessage || null === $helpHtml) {
throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.');
}
$fulfilled = call_user_func($evaluation, $cfgValue);
} else {
if (null === $testMessage) {
$testMessage = sprintf('%s %s be %s in php.ini',
$cfgName,
$optional ? 'should' : 'must',
$evaluation ? 'enabled' : 'disabled'
);
}
if (null === $helpHtml) {
$helpHtml = sprintf('Set <strong>%s</strong> to <strong>%s</strong> in php.ini<a href="#phpini">*</a>.',
$cfgName,
$evaluation ? 'on' : 'off'
);
}
$fulfilled = $evaluation == $cfgValue;
}
parent::__construct($fulfilled || ($approveCfgAbsence && false === $cfgValue), $testMessage, $helpHtml, $helpText, $optional);
}
}
/**
* A RequirementCollection represents a set of Requirement instances.
*
* @author Tobias Schultze <http://tobion.de>
*/
class RequirementCollection implements IteratorAggregate
{
private $requirements = array();
/**
* Gets the current RequirementCollection as an Iterator.
*
* @return Traversable A Traversable interface
*/
public function getIterator()
{
return new ArrayIterator($this->requirements);
}
/**
* Adds a Requirement.
*
* @param Requirement $requirement A Requirement instance
*/
public function add(Requirement $requirement)
{
$this->requirements[] = $requirement;
}
/**
* Adds a mandatory requirement.
*
* @param bool $fulfilled Whether the requirement is fulfilled
* @param string $testMessage The message for testing the requirement
* @param string $helpHtml The help text formatted in HTML for resolving the problem
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
*/
public function addRequirement($fulfilled, $testMessage, $helpHtml, $helpText = null)
{
$this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, false));
}
/**
* Adds an optional recommendation.
*
* @param bool $fulfilled Whether the recommendation is fulfilled
* @param string $testMessage The message for testing the recommendation
* @param string $helpHtml The help text formatted in HTML for resolving the problem
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
*/
public function addRecommendation($fulfilled, $testMessage, $helpHtml, $helpText = null)
{
$this->add(new Requirement($fulfilled, $testMessage, $helpHtml, $helpText, true));
}
/**
* Adds a mandatory requirement in form of a php.ini configuration.
*
* @param string $cfgName The configuration name used for ini_get()
* @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false,
or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
* @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
* @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived)
* @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived)
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
*/
public function addPhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null)
{
$this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, false));
}
/**
* Adds an optional recommendation in form of a php.ini configuration.
*
* @param string $cfgName The configuration name used for ini_get()
* @param bool|callback $evaluation Either a boolean indicating whether the configuration should evaluate to true or false,
or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement
* @param bool $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false.
This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin.
Example: You require a config to be true but PHP later removes this config and defaults it to true internally.
* @param string $testMessage The message for testing the requirement (when null and $evaluation is a boolean a default message is derived)
* @param string $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a boolean a default help is derived)
* @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags)
*/
public function addPhpIniRecommendation($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null)
{
$this->add(new PhpIniRequirement($cfgName, $evaluation, $approveCfgAbsence, $testMessage, $helpHtml, $helpText, true));
}
/**
* Adds a requirement collection to the current set of requirements.
*
* @param RequirementCollection $collection A RequirementCollection instance
*/
public function addCollection(RequirementCollection $collection)
{
$this->requirements = array_merge($this->requirements, $collection->all());
}
/**
* Returns both requirements and recommendations.
*
* @return array Array of Requirement instances
*/
public function all()
{
return $this->requirements;
}
/**
* Returns all mandatory requirements.
*
* @return array Array of Requirement instances
*/
public function getRequirements()
{
$array = array();
foreach ($this->requirements as $req) {
if (!$req->isOptional()) {
$array[] = $req;
}
}
return $array;
}
/**
* Returns the mandatory requirements that were not met.
*
* @return array Array of Requirement instances
*/
public function getFailedRequirements()
{
$array = array();
foreach ($this->requirements as $req) {
if (!$req->isFulfilled() && !$req->isOptional()) {
$array[] = $req;
}
}
return $array;
}
/**
* Returns all optional recommendations.
*
* @return array Array of Requirement instances
*/
public function getRecommendations()
{
$array = array();
foreach ($this->requirements as $req) {
if ($req->isOptional()) {
$array[] = $req;
}
}
return $array;
}
/**
* Returns the recommendations that were not met.
*
* @return array Array of Requirement instances
*/
public function getFailedRecommendations()
{
$array = array();
foreach ($this->requirements as $req) {
if (!$req->isFulfilled() && $req->isOptional()) {
$array[] = $req;
}
}
return $array;
}
/**
* Returns whether a php.ini configuration is not correct.
*
* @return bool php.ini configuration problem?
*/
public function hasPhpIniConfigIssue()
{
foreach ($this->requirements as $req) {
if (!$req->isFulfilled() && $req instanceof PhpIniRequirement) {
return true;
}
}
return false;
}
/**
* Returns the PHP configuration file (php.ini) path.
*
* @return string|false php.ini file path
*/
public function getPhpIniConfigPath()
{
return get_cfg_var('cfg_file_path');
}
}
/**
* This class specifies all requirements and optional recommendations that
* are necessary to run the Symfony Standard Edition.
*
* @author Tobias Schultze <http://tobion.de>
* @author Fabien Potencier <fabien@symfony.com>
*/
class SymfonyRequirements extends RequirementCollection
{
const REQUIRED_PHP_VERSION = '5.3.3';
/**
* Constructor that initializes the requirements.
*/
public function __construct()
{
/* mandatory requirements follow */
$installedPhpVersion = phpversion();
$this->addRequirement(
version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>='),
sprintf('PHP version must be at least %s (%s installed)', self::REQUIRED_PHP_VERSION, $installedPhpVersion),
sprintf('You are running PHP version "<strong>%s</strong>", but Symfony needs at least PHP "<strong>%s</strong>" to run.
Before using Symfony, upgrade your PHP installation, preferably to the latest version.',
$installedPhpVersion, self::REQUIRED_PHP_VERSION),
sprintf('Install PHP %s or newer (installed version is %s)', self::REQUIRED_PHP_VERSION, $installedPhpVersion)
);
$this->addRequirement(
version_compare($installedPhpVersion, '5.3.16', '!='),
'PHP version must not be 5.3.16 as Symfony won\'t work properly with it',
'Install PHP 5.3.17 or newer (or downgrade to an earlier PHP version)'
);
$this->addRequirement(
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.'
);
$cacheDir = is_dir(__DIR__.'/../var/cache') ? __DIR__.'/../var/cache' : __DIR__.'/cache';
$this->addRequirement(
is_writable($cacheDir),
'app/cache/ or var/cache/ directory must be writable',
'Change the permissions of either "<strong>app/cache/</strong>" or "<strong>var/cache/</strong>" directory so that the web server can write into it.'
);
$logsDir = is_dir(__DIR__.'/../var/logs') ? __DIR__.'/../var/logs' : __DIR__.'/logs';
$this->addRequirement(
is_writable($logsDir),
'app/logs/ or var/logs/ directory must be writable',
'Change the permissions of either "<strong>app/logs/</strong>" or "<strong>var/logs/</strong>" directory so that the web server can write into it.'
);
$this->addPhpIniRequirement(
'date.timezone', true, false,
'date.timezone setting must be set',
'Set the "<strong>date.timezone</strong>" setting in php.ini<a href="#phpini">*</a> (like Europe/Paris).'
);
if (version_compare($installedPhpVersion, self::REQUIRED_PHP_VERSION, '>=')) {
$timezones = array();
foreach (DateTimeZone::listAbbreviations() as $abbreviations) {
foreach ($abbreviations as $abbreviation) {
$timezones[$abbreviation['timezone_id']] = true;
}
}
$this->addRequirement(
isset($timezones[@date_default_timezone_get()]),
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>.'
);
}
$this->addRequirement(
function_exists('json_encode'),
'json_encode() must be available',
'Install and enable the <strong>JSON</strong> extension.'
);
$this->addRequirement(
function_exists('session_start'),
'session_start() must be available',
'Install and enable the <strong>session</strong> extension.'
);
$this->addRequirement(
function_exists('ctype_alpha'),
'ctype_alpha() must be available',
'Install and enable the <strong>ctype</strong> extension.'
);
$this->addRequirement(
function_exists('token_get_all'),
'token_get_all() must be available',
'Install and enable the <strong>Tokenizer</strong> extension.'
);
$this->addRequirement(
function_exists('simplexml_import_dom'),
'simplexml_import_dom() must be available',
'Install and enable the <strong>SimpleXML</strong> extension.'
);
if (function_exists('apc_store') && ini_get('apc.enabled')) {
if (version_compare($installedPhpVersion, '5.4.0', '>=')) {
$this->addRequirement(
version_compare(phpversion('apc'), '3.1.13', '>='),
'APC version must be at least 3.1.13 when using PHP 5.4',
'Upgrade your <strong>APC</strong> extension (3.1.13+).'
);
} else {
$this->addRequirement(
version_compare(phpversion('apc'), '3.0.17', '>='),
'APC version must be at least 3.0.17',
'Upgrade your <strong>APC</strong> extension (3.0.17+).'
);
}
}
$this->addPhpIniRequirement('detect_unicode', false);
if (extension_loaded('suhosin')) {
$this->addPhpIniRequirement(
'suhosin.executor.include.whitelist',
create_function('$cfgValue', 'return false !== stripos($cfgValue, "phar");'),
false,
'suhosin.executor.include.whitelist must be configured correctly in php.ini',
'Add "<strong>phar</strong>" to <strong>suhosin.executor.include.whitelist</strong> in php.ini<a href="#phpini">*</a>.'
);
}
if (extension_loaded('xdebug')) {
$this->addPhpIniRequirement(
'xdebug.show_exception_trace', false, true
);
$this->addPhpIniRequirement(
'xdebug.scream', false, true
);
$this->addPhpIniRecommendation(
'xdebug.max_nesting_level',
create_function('$cfgValue', 'return $cfgValue > 100;'),
true,
'xdebug.max_nesting_level should be above 100 in php.ini',
'Set "<strong>xdebug.max_nesting_level</strong>" to e.g. "<strong>250</strong>" in php.ini<a href="#phpini">*</a> to stop Xdebug\'s infinite recursion protection erroneously throwing a fatal error in your project.'
);
}
$pcreVersion = defined('PCRE_VERSION') ? (float) PCRE_VERSION : null;
$this->addRequirement(
null !== $pcreVersion,
'PCRE extension must be available',
'Install the <strong>PCRE</strong> extension (version 8.0+).'
);
if (extension_loaded('mbstring')) {
$this->addPhpIniRequirement(
'mbstring.func_overload',
create_function('$cfgValue', 'return (int) $cfgValue === 0;'),
true,
'string functions should not be overloaded',
'Set "<strong>mbstring.func_overload</strong>" to <strong>0</strong> in php.ini<a href="#phpini">*</a> to disable function overloading by the mbstring extension.'
);
}
/* optional recommendations follow */
$this->addRecommendation(
file_get_contents(__FILE__) === file_get_contents(__DIR__.'/../vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/skeleton/app/SymfonyRequirements.php'),
'Requirements file should be up-to-date',
'Your requirements file is outdated. Run composer install and re-check your configuration.'
);
$this->addRecommendation(
version_compare($installedPhpVersion, '5.3.4', '>='),
'You should use at least PHP 5.3.4 due to PHP bug #52083 in earlier versions',
'Your project might malfunction randomly due to PHP bug #52083 ("Notice: Trying to get property of non-object"). Install PHP 5.3.4 or newer.'
);
$this->addRecommendation(
version_compare($installedPhpVersion, '5.3.8', '>='),
'When using annotations you should have at least PHP 5.3.8 due to PHP bug #55156',
'Install PHP 5.3.8 or newer if your project uses annotations.'
);
$this->addRecommendation(
version_compare($installedPhpVersion, '5.4.0', '!='),
'You should not use PHP 5.4.0 due to the PHP bug #61453',
'Your project might not work properly due to the PHP bug #61453 ("Cannot dump definitions which have method calls"). Install PHP 5.4.1 or newer.'
);
$this->addRecommendation(
version_compare($installedPhpVersion, '5.4.11', '>='),
'When using the logout handler from the Symfony Security Component, you should have at least PHP 5.4.11 due to PHP bug #63379 (as a workaround, you can also set invalidate_session to false in the security logout handler configuration)',
'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.'
);
$this->addRecommendation(
(version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<'))
||
version_compare($installedPhpVersion, '5.4.8', '>='),
'You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909',
'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.'
);
if (null !== $pcreVersion) {
$this->addRecommendation(
$pcreVersion >= 8.0,
sprintf('PCRE extension should be at least version 8.0 (%s installed)', $pcreVersion),
'<strong>PCRE 8.0+</strong> is preconfigured in PHP since 5.3.2 but you are using an outdated version of it. Symfony probably works anyway but it is recommended to upgrade your PCRE extension.'
);
}
$this->addRecommendation(
class_exists('DomDocument'),
'PHP-DOM and PHP-XML modules should be installed',
'Install and enable the <strong>PHP-DOM</strong> and the <strong>PHP-XML</strong> modules.'
);
$this->addRecommendation(
function_exists('mb_strlen'),
'mb_strlen() should be available',
'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',
'Install and enable the <strong>XML</strong> extension.'
);
$this->addRecommendation(
function_exists('filter_var'),
'filter_var() should be available',
'Install and enable the <strong>filter</strong> extension.'
);
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->addRecommendation(
function_exists('posix_isatty'),
'posix_isatty() should be available',
'Install and enable the <strong>php_posix</strong> extension (used to colorize the CLI output).'
);
}
$this->addRecommendation(
class_exists('Locale'),
'intl extension should be available',
'Install and enable the <strong>intl</strong> extension (used for validators).'
);
if (class_exists('Collator')) {
$this->addRecommendation(
null !== new Collator('fr_FR'),
'intl extension should be correctly configured',
'The intl extension does not behave properly. This problem is typical on PHP 5.3.X x64 WIN builds.'
);
}
if (class_exists('Locale')) {
if (defined('INTL_ICU_VERSION')) {
$version = INTL_ICU_VERSION;
} else {
$reflector = new ReflectionExtension('intl');
ob_start();
$reflector->info();
$output = strip_tags(ob_get_clean());
preg_match('/^ICU version +(?:=> )?(.*)$/m', $output, $matches);
$version = $matches[1];
}
$this->addRecommendation(
version_compare($version, '4.0', '>='),
'intl ICU version should be at least 4+',
'Upgrade your <strong>intl</strong> extension with a newer ICU version (4+).'
);
}
$accelerator =
(extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
||
(extension_loaded('apc') && ini_get('apc.enabled'))
||
(extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable'))
||
(extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
||
(extension_loaded('xcache') && ini_get('xcache.cacher'))
||
(extension_loaded('wincache') && ini_get('wincache.ocenabled'))
;
$this->addRecommendation(
$accelerator,
'a PHP accelerator should be installed',
'Install and/or enable a <strong>PHP accelerator</strong> (highly recommended).'
);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$this->addRecommendation(
$this->getRealpathCacheSize() > 1000,
'realpath_cache_size should be above 1024 in php.ini',
'Set "<strong>realpath_cache_size</strong>" to e.g. "<strong>1024</strong>" in php.ini<a href="#phpini">*</a> to improve performance on windows.'
);
}
$this->addPhpIniRecommendation('short_open_tag', false);
$this->addPhpIniRecommendation('magic_quotes_gpc', false, true);
$this->addPhpIniRecommendation('register_globals', false, true);
$this->addPhpIniRecommendation('session.auto_start', false);
$this->addRecommendation(
class_exists('PDO'),
'PDO should be installed',
'Install <strong>PDO</strong> (mandatory for Doctrine).'
);
if (class_exists('PDO')) {
$drivers = PDO::getAvailableDrivers();
$this->addRecommendation(
count($drivers) > 0,
sprintf('PDO should have some drivers installed (currently available: %s)', count($drivers) ? implode(', ', $drivers) : 'none'),
'Install <strong>PDO drivers</strong> (mandatory for Doctrine).'
);
}
}
/**
* Loads realpath_cache_size from php.ini and converts it to int.
*
* (e.g. 16k is converted to 16384 int)
*
* @return int
*/
protected function getRealpathCacheSize()
{
$size = ini_get('realpath_cache_size');
$size = trim($size);
$unit = strtolower(substr($size, -1, 1));
switch ($unit) {
case 'g':
return $size * 1024 * 1024 * 1024;
case 'm':
return $size * 1024 * 1024;
case 'k':
return $size * 1024;
default:
return (int) $size;
}
}
}

View File

@ -1,13 +0,0 @@
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Composer\Autoload\ClassLoader;
/**
* @var ClassLoader $loader
*/
$loader = require __DIR__.'/../vendor/autoload.php';
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
return $loader;

View File

@ -1,142 +0,0 @@
<?php
require_once dirname(__FILE__).'/SymfonyRequirements.php';
$lineSize = 70;
$symfonyRequirements = new SymfonyRequirements();
$iniPath = $symfonyRequirements->getPhpIniConfigPath();
echo_title('Symfony2 Requirements Checker');
echo '> PHP is using the following php.ini file:'.PHP_EOL;
if ($iniPath) {
echo_style('green', ' '.$iniPath);
} else {
echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!');
}
echo PHP_EOL.PHP_EOL;
echo '> Checking Symfony requirements:'.PHP_EOL.' ';
$messages = array();
foreach ($symfonyRequirements->getRequirements() as $req) {
/** @var $req Requirement */
if ($helpText = get_error_message($req, $lineSize)) {
echo_style('red', 'E');
$messages['error'][] = $helpText;
} else {
echo_style('green', '.');
}
}
$checkPassed = empty($messages['error']);
foreach ($symfonyRequirements->getRecommendations() as $req) {
if ($helpText = get_error_message($req, $lineSize)) {
echo_style('yellow', 'W');
$messages['warning'][] = $helpText;
} else {
echo_style('green', '.');
}
}
if ($checkPassed) {
echo_block('success', 'OK', 'Your system is ready to run Symfony2 projects', true);
} else {
echo_block('error', 'ERROR', 'Your system is not ready to run Symfony2 projects', true);
echo_title('Fix the following mandatory requirements', 'red');
foreach ($messages['error'] as $helpText) {
echo ' * '.$helpText.PHP_EOL;
}
}
if (!empty($messages['warning'])) {
echo_title('Optional recommendations to improve your setup', 'yellow');
foreach ($messages['warning'] as $helpText) {
echo ' * '.$helpText.PHP_EOL;
}
}
echo PHP_EOL;
echo_style('title', 'Note');
echo ' The command console could use a different php.ini file'.PHP_EOL;
echo_style('title', '~~~~');
echo ' than the one used with your web server. To be on the'.PHP_EOL;
echo ' safe side, please check the requirements from your web'.PHP_EOL;
echo ' server using the ';
echo_style('yellow', 'web/config.php');
echo ' script.'.PHP_EOL;
echo PHP_EOL;
exit($checkPassed ? 0 : 1);
function get_error_message(Requirement $requirement, $lineSize)
{
if ($requirement->isFulfilled()) {
return;
}
$errorMessage = wordwrap($requirement->getTestMessage(), $lineSize - 3, PHP_EOL.' ').PHP_EOL;
$errorMessage .= ' > '.wordwrap($requirement->getHelpText(), $lineSize - 5, PHP_EOL.' > ').PHP_EOL;
return $errorMessage;
}
function echo_title($title, $style = null)
{
$style = $style ?: 'title';
echo PHP_EOL;
echo_style($style, $title.PHP_EOL);
echo_style($style, str_repeat('~', strlen($title)).PHP_EOL);
echo PHP_EOL;
}
function echo_style($style, $message)
{
// ANSI color codes
$styles = array(
'reset' => "\033[0m",
'red' => "\033[31m",
'green' => "\033[32m",
'yellow' => "\033[33m",
'error' => "\033[37;41m",
'success' => "\033[37;42m",
'title' => "\033[34m",
);
$supports = has_color_support();
echo($supports ? $styles[$style] : '').$message.($supports ? $styles['reset'] : '');
}
function echo_block($style, $title, $message)
{
$message = ' '.trim($message).' ';
$width = strlen($message);
echo PHP_EOL.PHP_EOL;
echo_style($style, str_repeat(' ', $width).PHP_EOL);
echo_style($style, str_pad(' ['.$title.']', $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_pad($message, $width, ' ', STR_PAD_RIGHT).PHP_EOL);
echo_style($style, str_repeat(' ', $width).PHP_EOL);
}
function has_color_support()
{
static $support;
if (null === $support) {
if (DIRECTORY_SEPARATOR == '\\') {
$support = false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI');
} else {
$support = function_exists('posix_isatty') && @posix_isatty(STDOUT);
}
}
return $support;
}

View File

@ -1,99 +0,0 @@
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
framework:
#esi: ~
translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']
#assets_version: SomeVersionScheme
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
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [ ]
#java: /usr/bin/java
filters:
less:
node: "%nodejs_executable%"
node_paths: %nodejs_paths%
apply_to: "\.less$"
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
braincrafted_bootstrap:
output_dir: bootstrap
assets_dir: %kernel.root_dir%/../vendor/twbs/bootstrap
jquery_path: %kernel.root_dir%/../vendor/components/jquery/jquery.js
less_filter: less
fonts_dir: %kernel.root_dir%/../web/bootstrap/fonts
auto_configure:
assetic: true
twig: true
knp_menu: true
knp_paginator: true
customize:
variables_file: ~
bootstrap_output: %kernel.root_dir%/Resources/less/bootstrap.less
bootstrap_template: BraincraftedBootstrapBundle:Bootstrap:bootstrap.less.twig
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
doctrine_migrations:
dir_name: %kernel.root_dir%/DoctrineMigrations
namespace: Application\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 }

View File

@ -1,48 +0,0 @@
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
bubble: false
verbosity_levels:
VERBOSITY_VERBOSE: INFO
VERBOSITY_VERY_VERBOSE: DEBUG
channels: ["!doctrine"]
console_very_verbose:
type: console
bubble: false
verbosity_levels:
VERBOSITY_VERBOSE: NOTICE
VERBOSITY_VERY_VERBOSE: NOTICE
VERBOSITY_DEBUG: DEBUG
channels: ["doctrine"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
assetic:
use_controller: true
#swiftmailer:
# delivery_address: me@example.com

View File

@ -1,25 +0,0 @@
imports:
- { resource: config.yml }
#framework:
# validation:
# cache: apc
#doctrine:
# orm:
# metadata_cache_driver: apc
# result_cache_driver: apc
# query_cache_driver: apc
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console

View File

@ -1,16 +0,0 @@
imports:
- { resource: config_dev.yml }
framework:
test: ~
session:
storage_id: session.storage.mock_file
profiler:
collect: false
web_profiler:
toolbar: false
intercept_redirects: false
swiftmailer:
disable_delivery: true

View File

@ -1,25 +0,0 @@
# This file is a "template" of what your parameters.yml file should look like
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
# 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
secret: ThisTokenIsNotSoSecretChangeIt
# Other stuff
nodejs_executable: /usr/bin/node
nodejs_paths: [/usr/lib/node_modules/]

View File

@ -1,4 +0,0 @@
skobkin_copy_paste:
resource: "@SkobkinCopyPasteBundle/Resources/config/routing.yml"
prefix: /

View File

@ -1,18 +0,0 @@
_wdt:
resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_errors:
resource: "@TwigBundle/Resources/config/routing/errors.xml"
prefix: /_error
_main:
resource: routing.yml

View File

@ -1,9 +0,0 @@
# Learn more about services, parameters and containers at
# http://symfony.com/doc/current/book/service_container.html
parameters:
# parameter_name: value
services:
# service_name:
# class: AppBundle\Directory\ClassName
# arguments: ["@another_service_name", "plain_value", "%parameter_name%"]

View File

@ -1,27 +0,0 @@
#!/usr/bin/env php
<?php
// 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#configuration-and-setup for more information
//umask(0000);
set_time_limit(0);
require_once __DIR__.'/bootstrap.php.cache';
require_once __DIR__.'/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
if ($debug) {
Debug::enable();
}
$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="bootstrap.php.cache"
>
<testsuites>
<testsuite name="Project Test Suite">
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
<directory>../src/*Bundle/Tests</directory>
</testsuite>
</testsuites>
<!--
<php>
<server name="KERNEL_DIR" value="/path/to/your/app/" />
</php>
-->
<filter>
<whitelist>
<directory>../src</directory>
<exclude>
<directory>../src/*Bundle/Resources</directory>
<directory>../src/*Bundle/Tests</directory>
<directory>../src/*/*Bundle/Resources</directory>
<directory>../src/*/*Bundle/Tests</directory>
<directory>../src/*/Bundle/*Bundle/Resources</directory>
<directory>../src/*/Bundle/*Bundle/Tests</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

28
bin/console Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
set_time_limit(0);
require dirname(__DIR__).'/vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}
$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}
if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);

1
bin/doctrine Symbolic link
View File

@ -0,0 +1 @@
../vendor/doctrine/orm/bin/doctrine

1
bin/doctrine-dbal Symbolic link
View File

@ -0,0 +1 @@
../vendor/doctrine/dbal/bin/doctrine-dbal

1
bin/doctrine-migrations Symbolic link
View File

@ -0,0 +1 @@
../vendor/doctrine/migrations/bin/doctrine-migrations

19
bin/phpunit Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env php
<?php
if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}
if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
}
if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
putenv('SYMFONY_PHPUNIT_REMOVE=');
}
if (false === getenv('SYMFONY_PHPUNIT_DIR')) {
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
}
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

1
bin/sentry Symbolic link
View File

@ -0,0 +1 @@
../vendor/sentry/sentry/bin/sentry

View File

@ -1,71 +1,73 @@
{
"name": "symfony/framework-standard-edition",
"name": "skobkin/copypaste",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"description": "Online code sharing app",
"autoload": {
"psr-0": { "": "src/", "SymfonyStandard": "app/" }
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"minimum-stability": "stable",
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.7.x-dev",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.4",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"doctrine/migrations": "1.0.*@dev",
"doctrine/doctrine-migrations-bundle": "2.1.*@dev",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"php": ">=7.1.0",
"doctrine/annotations": "^1.3",
"doctrine/doctrine-migrations-bundle": "^2.0",
"sensio/framework-extra-bundle": "^5.2",
"sentry/sentry-symfony": "^2.2",
"symfony/console": "^4.2",
"symfony/dotenv": "^4.2",
"symfony/finder": "^4.2",
"symfony/flex": "^1.1",
"symfony/form": "^4.2",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/security-bundle": "^4.2",
"symfony/translation": "^4.2",
"symfony/twig-bundle": "^4.2",
"symfony/validator": "^4.2",
"symfony/yaml": "^4.2",
"theodordiaconu/geshi": "dev-master",
"theodordiaconu/geshi-bundle" : "dev-master",
"braincrafted/bootstrap-bundle": "dev-master",
"twbs/bootstrap": "3.3.*@dev",
"components/jquery": "dev-master"
"theodordiaconu/geshi-bundle": "dev-master"
},"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.1",
"symfony/debug-pack": "^1.0",
"symfony/phpunit-bridge": "^4.2",
"symfony/profiler-pack": "^1.0",
"symfony/web-server-bundle": "^4.2"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
"conflict": {
"symfony/symfony": "*"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
"@auto-scripts"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
"@auto-scripts"
]
},
"config": {
"bin-dir": "bin"
"platform": {
"php": "7.1.23"
},
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.7-dev"
"symfony": {
"allow-contrib": false
}
}
}

6362
composer.lock generated

File diff suppressed because it is too large Load Diff

17
config/bootstrap.php Normal file
View File

@ -0,0 +1,17 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
$_SERVER += $env;
$_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
// load all the .env files
(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
}
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

17
config/bundles.php Normal file
View File

@ -0,0 +1,17 @@
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
DT\Bundle\GeshiBundle\DTGeshiBundle::class => ['all' => true],
Sentry\SentryBundle\SentryBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
];

View File

@ -0,0 +1,19 @@
framework:
cache:
# Put the unique name of your app here: the prefix seed
# is used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The app cache caches to the filesystem by default.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: ~

View File

@ -0,0 +1,4 @@
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"

View File

@ -0,0 +1,16 @@
services:
EasyCorp\EasyLog\EasyLogHandler:
public: false
arguments: ['%kernel.logs_dir%/%kernel.environment%.log']
#// FIXME: How to add this configuration automatically without messing up with the monolog configuration?
#monolog:
# handlers:
# buffered:
# type: buffer
# handler: easylog
# channels: ['!event']
# level: debug
# easylog:
# type: service
# id: EasyCorp\EasyLog\EasyLogHandler

View File

@ -0,0 +1,19 @@
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]

View File

@ -0,0 +1,10 @@
# src/AppBundle/Resources/config/dataFixture.yml
services:
_defaults:
tags: ['doctrine.fixture.orm']
autowire: true # if you need dependency injection, see next bullet point
bind:
$projectDir: '%kernel.project_dir%'
App\DataFixtures\ORM\:
resource: '%kernel.project_dir%/src/DataFixtures/ORM/*'

View File

@ -0,0 +1,3 @@
framework:
router:
strict_requirements: true

View File

@ -0,0 +1,6 @@
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler: { only_exceptions: false }

View File

@ -0,0 +1,18 @@
parameters:
env(DATABASE_URL): ''
doctrine:
dbal:
driver: 'mysqli'
url: '%env(resolve:DATABASE_URL)%'
charset: 'UTF8'
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
mappings:
App\Entity:
type: annotation
dir: '%kernel.project_dir%/src/Entity'
is_bundle: false
prefix: App\Entity
alias: App

View File

@ -0,0 +1,3 @@
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
namespace: DoctrineMigrations

View File

@ -0,0 +1,11 @@
framework:
#esi: ~
secret: '%env(APP_SECRET)%'
trusted_hosts: ~
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
php_errors:
log: true

View File

@ -0,0 +1,32 @@
doctrine:
orm:
auto_generate_proxy_classes: false
metadata_cache_driver:
type: service
id: doctrine.system_cache_provider
query_cache_driver:
type: service
id: doctrine.system_cache_provider
result_cache_driver:
type: service
id: doctrine.result_cache_provider
services:
doctrine.result_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.result_cache_pool'
doctrine.system_cache_provider:
class: Symfony\Component\Cache\DoctrineProvider
public: false
arguments:
- '@doctrine.system_cache_pool'
framework:
cache:
pools:
doctrine.result_cache_pool:
adapter: cache.app
doctrine.system_cache_pool:
adapter: cache.system

View File

@ -0,0 +1,25 @@
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_404s:
# regex: exclude all 404 errors from the logs
- ^/
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
deprecation:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.deprecations.log"
deprecation_filter:
type: filter
handler: deprecation
max_level: info
channels: ["php"]

View File

@ -0,0 +1,2 @@
sentry:
dsn: '%env(SENTRY_DSN)%'

View File

@ -0,0 +1,3 @@
framework:
router:
strict_requirements: ~

View File

@ -0,0 +1,3 @@
sensio_framework_extra:
router:
annotations: false

View File

@ -0,0 +1,3 @@
sentry:
options:
curl_method: async

View File

@ -0,0 +1,5 @@
#doctrine:
# dbal:
# driver: 'mysqli'
# url: '%env(resolve:DATABASE_URL)%'
# charset: 'UTF8'

View File

@ -0,0 +1,6 @@
framework:
test: ~
session:
storage_id: session.storage.mock_file
profiler:
collect: false

View File

@ -0,0 +1,7 @@
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]

View File

@ -0,0 +1,10 @@
# src/AppBundle/Resources/config/dataFixture.yml
services:
_defaults:
tags: ['doctrine.fixture.orm']
autowire: true # if you need dependency injection, see next bullet point
bind:
$projectDir: '%kernel.project_dir%'
App\DataFixtures\ORM\:
resource: '%kernel.project_dir%/src/DataFixtures/ORM/*'

View File

@ -0,0 +1,3 @@
framework:
router:
strict_requirements: true

View File

@ -0,0 +1,6 @@
web_profiler:
toolbar: false
intercept_redirects: false
framework:
profiler: { collect: false }

View File

@ -0,0 +1,7 @@
framework:
default_locale: '%locale%'
translator:
paths:
- '%kernel.project_dir%/translations'
fallbacks:
- '%locale%'

View File

@ -0,0 +1,6 @@
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
form_themes:
- 'bootstrap_3_layout.html.twig'
- 'Form/fields.html.twig'

View File

@ -0,0 +1,3 @@
framework:
validation:
email_validation_mode: html5

21
config/routes.yaml Normal file
View File

@ -0,0 +1,21 @@
paste_new:
path: /
defaults: { _controller: 'App\Controller\PasteController::newAction' }
paste_show_public:
path: /{id}
defaults: { _controller: 'App\Controller\PasteController::showAction', secret: null }
requirements:
id: \d+
paste_show_private:
path: /{id}/{secret}
defaults: { _controller: 'App\Controller\PasteController::showAction' }
requirements:
id: \d+
secret: \w{16}
paste_create:
path: /create
defaults: { _controller: 'App\Controller\PasteController::createAction' }
methods: POST

View File

@ -0,0 +1,3 @@
#controllers:
# resource: ../../src/Controller/
# type: annotation

View File

@ -0,0 +1,3 @@
_errors:
resource: '@TwigBundle/Resources/config/routing/errors.xml'
prefix: /_error

View File

@ -0,0 +1,7 @@
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler

28
config/services.yaml Normal file
View File

@ -0,0 +1,28 @@
# Learn more about services, parameters and containers at
# http://symfony.com/doc/current/book/service_container.html
parameters:
locale: 'ru'
container.dumper.inline_class_loader: true
services:
# 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
App\:
resource: '../src/*'
exclude: '../src/{DataFixtures,Entity,Migrations,Tests,Kernel.php}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
# Overriding old bundle service definition
DT\Bundle\GeshiBundle\Highlighter\HighlighterInterface:
class: DT\Bundle\GeshiBundle\Highlighter\GeshiHighlighter

31
phpunit.xml.dist Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="config/bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1" />
<env name="APP_ENV" value="test" />
<env name="SHELL_VERBOSITY" value="-1" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

27
public/index.php Normal file
View File

@ -0,0 +1,27 @@
<?php
use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
umask(0000);
Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

View File

@ -1,21 +1,30 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\Command;
namespace App\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Paste;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\EntityManager;
/**
* Deleting expired copypastes by Cron
*
* @author Alexey Skobkin
*/
class DropExpiredCopypastesCommand extends ContainerAwareCommand
class DropExpiredPasteCommand extends Command
{
/** @var EntityManagerInterface */
private $em;
public function __construct(EntityManagerInterface $em)
{
parent::__construct();
$this->em = $em;
}
protected function configure()
{
$this
@ -27,14 +36,14 @@ class DropExpiredCopypastesCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->write('Deleting expired entities...');
/* @var $em EntityManager */
$em = $this->getContainer()->get('doctrine')->getManager();
$queryBuilder = $em->createQueryBuilder()
->delete('SkobkinCopyPasteBundle:Copypaste c')
// @todo move to repository
$qb = $this->em->createQueryBuilder()
->delete(Paste::class, 'c')
->where('c.dateExpire < :now')
->andWhere('c.dateExpire IS NOT NULL')
->setParameter('now', new \DateTime());
$queryBuilder->getQuery()->execute();
$qb->getQuery()->execute();
$output->writeln('Done.');
}

View File

@ -0,0 +1,122 @@
<?php
namespace App\Controller;
use Doctrine\ORM\EntityManagerInterface;
use DT\Bundle\GeshiBundle\Highlighter\HighlighterInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\{Request, Response};
use App\Entity\Paste;
use App\Form\PasteType;
use \GeSHi\GeSHi;
class PasteController extends AbstractController
{
public function createAction(Request $request): Response
{
$paste = new Paste();
$form = $this->createCreateForm($paste);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// Check "captcha"
// @todo check internally in transformation or somewhere else
if (null === $form->get('captcha')->getData()) {
throw $this->createNotFoundException('This isn\'t the service you\'re spamming to.');
}
$em = $this->getDoctrine()->getManager();
if ($form->get('private')->getData()) {
// Private paste
$paste->setSecret(substr(md5($paste->getText()), 0, 16));
}
$expire = (int) $form->get('expire')->getData();
//var_dump($expire); exit();
if ($expire) {
$dateExpire = new \DateTime();
$dateExpire->add(new \DateInterval('PT' . $expire . 'S'));
$paste->setDateExpire($dateExpire);
}
$paste->setIp($request->getClientIp());
$em->persist($paste);
$em->flush();
if ($paste->isPrivate()) {
return $this->redirect($this->generateUrl('paste_show_private', ['id' => $paste->getId(), 'secret' => $paste->getSecret()]));
} else {
return $this->redirect($this->generateUrl('paste_show_public', ['id' => $paste->getId()]));
}
}
throw $this->createAccessDeniedException('Sorry :(');
}
public function newAction(): Response
{
$paste = new Paste();
$createForm = $this->createCreateForm($paste);
return $this->render('Paste/new.html.twig', [
'entity' => $paste,
'form_create' => $createForm->createView(),
]);
}
public function showAction(int $id, ?string $secret, EntityManagerInterface $em, HighlighterInterface $highlighter): Response
{
/* @var $paste \App\Entity\Paste */
$paste = $em->getRepository(Paste::class)->findOneBy([
'id' =>$id,
'secret' => $secret
]);
if (!$paste) {
throw $this->createNotFoundException('Unable to find copypaste.');
}
$editForm = $this->createCreateForm($paste);
$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('Paste/show.html.twig', [
'paste' => $paste,
'highlighted_text' => $highlightedCode,
'form_create' => $editForm->createView(),
]);
}
public function sidebarAction(): Response
{
$em = $this->getDoctrine()->getManager();
$pastes = $em->getRepository(Paste::class)->findBy(
['secret' => null],
['id' => 'DESC'],
// @todo move to the config
15
);
return $this->render('sidebar.html.twig', ['pastes' => $pastes]);
}
private function createCreateForm(Paste $entity): FormInterface
{
$form = $this->createForm(PasteType::class, $entity, [
'action' => $this->generateUrl('paste_create'),
'method' => 'POST',
]);
$form->add('submit', SubmitType::class, ['label' => 'Create']);
return $form;
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace App\DataFixtures\ORM;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Finder\Finder;
use App\Entity\Language;
class LoadLanguages extends Fixture
{
/** @var string */
private $projectDir;
public function __construct(string $projectDir)
{
$this->projectDir = $projectDir;
}
public function load(ObjectManager $manager)
{
$geshiPath = $this->projectDir.'/vendor/theodordiaconu/geshi/src/GeSHi/geshi';
$finder = new Finder();
$finder->files()->in($geshiPath);
// Fix constants
define('GESHI_CAPS_NO_CHANGE', true);
define('GESHI_COMMENTS', true);
define('GESHI_NEVER', true);
define('GESHI_SEARCH', true);
define('GESHI_REPLACE', true);
define('GESHI_MODIFIERS', true);
define('GESHI_BEFORE', true);
define('GESHI_AFTER', true);
define('GESHI_MAYBE', true);
define('GESHI_NUMBER_INT_BASIC', true);
define('GESHI_NUMBER_HEX_PREFIX_DOLLAR', true);
define('GESHI_NUMBER_BIN_PREFIX_PERCENT', true);
define('GESHI_NUMBER_FLT_NONSCI', true);
define('GESHI_NUMBER_HEX_PREFIX', true);
define('GESHI_NUMBER_FLT_SCI_ZERO', true);
define('GESHI_NUMBER_OCT_PREFIX', true);
define('GESHI_ALWAYS', true);
define('GESHI_CAPS_UPPER', true);
define('GESHI_NUMBER_FLT_NONSCI_F', true);
define('GESHI_NUMBER_FLT_SCI_SHORT', true);
define('GESHI_NUMBER_HEX_SUFFIX', true);
define('GESHI_NUMBER_INT_CSTYLE', true);
define('GESHI_NUMBER_BIN_PREFIX_0B', true);
define('GESHI_NUMBER_BIN_SUFFIX', true);
define('GESHI_NUMBER_OCT_SUFFIX', true);
define('GESHI_CLASS', true);
define('GESHI_NUMBER_OCT_PREFIX_0O', true);
define('GESHI_NUMBER_OCT_PREFIX_AT', true);
/* @var $file \SplFileInfo */
foreach ($finder as $file) {
include $geshiPath.DIRECTORY_SEPARATOR.$file->getRelativePathname();
$language = new Language(
$language_data['LANG_NAME'],
basename($file->getRelativePathname(), '.php')
);
$manager->persist($language);
}
$manager->flush();
}
}

View File

@ -1,12 +1,10 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\Entity;
namespace App\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,14 @@ class Language
*/
private $isEnabled;
public function __construct(string $name, string $code, bool $enabled = true)
{
$this->name = $name;
$this->code = $code;
$this->isEnabled = $enabled;
}
/**
* Get id
*
* @return integer
*/
public function getId()
public function getId(): int
{
return $this->id;
}
@ -70,91 +68,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;

View File

@ -1,20 +1,17 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\Entity;
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Copypaste
*
* @ORM\Table(name="copypastes", indexes={
* @ORM\Index(name="idx_expire", columns={"date_expire"})
* })
* @ORM\Entity
* @ORM\HasLifecycleCallbacks()
*/
class Copypaste
class Paste
{
/**
* @var integer
@ -90,242 +87,123 @@ class Copypaste
*/
private $secret = null;
/**
* @ORM\PrePersist
*/
public function prePersist()
public function __construct()
{
$this->datePublished = new \DateTime();
}
/**
* Get id
*
* @return integer
*/
public function getId()
public function getId(): int
{
return $this->id;
}
public function __toString()
{
return $this->id;
return (string) $this->id;
}
/**
* Set text
*
* @param string $text
* @return Paste
*/
public function setText($text)
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
/**
* Get text
*
* @return string
*/
public function getText()
public function getText(): ?string
{
return $this->text;
}
/**
* Set description
*
* @param string $description
* @return Paste
*/
public function setDescription($description)
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
/**
* Get code description
*
* @return string
*/
public function getDescription()
public function getDescription(): ?string
{
return $this->description;
}
/**
* Set language
*
* @param integer $language
* @return Paste
*/
public function setLanguage($language)
public function setLanguage(Language $language): self
{
$this->language = $language;
return $this;
}
/**
* Get language
*
* @return integer
*/
public function getLanguage()
public function getLanguage(): ?Language
{
return $this->language;
}
/**
* Set filename
*
* @param string $filename
* @return Paste
*/
public function setFilename($filename)
public function setFilename(string $filename): self
{
$this->fileName = $filename;
return $this;
}
/**
* Get filename
*
* @return string
*/
public function getFilename()
public function getFilename(): ?string
{
return $this->fileName;
}
/**
* Set author
*
* @param string $author
* @return Paste
*/
public function setAuthor($author)
public function setAuthor(string $author): self
{
$this->author = $author;
return $this;
}
/**
* Get author
*
* @return string
*/
public function getAuthor()
public function getAuthor(): ?string
{
return $this->author;
}
/**
* Set publication date
*
* @param \DateTime $datePublished
* @return Paste
*/
public function setDatePublished($datePublished)
{
$this->datePublished = $datePublished;
return $this;
}
/**
* Get publication date
*
* @return \DateTime
*/
public function getDatePublished()
public function getDatePublished(): \DateTime
{
return $this->datePublished;
}
/**
* Set expiration date
*
* @param \DateTime $dateExpire
* @return Paste
*/
public function setDateExpire($dateExpire)
public function setDateExpire(\DateTime $dateExpire): self
{
$this->dateExpire = $dateExpire;
return $this;
}
/**
* Get expiration date
*
* @return \DateTime
*/
public function getDateExpire()
public function getDateExpire(): ?\DateTime
{
return $this->dateExpire;
}
/**
* Set ip
*
* @param string $ip
* @return Paste
*/
public function setIp($ip)
public function setIp(string $ip): self
{
$this->ip = $ip;
return $this;
}
/**
* Get ip
*
* @return string
*/
public function getIp()
public function getIp(): string
{
return $this->ip;
}
/**
* Set secret
*
* @param string $secret
* @return Paste
*/
public function setSecret($secret)
public function setSecret(?string $secret): self
{
$this->secret = $secret;
return $this;
}
/**
* Get secret
*
* @return string
*/
public function getSecret()
public function getSecret(): ?string
{
return $this->secret;
}
/**
* Check if copypaste is private
*
* @return boolean
*/
public function isPrivate()
public function isPrivate(): bool
{
return ($this->secret === null) ? false : true;
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class FakeCaptchaType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'label' => false,
]);
}
public function getParent()
{
return HiddenType::class;
}
}

View File

@ -1,61 +1,60 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\Form;
namespace App\Form;
use App\Entity\{Paste, Language};
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\{CheckboxType, ChoiceType, TextareaType, TextType};
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
class CopypasteType extends AbstractType
class PasteType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('text', 'textarea', ['label' => 'paste_add_form_text'])
->add('description', 'textarea', [
->add('text', TextareaType::class, ['label' => 'paste_add_form_text'])
->add('description', TextareaType::class, [
'label' => 'paste_add_form_description',
'required' => false,
])
->add('fileName', 'text', [
->add('fileName', TextType::class, [
'label' => 'paste_add_form_file_name',
'required' => false,
])
->add('author', 'text', [
->add('author', TextType::class, [
'label' => 'paste_add_form_author',
'required' => false,
])
->add('expire', 'choice', [
->add('expire', ChoiceType::class, [
'label' => 'paste_add_form_expire',
'mapped' => false,
// @todo move to config
'choices' => [
300 => '5 minutes',
3600 => '1 hour',
10800 => '3 hours',
43200 => '12 hours',
86400 => '1 day',
604800 => '1 week',
2419200 => '1 month',
7257600 => '3 months',
14515200 => '6 months',
29030400 => '1 year',
0 => 'Never',
'5 minutes'=> 300,
'1 hour' => 3600,
'3 hours' => 10800,
'12 hours' => 43200,
'1 day' => 86400,
'1 week' => 604800,
'1 month' => 2419200,
'3 months' => 7257600,
'6 months' => 14515200,
'1 year' => 29030400,
'Never' => 0,
]
])
->add('private', 'checkbox', [
->add('private', CheckboxType::class, [
'label' => 'paste_add_form_private',
'required' => false,
'mapped' => false
])
->add('language', 'entity', [
->add('language', EntityType::class, [
'label' => 'paste_add_form_language',
'class' => 'Skobkin\Bundle\CopyPasteBundle\Entity\Language',
'class' => Language::class,
'query_builder' => function (EntityRepository $repo) {
/* @var $qb QueryBuilder */
return $repo->createQueryBuilder('lang')
@ -66,25 +65,17 @@ class CopypasteType extends AbstractType
},
//'preferred_choices' => []
])
->add('actions', 'form_actions')
->add('captcha', FakeCaptchaType::class, [
'mapped' => false,
'required' => true,
])
;
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => 'Skobkin\Bundle\CopyPasteBundle\Entity\Copypaste'
'data_class' => Paste::class
]);
}
/**
* @return string
*/
public function getName()
{
return 'skobkin_bundle_copypastebundle_copypaste';
}
}

39
src/Kernel.php Normal file
View File

@ -0,0 +1,39 @@
<?php
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function registerBundles()
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
yield new $class();
}
}
}
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
{
$container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
$container->setParameter('container.dumper.inline_class_loader', true);
$confDir = $this->getProjectDir().'/config';
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
}
protected function configureRoutes(RouteCollectionBuilder $routes)
{
$confDir = $this->getProjectDir().'/config';
$routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
}
}

View File

@ -1,8 +1,8 @@
<?php
namespace Application\Migrations;
namespace DoctrineMigrations;
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\'.');
@ -40,7 +40,7 @@ class Version20150302205121 extends AbstractMigration
`filename` varchar(128) CHARACTER SET utf8 NOT NULL COMMENT \'Filename\',
`name` varchar(48) CHARACTER SET utf8 NOT NULL COMMENT \'Author of quote name\',
`date_pub` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT \'Publish date\',
`date_exp` timestamp NOT NULL DEFAULT \'0000-00-00 00:00:00\' COMMENT \'Expire date\',
`date_exp` timestamp NOT NULL DEFAULT \'2020-01-01 00:00:00\' COMMENT \'Expire date\',
`ip` varchar(48) CHARACTER SET utf8 NOT NULL COMMENT \'IP\',
`secret` varchar(16) COLLATE utf8_unicode_ci NOT NULL COMMENT \'Paste secret\',
PRIMARY KEY (`id`),
@ -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\'.');

View File

@ -1,8 +1,8 @@
<?php
namespace Application\Migrations;
namespace DoctrineMigrations;
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\'.');

View File

@ -1,8 +1,8 @@
<?php
namespace Application\Migrations;
namespace DoctrineMigrations;
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\'.');

View File

@ -1,8 +1,8 @@
<?php
namespace Application\Migrations;
namespace DoctrineMigrations;
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');
}

View File

@ -0,0 +1,23 @@
<?php
namespace DoctrineMigrations;
use Doctrine\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20150305184842 extends AbstractMigration
{
public function up(Schema $schema): void
{
$this->addSql('UPDATE copypastes SET date_expire=NULL WHERE date_expire=\'2020-01-01 00:00:00\'');
}
public function down(Schema $schema): void
{
$this->addSql('UPDATE copypastes SET date_expire=\'2020-01-01 00:00:00\' WHERE date_expire=NULL');
}
}

View File

@ -1,8 +1,8 @@
<?php
namespace Application\Migrations;
namespace DoctrineMigrations;
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\'.');

0
src/Repository/.gitignore vendored Normal file
View File

View File

@ -1,154 +0,0 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
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
{
/**
* Creates a new Copypaste entity.
*
* @return Response
*/
public function createAction(Request $request)
{
$paste = new Copypaste();
$form = $this->createCreateForm($paste);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
if ($form->get('private')->getData()) {
// Private paste
$paste->setSecret(substr(md5($paste->getText()), 0, 16));
}
$expire = (int) $form->get('expire')->getData();
//var_dump($expire); exit();
if ($expire) {
$dateExpire = new \DateTime();
$dateExpire->add(new \DateInterval('PT' . $expire . 'S'));
$paste->setDateExpire($dateExpire);
}
$paste->setIp($request->getClientIp());
$em->persist($paste);
$em->flush();
if ($paste->isPrivate()) {
return $this->redirect($this->generateUrl('copypaste_show_private', ['id' => $paste->getId(), 'secret' => $paste->getSecret()]));
} else {
return $this->redirect($this->generateUrl('copypaste_show_public', ['id' => $paste->getId()]));
}
}
throw new $this->createAccessDeniedException('Sorry :(');
}
/**
* Creates a form to create a Copypaste entity.
*
* @param Copypaste $entity The entity
*
* @return Form The form
*/
private function createCreateForm(Copypaste $entity)
{
$form = $this->createForm(new CopypasteType(), $entity, [
'action' => $this->generateUrl('copypaste_create'),
'method' => 'POST',
]);
$form->add('submit', 'submit', array('label' => 'Create'));
return $form;
}
/**
* Displays a form to create a new Copypaste entity.
*
* @return Response
*/
public function newAction()
{
$paste = new Copypaste();
$createForm = $this->createCreateForm($paste);
return $this->render('SkobkinCopyPasteBundle:Copypaste:new.html.twig', [
'entity' => $paste,
'form_create' => $createForm->createView(),
]);
}
/**
* Finds and displays a Copypaste entity.
*
* @return Response
*/
public function showAction($id, $secret)
{
$em = $this->getDoctrine()->getManager();
/* @var $paste Copypaste */
$paste = $em->getRepository('SkobkinCopyPasteBundle:Copypaste')->findOneBy([
'id' =>$id,
'secret' => $secret
]);
if (!$paste) {
throw $this->createNotFoundException('Unable to find copypaste.');
}
$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', [
'paste' => $paste,
'highlighted_text' => $highlightedCode,
'form_create' => $editForm->createView(),
]);
}
/**
* Main page
*
* @return Response
*/
public function sidebarAction()
{
$em = $this->getDoctrine()->getManager();
$pastes = $em->getRepository('SkobkinCopyPasteBundle:Copypaste')->findBy(
['secret' => null],
['id' => 'DESC'],
// @todo move to the config
15
);
return $this->render('::sidebar.html.twig', ['pastes' => $pastes]);
}
}

View File

@ -1,98 +0,0 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
use Skobkin\Bundle\CopyPasteBundle\Entity\Language;
/**
* Description of LoadLanguages
*
* @author Alexey Skobkin
*/
class LoadLanguages implements FixtureInterface, ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
/**
* {@inheritDoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$output = new ConsoleOutput();
$geshiPath = $this->container->get('kernel')->getRootDir() . '/../vendor/theodordiaconu/geshi/src/GeSHi/geshi';
$finder = new Finder();
$finder->files()->in($geshiPath);
// Fix constants
define('GESHI_CAPS_NO_CHANGE', true);
define('GESHI_COMMENTS', true);
define('GESHI_NEVER', true);
define('GESHI_SEARCH', true);
define('GESHI_REPLACE', true);
define('GESHI_MODIFIERS', true);
define('GESHI_BEFORE', true);
define('GESHI_AFTER', true);
define('GESHI_MAYBE', true);
define('GESHI_NUMBER_INT_BASIC', true);
define('GESHI_NUMBER_HEX_PREFIX_DOLLAR', true);
define('GESHI_NUMBER_BIN_PREFIX_PERCENT', true);
define('GESHI_NUMBER_FLT_NONSCI', true);
define('GESHI_NUMBER_HEX_PREFIX', true);
define('GESHI_NUMBER_FLT_SCI_ZERO', true);
define('GESHI_NUMBER_OCT_PREFIX', true);
define('GESHI_ALWAYS', true);
define('GESHI_CAPS_UPPER', true);
define('GESHI_NUMBER_FLT_NONSCI_F', true);
define('GESHI_NUMBER_FLT_SCI_SHORT', true);
define('GESHI_NUMBER_HEX_SUFFIX', true);
define('GESHI_NUMBER_INT_CSTYLE', true);
define('GESHI_NUMBER_BIN_PREFIX_0B', true);
define('GESHI_NUMBER_BIN_SUFFIX', true);
define('GESHI_NUMBER_OCT_SUFFIX', true);
define('GESHI_CLASS', true);
define('GESHI_NUMBER_OCT_PREFIX_0O', true);
define('GESHI_NUMBER_OCT_PREFIX_AT', true);
/* @var $file SplFileInfo */
foreach ($finder as $file) {
$output->writeln($file->getRelativePathname() . ' found. Parsing...');
include $geshiPath . DIRECTORY_SEPARATOR .$file->getRelativePathname();
$language = new Language();
$language
->setName($language_data['LANG_NAME'])
->setCode(basename($file->getRelativePathname(), '.php'))
->setEnabled(true)
;
$output->write('---> "' . $language->getName() . '"');
$manager->persist($language);
$manager->flush();
$output->writeln(' [ PERSISTED ]');
}
$output->writeln('Import finished!');
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('skobkin_copy_paste');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
return $treeBuilder;
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class SkobkinCopyPasteExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
}

View File

@ -1,3 +0,0 @@
skobkin_copy_paste:
resource: "@SkobkinCopyPasteBundle/Resources/config/routing/copypaste.yml"
prefix: /

View File

@ -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

View File

@ -1,4 +0,0 @@
services:
# skobkin_copy_paste.example:
# class: Skobkin\Bundle\CopyPasteBundle\Example
# arguments: [@service_id, "plain_value", %parameter%]

View File

@ -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 %}

View File

@ -1,9 +0,0 @@
<?php
namespace Skobkin\Bundle\CopyPasteBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class SkobkinCopyPasteBundle extends Bundle
{
}

407
symfony.lock Normal file
View File

@ -0,0 +1,407 @@
{
"doctrine/annotations": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "cb4152ebcadbe620ea2261da1a1c5a9b8cea7672"
}
},
"doctrine/cache": {
"version": "v1.8.0"
},
"doctrine/collections": {
"version": "v1.5.0"
},
"doctrine/common": {
"version": "v2.10.0"
},
"doctrine/data-fixtures": {
"version": "v1.3.1"
},
"doctrine/dbal": {
"version": "v2.9.2"
},
"doctrine/doctrine-bundle": {
"version": "1.6",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.6",
"ref": "453e89b78ded666f351617baca5ae40d20622351"
}
},
"doctrine/doctrine-cache-bundle": {
"version": "1.3.5"
},
"doctrine/doctrine-fixtures-bundle": {
"version": "3.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.0",
"ref": "fc52d86631a6dfd9fdf3381d0b7e3df2069e51b3"
}
},
"doctrine/doctrine-migrations-bundle": {
"version": "1.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.2",
"ref": "c1431086fec31f17fbcfe6d6d7e92059458facc1"
}
},
"doctrine/event-manager": {
"version": "v1.0.0"
},
"doctrine/inflector": {
"version": "v1.3.0"
},
"doctrine/instantiator": {
"version": "1.1.0"
},
"doctrine/lexer": {
"version": "v1.0.1"
},
"doctrine/migrations": {
"version": "v2.0.0"
},
"doctrine/orm": {
"version": "v2.6.3"
},
"doctrine/persistence": {
"version": "v1.1.0"
},
"doctrine/reflection": {
"version": "v1.0.0"
},
"easycorp/easy-log-handler": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "70062abc2cd58794d2a90274502f81b55cd9951b"
}
},
"fig/link-util": {
"version": "1.0.0"
},
"jdorn/sql-formatter": {
"version": "v1.2.17"
},
"jean85/pretty-package-versions": {
"version": "1.2"
},
"monolog/monolog": {
"version": "1.24.0"
},
"ocramius/proxy-manager": {
"version": "2.2.2"
},
"paragonie/random_compat": {
"version": "v9.99.99"
},
"php": {
"version": "7.1.23"
},
"psr/cache": {
"version": "1.0.1"
},
"psr/container": {
"version": "1.0.0"
},
"psr/link": {
"version": "1.0.0"
},
"psr/log": {
"version": "1.1.0"
},
"psr/simple-cache": {
"version": "1.0.1"
},
"sensio/framework-extra-bundle": {
"version": "5.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "5.2",
"ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b"
}
},
"sentry/sentry": {
"version": "1.10.0"
},
"sentry/sentry-symfony": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "master",
"version": "1.0",
"ref": "fa1a2dfc020798cd7076b5419596e72dca07047a"
}
},
"symfony/cache": {
"version": "v4.2.2"
},
"symfony/cache-contracts": {
"version": "v1.1.7"
},
"symfony/config": {
"version": "v4.2.2"
},
"symfony/console": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "0fa049c19069a65f52c1c181d64be3de672c1504"
}
},
"symfony/contracts": {
"version": "v1.0.2"
},
"symfony/debug": {
"version": "v4.2.2"
},
"symfony/debug-bundle": {
"version": "4.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.1",
"ref": "f8863cbad2f2e58c4b65fa1eac892ab189971bea"
}
},
"symfony/debug-pack": {
"version": "v1.0.7"
},
"symfony/dependency-injection": {
"version": "v4.2.2"
},
"symfony/doctrine-bridge": {
"version": "v4.2.2"
},
"symfony/dotenv": {
"version": "v4.2.2"
},
"symfony/error-handler": {
"version": "v4.4.7"
},
"symfony/event-dispatcher": {
"version": "v4.2.2"
},
"symfony/event-dispatcher-contracts": {
"version": "v1.1.7"
},
"symfony/filesystem": {
"version": "v4.2.2"
},
"symfony/finder": {
"version": "v4.2.2"
},
"symfony/flex": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "dc3fc2e0334a4137c47cfd5a3ececc601fa61a0b"
}
},
"symfony/form": {
"version": "v4.2.2"
},
"symfony/framework-bundle": {
"version": "4.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.2",
"ref": "5bb3a8c27df824d195fa68bb635d074854f8498f"
}
},
"symfony/http-foundation": {
"version": "v4.2.2"
},
"symfony/http-kernel": {
"version": "v4.2.2"
},
"symfony/inflector": {
"version": "v4.2.2"
},
"symfony/intl": {
"version": "v4.2.2"
},
"symfony/mime": {
"version": "v4.4.7"
},
"symfony/monolog-bridge": {
"version": "v4.2.2"
},
"symfony/monolog-bundle": {
"version": "3.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.1",
"ref": "18ebf5a940573a20de06f9c4060101eeb438cf3d"
}
},
"symfony/options-resolver": {
"version": "v4.2.2"
},
"symfony/orm-pack": {
"version": "v1.0.6"
},
"symfony/phpunit-bridge": {
"version": "4.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.1",
"ref": "0e548dd90adba18fabd4ef419b14d361fe4d6c74"
}
},
"symfony/polyfill-ctype": {
"version": "v1.10.0"
},
"symfony/polyfill-intl-icu": {
"version": "v1.10.0"
},
"symfony/polyfill-intl-idn": {
"version": "v1.15.0"
},
"symfony/polyfill-mbstring": {
"version": "v1.10.0"
},
"symfony/polyfill-php72": {
"version": "v1.10.0"
},
"symfony/polyfill-php73": {
"version": "v1.15.0"
},
"symfony/process": {
"version": "v4.2.2"
},
"symfony/profiler-pack": {
"version": "v1.0.4"
},
"symfony/property-access": {
"version": "v4.2.2"
},
"symfony/routing": {
"version": "4.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.2",
"ref": "5374e24d508ba8fd6ba9eb15170255fdb778316a"
}
},
"symfony/security-bundle": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "f8a63faa0d9521526499c0a8f403c9964ecb0527"
}
},
"symfony/security-core": {
"version": "v4.2.2"
},
"symfony/security-csrf": {
"version": "v4.2.2"
},
"symfony/security-guard": {
"version": "v4.2.2"
},
"symfony/security-http": {
"version": "v4.2.2"
},
"symfony/service-contracts": {
"version": "v1.1.8"
},
"symfony/stopwatch": {
"version": "v4.2.2"
},
"symfony/translation": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "1fb02a6e1c8f3d4232cce485c9afa868d63b115a"
}
},
"symfony/translation-contracts": {
"version": "v1.1.7"
},
"symfony/twig-bridge": {
"version": "v4.2.2"
},
"symfony/twig-bundle": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "369b5b29dc52b2c190002825ae7ec24ab6f962dd"
}
},
"symfony/validator": {
"version": "4.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.1",
"ref": "0cdc982334f45d554957a6167e030482795bf9d7"
}
},
"symfony/var-dumper": {
"version": "v4.2.2"
},
"symfony/var-exporter": {
"version": "v4.2.2"
},
"symfony/web-profiler-bundle": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "6bdfa1a95f6b2e677ab985cd1af2eae35d62e0f6"
}
},
"symfony/web-server-bundle": {
"version": "3.3",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "dae9b39fd6717970be7601101ce5aa960bf53d9a"
}
},
"symfony/yaml": {
"version": "v4.2.2"
},
"theodordiaconu/geshi": {
"version": "dev-master"
},
"theodordiaconu/geshi-bundle": {
"version": "dev-master"
},
"twig/twig": {
"version": "v2.6.2"
},
"zendframework/zend-code": {
"version": "3.3.1"
},
"zendframework/zend-eventmanager": {
"version": "3.2.1"
}
}

View File

@ -0,0 +1,15 @@
{% block fake_captcha_widget %}
{% spaceless %}
<div id="{{ form.vars.id }}"></div>
<script type="text/javascript">
(function () {
div = document.getElementById('{{ form.vars.id }}');
input = document.createElement('input');
input.setAttribute('type', 'hidden');
input.setAttribute('name', '{{ form.vars.full_name }}');
input.setAttribute('value', 'dumb_text');
div.appendChild(input);
})();
</script>
{% endspaceless %}
{% endblock %}

View 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 %}

Some files were not shown because too many files have changed in this diff Show More