This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update UPGRADE-3.x.md Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update src/CustomerBundle/Block/ProfileMenuBlockService.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update src/CustomerBundle/Block/ProfileMenuBlockService.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update src/CustomerBundle/Block/ProfileMenuBlockService.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update src/CustomerBundle/Menu/ProfileMenuBuilder.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update tests/CustomerBundle/Menu/ProfileMenuBuilderTest.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update tests/CustomerBundle/Controller/CustomerControllerTest.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update profile descriptions Update src/CustomerBundle/DependencyInjection/Configuration.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update src/CustomerBundle/DependencyInjection/Configuration.php Co-Authored-By: Grégoire Paris <postmaster@greg0ire.fr> Update src/CustomerBundle/Twig/GlobalVariables.php Co-Authored-By: Fran Moreno <franmomu@gmail.com> Update test
- Loading branch information
Showing
29 changed files
with
714 additions
and
7 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
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,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\CustomerBundle\Block; | ||
|
||
use Knp\Menu\ItemInterface; | ||
use Knp\Menu\Provider\MenuProviderInterface; | ||
use Sonata\BlockBundle\Block\BlockContextInterface; | ||
use Sonata\BlockBundle\Block\Service\MenuBlockService; | ||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
/** | ||
* @author Hugo Briand <briand@ekino.com> | ||
*/ | ||
final class ProfileMenuBlockService extends MenuBlockService | ||
{ | ||
private $menuBuilder; | ||
|
||
/** | ||
* @param object $menuBuilder | ||
*/ | ||
public function __construct(string $name, EngineInterface $templating, MenuProviderInterface $menuProvider, $menuBuilder) | ||
{ | ||
parent::__construct($name, $templating, $menuProvider, []); | ||
|
||
if (!\is_object($menuBuilder) || !method_exists($menuBuilder, 'createProfileMenu')) { | ||
throw new \InvalidArgumentException( | ||
'Argument 4 should be object with public function "createProfileMenu(array $itemOptions = [])"' | ||
); | ||
} | ||
|
||
$this->menuBuilder = $menuBuilder; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'Ecommerce Profile Menu'; | ||
} | ||
|
||
public function configureSettings(OptionsResolver $resolver): void | ||
{ | ||
parent::configureSettings($resolver); | ||
|
||
$resolver->setDefaults([ | ||
'cache_policy' => 'private', | ||
'menu_template' => 'SonataBlockBundle:Block:block_side_menu_template.html.twig', | ||
]); | ||
} | ||
|
||
private function getMenu(BlockContextInterface $blockContext): ItemInterface | ||
{ | ||
$settings = $blockContext->getSettings(); | ||
|
||
$menu = parent::getMenu($blockContext); | ||
|
||
if (null === $menu || '' === $menu) { | ||
$menu = $this->menuBuilder->createProfileMenu( | ||
[ | ||
'childrenAttributes' => ['class' => $settings['menu_class']], | ||
'attributes' => ['class' => $settings['children_class']], | ||
] | ||
); | ||
|
||
if (method_exists($menu, 'setCurrentUri')) { | ||
$menu->setCurrentUri($settings['current_uri']); | ||
} | ||
} | ||
|
||
return $menu; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\CustomerBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
final class DashboardController extends Controller | ||
{ | ||
public function dashboardAction(): Response | ||
{ | ||
return $this->render('SonataCustomerBundle:Profile:dashboard.html.twig', [ | ||
'blocks' => $this->container->getParameter('sonata.customer.profile.blocks'), | ||
]); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/CustomerBundle/DependencyInjection/Compiler/GlobalVariablesCompilerPass.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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\CustomerBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org> | ||
*/ | ||
final class GlobalVariablesCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
$container->getDefinition('twig') | ||
->addMethodCall('addGlobal', ['sonata_customer', new Reference('sonata.customer.twig.global')]); | ||
} | ||
} |
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.