Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
feeds
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
feeds
Merge requests
!86
Issue
#3287478
: Automated Drupal 10 compatibility fixes
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3287478
: Automated Drupal 10 compatibility fixes
issue/feeds-3287478:3287478-d10
into
8.x-3.x
Overview
0
Commits
14
Pipelines
0
Changes
23
Merged
Youri van Koppen
requested to merge
issue/feeds-3287478:3287478-d10
into
8.x-3.x
2 years ago
Overview
0
Commits
14
Pipelines
0
Changes
23
Expand
0
0
Merge request reports
Compare
8.x-3.x
version 11
e7f7fd0e
2 years ago
version 10
0d39867e
2 years ago
version 9
c8969980
2 years ago
version 8
a821ccbf
2 years ago
version 7
0829927e
2 years ago
version 6
3a2ca8df
2 years ago
version 5
4b936c46
2 years ago
version 4
cc7628ba
2 years ago
version 3
567e27a8
2 years ago
version 2
b26ea1f8
2 years ago
version 1
701b0f08
2 years ago
8.x-3.x (base)
and
latest version
latest version
e7f7fd0e
14 commits,
2 years ago
version 11
e7f7fd0e
14 commits,
2 years ago
version 10
0d39867e
13 commits,
2 years ago
version 9
c8969980
11 commits,
2 years ago
version 8
a821ccbf
10 commits,
2 years ago
version 7
0829927e
7 commits,
2 years ago
version 6
3a2ca8df
6 commits,
2 years ago
version 5
4b936c46
5 commits,
2 years ago
version 4
cc7628ba
4 commits,
2 years ago
version 3
567e27a8
3 commits,
2 years ago
version 2
b26ea1f8
2 commits,
2 years ago
version 1
701b0f08
1 commit,
2 years ago
23 files
+
248
−
53
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
23
Search (e.g. *.vue) (Ctrl+P)
src/Component/ZfExtensionManagerSfContainer.php
0 → 100644
+
140
−
0
Options
<?php
namespace
Drupal\feeds\Component
;
use
Symfony\Component\DependencyInjection\ContainerAwareInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Laminas\Feed\Reader\ExtensionManagerInterface
as
ReaderManagerInterface
;
use
Laminas\Feed\Writer\ExtensionManagerInterface
as
WriterManagerInterface
;
/**
* Defines a bridge between the Laminas service manager to Symfony container.
*/
class
ZfExtensionManagerSfContainer
implements
ReaderManagerInterface
,
WriterManagerInterface
,
ContainerAwareInterface
{
/**
* A map of characters to be replaced through strtr.
*
* This property is based on Laminas service manager.
*
* @var array
*
* @link https://github.com/laminas/laminas-servicemanager for the canonical source repository
* @copyright Copyright (c) 2019, Laminas Foundation. (https://getlaminas.org/)
* @license https://github.com/laminas/laminas-servicemanager/blob/master/LICENSE.md
*
* @see \Drupal\feeds\Component\ZfExtensionManagerSfContainer::canonicalizeName().
* @see https://github.com/laminas/laminas-servicemanager/blob/2.7.11/src/ServiceManager.php#L114
*/
protected
$canonicalNamesReplacements
=
[
'-'
=>
''
,
'_'
=>
''
,
' '
=>
''
,
'\\'
=>
''
,
'/'
=>
''
,
];
/**
* The prefix to be used when retrieving plugins from the container.
*
* @var string
*/
protected
$prefix
=
''
;
/**
* The service container.
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected
$container
;
/**
* A local cache of computed canonical names.
*
* @var string[]
*/
protected
$canonicalNames
;
/**
* The Laminas Feed class to use.
*
* @var \Laminas\Feed\Reader\ExtensionManagerInterface|\Laminas\Feed\Writer\ExtensionManagerInterface
*/
protected
$standalone
;
/**
* Constructs a ZfExtensionManagerSfContainer object.
*
* @param string $prefix
* The prefix to be used when retrieving plugins from the container.
*/
public
function
__construct
(
$prefix
=
''
)
{
$this
->
prefix
=
$prefix
;
}
/**
* {@inheritdoc}
*/
public
function
get
(
$extension
)
{
if
(
$this
->
standalone
&&
$this
->
standalone
->
has
(
$extension
))
{
return
$this
->
standalone
->
get
(
$extension
);
}
return
$this
->
container
->
get
(
$this
->
prefix
.
$this
->
canonicalizeName
(
$extension
));
}
/**
* {@inheritdoc}
*/
public
function
has
(
$extension
)
{
if
(
$this
->
standalone
&&
$this
->
standalone
->
has
(
$extension
))
{
return
TRUE
;
}
return
$this
->
container
->
has
(
$this
->
prefix
.
$this
->
canonicalizeName
(
$extension
));
}
/**
* Canonicalize the extension name to a service name.
*
* This method is based on Laminas service manager.
*
* @link https://github.com/laminas/laminas-servicemanager for the canonical source repository
* @copyright Copyright (c) 2019, Laminas Foundation. (https://getlaminas.org/)
* @license https://github.com/laminas/laminas-servicemanager/blob/master/LICENSE.md
*
* @param string $name
* The extension name.
*
* @return string
* The service name, without the prefix.
*
* @see https://github.com/laminas/laminas-servicemanager/blob/2.7.11/src/ServiceManager.php#L900
*/
protected
function
canonicalizeName
(
$name
)
{
if
(
isset
(
$this
->
canonicalNames
[
$name
]))
{
return
$this
->
canonicalNames
[
$name
];
}
// This is just for performance instead of using str_replace().
return
$this
->
canonicalNames
[
$name
]
=
strtolower
(
strtr
(
$name
,
$this
->
canonicalNamesReplacements
));
}
/**
* {@inheritdoc}
*/
public
function
setContainer
(
ContainerInterface
$container
=
NULL
)
{
$this
->
container
=
$container
;
}
/**
* Sets the Laminas Feed class to use.
*
* @param string $class
* The class to set as standalone.
*/
public
function
setStandalone
(
$class
)
{
if
(
!
is_subclass_of
(
$class
,
ReaderManagerInterface
::
class
)
&&
!
is_subclass_of
(
$class
,
WriterManagerInterface
::
class
))
{
throw
new
\RuntimeException
(
"
$class
must implement Laminas\Feed\Reader\ExtensionManagerInterface or Laminas\Feed\Writer\ExtensionManagerInterface"
);
}
$this
->
standalone
=
new
$class
();
}
}
Loading