Skip to content
Snippets Groups Projects
Unverified Commit 0be76180 authored by Hussain Abbas's avatar Hussain Abbas
Browse files

Issue #3401251 by hussainweb: Fix phpcs errors

parent 27356e92
No related branches found
No related tags found
No related merge requests found
Pipeline #48774 failed
......@@ -2,10 +2,10 @@
namespace Drupal\do_username\Commands;
use Drush\Commands\DrushCommands;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Entity\EntityFieldManager;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drush\Commands\DrushCommands;
/**
* A drush command file.
......@@ -31,16 +31,16 @@ class DOCopyFieldValues extends DrushCommands {
/**
* Source field.
*
* @var stringsource_field
* @var string sourceField
*/
protected $source_field;
protected $sourceField;
/**
* Destination field.
*
* @var stringdestination_field
* @var string destinationField
*/
protected $destination_field;
protected $destinationField;
/**
* Constructs a new UpdateVideosStatsController object.
......@@ -75,8 +75,8 @@ class DOCopyFieldValues extends DrushCommands {
* @usage do_username:copy entity_type bundle field_to field_from
*/
public function copyFieldValue($entity_type, $bundle, $destination_field, $source_field) {
$this->destination_field = $destination_field;
$this->source_field = $source_field;
$this->destinationField = $destination_field;
$this->sourceField = $source_field;
$fieldDefinitions = $this->entityFieldManager->getFieldDefinitions($entity_type, $bundle);
if (!$this->isDestinationValid($fieldDefinitions)) {
$this->output()->writeln('Invalid destination field. Please make sure the field exists and its type is text(formateed)');
......@@ -107,21 +107,21 @@ class DOCopyFieldValues extends DrushCommands {
/**
* Check Destination field validity.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface[] $fieldDefnitions
* @param \Drupal\Core\Field\FieldDefinitionInterface[] $fieldDefinitions
* List of field definitions for the bundle.
*/
protected function isDestinationValid($fieldDefinitions): bool {
return isset($fieldDefinitions[$this->destination_field]) && $fieldDefinitions[$this->destination_field]->getType() == 'text';
return isset($fieldDefinitions[$this->destinationField]) && $fieldDefinitions[$this->destinationField]->getType() == 'text';
}
/**
* Check Source field validity.
*
* @param \Drupal\Core\Field\FieldDefinitionInterface[] $fieldDefnitions
* @param \Drupal\Core\Field\FieldDefinitionInterface[] $fieldDefinitions
* List of field definitions for the bundle.
*/
protected function isSourceValid($fieldDefinitions): bool {
return isset($fieldDefinitions[$this->source_field]) && $fieldDefinitions[$this->source_field]->getType() == 'text';
return isset($fieldDefinitions[$this->sourceField]) && $fieldDefinitions[$this->sourceField]->getType() == 'text';
}
}
......@@ -2,8 +2,8 @@
namespace Drupal\do_username;
use Drupal\Core\TypedData\TypedData;
use Drupal\Core\TypedData\DataDefinitionInterface;
use Drupal\Core\TypedData\TypedData;
use Drupal\Core\TypedData\TypedDataInterface;
/**
......
......@@ -52,7 +52,10 @@ class UsernameFormatConstraintValidator extends ConstraintValidator {
$this->context->addViolation($constraint->illegalMessage);
}
if (mb_strlen($name) > UserInterface::USERNAME_MAX_LENGTH) {
$this->context->addViolation($constraint->tooLongMessage, ['%name' => $name, '%max' => UserInterface::USERNAME_MAX_LENGTH]);
$this->context->addViolation($constraint->tooLongMessage, [
'%name' => $name,
'%max' => UserInterface::USERNAME_MAX_LENGTH,
]);
}
}
......
......@@ -2,11 +2,11 @@
namespace Drupal\do_username\Plugin\Validation\Constraint;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\do_username\DOUserInfoRetriever;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Validates the Username Valid constraint.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment