/**
  * Add Free payment method
  *
  * @param PaymentCollectionEvent $event Event
  */
 public function addFreePaymentPaymentMethod(PaymentCollectionEvent $event)
 {
     if ($this->plugin->isUsable()) {
         $bankwire = new PaymentMethod($this->plugin->getHash(), 'elcodi_plugin.bankwire.name', 'elcodi_plugin.bankwire.description', $this->router->generate('paymentsuite_bankwire_execute'));
         $event->addPaymentMethod($bankwire);
     }
 }
 /**
  * Add Free payment method
  *
  * @param PaymentCollectionEvent $event Event
  */
 public function addFreePaymentPaymentMethod(PaymentCollectionEvent $event)
 {
     if ($this->plugin->isUsable()) {
         $freePayment = new PaymentMethod($this->plugin->getHash(), 'elcodi_plugin.free_payment.name', 'elcodi_plugin.free_payment.description', $this->router->generate('freepayment_payment_routes'));
         $event->addPaymentMethod($freePayment);
     }
 }
Exemplo n.º 3
0
 /**
  * Add PayPal payment method
  *
  * @param PaymentCollectionEvent $event Event
  */
 public function addPaypalPaymentMethod(PaymentCollectionEvent $event)
 {
     if ($this->plugin->isUsable(['business'])) {
         $paypal = new PaymentMethod($this->plugin->getHash(), 'elcodi_plugin.paypal_web_checkout.name', 'elcodi_plugin.paypal_web_checkout.description', $this->router->generate('paymentsuite_paypal_web_checkout_execute'));
         $event->addPaymentMethod($paypal);
     }
 }
Exemplo n.º 4
0
 /**
  * Add Stripe payment method
  *
  * @param PaymentCollectionEvent $event Event
  */
 public function addStripePaymentMethod(PaymentCollectionEvent $event)
 {
     if ($this->plugin->isUsable(['private_key', 'public_key'])) {
         $stripeForm = $this->getStripeForm() . $this->getStripeScript();
         $stripe = new PaymentMethod($this->plugin->getHash(), 'elcodi_plugin.stripe.name', 'elcodi_plugin.stripe.description', '', '', $stripeForm);
         $event->addPaymentMethod($stripe);
     }
 }
Exemplo n.º 5
0
 /**
  * Renders import/export buttons
  *
  * @param EventInterface $event
  *
  * @return string
  */
 public function renderButtons(EventInterface $event)
 {
     if ($event->get('entity_type') !== 'product') {
         return null;
     }
     if ($this->plugin->isUsable()) {
         $this->appendTemplate('ElcodiProductCsvBundle::buttons.html.twig', $event, $this->plugin);
     }
 }
 /**
  * Given a Cart, return a set of Valid ShippingRanges satisfied.
  *
  * @param ShippingCollectionEvent $event Event
  *
  * @return $this Self object
  */
 public function addCustomShippingMethods(ShippingCollectionEvent $event)
 {
     if (!$this->plugin->isEnabled()) {
         return $this;
     }
     $cart = $event->getCart();
     $carrierRanges = $this->shippingRangesProvider->getAllShippingRangesSatisfiedWithCart($cart);
     foreach ($carrierRanges as $carrierRange) {
         $event->addShippingMethod(new ShippingMethod('custom-shipping-method-' . $carrierRange->getId(), $carrierRange->getCarrier()->getName(), $carrierRange->getName(), '', $carrierRange->getPrice()));
     }
 }
Exemplo n.º 7
0
 /**
  * Renders the share product button.
  *
  * @param EventInterface $event The event
  */
 public function renderShareOrder(EventInterface $event)
 {
     if ($this->plugin->isUsable()) {
         $shareUrl = $this->urlGenerator->generate('store_homepage', [], true);
         $this->appendTemplate('@ElcodiFacebook/Post/share.html.twig', $event, $this->plugin, ['url' => $shareUrl]);
     }
 }
Exemplo n.º 8
0
 /**
  * Checks if the plugin should be disabled
  *
  * @param GetResponseEvent $event The response event
  */
 public function handle(GetResponseEvent $event)
 {
     if ($this->plugin->isEnabled() && $this->wizardStatus->isWizardFinished()) {
         $this->plugin->setEnabled(false);
         $this->pluginObjectManager->flush($this->plugin);
     }
 }
Exemplo n.º 9
0
 /**
  * Renders the share product button.
  *
  * @param EventInterface $event The event
  */
 public function renderShareOrder(EventInterface $event)
 {
     if ($this->plugin->isUsable(['twitter_account'])) {
         $shareUrl = $this->urlGenerator->generate('store_homepage', [], true);
         $this->appendTemplate('@ElcodiTwitter/Tweet/share.html.twig', $event, $this->plugin, ['url' => $shareUrl, 'text' => $this->translator->trans('twitter_plugin.tweet.take_look')]);
     }
 }
 /**
  * Handles the event redirecting to the wizard if the user is visiting the
  * dashboard
  *
  * @param GetResponseEvent $event The response event
  */
 public function handle(GetResponseEvent $event)
 {
     if ($this->plugin->isEnabled() && !$this->wizardStatus->isWizardFinished()) {
         $request = $event->getRequest();
         $currentRoute = $this->getCurrentRequestRoute($request);
         if ('admin_homepage' == $currentRoute) {
             $event->setResponse(new RedirectResponse($this->urlGenerator->generate($this->wizardRoutes->getDefaultWizardRoute())));
         }
     }
 }
