You are here

public function DefaultConfigEntityHandler::push in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/cms_content_sync/entity_handler/DefaultConfigEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultConfigEntityHandler::push()
  2. 2.1.x src/Plugin/cms_content_sync/entity_handler/DefaultConfigEntityHandler.php \Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler\DefaultConfigEntityHandler::push()

Parameters

\Drupal\cms_content_sync\PushIntent $intent: The request to store all relevant info at

Return value

bool Whether or not the content has been pushed. FALSE is a desired state, meaning nothing should be pushed according to config.

Throws

\Drupal\cms_content_sync\Exception\SyncException

Overrides EntityHandlerBase::push

File

src/Plugin/cms_content_sync/entity_handler/DefaultConfigEntityHandler.php, line 100

Class

DefaultConfigEntityHandler
Class DefaultConfigEntityHandler, providing a minimalistic implementation for any config entity type.

Namespace

Drupal\cms_content_sync\Plugin\cms_content_sync\entity_handler

Code

public function push(PushIntent $intent, EntityInterface $entity = null) {
  if (!parent::push($intent, $entity)) {
    return false;
  }
  if (!$entity) {
    $entity = $intent
      ->getEntity();
  }

  /**
   * @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
   */
  foreach ($this
    ->getConfigProperties() as $property => $config) {
    $entity_property = $entity
      ->get($property);
    if (is_array($entity_property) && !count($entity_property)) {
      $entity_property = null;
    }
    $intent
      ->setProperty($property, $entity_property);
  }
  return true;
}