Skip to content

WIP - Propel2 support #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
13 changes: 13 additions & 0 deletions Builder/Propel2/ActionsBuilderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\ActionsBuilderAction as AdminActionsBuilderAction;

/**
* This builder generate php for actions in propel
* @author Piotr Gołębiewski <[email protected]>
*/
class ActionsBuilderAction extends AdminActionsBuilderAction
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/ActionsBuilderTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\ActionsBuilderTemplate as AdminActionsBuilderTemplate;

/**
* This builder generate php for actions for propel
* @author Piotr Gołębiewski <[email protected]>
*/
class ActionsBuilderTemplate extends AdminActionsBuilderTemplate
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/EditBuilderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\EditBuilderAction as AdminEditBuilderAction;

/**
* This builder generate php for edit actions in Propel
* @author cedric Lombardot
*/
class EditBuilderAction extends AdminEditBuilderAction
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/EditBuilderTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\EditBuilderTemplate as AdminEditBuilderTemplate;

/**
* This builder generate php for edit actions for Propel
* @author cedric Lombardot
*/
class EditBuilderTemplate extends AdminEditBuilderTemplate
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/EditBuilderType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\EditBuilderType as AdminEditBuilderType;

/**
* This builder generate php for edit form
* @author cedric Lombardot
*/
class EditBuilderType extends AdminEditBuilderType
{
}
14 changes: 14 additions & 0 deletions Builder/Propel2/ExcelBuilderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\ExcelBuilderAction as AdminExcelBuilderAction;

/**
* This builder generate php for Excel actions in Propel
* @author cedric Lombardot
* @author Bob van de Vijver
*/
class ExcelBuilderAction extends AdminExcelBuilderAction
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/FiltersBuilderType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\FiltersBuilderType as AdminFiltersBuilderType;

/**
* This builder generate php for Filters form
* @author cedric Lombardot
*/
class FiltersBuilderType extends AdminFiltersBuilderType
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/ListBuilderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\ListBuilderAction as AdminListBuilderAction;

/**
* This builder generate php for lists actions in Propel
* @author cedric Lombardot
*/
class ListBuilderAction extends AdminListBuilderAction
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/ListBuilderTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\ListBuilderTemplate as AdminListBuilderTemplate;

/**
* This builder generate php for lists actions for Propel
* @author cedric Lombardot
*/
class ListBuilderTemplate extends AdminListBuilderTemplate
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/NestedListBuilderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\NestedListBuilderAction as AdminNestedListBuilderAction;

/**
* This builder generate php for lists actions in Propel
* @author cedric Lombardot
*/
class NestedListBuilderAction extends AdminNestedListBuilderAction
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/NestedListBuilderTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\NestedListBuilderTemplate as AdminNestedListBuilderTemplate;

/**
* This builder generate php for lists actions for Propel
* @author cedric Lombardot
*/
class NestedListBuilderTemplate extends AdminNestedListBuilderTemplate
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/NewBuilderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\NewBuilderAction as AdminNewBuilderAction;

/**
* This builder generate php for New actions in Propel
* @author cedric Lombardot
*/
class NewBuilderAction extends AdminNewBuilderAction
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/NewBuilderTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\NewBuilderTemplate as AdminNewBuilderTemplate;

/**
* This builder generate php for New actions for Propel
* @author cedric Lombardot
*/
class NewBuilderTemplate extends AdminNewBuilderTemplate
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/NewBuilderType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\NewBuilderType as AdminNewBuilderType;

/**
* This builder generate php for New form
* @author cedric Lombardot
*/
class NewBuilderType extends AdminNewBuilderType
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/ShowBuilderAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\ShowBuilderAction as AdminShowBuilderAction;

/**
* This builder generate php for edit actions in Propel
* @author Eymen Gunay
*/
class ShowBuilderAction extends AdminShowBuilderAction
{
}
13 changes: 13 additions & 0 deletions Builder/Propel2/ShowBuilderTemplate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Admingenerator\GeneratorBundle\Builder\Propel2;

use Admingenerator\GeneratorBundle\Builder\Admin\ShowBuilderTemplate as AdminShowBuilderTemplate;

/**
* This builder generate php for edit actions for Propel
* @author Eymen Gunay
*/
class ShowBuilderTemplate extends AdminShowBuilderTemplate
{
}
10 changes: 7 additions & 3 deletions CacheWarmer/GeneratorCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,13 @@ protected function buildFromYaml($file)
*/
protected function propelInit()
{
if (!\Propel::isInit()) {
\Propel::setConfiguration($this->container->get('propel.configuration'));
\Propel::initialize();
if (class_exists('Propel')) { // Propel 1
if (!\Propel::isInit()) {
\Propel::setConfiguration($this->container->get('propel.configuration'));
\Propel::initialize();
}

return;
}
}
}
22 changes: 20 additions & 2 deletions DependencyInjection/AdmingeneratorGeneratorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function load(array $configs, ContainerBuilder $container)
if ($config['use_jms_security']) {
$container->getDefinition('twig.extension.admingenerator.security')->addArgument(true);
$container->getDefinition('twig.extension.admingenerator.echo')->addArgument(true);
}
}

$this->registerGeneratedFormsAsServices($container);
$this->processModelManagerConfiguration($config, $container);
Expand All @@ -91,7 +91,7 @@ public function load(array $configs, ContainerBuilder $container)
*/
private function processModelManagerConfiguration(array $config, ContainerBuilder $container)
{
if (!($config['use_doctrine_orm'] || $config['use_doctrine_odm'] || $config['use_propel'])) {
if (!($config['use_doctrine_orm'] || $config['use_doctrine_odm'] || $config['use_propel'] || $config['use_propel2'])) {
throw new ModelManagerNotSelectedException();
}

Expand All @@ -105,6 +105,7 @@ private function processModelManagerConfiguration(array $config, ContainerBuilde
$doctrineOrmTemplatesDirs[] = $dir . DIRECTORY_SEPARATOR . 'Doctrine';
$doctrineOdmTemplatesDirs[] = $dir . DIRECTORY_SEPARATOR . 'DoctrineODM';
$propelTemplatesDirs[] = $dir . DIRECTORY_SEPARATOR . 'Propel';
$propel2TemplatesDirs[] = $dir . DIRECTORY_SEPARATOR . 'Propel2';
}

if ($config['use_doctrine_orm']) {
Expand Down Expand Up @@ -155,6 +156,23 @@ private function processModelManagerConfiguration(array $config, ContainerBuilde
->addArgument($config['guess_required'])
->addArgument($config['default_required']);
}


if ($config['use_propel2']) {
$loader->load('propel2.xml');
$this->addTemplatesInitialization($container->getDefinition('admingenerator.generator.propel2'), $propel2TemplatesDirs);
if ($config['overwrite_if_exists']) {
$container
->getDefinition('admingenerator.generator.propel2')
->addMethodCall('forceOverwriteIfExists');
}

$container->getDefinition('admingenerator.fieldguesser.propel2')
->addArgument($config['form_types']['propel2'])
->addArgument($config['filter_types']['propel2'])
->addArgument($config['guess_required'])
->addArgument($config['default_required']);
}
}

/**
Expand Down
Loading