Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
TYPO3
sg_mail
Commits
68f6d76c
Commit
68f6d76c
authored
Sep 11, 2016
by
Torsten Oppermann
Browse files
[TASK] Refactoring extension registration
parent
46081957
Changes
8
Hide whitespace changes
Inline
Side-by-side
Classes/Controller/MailController.php
View file @
68f6d76c
...
...
@@ -26,7 +26,7 @@ namespace SGalinski\SgMail\Controller;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use
SGalinski\SgMail\Service\MailTemplateService
;
use
TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
use
TYPO3\CMS\Extbase\Mvc\Controller\ActionController
;
/**
...
...
@@ -38,7 +38,21 @@ class MailController extends ActionController {
*
*/
public
function
indexAction
()
{
$this
->
view
->
assign
(
'extensions'
,
MailTemplateService
::
$registerArray
);
$path
=
ExtensionManagementUtility
::
extPath
(
Stefan Galinski
🎮
@sgalinski
·
Sep 12, 2016
Owner
Code Formatting
Code Formatting
Please
register
or
sign in
to reply
'sg_mail'
)
.
'Configuration/Templates/'
;
$results
=
scandir
(
$path
);
$extensions
=
[];
foreach
(
$results
as
$result
)
{
if
(
$result
==
'.'
||
$result
==
'..'
)
{
Stefan Galinski
🎮
@sgalinski
·
Sep 12, 2016
Owner
kein strict-check
kein strict-check
Please
register
or
sign in
to reply
continue
;
}
is_dir
(
$path
.
$result
)
?
$extensions
[]
=
$result
:
NULL
;
}
$this
->
view
->
assign
(
'extensions'
,
$extensions
);
}
/**
...
...
@@ -48,10 +62,18 @@ class MailController extends ActionController {
public
function
showTemplatesAction
()
{
$extensionKey
=
$this
->
request
->
getArgument
(
'ext_key'
);
$extPath
=
ExtensionManagementUtility
::
extPath
(
Stefan Galinski
🎮
@sgalinski
·
Sep 12, 2016
Owner
Code Formatting
Code Formatting
Please
register
or
sign in
to reply
'sg_mail'
)
.
'Configuration/Templates/'
.
$extensionKey
.
'/'
;
$files
=
glob
(
$extPath
.
'*.html'
);
$this
->
view
->
assign
(
'templates'
,
array_map
(
'basename'
,
$files
));
}
$files
=
glob
(
'/path/to/dir/*.xml'
);
$this
->
view
->
assign
(
'templates'
,
MailTemplateService
::
$registerArray
[
$extensionKey
]);
/**
*
*
*/
public
function
showMarkerAction
()
{
}
...
...
Classes/Service/MailTemplateService.php
View file @
68f6d76c
...
...
@@ -42,18 +42,9 @@ class MailTemplateService {
* @param $template
* @return string
*/
public
static
function
registerTemplate
(
$extensionKey
,
$template
)
{
$path
=
ExtensionManagementUtility
::
extPath
(
'sg_mail'
);
if
(
!
file_exists
(
$path
.
'/Configuration/Templates/'
.
$template
.
'.html'
))
{
// @TODO Throw exception
return
;
}
public
static
function
registerTemplate
(
$extensionKey
)
{
if
(
!
array_key_exists
(
$extensionKey
,
MailTemplateService
::
$registerArray
))
{
MailTemplateService
::
$registerArray
[
$extensionKey
]
=
[
$template
];
}
elseif
(
!
in_array
(
MailTemplateService
::
$registerArray
[
$extensionKey
],
$template
))
{
MailTemplateService
::
$registerArray
[
$extensionKey
][]
=
$template
;
MailTemplateService
::
$registerArray
[
$extensionKey
];
}
}
}
Configuration/Templates/test.html
→
Configuration/Templates/
sg_comments/
test.html
View file @
68f6d76c
File moved
Configuration/Templates/sg_documentation/demo_mail.html
0 → 100644
View file @
68f6d76c
Resources/Private/Templates/Mail/Index.html
View file @
68f6d76c
...
...
@@ -4,13 +4,12 @@
</f:section>
<f:section
name=
"main"
>
<f:flashMessages
renderMode=
"div"
/>
<f:debug>
{extensions}
</f:debug>
<h3>
Registered Extensions
</h3>
<ul
class=
"list-group"
>
<f:for
each=
"{extensions}"
as=
"extension"
key=
"key"
>
<f:for
each=
"{extensions}"
as=
"extension"
>
<li
class=
"list-group-item"
>
<f:link.action
controller=
"Mail"
action=
"showTemplates"
arguments=
"{ext_key:'{key}'}"
>
{key}
</f:link.action>
<span
class=
"badge"
><f:count>
{extension}
</f:count></span>
<f:link.action
controller=
"Mail"
action=
"showTemplates"
arguments=
"{ext_key:'{extension}'}"
>
{extension}
</f:link.action>
</li>
</f:for>
</ul>
...
...
Resources/Private/Templates/Mail/ShowMarker.html
0 → 100644
View file @
68f6d76c
Show Marker Template
Resources/Private/Templates/Mail/ShowTemplates.html
View file @
68f6d76c
...
...
@@ -4,8 +4,13 @@
</f:section>
<f:section
name=
"main"
>
<f:flashMessages
renderMode=
"div"
/>
<f:for
each=
"{templates}"
as=
"template"
>
{template}
<br
/>
</f:for>
<ul
class=
"list-group"
>
<f:for
each=
"{templates}"
as=
"template"
>
<li
class=
"list-group-item"
>
<f:link.action
controller=
"Mail"
action=
"showMarker"
arguments=
"{template:'{template}'}"
>
{template}
</f:link.action>
</li>
</f:for>
</ul>
</f:section>
ext_tables.php
View file @
68f6d76c
...
...
@@ -10,7 +10,7 @@ if (!defined('TYPO3_MODE')) {
'Mail'
,
''
,
[
'Mail'
=>
'index, showTemplates'
,
'Mail'
=>
'index, showTemplates
, showMarker
'
,
],
[
'access'
=>
'admin,user,group'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment