| #2 | Phalcon\Db\Adapter\Pdo\AbstractPdo->execute 
 /var/www/html/discounts-n-coupons.com/src/app/Lib/Mvc/Model/Nested.php (33) <?php
 
namespace CLSystems\PhalCMS\Lib\Mvc\Model;
 
use Phalcon\Db\Adapter\Pdo\Mysql;
use Phalcon\Db\Enum;
use stdClass;
 
class Nested extends UcmItem
{
  private $isNew = true;
 
  public function getRootId()
  {
    static $rootId = null;
 
    if (null === $rootId)
    {
      /** @var Mysql $db */
      $db     = $this->getDI()->get('db');
      $source = $this->getSource();
      $root   = $db->fetchOne('SELECT id FROM ' . $source . ' WHERE context = :context AND parentId = 0 AND title = \'system-node-root\'',
        Enum::FETCH_OBJ,
        [
          'context' => $this->context,
        ]
      );
 
      if (empty($root->id))
      {
        $db->execute('INSERT INTO ' . $source . '(context, title, state, lft, rgt) VALUES (:context, \'system-node-root\', \'P\', 0, 1)',
          [
            'context' => $this->context,
          ]
        );
 
        $rootId = (int) $db->lastInsertId();
      }
      else
      {
        $rootId = (int) $root->id;
      }
    }
 
    return $rootId;
  }
 
  public function beforeSave()
  {
    $this->isNew = empty($this->id);
 
    if ((int) $this->parentId < 1)
    {
      $this->parentId = $this->getRootId();
    }
 
    if (!$this->isNew)
    {
      $this->moveNodeToNewParent($this->parentId);
    }
 
    return parent::beforeSave();
  }
 
  public function afterSave()
  {
    if ($this->isNew)
    {
      $this->handleAddNewNode();
    }
 
    return true;
  }
 
  public function getTree($rootId = null)
  {
    /** @var Mysql $db */
    $db     = $this->getDI()->get('db');
    $source = $this->getSource();
 
    if (null === $rootId)
    {
      $rootId = $this->id;
    }
 
    return $db->fetchAll('SELECT n.* FROM ' . $source . ' AS n, ' . $source . ' AS p WHERE n.lft BETWEEN p.lft AND p.rgt AND n.context = :context AND n.state = :state AND p.id = :rootId GROUP BY n.id ORDER BY n.lft',
      Enum::FETCH_OBJ,
      [
        'state'   => 'P',
        'rootId'  => $rootId,
        'context' => $this->context,
      ]
    );
  }
 
  public function getParentTree()
  {
    /** @var Mysql $db */
    $db     = $this->getDI()->get('db');
    $source = $this->getSource();
 
    return $db->fetchAll('SELECT * FROM ' . $source . ' WHERE lft < :lft AND rgt > :rgt AND context = :context ORDER BY lft',
      Enum::FETCH_OBJ,
      [
        'lft'     => $this->lft,
        'rgt'     => $this->rgt,
        'context' => $this->context,
      ]
    );
  }
 
  public function fix()
  {
    /** @var Mysql $db */
    $db     = $this->getDI()->get('db');
    $source = $this->getSource();
    $rootId = $this->getRootId();
    $db->execute('UPDATE ' . $source . ' SET level = 0 WHERE id = :rootId',
      [
        'rootId' => $rootId,
      ]
    );
    $db->execute('UPDATE ' . $source . ' SET parentId = :rootId, level = 1 WHERE context = :context AND id <> :rootId AND (parentId = id OR parentId = 0)',
      [
        'rootId'  => $rootId,
        'context' => $this->context,
      ]
    );
  }
 
  public function rebuild($nodeId = null, $leftId = 0, $level = 0)
  {
    if (null === $nodeId)
    {
      $nodeId = $this->getRootId();
    }
 
    /** @var Mysql $db */
    $db       = $this->getDI()->get('db');
    $source   = $this->getSource();
    $rightId  = $leftId + 1;
    $children = $db->fetchAll('SELECT id FROM ' . $source . ' WHERE context = :context AND parentId = :parentId ORDER BY parentId, lft',
      Enum::FETCH_OBJ,
      [
        'parentId' => $nodeId,
        'context'  => $this->context,
      ]
    );
 
    if (!empty($children))
    {
      foreach ($children as $child)
      {
        $rightId = $this->rebuild($child->id, $rightId, $level + 1);
      }
    }
 
    $db->execute('UPDATE ' . $source . ' SET lft = :lft, rgt = :rgt, level = :level WHERE context = :context AND id = :nodeId',
      [
        'lft'     => $leftId,
        'rgt'     => $rightId,
        'nodeId'  => $nodeId,
        'level'   => $level ?: 1,
        'context' => $this->context,
      ]
    );
 
    return $rightId + 1;
  }
 
