Commit c83c8bbd authored by Adam G-H's avatar Adam G-H
Browse files

Made all classes final and added doc comments.

parent 9c82f6b7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@ namespace Drupal\core_context;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Plugin\Context\ContextInterface as CacheableContextInterface;

/**
 * Provides methods for working with contexts that can be cached.
 */
trait CacheableContextTrait {

  /**
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@ namespace Drupal\core_context;
use Drupal\Core\Entity\EntityHandlerInterface;
use Drupal\Core\Entity\EntityInterface;

/**
 * Defines an interface for entity handlers that expose contexts.
 */
interface EntityContextHandlerInterface extends EntityHandlerInterface {

  /**
+3 −0
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Context\ContextProviderInterface;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Provides contexts stored in an entity when viewing it at its canonical route.
 */
final class EntityRouteProvider implements ContextProviderInterface {

  use CacheableContextTrait;
+12 −1
Original line number Diff line number Diff line
@@ -8,7 +8,10 @@ use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\ctools\ContextMapperInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class FieldContextHandler implements EntityContextHandlerInterface {
/**
 * Exposes contexts stored on an entity field.
 */
final class FieldContextHandler implements EntityContextHandlerInterface {

  use CacheableContextTrait;

@@ -26,6 +29,14 @@ class FieldContextHandler implements EntityContextHandlerInterface {
   */
  private $entityFieldManager;

  /**
   * FieldContextHandler constructor.
   *
   * @param \Drupal\ctools\ContextMapperInterface $context_mapper
   *   The context mapper service.
   * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
   *   The entity field manager service.
   */
  public function __construct(ContextMapperInterface $context_mapper, EntityFieldManagerInterface $entity_field_manager) {
    $this->contextMapper = $context_mapper;
    $this->entityFieldManager = $entity_field_manager;
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,9 @@ namespace Drupal\core_context\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Modifies certain canonical entity routes to expose contexts.
 */
final class RouteSubscriber extends RouteSubscriberBase {

  /**
Loading