-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Add links for backend editor on the frontend (#800)
This patch prepares backend for nuxt-typo3 implementation.
- Loading branch information
1 parent
eaf2010
commit da479f3
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the "headless" Extension for TYPO3 CMS. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.md file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace FriendsOfTYPO3\Headless\Frontend; | ||
|
||
use TYPO3\CMS\Backend\Routing\UriBuilder; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class BackendEditorUrl | ||
{ | ||
public function __construct(protected UriBuilder $uriBuilder) {} | ||
|
||
public function page(): string | ||
{ | ||
return $this->generateUrl('pages'); | ||
} | ||
|
||
public function record(): string | ||
{ | ||
return $this->generateUrl(); | ||
} | ||
|
||
private function generateUrl(string $table = 'tt_content'): string | ||
{ | ||
$beUser = $GLOBALS['BE_USER'] ?? null; | ||
|
||
if ($beUser === null) { | ||
return ''; | ||
} | ||
|
||
$params = [ | ||
'edit' => [ | ||
$table => [ | ||
'__id__' => 'edit', | ||
], | ||
], | ||
]; | ||
|
||
return (string)$this->uriBuilder->buildUriFromRoute('record_edit', $params, UriBuilder::ABSOLUTE_URL); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Configuration/TypoScript/Configuration/BackendEditor.typoscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
lib.backendEditor = JSON | ||
lib.backendEditor { | ||
fields { | ||
record = USER_INT | ||
record { | ||
userFunc = FriendsOfTYPO3\Headless\Frontend\BackendEditorUrl->record | ||
} | ||
|
||
page = USER_INT | ||
page { | ||
userFunc = FriendsOfTYPO3\Headless\Frontend\BackendEditorUrl->page | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[backend.user.isLoggedIn] | ||
initialData.10.fields.backendEditor < lib.backendEditor | ||
[END] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters