Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrik Rombach committed Apr 28, 2017
2 parents 1f12ecf + ec99b9a commit fda529f
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 107 deletions.
55 changes: 55 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
preset: psr2

risky: false

enabled:
- align_double_arrow # Align double arrow symbols (=>) in consecutive lines
- align_equals # Align equals symbols in consecutive lines
- alpha_ordered_imports # alternatively: length_ordered_imports
- blank_line_before_return # An empty line feed should precede a return statement.
- combine_consecutive_unsets # Calling unset on multiple items should be done in one call
- concat_with_spaces # Concatenation should be used with at least one whitespace around
- function_typehint_space # Add missing space between function's argument and its typehint
- hash_to_slash_comment # Single line comments should use double slashes // and not hash #
- linebreak_after_opening_tag # Ensure there is no code on the same line as the PHP open tag
- lowercase_cast # Cast should be written in lower case
- native_function_casing # Function defined by PHP should be called using the correct casing
- no_blank_lines_after_phpdoc # There should not be blank lines between docblock and the documented element
- no_blank_lines_after_return # Removes empty lines following a return statement
- no_blank_lines_after_throw # Removes empty lines following a throw statement
- no_blank_lines_between_imports # Removes empty lines inbetween import use statements
- no_empty_comment # There should not be any empty comments
- no_empty_phpdoc # There should not be empty PHPDoc blocks
- no_extra_consecutive_blank_lines # Removes extra consecutive empty lines
- no_short_bool_cast # Short cast bool using double exclamation mark should not be used
#- no_unreachable_default_argument_value # In method arguments there must not be arguments with default values before non-default ones
- no_unused_imports # Unused use statements must be removed
- no_useless_else # There should not be useless else cases
- no_useless_return # There should not be an empty return statement at the end of a function
- no_whitespace_in_blank_line # Remove trailing whitespace at the end of blank lines
- object_operator_without_whitespace # There should not be space before or after object T_OBJECT_OPERATOR
- ordered_class_elements # Orders the elements of classes/interfaces/traits
- phpdoc_add_missing_param_annotation # phpdoc_add_missing_param_annotation
- phpdoc_align # All items of the @param, @throws, @return, @var, and @type phpdoc tags must be aligned vertically
- phpdoc_indent # Docblocks should have the same indentation as the documented subject
- phpdoc_order # Annotations in phpdocs should be ordered so that param annotations come first, then throws annotations, then return annotations
- phpdoc_scalar # Scalar types should always be written in the same form. int not integer, bool not boolean, float not real or double
- phpdoc_separation # Annotations of the same type should immediately follow each other, and annotations of different types should be separated
- phpdoc_single_line_var_spacing # Single line @var PHPDoc should have proper spacing
- phpdoc_trim # Phpdocs should start and end with content, excluding the very first and last line of the docblocks
- pre_increment # Pre incrementation/decrementation should be used if possible
- short_array_syntax # Arrays should use the short syntax
- short_scalar_cast # Cast (boolean) and (integer) should be written as (bool) and (int), (double) and (real) as (float)
- single_blank_line_before_namespace # There should be exactly one blank line before a namespace declaration
- single_quote # Convert double quotes to single quotes for simple strings
- standardize_not_equals # Replace all <> with !=
- ternary_operator_spaces # Standardize spaces around ternary operator
- trailing_comma_in_multiline_array # PHP multi-line arrays should have a trailing comma
- unary_operator_spaces # Unary operators should be placed adjacent to their operands
- whitespace_after_comma_in_array # In array declaration, there MUST be a whitespace after each comma

finder:
name:
- "*.php"
not-path:
- "Views"
28 changes: 28 additions & 0 deletions CompilerPasses/EmotionComponentPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* @copyright Copyright (c) 2016, Net Inventors GmbH
* @category Shopware
* @author Net Inventors GmbH
*
*/

namespace NetiToolKit\CompilerPasses;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class EmotionComponentPass implements CompilerPassInterface
{
/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('shopware.emotion_component_installer')) {
$container->removeDefinition('neti_tool_kit.emotion_view_subscriber');
}
}
}
64 changes: 61 additions & 3 deletions NetiToolKit.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,72 @@
<?php
/**

/*
* @copyright Copyright (c) 2016, Net Inventors GmbH
* @category Shopware
* @author hrombach
* @author Net Inventors GmbH
*
*/

namespace NetiToolKit;

use NetiToolKit\CompilerPasses\EmotionComponentPass;
use Shopware\Components\Emotion\ComponentInstaller;
use Shopware\Components\Plugin;
use Shopware\Components\Plugin\Context\InstallContext;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;

class NetiToolKit extends Plugin
{
}
/**
* @param InstallContext $context
*/
public function install(InstallContext $context)
{
$emotionInstaller = $this->container->get(
'shopware.emotion_component_installer',
ContainerInterface::NULL_ON_INVALID_REFERENCE
);

if ($emotionInstaller instanceof ComponentInstaller) {
$this->createEmotionComponent($emotionInstaller);
}
}

/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
// avoid DI errors in Shopware < 5.2.10
$container->addCompilerPass(new EmotionComponentPass());

parent::build($container);
}

