Generate the pagepart entity.

@throws \RuntimeException
964599
private function generatePagePartEntity()
    {
        if (file_exists($this->bundle->getPath() . '/Entity/PageParts/AbstractPagePart.php')) {
            $abstractClass = $this->bundle->getNamespace() . '\Entity\PageParts\AbstractPagePart';
        } else {
            $abstractClass = 'Kunstmaan\PagePartBundle\Entity\AbstractPagePart';
        }

        list($entityCode, $entityPath) = $this->generateEntity(
            $this->bundle,
            $this->entity,
            $this->fields,
            'PageParts',
            $this->prefix,
            $abstractClass
        );

        // Add some extra functions in the generated entity :s
        $params = array(
            'bundle' => $this->bundle->getName(),
            'pagepart' => $this->entity,
            'adminType' => '\\' . $this->bundle->getNamespace() . '\\Form\\PageParts\\' . $this->entity . 'AdminType',
            'isV4' => $this->isSymfony4(),
        );
        $extraCode = $this->render('/Entity/PageParts/ExtraFunctions.php', $params);

        $pos = strrpos($entityCode, "\n}");
        $trimmed = substr($entityCode, 0, $pos);
        $entityCode = $trimmed."\n\n".$extraCode."\n}\n";

        // Write class to filesystem
        $this->filesystem->mkdir(dirname($entityPath));
        file_put_contents($entityPath, $entityCode);

        $this->assistant->writeLine('Generating entity : <info>OK</info>');
    }
336992
public function getEntityService()
    {
        if (null === $this->entityService) {
            $entityServiceClass = $this->getEntityServiceClass();
            if (!class_exists($entityServiceClass)) {
                throw new \RuntimeException("Classe $entityServiceClass inexistente!");
            }
            $this->entityService = new $entityServiceClass();
            $this->entityService->setServiceLocator($this->getServiceLocator());
        }

        return $this->entityService;
    }
750367
protected function createComponentPagePrimaryModal() : object
    {
        $control = $this->IPage_PrimaryModal->create();

        $control->onSave[] = function () use ($control)
        {
            $this->getComponent('pageSummaryModal')->redrawControl('pageSummary');
            $this->getComponent('pageUrlModal')->redrawControl('urlSummary');
            $control->redrawControl('primaryForm');
        };

        return $control;
    }
56024
public function updateSeoByEntity(BasePage $page, $entity)
    {
        //if no entity is provided
        if ($entity === null) {
            //we look for the entity of the page
            if ($page->getBusinessEntity() !== null) {
                $entity = $page->getBusinessEntity();
            }
        }

        //only if we have an entity instance
        if ($entity !== null) {
            //the page seo
            $pageSeo = $page->getSeo();

            //the page seo might not exist yet
            if ($pageSeo !== null) {
                $businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);

                if ($businessEntity !== null) {
                    $businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');

                    //parse the business properties
                    foreach ($businessProperties as $businessProperty) {
                        //parse of seo attributes
                        foreach ($this->pageSeoAttributes as $seoAttribute) {
                            $value = $this->getEntityAttributeValue($pageSeo, $seoAttribute);
                            // we only update value if its a string and (if its a VBP or its a BP where value is not defined)
                            if (is_string($value) && ($page instanceof VirtualBusinessPage || ($page instanceof BusinessPage && $value == null))) {
                                $value = $this->parameterConverter->setBusinessPropertyInstance(
                                    $value,
                                    $businessProperty,
                                    $entity
                                );
                            }
                            $this->setEntityAttributeValue($pageSeo, $seoAttribute, $value);
                        }
                    }
                }
            }
        }
    }
1041310
public function getContent()
    {
        if (is_null($this->view)) {
            throw new RuntimeException('No view was set for the ViewResponse object.');
        }
        return $this->template->render($this->view, $this->viewdata);
    }
965128
public function newPartialAction()
    {
        $postParams = $this->params()->fromPost();
        $parentName = $postParams['parent_name'];
        $childName  = $postParams['child_name'];
        $parent     = $postParams['parent'];

        $parent = $this->getService($parentName)->find($parent);
        $child  = $this->getService($childName)->getModel();

        $child->setParent($parent);

        $partial  = $this->dash($childName);
        $viewVars = array(lcfirst($this->camel($childName)) => $child);
        return $this->partialView($partial, $viewVars);
    }
1371936
public function generateContent()
    {
        parent::generateContent();
        $out = "";
        $pageOrder = $this->pageOrder->getPageOrder();

        /** @var $page Page */
        foreach($pageOrder as $page){
            $id = $page->getID();
            $active = $this->currentPage === $page?"class='active'":"";
            $hidden = $page->isHidden()?'hidden':'';
            $out .= "
            <li $active $hidden>
                <a href='/$id'>{$page->getTitle()}</a>
            </li>
            ";
        }
        return "<ul>$out</ul>";
    }
1145366
public function page($page)
    {
        $page = (int)$page;

        if($page<0){
            throw new \RuntimeException('Invalid page specified', ResourceException::INVALID_PAGE);
        }

        $this->page = $page;

        return $this;
    }
