Skip to content

Commit

Permalink
Merge pull request #60 from chives/dev
Browse files Browse the repository at this point in the history
Symfony 2.7 compatibility
  • Loading branch information
JarekW committed Jun 8, 2015
2 parents d613ff1 + a064770 commit 528548d
Show file tree
Hide file tree
Showing 27 changed files with 156 additions and 180 deletions.
10 changes: 8 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

sudo: false

env:
- COMPOSER_FLAGS=""
- COMPOSER_FLAGS="--prefer-lowest"

before_script:
- composer update --no-interaction
- composer update --no-interaction ${COMPOSER_FLAGS}

script: bin/phpunit

Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
}
],
"require": {
"php": ">=5.3.0",
"php": ">=5.4.0",
"symfony/event-dispatcher" : "~2.2",
"symfony/property-access": "~2.2",
"symfony/options-resolver": "~2.2",
"symfony/property-access": "~2.3",
"symfony/options-resolver": "~2.6",
"fsi/reflection" : "0.9.*",
"fsi/data-indexer" : "0.9.*"
},
"require-dev": {
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/common": "~2.2,>=2.2.3",
"gedmo/doctrine-extensions": "2.3.*",
"symfony/form" : "~2.2",
"doctrine/orm": "~2.5",
"doctrine/common": "~2.5",
"gedmo/doctrine-extensions": "~2.3.10",
"symfony/form" : "~2.4",
"symfony/doctrine-bridge": "~2.2",
"symfony/security" : "~2.2",
"symfony/security-csrf" : "~2.4",
"symfony/routing" : "~2.2",
"symfony/http-foundation": "~2.2",
"symfony/dependency-injection" : "~2.2",
Expand All @@ -41,7 +41,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
"dev-master": "1.2-dev"
}
}
}
4 changes: 2 additions & 2 deletions lib/FSi/Component/DataGrid/Column/ColumnTypeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace FSi\Component\DataGrid\Column;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use FSi\Component\DataGrid\DataGridInterface;
use FSi\Component\DataGrid\Column\CellViewInterface;
use FSi\Component\DataGrid\Column\HeaderViewInterface;
Expand Down Expand Up @@ -159,7 +159,7 @@ public function getExtensions();
/**
* Returns the configured options resolver used for this type.
*
* @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver.
* @return \Symfony\Component\OptionsResolver\OptionsResolver The options resolver.
*/
public function getOptionsResolver();
}
10 changes: 5 additions & 5 deletions lib/FSi/Component/DataGrid/DataMapper/ChainMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace FSi\Component\DataGrid\DataMapper;

use FSi\Component\DataGrid\Exception\DataMappingExteption;
use FSi\Component\DataGrid\Exception\DataMappingException;

