public function execute(Batch $batch)
 {
     $this->batch = $batch;
     $stacks = $batch->getObjectCollection('stack');
     if (!$stacks) {
         return;
     }
     foreach ($stacks->getStacks() as $stack) {
         if (!$stack->getPublisherValidator()->skipItem()) {
             $s = Stack::getByName($stack->getName());
             if (is_object($s)) {
                 foreach ($stack->getBlocks() as $block) {
                     $bt = $this->getTargetItem('block_type', $block->getType());
                     if (is_object($bt)) {
                         $value = $block->getBlockValue();
                         $publisher = $value->getPublisher();
                         $area = new Area();
                         $area->setName(STACKS_AREA_NAME);
                         $b = $publisher->publish($batch, $bt, $s, $area, $value);
                         $styleSet = $block->getStyleSet();
                         if (is_object($styleSet)) {
                             $styleSetPublisher = $styleSet->getPublisher();
                             $publishedStyleSet = $styleSetPublisher->publish();
                             $b->setCustomStyleSet($publishedStyleSet);
                         }
                         if ($block->getCustomTemplate()) {
                             $b->setCustomTemplate($block->getCustomTemplate());
                         }
                     }
                 }
             }
         }
     }
 }
 public function publish(Batch $batch, BlockType $bt, Page $page, Area $area, BlockValue $value)
 {
     $routine = new PublishPageContentRoutine();
     $routine->setBatch($batch);
     /* @var $value AreaLayoutBlockValue */
     $layout = $value->getAreaLayout();
     $publisher = $layout->getPublisher();
     $layoutObject = $publisher->publish($layout);
     $columns = $layout->getColumns();
     $i = 0;
     $layoutBlock = $page->addBlock($bt, $area->getName(), array('arLayoutID' => $layoutObject->getAreaLayoutID()));
     foreach ($layoutObject->getAreaLayoutColumns() as $columnObject) {
         $column = $columns[$i];
         foreach ($column->getBlocks() as $block) {
             $subValue = $block->getBlockValue();
             $publisher = $subValue->getPublisher();
             $subarea = new Area();
             $subAreaName = $area->getName() . SubArea::AREA_SUB_DELIMITER . $columnObject->getAreaLayoutColumnDisplayID();
             $subarea->setName($subAreaName);
             /*
              * @var $publisher BlockPublisherInterface
              */
             $subBlockType = $routine->getTargetItem('block_type', $block->getType());
             if (is_object($subBlockType)) {
                 $b = $publisher->publish($batch, $subBlockType, $page, $subarea, $subValue);
                 $styleSet = $block->getStyleSet();
                 if (is_object($styleSet)) {
                     $styleSetPublisher = $styleSet->getPublisher();
                     $publishedStyleSet = $styleSetPublisher->publish();
                     $b->setCustomStyleSet($publishedStyleSet);
                 }
                 if ($block->getCustomTemplate()) {
                     $b->setCustomTemplate($block->getCustomTemplate());
                 }
             }
         }
         ++$i;
     }
     return $layoutBlock;
 }
Esempio n. 3
0
 private function parseArea($node)
 {
     $area = new Area();
     $area->setName('Main');
     $block = $this->parseBlocks($node);
     $block->setArea($area);
     $area->blocks->add($block);
     return $area;
 }
Esempio n. 4
0
 protected function parseArea($node)
 {
     $area = new Area();
     $area->setName((string) $node['name']);
     if (isset($node->style)) {
         $styleSet = $this->styleSetImporter->import($node->style);
         $area->setStyleSet($styleSet);
     }
     // Parse areas
     $nodes = false;
     if ($node->blocks->block) {
         $nodes = $node->blocks->block;
     } elseif ($node->block) {
         // 5.6
         $nodes = $node->block;
     }
     if ($nodes) {
         $i = 0;
         foreach ($nodes as $blockNode) {
             if ($blockNode['type']) {
                 $block = $this->parseBlock($blockNode);
             } elseif ($blockNode['mc-block-id'] != '') {
                 $block = new Block();
                 $block->setDefaultsOutputIdentifier((string) $blockNode['mc-block-id']);
             }
             if (isset($block)) {
                 $block->setPosition($i);
                 $block->setArea($area);
                 $area->blocks->add($block);
                 ++$i;
             }
         }
     }
     return $area;
 }