Skip to content

Commit

Permalink
changes and fixes structure to sylius 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboss86 committed Nov 14, 2019
1 parent aea427d commit e2243d9
Show file tree
Hide file tree
Showing 85 changed files with 523 additions and 535 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/vendor/
/node_modules/
/composer.lock
/.php_cs.cache
/.phpunit.result.cache

/etc/build/*
!/etc/build/.gitignore
Expand Down
1 change: 0 additions & 1 deletion .php_cs.cache

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ before_script:
- (cd tests/Application && bin/console server:run 127.0.0.1:8080 --quiet > /dev/null 2>&1 &)

script:
- composer validate --strict
- composer validate
- vendor/bin/phpstan analyse -c phpstan.neon -l max src/

- vendor/bin/phpunit
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-2019 Odiseo Team

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.
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<h1 align="center">
<a href="https://odiseo.com.ar/" target="_blank" title="Odiseo">
<img src="https://github.com/odiseoteam/SyliusBlogPlugin/blob/master/logo_odiseo.png" alt="Odiseo" width="300px" />
<img src="https://github.com/odiseoteam/SyliusBlogPlugin/blob/master/sylius-blog-plugin.png" alt="Sylius Blog Plugin" />
</a>
<br />
Odiseo Sylius Blog Plugin
<br />
<a href="https://packagist.org/packages/odiseoteam/sylius-blog-plugin" title="License" target="_blank">
<img src="https://img.shields.io/packagist/l/odiseoteam/sylius-blog-plugin.svg" />
</a>
Expand All @@ -25,18 +23,19 @@

## Description

This plugin add blog features to the Sylius ecommerce framework. It uses the [OdiseoBlogBundle](https://github.com/odiseoteam/OdiseoBlogBundle) Symfony bundle.

Now supporting Sylius 1.4+ with Symfony 4 + Flex structure.
This is a Sylius Plugin that add blog features to your store. It uses the [OdiseoBlogBundle](https://github.com/odiseoteam/OdiseoBlogBundle) Symfony bundle.

Features:

* Articles and article categories, both translatables.

* Multi images for articles.

* This plugin comes with fixtures.
* [NEW] Comments and comment replies. Comments can be made as ShopUser or as guest.

Screenshots:
* Comments and comment replies. Comments can be made as ShopUser or as guest.

Support Sylius version 1.3+.

<img src="https://github.com/odiseoteam/SyliusBlogPlugin/blob/master/screenshot_1.png" alt="Blog admin" width="80%">
<img src="https://github.com/odiseoteam/SyliusBlogPlugin/blob/master/screenshot_2.png" alt="Blog admin" width="80%">
Expand All @@ -45,15 +44,15 @@ Screenshots:

You can see this plugin in action in our Sylius Demo application.

- Frontend: [sylius-demo.odiseo.com.ar](https://sylius-demo.odiseo.com.ar).
- Frontend: [sylius-demo.odiseo.com.ar](https://sylius-demo.odiseo.com.ar).
- Administration: [sylius-demo.odiseo.com.ar/admin](https://sylius-demo.odiseo.com.ar/admin) with `odiseo: odiseo` credentials.

## Installation

1. Run `composer require odiseoteam/sylius-blog-plugin`

2. Enable the plugin in bundles.php. This plugin need the FOSCKEditorBundle and EWZRecaptchaBundle so make sure to include
them too:
them too

```php
<?php
Expand All @@ -64,26 +63,25 @@ return [
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
EWZ\Bundle\RecaptchaBundle\EWZRecaptchaBundle::class => ['all' => true],
Odiseo\SyliusBlogPlugin\OdiseoSyliusBlogPlugin::class => ['all' => true],
// ...
];
```

3. Import the plugin configurations

```yml
imports:
- { resource: "@OdiseoSyliusBlogPlugin/Resources/config/config.yml" }
- { resource: "@OdiseoSyliusBlogPlugin/Resources/config/config.yaml" }
```
4. Add the shop and admin routes
```yml
odiseo_sylius_blog_admin:
resource: "@OdiseoSyliusBlogPlugin/Resources/config/routing/admin.yml"
odiseo_sylius_blog_plugin_admin:
resource: "@OdiseoSyliusBlogPlugin/Resources/config/routing/admin.yaml"
prefix: /admin

odiseo_sylius_blog_shop:
resource: "@OdiseoSyliusBlogPlugin/Resources/config/routing/shop.yml"
odiseo_sylius_blog_plugin_shop:
resource: "@OdiseoSyliusBlogPlugin/Resources/config/routing/shop.yaml"
prefix: /{_locale}/blog
requirements:
_locale: ^[a-z]{2}(?:_[A-Z]{2})?$
Expand All @@ -97,7 +95,7 @@ php bin/console assets:install public
```

6. Finish the installation updating the database schema and installing assets

```
php bin/console doctrine:schema:update --force
php bin/console sylius:theme:assets:install
Expand All @@ -115,7 +113,7 @@ To render a list of latest articles you can do something like this:
```twig
{{ render(url('odiseo_sylius_blog_shop_partial_article_index_latest', {'count': 4, 'template': '@OdiseoSyliusBlogPlugin/Shop/Article/_latest.html.twig'})) }}
```

And to render a list of categories:

```twig
Expand All @@ -133,12 +131,13 @@ Simply add this configuration on your fixture suite:
```yml
blog:
options:
articles_per_channel: 10
articles_per_channel: 12
```
## Test the plugin
You can follow the instructions to test this plugins in the proper documentation page: [Test the plugin](doc/tests.md).
## Credits
This plugin is maintained by <a href="https://odiseo.com.ar">Odiseo</a>. Want us to help you with this plugin or any Sylius project? Contact us on <a href="mailto:[email protected]">[email protected]</a>.
4 changes: 3 additions & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/suites.yml
- tests/Behat/Resources/suites.yaml

default:
extensions:
Expand Down Expand Up @@ -30,6 +30,8 @@ default:
- "start-fullscreen"
- "start-maximized"
- "no-sandbox"
extra_capabilities:
unexpectedAlertBehaviour: accept
firefox:
selenium2:
browser: firefox
Expand Down
19 changes: 6 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,12 @@
"phpunit/phpunit": "^8.0",
"sensiolabs/security-checker": "^5.0",
"sylius-labs/coding-standard": "^3.0",
"symfony/browser-kit": "^3.4|^4.1",
"symfony/debug-bundle": "^3.4|^4.1",
"symfony/dotenv": "^4.2",
"symfony/intl": "^3.4|^4.1",
"symfony/web-profiler-bundle": "^3.4|^4.1",
"symfony/web-server-bundle": "^3.4|^4.1"
},
"conflict": {
"symfony/symfony": "4.1.8",
"symfony/browser-kit": "4.1.8",
"symfony/dependency-injection": "4.1.8",
"symfony/dom-crawler": "4.1.8",
"symfony/routing": "4.1.8"
"symfony/browser-kit": "^3.4|^4.3",
"symfony/debug-bundle": "^3.4|^4.3",
"symfony/dotenv": "^4.3",
"symfony/intl": "^3.4|^4.3",
"symfony/web-profiler-bundle": "^3.4|^4.3",
"symfony/web-server-bundle": "^3.4|^4.3"
},
"prefer-stable": true,
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion doc/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ We are using Behat, PHPSpec and PHPUnit to test this plugin.
From the plugin root directory, run the following commands:

$ (cd tests/Application && yarn install)
$ (cd tests/Application && yarn build)
$ (cd tests/Application && yarn run gulp)
$ (cd tests/Application && bin/console assets:install public -e test)

$ (cd tests/Application && bin/console doctrine:database:create -e test)
Expand Down
Binary file removed logo_odiseo.png
Binary file not shown.
19 changes: 7 additions & 12 deletions spec/Model/ArticleSpec.php → spec/Entity/ArticleSpec.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<?php

namespace spec\Odiseo\SyliusBlogPlugin\Model;
declare(strict_types=1);

use Doctrine\Common\Collections\ArrayCollection;
use Odiseo\SyliusBlogPlugin\Model\Article;
use Odiseo\SyliusBlogPlugin\Model\ArticleInterface;
namespace spec\Odiseo\SyliusBlogPlugin\Entity;

use Odiseo\SyliusBlogPlugin\Entity\Article;
use Odiseo\SyliusBlogPlugin\Entity\ArticleInterface;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\Channel;
use Sylius\Component\Resource\Model\CodeAwareInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Model\TimestampableInterface;

/**
* @author Diego D'amico <[email protected]>
*/
class ArticleSpec extends ObjectBehavior

