Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_mail
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_mail
Commits
9a80818c
Commit
9a80818c
authored
6 years ago
by
Torsten Oppermann
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Refactored registration functions, moved them to a dedicated service.
parent
836af9dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Feature security update
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Classes/Service/RegisterService.php
+81
-1
81 additions, 1 deletion
Classes/Service/RegisterService.php
with
81 additions
and
1 deletion
Classes/Service/RegisterService.php
+
81
−
1
View file @
9a80818c
...
...
@@ -28,6 +28,7 @@ namespace SGalinski\SgMail\Service;
use
TYPO3\CMS\Core\Cache\CacheManager
;
use
TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
;
use
TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
/**
...
...
@@ -91,10 +92,89 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
}
/**
*
*
Read every registered file and create a registration entry in the registerArray if possible
*/
private
function
registerExtensions
()
{
foreach
(
$this
->
registrationFiles
as
$registerFile
)
{
// clear registerArray
$registerArray
=
[];
if
(
\is_file
(
$registerFile
))
{
$configArray
=
(
include
$registerFile
);
$extensionKey
=
$configArray
[
'extension_key'
];
$templateKey
=
$configArray
[
'template_key'
];
if
(
$extensionKey
===
NULL
||
$templateKey
===
NULL
)
{
continue
;
}
$registerArray
=
$this
->
writeRegisterArrayEntry
(
$registerArray
,
$extensionKey
,
$templateKey
,
$configArray
);
}
// set the register array after every registration has been parsed
$this
->
registerArray
=
$registerArray
;
}
}
/**
* write a single entry into the register array
*
* @param array $registerArray
* @param $extensionKey
* @param $templateKey
* @param array $configArray
* @param bool $transformTemplateFolder
* @param string $storeTemplateExtension
* @return array
*/
private
function
writeRegisterArrayEntry
(
array
$registerArray
,
$extensionKey
,
$templateKey
,
array
$configArray
,
$transformTemplateFolder
=
TRUE
,
$storeTemplateExtension
=
''
):
array
{
// If it is not explicitly set in which extension the html should be located, use the extension set in the template settings
if
(
$storeTemplateExtension
===
''
)
{
$storeTemplateExtension
=
$extensionKey
;
}
// give the option to use the template key as folder name. this is used mainly with auto registering
$templateDirectory
=
$templateKey
;
// by default folders with underscore will be transformed to upper camelcase
if
(
$transformTemplateFolder
)
{
// transform template directory name: your_templates => YourTemplates/
$templateDirectoryParts
=
GeneralUtility
::
trimExplode
(
'_'
,
$templateKey
);
$templateDirectory
=
''
;
foreach
(
$templateDirectoryParts
as
$part
)
{
$templateDirectory
.
=
ucfirst
(
$part
);
}
}
$templateDirectory
.
=
'/'
;
$templatePath
=
ExtensionManagementUtility
::
extPath
(
$storeTemplateExtension
)
.
self
::
DEFAULT_TEMPLATE_PATH
.
$templateDirectory
;
if
(
$configArray
[
'template_path'
])
{
$templatePath
=
$configArray
[
$templateKey
];
}
$description
=
$configArray
[
'description'
];
$subject
=
$configArray
[
'subject'
];
$marker
=
$configArray
[
'markers'
];
$registerArray
[
$extensionKey
][
$templateKey
]
=
[
'templatePath'
=>
$templatePath
,
'description'
=>
$description
,
'marker'
=>
$marker
,
'extension'
=>
$extensionKey
,
'templateName'
=>
$templateKey
,
'subject'
=>
$subject
];
return
$registerArray
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment