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/PageBundle/Controller/BasePageController.php | BasePageController.settingsAction | protected function settingsAction(Request $request, BasePage $page)
{
$form = $this->createSettingsForm($page);
return [
'success' => true,
'html' => $this->get('templating')->render(
$this->getBaseTemplatePath().':settings.html.twig',
[
'page' => $page,
'form' => $form->createView(),
'businessProperties' => $this->getBusinessProperties($page),
]
),
];
} | php | protected function settingsAction(Request $request, BasePage $page)
{
$form = $this->createSettingsForm($page);
return [
'success' => true,
'html' => $this->get('templating')->render(
$this->getBaseTemplatePath().':settings.html.twig',
[
'page' => $page,
'form' => $form->createView(),
'businessProperties' => $this->getBusinessProperties($page),
]
),
];
} | [
"protected",
"function",
"settingsAction",
"(",
"Request",
"$",
"request",
",",
"BasePage",
"$",
"page",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createSettingsForm",
"(",
"$",
"page",
")",
";",
"return",
"[",
"'success'",
"=>",
"true",
",",
"'htm... | Display a form to edit Page settings.
Route is defined in inherited controllers.
@param Request $request
@param BasePage $page
@return array | [
"Display",
"a",
"form",
"to",
"edit",
"Page",
"settings",
".",
"Route",
"is",
"defined",
"in",
"inherited",
"controllers",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L193-L208 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.settingsPostAction | protected function settingsPostAction(Request $request, BasePage $page)
{
$entityManager = $this->getDoctrine()->getManager();
$form = $this->createSettingsForm($page);
$form->handleRequest($request);
if ($form->isValid()) {
$entityManager->persist($page);
$entityManager->flush();
$this->congrat($this->get('translator')->trans('victoire_page.update.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().':settings.html.twig',
[
'page' => $page,
'form' => $form->createView(),
'businessProperties' => $this->getBusinessProperties($page),
]
),
];
} | php | protected function settingsPostAction(Request $request, BasePage $page)
{
$entityManager = $this->getDoctrine()->getManager();
$form = $this->createSettingsForm($page);
$form->handleRequest($request);
if ($form->isValid()) {
$entityManager->persist($page);
$entityManager->flush();
$this->congrat($this->get('translator')->trans('victoire_page.update.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().':settings.html.twig',
[
'page' => $page,
'form' => $form->createView(),
'businessProperties' => $this->getBusinessProperties($page),
]
),
];
} | [
"protected",
"function",
"settingsPostAction",
"(",
"Request",
"$",
"request",
",",
"BasePage",
"$",
"page",
")",
"{",
"$",
"entityManager",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this"... | Save Page settings.
Route is defined in inherited controllers.
@param Request $request
@param BasePage $page
@return array|Response | [
"Save",
"Page",
"settings",
".",
"Route",
"is",
"defined",
"in",
"inherited",
"controllers",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L219-L247 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.deleteAction | protected function deleteAction(BasePage $page)
{
try {
//Throw Exception if Page is undeletable
if ($page->isUndeletable()) {
$message = $this->get('translator')->trans('page.undeletable', [], 'victoire');
throw new \Exception($message);
}
$entityManager = $this->get('doctrine.orm.entity_manager');
$entityManager->remove($page);
$entityManager->flush();
return [
'success' => true,
'url' => $this->generateUrl('victoire_core_homepage_show'),
];
} catch (\Exception $ex) {
return [
'success' => false,
'message' => $ex->getMessage(),
];
}
} | php | protected function deleteAction(BasePage $page)
{
try {
//Throw Exception if Page is undeletable
if ($page->isUndeletable()) {
$message = $this->get('translator')->trans('page.undeletable', [], 'victoire');
throw new \Exception($message);
}
$entityManager = $this->get('doctrine.orm.entity_manager');
$entityManager->remove($page);
$entityManager->flush();
return [
'success' => true,
'url' => $this->generateUrl('victoire_core_homepage_show'),
];
} catch (\Exception $ex) {
return [
'success' => false,
'message' => $ex->getMessage(),
];
}
} | [
"protected",
"function",
"deleteAction",
"(",
"BasePage",
"$",
"page",
")",
"{",
"try",
"{",
"//Throw Exception if Page is undeletable",
"if",
"(",
"$",
"page",
"->",
"isUndeletable",
"(",
")",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"get",
"(",
... | Delete a Page.
Route is defined in inherited controllers.
@param BasePage $page
@return array | [
"Delete",
"a",
"Page",
".",
"Route",
"is",
"defined",
"in",
"inherited",
"controllers",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L257-L281 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.getViewReferenceRedirect | protected function getViewReferenceRedirect(Request $request, BasePage $page)
{
$parameters = [
'viewId' => $page->getId(),
];
if (!($page instanceof Blog)) {
$parameters['locale'] = $request->getLocale();
}
$viewReference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters($parameters);
$page->setReference($viewReference);
return [
'success' => true,
'url' => $this->generateUrl(
'victoire_core_page_show',
[
'_locale' => $request->getLocale(),
'url' => $viewReference->getUrl(),
]
),
];
} | php | protected function getViewReferenceRedirect(Request $request, BasePage $page)
{
$parameters = [
'viewId' => $page->getId(),
];
if (!($page instanceof Blog)) {
$parameters['locale'] = $request->getLocale();
}
$viewReference = $this->get('victoire_view_reference.repository')
->getOneReferenceByParameters($parameters);
$page->setReference($viewReference);
return [
'success' => true,
'url' => $this->generateUrl(
'victoire_core_page_show',
[
'_locale' => $request->getLocale(),
'url' => $viewReference->getUrl(),
]
),
];
} | [
"protected",
"function",
"getViewReferenceRedirect",
"(",
"Request",
"$",
"request",
",",
"BasePage",
"$",
"page",
")",
"{",
"$",
"parameters",
"=",
"[",
"'viewId'",
"=>",
"$",
"page",
"->",
"getId",
"(",
")",
",",
"]",
";",
"if",
"(",
"!",
"(",
"$",
... | Return an array for JsonResponse redirecting to a ViewReference.
@param Request $request
@param BasePage $page
@return array | [
"Return",
"an",
"array",
"for",
"JsonResponse",
"redirecting",
"to",
"a",
"ViewReference",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L291-L316 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.createSettingsForm | protected function createSettingsForm(BasePage $page)
{
$form = $this->createForm($this->getPageSettingsType(), $page);
if ($page instanceof BusinessPage) {
$form = $this->createForm($this->getBusinessPageType(), $page);
}
return $form;
} | php | protected function createSettingsForm(BasePage $page)
{
$form = $this->createForm($this->getPageSettingsType(), $page);
if ($page instanceof BusinessPage) {
$form = $this->createForm($this->getBusinessPageType(), $page);
}
return $form;
} | [
"protected",
"function",
"createSettingsForm",
"(",
"BasePage",
"$",
"page",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"this",
"->",
"getPageSettingsType",
"(",
")",
",",
"$",
"page",
")",
";",
"if",
"(",
"$",
"page",
"inst... | Create Settings form according to Page type.
@param BasePage $page
@return Form | [
"Create",
"Settings",
"form",
"according",
"to",
"Page",
"type",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L325-L334 | train |
Victoire/victoire | Bundle/PageBundle/Controller/BasePageController.php | BasePageController.getBusinessProperties | protected function getBusinessProperties(BasePage $page)
{
$businessProperties = [];
if ($page instanceof BusinessTemplate) {
//we can use the business entity properties on the seo
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($page->getBusinessEntityId());
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}
return $businessProperties;
} | php | protected function getBusinessProperties(BasePage $page)
{
$businessProperties = [];
if ($page instanceof BusinessTemplate) {
//we can use the business entity properties on the seo
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($page->getBusinessEntityId());
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}
return $businessProperties;
} | [
"protected",
"function",
"getBusinessProperties",
"(",
"BasePage",
"$",
"page",
")",
"{",
"$",
"businessProperties",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"page",
"instanceof",
"BusinessTemplate",
")",
"{",
"//we can use the business entity properties on the seo",
"$",
... | Return BusinessEntity seaoable properties if Page is a BusinessTemplate.
@param BasePage $page
@return array | [
"Return",
"BusinessEntity",
"seaoable",
"properties",
"if",
"Page",
"is",
"a",
"BusinessTemplate",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Controller/BasePageController.php#L343-L354 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Handler/TwigSlugHandler.php | TwigSlugHandler.transliterate | public function transliterate($text, $separator, $object)
{
if ($object instanceof BusinessTemplate
|| (in_array(Translation::class, class_uses($object))
&& $object->getTranslatable() instanceof BusinessTemplate)) {
$slug = Transliterator::urlize($text, $separator, true);
} else {
$slug = Transliterator::urlize($text, $separator);
}
return $slug;
} | php | public function transliterate($text, $separator, $object)
{
if ($object instanceof BusinessTemplate
|| (in_array(Translation::class, class_uses($object))
&& $object->getTranslatable() instanceof BusinessTemplate)) {
$slug = Transliterator::urlize($text, $separator, true);
} else {
$slug = Transliterator::urlize($text, $separator);
}
return $slug;
} | [
"public",
"function",
"transliterate",
"(",
"$",
"text",
",",
"$",
"separator",
",",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"BusinessTemplate",
"||",
"(",
"in_array",
"(",
"Translation",
"::",
"class",
",",
"class_uses",
"(",
"$",... | Transliterates the slug and keep twig variable.
@param string $text
@param string $separator
@param object $object
@return string | [
"Transliterates",
"the",
"slug",
"and",
"keep",
"twig",
"variable",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Handler/TwigSlugHandler.php#L71-L82 | train |
Victoire/victoire | Bundle/SeoBundle/Repository/RedirectionRepository.php | RedirectionRepository.getUnresolvedQuery | public function getUnresolvedQuery($order = 'redirection.counter', $direction = 'DESC')
{
$this->getAll();
return $this->qb->orderBy($order, $direction);
} | php | public function getUnresolvedQuery($order = 'redirection.counter', $direction = 'DESC')
{
$this->getAll();
return $this->qb->orderBy($order, $direction);
} | [
"public",
"function",
"getUnresolvedQuery",
"(",
"$",
"order",
"=",
"'redirection.counter'",
",",
"$",
"direction",
"=",
"'DESC'",
")",
"{",
"$",
"this",
"->",
"getAll",
"(",
")",
";",
"return",
"$",
"this",
"->",
"qb",
"->",
"orderBy",
"(",
"$",
"order"... | Get all redirections in the repository.
@param string $order
@param string $direction
@return QueryBuilder | [
"Get",
"all",
"redirections",
"in",
"the",
"repository",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Repository/RedirectionRepository.php#L37-L42 | train |
Victoire/victoire | Bundle/SeoBundle/Helper/PageSeoHelper.php | PageSeoHelper.updateSeoByEntity | public function updateSeoByEntity(BasePage $page, $entity)
{
//if no entity is provided
if ($entity === null) {
//we look for the entity of the page
if ($page->getBusinessEntity() !== null) {
$entity = $page->getBusinessEntity();
}
}
//only if we have an entity instance
if ($entity !== null) {
//the page seo
$pageSeo = $page->getSeo();
//the page seo might not exist yet
if ($pageSeo !== null) {
$businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
if ($businessEntity !== null) {
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
//parse the business properties
foreach ($businessProperties as $businessProperty) {
//parse of seo attributes
foreach ($this->pageSeoAttributes as $seoAttribute) {
$value = $this->getEntityAttributeValue($pageSeo, $seoAttribute);
// we only update value if its a string and (if its a VBP or its a BP where value is not defined)
if (is_string($value) && ($page instanceof VirtualBusinessPage || ($page instanceof BusinessPage && $value == null))) {
$value = $this->parameterConverter->setBusinessPropertyInstance(
$value,
$businessProperty,
$entity
);
}
$this->setEntityAttributeValue($pageSeo, $seoAttribute, $value);
}
}
}
}
}
} | php | public function updateSeoByEntity(BasePage $page, $entity)
{
//if no entity is provided
if ($entity === null) {
//we look for the entity of the page
if ($page->getBusinessEntity() !== null) {
$entity = $page->getBusinessEntity();
}
}
//only if we have an entity instance
if ($entity !== null) {
//the page seo
$pageSeo = $page->getSeo();
//the page seo might not exist yet
if ($pageSeo !== null) {
$businessEntity = $this->businessEntityHelper->findByEntityInstance($entity);
if ($businessEntity !== null) {
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
//parse the business properties
foreach ($businessProperties as $businessProperty) {
//parse of seo attributes
foreach ($this->pageSeoAttributes as $seoAttribute) {
$value = $this->getEntityAttributeValue($pageSeo, $seoAttribute);
// we only update value if its a string and (if its a VBP or its a BP where value is not defined)
if (is_string($value) && ($page instanceof VirtualBusinessPage || ($page instanceof BusinessPage && $value == null))) {
$value = $this->parameterConverter->setBusinessPropertyInstance(
$value,
$businessProperty,
$entity
);
}
$this->setEntityAttributeValue($pageSeo, $seoAttribute, $value);
}
}
}
}
}
} | [
"public",
"function",
"updateSeoByEntity",
"(",
"BasePage",
"$",
"page",
",",
"$",
"entity",
")",
"{",
"//if no entity is provided",
"if",
"(",
"$",
"entity",
"===",
"null",
")",
"{",
"//we look for the entity of the page",
"if",
"(",
"$",
"page",
"->",
"getBusi... | Generate a seo for the page using the current entity.
@param Page $page
@param Entity $entity | [
"Generate",
"a",
"seo",
"for",
"the",
"page",
"using",
"the",
"current",
"entity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Helper/PageSeoHelper.php#L65-L106 | train |
Victoire/victoire | Bundle/CoreBundle/Handler/WidgetExceptionHandler.php | WidgetExceptionHandler.handle | public function handle(\Exception $ex, $currentView, $widget = null, $widgetId = null)
{
$templating = $this->container->get('templating');
$result = '';
//
if ($this->debug) {
$exceptionResult = '<div style="border: 3px solid #FF0000;height: 500px;overflow: auto;">';
$template = new TemplateReference('TwigBundle', 'Exception', 'exception', 'html', 'twig');
$exception = FlattenException::create($ex);
$exceptionResult = $templating->render(
$template,
[
'status_code' => $ex->getCode(),
'status_text' => 500,
'exception' => $exception,
'logger' => null,
'currentContent' => null,
]
);
$exceptionResult .= '</div>';
//only a user victoire can see that there is an error
$result = $templating->render(
'VictoireCoreBundle:Widget:showError.html.twig',
[
'widget' => $widget,
'widgetId' => $widgetId,
'currentView' => $currentView,
'error' => $exceptionResult,
]
);
} else {
//environnement not debug
//only a user victoire can see that there is an error
if ($this->authorizationChecker->isGranted('ROLE_VICTOIRE')) {
$result = $templating->render(
'VictoireCoreBundle:Widget:showError.html.twig',
[
'widget' => $widget,
'widgetId' => $widgetId,
'currentView' => $currentView,
'error' => $ex->getMessage(),
]
);
}
}
return $result;
} | php | public function handle(\Exception $ex, $currentView, $widget = null, $widgetId = null)
{
$templating = $this->container->get('templating');
$result = '';
//
if ($this->debug) {
$exceptionResult = '<div style="border: 3px solid #FF0000;height: 500px;overflow: auto;">';
$template = new TemplateReference('TwigBundle', 'Exception', 'exception', 'html', 'twig');
$exception = FlattenException::create($ex);
$exceptionResult = $templating->render(
$template,
[
'status_code' => $ex->getCode(),
'status_text' => 500,
'exception' => $exception,
'logger' => null,
'currentContent' => null,
]
);
$exceptionResult .= '</div>';
//only a user victoire can see that there is an error
$result = $templating->render(
'VictoireCoreBundle:Widget:showError.html.twig',
[
'widget' => $widget,
'widgetId' => $widgetId,
'currentView' => $currentView,
'error' => $exceptionResult,
]
);
} else {
//environnement not debug
//only a user victoire can see that there is an error
if ($this->authorizationChecker->isGranted('ROLE_VICTOIRE')) {
$result = $templating->render(
'VictoireCoreBundle:Widget:showError.html.twig',
[
'widget' => $widget,
'widgetId' => $widgetId,
'currentView' => $currentView,
'error' => $ex->getMessage(),
]
);
}
}
return $result;
} | [
"public",
"function",
"handle",
"(",
"\\",
"Exception",
"$",
"ex",
",",
"$",
"currentView",
",",
"$",
"widget",
"=",
"null",
",",
"$",
"widgetId",
"=",
"null",
")",
"{",
"$",
"templating",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'temp... | Handle response for an exception for a widget.
@param View $currentView
@param Widget $widget
@param int $widgetId
@return string The html with the Error | [
"Handle",
"response",
"for",
"an",
"exception",
"for",
"a",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Handler/WidgetExceptionHandler.php#L43-L95 | train |
Victoire/victoire | Bundle/SeoBundle/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('victoire_seo');
$rootNode
->addDefaultsIfNotSet()
->children()
->arrayNode('analytics')
->useAttributeAsKey(true)
->prototype('array')
->children()
->booleanNode('enabled')->defaultValue('false')->end()
->scalarNode('key')->defaultNull()->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('victoire_seo');
$rootNode
->addDefaultsIfNotSet()
->children()
->arrayNode('analytics')
->useAttributeAsKey(true)
->prototype('array')
->children()
->booleanNode('enabled')->defaultValue('false')->end()
->scalarNode('key')->defaultNull()->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"treeBuilder",
"->",
"root",
"(",
"'victoire_seo'",
")",
";",
"$",
"rootNode",
"->",
"addDefaultsIfNotSet",
... | Get the config tree builder.
@return TreeBuilder The tree builder | [
"Get",
"the",
"config",
"tree",
"builder",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/DependencyInjection/Configuration.php#L18-L38 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisManager.php | ViewReferenceRedisManager.index | public function index($id, $values)
{
foreach ($values as $name => $value) {
$key = $this->tools->generateKey($name.'_'.$this->alias, $value);
// Store id for value
$this->redis->sadd($key, $id);
}
} | php | public function index($id, $values)
{
foreach ($values as $name => $value) {
$key = $this->tools->generateKey($name.'_'.$this->alias, $value);
// Store id for value
$this->redis->sadd($key, $id);
}
} | [
"public",
"function",
"index",
"(",
"$",
"id",
",",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"tools",
"->",
"generateKey",
"(",
"$",
"name",
".",
... | This method index a reference.
@param $id
@param $values | [
"This",
"method",
"index",
"a",
"reference",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisManager.php#L97-L104 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Converter/ParameterConverter.php | ParameterConverter.setBusinessPropertyInstance | public function setBusinessPropertyInstance($string, BusinessProperty $businessProperty, $entity)
{
//test parameters
if ($entity === null) {
throw new \Exception('The parameter entity can not be null');
}
//the attribute to set
$entityProperty = $businessProperty->getEntityProperty();
//the string to replace
$stringToReplace = '{{item.'.$entityProperty.'}}';
//the value of the attribute
$attributeValue = $entity->getEntityAttributeValue($entityProperty);
//we provide a default value
if ($attributeValue === null) {
$attributeValue = '';
}
//we replace the string
$string = str_replace($stringToReplace, $attributeValue, $string);
return $string;
} | php | public function setBusinessPropertyInstance($string, BusinessProperty $businessProperty, $entity)
{
//test parameters
if ($entity === null) {
throw new \Exception('The parameter entity can not be null');
}
//the attribute to set
$entityProperty = $businessProperty->getEntityProperty();
//the string to replace
$stringToReplace = '{{item.'.$entityProperty.'}}';
//the value of the attribute
$attributeValue = $entity->getEntityAttributeValue($entityProperty);
//we provide a default value
if ($attributeValue === null) {
$attributeValue = '';
}
//we replace the string
$string = str_replace($stringToReplace, $attributeValue, $string);
return $string;
} | [
"public",
"function",
"setBusinessPropertyInstance",
"(",
"$",
"string",
",",
"BusinessProperty",
"$",
"businessProperty",
",",
"$",
"entity",
")",
"{",
"//test parameters",
"if",
"(",
"$",
"entity",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
... | Replace the code string with the value of the entity attribute.
@param string $string
@param BusinessProperty $businessProperty
@param object $entity
@throws \Exception
@return string The updated string | [
"Replace",
"the",
"code",
"string",
"with",
"the",
"value",
"of",
"the",
"entity",
"attribute",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Converter/ParameterConverter.php#L24-L49 | train |
Victoire/victoire | Bundle/CoreBundle/Form/WidgetType.php | WidgetType.addCriteriasFields | protected function addCriteriasFields($builder, $options)
{
$builder->add('criterias', CriteriaCollectionType::class, [
'label' => 'victoire.widget.type.criterias.label',
'entry_type' => CriteriaType::class,
'required' => false,
'entry_options' => [
'dataSources' => $options['dataSources'],
],
]);
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) use ($options) {
$dataSources = $options['dataSources']->getDataSources();
$widget = $event->getData();
foreach ($dataSources as $alias => $dataSource) {
if (!$widget->hasCriteriaNamed($alias)) {
$criteria = new Criteria();
$criteria->setName($alias);
$widget->addCriteria($criteria);
}
}
}
);
$builder->addEventListener(
FormEvents::POST_SUBMIT,
function (FormEvent $event) use ($options) {
$widget = $event->getData();
/** @var Criteria $criteria */
foreach ($widget->getCriterias() as $criteria) {
if ($criteria->getValue() === null) {
$widget->removeCriteria($criteria);
}
}
}
);
} | php | protected function addCriteriasFields($builder, $options)
{
$builder->add('criterias', CriteriaCollectionType::class, [
'label' => 'victoire.widget.type.criterias.label',
'entry_type' => CriteriaType::class,
'required' => false,
'entry_options' => [
'dataSources' => $options['dataSources'],
],
]);
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) use ($options) {
$dataSources = $options['dataSources']->getDataSources();
$widget = $event->getData();
foreach ($dataSources as $alias => $dataSource) {
if (!$widget->hasCriteriaNamed($alias)) {
$criteria = new Criteria();
$criteria->setName($alias);
$widget->addCriteria($criteria);
}
}
}
);
$builder->addEventListener(
FormEvents::POST_SUBMIT,
function (FormEvent $event) use ($options) {
$widget = $event->getData();
/** @var Criteria $criteria */
foreach ($widget->getCriterias() as $criteria) {
if ($criteria->getValue() === null) {
$widget->removeCriteria($criteria);
}
}
}
);
} | [
"protected",
"function",
"addCriteriasFields",
"(",
"$",
"builder",
",",
"$",
"options",
")",
"{",
"$",
"builder",
"->",
"add",
"(",
"'criterias'",
",",
"CriteriaCollectionType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'victoire.widget.type.criterias.label'",
"... | Add the criterias fields.
@param FormBuilderInterface $builder
@param array $options | [
"Add",
"the",
"criterias",
"fields",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Form/WidgetType.php#L103-L139 | train |
Victoire/victoire | Bundle/CoreBundle/Form/WidgetType.php | WidgetType.addEntityFields | protected function addEntityFields($form, $options)
{
$form
->add('fields', WidgetFieldsFormType::class, [
'label' => 'widget.form.entity.fields.label',
'namespace' => $options['namespace'],
'widget' => $options['widget'],
])
->add('entity_proxy', EntityProxyFormType::class, [
'business_entity_id' => $options['businessEntityId'],
'namespace' => $options['namespace'],
'widget' => $options['widget'],
]);
} | php | protected function addEntityFields($form, $options)
{
$form
->add('fields', WidgetFieldsFormType::class, [
'label' => 'widget.form.entity.fields.label',
'namespace' => $options['namespace'],
'widget' => $options['widget'],
])
->add('entity_proxy', EntityProxyFormType::class, [
'business_entity_id' => $options['businessEntityId'],
'namespace' => $options['namespace'],
'widget' => $options['widget'],
]);
} | [
"protected",
"function",
"addEntityFields",
"(",
"$",
"form",
",",
"$",
"options",
")",
"{",
"$",
"form",
"->",
"add",
"(",
"'fields'",
",",
"WidgetFieldsFormType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'widget.form.entity.fields.label'",
",",
"'namespace'"... | Add the fields for the form and the entity mode.
@param FormBuilderInterface|FormInterface $form
@param array $options | [
"Add",
"the",
"fields",
"for",
"the",
"form",
"and",
"the",
"entity",
"mode",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Form/WidgetType.php#L162-L175 | train |
Victoire/victoire | Bundle/CoreBundle/Form/WidgetType.php | WidgetType.addQueryFields | protected function addQueryFields($form, $options)
{
$form->add('query');
$form->add('fields', WidgetFieldsFormType::class, [
'label' => 'widget.form.entity.fields.label',
'namespace' => $options['namespace'],
'widget' => $options['widget'],
]);
} | php | protected function addQueryFields($form, $options)
{
$form->add('query');
$form->add('fields', WidgetFieldsFormType::class, [
'label' => 'widget.form.entity.fields.label',
'namespace' => $options['namespace'],
'widget' => $options['widget'],
]);
} | [
"protected",
"function",
"addQueryFields",
"(",
"$",
"form",
",",
"$",
"options",
")",
"{",
"$",
"form",
"->",
"add",
"(",
"'query'",
")",
";",
"$",
"form",
"->",
"add",
"(",
"'fields'",
",",
"WidgetFieldsFormType",
"::",
"class",
",",
"[",
"'label'",
... | Add the fields to the form for the query mode.
@param FormBuilderInterface|FormInterface $form
@param array $options | [
"Add",
"the",
"fields",
"to",
"the",
"form",
"for",
"the",
"query",
"mode",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Form/WidgetType.php#L183-L191 | train |
Victoire/victoire | Bundle/BusinessPageBundle/Repository/BusinessPageRepository.php | BusinessPageRepository.findPageByBusinessEntityAndPattern | public function findPageByBusinessEntityAndPattern(BusinessTemplate $pattern, $entity, BusinessEntity $businessEntity)
{
if (is_object($entity)) {
$entity = $entity->getId();
}
$qb = $this->createQueryBuilder('BusinessPage');
$qb->join('BusinessPage.entityProxy', 'proxy');
$qb->join('BusinessPage.template', 'template');
$qb->join('proxy.'.$businessEntity->getId(), 'entity');
$qb->where('template.id = :templateId');
$qb->andWhere('entity.id = :entityId');
$qb->setParameter(':templateId', $pattern);
$qb->setParameter(':entityId', $entity);
$result = $qb->getQuery()->getOneOrNullResult();
return $result;
} | php | public function findPageByBusinessEntityAndPattern(BusinessTemplate $pattern, $entity, BusinessEntity $businessEntity)
{
if (is_object($entity)) {
$entity = $entity->getId();
}
$qb = $this->createQueryBuilder('BusinessPage');
$qb->join('BusinessPage.entityProxy', 'proxy');
$qb->join('BusinessPage.template', 'template');
$qb->join('proxy.'.$businessEntity->getId(), 'entity');
$qb->where('template.id = :templateId');
$qb->andWhere('entity.id = :entityId');
$qb->setParameter(':templateId', $pattern);
$qb->setParameter(':entityId', $entity);
$result = $qb->getQuery()->getOneOrNullResult();
return $result;
} | [
"public",
"function",
"findPageByBusinessEntityAndPattern",
"(",
"BusinessTemplate",
"$",
"pattern",
",",
"$",
"entity",
",",
"BusinessEntity",
"$",
"businessEntity",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"entity",
"=",
"$",... | Find the pagePatterns of the business entity.
@param BusinessTemplate $pattern
@param object $entity | int $entityId
@param BusinessEntity $businessEntity
@return mixed | [
"Find",
"the",
"pagePatterns",
"of",
"the",
"business",
"entity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Repository/BusinessPageRepository.php#L23-L42 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisTool.php | ViewReferenceRedisTool.redislize | public function redislize($data)
{
// Only serialize if it's not a string or a integer
if (!is_string($data) && !is_int($data)) {
return urlencode(serialize($data));
}
// Encode string to escape wrong saves
return urlencode($data);
} | php | public function redislize($data)
{
// Only serialize if it's not a string or a integer
if (!is_string($data) && !is_int($data)) {
return urlencode(serialize($data));
}
// Encode string to escape wrong saves
return urlencode($data);
} | [
"public",
"function",
"redislize",
"(",
"$",
"data",
")",
"{",
"// Only serialize if it's not a string or a integer",
"if",
"(",
"!",
"is_string",
"(",
"$",
"data",
")",
"&&",
"!",
"is_int",
"(",
"$",
"data",
")",
")",
"{",
"return",
"urlencode",
"(",
"seria... | This method generated a string that can be persisted for redis with data.
@param $data
@return string | [
"This",
"method",
"generated",
"a",
"string",
"that",
"can",
"be",
"persisted",
"for",
"redis",
"with",
"data",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisTool.php#L17-L25 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisTool.php | ViewReferenceRedisTool.unredislize | public function unredislize($data)
{
$data = urldecode($data);
if (self::isSerialized($data)) {
$unserializedData = @unserialize($data);
if ($unserializedData !== false) {
return $unserializedData;
}
}
return $data;
} | php | public function unredislize($data)
{
$data = urldecode($data);
if (self::isSerialized($data)) {
$unserializedData = @unserialize($data);
if ($unserializedData !== false) {
return $unserializedData;
}
}
return $data;
} | [
"public",
"function",
"unredislize",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"urldecode",
"(",
"$",
"data",
")",
";",
"if",
"(",
"self",
"::",
"isSerialized",
"(",
"$",
"data",
")",
")",
"{",
"$",
"unserializedData",
"=",
"@",
"unserialize",
"(... | This method unredislize a string.
@param $data
@return mixed|string | [
"This",
"method",
"unredislize",
"a",
"string",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/Redis/ViewReferenceRedisTool.php#L34-L46 | train |
Victoire/victoire | Bundle/WidgetBundle/Builder/WidgetFormBuilder.php | WidgetFormBuilder.renderNewForm | public function renderNewForm($form, $widget, $slot, View $view, $quantum = null, $entity = null)
{
//the template displayed is in the widget bundle
$templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName('new', $widget);
return $this->container->get('templating')->render(
$templateName,
[
'widget' => $widget,
'form' => $form->createView(),
'slot' => $slot,
'entity' => $entity,
'view' => $view,
'quantum' => $quantum,
]
);
} | php | public function renderNewForm($form, $widget, $slot, View $view, $quantum = null, $entity = null)
{
//the template displayed is in the widget bundle
$templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName('new', $widget);
return $this->container->get('templating')->render(
$templateName,
[
'widget' => $widget,
'form' => $form->createView(),
'slot' => $slot,
'entity' => $entity,
'view' => $view,
'quantum' => $quantum,
]
);
} | [
"public",
"function",
"renderNewForm",
"(",
"$",
"form",
",",
"$",
"widget",
",",
"$",
"slot",
",",
"View",
"$",
"view",
",",
"$",
"quantum",
"=",
"null",
",",
"$",
"entity",
"=",
"null",
")",
"{",
"//the template displayed is in the widget bundle",
"$",
"... | create form new for a widget.
@param Form $form
@param Widget $widget
@param string $slot
@param View $view
@param string $entity
@return string | [
"create",
"form",
"new",
"for",
"a",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Builder/WidgetFormBuilder.php#L40-L56 | train |
Victoire/victoire | Bundle/WidgetBundle/Builder/WidgetFormBuilder.php | WidgetFormBuilder.renderForm | public function renderForm(Form $form, Widget $widget, $entity = null)
{
//the template displayed is in the widget bundle
$templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName('edit', $widget);
return $this->container->get('templating')->render(
$templateName,
[
'widget' => $widget,
'slot' => $widget->getWidgetMap()->getSlot(),
'view' => $this->container->get('victoire_core.current_view')->getCurrentView(),
'form' => $form->createView(),
'id' => $widget->getId(),
'entity' => $entity,
]
);
} | php | public function renderForm(Form $form, Widget $widget, $entity = null)
{
//the template displayed is in the widget bundle
$templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName('edit', $widget);
return $this->container->get('templating')->render(
$templateName,
[
'widget' => $widget,
'slot' => $widget->getWidgetMap()->getSlot(),
'view' => $this->container->get('victoire_core.current_view')->getCurrentView(),
'form' => $form->createView(),
'id' => $widget->getId(),
'entity' => $entity,
]
);
} | [
"public",
"function",
"renderForm",
"(",
"Form",
"$",
"form",
",",
"Widget",
"$",
"widget",
",",
"$",
"entity",
"=",
"null",
")",
"{",
"//the template displayed is in the widget bundle",
"$",
"templateName",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(... | render Widget form.
@param Form $form
@param Widget $widget
@param object $entity
@return form | [
"render",
"Widget",
"form",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Builder/WidgetFormBuilder.php#L67-L83 | train |
Victoire/victoire | Bundle/WidgetBundle/Builder/WidgetFormBuilder.php | WidgetFormBuilder.renderQuantumStyleForms | public function renderQuantumStyleForms($viewReference, $widgets, Widget $activeWidget)
{
$forms = [];
foreach ($widgets as $key => $widget) {
$_quantum = $this->convertToString($key);
$forms[$key]['form'] = $this->buildWidgetStyleForm($widget, $viewReference, $_quantum)->createView();
$forms[$key]['quantum'] = $_quantum;
$forms[$key]['active'] = $widget === $activeWidget ? true : false;
}
return $forms;
} | php | public function renderQuantumStyleForms($viewReference, $widgets, Widget $activeWidget)
{
$forms = [];
foreach ($widgets as $key => $widget) {
$_quantum = $this->convertToString($key);
$forms[$key]['form'] = $this->buildWidgetStyleForm($widget, $viewReference, $_quantum)->createView();
$forms[$key]['quantum'] = $_quantum;
$forms[$key]['active'] = $widget === $activeWidget ? true : false;
}
return $forms;
} | [
"public",
"function",
"renderQuantumStyleForms",
"(",
"$",
"viewReference",
",",
"$",
"widgets",
",",
"Widget",
"$",
"activeWidget",
")",
"{",
"$",
"forms",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"widgets",
"as",
"$",
"key",
"=>",
"$",
"widget",
")",
... | Generates style forms for each quantum.
@param $viewReference
@param ArrayCollection|Widget[] $widgets
@param Widget $activeWidget
@param null $quantum
@return Form[] | [
"Generates",
"style",
"forms",
"for",
"each",
"quantum",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Builder/WidgetFormBuilder.php#L160-L171 | train |
Victoire/victoire | Bundle/WidgetBundle/Builder/WidgetFormBuilder.php | WidgetFormBuilder.buildWidgetStyleForm | public function buildWidgetStyleForm(Widget $widget, $viewReference, $quantum)
{
$formFactory = $this->container->get('form.factory');
$options = [
'method' => 'POST',
'action' => $this->container->get('router')->generate(
'victoire_core_widget_stylize',
[
'id' => $widget->getId(),
'viewReference' => $viewReference,
'quantum' => $quantum,
]
),
];
$mockForm = $formFactory->create(WidgetStyleType::class, $widget, $options);
$builder = $formFactory->createNamed(
sprintf('%s_%s', $quantum, $mockForm->getName()),
WidgetStyleType::class,
$widget,
$options
);
return $builder;
} | php | public function buildWidgetStyleForm(Widget $widget, $viewReference, $quantum)
{
$formFactory = $this->container->get('form.factory');
$options = [
'method' => 'POST',
'action' => $this->container->get('router')->generate(
'victoire_core_widget_stylize',
[
'id' => $widget->getId(),
'viewReference' => $viewReference,
'quantum' => $quantum,
]
),
];
$mockForm = $formFactory->create(WidgetStyleType::class, $widget, $options);
$builder = $formFactory->createNamed(
sprintf('%s_%s', $quantum, $mockForm->getName()),
WidgetStyleType::class,
$widget,
$options
);
return $builder;
} | [
"public",
"function",
"buildWidgetStyleForm",
"(",
"Widget",
"$",
"widget",
",",
"$",
"viewReference",
",",
"$",
"quantum",
")",
"{",
"$",
"formFactory",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'form.factory'",
")",
";",
"$",
"options",
"="... | Create style form for given widget.
@param Widget $widget
@param $viewReference
@param $quantum
@throws \Throwable
@return \Symfony\Component\Form\FormInterface | [
"Create",
"style",
"form",
"for",
"given",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Builder/WidgetFormBuilder.php#L319-L344 | train |
Victoire/victoire | Bundle/WidgetBundle/Builder/WidgetFormBuilder.php | WidgetFormBuilder.convertToString | public function convertToString($number, $letter = 'a', $i = 0)
{
if (!is_numeric($number)) {
return $number;
}
while ($i < $number) {
$i++;
$letter++;
}
return $letter;
} | php | public function convertToString($number, $letter = 'a', $i = 0)
{
if (!is_numeric($number)) {
return $number;
}
while ($i < $number) {
$i++;
$letter++;
}
return $letter;
} | [
"public",
"function",
"convertToString",
"(",
"$",
"number",
",",
"$",
"letter",
"=",
"'a'",
",",
"$",
"i",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"number",
")",
")",
"{",
"return",
"$",
"number",
";",
"}",
"while",
"(",
"$",... | This method converts a number to an alphabetic char.
If the number is > 26, convert to aa...az...zz...
@param $number
@param string $letter
@return string | [
"This",
"method",
"converts",
"a",
"number",
"to",
"an",
"alphabetic",
"char",
".",
"If",
"the",
"number",
"is",
">",
"26",
"convert",
"to",
"aa",
"...",
"az",
"...",
"zz",
"..."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Builder/WidgetFormBuilder.php#L355-L367 | train |
Victoire/victoire | Bundle/WidgetBundle/Builder/WidgetFormBuilder.php | WidgetFormBuilder.callBuildFormSwitchParameters | public function callBuildFormSwitchParameters(Widget $widget, $view, $businessEntityId, $position, $parentWidgetMap, $slotId, $quantum)
{
$entityClass = null;
//if there is an entity
if ($businessEntityId) {
//get the businessClasses for the widget
$classes = $this->container->get('victoire_core.helper.business_entity_helper')->getBusinessClassesForWidget($widget);
//test the result
if (!isset($classes[$businessEntityId])) {
throw new \Exception('The entity '.$businessEntityId.' was not found int the business classes.');
}
//get the class of the entity name
$entityClass = $classes[$businessEntityId]->getClass();
}
$form = $this->buildForm($widget, $view, $businessEntityId, $entityClass, $widget->getMode(), $slotId, $position, $parentWidgetMap, $quantum);
return $form;
} | php | public function callBuildFormSwitchParameters(Widget $widget, $view, $businessEntityId, $position, $parentWidgetMap, $slotId, $quantum)
{
$entityClass = null;
//if there is an entity
if ($businessEntityId) {
//get the businessClasses for the widget
$classes = $this->container->get('victoire_core.helper.business_entity_helper')->getBusinessClassesForWidget($widget);
//test the result
if (!isset($classes[$businessEntityId])) {
throw new \Exception('The entity '.$businessEntityId.' was not found int the business classes.');
}
//get the class of the entity name
$entityClass = $classes[$businessEntityId]->getClass();
}
$form = $this->buildForm($widget, $view, $businessEntityId, $entityClass, $widget->getMode(), $slotId, $position, $parentWidgetMap, $quantum);
return $form;
} | [
"public",
"function",
"callBuildFormSwitchParameters",
"(",
"Widget",
"$",
"widget",
",",
"$",
"view",
",",
"$",
"businessEntityId",
",",
"$",
"position",
",",
"$",
"parentWidgetMap",
",",
"$",
"slotId",
",",
"$",
"quantum",
")",
"{",
"$",
"entityClass",
"="... | Call the build form with selected parameter switch the parameters
The call is not the same if an entity is provided or not.
@param Widget $widget
@param View $view
@param string $businessEntityId
@param int $position
@param string $slotId
@throws \Exception
@return \Symfony\Component\Form\Form | [
"Call",
"the",
"build",
"form",
"with",
"selected",
"parameter",
"switch",
"the",
"parameters",
"The",
"call",
"is",
"not",
"the",
"same",
"if",
"an",
"entity",
"is",
"provided",
"or",
"not",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Builder/WidgetFormBuilder.php#L418-L437 | train |
Victoire/victoire | Bundle/WidgetBundle/Renderer/WidgetRenderer.php | WidgetRenderer.render | public function render(Widget $widget, View $view)
{
//the mode of display of the widget
$mode = $widget->getMode();
//if entity is given and it's not the object, retrieve it and set the entity for the widget
if ($mode == Widget::MODE_BUSINESS_ENTITY && $view instanceof BusinessPage) {
$widget->setEntity($view->getBusinessEntity());
} elseif ($view instanceof BusinessTemplate) {
//We'll try to find a sample entity to mock the widget behavior
/** @var EntityManager $entityManager */
$entityManager = $this->container->get('doctrine.orm.entity_manager');
if ($mock = $this->bepHelper->getEntitiesAllowedQueryBuilder($view, $entityManager)->setMaxResults(1)->getQuery()->getOneOrNullResult()) {
$widget->setEntity($mock);
}
}
//the templating service
$templating = $this->container->get('templating');
//the content of the widget
$parameters = $this->container->get('victoire_widget.widget_content_resolver')->getWidgetContent($widget);
/*
* In some cases, for example, WidgetRender in BusinessEntity mode with magic variables {{entity.id}} transformed
* into the real business entity id, then if in the rendered action, we need to flush, it would persist the
* modified widget which really uncomfortable ;)
*/
if ($widget->getMode() == Widget::MODE_BUSINESS_ENTITY) {
$this->container->get('doctrine.orm.entity_manager')->refresh($widget);
}
//the template displayed is in the widget bundle (with the potential theme)
$showView = 'show'.ucfirst($widget->getTheme());
$templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName($showView, $widget);
return $templating->render($templateName, $parameters);
} | php | public function render(Widget $widget, View $view)
{
//the mode of display of the widget
$mode = $widget->getMode();
//if entity is given and it's not the object, retrieve it and set the entity for the widget
if ($mode == Widget::MODE_BUSINESS_ENTITY && $view instanceof BusinessPage) {
$widget->setEntity($view->getBusinessEntity());
} elseif ($view instanceof BusinessTemplate) {
//We'll try to find a sample entity to mock the widget behavior
/** @var EntityManager $entityManager */
$entityManager = $this->container->get('doctrine.orm.entity_manager');
if ($mock = $this->bepHelper->getEntitiesAllowedQueryBuilder($view, $entityManager)->setMaxResults(1)->getQuery()->getOneOrNullResult()) {
$widget->setEntity($mock);
}
}
//the templating service
$templating = $this->container->get('templating');
//the content of the widget
$parameters = $this->container->get('victoire_widget.widget_content_resolver')->getWidgetContent($widget);
/*
* In some cases, for example, WidgetRender in BusinessEntity mode with magic variables {{entity.id}} transformed
* into the real business entity id, then if in the rendered action, we need to flush, it would persist the
* modified widget which really uncomfortable ;)
*/
if ($widget->getMode() == Widget::MODE_BUSINESS_ENTITY) {
$this->container->get('doctrine.orm.entity_manager')->refresh($widget);
}
//the template displayed is in the widget bundle (with the potential theme)
$showView = 'show'.ucfirst($widget->getTheme());
$templateName = $this->container->get('victoire_widget.widget_helper')->getTemplateName($showView, $widget);
return $templating->render($templateName, $parameters);
} | [
"public",
"function",
"render",
"(",
"Widget",
"$",
"widget",
",",
"View",
"$",
"view",
")",
"{",
"//the mode of display of the widget",
"$",
"mode",
"=",
"$",
"widget",
"->",
"getMode",
"(",
")",
";",
"//if entity is given and it's not the object, retrieve it and set... | render the Widget.
@param Widget $widget
@param View $view
@return widget show | [
"render",
"the",
"Widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Renderer/WidgetRenderer.php#L67-L104 | train |
Victoire/victoire | Bundle/WidgetBundle/Renderer/WidgetRenderer.php | WidgetRenderer.renderContainer | public function renderContainer(Widget $widget, View $view)
{
$dispatcher = $this->container->get('event_dispatcher');
$dispatcher->dispatch(VictoireCmsEvents::WIDGET_PRE_RENDER, new WidgetRenderEvent($widget));
$widgetMap = $widget->getWidgetMap();
$directive = '';
if ($this->container->get('security.authorization_checker')->isGranted('ROLE_VICTOIRE')) {
$directive = 'widget';
}
$id = 'vic-widget-'.$widget->getId().'-container';
$html = sprintf('<div %s widget-map="%s" id="%s" class="vic-widget-container" data-id="%s">', $directive, $widgetMap->getId(), $id, $widget->getId());
if ($this->widgetHelper->isCacheEnabled($widget)) {
$content = $this->widgetCache->fetch($widget);
if (null === $content) {
$content = $this->render($widget, $view);
$this->widgetCache->save($widget, $content);
} else {
$this->victoireCollector->addCachedWidget($widget);
}
} else {
$content = $this->render($widget, $view);
}
$html .= $content;
$html .= '</div>'; //close container
$dispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_RENDER, new WidgetRenderEvent($widget, $html));
return $html;
} | php | public function renderContainer(Widget $widget, View $view)
{
$dispatcher = $this->container->get('event_dispatcher');
$dispatcher->dispatch(VictoireCmsEvents::WIDGET_PRE_RENDER, new WidgetRenderEvent($widget));
$widgetMap = $widget->getWidgetMap();
$directive = '';
if ($this->container->get('security.authorization_checker')->isGranted('ROLE_VICTOIRE')) {
$directive = 'widget';
}
$id = 'vic-widget-'.$widget->getId().'-container';
$html = sprintf('<div %s widget-map="%s" id="%s" class="vic-widget-container" data-id="%s">', $directive, $widgetMap->getId(), $id, $widget->getId());
if ($this->widgetHelper->isCacheEnabled($widget)) {
$content = $this->widgetCache->fetch($widget);
if (null === $content) {
$content = $this->render($widget, $view);
$this->widgetCache->save($widget, $content);
} else {
$this->victoireCollector->addCachedWidget($widget);
}
} else {
$content = $this->render($widget, $view);
}
$html .= $content;
$html .= '</div>'; //close container
$dispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_RENDER, new WidgetRenderEvent($widget, $html));
return $html;
} | [
"public",
"function",
"renderContainer",
"(",
"Widget",
"$",
"widget",
",",
"View",
"$",
"view",
")",
"{",
"$",
"dispatcher",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'event_dispatcher'",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
... | render a widget.
@param Widget $widget
@param View $view
@return string | [
"render",
"a",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Renderer/WidgetRenderer.php#L114-L147 | train |
Victoire/victoire | Bundle/WidgetBundle/Renderer/WidgetRenderer.php | WidgetRenderer.prepareAsynchronousRender | public function prepareAsynchronousRender($widgetId)
{
$ngControllerName = 'widget'.$widgetId.'AsynchronousLoadCtrl';
$ngDirectives = sprintf('ng-controller="WidgetAsynchronousLoadController as %s" class="vic-widget" ng-init="%s.init(%d)" ng-bind-html="html"', $ngControllerName, $ngControllerName, $widgetId);
$html = sprintf('<div class="vic-widget-container vic-widget-asynchronous" data-id="%d" %s></div>', $widgetId, $ngDirectives);
return $html;
} | php | public function prepareAsynchronousRender($widgetId)
{
$ngControllerName = 'widget'.$widgetId.'AsynchronousLoadCtrl';
$ngDirectives = sprintf('ng-controller="WidgetAsynchronousLoadController as %s" class="vic-widget" ng-init="%s.init(%d)" ng-bind-html="html"', $ngControllerName, $ngControllerName, $widgetId);
$html = sprintf('<div class="vic-widget-container vic-widget-asynchronous" data-id="%d" %s></div>', $widgetId, $ngDirectives);
return $html;
} | [
"public",
"function",
"prepareAsynchronousRender",
"(",
"$",
"widgetId",
")",
"{",
"$",
"ngControllerName",
"=",
"'widget'",
".",
"$",
"widgetId",
".",
"'AsynchronousLoadCtrl'",
";",
"$",
"ngDirectives",
"=",
"sprintf",
"(",
"'ng-controller=\"WidgetAsynchronousLoadContr... | prepare a widget to be rendered asynchronously.
@param int $widgetId
@return string | [
"prepare",
"a",
"widget",
"to",
"be",
"rendered",
"asynchronously",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Renderer/WidgetRenderer.php#L156-L163 | train |
Victoire/victoire | Bundle/WidgetBundle/Renderer/WidgetRenderer.php | WidgetRenderer.computeOptions | public function computeOptions($slotId, $options = [])
{
$slots = $this->container->getParameter('victoire_core.slots');
$availableWidgets = $this->container->getParameter('victoire_core.widgets');
$widgets = [];
//If the slot is declared in config
if (!empty($slots[$slotId]) && !empty($slots[$slotId]['widgets'])) {
//parse declared widgets
$slotWidgets = array_keys($slots[$slotId]['widgets']);
} elseif (!empty($options['availableWidgets'])) {
$slotWidgets = $options['availableWidgets'];
} else {
//parse all widgets
$slotWidgets = array_keys($availableWidgets);
}
foreach ($slotWidgets as $slotWidget) {
$widgetParams = $availableWidgets[$slotWidget];
$widgets[$slotWidget]['params'] = $widgetParams;
}
$slots[$slotId]['availableWidgets'] = $widgets;
if (isset($options['max'])) {
$slots[$slotId]['max'] = $options['max'];
}
return $slots[$slotId];
} | php | public function computeOptions($slotId, $options = [])
{
$slots = $this->container->getParameter('victoire_core.slots');
$availableWidgets = $this->container->getParameter('victoire_core.widgets');
$widgets = [];
//If the slot is declared in config
if (!empty($slots[$slotId]) && !empty($slots[$slotId]['widgets'])) {
//parse declared widgets
$slotWidgets = array_keys($slots[$slotId]['widgets']);
} elseif (!empty($options['availableWidgets'])) {
$slotWidgets = $options['availableWidgets'];
} else {
//parse all widgets
$slotWidgets = array_keys($availableWidgets);
}
foreach ($slotWidgets as $slotWidget) {
$widgetParams = $availableWidgets[$slotWidget];
$widgets[$slotWidget]['params'] = $widgetParams;
}
$slots[$slotId]['availableWidgets'] = $widgets;
if (isset($options['max'])) {
$slots[$slotId]['max'] = $options['max'];
}
return $slots[$slotId];
} | [
"public",
"function",
"computeOptions",
"(",
"$",
"slotId",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"slots",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'victoire_core.slots'",
")",
";",
"$",
"availableWidgets",
"=",
"$",
... | Compute slot options.
@param Slot $slotId
@param array $options
@return string | [
"Compute",
"slot",
"options",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Renderer/WidgetRenderer.php#L192-L220 | train |
Victoire/victoire | Bundle/WidgetBundle/Renderer/WidgetRenderer.php | WidgetRenderer.getExtraCssClass | public function getExtraCssClass(Widget $widget)
{
$cssClass = 'v-widget--'.strtolower($this->container->get('victoire_widget.widget_helper')->getWidgetName($widget));
return $cssClass;
} | php | public function getExtraCssClass(Widget $widget)
{
$cssClass = 'v-widget--'.strtolower($this->container->get('victoire_widget.widget_helper')->getWidgetName($widget));
return $cssClass;
} | [
"public",
"function",
"getExtraCssClass",
"(",
"Widget",
"$",
"widget",
")",
"{",
"$",
"cssClass",
"=",
"'v-widget--'",
".",
"strtolower",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'victoire_widget.widget_helper'",
")",
"->",
"getWidgetName",
"(",
... | Get the extra classes for the css.
@return string The classes | [
"Get",
"the",
"extra",
"classes",
"for",
"the",
"css",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Renderer/WidgetRenderer.php#L227-L232 | train |
Victoire/victoire | Bundle/PageBundle/Entity/Traits/WebViewTrait.php | WebViewTrait.isPublished | public function isPublished()
{
if (
$this->getStatus() === PageStatus::PUBLISHED ||
($this->getStatus() === PageStatus::SCHEDULED &&
$this->getPublishedAt() < new \DateTime())
) {
return true;
} else {
return false;
}
} | php | public function isPublished()
{
if (
$this->getStatus() === PageStatus::PUBLISHED ||
($this->getStatus() === PageStatus::SCHEDULED &&
$this->getPublishedAt() < new \DateTime())
) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"isPublished",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
"===",
"PageStatus",
"::",
"PUBLISHED",
"||",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
"===",
"PageStatus",
"::",
"SCHEDULED",
"&&",
"$",
"th... | Is this page published.
@return bool | [
"Is",
"this",
"page",
"published",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Entity/Traits/WebViewTrait.php#L111-L122 | train |
Victoire/victoire | Bundle/SeoBundle/Controller/PageSeoController.php | PageSeoController.settingsAction | public function settingsAction(Request $request, View $view)
{
$pageSeo = $view->getSeo() ?: new PageSeo();
$form = $this->createSettingsForm($pageSeo, $view);
$form->handleRequest($request);
$response = $this->getNotPersistedSettingsResponse(
$form,
$view,
$request->query->get('novalidate', false)
);
return new JsonResponse($response);
} | php | public function settingsAction(Request $request, View $view)
{
$pageSeo = $view->getSeo() ?: new PageSeo();
$form = $this->createSettingsForm($pageSeo, $view);
$form->handleRequest($request);
$response = $this->getNotPersistedSettingsResponse(
$form,
$view,
$request->query->get('novalidate', false)
);
return new JsonResponse($response);
} | [
"public",
"function",
"settingsAction",
"(",
"Request",
"$",
"request",
",",
"View",
"$",
"view",
")",
"{",
"$",
"pageSeo",
"=",
"$",
"view",
"->",
"getSeo",
"(",
")",
"?",
":",
"new",
"PageSeo",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
... | Display a form to edit Seo settings.
@param Request $request
@param View $view
@throws \Exception
@Route("/{id}/settings", name="victoire_seo_pageSeo_settings")
@Method("GET")
@return JsonResponse | [
"Display",
"a",
"form",
"to",
"edit",
"Seo",
"settings",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Controller/PageSeoController.php#L40-L54 | train |
Victoire/victoire | Bundle/SeoBundle/Controller/PageSeoController.php | PageSeoController.settingsPostAction | public function settingsPostAction(Request $request, View $view)
{
$em = $this->getDoctrine()->getManager();
$pageSeo = $view->getSeo() ?: new PageSeo();
$form = $this->createSettingsForm($pageSeo, $view);
$form->handleRequest($request);
$novalidate = $request->query->get('novalidate', false);
if (false === $novalidate && $form->isValid()) {
$em->persist($pageSeo);
$view->setSeo($pageSeo);
$em->persist($view);
$em->flush();
$this->get('victoire_core.current_view')->setCurrentView($view);
$this->congrat('victoire_seo.save.success');
$response = [
'success' => true,
'url' => $this->getViewUrl($view),
];
} else {
$response = $this->getNotPersistedSettingsResponse($form, $view, $novalidate);
}
return new JsonResponse($response);
} | php | public function settingsPostAction(Request $request, View $view)
{
$em = $this->getDoctrine()->getManager();
$pageSeo = $view->getSeo() ?: new PageSeo();
$form = $this->createSettingsForm($pageSeo, $view);
$form->handleRequest($request);
$novalidate = $request->query->get('novalidate', false);
if (false === $novalidate && $form->isValid()) {
$em->persist($pageSeo);
$view->setSeo($pageSeo);
$em->persist($view);
$em->flush();
$this->get('victoire_core.current_view')->setCurrentView($view);
$this->congrat('victoire_seo.save.success');
$response = [
'success' => true,
'url' => $this->getViewUrl($view),
];
} else {
$response = $this->getNotPersistedSettingsResponse($form, $view, $novalidate);
}
return new JsonResponse($response);
} | [
"public",
"function",
"settingsPostAction",
"(",
"Request",
"$",
"request",
",",
"View",
"$",
"view",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"pageSeo",
"=",
"$",
"view",
"->",
"ge... | Save Seo settings.
@param Request $request
@param View $view
@throws \Exception
@Route("/{id}/settings", name="victoire_seo_pageSeo_settings_post")
@Method("POST")
@return JsonResponse | [
"Save",
"Seo",
"settings",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Controller/PageSeoController.php#L69-L97 | train |
Victoire/victoire | Bundle/SeoBundle/Controller/PageSeoController.php | PageSeoController.createSettingsForm | private function createSettingsForm(PageSeo $pageSeo, View $view)
{
return $this->get('form.factory')->create(PageSeoType::class, $pageSeo,
[
'action' => $this->get('router')->generate('victoire_seo_pageSeo_settings_post',
[
'id' => $view->getId(),
]
),
'method' => 'POST',
]
);
} | php | private function createSettingsForm(PageSeo $pageSeo, View $view)
{
return $this->get('form.factory')->create(PageSeoType::class, $pageSeo,
[
'action' => $this->get('router')->generate('victoire_seo_pageSeo_settings_post',
[
'id' => $view->getId(),
]
),
'method' => 'POST',
]
);
} | [
"private",
"function",
"createSettingsForm",
"(",
"PageSeo",
"$",
"pageSeo",
",",
"View",
"$",
"view",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"'form.factory'",
")",
"->",
"create",
"(",
"PageSeoType",
"::",
"class",
",",
"$",
"pageSeo",
",",
... | Create PageSeo Form.
@param PageSeo $pageSeo
@param View $view
@return FormInterface | [
"Create",
"PageSeo",
"Form",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Controller/PageSeoController.php#L107-L119 | train |
Victoire/victoire | Bundle/SeoBundle/Controller/PageSeoController.php | PageSeoController.getViewUrl | private function getViewUrl(View $view)
{
if (!method_exists($view, 'getUrl')) {
return $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
}
/** @var ViewReference $viewReference */
$viewReference = $this->container->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $view->getId()]);
$view->setReference($viewReference);
return $this->generateUrl('victoire_core_page_show', ['url' => $viewReference->getUrl()]);
} | php | private function getViewUrl(View $view)
{
if (!method_exists($view, 'getUrl')) {
return $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]);
}
/** @var ViewReference $viewReference */
$viewReference = $this->container->get('victoire_view_reference.repository')
->getOneReferenceByParameters(['viewId' => $view->getId()]);
$view->setReference($viewReference);
return $this->generateUrl('victoire_core_page_show', ['url' => $viewReference->getUrl()]);
} | [
"private",
"function",
"getViewUrl",
"(",
"View",
"$",
"view",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"view",
",",
"'getUrl'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"generateUrl",
"(",
"'victoire_business_template_show'",
",",
"[",
"'id... | Get url for a View using ViewReferences if necessary.
@param View $view
@return string | [
"Get",
"url",
"for",
"a",
"View",
"using",
"ViewReferences",
"if",
"necessary",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Controller/PageSeoController.php#L160-L173 | train |
Victoire/victoire | Bundle/SeoBundle/Controller/PageSeoController.php | PageSeoController.getBusinessProperties | private function getBusinessProperties(View $view)
{
$businessProperties = [];
if ($view instanceof BusinessTemplate) {
//we can use the business entity properties on the seo
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($view->getBusinessEntityId());
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}
return $businessProperties;
} | php | private function getBusinessProperties(View $view)
{
$businessProperties = [];
if ($view instanceof BusinessTemplate) {
//we can use the business entity properties on the seo
$businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($view->getBusinessEntityId());
$businessProperties = $businessEntity->getBusinessPropertiesByType('seoable');
}
return $businessProperties;
} | [
"private",
"function",
"getBusinessProperties",
"(",
"View",
"$",
"view",
")",
"{",
"$",
"businessProperties",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"view",
"instanceof",
"BusinessTemplate",
")",
"{",
"//we can use the business entity properties on the seo",
"$",
"bus... | Return BusinessEntity seaoable properties if View is a BusinessTemplate.
@param View $view
@throws \Exception
@return array | [
"Return",
"BusinessEntity",
"seaoable",
"properties",
"if",
"View",
"is",
"a",
"BusinessTemplate",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Controller/PageSeoController.php#L184-L195 | train |
Victoire/victoire | Bundle/BlogBundle/Repository/ArticleRepository.php | ArticleRepository.getAll | public function getAll($excludeUnpublished = false, Blog $blog = null)
{
$this->clearInstance();
$this->qb = $this->getInstance();
//If $excludeUnpublished === true, we exclude the non published results
if ($excludeUnpublished) {
$this->qb
->andWhere('article.status = :status')
->orWhere('article.status = :scheduled_status AND article.publishedAt <= :now')
->setParameter('status', PageStatus::PUBLISHED)
->setParameter('scheduled_status', PageStatus::SCHEDULED)
->setParameter('now', new \DateTime());
}
if (null != $blog) {
$this->qb
->andWhere('article.blog = :blog')
->setParameter('blog', $blog->getId());
}
return $this;
} | php | public function getAll($excludeUnpublished = false, Blog $blog = null)
{
$this->clearInstance();
$this->qb = $this->getInstance();
//If $excludeUnpublished === true, we exclude the non published results
if ($excludeUnpublished) {
$this->qb
->andWhere('article.status = :status')
->orWhere('article.status = :scheduled_status AND article.publishedAt <= :now')
->setParameter('status', PageStatus::PUBLISHED)
->setParameter('scheduled_status', PageStatus::SCHEDULED)
->setParameter('now', new \DateTime());
}
if (null != $blog) {
$this->qb
->andWhere('article.blog = :blog')
->setParameter('blog', $blog->getId());
}
return $this;
} | [
"public",
"function",
"getAll",
"(",
"$",
"excludeUnpublished",
"=",
"false",
",",
"Blog",
"$",
"blog",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"clearInstance",
"(",
")",
";",
"$",
"this",
"->",
"qb",
"=",
"$",
"this",
"->",
"getInstance",
"(",
")"... | Get all articles in the repository.
@param bool $excludeUnpublished Should we get only the published BasePages ?
@return ArticleRepository | [
"Get",
"all",
"articles",
"in",
"the",
"repository",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/ArticleRepository.php#L25-L47 | train |
Victoire/victoire | Bundle/BlogBundle/Repository/ArticleRepository.php | ArticleRepository.run | public function run($method = 'getResult', $hydrationMode = Query::HYDRATE_OBJECT)
{
return $this->getInstance()->getQuery()->$method($hydrationMode);
} | php | public function run($method = 'getResult', $hydrationMode = Query::HYDRATE_OBJECT)
{
return $this->getInstance()->getQuery()->$method($hydrationMode);
} | [
"public",
"function",
"run",
"(",
"$",
"method",
"=",
"'getResult'",
",",
"$",
"hydrationMode",
"=",
"Query",
"::",
"HYDRATE_OBJECT",
")",
"{",
"return",
"$",
"this",
"->",
"getInstance",
"(",
")",
"->",
"getQuery",
"(",
")",
"->",
"$",
"method",
"(",
... | Get very next festivals query builder.
@param method $method The method to run
@param hydrationMode $hydrationMode How the results will be (Object ? Array )
@return array() | [
"Get",
"very",
"next",
"festivals",
"query",
"builder",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/ArticleRepository.php#L71-L74 | train |
Victoire/victoire | Bundle/BlogBundle/Repository/ArticleRepository.php | ArticleRepository.filterWithListingQuery | public function filterWithListingQuery($listingQuery = null)
{
if ($listingQuery) {
$dql = $this->createQueryBuilder('item')
->leftJoin('item.blog', 'blog')
->getDql();
$dql = $dql.' '.$listingQuery;
$this->qb
->andWhere($this->qb->expr()->in('article', $dql));
}
return $this;
} | php | public function filterWithListingQuery($listingQuery = null)
{
if ($listingQuery) {
$dql = $this->createQueryBuilder('item')
->leftJoin('item.blog', 'blog')
->getDql();
$dql = $dql.' '.$listingQuery;
$this->qb
->andWhere($this->qb->expr()->in('article', $dql));
}
return $this;
} | [
"public",
"function",
"filterWithListingQuery",
"(",
"$",
"listingQuery",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"listingQuery",
")",
"{",
"$",
"dql",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'item'",
")",
"->",
"leftJoin",
"(",
"'item.blog'",
"... | Use to assemble ArticleList Query with Filter Query.
@param null $listingQuery
@return $this | [
"Use",
"to",
"assemble",
"ArticleList",
"Query",
"with",
"Filter",
"Query",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/ArticleRepository.php#L83-L95 | train |
Victoire/victoire | Bundle/BlogBundle/Repository/ArticleRepository.php | ArticleRepository.getArticles | public function getArticles(Blog $blog)
{
$queryBuilder = $this->getAll(false, $blog)
->getInstance();
return $queryBuilder
->andWhere('article.status IN (:status)')
->setParameter('status', [
PageStatus::PUBLISHED,
PageStatus::SCHEDULED,
PageStatus::UNPUBLISHED,
])
->orderBy('article.publishedAt', 'DESC')
->getQuery()
->getResult();
} | php | public function getArticles(Blog $blog)
{
$queryBuilder = $this->getAll(false, $blog)
->getInstance();
return $queryBuilder
->andWhere('article.status IN (:status)')
->setParameter('status', [
PageStatus::PUBLISHED,
PageStatus::SCHEDULED,
PageStatus::UNPUBLISHED,
])
->orderBy('article.publishedAt', 'DESC')
->getQuery()
->getResult();
} | [
"public",
"function",
"getArticles",
"(",
"Blog",
"$",
"blog",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getAll",
"(",
"false",
",",
"$",
"blog",
")",
"->",
"getInstance",
"(",
")",
";",
"return",
"$",
"queryBuilder",
"->",
"andWhere",
"(... | Get Article by blog ordered by publication DESC.
@param Blog $blog
@return array() | [
"Get",
"Article",
"by",
"blog",
"ordered",
"by",
"publication",
"DESC",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/ArticleRepository.php#L154-L169 | train |
Victoire/victoire | Bundle/BlogBundle/Repository/ArticleRepository.php | ArticleRepository.getDrafts | public function getDrafts(Blog $blog)
{
$queryBuilder = $this->getAll(false, $blog)
->getInstance();
return $queryBuilder
->andWhere('article.status = :status')
->setParameter('status', PageStatus::DRAFT)
->orderBy('article.createdAt', 'DESC')
->getQuery()
->getResult();
} | php | public function getDrafts(Blog $blog)
{
$queryBuilder = $this->getAll(false, $blog)
->getInstance();
return $queryBuilder
->andWhere('article.status = :status')
->setParameter('status', PageStatus::DRAFT)
->orderBy('article.createdAt', 'DESC')
->getQuery()
->getResult();
} | [
"public",
"function",
"getDrafts",
"(",
"Blog",
"$",
"blog",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"getAll",
"(",
"false",
",",
"$",
"blog",
")",
"->",
"getInstance",
"(",
")",
";",
"return",
"$",
"queryBuilder",
"->",
"andWhere",
"(",... | Get articles by blog ordered by creation DESC.
@param Blog $blog
@return array() | [
"Get",
"articles",
"by",
"blog",
"ordered",
"by",
"creation",
"DESC",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/ArticleRepository.php#L178-L189 | train |
Victoire/victoire | Bundle/SeoBundle/Repository/HttpErrorRepository.php | HttpErrorRepository.getAll | public function getAll($exceptRedirected = false)
{
$this->clearInstance();
$this->qb = $this->getInstance('error');
if (true === $exceptRedirected) {
$this->qb->andWhere('error.redirection IS NULL');
}
return $this;
} | php | public function getAll($exceptRedirected = false)
{
$this->clearInstance();
$this->qb = $this->getInstance('error');
if (true === $exceptRedirected) {
$this->qb->andWhere('error.redirection IS NULL');
}
return $this;
} | [
"public",
"function",
"getAll",
"(",
"$",
"exceptRedirected",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"clearInstance",
"(",
")",
";",
"$",
"this",
"->",
"qb",
"=",
"$",
"this",
"->",
"getInstance",
"(",
"'error'",
")",
";",
"if",
"(",
"true",
"===... | Get every errors in the repository.
@param bool $exceptRedirected
@return HttpErrorRepository | [
"Get",
"every",
"errors",
"in",
"the",
"repository",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Repository/HttpErrorRepository.php#L24-L35 | train |
Victoire/victoire | Bundle/SeoBundle/Repository/HttpErrorRepository.php | HttpErrorRepository.getRouteErrors | public function getRouteErrors($order = 'error.counter', $direction = 'DESC')
{
$this->getAll(true);
/** @var QueryBuilder $qb */
$qb = $this->qb;
return $qb
->andWhere('error.type = :type')
->setParameter('type', HttpError::TYPE_ROUTE)
->orderBy($order, $direction);
} | php | public function getRouteErrors($order = 'error.counter', $direction = 'DESC')
{
$this->getAll(true);
/** @var QueryBuilder $qb */
$qb = $this->qb;
return $qb
->andWhere('error.type = :type')
->setParameter('type', HttpError::TYPE_ROUTE)
->orderBy($order, $direction);
} | [
"public",
"function",
"getRouteErrors",
"(",
"$",
"order",
"=",
"'error.counter'",
",",
"$",
"direction",
"=",
"'DESC'",
")",
"{",
"$",
"this",
"->",
"getAll",
"(",
"true",
")",
";",
"/** @var QueryBuilder $qb */",
"$",
"qb",
"=",
"$",
"this",
"->",
"qb",
... | Get every route errors in the repository.
@param string $order
@param string $direction
@return QueryBuilder | [
"Get",
"every",
"route",
"errors",
"in",
"the",
"repository",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Repository/HttpErrorRepository.php#L45-L56 | train |
Victoire/victoire | Bundle/SeoBundle/Repository/HttpErrorRepository.php | HttpErrorRepository.getFileErrors | public function getFileErrors($order = 'error.counter', $direction = 'DESC')
{
$this->getAll(true);
/** @var QueryBuilder $qb */
$qb = $this->qb;
return $qb
->andWhere('error.type = :type')
->setParameter('type', HttpError::TYPE_FILE)
->orderBy($order, $direction);
} | php | public function getFileErrors($order = 'error.counter', $direction = 'DESC')
{
$this->getAll(true);
/** @var QueryBuilder $qb */
$qb = $this->qb;
return $qb
->andWhere('error.type = :type')
->setParameter('type', HttpError::TYPE_FILE)
->orderBy($order, $direction);
} | [
"public",
"function",
"getFileErrors",
"(",
"$",
"order",
"=",
"'error.counter'",
",",
"$",
"direction",
"=",
"'DESC'",
")",
"{",
"$",
"this",
"->",
"getAll",
"(",
"true",
")",
";",
"/** @var QueryBuilder $qb */",
"$",
"qb",
"=",
"$",
"this",
"->",
"qb",
... | Get every file errors in the repository.
@param string $order
@param string $direction
@return QueryBuilder | [
"Get",
"every",
"file",
"errors",
"in",
"the",
"repository",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Repository/HttpErrorRepository.php#L66-L77 | train |
Victoire/victoire | Bundle/WidgetBundle/Helper/WidgetHelper.php | WidgetHelper.getWidgetName | public function getWidgetName(Widget $widget)
{
$widgets = $this->container->getParameter('victoire_core.widgets');
foreach ($widgets as $widgetParams) {
if ($widgetParams['class'] === ClassUtils::getClass($widget)) {
return $widgetParams['name'];
}
}
throw new \Exception('Widget name not found for widget '.get_class($widget).'. Is this widget right declared in AppKernel ?');
} | php | public function getWidgetName(Widget $widget)
{
$widgets = $this->container->getParameter('victoire_core.widgets');
foreach ($widgets as $widgetParams) {
if ($widgetParams['class'] === ClassUtils::getClass($widget)) {
return $widgetParams['name'];
}
}
throw new \Exception('Widget name not found for widget '.get_class($widget).'. Is this widget right declared in AppKernel ?');
} | [
"public",
"function",
"getWidgetName",
"(",
"Widget",
"$",
"widget",
")",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'victoire_core.widgets'",
")",
";",
"foreach",
"(",
"$",
"widgets",
"as",
"$",
"widgetParams",
")"... | The name of the widget.
@return string | [
"The",
"name",
"of",
"the",
"widget",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Helper/WidgetHelper.php#L23-L33 | train |
Victoire/victoire | Bundle/WidgetBundle/Helper/WidgetHelper.php | WidgetHelper.isWidgetAllowedForSlot | public function isWidgetAllowedForSlot(Widget $widget, $slot)
{
$widgetName = $this->getWidgetName($widget);
$slots = $this->slots;
return !empty($slots[$slot]) && (array_key_exists($widgetName, $slots[$slot]['widgets']));
} | php | public function isWidgetAllowedForSlot(Widget $widget, $slot)
{
$widgetName = $this->getWidgetName($widget);
$slots = $this->slots;
return !empty($slots[$slot]) && (array_key_exists($widgetName, $slots[$slot]['widgets']));
} | [
"public",
"function",
"isWidgetAllowedForSlot",
"(",
"Widget",
"$",
"widget",
",",
"$",
"slot",
")",
"{",
"$",
"widgetName",
"=",
"$",
"this",
"->",
"getWidgetName",
"(",
"$",
"widget",
")",
";",
"$",
"slots",
"=",
"$",
"this",
"->",
"slots",
";",
"ret... | check if widget is allowed for slot.
@param Widget $widget
@param string $slot
@return bool | [
"check",
"if",
"widget",
"is",
"allowed",
"for",
"slot",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Helper/WidgetHelper.php#L43-L49 | train |
Victoire/victoire | Bundle/WidgetBundle/Helper/WidgetHelper.php | WidgetHelper.newWidgetInstance | public function newWidgetInstance($type, $view, $slot, $mode)
{
$widgetAlias = 'victoire.widget.'.strtolower($type);
$widget = $this->container->get($widgetAlias);
$widget->setMode($mode);
return $widget;
} | php | public function newWidgetInstance($type, $view, $slot, $mode)
{
$widgetAlias = 'victoire.widget.'.strtolower($type);
$widget = $this->container->get($widgetAlias);
$widget->setMode($mode);
return $widget;
} | [
"public",
"function",
"newWidgetInstance",
"(",
"$",
"type",
",",
"$",
"view",
",",
"$",
"slot",
",",
"$",
"mode",
")",
"{",
"$",
"widgetAlias",
"=",
"'victoire.widget.'",
".",
"strtolower",
"(",
"$",
"type",
")",
";",
"$",
"widget",
"=",
"$",
"this",
... | create a new WidgetRedactor.
@param string $type
@param \Victoire\Bundle\CoreBundle\Entity\View $view
@param string $slot
@param string $mode
@return Widget $widget | [
"create",
"a",
"new",
"WidgetRedactor",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Helper/WidgetHelper.php#L61-L69 | train |
Victoire/victoire | Bundle/WidgetBundle/Helper/WidgetHelper.php | WidgetHelper.getTemplateName | public function getTemplateName($action, Widget $widget)
{
//the template displayed is in the widget bundle
$templateName = 'VictoireWidget'.$this->getWidgetName($widget).'Bundle::'.$action.'.html.twig';
return $templateName;
} | php | public function getTemplateName($action, Widget $widget)
{
//the template displayed is in the widget bundle
$templateName = 'VictoireWidget'.$this->getWidgetName($widget).'Bundle::'.$action.'.html.twig';
return $templateName;
} | [
"public",
"function",
"getTemplateName",
"(",
"$",
"action",
",",
"Widget",
"$",
"widget",
")",
"{",
"//the template displayed is in the widget bundle",
"$",
"templateName",
"=",
"'VictoireWidget'",
".",
"$",
"this",
"->",
"getWidgetName",
"(",
"$",
"widget",
")",
... | Get the name of the template to display for an action.
@param string $action
@param Widget $widget
@todo find a better way to get the requested template
@return string | [
"Get",
"the",
"name",
"of",
"the",
"template",
"to",
"display",
"for",
"an",
"action",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Helper/WidgetHelper.php#L81-L87 | train |
Victoire/victoire | Bundle/WidgetBundle/Helper/WidgetHelper.php | WidgetHelper.deleteById | public function deleteById($widgetId)
{
$entityManager = $this->container->get('doctrine.orm.entity_manager');
$connection = $entityManager->getConnection();
$statement = $connection->prepare('DELETE FROM vic_widget WHERE id = :id');
$statement->bindValue('id', $widgetId);
$statement->execute();
} | php | public function deleteById($widgetId)
{
$entityManager = $this->container->get('doctrine.orm.entity_manager');
$connection = $entityManager->getConnection();
$statement = $connection->prepare('DELETE FROM vic_widget WHERE id = :id');
$statement->bindValue('id', $widgetId);
$statement->execute();
} | [
"public",
"function",
"deleteById",
"(",
"$",
"widgetId",
")",
"{",
"$",
"entityManager",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine.orm.entity_manager'",
")",
";",
"$",
"connection",
"=",
"$",
"entityManager",
"->",
"getConnection",
"("... | Delete manually a widget with its id.
@param int $widgetId
@return string | [
"Delete",
"manually",
"a",
"widget",
"with",
"its",
"id",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Helper/WidgetHelper.php#L96-L103 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Command/GenerateViewReferenceCommand.php | GenerateViewReferenceCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var ViewHelper $viewHelper */
$viewHelper = $this->getContainer()->get('victoire_core.view_helper');
$viewsReferences = $viewHelper->buildViewsReferences();
$this->getContainer()->get('victoire_view_reference.manager')->saveReferences($viewsReferences);
$output->writeln('<info>The ViewReference has been generated.</info>');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var ViewHelper $viewHelper */
$viewHelper = $this->getContainer()->get('victoire_core.view_helper');
$viewsReferences = $viewHelper->buildViewsReferences();
$this->getContainer()->get('victoire_view_reference.manager')->saveReferences($viewsReferences);
$output->writeln('<info>The ViewReference has been generated.</info>');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"/** @var ViewHelper $viewHelper */",
"$",
"viewHelper",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'victoire_core.v... | Read declared business entities and BusinessEntityPatternPages to generate their urls.
@param InputInterface $input
@param OutputInterface $output
@return void | [
"Read",
"declared",
"business",
"entities",
"and",
"BusinessEntityPatternPages",
"to",
"generate",
"their",
"urls",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Command/GenerateViewReferenceCommand.php#L34-L41 | train |
Victoire/victoire | Bundle/ConfigBundle/Favicon/FaviconGenerator.php | FaviconGenerator.generate | public function generate(GlobalConfig $globalConfig, $path = 'faviconConfig.json')
{
return $this->generateFromConfigFile($this->faviconConfigDumper->dump($globalConfig, $path));
} | php | public function generate(GlobalConfig $globalConfig, $path = 'faviconConfig.json')
{
return $this->generateFromConfigFile($this->faviconConfigDumper->dump($globalConfig, $path));
} | [
"public",
"function",
"generate",
"(",
"GlobalConfig",
"$",
"globalConfig",
",",
"$",
"path",
"=",
"'faviconConfig.json'",
")",
"{",
"return",
"$",
"this",
"->",
"generateFromConfigFile",
"(",
"$",
"this",
"->",
"faviconConfigDumper",
"->",
"dump",
"(",
"$",
"... | Generate favicons from realfavicon generator and a GlobalConfig object.
@param GlobalConfig $globalConfig
@param string $path
@return array The generated files | [
"Generate",
"favicons",
"from",
"realfavicon",
"generator",
"and",
"a",
"GlobalConfig",
"object",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ConfigBundle/Favicon/FaviconGenerator.php#L56-L59 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Entity/Slot.php | Slot.updateWidgetMap | public function updateWidgetMap($widgetMap)
{
//parse all widfgetMaps
foreach ($this->widgetMaps as $key => $_widgetMap) {
//if this the widgetMap we are looking for
if ($_widgetMap->getWidgetId() === $widgetMap->getWidgetId()) {
$this->widgetMaps[$key] = $widgetMap;
//there no need to continue, we found the slot
break;
}
}
return $this;
} | php | public function updateWidgetMap($widgetMap)
{
//parse all widfgetMaps
foreach ($this->widgetMaps as $key => $_widgetMap) {
//if this the widgetMap we are looking for
if ($_widgetMap->getWidgetId() === $widgetMap->getWidgetId()) {
$this->widgetMaps[$key] = $widgetMap;
//there no need to continue, we found the slot
break;
}
}
return $this;
} | [
"public",
"function",
"updateWidgetMap",
"(",
"$",
"widgetMap",
")",
"{",
"//parse all widfgetMaps",
"foreach",
"(",
"$",
"this",
"->",
"widgetMaps",
"as",
"$",
"key",
"=>",
"$",
"_widgetMap",
")",
"{",
"//if this the widgetMap we are looking for",
"if",
"(",
"$",... | Update the given widgetMap.
@param WidgetMap $widgetMap
@return Slot | [
"Update",
"the",
"given",
"widgetMap",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Entity/Slot.php#L76-L89 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Entity/Slot.php | Slot.getWidgetMapByWidgetId | public function getWidgetMapByWidgetId($widgetId)
{
$widgetMap = null;
$widgetMaps = $this->widgetMaps;
//parse the widgets maps
foreach ($widgetMaps as $wm) {
if ($wm->getWidgetId() === $widgetId) {
$widgetMap = $wm;
//entity found, there is no need to continue
break;
}
}
return $widgetMap;
} | php | public function getWidgetMapByWidgetId($widgetId)
{
$widgetMap = null;
$widgetMaps = $this->widgetMaps;
//parse the widgets maps
foreach ($widgetMaps as $wm) {
if ($wm->getWidgetId() === $widgetId) {
$widgetMap = $wm;
//entity found, there is no need to continue
break;
}
}
return $widgetMap;
} | [
"public",
"function",
"getWidgetMapByWidgetId",
"(",
"$",
"widgetId",
")",
"{",
"$",
"widgetMap",
"=",
"null",
";",
"$",
"widgetMaps",
"=",
"$",
"this",
"->",
"widgetMaps",
";",
"//parse the widgets maps",
"foreach",
"(",
"$",
"widgetMaps",
"as",
"$",
"wm",
... | Get the widget map by the widget id.
@param int $widgetId
@return WidgetMap | [
"Get",
"the",
"widget",
"map",
"by",
"the",
"widget",
"id",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Entity/Slot.php#L98-L114 | train |
Victoire/victoire | Bundle/WidgetMapBundle/Entity/Slot.php | Slot.removeWidgetMap | public function removeWidgetMap(WidgetMap $widgetMap)
{
$widgetMaps = $this->widgetMaps;
//parse the widgets maps
foreach ($widgetMaps as $index => $wm) {
if ($wm->getWidgetId() === $widgetMap->getWidgetId()) {
unset($this->widgetMaps[$index]);
//entity found, there is no need to continue
break;
}
}
} | php | public function removeWidgetMap(WidgetMap $widgetMap)
{
$widgetMaps = $this->widgetMaps;
//parse the widgets maps
foreach ($widgetMaps as $index => $wm) {
if ($wm->getWidgetId() === $widgetMap->getWidgetId()) {
unset($this->widgetMaps[$index]);
//entity found, there is no need to continue
break;
}
}
} | [
"public",
"function",
"removeWidgetMap",
"(",
"WidgetMap",
"$",
"widgetMap",
")",
"{",
"$",
"widgetMaps",
"=",
"$",
"this",
"->",
"widgetMaps",
";",
"//parse the widgets maps",
"foreach",
"(",
"$",
"widgetMaps",
"as",
"$",
"index",
"=>",
"$",
"wm",
")",
"{",... | Remove the widget map from the slot.
@param WidgetMap $widgetMap | [
"Remove",
"the",
"widget",
"map",
"from",
"the",
"slot",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Entity/Slot.php#L121-L133 | train |
Victoire/victoire | Bundle/FormBundle/Twig/IconExtension.php | IconExtension.renderIcon | public function renderIcon($icon, $inverted = false)
{
$template = $this->getIconTemplate();
$context = [
'icon' => $icon,
'inverted' => $inverted,
];
return $template->renderBlock($this->iconSet, $context);
} | php | public function renderIcon($icon, $inverted = false)
{
$template = $this->getIconTemplate();
$context = [
'icon' => $icon,
'inverted' => $inverted,
];
return $template->renderBlock($this->iconSet, $context);
} | [
"public",
"function",
"renderIcon",
"(",
"$",
"icon",
",",
"$",
"inverted",
"=",
"false",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getIconTemplate",
"(",
")",
";",
"$",
"context",
"=",
"[",
"'icon'",
"=>",
"$",
"icon",
",",
"'inverted'",
"... | Renders the icon.
@param string $icon
@param bool $inverted
@return Response | [
"Renders",
"the",
"icon",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/FormBundle/Twig/IconExtension.php#L87-L96 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Listener/ViewReferenceListener.php | ViewReferenceListener.updateViewReference | public function updateViewReference(ViewReferenceEvent $event)
{
$view = $event->getView();
if ($viewReference = $this->viewReferenceBuilder->buildViewReference($view, $this->em)) {
$this->viewReferenceManager->saveReference($viewReference);
}
} | php | public function updateViewReference(ViewReferenceEvent $event)
{
$view = $event->getView();
if ($viewReference = $this->viewReferenceBuilder->buildViewReference($view, $this->em)) {
$this->viewReferenceManager->saveReference($viewReference);
}
} | [
"public",
"function",
"updateViewReference",
"(",
"ViewReferenceEvent",
"$",
"event",
")",
"{",
"$",
"view",
"=",
"$",
"event",
"->",
"getView",
"(",
")",
";",
"if",
"(",
"$",
"viewReference",
"=",
"$",
"this",
"->",
"viewReferenceBuilder",
"->",
"buildViewR... | This method is call when a viewReference need to be update.
@param ViewReferenceEvent $event | [
"This",
"method",
"is",
"call",
"when",
"a",
"viewReference",
"need",
"to",
"be",
"update",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Listener/ViewReferenceListener.php#L51-L57 | train |
Victoire/victoire | Bundle/ViewReferenceBundle/Listener/ViewReferenceListener.php | ViewReferenceListener.removeViewReference | public function removeViewReference(ViewReferenceEvent $event)
{
$view = $event->getView();
if ($viewReference = $this->viewReferenceBuilder->buildViewReference($view, $this->em)) {
$this->viewReferenceManager->removeReference($viewReference);
}
} | php | public function removeViewReference(ViewReferenceEvent $event)
{
$view = $event->getView();
if ($viewReference = $this->viewReferenceBuilder->buildViewReference($view, $this->em)) {
$this->viewReferenceManager->removeReference($viewReference);
}
} | [
"public",
"function",
"removeViewReference",
"(",
"ViewReferenceEvent",
"$",
"event",
")",
"{",
"$",
"view",
"=",
"$",
"event",
"->",
"getView",
"(",
")",
";",
"if",
"(",
"$",
"viewReference",
"=",
"$",
"this",
"->",
"viewReferenceBuilder",
"->",
"buildViewR... | This method is call when a viewReference need to be remove.
@param ViewReferenceEvent $event | [
"This",
"method",
"is",
"call",
"when",
"a",
"viewReference",
"need",
"to",
"be",
"remove",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Listener/ViewReferenceListener.php#L64-L70 | train |
Victoire/victoire | Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php | StateFullRepositoryTrait.getInstance | public function getInstance($alias = null)
{
if (!$alias && !$this->mainAlias) {
$namespace = explode('\\', $this->_entityName);
$alias = strtolower(end($namespace));
$this->mainAlias = $alias;
} elseif ($alias) {
$this->mainAlias = $alias;
}
return $this->qb ? $this->qb : $this->qb = $this->createQueryBuilder($this->mainAlias);
} | php | public function getInstance($alias = null)
{
if (!$alias && !$this->mainAlias) {
$namespace = explode('\\', $this->_entityName);
$alias = strtolower(end($namespace));
$this->mainAlias = $alias;
} elseif ($alias) {
$this->mainAlias = $alias;
}
return $this->qb ? $this->qb : $this->qb = $this->createQueryBuilder($this->mainAlias);
} | [
"public",
"function",
"getInstance",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"alias",
"&&",
"!",
"$",
"this",
"->",
"mainAlias",
")",
"{",
"$",
"namespace",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"_entityName",
... | Get query builder instance.
@param string $alias The entity alias
@return QueryBuilder The active or default query builder | [
"Get",
"query",
"builder",
"instance",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php#L25-L36 | train |
Victoire/victoire | Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php | StateFullRepositoryTrait.run | public function run($method = 'getResult', $hydrationMode = Query::HYDRATE_OBJECT, $autoClear = true)
{
$results = $this->qb->getQuery()->$method($hydrationMode);
if ($autoClear) {
$this->clearInstance();
}
return $results;
} | php | public function run($method = 'getResult', $hydrationMode = Query::HYDRATE_OBJECT, $autoClear = true)
{
$results = $this->qb->getQuery()->$method($hydrationMode);
if ($autoClear) {
$this->clearInstance();
}
return $results;
} | [
"public",
"function",
"run",
"(",
"$",
"method",
"=",
"'getResult'",
",",
"$",
"hydrationMode",
"=",
"Query",
"::",
"HYDRATE_OBJECT",
",",
"$",
"autoClear",
"=",
"true",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"qb",
"->",
"getQuery",
"(",
")"... | Run active query.
@param string $method The method to run
@param string $hydrationMode How the results will be (Object ? Array )
@param bool $autoClear AutoClear means reset active instance
@return array() | [
"Run",
"active",
"query",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/StateFullRepositoryTrait.php#L74-L82 | train |
Victoire/victoire | Bundle/MediaBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.getCurrent | public function getCurrent()
{
if ($this->currentCache !== null) {
return $this->currentCache;
}
/* @var $active MenuItem */
$active = null;
do {
/* @var MenuItem[] $children */
$children = $this->getChildren($active);
$foundActiveChild = false;
foreach ($children as $child) {
if ($child->getActive()) {
$foundActiveChild = true;
$active = $child;
break;
}
}
} while ($foundActiveChild);
$this->currentCache = $active;
return $active;
} | php | public function getCurrent()
{
if ($this->currentCache !== null) {
return $this->currentCache;
}
/* @var $active MenuItem */
$active = null;
do {
/* @var MenuItem[] $children */
$children = $this->getChildren($active);
$foundActiveChild = false;
foreach ($children as $child) {
if ($child->getActive()) {
$foundActiveChild = true;
$active = $child;
break;
}
}
} while ($foundActiveChild);
$this->currentCache = $active;
return $active;
} | [
"public",
"function",
"getCurrent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentCache",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"currentCache",
";",
"}",
"/* @var $active MenuItem */",
"$",
"active",
"=",
"null",
";",
"do",
"{",
"/... | Get current menu item.
@return MenuItem|null | [
"Get",
"current",
"menu",
"item",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/Menu/MenuBuilder.php#L58-L80 | train |
Victoire/victoire | Bundle/MediaBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.getBreadCrumb | public function getBreadCrumb()
{
$result = [];
$current = $this->getCurrent();
while (!is_null($current)) {
array_unshift($result, $current);
$current = $current->getParent();
}
return $result;
} | php | public function getBreadCrumb()
{
$result = [];
$current = $this->getCurrent();
while (!is_null($current)) {
array_unshift($result, $current);
$current = $current->getParent();
}
return $result;
} | [
"public",
"function",
"getBreadCrumb",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"current",
"=",
"$",
"this",
"->",
"getCurrent",
"(",
")",
";",
"while",
"(",
"!",
"is_null",
"(",
"$",
"current",
")",
")",
"{",
"array_unshift",
"(",
"$... | Get breadcrumb path for current menu item.
@return MenuItem[] | [
"Get",
"breadcrumb",
"path",
"for",
"current",
"menu",
"item",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/Menu/MenuBuilder.php#L87-L97 | train |
Victoire/victoire | Bundle/MediaBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.getTopChildren | public function getTopChildren()
{
if (is_null($this->topMenuItems)) {
$this->topMenuItems = [];
foreach ($this->adaptors as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $this->topMenuItems, null, $this->getRequest());
}
}
return $this->topMenuItems;
} | php | public function getTopChildren()
{
if (is_null($this->topMenuItems)) {
$this->topMenuItems = [];
foreach ($this->adaptors as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $this->topMenuItems, null, $this->getRequest());
}
}
return $this->topMenuItems;
} | [
"public",
"function",
"getTopChildren",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"topMenuItems",
")",
")",
"{",
"$",
"this",
"->",
"topMenuItems",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"adaptors",
"as",
"$",
"menu... | Get all top menu items.
@return MenuItem[] | [
"Get",
"all",
"top",
"menu",
"items",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/Menu/MenuBuilder.php#L120-L130 | train |
Victoire/victoire | Bundle/MediaBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.getChildren | public function getChildren(MenuItem $parent = null)
{
if ($parent == null) {
return $this->getTopChildren();
}
$result = [];
foreach ($this->adaptors as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $result, $parent, $this->getRequest());
}
return $result;
} | php | public function getChildren(MenuItem $parent = null)
{
if ($parent == null) {
return $this->getTopChildren();
}
$result = [];
foreach ($this->adaptors as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $result, $parent, $this->getRequest());
}
return $result;
} | [
"public",
"function",
"getChildren",
"(",
"MenuItem",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parent",
"==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getTopChildren",
"(",
")",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"for... | Get immediate children of the specified menu item.
@param MenuItem $parent
@return MenuItem[] | [
"Get",
"immediate",
"children",
"of",
"the",
"specified",
"menu",
"item",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/Menu/MenuBuilder.php#L139-L150 | train |
Victoire/victoire | Bundle/CoreBundle/Entity/Link.php | Link.checkLink | public function checkLink(ExecutionContextInterface $context)
{
$violation = false;
// check if the name is actually a fake name
switch ($this->getLinkType()) {
case self::TYPE_VIEW_REFERENCE:
$violation = $this->getViewReference() == null;
break;
case self::TYPE_ROUTE:
$violation = $this->getRoute() == null;
break;
case self::TYPE_URL:
$violation = $this->getUrl() == null;
break;
case self::TYPE_WIDGET:
$violation = $this->getAttachedWidget() == null;
break;
default:
break;
}
if ($violation) {
$context->buildViolation('validator.link.error.message.'.$this->getLinkType().'Missing')->addViolation();
}
} | php | public function checkLink(ExecutionContextInterface $context)
{
$violation = false;
// check if the name is actually a fake name
switch ($this->getLinkType()) {
case self::TYPE_VIEW_REFERENCE:
$violation = $this->getViewReference() == null;
break;
case self::TYPE_ROUTE:
$violation = $this->getRoute() == null;
break;
case self::TYPE_URL:
$violation = $this->getUrl() == null;
break;
case self::TYPE_WIDGET:
$violation = $this->getAttachedWidget() == null;
break;
default:
break;
}
if ($violation) {
$context->buildViolation('validator.link.error.message.'.$this->getLinkType().'Missing')->addViolation();
}
} | [
"public",
"function",
"checkLink",
"(",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"$",
"violation",
"=",
"false",
";",
"// check if the name is actually a fake name",
"switch",
"(",
"$",
"this",
"->",
"getLinkType",
"(",
")",
")",
"{",
"case",
"self",... | undocumented function.
@param ExecutionContextInterface $context
@author | [
"undocumented",
"function",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Entity/Link.php#L337-L361 | train |
Victoire/victoire | Bundle/PageBundle/Matcher/UrlMatcher.php | UrlMatcher.removeLastPart | protected function removeLastPart($url)
{
$shortenUrl = null;
if ($url !== null && $url !== '') {
// split on the / character
$keywords = preg_split("/\//", $url);
//if there are some words, we pop the last
if (count($keywords) > 0) {
array_pop($keywords);
//rebuild the url
$shortenUrl = implode('/', $keywords);
}
}
return $shortenUrl;
} | php | protected function removeLastPart($url)
{
$shortenUrl = null;
if ($url !== null && $url !== '') {
// split on the / character
$keywords = preg_split("/\//", $url);
//if there are some words, we pop the last
if (count($keywords) > 0) {
array_pop($keywords);
//rebuild the url
$shortenUrl = implode('/', $keywords);
}
}
return $shortenUrl;
} | [
"protected",
"function",
"removeLastPart",
"(",
"$",
"url",
")",
"{",
"$",
"shortenUrl",
"=",
"null",
";",
"if",
"(",
"$",
"url",
"!==",
"null",
"&&",
"$",
"url",
"!==",
"''",
")",
"{",
"// split on the / character",
"$",
"keywords",
"=",
"preg_split",
"... | Remove the last part of the url.
@param string $url
@return string The shorten url | [
"Remove",
"the",
"last",
"part",
"of",
"the",
"url",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Matcher/UrlMatcher.php#L127-L145 | train |
Victoire/victoire | Bundle/PageBundle/Matcher/UrlMatcher.php | UrlMatcher.extractPartByPosition | protected function extractPartByPosition($url, $position)
{
$part = null;
if ($url !== null && $url !== '') {
// split on the / character
$keywords = preg_split("/\//", $url);
// preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches);
//if there are some words, we pop the last
if (count($keywords) > 0) {
//get the part
$part = $keywords[$position - 1];
}
}
return $part;
} | php | protected function extractPartByPosition($url, $position)
{
$part = null;
if ($url !== null && $url !== '') {
// split on the / character
$keywords = preg_split("/\//", $url);
// preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches);
//if there are some words, we pop the last
if (count($keywords) > 0) {
//get the part
$part = $keywords[$position - 1];
}
}
return $part;
} | [
"protected",
"function",
"extractPartByPosition",
"(",
"$",
"url",
",",
"$",
"position",
")",
"{",
"$",
"part",
"=",
"null",
";",
"if",
"(",
"$",
"url",
"!==",
"null",
"&&",
"$",
"url",
"!==",
"''",
")",
"{",
"// split on the / character",
"$",
"keywords... | Extract a part of the url.
@param string $url
@param int $position
@return string The extracted part | [
"Extract",
"a",
"part",
"of",
"the",
"url",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Matcher/UrlMatcher.php#L155-L172 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php | BusinessEntityHelper.findByEntityInstance | public function findByEntityInstance($entity)
{
$businessEntity = null;
$class = new \ReflectionClass($entity);
while (!$businessEntity && $class && $class->name !== null) {
$businessEntity = $this->findByEntityClassname($class->name);
$class = $class->getParentClass();
}
return $businessEntity;
} | php | public function findByEntityInstance($entity)
{
$businessEntity = null;
$class = new \ReflectionClass($entity);
while (!$businessEntity && $class && $class->name !== null) {
$businessEntity = $this->findByEntityClassname($class->name);
$class = $class->getParentClass();
}
return $businessEntity;
} | [
"public",
"function",
"findByEntityInstance",
"(",
"$",
"entity",
")",
"{",
"$",
"businessEntity",
"=",
"null",
";",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"entity",
")",
";",
"while",
"(",
"!",
"$",
"businessEntity",
"&&",
"$",
"cl... | Get a business entity.
@param object $entity
@return BusinessEntity | [
"Get",
"a",
"business",
"entity",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php#L93-L103 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php | BusinessEntityHelper.findByEntityClassname | public function findByEntityClassname($classname)
{
//get all the business entities
$businessEntities = $this->getBusinessEntities();
//the result
$businessEntity = null;
//parse the business entities
foreach ($businessEntities as $tempBusinessEntity) {
//look for the same id
if ($tempBusinessEntity->getClass() === $classname) {
$businessEntity = $tempBusinessEntity;
//business entity was found, there is no need to continue
continue;
}
}
return $businessEntity;
} | php | public function findByEntityClassname($classname)
{
//get all the business entities
$businessEntities = $this->getBusinessEntities();
//the result
$businessEntity = null;
//parse the business entities
foreach ($businessEntities as $tempBusinessEntity) {
//look for the same id
if ($tempBusinessEntity->getClass() === $classname) {
$businessEntity = $tempBusinessEntity;
//business entity was found, there is no need to continue
continue;
}
}
return $businessEntity;
} | [
"public",
"function",
"findByEntityClassname",
"(",
"$",
"classname",
")",
"{",
"//get all the business entities",
"$",
"businessEntities",
"=",
"$",
"this",
"->",
"getBusinessEntities",
"(",
")",
";",
"//the result",
"$",
"businessEntity",
"=",
"null",
";",
"//pars... | Get a business entity by classname.
@param string $classname
@return BusinessEntity | [
"Get",
"a",
"business",
"entity",
"by",
"classname",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php#L112-L131 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php | BusinessEntityHelper.findEntityByBusinessEntityAndAttribute | protected function findEntityByBusinessEntityAndAttribute(BusinessEntity $businessEntity, $attributeName, $attributeValue)
{
if (!$this->entityManager) {
throw new \Exception('EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service');
}
//retrieve the class of the business entity
$class = $businessEntity->getClass();
//get the repository
$repo = $this->entityManager->getRepository($class);
$functionName = 'findOneBy'.ucfirst($attributeName);
//get the entity
$entity = call_user_func([$repo, $functionName], $attributeValue);
return $entity;
} | php | protected function findEntityByBusinessEntityAndAttribute(BusinessEntity $businessEntity, $attributeName, $attributeValue)
{
if (!$this->entityManager) {
throw new \Exception('EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service');
}
//retrieve the class of the business entity
$class = $businessEntity->getClass();
//get the repository
$repo = $this->entityManager->getRepository($class);
$functionName = 'findOneBy'.ucfirst($attributeName);
//get the entity
$entity = call_user_func([$repo, $functionName], $attributeValue);
return $entity;
} | [
"protected",
"function",
"findEntityByBusinessEntityAndAttribute",
"(",
"BusinessEntity",
"$",
"businessEntity",
",",
"$",
"attributeName",
",",
"$",
"attributeValue",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"entityManager",
")",
"{",
"throw",
"new",
"\\",
... | Find a entity by the business entity and the attributeValue.
Must be called by the service victoire_core.helper.queriable_business_entity_helper.
@param BusinessEntity $businessEntity
@param string $attributeName
@param string $attributeValue
@return Entity | [
"Find",
"a",
"entity",
"by",
"the",
"business",
"entity",
"and",
"the",
"attributeValue",
".",
"Must",
"be",
"called",
"by",
"the",
"service",
"victoire_core",
".",
"helper",
".",
"queriable_business_entity_helper",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php#L143-L160 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php | BusinessEntityHelper.getEntityByPageAndBusinessIdentifier | public function getEntityByPageAndBusinessIdentifier(BusinessTemplate $page, $entityIdentifier, $attributeName)
{
if (!$this->entityManager) {
throw new \Exception('EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service');
}
$entity = null;
$businessEntityId = $page->getBusinessEntityId();
$businessEntity = $this->findById($businessEntityId);
//test the result
if ($businessEntity === null) {
throw new \Exception('The business entity ['.$businessEntityId.'] was not found.');
}
$entity = $this->findEntityByBusinessEntityAndAttribute($businessEntity, $attributeName, $entityIdentifier);
//test the result
if ($entity === null) {
throw new \Exception('The entity ['.$entityIdentifier.'] was not found.');
}
return $entity;
} | php | public function getEntityByPageAndBusinessIdentifier(BusinessTemplate $page, $entityIdentifier, $attributeName)
{
if (!$this->entityManager) {
throw new \Exception('EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service');
}
$entity = null;
$businessEntityId = $page->getBusinessEntityId();
$businessEntity = $this->findById($businessEntityId);
//test the result
if ($businessEntity === null) {
throw new \Exception('The business entity ['.$businessEntityId.'] was not found.');
}
$entity = $this->findEntityByBusinessEntityAndAttribute($businessEntity, $attributeName, $entityIdentifier);
//test the result
if ($entity === null) {
throw new \Exception('The entity ['.$entityIdentifier.'] was not found.');
}
return $entity;
} | [
"public",
"function",
"getEntityByPageAndBusinessIdentifier",
"(",
"BusinessTemplate",
"$",
"page",
",",
"$",
"entityIdentifier",
",",
"$",
"attributeName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"entityManager",
")",
"{",
"throw",
"new",
"\\",
"Exception"... | Get the entity from the page and the id given.
Must be called by the service victoire_core.helper.queriable_business_entity_helper.
@param BusinessTemplate $page The page
@param string $entityIdentifier The identifier for the business entity
@param string $attributeName The name of the attribute used to identify an entity
@throws \Exception
@return entity | [
"Get",
"the",
"entity",
"from",
"the",
"page",
"and",
"the",
"id",
"given",
".",
"Must",
"be",
"called",
"by",
"the",
"service",
"victoire_core",
".",
"helper",
".",
"queriable_business_entity_helper",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php#L174-L198 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php | BusinessEntityHelper.createBusinessEntity | public static function createBusinessEntity($className, array $businessProperties)
{
$businessEntity = new BusinessEntity();
$classNameArray = explode('\\', $className);
$entityName = array_pop($classNameArray);
$businessEntity->setId(strtolower($entityName));
$businessEntity->setName($entityName);
$businessEntity->setClass($className);
//parse the array of the annotation reader
foreach ($businessProperties as $type => $properties) {
foreach ($properties as $property) {
$businessProperty = new BusinessProperty();
$businessProperty->setType($type);
$businessProperty->setEntityProperty($property);
//add the business property to the business entity object
$businessEntity->addBusinessProperty($businessProperty);
unset($businessProperty);
}
}
return $businessEntity;
} | php | public static function createBusinessEntity($className, array $businessProperties)
{
$businessEntity = new BusinessEntity();
$classNameArray = explode('\\', $className);
$entityName = array_pop($classNameArray);
$businessEntity->setId(strtolower($entityName));
$businessEntity->setName($entityName);
$businessEntity->setClass($className);
//parse the array of the annotation reader
foreach ($businessProperties as $type => $properties) {
foreach ($properties as $property) {
$businessProperty = new BusinessProperty();
$businessProperty->setType($type);
$businessProperty->setEntityProperty($property);
//add the business property to the business entity object
$businessEntity->addBusinessProperty($businessProperty);
unset($businessProperty);
}
}
return $businessEntity;
} | [
"public",
"static",
"function",
"createBusinessEntity",
"(",
"$",
"className",
",",
"array",
"$",
"businessProperties",
")",
"{",
"$",
"businessEntity",
"=",
"new",
"BusinessEntity",
"(",
")",
";",
"$",
"classNameArray",
"=",
"explode",
"(",
"'\\\\'",
",",
"$"... | create a BusinessEntity from an annotation object.
@param string $className
@param array $businessProperties
@return BusinessEntity | [
"create",
"a",
"BusinessEntity",
"from",
"an",
"annotation",
"object",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php#L208-L232 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php | BusinessEntityHelper.getByBusinessEntityAndId | public function getByBusinessEntityAndId(BusinessEntity $businessEntity, $id)
{
if (!$this->entityManager) {
throw new \Exception('EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service');
}
return $this->entityManager->getRepository($businessEntity->getClass())->findOneById($id);
} | php | public function getByBusinessEntityAndId(BusinessEntity $businessEntity, $id)
{
if (!$this->entityManager) {
throw new \Exception('EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service');
}
return $this->entityManager->getRepository($businessEntity->getClass())->findOneById($id);
} | [
"public",
"function",
"getByBusinessEntityAndId",
"(",
"BusinessEntity",
"$",
"businessEntity",
",",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"entityManager",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'EntityManager not defined, you should ... | Must be called by the service victoire_core.helper.queriable_business_entity_helper.
@param BusinessEntity $businessEntity
@param $id
@throws \Exception
@return mixed | [
"Must",
"be",
"called",
"by",
"the",
"service",
"victoire_core",
".",
"helper",
".",
"queriable_business_entity_helper",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Helper/BusinessEntityHelper.php#L244-L251 | train |
Victoire/victoire | Bundle/PageBundle/Twig/Extension/PageExtension.php | PageExtension.cmsPageCss | public function cmsPageCss()
{
$currentView = $this->currentViewHelper->getCurrentView();
if (!$currentView || !$this->viewCssBuilder->cssFileExists($currentView)) {
return '<!-- CSS File not found -->';
}
return sprintf(
'<link href="%s" rel="stylesheet" type="text/css" rel="stylesheet"/>',
$this->viewCssBuilder->getHref($currentView)
);
} | php | public function cmsPageCss()
{
$currentView = $this->currentViewHelper->getCurrentView();
if (!$currentView || !$this->viewCssBuilder->cssFileExists($currentView)) {
return '<!-- CSS File not found -->';
}
return sprintf(
'<link href="%s" rel="stylesheet" type="text/css" rel="stylesheet"/>',
$this->viewCssBuilder->getHref($currentView)
);
} | [
"public",
"function",
"cmsPageCss",
"(",
")",
"{",
"$",
"currentView",
"=",
"$",
"this",
"->",
"currentViewHelper",
"->",
"getCurrentView",
"(",
")",
";",
"if",
"(",
"!",
"$",
"currentView",
"||",
"!",
"$",
"this",
"->",
"viewCssBuilder",
"->",
"cssFileExi... | Construct CSS link markup for the style of all the Widgets contained in the current View.
@return string | [
"Construct",
"CSS",
"link",
"markup",
"for",
"the",
"style",
"of",
"all",
"the",
"Widgets",
"contained",
"in",
"the",
"current",
"View",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Twig/Extension/PageExtension.php#L72-L83 | train |
Victoire/victoire | Bundle/PageBundle/Twig/Extension/PageExtension.php | PageExtension.getChildrenUrls | protected function getChildrenUrls(BasePage $page)
{
$urls = [];
$children = $page->getInstances();
//parse the children
foreach ($children as $child) {
$url = $child->getUrl();
$urls[] = $url;
unset($url);
}
return $urls;
} | php | protected function getChildrenUrls(BasePage $page)
{
$urls = [];
$children = $page->getInstances();
//parse the children
foreach ($children as $child) {
$url = $child->getUrl();
$urls[] = $url;
unset($url);
}
return $urls;
} | [
"protected",
"function",
"getChildrenUrls",
"(",
"BasePage",
"$",
"page",
")",
"{",
"$",
"urls",
"=",
"[",
"]",
";",
"$",
"children",
"=",
"$",
"page",
"->",
"getInstances",
"(",
")",
";",
"//parse the children",
"foreach",
"(",
"$",
"children",
"as",
"$... | Get the list of urls of the children.
@param BasePage $page
@return aray of strings The list of urls | [
"Get",
"the",
"list",
"of",
"urls",
"of",
"the",
"children",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Twig/Extension/PageExtension.php#L92-L107 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php | AnnotationDriver.getAllClassNames | public function getAllClassNames()
{
if (!$this->paths) {
throw MappingException::pathRequired();
}
$classes = [];
$includedFiles = [];
foreach ($this->paths as $path) {
if (!is_dir($path)) {
$this->logger->warning(sprintf(
'The given path "%s" seems to be incorrect. You need to edit victoire_core.base_paths configuration.',
$path
));
continue;
}
$iterator = new \RegexIterator(
new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
),
$this->regex,
\RecursiveRegexIterator::GET_MATCH
);
foreach ($iterator as $file) {
$sourceFile = realpath($file[0]);
$includedFiles[] = $sourceFile;
}
}
foreach ($includedFiles as $fileName) {
$class = $this->getClassNameFromFile($fileName);
if (class_exists($class) && !$this->isTransient($class)) {
$classes[] = $class;
}
}
return $classes;
} | php | public function getAllClassNames()
{
if (!$this->paths) {
throw MappingException::pathRequired();
}
$classes = [];
$includedFiles = [];
foreach ($this->paths as $path) {
if (!is_dir($path)) {
$this->logger->warning(sprintf(
'The given path "%s" seems to be incorrect. You need to edit victoire_core.base_paths configuration.',
$path
));
continue;
}
$iterator = new \RegexIterator(
new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::LEAVES_ONLY
),
$this->regex,
\RecursiveRegexIterator::GET_MATCH
);
foreach ($iterator as $file) {
$sourceFile = realpath($file[0]);
$includedFiles[] = $sourceFile;
}
}
foreach ($includedFiles as $fileName) {
$class = $this->getClassNameFromFile($fileName);
if (class_exists($class) && !$this->isTransient($class)) {
$classes[] = $class;
}
}
return $classes;
} | [
"public",
"function",
"getAllClassNames",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"paths",
")",
"{",
"throw",
"MappingException",
"::",
"pathRequired",
"(",
")",
";",
"}",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"includedFiles",
"=",
"[",
... | Get all class names.
@throws MappingException
@return array | [
"Get",
"all",
"class",
"names",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php#L70-L107 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php | AnnotationDriver.parse | public function parse(\ReflectionClass $class)
{
$classPath = dirname($class->getFileName());
$inPaths = false;
foreach ($this->paths as $key => $_path) {
//Check the entity path is in watching paths
if (strpos($classPath, realpath($_path)) === 0) {
$inPaths = true;
}
}
if ($inPaths) {
$classAnnotations = $this->reader->getClassAnnotations($class);
if (!empty($classAnnotations)) {
foreach ($classAnnotations as $key => $annot) {
if (!is_numeric($key)) {
continue;
}
$classAnnotations[get_class($annot)] = $annot;
}
}
// Evaluate Entity annotation
if (isset($classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'])) {
/** @var BusinessEntity $annotationObj */
$annotationObj = $classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'];
$businessEntity = BusinessEntityHelper::createBusinessEntity(
$class->getName(),
$this->loadBusinessProperties($class)
);
$event = new BusinessEntityAnnotationEvent(
$businessEntity,
$annotationObj->getWidgets()
);
//do what you want (caching BusinessEntity...)
$this->eventDispatcher->dispatch('victoire.business_entity_annotation_load', $event);
}
//check if the entity is a widget (extends (in depth) widget class)
$parentClass = $class->getParentClass();
$isWidget = false;
while ($parentClass && ($parentClass = $parentClass->getParentClass()) && !$isWidget && $parentClass->name != null) {
$isWidget = $parentClass->name === 'Victoire\\Bundle\\WidgetBundle\\Model\\Widget';
}
if ($isWidget) {
if ($this->widgetHelper->isEnabled(new $class->name())) {
$event = new WidgetAnnotationEvent(
$this->widgetHelper->getWidgetName(new $class->name()),
$this->loadReceiverProperties($class)
);
//dispatch victoire.widget_annotation_load to save receiverProperties in cache
$this->eventDispatcher->dispatch('victoire.widget_annotation_load', $event);
} else {
error_log(sprintf('Widget name not found for widget %s. Is this widget declared in AppKernel ?', $class->name));
}
}
}
} | php | public function parse(\ReflectionClass $class)
{
$classPath = dirname($class->getFileName());
$inPaths = false;
foreach ($this->paths as $key => $_path) {
//Check the entity path is in watching paths
if (strpos($classPath, realpath($_path)) === 0) {
$inPaths = true;
}
}
if ($inPaths) {
$classAnnotations = $this->reader->getClassAnnotations($class);
if (!empty($classAnnotations)) {
foreach ($classAnnotations as $key => $annot) {
if (!is_numeric($key)) {
continue;
}
$classAnnotations[get_class($annot)] = $annot;
}
}
// Evaluate Entity annotation
if (isset($classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'])) {
/** @var BusinessEntity $annotationObj */
$annotationObj = $classAnnotations['Victoire\Bundle\CoreBundle\Annotations\BusinessEntity'];
$businessEntity = BusinessEntityHelper::createBusinessEntity(
$class->getName(),
$this->loadBusinessProperties($class)
);
$event = new BusinessEntityAnnotationEvent(
$businessEntity,
$annotationObj->getWidgets()
);
//do what you want (caching BusinessEntity...)
$this->eventDispatcher->dispatch('victoire.business_entity_annotation_load', $event);
}
//check if the entity is a widget (extends (in depth) widget class)
$parentClass = $class->getParentClass();
$isWidget = false;
while ($parentClass && ($parentClass = $parentClass->getParentClass()) && !$isWidget && $parentClass->name != null) {
$isWidget = $parentClass->name === 'Victoire\\Bundle\\WidgetBundle\\Model\\Widget';
}
if ($isWidget) {
if ($this->widgetHelper->isEnabled(new $class->name())) {
$event = new WidgetAnnotationEvent(
$this->widgetHelper->getWidgetName(new $class->name()),
$this->loadReceiverProperties($class)
);
//dispatch victoire.widget_annotation_load to save receiverProperties in cache
$this->eventDispatcher->dispatch('victoire.widget_annotation_load', $event);
} else {
error_log(sprintf('Widget name not found for widget %s. Is this widget declared in AppKernel ?', $class->name));
}
}
}
} | [
"public",
"function",
"parse",
"(",
"\\",
"ReflectionClass",
"$",
"class",
")",
"{",
"$",
"classPath",
"=",
"dirname",
"(",
"$",
"class",
"->",
"getFileName",
"(",
")",
")",
";",
"$",
"inPaths",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"... | Parse the given Class to find some annotations related to BusinessEntities. | [
"Parse",
"the",
"given",
"Class",
"to",
"find",
"some",
"annotations",
"related",
"to",
"BusinessEntities",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php#L152-L216 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php | AnnotationDriver.loadBusinessProperties | protected function loadBusinessProperties(\ReflectionClass $class)
{
$businessProperties = [];
$properties = $class->getProperties();
$traits = $class->getTraits();
$className = $class->getName();
// if the class is translatable, then parse annotations on it's translation class
if (array_key_exists(Translatable::class, $traits)) {
$translation = new \ReflectionClass($className::getTranslationEntityClass());
$translationProperties = $translation->getProperties();
$properties = array_merge($properties, $translationProperties);
}
foreach ($properties as $property) {
$annotations = $this->reader->getPropertyAnnotations($property);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof BusinessProperty && !in_array($class, $businessProperties)) {
if (!$annotations[$key]->getTypes()) {
$message = $class->name.':$'.$property->name.'" field';
throw AnnotationException::requiredError('type', 'BusinessProperty annotation', $message, 'array or string');
}
foreach ($annotations[$key]->getTypes() as $type) {
$businessProperties[$type][] = $property->name;
}
}
}
}
// we load business properties of parents recursively
// because they are defined by an annotation not by the property type(private, protected, public)
$parentClass = $class->getParentClass();
if ($parentClass) {
//load parent properties recursively
$parentProperties = $this->loadBusinessProperties(new \ReflectionClass($parentClass->getName()));
foreach ($parentProperties as $key => $parentProperty) {
if (array_key_exists($key, $businessProperties)) {
//if parent and current have a same business property type we merge the properties and remove
//duplicates if properties are the same;
$businessProperties[$key] = array_unique(array_merge($parentProperty, $businessProperties[$key]));
} else {
//else we had a business property type for the parent properties
$businessProperties[$key] = $parentProperty;
}
}
}
return $businessProperties;
} | php | protected function loadBusinessProperties(\ReflectionClass $class)
{
$businessProperties = [];
$properties = $class->getProperties();
$traits = $class->getTraits();
$className = $class->getName();
// if the class is translatable, then parse annotations on it's translation class
if (array_key_exists(Translatable::class, $traits)) {
$translation = new \ReflectionClass($className::getTranslationEntityClass());
$translationProperties = $translation->getProperties();
$properties = array_merge($properties, $translationProperties);
}
foreach ($properties as $property) {
$annotations = $this->reader->getPropertyAnnotations($property);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof BusinessProperty && !in_array($class, $businessProperties)) {
if (!$annotations[$key]->getTypes()) {
$message = $class->name.':$'.$property->name.'" field';
throw AnnotationException::requiredError('type', 'BusinessProperty annotation', $message, 'array or string');
}
foreach ($annotations[$key]->getTypes() as $type) {
$businessProperties[$type][] = $property->name;
}
}
}
}
// we load business properties of parents recursively
// because they are defined by an annotation not by the property type(private, protected, public)
$parentClass = $class->getParentClass();
if ($parentClass) {
//load parent properties recursively
$parentProperties = $this->loadBusinessProperties(new \ReflectionClass($parentClass->getName()));
foreach ($parentProperties as $key => $parentProperty) {
if (array_key_exists($key, $businessProperties)) {
//if parent and current have a same business property type we merge the properties and remove
//duplicates if properties are the same;
$businessProperties[$key] = array_unique(array_merge($parentProperty, $businessProperties[$key]));
} else {
//else we had a business property type for the parent properties
$businessProperties[$key] = $parentProperty;
}
}
}
return $businessProperties;
} | [
"protected",
"function",
"loadBusinessProperties",
"(",
"\\",
"ReflectionClass",
"$",
"class",
")",
"{",
"$",
"businessProperties",
"=",
"[",
"]",
";",
"$",
"properties",
"=",
"$",
"class",
"->",
"getProperties",
"(",
")",
";",
"$",
"traits",
"=",
"$",
"cl... | load business properties from ReflectionClass.
@return array | [
"load",
"business",
"properties",
"from",
"ReflectionClass",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php#L223-L270 | train |
Victoire/victoire | Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php | AnnotationDriver.loadReceiverProperties | protected function loadReceiverProperties(\ReflectionClass $class)
{
$receiverPropertiesTypes = [];
$properties = $class->getProperties();
//Store receiver properties
foreach ($properties as $property) {
$annotations = $this->reader->getPropertyAnnotations($property);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof ReceiverPropertyAnnotation && !in_array($class, $receiverPropertiesTypes)) {
if (!$annotations[$key]->getTypes()) {
$message = $class->name.':$'.$property->name.'" field';
throw AnnotationException::requiredError('type', 'ReceiverProperty annotation', $message, 'array or string');
}
foreach ($annotations[$key]->getTypes() as $type) {
$receiverProperty = new ReceiverProperty();
$receiverProperty->setFieldName($property->name);
$receiverPropertiesTypes[$type][] = $receiverProperty;
}
}
}
}
//Set receiver properties as required if necessary
foreach ($receiverPropertiesTypes as $type => $receiverProperties) {
/* @var ReceiverProperty[] $receiverProperties */
foreach ($receiverProperties as $receiverProperty) {
$receiverPropertyName = $receiverProperty->getFieldName();
$refProperty = $class->getProperty($receiverPropertyName);
$annotations = $this->reader->getPropertyAnnotations($refProperty);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof Column && $annotationObj->nullable === false) {
throw new Exception(sprintf(
'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence must have "nullable=true" for ORM\Column annotation',
$refProperty->name,
$refProperty->class
));
} elseif ($annotationObj instanceof NotBlank) {
throw new Exception(sprintf(
'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotBlank annotation',
$refProperty->name,
$refProperty->class
));
} elseif ($annotationObj instanceof NotNull) {
throw new Exception(sprintf(
'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotNull annotation',
$refProperty->name,
$refProperty->class
));
} elseif ($annotationObj instanceof ReceiverPropertyAnnotation && $annotationObj->isRequired()) {
$receiverProperty->setRequired(true);
}
}
}
}
return $receiverPropertiesTypes;
} | php | protected function loadReceiverProperties(\ReflectionClass $class)
{
$receiverPropertiesTypes = [];
$properties = $class->getProperties();
//Store receiver properties
foreach ($properties as $property) {
$annotations = $this->reader->getPropertyAnnotations($property);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof ReceiverPropertyAnnotation && !in_array($class, $receiverPropertiesTypes)) {
if (!$annotations[$key]->getTypes()) {
$message = $class->name.':$'.$property->name.'" field';
throw AnnotationException::requiredError('type', 'ReceiverProperty annotation', $message, 'array or string');
}
foreach ($annotations[$key]->getTypes() as $type) {
$receiverProperty = new ReceiverProperty();
$receiverProperty->setFieldName($property->name);
$receiverPropertiesTypes[$type][] = $receiverProperty;
}
}
}
}
//Set receiver properties as required if necessary
foreach ($receiverPropertiesTypes as $type => $receiverProperties) {
/* @var ReceiverProperty[] $receiverProperties */
foreach ($receiverProperties as $receiverProperty) {
$receiverPropertyName = $receiverProperty->getFieldName();
$refProperty = $class->getProperty($receiverPropertyName);
$annotations = $this->reader->getPropertyAnnotations($refProperty);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof Column && $annotationObj->nullable === false) {
throw new Exception(sprintf(
'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence must have "nullable=true" for ORM\Column annotation',
$refProperty->name,
$refProperty->class
));
} elseif ($annotationObj instanceof NotBlank) {
throw new Exception(sprintf(
'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotBlank annotation',
$refProperty->name,
$refProperty->class
));
} elseif ($annotationObj instanceof NotNull) {
throw new Exception(sprintf(
'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotNull annotation',
$refProperty->name,
$refProperty->class
));
} elseif ($annotationObj instanceof ReceiverPropertyAnnotation && $annotationObj->isRequired()) {
$receiverProperty->setRequired(true);
}
}
}
}
return $receiverPropertiesTypes;
} | [
"protected",
"function",
"loadReceiverProperties",
"(",
"\\",
"ReflectionClass",
"$",
"class",
")",
"{",
"$",
"receiverPropertiesTypes",
"=",
"[",
"]",
";",
"$",
"properties",
"=",
"$",
"class",
"->",
"getProperties",
"(",
")",
";",
"//Store receiver properties",
... | Load receiver properties and NotBlank constraints from ReflectionClass.
@param \ReflectionClass $class
@throws AnnotationException
@return array | [
"Load",
"receiver",
"properties",
"and",
"NotBlank",
"constraints",
"from",
"ReflectionClass",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Annotation/AnnotationDriver.php#L281-L340 | train |
Victoire/victoire | Bundle/PageBundle/Listener/PageMenuListener.php | PageMenuListener.getMainItem | public function getMainItem()
{
$menuPage = $this->menuBuilder->getTopNavbar()->getChild('menu.page');
if ($menuPage) {
return $menuPage;
} else {
return $this->menuBuilder->createDropdownMenuItem(
$this->menuBuilder->getTopNavbar(),
'menu.page'
);
}
} | php | public function getMainItem()
{
$menuPage = $this->menuBuilder->getTopNavbar()->getChild('menu.page');
if ($menuPage) {
return $menuPage;
} else {
return $this->menuBuilder->createDropdownMenuItem(
$this->menuBuilder->getTopNavbar(),
'menu.page'
);
}
} | [
"public",
"function",
"getMainItem",
"(",
")",
"{",
"$",
"menuPage",
"=",
"$",
"this",
"->",
"menuBuilder",
"->",
"getTopNavbar",
"(",
")",
"->",
"getChild",
"(",
"'menu.page'",
")",
";",
"if",
"(",
"$",
"menuPage",
")",
"{",
"return",
"$",
"menuPage",
... | Get the main item.
@return \Knp\Menu\ItemInterface <\Knp\Menu\ItemInterface, NULL>|\Knp\Menu\ItemInterface | [
"Get",
"the",
"main",
"item",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Listener/PageMenuListener.php#L86-L98 | train |
Victoire/victoire | Bundle/CoreBundle/Helper/CurrentViewHelper.php | CurrentViewHelper.setCurrentView | public function setCurrentView(View $currentView)
{
if ($this->currentView == null) {
$this->currentView = clone $currentView;
}
$this->updatedCurrentView = $currentView;
return $this;
} | php | public function setCurrentView(View $currentView)
{
if ($this->currentView == null) {
$this->currentView = clone $currentView;
}
$this->updatedCurrentView = $currentView;
return $this;
} | [
"public",
"function",
"setCurrentView",
"(",
"View",
"$",
"currentView",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentView",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"currentView",
"=",
"clone",
"$",
"currentView",
";",
"}",
"$",
"this",
"->",
"up... | Set currentView.
@param View $currentView
@return $this | [
"Set",
"currentView",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Helper/CurrentViewHelper.php#L43-L51 | train |
Victoire/victoire | Bundle/BlogBundle/Form/CategoryType.php | CategoryType.addChildrenField | protected function addChildrenField($form)
{
$form->add(
'children',
CollectionType::class,
[
'entry_type' => self::class,
'required' => false,
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'by_reference' => false,
]
);
} | php | protected function addChildrenField($form)
{
$form->add(
'children',
CollectionType::class,
[
'entry_type' => self::class,
'required' => false,
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'by_reference' => false,
]
);
} | [
"protected",
"function",
"addChildrenField",
"(",
"$",
"form",
")",
"{",
"$",
"form",
"->",
"add",
"(",
"'children'",
",",
"CollectionType",
"::",
"class",
",",
"[",
"'entry_type'",
"=>",
"self",
"::",
"class",
",",
"'required'",
"=>",
"false",
",",
"'allo... | Add the items field to the form.
@param Form $form | [
"Add",
"the",
"items",
"field",
"to",
"the",
"form",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Form/CategoryType.php#L94-L108 | train |
Victoire/victoire | Bundle/CoreBundle/Entity/View.php | View.setChildren | public function setChildren($children)
{
$this->children = $children;
if ($children !== null) {
foreach ($children as $child) {
$child->setParent($this);
}
}
return $this;
} | php | public function setChildren($children)
{
$this->children = $children;
if ($children !== null) {
foreach ($children as $child) {
$child->setParent($this);
}
}
return $this;
} | [
"public",
"function",
"setChildren",
"(",
"$",
"children",
")",
"{",
"$",
"this",
"->",
"children",
"=",
"$",
"children",
";",
"if",
"(",
"$",
"children",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
... | Set children.
@param View[] $children
@return View | [
"Set",
"children",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Entity/View.php#L259-L269 | train |
Victoire/victoire | Bundle/CoreBundle/Entity/View.php | View.addWidgetMap | public function addWidgetMap(WidgetMap $widgetMap)
{
if (!$widgetMap->getView()) {
$widgetMap->setView($this);
}
$this->widgetMaps[] = $widgetMap;
} | php | public function addWidgetMap(WidgetMap $widgetMap)
{
if (!$widgetMap->getView()) {
$widgetMap->setView($this);
}
$this->widgetMaps[] = $widgetMap;
} | [
"public",
"function",
"addWidgetMap",
"(",
"WidgetMap",
"$",
"widgetMap",
")",
"{",
"if",
"(",
"!",
"$",
"widgetMap",
"->",
"getView",
"(",
")",
")",
"{",
"$",
"widgetMap",
"->",
"setView",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"widgetM... | Add WidgetMap.
@param WidgetMap $widgetMap | [
"Add",
"WidgetMap",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Entity/View.php#L516-L522 | train |
Victoire/victoire | Bundle/CoreBundle/Entity/View.php | View.getWidgetMapsForViewAndTemplates | public function getWidgetMapsForViewAndTemplates()
{
$widgetMaps = [];
foreach ($this->getWidgetMaps() as $_widgetMap) {
$widgetMaps[] = $_widgetMap;
}
if ($template = $this->getTemplate()) {
$templateWidgetMaps = $template->getWidgetMapsForViewAndTemplates();
$widgetMaps = array_merge($widgetMaps, $templateWidgetMaps);
}
return $widgetMaps;
} | php | public function getWidgetMapsForViewAndTemplates()
{
$widgetMaps = [];
foreach ($this->getWidgetMaps() as $_widgetMap) {
$widgetMaps[] = $_widgetMap;
}
if ($template = $this->getTemplate()) {
$templateWidgetMaps = $template->getWidgetMapsForViewAndTemplates();
$widgetMaps = array_merge($widgetMaps, $templateWidgetMaps);
}
return $widgetMaps;
} | [
"public",
"function",
"getWidgetMapsForViewAndTemplates",
"(",
")",
"{",
"$",
"widgetMaps",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getWidgetMaps",
"(",
")",
"as",
"$",
"_widgetMap",
")",
"{",
"$",
"widgetMaps",
"[",
"]",
"=",
"$",
"_widg... | Get WidgetMaps for View and its Templates.
@return WidgetMap[] | [
"Get",
"WidgetMaps",
"for",
"View",
"and",
"its",
"Templates",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Entity/View.php#L539-L553 | train |
Victoire/victoire | Bundle/CoreBundle/Entity/View.php | View.getReference | public function getReference($locale = null)
{
$locale = $locale ?: $this->getCurrentLocale();
if (is_array($this->references) && isset($this->references[$locale])) {
return $this->references[$locale];
}
} | php | public function getReference($locale = null)
{
$locale = $locale ?: $this->getCurrentLocale();
if (is_array($this->references) && isset($this->references[$locale])) {
return $this->references[$locale];
}
} | [
"public",
"function",
"getReference",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"$",
"locale",
"?",
":",
"$",
"this",
"->",
"getCurrentLocale",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"references",
")",
"&&"... | Get reference according to the current locale.
@param string $locale
@return null|ViewReference | [
"Get",
"reference",
"according",
"to",
"the",
"current",
"locale",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Entity/View.php#L618-L624 | train |
Victoire/victoire | Bundle/CoreBundle/Entity/View.php | View.setReference | public function setReference(ViewReference $reference = null, $locale = null)
{
$locale = $locale ?: $this->getCurrentLocale();
$this->references[$locale] = $reference;
return $this;
} | php | public function setReference(ViewReference $reference = null, $locale = null)
{
$locale = $locale ?: $this->getCurrentLocale();
$this->references[$locale] = $reference;
return $this;
} | [
"public",
"function",
"setReference",
"(",
"ViewReference",
"$",
"reference",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"locale",
"=",
"$",
"locale",
"?",
":",
"$",
"this",
"->",
"getCurrentLocale",
"(",
")",
";",
"$",
"this",
"->",
... | Set reference.
@param ViewReference $reference
@param string $locale
@return $this | [
"Set",
"reference",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Entity/View.php#L658-L664 | train |
Victoire/victoire | Bundle/QueryBundle/Helper/QueryHelper.php | QueryHelper.getQueryBuilder | public function getQueryBuilder(VictoireQueryInterface $containerEntity, EntityManager $em)
{
if ($containerEntity === null) {
throw new \Exception('The container entity parameter must not be null.');
}
//the business name of the container entity
$businessEntityId = $containerEntity->getBusinessEntityId();
//test that there is a business entity name
if ($businessEntityId === null || $businessEntityId === '') {
$containerId = $containerEntity->getId();
throw new \Exception('The container entity ['.$containerId.'] does not have any businessEntityId.');
}
//the business class of the container entity
$businessEntity = $this->businessEntityHelper->findById(strtolower($businessEntityId));
//test that there was a businessEntity
if ($businessEntity === null) {
throw new \Exception('The business entity was not found for the id:['.$businessEntityId.']');
}
$businessClass = $businessEntity->getClass();
$itemsQueryBuilder = $em
->createQueryBuilder()
->select('main_item')
->from($businessClass, 'main_item')
->andWhere('main_item.visibleOnFront = 1');
$view = null;
if ($containerEntity instanceof View) {
$view = $containerEntity;
} elseif ($containerEntity instanceof Widget) {
$view = $containerEntity->getCurrentView();
}
// when the businessClass is translatable, join translations for the current locale
if ($view && in_array(Translatable::class, class_uses($businessClass))) {
$itemsQueryBuilder->join('main_item.translations', 'translation')
->andWhere('translation.locale = :locale')
->setParameter(':locale', $view->getCurrentLocale());
}
$refClass = new \ReflectionClass($businessClass);
if ($refClass->hasMethod('getDeletedAt')) {
$itemsQueryBuilder->andWhere('main_item.deletedAt IS NULL');
}
return $itemsQueryBuilder;
} | php | public function getQueryBuilder(VictoireQueryInterface $containerEntity, EntityManager $em)
{
if ($containerEntity === null) {
throw new \Exception('The container entity parameter must not be null.');
}
//the business name of the container entity
$businessEntityId = $containerEntity->getBusinessEntityId();
//test that there is a business entity name
if ($businessEntityId === null || $businessEntityId === '') {
$containerId = $containerEntity->getId();
throw new \Exception('The container entity ['.$containerId.'] does not have any businessEntityId.');
}
//the business class of the container entity
$businessEntity = $this->businessEntityHelper->findById(strtolower($businessEntityId));
//test that there was a businessEntity
if ($businessEntity === null) {
throw new \Exception('The business entity was not found for the id:['.$businessEntityId.']');
}
$businessClass = $businessEntity->getClass();
$itemsQueryBuilder = $em
->createQueryBuilder()
->select('main_item')
->from($businessClass, 'main_item')
->andWhere('main_item.visibleOnFront = 1');
$view = null;
if ($containerEntity instanceof View) {
$view = $containerEntity;
} elseif ($containerEntity instanceof Widget) {
$view = $containerEntity->getCurrentView();
}
// when the businessClass is translatable, join translations for the current locale
if ($view && in_array(Translatable::class, class_uses($businessClass))) {
$itemsQueryBuilder->join('main_item.translations', 'translation')
->andWhere('translation.locale = :locale')
->setParameter(':locale', $view->getCurrentLocale());
}
$refClass = new \ReflectionClass($businessClass);
if ($refClass->hasMethod('getDeletedAt')) {
$itemsQueryBuilder->andWhere('main_item.deletedAt IS NULL');
}
return $itemsQueryBuilder;
} | [
"public",
"function",
"getQueryBuilder",
"(",
"VictoireQueryInterface",
"$",
"containerEntity",
",",
"EntityManager",
"$",
"em",
")",
"{",
"if",
"(",
"$",
"containerEntity",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The container entity pa... | Get the query builder base. This makes a "select from item XXX"
use the item for doing the left join or where dql.
@param \Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate $containerEntity
@throws \Exception
@return QueryBuilder | [
"Get",
"the",
"query",
"builder",
"base",
".",
"This",
"makes",
"a",
"select",
"from",
"item",
"XXX",
"use",
"the",
"item",
"for",
"doing",
"the",
"left",
"join",
"or",
"where",
"dql",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/QueryBundle/Helper/QueryHelper.php#L60-L112 | train |
Victoire/victoire | Bundle/QueryBundle/Helper/QueryHelper.php | QueryHelper.isAssociationField | private function isAssociationField(\ReflectionProperty $field)
{
$annotations = $this->reader->getPropertyAnnotations($field);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof OneToOne || $annotationObj instanceof OneToMany || $annotationObj instanceof ManyToOne || $annotationObj instanceof ManyToMany) {
return true;
}
}
return false;
} | php | private function isAssociationField(\ReflectionProperty $field)
{
$annotations = $this->reader->getPropertyAnnotations($field);
foreach ($annotations as $key => $annotationObj) {
if ($annotationObj instanceof OneToOne || $annotationObj instanceof OneToMany || $annotationObj instanceof ManyToOne || $annotationObj instanceof ManyToMany) {
return true;
}
}
return false;
} | [
"private",
"function",
"isAssociationField",
"(",
"\\",
"ReflectionProperty",
"$",
"field",
")",
"{",
"$",
"annotations",
"=",
"$",
"this",
"->",
"reader",
"->",
"getPropertyAnnotations",
"(",
"$",
"field",
")",
";",
"foreach",
"(",
"$",
"annotations",
"as",
... | Check if field is a OneToOne, OneToMany, ManyToOne or ManyToMany association.
@param \ReflectionProperty $field
@return bool | [
"Check",
"if",
"field",
"is",
"a",
"OneToOne",
"OneToMany",
"ManyToOne",
"or",
"ManyToMany",
"association",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/QueryBundle/Helper/QueryHelper.php#L197-L207 | train |
Victoire/victoire | Bundle/CoreBundle/Repository/ViewRepository.php | ViewRepository.getAll | public function getAll($excludeUnpublished = false)
{
$this->qb = $this->getInstance();
//If $excludeUnpublished === true, we exclude the non published results
if ($excludeUnpublished) {
$this->qb
->andWhere($this->mainAlias.'.status = :status')
->orWhere($this->mainAlias.'.status = :scheduled_status AND '.$this->mainAlias.'.publishedAt > :publicationDate')
->setParameter('status', PageStatus::PUBLISHED)
->setParameter('scheduled_status', PageStatus::SCHEDULED)
->setParameter('publicationDate', new \DateTime());
}
return $this;
} | php | public function getAll($excludeUnpublished = false)
{
$this->qb = $this->getInstance();
//If $excludeUnpublished === true, we exclude the non published results
if ($excludeUnpublished) {
$this->qb
->andWhere($this->mainAlias.'.status = :status')
->orWhere($this->mainAlias.'.status = :scheduled_status AND '.$this->mainAlias.'.publishedAt > :publicationDate')
->setParameter('status', PageStatus::PUBLISHED)
->setParameter('scheduled_status', PageStatus::SCHEDULED)
->setParameter('publicationDate', new \DateTime());
}
return $this;
} | [
"public",
"function",
"getAll",
"(",
"$",
"excludeUnpublished",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"qb",
"=",
"$",
"this",
"->",
"getInstance",
"(",
")",
";",
"//If $excludeUnpublished === true, we exclude the non published results",
"if",
"(",
"$",
"exclu... | Get all rentals in the repository.
@param bool $excludeUnpublished Should we get only the published Views ?
@return ViewRepository | [
"Get",
"all",
"rentals",
"in",
"the",
"repository",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/ViewRepository.php#L47-L62 | train |
Victoire/victoire | Bundle/CoreBundle/Repository/ViewRepository.php | ViewRepository.findByViewReferences | public function findByViewReferences(array $viewReferences)
{
$pageIds = [];
foreach ($viewReferences as $viewReference) {
if ($viewReference instanceof BusinessPageReference) {
$pageIds[] = $viewReference->getTemplateId();
} else {
$pageIds[] = $viewReference->getViewId();
}
}
$qb = $this->getInstance();
$qb->andWhere($this->mainAlias.'.id IN (:pageIds)')
->setParameter('pageIds', $pageIds);
$pages = $qb->getQuery()->getResult();
foreach ($pages as $page) {
$pageId = $page->getId();
$viewReference = array_filter(
$viewReferences,
function ($e) use ($pageId) {
return $e->getViewId() == $pageId;
});
if (!empty($viewReference[0])) {
$page->setCurrentLocale($viewReference[0]->getLocale());
}
}
return $pages;
} | php | public function findByViewReferences(array $viewReferences)
{
$pageIds = [];
foreach ($viewReferences as $viewReference) {
if ($viewReference instanceof BusinessPageReference) {
$pageIds[] = $viewReference->getTemplateId();
} else {
$pageIds[] = $viewReference->getViewId();
}
}
$qb = $this->getInstance();
$qb->andWhere($this->mainAlias.'.id IN (:pageIds)')
->setParameter('pageIds', $pageIds);
$pages = $qb->getQuery()->getResult();
foreach ($pages as $page) {
$pageId = $page->getId();
$viewReference = array_filter(
$viewReferences,
function ($e) use ($pageId) {
return $e->getViewId() == $pageId;
});
if (!empty($viewReference[0])) {
$page->setCurrentLocale($viewReference[0]->getLocale());
}
}
return $pages;
} | [
"public",
"function",
"findByViewReferences",
"(",
"array",
"$",
"viewReferences",
")",
"{",
"$",
"pageIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"viewReferences",
"as",
"$",
"viewReference",
")",
"{",
"if",
"(",
"$",
"viewReference",
"instanceof",
"Busi... | Find a large amount of views by ViewReferences.
@param ViewReference[] $viewReferences
@return View[]|null The entity instance or NULL if the entities cannot be found. | [
"Find",
"a",
"large",
"amount",
"of",
"views",
"by",
"ViewReferences",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/ViewRepository.php#L71-L101 | train |
Victoire/victoire | Bundle/CoreBundle/Repository/ViewRepository.php | ViewRepository.findOneByHomepage | public function findOneByHomepage($locale = 'fr')
{
//the query builder
$qb = $this->getInstance();
$qb
->where($this->mainAlias.'.homepage = true')
->andWhere($this->mainAlias.'.status = :status')
->setMaxResults(1)
->setParameter('status', PageStatus::PUBLISHED);
// Use Translation Walker
$query = $qb->getQuery();
$view = $query->getOneOrNullResult();
$view->translate($locale);
return $view;
} | php | public function findOneByHomepage($locale = 'fr')
{
//the query builder
$qb = $this->getInstance();
$qb
->where($this->mainAlias.'.homepage = true')
->andWhere($this->mainAlias.'.status = :status')
->setMaxResults(1)
->setParameter('status', PageStatus::PUBLISHED);
// Use Translation Walker
$query = $qb->getQuery();
$view = $query->getOneOrNullResult();
$view->translate($locale);
return $view;
} | [
"public",
"function",
"findOneByHomepage",
"(",
"$",
"locale",
"=",
"'fr'",
")",
"{",
"//the query builder",
"$",
"qb",
"=",
"$",
"this",
"->",
"getInstance",
"(",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"$",
"this",
"->",
"mainAlias",
".",
"'.homepage ... | Get the view that is a page and a published one.
@param string $locale
@return Page | [
"Get",
"the",
"view",
"that",
"is",
"a",
"page",
"and",
"a",
"published",
"one",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/ViewRepository.php#L110-L125 | train |
Victoire/victoire | Bundle/CoreBundle/Repository/ViewRepository.php | ViewRepository.joinSeoTranslations | public function joinSeoTranslations($locale)
{
$this->getInstance()
->leftJoin('seo.translations', 'translation', Expr\Join::WITH, 'translation.locale = :locale')
->setParameter('locale', $locale);
return $this;
} | php | public function joinSeoTranslations($locale)
{
$this->getInstance()
->leftJoin('seo.translations', 'translation', Expr\Join::WITH, 'translation.locale = :locale')
->setParameter('locale', $locale);
return $this;
} | [
"public",
"function",
"joinSeoTranslations",
"(",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"getInstance",
"(",
")",
"->",
"leftJoin",
"(",
"'seo.translations'",
",",
"'translation'",
",",
"Expr",
"\\",
"Join",
"::",
"WITH",
",",
"'translation.locale = :locale... | Join PageSeoTranslation to PageSeo for a locale.
@param string $locale
@return ViewRepository | [
"Join",
"PageSeoTranslation",
"to",
"PageSeo",
"for",
"a",
"locale",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/ViewRepository.php#L148-L155 | train |
Victoire/victoire | Bundle/CoreBundle/Repository/ViewRepository.php | ViewRepository.joinTranslations | public function joinTranslations($locale)
{
$this->getInstance()
->innerJoin($this->mainAlias.'.translations', 'translation', Expr\Join::WITH, 'translation.locale = :locale')
->setParameter('locale', $locale);
return $this;
} | php | public function joinTranslations($locale)
{
$this->getInstance()
->innerJoin($this->mainAlias.'.translations', 'translation', Expr\Join::WITH, 'translation.locale = :locale')
->setParameter('locale', $locale);
return $this;
} | [
"public",
"function",
"joinTranslations",
"(",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"getInstance",
"(",
")",
"->",
"innerJoin",
"(",
"$",
"this",
"->",
"mainAlias",
".",
"'.translations'",
",",
"'translation'",
",",
"Expr",
"\\",
"Join",
"::",
"WITH... | Join ViewTranslation for a locale.
@param string $locale
@return ViewRepository | [
"Join",
"ViewTranslation",
"for",
"a",
"locale",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/ViewRepository.php#L164-L171 | train |
Victoire/victoire | Bundle/CoreBundle/Entity/BaseEntityProxy.php | BaseEntityProxy.getEntity | public function getEntity($entityId)
{
//test the entity name
if ($entityId == null) {
throw new \Exception('The businessEntityId is not defined for the entityProxy with the id:'.$this->getId());
}
$functionName = 'get'.ucfirst($entityId);
$entity = call_user_func([$this, $functionName]);
return $entity;
} | php | public function getEntity($entityId)
{
//test the entity name
if ($entityId == null) {
throw new \Exception('The businessEntityId is not defined for the entityProxy with the id:'.$this->getId());
}
$functionName = 'get'.ucfirst($entityId);
$entity = call_user_func([$this, $functionName]);
return $entity;
} | [
"public",
"function",
"getEntity",
"(",
"$",
"entityId",
")",
"{",
"//test the entity name",
"if",
"(",
"$",
"entityId",
"==",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The businessEntityId is not defined for the entityProxy with the id:'",
".",
"$",... | Get the entity of the proxy.
@param string $entityId
@throws \Exception
@return object | [
"Get",
"the",
"entity",
"of",
"the",
"proxy",
"."
] | 53c314c578dcf92adfb6538b27dbc7a2ec16f432 | https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Entity/BaseEntityProxy.php#L51-L62 | train |
Yurunsoft/IMI | src/Db/Query/Query.php | Query.whereIsNull | public function whereIsNull(string $fieldName, string $logicalOperator = LogicalOperator::AND)
{
return $this->where($fieldName, 'is', null, $logicalOperator);
} | php | public function whereIsNull(string $fieldName, string $logicalOperator = LogicalOperator::AND)
{
return $this->where($fieldName, 'is', null, $logicalOperator);
} | [
"public",
"function",
"whereIsNull",
"(",
"string",
"$",
"fieldName",
",",
"string",
"$",
"logicalOperator",
"=",
"LogicalOperator",
"::",
"AND",
")",
"{",
"return",
"$",
"this",
"->",
"where",
"(",
"$",
"fieldName",
",",
"'is'",
",",
"null",
",",
"$",
"... | where field is null
@param string $fieldName
@param string $logicalOperator
@return static | [
"where",
"field",
"is",
"null"
] | 0bd4fe2b10fc309a7574c90cff98f9fe60c3ccf0 | https://github.com/Yurunsoft/IMI/blob/0bd4fe2b10fc309a7574c90cff98f9fe60c3ccf0/src/Db/Query/Query.php#L432-L435 | train |
norkunas/onesignal-php-api | src/Apps.php | Apps.getOne | public function getOne($id)
{
return $this->api->request('GET', '/apps/'.$id, [
'Authorization' => 'Basic '.$this->api->getConfig()->getUserAuthKey(),
]);
} | php | public function getOne($id)
{
return $this->api->request('GET', '/apps/'.$id, [
'Authorization' => 'Basic '.$this->api->getConfig()->getUserAuthKey(),
]);
} | [
"public",
"function",
"getOne",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"api",
"->",
"request",
"(",
"'GET'",
",",
"'/apps/'",
".",
"$",
"id",
",",
"[",
"'Authorization'",
"=>",
"'Basic '",
".",
"$",
"this",
"->",
"api",
"->",
"getConf... | Get information about application with provided ID.
User authentication key must be set.
@param string $id ID of your application
@return array | [
"Get",
"information",
"about",
"application",
"with",
"provided",
"ID",
"."
] | 0d9e35fdbfa5c05864d14baed381cd1cda37c8b1 | https://github.com/norkunas/onesignal-php-api/blob/0d9e35fdbfa5c05864d14baed381cd1cda37c8b1/src/Apps.php#L28-L33 | train |
norkunas/onesignal-php-api | src/Apps.php | Apps.add | public function add(array $data)
{
$data = $this->resolverFactory->createAppResolver()->resolve($data);
return $this->api->request('POST', '/apps', [
'Authorization' => 'Basic '.$this->api->getConfig()->getUserAuthKey(),
], json_encode($data));
} | php | public function add(array $data)
{
$data = $this->resolverFactory->createAppResolver()->resolve($data);
return $this->api->request('POST', '/apps', [
'Authorization' => 'Basic '.$this->api->getConfig()->getUserAuthKey(),
], json_encode($data));
} | [
"public",
"function",
"add",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"resolverFactory",
"->",
"createAppResolver",
"(",
")",
"->",
"resolve",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"api",
"->",
"req... | Create a new application with provided data.
User authentication key must be set.
@param array $data Application data
@return array | [
"Create",
"a",
"new",
"application",
"with",
"provided",
"data",
"."
] | 0d9e35fdbfa5c05864d14baed381cd1cda37c8b1 | https://github.com/norkunas/onesignal-php-api/blob/0d9e35fdbfa5c05864d14baed381cd1cda37c8b1/src/Apps.php#L58-L65 | train |
norkunas/onesignal-php-api | src/Apps.php | Apps.update | public function update($id, array $data)
{
$data = $this->resolverFactory->createAppResolver()->resolve($data);
return $this->api->request('PUT', '/apps/'.$id, [
'Authorization' => 'Basic '.$this->api->getConfig()->getUserAuthKey(),
], json_encode($data));
} | php | public function update($id, array $data)
{
$data = $this->resolverFactory->createAppResolver()->resolve($data);
return $this->api->request('PUT', '/apps/'.$id, [
'Authorization' => 'Basic '.$this->api->getConfig()->getUserAuthKey(),
], json_encode($data));
} | [
"public",
"function",
"update",
"(",
"$",
"id",
",",
"array",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"resolverFactory",
"->",
"createAppResolver",
"(",
")",
"->",
"resolve",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->"... | Update application with provided data.
User authentication key must be set.
@param string $id ID of your application
@param array $data New application data
@return array | [
"Update",
"application",
"with",
"provided",
"data",
"."
] | 0d9e35fdbfa5c05864d14baed381cd1cda37c8b1 | https://github.com/norkunas/onesignal-php-api/blob/0d9e35fdbfa5c05864d14baed381cd1cda37c8b1/src/Apps.php#L77-L84 | train |
norkunas/onesignal-php-api | src/OneSignal.php | OneSignal.request | public function request($method, $uri, array $headers = [], $body = null)
{
try {
$response = $this->client->send($method, self::API_URL.$uri, array_merge([
'Content-Type' => 'application/json',
], $headers), $body);
return json_decode($response->getBody(), true);
} catch (\Throwable $t) {
throw new OneSignalException($t->getMessage());
} catch (\Exception $e) {
throw new OneSignalException($e->getMessage());
}
} | php | public function request($method, $uri, array $headers = [], $body = null)
{
try {
$response = $this->client->send($method, self::API_URL.$uri, array_merge([
'Content-Type' => 'application/json',
], $headers), $body);
return json_decode($response->getBody(), true);
} catch (\Throwable $t) {
throw new OneSignalException($t->getMessage());
} catch (\Exception $e) {
throw new OneSignalException($e->getMessage());
}
} | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"body",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"... | Make a custom api request.
@param string $method HTTP Method
@param string $uri URI template
@param array $headers
@param string|StreamInterface|null $body
@throws OneSignalException
@return array | [
"Make",
"a",
"custom",
"api",
"request",
"."
] | 0d9e35fdbfa5c05864d14baed381cd1cda37c8b1 | https://github.com/norkunas/onesignal-php-api/blob/0d9e35fdbfa5c05864d14baed381cd1cda37c8b1/src/OneSignal.php#L105-L118 | train |
norkunas/onesignal-php-api | src/Devices.php | Devices.getOne | public function getOne($id)
{
$query = [
'app_id' => $this->api->getConfig()->getApplicationId(),
];
return $this->api->request('GET', '/players/'.$id.'?'.http_build_query($query));
} | php | public function getOne($id)
{
$query = [
'app_id' => $this->api->getConfig()->getApplicationId(),
];
return $this->api->request('GET', '/players/'.$id.'?'.http_build_query($query));
} | [
"public",
"function",
"getOne",
"(",
"$",
"id",
")",
"{",
"$",
"query",
"=",
"[",
"'app_id'",
"=>",
"$",
"this",
"->",
"api",
"->",
"getConfig",
"(",
")",
"->",
"getApplicationId",
"(",
")",
",",
"]",
";",
"return",
"$",
"this",
"->",
"api",
"->",
... | Get information about device with provided ID.
@param string $id Device ID
@return array | [
"Get",
"information",
"about",
"device",
"with",
"provided",
"ID",
"."
] | 0d9e35fdbfa5c05864d14baed381cd1cda37c8b1 | https://github.com/norkunas/onesignal-php-api/blob/0d9e35fdbfa5c05864d14baed381cd1cda37c8b1/src/Devices.php#L54-L61 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.