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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/SeoBundle/Helper/OrderConverter.php | OrderConverter.convert | public function convert(Order $order)
{
$orderItems = array();
foreach ($order->orderItems as $orderItem) {
/* @var $orderItem OrderItem */
$orderItems[] = array(
'sku' => $orderItem->getSKU(),
'quantity' => $this->formatNumber($orderItem->getQuantity()),
'unit_price' => $this->formatNumber($orderItem->getUnitPrice()),
'taxes' => $this->formatNumber($orderItem->getTaxes()),
'category_or_variation' => $orderItem->getCategoryOrVariation(),
'name' => $orderItem->getName(),
);
}
return array(
'transaction_id' => $order->getTransactionID(),
'store_name' => $order->getStoreName(),
'total' => $this->formatNumber($order->getTotal()),
'taxes_total' => $this->formatNumber($order->getTaxesTotal()),
'shipping_total' => $this->formatNumber($order->getShippingTotal()),
'city' => $order->getCity(),
'state_or_province' => $order->getStateOrProvince(),
'country' => $order->getCountry(),
'order_items' => $orderItems,
);
} | php | public function convert(Order $order)
{
$orderItems = array();
foreach ($order->orderItems as $orderItem) {
/* @var $orderItem OrderItem */
$orderItems[] = array(
'sku' => $orderItem->getSKU(),
'quantity' => $this->formatNumber($orderItem->getQuantity()),
'unit_price' => $this->formatNumber($orderItem->getUnitPrice()),
'taxes' => $this->formatNumber($orderItem->getTaxes()),
'category_or_variation' => $orderItem->getCategoryOrVariation(),
'name' => $orderItem->getName(),
);
}
return array(
'transaction_id' => $order->getTransactionID(),
'store_name' => $order->getStoreName(),
'total' => $this->formatNumber($order->getTotal()),
'taxes_total' => $this->formatNumber($order->getTaxesTotal()),
'shipping_total' => $this->formatNumber($order->getShippingTotal()),
'city' => $order->getCity(),
'state_or_province' => $order->getStateOrProvince(),
'country' => $order->getCountry(),
'order_items' => $orderItems,
);
} | [
"public",
"function",
"convert",
"(",
"Order",
"$",
"order",
")",
"{",
"$",
"orderItems",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"order",
"->",
"orderItems",
"as",
"$",
"orderItem",
")",
"{",
"/* @var $orderItem OrderItem */",
"$",
"orderItems",
... | Converts an Order object to an Array.
@param Order $order
@return array | [
"Converts",
"an",
"Order",
"object",
"to",
"an",
"Array",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Helper/OrderConverter.php#L17-L44 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminListBundle/AdminList/FilterType/AbstractFilterType.php | AbstractFilterType.getAlias | protected function getAlias()
{
if (empty($this->alias)) {
return '';
}
if (strpos($this->alias, '.') !== false) {
return $this->alias;
}
return $this->alias . '.';
} | php | protected function getAlias()
{
if (empty($this->alias)) {
return '';
}
if (strpos($this->alias, '.') !== false) {
return $this->alias;
}
return $this->alias . '.';
} | [
"protected",
"function",
"getAlias",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"alias",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"alias",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"... | Returns empty string if no alias, otherwise make sure the alias has just one '.' after it.
@return string | [
"Returns",
"empty",
"string",
"if",
"no",
"alias",
"otherwise",
"make",
"sure",
"the",
"alias",
"has",
"just",
"one",
".",
"after",
"it",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/AdminList/FilterType/AbstractFilterType.php#L37-L48 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/LeadGenerationBundle/Twig/PopupTwigExtension.php | PopupTwigExtension.getAvailablePopupTypes | public function getAvailablePopupTypes()
{
$popups = array();
foreach ($this->popupTypes as $popupType) {
$object = new $popupType();
$popups[$object->getClassname()] = $object->getFullClassname();
}
return $popups;
} | php | public function getAvailablePopupTypes()
{
$popups = array();
foreach ($this->popupTypes as $popupType) {
$object = new $popupType();
$popups[$object->getClassname()] = $object->getFullClassname();
}
return $popups;
} | [
"public",
"function",
"getAvailablePopupTypes",
"(",
")",
"{",
"$",
"popups",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"popupTypes",
"as",
"$",
"popupType",
")",
"{",
"$",
"object",
"=",
"new",
"$",
"popupType",
"(",
")",
";",
... | Get the available popup types.
@return array | [
"Get",
"the",
"available",
"popup",
"types",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/LeadGenerationBundle/Twig/PopupTwigExtension.php#L117-L126 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/LeadGenerationBundle/Twig/PopupTwigExtension.php | PopupTwigExtension.getAvailableRuleTypes | public function getAvailableRuleTypes(AbstractPopup $popup)
{
$rulesTypes = $this->popupManager->getAvailableRules($popup);
$rules = array();
foreach ($rulesTypes as $ruleType) {
$object = new $ruleType();
$rules[$object->getClassname()] = $object->getFullClassname();
}
return $rules;
} | php | public function getAvailableRuleTypes(AbstractPopup $popup)
{
$rulesTypes = $this->popupManager->getAvailableRules($popup);
$rules = array();
foreach ($rulesTypes as $ruleType) {
$object = new $ruleType();
$rules[$object->getClassname()] = $object->getFullClassname();
}
return $rules;
} | [
"public",
"function",
"getAvailableRuleTypes",
"(",
"AbstractPopup",
"$",
"popup",
")",
"{",
"$",
"rulesTypes",
"=",
"$",
"this",
"->",
"popupManager",
"->",
"getAvailableRules",
"(",
"$",
"popup",
")",
";",
"$",
"rules",
"=",
"array",
"(",
")",
";",
"fore... | Get the available popup types for a specific popup.
@param AbstractPopup $popup
@return array | [
"Get",
"the",
"available",
"popup",
"types",
"for",
"a",
"specific",
"popup",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/LeadGenerationBundle/Twig/PopupTwigExtension.php#L135-L146 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractPageAdminListConfigurator.php | AbstractPageAdminListConfigurator.getOverviewPage | public function getOverviewPage()
{
/** @var EntityRepository $repository */
$repository = $this->em->getRepository($this->getOverviewPageClass());
$overviewPage = $repository->createQueryBuilder('o')
->orderBy('o.id', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
return $overviewPage;
} | php | public function getOverviewPage()
{
/** @var EntityRepository $repository */
$repository = $this->em->getRepository($this->getOverviewPageClass());
$overviewPage = $repository->createQueryBuilder('o')
->orderBy('o.id', 'DESC')
->setMaxResults(1)
->getQuery()
->getOneOrNullResult();
return $overviewPage;
} | [
"public",
"function",
"getOverviewPage",
"(",
")",
"{",
"/** @var EntityRepository $repository */",
"$",
"repository",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getOverviewPageClass",
"(",
")",
")",
";",
"$",
"overviewPage",
"... | Returns the overviewpage. | [
"Returns",
"the",
"overviewpage",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractPageAdminListConfigurator.php#L203-L215 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/MediaBundle/Repository/FolderRepository.php | FolderRepository.rebuildTree | public function rebuildTree()
{
$em = $this->getEntityManager();
// Reset tree...
$sql = 'UPDATE kuma_folders SET lvl=NULL,lft=NULL,rgt=NULL';
$stmt = $em->getConnection()->prepare($sql);
$stmt->execute();
$folders = $this->findBy(array(), array('parent' => 'ASC', 'name' => 'asc'));
$rootFolder = $folders[0];
$first = true;
foreach ($folders as $folder) {
// Force parent load
$parent = $folder->getParent();
if (is_null($parent)) {
$folder->setLevel(0);
if ($first) {
$this->persistAsFirstChild($folder);
$first = false;
} else {
$this->persistAsNextSiblingOf($folder, $rootFolder);
}
} else {
$folder->setLevel($parent->getLevel() + 1);
$this->persistAsLastChildOf($folder, $parent);
}
}
$em->flush();
} | php | public function rebuildTree()
{
$em = $this->getEntityManager();
// Reset tree...
$sql = 'UPDATE kuma_folders SET lvl=NULL,lft=NULL,rgt=NULL';
$stmt = $em->getConnection()->prepare($sql);
$stmt->execute();
$folders = $this->findBy(array(), array('parent' => 'ASC', 'name' => 'asc'));
$rootFolder = $folders[0];
$first = true;
foreach ($folders as $folder) {
// Force parent load
$parent = $folder->getParent();
if (is_null($parent)) {
$folder->setLevel(0);
if ($first) {
$this->persistAsFirstChild($folder);
$first = false;
} else {
$this->persistAsNextSiblingOf($folder, $rootFolder);
}
} else {
$folder->setLevel($parent->getLevel() + 1);
$this->persistAsLastChildOf($folder, $parent);
}
}
$em->flush();
} | [
"public",
"function",
"rebuildTree",
"(",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"// Reset tree...",
"$",
"sql",
"=",
"'UPDATE kuma_folders SET lvl=NULL,lft=NULL,rgt=NULL'",
";",
"$",
"stmt",
"=",
"$",
"em",
"->",
"getC... | Rebuild the nested tree | [
"Rebuild",
"the",
"nested",
"tree"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Repository/FolderRepository.php#L279-L309 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/MediaBundle/Repository/FolderRepository.php | FolderRepository.selectFolderQueryBuilder | public function selectFolderQueryBuilder(Folder $ignoreSubtree = null)
{
/** @var QueryBuilder $qb */
$qb = $this->createQueryBuilder('f');
$qb->where('f.deleted != true')
->orderBy('f.lft');
// Fetch all folders except the current one and its children
if (!is_null($ignoreSubtree) && $ignoreSubtree->getId() !== null) {
$orX = $qb->expr()->orX();
$orX->add('f.rgt > :right')
->add('f.lft < :left');
$qb->andWhere($orX)
->setParameter('left', $ignoreSubtree->getLeft())
->setParameter('right', $ignoreSubtree->getRight());
}
return $qb;
} | php | public function selectFolderQueryBuilder(Folder $ignoreSubtree = null)
{
/** @var QueryBuilder $qb */
$qb = $this->createQueryBuilder('f');
$qb->where('f.deleted != true')
->orderBy('f.lft');
// Fetch all folders except the current one and its children
if (!is_null($ignoreSubtree) && $ignoreSubtree->getId() !== null) {
$orX = $qb->expr()->orX();
$orX->add('f.rgt > :right')
->add('f.lft < :left');
$qb->andWhere($orX)
->setParameter('left', $ignoreSubtree->getLeft())
->setParameter('right', $ignoreSubtree->getRight());
}
return $qb;
} | [
"public",
"function",
"selectFolderQueryBuilder",
"(",
"Folder",
"$",
"ignoreSubtree",
"=",
"null",
")",
"{",
"/** @var QueryBuilder $qb */",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'f'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'f.dele... | Used as querybuilder for Folder entity selectors
@param Folder $ignoreSubtree Folder (with children) that has to be filtered out (optional)
@return QueryBuilder | [
"Used",
"as",
"querybuilder",
"for",
"Folder",
"entity",
"selectors"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Repository/FolderRepository.php#L318-L337 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsSegmentRepository.php | AnalyticsSegmentRepository.deleteSegment | public function deleteSegment($id)
{
$em = $this->getEntityManager();
$qb = $em->createQueryBuilder();
$qb->select('s')
->from('KunstmaanDashboardBundle:AnalyticsSegment', 's')
->where('s.id = :id')
->setParameter('id', $id);
$results = $qb->getQuery()->getResult();
if ($results) {
$em->remove($results[0]);
$em->flush();
}
} | php | public function deleteSegment($id)
{
$em = $this->getEntityManager();
$qb = $em->createQueryBuilder();
$qb->select('s')
->from('KunstmaanDashboardBundle:AnalyticsSegment', 's')
->where('s.id = :id')
->setParameter('id', $id);
$results = $qb->getQuery()->getResult();
if ($results) {
$em->remove($results[0]);
$em->flush();
}
} | [
"public",
"function",
"deleteSegment",
"(",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"qb",
"=",
"$",
"em",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'s'",
")",... | Get a segment
@param int $id
@return AnalyticsOverview|bool | [
"Get",
"a",
"segment"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsSegmentRepository.php#L22-L36 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Repository/AnalyticsSegmentRepository.php | AnalyticsSegmentRepository.initSegment | public function initSegment($segment, $configId = false)
{
if (!count($segment->getOverviews()->toArray())) {
if ($configId) {
$config = $this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->find($configId);
} else {
$config = $this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->findFirst();
}
$this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsOverview')->addOverviews($config, $segment);
}
} | php | public function initSegment($segment, $configId = false)
{
if (!count($segment->getOverviews()->toArray())) {
if ($configId) {
$config = $this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->find($configId);
} else {
$config = $this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->findFirst();
}
$this->getEntityManager()->getRepository('KunstmaanDashboardBundle:AnalyticsOverview')->addOverviews($config, $segment);
}
} | [
"public",
"function",
"initSegment",
"(",
"$",
"segment",
",",
"$",
"configId",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"segment",
"->",
"getOverviews",
"(",
")",
"->",
"toArray",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"configI... | Initialise a segment by adding new overviews if they don't exist yet
@param AnalyticsSegment $segment
@param int $configId | [
"Initialise",
"a",
"segment",
"by",
"adding",
"new",
"overviews",
"if",
"they",
"don",
"t",
"exist",
"yet"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsSegmentRepository.php#L44-L54 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/UserManagementBundle/Controller/UsersController.php | UsersController.editAction | public function editAction(Request $request, $id)
{
// The logged in user should be able to change his own password/username/email and not for other users
if ($id == $this->container->get('security.token_storage')->getToken()->getUser()->getId()) {
$requiredRole = 'ROLE_ADMIN';
} else {
$requiredRole = 'ROLE_SUPER_ADMIN';
}
$this->denyAccessUnlessGranted($requiredRole);
/* @var $em EntityManager */
$em = $this->getDoctrine()->getManager();
/** @var UserInterface $user */
$user = $em->getRepository($this->container->getParameter('fos_user.model.user.class'))->find($id);
if ($user === null) {
throw new NotFoundHttpException(sprintf('User with ID %s not found', $id));
}
$userEvent = new UserEvent($user, $request);
$this->container->get('event_dispatcher')->dispatch(UserEvents::USER_EDIT_INITIALIZE, $userEvent);
$options = array('password_required' => false, 'langs' => $this->container->getParameter('kunstmaan_admin.admin_locales'), 'data_class' => get_class($user));
$formFqn = $user->getFormTypeClass();
$formType = new $formFqn();
if ($formType instanceof RoleDependentUserFormInterface) {
// to edit groups and enabled the current user should have ROLE_SUPER_ADMIN
$options['can_edit_all_fields'] = $this->isGranted('ROLE_SUPER_ADMIN');
}
$event = new AdaptSimpleFormEvent($request, $formFqn, $user, $options);
$event = $this->container->get('event_dispatcher')->dispatch(Events::ADAPT_SIMPLE_FORM, $event);
$tabPane = $event->getTabPane();
$form = $this->createForm($formFqn, $user, $options);
if ($request->isMethod('POST')) {
if ($tabPane) {
$tabPane->bindRequest($request);
$form = $tabPane->getForm();
} else {
$form->handleRequest($request);
}
if ($form->isSubmitted() && $form->isValid()) {
/* @var UserManager $userManager */
$userManager = $this->container->get('fos_user.user_manager');
$userManager->updateUser($user, true);
$this->addFlash(
FlashTypes::SUCCESS,
$this->container->get('translator')->trans('kuma_user.users.edit.flash.success.%username%', [
'%username%' => $user->getUsername(),
])
);
return new RedirectResponse(
$this->generateUrl(
'KunstmaanUserManagementBundle_settings_users_edit',
array('id' => $id)
)
);
}
}
$params = array(
'form' => $form->createView(),
'user' => $user,
);
if ($tabPane) {
$params = array_merge($params, array('tabPane' => $tabPane));
}
return $params;
} | php | public function editAction(Request $request, $id)
{
// The logged in user should be able to change his own password/username/email and not for other users
if ($id == $this->container->get('security.token_storage')->getToken()->getUser()->getId()) {
$requiredRole = 'ROLE_ADMIN';
} else {
$requiredRole = 'ROLE_SUPER_ADMIN';
}
$this->denyAccessUnlessGranted($requiredRole);
/* @var $em EntityManager */
$em = $this->getDoctrine()->getManager();
/** @var UserInterface $user */
$user = $em->getRepository($this->container->getParameter('fos_user.model.user.class'))->find($id);
if ($user === null) {
throw new NotFoundHttpException(sprintf('User with ID %s not found', $id));
}
$userEvent = new UserEvent($user, $request);
$this->container->get('event_dispatcher')->dispatch(UserEvents::USER_EDIT_INITIALIZE, $userEvent);
$options = array('password_required' => false, 'langs' => $this->container->getParameter('kunstmaan_admin.admin_locales'), 'data_class' => get_class($user));
$formFqn = $user->getFormTypeClass();
$formType = new $formFqn();
if ($formType instanceof RoleDependentUserFormInterface) {
// to edit groups and enabled the current user should have ROLE_SUPER_ADMIN
$options['can_edit_all_fields'] = $this->isGranted('ROLE_SUPER_ADMIN');
}
$event = new AdaptSimpleFormEvent($request, $formFqn, $user, $options);
$event = $this->container->get('event_dispatcher')->dispatch(Events::ADAPT_SIMPLE_FORM, $event);
$tabPane = $event->getTabPane();
$form = $this->createForm($formFqn, $user, $options);
if ($request->isMethod('POST')) {
if ($tabPane) {
$tabPane->bindRequest($request);
$form = $tabPane->getForm();
} else {
$form->handleRequest($request);
}
if ($form->isSubmitted() && $form->isValid()) {
/* @var UserManager $userManager */
$userManager = $this->container->get('fos_user.user_manager');
$userManager->updateUser($user, true);
$this->addFlash(
FlashTypes::SUCCESS,
$this->container->get('translator')->trans('kuma_user.users.edit.flash.success.%username%', [
'%username%' => $user->getUsername(),
])
);
return new RedirectResponse(
$this->generateUrl(
'KunstmaanUserManagementBundle_settings_users_edit',
array('id' => $id)
)
);
}
}
$params = array(
'form' => $form->createView(),
'user' => $user,
);
if ($tabPane) {
$params = array_merge($params, array('tabPane' => $tabPane));
}
return $params;
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"// The logged in user should be able to change his own password/username/email and not for other users",
"if",
"(",
"$",
"id",
"==",
"$",
"this",
"->",
"container",
"->",
"get... | Edit a user
@param int $id
@Route("/{id}/edit", requirements={"id" = "\d+"}, name="KunstmaanUserManagementBundle_settings_users_edit", methods={"GET", "POST"})
@Template("@KunstmaanUserManagement/Users/edit.html.twig")
@throws AccessDeniedException
@return array | [
"Edit",
"a",
"user"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/UserManagementBundle/Controller/UsersController.php#L140-L216 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/Menu/PageMenuAdaptor.php | PageMenuAdaptor.getTreeNodes | private function getTreeNodes(
$lang,
$permission,
AclNativeHelper $aclNativeHelper,
$includeHiddenFromNav
) {
if (null === $this->treeNodes) {
$repo = $this->em->getRepository('KunstmaanNodeBundle:Node');
$this->treeNodes = [];
$rootNode = $this->domainConfiguration->getRootNode();
// Get all nodes that should be shown in the menu
$allNodes = $repo->getAllMenuNodes(
$lang,
$permission,
$aclNativeHelper,
$includeHiddenFromNav,
$rootNode
);
/** @var Node $nodeInfo */
foreach ($allNodes as $nodeInfo) {
$refEntityName = $nodeInfo['ref_entity_name'];
if ($this->pagesConfiguration->isHiddenFromTree($refEntityName)) {
continue;
}
$parent_id = is_null($nodeInfo['parent']) ? 0 : $nodeInfo['parent'];
unset($nodeInfo['parent']);
$this->treeNodes[$parent_id][] = $nodeInfo;
}
unset($allNodes);
}
return $this->treeNodes;
} | php | private function getTreeNodes(
$lang,
$permission,
AclNativeHelper $aclNativeHelper,
$includeHiddenFromNav
) {
if (null === $this->treeNodes) {
$repo = $this->em->getRepository('KunstmaanNodeBundle:Node');
$this->treeNodes = [];
$rootNode = $this->domainConfiguration->getRootNode();
// Get all nodes that should be shown in the menu
$allNodes = $repo->getAllMenuNodes(
$lang,
$permission,
$aclNativeHelper,
$includeHiddenFromNav,
$rootNode
);
/** @var Node $nodeInfo */
foreach ($allNodes as $nodeInfo) {
$refEntityName = $nodeInfo['ref_entity_name'];
if ($this->pagesConfiguration->isHiddenFromTree($refEntityName)) {
continue;
}
$parent_id = is_null($nodeInfo['parent']) ? 0 : $nodeInfo['parent'];
unset($nodeInfo['parent']);
$this->treeNodes[$parent_id][] = $nodeInfo;
}
unset($allNodes);
}
return $this->treeNodes;
} | [
"private",
"function",
"getTreeNodes",
"(",
"$",
"lang",
",",
"$",
"permission",
",",
"AclNativeHelper",
"$",
"aclNativeHelper",
",",
"$",
"includeHiddenFromNav",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"treeNodes",
")",
"{",
"$",
"repo",
"=... | Get the list of nodes that is used in the admin menu.
@param string $lang
@param string $permission
@param AclNativeHelper $aclNativeHelper
@param bool $includeHiddenFromNav
@return array | [
"Get",
"the",
"list",
"of",
"nodes",
"that",
"is",
"used",
"in",
"the",
"admin",
"menu",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/Menu/PageMenuAdaptor.php#L140-L174 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/Menu/PageMenuAdaptor.php | PageMenuAdaptor.getActiveNodeIds | private function getActiveNodeIds($request)
{
if (null === $this->activeNodeIds) {
if (stripos($request->attributes->get('_route'), 'KunstmaanNodeBundle_nodes_edit') === 0) {
$repo = $this->em->getRepository('KunstmaanNodeBundle:Node');
$currentNode = $repo->findOneById($request->attributes->get('id'));
$parentNodes = $repo->getAllParents($currentNode);
$this->activeNodeIds = [];
foreach ($parentNodes as $parentNode) {
$this->activeNodeIds[] = $parentNode->getId();
}
}
}
return is_null($this->activeNodeIds) ? [] : $this->activeNodeIds;
} | php | private function getActiveNodeIds($request)
{
if (null === $this->activeNodeIds) {
if (stripos($request->attributes->get('_route'), 'KunstmaanNodeBundle_nodes_edit') === 0) {
$repo = $this->em->getRepository('KunstmaanNodeBundle:Node');
$currentNode = $repo->findOneById($request->attributes->get('id'));
$parentNodes = $repo->getAllParents($currentNode);
$this->activeNodeIds = [];
foreach ($parentNodes as $parentNode) {
$this->activeNodeIds[] = $parentNode->getId();
}
}
}
return is_null($this->activeNodeIds) ? [] : $this->activeNodeIds;
} | [
"private",
"function",
"getActiveNodeIds",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"activeNodeIds",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_route'",
")",
",",
"'K... | Get an array with the id's off all nodes in the tree that should be
expanded.
@param $request
@return array | [
"Get",
"an",
"array",
"with",
"the",
"id",
"s",
"off",
"all",
"nodes",
"in",
"the",
"tree",
"that",
"should",
"be",
"expanded",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/Menu/PageMenuAdaptor.php#L184-L200 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/MenuBundle/Controller/MenuItemAdminListController.php | MenuItemAdminListController.indexAction | public function indexAction(Request $request, $menuid)
{
$menuRepo = $this->getDoctrine()->getManager()->getRepository(
$this->container->getParameter('kunstmaan_menu.entity.menu.class')
);
/** @var BaseMenu $menu */
$menu = $menuRepo->find($menuid);
if ($menu->getLocale() != $request->getLocale()) {
/** @var BaseMenu $translatedMenu */
$translatedMenu = $menuRepo->findOneBy(['locale' => $request->getLocale(), 'name' => $menu->getName()]);
$menuid = $translatedMenu->getId();
}
$configurator = $this->getAdminListConfigurator($request, $menuid);
$itemRoute = function (EntityInterface $item) use ($menuid) {
return array(
'path' => 'kunstmaanmenubundle_admin_menuitem_move_up',
'params' => array(
'menuid' => $menuid,
'item' => $item->getId(),
),
);
};
$configurator->addItemAction(new SimpleItemAction($itemRoute, 'arrow-up', 'kuma_admin_list.action.move_up'));
$itemRoute = function (EntityInterface $item) use ($menuid) {
return array(
'path' => 'kunstmaanmenubundle_admin_menuitem_move_down',
'params' => array(
'menuid' => $menuid,
'item' => $item->getId(),
),
);
};
$configurator->addItemAction(new SimpleItemAction($itemRoute, 'arrow-down', 'kuma_admin_list.action.move_down'));
return parent::doIndexAction($configurator, $request);
} | php | public function indexAction(Request $request, $menuid)
{
$menuRepo = $this->getDoctrine()->getManager()->getRepository(
$this->container->getParameter('kunstmaan_menu.entity.menu.class')
);
/** @var BaseMenu $menu */
$menu = $menuRepo->find($menuid);
if ($menu->getLocale() != $request->getLocale()) {
/** @var BaseMenu $translatedMenu */
$translatedMenu = $menuRepo->findOneBy(['locale' => $request->getLocale(), 'name' => $menu->getName()]);
$menuid = $translatedMenu->getId();
}
$configurator = $this->getAdminListConfigurator($request, $menuid);
$itemRoute = function (EntityInterface $item) use ($menuid) {
return array(
'path' => 'kunstmaanmenubundle_admin_menuitem_move_up',
'params' => array(
'menuid' => $menuid,
'item' => $item->getId(),
),
);
};
$configurator->addItemAction(new SimpleItemAction($itemRoute, 'arrow-up', 'kuma_admin_list.action.move_up'));
$itemRoute = function (EntityInterface $item) use ($menuid) {
return array(
'path' => 'kunstmaanmenubundle_admin_menuitem_move_down',
'params' => array(
'menuid' => $menuid,
'item' => $item->getId(),
),
);
};
$configurator->addItemAction(new SimpleItemAction($itemRoute, 'arrow-down', 'kuma_admin_list.action.move_down'));
return parent::doIndexAction($configurator, $request);
} | [
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
",",
"$",
"menuid",
")",
"{",
"$",
"menuRepo",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"container",... | The index action
@param Request $request
@param int $menuid
@return Response
@Route("/{menuid}/items", name="kunstmaanmenubundle_admin_menuitem") | [
"The",
"index",
"action"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MenuBundle/Controller/MenuItemAdminListController.php#L60-L98 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/MenuBundle/Controller/MenuItemAdminListController.php | MenuItemAdminListController.deleteAction | public function deleteAction(Request $request, $menuid, $id)
{
return parent::doDeleteAction($this->getAdminListConfigurator($request, $menuid), $id, $request);
} | php | public function deleteAction(Request $request, $menuid, $id)
{
return parent::doDeleteAction($this->getAdminListConfigurator($request, $menuid), $id, $request);
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"$",
"menuid",
",",
"$",
"id",
")",
"{",
"return",
"parent",
"::",
"doDeleteAction",
"(",
"$",
"this",
"->",
"getAdminListConfigurator",
"(",
"$",
"request",
",",
"$",
"menuid",
")"... | The delete action
@param int $id
@Route("{menuid}/items/{id}/delete", requirements={"id" = "\d+"}, name="kunstmaanmenubundle_admin_menuitem_delete", methods={"GET", "POST"})
@return array | [
"The",
"delete",
"action"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MenuBundle/Controller/MenuItemAdminListController.php#L135-L138 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/MenuBundle/Controller/MenuItemAdminListController.php | MenuItemAdminListController.moveDownAction | public function moveDownAction(Request $request, $menuid, $item)
{
$em = $this->getEntityManager();
$repo = $em->getRepository($this->container->getParameter('kunstmaan_menu.entity.menuitem.class'));
$item = $repo->find($item);
if ($item) {
$repo->moveDown($item);
}
return new RedirectResponse(
$this->generateUrl('kunstmaanmenubundle_admin_menuitem', array('menuid' => $menuid))
);
} | php | public function moveDownAction(Request $request, $menuid, $item)
{
$em = $this->getEntityManager();
$repo = $em->getRepository($this->container->getParameter('kunstmaan_menu.entity.menuitem.class'));
$item = $repo->find($item);
if ($item) {
$repo->moveDown($item);
}
return new RedirectResponse(
$this->generateUrl('kunstmaanmenubundle_admin_menuitem', array('menuid' => $menuid))
);
} | [
"public",
"function",
"moveDownAction",
"(",
"Request",
"$",
"request",
",",
"$",
"menuid",
",",
"$",
"item",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"repo",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$"... | Move an item down in the list.
@Route("{menuid}/items/{item}/move-down", name="kunstmaanmenubundle_admin_menuitem_move_down", methods={"GET"})
@return RedirectResponse | [
"Move",
"an",
"item",
"down",
"in",
"the",
"list",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MenuBundle/Controller/MenuItemAdminListController.php#L169-L182 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.initialize | public function initialize(AbstractEntity $resource, PermissionMapInterface $permissionMap)
{
$this->resource = $resource;
$this->permissionMap = $permissionMap;
$this->permissions = array();
// Init permissions
try {
$objectIdentity = $this->oidRetrievalStrategy->getObjectIdentity($this->resource);
/* @var $acl AclInterface */
$acl = $this->aclProvider->findAcl($objectIdentity);
$objectAces = $acl->getObjectAces();
/* @var $ace AuditableEntryInterface */
foreach ($objectAces as $ace) {
$securityIdentity = $ace->getSecurityIdentity();
if ($securityIdentity instanceof RoleSecurityIdentity) {
$this->permissions[$securityIdentity->getRole()] = new MaskBuilder($ace->getMask());
}
}
} catch (AclNotFoundException $e) {
// No Acl found - do nothing (or should we initialize with default values here?)
}
} | php | public function initialize(AbstractEntity $resource, PermissionMapInterface $permissionMap)
{
$this->resource = $resource;
$this->permissionMap = $permissionMap;
$this->permissions = array();
// Init permissions
try {
$objectIdentity = $this->oidRetrievalStrategy->getObjectIdentity($this->resource);
/* @var $acl AclInterface */
$acl = $this->aclProvider->findAcl($objectIdentity);
$objectAces = $acl->getObjectAces();
/* @var $ace AuditableEntryInterface */
foreach ($objectAces as $ace) {
$securityIdentity = $ace->getSecurityIdentity();
if ($securityIdentity instanceof RoleSecurityIdentity) {
$this->permissions[$securityIdentity->getRole()] = new MaskBuilder($ace->getMask());
}
}
} catch (AclNotFoundException $e) {
// No Acl found - do nothing (or should we initialize with default values here?)
}
} | [
"public",
"function",
"initialize",
"(",
"AbstractEntity",
"$",
"resource",
",",
"PermissionMapInterface",
"$",
"permissionMap",
")",
"{",
"$",
"this",
"->",
"resource",
"=",
"$",
"resource",
";",
"$",
"this",
"->",
"permissionMap",
"=",
"$",
"permissionMap",
... | Initialize permission admin with specified entity.
@param AbstractEntity $resource The object which has the permissions
@param PermissionMapInterface $permissionMap The permission map to use | [
"Initialize",
"permission",
"admin",
"with",
"specified",
"entity",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L118-L140 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.getPermission | public function getPermission($role)
{
if ($role instanceof RoleInterface || $role instanceof \Symfony\Component\Security\Core\Role\Role) {
$role = $role->getRole();
}
if (isset($this->permissions[$role])) {
return $this->permissions[$role];
}
return null;
} | php | public function getPermission($role)
{
if ($role instanceof RoleInterface || $role instanceof \Symfony\Component\Security\Core\Role\Role) {
$role = $role->getRole();
}
if (isset($this->permissions[$role])) {
return $this->permissions[$role];
}
return null;
} | [
"public",
"function",
"getPermission",
"(",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"role",
"instanceof",
"RoleInterface",
"||",
"$",
"role",
"instanceof",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"Security",
"\\",
"Core",
"\\",
"Role",
"\\",
"Role",
")",
... | Get permission for specified role.
@param RoleInterface|string $role
@return MaskBuilder|null | [
"Get",
"permission",
"for",
"specified",
"role",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L159-L169 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.getManageableRolesForPages | public function getManageableRolesForPages()
{
$roles = $this->em->getRepository('KunstmaanAdminBundle:Role')->findAll();
if (($token = $this->tokenStorage->getToken()) && ($user = $token->getUser())) {
if ($user && !$user->isSuperAdmin() && ($superAdminRole = array_keys($roles, 'ROLE_SUPER_ADMIN'))) {
$superAdminRole = current($superAdminRole);
unset($roles[$superAdminRole]);
}
}
return $roles;
} | php | public function getManageableRolesForPages()
{
$roles = $this->em->getRepository('KunstmaanAdminBundle:Role')->findAll();
if (($token = $this->tokenStorage->getToken()) && ($user = $token->getUser())) {
if ($user && !$user->isSuperAdmin() && ($superAdminRole = array_keys($roles, 'ROLE_SUPER_ADMIN'))) {
$superAdminRole = current($superAdminRole);
unset($roles[$superAdminRole]);
}
}
return $roles;
} | [
"public",
"function",
"getManageableRolesForPages",
"(",
")",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'KunstmaanAdminBundle:Role'",
")",
"->",
"findAll",
"(",
")",
";",
"if",
"(",
"(",
"$",
"token",
"=",
"$",
"this",
... | Get all manageable roles for pages
@return Role[] | [
"Get",
"all",
"manageable",
"roles",
"for",
"pages"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L186-L198 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.bindRequest | public function bindRequest(Request $request)
{
$changes = $request->request->get('permission-hidden-fields');
if (empty($changes)) {
return true;
}
// Just apply the changes to the current node (non recursively)
$this->applyAclChangeset($this->resource, $changes, false);
// Apply recursively (on request)
$applyRecursive = $request->request->get('applyRecursive');
if ($applyRecursive) {
// Serialize changes & store them in DB
$user = $this->tokenStorage->getToken()->getUser();
$this->createAclChangeSet($this->resource, $changes, $user);
$cmd = 'php ' . $this->kernel->getRootDir() . '/../bin/console kuma:acl:apply';
$cmd .= ' --env=' . $this->kernel->getEnvironment();
$this->shellHelper->runInBackground($cmd);
}
return true;
} | php | public function bindRequest(Request $request)
{
$changes = $request->request->get('permission-hidden-fields');
if (empty($changes)) {
return true;
}
// Just apply the changes to the current node (non recursively)
$this->applyAclChangeset($this->resource, $changes, false);
// Apply recursively (on request)
$applyRecursive = $request->request->get('applyRecursive');
if ($applyRecursive) {
// Serialize changes & store them in DB
$user = $this->tokenStorage->getToken()->getUser();
$this->createAclChangeSet($this->resource, $changes, $user);
$cmd = 'php ' . $this->kernel->getRootDir() . '/../bin/console kuma:acl:apply';
$cmd .= ' --env=' . $this->kernel->getEnvironment();
$this->shellHelper->runInBackground($cmd);
}
return true;
} | [
"public",
"function",
"bindRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"changes",
"=",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'permission-hidden-fields'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"changes",
")",
")",
"{",
"return... | Handle form entry of permission changes.
@param Request $request
@return bool | [
"Handle",
"form",
"entry",
"of",
"permission",
"changes",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L217-L242 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.createAclChangeSet | public function createAclChangeSet(AbstractEntity $entity, $changes, UserInterface $user)
{
$aclChangeset = new AclChangeset();
$aclChangeset->setRef($entity);
$aclChangeset->setChangeset($changes);
/* @var $user BaseUser */
$aclChangeset->setUser($user);
$this->em->persist($aclChangeset);
$this->em->flush();
return $aclChangeset;
} | php | public function createAclChangeSet(AbstractEntity $entity, $changes, UserInterface $user)
{
$aclChangeset = new AclChangeset();
$aclChangeset->setRef($entity);
$aclChangeset->setChangeset($changes);
/* @var $user BaseUser */
$aclChangeset->setUser($user);
$this->em->persist($aclChangeset);
$this->em->flush();
return $aclChangeset;
} | [
"public",
"function",
"createAclChangeSet",
"(",
"AbstractEntity",
"$",
"entity",
",",
"$",
"changes",
",",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"aclChangeset",
"=",
"new",
"AclChangeset",
"(",
")",
";",
"$",
"aclChangeset",
"->",
"setRef",
"(",
"$",... | Create a new ACL changeset.
@param AbstractEntity $entity The entity
@param array $changes The changes
@param UserInterface $user The user
@return AclChangeset | [
"Create",
"a",
"new",
"ACL",
"changeset",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L253-L264 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.applyAclChangeset | public function applyAclChangeset(AbstractEntity $entity, $changeset, $recursive = true)
{
if ($recursive) {
if (!method_exists($entity, 'getChildren')) {
return;
}
// Iterate over children and apply recursively
/* @noinspection PhpUndefinedMethodInspection */
foreach ($entity->getChildren() as $child) {
$this->applyAclChangeset($child, $changeset);
}
}
// Apply ACL modifications to node
$objectIdentity = $this->oidRetrievalStrategy->getObjectIdentity($entity);
try {
/* @var $acl MutableAclInterface */
$acl = $this->aclProvider->findAcl($objectIdentity);
} catch (AclNotFoundException $e) {
/* @var $acl MutableAclInterface */
$acl = $this->aclProvider->createAcl($objectIdentity);
}
// Process permissions in changeset
foreach ($changeset as $role => $roleChanges) {
$index = $this->getObjectAceIndex($acl, $role);
$mask = 0;
if (false !== $index) {
$mask = $this->getMaskAtIndex($acl, $index);
}
foreach ($roleChanges as $type => $permissions) {
$maskChange = new MaskBuilder();
foreach ($permissions as $permission) {
$maskChange->add($permission);
}
switch ($type) {
case self::ADD:
$mask = $mask | $maskChange->get();
break;
case self::DELETE:
$mask = $mask & ~$maskChange->get();
break;
}
}
if (false !== $index) {
$acl->updateObjectAce($index, $mask);
} else {
$securityIdentity = new RoleSecurityIdentity($role);
$acl->insertObjectAce($securityIdentity, $mask);
}
}
$this->aclProvider->updateAcl($acl);
} | php | public function applyAclChangeset(AbstractEntity $entity, $changeset, $recursive = true)
{
if ($recursive) {
if (!method_exists($entity, 'getChildren')) {
return;
}
// Iterate over children and apply recursively
/* @noinspection PhpUndefinedMethodInspection */
foreach ($entity->getChildren() as $child) {
$this->applyAclChangeset($child, $changeset);
}
}
// Apply ACL modifications to node
$objectIdentity = $this->oidRetrievalStrategy->getObjectIdentity($entity);
try {
/* @var $acl MutableAclInterface */
$acl = $this->aclProvider->findAcl($objectIdentity);
} catch (AclNotFoundException $e) {
/* @var $acl MutableAclInterface */
$acl = $this->aclProvider->createAcl($objectIdentity);
}
// Process permissions in changeset
foreach ($changeset as $role => $roleChanges) {
$index = $this->getObjectAceIndex($acl, $role);
$mask = 0;
if (false !== $index) {
$mask = $this->getMaskAtIndex($acl, $index);
}
foreach ($roleChanges as $type => $permissions) {
$maskChange = new MaskBuilder();
foreach ($permissions as $permission) {
$maskChange->add($permission);
}
switch ($type) {
case self::ADD:
$mask = $mask | $maskChange->get();
break;
case self::DELETE:
$mask = $mask & ~$maskChange->get();
break;
}
}
if (false !== $index) {
$acl->updateObjectAce($index, $mask);
} else {
$securityIdentity = new RoleSecurityIdentity($role);
$acl->insertObjectAce($securityIdentity, $mask);
}
}
$this->aclProvider->updateAcl($acl);
} | [
"public",
"function",
"applyAclChangeset",
"(",
"AbstractEntity",
"$",
"entity",
",",
"$",
"changeset",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"recursive",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"entity",
",",
"'getCh... | Apply the specified ACL changeset.
@param AbstractEntity $entity The entity
@param array $changeset The changeset
@param bool $recursive The recursive | [
"Apply",
"the",
"specified",
"ACL",
"changeset",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L273-L329 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.getObjectAceIndex | private function getObjectAceIndex(AclInterface $acl, $role)
{
$objectAces = $acl->getObjectAces();
/* @var $ace AuditableEntryInterface */
foreach ($objectAces as $index => $ace) {
$securityIdentity = $ace->getSecurityIdentity();
if ($securityIdentity instanceof RoleSecurityIdentity) {
if ($securityIdentity->getRole() == $role) {
return $index;
}
}
}
return false;
} | php | private function getObjectAceIndex(AclInterface $acl, $role)
{
$objectAces = $acl->getObjectAces();
/* @var $ace AuditableEntryInterface */
foreach ($objectAces as $index => $ace) {
$securityIdentity = $ace->getSecurityIdentity();
if ($securityIdentity instanceof RoleSecurityIdentity) {
if ($securityIdentity->getRole() == $role) {
return $index;
}
}
}
return false;
} | [
"private",
"function",
"getObjectAceIndex",
"(",
"AclInterface",
"$",
"acl",
",",
"$",
"role",
")",
"{",
"$",
"objectAces",
"=",
"$",
"acl",
"->",
"getObjectAces",
"(",
")",
";",
"/* @var $ace AuditableEntryInterface */",
"foreach",
"(",
"$",
"objectAces",
"as",... | Get current object ACE index for specified role.
@param AclInterface $acl The AclInterface
@param string $role The role
@return bool|int | [
"Get",
"current",
"object",
"ACE",
"index",
"for",
"specified",
"role",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L339-L353 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php | PermissionAdmin.getMaskAtIndex | private function getMaskAtIndex(AclInterface $acl, $index)
{
$objectAces = $acl->getObjectAces();
/* @var $ace AuditableEntryInterface */
$ace = $objectAces[$index];
$securityIdentity = $ace->getSecurityIdentity();
if ($securityIdentity instanceof RoleSecurityIdentity) {
return $ace->getMask();
}
return false;
} | php | private function getMaskAtIndex(AclInterface $acl, $index)
{
$objectAces = $acl->getObjectAces();
/* @var $ace AuditableEntryInterface */
$ace = $objectAces[$index];
$securityIdentity = $ace->getSecurityIdentity();
if ($securityIdentity instanceof RoleSecurityIdentity) {
return $ace->getMask();
}
return false;
} | [
"private",
"function",
"getMaskAtIndex",
"(",
"AclInterface",
"$",
"acl",
",",
"$",
"index",
")",
"{",
"$",
"objectAces",
"=",
"$",
"acl",
"->",
"getObjectAces",
"(",
")",
";",
"/* @var $ace AuditableEntryInterface */",
"$",
"ace",
"=",
"$",
"objectAces",
"[",... | Get object ACE mask at specified index.
@param AclInterface $acl The acl interface
@param int $index The index
@return bool|int | [
"Get",
"object",
"ACE",
"mask",
"at",
"specified",
"index",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionAdmin.php#L363-L374 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminListBundle/Controller/AdminListController.php | AdminListController.doIndexAction | protected function doIndexAction(AbstractAdminListConfigurator $configurator, Request $request)
{
$em = $this->getEntityManager();
/* @var AdminList $adminList */
$adminList = $this->container->get('kunstmaan_adminlist.factory')->createList($configurator, $em);
$adminList->bindRequest($request);
$this->buildSortableFieldActions($configurator);
return new Response(
$this->renderView(
$configurator->getListTemplate(),
array('adminlist' => $adminList, 'adminlistconfigurator' => $configurator, 'addparams' => array())
)
);
} | php | protected function doIndexAction(AbstractAdminListConfigurator $configurator, Request $request)
{
$em = $this->getEntityManager();
/* @var AdminList $adminList */
$adminList = $this->container->get('kunstmaan_adminlist.factory')->createList($configurator, $em);
$adminList->bindRequest($request);
$this->buildSortableFieldActions($configurator);
return new Response(
$this->renderView(
$configurator->getListTemplate(),
array('adminlist' => $adminList, 'adminlistconfigurator' => $configurator, 'addparams' => array())
)
);
} | [
"protected",
"function",
"doIndexAction",
"(",
"AbstractAdminListConfigurator",
"$",
"configurator",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
";",
"/* @var AdminList $adminList */",
"$",
"adminList",
... | Shows the list of entities
@param AbstractAdminListConfigurator $configurator
@param null|Request $request
@return Response | [
"Shows",
"the",
"list",
"of",
"entities"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Controller/AdminListController.php#L51-L66 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminListBundle/Controller/AdminListController.php | AdminListController.doExportAction | protected function doExportAction(AbstractAdminListConfigurator $configurator, $_format, Request $request = null)
{
if (!$configurator->canExport()) {
throw $this->createAccessDeniedException('You do not have sufficient rights to access this page.');
}
$em = $this->getEntityManager();
/* @var AdminList $adminList */
$adminList = $this->container->get('kunstmaan_adminlist.factory')->createExportList($configurator, $em);
$adminList->bindRequest($request);
return $this->container->get('kunstmaan_adminlist.service.export')->getDownloadableResponse($adminList, $_format);
} | php | protected function doExportAction(AbstractAdminListConfigurator $configurator, $_format, Request $request = null)
{
if (!$configurator->canExport()) {
throw $this->createAccessDeniedException('You do not have sufficient rights to access this page.');
}
$em = $this->getEntityManager();
/* @var AdminList $adminList */
$adminList = $this->container->get('kunstmaan_adminlist.factory')->createExportList($configurator, $em);
$adminList->bindRequest($request);
return $this->container->get('kunstmaan_adminlist.service.export')->getDownloadableResponse($adminList, $_format);
} | [
"protected",
"function",
"doExportAction",
"(",
"AbstractAdminListConfigurator",
"$",
"configurator",
",",
"$",
"_format",
",",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"configurator",
"->",
"canExport",
"(",
")",
")",
"{",
"thr... | Export a list of Entities
@param AbstractAdminListConfigurator $configurator The adminlist configurator
@param string $_format The format to export to
@param null|Request $request
@throws AccessDeniedHttpException
@return Response | [
"Export",
"a",
"list",
"of",
"Entities"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Controller/AdminListController.php#L79-L92 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminListBundle/Controller/AdminListController.php | AdminListController.doDeleteAction | protected function doDeleteAction(AbstractAdminListConfigurator $configurator, $entityId, Request $request)
{
/* @var $em EntityManager */
$em = $this->getEntityManager();
$helper = $em->getRepository($configurator->getRepositoryName())->findOneById($entityId);
if ($helper === null) {
throw new NotFoundHttpException('Entity not found.');
}
if (!$configurator->canDelete($helper)) {
throw $this->createAccessDeniedException('You do not have sufficient rights to access this page.');
}
$indexUrl = $configurator->getIndexUrl();
if ($request->isMethod('POST')) {
$adminListEvent = new AdminListEvent($helper, $request);
$this->container->get('event_dispatcher')->dispatch(
AdminListEvents::PRE_DELETE,
$adminListEvent
);
// Check if Response is given
if ($adminListEvent->getResponse() instanceof Response) {
return $adminListEvent->getResponse();
}
$em->remove($helper);
$em->flush();
$this->container->get('event_dispatcher')->dispatch(
AdminListEvents::POST_DELETE,
$adminListEvent
);
// Check if Response is given
if ($adminListEvent->getResponse() instanceof Response) {
return $adminListEvent->getResponse();
}
}
return new RedirectResponse(
$this->generateUrl($indexUrl['path'], isset($indexUrl['params']) ? $indexUrl['params'] : array())
);
} | php | protected function doDeleteAction(AbstractAdminListConfigurator $configurator, $entityId, Request $request)
{
/* @var $em EntityManager */
$em = $this->getEntityManager();
$helper = $em->getRepository($configurator->getRepositoryName())->findOneById($entityId);
if ($helper === null) {
throw new NotFoundHttpException('Entity not found.');
}
if (!$configurator->canDelete($helper)) {
throw $this->createAccessDeniedException('You do not have sufficient rights to access this page.');
}
$indexUrl = $configurator->getIndexUrl();
if ($request->isMethod('POST')) {
$adminListEvent = new AdminListEvent($helper, $request);
$this->container->get('event_dispatcher')->dispatch(
AdminListEvents::PRE_DELETE,
$adminListEvent
);
// Check if Response is given
if ($adminListEvent->getResponse() instanceof Response) {
return $adminListEvent->getResponse();
}
$em->remove($helper);
$em->flush();
$this->container->get('event_dispatcher')->dispatch(
AdminListEvents::POST_DELETE,
$adminListEvent
);
// Check if Response is given
if ($adminListEvent->getResponse() instanceof Response) {
return $adminListEvent->getResponse();
}
}
return new RedirectResponse(
$this->generateUrl($indexUrl['path'], isset($indexUrl['params']) ? $indexUrl['params'] : array())
);
} | [
"protected",
"function",
"doDeleteAction",
"(",
"AbstractAdminListConfigurator",
"$",
"configurator",
",",
"$",
"entityId",
",",
"Request",
"$",
"request",
")",
"{",
"/* @var $em EntityManager */",
"$",
"em",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"... | Delete the Entity using its ID
@param AbstractAdminListConfigurator $configurator The adminlist configurator
@param int $entityId The id to delete
@param null|Request $request
@throws NotFoundHttpException
@throws AccessDeniedHttpException
@return Response | [
"Delete",
"the",
"Entity",
"using",
"its",
"ID"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Controller/AdminListController.php#L357-L398 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminListBundle/Controller/AdminListController.php | AdminListController.setSortWeightOnNewItem | protected function setSortWeightOnNewItem(AbstractAdminListConfigurator $configurator, $item)
{
if ($configurator instanceof SortableInterface) {
$repo = $this->getEntityManager()->getRepository($configurator->getRepositoryName());
$sort = $configurator->getSortableField();
$weight = $this->getMaxSortableField($repo, $sort);
$setter = 'set'.ucfirst($sort);
$item->$setter($weight + 1);
}
return $item;
} | php | protected function setSortWeightOnNewItem(AbstractAdminListConfigurator $configurator, $item)
{
if ($configurator instanceof SortableInterface) {
$repo = $this->getEntityManager()->getRepository($configurator->getRepositoryName());
$sort = $configurator->getSortableField();
$weight = $this->getMaxSortableField($repo, $sort);
$setter = 'set'.ucfirst($sort);
$item->$setter($weight + 1);
}
return $item;
} | [
"protected",
"function",
"setSortWeightOnNewItem",
"(",
"AbstractAdminListConfigurator",
"$",
"configurator",
",",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"configurator",
"instanceof",
"SortableInterface",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"getEntityMa... | Sets the sort weight on a new item. Can be overridden if a non-default sorting implementation is being used.
@param AbstractAdminListConfigurator $configurator The adminlist configurator
@param $item
@return mixed | [
"Sets",
"the",
"sort",
"weight",
"on",
"a",
"new",
"item",
".",
"Can",
"be",
"overridden",
"if",
"a",
"non",
"-",
"default",
"sorting",
"implementation",
"is",
"being",
"used",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Controller/AdminListController.php#L511-L522 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php | GeneratorUtils.cleanPrefix | public static function cleanPrefix($prefixString)
{
$prefixString = trim($prefixString);
if (empty($prefixString)) {
return null;
}
$result = preg_replace('/_*$/i', '', strtolower($prefixString)) . '_';
if ($result == '_') {
return null;
}
return $result;
} | php | public static function cleanPrefix($prefixString)
{
$prefixString = trim($prefixString);
if (empty($prefixString)) {
return null;
}
$result = preg_replace('/_*$/i', '', strtolower($prefixString)) . '_';
if ($result == '_') {
return null;
}
return $result;
} | [
"public",
"static",
"function",
"cleanPrefix",
"(",
"$",
"prefixString",
")",
"{",
"$",
"prefixString",
"=",
"trim",
"(",
"$",
"prefixString",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"prefixString",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"resu... | Cleans the prefix. Prevents a double underscore from happening.
@param $prefixString
@return string | [
"Cleans",
"the",
"prefix",
".",
"Prevents",
"a",
"double",
"underscore",
"from",
"happening",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php#L24-L38 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php | GeneratorUtils.append | public static function append($string, $filename)
{
$context = stream_context_create();
$fp = fopen($filename, 'r', 1, $context);
$tmpname = md5($string);
file_put_contents($tmpname, $fp);
file_put_contents($tmpname, $string, FILE_APPEND);
fclose($fp);
unlink($filename);
rename($tmpname, $filename);
} | php | public static function append($string, $filename)
{
$context = stream_context_create();
$fp = fopen($filename, 'r', 1, $context);
$tmpname = md5($string);
file_put_contents($tmpname, $fp);
file_put_contents($tmpname, $string, FILE_APPEND);
fclose($fp);
unlink($filename);
rename($tmpname, $filename);
} | [
"public",
"static",
"function",
"append",
"(",
"$",
"string",
",",
"$",
"filename",
")",
"{",
"$",
"context",
"=",
"stream_context_create",
"(",
")",
";",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"filename",
",",
"'r'",
",",
"1",
",",
"$",
"context",
")",
... | Append the string in the file
@param string $string Text to be added in front of the file
@param string $filename File to prepend in | [
"Append",
"the",
"string",
"in",
"the",
"file"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php#L90-L100 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php | GeneratorUtils.replace | public static function replace($toReplace, $replaceText, $filename)
{
$content = file_get_contents($filename);
if ($content) {
$content = str_replace($toReplace, $replaceText, $content);
file_put_contents($filename, $content);
}
} | php | public static function replace($toReplace, $replaceText, $filename)
{
$content = file_get_contents($filename);
if ($content) {
$content = str_replace($toReplace, $replaceText, $content);
file_put_contents($filename, $content);
}
} | [
"public",
"static",
"function",
"replace",
"(",
"$",
"toReplace",
",",
"$",
"replaceText",
",",
"$",
"filename",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=... | Find and replace the string in the file
@param string $toReplace Text to be replaced
@param string $replaceText Text as replacement
@param string $filename File to replace in | [
"Find",
"and",
"replace",
"the",
"string",
"in",
"the",
"file"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php#L109-L116 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php | GeneratorUtils.getInputAssistant | public static function getInputAssistant(InputInterface &$input, OutputInterface $output, QuestionHelper $questionHelper, Kernel $kernel, ContainerInterface $container)
{
return new InputAssistant($input, $output, $questionHelper, $kernel, $container);
} | php | public static function getInputAssistant(InputInterface &$input, OutputInterface $output, QuestionHelper $questionHelper, Kernel $kernel, ContainerInterface $container)
{
return new InputAssistant($input, $output, $questionHelper, $kernel, $container);
} | [
"public",
"static",
"function",
"getInputAssistant",
"(",
"InputInterface",
"&",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
",",
"QuestionHelper",
"$",
"questionHelper",
",",
"Kernel",
"$",
"kernel",
",",
"ContainerInterface",
"$",
"container",
")",
"{",... | Returns an inputAssistant.
This probably isn't the cleanest way. It'd be nicer if we could make a KunstmaanGenerator class
which all generators inherit from. It then provides a bunch of helper functions and a uniform manner
in which the input options are handled.
@param InputInterface $input
@param OutputInterface $output
@param QuestionHelper $questionHelper
@param Kernel $kernel
@param ContainerInterface $container
@return InputAssistant | [
"Returns",
"an",
"inputAssistant",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Helper/GeneratorUtils.php#L171-L174 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/UserManagementBundle/Controller/GroupsController.php | GroupsController.editAction | public function editAction(Request $request, $id)
{
$this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
/* @var $em EntityManager */
$em = $this->getDoctrine()->getManager();
/* @var Group $group */
$group = $em->getRepository('KunstmaanAdminBundle:Group')->find($id);
$form = $this->createForm(GroupType::class, $group);
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($group);
$em->flush();
$this->addFlash(
FlashTypes::SUCCESS,
$this->container->get('translator')->trans('kuma_user.group.edit.flash.success', array(
'%groupname%' => $group->getName(),
))
);
return new RedirectResponse($this->generateUrl('KunstmaanUserManagementBundle_settings_groups'));
}
}
return array(
'form' => $form->createView(),
'group' => $group,
);
} | php | public function editAction(Request $request, $id)
{
$this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
/* @var $em EntityManager */
$em = $this->getDoctrine()->getManager();
/* @var Group $group */
$group = $em->getRepository('KunstmaanAdminBundle:Group')->find($id);
$form = $this->createForm(GroupType::class, $group);
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($group);
$em->flush();
$this->addFlash(
FlashTypes::SUCCESS,
$this->container->get('translator')->trans('kuma_user.group.edit.flash.success', array(
'%groupname%' => $group->getName(),
))
);
return new RedirectResponse($this->generateUrl('KunstmaanUserManagementBundle_settings_groups'));
}
}
return array(
'form' => $form->createView(),
'group' => $group,
);
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"denyAccessUnlessGranted",
"(",
"'ROLE_SUPER_ADMIN'",
")",
";",
"/* @var $em EntityManager */",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"... | Edit a group
@param int $id
@Route("/{id}/edit", requirements={"id" = "\d+"}, name="KunstmaanUserManagementBundle_settings_groups_edit", methods={"GET", "POST"})
@Template("@KunstmaanUserManagement/Groups/edit.html.twig")
@throws AccessDeniedException
@return array | [
"Edit",
"a",
"group"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/UserManagementBundle/Controller/GroupsController.php#L101-L132 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php | ExportCommandHandler.executeExportCommand | public function executeExportCommand(ExportCommand $exportCommand)
{
$exportFiles = $this->getExportFiles($exportCommand);
$this->fillExportFilesContent($exportFiles);
} | php | public function executeExportCommand(ExportCommand $exportCommand)
{
$exportFiles = $this->getExportFiles($exportCommand);
$this->fillExportFilesContent($exportFiles);
} | [
"public",
"function",
"executeExportCommand",
"(",
"ExportCommand",
"$",
"exportCommand",
")",
"{",
"$",
"exportFiles",
"=",
"$",
"this",
"->",
"getExportFiles",
"(",
"$",
"exportCommand",
")",
";",
"$",
"this",
"->",
"fillExportFilesContent",
"(",
"$",
"exportF... | Execute an export command.
Get all translations per domain and sort on file.
A File has a domain locale, an extensions, with keywords and a ArrayCollection with translations.
@param ExportCommand $exportCommand
@return int total number of files imported | [
"Execute",
"an",
"export",
"command",
".",
"Get",
"all",
"translations",
"per",
"domain",
"and",
"sort",
"on",
"file",
".",
"A",
"File",
"has",
"a",
"domain",
"locale",
"an",
"extensions",
"with",
"keywords",
"and",
"a",
"ArrayCollection",
"with",
"translati... | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php#L37-L41 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php | ExportCommandHandler.executeExportCSVCommand | public function executeExportCSVCommand(ExportCommand $exportCommand)
{
$translations = $this->getTranslations($exportCommand);
/** @var CSVFileExporter $exporter */
$exporter = $this->exporter->getExporterByExtension($exportCommand->getFormat());
$exporter->setLocales($this->determineLocalesToImport($exportCommand));
return $exporter->export($translations);
} | php | public function executeExportCSVCommand(ExportCommand $exportCommand)
{
$translations = $this->getTranslations($exportCommand);
/** @var CSVFileExporter $exporter */
$exporter = $this->exporter->getExporterByExtension($exportCommand->getFormat());
$exporter->setLocales($this->determineLocalesToImport($exportCommand));
return $exporter->export($translations);
} | [
"public",
"function",
"executeExportCSVCommand",
"(",
"ExportCommand",
"$",
"exportCommand",
")",
"{",
"$",
"translations",
"=",
"$",
"this",
"->",
"getTranslations",
"(",
"$",
"exportCommand",
")",
";",
"/** @var CSVFileExporter $exporter */",
"$",
"exporter",
"=",
... | Execute an export to CSV command.
@param ExportCommand $exportCommand
@return string|Response | [
"Execute",
"an",
"export",
"to",
"CSV",
"command",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php#L50-L58 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php | ExportCommandHandler.getTranslations | public function getTranslations(ExportCommand $exportCommand)
{
$locales = $this->determineLocalesToImport($exportCommand);
$domains = $this->determineDomainsToImport($exportCommand);
$translations = [];
/** @var Translation $translation */
foreach ($this->translationRepository->getTranslationsByLocalesAndDomains($locales, $domains) as $translation) {
// Sort by translation key.
$translations[$translation->getKeyword()][$translation->getLocale()] = $translation;
}
return $translations;
} | php | public function getTranslations(ExportCommand $exportCommand)
{
$locales = $this->determineLocalesToImport($exportCommand);
$domains = $this->determineDomainsToImport($exportCommand);
$translations = [];
/** @var Translation $translation */
foreach ($this->translationRepository->getTranslationsByLocalesAndDomains($locales, $domains) as $translation) {
// Sort by translation key.
$translations[$translation->getKeyword()][$translation->getLocale()] = $translation;
}
return $translations;
} | [
"public",
"function",
"getTranslations",
"(",
"ExportCommand",
"$",
"exportCommand",
")",
"{",
"$",
"locales",
"=",
"$",
"this",
"->",
"determineLocalesToImport",
"(",
"$",
"exportCommand",
")",
";",
"$",
"domains",
"=",
"$",
"this",
"->",
"determineDomainsToImp... | Convert an exportCommand into an array of translations
@param ExportCommand $exportCommand
@return array an array of translations | [
"Convert",
"an",
"exportCommand",
"into",
"an",
"array",
"of",
"translations"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php#L67-L80 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php | ExportCommandHandler.getExportFiles | public function getExportFiles(ExportCommand $exportCommand)
{
$locales = $this->determineLocalesToImport($exportCommand);
$domains = $this->determineDomainsToImport($exportCommand);
$translations = $this->translationRepository->getTranslationsByLocalesAndDomains($locales, $domains);
$translationFiles = new ArrayCollection();
/** @var Translation $translation */
foreach ($translations as $translation) {
$exportFileKey = $translation->getDomain() . '.' . $translation->getLocale() . '.' . $exportCommand->getFormat();
if (!$translationFiles->containsKey($exportFileKey)) {
$exportFile = new ExportFile();
$exportFile->setExtension($exportCommand->getFormat());
$exportFile->setDomain($translation->getDomain());
$exportFile->setLocale($translation->getLocale());
$translationFiles->set($exportFileKey, $exportFile);
}
$translationFiles->get($exportFileKey)->addTranslation($translation);
}
return $translationFiles;
} | php | public function getExportFiles(ExportCommand $exportCommand)
{
$locales = $this->determineLocalesToImport($exportCommand);
$domains = $this->determineDomainsToImport($exportCommand);
$translations = $this->translationRepository->getTranslationsByLocalesAndDomains($locales, $domains);
$translationFiles = new ArrayCollection();
/** @var Translation $translation */
foreach ($translations as $translation) {
$exportFileKey = $translation->getDomain() . '.' . $translation->getLocale() . '.' . $exportCommand->getFormat();
if (!$translationFiles->containsKey($exportFileKey)) {
$exportFile = new ExportFile();
$exportFile->setExtension($exportCommand->getFormat());
$exportFile->setDomain($translation->getDomain());
$exportFile->setLocale($translation->getLocale());
$translationFiles->set($exportFileKey, $exportFile);
}
$translationFiles->get($exportFileKey)->addTranslation($translation);
}
return $translationFiles;
} | [
"public",
"function",
"getExportFiles",
"(",
"ExportCommand",
"$",
"exportCommand",
")",
"{",
"$",
"locales",
"=",
"$",
"this",
"->",
"determineLocalesToImport",
"(",
"$",
"exportCommand",
")",
";",
"$",
"domains",
"=",
"$",
"this",
"->",
"determineDomainsToImpo... | Convert an exportCommand into an array of ExportFiles
@param ExportCommand $exportCommand
@return ArrayCollection an array of ExportFiles (without filecontent filled in) | [
"Convert",
"an",
"exportCommand",
"into",
"an",
"array",
"of",
"ExportFiles"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Exporter/ExportCommandHandler.php#L89-L114 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionDefinition.php | PermissionDefinition.setPermissions | public function setPermissions(array $permissions)
{
if (!is_array($permissions) || empty($permissions)) {
throw new InvalidArgumentException('You have to provide at least one permission!');
}
$this->permissions = $permissions;
} | php | public function setPermissions(array $permissions)
{
if (!is_array($permissions) || empty($permissions)) {
throw new InvalidArgumentException('You have to provide at least one permission!');
}
$this->permissions = $permissions;
} | [
"public",
"function",
"setPermissions",
"(",
"array",
"$",
"permissions",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"permissions",
")",
"||",
"empty",
"(",
"$",
"permissions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'You have t... | Set permissions.
@param array $permissions
@throws InvalidArgumentException | [
"Set",
"permissions",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/PermissionDefinition.php#L90-L96 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/MultiDomainBundle/Helper/HostOverrideCleanupHandler.php | HostOverrideCleanupHandler.logout | public function logout(Request $request, Response $response, TokenInterface $token)
{
// Remove host override
if ($request->hasPreviousSession() && $request->getSession()->has(DomainConfiguration::OVERRIDE_HOST)) {
$request->getSession()->remove(DomainConfiguration::OVERRIDE_HOST);
}
} | php | public function logout(Request $request, Response $response, TokenInterface $token)
{
// Remove host override
if ($request->hasPreviousSession() && $request->getSession()->has(DomainConfiguration::OVERRIDE_HOST)) {
$request->getSession()->remove(DomainConfiguration::OVERRIDE_HOST);
}
} | [
"public",
"function",
"logout",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"// Remove host override",
"if",
"(",
"$",
"request",
"->",
"hasPreviousSession",
"(",
")",
"&&",
"$",
"request",
... | This method is called by the LogoutListener when a user has requested
to be logged out. Usually, you would unset session variables, or remove
cookies, etc.
@param Request $request
@param Response $response
@param TokenInterface $token | [
"This",
"method",
"is",
"called",
"by",
"the",
"LogoutListener",
"when",
"a",
"user",
"has",
"requested",
"to",
"be",
"logged",
"out",
".",
"Usually",
"you",
"would",
"unset",
"session",
"variables",
"or",
"remove",
"cookies",
"etc",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MultiDomainBundle/Helper/HostOverrideCleanupHandler.php#L21-L27 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php | ImportCommandHandler.executeImportCommand | public function executeImportCommand(ImportCommand $importCommand)
{
if ($importCommand->getGlobals() || $importCommand->getDefaultBundle() === false || $importCommand->getDefaultBundle() === null) {
return $this->importGlobalTranslationFiles($importCommand);
}
return $this->importBundleTranslationFiles($importCommand);
} | php | public function executeImportCommand(ImportCommand $importCommand)
{
if ($importCommand->getGlobals() || $importCommand->getDefaultBundle() === false || $importCommand->getDefaultBundle() === null) {
return $this->importGlobalTranslationFiles($importCommand);
}
return $this->importBundleTranslationFiles($importCommand);
} | [
"public",
"function",
"executeImportCommand",
"(",
"ImportCommand",
"$",
"importCommand",
")",
"{",
"if",
"(",
"$",
"importCommand",
"->",
"getGlobals",
"(",
")",
"||",
"$",
"importCommand",
"->",
"getDefaultBundle",
"(",
")",
"===",
"false",
"||",
"$",
"impor... | Execute an import command
@param ImportCommand $importCommand
@return int total number of files imported | [
"Execute",
"an",
"import",
"command"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php#L38-L45 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php | ImportCommandHandler.importGlobalTranslationFiles | private function importGlobalTranslationFiles(ImportCommand $importCommand)
{
$baseDir = Kernel::VERSION_ID >= 40000 ? $this->kernel->getProjectDir() : $this->kernel->getRootDir();
$translationsDir = Kernel::VERSION_ID >= 40000 ? 'translations' : null;
$locales = $this->determineLocalesToImport($importCommand);
$finder = $this->translationFileExplorer->find($baseDir, $locales, $translationsDir);
return $this->importTranslationFiles($finder, $importCommand->getForce());
} | php | private function importGlobalTranslationFiles(ImportCommand $importCommand)
{
$baseDir = Kernel::VERSION_ID >= 40000 ? $this->kernel->getProjectDir() : $this->kernel->getRootDir();
$translationsDir = Kernel::VERSION_ID >= 40000 ? 'translations' : null;
$locales = $this->determineLocalesToImport($importCommand);
$finder = $this->translationFileExplorer->find($baseDir, $locales, $translationsDir);
return $this->importTranslationFiles($finder, $importCommand->getForce());
} | [
"private",
"function",
"importGlobalTranslationFiles",
"(",
"ImportCommand",
"$",
"importCommand",
")",
"{",
"$",
"baseDir",
"=",
"Kernel",
"::",
"VERSION_ID",
">=",
"40000",
"?",
"$",
"this",
"->",
"kernel",
"->",
"getProjectDir",
"(",
")",
":",
"$",
"this",
... | Import all translation files from app resources
@param ImportCommand $importCommand
@return int total number of files imported | [
"Import",
"all",
"translation",
"files",
"from",
"app",
"resources"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php#L54-L62 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php | ImportCommandHandler.importBundleTranslationFiles | public function importBundleTranslationFiles(ImportCommand $importCommand)
{
$importBundle = strtolower($importCommand->getDefaultBundle());
if ($importBundle == 'all') {
$importCount = $this->importAllBundlesTranslationFiles($importCommand);
if (Kernel::VERSION_ID >= 40000) {
$importCount += $this->importSf4TranslationFiles($importCommand);
}
return $importCount;
} elseif ($importBundle == 'custom') {
return $this->importCustomBundlesTranslationFiles($importCommand);
} else {
if (Kernel::VERSION_ID >= 40000) {
return $this->importSf4TranslationFiles($importCommand);
}
return $this->importOwnBundlesTranslationFiles($importCommand);
}
} | php | public function importBundleTranslationFiles(ImportCommand $importCommand)
{
$importBundle = strtolower($importCommand->getDefaultBundle());
if ($importBundle == 'all') {
$importCount = $this->importAllBundlesTranslationFiles($importCommand);
if (Kernel::VERSION_ID >= 40000) {
$importCount += $this->importSf4TranslationFiles($importCommand);
}
return $importCount;
} elseif ($importBundle == 'custom') {
return $this->importCustomBundlesTranslationFiles($importCommand);
} else {
if (Kernel::VERSION_ID >= 40000) {
return $this->importSf4TranslationFiles($importCommand);
}
return $this->importOwnBundlesTranslationFiles($importCommand);
}
} | [
"public",
"function",
"importBundleTranslationFiles",
"(",
"ImportCommand",
"$",
"importCommand",
")",
"{",
"$",
"importBundle",
"=",
"strtolower",
"(",
"$",
"importCommand",
"->",
"getDefaultBundle",
"(",
")",
")",
";",
"if",
"(",
"$",
"importBundle",
"==",
"'a... | Import all translation files from a specific bundle, bundle name will be lowercased so cases don't matter
@param ImportCommand $importCommand
@return int total number of files imported | [
"Import",
"all",
"translation",
"files",
"from",
"a",
"specific",
"bundle",
"bundle",
"name",
"will",
"be",
"lowercased",
"so",
"cases",
"don",
"t",
"matter"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php#L71-L92 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php | ImportCommandHandler.importCustomBundlesTranslationFiles | private function importCustomBundlesTranslationFiles(ImportCommand $importCommand)
{
$imported = 0;
foreach ($importCommand->getBundles() as $bundle) {
$importCommand->setDefaultBundle(strtolower($bundle));
try {
$imported += $this->importSingleBundleTranslationFiles($importCommand);
} catch (TranslationsNotFoundException $e) {
continue;
}
}
return $imported;
} | php | private function importCustomBundlesTranslationFiles(ImportCommand $importCommand)
{
$imported = 0;
foreach ($importCommand->getBundles() as $bundle) {
$importCommand->setDefaultBundle(strtolower($bundle));
try {
$imported += $this->importSingleBundleTranslationFiles($importCommand);
} catch (TranslationsNotFoundException $e) {
continue;
}
}
return $imported;
} | [
"private",
"function",
"importCustomBundlesTranslationFiles",
"(",
"ImportCommand",
"$",
"importCommand",
")",
"{",
"$",
"imported",
"=",
"0",
";",
"foreach",
"(",
"$",
"importCommand",
"->",
"getBundles",
"(",
")",
"as",
"$",
"bundle",
")",
"{",
"$",
"importC... | Import the translation files from the defined bundles.
@param ImportCommand $importCommand
@return int The total number of imported files | [
"Import",
"the",
"translation",
"files",
"from",
"the",
"defined",
"bundles",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php#L153-L168 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php | ImportCommandHandler.importSingleBundleTranslationFiles | private function importSingleBundleTranslationFiles(ImportCommand $importCommand)
{
$this->validateBundleName($importCommand->getDefaultBundle());
$bundles = array_change_key_case($this->kernel->getBundles(), CASE_LOWER);
$finder = $this->translationFileExplorer->find($bundles[strtolower($importCommand->getDefaultBundle())]->getPath(), $this->determineLocalesToImport($importCommand));
if ($finder === null) {
return 0;
}
return $this->importTranslationFiles($finder, $importCommand->getForce());
} | php | private function importSingleBundleTranslationFiles(ImportCommand $importCommand)
{
$this->validateBundleName($importCommand->getDefaultBundle());
$bundles = array_change_key_case($this->kernel->getBundles(), CASE_LOWER);
$finder = $this->translationFileExplorer->find($bundles[strtolower($importCommand->getDefaultBundle())]->getPath(), $this->determineLocalesToImport($importCommand));
if ($finder === null) {
return 0;
}
return $this->importTranslationFiles($finder, $importCommand->getForce());
} | [
"private",
"function",
"importSingleBundleTranslationFiles",
"(",
"ImportCommand",
"$",
"importCommand",
")",
"{",
"$",
"this",
"->",
"validateBundleName",
"(",
"$",
"importCommand",
"->",
"getDefaultBundle",
"(",
")",
")",
";",
"$",
"bundles",
"=",
"array_change_ke... | Import all translation files from a single bundle
@param ImportCommand $importCommand
@return int total number of files imported | [
"Import",
"all",
"translation",
"files",
"from",
"a",
"single",
"bundle"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php#L177-L188 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php | ImportCommandHandler.importTranslationFiles | private function importTranslationFiles(Finder $finder, $force = flase)
{
if (!$finder instanceof Finder) {
return false;
}
$imported = 0;
foreach ($finder as $file) {
$imported += $this->importer->import($file, $force);
}
return $imported;
} | php | private function importTranslationFiles(Finder $finder, $force = flase)
{
if (!$finder instanceof Finder) {
return false;
}
$imported = 0;
foreach ($finder as $file) {
$imported += $this->importer->import($file, $force);
}
return $imported;
} | [
"private",
"function",
"importTranslationFiles",
"(",
"Finder",
"$",
"finder",
",",
"$",
"force",
"=",
"flase",
")",
"{",
"if",
"(",
"!",
"$",
"finder",
"instanceof",
"Finder",
")",
"{",
"return",
"false",
";",
"}",
"$",
"imported",
"=",
"0",
";",
"for... | Import translation files from a specific Finder object
The finder object shoud already have the files to look for defined;
Forcing the import will override all existing translations in the stasher
@param Finder $finder
@param bool $force override identical translations in the stasher (domain/locale and keyword combination)
@return int total number of files imported | [
"Import",
"translation",
"files",
"from",
"a",
"specific",
"Finder",
"object",
"The",
"finder",
"object",
"shoud",
"already",
"have",
"the",
"files",
"to",
"look",
"for",
"defined",
";",
"Forcing",
"the",
"import",
"will",
"override",
"all",
"existing",
"trans... | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php#L200-L213 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php | ImportCommandHandler.validateBundleName | public function validateBundleName($bundle)
{
// strtolower all bundle names
$bundles = array_map('strtolower', array_keys($this->kernel->getBundles()));
if (in_array(strtolower(trim($bundle)), $bundles)) {
return true;
}
throw new \Exception(sprintf('bundle "%s" not found in available bundles: %s', $bundle, implode(', ', $bundles)));
} | php | public function validateBundleName($bundle)
{
// strtolower all bundle names
$bundles = array_map('strtolower', array_keys($this->kernel->getBundles()));
if (in_array(strtolower(trim($bundle)), $bundles)) {
return true;
}
throw new \Exception(sprintf('bundle "%s" not found in available bundles: %s', $bundle, implode(', ', $bundles)));
} | [
"public",
"function",
"validateBundleName",
"(",
"$",
"bundle",
")",
"{",
"// strtolower all bundle names",
"$",
"bundles",
"=",
"array_map",
"(",
"'strtolower'",
",",
"array_keys",
"(",
"$",
"this",
"->",
"kernel",
"->",
"getBundles",
"(",
")",
")",
")",
";",... | Validates that a bundle is registered in the AppKernel
@param string $bundle
@return bool bundle is valid or not
@throws \Exception If the bundlename isn't valid | [
"Validates",
"that",
"a",
"bundle",
"is",
"registered",
"in",
"the",
"AppKernel"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Command/Importer/ImportCommandHandler.php#L224-L234 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/Services/PageCreatorService.php | PageCreatorService.setContainer | public function setContainer(ContainerInterface $container = null)
{
$this->setEntityManager($container->get('doctrine.orm.entity_manager'));
$this->setACLPermissionCreatorService($container->get('kunstmaan_node.acl_permission_creator_service'));
$this->setUserEntityClass($container->getParameter('fos_user.model.user.class'));
} | php | public function setContainer(ContainerInterface $container = null)
{
$this->setEntityManager($container->get('doctrine.orm.entity_manager'));
$this->setACLPermissionCreatorService($container->get('kunstmaan_node.acl_permission_creator_service'));
$this->setUserEntityClass($container->getParameter('fos_user.model.user.class'));
} | [
"public",
"function",
"setContainer",
"(",
"ContainerInterface",
"$",
"container",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setEntityManager",
"(",
"$",
"container",
"->",
"get",
"(",
"'doctrine.orm.entity_manager'",
")",
")",
";",
"$",
"this",
"->",
"setACL... | Sets the Container. This is still here for backwards compatibility.
The ContainerAwareInterface has been removed so the container won't be injected automatically.
This function is just there for code that calls it manually.
@param ContainerInterface $container a ContainerInterface instance
@api | [
"Sets",
"the",
"Container",
".",
"This",
"is",
"still",
"here",
"for",
"backwards",
"compatibility",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/Services/PageCreatorService.php#L60-L65 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/PagePartBundle/PageTemplate/PageTemplateConfigurationParser.php | PageTemplateConfigurationParser.buildRegion | private function buildRegion($rawRegion)
{
$children = [];
$rows = [];
$rawRegion = array_replace(['regions' => [], 'rows' => []], $rawRegion);
foreach ($rawRegion['regions'] as $child) {
$children[] = $this->buildRegion($child);
}
foreach ($rawRegion['rows'] as $row) {
$rows[] = $this->buildRow($row);
}
$rawRegion = array_replace([
'name' => null,
'span' => 12,
'template' => null,
], $rawRegion);
return new Region($rawRegion['name'], $rawRegion['span'], $rawRegion['template'], $children, $rows);
} | php | private function buildRegion($rawRegion)
{
$children = [];
$rows = [];
$rawRegion = array_replace(['regions' => [], 'rows' => []], $rawRegion);
foreach ($rawRegion['regions'] as $child) {
$children[] = $this->buildRegion($child);
}
foreach ($rawRegion['rows'] as $row) {
$rows[] = $this->buildRow($row);
}
$rawRegion = array_replace([
'name' => null,
'span' => 12,
'template' => null,
], $rawRegion);
return new Region($rawRegion['name'], $rawRegion['span'], $rawRegion['template'], $children, $rows);
} | [
"private",
"function",
"buildRegion",
"(",
"$",
"rawRegion",
")",
"{",
"$",
"children",
"=",
"[",
"]",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"$",
"rawRegion",
"=",
"array_replace",
"(",
"[",
"'regions'",
"=>",
"[",
"]",
",",
"'rows'",
"=>",
"[",
"]... | This builds a Region out of the rawRegion from the Yaml
@param array $rawRegion
@return Region | [
"This",
"builds",
"a",
"Region",
"out",
"of",
"the",
"rawRegion",
"from",
"the",
"Yaml"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/PageTemplate/PageTemplateConfigurationParser.php#L65-L86 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/PagePartBundle/PageTemplate/PageTemplateConfigurationParser.php | PageTemplateConfigurationParser.buildRow | private function buildRow($rawRow)
{
$regions = [];
foreach ($rawRow as $region) {
$regions[] = $this->buildRegion($region);
}
return new Row($regions);
} | php | private function buildRow($rawRow)
{
$regions = [];
foreach ($rawRow as $region) {
$regions[] = $this->buildRegion($region);
}
return new Row($regions);
} | [
"private",
"function",
"buildRow",
"(",
"$",
"rawRow",
")",
"{",
"$",
"regions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rawRow",
"as",
"$",
"region",
")",
"{",
"$",
"regions",
"[",
"]",
"=",
"$",
"this",
"->",
"buildRegion",
"(",
"$",
"region",
... | This builds a Row out of the rawRow from the Yaml
@param array $rawRow
@return Row | [
"This",
"builds",
"a",
"Row",
"out",
"of",
"the",
"rawRow",
"from",
"the",
"Yaml"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/PageTemplate/PageTemplateConfigurationParser.php#L95-L104 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.addAdaptMenu | public function addAdaptMenu(MenuAdaptorInterface $adaptor, $priority = 0)
{
$this->adaptors[$priority][] = $adaptor;
unset($this->sorted);
} | php | public function addAdaptMenu(MenuAdaptorInterface $adaptor, $priority = 0)
{
$this->adaptors[$priority][] = $adaptor;
unset($this->sorted);
} | [
"public",
"function",
"addAdaptMenu",
"(",
"MenuAdaptorInterface",
"$",
"adaptor",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"adaptors",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"$",
"adaptor",
";",
"unset",
"(",
"$",
"this",
"->",
... | Add menu adaptor
@param MenuAdaptorInterface $adaptor | [
"Add",
"menu",
"adaptor"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php#L53-L57 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.getLowestTopChild | public function getLowestTopChild()
{
$current = $this->getCurrent();
while (!is_null($current)) {
if ($current instanceof TopMenuItem) {
return $current;
}
$current = $current->getParent();
}
return null;
} | php | public function getLowestTopChild()
{
$current = $this->getCurrent();
while (!is_null($current)) {
if ($current instanceof TopMenuItem) {
return $current;
}
$current = $current->getParent();
}
return null;
} | [
"public",
"function",
"getLowestTopChild",
"(",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"getCurrent",
"(",
")",
";",
"while",
"(",
"!",
"is_null",
"(",
"$",
"current",
")",
")",
"{",
"if",
"(",
"$",
"current",
"instanceof",
"TopMenuItem",
")"... | Get top parent menu of current menu item
@return TopMenuItem|null | [
"Get",
"top",
"parent",
"menu",
"of",
"current",
"menu",
"item"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php#L111-L122 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.getTopChildren | public function getTopChildren()
{
if (is_null($this->topMenuItems)) {
/* @var $request Request */
$request = $this->container->get('request_stack')->getCurrentRequest();
$this->topMenuItems = array();
foreach ($this->getAdaptors() as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $this->topMenuItems, null, $request);
}
}
return $this->topMenuItems;
} | php | public function getTopChildren()
{
if (is_null($this->topMenuItems)) {
/* @var $request Request */
$request = $this->container->get('request_stack')->getCurrentRequest();
$this->topMenuItems = array();
foreach ($this->getAdaptors() as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $this->topMenuItems, null, $request);
}
}
return $this->topMenuItems;
} | [
"public",
"function",
"getTopChildren",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"topMenuItems",
")",
")",
"{",
"/* @var $request Request */",
"$",
"request",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request_stack'",
")",
... | Get all top menu items
@return MenuItem[] | [
"Get",
"all",
"top",
"menu",
"items"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php#L129-L141 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.getChildren | public function getChildren(MenuItem $parent = null)
{
if ($parent === null) {
return $this->getTopChildren();
}
/* @var $request Request */
$request = $this->container->get('request_stack')->getCurrentRequest();
$result = array();
foreach ($this->getAdaptors() as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $result, $parent, $request);
}
return $result;
} | php | public function getChildren(MenuItem $parent = null)
{
if ($parent === null) {
return $this->getTopChildren();
}
/* @var $request Request */
$request = $this->container->get('request_stack')->getCurrentRequest();
$result = array();
foreach ($this->getAdaptors() as $menuAdaptor) {
$menuAdaptor->adaptChildren($this, $result, $parent, $request);
}
return $result;
} | [
"public",
"function",
"getChildren",
"(",
"MenuItem",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parent",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getTopChildren",
"(",
")",
";",
"}",
"/* @var $request Request */",
"$",
"request",... | Get immediate children of the specified menu item
@param MenuItem $parent
@return MenuItem[] | [
"Get",
"immediate",
"children",
"of",
"the",
"specified",
"menu",
"item"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php#L150-L163 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php | MenuBuilder.sortAdaptors | private function sortAdaptors()
{
$this->sorted = array();
if (isset($this->adaptors)) {
krsort($this->adaptors);
$this->sorted = call_user_func_array('array_merge', $this->adaptors);
}
} | php | private function sortAdaptors()
{
$this->sorted = array();
if (isset($this->adaptors)) {
krsort($this->adaptors);
$this->sorted = call_user_func_array('array_merge', $this->adaptors);
}
} | [
"private",
"function",
"sortAdaptors",
"(",
")",
"{",
"$",
"this",
"->",
"sorted",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"adaptors",
")",
")",
"{",
"krsort",
"(",
"$",
"this",
"->",
"adaptors",
")",
";",
"$",
"t... | Sorts the internal list of adaptors by priority. | [
"Sorts",
"the",
"internal",
"list",
"of",
"adaptors",
"by",
"priority",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Menu/MenuBuilder.php#L177-L185 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Repository/NodeRepository.php | NodeRepository.getAllMenuNodes | public function getAllMenuNodes(
$lang,
$permission,
AclNativeHelper $aclNativeHelper,
$includeHiddenFromNav = false,
Node $rootNode = null
) {
$connection = $this->_em->getConnection();
$qb = $connection->createQueryBuilder();
$databasePlatformName = $connection->getDatabasePlatform()->getName();
$createIfStatement = function (
$expression,
$trueValue,
$falseValue
) use ($databasePlatformName) {
switch ($databasePlatformName) {
case 'sqlite':
$statement = 'CASE WHEN %s THEN %s ELSE %s END';
break;
default:
$statement = 'IF(%s, %s, %s)';
}
return sprintf($statement, $expression, $trueValue, $falseValue);
};
$sql = <<<SQL
n.id, n.parent_id AS parent, t.url, t.id AS nt_id,
{$createIfStatement('t.weight IS NULL', 'v.weight', 't.weight')} AS weight,
{$createIfStatement('t.title IS NULL', 'v.title', 't.title')} AS title,
{$createIfStatement('t.online IS NULL', '0', 't.online')} AS online,
n.hidden_from_nav AS hidden,
n.ref_entity_name AS ref_entity_name
SQL;
$qb->select($sql)
->from('kuma_nodes', 'n')
->leftJoin(
'n',
'kuma_node_translations',
't',
'(t.node_id = n.id AND t.lang = :lang)'
)
->leftJoin(
'n',
'kuma_node_translations',
'v',
'(v.node_id = n.id AND v.lang <> :lang)'
)
->where('n.deleted = 0')
->addGroupBy('n.id')
->addOrderBy('t.weight', 'ASC')
->addOrderBy('t.title', 'ASC');
if (!$includeHiddenFromNav) {
$qb->andWhere('n.hidden_from_nav <> 0');
}
if (!is_null($rootNode)) {
$qb->andWhere('n.lft >= :left')
->andWhere('n.rgt <= :right');
}
$permissionDef = new PermissionDefinition(array($permission));
$permissionDef->setEntity('Kunstmaan\NodeBundle\Entity\Node');
$permissionDef->setAlias('n');
$qb = $aclNativeHelper->apply($qb, $permissionDef);
$stmt = $this->_em->getConnection()->prepare($qb->getSQL());
$stmt->bindValue(':lang', $lang);
if (!is_null($rootNode)) {
$stmt->bindValue(':left', $rootNode->getLeft());
$stmt->bindValue(':right', $rootNode->getRight());
}
$stmt->execute();
return $stmt->fetchAll();
} | php | public function getAllMenuNodes(
$lang,
$permission,
AclNativeHelper $aclNativeHelper,
$includeHiddenFromNav = false,
Node $rootNode = null
) {
$connection = $this->_em->getConnection();
$qb = $connection->createQueryBuilder();
$databasePlatformName = $connection->getDatabasePlatform()->getName();
$createIfStatement = function (
$expression,
$trueValue,
$falseValue
) use ($databasePlatformName) {
switch ($databasePlatformName) {
case 'sqlite':
$statement = 'CASE WHEN %s THEN %s ELSE %s END';
break;
default:
$statement = 'IF(%s, %s, %s)';
}
return sprintf($statement, $expression, $trueValue, $falseValue);
};
$sql = <<<SQL
n.id, n.parent_id AS parent, t.url, t.id AS nt_id,
{$createIfStatement('t.weight IS NULL', 'v.weight', 't.weight')} AS weight,
{$createIfStatement('t.title IS NULL', 'v.title', 't.title')} AS title,
{$createIfStatement('t.online IS NULL', '0', 't.online')} AS online,
n.hidden_from_nav AS hidden,
n.ref_entity_name AS ref_entity_name
SQL;
$qb->select($sql)
->from('kuma_nodes', 'n')
->leftJoin(
'n',
'kuma_node_translations',
't',
'(t.node_id = n.id AND t.lang = :lang)'
)
->leftJoin(
'n',
'kuma_node_translations',
'v',
'(v.node_id = n.id AND v.lang <> :lang)'
)
->where('n.deleted = 0')
->addGroupBy('n.id')
->addOrderBy('t.weight', 'ASC')
->addOrderBy('t.title', 'ASC');
if (!$includeHiddenFromNav) {
$qb->andWhere('n.hidden_from_nav <> 0');
}
if (!is_null($rootNode)) {
$qb->andWhere('n.lft >= :left')
->andWhere('n.rgt <= :right');
}
$permissionDef = new PermissionDefinition(array($permission));
$permissionDef->setEntity('Kunstmaan\NodeBundle\Entity\Node');
$permissionDef->setAlias('n');
$qb = $aclNativeHelper->apply($qb, $permissionDef);
$stmt = $this->_em->getConnection()->prepare($qb->getSQL());
$stmt->bindValue(':lang', $lang);
if (!is_null($rootNode)) {
$stmt->bindValue(':left', $rootNode->getLeft());
$stmt->bindValue(':right', $rootNode->getRight());
}
$stmt->execute();
return $stmt->fetchAll();
} | [
"public",
"function",
"getAllMenuNodes",
"(",
"$",
"lang",
",",
"$",
"permission",
",",
"AclNativeHelper",
"$",
"aclNativeHelper",
",",
"$",
"includeHiddenFromNav",
"=",
"false",
",",
"Node",
"$",
"rootNode",
"=",
"null",
")",
"{",
"$",
"connection",
"=",
"$... | Get all the information needed to build a menu tree with one query.
We only fetch the fields we need, instead of fetching full objects to
limit the memory usage.
@param string $lang The locale
@param string $permission The permission (read,
write, ...)
@param AclNativeHelper $aclNativeHelper The acl helper
@param bool $includeHiddenFromNav Include nodes hidden from
navigation or not
@param Node $rootNode The root node of the
current site
@return array | [
"Get",
"all",
"the",
"information",
"needed",
"to",
"build",
"a",
"menu",
"tree",
"with",
"one",
"query",
".",
"We",
"only",
"fetch",
"the",
"fields",
"we",
"need",
"instead",
"of",
"fetching",
"full",
"objects",
"to",
"limit",
"the",
"memory",
"usage",
... | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php#L267-L346 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Repository/NodeRepository.php | NodeRepository.getAllParents | public function getAllParents(Node $node = null, $lang = null)
{
if (is_null($node)) {
return array();
}
$qb = $this->createQueryBuilder('node');
// Directly hydrate the nodeTranslation and nodeVersion
$qb->select('node', 't', 'v')
->innerJoin('node.nodeTranslations', 't')
->leftJoin(
't.publicNodeVersion',
'v',
'WITH',
't.publicNodeVersion = v.id'
)
->where('node.deleted = 0');
if ($lang) {
$qb->andWhere('t.lang = :lang')
->setParameter('lang', $lang);
}
$qb->andWhere(
$qb->expr()->andX(
$qb->expr()->lte('node.lft', $node->getLeft()),
$qb->expr()->gte('node.rgt', $node->getRight())
)
);
$qb->addOrderBy('node.lft', 'ASC');
return $qb->getQuery()->getResult();
} | php | public function getAllParents(Node $node = null, $lang = null)
{
if (is_null($node)) {
return array();
}
$qb = $this->createQueryBuilder('node');
// Directly hydrate the nodeTranslation and nodeVersion
$qb->select('node', 't', 'v')
->innerJoin('node.nodeTranslations', 't')
->leftJoin(
't.publicNodeVersion',
'v',
'WITH',
't.publicNodeVersion = v.id'
)
->where('node.deleted = 0');
if ($lang) {
$qb->andWhere('t.lang = :lang')
->setParameter('lang', $lang);
}
$qb->andWhere(
$qb->expr()->andX(
$qb->expr()->lte('node.lft', $node->getLeft()),
$qb->expr()->gte('node.rgt', $node->getRight())
)
);
$qb->addOrderBy('node.lft', 'ASC');
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"getAllParents",
"(",
"Node",
"$",
"node",
"=",
"null",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"node",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"qb",
"=",
"$",
"this",
"-... | Get all parents of a given node. We can go multiple levels up.
@param Node $node
@param string $lang
@return Node[] | [
"Get",
"all",
"parents",
"of",
"a",
"given",
"node",
".",
"We",
"can",
"go",
"multiple",
"levels",
"up",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php#L356-L390 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Repository/NodeRepository.php | NodeRepository.getNodesByInternalName | public function getNodesByInternalName(
$internalName,
$lang,
$parentId = false,
$includeOffline = false
) {
$qb = $this->createQueryBuilder('n')
->select('n', 't', 'v')
->innerJoin('n.nodeTranslations', 't')
->leftJoin(
't.publicNodeVersion',
'v',
'WITH',
't.publicNodeVersion = v.id'
)
->where('n.deleted = 0')
->andWhere('n.internalName = :internalName')
->setParameter('internalName', $internalName)
->andWhere('t.lang = :lang')
->setParameter('lang', $lang)
->addOrderBy('t.weight', 'ASC')
->addOrderBy('t.title', 'ASC');
if (!$includeOffline) {
$qb->andWhere('t.online = true');
}
if (is_null($parentId)) {
$qb->andWhere('n.parent is NULL');
} elseif ($parentId === false) {
// Do nothing
} else {
$qb->andWhere('n.parent = :parent')
->setParameter('parent', $parentId);
}
$query = $qb->getQuery();
return $query->getResult();
} | php | public function getNodesByInternalName(
$internalName,
$lang,
$parentId = false,
$includeOffline = false
) {
$qb = $this->createQueryBuilder('n')
->select('n', 't', 'v')
->innerJoin('n.nodeTranslations', 't')
->leftJoin(
't.publicNodeVersion',
'v',
'WITH',
't.publicNodeVersion = v.id'
)
->where('n.deleted = 0')
->andWhere('n.internalName = :internalName')
->setParameter('internalName', $internalName)
->andWhere('t.lang = :lang')
->setParameter('lang', $lang)
->addOrderBy('t.weight', 'ASC')
->addOrderBy('t.title', 'ASC');
if (!$includeOffline) {
$qb->andWhere('t.online = true');
}
if (is_null($parentId)) {
$qb->andWhere('n.parent is NULL');
} elseif ($parentId === false) {
// Do nothing
} else {
$qb->andWhere('n.parent = :parent')
->setParameter('parent', $parentId);
}
$query = $qb->getQuery();
return $query->getResult();
} | [
"public",
"function",
"getNodesByInternalName",
"(",
"$",
"internalName",
",",
"$",
"lang",
",",
"$",
"parentId",
"=",
"false",
",",
"$",
"includeOffline",
"=",
"false",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'n'",
")",
... | Get an array of Nodes based on the internal name.
@param string $internalName The internal name of the node
@param string $lang The locale
@param int|null|bool $parentId The parent id
@param bool $includeOffline Include offline nodes
@return Node[] | [
"Get",
"an",
"array",
"of",
"Nodes",
"based",
"on",
"the",
"internal",
"name",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php#L467-L506 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Repository/NodeRepository.php | NodeRepository.getNodeByInternalName | public function getNodeByInternalName($internalName)
{
$qb = $this->createQueryBuilder('n')
->select('n')
->where('n.deleted = 0')
->andWhere('n.internalName = :internalName')
->setParameter('internalName', $internalName);
return $qb->getQuery()->getOneOrNullResult();
} | php | public function getNodeByInternalName($internalName)
{
$qb = $this->createQueryBuilder('n')
->select('n')
->where('n.deleted = 0')
->andWhere('n.internalName = :internalName')
->setParameter('internalName', $internalName);
return $qb->getQuery()->getOneOrNullResult();
} | [
"public",
"function",
"getNodeByInternalName",
"(",
"$",
"internalName",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'n'",
")",
"->",
"select",
"(",
"'n'",
")",
"->",
"where",
"(",
"'n.deleted = 0'",
")",
"->",
"andWhere",
"(",... | Get a single node by internal name.
@param string $internalName The internal name of the node
@return Node | [
"Get",
"a",
"single",
"node",
"by",
"internal",
"name",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php#L515-L524 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Repository/NodeRepository.php | NodeRepository.findAllDistinctPageClasses | public function findAllDistinctPageClasses()
{
$qb = $this->createQueryBuilder('n')
->select('n.refEntityName')
->where('n.deleted = 0')
->distinct(true);
return $qb->getQuery()->getArrayResult();
} | php | public function findAllDistinctPageClasses()
{
$qb = $this->createQueryBuilder('n')
->select('n.refEntityName')
->where('n.deleted = 0')
->distinct(true);
return $qb->getQuery()->getArrayResult();
} | [
"public",
"function",
"findAllDistinctPageClasses",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'n'",
")",
"->",
"select",
"(",
"'n.refEntityName'",
")",
"->",
"where",
"(",
"'n.deleted = 0'",
")",
"->",
"distinct",
"(",
"tr... | Finds all different page classes currently registered as nodes
@return string[] | [
"Finds",
"all",
"different",
"page",
"classes",
"currently",
"registered",
"as",
"nodes"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeRepository.php#L531-L539 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php | PagePartCreatorService.setEntityManager | public function setEntityManager(EntityManagerInterface $em)
{
$this->em = $em;
// Because these repositories are shared between the different functions it's
// easier to make them available in the class.
$this->pagePartRepo = $em->getRepository('KunstmaanPagePartBundle:PagePartRef');
$this->translationRepo = $em->getRepository('KunstmaanNodeBundle:NodeTranslation');
$this->nodeRepo = $em->getRepository('KunstmaanNodeBundle:Node');
} | php | public function setEntityManager(EntityManagerInterface $em)
{
$this->em = $em;
// Because these repositories are shared between the different functions it's
// easier to make them available in the class.
$this->pagePartRepo = $em->getRepository('KunstmaanPagePartBundle:PagePartRef');
$this->translationRepo = $em->getRepository('KunstmaanNodeBundle:NodeTranslation');
$this->nodeRepo = $em->getRepository('KunstmaanNodeBundle:Node');
} | [
"public",
"function",
"setEntityManager",
"(",
"EntityManagerInterface",
"$",
"em",
")",
"{",
"$",
"this",
"->",
"em",
"=",
"$",
"em",
";",
"// Because these repositories are shared between the different functions it's",
"// easier to make them available in the class.",
"$",
... | Sets the EntityManager dependency.
@param EntityManagerInterface $em | [
"Sets",
"the",
"EntityManager",
"dependency",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php#L51-L59 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php | PagePartCreatorService.addPagePartToPage | public function addPagePartToPage($nodeOrInternalName, PagePartInterface $pagePart, $language, $context = 'main', $position = null)
{
// Find the correct page instance.
$node = $this->getNode($nodeOrInternalName);
/** @var $translation NodeTranslation */
$translation = $node->getNodeTranslation($language, true);
/** @var HasPagePartsInterface $page */
$page = $translation->getRef($this->em);
// Find latest position.
if (is_null($position)) {
$pageParts = $this->pagePartRepo->getPagePartRefs($page, $context);
$position = count($pageParts) + 1;
}
$this->em->persist($pagePart);
$this->em->flush();
$this->pagePartRepo->addPagePart($page, $pagePart, $position, $context);
} | php | public function addPagePartToPage($nodeOrInternalName, PagePartInterface $pagePart, $language, $context = 'main', $position = null)
{
// Find the correct page instance.
$node = $this->getNode($nodeOrInternalName);
/** @var $translation NodeTranslation */
$translation = $node->getNodeTranslation($language, true);
/** @var HasPagePartsInterface $page */
$page = $translation->getRef($this->em);
// Find latest position.
if (is_null($position)) {
$pageParts = $this->pagePartRepo->getPagePartRefs($page, $context);
$position = count($pageParts) + 1;
}
$this->em->persist($pagePart);
$this->em->flush();
$this->pagePartRepo->addPagePart($page, $pagePart, $position, $context);
} | [
"public",
"function",
"addPagePartToPage",
"(",
"$",
"nodeOrInternalName",
",",
"PagePartInterface",
"$",
"pagePart",
",",
"$",
"language",
",",
"$",
"context",
"=",
"'main'",
",",
"$",
"position",
"=",
"null",
")",
"{",
"// Find the correct page instance.",
"$",
... | Add a single pagepart to an existing page for a specific language, in an optional position.
@param mixed(Node|string) $nodeOrInternalName
A Node instance or the internal name.
When the internal name is passed we'll get the node instance.
Based on the language we'll locate the correct Page instance.
@param pagePartInterface $pagePart
A completely configured pagepart for this language
@param string $language
The languagecode. nl|fr|en|.. . Just one.
@param string $context
Where you want the pagepart to be
@param mixed(integer\NULL) $position
Leave null if you want to append at the end.
Otherwise set a position you would like and it'll inject the pagepart in that position.
It won't override pageparts but it will rather inject itself in that position and
push the other pageparts down. | [
"Add",
"a",
"single",
"pagepart",
"to",
"an",
"existing",
"page",
"for",
"a",
"specific",
"language",
"in",
"an",
"optional",
"position",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php#L88-L107 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php | PagePartCreatorService.addPagePartsToPage | public function addPagePartsToPage($nodeOrInternalName, array $structure, $language)
{
$node = $this->getNode($nodeOrInternalName);
// First instantiate all PageParts. This way no PageParts will be saved if there is an issue instantiating some of them.
$instantiatedPageParts = array();
foreach ($structure as $context => $pageParts) {
$instantiatedPageParts[$context] = array();
foreach ($pageParts as $pagePartOrFunction) {
if (is_callable($pagePartOrFunction)) {
$pagePartOrFunction = $pagePartOrFunction();
if (!isset($pagePartOrFunction) || (is_null($pagePartOrFunction))) {
throw new \LogicException('A function returned nothing for a pagepart. Make sure you return your instantiated pageparts in your anonymous functions.');
}
}
if (!$pagePartOrFunction instanceof PagePartInterface) {
throw new \LogicException('Detected a supposed pagepart that did not implement the PagePartInterface.');
}
$instantiatedPageParts[$context][] = $pagePartOrFunction;
}
}
// All good. We can start saving.
foreach ($instantiatedPageParts as $context => $pageParts) {
foreach ($pageParts as $pagePart) {
$this->addPagePartToPage($node, $pagePart, $language, $context);
}
}
} | php | public function addPagePartsToPage($nodeOrInternalName, array $structure, $language)
{
$node = $this->getNode($nodeOrInternalName);
// First instantiate all PageParts. This way no PageParts will be saved if there is an issue instantiating some of them.
$instantiatedPageParts = array();
foreach ($structure as $context => $pageParts) {
$instantiatedPageParts[$context] = array();
foreach ($pageParts as $pagePartOrFunction) {
if (is_callable($pagePartOrFunction)) {
$pagePartOrFunction = $pagePartOrFunction();
if (!isset($pagePartOrFunction) || (is_null($pagePartOrFunction))) {
throw new \LogicException('A function returned nothing for a pagepart. Make sure you return your instantiated pageparts in your anonymous functions.');
}
}
if (!$pagePartOrFunction instanceof PagePartInterface) {
throw new \LogicException('Detected a supposed pagepart that did not implement the PagePartInterface.');
}
$instantiatedPageParts[$context][] = $pagePartOrFunction;
}
}
// All good. We can start saving.
foreach ($instantiatedPageParts as $context => $pageParts) {
foreach ($pageParts as $pagePart) {
$this->addPagePartToPage($node, $pagePart, $language, $context);
}
}
} | [
"public",
"function",
"addPagePartsToPage",
"(",
"$",
"nodeOrInternalName",
",",
"array",
"$",
"structure",
",",
"$",
"language",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"nodeOrInternalName",
")",
";",
"// First instantiate all PagePa... | A helper function to more easily append multiple pageparts in different manners.
@param mixed(Node|string) $nodeOrInternalName
The node that you'd like to append the pageparts to. It's also possible to provide an internalname.
@param array $structure
The structure array is something like this:
array('main' => array(
function() { return new DummyPagePart('A') }, function() { return new DummyPagePart('B') }
), 'banners' => array($awesomeBanner));
So it's an array containing the pageparts per region. Each pagepart is returned by a function.
This is clean because we don't have to bother with variablenames which we have to remember to pass
to the pagecreatorservice at the right time. With this method it's impossible to assign a wrong pagepart to a page.
Unless you provide the incorrect page oviously ... .
You can also include variables in the pagepart arrays if you want.
Or optionally you can use the results of the getCreatorArgumentsForPagePartAndProperties function instead of an anonymous function.
@param string $language
The language of the translation you want to append to
@throws \LogicException | [
"A",
"helper",
"function",
"to",
"more",
"easily",
"append",
"multiple",
"pageparts",
"in",
"different",
"manners",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php#L134-L165 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php | PagePartCreatorService.getCreatorArgumentsForPagePartAndProperties | public function getCreatorArgumentsForPagePartAndProperties($pagePartClassName, array $setters = null)
{
return function () use ($pagePartClassName, $setters) {
$pp = new $pagePartClassName();
if (!is_null($setters)) {
foreach ($setters as $setter => $value) {
call_user_func(array($pp, $setter), $value);
}
}
return $pp;
};
} | php | public function getCreatorArgumentsForPagePartAndProperties($pagePartClassName, array $setters = null)
{
return function () use ($pagePartClassName, $setters) {
$pp = new $pagePartClassName();
if (!is_null($setters)) {
foreach ($setters as $setter => $value) {
call_user_func(array($pp, $setter), $value);
}
}
return $pp;
};
} | [
"public",
"function",
"getCreatorArgumentsForPagePartAndProperties",
"(",
"$",
"pagePartClassName",
",",
"array",
"$",
"setters",
"=",
"null",
")",
"{",
"return",
"function",
"(",
")",
"use",
"(",
"$",
"pagePartClassName",
",",
"$",
"setters",
")",
"{",
"$",
"... | A helper function to express what pagepart you want.
It just accepts a classname and an array of setter functions with their requested values.
It'll return an anonymous function which instantiates the pagepart.
@param string $pagePartClassName the full class name of the pagepart you want to instantiate
@param array $setters An array of setternames and their values. array('setName' => 'Kim', 'isDeveloper' => true)
@return callable the function that will instantiate a pagepart | [
"A",
"helper",
"function",
"to",
"express",
"what",
"pagepart",
"you",
"want",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/Helper/Services/PagePartCreatorService.php#L208-L221 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php | KunstmaanGenerateCommand.setInputAndOutput | private function setInputAndOutput(InputInterface $input, OutputInterface $output)
{
if (is_null($this->assistant)) {
$this->assistant = new CommandAssistant();
$this->assistant->setQuestionHelper($this->getQuestionHelper());
$this->assistant->setKernel($this->getApplication()->getKernel());
}
$this->assistant->setOutput($output);
$this->assistant->setInput($input);
} | php | private function setInputAndOutput(InputInterface $input, OutputInterface $output)
{
if (is_null($this->assistant)) {
$this->assistant = new CommandAssistant();
$this->assistant->setQuestionHelper($this->getQuestionHelper());
$this->assistant->setKernel($this->getApplication()->getKernel());
}
$this->assistant->setOutput($output);
$this->assistant->setInput($input);
} | [
"private",
"function",
"setInputAndOutput",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"assistant",
")",
")",
"{",
"$",
"this",
"->",
"assistant",
"=",
"new",
"Command... | Create the CommandAssistant.
@param InputInterface $input
@param OutputInterface $output | [
"Create",
"the",
"CommandAssistant",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php#L72-L81 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php | KunstmaanGenerateCommand.askForBundleName | protected function askForBundleName(
$objectName,
$namespace = null,
$questionMoreBundles = "\nIn which bundle do you want to create the %s",
$questionOneBundle = "The %s will be created for the <comment>%s</comment> bundle.\n"
) {
if (Kernel::VERSION_ID >= 40000) {
return new Sf4AppBundle($this->getContainer()->getParameter('kernel.project_dir'));
}
$ownBundles = $this->getOwnBundles();
if (count($ownBundles) <= 0) {
$this->assistant->writeError("Looks like you don't have created any bundles for your project...", true);
}
// If the user provided the namespace as input option
if (!is_null($namespace)) {
foreach ($ownBundles as $key => $bundleInfo) {
if (GeneratorUtils::fixNamespace($namespace) == GeneratorUtils::fixNamespace(
$bundleInfo['namespace']
)
) {
$bundleName = $bundleInfo['name'];
break;
}
}
// When the provided namespace was not found, we show an error on the screen and ask the bundle again
if (empty($bundleName)) {
$this->assistant->writeError("The provided bundle namespace '$namespace' was not found...");
}
}
if (empty($bundleName)) {
// If we only have 1 bundle, we don't need to ask
if (count($ownBundles) > 1) {
$bundleSelect = [];
foreach ($ownBundles as $key => $bundleInfo) {
$bundleSelect[$key] = $bundleInfo['name'];
}
$bundleId = $this->assistant->askSelect(
sprintf($questionMoreBundles, $objectName),
$bundleSelect
);
$bundleName = $ownBundles[$bundleId]['name'];
$this->assistant->writeLine('');
} else {
$bundleName = $ownBundles[1]['name'];
$this->assistant->writeLine(
[sprintf($questionOneBundle, $objectName, $bundleName)]
);
}
}
$bundle = $this->assistant->getKernel()->getBundle($bundleName);
return $bundle;
} | php | protected function askForBundleName(
$objectName,
$namespace = null,
$questionMoreBundles = "\nIn which bundle do you want to create the %s",
$questionOneBundle = "The %s will be created for the <comment>%s</comment> bundle.\n"
) {
if (Kernel::VERSION_ID >= 40000) {
return new Sf4AppBundle($this->getContainer()->getParameter('kernel.project_dir'));
}
$ownBundles = $this->getOwnBundles();
if (count($ownBundles) <= 0) {
$this->assistant->writeError("Looks like you don't have created any bundles for your project...", true);
}
// If the user provided the namespace as input option
if (!is_null($namespace)) {
foreach ($ownBundles as $key => $bundleInfo) {
if (GeneratorUtils::fixNamespace($namespace) == GeneratorUtils::fixNamespace(
$bundleInfo['namespace']
)
) {
$bundleName = $bundleInfo['name'];
break;
}
}
// When the provided namespace was not found, we show an error on the screen and ask the bundle again
if (empty($bundleName)) {
$this->assistant->writeError("The provided bundle namespace '$namespace' was not found...");
}
}
if (empty($bundleName)) {
// If we only have 1 bundle, we don't need to ask
if (count($ownBundles) > 1) {
$bundleSelect = [];
foreach ($ownBundles as $key => $bundleInfo) {
$bundleSelect[$key] = $bundleInfo['name'];
}
$bundleId = $this->assistant->askSelect(
sprintf($questionMoreBundles, $objectName),
$bundleSelect
);
$bundleName = $ownBundles[$bundleId]['name'];
$this->assistant->writeLine('');
} else {
$bundleName = $ownBundles[1]['name'];
$this->assistant->writeLine(
[sprintf($questionOneBundle, $objectName, $bundleName)]
);
}
}
$bundle = $this->assistant->getKernel()->getBundle($bundleName);
return $bundle;
} | [
"protected",
"function",
"askForBundleName",
"(",
"$",
"objectName",
",",
"$",
"namespace",
"=",
"null",
",",
"$",
"questionMoreBundles",
"=",
"\"\\nIn which bundle do you want to create the %s\"",
",",
"$",
"questionOneBundle",
"=",
"\"The %s will be created for the <comment... | Ask for which bundle we need to generate something. It there is only one custom bundle
created by the user, we don't ask anything and just use that bundle. If the user provided
a namespace as input option, we try to get that bundle first.
@param string $objectName The thing we are going to create (pagepart, bundle, layout, ...)
@param string|null $namespace The namespace provided as input option
@param string $questionMoreBundles
@param string $questionOneBundle
@return BundleInterface | [
"Ask",
"for",
"which",
"bundle",
"we",
"need",
"to",
"generate",
"something",
".",
"It",
"there",
"is",
"only",
"one",
"custom",
"bundle",
"created",
"by",
"the",
"user",
"we",
"don",
"t",
"ask",
"anything",
"and",
"just",
"use",
"that",
"bundle",
".",
... | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php#L233-L292 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php | KunstmaanGenerateCommand.getAvailableSections | protected function getAvailableSections(BundleInterface $bundle, $context = null, $defaultSections = [])
{
$configs = [];
$counter = 1;
// Get the available sections from disc
$dir = Kernel::VERSION_ID >= 40000 ?
$this->getContainer()->getParameter('kernel.project_dir').'/config/kunstmaancms/pageparts/' :
$bundle->getPath().'/Resources/config/pageparts/'
;
if (file_exists($dir) && is_dir($dir)) {
$finder = new Finder();
$finder->files()->in($dir)->depth('== 0');
foreach ($finder as $file) {
$info = $this->getSectionInfo($dir, $file->getFileName());
if (is_array($info) && (is_null($context) || $info['context'] == $context)) {
$configs[$counter++] = $info;
if (array_key_exists($info['file'], $defaultSections)) {
unset($defaultSections[$info['file']]);
}
}
}
}
// Add the default sections
foreach ($defaultSections as $file => $info) {
if (is_null($context) || $info['context'] == $context) {
$configs[$counter++] = $info;
}
}
return $configs;
} | php | protected function getAvailableSections(BundleInterface $bundle, $context = null, $defaultSections = [])
{
$configs = [];
$counter = 1;
// Get the available sections from disc
$dir = Kernel::VERSION_ID >= 40000 ?
$this->getContainer()->getParameter('kernel.project_dir').'/config/kunstmaancms/pageparts/' :
$bundle->getPath().'/Resources/config/pageparts/'
;
if (file_exists($dir) && is_dir($dir)) {
$finder = new Finder();
$finder->files()->in($dir)->depth('== 0');
foreach ($finder as $file) {
$info = $this->getSectionInfo($dir, $file->getFileName());
if (is_array($info) && (is_null($context) || $info['context'] == $context)) {
$configs[$counter++] = $info;
if (array_key_exists($info['file'], $defaultSections)) {
unset($defaultSections[$info['file']]);
}
}
}
}
// Add the default sections
foreach ($defaultSections as $file => $info) {
if (is_null($context) || $info['context'] == $context) {
$configs[$counter++] = $info;
}
}
return $configs;
} | [
"protected",
"function",
"getAvailableSections",
"(",
"BundleInterface",
"$",
"bundle",
",",
"$",
"context",
"=",
"null",
",",
"$",
"defaultSections",
"=",
"[",
"]",
")",
"{",
"$",
"configs",
"=",
"[",
"]",
";",
"$",
"counter",
"=",
"1",
";",
"// Get the... | Get an array with the available page sections. We also parse the yaml files to get more information about
the sections.
@param BundleInterface $bundle The bundle for which we want to get the section configuration
@param string|null $context If provided, only return configurations with this context
@param array $defaultSections The default section configurations that are always available
@return array | [
"Get",
"an",
"array",
"with",
"the",
"available",
"page",
"sections",
".",
"We",
"also",
"parse",
"the",
"yaml",
"files",
"to",
"get",
"more",
"information",
"about",
"the",
"sections",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php#L349-L382 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php | KunstmaanGenerateCommand.getTypes | private function getTypes($niceNames = false)
{
$counter = 1;
$types = [];
$types[$counter++] = $niceNames ? 'Single line text' : 'single_line';
$types[$counter++] = $niceNames ? 'Multi line text' : 'multi_line';
$types[$counter++] = $niceNames ? 'Wysiwyg' : 'wysiwyg';
$types[$counter++] = $niceNames ? 'Link (url, text, new window)' : 'link';
if ($this->isBundleAvailable('KunstmaanMediaPagePartBundle')) {
$types[$counter++] = $niceNames ? 'Image (media, alt text)' : 'image';
$types[$counter++] = $niceNames ? 'Media (File or Video or Slideshow)' : 'media';
}
$types[$counter++] = $niceNames ? 'Single entity reference' : 'single_ref';
$types[$counter++] = $niceNames ? 'Multi entity reference' : 'multi_ref';
$types[$counter++] = $niceNames ? 'Boolean' : 'boolean';
$types[$counter++] = $niceNames ? 'Integer' : 'integer';
$types[$counter++] = $niceNames ? 'Decimal number' : 'decimal';
$types[$counter++] = $niceNames ? 'DateTime' : 'datetime';
return $types;
} | php | private function getTypes($niceNames = false)
{
$counter = 1;
$types = [];
$types[$counter++] = $niceNames ? 'Single line text' : 'single_line';
$types[$counter++] = $niceNames ? 'Multi line text' : 'multi_line';
$types[$counter++] = $niceNames ? 'Wysiwyg' : 'wysiwyg';
$types[$counter++] = $niceNames ? 'Link (url, text, new window)' : 'link';
if ($this->isBundleAvailable('KunstmaanMediaPagePartBundle')) {
$types[$counter++] = $niceNames ? 'Image (media, alt text)' : 'image';
$types[$counter++] = $niceNames ? 'Media (File or Video or Slideshow)' : 'media';
}
$types[$counter++] = $niceNames ? 'Single entity reference' : 'single_ref';
$types[$counter++] = $niceNames ? 'Multi entity reference' : 'multi_ref';
$types[$counter++] = $niceNames ? 'Boolean' : 'boolean';
$types[$counter++] = $niceNames ? 'Integer' : 'integer';
$types[$counter++] = $niceNames ? 'Decimal number' : 'decimal';
$types[$counter++] = $niceNames ? 'DateTime' : 'datetime';
return $types;
} | [
"private",
"function",
"getTypes",
"(",
"$",
"niceNames",
"=",
"false",
")",
"{",
"$",
"counter",
"=",
"1",
";",
"$",
"types",
"=",
"[",
"]",
";",
"$",
"types",
"[",
"$",
"counter",
"++",
"]",
"=",
"$",
"niceNames",
"?",
"'Single line text'",
":",
... | Get all the available types.
@param bool $niceNames
@return array | [
"Get",
"all",
"the",
"available",
"types",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php#L632-L653 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php | KunstmaanGenerateCommand.getMediaTypes | private function getMediaTypes()
{
$counter = 1;
$types = [];
$types[$counter++] = 'None';
$types[$counter++] = 'File';
$types[$counter++] = 'Image';
$types[$counter++] = 'Video';
return $types;
} | php | private function getMediaTypes()
{
$counter = 1;
$types = [];
$types[$counter++] = 'None';
$types[$counter++] = 'File';
$types[$counter++] = 'Image';
$types[$counter++] = 'Video';
return $types;
} | [
"private",
"function",
"getMediaTypes",
"(",
")",
"{",
"$",
"counter",
"=",
"1",
";",
"$",
"types",
"=",
"[",
"]",
";",
"$",
"types",
"[",
"$",
"counter",
"++",
"]",
"=",
"'None'",
";",
"$",
"types",
"[",
"$",
"counter",
"++",
"]",
"=",
"'File'",... | Get all available media types.
@return array | [
"Get",
"all",
"available",
"media",
"types",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Command/KunstmaanGenerateCommand.php#L660-L671 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/SeoBundle/Controller/Admin/SettingsController.php | SettingsController.robotsSettingsAction | public function robotsSettingsAction(Request $request)
{
$this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
$em = $this->getDoctrine()->getManager();
$repo = $this->getDoctrine()->getRepository('KunstmaanSeoBundle:Robots');
$robot = $repo->findOneBy(array());
$default = $this->container->getParameter('robots_default');
$isSaved = true;
if (!$robot) {
$robot = new Robots();
}
if ($robot->getRobotsTxt() == null) {
$robot->setRobotsTxt($default);
$isSaved = false;
}
$form = $this->createForm(RobotsType::class, $robot, array(
'action' => $this->generateUrl('KunstmaanSeoBundle_settings_robots'),
));
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($robot);
$em->flush();
return new RedirectResponse($this->generateUrl('KunstmaanSeoBundle_settings_robots'));
}
}
if (!$isSaved) {
$this->addFlash(
FlashTypes::WARNING,
$this->container->get('translator')->trans('seo.robots.warning')
);
}
return array(
'form' => $form->createView(),
);
} | php | public function robotsSettingsAction(Request $request)
{
$this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN');
$em = $this->getDoctrine()->getManager();
$repo = $this->getDoctrine()->getRepository('KunstmaanSeoBundle:Robots');
$robot = $repo->findOneBy(array());
$default = $this->container->getParameter('robots_default');
$isSaved = true;
if (!$robot) {
$robot = new Robots();
}
if ($robot->getRobotsTxt() == null) {
$robot->setRobotsTxt($default);
$isSaved = false;
}
$form = $this->createForm(RobotsType::class, $robot, array(
'action' => $this->generateUrl('KunstmaanSeoBundle_settings_robots'),
));
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($robot);
$em->flush();
return new RedirectResponse($this->generateUrl('KunstmaanSeoBundle_settings_robots'));
}
}
if (!$isSaved) {
$this->addFlash(
FlashTypes::WARNING,
$this->container->get('translator')->trans('seo.robots.warning')
);
}
return array(
'form' => $form->createView(),
);
} | [
"public",
"function",
"robotsSettingsAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"denyAccessUnlessGranted",
"(",
"'ROLE_SUPER_ADMIN'",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")... | Generates the robots administration form and fills it with a default value if needed.
@Route(path="/", name="KunstmaanSeoBundle_settings_robots")
@Template(template="@KunstmaanSeo/Admin/Settings/robotsSettings.html.twig")
@param Request $request
@return array|RedirectResponse | [
"Generates",
"the",
"robots",
"administration",
"form",
"and",
"fills",
"it",
"with",
"a",
"default",
"value",
"if",
"needed",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Controller/Admin/SettingsController.php#L26-L68 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Command/TranslationFlagCommand.php | TranslationFlagCommand.resetAllTranslationFlags | public function resetAllTranslationFlags()
{
if (null === $this->translationRepository) {
$this->translationRepository = $this->getContainer()->get('kunstmaan_translator.repository.translation');
}
$this->translationRepository->resetAllFlags();
} | php | public function resetAllTranslationFlags()
{
if (null === $this->translationRepository) {
$this->translationRepository = $this->getContainer()->get('kunstmaan_translator.repository.translation');
}
$this->translationRepository->resetAllFlags();
} | [
"public",
"function",
"resetAllTranslationFlags",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"translationRepository",
")",
"{",
"$",
"this",
"->",
"translationRepository",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
... | Rest all flags of all translations and all domains | [
"Rest",
"all",
"flags",
"of",
"all",
"translations",
"and",
"all",
"domains"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Command/TranslationFlagCommand.php#L64-L71 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/TranslationGroupManager.php | TranslationGroupManager.addTranslation | public function addTranslation(TranslationGroup $translationGroup, $locale, $text, $filename)
{
$translation = new \Kunstmaan\TranslatorBundle\Entity\Translation();
$translation->setLocale($locale);
$translation->setText($text);
$translation->setDomain($translationGroup->getDomain());
$translation->setFile($filename);
$translation->setKeyword($translationGroup->getKeyword());
$translation->setCreatedAt(new \DateTime());
$translation->setUpdatedAt(new \DateTime());
$translation->setTranslationId($translationGroup->getId());
$this->translationRepository->persist($translation);
$this->dbCopy[] = $translation;
} | php | public function addTranslation(TranslationGroup $translationGroup, $locale, $text, $filename)
{
$translation = new \Kunstmaan\TranslatorBundle\Entity\Translation();
$translation->setLocale($locale);
$translation->setText($text);
$translation->setDomain($translationGroup->getDomain());
$translation->setFile($filename);
$translation->setKeyword($translationGroup->getKeyword());
$translation->setCreatedAt(new \DateTime());
$translation->setUpdatedAt(new \DateTime());
$translation->setTranslationId($translationGroup->getId());
$this->translationRepository->persist($translation);
$this->dbCopy[] = $translation;
} | [
"public",
"function",
"addTranslation",
"(",
"TranslationGroup",
"$",
"translationGroup",
",",
"$",
"locale",
",",
"$",
"text",
",",
"$",
"filename",
")",
"{",
"$",
"translation",
"=",
"new",
"\\",
"Kunstmaan",
"\\",
"TranslatorBundle",
"\\",
"Entity",
"\\",
... | Checks if the translation exists in the group for this locale, if not, it creates it | [
"Checks",
"if",
"the",
"translation",
"exists",
"in",
"the",
"group",
"for",
"this",
"locale",
"if",
"not",
"it",
"creates",
"it"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/TranslationGroupManager.php#L32-L46 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TranslatorBundle/Service/TranslationGroupManager.php | TranslationGroupManager.getTranslationGroupByKeywordAndDomain | public function getTranslationGroupByKeywordAndDomain($keyword, $domain)
{
$translations = $this->findTranslations($keyword, $domain);
$translationGroup = new TranslationGroup();
$translationGroup->setDomain($domain);
$translationGroup->setKeyword($keyword);
if (empty($translations)) {
$translationGroup->setId($this->maxId);
++$this->maxId;
} else {
$translationGroup->setId($translations[0]->getTranslationId());
}
$translationGroup->setTranslations($translations);
return $translationGroup;
} | php | public function getTranslationGroupByKeywordAndDomain($keyword, $domain)
{
$translations = $this->findTranslations($keyword, $domain);
$translationGroup = new TranslationGroup();
$translationGroup->setDomain($domain);
$translationGroup->setKeyword($keyword);
if (empty($translations)) {
$translationGroup->setId($this->maxId);
++$this->maxId;
} else {
$translationGroup->setId($translations[0]->getTranslationId());
}
$translationGroup->setTranslations($translations);
return $translationGroup;
} | [
"public",
"function",
"getTranslationGroupByKeywordAndDomain",
"(",
"$",
"keyword",
",",
"$",
"domain",
")",
"{",
"$",
"translations",
"=",
"$",
"this",
"->",
"findTranslations",
"(",
"$",
"keyword",
",",
"$",
"domain",
")",
";",
"$",
"translationGroup",
"=",
... | Returns a TranslationGroup with the given keyword and domain, and fills in the translations | [
"Returns",
"a",
"TranslationGroup",
"with",
"the",
"given",
"keyword",
"and",
"domain",
"and",
"fills",
"in",
"the",
"translations"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/TranslationGroupManager.php#L73-L88 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Twig/AdminPermissionsTwigExtension.php | AdminPermissionsTwigExtension.renderWidget | public function renderWidget(Twig_Environment $env, PermissionAdmin $permissionAdmin, FormView $form, array $parameters = array())
{
$template = $env->loadTemplate('KunstmaanAdminBundle:PermissionsAdminTwigExtension:widget.html.twig');
return $template->render(array_merge(array(
'form' => $form,
'permissionadmin' => $permissionAdmin,
'recursiveSupport' => true,
), $parameters));
} | php | public function renderWidget(Twig_Environment $env, PermissionAdmin $permissionAdmin, FormView $form, array $parameters = array())
{
$template = $env->loadTemplate('KunstmaanAdminBundle:PermissionsAdminTwigExtension:widget.html.twig');
return $template->render(array_merge(array(
'form' => $form,
'permissionadmin' => $permissionAdmin,
'recursiveSupport' => true,
), $parameters));
} | [
"public",
"function",
"renderWidget",
"(",
"Twig_Environment",
"$",
"env",
",",
"PermissionAdmin",
"$",
"permissionAdmin",
",",
"FormView",
"$",
"form",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"template",
"=",
"$",
"env",
"-... | Renders the permission admin widget.
@param \Twig_Environment $env
@param PermissionAdmin $permissionAdmin The permission admin
@param FormView $form The form
@param array $parameters Extra parameters
@return string | [
"Renders",
"the",
"permission",
"admin",
"widget",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Twig/AdminPermissionsTwigExtension.php#L36-L45 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/MediaBundle/Command/CreatePdfPreviewCommand.php | CreatePdfPreviewCommand.isEnabled | public function isEnabled()
{
if (null === $this->enablePdfPreview) {
$this->enablePdfPreview = $this->getContainer()->getParameter('kunstmaan_media.enable_pdf_preview');
}
return $this->enablePdfPreview;
} | php | public function isEnabled()
{
if (null === $this->enablePdfPreview) {
$this->enablePdfPreview = $this->getContainer()->getParameter('kunstmaan_media.enable_pdf_preview');
}
return $this->enablePdfPreview;
} | [
"public",
"function",
"isEnabled",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"enablePdfPreview",
")",
"{",
"$",
"this",
"->",
"enablePdfPreview",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'kunstmaan_med... | Checks whether the command is enabled or not in the current environment.
Override this to check for x or y and return false if the command can not
run properly under the current conditions.
@return bool | [
"Checks",
"whether",
"the",
"command",
"is",
"enabled",
"or",
"not",
"in",
"the",
"current",
"environment",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Command/CreatePdfPreviewCommand.php#L111-L118 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/ChoiceFormSubmissionField.php | ChoiceFormSubmissionField.isNull | public function isNull()
{
$values = $this->getValue();
if (is_array($values)) {
return empty($values) || count($values) <= 0;
} elseif (is_string($values)) {
return !isset($values) || trim($values) === '';
} else {
return is_null($values);
}
} | php | public function isNull()
{
$values = $this->getValue();
if (is_array($values)) {
return empty($values) || count($values) <= 0;
} elseif (is_string($values)) {
return !isset($values) || trim($values) === '';
} else {
return is_null($values);
}
} | [
"public",
"function",
"isNull",
"(",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"return",
"empty",
"(",
"$",
"values",
")",
"||",
"count",
"(",
"$",
"value... | Checks if the value of this field is null
@return bool | [
"Checks",
"if",
"the",
"value",
"of",
"this",
"field",
"is",
"null"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/ChoiceFormSubmissionField.php#L97-L107 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Controller/SlugController.php | SlugController.slugAction | public function slugAction(Request $request, $url = null, $preview = false)
{
/* @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
$locale = $request->getLocale();
/* @var NodeTranslation $nodeTranslation */
$nodeTranslation = $request->attributes->get('_nodeTranslation');
// If no node translation -> 404
if (!$nodeTranslation) {
throw $this->createNotFoundException('No page found for slug ' . $url);
}
$entity = $this->getPageEntity(
$request,
$preview,
$em,
$nodeTranslation
);
$node = $nodeTranslation->getNode();
$securityEvent = new SlugSecurityEvent();
$securityEvent
->setNode($node)
->setEntity($entity)
->setRequest($request)
->setNodeTranslation($nodeTranslation);
$nodeMenu = $this->container->get('kunstmaan_node.node_menu');
$nodeMenu->setLocale($locale);
$nodeMenu->setCurrentNode($node);
$nodeMenu->setIncludeOffline($preview);
$eventDispatcher = $this->get('event_dispatcher');
$eventDispatcher->dispatch(Events::SLUG_SECURITY, $securityEvent);
//render page
$renderContext = new RenderContext(
array(
'nodetranslation' => $nodeTranslation,
'slug' => $url,
'page' => $entity,
'resource' => $entity,
'nodemenu' => $nodeMenu,
)
);
if (method_exists($entity, 'getDefaultView')) {
/* @noinspection PhpUndefinedMethodInspection */
$renderContext->setView($entity->getDefaultView());
}
$preEvent = new SlugEvent(null, $renderContext);
$eventDispatcher->dispatch(Events::PRE_SLUG_ACTION, $preEvent);
$renderContext = $preEvent->getRenderContext();
/** @noinspection PhpUndefinedMethodInspection */
$response = $entity->service($this->container, $request, $renderContext);
$postEvent = new SlugEvent($response, $renderContext);
$eventDispatcher->dispatch(Events::POST_SLUG_ACTION, $postEvent);
$response = $postEvent->getResponse();
$renderContext = $postEvent->getRenderContext();
if ($response instanceof Response) {
return $response;
}
$view = $renderContext->getView();
if (empty($view)) {
throw $this->createNotFoundException(sprintf('Missing view path for page "%s"', get_class($entity)));
}
$template = new Template(array());
$template->setTemplate($view);
$request->attributes->set('_template', $template);
return $renderContext->getArrayCopy();
} | php | public function slugAction(Request $request, $url = null, $preview = false)
{
/* @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
$locale = $request->getLocale();
/* @var NodeTranslation $nodeTranslation */
$nodeTranslation = $request->attributes->get('_nodeTranslation');
// If no node translation -> 404
if (!$nodeTranslation) {
throw $this->createNotFoundException('No page found for slug ' . $url);
}
$entity = $this->getPageEntity(
$request,
$preview,
$em,
$nodeTranslation
);
$node = $nodeTranslation->getNode();
$securityEvent = new SlugSecurityEvent();
$securityEvent
->setNode($node)
->setEntity($entity)
->setRequest($request)
->setNodeTranslation($nodeTranslation);
$nodeMenu = $this->container->get('kunstmaan_node.node_menu');
$nodeMenu->setLocale($locale);
$nodeMenu->setCurrentNode($node);
$nodeMenu->setIncludeOffline($preview);
$eventDispatcher = $this->get('event_dispatcher');
$eventDispatcher->dispatch(Events::SLUG_SECURITY, $securityEvent);
//render page
$renderContext = new RenderContext(
array(
'nodetranslation' => $nodeTranslation,
'slug' => $url,
'page' => $entity,
'resource' => $entity,
'nodemenu' => $nodeMenu,
)
);
if (method_exists($entity, 'getDefaultView')) {
/* @noinspection PhpUndefinedMethodInspection */
$renderContext->setView($entity->getDefaultView());
}
$preEvent = new SlugEvent(null, $renderContext);
$eventDispatcher->dispatch(Events::PRE_SLUG_ACTION, $preEvent);
$renderContext = $preEvent->getRenderContext();
/** @noinspection PhpUndefinedMethodInspection */
$response = $entity->service($this->container, $request, $renderContext);
$postEvent = new SlugEvent($response, $renderContext);
$eventDispatcher->dispatch(Events::POST_SLUG_ACTION, $postEvent);
$response = $postEvent->getResponse();
$renderContext = $postEvent->getRenderContext();
if ($response instanceof Response) {
return $response;
}
$view = $renderContext->getView();
if (empty($view)) {
throw $this->createNotFoundException(sprintf('Missing view path for page "%s"', get_class($entity)));
}
$template = new Template(array());
$template->setTemplate($view);
$request->attributes->set('_template', $template);
return $renderContext->getArrayCopy();
} | [
"public",
"function",
"slugAction",
"(",
"Request",
"$",
"request",
",",
"$",
"url",
"=",
"null",
",",
"$",
"preview",
"=",
"false",
")",
"{",
"/* @var EntityManager $em */",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
... | Handle the page requests
@param Request $request The request
@param string $url The url
@param bool $preview Show in preview mode
@throws NotFoundHttpException
@throws AccessDeniedException
@return Response|array | [
"Handle",
"the",
"page",
"requests"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Controller/SlugController.php#L37-L116 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeVersionLockHelper.php | NodeVersionLockHelper.createNodeVersionLock | protected function createNodeVersionLock(BaseUser $user, NodeTranslation $nodeTranslation, $isPublicVersion)
{
$lock = $this->objectManager->getRepository('KunstmaanNodeBundle:NodeVersionLock')->findOneBy([
'owner' => $user->getUsername(),
'nodeTranslation' => $nodeTranslation,
'publicVersion' => $isPublicVersion,
]);
if (!$lock) {
$lock = new NodeVersionLock();
}
$lock->setOwner($user->getUsername());
$lock->setNodeTranslation($nodeTranslation);
$lock->setPublicVersion($isPublicVersion);
$lock->setCreatedAt(new \DateTime());
$this->objectManager->persist($lock);
$this->objectManager->flush();
} | php | protected function createNodeVersionLock(BaseUser $user, NodeTranslation $nodeTranslation, $isPublicVersion)
{
$lock = $this->objectManager->getRepository('KunstmaanNodeBundle:NodeVersionLock')->findOneBy([
'owner' => $user->getUsername(),
'nodeTranslation' => $nodeTranslation,
'publicVersion' => $isPublicVersion,
]);
if (!$lock) {
$lock = new NodeVersionLock();
}
$lock->setOwner($user->getUsername());
$lock->setNodeTranslation($nodeTranslation);
$lock->setPublicVersion($isPublicVersion);
$lock->setCreatedAt(new \DateTime());
$this->objectManager->persist($lock);
$this->objectManager->flush();
} | [
"protected",
"function",
"createNodeVersionLock",
"(",
"BaseUser",
"$",
"user",
",",
"NodeTranslation",
"$",
"nodeTranslation",
",",
"$",
"isPublicVersion",
")",
"{",
"$",
"lock",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"getRepository",
"(",
"'KunstmaanNode... | When editing the node, create a new node translation lock.
@param BaseUser $user
@param NodeTranslation $nodeTranslation
@param bool $isPublicVersion | [
"When",
"editing",
"the",
"node",
"create",
"a",
"new",
"node",
"translation",
"lock",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeVersionLockHelper.php#L96-L113 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeVersionLockHelper.php | NodeVersionLockHelper.getNodeVersionLocksByNodeTranslation | protected function getNodeVersionLocksByNodeTranslation(NodeTranslation $nodeTranslation, $isPublicVersion, BaseUser $userToExclude = null)
{
$threshold = $this->container->getParameter('kunstmaan_node.lock_threshold');
/** @var NodeVersionLockRepository $objectRepository */
$objectRepository = $this->objectManager->getRepository('KunstmaanNodeBundle:NodeVersionLock');
return $objectRepository->getLocksForNodeTranslation($nodeTranslation, $isPublicVersion, $threshold, $userToExclude);
} | php | protected function getNodeVersionLocksByNodeTranslation(NodeTranslation $nodeTranslation, $isPublicVersion, BaseUser $userToExclude = null)
{
$threshold = $this->container->getParameter('kunstmaan_node.lock_threshold');
/** @var NodeVersionLockRepository $objectRepository */
$objectRepository = $this->objectManager->getRepository('KunstmaanNodeBundle:NodeVersionLock');
return $objectRepository->getLocksForNodeTranslation($nodeTranslation, $isPublicVersion, $threshold, $userToExclude);
} | [
"protected",
"function",
"getNodeVersionLocksByNodeTranslation",
"(",
"NodeTranslation",
"$",
"nodeTranslation",
",",
"$",
"isPublicVersion",
",",
"BaseUser",
"$",
"userToExclude",
"=",
"null",
")",
"{",
"$",
"threshold",
"=",
"$",
"this",
"->",
"container",
"->",
... | When editing a node, check if there is a lock for this node translation.
@param NodeTranslation $nodeTranslation
@param bool $isPublicVersion
@param BaseUser $userToExclude
@return NodeVersionLock[] | [
"When",
"editing",
"a",
"node",
"check",
"if",
"there",
"is",
"a",
"lock",
"for",
"this",
"node",
"translation",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeVersionLockHelper.php#L124-L131 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/TaggingBundle/Entity/TaggableTrait.php | TaggableTrait.getTags | public function getTags()
{
if (null === $this->tags) {
$this->tags = new ArrayCollection();
if ($this->lazyTagLoader) {
call_user_func($this->lazyTagLoader, $this);
}
}
return $this->tags;
} | php | public function getTags()
{
if (null === $this->tags) {
$this->tags = new ArrayCollection();
if ($this->lazyTagLoader) {
call_user_func($this->lazyTagLoader, $this);
}
}
return $this->tags;
} | [
"public",
"function",
"getTags",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"tags",
")",
"{",
"$",
"this",
"->",
"tags",
"=",
"new",
"ArrayCollection",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"lazyTagLoader",
")",
"{",
"call_u... | Returns the collection of tags for this Taggable entity
@return \Doctrine\Common\Collections\Collection | [
"Returns",
"the",
"collection",
"of",
"tags",
"for",
"this",
"Taggable",
"entity"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TaggingBundle/Entity/TaggableTrait.php#L49-L60 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Controller/DefaultController.php | DefaultController.editIndexAction | public function editIndexAction(Request $request)
{
/* @var $em EntityManager */
$em = $this->getDoctrine()->getManager();
/* @var DashboardConfiguration $dashboardConfiguration */
$dashboardConfiguration = $em
->getRepository('KunstmaanAdminBundle:DashboardConfiguration')
->findOneBy(array());
if (is_null($dashboardConfiguration)) {
$dashboardConfiguration = new DashboardConfiguration();
}
$form = $this->createForm(DashboardConfigurationType::class, $dashboardConfiguration);
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($dashboardConfiguration);
$em->flush($dashboardConfiguration);
$this->addFlash(
FlashTypes::SUCCESS,
$this->get('translator')->trans('kuma_admin.edit.flash.success')
);
return new RedirectResponse($this->generateUrl('KunstmaanAdminBundle_homepage'));
}
}
return array(
'form' => $form->createView(),
'dashboardConfiguration' => $dashboardConfiguration,
);
} | php | public function editIndexAction(Request $request)
{
/* @var $em EntityManager */
$em = $this->getDoctrine()->getManager();
/* @var DashboardConfiguration $dashboardConfiguration */
$dashboardConfiguration = $em
->getRepository('KunstmaanAdminBundle:DashboardConfiguration')
->findOneBy(array());
if (is_null($dashboardConfiguration)) {
$dashboardConfiguration = new DashboardConfiguration();
}
$form = $this->createForm(DashboardConfigurationType::class, $dashboardConfiguration);
if ($request->isMethod('POST')) {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($dashboardConfiguration);
$em->flush($dashboardConfiguration);
$this->addFlash(
FlashTypes::SUCCESS,
$this->get('translator')->trans('kuma_admin.edit.flash.success')
);
return new RedirectResponse($this->generateUrl('KunstmaanAdminBundle_homepage'));
}
}
return array(
'form' => $form->createView(),
'dashboardConfiguration' => $dashboardConfiguration,
);
} | [
"public",
"function",
"editIndexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"/* @var $em EntityManager */",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"/* @var DashboardConfiguration $dashboardConfiguration */... | The admin of the index page
@Route("/adminindex", name="KunstmaanAdminBundle_homepage_admin")
@Template("@KunstmaanAdmin/Default/editIndex.html.twig")
@param \Symfony\Component\HttpFoundation\Request $request
@return array | [
"The",
"admin",
"of",
"the",
"index",
"page"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Controller/DefaultController.php#L53-L87 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php | FormPageGenerator.generatePageTemplateConfiguration | private function generatePageTemplateConfiguration()
{
$this->copyTemplates();
$this->installDefaultPagePartConfiguration($this->bundle);
$this->copyTemplateConfig();
$this->assistant->writeLine('Generating template configuration : <info>OK</info>');
} | php | private function generatePageTemplateConfiguration()
{
$this->copyTemplates();
$this->installDefaultPagePartConfiguration($this->bundle);
$this->copyTemplateConfig();
$this->assistant->writeLine('Generating template configuration : <info>OK</info>');
} | [
"private",
"function",
"generatePageTemplateConfiguration",
"(",
")",
"{",
"$",
"this",
"->",
"copyTemplates",
"(",
")",
";",
"$",
"this",
"->",
"installDefaultPagePartConfiguration",
"(",
"$",
"this",
"->",
"bundle",
")",
";",
"$",
"this",
"->",
"copyTemplateCo... | Generate the page template and pagepart configuration. | [
"Generate",
"the",
"page",
"template",
"and",
"pagepart",
"configuration",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php#L172-L178 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php | FormPageGenerator.copyTemplates | private function copyTemplates()
{
$dirPath = $this->bundle->getPath();
$this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/view.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig', true);
$this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/pagetemplate.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig', true);
GeneratorUtils::replace('~~~BUNDLE~~~', $this->bundle->getName(), $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig');
GeneratorUtils::prepend("{% extends '" . $this->bundle->getName() .":Page:layout.html.twig' %}\n", $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig');
} | php | private function copyTemplates()
{
$dirPath = $this->bundle->getPath();
$this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/view.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig', true);
$this->filesystem->copy($this->skeletonDir . '/Resources/views/Pages/FormPage/pagetemplate.html.twig', $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig', true);
GeneratorUtils::replace('~~~BUNDLE~~~', $this->bundle->getName(), $dirPath . '/Resources/views/Pages/'.$this->entity.'/pagetemplate.html.twig');
GeneratorUtils::prepend("{% extends '" . $this->bundle->getName() .":Page:layout.html.twig' %}\n", $dirPath . '/Resources/views/Pages/'.$this->entity.'/view.html.twig');
} | [
"private",
"function",
"copyTemplates",
"(",
")",
"{",
"$",
"dirPath",
"=",
"$",
"this",
"->",
"bundle",
"->",
"getPath",
"(",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"copy",
"(",
"$",
"this",
"->",
"skeletonDir",
".",
"'/Resources/views/Pages/For... | Copy and modify default formPage templates | [
"Copy",
"and",
"modify",
"default",
"formPage",
"templates"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php#L183-L191 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php | FormPageGenerator.copyTemplateConfig | private function copyTemplateConfig()
{
$dirPath = $this->bundle->getPath();
$pagepartFile = $dirPath.'/Resources/config/pageparts/'.$this->template.'.yml';
$namespace = $this->generateFormPageParts ? $this->bundle->getNamespace() : 'Kunstmaan\FormBundle';
$this->filesystem->copy($this->skeletonDir.'/Resources/config/pageparts/formpage.yml', $pagepartFile, false);
GeneratorUtils::replace('~~~ENTITY~~~', $this->entity, $pagepartFile);
GeneratorUtils::replace('~~~FORM_BUNDLE~~~', $namespace, $pagepartFile);
$pagetemplateFile = $dirPath.'/Resources/config/pagetemplates/'.$this->template.'.yml';
$this->filesystem->copy($this->skeletonDir.'/Resources/config/pagetemplates/formpage.yml', $pagetemplateFile, false);
GeneratorUtils::replace('~~~BUNDLE~~~', $this->bundle->getName(), $pagetemplateFile);
GeneratorUtils::replace('~~~ENTITY~~~', $this->entity, $pagetemplateFile);
} | php | private function copyTemplateConfig()
{
$dirPath = $this->bundle->getPath();
$pagepartFile = $dirPath.'/Resources/config/pageparts/'.$this->template.'.yml';
$namespace = $this->generateFormPageParts ? $this->bundle->getNamespace() : 'Kunstmaan\FormBundle';
$this->filesystem->copy($this->skeletonDir.'/Resources/config/pageparts/formpage.yml', $pagepartFile, false);
GeneratorUtils::replace('~~~ENTITY~~~', $this->entity, $pagepartFile);
GeneratorUtils::replace('~~~FORM_BUNDLE~~~', $namespace, $pagepartFile);
$pagetemplateFile = $dirPath.'/Resources/config/pagetemplates/'.$this->template.'.yml';
$this->filesystem->copy($this->skeletonDir.'/Resources/config/pagetemplates/formpage.yml', $pagetemplateFile, false);
GeneratorUtils::replace('~~~BUNDLE~~~', $this->bundle->getName(), $pagetemplateFile);
GeneratorUtils::replace('~~~ENTITY~~~', $this->entity, $pagetemplateFile);
} | [
"private",
"function",
"copyTemplateConfig",
"(",
")",
"{",
"$",
"dirPath",
"=",
"$",
"this",
"->",
"bundle",
"->",
"getPath",
"(",
")",
";",
"$",
"pagepartFile",
"=",
"$",
"dirPath",
".",
"'/Resources/config/pageparts/'",
".",
"$",
"this",
"->",
"template",... | Copy and modify default config files for the pagetemplate and pageparts. | [
"Copy",
"and",
"modify",
"default",
"config",
"files",
"for",
"the",
"pagetemplate",
"and",
"pageparts",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php#L196-L209 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php | FormPageGenerator.updateParentPages | private function updateParentPages()
{
$phpCode = " [\n";
$phpCode .= " 'name' => '" . $this->entity . "',\n";
$phpCode .= " 'class'=> '" .
$this->bundle->getNamespace() .
'\\Entity\\Pages\\' . $this->entity . "'\n";
$phpCode .= ' ],'."\n ";
// When there is a BehatTestPage, we should also allow the new page as sub page
$behatTestPage = $this->bundle->getPath() . '/Entity/Pages/BehatTestPage.php';
if (file_exists($behatTestPage)) {
$this->parentPages[] = $behatTestPage;
}
foreach ($this->parentPages as $file) {
$data = file_get_contents($file);
$data = preg_replace(
'/(function\s*getPossibleChildTypes\s*\(\)\s*\{\s*)(return\s*\[|return\s*array\()/',
"$1$2\n$phpCode",
$data
);
file_put_contents($file, $data);
}
} | php | private function updateParentPages()
{
$phpCode = " [\n";
$phpCode .= " 'name' => '" . $this->entity . "',\n";
$phpCode .= " 'class'=> '" .
$this->bundle->getNamespace() .
'\\Entity\\Pages\\' . $this->entity . "'\n";
$phpCode .= ' ],'."\n ";
// When there is a BehatTestPage, we should also allow the new page as sub page
$behatTestPage = $this->bundle->getPath() . '/Entity/Pages/BehatTestPage.php';
if (file_exists($behatTestPage)) {
$this->parentPages[] = $behatTestPage;
}
foreach ($this->parentPages as $file) {
$data = file_get_contents($file);
$data = preg_replace(
'/(function\s*getPossibleChildTypes\s*\(\)\s*\{\s*)(return\s*\[|return\s*array\()/',
"$1$2\n$phpCode",
$data
);
file_put_contents($file, $data);
}
} | [
"private",
"function",
"updateParentPages",
"(",
")",
"{",
"$",
"phpCode",
"=",
"\" [\\n\"",
";",
"$",
"phpCode",
".=",
"\" 'name' => '\"",
".",
"$",
"this",
"->",
"entity",
".",
"\"',\\n\"",
";",
"$",
"phpCode",
".=",
"\" ... | Update the getPossibleChildTypes function of the parent Page classes | [
"Update",
"the",
"getPossibleChildTypes",
"function",
"of",
"the",
"parent",
"Page",
"classes"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/FormPageGenerator.php#L214-L238 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/FormBundle/AdminList/FormSubmissionExportListConfigurator.php | FormSubmissionExportListConfigurator.buildExportFields | public function buildExportFields()
{
$this->addExportField('id', $this->translator->trans('Id'))
->addExportField('date', $this->translator->trans('Date'))
->addExportField('language', $this->translator->trans('Language'));
} | php | public function buildExportFields()
{
$this->addExportField('id', $this->translator->trans('Id'))
->addExportField('date', $this->translator->trans('Date'))
->addExportField('language', $this->translator->trans('Language'));
} | [
"public",
"function",
"buildExportFields",
"(",
")",
"{",
"$",
"this",
"->",
"addExportField",
"(",
"'id'",
",",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"'Id'",
")",
")",
"->",
"addExportField",
"(",
"'date'",
",",
"$",
"this",
"->",
"transl... | Build export fields | [
"Build",
"export",
"fields"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/AdminList/FormSubmissionExportListConfigurator.php#L96-L101 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/GoalCommandHelper.php | GoalCommandHelper.parseGoals | private function parseGoals(&$overview, $goalCollection)
{
$timespan = $overview->getTimespan() - $overview->getStartOffset();
$goals = $overview->getGoals();
if ($goals) {
// delete existing entries
foreach ($goals as $goal) {
$this->em->remove($goal);
}
$this->em->flush();
}
foreach ($goalCollection as $goalEntry) {
// create a new goal
$goal = new AnalyticsGoal();
$goal->setOverview($overview);
$goal->setName($goalEntry['name']);
$goal->setPosition($goalEntry['position']);
$chartData = array();
$totalVisits = 0;
$goalVisits = 0;
$i = 0;
// Fill the chartdata array
foreach ($goalEntry['visits'] as $timestamp => $visits) {
$totalVisits += $visits;
if ($timespan <= 7 && $timespan > 1) {
$goalVisits += $visits;
if ($i % 5 == 0) {
$chartData[] = array('timestamp' => $timestamp, 'conversions' => $goalVisits);
$goalVisits = 0;
}
} else {
$chartData[] = array('timestamp' => $timestamp, 'conversions' => $visits);
}
$i += 1;
}
// set the data
$goal->setVisits($totalVisits);
$goal->setChartData(json_encode($chartData));
$this->em->persist($goal);
$this->output->writeln(
"\t\t" . 'Fetched goal ' . $goal->getPosition() . ': "' . $goal->getName() . '" @ ' . $totalVisits
);
}
} | php | private function parseGoals(&$overview, $goalCollection)
{
$timespan = $overview->getTimespan() - $overview->getStartOffset();
$goals = $overview->getGoals();
if ($goals) {
// delete existing entries
foreach ($goals as $goal) {
$this->em->remove($goal);
}
$this->em->flush();
}
foreach ($goalCollection as $goalEntry) {
// create a new goal
$goal = new AnalyticsGoal();
$goal->setOverview($overview);
$goal->setName($goalEntry['name']);
$goal->setPosition($goalEntry['position']);
$chartData = array();
$totalVisits = 0;
$goalVisits = 0;
$i = 0;
// Fill the chartdata array
foreach ($goalEntry['visits'] as $timestamp => $visits) {
$totalVisits += $visits;
if ($timespan <= 7 && $timespan > 1) {
$goalVisits += $visits;
if ($i % 5 == 0) {
$chartData[] = array('timestamp' => $timestamp, 'conversions' => $goalVisits);
$goalVisits = 0;
}
} else {
$chartData[] = array('timestamp' => $timestamp, 'conversions' => $visits);
}
$i += 1;
}
// set the data
$goal->setVisits($totalVisits);
$goal->setChartData(json_encode($chartData));
$this->em->persist($goal);
$this->output->writeln(
"\t\t" . 'Fetched goal ' . $goal->getPosition() . ': "' . $goal->getName() . '" @ ' . $totalVisits
);
}
} | [
"private",
"function",
"parseGoals",
"(",
"&",
"$",
"overview",
",",
"$",
"goalCollection",
")",
"{",
"$",
"timespan",
"=",
"$",
"overview",
"->",
"getTimespan",
"(",
")",
"-",
"$",
"overview",
"->",
"getStartOffset",
"(",
")",
";",
"$",
"goals",
"=",
... | Fetch a specific goals
@param AnalyticsOverview $overview The overview
@param $goalCollection | [
"Fetch",
"a",
"specific",
"goals"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/GoalCommandHelper.php#L205-L252 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Command/GeneratePageCommand.php | GeneratePageCommand.getTemplateList | private function getTemplateList()
{
$templates = $this->getAvailableTemplates($this->bundle);
$types = array();
foreach ($templates as $key => $template) {
$types[$key] = $template['name'];
}
return $types;
} | php | private function getTemplateList()
{
$templates = $this->getAvailableTemplates($this->bundle);
$types = array();
foreach ($templates as $key => $template) {
$types[$key] = $template['name'];
}
return $types;
} | [
"private",
"function",
"getTemplateList",
"(",
")",
"{",
"$",
"templates",
"=",
"$",
"this",
"->",
"getAvailableTemplates",
"(",
"$",
"this",
"->",
"bundle",
")",
";",
"$",
"types",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"templates",
"as",
"... | Get all the available default templates.
@return array | [
"Get",
"all",
"the",
"available",
"default",
"templates",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Command/GeneratePageCommand.php#L248-L258 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Twig/MultiDomainAdminTwigExtension.php | MultiDomainAdminTwigExtension.renderWidget | public function renderWidget(Twig_Environment $env, $route, array $parameters = [])
{
$template = $env->loadTemplate(
'@KunstmaanAdmin/MultiDomainAdminTwigExtension/widget.html.twig'
);
return $template->render(
\array_merge(
$parameters, [
'hosts' => $this->getAdminDomainHosts(),
'route' => $route,
]
)
);
} | php | public function renderWidget(Twig_Environment $env, $route, array $parameters = [])
{
$template = $env->loadTemplate(
'@KunstmaanAdmin/MultiDomainAdminTwigExtension/widget.html.twig'
);
return $template->render(
\array_merge(
$parameters, [
'hosts' => $this->getAdminDomainHosts(),
'route' => $route,
]
)
);
} | [
"public",
"function",
"renderWidget",
"(",
"Twig_Environment",
"$",
"env",
",",
"$",
"route",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"template",
"=",
"$",
"env",
"->",
"loadTemplate",
"(",
"'@KunstmaanAdmin/MultiDomainAdminTwigExtension/w... | Render multidomain switcher widget.
@param Twig_Environment $env
@param string $route The route
@param array $parameters The route parameters
@return string | [
"Render",
"multidomain",
"switcher",
"widget",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Twig/MultiDomainAdminTwigExtension.php#L46-L60 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Menu/MenuItem.php | MenuItem.setRoute | public function setRoute($route, array $params = array())
{
$this->route = $route;
$this->routeParams = $params;
return $this;
} | php | public function setRoute($route, array $params = array())
{
$this->route = $route;
$this->routeParams = $params;
return $this;
} | [
"public",
"function",
"setRoute",
"(",
"$",
"route",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"route",
"=",
"$",
"route",
";",
"$",
"this",
"->",
"routeParams",
"=",
"$",
"params",
";",
"return",
"$",
"this"... | Set route and parameters for menu item
@param string $route The route
@param array $params The route parameters
@return MenuItem | [
"Set",
"route",
"and",
"parameters",
"for",
"menu",
"item"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Menu/MenuItem.php#L215-L221 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeSearchBundle/Search/NodeSearcher.php | NodeSearcher.applySecurityFilter | protected function applySecurityFilter($elasticaQueryBool)
{
$roles = $this->getCurrentUserRoles();
$elasticaQueryRoles = new Query\Terms();
$elasticaQueryRoles
->setTerms('view_roles', $roles);
$elasticaQueryBool->addMust($elasticaQueryRoles);
} | php | protected function applySecurityFilter($elasticaQueryBool)
{
$roles = $this->getCurrentUserRoles();
$elasticaQueryRoles = new Query\Terms();
$elasticaQueryRoles
->setTerms('view_roles', $roles);
$elasticaQueryBool->addMust($elasticaQueryRoles);
} | [
"protected",
"function",
"applySecurityFilter",
"(",
"$",
"elasticaQueryBool",
")",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"getCurrentUserRoles",
"(",
")",
";",
"$",
"elasticaQueryRoles",
"=",
"new",
"Query",
"\\",
"Terms",
"(",
")",
";",
"$",
"elasticaQ... | Filter search results so only documents that are viewable by the current
user will be returned...
@param \Elastica\Query\BoolQuery $elasticaQueryBool | [
"Filter",
"search",
"results",
"so",
"only",
"documents",
"that",
"are",
"viewable",
"by",
"the",
"current",
"user",
"will",
"be",
"returned",
"..."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Search/NodeSearcher.php#L148-L156 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeSearchBundle/Search/NodeSearcher.php | NodeSearcher.getPageBoosts | protected function getPageBoosts()
{
$rescoreQueryBool = new BoolQuery();
//Apply page type boosts
$pageClasses = $this->em->getRepository('KunstmaanNodeBundle:Node')->findAllDistinctPageClasses();
foreach ($pageClasses as $pageClass) {
$page = new $pageClass['refEntityName']();
if ($page instanceof SearchBoostInterface) {
$elasticaQueryTypeBoost = new QueryString();
$elasticaQueryTypeBoost
->setBoost($page->getSearchBoost())
->setDefaultField('page_class')
->setQuery(addslashes($pageClass['refEntityName']));
$rescoreQueryBool->addShould($elasticaQueryTypeBoost);
}
}
//Apply page specific boosts
$nodeSearches = $this->em->getRepository('KunstmaanNodeSearchBundle:NodeSearch')->findAll();
foreach ($nodeSearches as $nodeSearch) {
$elasticaQueryNodeId = new QueryString();
$elasticaQueryNodeId
->setBoost($nodeSearch->getBoost())
->setDefaultField('node_id')
->setQuery($nodeSearch->getNode()->getId());
$rescoreQueryBool->addShould($elasticaQueryNodeId);
}
return $rescoreQueryBool;
} | php | protected function getPageBoosts()
{
$rescoreQueryBool = new BoolQuery();
//Apply page type boosts
$pageClasses = $this->em->getRepository('KunstmaanNodeBundle:Node')->findAllDistinctPageClasses();
foreach ($pageClasses as $pageClass) {
$page = new $pageClass['refEntityName']();
if ($page instanceof SearchBoostInterface) {
$elasticaQueryTypeBoost = new QueryString();
$elasticaQueryTypeBoost
->setBoost($page->getSearchBoost())
->setDefaultField('page_class')
->setQuery(addslashes($pageClass['refEntityName']));
$rescoreQueryBool->addShould($elasticaQueryTypeBoost);
}
}
//Apply page specific boosts
$nodeSearches = $this->em->getRepository('KunstmaanNodeSearchBundle:NodeSearch')->findAll();
foreach ($nodeSearches as $nodeSearch) {
$elasticaQueryNodeId = new QueryString();
$elasticaQueryNodeId
->setBoost($nodeSearch->getBoost())
->setDefaultField('node_id')
->setQuery($nodeSearch->getNode()->getId());
$rescoreQueryBool->addShould($elasticaQueryNodeId);
}
return $rescoreQueryBool;
} | [
"protected",
"function",
"getPageBoosts",
"(",
")",
"{",
"$",
"rescoreQueryBool",
"=",
"new",
"BoolQuery",
"(",
")",
";",
"//Apply page type boosts",
"$",
"pageClasses",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'KunstmaanNodeBundle:Node'",
")",
... | Apply PageType specific and Page specific boosts
@return \Elastica\Query\BoolQuery | [
"Apply",
"PageType",
"specific",
"and",
"Page",
"specific",
"boosts"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Search/NodeSearcher.php#L184-L217 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsSegmentsListCommand.php | GoogleAnalyticsSegmentsListCommand.getSegmentsOfConfig | private function getSegmentsOfConfig($configId)
{
// get specified config
$configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig');
$config = $configRepository->find($configId);
if (!$config) {
throw new \Exception('Unkown config ID');
}
// get the segments
return $config->getSegments();
} | php | private function getSegmentsOfConfig($configId)
{
// get specified config
$configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig');
$config = $configRepository->find($configId);
if (!$config) {
throw new \Exception('Unkown config ID');
}
// get the segments
return $config->getSegments();
} | [
"private",
"function",
"getSegmentsOfConfig",
"(",
"$",
"configId",
")",
"{",
"// get specified config",
"$",
"configRepository",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'KunstmaanDashboardBundle:AnalyticsConfig'",
")",
";",
"$",
"config",
"=",
"$... | get all segments of a config
@param int $configId
@return array | [
"get",
"all",
"segments",
"of",
"a",
"config"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsSegmentsListCommand.php#L101-L113 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/DashboardBundle/Controller/GoogleAnalyticsAJAXController.php | GoogleAnalyticsAJAXController.getOverviewAction | public function getOverviewAction($id)
{
$em = $this->getDoctrine()->getManager();
/** @var AnalyticsOverviewRepository $analyticsOverviewRepository */
$analyticsOverviewRepository = $em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
$overview = $analyticsOverviewRepository->find($id);
// goals data
$goals = array();
foreach ($overview->getActiveGoals() as $key => $goal) {
/* @var AnalyticsGoal $goal */
$goals[$key]['name'] = $goal->getName();
$goals[$key]['visits'] = $goal->getVisits();
$goals[$key]['id'] = $goal->getId();
$goals[$key]['chartData'] = json_decode($goal->getChartData());
}
// overview data
$overviewData = array(
'id' => $overview->getId(),
'chartData' => json_decode($overview->getChartData(), true),
'chartDataMaxValue' => $overview->getChartDataMaxValue(),
'title' => $overview->getTitle(),
'timespan' => $overview->getTimespan(),
'startOffset' => $overview->getStartOffset(),
'sessions' => number_format($overview->getSessions()),
'users' => number_format($overview->getUsers()),
'pagesPerSession' => round($overview->getPagesPerSession(), 2),
'avgSessionDuration' => $overview->getAvgSessionDuration(),
'returningUsers' => number_format($overview->getReturningUsers()),
'newUsers' => round($overview->getNewUsers(), 2),
'pageViews' => number_format($overview->getPageViews()),
'returningUsersPercentage' => $overview->getReturningUsersPercentage(),
'newUsersPercentage' => $overview->getNewUsersPercentage(),
);
// put all data in the return array
$return = array(
'responseCode' => 200,
'overview' => $overviewData,
'goals' => $goals,
);
// return json response
return new JsonResponse($return, 200, array('Content-Type' => 'application/json'));
} | php | public function getOverviewAction($id)
{
$em = $this->getDoctrine()->getManager();
/** @var AnalyticsOverviewRepository $analyticsOverviewRepository */
$analyticsOverviewRepository = $em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview');
$overview = $analyticsOverviewRepository->find($id);
// goals data
$goals = array();
foreach ($overview->getActiveGoals() as $key => $goal) {
/* @var AnalyticsGoal $goal */
$goals[$key]['name'] = $goal->getName();
$goals[$key]['visits'] = $goal->getVisits();
$goals[$key]['id'] = $goal->getId();
$goals[$key]['chartData'] = json_decode($goal->getChartData());
}
// overview data
$overviewData = array(
'id' => $overview->getId(),
'chartData' => json_decode($overview->getChartData(), true),
'chartDataMaxValue' => $overview->getChartDataMaxValue(),
'title' => $overview->getTitle(),
'timespan' => $overview->getTimespan(),
'startOffset' => $overview->getStartOffset(),
'sessions' => number_format($overview->getSessions()),
'users' => number_format($overview->getUsers()),
'pagesPerSession' => round($overview->getPagesPerSession(), 2),
'avgSessionDuration' => $overview->getAvgSessionDuration(),
'returningUsers' => number_format($overview->getReturningUsers()),
'newUsers' => round($overview->getNewUsers(), 2),
'pageViews' => number_format($overview->getPageViews()),
'returningUsersPercentage' => $overview->getReturningUsersPercentage(),
'newUsersPercentage' => $overview->getNewUsersPercentage(),
);
// put all data in the return array
$return = array(
'responseCode' => 200,
'overview' => $overviewData,
'goals' => $goals,
);
// return json response
return new JsonResponse($return, 200, array('Content-Type' => 'application/json'));
} | [
"public",
"function",
"getOverviewAction",
"(",
"$",
"id",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"/** @var AnalyticsOverviewRepository $analyticsOverviewRepository */",
"$",
"analyticsOverviewRepositor... | Return an ajax response with all data for an overview
@Route("/getOverview/{id}", requirements={"id" = "\d+"}, name="KunstmaanDashboardBundle_analytics_overview_ajax") | [
"Return",
"an",
"ajax",
"response",
"with",
"all",
"data",
"for",
"an",
"overview"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Controller/GoogleAnalyticsAJAXController.php#L41-L86 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/SitemapBundle/Controller/SitemapController.php | SitemapController.sitemapAction | public function sitemapAction($locale)
{
$nodeMenu = $this->get('kunstmaan_node.node_menu');
$nodeMenu->setLocale($locale);
$nodeMenu->setIncludeOffline(false);
$nodeMenu->setIncludeHiddenFromNav(true);
$nodeMenu->setCurrentNode(null);
return array(
'nodemenu' => $nodeMenu,
'locale' => $locale,
);
} | php | public function sitemapAction($locale)
{
$nodeMenu = $this->get('kunstmaan_node.node_menu');
$nodeMenu->setLocale($locale);
$nodeMenu->setIncludeOffline(false);
$nodeMenu->setIncludeHiddenFromNav(true);
$nodeMenu->setCurrentNode(null);
return array(
'nodemenu' => $nodeMenu,
'locale' => $locale,
);
} | [
"public",
"function",
"sitemapAction",
"(",
"$",
"locale",
")",
"{",
"$",
"nodeMenu",
"=",
"$",
"this",
"->",
"get",
"(",
"'kunstmaan_node.node_menu'",
")",
";",
"$",
"nodeMenu",
"->",
"setLocale",
"(",
"$",
"locale",
")",
";",
"$",
"nodeMenu",
"->",
"se... | This will generate a sitemap for the specified locale.
Use the mode parameter to select in which mode the sitemap should be
generated. At this moment only XML is supported
@Route("/sitemap-{locale}.{_format}", name="KunstmaanSitemapBundle_sitemap",
requirements={"_format" = "xml"})
@Template("KunstmaanSitemapBundle:Sitemap:view.xml.twig")
@param $locale
@return array | [
"This",
"will",
"generate",
"a",
"sitemap",
"for",
"the",
"specified",
"locale",
".",
"Use",
"the",
"mode",
"parameter",
"to",
"select",
"in",
"which",
"mode",
"the",
"sitemap",
"should",
"be",
"generated",
".",
"At",
"this",
"moment",
"only",
"XML",
"is",... | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SitemapBundle/Controller/SitemapController.php#L25-L37 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Router/SlugRouter.php | SlugRouter.match | public function match($pathinfo)
{
$urlMatcher = new UrlMatcher(
$this->getRouteCollection(),
$this->getContext()
);
$result = $urlMatcher->match($pathinfo);
if (!empty($result)) {
$nodeTranslation = $this->getNodeTranslation($result);
if (is_null($nodeTranslation)) {
throw new ResourceNotFoundException(
'No page found for slug ' . $pathinfo
);
}
$result['_nodeTranslation'] = $nodeTranslation;
}
return $result;
} | php | public function match($pathinfo)
{
$urlMatcher = new UrlMatcher(
$this->getRouteCollection(),
$this->getContext()
);
$result = $urlMatcher->match($pathinfo);
if (!empty($result)) {
$nodeTranslation = $this->getNodeTranslation($result);
if (is_null($nodeTranslation)) {
throw new ResourceNotFoundException(
'No page found for slug ' . $pathinfo
);
}
$result['_nodeTranslation'] = $nodeTranslation;
}
return $result;
} | [
"public",
"function",
"match",
"(",
"$",
"pathinfo",
")",
"{",
"$",
"urlMatcher",
"=",
"new",
"UrlMatcher",
"(",
"$",
"this",
"->",
"getRouteCollection",
"(",
")",
",",
"$",
"this",
"->",
"getContext",
"(",
")",
")",
";",
"$",
"result",
"=",
"$",
"ur... | Match given urls via the context to the routes we defined.
This functionality re-uses the default Symfony way of routing and its
components
@param string $pathinfo
@throws ResourceNotFoundException
@return array | [
"Match",
"given",
"urls",
"via",
"the",
"context",
"to",
"the",
"routes",
"we",
"defined",
".",
"This",
"functionality",
"re",
"-",
"uses",
"the",
"default",
"Symfony",
"way",
"of",
"routing",
"and",
"its",
"components"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Router/SlugRouter.php#L104-L123 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Router/SlugRouter.php | SlugRouter.getPreviewRouteParameters | protected function getPreviewRouteParameters()
{
$previewPath = sprintf('/%s/preview/{url}', $this->adminKey);
$previewDefaults = array(
'_controller' => 'KunstmaanNodeBundle:Slug:slug',
'preview' => true,
'url' => '',
'_locale' => $this->getDefaultLocale(),
);
$previewRequirements = array(
'url' => $this->getSlugPattern(),
);
if ($this->isMultiLanguage()) {
$previewPath = '/{_locale}' . $previewPath;
unset($previewDefaults['_locale']);
$previewRequirements['_locale'] = $this->getEscapedLocales($this->getBackendLocales());
}
return array(
'path' => $previewPath,
'defaults' => $previewDefaults,
'requirements' => $previewRequirements,
);
} | php | protected function getPreviewRouteParameters()
{
$previewPath = sprintf('/%s/preview/{url}', $this->adminKey);
$previewDefaults = array(
'_controller' => 'KunstmaanNodeBundle:Slug:slug',
'preview' => true,
'url' => '',
'_locale' => $this->getDefaultLocale(),
);
$previewRequirements = array(
'url' => $this->getSlugPattern(),
);
if ($this->isMultiLanguage()) {
$previewPath = '/{_locale}' . $previewPath;
unset($previewDefaults['_locale']);
$previewRequirements['_locale'] = $this->getEscapedLocales($this->getBackendLocales());
}
return array(
'path' => $previewPath,
'defaults' => $previewDefaults,
'requirements' => $previewRequirements,
);
} | [
"protected",
"function",
"getPreviewRouteParameters",
"(",
")",
"{",
"$",
"previewPath",
"=",
"sprintf",
"(",
"'/%s/preview/{url}'",
",",
"$",
"this",
"->",
"adminKey",
")",
";",
"$",
"previewDefaults",
"=",
"array",
"(",
"'_controller'",
"=>",
"'KunstmaanNodeBund... | Return preview route parameters
@return array | [
"Return",
"preview",
"route",
"parameters"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Router/SlugRouter.php#L228-L252 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/GeneratorBundle/Helper/EntityValidator.php | EntityValidator.validate | public static function validate($entity)
{
if (Kernel::VERSION_ID >= 40000) {
$classFound = class_exists($entity, true);
if (!$classFound) {
throw new \InvalidArgumentException(sprintf('Entity "%s" was not found', $entity));
}
return $entity;
}
if (!preg_match('{^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*:[a-zA-Z0-9_\x7f-\xff\\\/]+$}', $entity)) {
throw new \InvalidArgumentException(sprintf('The entity name isn\'t valid ("%s" given, expecting something like AcmeBlogBundle:Blog/Post)', $entity));
}
return $entity;
} | php | public static function validate($entity)
{
if (Kernel::VERSION_ID >= 40000) {
$classFound = class_exists($entity, true);
if (!$classFound) {
throw new \InvalidArgumentException(sprintf('Entity "%s" was not found', $entity));
}
return $entity;
}
if (!preg_match('{^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*:[a-zA-Z0-9_\x7f-\xff\\\/]+$}', $entity)) {
throw new \InvalidArgumentException(sprintf('The entity name isn\'t valid ("%s" given, expecting something like AcmeBlogBundle:Blog/Post)', $entity));
}
return $entity;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"Kernel",
"::",
"VERSION_ID",
">=",
"40000",
")",
"{",
"$",
"classFound",
"=",
"class_exists",
"(",
"$",
"entity",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"class... | Performs basic checks in entity name.
@param string $entity
@return string
@throws \InvalidArgumentException | [
"Performs",
"basic",
"checks",
"in",
"entity",
"name",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Helper/EntityValidator.php#L21-L38 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/NodeBundle/Helper/Routing/DynamicUrlMatcher.php | DynamicUrlMatcher.match | public function match($pathInfo)
{
if ($ret = $this->matchCollection($pathInfo, $this->routesCopy)) {
return $ret;
}
return false;
} | php | public function match($pathInfo)
{
if ($ret = $this->matchCollection($pathInfo, $this->routesCopy)) {
return $ret;
}
return false;
} | [
"public",
"function",
"match",
"(",
"$",
"pathInfo",
")",
"{",
"if",
"(",
"$",
"ret",
"=",
"$",
"this",
"->",
"matchCollection",
"(",
"$",
"pathInfo",
",",
"$",
"this",
"->",
"routesCopy",
")",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"return",
"f... | Check if url exists
@param string $pathInfo
@return bool | [
"Check",
"if",
"url",
"exists"
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/Routing/DynamicUrlMatcher.php#L36-L43 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclWalker.php | AclWalker.walkFromClause | public function walkFromClause($fromClause)
{
$sql = parent::walkFromClause($fromClause);
$name = $this->getQuery()->getHint('acl.entityRootTableName');
$alias = $this->getQuery()->getHint('acl.entityRootTableDqlAlias');
$tableAlias = $this->getSQLTableAlias($name, $alias);
$extraQuery = $this->getQuery()->getHint('acl.extra.query');
$tempAclView = <<<tempAclView
JOIN ({$extraQuery}) ta_ ON {$tableAlias}.id = ta_.id
tempAclView;
return $sql . ' ' . $tempAclView;
} | php | public function walkFromClause($fromClause)
{
$sql = parent::walkFromClause($fromClause);
$name = $this->getQuery()->getHint('acl.entityRootTableName');
$alias = $this->getQuery()->getHint('acl.entityRootTableDqlAlias');
$tableAlias = $this->getSQLTableAlias($name, $alias);
$extraQuery = $this->getQuery()->getHint('acl.extra.query');
$tempAclView = <<<tempAclView
JOIN ({$extraQuery}) ta_ ON {$tableAlias}.id = ta_.id
tempAclView;
return $sql . ' ' . $tempAclView;
} | [
"public",
"function",
"walkFromClause",
"(",
"$",
"fromClause",
")",
"{",
"$",
"sql",
"=",
"parent",
"::",
"walkFromClause",
"(",
"$",
"fromClause",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
"->",
"getHint",
"(",
"'acl.entityRo... | Walks down a FromClause AST node, thereby generating the appropriate SQL.
@param string $fromClause
@return string the SQL | [
"Walks",
"down",
"a",
"FromClause",
"AST",
"node",
"thereby",
"generating",
"the",
"appropriate",
"SQL",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclWalker.php#L20-L33 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/ArticleBundle/Twig/ArticleTwigExtension.php | ArticleTwigExtension.getTags | public function getTags(Request $request, $className)
{
$context = array();
$tagRepository = $this->em->getRepository($className);
$context['tags'] = $tagRepository->findBy(array(), array('name' => 'ASC'));
$searchTag = $request->get('tag') ? explode(',', $request->get('tag')) : null;
if ($searchTag) {
$context['activeTag'] = true;
$context['activeTags'] = $searchTag;
}
return $context;
} | php | public function getTags(Request $request, $className)
{
$context = array();
$tagRepository = $this->em->getRepository($className);
$context['tags'] = $tagRepository->findBy(array(), array('name' => 'ASC'));
$searchTag = $request->get('tag') ? explode(',', $request->get('tag')) : null;
if ($searchTag) {
$context['activeTag'] = true;
$context['activeTags'] = $searchTag;
}
return $context;
} | [
"public",
"function",
"getTags",
"(",
"Request",
"$",
"request",
",",
"$",
"className",
")",
"{",
"$",
"context",
"=",
"array",
"(",
")",
";",
"$",
"tagRepository",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"$",
"className",
")",
";",
... | Get tags array for view.
@param Request $request
@param string $className
@return array | [
"Get",
"tags",
"array",
"for",
"view",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/ArticleBundle/Twig/ArticleTwigExtension.php#L73-L87 | train |
Kunstmaan/KunstmaanBundlesCMS | src/Kunstmaan/ArticleBundle/Twig/ArticleTwigExtension.php | ArticleTwigExtension.getCategories | public function getCategories(Request $request, $className)
{
$context = array();
$categoryRepository = $this->em->getRepository($className);
$context['categories'] = $categoryRepository->findBy(array(), array('name' => 'ASC'));
$searchCategory = $request->get('category') ? explode(',', $request->get('category')) : null;
if ($searchCategory) {
$context['activeCategory'] = true;
$context['activeCategories'] = $searchCategory;
}
return $context;
} | php | public function getCategories(Request $request, $className)
{
$context = array();
$categoryRepository = $this->em->getRepository($className);
$context['categories'] = $categoryRepository->findBy(array(), array('name' => 'ASC'));
$searchCategory = $request->get('category') ? explode(',', $request->get('category')) : null;
if ($searchCategory) {
$context['activeCategory'] = true;
$context['activeCategories'] = $searchCategory;
}
return $context;
} | [
"public",
"function",
"getCategories",
"(",
"Request",
"$",
"request",
",",
"$",
"className",
")",
"{",
"$",
"context",
"=",
"array",
"(",
")",
";",
"$",
"categoryRepository",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"$",
"className",
")... | Get categories array for view.
@param Request $request
@param string $className
@return array | [
"Get",
"categories",
"array",
"for",
"view",
"."
] | d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1 | https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/ArticleBundle/Twig/ArticleTwigExtension.php#L97-L111 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.