Browse code

Initial commit

Benjamin Roth authored on25/11/2018 15:53:19
Showing16 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+# EditorConfig is awesome: http://EditorConfig.org
2
+
3
+# top-most EditorConfig file
4
+root = true
5
+
6
+# Unix-style newlines with a newline ending every file
7
+[*]
8
+end_of_line = lf
9
+insert_final_newline = true
10
+trim_trailing_whitespace = true
11
+
12
+[*.{php,twig,yml}]
13
+indent_style = space
14
+indent_size = 4
15
+
16
+[*.{html5,svg,min.css,min.js}]
17
+insert_final_newline = false
0 18
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+# Composer
2
+/composer.lock
3
+/vendor/
4
+
5
+# PhpUnit
6
+/phpunit.xml
7
+
8
+# IDE
9
+/.idea/
0 10
new file mode 100644
... ...
@@ -0,0 +1,58 @@
1
+<?php
2
+
3
+$header = <<<EOF
4
+This file is part of eSales Media ContentHelperBundle.
5
+
6
+(c) Benjamin Roth
7
+
8
+@license proprietary
9
+EOF;
10
+
11
+$finder = PhpCsFixer\Finder::create()
12
+    ->exclude('Resources')
13
+    ->in([__DIR__.'/src', __DIR__.'/tests'])
14
+;
15
+
16
+return PhpCsFixer\Config::create()
17
+    ->setRules([
18
+        '@Symfony' => true,
19
+        '@Symfony:risky' => true,
20
+        '@PHPUnit60Migration:risky' => true,
21
+        'align_multiline_comment' => true,
22
+        'array_syntax' => ['syntax' => 'short'],
23
+        'combine_consecutive_issets' => true,
24
+        'combine_consecutive_unsets' => true,
25
+        'compact_nullable_typehint' => true,
26
+        'general_phpdoc_annotation_remove' => [
27
+            'expectedException',
28
+            'expectedExceptionMessage',
29
+        ],
30
+        'header_comment' => ['header' => $header],
31
+        'heredoc_to_nowdoc' => true,
32
+        'linebreak_after_opening_tag' => true,
33
+        'no_null_property_initialization' => true,
34
+        'no_superfluous_elseif' => true,
35
+        'no_unreachable_default_argument_value' => true,
36
+        'no_useless_else' => true,
37
+        'no_useless_return' => true,
38
+        'ordered_class_elements' => true,
39
+        'ordered_imports' => true,
40
+        'php_unit_strict' => true,
41
+        'phpdoc_add_missing_param_annotation' => true,
42
+        'phpdoc_order' => true,
43
+        'phpdoc_types_order' => [
44
+            'null_adjustment' => 'always_last',
45
+            'sort_algorithm' => 'none',
46
+        ],
47
+        'strict_comparison' => true,
48
+        'strict_param' => true,
49
+        // Remove when https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/3222 has been merged
50
+        'LeoFeyer/optimize_native_functions' => true,
51
+    ])
52
+    ->registerCustomFixers([
53
+        new LeoFeyer\PhpCsFixer\OptimizeNativeFunctionsFixer()
54
+    ])
55
+    ->setFinder($finder)
56
+    ->setRiskyAllowed(true)
57
+    ->setUsingCache(false)
58
+;
0 59
new file mode 100644
... ...
@@ -0,0 +1,6 @@
1
+# Content helper bundle for Contao CMS
2
+
3
+This bundle adds little helpers for content handling in [Contao][1]
4
+
5
+
6
+[1]: https://contao.org
0 7
new file mode 100644
... ...
@@ -0,0 +1,40 @@
1
+{
2
+    "name": "esalesmedia/content-helper-bundle",
3
+    "type": "contao-bundle",
4
+    "description": "Adds little helpers for Contao contents",
5
+    "license": "proprietary",
6
+    "authors": [
7
+        {
8
+            "name": "Benjamin Roth",
9
+            "homepage": "https://www.esales-media.de"
10
+        }
11
+    ],
12
+    "require": {
13
+        "php": "^5.6 || ^7.0",
14
+        "contao/core-bundle": "^4.4"
15
+    },
16
+    "conflict": {
17
+        "contao/core": "*",
18
+        "contao/manager-plugin": "<2.0 || >=3.0"
19
+    },
20
+    "require-dev": {
21
+        "contao/manager-plugin": "^2.0",
22
+        "friendsofphp/php-cs-fixer": "^2.6"
23
+    },
24
+    "extra": {
25
+        "contao-manager-plugin": "EsalesMedia\\ContentHelperBundle\\ContaoManager\\Plugin"
26
+    },
27
+    "autoload": {
28
+        "psr-4": {
29
+            "EsalesMedia\\ContentHelperBundle\\": "src/"
30
+        }
31
+    },
32
+    "autoload-dev": {
33
+        "psr-4": {
34
+            "EsalesMedia\\ContentHelperBundle\\Tests\\": "tests/"
35
+        }
36
+    },
37
+    "support": {
38
+        "issues": "https://www.esales-media.de"
39
+    }
40
+}
0 41
new file mode 100644
1 42
Binary files /dev/null and b/composer.phar differ
2 43
new file mode 100644
... ...
@@ -0,0 +1,26 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+
3
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+         xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.0/phpunit.xsd"
5
+         backupGlobals="false"
6
+         colors="true"
7
+>
8
+    <php>
9
+        <ini name="error_reporting" value="-1" />
10
+    </php>
11
+
12
+    <testsuites>
13
+        <testsuite name="Linzertorten.com Bundle">
14
+            <directory>./tests</directory>
15
+        </testsuite>
16
+    </testsuites>
17
+
18
+    <filter>
19
+        <whitelist>
20
+            <directory>./src</directory>
21
+            <exclude>
22
+                <directory>./src/Resources</directory>
23
+            </exclude>
24
+        </whitelist>
25
+    </filter>
26
+</phpunit>
0 27
new file mode 100644
... ...
@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of eSales Media ContentHelperBundle
5
+ *
6
+ * (c) John Doe
7
+ *
8
+ * @license LGPL-3.0-or-later
9
+ */
10
+
11
+namespace EsalesMedia\ContentHelperBundle\ContaoManager;
12
+
13
+use EsalesMedia\ContentHelperBundle\EsalesMediaContentHelperBundle;
14
+use Contao\CoreBundle\ContaoCoreBundle;
15
+use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
16
+use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
17
+use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
18
+use MadeYourDay\RockSolidColumns\RockSolidColumnsBundle;
19
+
20
+class Plugin implements BundlePluginInterface
21
+{
22
+    /**
23
+     * {@inheritdoc}
24
+     */
25
+    public function getBundles(ParserInterface $parser)
26
+    {
27
+        $arrLoadAfter = [ContaoCoreBundle::class];
28
+
29
+        if (RockSolidColumnsBundle::class)
30
+        {
31
+            $arrLoadAfter[] = RockSolidColumnsBundle::class;
32
+        }
33
+
34
+        return [
35
+            BundleConfig::create(EsalesMediaContentHelperBundle::class)
36
+                ->setLoadAfter($arrLoadAfter)
37
+        ];
38
+    }
39
+}
0 40
new file mode 100644
... ...
@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of eSales Media ContentHelperBundle
5
+ *
6
+ * (c) Benjamin Roth
7
+ *
8
+ * @license proprietary
9
+ */
10
+
11
+namespace EsalesMedia\ContentHelperBundle\DependencyInjection;
12
+
13
+use Symfony\Component\Config\FileLocator;
14
+use Symfony\Component\DependencyInjection\ContainerBuilder;
15
+use Symfony\Component\DependencyInjection\Extension\Extension;
16
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
17
+
18
+class EsalesMediaContentHelperExtension extends Extension
19
+{
20
+    /**
21
+     * {@inheritdoc}
22
+     */
23
+    public function load(array $mergedConfig, ContainerBuilder $container)
24
+    {
25
+        $loader = new YamlFileLoader(
26
+            $container,
27
+            new FileLocator(__DIR__.'/../Resources/config')
28
+        );
29
+
30
+        $loader->load('listener.yml');
31
+        $loader->load('services.yml');
32
+    }
33
+}
0 34
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of eSales Media ContentHelperBundle
5
+ *
6
+ * (c) John Doe
7
+ *
8
+ * @license LGPL-3.0-or-later
9
+ */
10
+
11
+namespace EsalesMedia\ContentHelperBundle;
12
+
13
+use Symfony\Component\HttpKernel\Bundle\Bundle;
14
+
15
+class EsalesMediaContentHelperBundle extends Bundle
16
+{
17
+}
0 18
new file mode 100644
... ...
@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of eSales Media ContentHelperBundle
5
+ *
6
+ * (c) Benjamin Roth
7
+ *
8
+ * @license proprietary
9
+ */
10
+
11
+namespace EsalesMedia\ContentHelperBundle\EventListener;
12
+
13
+use Contao\CoreBundle\Framework\FrameworkAwareInterface;
14
+use Contao\CoreBundle\Framework\FrameworkAwareTrait;
15
+use Contao\Template;
16
+
17
+class TemplateListener implements FrameworkAwareInterface
18
+{
19
+    use FrameworkAwareTrait;
20
+
21
+    public function onParseTemplate(Template $template)
22
+    {
23
+        if ($template->es_spacing)
24
+        {
25
+            $template->class = trim($template->class.' spc_'.$template->es_spacing);
26
+        }
27
+    }
28
+}
0 29
new file mode 100644
... ...
@@ -0,0 +1,12 @@
1
+services:
2
+    _defaults:
3
+        public: true
4
+
5
+    _instanceof:
6
+        Contao\CoreBundle\Framework\FrameworkAwareInterface:
7
+            calls:
8
+                - ["setFramework", ["@contao.framework"]]
9
+
10
+    esalesmedia_content_helper.listener.template:
11
+        class: \EsalesMedia\ContentHelperBundle\EventListener\TemplateListener
12
+        public: true
0 13
new file mode 100644
... ...
@@ -0,0 +1,9 @@
1
+services:
2
+    _instanceof:
3
+        Contao\CoreBundle\Framework\FrameworkAwareInterface:
4
+            calls:
5
+                - ["setFramework", ["@contao.framework"]]
6
+
7
+        Symfony\Component\DependencyInjection\ContainerAwareInterface:
8
+            calls:
9
+                - ["setContainer", ["@service_container"]]
0 10
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of eSales Media ContentHelperBundle
5
+ *
6
+ * (c) Benjamin Roth
7
+ *
8
+ * @license proprietary
9
+ */
10
+
11
+
12
+/**
13
+ * Hooks
14
+ */
15
+$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('esalesmedia_content_helper.listener.template','onParseTemplate');
0 16
new file mode 100644
... ...
@@ -0,0 +1,32 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of eSales Media ContentHelperBundle
5
+ *
6
+ * (c) Benjamin Roth
7
+ *
8
+ * @license proprietary
9
+ */
10
+
11
+/*
12
+ * Modify palettes
13
+ */
14
+foreach ($GLOBALS['TL_DCA']['tl_content']['palettes'] as $key => $palette)
15
+{
16
+  $GLOBALS['TL_DCA']['tl_content']['palettes'][$key] = str_replace(',cssID;', ',cssID,es_spacing;', $palette);
17
+}
18
+
19
+/*
20
+ * Add fields
21
+ */
22
+
23
+$GLOBALS['TL_DCA']['tl_content']['fields']['es_spacing'] = array
24
+(
25
+  'label'                   => &$GLOBALS['TL_LANG']['tl_content']['es_spacing'],
26
+  'exclude'                 => true,
27
+  'inputType'               => 'select',
28
+  'options'                 => array('default','paragraph'),
29
+  'reference'               => &$GLOBALS['TL_LANG']['tl_content']['REF']['es_spacing'],
30
+  'eval'                    => array('tl_class'=>'w50','mandatory'=>false,'includeBlankOption'=>true),
31
+  'sql'                     => "varchar(32) NOT NULL default ''"
32
+);
0 33
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of [package name].
5
+ *
6
+ * (c) John Doe
7
+ *
8
+ * @license LGPL-3.0-or-later
9
+ */
10
+
11
+namespace EsalesMedia\ContentHelperBundle\Tests;
12
+
13
+use EsalesMedia\ContentHelperBundle\EsalesMediaContentHelperBundle;
14
+use PHPUnit\Framework\TestCase;
15
+
16
+class EsalesMediaContentHelperBundleTest extends TestCase
17
+{
18
+    public function testCanBeInstantiated()
19
+    {
20
+        $bundle = new EsalesMediaContentHelperBundle();
21
+
22
+        $this->assertInstanceOf('Contao\SkeletonBundle\EsalesMediaContentHelperBundle', $bundle);
23
+    }
24
+}