final class ArticleSpec extends ObjectBehavior
{
function it_is_initializable()
{
Expand Down
7 changes: 5 additions & 2 deletions spec/Form/Extension/ArticleTypeExtensionSpec.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php

declare(strict_types=1);

namespace spec\Odiseo\SyliusBlogPlugin\Form\Extension;

use Odiseo\BlogBundle\Form\Type\ArticleType;
use Odiseo\SyliusBlogPlugin\Form\Extension\ArticleTypeExtension;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Bundle\ChannelBundle\Form\Type\ChannelChoiceType;
Expand All @@ -13,7 +16,7 @@ final class ArticleTypeExtensionSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Odiseo\SyliusBlogPlugin\Form\Extension\ArticleTypeExtension');
$this->shouldHaveType(ArticleTypeExtension::class);
}

function it_should_be_abstract_type_extension_object()
Expand All @@ -33,4 +36,4 @@ function it_has_extended_type()
{
$this->getExtendedType()->shouldReturn(ArticleType::class);
}
}
}
24 changes: 7 additions & 17 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,20 @@
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This class contains the configuration information for the bundle.
*
* This information is solely responsible for how the different configuration
* sections are normalized, and merged.
*
* @author Diego D'amico <[email protected]>
*/
final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('odiseo_sylius_blog');

