Commit 67f0d68f authored by alexpott's avatar alexpott

Issue #2479767 by Wim Leers: Fix MenuLinkInterface::isCacheable(): remove it...

Issue #2479767 by Wim Leers: Fix MenuLinkInterface::isCacheable(): remove it in favor of implementing CacheableDependencyInterface
parent 34d780b4
......@@ -9,6 +9,7 @@
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Url;
......@@ -107,13 +108,6 @@ public function getMetaData() {
return $this->pluginDefinition['metadata'] ?: array();
}
/**
* {@inheritdoc}
*/
public function isCacheable() {
return TRUE;
}
/**
* {@inheritdoc}
*/
......@@ -179,4 +173,25 @@ public function deleteLink() {
throw new PluginException(SafeMarkup::format('Menu link plugin with ID @id does not support deletion', array('@id' => $this->getPluginId())));
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return [];
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
return [];
}
}
......@@ -9,11 +9,12 @@
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\Core\Cache\CacheableDependencyInterface;
/**
* Defines an interface for classes providing a type of menu link.
*/
interface MenuLinkInterface extends PluginInspectionInterface, DerivativeInspectionInterface {
interface MenuLinkInterface extends PluginInspectionInterface, DerivativeInspectionInterface, CacheableDependencyInterface {
/**
* Returns the weight of the menu link.
......@@ -150,20 +151,6 @@ public function getOptions();
*/
public function getMetaData();
/**
* Returns whether the rendered link can be cached.
*
* The plugin class may make some or all of the data used in the Url object
* and build array dynamic. For example, it could include the current user
* name in the title, the current time in the description, or a destination
* query string. In addition the route parameters may be dynamic so an access
* check should be performed for each user.
*
* @return bool
* TRUE if the link can be cached, FALSE otherwise.
*/
public function isCacheable();
/**
* Updates the definition values for a menu link.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment