api-8.x-1.x-dev/src/Traits/ReParseTrait.php

src/Traits/ReParseTrait.php
<?php

namespace Drupal\api\Traits;

use Drupal\Core\Entity\EntityInterface;

/**
 * Common reparsing logic to use in branches.
 *
 * @package Drupal\api\Traits
 */
trait ReParseTrait {

  /**
   * Sets up a branch for parsing.
   */
  public function reParse() {
    \Drupal::state()->set(static::getStateKey($this), TRUE);
  }

  /**
   * Gets the key where the parse information is stored in state.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   An entity like Branch, PhpBranch or ExternalBranch.
   *
   * @return string
   *   The key where the parse information is stored in state.
   */
  protected static function getStateKey(EntityInterface $entity) {
    return sprintf("api.%s.needs_parsing.%d", $entity->getEntityTypeId(), $entity->id());
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc