-
Notifications
You must be signed in to change notification settings - Fork 1
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
OHRM-941:Integrate Doctrine 2.6 for i18n related entities #10
base: 4.6
Are you sure you want to change the base?
Conversation
->leftJoin('t.I18NLangString ls') | ||
->leftJoin('t.I18NLanguage l') | ||
->andWhere('l.code = ?', $langCode); | ||
$q = Doctrine2::getEntityManager()->getRepository(I18NTranslate::class)->createQueryBuilder('t'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part may be abstract to DAO class .. something like $this->getQueryBuilder()
* @throws DaoException | ||
*/ | ||
public function getLanguageByCode(string $langCode) | ||
{ | ||
try { | ||
return Doctrine::getTable('I18NLanguage')->findOneBy('code', $langCode); | ||
return Doctrine2::getEntityManager()->getRepository(I18NLanguage::class)->findOneBy(['code' => $langCode]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reuse $this->queryBuilder here
|
||
if (!empty($searchParams->getParameter('langCode'))) { | ||
$q->andWhere('l.code = ?', $searchParams->getParameter('langCode')); | ||
$q->andWhere('l.code = :langCode'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good, binding param with a name
* @throws DaoException | ||
*/ | ||
public function getI18NSource(string $source) | ||
{ | ||
try { | ||
return Doctrine::getTable('I18NSource')->findOneBy('source', $source); | ||
return Doctrine2::getEntityManager()->getRepository(I18NSource::class)->findOneBy(['source' => $source]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if use orangehrm/orm class that wraps doctrine stuff ?
@@ -272,7 +279,8 @@ public function saveI18NTranslate(I18NTranslate $i18NTranslate) | |||
*/ | |||
public function saveI18NLanguage(I18NLanguage $i18NLanguage) | |||
{ | |||
$i18NLanguage->save(); | |||
Doctrine2::getEntityManager()->persist($i18NLanguage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doctrine2 may replace oranghrm/orm:getEntityManager()
No description provided.