Skip to content

Commit

Permalink
Merge pull request #965 from dpfaffenbauer/standalone-index-bundle
Browse files Browse the repository at this point in the history
[IndexBundle] improve standalone usage
  • Loading branch information
dpfaffenbauer committed May 2, 2019
2 parents f83e10f + 163d25d commit 42c9891
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 2 deletions.
91 changes: 90 additions & 1 deletion src/CoreShop/Bundle/IndexBundle/CoreShopIndexBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@
use CoreShop\Bundle\IndexBundle\DependencyInjection\Compiler\RegisterIndexWorkerPass;
use CoreShop\Bundle\IndexBundle\DependencyInjection\Compiler\RegisterInterpreterPass;
use CoreShop\Bundle\IndexBundle\DependencyInjection\Compiler\RegisterOrderRendererTypesPass;
use CoreShop\Bundle\MenuBundle\CoreShopMenuBundle;
use CoreShop\Bundle\ResourceBundle\AbstractResourceBundle;
use CoreShop\Bundle\ResourceBundle\CoreShopResourceBundle;
use Pimcore\Extension\Bundle\PimcoreBundleInterface;
use Pimcore\Extension\Bundle\Traits\PackageVersionTrait;
use Pimcore\HttpKernel\BundleCollection\BundleCollection;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class CoreShopIndexBundle extends AbstractResourceBundle
final class CoreShopIndexBundle extends AbstractResourceBundle implements PimcoreBundleInterface
{
use PackageVersionTrait;

public static function registerDependentBundles(BundleCollection $collection)
{
parent::registerDependentBundles($collection);

$collection->addBundle(new CoreShopMenuBundle(), 4000);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -60,4 +73,80 @@ protected function getModelNamespace()
{
return 'CoreShop\Component\Index\Model';
}

/**
* {@inheritdoc}
*/
public function getNiceName()
{
return 'CoreShop - Core';
}

/**
* {@inheritdoc}
*/
public function getDescription()
{
return 'CoreShop - Pimcore eCommerce';
}

/**
* {@inheritdoc}
*/
protected function getComposerPackageName(): string
{
return 'coreshop/index-bundle';
}

/**
* {@inheritdoc}
*/
public function getInstaller()
{
if ($this->container->has(Installer::class)) {
return $this->container->get(Installer::class);
}

return null;
}

/**
* {@inheritdoc}
*/
public function getAdminIframePath()
{
return null;
}

/**
* {@inheritdoc}
*/
public function getJsPaths()
{
return [];
}

/**
* {@inheritdoc}
*/
public function getCssPaths()
{
return [];
}

/**
* {@inheritdoc}
*/
public function getEditmodeJsPaths()
{
return [];
}

/**
* {@inheritdoc}
*/
public function getEditmodeCssPaths()
{
return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function load(array $config, ContainerBuilder $container)

if (!array_key_exists('CoreShopCoreBundle', $bundles)) {
$loader->load('services/menu.yml');
$loader->load('services/installer.yml');

$config['pimcore_admin']['js']['menu'] = '/admin/coreshop/coreshop.index/menu.js';
}
Expand Down
56 changes: 56 additions & 0 deletions src/CoreShop/Bundle/IndexBundle/Installer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2019 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/

namespace CoreShop\Bundle\IndexBundle;

use Doctrine\DBAL\Migrations\Version;
use Doctrine\DBAL\Schema\Schema;
use Pimcore\Extension\Bundle\Installer\MigrationInstaller;
use Pimcore\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;

class Installer extends MigrationInstaller
{
/**
*
*/
protected function beforeInstallMigration()
{
$kernel = \Pimcore::getKernel();
$application = new Application($kernel);
$application->setAutoExit(false);
$options = ['command' => 'coreshop:resources:install'];
$options = array_merge($options, ['--no-interaction' => true, '--application-name object_index']);
$application->run(new ArrayInput($options));

$options = ['command' => 'coreshop:resources:create-tables'];
$options = array_merge($options, ['application-name' => 'coreshop', '--no-interaction' => true, '--force' => true]);
$application->run(new ArrayInput($options));
}


/**
* {@inheritdoc}
*/
public function migrateInstall(Schema $schema, Version $version)
{

}

/**
* {@inheritdoc}
*/
public function migrateUninstall(Schema $schema, Version $version)
{

}
}
2 changes: 1 addition & 1 deletion src/CoreShop/Bundle/IndexBundle/Menu/IndexMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function buildMenu(ItemInterface $menuItem, FactoryInterface $factory, st
->addChild('coreshop_indexes')
->setLabel('coreshop_indexes')
->setAttribute('permission', 'coreshop_permission_index')
->setAttribute('iconCls', 'coreshop_icon_carriers')
->setAttribute('iconCls', 'coreshop_icon_indexes')
->setAttribute('resource', 'coreshop.index')
->setAttribute('function', 'index');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
_defaults:
autowire: true
autoconfigure: true
public: false

CoreShop\Bundle\IndexBundle\Installer:
public: true
arguments:
$bundle: "@=service('kernel').getBundle('CoreShopIndexBundle')"
6 changes: 6 additions & 0 deletions src/CoreShop/Bundle/IndexBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"coreshop/index": "^2.0",
"coreshop/registry": "^2.0",
"coreshop/resource-bundle": "^2.0",
"coreshop/menu-bundle": "^2.1",
"pimcore/pimcore": "^5.7.2"
},
"conflict": {
Expand All @@ -42,6 +43,11 @@
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
},
"pimcore": {
"bundles": [
"CoreShop\\Bundle\\IndexBundle\\CoreShopIndexBundle"
]
}
}
}

0 comments on commit 42c9891

Please sign in to comment.