src/Step/ConvertPages.php
public function process()
    {
        if (count($this->phpoole->getPages()) <= 0) {
            return;
        }
        $message = 'Converting pages';
        if ($this->phpoole->getBuildOptions()['drafts']) {
            $message .= ' (drafts included)';
        }
        call_user_func_array($this->phpoole->getMessageCb(), ['CONVERT', $message]);
        $max = count($this->phpoole->getPages());
        $count = 0;
        $countError = 0;
        /* @var $page Page */
        foreach ($this->phpoole->getPages() as $page) {
            if (!$page->isVirtual()) {
                $count++;
                $convertedPage = $this->convertPage($page, $this->phpoole->getConfig()->get('frontmatter.format'));
                if (false !== $convertedPage) {
                    $message = $page->getPathname();
                    // force convert drafts?
                    if ($this->phpoole->getBuildOptions()['drafts']) {
                        $page->setVariable('published', true);
                    }
                    if ($page->getVariable('published')) {
                        $this->phpoole->getPages()->replace($page->getId(), $convertedPage);
                    } else {
                        $this->phpoole->getPages()->remove($page->getId());
                        $message .= ' (not published)';
                    }
                    call_user_func_array($this->phpoole->getMessageCb(), ['CONVERT_PROGRESS', $message, $count, $max]);
                } else {
                    $this->phpoole->getPages()->remove($page->getId());
                    $countError++;
                }
            }
        }
        if ($countError > 0) {
            $message = sprintf('Number of errors: %s', $countError);
            call_user_func_array($this->phpoole->getMessageCb(), ['CONVERT_ERROR', $message]);
        }
    }
public function process()
    {
        if (count($this->phpoole->getPages()) <= 0) {
            return;
        }
        $message = 'Converting pages';
        if ($this->phpoole->getBuildOptions()['drafts']) {
            $message .= ' (drafts included)';
        }
        call_user_func_array($this->phpoole->getMessageCb(), ['CONVERT', $message]);
        $max = count($this->phpoole->getPages());
        $count = 0;
        $countError = 0;
        /* @var $page Page */
        foreach ($this->phpoole->getPages() as $page) {
            if (!$page->isVirtual()) {
                $count++;
                $convertedPage = $this->convertPage($page, $this->phpoole->getConfig()->get('frontmatter.format'));
                if (false !== $convertedPage) {
                    $message = $page->getPathname();
                    // force convert drafts?
                    if ($this->phpoole->getBuildOptions()['drafts']) {
                        $page->setVariable('published', true);
                    }
                    if ($page->getVariable('published')) {
                        $this->phpoole->getPages()->replace($page->getId(), $convertedPage);
                    } else {
                        $this->phpoole->getPages()->remove($page->getId());
                        $message .= ' (not published)';
                    }
                    call_user_func_array($this->phpoole->getMessageCb(), ['CONVERT_PROGRESS', $message, $count, $max]);
                } else {
                    $this->phpoole->getPages()->remove($page->getId());
                    $countError++;
                }
            }
        }
        if ($countError > 0) {
            $message = sprintf('Number of errors: %s', $countError);
            call_user_func_array($this->phpoole->getMessageCb(), ['CONVERT_ERROR', $message]);
        }
    }
{@inheritdoc}