<commit_before><?php
/*
 * This file is part of the AlphaLemon CMS Application and it is distributed
 * under the GPL LICENSE Version 2.0. To use this application you must leave
 * intact this copyright notice.
 *
 * Copyright (c) AlphaLemon <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * For extra documentation and help please visit http://www.alphalemon.com
 *
 * @license    GPL LICENSE Version 2.0
 *
 */

namespace AlphaLemon\AlphaLemonCmsBundle\Core\Deploy;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Finder\Finder;
use AlphaLemon\AlphaLemonCmsBundle\Core\PageTree\AlPageTree;
use AlphaLemon\ThemeEngineBundle\Core\Asset\AlAsset;
use AlphaLemon\AlphaLemonCmsBundle\Core\Exception\Content\General\InvalidParameterException;

/**
 * The object deputated to deploy the website from development (CMS) to production (the deploy bundle)
 *
 * @author alphalemon <<EMAIL>>
 */
abstract class AlDeployer implements AlDeployerInterface
{
    protected $container = null;
    protected $kernel = null;
    protected $deployBundle = null;
    protected $deployBundleAsset = null;
    protected $configDir = null;
    protected $assetsDir = null;
    protected $factoryRepository;

    /**
     * Save the page from an AlPageTree object
     *
     * @param  AlPageTree $pageTree
     * @return boolean
     */
    abstract protected function save(AlPageTree $pageTree);

    /**
     * Constructor
     *
     * @param  ContainerInterface        $container
     * @throws InvalidParameterException
     */
    public function  __construct(ContainerInterface $container)
    {
        $this->container = $container;
        $this->kernel = $this->container->get('kernel');
        $this->factoryRepository = $this->container->get('alpha_lemon_cms.factory_repository');
        $this->seoRepository = $this->factoryRepository->createRepository('Seo');
        $this->deployBundle = $this->container->getParameter('alpha_lemon_theme_engine.deploy_bundle');
        $this->deployBundleAsset = new AlAsset($this->kernel, $this->deployBundle);
        if (null === $this->deployBundleAsset->getWebFolderRealPath()) {
            throw new InvalidParameterException(sprintf('The %s cannot be located. Check it is correctly enabled in your AppKernel class', $this->deployBundle));
        }

        $this->configDir = $this->deployBundleAsset->getRealPath() . '/' . $this->container->getParameter('alpha_lemon_cms.deploy_bundle.config_dir');
        $this->assetsDir = $this->deployBundleAsset->getRealPath()  . '/' . $this->container->getParameter('alpha_lemon_cms.deploy_bundle.assets_base_dir');

        $this->uploadAssetsFullPath = $this->container->getParameter('alpha_lemon_cms.upload_assets_full_path');
        $this->uploadAssetsAbsolutePath = $this->container->getParameter('alpha_lemon_cms.upload_assets_full_path');
    }

    /**
     * Deploys all the website's pages
     */
    public function deploy()
    {
        $this->checkTargetFolders();
        $this->copyAssets();

        return ($this->generateRoutes() && $this->savePages()) ? true :false;
    }

    /**
     * Checks if the publisher folders exist and creates them when required
     */
    protected function checkTargetFolders()
    {
        $this->checkFolder($this->configDir);
        $this->checkFolder($this->assetsDir);
    }

    /**<commit_msg>fixed wrong parameter<commit_after><?php
/*
 * This file is part of the AlphaLemon CMS Application and it is distributed
 * under the GPL LICENSE Version 2.0. To use this application you must leave
 * intact this copyright notice.
 *
 * Copyright (c) AlphaLemon <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * For extra documentation and help please visit http://www.alphalemon.com
 *
 * @license    GPL LICENSE Version 2.0
 *
 */

namespace AlphaLemon\AlphaLemonCmsBundle\Core\Deploy;

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Finder\Finder;
use AlphaLemon\AlphaLemonCmsBundle\Core\PageTree\AlPageTree;
use AlphaLemon\ThemeEngineBundle\Core\Asset\AlAsset;
use AlphaLemon\AlphaLemonCmsBundle\Core\Exception\Content\General\InvalidParameterException;

/**
 * The object deputated to deploy the website from development (CMS) to production (the deploy bundle)
 *
 * @author alphalemon <<EMAIL>>
 */
abstract class AlDeployer implements AlDeployerInterface
{
    protected $container = null;
    protected $kernel = null;
    protected $deployBundle = null;
    protected $deployBundleAsset = null;
    protected $configDir = null;
    protected $assetsDir = null;
    protected $factoryRepository;

    /**
     * Save the page from an AlPageTree object
     *
     * @param  AlPageTree $pageTree
     * @return boolean
     */
    abstract protected function save(AlPageTree $pageTree);

    /**
     * Constructor
     *
     * @param  ContainerInterface        $container
     * @throws InvalidParameterException
     */
    public function  __construct(ContainerInterface $container)
    {
        $this->container = $container;
        $this->kernel = $this->container->get('kernel');
        $this->factoryRepository = $this->container->get('alpha_lemon_cms.factory_repository');
        $this->seoRepository = $this->factoryRepository->createRepository('Seo');
        $this->deployBundle = $this->container->getParameter('alpha_lemon_theme_engine.deploy_bundle');
        $this->deployBundleAsset = new AlAsset($this->kernel, $this->deployBundle);
        if (null === $this->deployBundleAsset->getWebFolderRealPath()) {
            throw new InvalidParameterException(sprintf('The %s cannot be located. Check it is correctly enabled in your AppKernel class', $this->deployBundle));
        }

        $this->configDir = $this->deployBundleAsset->getRealPath() . '/' . $this->container->getParameter('alpha_lemon_cms.deploy_bundle.config_dir');
        $this->assetsDir = $this->deployBundleAsset->getRealPath()  . '/' . $this->container->getParameter('alpha_lemon_cms.deploy_bundle.assets_base_dir');

        $this->uploadAssetsFullPath = $this->container->getParameter('alpha_lemon_cms.upload_assets_full_path');
        $this->uploadAssetsAbsolutePath = $this->container->getParameter('alpha_lemon_cms.upload_assets_absolute_path');
    }

    /**
     * Deploys all the website's pages
     */
    public function deploy()
    {
        $this->checkTargetFolders();
        $this->copyAssets();

        return ($this->generateRoutes() && $this->savePages()) ? true :false;
    }

    /**
     * Checks if the publisher folders exist and creates them when required
     */
    protected function checkTargetFolders()
    {
        $this->checkFolder($this->configDir);
        $this->checkFolder($this->assetsDir);
    }

    /**
{'fraction_non_alphanumeric': 0.11534090909090909, 'fraction_numerical': 0.0011363636363636363, 'mean_word_length': 3.6660039761431413, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '17685', 'n_tokens_mistral': 1983, 'n_tokens_neox': 1922, 'n_words': 456}