Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage custom types in Condition value #133

Closed
Bashka opened this issue Jan 9, 2017 · 2 comments
Closed

Usage custom types in Condition value #133

Bashka opened this issue Jan 9, 2017 · 2 comments

Comments

@Bashka
Copy link

Bashka commented Jan 9, 2017

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
Copy link
Member

Perhaps this problem has already been solved in #143. Check, please.

@peter-gribanov
Copy link
Member

Now you can specify the data type explicitly:

Spec::eq('type', Spec::value(new OfferType(OfferType::GROUP), 'offerType'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants