You are here

public function SimpleSitemapStorage::create in Simple XML sitemap 4.x

Constructs a new entity object, without permanently saving it.

Parameters

array $values: (optional) An array of values to set, keyed by property name. If the entity type has bundles, the bundle key has to be specified.

Return value

\Drupal\Core\Entity\EntityInterface A new entity object.

Overrides EntityStorageBase::create

File

src/Entity/SimpleSitemapStorage.php, line 114

Class

SimpleSitemapStorage

Namespace

Drupal\simple_sitemap\Entity

Code

public function create(array $values = []) {
  if (isset($values['id']) && ($sitemap = SimpleSitemap::load($values['id'])) !== NULL) {
    foreach ([
      'type',
      'label',
      'weight',
    ] as $property) {
      if (isset($values[$property])) {
        $sitemap
          ->set('type', $values[$property]);
      }
    }
    return $sitemap;
  }
  return parent::create($values);
}