/** * @param InputInterface $input * @param OutputInterface $output */ protected function execute(InputInterface $input, OutputInterface $output) { $providerPool = $this->getContainer()->get('opifer.mailinglist.provider_pool'); $lists = $this->em->getRepository('OpiferMailingListBundle:MailingList')->findWithProviders(); if (empty($lists)) { $output->writeln("<info>0 lists found to synchronise: exiting…</info>"); return; } $logger = $this->buildLoggerClosure($output, count($lists)); $logger('Lists initialised.'); foreach ($lists as $list) { /** @var MailingListProviderInterface $provider */ $provider = $providerPool->getProvider($list->getProvider()); $provider->synchroniseList($list, $logger); $logger(sprintf('Finished synchronisation on %s with %s', $list->getName(), $provider->getName()), 1); } // // /** @var MailingList $mailingList */ // foreach ($mailingLists as $mailingList) { // if ($mailingList->getProvider() == 'mailplus') { // $output->writeln(sprintf('Synchronizing subscriptions for mailinglist %s', $mailingList->getDisplayName())); // // /** @var MailPlusProvider $provider */ // $provider = $this->getContainer()->get('opifer.mailplus_provider'); // // $synced = $failed = 0; // // $subscriptions = $subscriptionRepository->getUnsyncedByMailinglist($mailingList); // // /** @var Subscription $subscription */ // foreach ($subscriptions as $subscription) { // $success = $provider->sync($subscription); // // if ($success) { // $synced++; // } else { // $failed++; // } // } // // $output->writeln(sprintf('%d synched and %d failed of %d subscriptions', $synced, $failed, count($subscriptions))); // } // } // } }
/** * Get the role by slug * * @param $slug * @return mixed * @throws RoleNotFoundException */ public function get($slug) { $lowerslug = strtolower($slug); //create unique key for kind and uppercased name $key = md5('role.' . $lowerslug); //cache has value return this one $cached = Cache::get($key); if ($cached) { return $cached; } $role = $this->em->getRepository($this->class)->findOneBy(['slug' => $lowerslug]); if (!$role) { throw new RoleNotFoundException($slug); } //cache it for next request Cache::forever($key, $role); return Cache::get($key); }
/** * Find an Organization by their domain name * * @param string $domain_name * @return Organization */ public function organizationOfDomain($domain_name) { return $this->em->getRepository($this->class)->findOneBy(['domain_name' => $domain_name]); }
/** * Find a user by their id * * @param $id * @return User */ public function userOfId($id) { return $this->em->getRepository($this->class)->findOneBy(['id' => $id]); }