271144
public function CreatePage()
	{
		$this->_myWords = $this->WordCollection();

		$this->_document = new XmlnukeDocument($this->_myWords->Value("TITLE", $this->_context->get("SERVER_NAME")),$this->_myWords->Value("ABSTRACT", $this->_context->get("SERVER_NAME")));

		if ($this->_link == "")
		{
			$this->goBack( $this->_myWords->Value("ERRORINVALID") );
		}
		elseif ($this->_action == "submit")
		{
			if (!XmlInputImageValidate::validateText($this->_context))
			{
					$this->goBack( $this->_myWords->Value("OBJECTIMAGEINVALID") );
			}
			else 
			{
				if ( ($this->_toName == "") || ($this->_toEmail == "") || ($this->_fromName == "") || ($this->_fromEmail == "") )
				{
					$this->goBack( $this->_myWords->Value("ERROR") );
				}
				else
				{
					$custMessage = $this->_myWords->Value("MESSAGE", array($this->_toName, $this->_toEmail, urldecode($this->_link), $this->_fromName, $this->_customMessage) );

					MailUtil::Mail
					(
						MailUtil::getEmailFromID(),
						MailUtil::getFullEmailName($this->_toName, $this->_toEmail),
						$this->_myWords->Value("SUBJECT"),
						"",
						$this->_fromEmail,$custMessage
					);

					$this->showMessage();
				}
			}
		}
		else
		{
			$this->showForm();
		}

		return $this->_document->generatePage();		
	}
666226
public function generate()
    {
        $this->dirctoryName = $this->getPluginDir($this->name);

        $pluginDir = $this->targetDir.'/'.$this->dirctoryName;

        if (file_exists($pluginDir)) {
            throw new \RuntimeException(sprintf('Unable to generate the plugin as the plugin directory "%s" exists.', $pluginDir));
        }

        $model = [
            'name' => $this->name,
            'classname' => $this->getClassname($this->name),
            'namespace' => $this->namespace,
            'namespace_psr4' => $this->getNamespacePsr4($this->namespace),
            'author' => $this->author,
            'email' => $this->email,
            'description' => $this->description,
            'license' => $this->license,
        ];

        $this->cleanFilesAffected();

        $pluginTemplateFile = 'plugin/plugin.php.twig';

        if (empty($this->commandName) === false) {
            $pluginTemplateFile = 'plugin/commandPlugin.php.twig';

            $model['command_name'] = $this->commandName;
            $model['command_description'] = $this->commandDescription;
            $model['command_help'] = $this->commandHelp;
        }

        $this->renderFile($pluginTemplateFile, $pluginDir.'/'.$this->getPluginFilename($this->name), $model);
        $this->renderFile('plugin/composer.json.twig', $pluginDir.'/composer.json', $model);

        $licenseFile = $this->getLicenseFile($this->license);

        if ($licenseFile) {
            $model = [
                'author' => $this->author,
            ];

            $this->renderFile($licenseFile, $pluginDir.'/LICENSE', $model);
        }

        return $this->getFilesAffected();
    }
1165649
protected function indexAction() {
        try {
            $entity = $this->generateEntity();

            $query = new Index($this->request, $entity, $this->getQueryWhiteList());
            $this->response->setHeader('link', $query->generateLinks());
            /** @var ResultSet|ModelInterface[] $entities */
            $entities = $query->getResultSet();
            $entities = $this->filterEntities($entities);
            $this->indexActionInternal($entities);
            if($this->hasFlag((new FlagEnum(FlagEnum::PAGE_COUNTS)))) {
                $this->getOutputObject()->PageCounts = $query->generatePageCounts();
            }
        } catch(Exception $e) {
            $this->handleError($e);
        } catch(ValidationException $e) {
            $this->handleValidationError($e);
        } catch(AclException $e) {
            $this->handleAclError($e);
        } catch(CatchableException $e) {
            $this->handleCatchableError($e);
        }
    }
155312
function Generate()
    {
        if ($this->cacher->MustUseCache())
        {
            $this->xml = $this->cacher->GetFromCache();
            return;
        }
        $this->AddAllPages();
        $this->xml = $this->sitemap->SaveXml();
        if ($this->cacher->MustStoreToCache())
        {
            $this->cacher->StoreToCache($this->xml);
        }
    }