  public function getNode($nodeId)
  {
    /**
     * @var Mysql     $db
     * @var stdClass $node
     */
    $db     = $this->getDI()->get('db');
    $source = $this->getSource();
    $node   = $db->fetchOne('SELECT id, lft, rgt, parentId, level FROM ' . $source . ' WHERE id = :nodeId',
      Enum::FETCH_OBJ,
      [
        'nodeId' => $nodeId,
      ]
    );
 
    if ($node)
    {
      $node->width = (int) $node->rgt - (int) $node->lft + 1;
    }
 
    return $node;
  }
 
  protected function handleAddNewNode()
  {
    /** @var Mysql $db */
    $db     = $this->getDI()->get('db');
    $source = $this->getSource();
 
    // Lock the table
    $db->execute('LOCK TABLE ' . $source . ' WRITE');
    $parent   = $this->getNode($this->parentId);
    $newLevel = (int) $parent->level + 1;
    $newLft   = (int) $parent->rgt;
    $newRgt   = $newLft + 1;
 
    // make a gap in tree
    $db->execute('UPDATE ' . $source . ' SET rgt = rgt + 2 WHERE context = :context AND rgt >= :newLft',
      [
        'context' => $this->context,
        'newLft'  => $newLft,
      ]
    );
    $db->execute('UPDATE ' . $source . ' SET lft = lft + 2 WHERE context = :context AND lft > :newLft',
      [
        'context' => $this->context,
        'newLft'  => $newLft,
      ]
    );
 
    // Update itself
    $db->execute('UPDATE ' . $source . ' SET lft = :lft, rgt = :rgt, level = :level WHERE id = :id',
      [
        'lft'   => $newLft,
        'rgt'   => $newRgt,
        'level' => $newLevel,
        'id'    => $this->id,
      ]
    );
 
 
    // Unlock tables
    $db->execute('UNLOCK TABLES');
    $this->lft   = $newLft;
    $this->rgt   = $newRgt;
    $this->level = $newLevel ?: 1;
  }
 
  public function moveNodeToNewParent($toParentId)
  {
    $node   = $this->getNode($this->id);
    $parent = $this->getNode($toParentId);
 
    if (empty($node)
      || empty($parent)
      || $node->width < 2
    )
    {
      return false;
    }
 
    if ($node->parentId == $parent->id)
    {
      // Node has the same parent, so we done here
      return true;
    }
 
    /** @var Mysql $db */
    $db     = $this->getDI()->get('db');
    $source = $this->getSource();
 
    // Lock the table
    $db->execute('LOCK TABLE ' . $source . ' WRITE');
 
    $oldLft = (int) $node->lft;
    $oldRgt = (int) $node->rgt;
    $width  = (int) $node->width;
 
    // Get the ids of child nodes.
    $children = $db->fetchAll('SELECT id FROM ' . $source . ' WHERE context = :context AND lft BETWEEN :lft AND :rgt',
      Db::FETCH_OBJ,
      [
        'context' => $this->context,
        'lft'     => $oldLft,
        'rgt'     => $oldRgt,
      ]
    );
 
    foreach ($children as $child)
    {
      if ($child->id == $toParentId)
      {
        // Unlock tables
        $db->execute('UNLOCK TABLES');
 
        return false;
      }
    }
 
    // Move the sub-tree out of the nested sets by negating its left and right values.
    $db->execute('UPDATE ' . $source . ' SET lft = lft * (-1), rgt = rgt * (-1) WHERE context = :context AND lft BETWEEN :lft AND :rgt',
      [
        'context' => $this->context,
        'lft'     => $oldLft,
        'rgt'     => $oldRgt,
      ]
    );
 
    // Compress the right values.
    $db->execute('UPDATE ' . $source . ' SET lft = lft - :width WHERE context = :context AND lft > :oldRgt',
      [
        'context' => $this->context,
        'width'   => $width,
        'oldRgt'  => $oldRgt,
      ]
    );
    $db->execute('UPDATE ' . $source . ' SET rgt = rgt - :width WHERE context = :context AND rgt > :oldRgt',
      [
        'context' => $this->context,
        'width'   => $width,
        'oldRgt'  => $oldRgt,
      ]
    );
 
    // Get new updated parent node
    $parent    = $this->getNode($toParentId);
    $parentRgt = (int) $parent->rgt;
    $newLft    = $parentRgt;
    $newRgt    = $parentRgt + $width - 1;
    $offset    = $newLft - $oldLft;
 
    // Shift left values.
    $db->execute('UPDATE ' . $source . ' SET lft = lft + :width WHERE context = :context AND lft > :parentRgt',
      [
        'context'   => $this->context,
        'width'     => $width,
        'parentRgt' => $parentRgt,
      ]
    );
    $db->execute('UPDATE ' . $source . ' SET rgt = rgt + :width WHERE context = :context AND rgt >= :parentRgt',
      [
        'context'   => $this->context,
        'width'     => $width,
        'parentRgt' => $parentRgt,
      ]
    );
 
    // Move the nodes back into position in the tree using the calculated offsets.
    $db->execute('UPDATE ' . $source . ' SET rgt = :offset - rgt, lft = :offset - lft WHERE context = :context AND lft < 0',
      [
        'context' => $this->context,
        'offset'  => $offset,
      ]
    );
 
    // Update itself
    $this->lft   = $newLft;
    $this->rgt   = $newRgt;
    $this->level = $parent->level + 1;
 
    $db->execute('UPDATE ' . $source . ' SET lft = :lft, rgt = :rgt, level = :level WHERE id = :id',
      [
        'lft'   => $this->lft,
        'rgt'   => $this->rgt,
        'level' => $this->level ?: 1,
        'id'    => $this->id,
      ]
    );
 
    // Unlock tables
    $db->execute('UNLOCK TABLES');
  }
 
  public function modifyNode($nodeId, $state)
  {
    $node = $this->getNode($nodeId);
 
    if (empty($node) || !in_array($state, ['P', 'U', 'T', 'unlock']))
    {
      return false;
    }
 
    if ('unlock' === $state)
    {
      /** @var UcmItem $entity */
      $entity = static::findFirst('id = ' . (int) $nodeId);
 
      if (!$entity || !$entity->checkout())
      {
        return false;
      }
 
      return true;
    }
 
    /** @var Mysql $db */
    $db     = $this->getDI()->get('db');
    $source = $this->getSource();
    $lft    = (int) $node->lft;
    $rgt    = (int) $node->rgt;
    $width  = (int) $node->width;
 
    // Lock the table
    $db->execute('LOCK TABLE ' . $source . ' WRITE');
 
    if ('T' === $state)
    {
      // Delete the node and all of its children.
      $db->execute('DELETE FROM  ' . $source . ' WHERE context = :context AND lft BETWEEN :lft AND :rgt',
        [
          'context' => $this->context,
          'lft'     => $lft,
          'rgt'     => $rgt,
        ]
      );
 
      // Compress the right values.
      $db->execute('UPDATE ' . $source . ' SET lft = lft - :width WHERE context = :context AND lft > :rgt',
        [
          'context' => $this->context,
          'width'   => $width,
          'rgt'     => $rgt,
        ]
      );
      $db->execute('UPDATE ' . $source . ' SET rgt = rgt - :width WHERE context = :context AND rgt > :rgt',
        [
          'context' => $this->context,
          'width'   => $width,
          'rgt'     => $rgt,
        ]
      );
    }
    else
    {
      // Update state node and all its children
      $db->execute('UPDATE  ' . $source . ' SET state = :state WHERE context = :context AND lft BETWEEN :lft AND :rgt',
        [
          'context' => $this->context,
          'lft'     => $lft,
          'rgt'     => $rgt,
          'state'   => $state,
        ]
      );
    }
 
    // Unlock tables
    $db->execute('UNLOCK TABLES');
 
    return true;
  }
} | 
| #3 | CLSystems\PhalCMS\Lib\Mvc\Model\Nested->getRootId 
 /var/www/html/discounts-n-coupons.com/src/app/Lib/Mvc/Controller/DisplayController.php (124) <?php
 
namespace CLSystems\PhalCMS\Lib\Mvc\Controller;
 
