-
Notifications
You must be signed in to change notification settings - Fork 33
[AdminUi] Add a Twig global variable for the context #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Sylius package. | ||
| * | ||
| * (c) Sylius Sp. z o.o. | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Sylius\AdminUi\Context; | ||
|
|
||
| final class Context | ||
| { | ||
| public function __construct( | ||
| private readonly RoutingContext $routing, | ||
| ) { | ||
| } | ||
|
|
||
| public function getRouting(): RoutingContext | ||
| { | ||
| return $this->routing; | ||
| } | ||
| } |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should both Context and RoutingContext have interfaces? In case I would want to override those classes at end-user projects.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want user to change those contexts for now. That's only to bring access to admin ui configuration.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either interfaces or some other extension point would be great, but yeah, it could be added at a later date.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but before adding some extension point, it's preferable to be stable on data accessors. I think I need to add login path and things like that before. Or just adding the interface on the main context class. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Sylius package. | ||
| * | ||
| * (c) Sylius Sp. z o.o. | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Sylius\AdminUi\Context; | ||
|
|
||
| final class RoutingContext | ||
| { | ||
| public function __construct( | ||
| private readonly array $routing, | ||
| ) { | ||
| } | ||
|
|
||
| public function getDashboardPath(): string | ||
| { | ||
| return $this->routing['dashboard_path'] ?? '/admin'; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Sylius package. | ||
| * | ||
| * (c) Sylius Sp. z o.o. | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Sylius\AdminUi\Twig\Extension; | ||
|
|
||
| use Sylius\AdminUi\Context\Context; | ||
| use Twig\Extension\AbstractExtension; | ||
| use Twig\Extension\GlobalsInterface; | ||
|
|
||
| final class ContextExtension extends AbstractExtension implements GlobalsInterface | ||
| { | ||
| public function __construct( | ||
| private readonly Context $context, | ||
| ) { | ||
| } | ||
|
|
||
| public function getGlobals(): array | ||
| { | ||
| return [ | ||
| 'sylius_admin_ui_context' => $this->context, | ||
| ]; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need both?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's automatical now, after the composer install. Here, it's only on the test application.