Fix hidden use of repositories

This commit is contained in:
Romain Neutron
2014-02-27 17:26:33 +01:00
parent 6a06492679
commit 06f29575c7
8 changed files with 22 additions and 21 deletions

View File

@@ -103,8 +103,7 @@ class Lightbox implements ControllerProviderInterface
return new Response(''); return new Response('');
} }
$basketElement = $app['EM'] $basketElement = $app['repo.basket-elements']
->getRepository('Phraseanet:BasketElement')
->findUserElement($sselcont_id, $app['authentication']->getUser()); ->findUserElement($sselcont_id, $app['authentication']->getUser());
$parameters = [ $parameters = [

View File

@@ -305,8 +305,7 @@ class Login implements ControllerProviderInterface
return $app->redirectPath('login_register'); return $app->redirectPath('login_register');
} }
$userAuthProvider = $app['EM'] $userAuthProvider = $app['repo.usr-auth-providers']
->getRepository('Phraseanet:UsrAuthProvider')
->findWithProviderAndId($token->getProvider()->getId(), $token->getId()); ->findWithProviderAndId($token->getProvider()->getId(), $token->getId());
if (null !== $userAuthProvider) { if (null !== $userAuthProvider) {
@@ -827,8 +826,7 @@ class Login implements ControllerProviderInterface
{ {
$date = new \DateTime('+' . (int) $app['conf']->get(['registry', 'actions', 'validation-reminder-days']) . ' days'); $date = new \DateTime('+' . (int) $app['conf']->get(['registry', 'actions', 'validation-reminder-days']) . ' days');
foreach ($app['EM'] foreach ($app['repo.validation-participants']
->getRepository('Phraseanet:ValidationParticipant')
->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) { ->findNotConfirmedAndNotRemindedParticipantsByExpireDate($date) as $participant) {
/* @var $participant ValidationParticipant */ /* @var $participant ValidationParticipant */
@@ -900,8 +898,7 @@ class Login implements ControllerProviderInterface
return $app->redirectPath('homepage'); return $app->redirectPath('homepage');
} }
$userAuthProvider = $app['EM'] $userAuthProvider = $app['repo.usr-auth-providers']
->getRepository('Phraseanet:UsrAuthProvider')
->findWithProviderAndId($token->getProvider()->getId(), $token->getId()); ->findWithProviderAndId($token->getProvider()->getId(), $token->getId());
if (null !== $userAuthProvider) { if (null !== $userAuthProvider) {

View File

@@ -199,6 +199,9 @@ class ORMServiceProvider implements ServiceProviderInterface
$app['repo.basket-elements'] = $app->share(function (PhraseaApplication $app) { $app['repo.basket-elements'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:BasketElement'); return $app['EM']->getRepository('Phraseanet:BasketElement');
}); });
$app['repo.validation-participants'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:ValidationParticipant');
});
$app['repo.story-wz'] = $app->share(function (PhraseaApplication $app) { $app['repo.story-wz'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:StoryWZ'); return $app['EM']->getRepository('Phraseanet:StoryWZ');
}); });
@@ -235,6 +238,15 @@ class ORMServiceProvider implements ServiceProviderInterface
$app['repo.lazaret-files'] = $app->share(function (PhraseaApplication $app) { $app['repo.lazaret-files'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:LazaretFile'); return $app['EM']->getRepository('Phraseanet:LazaretFile');
}); });
$app['repo.usr-auth-providers'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:UsrAuthProvider');
});
$app['repo.ftp-exports'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:FtpExport');
});
$app['repo.user-queries'] = $app->share(function (PhraseaApplication $app) {
return $app['EM']->getRepository('Phraseanet:UserQuery');
});
} }
public function boot(Application $app) public function boot(Application $app)

View File

@@ -73,8 +73,7 @@ class FtpJob extends AbstractJob
private function removeDeadExports(Application $app) private function removeDeadExports(Application $app)
{ {
foreach ($app['EM'] foreach ($app['repo.ftp-exports']
->getRepository('Phraseanet:FtpExport')
->findCrashedExports(new \DateTime('-1 month')) as $export) { ->findCrashedExports(new \DateTime('-1 month')) as $export) {
$app['EM']->remove($export); $app['EM']->remove($export);
} }
@@ -83,8 +82,7 @@ class FtpJob extends AbstractJob
private function retrieveExports(Application $app) private function retrieveExports(Application $app)
{ {
return $app['EM'] return $app['repo.ftp-exports']
->getRepository('Phraseanet:FtpExport')
->findDoableExports(); ->findDoableExports();
} }

View File

@@ -96,8 +96,7 @@ class eventsmanager_notify_validate extends eventsmanager_notifyAbstract
$user_from = $this->app['repo.users']->find($params['from']); $user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']); $user_to = $this->app['repo.users']->find($params['to']);
$basket = $this->app['EM'] $basket = $this->app['repo.baskets']
->getRepository('Phraseanet:Basket')
->find($params['ssel_id']); ->find($params['ssel_id']);
$title = $basket->getName(); $title = $basket->getName();

View File

@@ -91,8 +91,7 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
$user_from = $this->app['repo.users']->find($params['from']); $user_from = $this->app['repo.users']->find($params['from']);
$user_to = $this->app['repo.users']->find($params['to']); $user_to = $this->app['repo.users']->find($params['to']);
$basket = $this->app['EM'] $basket = $this->app['repo.baskets']
->getRepository('Phraseanet:Basket')
->find($params['ssel_id']); ->find($params['ssel_id']);
$title = $basket->getName(); $title = $basket->getName();

View File

@@ -97,8 +97,7 @@ class eventsmanager_notify_validationreminder extends eventsmanager_notifyAbstra
$readyToSend = false; $readyToSend = false;
try { try {
$basket = $this->app['EM'] $basket = $this->app['repo.baskets']
->getRepository('Phraseanet:Basket')
->find($params['ssel_id']); ->find($params['ssel_id']);
$title = $basket->getName(); $title = $basket->getName();

View File

@@ -188,9 +188,7 @@ class queries
{ {
$history = '<ul>'; $history = '<ul>';
$queries = $app['EM'] $queries = $app['repo.user-queries']->findBy(['user' => $usrId], ['created' => 'ASC'], 25, 0);
->getRepository('Phraseanet:UserQuery')
->findBy(['user' => $usrId], ['created' => 'ASC'], 25, 0);
foreach ($queries as $query) { foreach ($queries as $query) {
$history .= '<li onclick="doSpecialSearch(\'' . str_replace(["'", '"'], ["\'", '&quot;'], $query->getQuery()) . '\')">' . $query->getQuery() . '</li>'; $history .= '<li onclick="doSpecialSearch(\'' . str_replace(["'", '"'], ["\'", '&quot;'], $query->getQuery()) . '\')">' . $query->getQuery() . '</li>';