Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dneustadt committed Apr 19, 2018
1 parent 71ca956 commit c8b8e92
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 55 deletions.
1 change: 1 addition & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ return PhpCsFixer\Config::create()
'array_syntax' => ['syntax' => 'short'],
'declare_strict_types' => false,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
'increment_style' => ['style' => 'post'],
]
)
->setFinder($finder);
23 changes: 10 additions & 13 deletions Controllers/Backend/ViewSnapshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
*/
class Shopware_Controllers_Backend_ViewSnapshots extends Shopware_Controllers_Backend_ExtJs
{

public function indexAction()
public function indexAction()
{
$this->View()->loadTemplate("backend/view_snapshots/app.js");
$this->View()->loadTemplate('backend/view_snapshots/app.js');
}

/**
* @throws \Exception
*/
public function listAction()
{
$limit = (int)$this->Request()->getParam('limit', 20);
$offset = (int)$this->Request()->getParam('start', 0);
$limit = (int) $this->Request()->getParam('limit', 20);
$offset = (int) $this->Request()->getParam('start', 0);

$qb = $this->getModelManager()->getDBALQueryBuilder();

Expand All @@ -41,21 +40,19 @@ public function listAction()
foreach ($data as &$row) {
$row['url'] = $this->get('router')->assemble(
[
'module' => 'frontend',
'controller' => 'snapshots',
'action' => 'load',
'session' => $row['sessionID'],
'step' => $row['step'],
'module' => 'frontend',
'controller' => 'snapshots',
'action' => 'load',
'session' => $row['sessionID'],
'step' => $row['step'],
]
);
}

$total = (int)$this->container->get('dbal_connection')->fetchColumn('SELECT FOUND_ROWS()');
$total = (int) $this->container->get('dbal_connection')->fetchColumn('SELECT FOUND_ROWS()');

$this->View()->assign(
['success' => true, 'data' => $data, 'total' => $total]
);
}

}

8 changes: 4 additions & 4 deletions Controllers/Frontend/Snapshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function indexAction()
public function loadAction()
{
$sessionID = $this->Request()->getParam('session');
$step = (int)$this->Request()->getParam('step', 1);
$step = (int) $this->Request()->getParam('step', 1);

if (empty($sessionID)) {
throw new \Exception(
Expand All @@ -37,12 +37,12 @@ public function loadAction()
);
}

$nextStep = (int)$this->get('dbal_connection')->fetchColumn(
$nextStep = (int) $this->get('dbal_connection')->fetchColumn(
'SELECT MIN(`step`) as step FROM `view_snapshots` WHERE `sessionID` = :sessionID AND `step` > :step LIMIT 1',
$sqlParams
);

$prevStep = (int)$this->get('dbal_connection')->fetchColumn(
$prevStep = (int) $this->get('dbal_connection')->fetchColumn(
'SELECT MAX(`step`) as step FROM `view_snapshots` WHERE `sessionID` = :sessionID AND `step` < :step LIMIT 1',
$sqlParams
);
Expand Down Expand Up @@ -90,4 +90,4 @@ public function stopRecordingAction()

$this->Response()->setBody(json_encode(['success' => true]));
}
}
}
7 changes: 3 additions & 4 deletions FroshViewSnapshots.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace FroshViewSnapshots;

use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\UninstallContext;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\InstallContext;
use Shopware\Components\Plugin\Context\UninstallContext;
use Shopware\Components\Plugin\Context\UpdateContext;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Class FroshViewSnapshots
* @package FroshViewSnapshots
*/
class FroshViewSnapshots extends Plugin
{
Expand Down Expand Up @@ -60,4 +59,4 @@ public function uninstall(UninstallContext $context)

$this->container->get('dbal_connection')->query($sql);
}
}
}
1 change: 0 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# View Snapshots

