Skip to content
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

Improve view engines and their integration in the Admin #70

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function results()
protected function setDependencies(Container $container)
{
parent::setDependencies($container);
$this->setEmailFactory($container['email/factory']);
$this->setEmailFactory($container['admin/email/factory']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

// From Pimple
use Pimple\Container;
// From 'charcoal-view'
use Charcoal\View\ViewableInterface;
use Charcoal\View\ViewableTrait;
// From 'charcoal-translator'
use Charcoal\Translator\Translation;
// From 'charcoal-admin'
Expand All @@ -32,11 +29,8 @@
* }
* ```
*/
class MessageDisplay extends AbstractPropertyDisplay implements
ViewableInterface
class MessageDisplay extends AbstractPropertyDisplay
{
use ViewableTrait;

/**
* @var Translation|null
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

// from 'charcoal-admin'
use Charcoal\Admin\Property\AbstractPropertyDisplay;
// from 'charcoal-view'
use Charcoal\View\ViewableInterface;
use Charcoal\View\ViewableTrait;
// from 'pimple'
use Pimple\Container;
use UnexpectedValueException;
Expand All @@ -16,10 +13,8 @@
*
* The default display for most properties; only output {@see AbstractProperty::displayVal()}.
*/
class StatusDisplay extends AbstractPropertyDisplay implements ViewableInterface
class StatusDisplay extends AbstractPropertyDisplay
{
use ViewableTrait;

public const STATE_PRIMARY = 'primary';
public const STATE_SUCCESS = 'success';
public const STATE_INFO = 'info';
Expand Down Expand Up @@ -68,9 +63,6 @@ class StatusDisplay extends AbstractPropertyDisplay implements ViewableInterface
protected function setDependencies(Container $container)
{
parent::setDependencies($container);

// Fulfills the ViewableTrait dependencies
$this->setView($container['admin/view']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function setDependencies(Container $container)
parent::setDependencies($container);
$this->setNotificationFactory($container['model/factory']);
$this->setRevisionFactory($container['model/factory']);
$this->emailFactory = $container['email/factory'];
$this->emailFactory = $container['admin/email/factory'];
$this->userFactory = $container['model/factory'];
$this->objectFactory = $container['model/factory'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
// From 'charcoal-config'
use Charcoal\Config\ConfigInterface;
use Charcoal\Config\GenericConfig as Config;
// From email
use Charcoal\Email\Email;
use Charcoal\Email\EmailInterface;
// From 'charcoal-factory'
use Charcoal\Factory\FactoryInterface;
use Charcoal\Factory\GenericFactory;
// From 'charcoal-core'
use Charcoal\Model\Service\MetadataConfig;
// From 'charcoal-ui'
Expand Down Expand Up @@ -177,6 +181,29 @@ protected function registerAdminServices(Container $container)
};
}

/**
* @param Container $container Pimple DI Container.
* @return FactoryInterface
*/
$container['admin/email/factory'] = function (Container $container): FactoryInterface {
return new GenericFactory([
'map' => [
'email' => Email::class
],
'base_class' => EmailInterface::class,
'default_class' => Email::class,
'arguments' => [[
'logger' => $container['logger'],
'config' => $container['email/config'],
'view' => $container['admin/view'],
'template_factory' => $container['template/factory'],
'queue_item_factory' => $container['model/factory'],
'log_factory' => $container['model/factory'],
'tracker' => $container['email/tracker']
]]
mcaskill marked this conversation as resolved.
Show resolved Hide resolved
]);
};

/**
* The admin view instance.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/Charcoal/Ui/Layout/LayoutBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function build($options)

$obj = $this->factory->create($objType, [
'logger' => $container['logger'],
'view' => $container['view']
'view' => $container['admin/view']
]);
$obj->setData($options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private function registerDashboardServices(Container $container)
[
'container' => $container,
'logger' => $container['logger'],
'view' => $container['view'],
'view' => $container['admin/view'],
'widget_builder' => $container['widget/builder'],
'layout_builder' => $container['layout/builder'],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function registerFormServices(Container $container)
[
'container' => $container,
'logger' => $container['logger'],
'view' => $container['view'],
'view' => $container['admin/view'],
'layout_builder' => $container['layout/builder'],
'form_group_factory' => $container['form/group/factory'],
],
Expand Down Expand Up @@ -89,7 +89,7 @@ public function registerFormGroupServices(Container $container)
[
'container' => $container,
'logger' => $container['logger'],
'view' => $container['view'],
'view' => $container['admin/view'],
'layout_builder' => $container['layout/builder'],
'form_input_builder' => $container['form/input/builder'],
],
Expand Down