use CLSystems\PhalCMS\Lib\Helper\Config;
use CLSystems\PhalCMS\Lib\Helper\Event;
use CLSystems\PhalCMS\Lib\Helper\StringHelper;
use CLSystems\PhalCMS\Lib\Helper\Text;
use CLSystems\PhalCMS\Lib\Helper\Uri;
use CLSystems\PhalCMS\Lib\Helper\State;
use CLSystems\PhalCMS\Lib\Helper\Language;
use CLSystems\PhalCMS\Lib\Helper\UcmItem as UcmItemHelper;
use CLSystems\PhalCMS\Lib\Mvc\Model\UcmItem as UcmItemModel;
use CLSystems\PhalCMS\Lib\Mvc\Model\Nested;
use CLSystems\PhalCMS\Lib\Mvc\Model\Translation;
use stdClass;
 
class DisplayController extends ControllerBase
{
  protected function notFound()
  {
    $this->dispatcher->forward(
      [
        'controller' => 'error',
        'action'     => 'show',
      ]
    );
 
    return false;
  }
 
  public function showAction()
  {
    /** @var UcmItemModel $ucmItem */
    $params = $this->dispatcher->getParams();
    
    if (isset($params[0]) && strpos($params[0], '?') !== 0)
    {
      return $this->notFound();
    }
 
    $language     = Language::getLanguageQuery();
    $queryBuilder = $this->modelsManager
      ->createBuilder()
      ->columns('id, context')
      ->from(UcmItemModel::class)
      ->where('state = :state:')
      ->andWhere('route = :route:');
    $bindParams   = [
      'route' => $this->dispatcher->getParam('path'),
      'state' => 'P',
    ];
 
    if ('*' !== $language)
    {
      // We're in multilingual mode
      $translation = Translation::findFirst(
        [
          'conditions' => 'translationId LIKE :translationId: AND translatedValue = :route:',
          'bind'       => [
            'translationId' => $language . '.ucm_items.id=%.route',
            'route'         => $bindParams['route'],
          ],
        ]
      );
 
      if ($translation && $translation->originalValue)
      {
        $bindParams['route'] = $translation->originalValue;
      }
    }
 
    $result = $queryBuilder->getQuery()
      ->execute($bindParams)
      ->getFirst();
 
    if (!$result || empty($result->context))
    {
      return $this->notFound();
    }
 
    /** @var UcmItemModel $targetItem */
    $context     = UcmItemHelper::prepareContext($result->context);
    $targetClass = 'CLSystems\\PhalCMS\\Lib\\Mvc\\Model\\' . $context;
 
    if (!class_exists($targetClass)
      || !($targetItem = $targetClass::findFirst(['conditions' => 'id = ' . $result->id]))
    )
    {
      return $this->notFound();
    }
 
    // Metadata
    $metadata                = new stdClass;
    $metadata->metaTitle     = $targetItem->t('metaTitle');
    $metadata->metaDesc      = $targetItem->t('metaDesc');
    $metadata->metaKeys      = $targetItem->t('metaKeys');
    $metadata->contentRights = Config::get('siteContentRights');
    $metadata->metaRobots    = Config::get('siteRobots');
 
    if (empty($metadata->metaTitle))
    {
      $metadata->metaTitle = $targetItem->t('title');
    }
 
    if ((int)$targetItem->parentId === 117) // Merken
    {
      $metadata->metaTitle = Text::_('discounts-at') . ' ' . $metadata->metaTitle;
    }
 
    if (empty($metadata->metaDesc))
    {
      $metadata->metaDesc = StringHelper::truncate($targetItem->t('description'), 160);
    }
 
    $parent = $targetItem->getParent();
 
    if ($targetItem instanceof Nested)
    {
      $rootId = $targetItem->getRootId();
    }
    elseif ($parent instanceof Nested)
    {
      $rootId = $parent->getRootId();
    }
    else
    {
      $rootId = 0;
    }
 
    $breadcrumbs = [];
 
    while ($parent)
    {
      if ((int) $parent->id !== $rootId)
      {
        $breadcrumbs[] = [
          'link'  => $parent->getLink(),
          'title' => $parent->t('title'),
        ];
      }
 
      $parent = $parent->getParent();
    }
 
    $itemAlias   = lcfirst($context);
    $breadcrumbs = array_reverse($breadcrumbs);
    array_unshift($breadcrumbs,
      [
        'link'  => Uri::home(),
        'title' => Text::_('home'),
      ]
    );
    $breadcrumbs[] = [
      'link'  => null,
      'title' => $targetItem->t('title'),
    ];
    $vars          = [
      'metadata'    => $metadata,
      'breadcrumbs' => $breadcrumbs,
      $itemAlias    => $targetItem,
    ];
 
    // Update hits
    $targetItem->hit();
    State::setMark('displayUcmItem', $targetItem);
    Event::trigger('beforeDisplayUcm' . $context, [$this, $targetItem]);
    $this->view->setVars($vars);
    $this->view->pick($context . '/Show');
  }
}
 | 
