protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->institutionMediaService = $this->getContainer()->get('services.institution.media');
     $this->fileSystem = $this->institutionMediaService->getFilesystem();
     $this->logoSizes = $this->institutionMediaService->getSizesByType(InstitutionMediaService::LOGO_TYPE_IMAGE);
     $this->featuredMediaSizes = $this->institutionMediaService->getSizesByType(InstitutionMediaService::FEATURED_TYPE_IMAGE);
     $this->gallerySizes = $this->institutionMediaService->getSizesByType(InstitutionMediaService::GALLERY_TYPE_IMAGE);
     // loop through all institutions
     $this->doctrine = $this->getContainer()->get('doctrine');
     $institutions = $this->doctrine->getRepository('InstitutionBundle:Institution')->findAll();
     foreach ($institutions as $_institution) {
         $this->output->writeln('Migrating images of institution #' . $_institution->getId());
         $this->output->write("    ");
         // migrate logo
         $this->migrateLogo($_institution);
         $this->output->write("    ");
         // migrate banner
         $this->migrateFeaturedMedia($_institution);
         $this->output->write("    ");
         // migrate gallery
         $this->migrateGallery($_institution);
         $this->output->write("    ");
         // migrate clinic logos
         foreach ($_institution->getInstitutionMedicalCenters() as $imc) {
             $this->migrateClinicLogo($imc);
             $this->output->write("    ");
         }
         $this->output->writeln('All Done.');
     }
     $this->output->writeln('END OF SCRIPT');
 }
 /**
  * @param Registry      $manager,
  * @param RequestStack  $requestStack,
  * @param ObjectManager $persistence
  *
  * @InjectParams({
  *     "manager"        = @Inject("doctrine"),
  *     "requestStack"   = @Inject("request_stack"),
  *     "persistence"    = @Inject("claroline.persistence.object_manager")
  * })
  */
 public function __construct(Registry $manager, RequestStack $requestStack, ObjectManager $persistence)
 {
     $this->manager = $persistence;
     $this->request = $requestStack->getCurrentRequest();
     $this->content = $manager->getRepository('ClarolineCoreBundle:Content');
     $this->translations = $manager->getRepository('ClarolineCoreBundle:ContentTranslation');
 }
 /**
  * @param GridView $entity
  */
 protected function onSuccess(GridView $entity)
 {
     $this->fixFilters($entity);
     $om = $this->registry->getManagerForClass('OroDataGridBundle:GridView');
     $om->persist($entity);
     $om->flush();
 }
 /**
  * @return EntityManager
  */
 private function getEntityManager()
 {
     if (!$this->doctrine) {
         $this->doctrine = $this->container->get('doctrine');
     }
     return $this->doctrine->getManager($this->entityManagerName);
 }
 /**
  * @param UserEmailOrigin $origin
  *
  * @return string
  */
 public function getAccessTokenWithCheckingExpiration(UserEmailOrigin $origin)
 {
     $expiresAt = $origin->getAccessTokenExpiresAt();
     $utcTimeZone = new \DateTimeZone('UTC');
     $now = new \DateTime('now', $utcTimeZone);
     $token = $origin->getAccessToken();
     //if token had been expired, the new one must be generated and saved to DB
     if ($now > $expiresAt && $this->configManager->get('oro_imap.enable_google_imap')) {
         $parameters = ['refresh_token' => $origin->getRefreshToken(), 'grant_type' => 'refresh_token'];
         $attemptNumber = 0;
         do {
             $attemptNumber++;
             $response = $this->doHttpRequest($parameters);
             if (!empty($response['access_token'])) {
                 $token = $response['access_token'];
                 $origin->setAccessToken($token);
                 $newExpireDate = new \DateTime('+' . $response['expires_in'] . ' seconds', $utcTimeZone);
                 $origin->setAccessTokenExpiresAt($newExpireDate);
                 $this->doctrine->getManager()->persist($origin);
                 $this->doctrine->getManager()->flush();
             }
         } while ($attemptNumber <= self::RETRY_TIMES && empty($response['access_token']));
     }
     return $token;
 }
 /**
  * @param $date
  * @param $item
  * @param $precision 
  * @param $route_new
  * @param $route_show 
  */
 public function renderDay($date, $item, $project, $precision, $route_new, $route_show)
 {
     $start = new \DateTime($date);
     $end = (new \DateTime($date))->modify('+1 day');
     $bookings = $this->doctrine->getRepository($this->entity)->createQueryBuilder('b')->select('b')->where('b.start <= :start and b.end >= :end')->orwhere('b.end >= :start and b.end <= :end')->orwhere('b.start >= :start and b.start <= :end')->andWhere('b.item = :item')->orderBy('b.start', 'ASC')->setParameters(array('start' => $start, 'end' => $end, 'item' => $item))->getQuery()->getResult();
     return $this->environment->render('SladBookingBundle:Calendar:day.html.twig', array('date' => new \DateTime($date), 'item' => $item, 'project' => $project, 'bookings' => $bookings, 'precision' => $precision, 'route_new' => $route_new, 'route_show' => $route_show));
 }
 /**
  * @param LineItem $lineItem
  *
  * @return bool
  */
 public function process(LineItem $lineItem)
 {
     if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) {
         /** @var EntityManagerInterface $manager */
         $manager = $this->registry->getManagerForClass('OroB2BShoppingListBundle:LineItem');
         $manager->beginTransaction();
         // handle case for new shopping list creation
         $formName = $this->form->getName();
         $formData = $this->request->request->get($formName, []);
         if (empty($formData['shoppingList']) && !empty($formData['shoppingListLabel'])) {
             $shoppingList = $this->shoppingListManager->createCurrent($formData['shoppingListLabel']);
             $formData['shoppingList'] = $shoppingList->getId();
             $this->request->request->set($formName, $formData);
         }
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             /** @var LineItemRepository $lineItemRepository */
             $lineItemRepository = $manager->getRepository('OroB2BShoppingListBundle:LineItem');
             $existingLineItem = $lineItemRepository->findDuplicate($lineItem);
             if ($existingLineItem) {
                 $this->updateExistingLineItem($lineItem, $existingLineItem);
             } else {
                 $manager->persist($lineItem);
             }
             $manager->flush();
             $manager->commit();
             return true;
         } else {
             $manager->rollBack();
         }
     }
     return false;
 }
