Пример #1
0
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if ($value !== null) {
         $value = utf8_decode($value);
     }
     return parent::convertToDatabaseValue($value, $platform);
 }
Пример #2
0
 /**
  * 
  * @param string $value
  * @param AbstractPlatform $platform
  * @return string
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     try {
         $v = parent::convertToDatabaseValue($value, $platform);
         return BlockCipher::factory('mcrypt', array('algo' => 'aes'))->setKey(self::KEY)->encrypt($v);
     } catch (\Exception $ex) {
         return $value;
     }
 }
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!$value) {
         return '';
     }
     if (false === $value instanceof Source) {
         throw new \RuntimeException("Value should be a Source type.");
     }
     return parent::convertToDatabaseValue($value->getValue(), $platform);
 }
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!$value) {
         return '';
     }
     if (false === $value instanceof Priority) {
         throw new \RuntimeException("Variable type validation failed, value should be a Priority type");
     }
     return parent::convertToDatabaseValue($value->getValue(), $platform);
 }
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!$value) {
         return '';
     }
     if (false === $value instanceof User) {
         throw new \RuntimeException("Value should be a User type.");
     }
     return parent::convertToDatabaseValue((string) $value, $platform);
 }
 /**
  * @param File $value
  * @param AbstractPlatform $platform
  * @return string
  * @throws \RuntimeException
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!$value) {
         return '';
     }
     if (false === $value instanceof File) {
         throw new \RuntimeException("Value should be a File type.");
     }
     /** @var $value File */
     return parent::convertToDatabaseValue($value->getPathname(), $platform);
 }
Пример #7
0
 /**
  * @see \Doctrine\DBAL\Types\Type::convertToDatabaseValue()
  * @param string|null $sValue
  * @param \Doctrine\DBAL\Platforms\AbstractPlatform $oPlatform
  * @throws \InvalidArgumentException
  * @return string
  */
 public function convertToDatabaseValue($sValue, \Doctrine\DBAL\Platforms\AbstractPlatform $oPlatform)
 {
     if (is_null($sValue)) {
         return parent::convertToDatabaseValue($sValue, $oPlatform);
     }
     if (!is_string($sValue)) {
         throw new \InvalidArgumentException(sprintf(__FUNCTION__ . ' expects a string as value, "%s" given', gettype($sValue)));
     }
     if ($sFilterValue = filter_var($sValue, FILTER_VALIDATE_IP)) {
         return parent::convertToDatabaseValue($sFilterValue, $oPlatform);
     }
     throw new \InvalidArgumentException(__FUNCTION__ . ' expects a valid IP adress as value, "' . $sValue . '" given');
 }
 /**
  * @param Logo $value
  * @param AbstractPlatform $platform
  * @return mixed|string
  * @throws \RuntimeException
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!$value) {
         return '';
     }
     if (false === $value instanceof Logo) {
         throw new \RuntimeException("Variable type validation failed, value should be a Logo type");
     }
     $logo = null;
     $name = $value->getName();
     $originalName = $value->getOriginalName();
     if ($name && $originalName) {
         $logo = $name . self::DELIMITER . $originalName;
     }
     return parent::convertToDatabaseValue($logo, $platform);
 }