Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
E
ephoto_dam
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
ephoto_dam
Commits
97b863d5
Commit
97b863d5
authored
Sep 02, 2020
by
ephoto_dam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Ephoto Dam Field Constraint
parent
164b14d1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
4 deletions
+58
-4
modules/ephoto_dam_field/src/Plugin/Field/FieldType/EphotoDamField.php
...o_dam_field/src/Plugin/Field/FieldType/EphotoDamField.php
+2
-4
modules/ephoto_dam_field/src/Plugin/Validation/Constraint/EphotoDamFieldConstraint.php
...Plugin/Validation/Constraint/EphotoDamFieldConstraint.php
+16
-0
modules/ephoto_dam_field/src/Plugin/Validation/Constraint/EphotoDamFieldConstraintValidator.php
...lidation/Constraint/EphotoDamFieldConstraintValidator.php
+40
-0
No files found.
modules/ephoto_dam_field/src/Plugin/Field/FieldType/EphotoDamField.php
View file @
97b863d5
...
...
@@ -17,7 +17,8 @@ use Drupal\Core\TypedData\TraversableTypedDataInterface;
* description = @Translation("Stores a Ephoto Dam URL and then outputs some embed code"),
* category = @Translation("Media"),
* default_widget = "ephoto_dam_field_widget",
* default_formatter = "ephoto_dam_field_formatter"
* default_formatter = "ephoto_dam_field_formatter",
* constraints = {"EphotoDamFieldValidation" = {}}
* )
*/
class
EphotoDamField
extends
FieldItemBase
{
...
...
@@ -64,15 +65,12 @@ class EphotoDamField extends FieldItemBase {
public
static
function
propertyDefinitions
(
FieldStorageDefinitionInterface
$field_definition
)
{
$properties
[
'url'
]
=
DataDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Url'
));
//->setRequired(true);
$properties
[
'image_size'
]
=
DataDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Image size'
));
//->setRequired(true);
$properties
[
'version'
]
=
DataDefinition
::
create
(
'string'
)
->
setLabel
(
t
(
'Version'
));
//->setRequired(true);
return
$properties
;
}
...
...
modules/ephoto_dam_field/src/Plugin/Validation/Constraint/EphotoDamFieldConstraint.php
0 → 100644
View file @
97b863d5
<?php
namespace
Drupal\ephoto_dam_field\Plugin\Validation\Constraint
;
use
Symfony\Component\Validator\Constraint
;
/**
* Validation constraint for the ephoto dam field.
*
* @Constraint(
* id = "EphotoDamFieldValidation"
* )
*/
class
EphotoDamFieldConstraint
extends
Constraint
{
}
modules/ephoto_dam_field/src/Plugin/Validation/Constraint/EphotoDamFieldConstraintValidator.php
0 → 100644
View file @
97b863d5
<?php
namespace
Drupal\ephoto_dam_field\Plugin\Validation\Constraint
;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\Validator\Constraint
;
use
Symfony\Component\Validator\ConstraintValidator
;
/**
* Validates the Ephoto Dam Field
*/
class
EphotoDamFieldConstraintValidator
extends
ConstraintValidator
implements
ContainerInjectionInterface
{
/**
* Create an instance of the validator.
*/
public
function
__construct
()
{
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
();
}
/**
* {@inheritdoc}
*/
public
function
validate
(
$field
,
Constraint
$constraint
)
{
if
(
!
isset
(
$field
->
image_size
))
{
return
NULL
;
}
error_log
(
var_export
(
$field
->
image_size
,
true
));
//$this->context->addViolation('');
}
}
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