Usage custom types in Condition value
Bashka opened this issue · 2 comments
Bashka commented
For example:
Spec::orX(
Spec::eq('type', new OfferType(OfferType::GROUP)),
Spec::eq('type', new OfferType(OfferType::PERSONAL))
);
This OfferType
use Custom Doctrine Type OfferTypeType
:
class OfferTypeType extends Type{
...
public function convertToPHPValue($value, AbstractPlatform $platform){
return new OfferType(self::convertCodeToName((int) $value));
}
public function convertToDatabaseValue($value, AbstractPlatform $platform){
return self::convertNameToCode($value->getNmae());
}
}
class Offer{
...
/**
* @ORM\Column(type="offerType")
*/
private $type;
...
}
But OfferTypeType
not using in Spec condition:
Catchable fatal error: Object of class OfferType could not be converted to string in /var/www/work/ga/backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php on line 67
P.S. Sorry for my English.
peter-gribanov commented
Perhaps this problem has already been solved in #143. Check, please.
peter-gribanov commented
Now you can specify the data type explicitly:
Spec::eq('type', Spec::value(new OfferType(OfferType::GROUP), 'offerType'));