Beispiel #8
0
 public function loadUserByUsername($username)
 {
     if (!$username) {
         return null;
     }
     return $this->_doctrine->getRepository('SiteBundle:User')->findOneBy(['username' => $username]);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->doctrine = $this->getContainer()->get('doctrine');
     // get all cities
     $qb = $this->doctrine->getManager()->createQueryBuilder();
     $qb->select('ct')->from('HelperBundle:City', 'ct')->where('ct.geoCityId IS NOT NULL')->orderBy('ct.id', 'ASC');
     $cities = $qb->getQuery()->getResult();
     $connection = $this->doctrine->getConnection();
     foreach ($cities as $city) {
         $output->write('Updating data of old city #' . $city->getId());
         $sql = "SELECT cg_gct.* FROM `chromedia_global`.`geo_cities` cg_gct WHERE cg_gct.`id` = ?";
         $statement = $connection->prepare($sql);
         $statement->bindValue(1, $city->getGeoCityId());
         $statement->execute();
         $globalCityData = $statement->fetch();
         if ($globalCityData) {
             $updateSql = "UPDATE `cities` SET `id` = :geoCityId, `name` = :geoCityName, `slug` = :geoCitySlug WHERE `old_id` = :oldId";
             $updateStatement = $connection->prepare($updateSql);
             $updateStatement->bindValue('geoCityId', $globalCityData['id']);
             $updateStatement->bindValue('geoCityName', $globalCityData['name']);
             $updateStatement->bindValue('geoCitySlug', $globalCityData['slug']);
             $updateStatement->bindValue('oldId', $city->getOldId());
             $updateStatement->execute();
             $output->writeln(' OK');
         } else {
             $output->writeln(' Not found');
         }
     }
 }
 /**
  * Dispatch a covoit using database alerts.
  * Find matching alerts, create notifications and send them.
  *
  * @param Covoit $covoit
  */
 public function dispatch(Covoit $covoit)
 {
     /** @var EntityManager $em */
     $em = $this->doctrine->getManager();
     /*
      * We find all the alerts and try to match these objects with the covoit. However, as the number of result could
      * be big, we use some simple conditions to limit results : he startCity, the endCity and the price. Matching
      * date is difficult directly in SQL as the condition depends of which fields are filled.
      */
     /** @var CovoitAlert[] $alerts */
     $alerts = $em->createQueryBuilder()->select('a, s, e, u')->from('EtuModuleCovoitBundle:CovoitAlert', 'a')->leftJoin('a.startCity', 's')->leftJoin('a.endCity', 'e')->leftJoin('a.user', 'u')->where('a.startCity = :startCiy OR a.startCity IS NULL')->andWhere('a.endCity = :endCity OR a.endCity IS NULL')->andWhere('a.priceMax <= :price OR a.priceMax IS NULL')->setParameters(['startCiy' => $covoit->getStartCity()->getId(), 'endCity' => $covoit->getEndCity()->getId(), 'price' => $covoit->getPrice()])->getQuery()->getResult();
     // Notifications - Send only one notification per user, even if covoit match several alerts
     $notifications = [];
     foreach ($alerts as $alert) {
         if ($this->match($alert, $covoit)) {
             $notif = $this->createNotification($covoit);
             $notif->setEntityId($alert->getId());
             $notif->setAuthorId($covoit->getAuthor()->getId());
             $notifications[$alert->getUser()->getId()] = $notif;
         }
     }
     // Send the notifications
     foreach ($notifications as $notification) {
         $this->sender->send($notification);
     }
 }
 /**
  * @param string $entityType
  * @param integer $entityId
  * @param User $user
  * @return bool
  */
 public function unsubscribe(User $user, $entityType, $entityId)
 {
     /** @var $em EntityManager */
     $em = $this->doctrine->getManager();
     $em->createQueryBuilder()->delete('EtuCoreBundle:Subscription', 's')->andWhere('s.entityId = :entityId')->andWhere('s.entityType = :entityType')->andWhere('s.user = :user')->setParameter('entityType', $entityType)->setParameter('entityId', $entityId)->setParameter('user', $user->getId())->getQuery()->execute();
     return true;
 }
 public function __construct(ContainerInterface $container, UrlGeneratorInterface $router, SecurityContext $securityContext, Doctrine $doctrine)
 {
     $this->router = $router;
     $this->securityContext = $securityContext;
     $this->em = $doctrine->getManager();
     $this->container = $container;
 }
 /**
  * @param string $blockName
  * @param array  $options
  * @param string $default
  * @return string
  */
 public function contentBlock($blockName, $options = array(), $default = null)
 {
     $em = $this->doctrine->getManager();
     $repository = $em->getRepository('GlavwebContentBlockBundle:ContentBlock');
     $contentBlock = $repository->findOneByName($blockName);
     $tag = isset($options['tag']) ? $options['tag'] : 'div';
     $attr = isset($options['attr']) ? $options['attr'] : array();
     if (isset($options['class'])) {
         $attr['class'] = $options['class'];
     }
     if (isset($options['href'])) {
         $attr['href'] = $options['href'];
     }
     if (!$contentBlock) {
         $contentBlock = new ContentBlock();
         $contentBlock->setName($blockName);
         $contentBlock->setBody($default ? $default : $blockName);
         $em->persist($contentBlock);
         $em->flush();
     }
     $contentEditable = '';
     $dataBlockName = '';
     $isEditable = $this->request && $this->request->get('contenteditable') && $this->securityContext->isGranted('ROLE_ADMIN');
     if ($isEditable) {
         $contentEditable = ' contenteditable="true"';
         $dataBlockName = ' data-block-name="' . $blockName . '"';
         $attr['class'] = isset($attr['class']) ? $attr['class'] . ' js-content-block' : 'js-content-block';
     }
     $attrParts = array();
     foreach ($attr as $attrName => $value) {
         $attrParts[] = sprintf('%s="%s"', $attrName, $value);
     }
     return '<' . $tag . ' ' . implode(' ', $attrParts) . ' ' . $contentEditable . $dataBlockName . '>' . $contentBlock->getBody() . '</' . $tag . '>';
 }
Beispiel #14
0
 public function __construct(Registry $doctrine, ContainerInterface $container, VersionService $versionService, CronLoggerService $cronLoggerService)
 {
     $this->entityManager = $doctrine->getManager();
     $this->setContainer($container);
     $this->versionService = $versionService;
     $this->cronLoggerService = $cronLoggerService;
 }
Beispiel #15
0
 /**
  * @param Registry $em
  * @param string $class
  */
 public function __construct(Registry $em, $class, Request $request)
 {
     $this->em = $em->getManagerForClass($class);
     $this->class = $class;
     $this->repository = $em->getRepository($class);
     $this->request = $request;
 }
 /**
  * Read available User/Host requirements from database
  *
  * @return array
  */
 public function getRights()
 {
     /** @var UserHostRepository $repository */
     $repository = $this->doctrine->getRepository($this->bundleName . ':UserHost');
     $result = $repository->findAllSelect();
     return $result;
 }
 /**
  * Find an instance of LogClass by class name. If class exists and there is no record yet, a new LogClass will be saved
  * 
  * @param string $className
  * @return \HealthCareAbroad\LogBundle\Entity\LogClass
  */
 public function getLogClassByName($className)
 {
     if (!\class_exists($className)) {
         throw ListenerException::logClassDoesNotExist($className);
     }
     //         if (\array_key_exists($className, self::$logClassMap)) {
     //             $logClass = self::$logClassMap[$className];
     //         }
     //         else {
     //             $logClass = $this->doctrine->getRepository('LogBundle:LogClass')->findOneBy(array('name' => $className));
     //             if (!$logClass) {
     //                 $logClass = new LogClass();
     //                 $logClass->setName($className);
     //                 $this->saveLogClass($logClass);
     //             }
     //             else {
     //                 self::$logClassMap[$className] = $logClass;
     //             }
     //         }
     $logClass = $this->doctrine->getEntityManager('logger')->getRepository('LogBundle:LogClass')->findOneBy(array('name' => $className));
     if (!$logClass) {
         $logClass = new LogClass();
         $logClass->setName($className);
         $this->saveLogClass($logClass);
     }
     return $logClass;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->mediaService = $this->getContainer()->get('services.doctor.media');
     $this->doctrine = $this->getContainer()->get('doctrine');
     $qb = $this->doctrine->getEntityManager()->createQueryBuilder();
     $qb->select('d, m')->from('DoctorBundle:Doctor', 'd')->innerJoin('d.media', 'm');
     $doctors = $qb->getQuery()->getResult();
     $doctorDirectory = $this->getWebRootDirectory();
     $logoSizes = $this->mediaService->getSizesByType(DoctorMediaService::LOGO_TYPE_IMAGE);
     foreach ($doctors as $doctor) {
         $this->output->writeln("Migrate images of Doctor #{$doctor->getId()}");
         $this->output->write("    ");
         if ($media = $doctor->getMedia()) {
             $doctorFile = $doctorDirectory . '/' . $media->getName();
             if (\file_exists($doctorFile)) {
                 // resize the image
                 $this->mediaService->resize($media, $logoSizes);
                 $this->output->writeln('Ok');
             } else {
                 $this->output->writeln('Not found');
             }
         } else {
             $this->output->writeln('No media');
         }
     }
     $this->output->writeln('All done');
 }
 /**
  * Creates the query builder used to get the results of the search query
  * performed by the user in the "search" view.
  *
  * @param array       $entityConfig
  * @param string      $searchQuery
  * @param string|null $sortField
  * @param string|null $sortDirection
  *
  * @return DoctrineQueryBuilder
  */
 public function createSearchQueryBuilder(array $entityConfig, $searchQuery, $sortField = null, $sortDirection = null)
 {
     /* @var EntityManager */
     $em = $this->doctrine->getManagerForClass($entityConfig['class']);
     /* @var DoctrineQueryBuilder */
     $queryBuilder = $em->createQueryBuilder()->select('entity')->from($entityConfig['class'], 'entity');
     $queryParameters = array();
     foreach ($entityConfig['search']['fields'] as $name => $metadata) {
         $isNumericField = in_array($metadata['dataType'], array('integer', 'number', 'smallint', 'bigint', 'decimal', 'float'));
         $isTextField = in_array($metadata['dataType'], array('string', 'text', 'guid'));
         if ($isNumericField && is_numeric($searchQuery)) {
             $queryBuilder->orWhere(sprintf('entity.%s = :exact_query', $name));
             // adding '0' turns the string into a numeric value
             $queryParameters['exact_query'] = 0 + $searchQuery;
         } elseif ($isTextField) {
             $searchQuery = strtolower($searchQuery);
             $queryBuilder->orWhere(sprintf('LOWER(entity.%s) LIKE :fuzzy_query', $name));
             $queryParameters['fuzzy_query'] = '%' . $searchQuery . '%';
             $queryBuilder->orWhere(sprintf('LOWER(entity.%s) IN (:words_query)', $name));
             $queryParameters['words_query'] = explode(' ', $searchQuery);
         }
     }
     if (0 !== count($queryParameters)) {
         $queryBuilder->setParameters($queryParameters);
     }
     if (null !== $sortField) {
         $queryBuilder->orderBy('entity.' . $sortField, $sortDirection ?: 'DESC');
     }
     return $queryBuilder;
 }
 /**
  * get today timeline json
  *
  * @return array|null timeline or null
  */
 public function getTodayTimeline()
 {
     $get_query = ['user_id' => $this->user->getTwitterId()];
     $today = (new \DateTime())->format('Y-m-d');
     $since_id_at = $this->user->getSinceIdAt();
     // 今日の始点ツイートのsince_idが無ければsince_idを計算後、timlineを返す
     if ($since_id_at === null || $since_id_at->format('Y-m-d') !== $today) {
         $result = $this->findIdRangeByDate(new \DateTime(), $get_query);
         // エラーメッセージの場合
         if (isset($result['error'])) {
             return $result;
         }
         // since_idのDB登録
         $user = $this->user;
         $user->setTodaySinceId($result['since_id']);
         $user->setSinceIdAt(new \DateTime());
         $user->setUpdateAt(new \DateTime());
         $em = $this->doctrine->getEntityManager();
         $user = $em->merge($user);
         $em->persist($user);
         $em->flush();
         return $result['timeline_json'];
     }
     // since_idがあればget_queryに指定して今日のつぶやき一覧をapiから取得
     $today_since_id = $this->user->getTodaySinceId();
     if ($today_since_id !== '') {
         $get_query['since_id'] = $today_since_id;
         // since_idが無ければ200件まで取得 今日以前のつぶやきが存在しないアカウントなど
     } else {
         $get_query['count'] = '200';
     }
     $timeline = $this->callStatusesUserTimeline($get_query);
     return $timeline;
 }
 /**
  * reverseTransform
  *
  * @param integer $idx
  *
  * @return \Erichard\DmsBundle\Entity\DocumentNode|null|object
  */
 public function reverseTransform($idx)
 {
     if (null === $idx) {
         return null;
     }
     return $this->registry->getRepository('Erichard\\DmsBundle\\Entity\\DocumentNode')->find($idx);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->doctrine = $this->getContainer()->get('doctrine');
     $entity = $input->getArgument('entity');
     $property = $input->getArgument('property');
     $width = $input->getArgument('width');
     $height = $input->getArgument('height');
     $size = array($width . 'x' . $height);
     $cropImage = $input->getOption('crop-image');
     $qb = $this->doctrine->getEntityManager()->createQueryBuilder();
     $qb->select('a')->from($entity, 'a')->where("a.{$property} IS NOT NULL");
     if ($entityId = $input->getOption('entity-id')) {
         $qb->andWhere('a.id = :id')->setParameter('id', $entityId);
     }
     $objects = $qb->getQuery()->getResult();
     $entityArr = explode(':', $entity);
     if ($entityArr[1] == 'InstitutionMedicalCenter') {
         $entityArr[1] = 'institution';
     }
     $mediaServiceName = 'services.' . lcfirst($entityArr[1]) . '.media';
     $mediaService = $this->getContainer()->get($mediaServiceName);
     $propertyGetMethod = 'get' . ucfirst($property);
     foreach ($objects as $each) {
         $media = $each->{$propertyGetMethod}();
         if ($media && $mediaService->getFilesystem()->has($media->getName())) {
             $this->output->write('Resizing image: ' . $media->getName() . ' (id: ' . $media->getId() . ') ... ');
             $mediaService->resize($media, $size, $cropImage);
             $this->output->writeln('DONE');
         }
     }
     $this->output->writeln('END OF SCRIPT');
 }
