-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/magento2-integr' into testmerge-magentoint
- Loading branch information
Showing
24 changed files
with
437 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/Marello/Bundle/PricingBundle/Entity/PriceListInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\PricingBundle\Entity; | ||
|
||
use Marello\Bundle\ProductBundle\Entity\Product; | ||
|
||
interface PriceListInterface | ||
{ | ||
/** | ||
* @return BasePrice | ||
*/ | ||
public function getDefaultPrice(); | ||
|
||
/** | ||
* @return BasePrice | ||
*/ | ||
public function getSpecialPrice(); | ||
|
||
/** | ||
* @return Product | ||
*/ | ||
public function getProduct(); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCurrency(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Marello/Bundle/SalesBundle/Acl/Voter/SalesChannelGroupVoter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\SalesBundle\Acl\Voter; | ||
|
||
use Marello\Bundle\SalesBundle\Entity\Repository\SalesChannelGroupRepository; | ||
use Marello\Bundle\SalesBundle\Entity\SalesChannelGroup; | ||
use Oro\Bundle\SecurityBundle\Acl\BasicPermission; | ||
use Oro\Bundle\SecurityBundle\Acl\Voter\AbstractEntityVoter; | ||
|
||
/** | ||
* Disables deleting the sales channel group in case when it has attached integration | ||
*/ | ||
class SalesChannelGroupVoter extends AbstractEntityVoter | ||
{ | ||
/** @var array */ | ||
protected $supportedAttributes = [BasicPermission::DELETE]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getPermissionForAttribute($class, $identifier, $attribute) | ||
{ | ||
/** @var SalesChannelGroupRepository $scgRepository */ | ||
$scgRepository = $this->doctrineHelper->getEntityRepository(SalesChannelGroup::class); | ||
|
||
if ($scgRepository->hasAttachedIntegration($identifier)) { | ||
return self::ACCESS_DENIED; | ||
} | ||
|
||
return self::ACCESS_ABSTAIN; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/Marello/Bundle/SalesBundle/Autocomplete/GroupSalesChannelHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\SalesBundle\Autocomplete; | ||
|
||
use Doctrine\ORM\QueryBuilder; | ||
use Oro\Bundle\FormBundle\Autocomplete\SearchHandler; | ||
|
||
/** | ||
* @todo Cover with functional test | ||
*/ | ||
class GroupSalesChannelHandler extends SearchHandler | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function checkAllDependenciesInjected() | ||
{ | ||
if (!$this->entityRepository || !$this->idFieldName) { | ||
throw new \RuntimeException('Search handler is not fully configured'); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $searchTerm | ||
* @param int $firstResult | ||
* @param int $maxResults | ||
* @return QueryBuilder | ||
*/ | ||
protected function prepareQueryBuilder($searchTerm, $firstResult, $maxResults) | ||
{ | ||
$queryBuilder = $this->entityRepository->createQueryBuilder('scg'); | ||
$queryBuilder | ||
->where($queryBuilder->expr()->like('LOWER(scg.name)', ':searchTerm')) | ||
->andWhere(($queryBuilder->expr()->eq('scg.system', $queryBuilder->expr()->literal(false)))) | ||
->setParameter('searchTerm', '%' . mb_strtolower($searchTerm) . '%') | ||
->orderBy('scg.name', 'ASC') | ||
->setFirstResult($firstResult) | ||
->setMaxResults($maxResults); | ||
|
||
return $queryBuilder; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function searchEntities($search, $firstResult, $maxResults) | ||
{ | ||
$queryBuilder = $this->prepareQueryBuilder($search, $firstResult, $maxResults); | ||
$query = $this->aclHelper->apply($queryBuilder, 'VIEW'); | ||
|
||
return $query->getResult(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function findById($query) | ||
{ | ||
$parts = explode(';', $query); | ||
$id = $parts[0]; | ||
|
||
$criteria = [$this->idFieldName => $id]; | ||
|
||
return [$this->entityRepository->findOneBy($criteria, null)]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.