1082809
public function generateEntities(array $parameters)
    {
        $relPath = '/Entity/Pages/';
        $sourceDir = $this->skeletonDir.$relPath;
        $targetDir = $this->bundle->getPath().$relPath;

        $this->renderSingleFile($sourceDir, $targetDir, 'HomePage.php', $parameters);
        $this->renderSingleFile($sourceDir, $targetDir, 'ContentPage.php', $parameters);
        $this->renderSingleFile($sourceDir, $targetDir, 'BehatTestPage.php', $parameters);

        if ($this->demosite) {
            $this->renderSingleFile($sourceDir, $targetDir, 'FormPage.php', $parameters);
            $this->renderSingleFile($sourceDir, $targetDir, 'SearchPage.php', $parameters);
        }

        if ($this->demosite) {
            $relPath = '/Entity/PageParts/';
            $sourceDir = $this->skeletonDir.$relPath;
            $targetDir = $this->bundle->getPath().$relPath;

            $this->renderSingleFile($sourceDir, $targetDir, 'PageBannerPagePart.php', $parameters);
            $this->renderSingleFile($sourceDir, $targetDir, 'ServicePagePart.php', $parameters);
            $this->renderSingleFile($sourceDir, $targetDir, 'UspPagePart.php', $parameters);
            $this->renderSingleFile($sourceDir, $targetDir, 'BikesListPagePart.php', $parameters);
        }

        if ($this->demosite) {
            $relPath = '/Entity/';
            $sourceDir = $this->skeletonDir.$relPath;
            $targetDir = $this->bundle->getPath().$relPath;

            $this->renderSingleFile($sourceDir, $targetDir, 'Bike.php', $parameters);
            $this->renderSingleFile($sourceDir, $targetDir, 'UspItem.php', $parameters);
        }

        $this->assistant->writeLine('Generating entities : <info>OK</info>');
    }
1193030
public function generateEntities(
        BundleInterface $bundle,
        array $parameters,
        OutputInterface $output
    ) {
        $dirPath = sprintf(
            '%s/Entity/Pages/',
            $bundle->getPath()
        );
        $fullSkeletonDir = sprintf(
            '%s/Entity/Pages/',
            $this->skeletonDir
        );

        try {
            $this->generateSkeletonBasedClass(
                $fullSkeletonDir,
                $dirPath,
                'SearchPage',
                $parameters
            );
        } catch (\Exception $error) {
            throw new \RuntimeException($error->getMessage());
        }

        $output->writeln('Generating entities : <info>OK</info>');
    }
1349735
public function generatePagePath()
    {
        $newPath = '';
        //if ($this->cParentID > 0) {
            /**
             * @var Connection
             */
            $db = \Database::connection();
            /* @var $em \Doctrine\ORM\EntityManager */
            $pathObject = $this->getCollectionPathObject();
            if (is_object($pathObject) && !$pathObject->isPagePathAutoGenerated()) {
                $pathString = $pathObject->getPagePath();
            } else {
                $pathString = $this->computeCanonicalPagePath();
            }
            if (!$pathString) {
                return ''; // We are allowed to pass in a blank path in the event of the home page being scanned.
            }
            // ensure that the path is unique
            $suffix = 0;
            $cID = ($this->getCollectionPointerOriginalID() > 0) ? $this->getCollectionPointerOriginalID() : $this->cID;
            $pagePathSeparator = Config::get('concrete.seo.page_path_separator');
            while (true) {
                $newPath = ($suffix === 0) ? $pathString : $pathString.$pagePathSeparator.$suffix;
                $result = $db->fetchColumn('select p.cID from PagePaths pp inner join Pages p on pp.cID = p.cID where pp.cPath = ? and pp.cID <> ? and p.siteTreeID = ?',
                    [
                        $newPath,
                        $cID,
                        $this->getSiteTreeID(),
                    ]
                );
                if (empty($result)) {
                    break;
                }
                ++$suffix;
            }
        //}

        return $newPath;
    }
912407
public function generatePageList()
    {
        $this->now = new DateTime();
        $siteTreeIDList = array_merge([0], $this->getSiteTreesIDList());
        $connection = $this->getConnection();
        $rs = $connection->executeQuery('select cID from Pages where siteTreeID is null or siteTreeID in (' . implode(', ', $siteTreeIDList) . ')');
        while (($cID = $rs->fetchColumn()) !== false) {
            $page = Page::getByID($cID, 'ACTIVE');
            if ($page && $this->canIncludePageInSitemap($page)) {
                yield $page;
            }
        }
    }
170346
public function buildAction() {
		$request = $this->getConsoleRequest();
		
		$types = [
			'datatable' => [
				'DataTable'],
			'abstract' => [
				'EntityAbstract'],
			'entity' => [
				'Entity'],
			'ALL' => [
				'DataTable',
				'EntityAbstract',
				'Entity']];
		
		$class = $request->getParam('class');
		$table = $request->getParam('table');
		$write = $request->getParam('write') || $request->getParam('w');
		
		$body = '';
		$classes = $types[$class];
		foreach ( $classes as $type ) {
			$getFunc = "get{$type}Code";
			$writeFunc = "write{$type}";
			
			$body .= "Generating $type for $table\n";
			
			if ($table == 'ALL') {
				$bm = new BuilderManager($this->getNameManager(true));
				
				while ( $bm->nextTable() ) {
					if ($write) {
						if ($bm->$writeFunc(true)) {
							$body .= "\tWritten {$bm->getTableName()}\n";
						}
					} else {
						$body .= "\n//TODO:NEWCLASS\n" . $bm->$getFunc();
					}
				}
			} else {
				$bm = new BuilderManager($this->getNameManager(true), $table);
				$code = $bm->$getFunc();
				
				if ($write) {
					if ($bm->$writeFunc(true)) {
						$body .= "\tWritten to file\n";
					}
				} else {
					$body .= $code;
				}
			}
			
			$body .= $this->getDeveloperFooter();
		}
		
		return "$body\n";
	}