![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/EmailBundle/Entity/ |
<?php namespace Mautic\EmailBundle\Entity; use Doctrine\ORM\NoResultException; use Mautic\CoreBundle\Entity\CommonRepository; /** * @extends CommonRepository<Copy> */ class CopyRepository extends CommonRepository { /** * @param string $hash * @param string $subject * @param string $body * @param string $bodyText */ public function saveCopy($hash, $subject, $body, $bodyText) { $db = $this->getEntityManager()->getConnection(); try { $db->insert( MAUTIC_TABLE_PREFIX.'email_copies', [ 'id' => $hash, 'body' => $body, 'body_text' => $bodyText, 'subject' => $subject, 'date_created' => (new \DateTime())->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s'), ] ); return true; } catch (\Exception $e) { error_log($e); return false; } } /** * @param string $string md5 hash or content * * @return array */ public function findByHash($string, $subject = null) { if (null !== $subject) { // Combine subject with $string and hash together $string = $subject.$string; } // Assume that $string is already a md5 hash if 32 characters $hash = (32 !== strlen($string)) ? $hash = md5($string) : $string; $q = $this->createQueryBuilder($this->getTableAlias()); $q->where( $q->expr()->eq($this->getTableAlias().'.id', ':id') ) ->setParameter('id', $hash); try { $result = $q->getQuery()->getSingleResult(); } catch (NoResultException) { $result = null; } return $result; } public function getTableAlias(): string { return 'ec'; } }