| #7 | Phalcon\Mvc\Application->handle 
 /var/www/html/discounts-n-coupons.com/src/app/Lib/CmsApplication.php (117) <?php
 
namespace CLSystems\PhalCMS\Lib;
 
use Phalcon\Autoload\Loader;
use Phalcon\Http\Response;
use Phalcon\Events\Event;
use Phalcon\Mvc\Application;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\View;
use CLSystems\PhalCMS\Lib\Helper\Asset;
use CLSystems\PhalCMS\Lib\Helper\Config;
use CLSystems\PhalCMS\Lib\Helper\Uri;
use CLSystems\PhalCMS\Lib\Helper\State;
use CLSystems\PhalCMS\Lib\Helper\User;
use CLSystems\PhalCMS\Lib\Helper\Event as EventHelper;
use CLSystems\PhalCMS\Lib\Mvc\View\ViewBase;
use CLSystems\Php\Registry;
use MatthiasMullie\Minify;
use Exception;
 
class CmsApplication extends Application
{
    public function execute()
    {
        try {
            $eventsManager = $this->di->getShared('eventsManager');
            $eventsManager->attach('application:beforeSendResponse', $this);
            $plugins = EventHelper::getPlugins();
            $systemEvents = [
                'application:beforeSendResponse',
                'dispatch:beforeExecuteRoute',
                'dispatch:beforeException',
                'dispatch:beforeDispatch',
                'dispatch:afterDispatch',
                'dispatch:afterInitialize',
            ];
 
            foreach ($plugins['System'] as $className => $config) {
                $handler = EventHelper::getHandler($className, $config);
 
                foreach ($systemEvents as $systemEvent) {
                    $eventsManager->attach($systemEvent, $handler);
                }
            }
 
            // Update view dirs
            define('TPL_SITE_PATH', APP_PATH . '/Tmpl/Site/' . Config::get('siteTemplate', 'PhalCMS'));
            define('TPL_ADMINISTRATOR_PATH', APP_PATH . '/Tmpl/Administrator');
            define('TPL_SYSTEM_PATH', APP_PATH . '/Tmpl/System');
 
            if (Uri::isClient('site')) {
                $viewDirs = [
                    TPL_SITE_PATH . '/Tmpl/',
                    TPL_SITE_PATH . '/',
                ];
            } else {
                $viewDirs = [
                    TPL_ADMINISTRATOR_PATH . '/',
                ];
            }
 
            foreach (['System', 'Cms'] as $plgGroup) {
                if (isset($plugins[$plgGroup])) {
                    /**
                     * @var string $pluginClass
                     * @var Registry $pluginConfig
                     */
 
 
                    foreach ($plugins[$plgGroup] as $pluginClass => $pluginConfig) {
                        $pluginName = $pluginConfig->get('manifest.name');
                        $pluginPath = PLUGIN_PATH . '/' . $plgGroup . '/' . $pluginName;
                        $psrPaths = [];
 
                        if (is_dir($pluginPath . '/Tmpl')) {
                            $viewDirs[] = $pluginPath . '/Tmpl/';
                        }
 
                        if (is_dir($pluginPath . '/Lib')) {
                            $psrPaths['CLSystems\\PhalCMS\\Lib'] = $pluginPath . '/Lib';
                        }
 
                        if (is_dir($pluginPath . '/Widget')) {
                            $psrPaths['CLSystems\\PhalCMS\\Widget'] = $pluginPath . '/Widget';
                        }
 
                        if ($psrPaths) {
                            (new Loader)
                                ->setNamespaces($psrPaths, true)
                                ->register();
                        }
                    }
                }
            }
 
            $viewDirs[] = TPL_SYSTEM_PATH . '/';
 
            /** @var ViewBase $view */
            $view = $this->di->getShared('view');
            $requestUri = $_SERVER['REQUEST_URI'];
 
            if (Config::get('siteOffline') === 'Y'
                && !User::getInstance()->access('super')
            ) {
                $this->view->setMainView('Offline/Index');
 
                if (strpos($requestUri, '/user/') !== 0) {
                    $requestUri = '';
                }
            } else {
                $view->setMainView('Index');
            }
 
            $view->setViewsDir($viewDirs);
            $this->setEventsManager($eventsManager);
            $this->handle($requestUri)->send();
        } catch (Exception $e) {
            if (true === DEVELOPMENT_MODE) {
                // Let Phalcon Debug catch this
                throw $e;
            }
 
            try {
                if (User::getInstance()->access('super')) {
                    State::setMark('exception', $e);
                }
 
                /**
                 * @var Dispatcher $dispatcher
                 * @var View $view
                 */
                $dispatcher = $this->getDI()->getShared('dispatcher');
                $dispatcher->setControllerName(Uri::isClient('administrator') ? 'admin_error' : 'error');
                $dispatcher->setActionName('show');
                $dispatcher->setParams(
                    [
                        'code'    => $e->getCode(),
                        'message' => $e->getMessage(),
                    ]
                );
 
                $view = $this->getDI()->getShared('view');
                $view->start();
                $dispatcher->dispatch();
                $view->render(
                    $dispatcher->getControllerName(),
                    $dispatcher->getActionName(),
                    $dispatcher->getParams()
                );
                $view->finish();
                echo $view->getContent();
            } catch (Exception $e2) {
                debugVar($e2->getMessage());
            }
        }
    }
 
