Doctrine Fixtures installed. GeSHi installed. Fixture for language import implemented.

This commit is contained in:
Alexey Skobkin 2015-03-02 23:40:29 +03:00
parent a79d56d973
commit c3c801ddec
4 changed files with 304 additions and 3 deletions

View file

@ -16,7 +16,9 @@ class AppKernel extends Kernel
new Symfony\Bundle\AsseticBundle\AsseticBundle(), new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new DT\Bundle\GeshiBundle\DTGeshiBundle(),
new Skobkin\Bundle\CopyPasteBundle\SkobkinCopyPasteBundle(), new Skobkin\Bundle\CopyPasteBundle\SkobkinCopyPasteBundle(),
); );

View file

@ -20,7 +20,10 @@
"sensio/framework-extra-bundle": "~3.0,>=3.0.2", "sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0", "incenteev/composer-parameter-handler": "~2.0",
"doctrine/migrations": "1.0.*@dev", "doctrine/migrations": "1.0.*@dev",
"doctrine/doctrine-migrations-bundle": "2.1.*@dev" "doctrine/doctrine-migrations-bundle": "2.1.*@dev",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"theodordiaconu/geshi": "dev-master",
"theodordiaconu/geshi-bundle" : "dev-master"
}, },
"require-dev": { "require-dev": {
"sensio/generator-bundle": "~2.3" "sensio/generator-bundle": "~2.3"

202
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "5fc11fb887ef6aed953b90118745b7f8", "hash": "e36598c346f19a7d683f1c1f3d58399f",
"packages": [ "packages": [
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
@ -290,6 +290,62 @@
], ],
"time": "2014-05-21 19:28:51" "time": "2014-05-21 19:28:51"
}, },
{
"name": "doctrine/data-fixtures",
"version": "v1.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/data-fixtures.git",
"reference": "b4a135c7db56ecc4602b54a2184368f440cac33e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/b4a135c7db56ecc4602b54a2184368f440cac33e",
"reference": "b4a135c7db56ecc4602b54a2184368f440cac33e",
"shasum": ""
},
"require": {
"doctrine/common": ">=2.2,<2.5-dev",
"php": ">=5.3.2"
},
"require-dev": {
"doctrine/orm": ">=2.2,<2.5-dev"
},
"suggest": {
"doctrine/mongodb-odm": "For loading MongoDB ODM fixtures",
"doctrine/orm": "For loading ORM fixtures",
"doctrine/phpcr-odm": "For loading PHPCR ODM fixtures"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Common\\DataFixtures": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/",
"role": "Creator"
}
],
"description": "Data Fixtures for all Doctrine Object Managers",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"database"
],
"time": "2013-07-10 17:04:07"
},
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "v2.4.4", "version": "v2.4.4",
@ -514,6 +570,66 @@
], ],
"time": "2014-11-28 09:43:36" "time": "2014-11-28 09:43:36"
}, },
{
"name": "doctrine/doctrine-fixtures-bundle",
"version": "v2.2.0",
"target-dir": "Doctrine/Bundle/FixturesBundle",
"source": {
"type": "git",
"url": "https://github.com/doctrine/DoctrineFixturesBundle.git",
"reference": "c811f96f0cf83b997e3a3ed037cac729bbe3e803"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/c811f96f0cf83b997e3a3ed037cac729bbe3e803",
"reference": "c811f96f0cf83b997e3a3ed037cac729bbe3e803",
"shasum": ""
},
"require": {
"doctrine/data-fixtures": "~1.0",
"doctrine/doctrine-bundle": "~1.0",
"php": ">=5.3.2",
"symfony/doctrine-bridge": "~2.1"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
},
"autoload": {
"psr-0": {
"Doctrine\\Bundle\\FixturesBundle": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com",
"homepage": "http://fabien.potencier.org",
"role": "Lead Developer"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Doctrine Project",
"homepage": "http://www.doctrine-project.org"
}
],
"description": "Symfony DoctrineFixturesBundle",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"Fixture",
"persistence"
],
"time": "2013-09-05 11:23:37"
},
{ {
"name": "doctrine/doctrine-migrations-bundle", "name": "doctrine/doctrine-migrations-bundle",
"version": "dev-master", "version": "dev-master",
@ -1621,6 +1737,86 @@
], ],
"time": "2015-03-02 10:21:01" "time": "2015-03-02 10:21:01"
}, },
{
"name": "theodordiaconu/geshi",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/theodorDiaconu/geshi.git",
"reference": "c2a5294496b34d7561db5c0641b7f960d930f6b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theodorDiaconu/geshi/zipball/c2a5294496b34d7561db5c0641b7f960d930f6b1",
"reference": "c2a5294496b34d7561db5c0641b7f960d930f6b1",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"GeSHi": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Geshi library",
"homepage": "http://qbnz.com/highlighter/",
"keywords": [
"Symfony2",
"geshi",
"highlighter"
],
"time": "2013-03-19 00:39:21"
},
{
"name": "theodordiaconu/geshi-bundle",
"version": "dev-master",
"target-dir": "DT/Bundle/GeshiBundle",
"source": {
"type": "git",
"url": "https://github.com/theodorDiaconu/geshi-bundle.git",
"reference": "4606ec8c7e338054f589147a6a6e1355f7262094"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/theodorDiaconu/geshi-bundle/zipball/4606ec8c7e338054f589147a6a6e1355f7262094",
"reference": "4606ec8c7e338054f589147a6a6e1355f7262094",
"shasum": ""
},
"require": {
"theodordiaconu/geshi": "dev-master"
},
"type": "symfony-bundle",
"autoload": {
"psr-0": {
"DT\\Bundle\\GeshiBundle": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Theodor Diaconu",
"email": "diaconu.theodor@gmail.com"
}
],
"description": "Symfony GeshiBundle",
"homepage": "http://www.datati.ro",
"keywords": [
"geshi",
"highlight",
"highlighter",
"syntax highlight"
],
"time": "2013-03-29 12:54:06"
},
{ {
"name": "twig/extensions", "name": "twig/extensions",
"version": "v1.2.0", "version": "v1.2.0",
@ -1786,7 +1982,9 @@
"stability-flags": { "stability-flags": {
"symfony/symfony": 20, "symfony/symfony": 20,
"doctrine/migrations": 20, "doctrine/migrations": 20,
"doctrine/doctrine-migrations-bundle": 20 "doctrine/doctrine-migrations-bundle": 20,
"theodordiaconu/geshi": 20,
"theodordiaconu/geshi-bundle": 20
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,

View file

@ -0,0 +1,98 @@
<?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!');
}
}