[![Scrutinizer](https://scrutinizer-ci.com/g/FriendsOfShopware/FroshViewSnapshots/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/FriendsOfShopware/FroshViewSnapshots/?branch=master)
[![Travis CI](https://travis-ci.org/FriendsOfShopware/FroshViewSnapshots.svg?branch=master)](https://travis-ci.org/FriendsOfShopware/FroshViewSnapshots)

View Snapshots is a plugin for shopware that allows you to record/log requests
Expand Down
19 changes: 8 additions & 11 deletions Subscriber/Dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

/**
* Class Dispatch
* @package FroshViewSnapshots\Subscriber
*/
class Dispatch implements SubscriberInterface
{
Expand All @@ -23,14 +22,14 @@ class Dispatch implements SubscriberInterface

/**
* Dispatch constructor.
*
* @param \Enlight_Components_Session_Namespace $session
* @param Connection $connection
* @param Connection $connection
*/
public function __construct(
\Enlight_Components_Session_Namespace $session,
Connection $connection
)
{
) {
$this->session = $session;
$this->connection = $connection;
}
Expand Down Expand Up @@ -63,7 +62,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs

$view->assign(
[
'snapshotSessionID' => $snapshotSessionID ? : $sessionID,
'snapshotSessionID' => $snapshotSessionID ?: $sessionID,
'isSessionRecorded' => $isSessionRecorded,
]
);
Expand All @@ -72,8 +71,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs
$snapshotSessionID ||
!$isSessionRecorded ||
$request->isXmlHttpRequest()
)
{
) {
return;
}

Expand All @@ -86,8 +84,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs
try {
// workaround for PDOException when trying to serialize PDO instances
serialize($value);
}
catch (\Throwable $e) {
} catch (\Throwable $e) {
// as we only need a snapshot for the view, remove the PDO instance
$value = null;
}
Expand All @@ -100,7 +97,7 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs
$params['__action'] = $request->getActionName();
$params = json_encode($params);

$step = (int)$this->connection->fetchColumn(
$step = (int) $this->connection->fetchColumn(
'SELECT MAX(`step`) FROM `view_snapshots` WHERE `sessionID` = :sessionID',
['sessionID' => $sessionID]
);
Expand All @@ -117,4 +114,4 @@ public function onPostDispatchSecureFrontend(\Enlight_Controller_ActionEventArgs
]
);
}
}
}
7 changes: 3 additions & 4 deletions Subscriber/TemplateRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

/**
* Class TemplateRegistration
* @package FroshViewSnapshots\Subscriber
*/
class TemplateRegistration implements SubscriberInterface
{
Expand All @@ -22,14 +21,14 @@ class TemplateRegistration implements SubscriberInterface

/**
* TemplateRegistration constructor.
*
* @param $pluginDirectory
* @param \Enlight_Template_Manager $templateManager
*/
public function __construct(
$pluginDirectory,
\Enlight_Template_Manager $templateManager
)
{
) {
$this->pluginDirectory = $pluginDirectory;
$this->templateManager = $templateManager;
}
Expand All @@ -48,4 +47,4 @@ public function onPreDispatch()
{
$this->templateManager->addTemplateDir($this->pluginDirectory . '/Resources/views');
}
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "frosh/frosh-view-snapshots",
"name": "frosh/view-snapshots",
"keywords": ["views", "snapshot", "recording", "frontend", "template", "restore", "shopware", "shopware-plugin"],
"description": "Shopware plugin that allows you to record/log views and restore them",
"license": "MIT",
Expand Down
11 changes: 6 additions & 5 deletions tests/Unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

class TestKernel extends \Shopware\Kernel
{
protected function getConfigPath()
{
return __DIR__ . '/config.php';
}
/**
* Static method to start boot kernel without leaving local scope in test helper.
*/
Expand All @@ -47,5 +43,10 @@ public static function start()
$shop->registerResources();
$_SERVER['HTTP_HOST'] = $shop->getHost();
}

protected function getConfigPath()
{
return __DIR__ . '/config.php';
}
}
TestKernel::start();
TestKernel::start();
24 changes: 12 additions & 12 deletions tests/Unit/config.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<?php
return array_merge($this->loadConfig($this->AppPath() . 'Configs/Default.php'), [
'front' => [
'throwExceptions' => true,
'throwExceptions' => true,
'disableOutputBuffering' => false,
'showException' => true,
'showException' => true,
],
'errorHandler' => [
'throwOnRecoverableError' => true,
],
'session' => [
'unitTestEnabled' => true,
'name' => 'SHOPWARESID',
'name' => 'SHOPWARESID',
'cookie_lifetime' => 0,
'use_trans_sid' => false,
'gc_probability' => 1,
'gc_divisor' => 100,
'save_handler' => 'db',
'use_trans_sid' => false,
'gc_probability' => 1,
'gc_divisor' => 100,
'save_handler' => 'db',
],
'mail' => [
'type' => 'file',
'path' => $this->getCacheDir(),
],
'phpSettings' => [
'error_reporting' => E_ALL,
'display_errors' => 1,
'date.timezone' => 'Europe/Berlin',
'error_reporting' => E_ALL,
'display_errors' => 1,
'date.timezone' => 'Europe/Berlin',
'max_execution_time' => 0,
],
'csrfProtection' => [
'frontend' => false,
'backend' => false,
'backend' => false,
],
]);
]);

0 comments on commit c8b8e92

Please sign in to comment.