Loading src/CacheableContextTrait.php +3 −0 Original line number Diff line number Diff line Loading @@ -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 { /** Loading src/EntityContextHandlerInterface.php +3 −0 Original line number Diff line number Diff line Loading @@ -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 { /** Loading src/EntityRouteProvider.php +3 −0 Original line number Diff line number Diff line Loading @@ -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; Loading src/FieldContextHandler.php +12 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading src/Routing/RouteSubscriber.php +3 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
src/CacheableContextTrait.php +3 −0 Original line number Diff line number Diff line Loading @@ -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 { /** Loading
src/EntityContextHandlerInterface.php +3 −0 Original line number Diff line number Diff line Loading @@ -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 { /** Loading
src/EntityRouteProvider.php +3 −0 Original line number Diff line number Diff line Loading @@ -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; Loading
src/FieldContextHandler.php +12 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading
src/Routing/RouteSubscriber.php +3 −0 Original line number Diff line number Diff line Loading @@ -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