Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #430 from elcodi/feature/added-visithor
Browse files Browse the repository at this point in the history
Added Bridge for Visithor Bundle
  • Loading branch information
mmoreram committed May 7, 2015
2 parents 56f5889 + c101c6c commit 4af544f
Show file tree
Hide file tree
Showing 15 changed files with 511 additions and 108 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ services:

script:
- bin/behat -fprogress --tags="~javascript"
- bin/phpunit -c app
- bin/phpunit
- php app/console visithor:go --format=pretty --env=test

notifications:
email: false
Expand Down
3 changes: 3 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ public function registerBundles()
$bundles[] = new Elcodi\Bundle\FixturesBoosterBundle\ElcodiFixturesBoosterBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();

$bundles[] = new Visithor\Bundle\VisithorBundle();
$bundles[] = new Elcodi\Common\VisithorBridgeBundle\VisithorBridgeBundle();
}

return $bundles;
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
"phpunit/phpunit": "4.5.0",

"mmoreram/php-formatter": "1.0.4",
"fabpot/php-cs-fixer": "1.4.2"
"fabpot/php-cs-fixer": "1.4.2",
"visithor/visithor-bundle": "~0.1, >=0.1.7"
},
"scripts": {
"post-install-cmd": [
Expand Down
1 change: 0 additions & 1 deletion features/store/category.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Feature: Store category
Given I am on "category/women-shirts/1"
Then I should see more than 0 products

@haha
Scenario: Category redirection
Given I am on "category/women-shirts-false/1"
Then I should be on "category/women-shirts/1"
2 changes: 1 addition & 1 deletion features/workflow/product.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Product engine
And I check "elcodi_admin_product_form_type_product_enabled"
And I press "submit-save"
And I am on "/admin/product/19/variant/new"
And I wait "1" seconds
And I wait "3" seconds
And I select "1" from "select-Size"
And I select "4" from "select-Color"
And I fill in the following:
Expand Down
10 changes: 5 additions & 5 deletions app/phpunit.xml.dist → phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "bootstrap.php.cache" >
bootstrap = "app/bootstrap.php.cache" >

<testsuites>
<testsuite name="Bamboo Test Suite">
<directory>../src/Elcodi/*/*Bundle/Tests</directory>
<directory>src/Elcodi/*/*Bundle/Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>../src</directory>
<directory>src</directory>
<exclude>
<directory>../src/Elcodi/*/*Bundle/Resources</directory>
<directory>../src/Elcodi/*/*Bundle/Tests</directory>
<directory>src/Elcodi/*/*Bundle/Resources</directory>
<directory>src/Elcodi/*/*Bundle/Tests</directory>
</exclude>
</whitelist>
</filter>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@

{% block header_actions %}

<a href="{{ url('admin_customer_order_list', { customerId: customer.id }) }}" type="button" class="button-primary">
<i class="icon-shopping-cart"></i>
<span>{{ 'admin.order.from_user'|trans({ '%name%': customer.firstname }) }}</span>
</a>
{% if customer.id %}
<a href="{{ url('admin_customer_order_list', { customerId: customer.id }) }}" type="button" class="button-primary">
<i class="icon-shopping-cart"></i>
<span>{{ 'admin.order.from_user'|trans({ '%name%': customer.firstname }) }}</span>
</a>
{% endif %}

{% endblock header_actions %}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/*
* This file is part of the Elcodi package.
*
* Copyright (c) 2014-2015 Elcodi.com
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <yuhu@mmoreram.com>
* @author Aldo Chiecchia <zimage@tiscali.it>
* @author Elcodi Team <tech@elcodi.com>
*/

namespace Elcodi\Common\VisithorBridgeBundle\DependencyInjection;

use Elcodi\Bundle\CoreBundle\DependencyInjection\Abstracts\AbstractExtension;

/**
* Class VisithorBridgeExtension
*/
class VisithorBridgeExtension extends AbstractExtension
{
/**
* @var string
*
* Extension name
*/
const EXTENSION_NAME = 'visithor_bridge';

/**
* Get the Config file location
*
* @return string Config file location
*/
public function getConfigFilesLocation()
{
return __DIR__ . '/../Resources/config';
}

/**
* Config files to load
*
* Each array position can be a simple file name if must be loaded always,
* or an array, with the filename in the first position, and a boolean in
* the second one.
*
* As a parameter, this method receives all loaded configuration, to allow
* setting this boolean value from a configuration value.
*
* return array(
* 'file1.yml',
* 'file2.yml',
* ['file3.yml', $config['my_boolean'],
* ...
* );
*
* @param array $config Config definitions
*
* @return array Config files
*/
protected function getConfigFiles(array $config)
{
return [
'visithor',
];
}

/**
* Returns the extension alias, same value as extension name
*
* @return string The alias
*/
public function getAlias()
{
return self::EXTENSION_NAME;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

/*
* This file is part of the Elcodi package.
*
* Copyright (c) 2014-2015 Elcodi.com
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Feel free to edit as you please, and have fun.
*
* @author Marc Morera <yuhu@mmoreram.com>
* @author Aldo Chiecchia <zimage@tiscali.it>
* @author Elcodi Team <tech@elcodi.com>
*/

namespace Elcodi\Common\VisithorBridgeBundle\Environment;

use Symfony\Component\HttpKernel\KernelInterface;
use Visithor\Bundle\Environment\SymfonyEnvironmentBuilder;

use Elcodi\Component\User\Repository\AdminUserRepository;
use Elcodi\Component\User\Repository\CustomerRepository;

/**
* Class EnvironmentBuilder
*/
class EnvironmentBuilder extends SymfonyEnvironmentBuilder
{
/**
* @var CustomerRepository
*
* Customer Repository
*/
protected $customerRepository;

/**
* @var AdminUserRepository
*
* Admin User Repository
*/
protected $adminUserRepository;

/**
* Construct
*
* @param CustomerRepository $customerRepository Customer Repository
* @param AdminUserRepository $adminUserRepository Admin User Repository
*/
public function __construct(
CustomerRepository $customerRepository,
AdminUserRepository $adminUserRepository
) {
$this->customerRepository = $customerRepository;
$this->adminUserRepository = $adminUserRepository;
}

/**
* Set up environment
*
* @param KernelInterface $kernel Kernel
*
* @return $this Self object
*/
public function setUp(KernelInterface $kernel)
{
parent::setUp($kernel);

$this
->executeCommand('doctrine:fixtures:load', [
'--fixtures' => $kernel
->getRootDir() . '/../src/Elcodi/Fixtures',
])
->executeCommand('elcodi:templates:load')
->executeCommand('elcodi:templates:enable', [
'template' => 'StoreTemplateBundle',
])
->executeCommand('elcodi:plugins:load')
->executeCommand('assets:install')
->executeCommand('assetic:dump');
}

/**
* Get authenticated user
*
* @param string $role Role
*
* @return mixed User for authentication
*/
public function getAuthenticationUser($role)
{
return 'ROLE_ADMIN' === $role
? $this
->adminUserRepository
->findOneBy([
'email' => 'admin@admin.com',
])
: $this
->customerRepository
->find([
'email' => 'customer@customer.com',
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:

#
# Visithor Bridge
#
visitor.environment_builder:
class: Elcodi\Common\VisithorBridgeBundle\Environment\EnvironmentBuilder
arguments:
- @elcodi.repository.customer
- @elcodi.repository.admin_user
Loading

0 comments on commit 4af544f

Please sign in to comment.