-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
12 changed files
with
371 additions
and
107 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,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" |
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,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'); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -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, | ||
] | ||
); | ||
} | ||
} |
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
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
3 changes: 3 additions & 0 deletions
3
...rces/views/emotion_components/widgets/emotion/components/neti_tool_kit_emotion_custom.tpl
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,3 @@ | ||
{block name="widgets_emotion_components_toolkit_custom"} | ||
{$Data.html_code} | ||
{/block} |
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
Oops, something went wrong.