/**
* @param ComponentInstaller $emotionInstaller
*/
private function createEmotionComponent(ComponentInstaller $emotionInstaller)
{
$customCodeElement = $emotionInstaller->createOrUpdate(
$this->getName(),
'Custom HTML/JS',
[
'name' => 'ToolKit Custom Code',
'template' => 'neti_tool_kit_emotion_custom',
'cls' => 'emotion-tool_kit-element',
'description' => 'Custom HTML/JS Code that will be output as-is in the emotion element.',
]
);

$customCodeElement->createTextAreaField(
[
'name' => 'html_code',
'fieldLabel' => 'Code:',
'supportText' => 'Enter HTML/JS Code here, it will be not be altered in any way.',
'allowBlank' => false,
]
);
}
}
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Shopware ToolKit

[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Join the chat at https://gitter.im/NetInventors/sw.ext.neti_tool_kit](https://badges.gitter.im/NetInventors/sw.ext.neti_tool_kit.svg)](https://gitter.im/NetInventors/sw.ext.neti_tool_kit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NetInventors/sw.ext.neti_tool_kit/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/NetInventors/sw.ext.neti_tool_kit/?branch=develop)
[![Build Status](https://scrutinizer-ci.com/g/NetInventors/sw.ext.neti_tool_kit/badges/build.png?b=develop)](https://scrutinizer-ci.com/g/NetInventors/sw.ext.neti_tool_kit/build-status/develop)
## About ToolKit

This plugin for Shopware provides some usefull functions and tools wich every developer needs sometimes.
Expand All @@ -14,7 +14,7 @@ This plugin for Shopware provides some usefull functions and tools wich every d
## Install:
1. If you haven't already, download and install our free plugin "[NetiFoundation](http://store.shopware.com/detail/index/sArticle/162025)" from the Shopware Community Store
2. Download this plugin via [Shopware Store](http://store.shopware.com/detail/index/sArticle/163077) or clone this repository to the
*"engine/Shopware/Plugins/Core"* folder, **remember to name the plugin folder "NetiToolKit"** and install through the Plugin Manager
*"engine/Shopware/custom/plugins/"* folder, **remember to name the plugin folder "NetiToolKit"** and install through the Plugin Manager

## Configuration:
> Because some of these Features were moved from the Net Inventors Foundation Plugin the features **UserData**
Expand All @@ -35,6 +35,12 @@ If the user is logged in you can access the user infos on every page
Here you can check globally if the user is logged in
* Accessed in Smarty via `{$sUserLoggedIn}`

### Custom HTML / JS Code Emotion component (SW >= 5.2.10)
An emotion (Shopping worlds) component that enables you to add arbitrary HTML / JS code to shop pages with no
filtering or alteration. This differs from the default custom code emotion component in that you can mix JS and HTML code.
As this code is relayed to the page with no alteration, we take no responsibility for any problems resulting from this.
Use at your own risk!

## VCS
https://github.com/NetInventors/sw.ext.neti_tool_kit/

Expand Down
8 changes: 8 additions & 0 deletions Resources/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<service id="neti_tool_kit.subscriber.global_data" class="NetiToolKit\Subscriber\GlobalData">
<argument type="service" id="neti_foundation.plugin_manager_config"/>
<argument type="service" id="session"/>
<argument type="service" id="models" />
<tag name="shopware.event_subscriber"/>
</service>

Expand All @@ -19,5 +20,12 @@
<argument type="service" id="neti_foundation.plugin_manager_config"/>
<tag name="shopware.event_subscriber"/>
</service>

<!-- Emotion event subscriber -->
<service id="neti_tool_kit.emotion_view_subscriber"
class="Shopware\Components\Emotion\EmotionComponentViewSubscriber">
<argument>%neti_tool_kit.plugin_dir%</argument>
<tag name="shopware.event_subscriber"/>
</service>
</services>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{block name="widgets_emotion_components_toolkit_custom"}
{$Data.html_code}
{/block}
30 changes: 16 additions & 14 deletions Struct/PluginConfig.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
/**

/*
* @copyright Copyright (c) 2016, Net Inventors GmbH
* @category Shopware
* @author hrombach
* @author Net Inventors GmbH
*
*/

namespace NetiToolKit\Struct;
Expand All @@ -17,36 +19,36 @@ class PluginConfig extends AbstractClass
protected $listingProperties = false;

/**
* @var bool - provide $sUserLoggedIn globally
* @var bool - provide $netiUserData globally
*/
protected $globalLoginState = true;
protected $globalUserData = true;

/**
* @var bool - provide $netiUserData globally
* @var bool - provide $netiUserData with attributes globally
*/
protected $globalUserData = true;
protected $globalUserAttributeData;

/**
* @return boolean
* @return bool
*/
public function isListingProperties()
{
return $this->listingProperties;
}

/**
* @return boolean
* @return bool
*/
public function isGlobalLoginState()
public function isGlobalUserData()
{
return $this->globalLoginState;
return $this->globalUserData;
}

/**
* @return boolean
* @return string
*/
public function isGlobalUserData()
public function isGlobalUserAttributeData()
{
return $this->globalUserData;
return $this->globalUserAttributeData;
}
}
}
Loading

0 comments on commit fda529f

Please sign in to comment.