-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7e6d60
Showing
22 changed files
with
696 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
exec("ln -s ../../.githooks/pre-commit ".__DIR__."/../.git/hooks/pre-commit"); | ||
exec("chmod +x ".__DIR__ . "/../.git/hooks/pre-commit"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
/** | ||
* .git/hooks/pre-commit | ||
* | ||
* This pre-commit hooks will check for PHP errors (lint), and make sure the | ||
* code is PSR-2 compliant. | ||
*/ | ||
class PreCommitChecks | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $error = false; | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function run() | ||
{ | ||
$this->writeln(); | ||
$this->writeln('Checking commit requirements', 0); | ||
$this->writeln(); | ||
|
||
if ($this->isRebase()) { | ||
echo 'Not on branch' . PHP_EOL; | ||
|
||
return 0; | ||
} | ||
|
||
$this->runPhpLint($this->getCommittedFileList()); | ||
$this->runPhpCsFixer($this->getCommittedFileList()); | ||
$this->runEsLint($this->getCommittedFileList('js')); | ||
|
||
if ($this->error) { | ||
$this->writeln("If you are ABSOLUTELY sure your code is correct, you can use 'git commit --no-verify' to bypass this validation", 0); | ||
} | ||
|
||
exit((int) $this->error); | ||
} | ||
|
||
/** | ||
* @param string $output | ||
* @param int $level | ||
*/ | ||
private function writeln($output = '', $level = 1) | ||
{ | ||
$this->write($output, $level); | ||
echo PHP_EOL; | ||
} | ||
|
||
/** | ||
* @param string $output | ||
* @param int $level | ||
*/ | ||
private function write($output = '', $level = 1) | ||
{ | ||
$spaces = $level * 3; | ||
|
||
echo str_pad($output, strlen($output) + $spaces, ' ', STR_PAD_LEFT); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
private function isRebase() | ||
{ | ||
$output = []; | ||
exec('git symbolic-ref --short -q HEAD', $output); | ||
|
||
return empty($output); | ||
} | ||
|
||
/** | ||
* @param string $extension | ||
* @return string[] | ||
*/ | ||
private function getCommittedFileList($extension = 'php') | ||
{ | ||
exec("git diff --name-only --diff-filter=ACMRTUXB \"HEAD\" | grep -e '\." . $extension . "$'", $fileList); | ||
|
||
return $fileList; | ||
} | ||
|
||
/** | ||
* @param array $fileList | ||
*/ | ||
private function runPhpLint(array $fileList) | ||
{ | ||
$this->writeln('# Checking php syntax'); | ||
$this->writeln('> php -l'); | ||
|
||
foreach ($fileList as $file) { | ||
exec('php -l ' . escapeshellarg($file) . ' 2> /dev/null', $output, $return); | ||
if ($return !== 0) { | ||
$this->writeln('- ' . $output[1], 2); | ||
$this->error = true; | ||
} | ||
} | ||
|
||
$this->writeln(); | ||
} | ||
|
||
/** | ||
* @param array $fileList | ||
*/ | ||
private function runPhpCsFixer(array $fileList) | ||
{ | ||
$this->writeln('# Checking php code style'); | ||
$this->writeln('> php-cs-fixer fix -v --no-ansi --dry-run'); | ||
|
||
if (!$this->isPHPCSFixerAvailable()) { | ||
$this->error = true; | ||
$this->writeln('- php-cs-fixer is NOT installed. Please install composer with dev dependencies.', 2); | ||
$this->writeln(); | ||
|
||
return; | ||
} | ||
|
||
foreach ($fileList as $file) { | ||
exec('./../../../vendor/bin/php-cs-fixer fix -v --no-ansi --dry-run ' . escapeshellarg($file) . ' 2>&1', $output, $return); | ||
|
||
if ($return !== 0) { | ||
$this->writeln('- ' . preg_replace('#^(\s+)?\d\)\s#', '', $output[3]), 2); | ||
$fixes[] = './../../../vendor/bin/php-cs-fixer fix -v ' . escapeshellarg($file); | ||
$this->error = true; | ||
} | ||
} | ||
|
||
if (!empty($fixes)) { | ||
$this->writeln(); | ||
$this->writeln('Help:', 2); | ||
foreach ($fixes as $fix) { | ||
$this->writeln($fix, 3); | ||
} | ||
} | ||
|
||
$this->writeln(); | ||
} | ||
|
||
/** | ||
* @param array $fileList | ||
*/ | ||
private function runEsLint(array $fileList) | ||
{ | ||
$this->writeln('# Checking javascript code style'); | ||
$this->writeln('> eslint.js --ignore-path .eslintignore'); | ||
|
||
if (!$this->isESLintAvailable()) { | ||
$this->writeln('- eslint.js not found. Skipping javascript code style check.', 2); | ||
$this->writeln(); | ||
|
||
return; | ||
} | ||
|
||
$this->checkESLint($fileList); | ||
|
||
$this->writeln(); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
private function isPHPCSFixerAvailable() | ||
{ | ||
$output = []; | ||
$return = 0; | ||
exec('command -v ./../../../vendor/bin/php-cs-fixer >/dev/null 2>&1', $output, $return); | ||
|
||
return !(bool) $return; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
private function isESLintAvailable() | ||
{ | ||
$output = []; | ||
$return = 0; | ||
exec('command -v ./../../../themes/node_modules/eslint/bin/eslint.js >/dev/null 2>&1', $output, $return); | ||
|
||
return !(bool) $return; | ||
} | ||
|
||
/** | ||
* @param array $fileList | ||
*/ | ||
private function checkESLint(array $fileList = []) | ||
{ | ||
$output = []; | ||
$return = 0; | ||
exec( | ||
'./../../../themes/node_modules/eslint/bin/eslint.js ' . | ||
'--ignore-path .eslintignore ' . | ||
'-c ./../../../themes/.eslintrc.js ' . | ||
'--global "Ext" ' . | ||
implode(' ', $fileList), | ||
$output, | ||
$return | ||
); | ||
$return = !(bool) $return; | ||
|
||
if (!$return) { | ||
$this->error = true; | ||
|
||
foreach ($output as $line) { | ||
$this->writeln($line, 2); | ||
} | ||
|
||
$this->writeln('Help:', 2); | ||
$this->writeln( | ||
'./../../../themes/node_modules/eslint/bin/eslint.js ' . | ||
'--fix --ignore-path .eslintignore ' . | ||
'-c ./../../../themes/.eslintrc.js ' . | ||
'--global "Ext" ' . | ||
implode(' ', $fileList), | ||
3 | ||
); | ||
} | ||
} | ||
} | ||
|
||
$checks = new PreCommitChecks(); | ||
$checks->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
vendor | ||
.psh.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
; | ||
|
||
$header = <<<EOF | ||
(c) Datatrics B.V. <hello@datatrics.com> | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setUsingCache(false) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'@Symfony' => true, | ||
'header_comment' => ['header' => $header, 'separate' => 'bottom', 'commentType' => 'PHPDoc'], | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'ordered_class_elements' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_order' => true, | ||
'phpdoc_summary' => false, | ||
'blank_line_after_opening_tag' => false, | ||
'concat_space' => ['spacing' => 'one'], | ||
'array_syntax' => ['syntax' => 'short'], | ||
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], | ||
]) | ||
->setFinder($finder) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace DatatricsPixel; | ||
|
||
use Shopware\Components\Plugin; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* Shopware-Plugin DatatricsPixel. | ||
*/ | ||
class DatatricsPixel extends Plugin | ||
{ | ||
|
||
/** | ||
* @param ContainerBuilder $container | ||
*/ | ||
public function build(ContainerBuilder $container) | ||
{ | ||
$container->setParameter('datatrics_pixel.plugin_dir', $this->getPath()); | ||
parent::build($container); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Datatrics B.V. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# DatatricsPixel | ||
|
||
Datatrics Pixel for Shopware | ||
|
||
Required Minimum Shopware Version 5.2 | ||
|
||
# Installation | ||
|
||
## Zip Installation package for the Shopware Plugin Manager | ||
|
||
* Download the [latest plugin version](https://github.com/datatrics/shopware-pixel/releases/latest/) (e.g. `DatatricsPixel-1.0.0.zip`) | ||
* Upload and install plugin using Plugin Manager | ||
|
||
## Git Version | ||
* Checkout Plugin in `/custom/plugins/DatatricsPixel` | ||
* Change to Directory and run `composer install` to install the dependencies | ||
* Install the Plugin with the Plugin Manager | ||
|
||
## Install with composer | ||
* Change to your root Installation of shopware | ||
* Run command `composer require datatrics/shopware-pixel` and install and active plugin with Plugin Manager | ||
|
||
### Features | ||
|
||
* Pixel | ||
* Track product & category views | ||
* Track shoppingcart updates | ||
* Track conversions | ||
* Track loggedin customers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/shopware/5.5/engine/Shopware/Components/Plugin/schema/config.xsd"> | ||
<elements> | ||
<element scope="locale" required="true"> | ||
<name>tracking_code</name> | ||
<label lang="de">Datatrics Project ID</label> | ||
<label lang="en">Datatrics Project ID</label> | ||
<description lang="de">Sie finden Ihre Datatrics-Projekt-ID auf der Seite "Projekteinstellungen" in der Datatrics-App.</description> | ||
<description lang="en">You can find your Datatrics Project ID on your Project Settings page in the Datatrics App.</description> | ||
</element> | ||
|
||
<element scope="locale" type="boolean"> | ||
<name>include_header</name> | ||
<label lang="de">Tracking-Code im "head"-Bereich inkludieren (Responsive Theme)</label> | ||
<label lang="en">Include the tracking code in the "head" section (Responsive theme)</label> | ||
<value>true</value> | ||
</element> | ||
|
||
</elements> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="datatrics_pixel.subscriber.template_registration" class="DatatricsPixel\Subscriber\TemplateRegistration"> | ||
<argument>%datatrics_pixel.plugin_dir%</argument> | ||
<argument type="service" id="template"/> | ||
<tag name="shopware.event_subscriber"/> | ||
</service> | ||
<service id="datatrics_pixel.subscriber.route" class="DatatricsPixel\Subscriber\RouteSubscriber"> | ||
<argument>%datatrics_pixel.plugin_name%</argument> | ||
<argument>%datatrics_pixel.plugin_dir%</argument> | ||
<argument type="service" id="shopware.plugin.cached_config_reader" /> | ||
<tag name="shopware.event_subscriber" /> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script type="text/javascript"> | ||
_paq.push(["setEcommerceView", | ||
"{$sArticle.articleID }", | ||
"{$sArticle.articleName|escape:'javascript'}", | ||
"", | ||
"{$sArticle.price}" | ||
]); | ||
_paq.push(["trackPageView"]); | ||
</script> |
Oops, something went wrong.