<commit_before><commit_msg>added sonata:block:debug command<commit_after><?php

/*
 * This file is part of the Sonata package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\PageBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;

class DebugBlocksCommand extends ContainerAwareCommand
{
    public function configure()
    {
        $this->setName('sonata:block:debug');
        $this->setDescription('Debug all blocks available, show default settings of each block');
    }

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $cmsManager     = $this->getManager();
        $pageManager    = $cmsManager->getPageManager();
        $blockServices  = $cmsManager->getBlockServices();

        foreach ($blockServices as $code => $service) {
            $settings = $service->getDefaultSettings();

            $output->writeln('');
            $output->writeln(sprintf('<info>>> %s</info>', $service->getName()));
            $output->writeln(sprintf('<comment>%s:</comment>', $code));

            foreach ($settings as $key => $val) {
                $output->writeln(sprintf('    %s:%s%s', $key, str_repeat(' ', 20 - strlen($key)), $val));
            }
        }
    }

    /**
     * @return \Sonata\PageBundle\CmsManager\CmsPageManager
     */
    public function getManager()
    {
        return $this->getContainer()->get('sonata.page.cms.page');
    }
}
{'fraction_non_alphanumeric': 0.14049586776859505, 'fraction_numerical': 0.0011019283746556473, 'mean_word_length': 3.2830188679245285, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '641620', 'n_tokens_mistral': 508, 'n_tokens_neox': 502, 'n_words': 109}