Esempio n. 1
0
 /**
  * @param \Symfony\Component\HttpKernel\Event\FilterControllerEvent $event
  *
  * @return void
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $transactionName = $request->attributes->get('_route');
     $requestUri = $request->server->get('REQUEST_URI', 'n/a');
     $host = $request->server->get('COMPUTERNAME', $this->system->getHostname());
     $this->newRelicApi->setNameOfTransaction($transactionName);
     $this->newRelicApi->addCustomParameter('request_uri', $requestUri);
     $this->newRelicApi->addCustomParameter('host', $host);
     if ($this->ignoreTransaction($transactionName)) {
         $this->newRelicApi->markIgnoreTransaction();
     }
 }
Esempio n. 2
0
 /**
  * @return callable
  */
 protected function getFunction()
 {
     return function ($currentController) {
         $html = '<div class="zed:header__environment"><i class="icon-cogs"></i>' . '<span>' . APPLICATION_ENV . '</span>' . '<dl>' . '<dt>Locale:' . '<dd>' . Store::getInstance()->getCurrentLocale() . '<dt>Store:' . '<dd>' . Store::getInstance()->getStoreName() . '<dt>Server:' . '<dd>' . System::getHostName() . '<dt>Controller:' . '<dd>' . $currentController . '</dl></div>';
         return $html;
     };
 }
 /**
  * @param \Silex\Application $app
  *
  * @return void
  */
 public function boot(Application $app)
 {
     $app->before(function (Request $request) {
         $module = $request->attributes->get('module');
         $controller = $request->attributes->get('controller');
         $action = $request->attributes->get('action');
         $transactionName = $module . '/' . $controller . '/' . $action;
         $requestUri = array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : 'unknown';
         $host = isset($_SERVER['COMPUTERNAME']) ? $_SERVER['COMPUTERNAME'] : System::getHostname();
         $store = Store::getInstance();
         $newRelicApi = new NewRelicApi();
         $newRelicApi->setNameOfTransaction($transactionName);
         $newRelicApi->addCustomParameter('request_uri', $requestUri);
         $newRelicApi->addCustomParameter('host', $host);
         $newRelicApi->addCustomParameter('store', $store->getStoreName());
         $newRelicApi->addCustomParameter('locale', $store->getCurrentLocale());
     });
 }
Esempio n. 4
0
 /**
  * @param \Spryker\Shared\Transfer\TransferInterface|null $transferObject
  * @param array $metaTransfers
  *
  * @throws \LogicException
  *
  * @return \Spryker\Client\ZedRequest\Client\Request
  */
 protected function createRequestTransfer(TransferInterface $transferObject = null, array $metaTransfers = [])
 {
     $request = $this->getRequest();
     $request->setSessionId(session_id());
     $request->setTime(time());
     $request->setHost(System::getHostname() ?: 'n/a');
     foreach ($metaTransfers as $name => $metaTransfer) {
         if (!is_string($name) || is_numeric($name) || !$metaTransfer instanceof TransferInterface) {
             throw new LogicException(static::META_TRANSFER_ERROR);
         }
         $request->addMetaTransfer($name, $metaTransfer);
     }
     if ($transferObject) {
         $request->setTransfer($transferObject);
     }
     return $request;
 }
 /**
  * @return string
  */
 protected function getHost()
 {
     return isset($_SERVER['COMPUTERNAME']) ? $_SERVER['COMPUTERNAME'] : System::getHostname();
 }
Esempio n. 6
0
 /**
  * @param \Spryker\Shared\Transfer\TransferInterface $transferObject
  * @param array $metaTransfers
  *
  * @throws \LogicException
  *
  * @return \Spryker\Shared\Library\Communication\Request
  */
 protected function createRequestTransfer(TransferInterface $transferObject, array $metaTransfers)
 {
     $request = new Request();
     $request->setSessionId(session_id());
     $request->setTime(time());
     $request->setHost(System::getHostname() ?: 'n/a');
     foreach ($metaTransfers as $name => $metaTransfer) {
         if (!is_string($name) || is_numeric($name) || !$metaTransfer instanceof TransferInterface) {
             throw new LogicException('Adding MetaTransfer failed. Either name missing/invalid or no object of TransferInterface provided.');
         }
         $request->addMetaTransfer($name, $metaTransfer);
     }
     if ($this->username) {
         $request->setUsername($this->username);
     }
     if ($this->password) {
         $request->setPassword($this->password);
     }
     if ($transferObject) {
         $request->setTransfer($transferObject);
     }
     return $request;
 }
Esempio n. 7
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $salesOrderItem
  *
  * @return \Orm\Zed\Oms\Persistence\SpyOmsTransitionLog
  */
 protected function initEntity(SpySalesOrderItem $salesOrderItem)
 {
     $logEntity = $this->getEntity();
     $logEntity->setOrderItem($salesOrderItem);
     $logEntity->setQuantity($salesOrderItem->getQuantity());
     $logEntity->setFkSalesOrder($salesOrderItem->getFkSalesOrder());
     $logEntity->setFkOmsOrderProcess($salesOrderItem->getFkOmsOrderProcess());
     $logEntity->setHostname(System::getHostname());
     if (PHP_SAPI === self::SAPI_CLI) {
         $path = self::SAPI_CLI;
         if (isset($_SERVER[self::ARGV]) && is_array($_SERVER[self::ARGV])) {
             $path = implode(' ', $_SERVER[self::ARGV]);
         }
     } else {
         $path = $_SERVER[self::DOCUMENT_URI];
     }
     $logEntity->setPath($path);
     $params = [];
     if (!empty($_SERVER[self::QUERY_STRING])) {
         $params = $this->getParamsFromQueryString($_SERVER[self::QUERY_STRING]);
     }
     $logEntity->setParams($params);
     return $logEntity;
 }