Permalink
Browse files

updated deprecated calls

  • Loading branch information...
1 parent c3bdd45 commit ee4dfc6ab21b4048db037440a62ff19a182c9e53 @bamarni bamarni committed Mar 17, 2013
@@ -87,7 +87,7 @@ public function validate(DataEvent $event)
if (empty($this->options['code'])) {
if (empty($datas['challenge']) || empty($datas['response'])) {
$error = 'The captcha is not valid.';
- } elseif (true !== ($answer = $this->check($datas, $form->getAttribute('option_validator')))) {
+ } elseif (true !== ($answer = $this->check($datas, $form->getConfig()->getAttribute('option_validator')))) {
$error = sprintf('Unable to check the captcha from the server. (%s)', $answer);
}
} elseif ($this->options['code'] != $datas['response']) {
@@ -12,8 +12,9 @@
namespace Genemu\Bundle\FormBundle\Form\Doctrine\ChoiceList;
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList;
-use Symfony\Component\Form\Util\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyPath;
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
+use Symfony\Component\PropertyAccess\PropertyAccess;
use Doctrine\Common\Persistence\ObjectManager;
@@ -125,7 +126,7 @@ public function getIntersect(array $ids)
$id = current($this->classMetadata->getIdentifierValues($entity));
if ($this->propertyPath) {
- $label = $this->propertyPath->getValue($entity);
+ $label = PropertyAccess::getPropertyAccessor()->getValue($entity, $this->propertyPath);
} else {
$label = (string) $entity;
}
@@ -18,7 +18,8 @@
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
-use Symfony\Component\Form\Util\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyAccess;
/**
* @author Bilal Amarni <bilal.amarni@gmail.com>
@@ -103,7 +104,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
$objects = $options['em']->getRepository($options['class'])->findAll();
foreach ($objects as $object) {
if ($propertyPath) {
- $suggestions[] = $propertyPath->getValue($object);
+ $suggestions[] = PropertyAccess::getPropertyAccessor()->getValue($object, $propertyPath);
} elseif (method_exists($object, '__toString')) {
$suggestions[] = (string) $object;
} else {
@@ -15,6 +15,7 @@
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Genemu\Bundle\FormBundle\Form\Core\EventListener\GeolocationListener;
@@ -63,9 +64,9 @@ public function buildView(FormView $view, FormInterface $form, array $options)
/**
* {@inheritdoc}
*/
- public function getDefaultOptions(array $options)
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- return array(
+ $resolver->setDefaults(array(
'map' => false,
'latitude' => array(
'enabled' => false,
@@ -83,7 +84,7 @@ public function getDefaultOptions(array $options)
'enabled' => false,
'hidden' => false,
),
- );
+ ));
}
/**
@@ -14,6 +14,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Genemu\Bundle\FormBundle\Gd\File\Image;
@@ -48,11 +49,11 @@ public function __construct($selected, array $thumbnails, array $filters)
public function buildView(FormView $view, FormInterface $form, array $options)
{
$configs = $options['configs'];
- $data = $form->getClientData();
+ $data = $form->getViewData();
if (!empty($data)) {
if (!$data instanceof Image) {
- $data = new Image($form->getAttribute('rootDir') . '/' . $data);
+ $data = new Image($form->getConfig()->getAttribute('rootDir') . '/' . $data);
}
if ($data->hasThumbnail($this->selected)) {
@@ -82,14 +83,14 @@ public function buildView(FormView $view, FormInterface $form, array $options)
/**
* {@inheritdoc}
*/
- public function getDefaultOptions(array $options)
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- return array(
+ $resolver->setDefaults(array(
'configs' => array(
'fileExt' => '*.jpg;*.gif;*.png;*.jpeg',
'fileDesc' => 'Web Image Files (.jpg, .gif, .png, .jpeg)',
)
- );
+ ));
}
/**
@@ -39,7 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
- $view->vars['configs'] = $form->getAttribute('configs');
+ $view->vars['configs'] = $form->getConfig()->getAttribute('configs');
}
/**
@@ -90,7 +90,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
- $datas = json_decode($form->getClientData(), true);
+ $datas = json_decode($form->getViewData(), true);
$value = '';
if (!empty($datas)) {
@@ -104,7 +104,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
}
$view->vars['tokeninput_value'] = $value;
- $view->vars['route_name'] = $form->getAttribute('route_name');
+ $view->vars['route_name'] = $form->getConfig()->getAttribute('route_name');
foreach ($this->_availableTokeninputOptions as $option) {
if (null !== $options[$option]) {
@@ -12,7 +12,8 @@
namespace Genemu\Bundle\FormBundle\Form\Model\ChoiceList;
use Symfony\Bridge\Propel1\Form\ChoiceList\ModelChoiceList;
-use Symfony\Component\Form\Util\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyPath;
+use Symfony\Component\PropertyAccess\PropertyAccess;
/**
* AjaxModelChoiceList
@@ -88,7 +89,7 @@ public function getIntersect(array $ids)
$model = $this->getModel($id);
if ($this->propertyPath) {
- $label = $this->propertyPath->getValue($model);
+ $label = PropertyAccess::getPropertyAccessor()->getValue($model, $this->propertyPath);
} else {
$label = (string) $model;
}
@@ -13,6 +13,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\Options;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Genemu\Bundle\FormBundle\Form\Model\ChoiceList\AjaxModelChoiceList;
@@ -26,9 +27,9 @@ class AjaxModelType extends AbstractType
/**
* {@inheritdoc}
*/
- public function getDefaultOptions(array $options)
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
{
- $options = array(
+ $resolver->setDefaults(array(
'template' => 'choice',
'multiple' => false,
'expanded' => false,
@@ -53,7 +54,7 @@ public function getDefaultOptions(array $options)
return null;
}
- );
+ ));
return $options;
}
@@ -32,7 +32,7 @@ public function testDefaultConfigs()
{
$form = $this->factory->create('genemu_captcha');
$view = $form->createView();
- $captcha = $form->getAttribute('captcha');
+ $captcha = $form->getConfig()->getAttribute('captcha');
$this->assertEquals(100, $view->vars['width']);
$this->assertEquals(30, $view->vars['height']);
@@ -51,7 +51,7 @@ public function testConfigs()
));
$view = $form->createView();
- $captcha = $form->getAttribute('captcha');
+ $captcha = $form->getConfig()->getAttribute('captcha');
$this->assertEquals(200, $view->vars['width']);
$this->assertEquals(md5('1111s$cr$t'), $captcha->getCode());
@@ -35,7 +35,7 @@ public function testDefaultConfigs()
'port' => 80,
'path' => '/verify',
'timeout' => 10,
- ), $form->getAttribute('option_validator'));
+ ), $form->getConfig()->getAttribute('option_validator'));
}
public function testConfigs()
@@ -56,7 +56,7 @@ public function testConfigs()
'port' => 80,
'path' => '/verify',
'timeout' => 30
- ), $form->getAttribute('option_validator'));
+ ), $form->getConfig()->getAttribute('option_validator'));
}
/**
@@ -95,7 +95,7 @@ public function testDefaultValue()
), $view->vars['choices']);
$this->assertNull($form->getData());
- $this->assertEquals('', $form->getClientData());
+ $this->assertEquals('', $form->getViewData());
$this->assertNull($view->vars['route_name']);
$this->assertEquals('', $view->vars['autocompleter_value']);
@@ -124,7 +124,7 @@ public function testMultipleValue()
), $view->vars['choices']);
$this->assertNull($form->getData());
- $this->assertEquals('', $form->getClientData());
+ $this->assertEquals('', $form->getViewData());
$this->assertNull($view->vars['route_name']);
$this->assertEquals('', $view->vars['autocompleter_value']);
@@ -157,7 +157,7 @@ public function testValueData()
$this->assertEquals(json_encode(array(
'value' => '2',
'label' => 'Bar'
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertSame($document2, $form->getData());
$this->assertNull($view->vars['route_name']);
@@ -226,7 +226,7 @@ public function testValueAjaxData()
$this->assertEquals(json_encode(array(
'value' => 2,
'label' => 'Bar',
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertSame($document2, $form->getData());
$this->assertEquals('Foo', $view->vars['autocompleter_value']);
@@ -261,7 +261,7 @@ public function testValueAjaxMultipleData()
$this->assertEquals(json_encode(array(
array('value' => 2, 'label' => 'Bar')
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertSame($existing, $form->getData());
$this->assertEquals('Foo, Bar, ', $view->vars['autocompleter_value']);
@@ -103,7 +103,7 @@ public function testDefaultValue()
), $view->vars['choices']);
$this->assertNull($form->getData());
- $this->assertEquals('', $form->getClientData());
+ $this->assertEquals('', $form->getViewData());
$this->assertNull($view->vars['route_name']);
$this->assertEquals('', $view->vars['autocompleter_value']);
@@ -133,7 +133,7 @@ public function testMultipleValue()
), $view->vars['choices']);
$this->assertNull($form->getData());
- $this->assertEquals('', $form->getClientData());
+ $this->assertEquals('', $form->getViewData());
$this->assertNull($view->vars['route_name']);
$this->assertEquals('', $view->vars['autocompleter_value']);
@@ -167,7 +167,7 @@ public function testValueData()
$this->assertEquals(json_encode(array(
'value' => '2',
'label' => 'Bar'
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertSame($entity2, $form->getData());
$this->assertNull($view->vars['route_name']);
@@ -206,7 +206,7 @@ public function testValueMultipleData()
$this->assertEquals(json_encode(array(
array('value' => '1', 'label' => 'Foo'),
array('value' => '2', 'label' => 'Bar'),
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertSame($existing, $form->getData());
$this->assertEquals('Foo, ', $view->vars['autocompleter_value']);
@@ -237,7 +237,7 @@ public function testValueAjaxData()
$this->assertEquals(json_encode(array(
'value' => 2,
'label' => 'Bar',
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertSame($entity2, $form->getData());
$this->assertEquals('Foo', $view->vars['autocompleter_value']);
@@ -287,7 +287,7 @@ public function testValueAjaxMultipleData()
$this->assertEquals(json_encode(array(
array('value' => 2, 'label' => 'Bar')
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertSame($existing, $form->getData());
$this->assertEquals('Foo, Bar, ', $view->vars['autocompleter_value']);
@@ -99,7 +99,7 @@ public function testValueWithAjax()
$this->assertEquals(json_encode(array(
'value' => 'bar',
'label' => 'bar',
- )), $form->getClientData());
+ )), $form->getViewData());
}
public function testValueMultipleWithAjax()
@@ -140,7 +140,7 @@ public function testValueMultiple()
$this->assertEquals(json_encode(array(
array('value' => 'foo', 'label' => 'Foo'),
- )), $form->getClientData());
+ )), $form->getViewData());
$this->assertEquals(array('foo'), $form->getData());
@@ -42,7 +42,7 @@ public function testDefaultConfigs()
$this->assertEquals('', $view->vars['value']);
$this->assertFalse($view->vars['required']);
- $this->assertEquals(realpath(__DIR__.'/../../../Fixtures'), realpath($form->getAttribute('rootDir')));
+ $this->assertEquals(realpath(__DIR__.'/../../../Fixtures'), realpath($form->getConfig()->getAttribute('rootDir')));
$this->assertEquals('/upload', $configs['folder']);
$this->assertEquals('/swf/uploadify.swf', $configs['uploader']);
@@ -42,7 +42,7 @@ public function testDefaultConfigs()
$this->assertEquals('', $view->vars['value']);
$this->assertFalse($view->vars['required']);
- $this->assertEquals(realpath(__DIR__.'/../../../Fixtures'), realpath($form->getAttribute('rootDir')));
+ $this->assertEquals(realpath(__DIR__.'/../../../Fixtures'), realpath($form->getConfig()->getAttribute('rootDir')));
$this->assertEquals('/upload', $configs['folder']);
$this->assertEquals('/swf/uploadify.swf', $configs['uploader']);
@@ -77,7 +77,7 @@ public function testValue()
$form->setData('/upload/symfony.png');
$view = $form->createView();
- $this->assertEquals('/upload/symfony.png', $form->getClientData());
+ $this->assertEquals('/upload/symfony.png', $form->getViewData());
$this->assertEquals('/upload/symfony.png', $view->vars['value']);
}
Oops, something went wrong.

0 comments on commit ee4dfc6

Please sign in to comment.