Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
libraries
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
libraries
Commits
2eca15e7
Commit
2eca15e7
authored
9 years ago
by
Tobias Zimmermann
Browse files
Options
Downloads
Patches
Plain Diff
Remove HTTP handling from LibraryDefinitionsStream
parent
bb0db591
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/StreamWrapper/LibraryDefinitionsStream.php
+2
-37
2 additions, 37 deletions
src/StreamWrapper/LibraryDefinitionsStream.php
with
2 additions
and
37 deletions
src/StreamWrapper/LibraryDefinitionsStream.php
+
2
−
37
View file @
2eca15e7
...
...
@@ -7,11 +7,8 @@
namespace
Drupal\libraries\StreamWrapper
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\StreamWrapper\LocalStream
;
use
Drupal\Core\StreamWrapper\StreamWrapperInterface
;
use
GuzzleHttp\ClientInterface
;
use
GuzzleHttp\Exception\GuzzleException
;
/**
* Provides a stream wrapper for library definitions.
...
...
@@ -30,13 +27,6 @@ class LibraryDefinitionsStream extends LocalStream {
*/
protected
$configFactory
;
/**
* The HTTP client.
*
* @var \GuzzleHttp\ClientInterface
*/
protected
$httpClient
;
/**
* Constructs an external library registry.
*
...
...
@@ -44,7 +34,6 @@ class LibraryDefinitionsStream extends LocalStream {
*/
public
function
__construct
()
{
$this
->
configFactory
=
\Drupal
::
configFactory
();
$this
->
httpClient
=
\Drupal
::
httpClient
();
}
/**
...
...
@@ -72,39 +61,15 @@ class LibraryDefinitionsStream extends LocalStream {
* {@inheritdoc}
*/
public
function
getDirectoryPath
()
{
print
'Directory path: '
.
$this
->
getConfig
(
'local.path'
)
.
PHP_EOL
;
return
$this
->
getConfig
(
'local.path'
);
}
/**
* {@inheritdoc}
*/
public
function
getExternalUrl
()
{
if
(
$this
->
getConfig
(
'remote.enable'
))
{
$url
=
$this
->
getConfig
(
'remote.url'
);
return
$url
.
'/'
.
$this
->
uri
;
function
getExternalUrl
()
{
throw
new
\LogicException
(
'Library definitions should not be public.'
);
}
}
public
function
url_stat
(
$uri
,
$flags
)
{
$status
=
parent
::
url_stat
(
$uri
,
$flags
);
if
((
$status
===
FALSE
)
&&
$this
->
getConfig
(
'remote.enable'
))
{
$url
=
$this
->
getConfig
(
'remote.url'
);
try
{
$response
=
$this
->
httpClient
->
request
(
'GET'
,
$url
.
'/'
.
$this
->
getTarget
(
$uri
));
print
'Local path: '
.
$this
->
getLocalPath
(
$uri
)
.
PHP_EOL
;
print
'Body: '
.
$response
->
getBody
()
.
PHP_EOL
;
$written
=
file_put_contents
(
$this
->
getLocalPath
(
$uri
),
$response
->
getBody
());
if
(
$written
!==
FALSE
)
{
$status
=
parent
::
url_stat
(
$uri
,
$flags
);
}
}
catch
(
GuzzleException
$exception
)
{
// $status is already FALSE, nothing to do.
}
}
return
$status
;
}
/**
* Fetches a configuration value from the library definitions configuration.
...
...
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
register
or
sign in
to comment