Beispiel #23
0
 public function __construct(Registry $doctrine, ReflectionService $reflectionService, AdvancedSearchFilter $advancedSearchFilter, IriConverter $iriConverter)
 {
     $this->em = $doctrine->getManager();
     $this->reflectionService = $reflectionService;
     $this->advancedSearchFilter = $advancedSearchFilter;
     $this->iriConverter = $iriConverter;
 }
Beispiel #24
0
 /**
  * Get the repository from the registry
  * We have to do this here because the call to registry::getRepository
  * requires the database to be setup which is a problem for using managers in console commands
  *
  * @return EntityRepository
  */
 protected function getRepository()
 {
     if (!$this->repository) {
         $this->repository = $this->registry->getRepository($this->class);
     }
     return $this->repository;
 }
 public function __construct(SecurityContext $securityContext, Doctrine $doctrine, Session $session, ContainerInterface $container)
 {
     $this->securityContext = $securityContext;
     $this->em = $doctrine->getManager();
     $this->session = $session;
     $this->container = $container;
 }
 /**
  * @param \Doctrine\Bundle\DoctrineBundle\Registry $doctrine
  */
 public function __construct($doctrine)
 {
     $dbConfig = $doctrine->getConnection()->getParams();
     if (isset($dbConfig['dsn'])) {
         $data = EhrlichAndreas_Util_Dsn::parseDsn($dbConfig['dsn']);
         foreach ($data as $key => $value) {
             $dbConfig[$key] = $value;
         }
         $data = EhrlichAndreas_Util_Dsn::parseUri($dbConfig['dsn']);
         if (isset($data[0])) {
             $dbConfig['adapter'] = ucfirst($data[0]);
         }
         if (isset($dbConfig['adapter']) && $dbConfig['driver']) {
             $dbConfig['adapter'] = $dbConfig['driver'] . '_' . $dbConfig['adapter'];
         }
     }
     if (!isset($dbConfig['adapter']) && isset($dbConfig['driver'])) {
         $dbConfig['adapter'] = $dbConfig['driver'];
         unset($dbConfig['driver']);
     }
     if (!isset($dbConfig['driver_options']) && isset($dbConfig['driverOptions'])) {
         $dbConfig['driver_options'] = $dbConfig['driverOptions'];
         unset($dbConfig['driverOptions']);
     }
     if (!isset($dbConfig['username']) && isset($dbConfig['user'])) {
         $dbConfig['username'] = $dbConfig['user'];
         unset($dbConfig['user']);
     }
     $this->adapter = EhrlichAndreas_Db_Db::factory($dbConfig);
     $this->adapter->setConnection($doctrine->getConnection()->getWrappedConnection());
 }
