<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Engine_Content_Decorator_Children extends Engine_Content_Decorator_Abstract
{
  protected $_placement = null;
  
  public function render($content)
  {
    $element = $this->getElement();
    $separator = $this->getSeparator();
    $placement = $this->getPlacement();

    // Render children
    $childContent = '';
    foreach( $element->getElements() as $childElement ) {
      $childContent .= $separator . $childElement->render();
    }

    // Place child content
    switch( $placement ) {
      default:
        $content = $childContent;
        break;
      case self::APPEND:
        $content .= $separator . $childContent;
        break;
      case self::PREPEND;
        $content = $childContent . $separator . $content;
        break;
    }

    return $content;
  }
}
