Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bait-sk/BaitPollBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-sk committed Aug 13, 2012
2 parents 40424a2 + f6cde09 commit 7f49f87
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 60 deletions.
13 changes: 12 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,20 @@ public function getConfigTreeBuilder()
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('bait_poll');

$supportedDBDrivers = array('orm');

$rootNode
->children()
->scalarNode('db_driver')->cannotBeOverwritten()->isRequired()->end()
->scalarNode('db_driver')
->validate()
->ifNotInArray($supportedDBDrivers)
->thenInvalid('The driver %s is not supported. Please choose one of ' . json_encode($supportedDBDrivers))
->end()
->cannotBeEmpty()
->cannotBeOverwritten()
->isRequired()
->end()

->scalarNode('upload_dir')->defaultNull()->end()
->scalarNode('model_manager_name')->defaultNull()->end()

Expand Down
22 changes: 9 additions & 13 deletions Form/PollType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ class PollType extends AbstractType
*/
protected $fieldManager;

/**
* @var PollManagerInterface Poll manager
*/
protected $pollManager;

/**
* @var array $fields
*/
protected $fields;

protected $id;
/**
* @var integer $pollId Id of field
*/
protected $pollId;

/**
* @var array Translation table of field types
Expand All @@ -60,18 +58,17 @@ class PollType extends AbstractType
/**
* @param FieldManager $fieldManager Field manager
*/
public function __construct(PollManagerInterface $pollManager, FieldManager $fieldManager)
public function __construct(FieldManager $fieldManager)
{
$this->pollManager = $pollManager;
$this->fieldManager = $fieldManager;
}

/**
* @param mixed Sets id of poll
* @param mixed $pollId Sets id of poll
*/
public function setId($id)
public function setPollId($pollId)
{
$this->id = $id;
$this->pollId = $pollId;
}

/**
Expand All @@ -80,7 +77,7 @@ public function setId($id)
*/
public function setFields()
{
$this->fields = $this->fieldManager->findOrderedPollFields($this->id);
$this->fields = $this->fieldManager->findOrderedPollFields($this->pollId);
}

/**
Expand Down Expand Up @@ -194,7 +191,6 @@ public function getName()
return 'bait_poll_form';
}


/**
* Loads validation constraints of all provided fields.
*
Expand Down
6 changes: 3 additions & 3 deletions FormFactory/PollFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public function __construct(FormFactoryInterface $formFactory, $type, $name)
/**
* {@inheritdoc}
*/
public function create($id)
public function create($pollId)
{
$type = $this->formFactory->getType($this->type);
$type->setId($id);
$type->setPollId($pollId);
$type->setFields();

$builder = $this->formFactory->createNamedBuilder($type, sprintf('%s_%s', $this->name, $id));
$builder = $this->formFactory->createNamedBuilder($type, sprintf('%s_%s', $this->name, $pollId));

return $builder->getForm();
}
Expand Down
1 change: 0 additions & 1 deletion Resources/config/form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<services>
<service id="bait_poll.form.default" class="Bait\PollBundle\Form\PollType">
<tag name="form.type" alias="bait_poll.form" />
<argument type="service" id="bait_poll.poll.manager" />
<argument type="service" id="bait_poll.field.manager" />
</service>

Expand Down
2 changes: 1 addition & 1 deletion Resources/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="answer_group")
* @ORM\Table(name="poll_answer_group")
*/
class AnswerGroup extends BaseAnswerGroup
{
Expand Down
34 changes: 0 additions & 34 deletions Tests/autoload.php.dist

This file was deleted.

10 changes: 4 additions & 6 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
* file that was distributed with this source code.
*/

$vendorDir = __DIR__ . '/../vendor';

if (file_exists($file = __DIR__.'/autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
if (!is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
throw new \LogicException('Could not find autoload.php in vendor/. Did you run "composer install --dev"?');
}

require $autoloadFile;

Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@
"name": "bait/poll-bundle",
"type": "symfony-bundle",
"description": "Poll Bundle adds support for various forms of polls for Symfony2 applications",
"keywords": ["poll", "competition"],
"keywords": [
"poll",
"form",
"contest"
],
"homepage": "http://github.com/bait-sk/",
"license": "MIT",
"authors": [
{
"name": "Ondrej Slintak",
"email": "[email protected]"
},
{
"name": "Matej Zilak",
"email": "[email protected]"
}
],
"require": {
Expand Down

0 comments on commit 7f49f87

Please sign in to comment.