Beispiel #27
0
 /**
  * onKernelRequest
  */
 public function onKernelRequest()
 {
     /** @var MovieCommentFilter $movieCommentFilter */
     $movieCommentFilter = $this->em->getFilters()->getFilter('movie_comment_filter');
     $movieCommentFilter->setTokenStorage($this->tokenStorage);
     $movieCommentFilter->setAuthorizationChecker($this->authorizationChecker);
 }
 /**
  * Looks for the object that corresponds to the selected 'id' of the current entity.
  *
  * @param array $entityConfig
  * @param mixed $itemId
  *
  * @return object The entity
  *
  * @throws EntityNotFoundException
  */
 private function findCurrentItem(array $entityConfig, $itemId)
 {
     if (null === ($entity = $this->doctrine->getRepository($entityConfig['class'])->find($itemId))) {
         throw new EntityNotFoundException(array('entity' => $entityConfig, 'entity_id' => $itemId));
     }
     return $entity;
 }
Beispiel #29
0
 /**
  * @param \Doctrine\Bundle\DoctrineBundle\Registry $doctrine
  * @param \Symfony\Bridge\Monolog\Logger           $logger
  */
 public function __construct(Doctrine $doctrine, Logger $logger)
 {
     $this->entityManager = $doctrine->getManager();
     $dLogger = new \Doctrine\DBAL\Logging\DebugStack();
     $doctrine->getConnection()->getConfiguration()->setSQLLogger($dLogger);
     $logger->info(json_encode($dLogger->queries));
 }
Beispiel #30
0
 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $this->emFrom = $this->doctrine->getManager($this->parameters->getManagerFrom());
     $this->emTo = $this->doctrine->getManager($this->parameters->getManagerTo());
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     //$toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo() );
     //$toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever);
     //$this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever);
     if ($this->session->has(CompareStructure::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         throw new SyncException('No source data');
     }
     /*if($this->session->has(CompareStructure::SESSION_TO_KEY)){
           $this->toAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_TO_KEY));
           $this->toAnalyzer->initTables();
       }else{
           throw new SyncException('No targeted data');
       }*/
 }