repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Victoire/victoire | Bundle/BlogBundle/Controller/ArticleController.php | ArticleController.newAction | public function newAction(Blog $blog)
{
try {
$article = new Article();
$article->setBlog($blog);
$form = $this->createForm(ArticleType::class, $article);
return new JsonResponse([
'html' => $this->container->get('templating')->render(
'VictoireBlogBundle:Article:new.html.twig',
[
'form' => $form->createView(),
'blogId' => $blog->getId(),
]
),
]);
} catch (NoResultException $e) {
return new JsonResponse([
'success' => false,
'message' => $e->getMessage(),
]);
}
} | php | public function newAction(Blog $blog)
{
try {
$article = new Article();
$article->setBlog($blog);
$form = $this->createForm(ArticleType::class, $article);
return new JsonResponse([
'html' => $this->container->get('templating')->render(
'VictoireBlogBundle:Article:new.html.twig',
[
'form' => $form->createView(),
'blogId' => $blog->getId(),
]
),
]);
} catch (NoResultException $e) {
return new JsonResponse([
'success' => false,
'message' => $e->getMessage(),
]);
}
} | [
"public",
"function",
"newAction",
"(",
"Blog",
"$",
"blog",
")",
"{",
"try",
"{",
"$",
"article",
"=",
"new",
"Article",
"(",
")",
";",
"$",
"article",
"->",
"setBlog",
"(",
"$",
"blog",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",... | Display a form to create a new Blog Article.
@Route("/new/{id}", name="victoire_blog_article_new")
@Method("GET")
@return JsonResponse | [
"Display",
"a",
"form",
"to",
"create",
"a",
"new",
"Blog",
"Article",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/ArticleController.php#L38-L60 | train |
Victoire/victoire | Bundle/BlogBundle/Controller/ArticleController.php | ArticleController.newPostAction | public function newPostAction(Request $request, Blog $blog)
{
$article = new Article();
$article->setBlog($blog);
$form = $this->createForm(ArticleType::class, $article);
$form->handleRequest($request);
if ($form->isValid()) {
$page = $this->get('victoire_blog.manager.article')->create(
$article,
$this->getUser()
);
$dispatcher = $this->get('event_dispatcher');
$event = new ArticleEvent($article);
$dispatcher->dispatch(VictoireBlogEvents::CREATE_ARTICLE, $event);
if (null === $response = $event->getResponse()) {
$response = new JsonResponse([
'success' => true,
'url' => $this->generateUrl('victoire_core_page_show', [
'_locale' => $request->getLocale(),
'url' => $page->getUrl(),
]),
]);
}
return $response;
}
return new JsonResponse([
'success' => false,
'message' => $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
'html' => $this->container->get('templating')->render(
'VictoireBlogBundle:Article:new.html.twig',
[
'form' => $form->createView(),
'blogId' => $blog->getId(),
]
),
]);
} | php | public function newPostAction(Request $request, Blog $blog)
{
$article = new Article();
$article->setBlog($blog);
$form = $this->createForm(ArticleType::class, $article);
$form->handleRequest($request);
if ($form->isValid()) {
$page = $this->get('victoire_blog.manager.article')->create(
$article,
$this->getUser()
);
$dispatcher = $this->get('event_dispatcher');
$event = new ArticleEvent($article);
$dispatcher->dispatch(VictoireBlogEvents::CREATE_ARTICLE, $event);
if (null === $response = $event->getResponse()) {
$response = new JsonResponse([
'success' => true,
'url' => $this->generateUrl('victoire_core_page_show', [
'_locale' => $request->getLocale(),
'url' => $page->getUrl(),
]),
]);
}
return $response;
}
return new JsonResponse([
'success' => false,
'message' => $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
'html' => $this->container->get('templating')->render(
'VictoireBlogBundle:Article:new.html.twig',
[
'form' => $form->createView(),
'blogId' => $blog->getId(),
]
),
]);
} | [
"public",
"function",
"newPostAction",
"(",
"Request",
"$",
"request",
",",
"Blog",
"$",
"blog",
")",
"{",
"$",
"article",
"=",
"new",
"Article",
"(",
")",
";",
"$",
"article",
"->",
"setBlog",
"(",
"$",
"blog",
")",
";",
"$",
"form",
"=",
"$",
"th... | Create a new Blog Article.
@Route("/new/{id}", name="victoire_blog_article_new_post")
@Method("POST")
@ParamConverter("blog", class="VictoireBlogBundle:Blog")
@return JsonResponse | [
"Create",
"a",
"new",
"Blog",
"Article",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/ArticleController.php#L71-L112 | train |
Victoire/victoire | Bundle/BlogBundle/Controller/ArticleController.php | ArticleController.settingsAction | public function settingsAction(Request $request, Article $article)
{
$form = $this->createForm(ArticleSettingsType::class, $article);
$form->handleRequest($request);
$response = $this->getNotPersistedSettingsResponse(
$form,
$article,
$request->query->get('novalidate', false)
);
return new JsonResponse($response);
} | php | public function settingsAction(Request $request, Article $article)
{
$form = $this->createForm(ArticleSettingsType::class, $article);
$form->handleRequest($request);
$response = $this->getNotPersistedSettingsResponse(
$form,
$article,
$request->query->get('novalidate', false)
);
return new JsonResponse($response);
} | [
"public",
"function",
"settingsAction",
"(",
"Request",
"$",
"request",
",",
"Article",
"$",
"article",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"ArticleSettingsType",
"::",
"class",
",",
"$",
"article",
")",
";",
"$",
"form",
"-... | Display a form to edit Blog Article settings.
@param Request $request
@param Article $article
@Route("/{id}/settings", name="victoire_blog_article_settings")
@Method("GET")
@ParamConverter("article", class="VictoireBlogBundle:Article")
@throws \Victoire\Bundle\ViewReferenceBundle\Exception\ViewReferenceNotFoundException
@return JsonResponse | [
"Display",
"a",
"form",
"to",
"edit",
"Blog",
"Article",
"settings",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/ArticleController.php#L129-L141 | train |
Victoire/victoire | Bundle/BlogBundle/Controller/ArticleController.php | ArticleController.settingsPostAction | public function settingsPostAction(Request $request, Article $article)
{
$form = $this->createForm(ArticleSettingsType::class, $article);
$form->handleRequest($request);
$novalidate = $request->query->get('novalidate', false);
if ($novalidate === false && $form->isValid()) {
$page = $this->get('victoire_blog.manager.article')->updateSettings(
$article,
$this->getUser()
);
$response = [
'success' => true,
'url' => $this->generateUrl('victoire_core_page_show', [
'_locale' => $page->getCurrentLocale(),
'url' => $page->getReference()->getUrl(),
]),
];
} else {
$response = $this->getNotPersistedSettingsResponse($form, $article, $novalidate);
}
return new JsonResponse($response);
} | php | public function settingsPostAction(Request $request, Article $article)
{
$form = $this->createForm(ArticleSettingsType::class, $article);
$form->handleRequest($request);
$novalidate = $request->query->get('novalidate', false);
if ($novalidate === false && $form->isValid()) {
$page = $this->get('victoire_blog.manager.article')->updateSettings(
$article,
$this->getUser()
);
$response = [
'success' => true,
'url' => $this->generateUrl('victoire_core_page_show', [
'_locale' => $page->getCurrentLocale(),
'url' => $page->getReference()->getUrl(),
]),
];
} else {
$response = $this->getNotPersistedSettingsResponse($form, $article, $novalidate);
}
return new JsonResponse($response);
} | [
"public",
"function",
"settingsPostAction",
"(",
"Request",
"$",
"request",
",",
"Article",
"$",
"article",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"ArticleSettingsType",
"::",
"class",
",",
"$",
"article",
")",
";",
"$",
"form",
... | Save Blog Article settings.
@param Request $request
@param Article $article
@Route("/{id}/settings", name="victoire_blog_article_settings_post")
@Method("POST")
@ParamConverter("article", class="VictoireBlogBundle:Article")
@throws \Victoire\Bundle\ViewReferenceBundle\Exception\ViewReferenceNotFoundException
@return JsonResponse | [
"Save",
"Blog",
"Article",
"settings",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/ArticleController.php#L158-L183 | train |
Victoire/victoire | Bundle/BlogBundle/Controller/ArticleController.php | ArticleController.deleteAction | public function deleteAction(Article $article)
{
$blogViewReference = $this->container->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $article->getBlog()->getId()]);
$this->get('victoire_blog.manager.article')->delete($article);
$message = $this->get('translator')->trans('victoire.blog.article.delete.success', [], 'victoire');
$this->congrat($message);
$response = [
'success' => true,
'url' => $this->generateUrl('victoire_core_page_show', [
'url' => $blogViewReference->getUrl(),
]
),
'message' => $message,
];
return new JsonResponse($response);
} | php | public function deleteAction(Article $article)
{
$blogViewReference = $this->container->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $article->getBlog()->getId()]);
$this->get('victoire_blog.manager.article')->delete($article);
$message = $this->get('translator')->trans('victoire.blog.article.delete.success', [], 'victoire');
$this->congrat($message);
$response = [
'success' => true,
'url' => $this->generateUrl('victoire_core_page_show', [
'url' => $blogViewReference->getUrl(),
]
),
'message' => $message,
];
return new JsonResponse($response);
} | [
"public",
"function",
"deleteAction",
"(",
"Article",
"$",
"article",
")",
"{",
"$",
"blogViewReference",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'victoire_view_reference.repository'",
")",
"->",
"getOneReferenceByParameters",
"(",
"[",
"'viewId'",
... | Delete a Blog Article.
@param Article $article
@Route("/{id}/delete", name="victoire_core_article_delete")
@ParamConverter("article", class="VictoireBlogBundle:Article")
@return JsonResponse | [
"Delete",
"a",
"Blog",
"Article",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/ArticleController.php#L195-L215 | train |
Victoire/victoire | Bundle/WidgetBundle/Repository/WidgetRepository.php | WidgetRepository.getAllForView | public function getAllForView(View $view)
{
//Get all WidgetMaps ids for this View
$widgetMapsIdsToSearch = [];
foreach ($view->getBuiltWidgetMap() as $widgetMaps) {
foreach ($widgetMaps as $widgetMap) {
$widgetMapsIdsToSearch[] = $widgetMap->getId();
}
}
return $this->createQueryBuilder('widget')
->join('widget.widgetMap', 'widgetMap')
->andWhere('widgetMap.id IN (:widgetMapsIds)')
->setParameter('widgetMapsIds', $widgetMapsIdsToSearch);
} | php | public function getAllForView(View $view)
{
//Get all WidgetMaps ids for this View
$widgetMapsIdsToSearch = [];
foreach ($view->getBuiltWidgetMap() as $widgetMaps) {
foreach ($widgetMaps as $widgetMap) {
$widgetMapsIdsToSearch[] = $widgetMap->getId();
}
}
return $this->createQueryBuilder('widget')
->join('widget.widgetMap', 'widgetMap')
->andWhere('widgetMap.id IN (:widgetMapsIds)')
->setParameter('widgetMapsIds', $widgetMapsIdsToSearch);
} | [
"public",
"function",
"getAllForView",
"(",
"View",
"$",
"view",
")",
"{",
"//Get all WidgetMaps ids for this View",
"$",
"widgetMapsIdsToSearch",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"view",
"->",
"getBuiltWidgetMap",
"(",
")",
"as",
"$",
"widgetMaps",
")",... | Get all Widgets for a given View.
@param View $view
@return QueryBuilder | [
"Get",
"all",
"Widgets",
"for",
"a",
"given",
"View",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Repository/WidgetRepository.php#L22-L36 | train |
Victoire/victoire | Bundle/WidgetBundle/Repository/WidgetRepository.php | WidgetRepository.findAllWidgetsForView | public function findAllWidgetsForView(View $view)
{
$qb = $this->getAllForView($view);
return $qb->getQuery()->getResult();
} | php | public function findAllWidgetsForView(View $view)
{
$qb = $this->getAllForView($view);
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"findAllWidgetsForView",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"getAllForView",
"(",
"$",
"view",
")",
";",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
... | Find all Widgets for a given View.
@param View $view
@return Widget[] | [
"Find",
"all",
"Widgets",
"for",
"a",
"given",
"View",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Repository/WidgetRepository.php#L45-L50 | train |
Victoire/victoire | Bundle/MediaBundle/Helper/RemoteVideo/RemoteVideoHandler.php | RemoteVideoHandler.endsWith | private function endsWith($str, $sub)
{
return substr($str, strlen($str) - strlen($sub)) === $sub;
} | php | private function endsWith($str, $sub)
{
return substr($str, strlen($str) - strlen($sub)) === $sub;
} | [
"private",
"function",
"endsWith",
"(",
"$",
"str",
",",
"$",
"sub",
")",
"{",
"return",
"substr",
"(",
"$",
"str",
",",
"strlen",
"(",
"$",
"str",
")",
"-",
"strlen",
"(",
"$",
"sub",
")",
")",
"===",
"$",
"sub",
";",
"}"
] | String helper.
@param string $str string
@param string $sub substring
@return bool | [
"String",
"helper",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/RemoteVideo/RemoteVideoHandler.php#L181-L184 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php | ViewReferenceRepository.findReferenceByView | public function findReferenceByView(View $view)
{
$referenceId = ViewReferenceHelper::generateViewReferenceId($view);
$reference = $this->getOneReferenceByParameters(['id' => $referenceId], false);
$transformer = $this->transformer->getViewReferenceTransformer(
(string) $reference['viewNamespace'], 'array'
);
return $transformer->transform($reference);
} | php | public function findReferenceByView(View $view)
{
$referenceId = ViewReferenceHelper::generateViewReferenceId($view);
$reference = $this->getOneReferenceByParameters(['id' => $referenceId], false);
$transformer = $this->transformer->getViewReferenceTransformer(
(string) $reference['viewNamespace'], 'array'
);
return $transformer->transform($reference);
} | [
"public",
"function",
"findReferenceByView",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"referenceId",
"=",
"ViewReferenceHelper",
"::",
"generateViewReferenceId",
"(",
"$",
"view",
")",
";",
"$",
"reference",
"=",
"$",
"this",
"->",
"getOneReferenceByParameters",
... | This method return a ViewReference for a View.
@param View $view
@throws \Exception
@return ViewReference | [
"This",
"method",
"return",
"a",
"ViewReference",
"for",
"a",
"View",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php#L39-L48 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php | ViewReferenceRepository.getReferencesByParameters | public function getReferencesByParameters(array $parameters, $transform = true, $keepChildren = false, $type = null)
{
$viewsReferences = [];
$refsId = $this->repository->getAllBy($parameters, $type);
$references = $this->repository->getResults($refsId);
foreach ($references as $reference) {
if ($transform === true) {
$transformViewReferenceFn = function ($parentViewReference) use (&$transformViewReferenceFn, $keepChildren) {
$transformer = ViewReferenceManager::findTransformerFromElement($parentViewReference);
$reference = $transformer->transform($parentViewReference);
if ($keepChildren) {
foreach ($this->repository->getChildren($parentViewReference['id']) as $child) {
$reference->addChild($transformViewReferenceFn($this->repository->findById($child)));
}
}
return $reference;
};
$reference = $transformViewReferenceFn($reference);
}
$viewsReferences[] = $reference;
}
return $viewsReferences;
} | php | public function getReferencesByParameters(array $parameters, $transform = true, $keepChildren = false, $type = null)
{
$viewsReferences = [];
$refsId = $this->repository->getAllBy($parameters, $type);
$references = $this->repository->getResults($refsId);
foreach ($references as $reference) {
if ($transform === true) {
$transformViewReferenceFn = function ($parentViewReference) use (&$transformViewReferenceFn, $keepChildren) {
$transformer = ViewReferenceManager::findTransformerFromElement($parentViewReference);
$reference = $transformer->transform($parentViewReference);
if ($keepChildren) {
foreach ($this->repository->getChildren($parentViewReference['id']) as $child) {
$reference->addChild($transformViewReferenceFn($this->repository->findById($child)));
}
}
return $reference;
};
$reference = $transformViewReferenceFn($reference);
}
$viewsReferences[] = $reference;
}
return $viewsReferences;
} | [
"public",
"function",
"getReferencesByParameters",
"(",
"array",
"$",
"parameters",
",",
"$",
"transform",
"=",
"true",
",",
"$",
"keepChildren",
"=",
"false",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"viewsReferences",
"=",
"[",
"]",
";",
"$",
"ref... | Get references matching with parameters.
@param $parameters
@param bool|true $transform
@param bool|false $keepChildren
@return array | [
"Get",
"references",
"matching",
"with",
"parameters",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php#L84-L110 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php | ViewReferenceRepository.getOneReferenceByParameters | public function getOneReferenceByParameters(array $parameters, $transform = true, $keepChildren = false)
{
$result = $this->getReferencesByParameters($parameters, $transform, $keepChildren);
if (count($result)) {
return $result[0];
}
} | php | public function getOneReferenceByParameters(array $parameters, $transform = true, $keepChildren = false)
{
$result = $this->getReferencesByParameters($parameters, $transform, $keepChildren);
if (count($result)) {
return $result[0];
}
} | [
"public",
"function",
"getOneReferenceByParameters",
"(",
"array",
"$",
"parameters",
",",
"$",
"transform",
"=",
"true",
",",
"$",
"keepChildren",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getReferencesByParameters",
"(",
"$",
"parameter... | Get first reference matching with parameters.
@param $parameters
@param bool|true $transform
@param bool|false $keepChildren
@return mixed | [
"Get",
"first",
"reference",
"matching",
"with",
"parameters",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/ViewReferenceRepository.php#L121-L127 | train |
Victoire/victoire | Bundle/CoreBundle/Controller/SwitchController.php | SwitchController.switchModeAction | public function switchModeAction($mode)
{
//the session
$session = $this->get('session');
//memorize that we are in edit mode
$session->set('victoire.edit_mode', $mode);
return new JsonResponse(
['response' => true]
);
} | php | public function switchModeAction($mode)
{
//the session
$session = $this->get('session');
//memorize that we are in edit mode
$session->set('victoire.edit_mode', $mode);
return new JsonResponse(
['response' => true]
);
} | [
"public",
"function",
"switchModeAction",
"(",
"$",
"mode",
")",
"{",
"//the session",
"$",
"session",
"=",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
";",
"//memorize that we are in edit mode",
"$",
"session",
"->",
"set",
"(",
"'victoire.edit_mode'",
","... | Method used to change of edit mode.
@param string $mode The mode
@Route("/mode/{mode}", name="victoire_core_switchMode", options={"expose"=true})
@return JsonResponse Empty response | [
"Method",
"used",
"to",
"change",
"of",
"edit",
"mode",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Controller/SwitchController.php#L25-L36 | train |
Victoire/victoire | Bundle/I18nBundle/Route/I18nRouteLoader.php | I18nRouteLoader.addHomepageRedirection | protected function addHomepageRedirection(&$collection)
{
$route = new Route(
'/',
[
'_controller' => 'FrameworkBundle:Redirect:urlRedirect',
'path' => '/'.$this->localeResolver->defaultLocale,
'permanent' => true,
]
);
$collection->add('victoire_redirect_homepage', $route);
} | php | protected function addHomepageRedirection(&$collection)
{
$route = new Route(
'/',
[
'_controller' => 'FrameworkBundle:Redirect:urlRedirect',
'path' => '/'.$this->localeResolver->defaultLocale,
'permanent' => true,
]
);
$collection->add('victoire_redirect_homepage', $route);
} | [
"protected",
"function",
"addHomepageRedirection",
"(",
"&",
"$",
"collection",
")",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
"'/'",
",",
"[",
"'_controller'",
"=>",
"'FrameworkBundle:Redirect:urlRedirect'",
",",
"'path'",
"=>",
"'/'",
".",
"$",
"this",
"-... | Add a homepage redirection route to the collection.
@param RouteCollection $collection The collection where to add the new route | [
"Add",
"a",
"homepage",
"redirection",
"route",
"to",
"the",
"collection",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/I18nBundle/Route/I18nRouteLoader.php#L89-L101 | train |
Victoire/victoire | Bundle/WidgetBundle/Generator/WidgetGenerator.php | WidgetGenerator.render | protected function render($template, $parameters)
{
$twig = $this->templating;
$twig->setLoader(new \Twig_Loader_Filesystem($this->skeletonDirs));
return $twig->render($template, $parameters);
} | php | protected function render($template, $parameters)
{
$twig = $this->templating;
$twig->setLoader(new \Twig_Loader_Filesystem($this->skeletonDirs));
return $twig->render($template, $parameters);
} | [
"protected",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"parameters",
")",
"{",
"$",
"twig",
"=",
"$",
"this",
"->",
"templating",
";",
"$",
"twig",
"->",
"setLoader",
"(",
"new",
"\\",
"Twig_Loader_Filesystem",
"(",
"$",
"this",
"->",
"skelet... | write WidgetBundle files. | [
"write",
"WidgetBundle",
"files",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Generator/WidgetGenerator.php#L124-L130 | train |
Victoire/victoire | Bundle/CoreBundle/Annotations/BusinessEntity.php | BusinessEntity.getWidgets | public function getWidgets()
{
if ($this->widgets === null || !array_key_exists('value', $this->widgets)) {
return;
}
//return an array, no matter one or many widget defined
if (count($this->widgets['value']) > 1) {
return $this->widgets['value'];
} else {
return [$this->widgets['value']];
}
} | php | public function getWidgets()
{
if ($this->widgets === null || !array_key_exists('value', $this->widgets)) {
return;
}
//return an array, no matter one or many widget defined
if (count($this->widgets['value']) > 1) {
return $this->widgets['value'];
} else {
return [$this->widgets['value']];
}
} | [
"public",
"function",
"getWidgets",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"widgets",
"===",
"null",
"||",
"!",
"array_key_exists",
"(",
"'value'",
",",
"$",
"this",
"->",
"widgets",
")",
")",
"{",
"return",
";",
"}",
"//return an array, no matter on... | Get widgets associated to this businessEntity.
@return null|array | [
"Get",
"widgets",
"associated",
"to",
"this",
"businessEntity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Annotations/BusinessEntity.php#L29-L41 | train |
Victoire/victoire | Bundle/CoreBundle/Menu/MenuBuilder.php | MenuBuilder.initBottomLeftNavbar | public function initBottomLeftNavbar()
{
$this->bottomLeftNavbar = $this->factory->createItem('root', [
'childrenAttributes' => [
'id' => 'v-footer-navbar-bottom-left',
],
]
);
$this->createDropdownMenuItem(
$this->getBottomLeftNavbar(),
'menu.additionals',
[
'dropdown' => true,
'childrenAttributes' => [
'class' => 'v-drop v-drop__menu',
'id' => 'footer-drop-navbar-left',
],
'attributes' => [
'class' => 'vic-dropdown',
'data-toggle' => 'vic-dropdown',
],
'linkAttributes' => [
'id' => 'v-additionals-drop',
'class' => 'v-btn v-btn--transparent v-drop-trigger--no-toggle',
'data-flag' => 'v-drop',
'data-position' => 'topout leftin',
'data-droptarget' => '#footer-drop-navbar-left',
],
'uri' => '#',
],
false
);
return $this->bottomLeftNavbar;
} | php | public function initBottomLeftNavbar()
{
$this->bottomLeftNavbar = $this->factory->createItem('root', [
'childrenAttributes' => [
'id' => 'v-footer-navbar-bottom-left',
],
]
);
$this->createDropdownMenuItem(
$this->getBottomLeftNavbar(),
'menu.additionals',
[
'dropdown' => true,
'childrenAttributes' => [
'class' => 'v-drop v-drop__menu',
'id' => 'footer-drop-navbar-left',
],
'attributes' => [
'class' => 'vic-dropdown',
'data-toggle' => 'vic-dropdown',
],
'linkAttributes' => [
'id' => 'v-additionals-drop',
'class' => 'v-btn v-btn--transparent v-drop-trigger--no-toggle',
'data-flag' => 'v-drop',
'data-position' => 'topout leftin',
'data-droptarget' => '#footer-drop-navbar-left',
],
'uri' => '#',
],
false
);
return $this->bottomLeftNavbar;
} | [
"public",
"function",
"initBottomLeftNavbar",
"(",
")",
"{",
"$",
"this",
"->",
"bottomLeftNavbar",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"'root'",
",",
"[",
"'childrenAttributes'",
"=>",
"[",
"'id'",
"=>",
"'v-footer-navbar-bottom-left'",
... | create bottom left menu defined in the contructor.
@return \Knp\Menu\ItemInterface | [
"create",
"bottom",
"left",
"menu",
"defined",
"in",
"the",
"contructor",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Menu/MenuBuilder.php#L64-L99 | train |
Victoire/victoire | Bundle/CoreBundle/Menu/MenuBuilder.php | MenuBuilder.createDropdownMenuItem | public function createDropdownMenuItem(ItemInterface $rootItem, $title, $attributes = [], $caret = true)
{
// Add child to dropdown, still normal KnpMenu usage
$options = array_merge(
[
'dropdown' => true,
'childrenAttributes' => [
'class' => 'vic-dropdown-menu',
],
'attributes' => [
'class' => 'vic-dropdown',
'data-toggle' => 'vic-dropdown',
],
'linkAttributes' => [
'class' => 'vic-dropdown-toggle',
'data-toggle' => 'vic-dropdown',
],
'uri' => '#',
],
$attributes
);
$menu = $rootItem->addChild($title, $options)->setExtra('caret', $caret);
return $menu;
} | php | public function createDropdownMenuItem(ItemInterface $rootItem, $title, $attributes = [], $caret = true)
{
// Add child to dropdown, still normal KnpMenu usage
$options = array_merge(
[
'dropdown' => true,
'childrenAttributes' => [
'class' => 'vic-dropdown-menu',
],
'attributes' => [
'class' => 'vic-dropdown',
'data-toggle' => 'vic-dropdown',
],
'linkAttributes' => [
'class' => 'vic-dropdown-toggle',
'data-toggle' => 'vic-dropdown',
],
'uri' => '#',
],
$attributes
);
$menu = $rootItem->addChild($title, $options)->setExtra('caret', $caret);
return $menu;
} | [
"public",
"function",
"createDropdownMenuItem",
"(",
"ItemInterface",
"$",
"rootItem",
",",
"$",
"title",
",",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"caret",
"=",
"true",
")",
"{",
"// Add child to dropdown, still normal KnpMenu usage",
"$",
"options",
"=",
... | Create the dropdown menu.
@param ItemInterface $rootItem
@param string $title
@param array $attributes
@param bool $caret
@return \Knp\Menu\ItemInterface | [
"Create",
"the",
"dropdown",
"menu",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Menu/MenuBuilder.php#L199-L224 | train |
Victoire/victoire | Bundle/BlogBundle/Entity/Article.php | Article.getPublishedAt | public function getPublishedAt()
{
if ($this->status == PageStatus::PUBLISHED && $this->publishedAt === null) {
$this->setPublishedAt($this->getCreatedAt());
}
return $this->publishedAt;
} | php | public function getPublishedAt()
{
if ($this->status == PageStatus::PUBLISHED && $this->publishedAt === null) {
$this->setPublishedAt($this->getCreatedAt());
}
return $this->publishedAt;
} | [
"public",
"function",
"getPublishedAt",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"==",
"PageStatus",
"::",
"PUBLISHED",
"&&",
"$",
"this",
"->",
"publishedAt",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setPublishedAt",
"(",
"$",
"this",
... | Get the published at property.
@return \DateTime | [
"Get",
"the",
"published",
"at",
"property",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Entity/Article.php#L191-L198 | train |
Victoire/victoire | Bundle/BlogBundle/Entity/Article.php | Article.getCategoryTitle | public function getCategoryTitle()
{
$this->categoryTitle = $this->category ? $this->category->getTitle() : null;
return $this->categoryTitle;
} | php | public function getCategoryTitle()
{
$this->categoryTitle = $this->category ? $this->category->getTitle() : null;
return $this->categoryTitle;
} | [
"public",
"function",
"getCategoryTitle",
"(",
")",
"{",
"$",
"this",
"->",
"categoryTitle",
"=",
"$",
"this",
"->",
"category",
"?",
"$",
"this",
"->",
"category",
"->",
"getTitle",
"(",
")",
":",
"null",
";",
"return",
"$",
"this",
"->",
"categoryTitle... | Get categoryTitle.
@return string | [
"Get",
"categoryTitle",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Entity/Article.php#L372-L377 | train |
Victoire/victoire | Bundle/BlogBundle/Entity/Article.php | Article.getPublishedAtString | public function getPublishedAtString()
{
setlocale(LC_TIME, 'fr_FR');
if ($this->publishedAt) {
return $this->publishedAtString = strftime('%d %B %Y', $this->publishedAt->getTimestamp());
} else {
return '';
}
} | php | public function getPublishedAtString()
{
setlocale(LC_TIME, 'fr_FR');
if ($this->publishedAt) {
return $this->publishedAtString = strftime('%d %B %Y', $this->publishedAt->getTimestamp());
} else {
return '';
}
} | [
"public",
"function",
"getPublishedAtString",
"(",
")",
"{",
"setlocale",
"(",
"LC_TIME",
",",
"'fr_FR'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"publishedAt",
")",
"{",
"return",
"$",
"this",
"->",
"publishedAtString",
"=",
"strftime",
"(",
"'%d %B %Y'",
... | Get publishedAtString.
@return string | [
"Get",
"publishedAtString",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Entity/Article.php#L384-L393 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Entity/WidgetMap.php | WidgetMap.setAction | public function setAction($action)
{
//test validity of the action
if ($action !== self::ACTION_CREATE && $action !== self::ACTION_OVERWRITE && $action !== self::ACTION_DELETE) {
throw new \Exception('The action of the widget map is not valid. Action: ['.$action.']');
}
$this->action = $action;
} | php | public function setAction($action)
{
//test validity of the action
if ($action !== self::ACTION_CREATE && $action !== self::ACTION_OVERWRITE && $action !== self::ACTION_DELETE) {
throw new \Exception('The action of the widget map is not valid. Action: ['.$action.']');
}
$this->action = $action;
} | [
"public",
"function",
"setAction",
"(",
"$",
"action",
")",
"{",
"//test validity of the action",
"if",
"(",
"$",
"action",
"!==",
"self",
"::",
"ACTION_CREATE",
"&&",
"$",
"action",
"!==",
"self",
"::",
"ACTION_OVERWRITE",
"&&",
"$",
"action",
"!==",
"self",
... | Set the action.
@param string $action
@throws \Exception The action is not valid | [
"Set",
"the",
"action",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Entity/WidgetMap.php#L158-L166 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Entity/WidgetMap.php | WidgetMap.getSubstituteForView | public function getSubstituteForView(View $view)
{
foreach ($this->getContextualSubstitutes() as $substitute) {
if ($substitute->getView() === $view) {
return $substitute;
}
while ($template = $view->getTemplate()) {
if ($substitute->getView() === $template) {
return $substitute;
}
}
}
} | php | public function getSubstituteForView(View $view)
{
foreach ($this->getContextualSubstitutes() as $substitute) {
if ($substitute->getView() === $view) {
return $substitute;
}
while ($template = $view->getTemplate()) {
if ($substitute->getView() === $template) {
return $substitute;
}
}
}
} | [
"public",
"function",
"getSubstituteForView",
"(",
"View",
"$",
"view",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getContextualSubstitutes",
"(",
")",
"as",
"$",
"substitute",
")",
"{",
"if",
"(",
"$",
"substitute",
"->",
"getView",
"(",
")",
"===",
... | Return substitute if used in View or in one of its inherited Template.
@return WidgetMap|null | [
"Return",
"substitute",
"if",
"used",
"in",
"View",
"or",
"in",
"one",
"of",
"its",
"inherited",
"Template",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Entity/WidgetMap.php#L417-L430 | train |
Victoire/victoire | Bundle/PageBundle/EventSubscriber/PageSubscriber.php | PageSubscriber.postLoad | public function postLoad(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof View) {
$entity->setReferences([$entity->getCurrentLocale() => new ViewReference($entity->getId())]);
$viewReferences = $this->viewReferenceRepository->getReferencesByParameters([
'viewId' => $entity->getId(),
'templateId' => $entity->getId(),
], true, false, 'OR');
foreach ($viewReferences as $viewReference) {
if ($viewReference->getLocale() === $entity->getCurrentLocale()) {
if ($entity instanceof WebViewInterface && $viewReference instanceof ViewReference) {
$entity->setReference($viewReference, $viewReference->getLocale());
$entity->setUrl($viewReference->getUrl());
} elseif ($entity instanceof BusinessTemplate) {
$entity->setReferences([
$entity->getCurrentLocale() => $this->viewReferenceBuilder->buildViewReference($entity, $eventArgs->getEntityManager()),
]);
}
}
}
}
} | php | public function postLoad(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof View) {
$entity->setReferences([$entity->getCurrentLocale() => new ViewReference($entity->getId())]);
$viewReferences = $this->viewReferenceRepository->getReferencesByParameters([
'viewId' => $entity->getId(),
'templateId' => $entity->getId(),
], true, false, 'OR');
foreach ($viewReferences as $viewReference) {
if ($viewReference->getLocale() === $entity->getCurrentLocale()) {
if ($entity instanceof WebViewInterface && $viewReference instanceof ViewReference) {
$entity->setReference($viewReference, $viewReference->getLocale());
$entity->setUrl($viewReference->getUrl());
} elseif ($entity instanceof BusinessTemplate) {
$entity->setReferences([
$entity->getCurrentLocale() => $this->viewReferenceBuilder->buildViewReference($entity, $eventArgs->getEntityManager()),
]);
}
}
}
}
} | [
"public",
"function",
"postLoad",
"(",
"LifecycleEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"entity",
"=",
"$",
"eventArgs",
"->",
"getEntity",
"(",
")",
";",
"if",
"(",
"$",
"entity",
"instanceof",
"View",
")",
"{",
"$",
"entity",
"->",
"setReferences",... | If entity is a View
it will find the ViewReference related to the current view and populate its url.
@param LifecycleEventArgs $eventArgs | [
"If",
"entity",
"is",
"a",
"View",
"it",
"will",
"find",
"the",
"ViewReference",
"related",
"to",
"the",
"current",
"view",
"and",
"populate",
"its",
"url",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/EventSubscriber/PageSubscriber.php#L128-L151 | train |
Victoire/victoire | Bundle/MediaBundle/Helper/MediaManager.php | MediaManager.getHandler | public function getHandler($media)
{
foreach ($this->handlers as $handler) {
if ($handler->canHandle($media)) {
return $handler;
}
}
return new FileHandler();
} | php | public function getHandler($media)
{
foreach ($this->handlers as $handler) {
if ($handler->canHandle($media)) {
return $handler;
}
}
return new FileHandler();
} | [
"public",
"function",
"getHandler",
"(",
"$",
"media",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"canHandle",
"(",
"$",
"media",
")",
")",
"{",
"return",
"$",
"handler",
... | Returns handler to handle the Media item which can handle the item. If no handler is found, it returns FileHandler.
@param Media $media
@return AbstractMediaHandler | [
"Returns",
"handler",
"to",
"handle",
"the",
"Media",
"item",
"which",
"can",
"handle",
"the",
"item",
".",
"If",
"no",
"handler",
"is",
"found",
"it",
"returns",
"FileHandler",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/MediaManager.php#L36-L45 | train |
Victoire/victoire | Bundle/MediaBundle/Helper/MediaManager.php | MediaManager.getHandlerForType | public function getHandlerForType($type)
{
foreach ($this->handlers as $handler) {
if ($handler->getType() == $type) {
return $handler;
}
}
return new FileHandler();
} | php | public function getHandlerForType($type)
{
foreach ($this->handlers as $handler) {
if ($handler->getType() == $type) {
return $handler;
}
}
return new FileHandler();
} | [
"public",
"function",
"getHandlerForType",
"(",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"getType",
"(",
")",
"==",
"$",
"type",
")",
"{",
"return",
"$",
... | Returns handler to handle the Media item based on the Type. If no handler is found, it returns FileHandler.
@param string $type
@return AbstractMediaHandler | [
"Returns",
"handler",
"to",
"handle",
"the",
"Media",
"item",
"based",
"on",
"the",
"Type",
".",
"If",
"no",
"handler",
"is",
"found",
"it",
"returns",
"FileHandler",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/MediaManager.php#L54-L63 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Builder/Chain/ViewReferenceTransformerChain.php | ViewReferenceTransformerChain.addTransformer | public function addTransformer(DataTransformerInterface $transformer, $viewNamespace, $outputFormat)
{
if (!array_key_exists($viewNamespace, $this->viewsReferenceTransformers)) {
$this->viewsReferenceTransformers[$viewNamespace] = [];
}
if (!array_key_exists($outputFormat, $this->viewsReferenceTransformers[$viewNamespace])) {
$this->viewsReferenceTransformers[$viewNamespace][$outputFormat] = null;
}
$this->viewsReferenceTransformers[$viewNamespace][$outputFormat] = $transformer;
} | php | public function addTransformer(DataTransformerInterface $transformer, $viewNamespace, $outputFormat)
{
if (!array_key_exists($viewNamespace, $this->viewsReferenceTransformers)) {
$this->viewsReferenceTransformers[$viewNamespace] = [];
}
if (!array_key_exists($outputFormat, $this->viewsReferenceTransformers[$viewNamespace])) {
$this->viewsReferenceTransformers[$viewNamespace][$outputFormat] = null;
}
$this->viewsReferenceTransformers[$viewNamespace][$outputFormat] = $transformer;
} | [
"public",
"function",
"addTransformer",
"(",
"DataTransformerInterface",
"$",
"transformer",
",",
"$",
"viewNamespace",
",",
"$",
"outputFormat",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"viewNamespace",
",",
"$",
"this",
"->",
"viewsReferenceTransf... | add a view Manager.
@param DataTransformerInterface $viewManager
@param string $viewNamespace | [
"add",
"a",
"view",
"Manager",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Builder/Chain/ViewReferenceTransformerChain.php#L25-L34 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Manager/WidgetMapManager.php | WidgetMapManager.insert | public function insert(Widget $widget, View $view, $slotId, $position, $widgetReference)
{
$quantum = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->findOneBy([
'view' => $view,
'slot' => $slotId,
'position' => $position,
'parent' => $widgetReference,
'action' => [
WidgetMap::ACTION_CREATE,
WidgetMap::ACTION_OVERWRITE,
],
]);
if ($quantum) {
$widget->setWidgetMap($quantum);
$view->addWidgetMap($quantum);
} else {
$parent = null;
if ($widgetReference) {
$parent = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->find($widgetReference);
}
//create the new widget map
$widgetMapEntry = new WidgetMap();
$widgetMapEntry->setAction(WidgetMap::ACTION_CREATE);
$widgetMapEntry->setSlot($slotId);
$widgetMapEntry->setPosition($position);
$widgetMapEntry->setParent($parent);
$widget->setWidgetMap($widgetMapEntry);
$view->addWidgetMap($widgetMapEntry);
}
} | php | public function insert(Widget $widget, View $view, $slotId, $position, $widgetReference)
{
$quantum = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->findOneBy([
'view' => $view,
'slot' => $slotId,
'position' => $position,
'parent' => $widgetReference,
'action' => [
WidgetMap::ACTION_CREATE,
WidgetMap::ACTION_OVERWRITE,
],
]);
if ($quantum) {
$widget->setWidgetMap($quantum);
$view->addWidgetMap($quantum);
} else {
$parent = null;
if ($widgetReference) {
$parent = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->find($widgetReference);
}
//create the new widget map
$widgetMapEntry = new WidgetMap();
$widgetMapEntry->setAction(WidgetMap::ACTION_CREATE);
$widgetMapEntry->setSlot($slotId);
$widgetMapEntry->setPosition($position);
$widgetMapEntry->setParent($parent);
$widget->setWidgetMap($widgetMapEntry);
$view->addWidgetMap($widgetMapEntry);
}
} | [
"public",
"function",
"insert",
"(",
"Widget",
"$",
"widget",
",",
"View",
"$",
"view",
",",
"$",
"slotId",
",",
"$",
"position",
",",
"$",
"widgetReference",
")",
"{",
"$",
"quantum",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'Victoir... | Insert a WidgetMap in a view at given position.
@param string $slotId | [
"Insert",
"a",
"WidgetMap",
"in",
"a",
"view",
"at",
"given",
"position",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php#L40-L71 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Manager/WidgetMapManager.php | WidgetMapManager.move | public function move(View $view, $sortedWidget)
{
/** @var WidgetMap $parentWidgetMap */
$parentWidgetMap = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->find((int) $sortedWidget['parentWidgetMap']);
$position = $sortedWidget['position'];
$slot = $sortedWidget['slot'];
/** @var WidgetMap $widgetMap */
$widgetMap = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->find((int) $sortedWidget['widgetMap']);
$originalParent = $widgetMap->getParent();
$originalPosition = $widgetMap->getPosition();
$children = $this->resolver->getChildren($widgetMap, $view);
$beforeChild = !empty($children[WidgetMap::POSITION_BEFORE]) ? $children[WidgetMap::POSITION_BEFORE] : null;
$afterChild = !empty($children[WidgetMap::POSITION_AFTER]) ? $children[WidgetMap::POSITION_AFTER] : null;
$parentWidgetMapChildren = $this->getChildrenByView($parentWidgetMap);
$widgetMap = $this->moveWidgetMap($view, $widgetMap, $parentWidgetMap, $position, $slot);
$this->moveChildren($view, $beforeChild, $afterChild, $originalParent, $originalPosition);
foreach ($parentWidgetMapChildren['views'] as $_view) {
if ($_view !== $view) {
if (isset($parentWidgetMapChildren['before'][$_view->getId()]) && $parentWidgetMapChildren['before'][$_view->getId()]->getPosition() == $widgetMap->getPosition()) {
$parentWidgetMapChildren['before'][$_view->getId()]->setParent($widgetMap);
}
if (isset($parentWidgetMapChildren['after'][$_view->getId()]) && $parentWidgetMapChildren['after'][$_view->getId()]->getPosition() == $widgetMap->getPosition()) {
$parentWidgetMapChildren['after'][$_view->getId()]->setParent($widgetMap);
}
}
}
} | php | public function move(View $view, $sortedWidget)
{
/** @var WidgetMap $parentWidgetMap */
$parentWidgetMap = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->find((int) $sortedWidget['parentWidgetMap']);
$position = $sortedWidget['position'];
$slot = $sortedWidget['slot'];
/** @var WidgetMap $widgetMap */
$widgetMap = $this->em->getRepository('VictoireWidgetMapBundle:WidgetMap')->find((int) $sortedWidget['widgetMap']);
$originalParent = $widgetMap->getParent();
$originalPosition = $widgetMap->getPosition();
$children = $this->resolver->getChildren($widgetMap, $view);
$beforeChild = !empty($children[WidgetMap::POSITION_BEFORE]) ? $children[WidgetMap::POSITION_BEFORE] : null;
$afterChild = !empty($children[WidgetMap::POSITION_AFTER]) ? $children[WidgetMap::POSITION_AFTER] : null;
$parentWidgetMapChildren = $this->getChildrenByView($parentWidgetMap);
$widgetMap = $this->moveWidgetMap($view, $widgetMap, $parentWidgetMap, $position, $slot);
$this->moveChildren($view, $beforeChild, $afterChild, $originalParent, $originalPosition);
foreach ($parentWidgetMapChildren['views'] as $_view) {
if ($_view !== $view) {
if (isset($parentWidgetMapChildren['before'][$_view->getId()]) && $parentWidgetMapChildren['before'][$_view->getId()]->getPosition() == $widgetMap->getPosition()) {
$parentWidgetMapChildren['before'][$_view->getId()]->setParent($widgetMap);
}
if (isset($parentWidgetMapChildren['after'][$_view->getId()]) && $parentWidgetMapChildren['after'][$_view->getId()]->getPosition() == $widgetMap->getPosition()) {
$parentWidgetMapChildren['after'][$_view->getId()]->setParent($widgetMap);
}
}
}
} | [
"public",
"function",
"move",
"(",
"View",
"$",
"view",
",",
"$",
"sortedWidget",
")",
"{",
"/** @var WidgetMap $parentWidgetMap */",
"$",
"parentWidgetMap",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'VictoireWidgetMapBundle:WidgetMap'",
")",
"->",
... | moves a widget in a view.
@param View $view
@param array $sortedWidget | [
"moves",
"a",
"widget",
"in",
"a",
"view",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php#L79-L111 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Manager/WidgetMapManager.php | WidgetMapManager.delete | public function delete(View $view, Widget $widget)
{
$this->builder->build($view);
$widgetMap = $widget->getWidgetMap();
$slot = $widgetMap->getSlot();
$originalParent = $widgetMap->getParent();
$originalPosition = $widgetMap->getPosition();
$children = $this->resolver->getChildren($widgetMap, $view);
$beforeChild = !empty($children[WidgetMap::POSITION_BEFORE]) ? $children[WidgetMap::POSITION_BEFORE] : null;
$afterChild = !empty($children[WidgetMap::POSITION_AFTER]) ? $children[WidgetMap::POSITION_AFTER] : null;
//we remove the widget from the current view
if ($widgetMap->getView() === $view) {
// If the widgetMap has substitutes, delete them or transform them in create mode
if (count($widgetMap->getAllSubstitutes()) > 0) {
foreach ($widgetMap->getAllSubstitutes() as $substitute) {
if ($substitute->getAction() === WidgetMap::ACTION_OVERWRITE) {
$substitute->setAction(WidgetMap::ACTION_CREATE);
$substitute->setReplaced(null);
} else {
$view->removeWidgetMap($widgetMap);
}
}
}
//remove the widget map from the slot
$view->removeWidgetMap($widgetMap);
} else {
//the widget is owned by another view (a parent)
//so we add a new widget map that indicates we delete this widget
$replaceWidgetMap = new WidgetMap();
$replaceWidgetMap->setAction(WidgetMap::ACTION_DELETE);
$replaceWidgetMap->addWidget($widget);
$replaceWidgetMap->setSlot($slot);
$replaceWidgetMap->setReplaced($widgetMap);
$view->addWidgetMap($replaceWidgetMap);
}
//Move children for current WidgetMap View
$this->moveChildren($view, $beforeChild, $afterChild, $originalParent, $originalPosition);
//Move children WidgetMap for children from other View
foreach ($widgetMap->getChildren() as $child) {
if ($child->getView() === $view || $child->getView()->getTemplate() === $view) {
$this->moveWidgetMap($child->getView(), $child, $originalParent, $originalPosition);
}
}
} | php | public function delete(View $view, Widget $widget)
{
$this->builder->build($view);
$widgetMap = $widget->getWidgetMap();
$slot = $widgetMap->getSlot();
$originalParent = $widgetMap->getParent();
$originalPosition = $widgetMap->getPosition();
$children = $this->resolver->getChildren($widgetMap, $view);
$beforeChild = !empty($children[WidgetMap::POSITION_BEFORE]) ? $children[WidgetMap::POSITION_BEFORE] : null;
$afterChild = !empty($children[WidgetMap::POSITION_AFTER]) ? $children[WidgetMap::POSITION_AFTER] : null;
//we remove the widget from the current view
if ($widgetMap->getView() === $view) {
// If the widgetMap has substitutes, delete them or transform them in create mode
if (count($widgetMap->getAllSubstitutes()) > 0) {
foreach ($widgetMap->getAllSubstitutes() as $substitute) {
if ($substitute->getAction() === WidgetMap::ACTION_OVERWRITE) {
$substitute->setAction(WidgetMap::ACTION_CREATE);
$substitute->setReplaced(null);
} else {
$view->removeWidgetMap($widgetMap);
}
}
}
//remove the widget map from the slot
$view->removeWidgetMap($widgetMap);
} else {
//the widget is owned by another view (a parent)
//so we add a new widget map that indicates we delete this widget
$replaceWidgetMap = new WidgetMap();
$replaceWidgetMap->setAction(WidgetMap::ACTION_DELETE);
$replaceWidgetMap->addWidget($widget);
$replaceWidgetMap->setSlot($slot);
$replaceWidgetMap->setReplaced($widgetMap);
$view->addWidgetMap($replaceWidgetMap);
}
//Move children for current WidgetMap View
$this->moveChildren($view, $beforeChild, $afterChild, $originalParent, $originalPosition);
//Move children WidgetMap for children from other View
foreach ($widgetMap->getChildren() as $child) {
if ($child->getView() === $view || $child->getView()->getTemplate() === $view) {
$this->moveWidgetMap($child->getView(), $child, $originalParent, $originalPosition);
}
}
} | [
"public",
"function",
"delete",
"(",
"View",
"$",
"view",
",",
"Widget",
"$",
"widget",
")",
"{",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
"$",
"view",
")",
";",
"$",
"widgetMap",
"=",
"$",
"widget",
"->",
"getWidgetMap",
"(",
")",
";",
"$... | Delete the widget from the view.
@param View $view
@param Widget $widget
@throws \Exception Widget map does not exists | [
"Delete",
"the",
"widget",
"from",
"the",
"view",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php#L121-L171 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Manager/WidgetMapManager.php | WidgetMapManager.moveChildren | public function moveChildren(View $view, $beforeChild, $afterChild, $originalParent, $originalPosition)
{
if ($beforeChild && $afterChild) {
$this->moveWidgetMap($view, $beforeChild, $originalParent, $originalPosition);
$child = $beforeChild;
while ($child->getChild(WidgetMap::POSITION_AFTER)) {
$child = $child->getChild(WidgetMap::POSITION_AFTER);
}
if ($afterChild->getId() !== $child->getId()) {
$this->moveWidgetMap($view, $afterChild, $child);
}
} elseif ($beforeChild) {
$this->moveWidgetMap($view, $beforeChild, $originalParent, $originalPosition);
} elseif ($afterChild) {
$this->moveWidgetMap($view, $afterChild, $originalParent, $originalPosition);
}
} | php | public function moveChildren(View $view, $beforeChild, $afterChild, $originalParent, $originalPosition)
{
if ($beforeChild && $afterChild) {
$this->moveWidgetMap($view, $beforeChild, $originalParent, $originalPosition);
$child = $beforeChild;
while ($child->getChild(WidgetMap::POSITION_AFTER)) {
$child = $child->getChild(WidgetMap::POSITION_AFTER);
}
if ($afterChild->getId() !== $child->getId()) {
$this->moveWidgetMap($view, $afterChild, $child);
}
} elseif ($beforeChild) {
$this->moveWidgetMap($view, $beforeChild, $originalParent, $originalPosition);
} elseif ($afterChild) {
$this->moveWidgetMap($view, $afterChild, $originalParent, $originalPosition);
}
} | [
"public",
"function",
"moveChildren",
"(",
"View",
"$",
"view",
",",
"$",
"beforeChild",
",",
"$",
"afterChild",
",",
"$",
"originalParent",
",",
"$",
"originalPosition",
")",
"{",
"if",
"(",
"$",
"beforeChild",
"&&",
"$",
"afterChild",
")",
"{",
"$",
"t... | If the moved widgetMap has someone at both his before and after, arbitrary move UP the before side
and find the first place after the before widgetMap hierarchy to place the after widgetMap.
@param View $view
@param $beforeChild
@param $afterChild
@param $originalParent
@param $originalPosition | [
"If",
"the",
"moved",
"widgetMap",
"has",
"someone",
"at",
"both",
"his",
"before",
"and",
"after",
"arbitrary",
"move",
"UP",
"the",
"before",
"side",
"and",
"find",
"the",
"first",
"place",
"after",
"the",
"before",
"widgetMap",
"hierarchy",
"to",
"place",... | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php#L206-L223 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Manager/WidgetMapManager.php | WidgetMapManager.cloneWidgetMap | protected function cloneWidgetMap(WidgetMap $widgetMap, View $view)
{
$originalWidgetMap = $widgetMap;
$widgetMap = clone $widgetMap;
$widgetMap->setId(null);
$widgetMap->setAction(WidgetMap::ACTION_OVERWRITE);
$widgetMap->setReplaced($originalWidgetMap);
$widgetMap->setView($view);
$view->addWidgetMap($widgetMap);
$this->em->persist($widgetMap);
return $widgetMap;
} | php | protected function cloneWidgetMap(WidgetMap $widgetMap, View $view)
{
$originalWidgetMap = $widgetMap;
$widgetMap = clone $widgetMap;
$widgetMap->setId(null);
$widgetMap->setAction(WidgetMap::ACTION_OVERWRITE);
$widgetMap->setReplaced($originalWidgetMap);
$widgetMap->setView($view);
$view->addWidgetMap($widgetMap);
$this->em->persist($widgetMap);
return $widgetMap;
} | [
"protected",
"function",
"cloneWidgetMap",
"(",
"WidgetMap",
"$",
"widgetMap",
",",
"View",
"$",
"view",
")",
"{",
"$",
"originalWidgetMap",
"=",
"$",
"widgetMap",
";",
"$",
"widgetMap",
"=",
"clone",
"$",
"widgetMap",
";",
"$",
"widgetMap",
"->",
"setId",
... | Create a copy of a WidgetMap in "overwrite" mode and insert it in the given view.
@param WidgetMap $widgetMap
@param View $view
@throws \Exception
@return WidgetMap | [
"Create",
"a",
"copy",
"of",
"a",
"WidgetMap",
"in",
"overwrite",
"mode",
"and",
"insert",
"it",
"in",
"the",
"given",
"view",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php#L235-L247 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Manager/WidgetMapManager.php | WidgetMapManager.moveWidgetMap | protected function moveWidgetMap(View $view, WidgetMap $widgetMap, $parent = false, $position = false, $slot = false)
{
if ($widgetMap->getView() !== $view) {
$widgetMap = $this->cloneWidgetMap($widgetMap, $view);
}
if ($parent !== false) {
if ($oldParent = $widgetMap->getParent()) {
$oldParent->removeChild($widgetMap);
}
$widgetMap->setParent($parent);
if ($parent) {
$parent->addChild($widgetMap);
}
}
if ($position !== false) {
$widgetMap->setPosition($position);
}
if ($slot !== false) {
$widgetMap->setSlot($slot);
}
return $widgetMap;
} | php | protected function moveWidgetMap(View $view, WidgetMap $widgetMap, $parent = false, $position = false, $slot = false)
{
if ($widgetMap->getView() !== $view) {
$widgetMap = $this->cloneWidgetMap($widgetMap, $view);
}
if ($parent !== false) {
if ($oldParent = $widgetMap->getParent()) {
$oldParent->removeChild($widgetMap);
}
$widgetMap->setParent($parent);
if ($parent) {
$parent->addChild($widgetMap);
}
}
if ($position !== false) {
$widgetMap->setPosition($position);
}
if ($slot !== false) {
$widgetMap->setSlot($slot);
}
return $widgetMap;
} | [
"protected",
"function",
"moveWidgetMap",
"(",
"View",
"$",
"view",
",",
"WidgetMap",
"$",
"widgetMap",
",",
"$",
"parent",
"=",
"false",
",",
"$",
"position",
"=",
"false",
",",
"$",
"slot",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"widgetMap",
"->",
... | Move given WidgetMap as a child of given parent at given position and slot.
@param View $view
@param WidgetMap $widgetMap
@param bool $parent
@param bool $position
@param bool $slot
@return WidgetMap | [
"Move",
"given",
"WidgetMap",
"as",
"a",
"child",
"of",
"given",
"parent",
"at",
"given",
"position",
"and",
"slot",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php#L260-L283 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Manager/WidgetMapManager.php | WidgetMapManager.getChildrenByView | protected function getChildrenByView(WidgetMap $widgetMap)
{
$beforeChilds = $widgetMap->getContextualChildren(WidgetMap::POSITION_BEFORE);
$afterChilds = $widgetMap->getContextualChildren(WidgetMap::POSITION_AFTER);
$childrenByView['views'] = [];
$childrenByView['before'] = [];
$childrenByView['after'] = [];
foreach ($beforeChilds as $beforeChild) {
$view = $beforeChild->getView();
$childrenByView['views'][] = $view;
$childrenByView['before'][$view->getId()] = $beforeChild;
}
foreach ($afterChilds as $afterChild) {
$view = $afterChild->getView();
$childrenByView['views'][] = $view;
$childrenByView['after'][$view->getId()] = $afterChild;
}
return $childrenByView;
} | php | protected function getChildrenByView(WidgetMap $widgetMap)
{
$beforeChilds = $widgetMap->getContextualChildren(WidgetMap::POSITION_BEFORE);
$afterChilds = $widgetMap->getContextualChildren(WidgetMap::POSITION_AFTER);
$childrenByView['views'] = [];
$childrenByView['before'] = [];
$childrenByView['after'] = [];
foreach ($beforeChilds as $beforeChild) {
$view = $beforeChild->getView();
$childrenByView['views'][] = $view;
$childrenByView['before'][$view->getId()] = $beforeChild;
}
foreach ($afterChilds as $afterChild) {
$view = $afterChild->getView();
$childrenByView['views'][] = $view;
$childrenByView['after'][$view->getId()] = $afterChild;
}
return $childrenByView;
} | [
"protected",
"function",
"getChildrenByView",
"(",
"WidgetMap",
"$",
"widgetMap",
")",
"{",
"$",
"beforeChilds",
"=",
"$",
"widgetMap",
"->",
"getContextualChildren",
"(",
"WidgetMap",
"::",
"POSITION_BEFORE",
")",
";",
"$",
"afterChilds",
"=",
"$",
"widgetMap",
... | Find return all the given WidgetMap children for each view where it's related.
@param WidgetMap $widgetMap
@return mixed | [
"Find",
"return",
"all",
"the",
"given",
"WidgetMap",
"children",
"for",
"each",
"view",
"where",
"it",
"s",
"related",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php#L292-L312 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.showAction | public function showAction(Request $request, Widget $widget, $viewReferenceId)
{
try {
$view = $this->get('victoire_page.page_helper')->findPageByParameters(['id' => $viewReferenceId]);
$this->get('victoire_widget_map.builder')->build($view);
$this->get('victoire_core.current_view')->setCurrentView($view);
$response = new JsonResponse([
'html' => $this->get('victoire_widget.widget_renderer')->render($widget, $view),
'update' => 'vic-widget-'.$widget->getId().'-container',
'success' => true,
]
);
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | php | public function showAction(Request $request, Widget $widget, $viewReferenceId)
{
try {
$view = $this->get('victoire_page.page_helper')->findPageByParameters(['id' => $viewReferenceId]);
$this->get('victoire_widget_map.builder')->build($view);
$this->get('victoire_core.current_view')->setCurrentView($view);
$response = new JsonResponse([
'html' => $this->get('victoire_widget.widget_renderer')->render($widget, $view),
'update' => 'vic-widget-'.$widget->getId().'-container',
'success' => true,
]
);
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | [
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
",",
"Widget",
"$",
"widget",
",",
"$",
"viewReferenceId",
")",
"{",
"try",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"get",
"(",
"'victoire_page.page_helper'",
")",
"->",
"findPageByParamet... | Show a widget.
@param Request $request
@param Widget $widget
@param int $viewReferenceId
@Route("/victoire-dcms-public/widget/show/{id}/{viewReferenceId}", name="victoire_core_widget_show", options={"expose"=true})
@ParamConverter("id", class="VictoireWidgetBundle:Widget")
@throws Exception
@return JsonResponse | [
"Show",
"a",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L40-L57 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.apiWidgetsAction | public function apiWidgetsAction($widgetIds, $viewReferenceId)
{
$view = $this->get('victoire_page.page_helper')->findPageByParameters(['id' => $viewReferenceId]);
$response = [];
$widgets = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireWidgetBundle:Widget')
->findBy(['id' => json_decode($widgetIds)]);
foreach ($widgets as $widget) {
$response[$widget->getId()] = $this->get('victoire_widget.widget_renderer')->render($widget, $view);
}
return new JsonResponse($response);
} | php | public function apiWidgetsAction($widgetIds, $viewReferenceId)
{
$view = $this->get('victoire_page.page_helper')->findPageByParameters(['id' => $viewReferenceId]);
$response = [];
$widgets = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireWidgetBundle:Widget')
->findBy(['id' => json_decode($widgetIds)]);
foreach ($widgets as $widget) {
$response[$widget->getId()] = $this->get('victoire_widget.widget_renderer')->render($widget, $view);
}
return new JsonResponse($response);
} | [
"public",
"function",
"apiWidgetsAction",
"(",
"$",
"widgetIds",
",",
"$",
"viewReferenceId",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"get",
"(",
"'victoire_page.page_helper'",
")",
"->",
"findPageByParameters",
"(",
"[",
"'id'",
"=>",
"$",
"viewReferen... | API widgets function.
@param string $widgetIds the widget ids to fetch in json
@param int $viewReferenceId
@throws \Victoire\Bundle\ViewReferenceBundle\Exception\ViewReferenceNotFoundException
@Route("/victoire-dcms-public/api/widgets/{widgetIds}/{viewReferenceId}", name="victoire_core_widget_apiWidgets", options={"expose"=true})
@return JsonResponse | [
"API",
"widgets",
"function",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L71-L83 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.newAction | public function newAction(Request $request, $type, $viewReference, $slot = null, $quantum = 'a')
{
try {
$view = $this->getViewByReferenceId($viewReference);
if (!$reference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['id' => $viewReference])) {
$reference = new ViewReference($viewReference);
}
$view->setReference($reference);
$position = $request->query->has('position') ? $request->query->get('position') : null;
$parentWidgetMap = $request->query->has('parentWidgetMap') ? $request->query->get('parentWidgetMap') : null;
$widgetData = $this->get('victoire_widget.widget_manager')->newWidget(
Widget::MODE_STATIC,
$type,
$slot,
$view,
$position,
$parentWidgetMap,
$quantum
);
$response = new JsonResponse([
'success' => true,
'html' => $widgetData['html'],
]);
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | php | public function newAction(Request $request, $type, $viewReference, $slot = null, $quantum = 'a')
{
try {
$view = $this->getViewByReferenceId($viewReference);
if (!$reference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['id' => $viewReference])) {
$reference = new ViewReference($viewReference);
}
$view->setReference($reference);
$position = $request->query->has('position') ? $request->query->get('position') : null;
$parentWidgetMap = $request->query->has('parentWidgetMap') ? $request->query->get('parentWidgetMap') : null;
$widgetData = $this->get('victoire_widget.widget_manager')->newWidget(
Widget::MODE_STATIC,
$type,
$slot,
$view,
$position,
$parentWidgetMap,
$quantum
);
$response = new JsonResponse([
'success' => true,
'html' => $widgetData['html'],
]);
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | [
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
",",
"$",
"type",
",",
"$",
"viewReference",
",",
"$",
"slot",
"=",
"null",
",",
"$",
"quantum",
"=",
"'a'",
")",
"{",
"try",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getViewByRefer... | New Widget.
@param Request $request
@param string $type The type of the widget we edit
@param int $viewReference The view reference where attach the widget
@param string $slot The slot where attach the widget
@param string $quantum The quantum letter used to avoid same form name
@throws Exception
@return JsonResponse
@Route("/victoire-dcms/widget/new/{type}/{viewReference}/{slot}/{quantum}", name="victoire_core_widget_new", defaults={"slot":null, "quantum":"a"}, options={"expose"=true}) | [
"New",
"Widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L99-L131 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.createAction | public function createAction($mode, $type, $viewReference, $slot = null, $position = null, $parentWidgetMap = null, $businessEntityId = null, $quantum = null)
{
try {
//services
$view = $this->getViewByReferenceId($viewReference);
$isNewPage = $view->getId() === null ? true : false;
if (!$reference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['id' => $viewReference])) {
$reference = new ViewReference($viewReference);
}
$view->setReference($reference);
$this->get('victoire_core.current_view')->setCurrentView($view);
$this->congrat($this->get('translator')->trans('victoire.success.message', [], 'victoire'));
$response = $this->get('widget_manager')->createWidget($mode, $type, $slot, $view, $businessEntityId, $position, $parentWidgetMap, $quantum);
if ($isNewPage) {
$response = new JsonResponse([
'success' => true,
'redirect' => $this->generateUrl(
'victoire_core_page_show',
[
'url' => $reference->getUrl(),
]
),
]);
} else {
$response = new JsonResponse($response);
}
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | php | public function createAction($mode, $type, $viewReference, $slot = null, $position = null, $parentWidgetMap = null, $businessEntityId = null, $quantum = null)
{
try {
//services
$view = $this->getViewByReferenceId($viewReference);
$isNewPage = $view->getId() === null ? true : false;
if (!$reference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['id' => $viewReference])) {
$reference = new ViewReference($viewReference);
}
$view->setReference($reference);
$this->get('victoire_core.current_view')->setCurrentView($view);
$this->congrat($this->get('translator')->trans('victoire.success.message', [], 'victoire'));
$response = $this->get('widget_manager')->createWidget($mode, $type, $slot, $view, $businessEntityId, $position, $parentWidgetMap, $quantum);
if ($isNewPage) {
$response = new JsonResponse([
'success' => true,
'redirect' => $this->generateUrl(
'victoire_core_page_show',
[
'url' => $reference->getUrl(),
]
),
]);
} else {
$response = new JsonResponse($response);
}
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | [
"public",
"function",
"createAction",
"(",
"$",
"mode",
",",
"$",
"type",
",",
"$",
"viewReference",
",",
"$",
"slot",
"=",
"null",
",",
"$",
"position",
"=",
"null",
",",
"$",
"parentWidgetMap",
"=",
"null",
",",
"$",
"businessEntityId",
"=",
"null",
... | Create a widget.
This action needs 2 routes to handle the presence or not of "businessEntityId" and 'parentWidgetMap'
that are both integers but "businessEntityId" present only in !static mode.
@param string $type The type of the widget we edit
@param int $viewReference The view reference where attach the widget
@param string $slot The slot where attach the widget
@param string $businessEntityId The BusinessEntity::id (can be null if the submitted form is in static mode)
@throws Exception
@return Response|JsonResponse
@Route("/victoire-dcms/widget/create/static/{type}/{viewReference}/{slot}/{quantum}/{position}/{parentWidgetMap}", name="victoire_core_widget_create_static", defaults={"mode":"static", "slot":null, "businessEntityId":null, "position":null, "parentWidgetMap":null, "_format": "json", "quantum":"a"})
@Route("/victoire-dcms/widget/create/{mode}/{type}/{viewReference}/{slot}/{quantum}/{businessEntityId}/{position}/{parentWidgetMap}", name="victoire_core_widget_create", defaults={"slot":null, "businessEntityId":null, "position":null, "parentWidgetMap":null, "_format": "json", "quantum":"a"}) | [
"Create",
"a",
"widget",
".",
"This",
"action",
"needs",
"2",
"routes",
"to",
"handle",
"the",
"presence",
"or",
"not",
"of",
"businessEntityId",
"and",
"parentWidgetMap",
"that",
"are",
"both",
"integers",
"but",
"businessEntityId",
"present",
"only",
"in",
"... | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L149-L186 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.stylizeAction | public function stylizeAction(Request $request, Widget $widget, $viewReference, $quantum = null)
{
$view = $this->getViewByReferenceId($viewReference);
$this->get('victoire_widget_map.builder')->build($view);
try {
$widgetView = $widget->getWidgetMap()->getView();
} catch (WidgetMapNotFoundException $e) {
return new JsonResponse([
'success' => false,
'message' => $e->getMessage(),
]);
}
if (!$view instanceof \Victoire\Bundle\TemplateBundle\Entity\Template) {
$widgetViewReference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $view->getId()]);
$widgetView->setReference($widgetViewReference);
}
$this->get('victoire_core.current_view')->setCurrentView($view);
try {
$response = $this->get('widget_manager')->editWidgetStyle(
$request,
$widget,
$view,
$viewReference,
$quantum
);
$this->congrat($this->get('translator')->trans('victoire.success.message', [], 'victoire'));
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | php | public function stylizeAction(Request $request, Widget $widget, $viewReference, $quantum = null)
{
$view = $this->getViewByReferenceId($viewReference);
$this->get('victoire_widget_map.builder')->build($view);
try {
$widgetView = $widget->getWidgetMap()->getView();
} catch (WidgetMapNotFoundException $e) {
return new JsonResponse([
'success' => false,
'message' => $e->getMessage(),
]);
}
if (!$view instanceof \Victoire\Bundle\TemplateBundle\Entity\Template) {
$widgetViewReference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $view->getId()]);
$widgetView->setReference($widgetViewReference);
}
$this->get('victoire_core.current_view')->setCurrentView($view);
try {
$response = $this->get('widget_manager')->editWidgetStyle(
$request,
$widget,
$view,
$viewReference,
$quantum
);
$this->congrat($this->get('translator')->trans('victoire.success.message', [], 'victoire'));
} catch (Exception $ex) {
$response = $this->getJsonReponseFromException($ex);
}
return $response;
} | [
"public",
"function",
"stylizeAction",
"(",
"Request",
"$",
"request",
",",
"Widget",
"$",
"widget",
",",
"$",
"viewReference",
",",
"$",
"quantum",
"=",
"null",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getViewByReferenceId",
"(",
"$",
"viewReferenc... | Stylize a widget.
@param Request $request
@param Widget $widget
@param int $viewReference
@param string $quantum
@throws Exception
@return JsonResponse
@Route("/victoire-dcms/widget/stylize/{id}/{viewReference}/{quantum}/", name="victoire_core_widget_stylize", defaults={"quantum":"a"}, options={"expose"=true}) | [
"Stylize",
"a",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L248-L285 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.deleteAction | public function deleteAction(Widget $widget, $viewReference)
{
$view = $this->getViewByReferenceId($viewReference);
try {
$widgetId = $widget->getId();
$this->get('widget_manager')->deleteWidget($widget, $view);
return new JsonResponse([
'success' => true,
'message' => $this->get('translator')->trans('victoire_widget.delete.success', [], 'victoire'),
'widgetId' => $widgetId,
]
);
} catch (Exception $ex) {
return $this->getJsonReponseFromException($ex);
}
} | php | public function deleteAction(Widget $widget, $viewReference)
{
$view = $this->getViewByReferenceId($viewReference);
try {
$widgetId = $widget->getId();
$this->get('widget_manager')->deleteWidget($widget, $view);
return new JsonResponse([
'success' => true,
'message' => $this->get('translator')->trans('victoire_widget.delete.success', [], 'victoire'),
'widgetId' => $widgetId,
]
);
} catch (Exception $ex) {
return $this->getJsonReponseFromException($ex);
}
} | [
"public",
"function",
"deleteAction",
"(",
"Widget",
"$",
"widget",
",",
"$",
"viewReference",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getViewByReferenceId",
"(",
"$",
"viewReference",
")",
";",
"try",
"{",
"$",
"widgetId",
"=",
"$",
"widget",
"-... | Delete a Widget.
@param Widget $widget The widget to delete
@param int $viewReference The current view
@throws Exception
@return JsonResponse response
@Route("/victoire-dcms/widget/delete/{id}/{viewReference}", name="victoire_core_widget_delete", defaults={"_format": "json"}) | [
"Delete",
"a",
"Widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L298-L315 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.deleteBulkAction | public function deleteBulkAction(Widget $widget, $viewReference)
{
$view = $this->getViewByReferenceId($viewReference);
try {
$widgets = $widget->getWidgetMap()->getWidgets();
foreach ($widgets as $widget) {
$this->get('widget_manager')->deleteWidget($widget, $view);
}
return new JsonResponse([
'success' => true,
'message' => $this->get('translator')->trans('victoire_widget.delete.success', [], 'victoire'),
]
);
} catch (Exception $ex) {
return $this->getJsonReponseFromException($ex);
}
} | php | public function deleteBulkAction(Widget $widget, $viewReference)
{
$view = $this->getViewByReferenceId($viewReference);
try {
$widgets = $widget->getWidgetMap()->getWidgets();
foreach ($widgets as $widget) {
$this->get('widget_manager')->deleteWidget($widget, $view);
}
return new JsonResponse([
'success' => true,
'message' => $this->get('translator')->trans('victoire_widget.delete.success', [], 'victoire'),
]
);
} catch (Exception $ex) {
return $this->getJsonReponseFromException($ex);
}
} | [
"public",
"function",
"deleteBulkAction",
"(",
"Widget",
"$",
"widget",
",",
"$",
"viewReference",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getViewByReferenceId",
"(",
"$",
"viewReference",
")",
";",
"try",
"{",
"$",
"widgets",
"=",
"$",
"widget",
... | Delete a Widget quantum.
@param Widget $widget The widget to delete
@param int $viewReference The current view
@throws Exception
@return JsonResponse response
@Route("/victoire-dcms/widget/delete/quantum/{id}/{viewReference}", name="victoire_core_widget_delete_bulk", defaults={"_format": "json"}) | [
"Delete",
"a",
"Widget",
"quantum",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L328-L347 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.unlinkAction | public function unlinkAction($id, $viewReference)
{
$view = $this->getViewByReferenceId($viewReference);
try {
$this->get('victoire_widget.widget_helper')->deleteById($id);
$this->get('doctrine.orm.entity_manager')->flush();
if ($view instanceof Template) {
$redirect = $this->generateUrl('victoire_template_show', ['id' => $view->getId()]);
} elseif ($view instanceof BusinessTemplate) {
$redirect = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
} else {
$viewReference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $view->getId()]);
$redirect = $this->generateUrl('victoire_core_page_show', [
'url' => $viewReference->getUrl(),
]);
}
return new JsonResponse([
'success' => true,
'redirect' => $redirect,
]);
} catch (Exception $ex) {
return $this->getJsonReponseFromException($ex);
}
} | php | public function unlinkAction($id, $viewReference)
{
$view = $this->getViewByReferenceId($viewReference);
try {
$this->get('victoire_widget.widget_helper')->deleteById($id);
$this->get('doctrine.orm.entity_manager')->flush();
if ($view instanceof Template) {
$redirect = $this->generateUrl('victoire_template_show', ['id' => $view->getId()]);
} elseif ($view instanceof BusinessTemplate) {
$redirect = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
} else {
$viewReference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $view->getId()]);
$redirect = $this->generateUrl('victoire_core_page_show', [
'url' => $viewReference->getUrl(),
]);
}
return new JsonResponse([
'success' => true,
'redirect' => $redirect,
]);
} catch (Exception $ex) {
return $this->getJsonReponseFromException($ex);
}
} | [
"public",
"function",
"unlinkAction",
"(",
"$",
"id",
",",
"$",
"viewReference",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getViewByReferenceId",
"(",
"$",
"viewReference",
")",
";",
"try",
"{",
"$",
"this",
"->",
"get",
"(",
"'victoire_widget.widget... | Unlink a Widget by id
-> used to unlink an invalid widget after a bad widget unplug.
@param int $id The widgetId to unlink
@param int $viewReference The current viewReference
@throws Exception
@return JsonResponse response
@Route("/victoire-dcms/widget/unlink/{id}/{viewReference}", name="victoire_core_widget_unlink", defaults={"_format": "json"}, options={"expose"=true}) | [
"Unlink",
"a",
"Widget",
"by",
"id",
"-",
">",
"used",
"to",
"unlink",
"an",
"invalid",
"widget",
"after",
"a",
"bad",
"widget",
"unplug",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L361-L389 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetController.php | WidgetController.getJsonReponseFromException | protected function getJsonReponseFromException(Exception $ex)
{
$authorizationChecker = $this->get('security.authorization_checker');
$logger = $this->get('logger');
//can we see the debug
$isDebugAllowed = $authorizationChecker->isGranted('ROLE_VICTOIRE_PAGE_DEBUG') ? true : $this->get('kernel')->isDebug();
//whatever is the exception, we log it
$logger->error($ex->getMessage());
$logger->error($ex->getTraceAsString());
if ($isDebugAllowed) {
throw $ex;
} else {
//translate the message
$translator = $this->get('translator');
//get the translated message
$message = $translator->trans('error_occured', [], 'victoire');
$response = new JsonResponse(
[
'success' => false,
'message' => $message,
]
);
}
return $response;
} | php | protected function getJsonReponseFromException(Exception $ex)
{
$authorizationChecker = $this->get('security.authorization_checker');
$logger = $this->get('logger');
//can we see the debug
$isDebugAllowed = $authorizationChecker->isGranted('ROLE_VICTOIRE_PAGE_DEBUG') ? true : $this->get('kernel')->isDebug();
//whatever is the exception, we log it
$logger->error($ex->getMessage());
$logger->error($ex->getTraceAsString());
if ($isDebugAllowed) {
throw $ex;
} else {
//translate the message
$translator = $this->get('translator');
//get the translated message
$message = $translator->trans('error_occured', [], 'victoire');
$response = new JsonResponse(
[
'success' => false,
'message' => $message,
]
);
}
return $response;
} | [
"protected",
"function",
"getJsonReponseFromException",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"authorizationChecker",
"=",
"$",
"this",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
";",
"$",
"logger",
"=",
"$",
"this",
"->",
"get",
"(",
"'l... | Get the json response by the exception and the current user.
@param Exception $ex
@throws Exception
@return JsonResponse | [
"Get",
"the",
"json",
"response",
"by",
"the",
"exception",
"and",
"the",
"current",
"user",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetController.php#L457-L487 | train |
Victoire/victoire | Bundle/WidgetBundle/Twig/LinkExtension.php | LinkExtension.isVicLinkActive | public function isVicLinkActive(Link $link)
{
return $this->request && ($this->request->getRequestUri() == $this->victoireLinkUrl($link->getParameters(), false));
} | php | public function isVicLinkActive(Link $link)
{
return $this->request && ($this->request->getRequestUri() == $this->victoireLinkUrl($link->getParameters(), false));
} | [
"public",
"function",
"isVicLinkActive",
"(",
"Link",
"$",
"link",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"&&",
"(",
"$",
"this",
"->",
"request",
"->",
"getRequestUri",
"(",
")",
"==",
"$",
"this",
"->",
"victoireLinkUrl",
"(",
"$",
"link",
... | Check if a given Link is active for current request.
@param Link $link
@return bool | [
"Check",
"if",
"a",
"given",
"Link",
"is",
"active",
"for",
"current",
"request",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Twig/LinkExtension.php#L298-L301 | train |
Victoire/victoire | Bundle/WidgetBundle/Twig/LinkExtension.php | LinkExtension.addAttr | protected function addAttr($label, $value, &$attr)
{
if (!isset($attr[$label])) {
$attr[$label] = '';
} else {
$attr[$label] .= ' ';
}
$attr[$label] .= $value;
return $this;
} | php | protected function addAttr($label, $value, &$attr)
{
if (!isset($attr[$label])) {
$attr[$label] = '';
} else {
$attr[$label] .= ' ';
}
$attr[$label] .= $value;
return $this;
} | [
"protected",
"function",
"addAttr",
"(",
"$",
"label",
",",
"$",
"value",
",",
"&",
"$",
"attr",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"attr",
"[",
"$",
"label",
"]",
")",
")",
"{",
"$",
"attr",
"[",
"$",
"label",
"]",
"=",
"''",
";",
... | Add a given attribute to given attributes.
@param string $label
@param string $value
@param array $attr The current attributes array
@return LinkExtension | [
"Add",
"a",
"given",
"attribute",
"to",
"given",
"attributes",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Twig/LinkExtension.php#L312-L322 | train |
Victoire/victoire | Bundle/BlogBundle/Entity/BlogCategory.php | BlogCategory.setBlog | public function setBlog(Blog $blog)
{
$this->blog = $blog;
foreach ($this->children as $child) {
$child->setBlog($blog);
}
return $this;
} | php | public function setBlog(Blog $blog)
{
$this->blog = $blog;
foreach ($this->children as $child) {
$child->setBlog($blog);
}
return $this;
} | [
"public",
"function",
"setBlog",
"(",
"Blog",
"$",
"blog",
")",
"{",
"$",
"this",
"->",
"blog",
"=",
"$",
"blog",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"child",
"->",
"setBlog",
"(",
"$",
"blog",
"... | Set blog.
@param string $blog
@return $this | [
"Set",
"blog",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Entity/BlogCategory.php#L425-L433 | train |
Victoire/victoire | Bundle/BlogBundle/Form/DataTransformer/TagToStringTransformer.php | TagToStringTransformer.reverseTransform | public function reverseTransform($array)
{
if (is_array($array) && array_key_exists(0, $array)) {
$newIds = [];
$ids = explode(',', $array[0]);
$repo = $this->em->getRepository('VictoireBlogBundle:Tag');
$objects = $repo->findById($ids);
foreach ($objects as $object) {
if (false !== $key = array_search($object->getId(), $ids)) {
$newIds[] = $ids[$key];
unset($ids[$key]);
}
}
$objectsArray = [];
foreach ($ids as $title) {
if ($title !== '') {
$object = new Tag();
$object->setTitle($title);
$this->em->persist($object);
$objectsArray[] = $object;
}
}
$this->em->flush();
foreach ($objectsArray as $objectObj) {
$newIds[] = $objectObj->getId();
}
return $newIds;
}
return $array;
} | php | public function reverseTransform($array)
{
if (is_array($array) && array_key_exists(0, $array)) {
$newIds = [];
$ids = explode(',', $array[0]);
$repo = $this->em->getRepository('VictoireBlogBundle:Tag');
$objects = $repo->findById($ids);
foreach ($objects as $object) {
if (false !== $key = array_search($object->getId(), $ids)) {
$newIds[] = $ids[$key];
unset($ids[$key]);
}
}
$objectsArray = [];
foreach ($ids as $title) {
if ($title !== '') {
$object = new Tag();
$object->setTitle($title);
$this->em->persist($object);
$objectsArray[] = $object;
}
}
$this->em->flush();
foreach ($objectsArray as $objectObj) {
$newIds[] = $objectObj->getId();
}
return $newIds;
}
return $array;
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"array",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"array",
")",
"&&",
"array_key_exists",
"(",
"0",
",",
"$",
"array",
")",
")",
"{",
"$",
"newIds",
"=",
"[",
"]",
";",
"$",
"ids",
"=",
"explode... | String to Tags.
@param mixed $array
@internal param mixed $string
@return array | [
"String",
"to",
"Tags",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Form/DataTransformer/TagToStringTransformer.php#L27-L61 | train |
Victoire/victoire | Bundle/MediaBundle/Resources/public/js/ckeditor/ckeditor_php5.php | CKEditor.replaceAll | public function replaceAll($className = null)
{
$out = '';
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings();
$js = $this->returnGlobalEvents();
if (empty($_config)) {
if (empty($className)) {
$js .= 'CKEDITOR.replaceAll();';
} else {
$js .= "CKEDITOR.replaceAll('".$className."');";
}
} else {
$classDetection = '';
$js .= "CKEDITOR.replaceAll( function (textarea, config) {\n";
if (!empty($className)) {
$js .= " var classRegex = new RegExp('(?:^| )' + '".$className."' + '(?:$| )');\n";
$js .= " if (!classRegex.test(textarea.className))\n";
$js .= " return false;\n";
}
$js .= ' CKEDITOR.tools.extend(config, '.$this->jsEncode($_config).', true);';
$js .= '} );';
}
$out .= $this->script($js);
if (!$this->returnOutput) {
echo $out;
$out = '';
}
return $out;
} | php | public function replaceAll($className = null)
{
$out = '';
if (!$this->initialized) {
$out .= $this->init();
}
$_config = $this->configSettings();
$js = $this->returnGlobalEvents();
if (empty($_config)) {
if (empty($className)) {
$js .= 'CKEDITOR.replaceAll();';
} else {
$js .= "CKEDITOR.replaceAll('".$className."');";
}
} else {
$classDetection = '';
$js .= "CKEDITOR.replaceAll( function (textarea, config) {\n";
if (!empty($className)) {
$js .= " var classRegex = new RegExp('(?:^| )' + '".$className."' + '(?:$| )');\n";
$js .= " if (!classRegex.test(textarea.className))\n";
$js .= " return false;\n";
}
$js .= ' CKEDITOR.tools.extend(config, '.$this->jsEncode($_config).', true);';
$js .= '} );';
}
$out .= $this->script($js);
if (!$this->returnOutput) {
echo $out;
$out = '';
}
return $out;
} | [
"public",
"function",
"replaceAll",
"(",
"$",
"className",
"=",
"null",
")",
"{",
"$",
"out",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"initialized",
")",
"{",
"$",
"out",
".=",
"$",
"this",
"->",
"init",
"(",
")",
";",
"}",
"$",
"_co... | Replace all <textarea> elements available in the document with editor instances.
@param $className (string) If set, replace all textareas with class className in the page.
Example 1: replace all <textarea> elements in the page.
@code
$CKEditor = new CKEditor();
$CKEditor->replaceAll();
@endcode
Example 2: replace all <textarea class="myClassName"> elements in the page.
@code
$CKEditor = new CKEditor();
$CKEditor->replaceAll( 'myClassName' );
@endcode | [
"Replace",
"all",
"<",
";",
"textarea>",
";",
"elements",
"available",
"in",
"the",
"document",
"with",
"editor",
"instances",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Resources/public/js/ckeditor/ckeditor_php5.php#L222-L258 | train |
Victoire/victoire | Bundle/MediaBundle/Resources/public/js/ckeditor/ckeditor_php5.php | CKEditor.ckeditorPath | private function ckeditorPath()
{
if (!empty($this->basePath)) {
return $this->basePath;
}
/**
* The absolute pathname of the currently executing script.
* Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php,
* $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
*/
if (isset($_SERVER['SCRIPT_FILENAME'])) {
$realPath = dirname($_SERVER['SCRIPT_FILENAME']);
} else {
/*
* realpath - Returns canonicalized absolute pathname
*/
$realPath = realpath('./');
}
/*
* The filename of the currently executing script, relative to the document root.
* For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar
* would be /test.php/foo.bar.
*/
$selfPath = dirname($_SERVER['PHP_SELF']);
$file = str_replace('\\', '/', __FILE__);
if (!$selfPath || !$realPath || !$file) {
return '/ckeditor/';
}
$documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath));
$fileUrl = substr($file, strlen($documentRoot));
$ckeditorUrl = str_replace('ckeditor_php5.php', '', $fileUrl);
return $ckeditorUrl;
} | php | private function ckeditorPath()
{
if (!empty($this->basePath)) {
return $this->basePath;
}
/**
* The absolute pathname of the currently executing script.
* Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php,
* $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
*/
if (isset($_SERVER['SCRIPT_FILENAME'])) {
$realPath = dirname($_SERVER['SCRIPT_FILENAME']);
} else {
/*
* realpath - Returns canonicalized absolute pathname
*/
$realPath = realpath('./');
}
/*
* The filename of the currently executing script, relative to the document root.
* For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar
* would be /test.php/foo.bar.
*/
$selfPath = dirname($_SERVER['PHP_SELF']);
$file = str_replace('\\', '/', __FILE__);
if (!$selfPath || !$realPath || !$file) {
return '/ckeditor/';
}
$documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath));
$fileUrl = substr($file, strlen($documentRoot));
$ckeditorUrl = str_replace('ckeditor_php5.php', '', $fileUrl);
return $ckeditorUrl;
} | [
"private",
"function",
"ckeditorPath",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"basePath",
")",
")",
"{",
"return",
"$",
"this",
"->",
"basePath",
";",
"}",
"/**\n * The absolute pathname of the currently executing script.\n *... | Return path to ckeditor.js.
@return string | [
"Return",
"path",
"to",
"ckeditor",
".",
"js",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Resources/public/js/ckeditor/ckeditor_php5.php#L480-L517 | train |
Victoire/victoire | Bundle/MediaBundle/Resources/public/js/ckeditor/ckeditor_php5.php | CKEditor.jsEncode | private function jsEncode($val)
{
if (is_null($val)) {
return 'null';
}
if (is_bool($val)) {
return $val ? 'true' : 'false';
}
if (is_int($val)) {
return $val;
}
if (is_float($val)) {
return str_replace(',', '.', $val);
}
if (is_array($val) || is_object($val)) {
if (is_array($val) && (array_keys($val) === range(0, count($val) - 1))) {
return '['.implode(',', array_map([$this, 'jsEncode'], $val)).']';
}
$temp = [];
foreach ($val as $k => $v) {
$temp[] = $this->jsEncode("{$k}").':'.$this->jsEncode($v);
}
return '{'.implode(',', $temp).'}';
}
// String otherwise
if (strpos($val, '@@') === 0) {
return substr($val, 2);
}
if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') {
return $val;
}
return '"'.str_replace(['\\', '/', "\n", "\t", "\r", "\x08", "\x0c", '"'], ['\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'], $val).'"';
} | php | private function jsEncode($val)
{
if (is_null($val)) {
return 'null';
}
if (is_bool($val)) {
return $val ? 'true' : 'false';
}
if (is_int($val)) {
return $val;
}
if (is_float($val)) {
return str_replace(',', '.', $val);
}
if (is_array($val) || is_object($val)) {
if (is_array($val) && (array_keys($val) === range(0, count($val) - 1))) {
return '['.implode(',', array_map([$this, 'jsEncode'], $val)).']';
}
$temp = [];
foreach ($val as $k => $v) {
$temp[] = $this->jsEncode("{$k}").':'.$this->jsEncode($v);
}
return '{'.implode(',', $temp).'}';
}
// String otherwise
if (strpos($val, '@@') === 0) {
return substr($val, 2);
}
if (strtoupper(substr($val, 0, 9)) == 'CKEDITOR.') {
return $val;
}
return '"'.str_replace(['\\', '/', "\n", "\t", "\r", "\x08", "\x0c", '"'], ['\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'], $val).'"';
} | [
"private",
"function",
"jsEncode",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"val",
")",
")",
"{",
"return",
"'null'",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"val",
")",
")",
"{",
"return",
"$",
"val",
"?",
"'true'",
":",
"'... | This little function provides a basic JSON support.
@param mixed $val
@return string | [
"This",
"little",
"function",
"provides",
"a",
"basic",
"JSON",
"support",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Resources/public/js/ckeditor/ckeditor_php5.php#L526-L560 | train |
Victoire/victoire | Bundle/CriteriaBundle/DataSource/RolesDataSource.php | RolesDataSource.getAllAvailableRoles | public function getAllAvailableRoles($roleHierarchy)
{
$roles = [];
foreach ($roleHierarchy as $key => $value) {
if (is_array($value)) {
$roles = array_merge($roles, $this->getAllAvailableRoles($value));
}
if (is_string($key)) {
$roles[] = $key;
}
if (is_string($value)) {
$roles[] = $value;
}
}
return $roles;
} | php | public function getAllAvailableRoles($roleHierarchy)
{
$roles = [];
foreach ($roleHierarchy as $key => $value) {
if (is_array($value)) {
$roles = array_merge($roles, $this->getAllAvailableRoles($value));
}
if (is_string($key)) {
$roles[] = $key;
}
if (is_string($value)) {
$roles[] = $value;
}
}
return $roles;
} | [
"public",
"function",
"getAllAvailableRoles",
"(",
"$",
"roleHierarchy",
")",
"{",
"$",
"roles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"roleHierarchy",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
... | flatten the array of all roles defined in role_hierarchy.
@param array $roleHierarchy
@return array | [
"flatten",
"the",
"array",
"of",
"all",
"roles",
"defined",
"in",
"role_hierarchy",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CriteriaBundle/DataSource/RolesDataSource.php#L66-L82 | train |
Victoire/victoire | Bundle/PageBundle/Entity/BasePage.php | BasePage.getWebViewChildren | public function getWebViewChildren($excludeUnpublished = false)
{
$webViewChildren = [];
foreach ($this->children as $child) {
if (!$child instanceof BusinessTemplate) {
$notPublished = $child->getStatus() != PageStatus::PUBLISHED;
$scheduledDateNotReached = $child->getStatus() == PageStatus::SCHEDULED && $child->getPublishedAt() > new \DateTime();
if ($excludeUnpublished && ($notPublished || $scheduledDateNotReached)) {
continue;
}
$webViewChildren[] = $child;
}
}
return $webViewChildren;
} | php | public function getWebViewChildren($excludeUnpublished = false)
{
$webViewChildren = [];
foreach ($this->children as $child) {
if (!$child instanceof BusinessTemplate) {
$notPublished = $child->getStatus() != PageStatus::PUBLISHED;
$scheduledDateNotReached = $child->getStatus() == PageStatus::SCHEDULED && $child->getPublishedAt() > new \DateTime();
if ($excludeUnpublished && ($notPublished || $scheduledDateNotReached)) {
continue;
}
$webViewChildren[] = $child;
}
}
return $webViewChildren;
} | [
"public",
"function",
"getWebViewChildren",
"(",
"$",
"excludeUnpublished",
"=",
"false",
")",
"{",
"$",
"webViewChildren",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"!",
"$",
"child",
"... | Get WebView children.
Exclude unpublished or not published yet if asked.
@param bool $excludeUnpublished
@return string | [
"Get",
"WebView",
"children",
".",
"Exclude",
"unpublished",
"or",
"not",
"published",
"yet",
"if",
"asked",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Entity/BasePage.php#L40-L57 | train |
Victoire/victoire | Bundle/CoreBundle/Cache/Builder/CacheBuilder.php | CacheBuilder.saveBusinessEntity | public function saveBusinessEntity(BusinessEntity $businessEntity)
{
$businessEntities = $this->cache->get(BusinessEntity::CACHE_CLASSES);
$businessEntities[$businessEntity->getClass()] = $businessEntity;
$this->cache->save(BusinessEntity::CACHE_CLASSES, $businessEntities);
} | php | public function saveBusinessEntity(BusinessEntity $businessEntity)
{
$businessEntities = $this->cache->get(BusinessEntity::CACHE_CLASSES);
$businessEntities[$businessEntity->getClass()] = $businessEntity;
$this->cache->save(BusinessEntity::CACHE_CLASSES, $businessEntities);
} | [
"public",
"function",
"saveBusinessEntity",
"(",
"BusinessEntity",
"$",
"businessEntity",
")",
"{",
"$",
"businessEntities",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"BusinessEntity",
"::",
"CACHE_CLASSES",
")",
";",
"$",
"businessEntities",
"[",
"$",
... | save BusinessEntity. | [
"save",
"BusinessEntity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Cache/Builder/CacheBuilder.php#L24-L29 | train |
Victoire/victoire | Bundle/CoreBundle/Cache/Builder/CacheBuilder.php | CacheBuilder.saveWidgetReceiverProperties | public function saveWidgetReceiverProperties($widgetName, $receiverProperties)
{
$widgets = $this->cache->get(BusinessEntity::CACHE_WIDGETS, []);
if (!array_key_exists($widgetName, $widgets)) {
$widgets[$widgetName] = [];
}
$widgets[$widgetName]['receiverProperties'] = $receiverProperties;
$this->cache->save(BusinessEntity::CACHE_WIDGETS, $widgets);
} | php | public function saveWidgetReceiverProperties($widgetName, $receiverProperties)
{
$widgets = $this->cache->get(BusinessEntity::CACHE_WIDGETS, []);
if (!array_key_exists($widgetName, $widgets)) {
$widgets[$widgetName] = [];
}
$widgets[$widgetName]['receiverProperties'] = $receiverProperties;
$this->cache->save(BusinessEntity::CACHE_WIDGETS, $widgets);
} | [
"public",
"function",
"saveWidgetReceiverProperties",
"(",
"$",
"widgetName",
",",
"$",
"receiverProperties",
")",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"BusinessEntity",
"::",
"CACHE_WIDGETS",
",",
"[",
"]",
")",
";",
"if",... | save Widget. | [
"save",
"Widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Cache/Builder/CacheBuilder.php#L34-L43 | train |
Victoire/victoire | Bundle/CoreBundle/Cache/Builder/CacheBuilder.php | CacheBuilder.addWidgetBusinessEntity | public function addWidgetBusinessEntity($widgetName, $businessEntity)
{
$widgets = $this->cache->get(BusinessEntity::CACHE_WIDGETS, []);
if (!array_key_exists($widgetName, $widgets)) {
$widgets[$widgetName] = ['businessEntities' => []];
}
$widgets[$widgetName]['businessEntities'][$businessEntity->getId()] = $businessEntity;
$this->cache->save(BusinessEntity::CACHE_WIDGETS, $widgets);
} | php | public function addWidgetBusinessEntity($widgetName, $businessEntity)
{
$widgets = $this->cache->get(BusinessEntity::CACHE_WIDGETS, []);
if (!array_key_exists($widgetName, $widgets)) {
$widgets[$widgetName] = ['businessEntities' => []];
}
$widgets[$widgetName]['businessEntities'][$businessEntity->getId()] = $businessEntity;
$this->cache->save(BusinessEntity::CACHE_WIDGETS, $widgets);
} | [
"public",
"function",
"addWidgetBusinessEntity",
"(",
"$",
"widgetName",
",",
"$",
"businessEntity",
")",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"BusinessEntity",
"::",
"CACHE_WIDGETS",
",",
"[",
"]",
")",
";",
"if",
"(",
... | add a BusinessEntity For Widget. | [
"add",
"a",
"BusinessEntity",
"For",
"Widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Cache/Builder/CacheBuilder.php#L48-L56 | train |
Victoire/victoire | Bundle/I18nBundle/Resolver/LocaleResolver.php | LocaleResolver.resolve | public function resolve(Request $request)
{
//locale
switch ($this->localePattern) {
case self::PATTERN_DOMAIN:
$locale = $this->resolveFromDomain($request);
$request->setLocale($locale);
break;
}
return $request->getLocale();
} | php | public function resolve(Request $request)
{
//locale
switch ($this->localePattern) {
case self::PATTERN_DOMAIN:
$locale = $this->resolveFromDomain($request);
$request->setLocale($locale);
break;
}
return $request->getLocale();
} | [
"public",
"function",
"resolve",
"(",
"Request",
"$",
"request",
")",
"{",
"//locale",
"switch",
"(",
"$",
"this",
"->",
"localePattern",
")",
"{",
"case",
"self",
"::",
"PATTERN_DOMAIN",
":",
"$",
"locale",
"=",
"$",
"this",
"->",
"resolveFromDomain",
"("... | set the local depending on patterns
it also set the victoire_locale wich is the locale of the application admin. | [
"set",
"the",
"local",
"depending",
"on",
"patterns",
"it",
"also",
"set",
"the",
"victoire_locale",
"wich",
"is",
"the",
"locale",
"of",
"the",
"application",
"admin",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/I18nBundle/Resolver/LocaleResolver.php#L49-L60 | train |
Victoire/victoire | Bundle/WidgetBundle/Command/CreateWidgetCommand.php | CreateWidgetCommand.createWidgetGenerator | protected function createWidgetGenerator()
{
$generator = new WidgetGenerator($this->getContainer()->get('filesystem'));
$generator->setTemplating($this->getContainer()->get('twig'));
return $generator;
} | php | protected function createWidgetGenerator()
{
$generator = new WidgetGenerator($this->getContainer()->get('filesystem'));
$generator->setTemplating($this->getContainer()->get('twig'));
return $generator;
} | [
"protected",
"function",
"createWidgetGenerator",
"(",
")",
"{",
"$",
"generator",
"=",
"new",
"WidgetGenerator",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'filesystem'",
")",
")",
";",
"$",
"generator",
"->",
"setTemplating",
"(",... | Instanciate a new WidgetGenerator.
@return $generator | [
"Instanciate",
"a",
"new",
"WidgetGenerator",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Command/CreateWidgetCommand.php#L406-L412 | train |
Victoire/victoire | Bundle/WidgetBundle/Command/CreateWidgetCommand.php | CreateWidgetCommand.parseFields | private function parseFields($input)
{
if (is_array($input)) {
return $input;
}
$fields = [];
foreach (explode(' ', $input) as $value) {
$elements = explode(':', $value);
$name = $elements[0];
if (strlen($name)) {
$type = isset($elements[1]) ? $elements[1] : 'string';
preg_match_all('/(.*)\((.*)\)/', $type, $matches);
$type = isset($matches[1][0]) ? $matches[1][0] : $type;
$length = isset($matches[2][0]) ? $matches[2][0] : null;
$fields[$name] = ['fieldName' => $name, 'type' => $type, 'length' => $length];
}
}
return $fields;
} | php | private function parseFields($input)
{
if (is_array($input)) {
return $input;
}
$fields = [];
foreach (explode(' ', $input) as $value) {
$elements = explode(':', $value);
$name = $elements[0];
if (strlen($name)) {
$type = isset($elements[1]) ? $elements[1] : 'string';
preg_match_all('/(.*)\((.*)\)/', $type, $matches);
$type = isset($matches[1][0]) ? $matches[1][0] : $type;
$length = isset($matches[2][0]) ? $matches[2][0] : null;
$fields[$name] = ['fieldName' => $name, 'type' => $type, 'length' => $length];
}
}
return $fields;
} | [
"private",
"function",
"parseFields",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"return",
"$",
"input",
";",
"}",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"' '",
",",
"$",
"inp... | transform console's output string fields into an array of fields.
@param string $input
@return array $fields | [
"transform",
"console",
"s",
"output",
"string",
"fields",
"into",
"an",
"array",
"of",
"fields",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Command/CreateWidgetCommand.php#L431-L452 | train |
Victoire/victoire | Bundle/CoreBundle/VictoireCoreBundle.php | VictoireCoreBundle.boot | public function boot()
{
//Add entity proxy driver into the DriverChain
$driverChain = $this->container->get('doctrine.orm.entity_manager')->getConfiguration()->getMetadataDriverImpl();
$proxyDriver = $this->container->get('victoire_core.entity_proxy.cache_driver');
$driverChain->addDriver($proxyDriver, 'Victoire');
} | php | public function boot()
{
//Add entity proxy driver into the DriverChain
$driverChain = $this->container->get('doctrine.orm.entity_manager')->getConfiguration()->getMetadataDriverImpl();
$proxyDriver = $this->container->get('victoire_core.entity_proxy.cache_driver');
$driverChain->addDriver($proxyDriver, 'Victoire');
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"//Add entity proxy driver into the DriverChain",
"$",
"driverChain",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine.orm.entity_manager'",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getMetadataDriver... | Boot the bundle. | [
"Boot",
"the",
"bundle",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/VictoireCoreBundle.php#L19-L26 | train |
Victoire/victoire | Bundle/TwigBundle/Controller/ExceptionController.php | ExceptionController.showAction | public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
{
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$code = $exception->getStatusCode();
//get request extension
$uriArray = explode('/', rtrim($request->getRequestUri(), '/'));
$matches = preg_match('/^.*(\..*)$/', array_pop($uriArray), $matches);
$locale = $request->getLocale();
if (!in_array($locale, $this->availableLocales, true)) {
$request->setLocale($this->defaultLocale);
}
//if in production environment and the query is not a file
if ($this->debug === false && 0 === $matches) {
$page = $this->em->getRepository('VictoireTwigBundle:ErrorPage')->findOneByCode($code);
if ($page) {
return $this->forward('VictoireTwigBundle:ErrorPage:show', [
'code' => $page->getCode(),
]);
}
}
return new Response($this->twig->render(
$this->findTemplate($request, $_format, $code, $this->debug),
[
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
]
));
} | php | public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
{
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$code = $exception->getStatusCode();
//get request extension
$uriArray = explode('/', rtrim($request->getRequestUri(), '/'));
$matches = preg_match('/^.*(\..*)$/', array_pop($uriArray), $matches);
$locale = $request->getLocale();
if (!in_array($locale, $this->availableLocales, true)) {
$request->setLocale($this->defaultLocale);
}
//if in production environment and the query is not a file
if ($this->debug === false && 0 === $matches) {
$page = $this->em->getRepository('VictoireTwigBundle:ErrorPage')->findOneByCode($code);
if ($page) {
return $this->forward('VictoireTwigBundle:ErrorPage:show', [
'code' => $page->getCode(),
]);
}
}
return new Response($this->twig->render(
$this->findTemplate($request, $_format, $code, $this->debug),
[
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
]
));
} | [
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
",",
"FlattenException",
"$",
"exception",
",",
"DebugLoggerInterface",
"$",
"logger",
"=",
"null",
",",
"$",
"_format",
"=",
"'html'",
")",
"{",
"$",
"currentContent",
"=",
"$",
"this",
"->... | Converts an Exception to a Response to be able to render a Victoire view.
@param Request $request The request
@param FlattenException $exception A FlattenException instance
@param DebugLoggerInterface $logger A DebugLoggerInterface instance
@param string $_format The format to use for rendering (html, xml, ...)
@throws \InvalidArgumentException When the exception template does not exist
@return Response | [
"Converts",
"an",
"Exception",
"to",
"a",
"Response",
"to",
"be",
"able",
"to",
"render",
"a",
"Victoire",
"view",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/TwigBundle/Controller/ExceptionController.php#L68-L102 | train |
Victoire/victoire | Bundle/TwigBundle/Controller/ExceptionController.php | ExceptionController.forward | protected function forward($controller, array $path = [], array $query = [])
{
$path['_controller'] = $controller;
$subRequest = $this->request->duplicate($query, null, $path);
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
} | php | protected function forward($controller, array $path = [], array $query = [])
{
$path['_controller'] = $controller;
$subRequest = $this->request->duplicate($query, null, $path);
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
} | [
"protected",
"function",
"forward",
"(",
"$",
"controller",
",",
"array",
"$",
"path",
"=",
"[",
"]",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"path",
"[",
"'_controller'",
"]",
"=",
"$",
"controller",
";",
"$",
"subRequest",
"=",
... | Forwards the request to another controller.
@param string $controller The controller name (a string like BlogBundle:Post:index)
@param array $path An array of path parameters
@param array $query An array of query parameters
@return Response A Response instance | [
"Forwards",
"the",
"request",
"to",
"another",
"controller",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/TwigBundle/Controller/ExceptionController.php#L113-L119 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Warmer/ContextualViewWarmer.php | ContextualViewWarmer.warm | public function warm(View $viewToWarm, View $contextualView = null)
{
$widgetMaps = [];
if (null === $contextualView) {
$contextualView = $viewToWarm;
}
foreach ($viewToWarm->getWidgetMaps() as $_widgetMap) {
$_widgetMap->setContextualView($contextualView);
$widgetMaps[] = $_widgetMap;
}
if ($template = $viewToWarm->getTemplate()) {
$templateWidgetMaps = $this->warm($template, $contextualView);
$widgetMaps = array_merge($widgetMaps, $templateWidgetMaps);
}
return $widgetMaps;
} | php | public function warm(View $viewToWarm, View $contextualView = null)
{
$widgetMaps = [];
if (null === $contextualView) {
$contextualView = $viewToWarm;
}
foreach ($viewToWarm->getWidgetMaps() as $_widgetMap) {
$_widgetMap->setContextualView($contextualView);
$widgetMaps[] = $_widgetMap;
}
if ($template = $viewToWarm->getTemplate()) {
$templateWidgetMaps = $this->warm($template, $contextualView);
$widgetMaps = array_merge($widgetMaps, $templateWidgetMaps);
}
return $widgetMaps;
} | [
"public",
"function",
"warm",
"(",
"View",
"$",
"viewToWarm",
",",
"View",
"$",
"contextualView",
"=",
"null",
")",
"{",
"$",
"widgetMaps",
"=",
"[",
"]",
";",
"if",
"(",
"null",
"===",
"$",
"contextualView",
")",
"{",
"$",
"contextualView",
"=",
"$",
... | Give a contextual View to each WidgetMap used in a View and its Templates.
@param View $viewToWarm
@param View|null $contextualView Used in recursive call only
@return WidgetMap[] | [
"Give",
"a",
"contextual",
"View",
"to",
"each",
"WidgetMap",
"used",
"in",
"a",
"View",
"and",
"its",
"Templates",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Warmer/ContextualViewWarmer.php#L23-L42 | train |
Victoire/victoire | Bundle/CoreBundle/Command/WidgetCssGenerateCommand.php | WidgetCssGenerateCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
//Get options
$force = $input->getOption('force');
$limit = $input->getOption('limit');
//Get services
$this->entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
$viewCssBuilder = $this->getContainer()->get('victoire_core.view_css_builder');
$widgetMapBuilder = $this->getContainer()->get('victoire_widget_map.builder');
$widgetRepo = $this->entityManager->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget');
$views = $this->getViewsToTreat();
//Remove View if CSS is upToDate and we don't want to regenerate it
foreach ($views as $i => $view) {
if (!$force && $view->isCssUpToDate()) {
unset($views[$i]);
}
}
//Prepare limit
$limit = ($limit && $limit < count($views)) ? $limit : count($views);
$count = 0;
if (count($views) < 1) {
$output->writeln('<info>0 View\'s CSS to regenerate for your options</info>');
return true;
}
//Set progress for output
$progress = new ProgressBar($output, $limit);
$progress->start();
foreach ($views as $view) {
if ($count >= $limit) {
break;
}
//If hash already exist, remove CSS file
if ($viewHash = $view->getCssHash()) {
$viewCssBuilder->removeCssFile($viewHash);
}
//Generate a new hash to force browser reload
$view->changeCssHash();
//Generate CSS file with its widgets style
$widgetMapBuilder->build($view, $this->entityManager);
$widgets = $widgetRepo->findAllWidgetsForView($view);
$viewCssBuilder->generateViewCss($view, $widgets);
//Set View's CSS as up to date
$view->setCssUpToDate(true);
$this->entityManager->persist($view);
$this->entityManager->flush($view);
$progress->advance();
$count++;
}
$progress->finish();
return true;
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
//Get options
$force = $input->getOption('force');
$limit = $input->getOption('limit');
//Get services
$this->entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
$viewCssBuilder = $this->getContainer()->get('victoire_core.view_css_builder');
$widgetMapBuilder = $this->getContainer()->get('victoire_widget_map.builder');
$widgetRepo = $this->entityManager->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget');
$views = $this->getViewsToTreat();
//Remove View if CSS is upToDate and we don't want to regenerate it
foreach ($views as $i => $view) {
if (!$force && $view->isCssUpToDate()) {
unset($views[$i]);
}
}
//Prepare limit
$limit = ($limit && $limit < count($views)) ? $limit : count($views);
$count = 0;
if (count($views) < 1) {
$output->writeln('<info>0 View\'s CSS to regenerate for your options</info>');
return true;
}
//Set progress for output
$progress = new ProgressBar($output, $limit);
$progress->start();
foreach ($views as $view) {
if ($count >= $limit) {
break;
}
//If hash already exist, remove CSS file
if ($viewHash = $view->getCssHash()) {
$viewCssBuilder->removeCssFile($viewHash);
}
//Generate a new hash to force browser reload
$view->changeCssHash();
//Generate CSS file with its widgets style
$widgetMapBuilder->build($view, $this->entityManager);
$widgets = $widgetRepo->findAllWidgetsForView($view);
$viewCssBuilder->generateViewCss($view, $widgets);
//Set View's CSS as up to date
$view->setCssUpToDate(true);
$this->entityManager->persist($view);
$this->entityManager->flush($view);
$progress->advance();
$count++;
}
$progress->finish();
return true;
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"//Get options",
"$",
"force",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'force'",
")",
";",
"$",
"limit",
"=",
"$",
"input",
"->",
... | Generate a css file containing all css parameters for all widgets used in each view.
@param InputInterface $input
@param OutputInterface $output
@throws \Exception
@return bool | [
"Generate",
"a",
"css",
"file",
"containing",
"all",
"css",
"parameters",
"for",
"all",
"widgets",
"used",
"in",
"each",
"view",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Command/WidgetCssGenerateCommand.php#L43-L108 | train |
Victoire/victoire | Bundle/CoreBundle/Command/WidgetCssGenerateCommand.php | WidgetCssGenerateCommand.getViewsToTreat | private function getViewsToTreat()
{
$templateRepo = $this->entityManager->getRepository('VictoireTemplateBundle:Template');
$rootTemplates = $templateRepo->getInstance()
->where('template.template IS NULL')
->getQuery()
->getResult();
$templates = [];
$recursiveGetTemplates = function ($template) use (&$recursiveGetTemplates, &$templates) {
array_push($templates, $template);
foreach ($template->getInheritors() as $_template) {
if ($_template instanceof Template) {
$recursiveGetTemplates($_template);
}
}
};
foreach ($rootTemplates as $rootTemplate) {
$recursiveGetTemplates($rootTemplate);
}
$pageRepo = $this->entityManager->getRepository('VictoirePageBundle:BasePage');
$pages = $pageRepo->findAll();
$errorRepo = $this->entityManager->getRepository('VictoireTwigBundle:ErrorPage');
$errorPages = $errorRepo->findAll();
return array_merge($templates, array_merge($pages, $errorPages));
} | php | private function getViewsToTreat()
{
$templateRepo = $this->entityManager->getRepository('VictoireTemplateBundle:Template');
$rootTemplates = $templateRepo->getInstance()
->where('template.template IS NULL')
->getQuery()
->getResult();
$templates = [];
$recursiveGetTemplates = function ($template) use (&$recursiveGetTemplates, &$templates) {
array_push($templates, $template);
foreach ($template->getInheritors() as $_template) {
if ($_template instanceof Template) {
$recursiveGetTemplates($_template);
}
}
};
foreach ($rootTemplates as $rootTemplate) {
$recursiveGetTemplates($rootTemplate);
}
$pageRepo = $this->entityManager->getRepository('VictoirePageBundle:BasePage');
$pages = $pageRepo->findAll();
$errorRepo = $this->entityManager->getRepository('VictoireTwigBundle:ErrorPage');
$errorPages = $errorRepo->findAll();
return array_merge($templates, array_merge($pages, $errorPages));
} | [
"private",
"function",
"getViewsToTreat",
"(",
")",
"{",
"$",
"templateRepo",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"'VictoireTemplateBundle:Template'",
")",
";",
"$",
"rootTemplates",
"=",
"$",
"templateRepo",
"->",
"getInstance",
"... | Get Templates, BasePages and ErrorPages.
@return View[] | [
"Get",
"Templates",
"BasePages",
"and",
"ErrorPages",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Command/WidgetCssGenerateCommand.php#L115-L142 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/EventSubscriber/BusinessEntitySubscriber.php | BusinessEntitySubscriber.postFlush | public function postFlush(PostFlushEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
foreach ($this->flushedBusinessEntities as $entity) {
$businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
//find all BT that can represent the businessEntity
$businessTemplates = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->findPagePatternByBusinessEntity($businessEntity);
foreach ($businessTemplates as $businessTemplate) {
// Generate a viewReference for each BT translation
foreach ($businessTemplate->getTranslations() as $translation) {
$businessTemplate->setCurrentLocale($translation->getLocale());
if ($page = $em->getRepository(
'Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage'
)->findPageByBusinessEntityAndPattern($businessTemplate, $entity, $businessEntity)
) {
//if it's a BP we update the BP
$this->businessPageBuilder->updatePageParametersByEntity($page, $entity);
} else {
$page = $this->businessPageBuilder->generateEntityPageFromTemplate(
$businessTemplate,
$entity,
$em
);
}
if ($this->businessPageHelper->isEntityAllowed($businessTemplate, $entity, $em)) {
//update the reference
$event = new ViewReferenceEvent($page);
$this->dispatcher->dispatch(ViewReferenceEvents::UPDATE_VIEW_REFERENCE, $event);
}
}
}
}
foreach ($this->flushedBusinessTemplates as $entity) {
$businessEntityId = $entity->getBusinessEntityId();
$businessEntity = $this->businessEntityHelper->findById($businessEntityId);
//find all entities
$entities = $this->businessPageHelper->getEntitiesAllowed($entity, $em);
// Generate a viewReference for each BT translation
foreach ($entity->getTranslations() as $translation) {
$entity->setCurrentLocale($translation->getLocale());
foreach ($entities as $be) {
if ($this->businessPageHelper->isEntityAllowed($entity, $be, $em)) {
if ($page = $em->getRepository(
'Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage'
)->findPageByBusinessEntityAndPattern($entity, $be, $businessEntity)
) {
//rebuild page if its a BP
$this->businessPageBuilder->updatePageParametersByEntity($page, $be);
} else {
$page = $this->businessPageBuilder->generateEntityPageFromTemplate(
$entity,
$be,
$em
);
}
// update reference
$event = new ViewReferenceEvent($page);
$this->dispatcher->dispatch(ViewReferenceEvents::UPDATE_VIEW_REFERENCE, $event);
}
}
}
}
$this->flushedBusinessEntities->clear();
$this->flushedBusinessTemplates->clear();
} | php | public function postFlush(PostFlushEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
foreach ($this->flushedBusinessEntities as $entity) {
$businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
//find all BT that can represent the businessEntity
$businessTemplates = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->findPagePatternByBusinessEntity($businessEntity);
foreach ($businessTemplates as $businessTemplate) {
// Generate a viewReference for each BT translation
foreach ($businessTemplate->getTranslations() as $translation) {
$businessTemplate->setCurrentLocale($translation->getLocale());
if ($page = $em->getRepository(
'Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage'
)->findPageByBusinessEntityAndPattern($businessTemplate, $entity, $businessEntity)
) {
//if it's a BP we update the BP
$this->businessPageBuilder->updatePageParametersByEntity($page, $entity);
} else {
$page = $this->businessPageBuilder->generateEntityPageFromTemplate(
$businessTemplate,
$entity,
$em
);
}
if ($this->businessPageHelper->isEntityAllowed($businessTemplate, $entity, $em)) {
//update the reference
$event = new ViewReferenceEvent($page);
$this->dispatcher->dispatch(ViewReferenceEvents::UPDATE_VIEW_REFERENCE, $event);
}
}
}
}
foreach ($this->flushedBusinessTemplates as $entity) {
$businessEntityId = $entity->getBusinessEntityId();
$businessEntity = $this->businessEntityHelper->findById($businessEntityId);
//find all entities
$entities = $this->businessPageHelper->getEntitiesAllowed($entity, $em);
// Generate a viewReference for each BT translation
foreach ($entity->getTranslations() as $translation) {
$entity->setCurrentLocale($translation->getLocale());
foreach ($entities as $be) {
if ($this->businessPageHelper->isEntityAllowed($entity, $be, $em)) {
if ($page = $em->getRepository(
'Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage'
)->findPageByBusinessEntityAndPattern($entity, $be, $businessEntity)
) {
//rebuild page if its a BP
$this->businessPageBuilder->updatePageParametersByEntity($page, $be);
} else {
$page = $this->businessPageBuilder->generateEntityPageFromTemplate(
$entity,
$be,
$em
);
}
// update reference
$event = new ViewReferenceEvent($page);
$this->dispatcher->dispatch(ViewReferenceEvents::UPDATE_VIEW_REFERENCE, $event);
}
}
}
}
$this->flushedBusinessEntities->clear();
$this->flushedBusinessTemplates->clear();
} | [
"public",
"function",
"postFlush",
"(",
"PostFlushEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"em",
"=",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"flushedBusinessEntities",
"as",
"$",
"entity",
")",
"{",
... | Iterate over inserted BusinessEntities and BusinessTemplates catched by postPersist
and dispatch event to generate the needed ViewReferences.
@param PostFlushEventArgs $eventArgs
@throws \Exception | [
"Iterate",
"over",
"inserted",
"BusinessEntities",
"and",
"BusinessTemplates",
"catched",
"by",
"postPersist",
"and",
"dispatch",
"event",
"to",
"generate",
"the",
"needed",
"ViewReferences",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/EventSubscriber/BusinessEntitySubscriber.php#L170-L236 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/EventSubscriber/BusinessEntitySubscriber.php | BusinessEntitySubscriber.updateViewReference | private function updateViewReference(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
//if entity is a translation, get its translatable entity
if (in_array(Translation::class, class_uses($entity)) && null !== $entity->getTranslatable()) {
$entity = $entity->getTranslatable();
}
//if it's a businessEntity we need to rebuild virtuals (BPs are rebuild in businessEntitySubscriber)
if ($businessEntity = $this->businessEntityHelper->findByEntityInstance($entity)) {
$this->flushedBusinessEntities->add($entity);
}
//if it a businessTemplate we have to rebuild virtuals or update BP
if ($entity instanceof BusinessTemplate) {
$this->flushedBusinessTemplates->add($entity);
}
} | php | private function updateViewReference(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
//if entity is a translation, get its translatable entity
if (in_array(Translation::class, class_uses($entity)) && null !== $entity->getTranslatable()) {
$entity = $entity->getTranslatable();
}
//if it's a businessEntity we need to rebuild virtuals (BPs are rebuild in businessEntitySubscriber)
if ($businessEntity = $this->businessEntityHelper->findByEntityInstance($entity)) {
$this->flushedBusinessEntities->add($entity);
}
//if it a businessTemplate we have to rebuild virtuals or update BP
if ($entity instanceof BusinessTemplate) {
$this->flushedBusinessTemplates->add($entity);
}
} | [
"private",
"function",
"updateViewReference",
"(",
"LifecycleEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"entity",
"=",
"$",
"eventArgs",
"->",
"getEntity",
"(",
")",
";",
"//if entity is a translation, get its translatable entity",
"if",
"(",
"in_array",
"(",
"Trans... | This method throw an event if needed for a view related to a businessEntity.
@param LifecycleEventArgs $eventArgs
@throws \Exception | [
"This",
"method",
"throw",
"an",
"event",
"if",
"needed",
"for",
"a",
"view",
"related",
"to",
"a",
"businessEntity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/EventSubscriber/BusinessEntitySubscriber.php#L245-L262 | train |
Victoire/victoire | Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php | BaseWidgetContentResolver.getWidgetStaticContent | public function getWidgetStaticContent(Widget $widget)
{
$reflect = new \ReflectionClass($widget);
$widgetProperties = $reflect->getProperties();
$parameters = ['widget' => $widget];
$accessor = PropertyAccess::createPropertyAccessor();
foreach ($widgetProperties as $property) {
if (!$property->isStatic()) {
$value = $accessor->getValue($widget, $property->getName());
$parameters[$property->getName()] = $value;
}
}
return $parameters;
} | php | public function getWidgetStaticContent(Widget $widget)
{
$reflect = new \ReflectionClass($widget);
$widgetProperties = $reflect->getProperties();
$parameters = ['widget' => $widget];
$accessor = PropertyAccess::createPropertyAccessor();
foreach ($widgetProperties as $property) {
if (!$property->isStatic()) {
$value = $accessor->getValue($widget, $property->getName());
$parameters[$property->getName()] = $value;
}
}
return $parameters;
} | [
"public",
"function",
"getWidgetStaticContent",
"(",
"Widget",
"$",
"widget",
")",
"{",
"$",
"reflect",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"widget",
")",
";",
"$",
"widgetProperties",
"=",
"$",
"reflect",
"->",
"getProperties",
"(",
")",
";",
"... | Get the static content of the widget.
@param Widget $widget
@return string | [
"Get",
"the",
"static",
"content",
"of",
"the",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php#L22-L37 | train |
Victoire/victoire | Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php | BaseWidgetContentResolver.getWidgetBusinessEntityContent | public function getWidgetBusinessEntityContent(Widget $widget)
{
$entity = $widget->getEntity();
$parameters = $this->getWidgetStaticContent($widget);
$this->populateParametersWithWidgetFields($widget, $entity, $parameters);
return $parameters;
} | php | public function getWidgetBusinessEntityContent(Widget $widget)
{
$entity = $widget->getEntity();
$parameters = $this->getWidgetStaticContent($widget);
$this->populateParametersWithWidgetFields($widget, $entity, $parameters);
return $parameters;
} | [
"public",
"function",
"getWidgetBusinessEntityContent",
"(",
"Widget",
"$",
"widget",
")",
"{",
"$",
"entity",
"=",
"$",
"widget",
"->",
"getEntity",
"(",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getWidgetStaticContent",
"(",
"$",
"widget",
")",... | Get the business entity content.
@param Widget $widget
@return string | [
"Get",
"the",
"business",
"entity",
"content",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php#L46-L54 | train |
Victoire/victoire | Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php | BaseWidgetContentResolver.getWidgetQueryContent | public function getWidgetQueryContent(Widget $widget)
{
$parameters = $this->getWidgetStaticContent($widget);
$entity = $this->getWidgetQueryBuilder($widget)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
$fields = $widget->getFields();
$this->populateParametersWithWidgetFields($widget, $entity, $parameters);
return $parameters;
} | php | public function getWidgetQueryContent(Widget $widget)
{
$parameters = $this->getWidgetStaticContent($widget);
$entity = $this->getWidgetQueryBuilder($widget)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
$fields = $widget->getFields();
$this->populateParametersWithWidgetFields($widget, $entity, $parameters);
return $parameters;
} | [
"public",
"function",
"getWidgetQueryContent",
"(",
"Widget",
"$",
"widget",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"getWidgetStaticContent",
"(",
"$",
"widget",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getWidgetQueryBuilder",
"(",
"$"... | Get the content of the widget for the query mode.
@param Widget $widget
@return string | [
"Get",
"the",
"content",
"of",
"the",
"widget",
"for",
"the",
"query",
"mode",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php#L81-L94 | train |
Victoire/victoire | Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php | BaseWidgetContentResolver.getWidgetQueryBuilder | public function getWidgetQueryBuilder(Widget $widget)
{
//get the base query
$itemsQueryBuilder = $this->queryHelper->getQueryBuilder($widget, $this->entityManager);
// Filter only visibleOnFront
$itemsQueryBuilder->andWhere('main_item.visibleOnFront = true');
//add the query of the widget
return $this->queryHelper->buildWithSubQuery($widget, $itemsQueryBuilder, $this->entityManager);
} | php | public function getWidgetQueryBuilder(Widget $widget)
{
//get the base query
$itemsQueryBuilder = $this->queryHelper->getQueryBuilder($widget, $this->entityManager);
// Filter only visibleOnFront
$itemsQueryBuilder->andWhere('main_item.visibleOnFront = true');
//add the query of the widget
return $this->queryHelper->buildWithSubQuery($widget, $itemsQueryBuilder, $this->entityManager);
} | [
"public",
"function",
"getWidgetQueryBuilder",
"(",
"Widget",
"$",
"widget",
")",
"{",
"//get the base query",
"$",
"itemsQueryBuilder",
"=",
"$",
"this",
"->",
"queryHelper",
"->",
"getQueryBuilder",
"(",
"$",
"widget",
",",
"$",
"this",
"->",
"entityManager",
... | Get the widget query result.
@param Widget $widget The widget
@return \Doctrine\ORM\QueryBuilder The list of entities | [
"Get",
"the",
"widget",
"query",
"result",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Resolver/BaseWidgetContentResolver.php#L103-L113 | train |
Victoire/victoire | Bundle/BlogBundle/Form/HierarchyTreeType.php | HierarchyTreeType.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
foreach ($view->vars['choices'] as $choice) {
$dataNode = $choice->data;
$level = $this->propertyAccessor->getValue($dataNode, 'lvl');
$choice->label = str_repeat(str_repeat(' ', $level), 4).$choice->label;
}
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
foreach ($view->vars['choices'] as $choice) {
$dataNode = $choice->data;
$level = $this->propertyAccessor->getValue($dataNode, 'lvl');
$choice->label = str_repeat(str_repeat(' ', $level), 4).$choice->label;
}
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"view",
"->",
"vars",
"[",
"'choices'",
"]",
"as",
"$",
"choice",
")",
"{",
"$",
"dataNode"... | genere le formulaire.
@param \Symfony\Component\Form\FormView $view
@param \Symfony\Component\Form\FormInterface $form
@param array $options | [
"genere",
"le",
"formulaire",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Form/HierarchyTreeType.php#L41-L49 | train |
Victoire/victoire | Bundle/WidgetBundle/Controller/WidgetCacheController.php | WidgetCacheController.clearAction | public function clearAction(Request $request)
{
if (!$this->getParameter('kernel.debug')) {
throw new AccessDeniedException('You should be in debug mode to access this feature');
}
$this->get('victoire_widget.widget_cache')->clear();
return $this->redirect($request->headers->get('referer'));
} | php | public function clearAction(Request $request)
{
if (!$this->getParameter('kernel.debug')) {
throw new AccessDeniedException('You should be in debug mode to access this feature');
}
$this->get('victoire_widget.widget_cache')->clear();
return $this->redirect($request->headers->get('referer'));
} | [
"public",
"function",
"clearAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getParameter",
"(",
"'kernel.debug'",
")",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
"'You should be in debug mode to access this feature... | Clear the widgetcache.
@param Request $request
@Route("/victoire-dcms-public/widget-cache/clear", name="victoire_core_widget_cache_clear")
@throws Exception
@return Response | [
"Clear",
"the",
"widgetcache",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Controller/WidgetCacheController.php#L31-L39 | train |
Victoire/victoire | Bundle/PageBundle/Controller/PageController.php | PageController.newAction | public function newAction(Request $request, $isHomepage = false)
{
return new JsonResponse(parent::newAction($request, $isHomepage));
} | php | public function newAction(Request $request, $isHomepage = false)
{
return new JsonResponse(parent::newAction($request, $isHomepage));
} | [
"public",
"function",
"newAction",
"(",
"Request",
"$",
"request",
",",
"$",
"isHomepage",
"=",
"false",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"parent",
"::",
"newAction",
"(",
"$",
"request",
",",
"$",
"isHomepage",
")",
")",
";",
"}"
] | Display a form to create a new Page.
@param Request $request
@param bool $isHomepage Is the page a homepage
@Route("/new", name="victoire_core_page_new", defaults={"isHomepage" : false})
@Route("/homepage/new", name="victoire_core_homepage_new", defaults={"isHomepage" : true})
@Method("GET")
@return JsonResponse | [
"Display",
"a",
"form",
"to",
"create",
"a",
"new",
"Page",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/PageController.php#L34-L37 | train |
Victoire/victoire | Bundle/PageBundle/Controller/PageController.php | PageController.settingsAction | public function settingsAction(Request $request, BasePage $page)
{
return new JsonResponse(parent::settingsAction($request, $page));
} | php | public function settingsAction(Request $request, BasePage $page)
{
return new JsonResponse(parent::settingsAction($request, $page));
} | [
"public",
"function",
"settingsAction",
"(",
"Request",
"$",
"request",
",",
"BasePage",
"$",
"page",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"parent",
"::",
"settingsAction",
"(",
"$",
"request",
",",
"$",
"page",
")",
")",
";",
"}"
] | Display a form to edit Page settings.
@param Request $request
@param BasePage $page
@Route("/{id}/settings", name="victoire_core_page_settings")
@Method("GET")
@ParamConverter("page", class="VictoirePageBundle:BasePage")
@return JsonResponse The settings | [
"Display",
"a",
"form",
"to",
"edit",
"Page",
"settings",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/PageController.php#L67-L70 | train |
Victoire/victoire | Bundle/PageBundle/Controller/PageController.php | PageController.settingsPostAction | public function settingsPostAction(Request $request, BasePage $page)
{
return new JsonResponse(parent::settingsPostAction($request, $page));
} | php | public function settingsPostAction(Request $request, BasePage $page)
{
return new JsonResponse(parent::settingsPostAction($request, $page));
} | [
"public",
"function",
"settingsPostAction",
"(",
"Request",
"$",
"request",
",",
"BasePage",
"$",
"page",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"parent",
"::",
"settingsPostAction",
"(",
"$",
"request",
",",
"$",
"page",
")",
")",
";",
"}"
] | Save Page settings.
@param Request $request
@param BasePage $page
@Route("/{id}/settings", name="victoire_core_page_settings_post")
@Method("POST")
@ParamConverter("page", class="VictoirePageBundle:BasePage")
@return JsonResponse The settings | [
"Save",
"Page",
"settings",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/PageController.php#L84-L87 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php | WidgetDataWarmer.warm | public function warm(EntityManager $em, View $view)
{
$this->em = $em;
/* @var WidgetRepository $widgetRepo */
$widgetRepo = $this->em->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget');
$viewWidgets = $widgetRepo->findAllWidgetsForView($view);
$this->injectWidgets($view, $viewWidgets);
$this->extractAssociatedEntities($viewWidgets);
} | php | public function warm(EntityManager $em, View $view)
{
$this->em = $em;
/* @var WidgetRepository $widgetRepo */
$widgetRepo = $this->em->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget');
$viewWidgets = $widgetRepo->findAllWidgetsForView($view);
$this->injectWidgets($view, $viewWidgets);
$this->extractAssociatedEntities($viewWidgets);
} | [
"public",
"function",
"warm",
"(",
"EntityManager",
"$",
"em",
",",
"View",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"em",
"=",
"$",
"em",
";",
"/* @var WidgetRepository $widgetRepo */",
"$",
"widgetRepo",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepositor... | Find all Widgets for current View, inject them in WidgetMap and warm associated entities.
@param EntityManager $em
@param View $view | [
"Find",
"all",
"Widgets",
"for",
"current",
"View",
"inject",
"them",
"in",
"WidgetMap",
"and",
"warm",
"associated",
"entities",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php#L59-L70 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php | WidgetDataWarmer.injectWidgets | private function injectWidgets(View $view, $viewWidgets)
{
$builtWidgetMap = $view->getBuiltWidgetMap();
foreach ($builtWidgetMap as $slot => $widgetMaps) {
foreach ($widgetMaps as $i => $widgetMap) {
foreach ($viewWidgets as $widget) {
if ($widget->getWidgetMap() == $widgetMap) {
$builtWidgetMap[$slot][$i]->addWidget($widget);
//Override Collection default behaviour to avoid useless query
$builtWidgetMap[$slot][$i]->getWidgets()->setDirty(false);
$builtWidgetMap[$slot][$i]->getWidgets()->setInitialized(true);
continue;
}
}
}
}
$view->setBuiltWidgetMap($builtWidgetMap);
} | php | private function injectWidgets(View $view, $viewWidgets)
{
$builtWidgetMap = $view->getBuiltWidgetMap();
foreach ($builtWidgetMap as $slot => $widgetMaps) {
foreach ($widgetMaps as $i => $widgetMap) {
foreach ($viewWidgets as $widget) {
if ($widget->getWidgetMap() == $widgetMap) {
$builtWidgetMap[$slot][$i]->addWidget($widget);
//Override Collection default behaviour to avoid useless query
$builtWidgetMap[$slot][$i]->getWidgets()->setDirty(false);
$builtWidgetMap[$slot][$i]->getWidgets()->setInitialized(true);
continue;
}
}
}
}
$view->setBuiltWidgetMap($builtWidgetMap);
} | [
"private",
"function",
"injectWidgets",
"(",
"View",
"$",
"view",
",",
"$",
"viewWidgets",
")",
"{",
"$",
"builtWidgetMap",
"=",
"$",
"view",
"->",
"getBuiltWidgetMap",
"(",
")",
";",
"foreach",
"(",
"$",
"builtWidgetMap",
"as",
"$",
"slot",
"=>",
"$",
"... | Inject Widgets in View's builtWidgetMap.
@param View $view
@param $viewWidgets | [
"Inject",
"Widgets",
"in",
"View",
"s",
"builtWidgetMap",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php#L78-L98 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php | WidgetDataWarmer.extractAssociatedEntities | private function extractAssociatedEntities(array $entities)
{
$linkIds = $associatedEntities = [];
foreach ($entities as $entity) {
$reflect = new \ReflectionClass($entity);
//If Widget is already in cache, extract only its Criterias (used outside Widget rendering)
$widgetCached = ($entity instanceof Widget && $this->widgetHelper->isCacheEnabled($entity));
//If Widget has LinkTrait, store the entity link id
if (!$widgetCached && $this->hasLinkTrait($reflect) && $entity->getLink()) {
$linkIds[] = $entity->getLink()->getId();
}
//Pass through all entity associations
$metaData = $this->em->getClassMetadata(get_class($entity));
foreach ($metaData->getAssociationMappings() as $association) {
$targetClass = $association['targetEntity'];
//Skip already set WidgetMap association
if ($targetClass == WidgetMap::class) {
continue;
}
//If Widget has OneToOne or ManyToOne association, store target entity id to construct
//a single query for this entity type
if ($metaData->isSingleValuedAssociation($association['fieldName'])
&& !$widgetCached
) {
//If target Entity is not null, treat it
if ($targetEntity = $this->accessor->getValue($entity, $association['fieldName'])) {
$associatedEntities[$targetClass]['id']['unsorted']['entitiesToWarm'][] = new AssociatedEntityToWarm(
AssociatedEntityToWarm::TYPE_MANY_TO_ONE,
$entity,
$association['fieldName'],
$targetEntity->getId()
);
}
}
//If Widget has OneToMany association, store owner entity id and mappedBy value
//to construct a single query for this entity type
elseif ($metaData->isCollectionValuedAssociation($association['fieldName'])) {
//Even if Widget is cached, we need its Criterias used before cache call
if (!$widgetCached || $targetClass === Criteria::class) {
//If Collection is not null, treat it
if ($this->accessor->getValue($entity, $association['fieldName'])) {
//Don't use Collection getter directly and override Collection
//default behaviour to avoid useless query
$getter = 'get'.ucwords($association['fieldName']);
$entity->$getter()->setDirty(false);
$entity->$getter()->setInitialized(true);
$orderByToken = 'unsorted';
if (isset($association['orderBy'])) {
$orderByToken = implode($association['orderBy']);
$associatedEntities[$targetClass][$association['mappedBy']][$orderByToken]['orderBy'] = $association['orderBy'];
}
$associatedEntities[$targetClass][$association['mappedBy']][$orderByToken]['entitiesToWarm'][] = new AssociatedEntityToWarm(
AssociatedEntityToWarm::TYPE_ONE_TO_MANY,
$entity,
$association['fieldName'],
$entity->getId()
);
}
}
}
}
}
$newEntities = $this->setAssociatedEntities($associatedEntities);
$this->setPagesForLinks($linkIds);
//Recursive call if previous has return new entities to warm
if ($newEntities) {
$this->extractAssociatedEntities($newEntities);
}
} | php | private function extractAssociatedEntities(array $entities)
{
$linkIds = $associatedEntities = [];
foreach ($entities as $entity) {
$reflect = new \ReflectionClass($entity);
//If Widget is already in cache, extract only its Criterias (used outside Widget rendering)
$widgetCached = ($entity instanceof Widget && $this->widgetHelper->isCacheEnabled($entity));
//If Widget has LinkTrait, store the entity link id
if (!$widgetCached && $this->hasLinkTrait($reflect) && $entity->getLink()) {
$linkIds[] = $entity->getLink()->getId();
}
//Pass through all entity associations
$metaData = $this->em->getClassMetadata(get_class($entity));
foreach ($metaData->getAssociationMappings() as $association) {
$targetClass = $association['targetEntity'];
//Skip already set WidgetMap association
if ($targetClass == WidgetMap::class) {
continue;
}
//If Widget has OneToOne or ManyToOne association, store target entity id to construct
//a single query for this entity type
if ($metaData->isSingleValuedAssociation($association['fieldName'])
&& !$widgetCached
) {
//If target Entity is not null, treat it
if ($targetEntity = $this->accessor->getValue($entity, $association['fieldName'])) {
$associatedEntities[$targetClass]['id']['unsorted']['entitiesToWarm'][] = new AssociatedEntityToWarm(
AssociatedEntityToWarm::TYPE_MANY_TO_ONE,
$entity,
$association['fieldName'],
$targetEntity->getId()
);
}
}
//If Widget has OneToMany association, store owner entity id and mappedBy value
//to construct a single query for this entity type
elseif ($metaData->isCollectionValuedAssociation($association['fieldName'])) {
//Even if Widget is cached, we need its Criterias used before cache call
if (!$widgetCached || $targetClass === Criteria::class) {
//If Collection is not null, treat it
if ($this->accessor->getValue($entity, $association['fieldName'])) {
//Don't use Collection getter directly and override Collection
//default behaviour to avoid useless query
$getter = 'get'.ucwords($association['fieldName']);
$entity->$getter()->setDirty(false);
$entity->$getter()->setInitialized(true);
$orderByToken = 'unsorted';
if (isset($association['orderBy'])) {
$orderByToken = implode($association['orderBy']);
$associatedEntities[$targetClass][$association['mappedBy']][$orderByToken]['orderBy'] = $association['orderBy'];
}
$associatedEntities[$targetClass][$association['mappedBy']][$orderByToken]['entitiesToWarm'][] = new AssociatedEntityToWarm(
AssociatedEntityToWarm::TYPE_ONE_TO_MANY,
$entity,
$association['fieldName'],
$entity->getId()
);
}
}
}
}
}
$newEntities = $this->setAssociatedEntities($associatedEntities);
$this->setPagesForLinks($linkIds);
//Recursive call if previous has return new entities to warm
if ($newEntities) {
$this->extractAssociatedEntities($newEntities);
}
} | [
"private",
"function",
"extractAssociatedEntities",
"(",
"array",
"$",
"entities",
")",
"{",
"$",
"linkIds",
"=",
"$",
"associatedEntities",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"reflect",
"=",
"new",
"... | Pass through all widgets and associated entities to extract all missing associations,
store it by repository to group queries by entity type.
@param Widget[] $entities Widgets and associated entities | [
"Pass",
"through",
"all",
"widgets",
"and",
"associated",
"entities",
"to",
"extract",
"all",
"missing",
"associations",
"store",
"it",
"by",
"repository",
"to",
"group",
"queries",
"by",
"entity",
"type",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php#L106-L188 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php | WidgetDataWarmer.setAssociatedEntities | private function setAssociatedEntities(array $repositories)
{
$newEntities = [];
foreach ($repositories as $repositoryName => $findMethods) {
foreach ($findMethods as $findMethod => $groupedBySortAssociatedEntitiesToWarm) {
foreach ($groupedBySortAssociatedEntitiesToWarm as $orderByToken => $groupedAssociatedEntitiesToWarm) {
$associatedEntitiesToWarm = $groupedAssociatedEntitiesToWarm['entitiesToWarm'];
//Extract ids to search
$idsToSearch = array_map(function ($associatedEntityToWarm) {
return $associatedEntityToWarm->getEntityId();
}, $associatedEntitiesToWarm);
$orderBy = [];
if ($orderByToken !== 'unsorted') {
foreach ($groupedAssociatedEntitiesToWarm['orderBy'] as $orderAttribut => $order) {
$orderBy[$orderAttribut] = $order;
}
}
//Find by id for ManyToOne associations based on target entity id
//Find by mappedBy value for OneToMany associations based on owner entity id
$foundEntities = $this->em->getRepository($repositoryName)->findBy([
$findMethod => array_values($idsToSearch),
], $orderBy);
/* @var AssociatedEntityToWarm[] $associatedEntitiesToWarm */
foreach ($associatedEntitiesToWarm as $associatedEntityToWarm) {
foreach ($foundEntities as $foundEntity) {
if ($associatedEntityToWarm->getType() === AssociatedEntityToWarm::TYPE_MANY_TO_ONE
&& $foundEntity->getId() === $associatedEntityToWarm->getEntityId()
) {
$inheritorEntity = $associatedEntityToWarm->getInheritorEntity();
$inheritorPropertyName = $associatedEntityToWarm->getInheritorPropertyName();
$this->accessor->setValue($inheritorEntity, $inheritorPropertyName, $foundEntity);
continue;
} elseif ($associatedEntityToWarm->getType() === AssociatedEntityToWarm::TYPE_ONE_TO_MANY
&& $this->accessor->getValue($foundEntity, $findMethod) === $associatedEntityToWarm->getInheritorEntity()
) {
$inheritorEntity = $associatedEntityToWarm->getInheritorEntity();
$inheritorPropertyName = $associatedEntityToWarm->getInheritorPropertyName();
//Don't use Collection getter directly and override Collection
//default behaviour to avoid useless query
$getter = 'get'.ucwords($inheritorPropertyName);
$inheritorEntity->$getter()->add($foundEntity);
$inheritorEntity->$getter()->setDirty(false);
$inheritorEntity->$getter()->setInitialized(true);
//Store new entities to warm if necessary
$newEntities[] = $foundEntity;
continue;
}
}
}
}
}
}
return $newEntities;
} | php | private function setAssociatedEntities(array $repositories)
{
$newEntities = [];
foreach ($repositories as $repositoryName => $findMethods) {
foreach ($findMethods as $findMethod => $groupedBySortAssociatedEntitiesToWarm) {
foreach ($groupedBySortAssociatedEntitiesToWarm as $orderByToken => $groupedAssociatedEntitiesToWarm) {
$associatedEntitiesToWarm = $groupedAssociatedEntitiesToWarm['entitiesToWarm'];
//Extract ids to search
$idsToSearch = array_map(function ($associatedEntityToWarm) {
return $associatedEntityToWarm->getEntityId();
}, $associatedEntitiesToWarm);
$orderBy = [];
if ($orderByToken !== 'unsorted') {
foreach ($groupedAssociatedEntitiesToWarm['orderBy'] as $orderAttribut => $order) {
$orderBy[$orderAttribut] = $order;
}
}
//Find by id for ManyToOne associations based on target entity id
//Find by mappedBy value for OneToMany associations based on owner entity id
$foundEntities = $this->em->getRepository($repositoryName)->findBy([
$findMethod => array_values($idsToSearch),
], $orderBy);
/* @var AssociatedEntityToWarm[] $associatedEntitiesToWarm */
foreach ($associatedEntitiesToWarm as $associatedEntityToWarm) {
foreach ($foundEntities as $foundEntity) {
if ($associatedEntityToWarm->getType() === AssociatedEntityToWarm::TYPE_MANY_TO_ONE
&& $foundEntity->getId() === $associatedEntityToWarm->getEntityId()
) {
$inheritorEntity = $associatedEntityToWarm->getInheritorEntity();
$inheritorPropertyName = $associatedEntityToWarm->getInheritorPropertyName();
$this->accessor->setValue($inheritorEntity, $inheritorPropertyName, $foundEntity);
continue;
} elseif ($associatedEntityToWarm->getType() === AssociatedEntityToWarm::TYPE_ONE_TO_MANY
&& $this->accessor->getValue($foundEntity, $findMethod) === $associatedEntityToWarm->getInheritorEntity()
) {
$inheritorEntity = $associatedEntityToWarm->getInheritorEntity();
$inheritorPropertyName = $associatedEntityToWarm->getInheritorPropertyName();
//Don't use Collection getter directly and override Collection
//default behaviour to avoid useless query
$getter = 'get'.ucwords($inheritorPropertyName);
$inheritorEntity->$getter()->add($foundEntity);
$inheritorEntity->$getter()->setDirty(false);
$inheritorEntity->$getter()->setInitialized(true);
//Store new entities to warm if necessary
$newEntities[] = $foundEntity;
continue;
}
}
}
}
}
}
return $newEntities;
} | [
"private",
"function",
"setAssociatedEntities",
"(",
"array",
"$",
"repositories",
")",
"{",
"$",
"newEntities",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"repositories",
"as",
"$",
"repositoryName",
"=>",
"$",
"findMethods",
")",
"{",
"foreach",
"(",
"$",
... | Set all missing associated entities.
@param array $repositories
@throws \Throwable
@throws \TypeError
@return array | [
"Set",
"all",
"missing",
"associated",
"entities",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php#L200-L261 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php | WidgetDataWarmer.setPagesForLinks | private function setPagesForLinks(array $linkIds)
{
$viewReferences = [];
/* @var Link[] $links */
$links = $this->em->getRepository('VictoireCoreBundle:Link')->findById($linkIds);
foreach ($links as $link) {
if ($link->getParameters()['linkType'] == 'viewReference') {
$viewReference = $this->viewReferenceRepository->getOneReferenceByParameters([
'id' => $link->getParameters()['viewReference'],
'locale' => $link->getParameters()['locale'],
]);
if ($viewReference instanceof ViewReference) {
$viewReferences[$link->getId()] = $viewReference;
}
}
}
/* @var Page[] $pages */
$pages = $this->em->getRepository('VictoireCoreBundle:View')->findByViewReferences($viewReferences);
foreach ($links as $link) {
foreach ($pages as $page) {
if (!($page instanceof BusinessTemplate) && $page->getReference() && $link->getViewReference() == $page->getReference()->getId()) {
$link->setViewReferencePage($page);
}
}
}
} | php | private function setPagesForLinks(array $linkIds)
{
$viewReferences = [];
/* @var Link[] $links */
$links = $this->em->getRepository('VictoireCoreBundle:Link')->findById($linkIds);
foreach ($links as $link) {
if ($link->getParameters()['linkType'] == 'viewReference') {
$viewReference = $this->viewReferenceRepository->getOneReferenceByParameters([
'id' => $link->getParameters()['viewReference'],
'locale' => $link->getParameters()['locale'],
]);
if ($viewReference instanceof ViewReference) {
$viewReferences[$link->getId()] = $viewReference;
}
}
}
/* @var Page[] $pages */
$pages = $this->em->getRepository('VictoireCoreBundle:View')->findByViewReferences($viewReferences);
foreach ($links as $link) {
foreach ($pages as $page) {
if (!($page instanceof BusinessTemplate) && $page->getReference() && $link->getViewReference() == $page->getReference()->getId()) {
$link->setViewReferencePage($page);
}
}
}
} | [
"private",
"function",
"setPagesForLinks",
"(",
"array",
"$",
"linkIds",
")",
"{",
"$",
"viewReferences",
"=",
"[",
"]",
";",
"/* @var Link[] $links */",
"$",
"links",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'VictoireCoreBundle:Link'",
")",
... | Set viewReferencePage for each link.
@param array $linkIds | [
"Set",
"viewReferencePage",
"for",
"each",
"link",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php#L268-L298 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php | WidgetDataWarmer.hasLinkTrait | private function hasLinkTrait(\ReflectionClass $reflect)
{
$traits = $reflect->getTraits();
foreach ($traits as $trait) {
if ($trait->getName() == LinkTrait::class) {
return true;
}
}
if ($parentClass = $reflect->getParentClass()) {
if ($this->hasLinkTrait($parentClass)) {
return true;
}
}
return false;
} | php | private function hasLinkTrait(\ReflectionClass $reflect)
{
$traits = $reflect->getTraits();
foreach ($traits as $trait) {
if ($trait->getName() == LinkTrait::class) {
return true;
}
}
if ($parentClass = $reflect->getParentClass()) {
if ($this->hasLinkTrait($parentClass)) {
return true;
}
}
return false;
} | [
"private",
"function",
"hasLinkTrait",
"(",
"\\",
"ReflectionClass",
"$",
"reflect",
")",
"{",
"$",
"traits",
"=",
"$",
"reflect",
"->",
"getTraits",
"(",
")",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"{",
"if",
"(",
"$",
"trait",
... | Check if reflection class has LinkTrait.
@param \ReflectionClass $reflect
@return bool | [
"Check",
"if",
"reflection",
"class",
"has",
"LinkTrait",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Warmer/WidgetDataWarmer.php#L307-L323 | train |
Victoire/victoire | Bundle/TwigBundle/Repository/ErrorPageRepository.php | ErrorPageRepository.findOneByCode | public function findOneByCode($code, $deepMode = false)
{
//the query builder
$page = $this->createQueryBuilder($this->mainAlias)
->where($this->mainAlias.'.code = :code')
->setParameter('code', $code)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
if (!$page && $deepMode) {
// Check for a same family error
// for example, for a 404 code, if the 404 error page doesn't exist, we check for a 400 errorPage
$page = $this->findOneByCode(floor($code / 100) * 100);
}
return $page;
} | php | public function findOneByCode($code, $deepMode = false)
{
//the query builder
$page = $this->createQueryBuilder($this->mainAlias)
->where($this->mainAlias.'.code = :code')
->setParameter('code', $code)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
if (!$page && $deepMode) {
// Check for a same family error
// for example, for a 404 code, if the 404 error page doesn't exist, we check for a 400 errorPage
$page = $this->findOneByCode(floor($code / 100) * 100);
}
return $page;
} | [
"public",
"function",
"findOneByCode",
"(",
"$",
"code",
",",
"$",
"deepMode",
"=",
"false",
")",
"{",
"//the query builder",
"$",
"page",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"$",
"this",
"->",
"mainAlias",
")",
"->",
"where",
"(",
"$",
"t... | Get a page according to the given code.
@param int $code The error code
@return Page | [
"Get",
"a",
"page",
"according",
"to",
"the",
"given",
"code",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/TwigBundle/Repository/ErrorPageRepository.php#L19-L36 | train |
Victoire/victoire | Bundle/BusinessPageBundle/Entity/BusinessPage.php | BusinessPage.getBusinessEntity | public function getBusinessEntity()
{
//if there is no entity
if ($this->businessEntity === null) {
//if there is a proxy
if ($this->getEntityProxy() !== null) {
$this->businessEntity = $this->getEntityProxy()->getEntity($this->getBusinessEntityId());
return $this->businessEntity;
}
}
return $this->businessEntity;
} | php | public function getBusinessEntity()
{
//if there is no entity
if ($this->businessEntity === null) {
//if there is a proxy
if ($this->getEntityProxy() !== null) {
$this->businessEntity = $this->getEntityProxy()->getEntity($this->getBusinessEntityId());
return $this->businessEntity;
}
}
return $this->businessEntity;
} | [
"public",
"function",
"getBusinessEntity",
"(",
")",
"{",
"//if there is no entity",
"if",
"(",
"$",
"this",
"->",
"businessEntity",
"===",
"null",
")",
"{",
"//if there is a proxy",
"if",
"(",
"$",
"this",
"->",
"getEntityProxy",
"(",
")",
"!==",
"null",
")",... | Get the business entity.
@return number | [
"Get",
"the",
"business",
"entity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Entity/BusinessPage.php#L71-L84 | train |
Victoire/victoire | Bundle/CoreBundle/Twig/Extension/CmsExtension.php | CmsExtension.cmsWidgetUnlinkAction | public function cmsWidgetUnlinkAction($widgetId, $view)
{
$viewReference = $this->viewReferenceRepository->getOneReferenceByParameters(
['viewId' => $view->getId()]
);
if (!$viewReference && $view->getId() != '') {
$viewReference = new ViewReference($view->getId());
} elseif ($view instanceof VirtualBusinessPage) {
$viewReference = new ViewReference($view->getTemplate()->getId());
}
$view->setReference($viewReference);
return $this->widgetRenderer->renderUnlinkActionByWidgetId($widgetId, $view);
} | php | public function cmsWidgetUnlinkAction($widgetId, $view)
{
$viewReference = $this->viewReferenceRepository->getOneReferenceByParameters(
['viewId' => $view->getId()]
);
if (!$viewReference && $view->getId() != '') {
$viewReference = new ViewReference($view->getId());
} elseif ($view instanceof VirtualBusinessPage) {
$viewReference = new ViewReference($view->getTemplate()->getId());
}
$view->setReference($viewReference);
return $this->widgetRenderer->renderUnlinkActionByWidgetId($widgetId, $view);
} | [
"public",
"function",
"cmsWidgetUnlinkAction",
"(",
"$",
"widgetId",
",",
"$",
"view",
")",
"{",
"$",
"viewReference",
"=",
"$",
"this",
"->",
"viewReferenceRepository",
"->",
"getOneReferenceByParameters",
"(",
"[",
"'viewId'",
"=>",
"$",
"view",
"->",
"getId",... | render unlink action for a widgetId.
@param int $widgetId The widgetId to unlink
@return string the widget unlink action | [
"render",
"unlink",
"action",
"for",
"a",
"widgetId",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Twig/Extension/CmsExtension.php#L104-L118 | train |
Victoire/victoire | Bundle/CoreBundle/Twig/Extension/CmsExtension.php | CmsExtension.cmsSlotWidgets | public function cmsSlotWidgets($slotId, $slotOptions = [])
{
$currentView = $this->currentViewHelper->getUpdatedCurrentView();
$result = '';
$slotOptions = $this->widgetRenderer->computeOptions($slotId, $slotOptions);
if ($currentView && !empty($currentView->getBuiltWidgetMap()[$slotId])) {
//parse the widget maps
/* @var WidgetMap $widgetMap */
foreach ($currentView->getBuiltWidgetMap()[$slotId] as $widgetMap) {
$widget = null;
try {
//get the widget
$widget = $this->widgetResolver->resolve($widgetMap);
if ($widget) {
if (!$widgetMap->isAsynchronous()) {
//render this widget
$result .= $this->cmsWidget($widget);
} else {
$result .= $this->widgetRenderer->prepareAsynchronousRender($widget);
}
}
} catch (\Exception $ex) {
$result .= $this->widgetExceptionHandler->handle($ex, $currentView, $widget);
}
}
}
//the container for the slot
$ngSlotControllerName = 'slot'.$slotId.'Controller';
$ngInitLoadActions = $this->isRoleVictoireGranted() ? sprintf('ng-init=\'%s.init("%s", %s)\'', $ngSlotControllerName, $slotId, json_encode($slotOptions)) : '';
$result = sprintf(
'<div class="vic-slot" data-name="%s" id="vic-slot-%s" ng-controller="SlotController as %s" %s>%s</div>',
$slotId,
$slotId,
$ngSlotControllerName,
$ngInitLoadActions,
$result
);
return $result;
} | php | public function cmsSlotWidgets($slotId, $slotOptions = [])
{
$currentView = $this->currentViewHelper->getUpdatedCurrentView();
$result = '';
$slotOptions = $this->widgetRenderer->computeOptions($slotId, $slotOptions);
if ($currentView && !empty($currentView->getBuiltWidgetMap()[$slotId])) {
//parse the widget maps
/* @var WidgetMap $widgetMap */
foreach ($currentView->getBuiltWidgetMap()[$slotId] as $widgetMap) {
$widget = null;
try {
//get the widget
$widget = $this->widgetResolver->resolve($widgetMap);
if ($widget) {
if (!$widgetMap->isAsynchronous()) {
//render this widget
$result .= $this->cmsWidget($widget);
} else {
$result .= $this->widgetRenderer->prepareAsynchronousRender($widget);
}
}
} catch (\Exception $ex) {
$result .= $this->widgetExceptionHandler->handle($ex, $currentView, $widget);
}
}
}
//the container for the slot
$ngSlotControllerName = 'slot'.$slotId.'Controller';
$ngInitLoadActions = $this->isRoleVictoireGranted() ? sprintf('ng-init=\'%s.init("%s", %s)\'', $ngSlotControllerName, $slotId, json_encode($slotOptions)) : '';
$result = sprintf(
'<div class="vic-slot" data-name="%s" id="vic-slot-%s" ng-controller="SlotController as %s" %s>%s</div>',
$slotId,
$slotId,
$ngSlotControllerName,
$ngInitLoadActions,
$result
);
return $result;
} | [
"public",
"function",
"cmsSlotWidgets",
"(",
"$",
"slotId",
",",
"$",
"slotOptions",
"=",
"[",
"]",
")",
"{",
"$",
"currentView",
"=",
"$",
"this",
"->",
"currentViewHelper",
"->",
"getUpdatedCurrentView",
"(",
")",
";",
"$",
"result",
"=",
"''",
";",
"$... | render all widgets in a slot.
@param string $slotId
@param string $slotOptions
@return string HTML markup of the widget with action button if needed | [
"render",
"all",
"widgets",
"in",
"a",
"slot",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Twig/Extension/CmsExtension.php#L128-L171 | train |
Victoire/victoire | Bundle/CoreBundle/Twig/Extension/CmsExtension.php | CmsExtension.cmsWidget | public function cmsWidget($widget)
{
$widget->setCurrentView($this->currentViewHelper->getCurrentView());
try {
$response = $this->widgetRenderer->renderContainer($widget, $widget->getCurrentView());
} catch (\Exception $ex) {
$response = $this->widgetExceptionHandler->handle($ex, $widget);
}
return $response;
} | php | public function cmsWidget($widget)
{
$widget->setCurrentView($this->currentViewHelper->getCurrentView());
try {
$response = $this->widgetRenderer->renderContainer($widget, $widget->getCurrentView());
} catch (\Exception $ex) {
$response = $this->widgetExceptionHandler->handle($ex, $widget);
}
return $response;
} | [
"public",
"function",
"cmsWidget",
"(",
"$",
"widget",
")",
"{",
"$",
"widget",
"->",
"setCurrentView",
"(",
"$",
"this",
"->",
"currentViewHelper",
"->",
"getCurrentView",
"(",
")",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"widgetR... | Render a widget.
@param Widget $widget
@return string | [
"Render",
"a",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Twig/Extension/CmsExtension.php#L180-L191 | train |
Victoire/victoire | Bundle/CoreBundle/Twig/Extension/CmsExtension.php | CmsExtension.hash | public function hash($value, $algorithm = 'md5')
{
try {
return hash($algorithm, $value);
} catch (\Exception $e) {
error_log('Please check that the '.$algorithm.' does exists because it failed when trying to run. We are expecting a valid algorithm such as md5 or sha512 etc. ['.$e->getMessage().']');
return $value;
}
} | php | public function hash($value, $algorithm = 'md5')
{
try {
return hash($algorithm, $value);
} catch (\Exception $e) {
error_log('Please check that the '.$algorithm.' does exists because it failed when trying to run. We are expecting a valid algorithm such as md5 or sha512 etc. ['.$e->getMessage().']');
return $value;
}
} | [
"public",
"function",
"hash",
"(",
"$",
"value",
",",
"$",
"algorithm",
"=",
"'md5'",
")",
"{",
"try",
"{",
"return",
"hash",
"(",
"$",
"algorithm",
",",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"error_log",... | hash some string with given algorithm.
@param string $value The string to hash
@param string $algorithm The algorithm we have to use to hash the string
@return string | [
"hash",
"some",
"string",
"with",
"given",
"algorithm",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Twig/Extension/CmsExtension.php#L201-L210 | train |
Victoire/victoire | Bundle/CoreBundle/Twig/Extension/CmsExtension.php | CmsExtension.twigVicDateFormatFilter | public function twigVicDateFormatFilter($value, $format = 'F j, Y H:i', $timezone = null)
{
try {
$result = twig_date_format_filter($this->twig, $value, $format, $timezone);
} catch (\Exception $e) {
return $value;
}
return $result;
} | php | public function twigVicDateFormatFilter($value, $format = 'F j, Y H:i', $timezone = null)
{
try {
$result = twig_date_format_filter($this->twig, $value, $format, $timezone);
} catch (\Exception $e) {
return $value;
}
return $result;
} | [
"public",
"function",
"twigVicDateFormatFilter",
"(",
"$",
"value",
",",
"$",
"format",
"=",
"'F j, Y H:i'",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"twig_date_format_filter",
"(",
"$",
"this",
"->",
"twig",
",",
"$",
... | Converts a date to the given format.
@param string $format A format
@param DateTimeZone|string $timezone A timezone
<pre>
{{ post.published_at|date("m/d/Y") }}
</pre>
@return string The formatted date | [
"Converts",
"a",
"date",
"to",
"the",
"given",
"format",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Twig/Extension/CmsExtension.php#L224-L233 | train |
Victoire/victoire | Bundle/CoreBundle/Twig/Extension/CmsExtension.php | CmsExtension.isBusinessEntityAllowed | public function isBusinessEntityAllowed($formEntityName, View $view)
{
//the result
$isBusinessEntityAllowed = false;
if ($view instanceof BusinessTemplate || $view instanceof BusinessPage) {
//are we using the same business entity
if ($formEntityName === $view->getBusinessEntityId()) {
$isBusinessEntityAllowed = true;
}
}
return $isBusinessEntityAllowed;
} | php | public function isBusinessEntityAllowed($formEntityName, View $view)
{
//the result
$isBusinessEntityAllowed = false;
if ($view instanceof BusinessTemplate || $view instanceof BusinessPage) {
//are we using the same business entity
if ($formEntityName === $view->getBusinessEntityId()) {
$isBusinessEntityAllowed = true;
}
}
return $isBusinessEntityAllowed;
} | [
"public",
"function",
"isBusinessEntityAllowed",
"(",
"$",
"formEntityName",
",",
"View",
"$",
"view",
")",
"{",
"//the result",
"$",
"isBusinessEntityAllowed",
"=",
"false",
";",
"if",
"(",
"$",
"view",
"instanceof",
"BusinessTemplate",
"||",
"$",
"view",
"inst... | Is the business entity type allowed for the widget and the view context.
@param string $formEntityName The business entity name
@param View $view The view
@return bool Does the form allows this kind of business entity in this view | [
"Is",
"the",
"business",
"entity",
"type",
"allowed",
"for",
"the",
"widget",
"and",
"the",
"view",
"context",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Twig/Extension/CmsExtension.php#L257-L270 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Entity/BusinessEntity.php | BusinessEntity.setDisableForReceiverProperties | public function setDisableForReceiverProperties($receiverProperties = [])
{
foreach ($receiverProperties as $receiverProperty => $value) {
if (!array_key_exists($receiverProperty, $this->businessProperties)) {
$this->disable = true;
}
}
} | php | public function setDisableForReceiverProperties($receiverProperties = [])
{
foreach ($receiverProperties as $receiverProperty => $value) {
if (!array_key_exists($receiverProperty, $this->businessProperties)) {
$this->disable = true;
}
}
} | [
"public",
"function",
"setDisableForReceiverProperties",
"(",
"$",
"receiverProperties",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"receiverProperties",
"as",
"$",
"receiverProperty",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"... | Set disable if BusinessEntity dont have all receiverProperties required.
@param array $receiverProperties | [
"Set",
"disable",
"if",
"BusinessEntity",
"dont",
"have",
"all",
"receiverProperties",
"required",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Entity/BusinessEntity.php#L116-L123 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Entity/BusinessEntity.php | BusinessEntity.addBusinessProperty | public function addBusinessProperty(BusinessProperty $businessProperty)
{
//the type of business property (textable, slideable...)
$type = $businessProperty->getType();
if (!isset($this->businessProperties[$type])) {
$this->businessProperties[$type] = [];
}
//add the business property indexed by the type
$this->businessProperties[$type][] = $businessProperty;
} | php | public function addBusinessProperty(BusinessProperty $businessProperty)
{
//the type of business property (textable, slideable...)
$type = $businessProperty->getType();
if (!isset($this->businessProperties[$type])) {
$this->businessProperties[$type] = [];
}
//add the business property indexed by the type
$this->businessProperties[$type][] = $businessProperty;
} | [
"public",
"function",
"addBusinessProperty",
"(",
"BusinessProperty",
"$",
"businessProperty",
")",
"{",
"//the type of business property (textable, slideable...)",
"$",
"type",
"=",
"$",
"businessProperty",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"("... | Add a business property.
@param BusinessProperty $businessProperty | [
"Add",
"a",
"business",
"property",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Entity/BusinessEntity.php#L130-L141 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Entity/BusinessEntity.php | BusinessEntity.getBusinessPropertiesByType | public function getBusinessPropertiesByType($type)
{
$bp = [];
if (isset($this->businessProperties[$type])) {
$bp = $this->businessProperties[$type];
}
return $bp;
} | php | public function getBusinessPropertiesByType($type)
{
$bp = [];
if (isset($this->businessProperties[$type])) {
$bp = $this->businessProperties[$type];
}
return $bp;
} | [
"public",
"function",
"getBusinessPropertiesByType",
"(",
"$",
"type",
")",
"{",
"$",
"bp",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"businessProperties",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"bp",
"=",
"$",
"this",
"->... | Get the business properties by type.
@param string $type
@return array The businnes properties | [
"Get",
"the",
"business",
"properties",
"by",
"type",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Entity/BusinessEntity.php#L170-L179 | train |
Victoire/victoire | Bundle/MediaBundle/Entity/Media.php | Media.getMetadataValue | public function getMetadataValue($key)
{
return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
} | php | public function getMetadataValue($key)
{
return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
} | [
"public",
"function",
"getMetadataValue",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"metadata",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"metadata",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | Get the specified metadata value.
@param string $key
@return mixed|null | [
"Get",
"the",
"specified",
"metadata",
"value",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Entity/Media.php#L329-L332 | train |
Victoire/victoire | Bundle/CoreBundle/Listener/ViewCssListener.php | ViewCssListener.onRenderPage | public function onRenderPage(PageRenderEvent $event)
{
$currentView = $event->getCurrentView();
if ($currentView instanceof VirtualBusinessPage) {
$currentView->setCssHash($currentView->getTemplate()->getCssHash());
} elseif (!$currentView->getCssHash() || !$currentView->isCssUpToDate()) {
//CSS file will be regenerated during WidgetSubscriber onFlush event
$currentView->changeCssHash();
$this->entityManager->persist($currentView);
$this->entityManager->flush($currentView);
}
} | php | public function onRenderPage(PageRenderEvent $event)
{
$currentView = $event->getCurrentView();
if ($currentView instanceof VirtualBusinessPage) {
$currentView->setCssHash($currentView->getTemplate()->getCssHash());
} elseif (!$currentView->getCssHash() || !$currentView->isCssUpToDate()) {
//CSS file will be regenerated during WidgetSubscriber onFlush event
$currentView->changeCssHash();
$this->entityManager->persist($currentView);
$this->entityManager->flush($currentView);
}
} | [
"public",
"function",
"onRenderPage",
"(",
"PageRenderEvent",
"$",
"event",
")",
"{",
"$",
"currentView",
"=",
"$",
"event",
"->",
"getCurrentView",
"(",
")",
";",
"if",
"(",
"$",
"currentView",
"instanceof",
"VirtualBusinessPage",
")",
"{",
"$",
"currentView"... | Generate cssHash and css file for current View if cssHash has not been set yet or is not up to date.
@param PageRenderEvent $event
@throws \Exception | [
"Generate",
"cssHash",
"and",
"css",
"file",
"for",
"current",
"View",
"if",
"cssHash",
"has",
"not",
"been",
"set",
"yet",
"or",
"is",
"not",
"up",
"to",
"date",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Listener/ViewCssListener.php#L36-L49 | train |
Victoire/victoire | Bundle/TwigBundle/Controller/ErrorPageController.php | ErrorPageController.showAction | public function showAction(ErrorPage $page)
{
//add the view to twig
$this->container->get('twig')->addGlobal('view', $page);
$page->setReference(new ViewReference($page->getId()));
$parameters = [
'view' => $page,
'id' => $page->getId(),
'locale' => $page->getCurrentLocale(),
];
$this->get('victoire_widget_map.builder')->build($page);
$this->get('victoire_widget_map.widget_data_warmer')->warm(
$this->get('doctrine.orm.entity_manager'),
$page
);
$this->container->get('victoire_core.current_view')->setCurrentView($page);
//create the response
$response = $this->container->get('templating')->renderResponse(
'VictoireCoreBundle:Layout:'.$page->getTemplate()->getLayout().'.html.twig',
$parameters
);
return $response;
} | php | public function showAction(ErrorPage $page)
{
//add the view to twig
$this->container->get('twig')->addGlobal('view', $page);
$page->setReference(new ViewReference($page->getId()));
$parameters = [
'view' => $page,
'id' => $page->getId(),
'locale' => $page->getCurrentLocale(),
];
$this->get('victoire_widget_map.builder')->build($page);
$this->get('victoire_widget_map.widget_data_warmer')->warm(
$this->get('doctrine.orm.entity_manager'),
$page
);
$this->container->get('victoire_core.current_view')->setCurrentView($page);
//create the response
$response = $this->container->get('templating')->renderResponse(
'VictoireCoreBundle:Layout:'.$page->getTemplate()->getLayout().'.html.twig',
$parameters
);
return $response;
} | [
"public",
"function",
"showAction",
"(",
"ErrorPage",
"$",
"page",
")",
"{",
"//add the view to twig",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'twig'",
")",
"->",
"addGlobal",
"(",
"'view'",
",",
"$",
"page",
")",
";",
"$",
"page",
"->",
"setR... | Show an error page.
@Route("/{code}", name="victoire_errorPage_show")
@return Response | [
"Show",
"an",
"error",
"page",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/TwigBundle/Controller/ErrorPageController.php#L29-L55 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Builder/ViewReferenceBuilder.php | ViewReferenceBuilder.buildViewReference | public function buildViewReference(View $view, EntityManager $em = null)
{
$viewReferenceBuilder = $this->viewReferenceBuilderChain->getViewReferenceBuilder($view);
$viewReference = $viewReferenceBuilder->buildReference($view, $em);
return $viewReference;
} | php | public function buildViewReference(View $view, EntityManager $em = null)
{
$viewReferenceBuilder = $this->viewReferenceBuilderChain->getViewReferenceBuilder($view);
$viewReference = $viewReferenceBuilder->buildReference($view, $em);
return $viewReference;
} | [
"public",
"function",
"buildViewReference",
"(",
"View",
"$",
"view",
",",
"EntityManager",
"$",
"em",
"=",
"null",
")",
"{",
"$",
"viewReferenceBuilder",
"=",
"$",
"this",
"->",
"viewReferenceBuilderChain",
"->",
"getViewReferenceBuilder",
"(",
"$",
"view",
")"... | compute the viewReference relative to a View + entity.
@param WebViewInterface $view
@return ViewReference | [
"compute",
"the",
"viewReference",
"relative",
"to",
"a",
"View",
"+",
"entity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Builder/ViewReferenceBuilder.php#L31-L37 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.showAction | public function showAction(Request $request, $url = '')
{
$response = $this->get('victoire_page.page_helper')->renderPageByUrl(
$request->getUri(),
$url,
$request->getLocale(),
$request->isXmlHttpRequest() ? $request->query->get('modalLayout', null) : null
);
return $response;
} | php | public function showAction(Request $request, $url = '')
{
$response = $this->get('victoire_page.page_helper')->renderPageByUrl(
$request->getUri(),
$url,
$request->getLocale(),
$request->isXmlHttpRequest() ? $request->query->get('modalLayout', null) : null
);
return $response;
} | [
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
",",
"$",
"url",
"=",
"''",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"get",
"(",
"'victoire_page.page_helper'",
")",
"->",
"renderPageByUrl",
"(",
"$",
"request",
"->",
"getUri",... | Find Page from url and render it.
Route for this action is defined in RouteLoader.
@param Request $request
@param string $url
@return mixed | [
"Find",
"Page",
"from",
"url",
"and",
"render",
"it",
".",
"Route",
"for",
"this",
"action",
"is",
"defined",
"in",
"RouteLoader",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L34-L44 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.showByIdAction | public function showByIdAction(Request $request, $viewId, $entityId = null)
{
$parameters = [
'viewId' => $viewId,
'locale' => $request->getLocale(),
];
if ($entityId) {
$parameters['entityId'] = $entityId;
}
$page = $this->get('victoire_page.page_helper')->findPageByParameters($parameters);
return $this->redirect($this->generateUrl(
'victoire_core_page_show',
array_merge(
['url' => $page->getReference()->getUrl()],
$request->query->all()
)
));
} | php | public function showByIdAction(Request $request, $viewId, $entityId = null)
{
$parameters = [
'viewId' => $viewId,
'locale' => $request->getLocale(),
];
if ($entityId) {
$parameters['entityId'] = $entityId;
}
$page = $this->get('victoire_page.page_helper')->findPageByParameters($parameters);
return $this->redirect($this->generateUrl(
'victoire_core_page_show',
array_merge(
['url' => $page->getReference()->getUrl()],
$request->query->all()
)
));
} | [
"public",
"function",
"showByIdAction",
"(",
"Request",
"$",
"request",
",",
"$",
"viewId",
",",
"$",
"entityId",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"[",
"'viewId'",
"=>",
"$",
"viewId",
",",
"'locale'",
"=>",
"$",
"request",
"->",
"getLocale... | Find url for a View id and optionally an Entity id and redirect to showAction.
Route for this action is defined in RouteLoader.
@param Request $request
@param $viewId
@param null $entityId
@return RedirectResponse | [
"Find",
"url",
"for",
"a",
"View",
"id",
"and",
"optionally",
"an",
"Entity",
"id",
"and",
"redirect",
"to",
"showAction",
".",
"Route",
"for",
"this",
"action",
"is",
"defined",
"in",
"RouteLoader",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L56-L74 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.showBusinessPageByIdAction | public function showBusinessPageByIdAction(Request $request, $entityId, $type)
{
$businessEntityHelper = $this->get('victoire_core.helper.queriable_business_entity_helper');
$businessEntity = $businessEntityHelper->findById($type);
$entity = $businessEntityHelper->getByBusinessEntityAndId($businessEntity, $entityId);
$refClass = new \ReflectionClass($entity);
$templateId = $this->get('victoire_business_page.business_page_helper')
->guessBestPatternIdForEntity($refClass, $entityId, $this->container->get('doctrine.orm.entity_manager'));
$page = $this->get('victoire_page.page_helper')->findPageByParameters([
'viewId' => $templateId,
'entityId' => $entityId,
'locale' => $request->getLocale(),
]);
return $this->redirect(
$this->generateUrl(
'victoire_core_page_show',
[
'url' => $page->getReference()->getUrl(),
]
)
);
} | php | public function showBusinessPageByIdAction(Request $request, $entityId, $type)
{
$businessEntityHelper = $this->get('victoire_core.helper.queriable_business_entity_helper');
$businessEntity = $businessEntityHelper->findById($type);
$entity = $businessEntityHelper->getByBusinessEntityAndId($businessEntity, $entityId);
$refClass = new \ReflectionClass($entity);
$templateId = $this->get('victoire_business_page.business_page_helper')
->guessBestPatternIdForEntity($refClass, $entityId, $this->container->get('doctrine.orm.entity_manager'));
$page = $this->get('victoire_page.page_helper')->findPageByParameters([
'viewId' => $templateId,
'entityId' => $entityId,
'locale' => $request->getLocale(),
]);
return $this->redirect(
$this->generateUrl(
'victoire_core_page_show',
[
'url' => $page->getReference()->getUrl(),
]
)
);
} | [
"public",
"function",
"showBusinessPageByIdAction",
"(",
"Request",
"$",
"request",
",",
"$",
"entityId",
",",
"$",
"type",
")",
"{",
"$",
"businessEntityHelper",
"=",
"$",
"this",
"->",
"get",
"(",
"'victoire_core.helper.queriable_business_entity_helper'",
")",
";"... | Find BusinessPage url for an Entity id and type and redirect to showAction.
Route for this action is defined in RouteLoader.
@param Request $request
@param $entityId
@param $type
@return RedirectResponse | [
"Find",
"BusinessPage",
"url",
"for",
"an",
"Entity",
"id",
"and",
"type",
"and",
"redirect",
"to",
"showAction",
".",
"Route",
"for",
"this",
"action",
"is",
"defined",
"in",
"RouteLoader",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L86-L111 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.newAction | protected function newAction(Request $request, $isHomepage = false)
{
$page = $this->getNewPage();
if ($page instanceof Page) {
$page->setHomepage($isHomepage ? $isHomepage : 0);
}
$form = $this->get('form.factory')->create($this->getNewPageType(), $page);
return [
'success' => true,
'html' => $this->get('templating')->render(
$this->getBaseTemplatePath().':new.html.twig',
['form' => $form->createView()]
),
];
} | php | protected function newAction(Request $request, $isHomepage = false)
{
$page = $this->getNewPage();
if ($page instanceof Page) {
$page->setHomepage($isHomepage ? $isHomepage : 0);
}
$form = $this->get('form.factory')->create($this->getNewPageType(), $page);
return [
'success' => true,
'html' => $this->get('templating')->render(
$this->getBaseTemplatePath().':new.html.twig',
['form' => $form->createView()]
),
];
} | [
"protected",
"function",
"newAction",
"(",
"Request",
"$",
"request",
",",
"$",
"isHomepage",
"=",
"false",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getNewPage",
"(",
")",
";",
"if",
"(",
"$",
"page",
"instanceof",
"Page",
")",
"{",
"$",
"page... | Display a form to create a new Blog or Page.
Route is defined in inherited controllers.
@param Request $request
@param bool $isHomepage
@return array | [
"Display",
"a",
"form",
"to",
"create",
"a",
"new",
"Blog",
"or",
"Page",
".",
"Route",
"is",
"defined",
"in",
"inherited",
"controllers",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L122-L138 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.newPostAction | protected function newPostAction(Request $request)
{
$entityManager = $this->get('doctrine.orm.entity_manager');
$page = $this->getNewPage();
$form = $this->get('form.factory')->create($this->getNewPageType(), $page);
$form->handleRequest($request);
if ($form->isValid()) {
$page = $this->get('victoire_page.page_helper')->setPosition($page);
$page->setAuthor($this->getUser());
$entityManager->persist($page);
$entityManager->flush();
// If the $page is a BusinessEntity (eg. an Article), compute it's url
if (null !== $this->get('victoire_core.helper.business_entity_helper')->findByEntityInstance($page)) {
$page = $this
->get('victoire_business_page.business_page_builder')
->generateEntityPageFromTemplate($page->getTemplate(), $page, $entityManager);
}
$this->congrat($this->get('translator')->trans('victoire_page.create.success', [], 'victoire'));
return $this->getViewReferenceRedirect($request, $page);
}
return [
'success' => false,
'message' => $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
'html' => $this->get('templating')->render(
$this->getBaseTemplatePath().':new.html.twig',
['form' => $form->createView()]
),
];
} | php | protected function newPostAction(Request $request)
{
$entityManager = $this->get('doctrine.orm.entity_manager');
$page = $this->getNewPage();
$form = $this->get('form.factory')->create($this->getNewPageType(), $page);
$form->handleRequest($request);
if ($form->isValid()) {
$page = $this->get('victoire_page.page_helper')->setPosition($page);
$page->setAuthor($this->getUser());
$entityManager->persist($page);
$entityManager->flush();
// If the $page is a BusinessEntity (eg. an Article), compute it's url
if (null !== $this->get('victoire_core.helper.business_entity_helper')->findByEntityInstance($page)) {
$page = $this
->get('victoire_business_page.business_page_builder')
->generateEntityPageFromTemplate($page->getTemplate(), $page, $entityManager);
}
$this->congrat($this->get('translator')->trans('victoire_page.create.success', [], 'victoire'));
return $this->getViewReferenceRedirect($request, $page);
}
return [
'success' => false,
'message' => $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
'html' => $this->get('templating')->render(
$this->getBaseTemplatePath().':new.html.twig',
['form' => $form->createView()]
),
];
} | [
"protected",
"function",
"newPostAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"entityManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'doctrine.orm.entity_manager'",
")",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"getNewPage",
"(",
")",
";",
"$",
... | Create a new Blog or Page.
Route is defined in inherited controllers.
@param Request $request
@return array|Response | [
"Create",
"a",
"new",
"Blog",
"or",
"Page",
".",
"Route",
"is",
"defined",
"in",
"inherited",
"controllers",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L148-L182 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.