You are here

class PayloadViolations in Open Social 10.0.x

Returns the violations in a payload.

Plugin annotation


@DataProducer(
  id = "payload_violations",
  name = @Translation("Payload Violations"),
  description = @Translation("Returns the violations from a payload."),
  produces = @ContextDefinition("any",
    label = @Translation("Violations")
  ),
  consumes = {
    "payload" = @ContextDefinition("any",
      label = @Translation("Payload")
    )
  }
)

Hierarchy

  • class \Drupal\social_graphql\Plugin\GraphQL\DataProducer\Payload\PayloadViolations extends \Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase implements \Drupal\graphql\Plugin\DataProducerPluginCachingInterface

Expanded class hierarchy of PayloadViolations

File

modules/custom/social_graphql/src/Plugin/GraphQL/DataProducer/Payload/PayloadViolations.php, line 26

Namespace

Drupal\social_graphql\Plugin\GraphQL\DataProducer\Payload
View source
class PayloadViolations extends DataProducerPluginBase implements DataProducerPluginCachingInterface {

  /**
   * Resolves the value for this data producer.
   *
   * @param \Drupal\social_graphql\GraphQL\Payload\PayloadInterface $payload
   *   The payload to return violations for..
   *
   * @return null|\Drupal\social_graphql\GraphQL\ViolationInterface[]
   *   The violations for this payload or null if there are none.
   */
  public function resolve(PayloadInterface $payload) {

    // Explicitly turn empty arrays into NULL so that clients can perform an
    // is_null check to figure out if there are errors.
    $violations = $payload
      ->getViolations();
    return empty($violations) ? NULL : $violations;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PayloadViolations::resolve public function Resolves the value for this data producer.