Skip to content
GitLab
Explore
Sign in
project
drupal
Compare revisions
540a5f41541a3109995104e90720580e350ed433 to 8.1.x
Hide whitespace changes
Inline
Side-by-side
core/modules/image/src/Controller/ImageStyleDownloadController.php
View file @
614ba415
...
...
@@ -113,14 +113,9 @@ public function deliver(Request $request, $scheme, ImageStyleInterface $image_st
// If using the private scheme, let other modules provide headers and
// control access to the file.
if
(
$scheme
==
'private'
)
{
if
(
file_exists
(
$derivative_uri
))
{
return
parent
::
download
(
$request
,
$scheme
);
}
else
{
$headers
=
$this
->
moduleHandler
()
->
invokeAll
(
'file_download'
,
array
(
$image_uri
));
if
(
in_array
(
-
1
,
$headers
)
||
empty
(
$headers
))
{
throw
new
AccessDeniedHttpException
();
}
$headers
=
$this
->
moduleHandler
()
->
invokeAll
(
'file_download'
,
array
(
$image_uri
));
if
(
in_array
(
-
1
,
$headers
)
||
empty
(
$headers
))
{
throw
new
AccessDeniedHttpException
();
}
}
...
...
core/modules/image/src/ImageStyleListBuilder.php
View file @
614ba415
...
...
@@ -4,10 +4,7 @@
use
Drupal\Core\Config\Entity\ConfigEntityListBuilder
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Entity\EntityStorageInterface
;
use
Drupal\Core\Entity\EntityTypeInterface
;
use
Drupal\Core\Routing\UrlGeneratorInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Url
;
/**
* Defines a class to build a listing of image style entities.
...
...
@@ -16,40 +13,6 @@
*/
class
ImageStyleListBuilder
extends
ConfigEntityListBuilder
{
/**
* The URL generator.
*
* @var \Drupal\Core\Routing\UrlGeneratorInterface
*/
protected
$urlGenerator
;
/**
* Constructs a new ImageStyleListBuilder object.
*
* @param EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageInterface $image_style_storage
* The image style entity storage class.
* @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
* The URL generator.
*/
public
function
__construct
(
EntityTypeInterface
$entity_type
,
EntityStorageInterface
$image_style_storage
,
UrlGeneratorInterface
$url_generator
)
{
parent
::
__construct
(
$entity_type
,
$image_style_storage
);
$this
->
urlGenerator
=
$url_generator
;
}
/**
* {@inheritdoc}
*/
public
static
function
createInstance
(
ContainerInterface
$container
,
EntityTypeInterface
$entity_type
)
{
return
new
static
(
$entity_type
,
$container
->
get
(
'entity.manager'
)
->
getStorage
(
$entity_type
->
id
()),
$container
->
get
(
'url_generator'
),
$container
->
get
(
'string_translation'
)
);
}
/**
* {@inheritdoc}
*/
...
...
@@ -87,7 +50,7 @@ public function getDefaultOperations(EntityInterface $entity) {
public
function
render
()
{
$build
=
parent
::
render
();
$build
[
'table'
][
'#empty'
]
=
$this
->
t
(
'There are currently no styles. <a href=":url">Add a new one</a>.'
,
[
':url'
=>
$this
->
urlGenerator
->
generateF
romRoute
(
'image.style_add'
),
':url'
=>
Url
::
f
romRoute
(
'image.style_add'
)
->
toString
()
,
]);
return
$build
;
}
...
...
core/modules/image/src/Tests/ImageStylesPathAndUrlTest.php
View file @
614ba415
...
...
@@ -155,6 +155,11 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash =
$image
=
$this
->
container
->
get
(
'image.factory'
)
->
get
(
$generated_uri
);
$this
->
assertEqual
(
$this
->
drupalGetHeader
(
'Content-Type'
),
$image
->
getMimeType
(),
'Expected Content-Type was reported.'
);
$this
->
assertEqual
(
$this
->
drupalGetHeader
(
'Content-Length'
),
$image
->
getFileSize
(),
'Expected Content-Length was reported.'
);
// Check that we did not download the original file.
$original_image
=
$this
->
container
->
get
(
'image.factory'
)
->
get
(
$original_uri
);
$this
->
assertNotEqual
(
$this
->
drupalGetHeader
(
'Content-Length'
),
$original_image
->
getFileSize
());
if
(
$scheme
==
'private'
)
{
$this
->
assertEqual
(
$this
->
drupalGetHeader
(
'Expires'
),
'Sun, 19 Nov 1978 05:00:00 GMT'
,
'Expires header was sent.'
);
$this
->
assertNotEqual
(
strpos
(
$this
->
drupalGetHeader
(
'Cache-Control'
),
'no-cache'
),
FALSE
,
'Cache-Control header contains \'no-cache\' to prevent caching.'
);
...
...
@@ -165,6 +170,12 @@ function doImageStyleUrlAndPathTests($scheme, $clean_url = TRUE, $extra_slash =
$this
->
drupalGet
(
$generate_url
);
$this
->
assertResponse
(
200
,
'Image was generated at the URL.'
);
// Check that the second request also returned the generated image.
$this
->
assertEqual
(
$this
->
drupalGetHeader
(
'Content-Length'
),
$image
->
getFileSize
());
// Check that we did not download the original file.
$this
->
assertNotEqual
(
$this
->
drupalGetHeader
(
'Content-Length'
),
$original_image
->
getFileSize
());
// Make sure that access is denied for existing style files if we do not
// have access.
\Drupal
::
state
()
->
delete
(
'image.test_file_download'
);
...
...
core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
View file @
614ba415
...
...
@@ -169,7 +169,7 @@ public static function mainPropertyName() {
* {@inheritdoc}
*/
public
function
getUrl
()
{
return
Url
::
fromUri
(
$this
->
uri
,
$this
->
options
);
return
Url
::
fromUri
(
$this
->
uri
,
(
array
)
$this
->
options
);
}
/**
...
...
core/modules/link/tests/src/Kernel/LinkItemTest.php
View file @
614ba415
...
...
@@ -5,6 +5,7 @@
use
Drupal\Component\Utility\UrlHelper
;
use
Drupal\Core\Field\FieldItemListInterface
;
use
Drupal\Core\Field\FieldItemInterface
;
use
Drupal\Core\Url
;
use
Drupal\entity_test
\Entity\EntityTest
;
use
Drupal\field\Entity\FieldConfig
;
use
Drupal\field\Entity\FieldStorageConfig
;
...
...
@@ -154,6 +155,11 @@ public function testLinkItem() {
$this
->
assertNull
(
$entity
->
field_test
->
title
);
$this
->
assertIdentical
(
$entity
->
field_test
->
options
,
[]);
// Check that setting options to NULL does not trigger an error when
// calling getUrl();
$entity
->
field_test
->
options
=
NULL
;
$this
->
assertInstanceOf
(
Url
::
class
,
$entity
->
field_test
[
0
]
->
getUrl
());
// Check that setting LinkItem value NULL doesn't generate any error or
// warning.
$entity
->
field_test
[
0
]
=
NULL
;
...
...
core/modules/migrate/src/Event/MigrateEvents.php
View file @
614ba415
...
...
@@ -81,7 +81,7 @@ final class MigrateEvents {
*
* This event allows modules to perform an action whenever a specific item
* is about to be saved by the destination plugin. The event listener method
* receives a \Drupal\migrate\Event\MigratePreSaveEvent instance.
* receives a \Drupal\migrate\Event\MigratePre
Row
SaveEvent instance.
*
* @Event
*
...
...
core/modules/migrate/src/Plugin/MigratePluginManager.php
View file @
614ba415
...
...
@@ -21,7 +21,7 @@
*
* @ingroup migration
*/
class
MigratePluginManager
extends
DefaultPluginManager
{
class
MigratePluginManager
extends
DefaultPluginManager
implements
MigratePluginManagerInterface
{
/**
* Constructs a MigratePluginManager object.
...
...
@@ -49,8 +49,6 @@ public function __construct($type, \Traversable $namespaces, CacheBackendInterfa
/**
* {@inheritdoc}
*
* A specific createInstance method is necessary to pass the migration on.
*/
public
function
createInstance
(
$plugin_id
,
array
$configuration
=
array
(),
MigrationInterface
$migration
=
NULL
)
{
$plugin_definition
=
$this
->
getDefinition
(
$plugin_id
);
...
...
core/modules/migrate/src/Plugin/MigratePluginManagerInterface.php
0 → 100644
View file @
614ba415
<?php
namespace
Drupal\migrate\Plugin
;
use
Drupal\Component\Plugin\PluginManagerInterface
;
interface
MigratePluginManagerInterface
extends
PluginManagerInterface
{
/**
* Creates a pre-configured instance of a migration plugin.
*
* A specific createInstance method is necessary to pass the migration on.
*
* @param string $plugin_id
* The ID of the plugin being instantiated.
* @param array $configuration
* An array of configuration relevant to the plugin instance.
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration context in which the plugin will run.
*
* @return object
* A fully configured plugin instance.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
* If the instance cannot be created, such as if the ID is invalid.
*/
public
function
createInstance
(
$plugin_id
,
array
$configuration
=
[],
MigrationInterface
$migration
=
NULL
);
}
core/modules/migrate/src/Plugin/Migration.php
View file @
614ba415
...
...
@@ -268,16 +268,16 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
* The plugin definition.
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
* The migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager
* @param \Drupal\migrate\Plugin\MigratePluginManager
Interface
$source_plugin_manager
* The source migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager
* @param \Drupal\migrate\Plugin\MigratePluginManager
Interface
$process_plugin_manager
* The process migration plugin manager.
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
* The destination migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager
* @param \Drupal\migrate\Plugin\MigratePluginManager
Interface
$idmap_plugin_manager
* The ID map migration plugin manager.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationPluginManagerInterface
$migration_plugin_manager
,
MigratePluginManager
$source_plugin_manager
,
MigratePluginManager
$process_plugin_manager
,
MigrateDestinationPluginManager
$destination_plugin_manager
,
MigratePluginManager
$idmap_plugin_manager
)
{
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationPluginManagerInterface
$migration_plugin_manager
,
MigratePluginManager
Interface
$source_plugin_manager
,
MigratePluginManager
Interface
$process_plugin_manager
,
MigrateDestinationPluginManager
$destination_plugin_manager
,
MigratePluginManager
Interface
$idmap_plugin_manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
migrationPluginManager
=
$migration_plugin_manager
;
$this
->
sourcePluginManager
=
$source_plugin_manager
;
...
...
core/modules/migrate/src/Plugin/migrate/destination/EntityFieldInstance.php
View file @
614ba415
...
...
@@ -21,4 +21,12 @@ public function getIds() {
return
$ids
;
}
/**
* {@inheritdoc}
*/
public
function
rollback
(
array
$destination_identifier
)
{
$destination_identifier
=
implode
(
'.'
,
$destination_identifier
);
parent
::
rollback
(
array
(
$destination_identifier
));
}
}
core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
View file @
614ba415
...
...
@@ -20,4 +20,12 @@ public function getIds() {
return
$ids
;
}
/**
* {@inheritdoc}
*/
public
function
rollback
(
array
$destination_identifier
)
{
$destination_identifier
=
implode
(
'.'
,
$destination_identifier
);
parent
::
rollback
(
array
(
$destination_identifier
));
}
}
core/modules/migrate/src/Plugin/migrate/destination/EntityViewMode.php
View file @
614ba415
...
...
@@ -20,4 +20,12 @@ public function getIds() {
return
$ids
;
}
/**
* {@inheritdoc}
*/
public
function
rollback
(
array
$destination_identifier
)
{
$destination_identifier
=
implode
(
'.'
,
$destination_identifier
);
parent
::
rollback
(
array
(
$destination_identifier
));
}
}
core/modules/migrate/src/Plugin/migrate/process/Callback.php
View file @
614ba415
...
...
@@ -15,6 +15,8 @@
* arguments can be passed to the callback as this would make the migration YAML
* file too complex.
*
* @link https://www.drupal.org/node/2181783 Online handbook documentation for callback process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "callback"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/Concat.php
View file @
614ba415
...
...
@@ -10,6 +10,8 @@
/**
* Concatenates the strings in the current value.
*
* @link https://www.drupal.org/node/2345927 Online handbook documentation for concat process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "concat",
* handle_multiples = TRUE
...
...
core/modules/migrate/src/Plugin/migrate/process/DedupeBase.php
View file @
614ba415
...
...
@@ -15,6 +15,8 @@
* creating filter format names, the current value is checked against the
* existing filter format names and if it exists, a numeric postfix is added
* and incremented until a unique value is created.
*
* @link https://www.drupal.org/node/2345929 Online handbook documentation for dedupebase process plugin @endlink
*/
abstract
class
DedupeBase
extends
ProcessPluginBase
{
...
...
core/modules/migrate/src/Plugin/migrate/process/DedupeEntity.php
View file @
614ba415
...
...
@@ -10,6 +10,8 @@
/**
* Ensures value is not duplicated against an entity field.
*
* @link https://www.drupal.org/node/2135325 Online handbook documentation for dedupe_entity process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "dedupe_entity"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php
View file @
614ba415
...
...
@@ -9,6 +9,8 @@
/**
* This plugin sets missing values on the destination.
*
* @link https://www.drupal.org/node/2135313 Online handbook documentation for default_value process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "default_value"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/Explode.php
View file @
614ba415
...
...
@@ -10,6 +10,8 @@
/**
* This plugin explodes a delimited string into an array of values.
*
* @link https://www.drupal.org/node/2674504 Online handbook documentation for explode process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "explode"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/Extract.php
View file @
614ba415
...
...
@@ -11,7 +11,7 @@
/**
* This plugin extracts a value from an array.
*
* @
see
https://www.drupal.org/node/2152731
* @
link
https://www.drupal.org/node/2152731
Online handbook documentation for extract process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "extract"
...
...
core/modules/migrate/src/Plugin/migrate/process/Flatten.php
View file @
614ba415
...
...
@@ -12,7 +12,7 @@
* once a single value gets transformed into multiple values. This plugin will
* flatten them back down to single values again.
*
* @
see
https://www.drupal.org/node/2154215
* @
link
https://www.drupal.org/node/2154215
Online handbook documentation for flatten process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "flatten",
...
...
Prev
1
2
3
4
5
6
Next