Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
filefield_paths
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
filefield_paths
Merge requests
!11
Issue
#2718783
: Call to undefined method BaseFieldDefinition::getThirdPartySettings()
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#2718783
: Call to undefined method BaseFieldDefinition::getThirdPartySettings()
issue/filefield_paths-2718783:2718783-call-to-undefined
into
8.x-1.x
Overview
7
Commits
8
Pipelines
0
Changes
2
Merged
Oleh Vehera
requested to merge
issue/filefield_paths-2718783:2718783-call-to-undefined
into
8.x-1.x
2 years ago
Overview
7
Commits
8
Pipelines
0
Changes
2
Expand
0
0
Merge request reports
Compare
8.x-1.x
version 4
b7d7cc7e
2 years ago
version 3
4f36f4b7
2 years ago
version 2
98e524a0
2 years ago
version 1
2c0a0654
2 years ago
8.x-1.x (base)
and
latest version
latest version
b7d7cc7e
8 commits,
2 years ago
version 4
b7d7cc7e
8 commits,
2 years ago
version 3
4f36f4b7
7 commits,
2 years ago
version 2
98e524a0
4 commits,
2 years ago
version 1
2c0a0654
4 commits,
2 years ago
2 files
+
69
−
19
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/Utility/FieldItem.php
0 → 100644
+
63
−
0
Options
<?php
namespace
Drupal\filefield_paths\Utility
;
use
Drupal\Core\Config\Entity\ThirdPartySettingsInterface
;
use
Drupal\Core\Field\FieldItemListInterface
;
use
Drupal\file\Plugin\Field\FieldType\FileFieldItemList
;
/**
* Field Item Utility.
*/
final
class
FieldItem
{
/**
* Get filefield_paths field settings.
*
* @param \Drupal\Core\Field\FieldItemListInterface $fieldItemList
* A field item to check for settings.
*
* @return array
* The filefield_paths settings for the field if set, else empty.
*/
public
static
function
getConfiguration
(
FieldItemListInterface
$fieldItemList
):
array
{
$definition
=
$fieldItemList
->
getFieldDefinition
();
if
(
$definition
instanceof
ThirdPartySettingsInterface
)
{
return
$definition
->
getThirdPartySettings
(
'filefield_paths'
);
}
return
[];
}
/**
* Check if filefield_paths is enabled for a field item.
*
* @param \Drupal\Core\Field\FieldItemListInterface|mixed $field
* A field to check.
*
* @return bool
* State of filefield_path functionality for a given file field.
*/
public
static
function
hasConfigurationEnabled
(
$field
):
bool
{
return
$field
instanceof
FileFieldItemList
&&
(
self
::
getConfiguration
(
$field
)[
'enabled'
]
??
FALSE
);
}
/**
* Field widget helper.
*
* @param $element
* Widget element.
* @param $context
* Widget context.
*
* @return \Drupal\file\Plugin\Field\FieldType\FileFieldItemList|null
* Returns Field Item List instance. Null if widget type is not supported.
*/
public
static
function
getFromSupportedWidget
(
array
$element
,
array
$context
):
?FileFieldItemList
{
if
(
isset
(
$element
[
'#type'
])
&&
$element
[
'#type'
]
===
'managed_file'
)
{
return
$context
[
'items'
]
??
NULL
;
}
return
NULL
;
}
}
Loading