Exemplo n.º 1
0
    /**
     * @param \DateTime $maximumThumbnailAge
     *
     * @return SiteData\SiteForThumbnailUpdate|null
     */
    public function yieldSiteForThumbnailUpdate(\DateTime $maximumThumbnailAge)
    {
        $selectQuery = <<<SQL
SELECT s.id, s.url, s.http_username, s.http_password, s.thumbnailPath
FROM Site s
WHERE
  (
    # Thumbnail is not set...
    s.thumbnailPath IS NULL
    # ... or thumbnail is at least this old.
    OR (s.thumbnailUpdatedAt < :lockTimeout)
  )
  AND
  (
    # There is no lock...
    s.thumbnailLockedAt IS NULL
    OR
    # .. or the lock has expired.
    s.thumbnailLockedAt < :lockTimeout
  )
ORDER BY
  # Prioritize sites without a thumbnail.
  s.thumbnailPath IS NULL DESC
SQL;
        $data = $this->em->getConnection()->fetchAssoc($selectQuery, ['lockTimeout' => $maximumThumbnailAge->format('Y-m-d H:i:s')]);
        if ($data === false) {
            return null;
        }
        return new SiteData\SiteForThumbnailUpdate(\Undine\Functions\binary_to_uuid($data['id']), $data['url'], $data['http_username'], $data['http_password'], $data['thumbnailPath']);
    }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     if ($value === null) {
         return null;
     }
     try {
         return \Undine\Functions\binary_to_uuid($value);
     } catch (Uuid1TransformException $e) {
         throw ConversionException::conversionFailed($value, self::NAME);
     }
 }