Skip to content

Commit

Permalink
IFormMapperProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
pepakriz committed Oct 15, 2014
1 parent 4481bbf commit 154f205
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
25 changes: 25 additions & 0 deletions src/System/DI/IFormMapperProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* This file is part of the Venne:CMS (https://github.com/Venne)
*
* Copyright (c) 2011, 2012 Josef Kříž (http://www.josef-kriz.cz)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/

namespace Venne\System\DI;

/**
* @author Josef Kříž <[email protected]>
*/
interface IFormMapperProvider
{

/**
* @return string[]
*/
public function getFormMappers();

}
30 changes: 25 additions & 5 deletions src/System/DI/SystemExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Nette\DI\Statement;
use Nette\PhpGenerator\PhpLiteral;
use Venne\DataTransfer\DI\DataTransferExtension;
use Venne\System\Events\InvitationEvent;
use Venne\System\Forms\DoctrineForms\Controls\TextControl;
use Venne\Widgets\DI\WidgetsExtension;

/**
Expand All @@ -27,6 +29,7 @@ class SystemExtension extends \Nette\DI\CompilerExtension implements
\Kdyby\Translation\DI\ITranslationProvider,
\Venne\System\DI\ICssProvider,
\Venne\System\DI\IJsProvider,
\Venne\System\DI\IFormMapperProvider,
\Venne\Notifications\DI\IEventProvider
{

Expand Down Expand Up @@ -176,14 +179,21 @@ public function loadConfiguration()
}
}

$container->addDefinition($this->prefix('doctrineForms.textControl'))
->setClass('Venne\System\Forms\DoctrineForms\Controls\TextControl');

foreach ($this->compiler->extensions as $extension) {
if ($extension instanceof \Kdyby\DoctrineForms\DI\FormsExtension) {
$container->addDefinition($this->prefix('doctrineForms.textControl'))
->setClass('Venne\System\Forms\DoctrineForms\Controls\TextControl');
$entityFormMapper = $container->getDefinition($extension->prefix('entityFormMapper'));

foreach ($this->compiler->extensions as $extension) {
if ($extension instanceof IFormMapperProvider) {
foreach ($extension->getFormMappers() as $definition) {
$entityFormMapper->addSetup('?->setEntityFormMapper($service);$service->registerMapper(?)', array('@' . $definition, '@' . $definition));
}
}
}

$textControlService = $this->prefix('@doctrineForms.textControl');
$container->getDefinition($extension->prefix('entityFormMapper'))
->addSetup('?->setEntityFormMapper($service);$service->registerMapper(?)', array($textControlService, $textControlService));
break;
}
}
Expand Down Expand Up @@ -562,4 +572,14 @@ public function getEventTypes()
);
}

/**
* @return string[]
*/
public function getFormMappers()
{
return array(
TextControl::class,
);
}

}

0 comments on commit 154f205

Please sign in to comment.