diff --git a/src/Attribute/CommonRegexFormatEnum.php b/src/Attribute/CommonRegexFormatEnum.php new file mode 100644 index 0000000..06094d3 --- /dev/null +++ b/src/Attribute/CommonRegexFormatEnum.php @@ -0,0 +1,8 @@ +mandatory && $value === null )) { + if ($isNew && ( $this->mandatory === true && $value === null )) { throw new MandatoryFieldException("Mandatory field must be provided a value."); } elseif ($value !== null) { diff --git a/src/Attribute/MandatoryGroup.php b/src/Attribute/MandatoryGroup.php new file mode 100644 index 0000000..c956512 --- /dev/null +++ b/src/Attribute/MandatoryGroup.php @@ -0,0 +1,11 @@ +assignContextToEntity($context); - + if ( $saved = $entity::repository()->save($entity) ) { - method_exists($context, 'pushSuccessMessage') && $context->pushSuccessMessage('lean.api.form.save.success.save'); + method_exists($context, 'pushSuccessMessage') && $context->pushSuccessMessage($this->messageSuccessSave); } else { - method_exists($context, 'pushWarningMessage') && $context->pushWarningMessage('lean.api.form.save.warning.entity', [ 'entity' => substr($this->entity::class, strrpos($this->entity::class, '\\') + 1) ]); + method_exists($context, 'pushWarningMessage') && $context->pushWarningMessage($this->messageWarningSave, [ 'entity' => substr($this->entity::class, strrpos($this->entity::class, '\\') + 1) ]); } } catch(\PDOException $ex) { diff --git a/src/RouteDescriptor.php b/src/RouteDescriptor.php index 079b770..0ac0c1a 100644 --- a/src/RouteDescriptor.php +++ b/src/RouteDescriptor.php @@ -37,7 +37,7 @@ class RouteDescriptor $base = $attribute ? $attribute->object->getBase() : ""; - foreach($reflector->reflectMethods() as $method) { + foreach($reflector->reflectMethods(includeParents: (bool) $attribute->object->inheritRoutes) as $method) { foreach(array_reverse($method->getAttributes(Route::class)) as $routeAttribute) { $itemBase = $routeAttribute->object->getBase() ?? $base; $route = $routeAttribute->object;