Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
entity_sync_mailgun
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
entity_sync_mailgun
Commits
d5ec6df4
Commit
d5ec6df4
authored
Jul 23, 2024
by
Dimitris Bozelos
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3463234
Added support for token replacement in file directory
parent
ef52ea78
Branches
1.x
Tags
1.0.0-alpha2
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Plugin/EntitySync/FieldTransformer/FileAttachments.php
+10
-1
10 additions, 1 deletion
src/Plugin/EntitySync/FieldTransformer/FileAttachments.php
with
10 additions
and
1 deletion
src/Plugin/EntitySync/FieldTransformer/FileAttachments.php
+
10
−
1
View file @
d5ec6df4
...
@@ -12,10 +12,12 @@ use Drupal\file\FileInterface;
...
@@ -12,10 +12,12 @@ use Drupal\file\FileInterface;
use
Drupal\file\FileRepositoryInterface
;
use
Drupal\file\FileRepositoryInterface
;
// Drupal core.
// Drupal core.
use
Drupal\Component\Plugin\PluginManagerInterface
;
use
Drupal\Component\Plugin\PluginManagerInterface
;
use
Drupal\Component\Render\PlainTextOutput
;
use
Drupal\Core\Entity\ContentEntityInterface
;
use
Drupal\Core\Entity\ContentEntityInterface
;
use
Drupal\Core\Entity\EntityFieldManagerInterface
;
use
Drupal\Core\Entity\EntityFieldManagerInterface
;
use
Drupal\Core\File\Exception\DirectoryNotReadyException
;
use
Drupal\Core\File\Exception\DirectoryNotReadyException
;
use
Drupal\Core\File\FileSystemInterface
;
use
Drupal\Core\File\FileSystemInterface
;
use
Drupal\Core\Utility\Token
;
// Third-party libraries.
// Third-party libraries.
use
Mailgun\Exception\HttpClientException
;
use
Mailgun\Exception\HttpClientException
;
use
Mailgun\Mailgun
;
use
Mailgun\Mailgun
;
...
@@ -101,6 +103,8 @@ class FileAttachments extends PluginBase {
...
@@ -101,6 +103,8 @@ class FileAttachments extends PluginBase {
* The file system.
* The file system.
* @param \Drupal\file\FileRepositoryInterface $fileRepository
* @param \Drupal\file\FileRepositoryInterface $fileRepository
* The file repository.
* The file repository.
* @param \Drupal\Core\Utility\Token $token
* The token service.
*/
*/
public
function
__construct
(
public
function
__construct
(
array
$configuration
,
array
$configuration
,
...
@@ -111,6 +115,7 @@ class FileAttachments extends PluginBase {
...
@@ -111,6 +115,7 @@ class FileAttachments extends PluginBase {
protected
EntityFieldManagerInterface
$entityFieldManager
,
protected
EntityFieldManagerInterface
$entityFieldManager
,
protected
FileSystemInterface
$fileSystem
,
protected
FileSystemInterface
$fileSystem
,
protected
FileRepositoryInterface
$fileRepository
,
protected
FileRepositoryInterface
$fileRepository
,
protected
Token
$token
,
)
{
)
{
parent
::
__construct
(
parent
::
__construct
(
$configuration
,
$configuration
,
...
@@ -140,6 +145,7 @@ class FileAttachments extends PluginBase {
...
@@ -140,6 +145,7 @@ class FileAttachments extends PluginBase {
$container
->
get
(
'entity_field.manager'
),
$container
->
get
(
'entity_field.manager'
),
$container
->
get
(
'file_system'
),
$container
->
get
(
'file_system'
),
$container
->
get
(
'file.repository'
),
$container
->
get
(
'file.repository'
),
$container
->
get
(
'token'
),
);
);
}
}
...
@@ -436,7 +442,10 @@ class FileAttachments extends PluginBase {
...
@@ -436,7 +442,10 @@ class FileAttachments extends PluginBase {
);
);
$definition
=
$definitions
[
$field_name
];
$definition
=
$definitions
[
$field_name
];
$uri_scheme
=
$definition
->
getSetting
(
'uri_scheme'
);
$uri_scheme
=
$definition
->
getSetting
(
'uri_scheme'
);
$file_directory
=
$definition
->
getSetting
(
'file_directory'
)
??
''
;
$file_directory
=
PlainTextOutput
::
renderFromHtml
(
$this
->
token
->
replace
(
$definition
->
getSetting
(
'file_directory'
)
??
''
,
[],
));
if
(
empty
(
$uri_scheme
))
{
if
(
empty
(
$uri_scheme
))
{
throw
new
InvalidConfigurationException
(
throw
new
InvalidConfigurationException
(
'No URI scheme setting found for the field.'
'No URI scheme setting found for the field.'
...
...
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
sign in
to comment