Exemplo n.º 11
0
 /**
  * Render the disable under construction mode.
  *
  * @param EventInterface $event The event
  */
 public function renderDisableUnderConstructionMode(EventInterface $event)
 {
     if ($this->plugin->isUsable()) {
         $masterRequest = $this->requestStack->getMasterRequest();
         $currentRoute = $masterRequest->attributes->get('_route');
         $isWizardFinished = $this->wizardStatus->isWizardFinished();
         if ('admin_configuration_list' == $currentRoute && $isWizardFinished) {
             $this->appendTemplate('@ElcodiStoreSetupWizard/Wizard/disable-under-construction.html.twig', $event, $this->plugin);
         }
     }
 }
Exemplo n.º 12
0
 /**
  * Renders the follow button.
  *
  * @param EventInterface $event The event
  */
 public function renderFollowButton(EventInterface $event)
 {
     if ($this->plugin->isUsable(['twitter_account'])) {
         $this->appendTemplate('@ElcodiTwitter/Follow/follow.html.twig', $event, $this->plugin);
     }
 }
Exemplo n.º 13
0
 /**
  * Renders the javascript.
  *
  * @param EventInterface $event The event
  */
 public function renderJavascript(EventInterface $event)
 {
     if ($this->plugin->isUsable()) {
         $this->appendTemplate('@ElcodiTwitter/javascript.html.twig', $event, $this->plugin);
     }
 }
Exemplo n.º 14
0
 /**
  * Merge this plugin instance with a new one, and saves the result in
  * this instance.
  *
  * This method will give priority to its own properties values.
  *
  * @param Plugin $newPlugin New plugin configuration
  *
  * @return $this Self object
  */
 public function merge(Plugin $newPlugin)
 {
     if ($newPlugin->getNamespace() !== $this->getNamespace()) {
         throw new RuntimeException('Both plugins cannot be merged');
     }
     $this->configuration->merge($newPlugin->getConfiguration());
     return $this;
 }
Exemplo n.º 15
0
 /**
  * Create or update existing plugin given a set of plugin instances and the
  * information to create a new one.
  *
  * @param string $pluginNamespace     Plugin namespace
  * @param array  $pluginConfiguration Plugin Configuration
  *
  * @return Plugin Plugin instance
  */
 private function getPluginInstance($pluginNamespace, array $pluginConfiguration)
 {
     $pluginType = $pluginConfiguration['type'];
     $pluginCategory = $pluginConfiguration['category'];
     $pluginEnabledByDefault = $pluginConfiguration['enabled_by_default'];
     unset($pluginConfiguration['type']);
     $pluginInstance = Plugin::create($pluginNamespace, $pluginType, $pluginCategory, PluginConfiguration::create($pluginConfiguration), $pluginEnabledByDefault);
     return $pluginInstance;
 }
Exemplo n.º 16
0
 /**
  * Return route collection for injected plugins
  *
  * @return RouteCollection Collection generated
  */
 protected function addPluginRoutesCollection(Plugin $plugin)
 {
     $routes = new RouteCollection();
     $bundleName = $plugin->getBundleName();
     $bundle = $this->kernel->getBundle($bundleName);
     $routingFilePath = '/Resources/config/routing.yml';
     $resourcePath = $bundle->getPath() . $routingFilePath;
     $type = 'yaml';
     if (file_exists($resourcePath)) {
         $routes->addCollection($this->import('@' . $bundle->getName() . $routingFilePath, $type));
     }
     return $routes;
 }
Exemplo n.º 17
0
 /**
  * Check if, given a plugin hash, a configuration page is available
  *
  * @param Plugin $plugin Plugin
  *
  * @return boolean Is available
  */
 protected function isPluginConfigurable(Plugin $plugin = null)
 {
     return $plugin instanceof Plugin && $plugin->hasFields();
 }
Exemplo n.º 18
0
 /**
  * Renders import/export buttons
  *
  * @param EventInterface $event Event
  */
 public function renderPin(EventInterface $event)
 {
     if ($this->plugin->isUsable()) {
         $this->appendTemplate('@ElcodiPinterest/product_pin.html.twig', $event, $this->plugin);
     }
 }
Exemplo n.º 19
0
 /**
  * Renders disqus block on product page
  *
  * @param EventInterface $event Event
  */
 public function renderDisqusProductBlock(EventInterface $event)
 {
     if ($this->plugin->isUsable(['disqus_identifier', 'disqus_enabled_product'])) {
         $this->appendTemplate('@ElcodiDisqus/block.html.twig', $event, $this->plugin);
     }
 }
Exemplo n.º 20
0
 /**
  * Renders google analytics JS
  *
  * @param EventInterface $event Event
  */
 public function renderJavascript(EventInterface $event)
 {
     if ($this->plugin->isUsable(['analytics_tracker_id'])) {
         $this->appendTemplate('@ElcodiGoogleAnalytics/javascript.html.twig', $event, $this->plugin);
     }
 }
Exemplo n.º 21
0
 /**
  * @return PluginNotFoundException
  */
 public static function createPluginRouteNotFound(Plugin $plugin)
 {
     $message = sprintf('Elcodi cannot find plugin %s. Make sure it exists as a vendor by checking your composer, or load elcodi:install command in order to update the plugin database', $plugin->getNamespace());
     return new static($message);
 }
Exemplo n.º 22
0
 /**
  * Test merge with exception.
  *
  * @expectedException \RuntimeException
  */
 public function testMergeException()
 {
     $this->plugin->merge(Plugin::create('A\\Nother\\Plugin', 'plugin', 'social', PluginConfiguration::create(['name' => 'A Plugin', 'description' => 'A plugin description', 'fa_icon' => 'plugin_icon', 'fields' => ['field1' => ['type' => 'text', 'label' => 'label1', 'required' => true, 'data' => null, 'options' => []]]]), true));
 }