Skip to content
Browse files

Merge pull request #35 from wwwdata/symfony2.1

compatibility with symfony2.1 increased, unit tests working
  • Loading branch information...
2 parents f07c24a + 3560738 commit bf928b4cf9fed440f0c957faee4faeb98e5ef22c @DavidBadura DavidBadura committed Sep 19, 2012
View
23 Form/Extension/FieldTypeHelpExtension.php
@@ -3,29 +3,44 @@
namespace SimpleThings\FormExtraBundle\Form\Extension;
use Symfony\Component\Form\AbstractTypeExtension;
-use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
class FieldTypeHelpExtension extends AbstractTypeExtension
{
- public function buildForm(FormBuilder $builder, array $options)
+ /**
+ * @param FormBuilderInterface $builder
+ * @param array $options
+ */
+ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('help', $options['help']);
}
- public function buildView(FormView $view, FormInterface $form)
+ /**
+ * @param FormView $view
+ * @param FormInterface $form
+ * @param array $options
+ */
+ public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->set('help', $form->getAttribute('help'));
}
- public function getDefaultOptions(array $options)
+ /**
+ * @return array
+ */
+ public function getDefaultOptions()
{
return array(
'help' => null,
);
}
+ /**
+ * @return string
+ */
public function getExtendedType()
{
return 'field';
View
16 Form/Extension/TranslationDomainExtension.php
@@ -5,7 +5,7 @@
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
-use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
/**
* Extension providing forward compatibility for the handling of translation
@@ -24,28 +24,30 @@ public function getExtendedType()
}
/**
- * @param FormBuilder $builder
- * @param array $options
+ * @param FormBuilderInterface $builder
+ * @param array $options
*/
- public function buildForm(FormBuilder $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->setAttribute('translation_domain', $options['translation_domain']);
}
/**
- * @param FormView $view
+ * @param FormView $view
* @param FormInterface $form
+ * @param array $options
*/
- public function buildView(FormView $view, FormInterface $form)
+ public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->set('translation_domain', $form->getAttribute('translation_domain'));
}
/**
* @param array $options
+ *
* @return array
*/
- public function getDefaultOptions(array $options)
+ public function getDefaultOptions()
{
return array(
'translation_domain' => 'messages',
View
8 Form/Type/FileSetType.php
@@ -3,7 +3,7 @@
namespace SimpleThings\FormExtraBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
-use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
@@ -20,14 +20,14 @@
*/
class FileSetType extends AbstractType
{
- public function buildForm(FormBuilder $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->prependNormTransformer(new FileSetTransformer());
$builder->setAttribute('delete_route', $options['delete_route']);
$builder->setAttribute('delete_id', $options['delete_id']);
}
- public function buildView(FormView $view, FormInterface $form)
+ public function buildView(FormView $view, FormInterface $form, array $options)
{
$data = $form->getData();
if ($data === null) {
@@ -68,7 +68,7 @@ public function getName()
return 'formextra_fileset';
}
- public function getParent(array $options)
+ public function getParent()
{
return 'file';
}
View
18 Form/Type/ImageType.php
@@ -5,7 +5,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
-use Symfony\Component\Form\FormViewInterface;
+use Symfony\Component\Form\FormView;
/**
* Extends the File type, upload an image but show a version of the currently uploaded image.
@@ -25,7 +25,7 @@ class ImageType extends AbstractType
* Configures the Type
*
* @param FormBuilderInterface $builder
- * @param array $options
+ * @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -47,10 +47,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
/**
* Sets attributes for use with the renderer
*
- * @param FormViewInterface $view
+ * @param FormView $view
* @param FormInterface $form
*/
- public function buildView(FormViewInterface $view, FormInterface $form, array $options)
+ public function buildView(FormView $view, FormInterface $form, array $options)
{
$data = $form->getData();
@@ -60,20 +60,21 @@ public function buildView(FormViewInterface $view, FormInterface $form, array $o
if ('/' !== DIRECTORY_SEPARATOR) {
$uri = str_replace(DIRECTORY_SEPARATOR, '/', $uri);
}
- $view->setVar('image_uri', $uri);
+ $view->vars['image_uri'] = $uri;
} else if ($form->hasAttribute ('no_image_placeholder_uri') && $uri = $form->getAttribute ('no_image_placeholder_uri')) {
$view->setAttribute('image_uri', $uri);
}
- $view->setVar('image_alt', $form->getAttribute('image_alt'));
- $view->setVar('image_height', $form->getAttribute('image_height'));
- $view->setVar('image_width', $form->getAttribute('image_width'));
+ $view->vars['image_alt'] = $form->getAttribute('image_alt');
+ $view->vars['image_height'] = $form->getAttribute('image_height');
+ $view->vars['image_width'] = $form->getAttribute('image_width');
}
/**
* Options for this type
*
* @param array $options
+ *
* @return array
*/
public function getDefaultOptions(array $options)
@@ -93,6 +94,7 @@ public function getDefaultOptions(array $options)
* Inherits from file type and adds displaying capabilities.
*
* @param array $options
+ *
* @return string
*/
public function getParent()
View
25 Form/Type/RecaptchaType.php
@@ -2,10 +2,10 @@
namespace SimpleThings\FormExtraBundle\Form\Type;
-use Symfony\Component\Form\AbstractType;
+use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
-use Symfony\Component\Form\FormViewInterface;
+use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Exception\FormException;
use Symfony\Component\HttpFoundation\Request;
@@ -42,7 +42,7 @@ class RecaptchaType extends AbstractType
/**
* @param Recaptcha $recaptcha
- * @param string $publicKey
+ * @param string $publicKey
*/
public function __construct(Recaptcha $recaptcha, $publicKey)
{
@@ -54,7 +54,7 @@ public function __construct(Recaptcha $recaptcha, $publicKey)
* Configures the Type
*
* @param FormBuilderInterface $builder
- * @param array $options
+ * @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -66,33 +66,32 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('recaptcha_challenge_field', 'text')
->add('recaptcha_response_field', 'hidden', array(
'data' => 'manual_challenge',
- ))
- ;
+ ));
$builder->prependClientTransformer(new RecaptchaTransformer($this->recaptcha));
$builder
- ->setAttribute('widget_options', $options['widget_options'])
- ;
+ ->setAttribute('widget_options', $options['widget_options']);
}
/**
* Sets attributes for use with the renderer
*
- * @param FormViewInterface $view
+ * @param FormView $view
* @param FormInterface $form
- * @param array $options
+ * @param array $options
*/
- public function buildView(FormViewInterface $view, FormInterface $form, array $options)
+ public function buildView(FormView $view, FormInterface $form, array $options)
{
- $view->setVar('public_key', $this->publicKey);
- $view->setVar('widget_options', $form->getAttribute('widget_options'));
+ $view->vars['public_key'] = $this->publicKey;
+ $view->vars['widget_options'] = $form->getAttribute('widget_options');
}
/**
* Options for this type
*
* @param array $options
+ *
* @return array
*/
public function getDefaultOptions(array $options)
View
4 Tests/Form/Type/ImageTypeTest.php
@@ -60,7 +60,7 @@ public function testBuildForm()
public function testBuildView()
{
- $view = new FormView('name');
+ $view = new FormView();
$options = array(
'base_path' => __DIR__,
@@ -77,6 +77,6 @@ public function testBuildView()
$form->setData(new File(__FILE__));
$this->type->buildView($view, $form, array());
- $this->assertEquals('http://example.com/ImageTypeTest.php', $view->getVar('image_uri'));
+ $this->assertEquals('http://example.com/ImageTypeTest.php', $view->vars['image_uri']);
}
}
View
6 Tests/Form/Type/RecaptchaTypeTest.php
@@ -62,17 +62,17 @@ public function testBuildForm()
public function testBuildView()
{
- $view = new FormView('name');
+ $view = new FormView();
$this->builder->setAttribute('widget_options', array(
'theme' => 'white',
));
$this->type->buildView($view, $this->builder->getForm(), array());
- $this->assertEquals('publicKey', $view->getVar('public_key'));
+ $this->assertEquals('publicKey', $view->vars['public_key']);
$this->assertEquals(array(
'theme' => 'white',
- ), $view->getVar('widget_options'));
+ ), $view->vars['widget_options']);
}
}
View
2 Tests/bootstrap.php
@@ -1,6 +1,6 @@
<?php
-if (!@include __DIR__ . '/../vendor/.composer/autoload.php') {
+if (!@include __DIR__ . '/../vendor/autoload.php') {
die(<<<'EOT'
You must set up the project dependencies, run the following commands:
wget http://getcomposer.org/composer.phar
View
1 phpunit.xml.dist
@@ -13,6 +13,7 @@
<exclude>
<directory>./Resources</directory>
<directory>./Tests</directory>
+ <directory>./vendor</directory>
</exclude>
</whitelist>
</filter>

0 comments on commit bf928b4

Please sign in to comment.
Something went wrong with that request. Please try again.