Skip to content

Commit

Permalink
Merge branch 'release/3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
24198 committed Apr 22, 2021
2 parents b7df2ce + 0dcab9c commit d80705c
Show file tree
Hide file tree
Showing 236 changed files with 6,765 additions and 1,542 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "3.1-dev"
}
},
"autoload": {
Expand Down
6 changes: 4 additions & 2 deletions src/Marello/Bundle/CatalogBundle/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* @ORM\Table(name="marello_catalog_category",
* uniqueConstraints={
* @ORM\UniqueConstraint(
* name="marello_catalog_category_codeidx",
* columns={"code"}
* name="marello_catalog_category_codeorgidx",
* columns={"code", "organization_id"}
* )
* }
* )
Expand Down Expand Up @@ -218,6 +218,7 @@ public function addProduct(Product $product)
{
if (!$this->hasProduct($product)) {
$this->products->add($product);
$product->addCategoryCode($this->getCode());
}

return $this;
Expand All @@ -230,6 +231,7 @@ public function addProduct(Product $product)
public function removeProduct(Product $product)
{
if ($this->hasProduct($product)) {
$product->removeCategory($this);
$this->products->removeElement($product);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Marello\Bundle\CatalogBundle\Entity\Repository;

use Doctrine\ORM\EntityRepository;
use Marello\Bundle\CatalogBundle\Entity\Category;
use Marello\Bundle\ProductBundle\Entity\Product;
use Marello\Bundle\SalesBundle\Entity\SalesChannel;
use Oro\Bundle\SecurityBundle\ORM\Walker\AclHelper;

class CategoryRepository extends EntityRepository
Expand Down Expand Up @@ -33,4 +36,17 @@ public function findExcludedCategoriesIds(array $relatedCategoriesIds)

return $this->aclHelper->apply($qb)->getArrayResult();
}

/**
* @param Product $product
* @return Category[]
*/
public function findByProduct(Product $product)
{
$qb = $this->createQueryBuilder('c')
->where(':product MEMBER OF c.products')
->setParameters(['product' => $product]);

return $qb->getQuery()->getResult();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MarelloCatalogBundleInstaller implements Installation, ActivityExtensionAw
*/
public function getMigrationVersion()
{
return 'v1_1_1';
return 'v1_2';
}

/**
Expand Down Expand Up @@ -61,7 +61,7 @@ protected function createCatalogCategoryTable(Schema $schema)
$table->addColumn('updated_at', 'datetime', ['notnull' => false]);
$table->addColumn('organization_id', 'integer', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['code'], 'marello_catalog_category_codeidx');
$table->addUniqueIndex(['code', 'organization_id'], 'marello_catalog_category_codeorgidx');

$this->activityExtension->addActivityAssociation($schema, 'oro_note', 'marello_catalog_category');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Marello\Bundle\CatalogBundle\Migrations\Schema\v1_2;

use Doctrine\DBAL\Schema\Schema;
use Oro\Bundle\MigrationBundle\Migration\Migration;
use Oro\Bundle\MigrationBundle\Migration\QueryBag;

/**
* @SuppressWarnings(PHPMD.TooManyMethods)
*/
class MarelloCatalogBundle implements Migration
{
/**
* {@inheritdoc}
*/
public function up(Schema $schema, QueryBag $queries)
{
$this->changeMarelloCatalogCategoryUniqueIndex($schema);
}

/**
* @param Schema $schema
*/
protected function changeMarelloCatalogCategoryUniqueIndex(Schema $schema)
{
$table = $schema->getTable('marello_catalog_category');
$table->dropIndex('marello_catalog_category_codeidx');
$table->addUniqueIndex(['code', 'organization_id'], 'marello_catalog_category_codeorgidx');
}
}
14 changes: 6 additions & 8 deletions src/Marello/Bundle/CatalogBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ services:
- '@request_stack'
- '@doctrine.orm.entity_manager'

marello_catalog.event_listener.datagrid.products_grid:
class: 'Marello\Bundle\CatalogBundle\EventListener\Datagrid\CategoriesDatagridListener'
arguments:
- 'Marello\Bundle\ProductBundle\Entity\Product'
- '@marello_catalog.provider.categories_choices'
tags:
- { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.marello-products-grid, method: onBuildBefore }

marello_catalog.listener.datagrid.category_products_column_listener:
class: 'Marello\Bundle\CatalogBundle\EventListener\Datagrid\CategoryProductsColumnListener'
arguments:
Expand Down Expand Up @@ -57,3 +49,9 @@ services:
calls:
- [setAclHelper, ['@oro_security.acl_helper']]

marello_catalog.twig.category_extension:
class: 'Marello\Bundle\CatalogBundle\Twig\CategoryExtension'
arguments:
- '@doctrine'
tags:
- { name: twig.extension }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Marello\Bundle\CatalogBundle\Entity\Category:
constraints:
- Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
fields: code
fields: [code, organization]
message: 'marello.catalog.category.messages.error.code'
properties:
name:
Expand Down

This file was deleted.

68 changes: 68 additions & 0 deletions src/Marello/Bundle/CatalogBundle/Twig/CategoryExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace Marello\Bundle\CatalogBundle\Twig;

use Doctrine\Bundle\DoctrineBundle\Registry;
use Marello\Bundle\CatalogBundle\Entity\Category;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class CategoryExtension extends AbstractExtension
{
const NAME = 'marello_category';

/**
* @var Registry
*/
private $doctrine;

/**
* @param Registry $doctrine
*/
public function __construct(Registry $doctrine)
{
$this->doctrine = $doctrine;
}

/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return self::NAME;
}

/**
* Returns a list of functions to add to the existing list.
*
* @return array An array of functions
*/
public function getFunctions()
{
return [
new TwigFunction(
'marello_get_category_name_by_code',
[$this, 'getCategoryNameByCode']
)
];
}

/**
* @param string $code
* @return string
*/
public function getCategoryNameByCode($code)
{
$category = $this->doctrine
->getManagerForClass(Category::class)
->getRepository(Category::class)
->findOneBy(['code' => $code]);
if ($category) {
return $category->getName();
}

return $code;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Marello\Bundle\CustomerBundle\Autocomplete;

use Marello\Bundle\CustomerBundle\Entity\Company;
use Oro\Bundle\FormBundle\Autocomplete\SearchHandler;
use Oro\Bundle\FormBundle\Autocomplete\FullNameSearchHandler;
use Doctrine\ORM\QueryBuilder;

class CompanyCustomerHandler extends SearchHandler
class CompanyCustomerHandler extends FullNameSearchHandler
{
/**
* {@inheritdoc}
Expand Down
Loading

0 comments on commit d80705c

Please sign in to comment.