class ChainMapper implements DataMapperInterface
{
Expand Down Expand Up @@ -47,7 +47,7 @@ public function getData($field, $object)
foreach ($this->mappers as $mapper) {
try {
$data = $mapper->getData($field, $object);
} catch (DataMappingExteption $e) {
} catch (DataMappingException $e) {
$data = null;
$lastMsg = $e->getMessage();
continue;
Expand All @@ -61,7 +61,7 @@ public function getData($field, $object)
if (!isset($lastMsg)) {
$lastMsg = sprintf('Cant find any data that fit "%s" field.', $field);
}
throw new DataMappingExteption($lastMsg);
throw new DataMappingException($lastMsg);
}

return $data;
Expand All @@ -79,7 +79,7 @@ public function setData($field, $object, $value)
foreach ($this->mappers as $mapper) {
try {
$mapper->setData($field, $object, $value);
} catch (DataMappingExteption $e) {
} catch (DataMappingException $e) {
$lastMsg = $e->getMessage();
continue;
}
Expand All @@ -93,7 +93,7 @@ public function setData($field, $object, $value)
$lastMsg = sprintf('Cant find any data that fit "%s" field.', $field);
}

throw new DataMappingExteption($lastMsg);
throw new DataMappingException($lastMsg);
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions lib/FSi/Component/DataGrid/DataMapper/DataMapperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface DataMapperInterface
* @param string $field
* @param mixed $object
* @return boolean - return false if can't get value from object
* @throws \FSi\Component\DataGrid\Exception\DataMappingExteption - thrown when mapper cant fit any object data into column
* @throws \FSi\Component\DataGrid\Exception\DataMappingException - thrown when mapper cant fit any object data into column
*/
public function getData($field, $object);

Expand All @@ -28,7 +28,7 @@ public function getData($field, $object);
* @param mixed $object
* @param mixed $value
* @return boolean - return true if value was correctly changed
* @throws \FSi\Component\DataGrid\Exception\DataMappingExteption - thrown when mapper cant fit any object data into column
* @throws \FSi\Component\DataGrid\Exception\DataMappingException - thrown when mapper cant fit any object data into column
*/
public function setData($field, $object, $value);
}
10 changes: 5 additions & 5 deletions lib/FSi/Component/DataGrid/DataMapper/PropertyAccessorMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace FSi\Component\DataGrid\DataMapper;

use FSi\Component\DataGrid\Exception\DataMappingExteption;
use FSi\Component\DataGrid\Exception\DataMappingException;
use Symfony\Component\PropertyAccess\Exception\RuntimeException;
use Symfony\Component\PropertyAccess\PropertyAccess;

Expand All @@ -20,12 +20,12 @@ class PropertyAccessorMapper implements DataMapperInterface
*/
public function getData($field, $object)
{
$accessor = PropertyAccess::getPropertyAccessor();
$accessor = PropertyAccess::createPropertyAccessor();

try {
$data = $accessor->getValue($object, $field);
} catch (RuntimeException $e) {
throw new DataMappingExteption($e->getMessage());
throw new DataMappingException($e->getMessage());
}

return $data;
Expand All @@ -36,12 +36,12 @@ public function getData($field, $object)
*/
public function setData($field, $object, $value)
{
$accessor = PropertyAccess::getPropertyAccessor();
$accessor = PropertyAccess::createPropertyAccessor();

try {
$accessor->setValue($object, $field, $value);
} catch (RuntimeException $e) {
throw new DataMappingExteption($e->getMessage());
throw new DataMappingException($e->getMessage());
}
}
}
24 changes: 12 additions & 12 deletions lib/FSi/Component/DataGrid/DataMapper/ReflectionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace FSi\Component\DataGrid\DataMapper;

use FSi\Component\Reflection\ReflectionClass;
use FSi\Component\DataGrid\Exception\DataMappingExteption;
use FSi\Component\DataGrid\Exception\DataMappingException;

class ReflectionMapper implements DataMapperInterface
{
Expand All @@ -21,7 +21,7 @@ class ReflectionMapper implements DataMapperInterface
public function getData($field, $object)
{
if (!is_object($object)) {
throw new DataMappingExteption('Reflection mapper needs object to retrieve data.');
throw new DataMappingException('Reflection mapper needs object to retrieve data.');
}

$objectReflection = ReflectionClass::factory($object);
Expand All @@ -32,37 +32,37 @@ public function getData($field, $object)

if ($objectReflection->hasMethod($getter)) {
if (!$objectReflection->getMethod($getter)->isPublic()) {
throw new DataMappingExteption(sprintf('Method "%s()" is not public in class "%s"', $getter, $objectReflection->name));
throw new DataMappingException(sprintf('Method "%s()" is not public in class "%s"', $getter, $objectReflection->name));
}

return $object->$getter();
}

if ($objectReflection->hasMethod($isser)) {
if (!$objectReflection->getMethod($isser)->isPublic()) {
throw new DataMappingExteption(sprintf('Method "%s()" is not public in class "%s"', $isser, $objectReflection->name));
throw new DataMappingException(sprintf('Method "%s()" is not public in class "%s"', $isser, $objectReflection->name));
}

return $object->$isser();
}

if ($objectReflection->hasMethod($hasser)) {
if (!$objectReflection->getMethod($hasser)->isPublic()) {
throw new DataMappingExteption(sprintf('Method "%s()" is not public in class "%s"', $hasser, $objectReflection->name));
throw new DataMappingException(sprintf('Method "%s()" is not public in class "%s"', $hasser, $objectReflection->name));
}

return $object->$hasser();
}

if ($objectReflection->hasProperty($field)) {
if (!$objectReflection->getProperty($field)->isPublic()) {
throw new DataMappingExteption(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $field, $objectReflection->name, $getter, $isser));
throw new DataMappingException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $field, $objectReflection->name, $getter, $isser));
}
$property = $objectReflection->getProperty($field);
return $property->getValue($object);
}

throw new DataMappingExteption(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $field, $getter, $isser, $objectReflection->name));
throw new DataMappingException(sprintf('Neither property "%s" nor method "%s()" nor method "%s()" exists in class "%s"', $field, $getter, $isser, $objectReflection->name));
}

