当前位置: 首页>>代码示例>>PHP>>正文


PHP Registry::persist方法代码示例

本文整理汇总了PHP中Registry::persist方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::persist方法的具体用法?PHP Registry::persist怎么用?PHP Registry::persist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Registry的用法示例。


在下文中一共展示了Registry::persist方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateCode

 /**
  * @param SymfonyStyle|null $io
  */
 public function updateCode(SymfonyStyle $io = null)
 {
     $io->title('CampaignChain Data Update');
     if (empty($this->versions)) {
         $io->warning('No code updater Service found, maybe you didn\'t enable a bundle?');
         return;
     }
     $io->comment('The following data versions will be updated');
     $migratedVersions = array_map(function (DataUpdateVersion $version) {
         return $version->getVersion();
     }, $this->em->getRepository('CampaignChainUpdateBundle:DataUpdateVersion')->findAll());
     $updated = false;
     foreach ($this->versions as $version => $class) {
         if (in_array($version, $migratedVersions)) {
             continue;
         }
         $io->section('Version ' . $class->getVersion());
         $io->listing($class->getDescription());
         $io->text('Begin data update');
         $result = $class->execute($io);
         if ($result) {
             $dbVersion = new DataUpdateVersion();
             $dbVersion->setVersion($version);
             $this->em->persist($dbVersion);
             $this->em->flush();
             $io->text('Data update finished');
         }
         $updated = true;
     }
     if (!$updated) {
         $io->success('All data is up to date.');
     } else {
         $io->success('Every data version has been updated.');
     }
 }
开发者ID:campaignchain,项目名称:update,代码行数:38,代码来源:DataUpdateService.php

示例2: execute

 public function execute(SymfonyStyle $io = null)
 {
     $currentProfiles = $this->em->getRepository('CampaignChainLocationGoogleAnalyticsBundle:Profile')->findAll();
     if (empty($currentProfiles)) {
         $io->text('There is no Profile entity to update');
         return true;
     }
     foreach ($currentProfiles as $profile) {
         if (substr($profile->getProfileId(), 0, 2) != 'UA') {
             continue;
         }
         $profile->setPropertyId($profile->getProfileId());
         $gaProfileUrl = $profile->getLocation()->getUrl();
         $google_base_url = 'https:\\/\\/www.google.com\\/analytics\\/web\\/#report\\/visitors-overview\\/a' . $profile->getAccountId() . 'w\\d+p';
         $pattern = '/' . $google_base_url . '(.*)/';
         preg_match($pattern, $gaProfileUrl, $matches);
         if (!empty($matches) && count($matches) == 2) {
             $profile->setProfileId($matches[1]);
             $profile->setIdentifier($profile->getProfileId());
         }
         $this->em->persist($profile);
     }
     $this->em->flush();
     return true;
 }
开发者ID:campaignchain,项目名称:report-google-analytics,代码行数:25,代码来源:UpdateGoogleProfileEntities.php

示例3: setToken

 /**
  * @param Token $newToken
  * @param bool $sameToken
  * @return bool|string
  */
 public function setToken(Token $newToken, $sameToken = false)
 {
     if ($newToken->getLocation()) {
         $this->em->persist($newToken);
         $this->em->flush();
         return true;
     }
     // Check whether the token already exists in relation to a channel.
     $repository = $this->em->getRepository('CampaignChainSecurityAuthenticationClientOAuthBundle:Token');
     $query = $repository->createQueryBuilder('token')->where('token.application = :application')->andWhere('token.accessToken = :accessToken')->andWhere('token.location IS NOT NULL')->setParameter('application', $newToken->getApplication())->setParameter('accessToken', $newToken->getAccessToken())->setMaxResults(1)->getQuery();
     $oldToken = $query->getOneOrNullResult();
     if (!$oldToken) {
         // So, there's no token related to a specific channel, but perhaps there is one
         // that has been persisted at a previous attempt to connect to the channel?
         // TODO: Implement what to do if token was persisted previously without channel relationship?
         $this->token = $newToken;
         $this->em->persist($this->token);
         $this->em->flush();
         return self::STATUS_NEW_TOKEN;
     }
     // Has a scope been set?
     if (!$newToken->getScope() && !$sameToken) {
         return self::STATUS_NO_CHANGE;
     }
     //With LinkedIn if a user connects multiple times, he will get the same access token
     //And even though they are same, it has to be saved as a new token
     if ($sameToken) {
         $this->token = $newToken;
         $this->em->persist($this->token);
         $this->em->flush();
         return self::STATUS_NEW_TOKEN;
     }
     $newScope = $newToken->getScope();
     $newAccessToken = $newToken->getAccessToken();
     $existingScope = $oldToken->getScope();
     $existingAccessToken = $oldToken->getAccessToken();
     // If the channel has the same access token and the same scope,
     // or no scope has been defined, then we're done.
     if ($existingScope === $newScope) {
         return self::STATUS_SAME_SCOPE;
     }
     // Is the scope different for the same profile?
     if ($existingAccessToken !== $newAccessToken) {
         // If the channel has a different scope and access token,
         // then create a new token entry for the existing profile.
         // This takes care of how Google handles scopes for its APIs.
         $this->token = $newToken;
         $status = self::STATUS_NEW_TOKEN;
     } else {
         // If the channel has the same access token, but a different scope,
         // then just update the scope for the token.
         // This takes care of how Facebook deals with scope changes.
         $this->token = $oldToken;
         $this->token->setScope($newScope);
         $status = self::STATUS_NEW_SCOPE;
     }
     $this->em->persist($this->token);
     $this->em->flush();
     return $status;
 }
开发者ID:campaignchain,项目名称:security-authentication-client-oauth,代码行数:65,代码来源:TokenService.php

示例4: updateBitlyAccessToken

 public function updateBitlyAccessToken($access_token)
 {
     $activeSystem = $this->getActiveSystem();
     $activeSystem->setBitlyAccessToken($access_token);
     $this->em->persist($activeSystem);
     $this->em->flush();
 }
开发者ID:CampaignChain,项目名称:core,代码行数:7,代码来源:SystemService.php

示例5: cloneOperation

 /**
  * @param Operation $oldOperation
  * @param Operation $newOperation
  */
 public function cloneOperation(Operation $oldOperation, Operation $newOperation)
 {
     $newsItem = $this->getNewsItemByOperation($oldOperation);
     $clonedNewsItem = clone $newsItem;
     $clonedNewsItem->setOperation($newOperation);
     $this->em->persist($clonedNewsItem);
     $this->em->flush();
 }
开发者ID:campaignchain,项目名称:operation-linkedin,代码行数:12,代码来源:NewsItem.php

示例6: readAction

 /**
  * @param Operation $operation
  * @return \Symfony\Component\HttpFoundation\Response
  * @throws \Exception
  */
 public function readAction(Operation $operation)
 {
     $newsItem = $this->contentService->getNewsItemByOperation($operation);
     $activity = $operation->getActivity();
     $locationModuleIdentifier = $activity->getLocation()->getLocationModule()->getIdentifier();
     $isCompanyPageShare = 'campaignchain-linkedin-page' == $locationModuleIdentifier;
     $isLive = true;
     if (!$newsItem->getLinkedinData()) {
         $connection = $this->restClient->getConnectionByActivity($activity);
         /*
          * Below calls to the Linkedin REST API will throw errors if the
          * Linkedin App has not been approved by Linkedin as part of their
          * partner program.
          */
         try {
             if ($isCompanyPageShare) {
                 $response = $connection->getCompanyUpdate($activity, $newsItem);
             } else {
                 $response = $connection->getUserUpdate($activity, $newsItem);
             }
             if (!is_null($response)) {
                 $newsItem->setLinkedinData($response);
                 $this->em->persist($newsItem);
                 $this->em->flush();
             } else {
                 $isLive = false;
             }
         } catch (\Exception $e) {
             $isLive = true;
         }
     }
     return $this->templating->renderResponse('CampaignChainOperationLinkedInBundle::read.html.twig', array('page_title' => $activity->getName(), 'news_item' => $newsItem, 'activity' => $activity, 'is_live' => $isLive, 'is_company' => $isCompanyPageShare));
 }
开发者ID:campaignchain,项目名称:activity-linkedin,代码行数:38,代码来源:ShareNewsItemHandler.php

示例7: prepareReportLocationJobs

 protected function prepareReportLocationJobs()
 {
     /** @var SchedulerReportLocation[] $scheduledReports */
     $scheduledReports = $this->em->getRepository('CampaignChainCoreBundle:SchedulerReportLocation')->getScheduledReportJobsForSchedulerCommand($this->scheduler->getPeriodStart(), $this->scheduler->getPeriodEnd());
     if (empty($scheduledReports)) {
         $this->io->text('No scheduled Location reports.');
         $this->logger->info('No scheduled Location reports.');
         return;
     }
     // Queue the scheduled reports.
     $this->io->text('Processing scheduled Location reports.');
     $this->logger->info('Processing scheduled Location reports.');
     foreach ($scheduledReports as $scheduledReport) {
         $txt = 'Report ID: ' . $scheduledReport->getId();
         $this->io->section($txt);
         $this->logger->info($txt);
         $this->queueReportJob($scheduledReport);
         /*
          * Update next run.
          */
         // Are we within the regular scheduled period?
         if ($scheduledReport->getEndDate() > $this->now && $scheduledReport->getInterval() != null) {
             $interval = \DateInterval::createFromDateString($scheduledReport->getInterval());
             $nextRun = clone $scheduledReport->getNextRun();
             $scheduledReport->setNextRun($nextRun->add($interval));
             $txt = 'Regular period. Next run is in ' . $scheduledReport->getInterval();
             $this->io->text($txt);
             $this->logger->info($txt);
         }
         $this->em->persist($scheduledReport);
     }
     //update the next run dates for the scheduler
     $this->em->flush();
 }
开发者ID:CampaignChain,项目名称:core,代码行数:34,代码来源:SchedulerCommand.php

示例8: schedule

 public function schedule($operation, $facts = null)
 {
     $scheduler = new SchedulerReportOperation();
     $scheduler->setOperation($operation);
     $scheduler->setInterval('1 hour');
     $scheduler->setEndAction($operation->getActivity()->getCampaign());
     $this->em->persist($scheduler);
     // Add initial data to report.
     $this->newsitem = $this->em->getRepository('CampaignChainOperationLinkedInBundle:NewsItem')->findOneByOperation($operation);
     if (!$this->newsitem) {
         throw new \Exception('No Linkedin news item found for an operation with ID: ' . $operation->getId());
     }
     $facts[self::METRIC_LIKES] = 0;
     $facts[self::METRIC_COMMENTS] = 0;
     $this->factService->addFacts('activity', self::BUNDLE_NAME, $operation, $facts);
 }
开发者ID:campaignchain,项目名称:operation-linkedin,代码行数:16,代码来源:ReportShareNewsItem.php

示例9: onConsoleException

 /**
  * In case of an exception in scheduler console command
  * the message should be saved into the scheduler entity
  *
  * @param ConsoleExceptionEvent $event
  */
 public function onConsoleException(ConsoleExceptionEvent $event)
 {
     /** @var SchedulerCommand $command */
     $command = $event->getCommand();
     if ($command->getName() != 'campaignchain:scheduler') {
         return;
     }
     // if scheduler is null exception happened in early stage
     // maybe email should be sent
     if (!$command->getScheduler()) {
         return;
     }
     /** @var Scheduler $scheduler */
     $scheduler = $command->getScheduler();
     $scheduler->setMessage($event->getException()->getMessage());
     $scheduler->setStatus(Scheduler::STATUS_ERROR);
     $scheduler->setExecutionEnd(new \DateTime());
     $this->em->persist($scheduler);
     $this->em->flush();
     $command->getIo()->error($scheduler->getMessage());
     $this->logger->critical($scheduler->getMessage());
 }
开发者ID:CampaignChain,项目名称:core,代码行数:28,代码来源:ConsoleExceptionListener.php

示例10: load

 /**
  * @param array $files
  * @param bool $doDrop
  */
 public function load(array $files, $doDrop = true)
 {
     try {
         $this->em->getConnection()->beginTransaction();
         $userProcessor = new UserProcessor(realpath(SystemUtil::getRootDir() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR), $this->userService, $this->mimeTypeGuesser, $this->extensionGuesser);
         // Create Alice manager and fixture set
         $this->fixtureManager->addProcessor($userProcessor);
         $set = $this->fixtureManager->createFixtureSet();
         // Add the fixture files
         foreach ($files as $file) {
             $set->addFile($file, 'yaml');
         }
         $set->setDoDrop($doDrop);
         $set->setDoPersist(true);
         $set->setSeed(1337 + 42);
         // TODO Keep Module data intact
         $bundles = $this->em->getRepository("CampaignChain\\CoreBundle\\Entity\\Bundle")->findAll();
         $modules = $this->em->getRepository("CampaignChain\\CoreBundle\\Entity\\Module")->findAll();
         if ($this->fixtureManager->load($set)) {
             // TODO: Restore modules data
             foreach ($bundles as $bundle) {
                 $this->em->persist($bundle);
             }
             foreach ($modules as $module) {
                 $this->em->persist($module);
             }
             $this->em->flush();
             $this->em->getConnection()->commit();
             return true;
         }
         return false;
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->setException($e);
         return false;
     }
 }
开发者ID:CampaignChain,项目名称:core,代码行数:41,代码来源:FileLoader.php

示例11: registerModuleSystemParams

 /**
  * Store a module's system parameters.
  */
 private function registerModuleSystemParams()
 {
     if (!count($this->systemParams)) {
         return;
     }
     /*
      * If a system entry already exists, then update it. Otherwise,
      * create a new one.
      */
     $system = $this->systemService->getActiveSystem();
     if (!$system) {
         $system = new System();
         $system->setNavigation([]);
         $this->em->persist($system);
     }
     if (!is_array($system->getNavigation())) {
         $system->setNavigation([]);
     }
     foreach ($this->systemParams as $moduleParams) {
         foreach ($moduleParams as $key => $params) {
             switch ($key) {
                 case 'navigation':
                     // Does the app override the modules' navigation?
                     if (isset($this->appComposerJson['extra']) && isset($this->appComposerJson['extra']['campaignchain']) && isset($this->appComposerJson['extra']['campaignchain']['navigation'])) {
                         $system->setNavigation($this->appComposerJson['extra']['campaignchain']['navigation']);
                     } else {
                         // Merge existing navigations with new modules' navigation.
                         $navigation = array_merge_recursive($system->getNavigation(), $params);
                         $system->setNavigation($navigation);
                     }
                     break;
             }
         }
     }
     $this->em->flush();
 }
开发者ID:CampaignChain,项目名称:core,代码行数:39,代码来源:Installer.php

示例12: persist

 /**
  * Global implementation of Interfaces\Persistent
  */
 protected function persist()
 {
     Registry::persist($this);
 }
开发者ID:jgswift,项目名称:persistr,代码行数:7,代码来源:Persistent.php


注:本文中的Registry::persist方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。