$rootNode
->addDefaultsIfNotSet()
->children()
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
->end()
;
$treeBuilder = new TreeBuilder('odiseo_sylius_blog_plugin');
if (\method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$rootNode = $treeBuilder->root('odiseo_sylius_blog_plugin');
}

return $treeBuilder;
}
Expand Down
14 changes: 2 additions & 12 deletions src/DependencyInjection/OdiseoSyliusBlogExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;

/**
* @author Diego D'amico <[email protected]>
*/
final class OdiseoSyliusBlogExtension extends AbstractResourceExtension
{
/**
Expand All @@ -20,16 +17,9 @@ final class OdiseoSyliusBlogExtension extends AbstractResourceExtension
public function load(array $config, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $config);
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

$this->registerResources('odiseo_sylius_blog', $config['driver'], [], $container);

$configFiles = [
'services.yml',
];
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

foreach ($configFiles as $configFile) {
$loader->load($configFile);
}
$loader->load('services.yaml');
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<?php

namespace Odiseo\SyliusBlogPlugin\EventListener;
declare(strict_types=1);

use Odiseo\SyliusBlogPlugin\Model\ArticleInterface;
namespace Odiseo\SyliusBlogPlugin\Doctrine;

use Doctrine\ORM\Event\LifecycleEventArgs;
use Odiseo\SyliusBlogPlugin\Entity\ArticleInterface;
use Sylius\Component\Core\Model\AdminUserInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;

class SetArticleAuthorListener
final class SetArticleAuthorListener
{
/** @var TokenStorageInterface $tokenStorage */
protected $tokenStorage;
/** @var TokenStorageInterface */
private $tokenStorage;

public function __construct(TokenStorageInterface $tokenStorage)
{
public function __construct(
TokenStorageInterface $tokenStorage
) {
$this->tokenStorage = $tokenStorage;
}

Expand All @@ -25,7 +28,7 @@ public function prePersist(LifecycleEventArgs $args): void
$entity = $args->getEntity();
$token = $this->tokenStorage->getToken();

if($entity instanceOf ArticleInterface && $token) {
if ($entity instanceOf ArticleInterface && $token) {
$user = $token->getUser();

if ($user instanceof AdminUserInterface) {
Expand Down
Loading

0 comments on commit e2243d9

Please sign in to comment.