/** * {@inheritDoc} * @SuppressWarnings(PHPMD.NPathComplexity) */ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address) { /** @var \Magento\Quote\Model\Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); if ($quote->isVirtual()) { throw new NoSuchEntityException(__('Cart contains virtual product(s) only. Shipping address is not applicable.')); } $saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0; $sameAsBilling = $address->getSameAsBilling() ? 1 : 0; $customerAddressId = $address->getCustomerAddressId(); $this->addressValidator->validate($address); $quote->setShippingAddress($address); $address = $quote->getShippingAddress(); if ($customerAddressId) { $addressData = $this->addressRepository->getById($customerAddressId); $address = $quote->getShippingAddress()->importCustomerAddressData($addressData); } elseif ($quote->getCustomerId()) { $address->setEmail($quote->getCustomerEmail()); } $address->setSameAsBilling($sameAsBilling); $address->setSaveInAddressBook($saveInAddressBook); $address->setCollectShippingRates(true); try { $address->collectTotals()->save(); } catch (\Exception $e) { $this->logger->critical($e); throw new InputException(__('Unable to save address. Please, check input data.')); } if (!$quote->validateMinimumAmount($quote->getIsMultiShipping())) { throw new InputException($this->scopeConfig->getValue('sales/minimum_order/error_message', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $quote->getStoreId())); } return $quote->getShippingAddress()->getId(); }
/** * {@inheritdoc} */ public function render(BlockContextInterface $blockContext, Response $response = null) { $block = $blockContext->getBlock(); if ($this->logger) { $this->logger->info(sprintf('[cms::renderBlock] block.id=%d, block.type=%s ', $block->getId(), $block->getType())); } try { $service = $this->blockServiceManager->get($block); $service->load($block); $response = $service->execute($blockContext, $this->createResponse($blockContext, $response)); if (!$response instanceof Response) { $response = null; throw new \RuntimeException('A block service must return a Response object'); } $response = $this->addMetaInformation($response, $blockContext, $service); } catch (\Exception $exception) { if ($this->logger) { $this->logger->critical(sprintf('[cms::renderBlock] block.id=%d - error while rendering block - %s', $block->getId(), $exception->getMessage())); } // reseting the state object $this->lastResponse = null; $response = $this->exceptionStrategyManager->handleException($exception, $blockContext->getBlock(), $response); } return $response; }
/** * Start the backup. * * @return bool */ public function execute() { $successful = true; try { // Dump all databases $this->dbm->dump(); // Backup folders if specified $this->logger->info('[dizda-backup] Copying folders.'); $this->processor->copyFolders(); // Compress everything $this->logger->info(sprintf('[dizda-backup] Compressing to archive using %s', $this->processor->getName())); $this->processor->compress(); // Transfer with all clients $this->cm->upload($this->processor->getArchivePath()); } catch (\Exception $e) { // Write log $this->logger->critical('[dizda-backup] Unexpected exception.', array('exception' => $e)); $successful = false; } try { // If we catch an exception or not, we would still like to try cleaning up after us $this->logger->info('[dizda-backup] Cleaning up after us.'); $this->processor->cleanUp(); } catch (IOException $e) { $this->logger->error('[dizda-backup] Cleaning up failed.'); return false; } return $successful; }
/** * @param \Psr\Http\Message\ServerRequestInterface $request * @param \Psr\Http\Message\ResponseInterface $response * @param \Throwable $error * * @return \Psr\Http\Message\ResponseInterface */ public function __invoke(Request $request, Response $response, Throwable $error) : Response { if (!$this->shouldntReport($error)) { $this->logger->critical($error->getMessage()); } return call_user_func($this->handler, $request, $response, $error); }
/** * Handle errors. * * @param int $code Contains the level of the error raised, as an integer. * @param string $message The error message. * @param string $file The filename that the error was raised in. * @param int $line The line number the error was raised at. * @param array $context Contains an array of every variable that existed in the scope the error was triggered in. */ public function onError($code, $message, $file, $line, array $context) { if (error_reporting()) { $this->logger->critical($message, ['error' => new Error($message, $line, $file, debug_backtrace(), $context)]); $this->showNiceError(); } }
/** * Performs the request to make the deployment * * @param string $description * @param bool $change * @param bool $user * * @return bool|string */ public function setDeployment($description, $change = false, $user = false) { $apiUrl = $this->config->getNewRelicApiUrl(); if (empty($apiUrl)) { $this->logger->notice('New Relic API URL is blank, using fallback URL'); $apiUrl = self::API_URL; } /** @var \Magento\Framework\HTTP\ZendClient $client */ $client = $this->clientFactory->create(); $client->setUri($apiUrl); $client->setMethod(ZendClient::POST); $client->setHeaders(['x-api-key' => $this->config->getNewRelicApiKey()]); $params = ['deployment[app_name]' => $this->config->getNewRelicAppName(), 'deployment[application_id]' => $this->config->getNewRelicAppId(), 'deployment[description]' => $description, 'deployment[changelog]' => $change, 'deployment[user]' => $user]; $client->setParameterPost($params); try { $response = $client->request(); } catch (\Zend_Http_Client_Exception $e) { $this->logger->critical($e); return false; } if ($response->getStatus() < 200 || $response->getStatus() > 210) { $this->logger->warning('Deployment marker request did not send a 200 status code.'); return false; } return $response->getBody(); }
/** * Method to run a domain job whose workload is a serialized JobRequestInterface * * @param \GearmanJob $job Object with job parameters * * @throws \Ice\Domain\Jobs\UnsupportedJobException * @throws \Exception re-throw uncaught exceptions * @return boolean * * @Gearman\Job( * iterations = 1, * name = "addDomainJob", * description = "Data should be an json-encoded object containing at least a 'name' property. That domain job wll be executed" * ) */ public function addDomainJob($job) { $jobRequest = $this->requestSerializer->deserializeJobRequest($job->workload()); if ($this->logger) { $this->logger->notice("Job received", [$job->workload()]); } if (!$this->director->hasWorkerProviderFor($jobRequest->getName())) { if ($this->logger) { $this->logger->critical("No worker available for job of name: " . $jobRequest->getName(), [$job->workload()]); } throw new UnsupportedJobException("No worker available for job of name: " . $jobRequest->getName()); } $worker = $this->director->getWorkerProviderFor($jobRequest->getName())->getWorkerFor($jobRequest->getName()); try { if ($this->eventDispatcher) { $this->eventDispatcher->dispatch('ice.job.pre_execute'); } $worker->execute($jobRequest); if ($this->logger) { $this->logger->notice("Job complete", [$job->workload()]); } } catch (\Exception $e) { if ($this->logger) { $this->logger->critical("Uncaught exception when processing job", array('workload' => $job->workload(), 'message' => $e->getMessage(), 'stack_trace' => $e->getTrace(), 'exception' => $e)); } //Re-throw the exception anyway, so that gearman knows the job has failed. throw $e; } return true; }
/** * Replace standard admin login form with HTTP Basic authentication * * @param AbstractAction $subject * @param callable $proceed * @param RequestInterface $request * @return ResponseInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ public function aroundDispatch(AbstractAction $subject, \Closure $proceed, RequestInterface $request) { $resource = isset($this->aclResources[$request->getControllerName()]) ? isset($this->aclResources[$request->getControllerName()][$request->getActionName()]) ? $this->aclResources[$request->getControllerName()][$request->getActionName()] : $this->aclResources[$request->getControllerName()] : null; $type = $request->getParam('type'); $resourceType = isset($this->aclResources[$type]) ? $this->aclResources[$type] : null; if (!$resource || !$resourceType) { return parent::aroundDispatch($subject, $proceed, $request); } $session = $this->_auth->getAuthStorage(); // Try to login using HTTP-authentication if (!$session->isLoggedIn()) { list($login, $password) = $this->httpAuthentication->getCredentials(); try { $this->_auth->login($login, $password); } catch (AuthenticationException $e) { $this->logger->critical($e); } } // Verify if logged in and authorized if (!$session->isLoggedIn() || !$this->authorization->isAllowed($resource) || !$this->authorization->isAllowed($resourceType)) { $this->httpAuthentication->setAuthenticationFailed('RSS Feeds'); return $this->_response; } return parent::aroundDispatch($subject, $proceed, $request); }
/** * @return void */ public function execute() { foreach ($this->schedule as $i => $action) { $task = $this->getTask($this->schedule[$i]['action']); if (empty($task)) { $this->schedule[$i]['lastExecuted'] = date(\DateTime::ATOM); $this->schedule[$i]['executeCount'] = 0; $this->insertTask($this->schedule[$i]); } else { $this->schedule[$i] = array_merge($this->schedule[$i], $task); } } $startTime = microtime(true); try { $this->logger->debug('Schedule starting'); foreach ($this->schedule as $i => $action) { $nextExecute = Date::getDateTime($this->schedule[$i]['lastExecuted']); $nextExecute->modify('+' . $this->schedule[$i]['frequency'] . ' ' . $this->schedule[$i]['period']); if (time() > $nextExecute->getTimestamp()) { $this->schedule[$i]['executeCount'] = intval($this->schedule[$i]['executeCount']) + 1; $this->schedule[$i]['lastExecuted'] = date(\DateTime::ATOM); $this->updateTask($this->schedule[$i]); $this->executeTask($this->schedule[$i]); } } $this->logger->debug('Schedule complete'); } catch (Exception $e) { $this->logger->error($e->getMessage()); } catch (\Exception $e) { $this->logger->critical($e->getMessage()); } $this->logger->debug('Completed in ' . (microtime(true) - $startTime) . ' seconds'); }
/** * @param \Magento\Catalog\Model\Layer $layer * @return array|\Magento\Catalog\Model\Layer\Filter\AbstractFilter[] */ public function getFilters(\Magento\Catalog\Model\Layer $layer) { try { if ($this->bxHelperData->isFilterLayoutEnabled($layer) && $this->bxHelperData->isLeftFilterEnabled()) { $filters = array(); $facets = $this->getBxFacets(); if ($facets) { foreach ($this->bxHelperData->getLeftFacetFieldNames() as $fieldName) { $attribute = $this->objectManager->create("Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute"); $filter = $this->objectManager->create("Boxalino\\Intelligence\\Model\\Attribute", ['data' => ['attribute_model' => $attribute], 'layer' => $layer]); $filter->setFacets($facets); $filter->setFieldName($fieldName); $filters[] = $filter; } } return $filters; } else { return parent::getFilters($layer); } } catch (\Exception $e) { $this->bxHelperData->setFallback(true); $this->_logger->critical($e); return parent::getFilters($layer); } }
/** * Get associated grouped products grid popup * * @return void */ public function execute() { $productId = (int) $this->getRequest()->getParam('id'); /** @var $product \Magento\Catalog\Model\Product */ $product = $this->factory->create(); $product->setStoreId($this->getRequest()->getParam('store', 0)); $typeId = $this->getRequest()->getParam('type'); if (!$productId && $typeId) { $product->setTypeId($typeId); } $product->setData('_edit_mode', true); if ($productId) { try { $product->load($productId); } catch (\Exception $e) { $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); $this->logger->critical($e); } } $setId = (int) $this->getRequest()->getParam('set'); if ($setId) { $product->setAttributeSetId($setId); } $this->registry->register('current_product', $product); $this->_view->loadLayout(false); $this->_view->renderLayout(); }
/** * Save uploaded file and set its name to category * * @param \Magento\Framework\DataObject $object * @return \Magento\Catalog\Model\Category\Attribute\Backend\Image */ public function afterSave($object) { $value = $object->getData($this->getAttribute()->getName() . '_additional_data'); // if no image was set - nothing to do if (empty($value) && empty($_FILES)) { return $this; } if (is_array($value) && !empty($value['delete'])) { $object->setData($this->getAttribute()->getName(), ''); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName()); return $this; } $path = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath('catalog/category/'); try { /** @var $uploader \Magento\MediaStorage\Model\File\Uploader */ $uploader = $this->_fileUploaderFactory->create(['fileId' => $this->getAttribute()->getName()]); $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']); $uploader->setAllowRenameFiles(true); $result = $uploader->save($path); $object->setData($this->getAttribute()->getName(), $result['file']); $this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName()); } catch (\Exception $e) { if ($e->getCode() != \Magento\MediaStorage\Model\File\Uploader::TMP_NAME_EMPTY) { $this->_logger->critical($e); } } return $this; }
/** * @param \Magento\Framework\HTTP\Adapter\Curl $subject * @param $result * @return mixed */ public function afterRead(\Magento\Framework\HTTP\Adapter\Curl $subject, $result) { try { /* @var $curlLog \Foggyline\Sentinel\Model\CurlLog */ $curlLog = $this->curlLog->create(); $curlLog->setRequestId($this->helper->getHttpRequestUniqueId()); $curlLog->setResult($result); $curlLog->setMethod($this->cUrlMethod); $curlLog->setUrl($this->cUrlUrl); $curlLog->setHttpVer($this->cUrlHttpVer); $curlLog->setHeaders(serialize($this->cUrlHeaders)); $curlLog->setBody($this->cUrlBody); $curlLog->setHttpCode($subject->getInfo(CURLINFO_HTTP_CODE)); $curlLog->setTotalTime($subject->getInfo(CURLINFO_TOTAL_TIME)); $curlLog->setNameLookupTime($subject->getInfo(CURLINFO_NAMELOOKUP_TIME)); $curlLog->setPrimaryIp($subject->getInfo(CURLINFO_PRIMARY_IP)); $curlLog->setPrimaryPort($subject->getInfo(CURLINFO_PRIMARY_PORT)); $curlLog->setLocalIp($subject->getInfo(CURLINFO_LOCAL_IP)); $curlLog->setLocalPort($subject->getInfo(CURLINFO_LOCAL_PORT)); $curlLog->setSizeUpload($subject->getInfo(CURLINFO_SIZE_UPLOAD)); $curlLog->setSizeDownload($subject->getInfo(CURLINFO_SIZE_DOWNLOAD)); $curlLog->setSpeedUpload($subject->getInfo(CURLINFO_SPEED_UPLOAD)); $curlLog->setSpeedDownload($subject->getInfo(CURLINFO_SPEED_DOWNLOAD)); $curlLog->setContentType($subject->getInfo(CURLINFO_CONTENT_TYPE)); $curlLog->save(); } catch (\Exception $e) { $this->logger->critical($e); } return $result; }
/** * Order Cancel * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function execute() { $isEnabled = $this->helper->isEnabled(); if ($isEnabled) { $statuses = $this->helper->getOrderStatuses(); $olderThan = $this->helper->getOlderThan(); $recentThan = $this->helper->getRecentThan(); $comment = $this->helper->getComment(); $orders = $this->orderCollectionFactory->create(); $orders->addFieldToFilter('status', ['in' => $statuses]); $orders->getSelect()->where(new \Zend_Db_Expr('TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, `updated_at`)) >= ' . $olderThan * 60)); $orders->getSelect()->where(new \Zend_Db_Expr('TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, `updated_at`)) <= ' . $recentThan * 60)); $orders->getSelect()->limit(10); $orders->setOrder('entity_id', 'DESC'); foreach ($orders->getItems() as $order) { if (!$order->canCancel()) { continue; } try { $order->cancel(); $order->addStatusHistoryComment($comment)->setIsCustomerNotified(false); $order->save(); } catch (\Exception $e) { $this->logger->critical($e); } } } }
public function filter($tempMinifiedFilename) { $originalFilename = $this->srcFile->getPath(); $jarPath = $this->externalLibPath . '/closurecompiler/compiler.jar'; $command = "java -jar {$jarPath} --warning_level QUIET --language_in ECMASCRIPT5 --compilation_level SIMPLE_OPTIMIZATIONS --js {$originalFilename} --js_output_file {$tempMinifiedFilename}"; //SIMPLE_OPTIMIZATIONS //ADVANCED_OPTIMIZATIONS //java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js hello.js $output = system($command, $returnValue); if ($returnValue != 0) { @unlink($tempMinifiedFilename); $logging = "command is {$command} <br/>"; $logging .= "curr dir " . getcwd() . "<br/>"; $logging .= "returnValue {$returnValue} <br/>"; $logging .= "result is: "; $logging .= "Output is: " . $output . "<br/>"; $this->logger->critical("Failed to generate minified Javascript: " . $logging); header("Content-type: text/javascript"); header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past echo "alert('Javacript not generated. Someone please tell the server dude \"{$originalFilename}\" failed.')"; exit(0); } }
/** * Handle exception * * @param \Exception $e * @return void */ protected function handleException($e) { $needToMaskDisplayMessage = !$e instanceof \Magento\Framework\Exception\LocalizedException && $this->appState->getMode() != State::MODE_DEVELOPER; $displayMessage = $needToMaskDisplayMessage ? (string) new \Magento\Framework\Phrase('An error occurred while processing your request') : $e->getMessage(); $this->messageManager->addError($displayMessage); $this->logger->critical($e->getMessage()); }
/** * @inheritdoc * @throws ContentProcessorException */ public function processContent(File $asset) { $path = $asset->getPath(); try { $parser = new \Less_Parser(['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER]); $content = $this->assetSource->getContent($asset); if (trim($content) === '') { return ''; } $tmpFilePath = $this->temporaryFile->createFile($path, $content); gc_disable(); $parser->parseFile($tmpFilePath, ''); $content = $parser->getCss(); gc_enable(); if (trim($content) === '') { $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path; $this->logger->critical($errorMessage); throw new ContentProcessorException(new Phrase($errorMessage)); } return $content; } catch (\Exception $e) { $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage(); $this->logger->critical($errorMessage); throw new ContentProcessorException(new Phrase($errorMessage)); } }
/** * Get associated grouped products grid popup * * @return \Magento\Framework\View\Result\Layout */ public function execute() { $productId = (int) $this->getRequest()->getParam('id'); /** @var $product \Magento\Catalog\Model\Product */ $product = $this->factory->create(); $product->setStoreId($this->getRequest()->getParam('store', 0)); $typeId = $this->getRequest()->getParam('type'); if (!$productId && $typeId) { $product->setTypeId($typeId); } $product->setData('_edit_mode', true); if ($productId) { try { $product->load($productId); } catch (\Exception $e) { $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); $this->logger->critical($e); } } $setId = (int) $this->getRequest()->getParam('set'); if ($setId) { $product->setAttributeSetId($setId); } $this->registry->register('current_product', $product); /** @var \Magento\Framework\View\Result\Layout $resultLayout */ $resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT); return $resultLayout; }
public function stream_write($data) { $meta = substr($data, 0, strpos($data, ']') + 1); list($date, $level) = explode(' - ', trim($meta, '[]')); $message = trim(substr($data, strlen($meta))); $context = []; if (strpos($message, "POST") === 0) { $parts = explode("\n\n", $message); if (count($parts) > 1) { $context[] = explode("\r\n", $parts[0]); $context[] = $parts[1]; if (count($parts) > 3) { $context[] = explode("\r\n", $parts[2]); $context[] = $parts[3]; } } } if ($level == \Logger::$DEBUG) { self::$logger->debug($message, $context); } elseif ($level == \Logger::$ERROR) { self::$logger->error($message, $context); } elseif ($level == \Logger::$FATAL) { self::$logger->critical($message, $context); } else { self::$logger->info($message, $context); } }
/** * Critical conditions. * * Example: Application component unavailable, unexpected exception. * * @param string $message * @param array $context * @return null */ public function critical($message, array $context = array()) { if ($this->logger) { $context = $this->getLoggerContext($context); $this->logger->critical($message, $context); } }
/** * Build product based on user request * * @param RequestInterface $request * @return \Magento\Catalog\Model\Product */ public function build(RequestInterface $request) { $productId = (int) $request->getParam('id'); /** @var $product \Magento\Catalog\Model\Product */ $product = $this->productFactory->create(); $product->setStoreId($request->getParam('store', 0)); $typeId = $request->getParam('type'); if (!$productId && $typeId) { $product->setTypeId($typeId); } $product->setData('_edit_mode', true); if ($productId) { try { $product->load($productId); } catch (\Exception $e) { $product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE); $this->logger->critical($e); } } $setId = (int) $request->getParam('set'); if ($setId) { $product->setAttributeSetId($setId); } $this->registry->register('product', $product); $this->registry->register('current_product', $product); $this->wysiwygConfig->setStoreId($request->getParam('store')); return $product; }
/** * @param $class * @param $serializeName * @throws SerializeException */ public function mappingDuplicateSerializedName($class, $serializeName) { if (is_object($class)) { $class = get_class($class); } $this->logger->critical("DataTrans: duplicate serialize name with name '{serializeName}' within configuration on class '{class}'!", array('serializeName' => $serializeName, 'class' => $class)); throw new SerializeException($this->prepareExceptionMessage("DataTrans: duplicate serialize name with name '{serializeName}' within configuration on class '{class}'!", array('serializeName' => $serializeName, 'class' => $class))); }
/** * @param \Exception $exception */ public function handle(\Exception $exception) { if ($exception instanceof \ErrorException) { $this->handleErrorException($exception); return; } $this->logger->critical($this->buildLogMessage($exception)); }
private function logException(Exception $exception) { if ($this->logger === null) { return; } $message = sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine()); $this->logger->critical($message, array('exception' => $exception)); }
/** * Publish Customer message to the queue before it is persisted * * @param \Magento\Customer\Api\AccountManagementInterface $subject * @param \Magento\Customer\Api\Data\CustomerInterface $customer * @param null $password * @param string $redirectUrl */ public function beforeCreateAccount(\Magento\Customer\Api\AccountManagementInterface $subject, \Magento\Customer\Api\Data\CustomerInterface $customer, $password = null, $redirectUrl = '') { try { $this->publisher->publish('customer.created', ['customer' => $customer, 'password' => $password, 'redirect_url' => $redirectUrl]); } catch (\Exception $e) { $this->logger->critical($e); } }
/** * handleException * * Handles Exceptions * * @access public * @param Exception $exception * @return void * @todo Make default / fallback log level configurable **/ public function handleException(Exception $exception) { if (method_exists($exception, "getSeverityLevel")) { $this->logger->log($exception->getSeverityLevel(), $exception->getMessage(), $this->getExceptionContext($exception)); } else { $this->logger->critical($exception->getMessage(), $this->getExceptionContext($exception)); } }
public function sendNotify(Message $message, RedmineUser $user) { if ($user->getDevices()->count()) { /** @var Device $device */ foreach ($user->getDevices() as $device) { if ($device->isEnabled()) { $logMessage = 'platform not found'; $logCustom = 'custom'; if ($device->getPlatform() === self::PLATFORM_ANDROID) { $logMessage = $message->getGcmData(); $logCustom = $message->getCustom(); } if ($device->getPlatform() === self::PLATFORM_IOS) { $logMessage = $message->getApnsData(); $logCustom = $message->getCustom(); } if ($device->getPlatform() === self::PLATFORM_IOS_SB) { $logMessage = $message->getApnsData(); $logCustom = $message->getCustom(); } try { $this->messages->send($message, $device->getArn()); $this->logger->info("\nSend message to: ", ['DEVICE' => $device->toLog(), 'MESSAGE' => $logMessage, 'CUSTOM' => $logCustom]); } catch (\Exception $e) { $device->setEnabled(false); $this->em->flush(); $this->logger->critical("\n Device is disabled: ", ['DeviceArn: ' => $device->getArn()]); } } if (!$device->isEnabled()) { $newDevice = $this->getDevice($device->getUser(), $device->getDeviceId(), $device->getPushtoken(), $device->getPlatform()); $logMessage = 'platform not found'; $logCustom = 'custom'; if ($device->getPlatform() === self::PLATFORM_ANDROID) { $logMessage = $message->getGcmData(); $logCustom = $message->getCustom(); } if ($device->getPlatform() === self::PLATFORM_IOS) { $logMessage = $message->getApnsData(); $logCustom = $message->getCustom(); } if ($device->getPlatform() === self::PLATFORM_IOS_SB) { $logMessage = $message->getApnsData(); $logCustom = $message->getCustom(); } try { $this->messages->send($message, $newDevice->getArn()); $this->logger->info("\nSend message to: ", ['DEVICE' => $device->toLog(), 'MESSAGE' => $logMessage, 'CUSTOM' => $logCustom]); } catch (\Exception $e) { $device->setEnabled(false); $this->em->flush(); $this->logger->critical("\n Device is disabled: ", ['DeviceArn: ' => $device->getArn()]); } } } // end foreach devices } }
/** * Record an extension install. * * @param string $package * @param string $version */ public function recordInstall($package, $version) { $url = sprintf($this->extendSite . $this->urls['install'], $package, $version); try { $this->client->head($url); } catch (RequestException $e) { $this->loggerSystem->critical($e->getMessage(), ['event' => 'exception', 'exception' => $e]); } }
/** * Add new theme from filesystem * * @param AbstractAction $subject * @param RequestInterface $request * * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeDispatch(AbstractAction $subject, RequestInterface $request) { try { if ($this->appState->getMode() != AppState::MODE_PRODUCTION) { $this->themeRegistration->register(); } } catch (LocalizedException $e) { $this->logger->critical($e); } }
/** * Theme registration * * @param \Magento\Framework\Event\Observer $observer * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $pathPattern = $observer->getEvent()->getPathPattern(); try { $this->registration->register($pathPattern); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->logger->critical($e); } return $this; }