- WIP on skeleton

This commit is contained in:
mcndave committed 2026-01-05 12:38:35 +00:00
1 parent fdca37a79d
commit 78d2d9d291
7 files changed
+77 -27

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
<?php
namespace %NAMESPACE%\Lib;
use Picea\Picea;
use Storage\Session;
use Mcnd\Event\EventManager;
use Notes\{ Attribute\Ignore, Route\Attribute\Object\Route, Security\Attribute\Security };
use Ulmus\User\Entity\{ User, UserInterface };
use %NAMESPACE%\{ Entity, Lib, Form, Factory };
#[Security(locked: false)]
#[Route(base: "/api", method: [ "GET", "POST", "PUT", "PATCH", "DELETE", ])]
trait ApiTrait {
use \Lean\ControllerTrait, \Lean\Api\LeanApiTrait {
\Lean\Api\LeanApiTrait::renderMarkdown insteadof \Lean\ControllerTrait;
}
#[Ignore]
public UserInterface $user;
#[Ignore]
protected EventManager $eventManager;
#[Ignore]
protected Factory\FormFactoryInterface $formFactory;
}
-15
View File
@@ -23,19 +23,4 @@ trait ControllerTrait {
#[Ignore]
protected EventManager $eventManager;
#[Ignore]
public function __construct(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
$this->initializeController($picea, $session, $user, $breadcrumb, $eventManager);
}
#[Ignore]
public function initializeController(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
$this->picea = $picea;
$this->session = $session;
$this->eventManager = $eventManager;
$this->breadcrumb = $breadcrumb;
$this->user = $user;
}
}
+21 -5
View File
@@ -2,9 +2,10 @@
namespace %NAMESPACE%\Lib;
use Lean\Api\Factory\MessageFactoryInterface;
use Picea\Ui\Method\FormMessage;
class Message implements FormMessage {
class Message implements FormMessage, MessageFactoryInterface {
const MESSAGE_TYPE = [
'success' => [
@@ -34,7 +35,7 @@ class Message implements FormMessage {
public ? string $header = null;
public function __construct(string $message, string $type = "error", ? string $header = null, ? string $class = null)
public function __construct(string $message = "", string $type = "error", ? string $header = null, ? string $class = null)
{
$this->message = $message;
@@ -86,18 +87,33 @@ class Message implements FormMessage {
return $this->type === "error";
}
public static function generateSuccess(string $message, ? string $header = null, ? string $class = null) : self
public static function generateSuccess(string $message, ? string $header = null, ? string $class = null) : MessageFactoryInterface
{
return new static($message, 'success', $header, $class);
}
public static function generateError(string $message, ? string $header = null, ? string $class = null) : self
public static function generateError(string $message, ? string $header = null, ? string $class = null) : MessageFactoryInterface
{
return new static($message, 'error', $header, $class);
}
public static function generateWarning(string $message, ? string $header = null, ? string $class = null) : self
public static function generateWarning(string $message, ? string $header = null, ? string $class = null) : MessageFactoryInterface
{
return new static($message, 'warning', $header, $class);
}
public static function generateInformation(string $message, ?string $header = null, ?string $class = null): MessageFactoryInterface
{
return new static($message, 'information', $header, $class);
}
public static function generateDebug(string $message, ?string $header = null, ?string $class = null): MessageFactoryInterface
{
return new static($message, 'debug', $header, $class);
}
public static function generateTrace(string $message, ?string $header = null, ?string $class = null): MessageFactoryInterface
{
return new static($message, 'trace', $header, $class);
}
}