Newscoop\Tools\Console\Command\AssignThemeCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
    {
        $resourceId = new \Newscoop\Service\Resource\ResourceId(__CLASS__);
        $themeService = $resourceId->getService(IThemeManagementService::NAME_1);
        $publicationService = $this->getContainer()->getService('content.publication');
        $publications = $publicationService->findAll();
        $themeToSet = (string) $input->getArgument('theme');
        if ($themeToSet != null) {
            foreach ($themeService->getUnassignedThemes() as $theme) {
                if (strpos($theme->getPath(), $themeToSet) !== false) {
                    foreach ($publications as $publication) {
                        $themeService->assignTheme($theme, $publication, true);
                    }
                }
            }
        } else {
            foreach ($themeService->getUnassignedThemes() as $theme) {
                foreach ($publications as $publication) {
                    $themeService->assignTheme($theme, $publication, true);
                }
            }
        }
    }
AssignThemeCommand