Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
73b0592f
Commit
73b0592f
authored
Sep 09, 2014
by
alexpott
Browse files
Issue
#2084985
by mondrake: Added Implement ThirdPartySettingsInterface in ImageStyle.
parent
d60d5be0
Changes
9
Hide whitespace changes
Inline
Side-by-side
core/modules/config/src/Tests/ConfigSchemaTest.php
View file @
73b0592f
...
...
@@ -166,6 +166,9 @@ function testSchemaMapping() {
$expected
[
'mapping'
][
'effects'
][
'sequence'
][
0
][
'mapping'
][
'data'
][
'type'
]
=
'image.effect.[%parent.id]'
;
$expected
[
'mapping'
][
'effects'
][
'sequence'
][
0
][
'mapping'
][
'weight'
][
'type'
]
=
'integer'
;
$expected
[
'mapping'
][
'effects'
][
'sequence'
][
0
][
'mapping'
][
'uuid'
][
'type'
]
=
'string'
;
$expected
[
'mapping'
][
'third_party_settings'
][
'type'
]
=
'sequence'
;
$expected
[
'mapping'
][
'third_party_settings'
][
'label'
]
=
'Third party settings'
;
$expected
[
'mapping'
][
'third_party_settings'
][
'sequence'
][
0
][
'type'
]
=
'image_style.third_party.[%key]'
;
$expected
[
'type'
]
=
'image.style.*'
;
$this
->
assertEqual
(
$definition
,
$expected
);
...
...
core/modules/image/config/schema/image.schema.yml
View file @
73b0592f
...
...
@@ -22,6 +22,11 @@ image.style.*:
type
:
integer
uuid
:
type
:
string
third_party_settings
:
type
:
sequence
label
:
'
Third
party
settings'
sequence
:
-
type
:
image_style.third_party.[%key]
image.effect.image_crop
:
type
:
image_size
...
...
core/modules/image/src/Entity/ImageStyle.php
View file @
73b0592f
...
...
@@ -9,6 +9,7 @@
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Config\Entity\ConfigEntityBase
;
use
Drupal\Core\Config\Entity\ThirdPartySettingsTrait
;
use
Drupal\Core\Entity\EntityStorageInterface
;
use
Drupal\Core\Entity\EntityWithPluginBagsInterface
;
use
Drupal\Core\Routing\RequestHelper
;
...
...
@@ -50,6 +51,8 @@
*/
class
ImageStyle
extends
ConfigEntityBase
implements
ImageStyleInterface
,
EntityWithPluginBagsInterface
{
use
ThirdPartySettingsTrait
;
/**
* The name of the image style to use as replacement upon delete.
*
...
...
core/modules/image/src/ImageStyleInterface.php
View file @
73b0592f
...
...
@@ -8,11 +8,12 @@
namespace
Drupal\image
;
use
Drupal\Core\Config\Entity\ConfigEntityInterface
;
use
Drupal\Core\Config\Entity\ThirdPartySettingsInterface
;
/**
* Provides an interface defining an image style entity.
*/
interface
ImageStyleInterface
extends
ConfigEntityInterface
{
interface
ImageStyleInterface
extends
ConfigEntityInterface
,
ThirdPartySettingsInterface
{
/**
* Returns the replacement ID.
...
...
core/modules/image/src/Tests/ImageAdminStylesTest.php
View file @
73b0592f
...
...
@@ -129,6 +129,12 @@ function testStyle() {
// Load the saved image style.
$style
=
entity_load
(
'image_style'
,
$style_name
);
// Ensure that third party settings were added to the config entity.
// These are added by a hook_image_style_presave() implemented in
// image_module_test module.
$this
->
assertEqual
(
'bar'
,
$style
->
getThirdPartySetting
(
'image_module_test'
,
'foo'
),
'Third party settings were added to the image style.'
);
// Ensure that the image style URI matches our expected path.
$style_uri_path
=
$style
->
url
();
$this
->
assertTrue
(
strpos
(
$style_uri_path
,
$style_path
)
!==
FALSE
,
'The image style URI is correct.'
);
...
...
core/modules/image/src/Tests/ImageFieldTestBase.php
View file @
73b0592f
...
...
@@ -32,7 +32,7 @@ abstract class ImageFieldTestBase extends WebTestBase {
*
* @var array
*/
public
static
$modules
=
array
(
'node'
,
'image'
,
'field_ui'
);
public
static
$modules
=
array
(
'node'
,
'image'
,
'field_ui'
,
'image_module_test'
);
protected
$admin_user
;
...
...
core/modules/image/tests/modules/image_module_test/config/schema/image_module_test.schema.yml
0 → 100644
View file @
73b0592f
image_style.third_party.image_module_test
:
type
:
mapping
label
:
'
Schema
for
image_module_test
module
additions
to
image_style
entity'
mapping
:
foo
:
type
:
string
label
:
'
Label
for
foo'
core/modules/image/tests/modules/image_module_test/image_module_test.info.yml
View file @
73b0592f
name
:
'
Image
test'
type
:
module
description
:
'
Provides
hook
implementations
for
testing
Image
module
functionality.'
package
:
Core
package
:
Testing
version
:
VERSION
core
:
8.x
core/modules/image/tests/modules/image_module_test/image_module_test.module
View file @
73b0592f
...
...
@@ -5,6 +5,8 @@
* Provides Image module hook implementations for testing purposes.
*/
use
Drupal\image\ImageStyleInterface
;
function
image_module_test_file_download
(
$uri
)
{
$default_uri
=
\
Drupal
::
state
()
->
get
(
'image.test_file_download'
)
?:
FALSE
;
if
(
$default_uri
==
$uri
)
{
...
...
@@ -21,3 +23,12 @@ function image_module_test_image_effect_info_alter(&$effects) {
$image_effects_definition_called
=
&
drupal_static
(
__FUNCTION__
,
0
);
$image_effects_definition_called
++
;
}
/**
* Implements hook_image_style_presave().
*
* Used to save test third party settings in the image style entity.
*/
function
image_module_test_image_style_presave
(
ImageStyleInterface
$style
)
{
$style
->
setThirdPartySetting
(
'image_module_test'
,
'foo'
,
'bar'
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment