effd0fe23ab4421efb776cca09620347b8f458be
[yaffs-website] / web / core / modules / content_moderation / src / ParamConverter / EntityRevisionConverter.php
1 <?php
2
3 namespace Drupal\content_moderation\ParamConverter;
4
5 use Drupal\Core\ParamConverter\EntityConverter;
6
7 /**
8  * Defines a class for making sure the edit-route loads the current draft.
9  *
10  * @internal
11  *   This class only exists to provide backwards compatibility with the
12  *   load_pending_revision flag, the predecessor to load_latest_revision. The
13  *   core entity converter now natively loads the latest revision of an entity
14  *   when the load_latest_revision flag is present. This flag is also added
15  *   automatically to all entity forms.
16  */
17 class EntityRevisionConverter extends EntityConverter {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function convert($value, $definition, $name, array $defaults) {
23     if (!empty($definition['load_pending_revision'])) {
24       @trigger_error('The load_pending_revision flag has been deprecated. You should use load_latest_revision instead.', E_USER_DEPRECATED);
25       $definition['load_latest_revision'] = TRUE;
26     }
27     return parent::convert($value, $definition, $name, $defaults);
28   }
29
30 }