コード例 #1
0
 /**
  * Install external adapters
  * @return void
  * @throws Exception
  */
 private function installAdapters(AdaptersEvent $event)
 {
     $fs = new Filesystem();
     $finder = new Finder();
     try {
         $pluginsDir = __DIR__ . '/../../../';
         $iterator = $finder->ignoreUnreadableDirs()->files()->name('*Adapter.php')->in($pluginsDir . '*/*/Adapter/PaywallAdapters/')->in(__DIR__ . '/../Adapter/');
         foreach ($iterator as $file) {
             $classNamespace = str_replace(realpath($pluginsDir), '', substr($file->getRealPath(), 0, -4));
             $namespace = str_replace('/', '\\', $classNamespace);
             $adapterName = substr($file->getFilename(), 0, -4);
             $oneAdapter = $this->em->getRepository('Newscoop\\PaywallBundle\\Entity\\Settings')->findOneBy(array('value' => $adapterName));
             $event->registerAdapter($adapterName, array('class' => $namespace));
             if (!$oneAdapter) {
                 $adapter = new Settings();
                 $adapter->setName(str_replace("Adapter.php", "", $file->getFilename()));
                 $adapter->setValue($adapterName);
                 if ($adapterName !== 'PaypalAdapter') {
                     $adapter->setIsActive(false);
                 }
                 $this->em->persist($adapter);
             }
         }
         $this->em->flush();
     } catch (\Exception $e) {
     }
 }
コード例 #2
0
 public function install(GenericEvent $event)
 {
     $tool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     $tool->updateSchema($this->getClasses(), true);
     $adapter = new Settings();
     $adapter->setName('Paypal');
     $adapter->setValue('PaypalAdapter');
     $this->em->persist($adapter);
     $this->em->flush();
     $this->dispatcher->dispatch('newscoop_paywall.adapters.register', new AdaptersEvent($this, array()));
     // Generate proxies for entities
     $this->em->getProxyFactory()->generateProxyClasses($this->getClasses(), __DIR__ . '/../../../../library/Proxy');
     $this->addJobs();
     $this->systemPreferences->PaywallMembershipNotifyEmail = $this->systemPreferences->EmailFromAddress;
     $this->systemPreferences->PaywallMembershipNotifyFromEmail = $this->systemPreferences->EmailFromAddress;
     $this->systemPreferences->PaywallEmailNotifyEnabled = 0;
 }