    protected function getCompressor($type)
    {
        if ('css' === $type) {
            $compressor = new Minify\CSS;
            $compressor->setImportExtensions(
                [
                    'gif' => 'data:image/gif',
                    'png' => 'data:image/png',
                    'svg' => 'data:image/svg+xml',
                ]
            );
        } else {
            $compressor = new Minify\JS;
        }
 
        return $compressor;
    }
 
    protected function compressAssets()
    {
        $basePath = PUBLIC_PATH . '/assets';
        $assets = Factory::getService('assets');
 
        foreach (Asset::getFiles() as $type => $files) {
            $fileName = md5(implode(':', $files)) . '.' . $type;
            $filePath = $basePath . '/compressed/' . $fileName;
            $fileUri = DOMAIN . '/assets/compressed/' . $fileName . (DEVELOPMENT_MODE ? '?' . time() : '');
            $hasAsset = is_file($filePath);
            $ucType = ucfirst($type);
            $addFunc = 'add' . $ucType;
 
            if ($hasAsset && !DEVELOPMENT_MODE) {
                call_user_func_array([$assets, $addFunc], [$fileUri, false]);
                continue;
            }
 
            $compressor = self::getCompressor($type);
 
            foreach ($files as $file) {
                $compressor->add($file);
            }
 
            if (!is_dir($basePath . '/compressed/')) {
                mkdir($basePath . '/compressed/', 0777, true);
            }
 
            if ($compressor->minify($filePath)) {
//                echo $filePath;
                $chmodFile = chmod($filePath, 0777);
                if (false === $chmodFile)
                {
                    touch($filePath);
                    chmod($filePath, 0777);
                }
                call_user_func_array([$assets, $addFunc], [$fileUri, false]);
            }
 
            unset($compressor);
        }
    }
 
    public function beforeSendResponse(Event $event, CmsApplication $app, Response $response)
    {
        $request = $this->di->getShared('request');
 
        if ($request->isAjax()) {
            return;
        }
 
        /** @var Asset $assets */
        $this->compressAssets();
        $assets = $this->di->getShared('assets');
 
        // Compress CSS
        ob_start();
        $assets->outputCss();
        $assets->outputInlineCss();
        $content = str_replace('</head>', ob_get_clean() . '</head>', $response->getContent());
 
        // Compress JS
        ob_start();
        $assets->outputJs();
        $assets->outputInlineJs();
        $code = Asset::getCode() . ob_get_clean();
 
        // Extra code (in the footer)
        $content = str_replace('</body>', $code . '</body>', $content);
        $response->setContent($content);
    }
}
 |