/**
Expand All @@ -71,7 +71,7 @@ public function getData($field, $object)
public function setData($field, $object, $value)
{
if (!is_object($object)) {
throw new DataMappingExteption('Reflection mapper needs object to retrieve data.');
throw new DataMappingException('Reflection mapper needs object to retrieve data.');
}

$objectReflection = ReflectionClass::factory($object);
Expand All @@ -81,29 +81,29 @@ public function setData($field, $object, $value)

if ($objectReflection->hasMethod($setter)) {
if (!$objectReflection->getMethod($setter)->isPublic()) {
throw new DataMappingExteption(sprintf('Method "%s()" is not public in class "%s"', $setter, $objectReflection->name));
throw new DataMappingException(sprintf('Method "%s()" is not public in class "%s"', $setter, $objectReflection->name));
}

return $object->$setter($value);
}

if ($objectReflection->hasMethod($adder)) {
if (!$objectReflection->getMethod($adder)->isPublic()) {
throw new DataMappingExteption(sprintf('Method "%s()" is not public in class "%s"', $adder, $objectReflection->name));
throw new DataMappingException(sprintf('Method "%s()" is not public in class "%s"', $adder, $objectReflection->name));
}

return $object->$adder($value);
}

if ($objectReflection->hasProperty($field)) {
if (!$objectReflection->getProperty($field)->isPublic()) {
throw new DataMappingExteption(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $field, $objectReflection->name, $setter, $adder));
throw new DataMappingException(sprintf('Property "%s" is not public in class "%s". Maybe you should create the method "%s()" or "%s()"?', $field, $objectReflection->name, $setter, $adder));
}
$property = $objectReflection->getProperty($field);
return $property->setValue($object, $value);
}

throw new DataMappingExteption(sprintf('Neither property "%s" nor method "%s()" exists in class "%s"', $setter, $adder, $objectReflection->name));
throw new DataMappingException(sprintf('Neither property "%s" nor method "%s()" exists in class "%s"', $setter, $adder, $objectReflection->name));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

namespace FSi\Component\DataGrid\Exception;

/**
* @todo Fix class name in version 1.1.
*/
class DataMappingExteption extends DataGridException
class DataMappingException extends DataGridException
{
}
17 changes: 4 additions & 13 deletions lib/FSi/Component/DataGrid/Extension/Core/ColumnType/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ public function initOptions()
'actions' => array(),
));

$this->getOptionsResolver()->setAllowedTypes(array(
'actions' => 'array',
));
$this->getOptionsResolver()->setAllowedTypes('actions', 'array');

$this->actionOptionsResolver->setDefaults(array(
'redirect_uri' => null,
Expand All @@ -116,17 +114,10 @@ public function initOptions()
'uri_scheme'
));

$this->actionOptionsResolver->setAllowedTypes(array(
'redirect_uri' => array('string', 'null'),
'uri_scheme' => 'string',
));
$this->actionOptionsResolver->setAllowedTypes('redirect_uri', array('string', 'null'));
$this->actionOptionsResolver->setAllowedTypes('uri_scheme', 'string');

$this->actionOptionsResolver->addAllowedValues(array(
'protocol' => array(
'http://',
'https://'
)
));
$this->actionOptionsResolver->setAllowedValues('protocol', array('http://', 'https://'));

$this->actionOptionsResolver->setDefaults(array(
'protocol' => function (Options $options, $value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public function initOptions()
'collection_glue' => ' '
));

$this->getOptionsResolver()->setAllowedTypes(array(
'collection_glue' => 'string'
));
$this->getOptionsResolver()->setAllowedTypes('collection_glue', 'string');
}
}
24 changes: 8 additions & 16 deletions lib/FSi/Component/DataGrid/Extension/Core/ColumnType/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,14 @@ public function initOptions()
'input_field_format' => null
));

$this->getOptionsResolver()->setAllowedTypes(array(
'input_field_format' => array(
'null',
'array',
'string'
)
));

$this->getOptionsResolver()->setAllowedValues(array(
'input_type' => array(
null,
'string',
'timestamp',
'datetime',
'array'
)
$this->getOptionsResolver()->setAllowedTypes('input_field_format', array('null', 'array', 'string'));

$this->getOptionsResolver()->setAllowedValues('input_type', array(
null,
'string',
'timestamp',
'datetime',
'array'
));
}

Expand Down
20 changes: 9 additions & 11 deletions lib/FSi/Component/DataGrid/Extension/Core/ColumnType/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,14 @@ public function initOptions()
'currency_field' => null,
));

$this->getOptionsResolver()->setAllowedTypes(array(
'round_mode' => 'integer',
'precision' => 'integer',
'decimals' => 'integer',
'decimals' => 'integer',
'dec_point' => 'string',
'thousands_sep' => 'string',
'value_currency_separator' => 'string',
'currency' => array('null', 'string'),
'currency_field' => array('null', 'string'),
));
$this->getOptionsResolver()->setAllowedTypes('round_mode', 'integer');
$this->getOptionsResolver()->setAllowedTypes('precision', 'integer');
$this->getOptionsResolver()->setAllowedTypes('decimals', 'integer');
$this->getOptionsResolver()->setAllowedTypes('decimals', 'integer');
$this->getOptionsResolver()->setAllowedTypes('dec_point', 'string');
$this->getOptionsResolver()->setAllowedTypes('thousands_sep', 'string');
$this->getOptionsResolver()->setAllowedTypes('value_currency_separator', 'string');
$this->getOptionsResolver()->setAllowedTypes('currency', array('null', 'string'));
$this->getOptionsResolver()->setAllowedTypes('currency_field', array('null', 'string'));
}
}
Loading

0 comments on commit 528548d

Please sign in to comment.