public function execute() { $resultPage = $this->resultPageFactory->create(false, ['isIsolated' => true]); $layout = $this->_configHelper->getFormLayout(); $pageConfig = $resultPage->getConfig(); $pageConfig->setPageLayout($layout); return $resultPage; }
/** * Get profile image path or placeholder * @param \Swissup\Testimonials\Model\Data $testimonial * @return String */ public function getImagePath($testimonial) { $image = $testimonial->getImage(); if (!$image && ($placeholderImage = $this->_configHelper->getPlaceholderImage())) { $image = $placeholderImage; } return $image; }
/** * Save user testimonial * * @return void * @throws \Exception */ public function execute() { $post = $this->getRequest()->getPostValue(); if (!$post) { $this->_redirectReferer(); return; } try { $error = false; if (!\Zend_Validate::is(trim($post['name']), 'NotEmpty')) { $error = true; } if (!\Zend_Validate::is(trim($post['message']), 'NotEmpty')) { $error = true; } if (!\Zend_Validate::is(trim($post['email']), 'EmailAddress')) { $error = true; } if ($error) { throw new \Exception(); } $post['store_id'] = $this->_storeManager->getStore()->getId(); $post['status'] = $this->_configHelper->isAutoApprove() ? TestimonialsModel::STATUS_ENABLED : TestimonialsModel::STATUS_AWAITING_APPROVAL; $model = $this->_objectManager->create('Swissup\\Testimonials\\Model\\Data'); $model->setData($post); $imageName = $this->_uploadModel->uploadFileAndGetName('image', $this->_imageModel->getBaseDir(), $post, ['jpg', 'jpeg', 'gif', 'png', 'bmp']); $model->setImage($imageName); $this->_eventManager->dispatch('testimonials_save_new', ['item' => $model]); $model->save(); $this->messageManager->addSuccess(__($this->_configHelper->getSentMessage())); $this->_redirectReferer(); return; } catch (\Exception $e) { $this->messageManager->addError(__($e->getMessage())); $this->_testimonialSession->setFormData($post)->setRedirectUrl($this->_redirect->getRefererUrl()); $this->_redirectReferer(); return; } }
/** * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $item = $observer->getEvent()->getItem(); if ($item->getId() == null && $this->configHelper->isAdminNotificationEnabled()) { $store = $this->_storeManager->getStore($item->getStoreId()); $from = $this->configHelper->getAdminNotificationSendFrom(); $to = ['email' => $this->configHelper->getAdminEmail(), 'name' => 'Store Administrator']; $templateId = $this->configHelper->getAdminEmailTemplate(); $subject = $this->configHelper->getAdminEmailSubject(); $image = $item->getImage() ? __("Yes") : __("No"); $statuses = $item->getAvailableStatuses(); $status = $statuses[$item->getStatus()]; $vars = ['admin_subject' => $subject, 'user_name' => $item->getName(), 'user_email' => $item->getEmail(), 'message' => $item->getMessage(), 'company' => $item->getCompany(), 'website' => $item->getWebsite(), 'facebook' => $item->getFacebook(), 'twitter' => $item->getTwitter(), 'rating' => $item->getRating(), 'image' => $image, 'status' => $status, 'store_view' => $store->getFrontendName()]; $this->_sendEmail($from, $to, $templateId, $vars, $store); } return $this; }
/** * Check if social block enabled * @param \Swissup\Testimonials\Model\Data $testimonial * @return Boolean */ public function canShowSocial($testimonial) { return $testimonial->getFacebook() && $this->configHelper->isFacebookEnabled() || $testimonial->getTwitter() && $this->configHelper->isTwitterEnabled(); }