Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / pathauto / src / PathautoFieldItemList.php
1 <?php
2
3 namespace Drupal\pathauto;
4
5 use Drupal\path\Plugin\Field\FieldType\PathFieldItemList;
6
7 class PathautoFieldItemList extends PathFieldItemList {
8
9   /**
10    * @{inheritdoc}
11    */
12   protected function delegateMethod($method) {
13     // @todo Workaround until this is fixed, see
14     //   https://www.drupal.org/project/drupal/issues/2946289.
15     $this->ensureComputedValue();
16
17     // Duplicate the logic instead of calling the parent due to the dynamic
18     // arguments.
19     $result = [];
20     $args = array_slice(func_get_args(), 1);
21     foreach ($this->list as $delta => $item) {
22       // call_user_func_array() is way slower than a direct call so we avoid
23       // using it if have no parameters.
24       $result[$delta] = $args ? call_user_func_array([$item, $method], $args) : $item->{$method}();
25     }
26     return $result;
27   }
28
29   /**
30    * @{inheritdoc}
31    */
32   protected function computeValue() {
33     parent::computeValue();
34
35     // For a new entity, default to creating a new alias.
36     if ($this->getEntity()->isNew()) {
37       $this->list[0]->set('pathauto', PathautoState::CREATE);
38     }
39   }
40
41 }