Issue #2479767 by Wim Leers: Fix MenuLinkInterface::isCacheable(): remove it in favor of implementing CacheableDependencyInterface
parent
34d780b432
commit
67f0d68fac
|
@ -9,6 +9,7 @@ namespace Drupal\Core\Menu;
|
|||
|
||||
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 @@ abstract class MenuLinkBase extends PluginBase implements MenuLinkInterface {
|
|||
return $this->pluginDefinition['metadata'] ?: array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isCacheable() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -179,4 +173,25 @@ abstract class MenuLinkBase extends PluginBase implements MenuLinkInterface {
|
|||
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 @@ namespace Drupal\Core\Menu;
|
|||
|
||||
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 @@ interface MenuLinkInterface extends PluginInspectionInterface, DerivativeInspect
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue