id int32 0 241k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
42,300 | networking/init-cms-bundle | src/Controller/FrontendPageController.php | FrontendPageController.adminNavbarAction | public function adminNavbarAction(Request $request, $page_id = null)
{
if ($page_id) {
/** @var \Networking\InitCmsBundle\Entity\PageManager $pageManager */
$pageManager = $this->container->get('networking_init_cms.page_manager');
$page = $pageManager->find($page_id);
$request->attributes->set('_content', $page);
}
$response = $this->render(
'@NetworkingInitCms/Admin/esi_admin_navbar.html.twig',
['admin_pool' => $this->getAdminPool()]
);
// set the shared max age - which also marks the response as public
$response->setSharedMaxAge(10);
return $response;
} | php | public function adminNavbarAction(Request $request, $page_id = null)
{
if ($page_id) {
/** @var \Networking\InitCmsBundle\Entity\PageManager $pageManager */
$pageManager = $this->container->get('networking_init_cms.page_manager');
$page = $pageManager->find($page_id);
$request->attributes->set('_content', $page);
}
$response = $this->render(
'@NetworkingInitCms/Admin/esi_admin_navbar.html.twig',
['admin_pool' => $this->getAdminPool()]
);
// set the shared max age - which also marks the response as public
$response->setSharedMaxAge(10);
return $response;
} | [
"public",
"function",
"adminNavbarAction",
"(",
"Request",
"$",
"request",
",",
"$",
"page_id",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"page_id",
")",
"{",
"/** @var \\Networking\\InitCmsBundle\\Entity\\PageManager $pageManager */",
"$",
"pageManager",
"=",
"$",
"th... | Deliver the admin navigation bar via ajax.
@param null $page_id
@return Response | [
"Deliver",
"the",
"admin",
"navigation",
"bar",
"via",
"ajax",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/FrontendPageController.php#L431-L449 |
42,301 | networking/init-cms-bundle | src/Controller/HelpTextController.php | HelpTextController.adminHelpAction | public function adminHelpAction(Request $request, $adminCode, $action = '')
{
$parameters = ['adminCode' => $adminCode, 'action' => $action];
$defaultAdminCode = ['dashboard', 'overview'];
if ($action == '') {
$translationKey = $adminCode;
} else {
$translationKey = $adminCode.'.'.$action;
}
$helpTextManager = $this->get('networking_init_cms.help_text_manager');
$helpText = $helpTextManager->getHelpTextByKeyLocale($translationKey, $request->getLocale());
$parameters['help_text'] = $helpText;
if (!in_array($adminCode, $defaultAdminCode)) {
$admin = $this->container->get('sonata.admin.pool')->getAdminByAdminCode($adminCode);
$admin->setRequest($request);
$parameters['admin'] = $admin;
}
/** @var \Networking\InitCmsBundle\Admin\Pool $pool */
$pool = $this->get('sonata.admin.pool');
$parameters['admin_pool'] = $pool;
$parameters['base_template'] = isset($admin) ? $this->getBaseTemplate($request, $admin) : '@NetworkingInitCms/admin_layout.html.twig';
$dashBoardGroups = $pool->getDashboardNavigationGroups();
$parameters['help_nav'] = $this->adminGetHelpTextNavigation(
$dashBoardGroups,
$request->getLocale(),
$helpTextManager
);
return $this->render(
'@NetworkingInitCms/HelpText/adminHelp.html.twig',
$parameters
);
} | php | public function adminHelpAction(Request $request, $adminCode, $action = '')
{
$parameters = ['adminCode' => $adminCode, 'action' => $action];
$defaultAdminCode = ['dashboard', 'overview'];
if ($action == '') {
$translationKey = $adminCode;
} else {
$translationKey = $adminCode.'.'.$action;
}
$helpTextManager = $this->get('networking_init_cms.help_text_manager');
$helpText = $helpTextManager->getHelpTextByKeyLocale($translationKey, $request->getLocale());
$parameters['help_text'] = $helpText;
if (!in_array($adminCode, $defaultAdminCode)) {
$admin = $this->container->get('sonata.admin.pool')->getAdminByAdminCode($adminCode);
$admin->setRequest($request);
$parameters['admin'] = $admin;
}
/** @var \Networking\InitCmsBundle\Admin\Pool $pool */
$pool = $this->get('sonata.admin.pool');
$parameters['admin_pool'] = $pool;
$parameters['base_template'] = isset($admin) ? $this->getBaseTemplate($request, $admin) : '@NetworkingInitCms/admin_layout.html.twig';
$dashBoardGroups = $pool->getDashboardNavigationGroups();
$parameters['help_nav'] = $this->adminGetHelpTextNavigation(
$dashBoardGroups,
$request->getLocale(),
$helpTextManager
);
return $this->render(
'@NetworkingInitCms/HelpText/adminHelp.html.twig',
$parameters
);
} | [
"public",
"function",
"adminHelpAction",
"(",
"Request",
"$",
"request",
",",
"$",
"adminCode",
",",
"$",
"action",
"=",
"''",
")",
"{",
"$",
"parameters",
"=",
"[",
"'adminCode'",
"=>",
"$",
"adminCode",
",",
"'action'",
"=>",
"$",
"action",
"]",
";",
... | Help text page action.
@param Request $request
@param $adminCode
@param string $action
@return \Symfony\Component\HttpFoundation\Response | [
"Help",
"text",
"page",
"action",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/HelpTextController.php#L33-L70 |
42,302 | networking/init-cms-bundle | src/Controller/HelpTextController.php | HelpTextController.getBaseTemplate | protected function getBaseTemplate(Request $request, AbstractAdmin $admin)
{
if ($request->isXmlHttpRequest()) {
return $admin->getTemplate('ajax');
}
return $admin->getTemplate('layout');
} | php | protected function getBaseTemplate(Request $request, AbstractAdmin $admin)
{
if ($request->isXmlHttpRequest()) {
return $admin->getTemplate('ajax');
}
return $admin->getTemplate('layout');
} | [
"protected",
"function",
"getBaseTemplate",
"(",
"Request",
"$",
"request",
",",
"AbstractAdmin",
"$",
"admin",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"return",
"$",
"admin",
"->",
"getTemplate",
"(",
"'ajax'",
"... | return the base template name.
@param Request $request
@param AbstractAdmin $admin
@return string the template name | [
"return",
"the",
"base",
"template",
"name",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/HelpTextController.php#L80-L87 |
42,303 | networking/init-cms-bundle | src/Controller/HelpTextController.php | HelpTextController.adminGetHelpTextNavigation | protected function adminGetHelpTextNavigation(array $dashBoardGroups, $locale, $helpTextManager)
{
$navArray = [];
//add overview & dashboard manually
$navArray['overview']['group_name'] = $this->get('translator')->trans(
'title.help',
[],
'HelpTextAdmin'
);
$navArray['overview']['group_items']['0']['adminCode'] = 'overview';
$navArray['overview']['group_items']['0']['action'] = '';
$navArray['overview']['group_items']['0']['title'] = $this->get('translator')->trans(
'overview.title',
[],
'HelpTextAdmin'
);
$navArray['dashboard']['group_name'] = 'Dashboard';
$navArray['dashboard']['group_items']['0']['adminCode'] = 'dashboard';
$navArray['dashboard']['group_items']['0']['action'] = '';
$navArray['dashboard']['group_items']['0']['title'] = $this->get('translator')->trans(
'dashboard.title',
[],
'HelpTextAdmin'
);
foreach ($dashBoardGroups as $key => $group) {
foreach ($group['sub_group'] as $subGroup) {
$navArray[$subGroup['label']]['group_items'] = [];
$i = 0;
foreach ($subGroup['items'] as $admin) {
if (0 == $i++) {
$navArray[$subGroup['label']]['group_name'] = $this->get('translator')->trans(
$subGroup['label'],
[],
$admin->getTranslationDomain()
);
}
$help_text_result = $helpTextManager->searchHelpTextByKeyLocale($admin->getCode(), $locale);
if (count($help_text_result) > 0) {
foreach ($help_text_result as $row) {
//split Translation Key into adminCode and action
$strripos = strripos($row->getTranslationKey(), '.');
$action = substr($row->getTranslationKey(), $strripos + 1);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['adminCode'] = $admin->getCode(
);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['action'] = $action;
$navArray[$subGroup['label']]['group_items'][$row->getId()]['title'] = $row->getTitle();
}
}
}
}
}
return $navArray;
} | php | protected function adminGetHelpTextNavigation(array $dashBoardGroups, $locale, $helpTextManager)
{
$navArray = [];
//add overview & dashboard manually
$navArray['overview']['group_name'] = $this->get('translator')->trans(
'title.help',
[],
'HelpTextAdmin'
);
$navArray['overview']['group_items']['0']['adminCode'] = 'overview';
$navArray['overview']['group_items']['0']['action'] = '';
$navArray['overview']['group_items']['0']['title'] = $this->get('translator')->trans(
'overview.title',
[],
'HelpTextAdmin'
);
$navArray['dashboard']['group_name'] = 'Dashboard';
$navArray['dashboard']['group_items']['0']['adminCode'] = 'dashboard';
$navArray['dashboard']['group_items']['0']['action'] = '';
$navArray['dashboard']['group_items']['0']['title'] = $this->get('translator')->trans(
'dashboard.title',
[],
'HelpTextAdmin'
);
foreach ($dashBoardGroups as $key => $group) {
foreach ($group['sub_group'] as $subGroup) {
$navArray[$subGroup['label']]['group_items'] = [];
$i = 0;
foreach ($subGroup['items'] as $admin) {
if (0 == $i++) {
$navArray[$subGroup['label']]['group_name'] = $this->get('translator')->trans(
$subGroup['label'],
[],
$admin->getTranslationDomain()
);
}
$help_text_result = $helpTextManager->searchHelpTextByKeyLocale($admin->getCode(), $locale);
if (count($help_text_result) > 0) {
foreach ($help_text_result as $row) {
//split Translation Key into adminCode and action
$strripos = strripos($row->getTranslationKey(), '.');
$action = substr($row->getTranslationKey(), $strripos + 1);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['adminCode'] = $admin->getCode(
);
$navArray[$subGroup['label']]['group_items'][$row->getId()]['action'] = $action;
$navArray[$subGroup['label']]['group_items'][$row->getId()]['title'] = $row->getTitle();
}
}
}
}
}
return $navArray;
} | [
"protected",
"function",
"adminGetHelpTextNavigation",
"(",
"array",
"$",
"dashBoardGroups",
",",
"$",
"locale",
",",
"$",
"helpTextManager",
")",
"{",
"$",
"navArray",
"=",
"[",
"]",
";",
"//add overview & dashboard manually",
"$",
"navArray",
"[",
"'overview'",
... | Create the navigation for the help text view.
@param array $dashBoardGroups
@param $locale
@param $helpTextManager
@return array | [
"Create",
"the",
"navigation",
"for",
"the",
"help",
"text",
"view",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/HelpTextController.php#L98-L155 |
42,304 | networking/init-cms-bundle | src/Controller/MediaAdminController.php | MediaAdminController.redirectTo | public function redirectTo($object)
{
$url = false;
if ($this->getRequest()->get('btn_update_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_create')) {
$params = [];
if ($this->admin->hasActiveSubClass()) {
$params['subclass'] = $this->getRequest()->get('subclass');
}
$url = $this->admin->generateUrl('create', $params);
}
if (!$url) {
$url = $this->admin->generateObjectUrl('edit', $object);
}
return new RedirectResponse($url);
} | php | public function redirectTo($object)
{
$url = false;
if ($this->getRequest()->get('btn_update_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_list')) {
$url = $this->admin->generateUrl('list', ['active_tab' => $this->getRequest()->get('context')]);
}
if ($this->getRequest()->get('btn_create_and_create')) {
$params = [];
if ($this->admin->hasActiveSubClass()) {
$params['subclass'] = $this->getRequest()->get('subclass');
}
$url = $this->admin->generateUrl('create', $params);
}
if (!$url) {
$url = $this->admin->generateObjectUrl('edit', $object);
}
return new RedirectResponse($url);
} | [
"public",
"function",
"redirectTo",
"(",
"$",
"object",
")",
"{",
"$",
"url",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"get",
"(",
"'btn_update_and_list'",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"ad... | redirect the user depend on this choice.
@param object $object
@return Response | [
"redirect",
"the",
"user",
"depend",
"on",
"this",
"choice",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/MediaAdminController.php#L105-L129 |
42,305 | networking/init-cms-bundle | src/Controller/CkeditorAdminController.php | CkeditorAdminController.getTemplate | private function getTemplate($name)
{
$templates = $this->container->getParameter('sonata.formatter.ckeditor.configuration.templates');
if (isset($templates[$name])) {
return $templates[$name];
}
return null;
} | php | private function getTemplate($name)
{
$templates = $this->container->getParameter('sonata.formatter.ckeditor.configuration.templates');
if (isset($templates[$name])) {
return $templates[$name];
}
return null;
} | [
"private",
"function",
"getTemplate",
"(",
"$",
"name",
")",
"{",
"$",
"templates",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'sonata.formatter.ckeditor.configuration.templates'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"templates",
"[",
... | Returns a template.
@param string $name
@return string | [
"Returns",
"a",
"template",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/CkeditorAdminController.php#L242-L251 |
42,306 | networking/init-cms-bundle | src/Admin/Pool.php | Pool.getDashboardNavigationGroups | public function getDashboardNavigationGroups()
{
$groups = $this->getDashboardGroups();
$menuGroups = $this->getContainer()->getParameter('networking_init_cms.admin_menu_groups');
foreach ($menuGroups as $key => $menuGroup) {
foreach ($menuGroup['items'] as $k => $item) {
if (array_key_exists($item, $groups)) {
$menuGroups[$key]['sub_group'][$k] = $groups[$item];
}
}
}
return $menuGroups;
} | php | public function getDashboardNavigationGroups()
{
$groups = $this->getDashboardGroups();
$menuGroups = $this->getContainer()->getParameter('networking_init_cms.admin_menu_groups');
foreach ($menuGroups as $key => $menuGroup) {
foreach ($menuGroup['items'] as $k => $item) {
if (array_key_exists($item, $groups)) {
$menuGroups[$key]['sub_group'][$k] = $groups[$item];
}
}
}
return $menuGroups;
} | [
"public",
"function",
"getDashboardNavigationGroups",
"(",
")",
"{",
"$",
"groups",
"=",
"$",
"this",
"->",
"getDashboardGroups",
"(",
")",
";",
"$",
"menuGroups",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'networking_init_c... | Get the groups of admins that will be used to display the
admin menu on the side.
@return array | [
"Get",
"the",
"groups",
"of",
"admins",
"that",
"will",
"be",
"used",
"to",
"display",
"the",
"admin",
"menu",
"on",
"the",
"side",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/Pool.php#L28-L43 |
42,307 | networking/init-cms-bundle | src/Model/LayoutBlockFormListener.php | LayoutBlockFormListener.postBindData | public function postBindData(FormEvent $event)
{
/** @var $layoutBlock LayoutBlockInterface */
$layoutBlock = $event->getForm()->getData();
$contentObject = $layoutBlock->getContent();
if (!$contentObject instanceof ContentInterface) {
throw new \RuntimeException('Content Object must implement the ContentInterface');
}
$this->validate($event, $contentObject);
} | php | public function postBindData(FormEvent $event)
{
/** @var $layoutBlock LayoutBlockInterface */
$layoutBlock = $event->getForm()->getData();
$contentObject = $layoutBlock->getContent();
if (!$contentObject instanceof ContentInterface) {
throw new \RuntimeException('Content Object must implement the ContentInterface');
}
$this->validate($event, $contentObject);
} | [
"public",
"function",
"postBindData",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"/** @var $layoutBlock LayoutBlockInterface */",
"$",
"layoutBlock",
"=",
"$",
"event",
"->",
"getForm",
"(",
")",
"->",
"getData",
"(",
")",
";",
"$",
"contentObject",
"=",
"$",
"... | Bind the content type objects variables from the form.
If needed create an new content type object, or change to a new type deleting the old one.
Set the Content objects contentType and objectId fields accordingly.
@param FormEvent $event
@throws \RuntimeException | [
"Bind",
"the",
"content",
"type",
"objects",
"variables",
"from",
"the",
"form",
".",
"If",
"needed",
"create",
"an",
"new",
"content",
"type",
"object",
"or",
"change",
"to",
"a",
"new",
"type",
"deleting",
"the",
"old",
"one",
".",
"Set",
"the",
"Conte... | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/LayoutBlockFormListener.php#L131-L144 |
42,308 | networking/init-cms-bundle | src/Model/LayoutBlockFormListener.php | LayoutBlockFormListener.getContentType | public function getContentType(LayoutBlockInterface $layoutBlock = null)
{
if (is_null($layoutBlock) || !$classType = $layoutBlock->getClassType()) {
if ($this->contentType) {
return $this->contentType;
}
$contentTypes = $this->getContentTypes();
$classType = $contentTypes[0]['class'];
}
return $classType;
} | php | public function getContentType(LayoutBlockInterface $layoutBlock = null)
{
if (is_null($layoutBlock) || !$classType = $layoutBlock->getClassType()) {
if ($this->contentType) {
return $this->contentType;
}
$contentTypes = $this->getContentTypes();
$classType = $contentTypes[0]['class'];
}
return $classType;
} | [
"public",
"function",
"getContentType",
"(",
"LayoutBlockInterface",
"$",
"layoutBlock",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"layoutBlock",
")",
"||",
"!",
"$",
"classType",
"=",
"$",
"layoutBlock",
"->",
"getClassType",
"(",
")",
")",
"... | Get the content type of the content object, if the object is new, use the first available type.
@param LayoutBlockInterface $layoutBlock
@return string | [
"Get",
"the",
"content",
"type",
"of",
"the",
"content",
"object",
"if",
"the",
"object",
"is",
"new",
"use",
"the",
"first",
"available",
"type",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/LayoutBlockFormListener.php#L192-L205 |
42,309 | networking/init-cms-bundle | src/Admin/Model/MenuItemAdmin.php | MenuItemAdmin.getTranslatedLinkTargets | public function getTranslatedLinkTargets()
{
$translatedLinkTargets = [];
foreach ($this->linkTargets as $key => $value) {
$translatedLinkTargets[$key] = $value;
}
return $translatedLinkTargets;
} | php | public function getTranslatedLinkTargets()
{
$translatedLinkTargets = [];
foreach ($this->linkTargets as $key => $value) {
$translatedLinkTargets[$key] = $value;
}
return $translatedLinkTargets;
} | [
"public",
"function",
"getTranslatedLinkTargets",
"(",
")",
"{",
"$",
"translatedLinkTargets",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"linkTargets",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"translatedLinkTargets",
"[",
"$",
"ke... | returns all translated link targets.
@return array | [
"returns",
"all",
"translated",
"link",
"targets",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/Model/MenuItemAdmin.php#L364-L372 |
42,310 | networking/init-cms-bundle | src/Model/LayoutBlock.php | LayoutBlock.setIsActive | public function setIsActive($active)
{
$active = $active ? true : false;
$this->isActive = $active;
return $this;
} | php | public function setIsActive($active)
{
$active = $active ? true : false;
$this->isActive = $active;
return $this;
} | [
"public",
"function",
"setIsActive",
"(",
"$",
"active",
")",
"{",
"$",
"active",
"=",
"$",
"active",
"?",
"true",
":",
"false",
";",
"$",
"this",
"->",
"isActive",
"=",
"$",
"active",
";",
"return",
"$",
"this",
";",
"}"
] | Set isActive.
@param bool $active
@return $this | [
"Set",
"isActive",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Model/LayoutBlock.php#L276-L282 |
42,311 | networking/init-cms-bundle | src/Controller/AdminResettingController.php | AdminResettingController.sendResettingEmailMessage | private function sendResettingEmailMessage(UserInterface $user): void
{
$url = $this->generateUrl('networking_init_cms_admin_resetting_reset', [
'token' => $user->getConfirmationToken(),
], UrlGeneratorInterface::ABSOLUTE_URL);
$rendered = $this->renderView($this->container->getParameter('fos_user.resetting.email.template'), [
'user' => $user,
'confirmationUrl' => $url,
]);
// Render the email, use the first line as the subject, and the rest as the body
$renderedLines = explode(PHP_EOL, trim($rendered));
$subject = array_shift($renderedLines);
$body = implode(PHP_EOL, $renderedLines);
$message = (new \Swift_Message())
->setSubject($subject)
->setFrom($this->container->getParameter('fos_user.resetting.email.from_email'))
->setTo((string) $user->getEmail())
->setBody($body);
$this->get('mailer')->send($message);
} | php | private function sendResettingEmailMessage(UserInterface $user): void
{
$url = $this->generateUrl('networking_init_cms_admin_resetting_reset', [
'token' => $user->getConfirmationToken(),
], UrlGeneratorInterface::ABSOLUTE_URL);
$rendered = $this->renderView($this->container->getParameter('fos_user.resetting.email.template'), [
'user' => $user,
'confirmationUrl' => $url,
]);
// Render the email, use the first line as the subject, and the rest as the body
$renderedLines = explode(PHP_EOL, trim($rendered));
$subject = array_shift($renderedLines);
$body = implode(PHP_EOL, $renderedLines);
$message = (new \Swift_Message())
->setSubject($subject)
->setFrom($this->container->getParameter('fos_user.resetting.email.from_email'))
->setTo((string) $user->getEmail())
->setBody($body);
$this->get('mailer')->send($message);
} | [
"private",
"function",
"sendResettingEmailMessage",
"(",
"UserInterface",
"$",
"user",
")",
":",
"void",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"generateUrl",
"(",
"'networking_init_cms_admin_resetting_reset'",
",",
"[",
"'token'",
"=>",
"$",
"user",
"->",
"ge... | Send an email to a user to confirm the password reset.
@param UserInterface $user | [
"Send",
"an",
"email",
"to",
"a",
"user",
"to",
"confirm",
"the",
"password",
"reset",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/AdminResettingController.php#L178-L199 |
42,312 | networking/init-cms-bundle | src/Helper/LanguageSwitcherHelper.php | LanguageSwitcherHelper.getQueryString | public function getQueryString()
{
$qs = Request::normalizeQueryString($this->requestStack->getCurrentRequest()->server->get('QUERY_STRING'));
return '' === $qs ? null : $qs;
} | php | public function getQueryString()
{
$qs = Request::normalizeQueryString($this->requestStack->getCurrentRequest()->server->get('QUERY_STRING'));
return '' === $qs ? null : $qs;
} | [
"public",
"function",
"getQueryString",
"(",
")",
"{",
"$",
"qs",
"=",
"Request",
"::",
"normalizeQueryString",
"(",
"$",
"this",
"->",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
"->",
"server",
"->",
"get",
"(",
"'QUERY_STRING'",
")",
")",
";",
... | Get the query string parameters for the current request
Not used at present.
@return null|string | [
"Get",
"the",
"query",
"string",
"parameters",
"for",
"the",
"current",
"request",
"Not",
"used",
"at",
"present",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/LanguageSwitcherHelper.php#L203-L208 |
42,313 | networking/init-cms-bundle | src/Helper/LanguageSwitcherHelper.php | LanguageSwitcherHelper.getPathInfo | public function getPathInfo($referrer = null)
{
$baseUrl = $this->prepareBaseUrl($referrer);
if (null === ($referrer)) {
return '/';
}
$pathInfo = '/';
// Remove the query string from REQUEST_URI
if ($pos = strpos($referrer, '?')) {
$referrer = substr($referrer, 0, $pos);
}
$host = $this->requestStack->getCurrentRequest()->getHost();
if ((null !== $baseUrl) && (false === ($pathInfo = substr($referrer, strlen($baseUrl))))) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
} elseif (null === $baseUrl) {
return $referrer;
} elseif ($pos = strpos($pathInfo, $host)) {
$pathInfo = substr($pathInfo, $pos + strlen($host));
}
return (string) $pathInfo;
} | php | public function getPathInfo($referrer = null)
{
$baseUrl = $this->prepareBaseUrl($referrer);
if (null === ($referrer)) {
return '/';
}
$pathInfo = '/';
// Remove the query string from REQUEST_URI
if ($pos = strpos($referrer, '?')) {
$referrer = substr($referrer, 0, $pos);
}
$host = $this->requestStack->getCurrentRequest()->getHost();
if ((null !== $baseUrl) && (false === ($pathInfo = substr($referrer, strlen($baseUrl))))) {
// If substr() returns false then PATH_INFO is set to an empty string
return '/';
} elseif (null === $baseUrl) {
return $referrer;
} elseif ($pos = strpos($pathInfo, $host)) {
$pathInfo = substr($pathInfo, $pos + strlen($host));
}
return (string) $pathInfo;
} | [
"public",
"function",
"getPathInfo",
"(",
"$",
"referrer",
"=",
"null",
")",
"{",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"prepareBaseUrl",
"(",
"$",
"referrer",
")",
";",
"if",
"(",
"null",
"===",
"(",
"$",
"referrer",
")",
")",
"{",
"return",
"'/'"... | Returns the uri Path for the current uri if no referrer given,
otherwise it returns the path for the URL given.
@param null $referrer
@return null|string | [
"Returns",
"the",
"uri",
"Path",
"for",
"the",
"current",
"uri",
"if",
"no",
"referrer",
"given",
"otherwise",
"it",
"returns",
"the",
"path",
"for",
"the",
"URL",
"given",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/LanguageSwitcherHelper.php#L218-L244 |
42,314 | networking/init-cms-bundle | src/Entity/MenuItemManager.php | MenuItemManager.findAllJoinPage | public function findAllJoinPage()
{
$qb = $this->createQueryBuilder('m');
$qb->select('m,p');
$qb->leftJoin('m.page', 'p');
return $qb->getQuery()->execute();
} | php | public function findAllJoinPage()
{
$qb = $this->createQueryBuilder('m');
$qb->select('m,p');
$qb->leftJoin('m.page', 'p');
return $qb->getQuery()->execute();
} | [
"public",
"function",
"findAllJoinPage",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'m,p'",
")",
";",
"$",
"qb",
"->",
"leftJoin",
"(",
"'m.page'",
",",
"'p'",
")",
... | Get all menu items and their pages if available.
@return mixed | [
"Get",
"all",
"menu",
"items",
"and",
"their",
"pages",
"if",
"available",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Entity/MenuItemManager.php#L145-L152 |
42,315 | networking/init-cms-bundle | src/Controller/CacheController.php | CacheController.clearAction | public function clearAction()
{
/*
* to do: check if logged in user is sysadmin
* */
if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
/** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
$phpCache = $this->get('networking_init_cms.lib.php_cache');
$phpCache->clean();
/*clean function does not return status, therefore set success to true */
$success = true;
$response = ['success' => $success];
return new Response(json_encode($response));
} else {
/*wrong autorisation */
$success = false;
$response = ['success' => $success];
return new Response(json_encode($response));
}
} | php | public function clearAction()
{
/*
* to do: check if logged in user is sysadmin
* */
if ($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
/** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
$phpCache = $this->get('networking_init_cms.lib.php_cache');
$phpCache->clean();
/*clean function does not return status, therefore set success to true */
$success = true;
$response = ['success' => $success];
return new Response(json_encode($response));
} else {
/*wrong autorisation */
$success = false;
$response = ['success' => $success];
return new Response(json_encode($response));
}
} | [
"public",
"function",
"clearAction",
"(",
")",
"{",
"/*\n * to do: check if logged in user is sysadmin\n * */",
"if",
"(",
"$",
"this",
"->",
"authorizationChecker",
"->",
"isGranted",
"(",
"'ROLE_SUPER_ADMIN'",
")",
")",
"{",
"/** @var \\Networking\\InitCmsBu... | clear the Cache.
@return Response | [
"clear",
"the",
"Cache",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/CacheController.php#L45-L68 |
42,316 | networking/init-cms-bundle | src/Controller/MenuItemAdminController.php | MenuItemAdminController.placementAction | public function placementAction()
{
/** @var \Networking\InitCmsBundle\Entity\MenuItem $rootNode */
$rootNode = $this->admin->getObject($this->get('session')->get('root_menu_id'));
if (!$rootNode) {
throw new NotFoundHttpException();
}
if ($rootNode->getChildren()->count() > 1) {
return $this->listAction(null, null, 'placement', $this->get('session')->get('root_menu_id'));
} else {
return false;
}
} | php | public function placementAction()
{
/** @var \Networking\InitCmsBundle\Entity\MenuItem $rootNode */
$rootNode = $this->admin->getObject($this->get('session')->get('root_menu_id'));
if (!$rootNode) {
throw new NotFoundHttpException();
}
if ($rootNode->getChildren()->count() > 1) {
return $this->listAction(null, null, 'placement', $this->get('session')->get('root_menu_id'));
} else {
return false;
}
} | [
"public",
"function",
"placementAction",
"(",
")",
"{",
"/** @var \\Networking\\InitCmsBundle\\Entity\\MenuItem $rootNode */",
"$",
"rootNode",
"=",
"$",
"this",
"->",
"admin",
"->",
"getObject",
"(",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"get",
"... | renders the template html for the modal.
@return bool|string|Response
@throws \Sonata\AdminBundle\Exception\NoValueException | [
"renders",
"the",
"template",
"html",
"for",
"the",
"modal",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Controller/MenuItemAdminController.php#L490-L504 |
42,317 | networking/init-cms-bundle | src/EventListener/UserActivityListener.php | UserActivityListener.onCoreController | public function onCoreController(FilterControllerEvent $event)
{
// do not capture admin cms urls
if (!preg_match('/.*\/admin\/.*/', $event->getRequest()->getRequestUri())) {
return;
}
if (!$this->tokenStorage->getToken()) {
return;
}
$user = $this->tokenStorage->getToken()->getUser();
if ($user instanceof UserInterface) {
//here we can update the user as necessary
if (method_exists($user, 'setLastActivity')) {
try {
$user->setLastActivity(new \DateTime('now'));
$this->em->persist($user);
$this->em->flush($user);
} catch (\Doctrine\ORM\ORMException $e) {
//do nothing, entity manager is closed
}
}
}
} | php | public function onCoreController(FilterControllerEvent $event)
{
// do not capture admin cms urls
if (!preg_match('/.*\/admin\/.*/', $event->getRequest()->getRequestUri())) {
return;
}
if (!$this->tokenStorage->getToken()) {
return;
}
$user = $this->tokenStorage->getToken()->getUser();
if ($user instanceof UserInterface) {
//here we can update the user as necessary
if (method_exists($user, 'setLastActivity')) {
try {
$user->setLastActivity(new \DateTime('now'));
$this->em->persist($user);
$this->em->flush($user);
} catch (\Doctrine\ORM\ORMException $e) {
//do nothing, entity manager is closed
}
}
}
} | [
"public",
"function",
"onCoreController",
"(",
"FilterControllerEvent",
"$",
"event",
")",
"{",
"// do not capture admin cms urls",
"if",
"(",
"!",
"preg_match",
"(",
"'/.*\\/admin\\/.*/'",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"getRequestUri",
"(",... | On each request we want to update the user's last activity datetime.
@param \Symfony\Component\HttpKernel\Event\FilterControllerEvent $event | [
"On",
"each",
"request",
"we",
"want",
"to",
"update",
"the",
"user",
"s",
"last",
"activity",
"datetime",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/EventListener/UserActivityListener.php#L53-L78 |
42,318 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.getParentMenu | public function getParentMenu(Menu $menu, MenuItem $childNode)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
$parentId = $childNode->getParent()->getId();
if ($menuItem->getName() != $parentId) {
continue;
}
return $menuItem;
}
return false;
} | php | public function getParentMenu(Menu $menu, MenuItem $childNode)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
$parentId = $childNode->getParent()->getId();
if ($menuItem->getName() != $parentId) {
continue;
}
return $menuItem;
}
return false;
} | [
"public",
"function",
"getParentMenu",
"(",
"Menu",
"$",
"menu",
",",
"MenuItem",
"$",
"childNode",
")",
"{",
"$",
"itemIterator",
"=",
"new",
"RecursiveItemIterator",
"(",
"$",
"menu",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"iterator",
"=",
"new",
... | Recursively get parents.
@param $menu - menu to look for the parent in
@param $childNode - menu node whose parent we are looking for
@return mixed | [
"Recursively",
"get",
"parents",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L210-L224 |
42,319 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.createFromMenuItem | public function createFromMenuItem(MenuItem $menuItem)
{
if ($path = $menuItem->getPath()) {
$uri = $this->request->getBaseUrl().$path;
} elseif ($menuItem->getRedirectUrl()) {
$uri = $menuItem->getRedirectUrl();
} elseif ($menuItem->getInternalUrl()) {
$uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
} elseif ($contentRoute = $menuItem->getContentRoute()) {
$route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
$uri = $this->request->getBaseUrl().$route->getPath();
} else {
$uri = '#';
}
$options = [
'uri' => $uri,
'label' => $menuItem->getName(),
'attributes' => [],
'linkAttributes' => $menuItem->getLinkAttributes(),
'childrenAttributes' => [],
'labelAttributes' => [],
'extras' => [],
'display' => true,
'displayChildren' => true,
];
$item = $this->factory->createItem($menuItem->getId(), $options);
if ($menuItem->isHidden()) {
$item->setDisplay(false);
}
return $item;
} | php | public function createFromMenuItem(MenuItem $menuItem)
{
if ($path = $menuItem->getPath()) {
$uri = $this->request->getBaseUrl().$path;
} elseif ($menuItem->getRedirectUrl()) {
$uri = $menuItem->getRedirectUrl();
} elseif ($menuItem->getInternalUrl()) {
$uri = $this->request->getBaseUrl().$menuItem->getInternalUrl();
} elseif ($contentRoute = $menuItem->getContentRoute()) {
$route = ContentRouteManager::generateRoute($contentRoute, $contentRoute->getPath(), '');
$uri = $this->request->getBaseUrl().$route->getPath();
} else {
$uri = '#';
}
$options = [
'uri' => $uri,
'label' => $menuItem->getName(),
'attributes' => [],
'linkAttributes' => $menuItem->getLinkAttributes(),
'childrenAttributes' => [],
'labelAttributes' => [],
'extras' => [],
'display' => true,
'displayChildren' => true,
];
$item = $this->factory->createItem($menuItem->getId(), $options);
if ($menuItem->isHidden()) {
$item->setDisplay(false);
}
return $item;
} | [
"public",
"function",
"createFromMenuItem",
"(",
"MenuItem",
"$",
"menuItem",
")",
"{",
"if",
"(",
"$",
"path",
"=",
"$",
"menuItem",
"->",
"getPath",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"request",
"->",
"getBaseUrl",
"(",
")",
".... | Create an new node using the ContentRoute object to generate the uri.
@param \Networking\InitCmsBundle\Entity\MenuItem $menuItem
@return \Knp\Menu\ItemInterface | [
"Create",
"an",
"new",
"node",
"using",
"the",
"ContentRoute",
"object",
"to",
"generate",
"the",
"uri",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L233-L267 |
42,320 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.getFullMenu | public function getFullMenu($menuName)
{
if (is_array($menuName)) {
$menuName = reset($menuName);
}
if (array_key_exists($menuName, $this->menuIterators) && count($this->menuIterators[$menuName]) > 0) {
return $this->menuIterators[$menuName];
}
/** @var $mainMenu Menu */
$mainMenu = $this->menuManager->findOneBy(
['name' => $menuName, 'locale' => $this->request->getLocale()]
);
if (!$mainMenu) {
return [];
}
$this->menuIterators[$menuName] = $this->menuManager->getChildrenByStatus(
$mainMenu,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $this->menuIterators[$menuName];
} | php | public function getFullMenu($menuName)
{
if (is_array($menuName)) {
$menuName = reset($menuName);
}
if (array_key_exists($menuName, $this->menuIterators) && count($this->menuIterators[$menuName]) > 0) {
return $this->menuIterators[$menuName];
}
/** @var $mainMenu Menu */
$mainMenu = $this->menuManager->findOneBy(
['name' => $menuName, 'locale' => $this->request->getLocale()]
);
if (!$mainMenu) {
return [];
}
$this->menuIterators[$menuName] = $this->menuManager->getChildrenByStatus(
$mainMenu,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $this->menuIterators[$menuName];
} | [
"public",
"function",
"getFullMenu",
"(",
"$",
"menuName",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"menuName",
")",
")",
"{",
"$",
"menuName",
"=",
"reset",
"(",
"$",
"menuName",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"menuName",
... | Retrieve the full menu tree.
@param string $menuName
@return array|bool | [
"Retrieve",
"the",
"full",
"menu",
"tree",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L276-L305 |
42,321 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.getSubMenu | public function getSubMenu($menuName, $level = 1)
{
$currentParent = false;
$mainMenuIterator = $this->getFullMenu($menuName);
if (!$mainMenuIterator) {
return false;
}
foreach ($mainMenuIterator as $menuItem) {
if ($this->currentPath === $menuItem->getPath()
|| $this->currentPath === $menuItem->getInternalUrl()
) {
$currentParent = $menuItem->getParentByLevel($level);
}
}
if (!$currentParent) {
return false;
}
$menuIterator = $this->menuManager->getChildrenByStatus(
$currentParent,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $menuIterator;
} | php | public function getSubMenu($menuName, $level = 1)
{
$currentParent = false;
$mainMenuIterator = $this->getFullMenu($menuName);
if (!$mainMenuIterator) {
return false;
}
foreach ($mainMenuIterator as $menuItem) {
if ($this->currentPath === $menuItem->getPath()
|| $this->currentPath === $menuItem->getInternalUrl()
) {
$currentParent = $menuItem->getParentByLevel($level);
}
}
if (!$currentParent) {
return false;
}
$menuIterator = $this->menuManager->getChildrenByStatus(
$currentParent,
false,
null,
'ASC',
false,
$this->viewStatus
);
return $menuIterator;
} | [
"public",
"function",
"getSubMenu",
"(",
"$",
"menuName",
",",
"$",
"level",
"=",
"1",
")",
"{",
"$",
"currentParent",
"=",
"false",
";",
"$",
"mainMenuIterator",
"=",
"$",
"this",
"->",
"getFullMenu",
"(",
"$",
"menuName",
")",
";",
"if",
"(",
"!",
... | Retrieves the sub menu array based on the current url.
@param string $menuName
@param int $level
@return array|bool | [
"Retrieves",
"the",
"sub",
"menu",
"array",
"based",
"on",
"the",
"current",
"url",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L315-L347 |
42,322 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.createMenu | public function createMenu(Menu $menu, $menuIterator, $startDepth)
{
foreach ($menuIterator as $childNode) {
$this->addNodeToMenu($menu, $childNode, $startDepth);
}
return $menu;
} | php | public function createMenu(Menu $menu, $menuIterator, $startDepth)
{
foreach ($menuIterator as $childNode) {
$this->addNodeToMenu($menu, $childNode, $startDepth);
}
return $menu;
} | [
"public",
"function",
"createMenu",
"(",
"Menu",
"$",
"menu",
",",
"$",
"menuIterator",
",",
"$",
"startDepth",
")",
"{",
"foreach",
"(",
"$",
"menuIterator",
"as",
"$",
"childNode",
")",
"{",
"$",
"this",
"->",
"addNodeToMenu",
"(",
"$",
"menu",
",",
... | Creates a full menu based on the starting point given.
@param Menu $menu
@param array $menuIterator
@param int $startDepth
@return Menu | [
"Creates",
"a",
"full",
"menu",
"based",
"on",
"the",
"starting",
"point",
"given",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L358-L365 |
42,323 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.addNodeToMenu | public function addNodeToMenu(Menu $menu, MenuItem $node, $startDepth)
{
if ($node->getLvl() < $startDepth) {
return false;
}
if ($node->getLvl() > $startDepth) {
$menu = $this->getParentMenu($menu, $node);
}
if (is_object($menu)) {
$knpMenuNode = $this->createFromMenuItem($node);
if (!is_null($knpMenuNode)) {
$menu->addChild($knpMenuNode);
$knpMenuNode->setAttribute('class', $node->getLinkClass());
$knpMenuNode->setExtra('translation_domain', false);
if ($node->getVisibility() != MenuItem::VISIBILITY_PUBLIC && !$this->isLoggedIn) {
$knpMenuNode->setDisplay(false);
}
return $knpMenuNode;
}
}
return false;
} | php | public function addNodeToMenu(Menu $menu, MenuItem $node, $startDepth)
{
if ($node->getLvl() < $startDepth) {
return false;
}
if ($node->getLvl() > $startDepth) {
$menu = $this->getParentMenu($menu, $node);
}
if (is_object($menu)) {
$knpMenuNode = $this->createFromMenuItem($node);
if (!is_null($knpMenuNode)) {
$menu->addChild($knpMenuNode);
$knpMenuNode->setAttribute('class', $node->getLinkClass());
$knpMenuNode->setExtra('translation_domain', false);
if ($node->getVisibility() != MenuItem::VISIBILITY_PUBLIC && !$this->isLoggedIn) {
$knpMenuNode->setDisplay(false);
}
return $knpMenuNode;
}
}
return false;
} | [
"public",
"function",
"addNodeToMenu",
"(",
"Menu",
"$",
"menu",
",",
"MenuItem",
"$",
"node",
",",
"$",
"startDepth",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"getLvl",
"(",
")",
"<",
"$",
"startDepth",
")",
"{",
"return",
"false",
";",
"}",
"if",
... | Add a menu item node at the correct place in the menu.
@param Menu $menu
@param MenuItem $node
@param $startDepth
@return bool|\Knp\Menu\ItemInterface | [
"Add",
"a",
"menu",
"item",
"node",
"at",
"the",
"correct",
"place",
"in",
"the",
"menu",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L376-L401 |
42,324 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.showOnlyCurrentChildren | public function showOnlyCurrentChildren(ItemInterface $menu)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/** @var \Knp\Menu\MenuItem $menuItem */
if (!$this->matcher->isCurrent($menuItem) && !$this->matcher->isAncestor($menuItem)) {
$menuItem->setDisplayChildren(false);
}
}
} | php | public function showOnlyCurrentChildren(ItemInterface $menu)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/** @var \Knp\Menu\MenuItem $menuItem */
if (!$this->matcher->isCurrent($menuItem) && !$this->matcher->isAncestor($menuItem)) {
$menuItem->setDisplayChildren(false);
}
}
} | [
"public",
"function",
"showOnlyCurrentChildren",
"(",
"ItemInterface",
"$",
"menu",
")",
"{",
"$",
"itemIterator",
"=",
"new",
"RecursiveItemIterator",
"(",
"$",
"menu",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIter... | Set the children menu item nodes to be shown only if the node
is current or the parent is a current ancestor.
@param ItemInterface $menu | [
"Set",
"the",
"children",
"menu",
"item",
"nodes",
"to",
"be",
"shown",
"only",
"if",
"the",
"node",
"is",
"current",
"or",
"the",
"parent",
"is",
"a",
"current",
"ancestor",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L409-L420 |
42,325 | networking/init-cms-bundle | src/Menu/MenuBuilder.php | MenuBuilder.setRecursiveAttribute | public function setRecursiveAttribute(ItemInterface $menu, array $attr)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/* @var ItemInterface $menuItem */
$menuItem->setChildrenAttributes($attr);
}
} | php | public function setRecursiveAttribute(ItemInterface $menu, array $attr)
{
$itemIterator = new RecursiveItemIterator($menu->getIterator());
$iterator = new \RecursiveIteratorIterator($itemIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $menuItem) {
/* @var ItemInterface $menuItem */
$menuItem->setChildrenAttributes($attr);
}
} | [
"public",
"function",
"setRecursiveAttribute",
"(",
"ItemInterface",
"$",
"menu",
",",
"array",
"$",
"attr",
")",
"{",
"$",
"itemIterator",
"=",
"new",
"RecursiveItemIterator",
"(",
"$",
"menu",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"iterator",
"=",
... | Recursively set attributes on an item and its' children.
@param ItemInterface $menu
@param array $attr | [
"Recursively",
"set",
"attributes",
"on",
"an",
"item",
"and",
"its",
"children",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Menu/MenuBuilder.php#L442-L451 |
42,326 | networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.renderInitCmsBlock | public function renderInitCmsBlock($template, LayoutBlockInterface $layoutBlock, $params = [])
{
if (!$serializedContent = $layoutBlock->getSnapshotContent()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
// Live View
$contentItem = $this->serializer->deserialize(
$serializedContent,
$layoutBlock->getClassType(),
'json'
);
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return '---';
}
$options = $contentItem->getTemplateOptions($params);
$options = array_merge($options, $params);
return $this->templating->render($template, $options);
} | php | public function renderInitCmsBlock($template, LayoutBlockInterface $layoutBlock, $params = [])
{
if (!$serializedContent = $layoutBlock->getSnapshotContent()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
// Live View
$contentItem = $this->serializer->deserialize(
$serializedContent,
$layoutBlock->getClassType(),
'json'
);
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return '---';
}
$options = $contentItem->getTemplateOptions($params);
$options = array_merge($options, $params);
return $this->templating->render($template, $options);
} | [
"public",
"function",
"renderInitCmsBlock",
"(",
"$",
"template",
",",
"LayoutBlockInterface",
"$",
"layoutBlock",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"serializedContent",
"=",
"$",
"layoutBlock",
"->",
"getSnapshotContent",
"(",
... | Returns an HTML block for output in the frontend.
@param $template
@param LayoutBlockInterface $layoutBlock
@param array $params
@return string | [
"Returns",
"an",
"HTML",
"block",
"for",
"output",
"in",
"the",
"frontend",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L244-L269 |
42,327 | networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.renderInitcmsAdminBlock | public function renderInitcmsAdminBlock(LayoutBlockInterface $layoutBlock)
{
if ($layoutBlock->getObjectId()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
$classType = $layoutBlock->getClassType();
$contentItem = new $classType();
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return false;
}
$adminContent = $contentItem->getAdminContent();
return $this->templating->render($adminContent['template'], $adminContent['content']);
} | php | public function renderInitcmsAdminBlock(LayoutBlockInterface $layoutBlock)
{
if ($layoutBlock->getObjectId()) {
// Draft View
$contentItem = $layoutBlock->getContent();
} else {
$classType = $layoutBlock->getClassType();
$contentItem = new $classType();
}
if (!is_object($contentItem)) {
$this->layoutBlockAdmin->delete($layoutBlock);
return false;
}
$adminContent = $contentItem->getAdminContent();
return $this->templating->render($adminContent['template'], $adminContent['content']);
} | [
"public",
"function",
"renderInitcmsAdminBlock",
"(",
"LayoutBlockInterface",
"$",
"layoutBlock",
")",
"{",
"if",
"(",
"$",
"layoutBlock",
"->",
"getObjectId",
"(",
")",
")",
"{",
"// Draft View",
"$",
"contentItem",
"=",
"$",
"layoutBlock",
"->",
"getContent",
... | Returns an HTML block for output in the admin area.
@param LayoutBlockInterface $layoutBlock
@return bool|string | [
"Returns",
"an",
"HTML",
"block",
"for",
"output",
"in",
"the",
"admin",
"area",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L278-L297 |
42,328 | networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getInitcmsAdminIconPath | public function getInitcmsAdminIconPath(
AdminInterface $admin,
$size = 'small',
$active = false
) {
$state = $active ? '_active' : '';
$imagePath = '/bundles/networkinginitcms/img/icons/icon_blank_'.$size.$state.'.png';
$bundleGuesser = new BundleGuesser();
$bundleGuesser->initialize($admin);
$bundleName = $bundleGuesser->getBundleShortName();
$bundles = $this->kernel->getBundle($bundleName, false);
$bundle = end($bundles);
$path = $bundle->getPath();
$slug = self::slugify($admin->getLabel());
$iconName = 'icon_'.$slug.'_'.$size.$state;
$folders = ['img/icons', 'image/icons', 'img', 'image'];
$imageType = ['gif', 'png', 'jpg', 'jpeg'];
foreach ($folders as $folder) {
foreach ($imageType as $type) {
$icon = $folder.DIRECTORY_SEPARATOR.$iconName.'.'.$type;
if (file_exists(
$path.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.$icon
)
) {
$imagePath = 'bundles'.DIRECTORY_SEPARATOR.str_replace(
'bundle',
'',
strtolower($bundleName)
).DIRECTORY_SEPARATOR.$icon;
}
}
}
return $imagePath;
} | php | public function getInitcmsAdminIconPath(
AdminInterface $admin,
$size = 'small',
$active = false
) {
$state = $active ? '_active' : '';
$imagePath = '/bundles/networkinginitcms/img/icons/icon_blank_'.$size.$state.'.png';
$bundleGuesser = new BundleGuesser();
$bundleGuesser->initialize($admin);
$bundleName = $bundleGuesser->getBundleShortName();
$bundles = $this->kernel->getBundle($bundleName, false);
$bundle = end($bundles);
$path = $bundle->getPath();
$slug = self::slugify($admin->getLabel());
$iconName = 'icon_'.$slug.'_'.$size.$state;
$folders = ['img/icons', 'image/icons', 'img', 'image'];
$imageType = ['gif', 'png', 'jpg', 'jpeg'];
foreach ($folders as $folder) {
foreach ($imageType as $type) {
$icon = $folder.DIRECTORY_SEPARATOR.$iconName.'.'.$type;
if (file_exists(
$path.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.$icon
)
) {
$imagePath = 'bundles'.DIRECTORY_SEPARATOR.str_replace(
'bundle',
'',
strtolower($bundleName)
).DIRECTORY_SEPARATOR.$icon;
}
}
}
return $imagePath;
} | [
"public",
"function",
"getInitcmsAdminIconPath",
"(",
"AdminInterface",
"$",
"admin",
",",
"$",
"size",
"=",
"'small'",
",",
"$",
"active",
"=",
"false",
")",
"{",
"$",
"state",
"=",
"$",
"active",
"?",
"'_active'",
":",
"''",
";",
"$",
"imagePath",
"=",... | Guess which icon should represent an entity admin.
@param AdminInterface $admin
@param string $size
@param bool $active
@return string
@todo This is a bit of a hack. Need to provide a better way of providing admin icons | [
"Guess",
"which",
"icon",
"should",
"represent",
"an",
"entity",
"admin",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L476-L517 |
42,329 | networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getCurrentAdminLocale | public function getCurrentAdminLocale(\Sonata\AdminBundle\Admin\AdminInterface $admin)
{
$locale = '';
if (!$admin->hasRequest()) {
$admin->setRequest($this->requestStack->getCurrentRequest());
}
if ($subject = $admin->getSubject()) {
return $this->getFieldValue($subject, 'locale');
} elseif ($filter = $admin->getDatagrid()->getFilter('locale')) {
/** @var \Sonata\AdminBundle\Filter\Filter $filter */
$data = $filter->getValue();
if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
$locale = $this->getCurrentLocale();
}
$data['value'] = trim($data['value']);
if (strlen($data['value']) > 0) {
$locale = $data['value'];
}
if (!$locale && method_exists($admin, 'getDefaultLocale')) {
$locale = $admin->getDefaultLocale();
}
}
return $locale;
} | php | public function getCurrentAdminLocale(\Sonata\AdminBundle\Admin\AdminInterface $admin)
{
$locale = '';
if (!$admin->hasRequest()) {
$admin->setRequest($this->requestStack->getCurrentRequest());
}
if ($subject = $admin->getSubject()) {
return $this->getFieldValue($subject, 'locale');
} elseif ($filter = $admin->getDatagrid()->getFilter('locale')) {
/** @var \Sonata\AdminBundle\Filter\Filter $filter */
$data = $filter->getValue();
if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
$locale = $this->getCurrentLocale();
}
$data['value'] = trim($data['value']);
if (strlen($data['value']) > 0) {
$locale = $data['value'];
}
if (!$locale && method_exists($admin, 'getDefaultLocale')) {
$locale = $admin->getDefaultLocale();
}
}
return $locale;
} | [
"public",
"function",
"getCurrentAdminLocale",
"(",
"\\",
"Sonata",
"\\",
"AdminBundle",
"\\",
"Admin",
"\\",
"AdminInterface",
"$",
"admin",
")",
"{",
"$",
"locale",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"admin",
"->",
"hasRequest",
"(",
")",
")",
"{",
... | returns the locale of the current admin user.
@param AdminInterface $admin
@return mixed|string | [
"returns",
"the",
"locale",
"of",
"the",
"current",
"admin",
"user",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L559-L588 |
42,330 | networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getSubFormsByZone | public function getSubFormsByZone($formChildren, $zone)
{
$zones = [];
foreach ($formChildren as $subForms) {
if ($this->getFormFieldZone($subForms) == $zone) {
$zones[] = $subForms;
}
}
return $zones;
} | php | public function getSubFormsByZone($formChildren, $zone)
{
$zones = [];
foreach ($formChildren as $subForms) {
if ($this->getFormFieldZone($subForms) == $zone) {
$zones[] = $subForms;
}
}
return $zones;
} | [
"public",
"function",
"getSubFormsByZone",
"(",
"$",
"formChildren",
",",
"$",
"zone",
")",
"{",
"$",
"zones",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"formChildren",
"as",
"$",
"subForms",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getFormFieldZone",
"... | Gets a list of forms sorted to a particular zone.
@param $formChildren
@param $zone
@return array | [
"Gets",
"a",
"list",
"of",
"forms",
"sorted",
"to",
"a",
"particular",
"zone",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L702-L713 |
42,331 | networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getContentCss | public function getContentCss($configName = null)
{
if (is_null($configName)) {
$configName = $this->ckEditorConfigManager->getDefaultConfig();
}
$configs = $this->ckEditorConfigManager->getConfigs();
if (array_key_exists('contentsCss', $configs[$configName])) {
return $configs[$configName]['contentsCss'];
}
return false;
} | php | public function getContentCss($configName = null)
{
if (is_null($configName)) {
$configName = $this->ckEditorConfigManager->getDefaultConfig();
}
$configs = $this->ckEditorConfigManager->getConfigs();
if (array_key_exists('contentsCss', $configs[$configName])) {
return $configs[$configName]['contentsCss'];
}
return false;
} | [
"public",
"function",
"getContentCss",
"(",
"$",
"configName",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"configName",
")",
")",
"{",
"$",
"configName",
"=",
"$",
"this",
"->",
"ckEditorConfigManager",
"->",
"getDefaultConfig",
"(",
")",
";",
... | Return the path to the content css for the default or named ckeditor config contentsCss.
@param null $configName
@return bool | [
"Return",
"the",
"path",
"to",
"the",
"content",
"css",
"for",
"the",
"default",
"or",
"named",
"ckeditor",
"config",
"contentsCss",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L1191-L1203 |
42,332 | networking/init-cms-bundle | src/Twig/Extension/NetworkingHelperExtension.php | NetworkingHelperExtension.getFileIcon | public function getFileIcon($filename)
{
$parts = explode('.', $filename);
$postfix = strtolower(end($parts));
switch ($postfix) {
case 'doc':
case 'docx':
$icon = 'far fa-file-word';
break;
case 'pdf':
$icon = 'far fa-file-pdf';
break;
case 'xls':
case 'xlsx':
$icon = 'far fa-file-excel';
break;
case 'ppt':
case 'pptx':
$icon = 'far fa-file-powerpoint';
break;
case 'zip':
$icon = 'far fa-file-archive';
break;
case 'txt':
case 'rtf':
$icon = 'far fa-file-alt';
break;
case 'png':
case 'gif':
case 'jpeg':
case 'jpg':
case 'svg':
$icon = 'far fa-file-image';
break;
default:
$icon = 'far fa-file';
break;
}
return 'fa '.$icon;
} | php | public function getFileIcon($filename)
{
$parts = explode('.', $filename);
$postfix = strtolower(end($parts));
switch ($postfix) {
case 'doc':
case 'docx':
$icon = 'far fa-file-word';
break;
case 'pdf':
$icon = 'far fa-file-pdf';
break;
case 'xls':
case 'xlsx':
$icon = 'far fa-file-excel';
break;
case 'ppt':
case 'pptx':
$icon = 'far fa-file-powerpoint';
break;
case 'zip':
$icon = 'far fa-file-archive';
break;
case 'txt':
case 'rtf':
$icon = 'far fa-file-alt';
break;
case 'png':
case 'gif':
case 'jpeg':
case 'jpg':
case 'svg':
$icon = 'far fa-file-image';
break;
default:
$icon = 'far fa-file';
break;
}
return 'fa '.$icon;
} | [
"public",
"function",
"getFileIcon",
"(",
"$",
"filename",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"filename",
")",
";",
"$",
"postfix",
"=",
"strtolower",
"(",
"end",
"(",
"$",
"parts",
")",
")",
";",
"switch",
"(",
"$",
"pos... | Guess which fontawesome icon to use.
@param $filename
@return string | [
"Guess",
"which",
"fontawesome",
"icon",
"to",
"use",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Twig/Extension/NetworkingHelperExtension.php#L1212-L1253 |
42,333 | networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.setFieldValue | public static function setFieldValue(PageInterface $object, $fieldName, $value, $method = null)
{
$setters = [];
// prefer method name given in the code option
if ($method) {
$setters[] = $method;
}
$camelizedFieldName = self::camelize($fieldName);
$setters[] = 'set'.$camelizedFieldName;
foreach ($setters as $setter) {
if (method_exists($object, $setter)) {
call_user_func([&$object, $setter], $value);
return $object;
}
}
if ($object->getId()) {
throw new NoValueException(sprintf('Unable to set the value of `%s`', $camelizedFieldName));
}
return $object;
} | php | public static function setFieldValue(PageInterface $object, $fieldName, $value, $method = null)
{
$setters = [];
// prefer method name given in the code option
if ($method) {
$setters[] = $method;
}
$camelizedFieldName = self::camelize($fieldName);
$setters[] = 'set'.$camelizedFieldName;
foreach ($setters as $setter) {
if (method_exists($object, $setter)) {
call_user_func([&$object, $setter], $value);
return $object;
}
}
if ($object->getId()) {
throw new NoValueException(sprintf('Unable to set the value of `%s`', $camelizedFieldName));
}
return $object;
} | [
"public",
"static",
"function",
"setFieldValue",
"(",
"PageInterface",
"$",
"object",
",",
"$",
"fieldName",
",",
"$",
"value",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"setters",
"=",
"[",
"]",
";",
"// prefer method name given in the code option",
"if... | Set the variables to the given content type object.
@param PageInterface $object
@param $fieldName
@param $value
@param null $method
@return mixed
@throws \Sonata\AdminBundle\Exception\NoValueException | [
"Set",
"the",
"variables",
"to",
"the",
"given",
"content",
"type",
"object",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L153-L178 |
42,334 | networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.makePageSnapshot | public function makePageSnapshot(PageInterface $page)
{
foreach ($page->getLayoutBlock() as $layoutBlock) {
$layoutBlockContent = $this->registry->getManagerForClass($layoutBlock->getClassType())->getRepository($layoutBlock->getClassType())->find(
$layoutBlock->getObjectId()
);
$layoutBlock->takeSnapshot($this->serializer->serialize($layoutBlockContent, 'json'));
}
$pageSnapshotClass = $this->pageSnapshotManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\PageSnapshotInterface $pageSnapshot */
$pageSnapshot = new $pageSnapshotClass($page);
$pageSnapshot->setVersionedData($this->serializer->serialize($page, 'json'))
->setPage($page);
if ($oldPageSnapshot = $page->getSnapshot()) {
$snapshotContentRoute = $oldPageSnapshot->getContentRoute();
} else {
$contentRouteClass = $this->contentRouteManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\ContentRouteInterface $snapshotContentRoute */
$snapshotContentRoute = new $contentRouteClass();
}
$pageSnapshot->setContentRoute($snapshotContentRoute);
$pageSnapshot->setPath(self::getPageRoutePath($page->getPath()));
$om = $this->registry->getManagerForClass($pageSnapshotClass);
$om->persist($pageSnapshot);
$om->flush();
$snapshotContentRoute->setPath(self::getPageRoutePath($page->getPath()));
$snapshotContentRoute->setObjectId($pageSnapshot->getId());
if ($oldPageSnapshot && ($oldPageSnapshot->getPath() != self::getPageRoutePath($page->getPath()))) {
$this->phpCache->clean();
}
$om = $this->registry->getManagerForClass(get_class($snapshotContentRoute));
$om->persist($snapshotContentRoute);
$om->flush();
} | php | public function makePageSnapshot(PageInterface $page)
{
foreach ($page->getLayoutBlock() as $layoutBlock) {
$layoutBlockContent = $this->registry->getManagerForClass($layoutBlock->getClassType())->getRepository($layoutBlock->getClassType())->find(
$layoutBlock->getObjectId()
);
$layoutBlock->takeSnapshot($this->serializer->serialize($layoutBlockContent, 'json'));
}
$pageSnapshotClass = $this->pageSnapshotManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\PageSnapshotInterface $pageSnapshot */
$pageSnapshot = new $pageSnapshotClass($page);
$pageSnapshot->setVersionedData($this->serializer->serialize($page, 'json'))
->setPage($page);
if ($oldPageSnapshot = $page->getSnapshot()) {
$snapshotContentRoute = $oldPageSnapshot->getContentRoute();
} else {
$contentRouteClass = $this->contentRouteManager->getClassName();
/** @var \Networking\InitCmsBundle\Model\ContentRouteInterface $snapshotContentRoute */
$snapshotContentRoute = new $contentRouteClass();
}
$pageSnapshot->setContentRoute($snapshotContentRoute);
$pageSnapshot->setPath(self::getPageRoutePath($page->getPath()));
$om = $this->registry->getManagerForClass($pageSnapshotClass);
$om->persist($pageSnapshot);
$om->flush();
$snapshotContentRoute->setPath(self::getPageRoutePath($page->getPath()));
$snapshotContentRoute->setObjectId($pageSnapshot->getId());
if ($oldPageSnapshot && ($oldPageSnapshot->getPath() != self::getPageRoutePath($page->getPath()))) {
$this->phpCache->clean();
}
$om = $this->registry->getManagerForClass(get_class($snapshotContentRoute));
$om->persist($snapshotContentRoute);
$om->flush();
} | [
"public",
"function",
"makePageSnapshot",
"(",
"PageInterface",
"$",
"page",
")",
"{",
"foreach",
"(",
"$",
"page",
"->",
"getLayoutBlock",
"(",
")",
"as",
"$",
"layoutBlock",
")",
"{",
"$",
"layoutBlockContent",
"=",
"$",
"this",
"->",
"registry",
"->",
"... | Create a snapshot of a given page.
@param PageInterface $page | [
"Create",
"a",
"snapshot",
"of",
"a",
"given",
"page",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L243-L284 |
42,335 | networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.unserializePageSnapshotData | public function unserializePageSnapshotData(PageSnapshotInterface $pageSnapshot, $unserializeTranslations = true)
{
$context = new PageSnapshotDeserializationContext();
$context->setDeserializeTranslations($unserializeTranslations);
return $this->serializer->deserialize($pageSnapshot->getVersionedData(), $pageSnapshot->getResourceName(), 'json', $context);
} | php | public function unserializePageSnapshotData(PageSnapshotInterface $pageSnapshot, $unserializeTranslations = true)
{
$context = new PageSnapshotDeserializationContext();
$context->setDeserializeTranslations($unserializeTranslations);
return $this->serializer->deserialize($pageSnapshot->getVersionedData(), $pageSnapshot->getResourceName(), 'json', $context);
} | [
"public",
"function",
"unserializePageSnapshotData",
"(",
"PageSnapshotInterface",
"$",
"pageSnapshot",
",",
"$",
"unserializeTranslations",
"=",
"true",
")",
"{",
"$",
"context",
"=",
"new",
"PageSnapshotDeserializationContext",
"(",
")",
";",
"$",
"context",
"->",
... | Unserialize the PageSnapshot data into a page object.
@param PageSnapshotInterface $pageSnapshot
@param bool $unserializeTranslations
@return array|\JMS\Serializer\scalar|object | [
"Unserialize",
"the",
"PageSnapshot",
"data",
"into",
"a",
"page",
"object",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L294-L300 |
42,336 | networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.makeTranslationCopy | public function makeTranslationCopy(PageInterface $page, $locale)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$pageCopy->setPageName($page->getPageName());
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl());
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome($page->getIsHome());
$pageCopy->setLocale($locale);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setOriginal($page);
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | php | public function makeTranslationCopy(PageInterface $page, $locale)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$pageCopy->setPageName($page->getPageName());
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl());
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome($page->getIsHome());
$pageCopy->setLocale($locale);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setOriginal($page);
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | [
"public",
"function",
"makeTranslationCopy",
"(",
"PageInterface",
"$",
"page",
",",
"$",
"locale",
")",
"{",
"$",
"pageClass",
"=",
"$",
"this",
"->",
"pageManager",
"->",
"getClassName",
"(",
")",
";",
"/** @var PageInterface $pageCopy */",
"$",
"pageCopy",
"=... | create a copy of a given page object in a given locale.
@param PageInterface $page
@param $locale
@return PageInterface | [
"create",
"a",
"copy",
"of",
"a",
"given",
"page",
"object",
"in",
"a",
"given",
"locale",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L310-L355 |
42,337 | networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.makePageCopy | public function makePageCopy(PageInterface $page)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$now = new \DateTime();
$postfix = sprintf(' copy %s', $now->format('d.m.Y H:i:s'));
$pageCopy->setPageName($page->getPageName().$postfix);
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl().$postfix);
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome(false);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setLocale($page->getLocale());
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | php | public function makePageCopy(PageInterface $page)
{
$pageClass = $this->pageManager->getClassName();
/** @var PageInterface $pageCopy */
$pageCopy = new $pageClass();
$now = new \DateTime();
$postfix = sprintf(' copy %s', $now->format('d.m.Y H:i:s'));
$pageCopy->setPageName($page->getPageName().$postfix);
$pageCopy->setMetaTitle($page->getMetaTitle());
$pageCopy->setUrl($page->getUrl().$postfix);
$pageCopy->setMetaKeyword($page->getMetaKeyword());
$pageCopy->setMetaDescription($page->getMetaDescription());
$pageCopy->setActiveFrom($page->getActiveFrom());
$pageCopy->setIsHome(false);
$pageCopy->setTemplateName($page->getTemplateName());
$pageCopy->setLocale($page->getLocale());
$layoutBlocks = $page->getLayoutBlock();
$om = $this->registry->getManager();
foreach ($layoutBlocks as $layoutBlock) {
/** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
$newLayoutBlock = clone $layoutBlock;
$content = $om->getRepository($newLayoutBlock->getClassType())->find(
$newLayoutBlock->getObjectId()
);
$newContent = clone $content;
$om->persist($newContent);
$om->flush();
$newLayoutBlock->setObjectId($newContent->getId());
$newLayoutBlock->setPage($pageCopy);
$om->persist($newLayoutBlock);
}
$om->persist($pageCopy);
$om->flush();
return $pageCopy;
} | [
"public",
"function",
"makePageCopy",
"(",
"PageInterface",
"$",
"page",
")",
"{",
"$",
"pageClass",
"=",
"$",
"this",
"->",
"pageManager",
"->",
"getClassName",
"(",
")",
";",
"/** @var PageInterface $pageCopy */",
"$",
"pageCopy",
"=",
"new",
"$",
"pageClass",... | create a copy of a given page object.
@param PageInterface $page
@return PageInterface | [
"create",
"a",
"copy",
"of",
"a",
"given",
"page",
"object",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L364-L413 |
42,338 | networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.matchContentRouteRequest | public function matchContentRouteRequest(Request $request)
{
$requestParams = $this->router->matchRequest($request);
if (is_array($requestParams) && !empty($requestParams)) {
$request->attributes->add($requestParams);
unset($requestParams['_route']);
unset($requestParams['_controller']);
$request->attributes->set('_route_params', $requestParams);
$configuration = $request->attributes->get('_template');
$request->attributes->set('_template', $configuration->getTemplate());
$request->attributes->set('_template_vars', $configuration->getVars());
$request->attributes->set('_template_streamable', $configuration->isStreamable());
}
return $request;
} | php | public function matchContentRouteRequest(Request $request)
{
$requestParams = $this->router->matchRequest($request);
if (is_array($requestParams) && !empty($requestParams)) {
$request->attributes->add($requestParams);
unset($requestParams['_route']);
unset($requestParams['_controller']);
$request->attributes->set('_route_params', $requestParams);
$configuration = $request->attributes->get('_template');
$request->attributes->set('_template', $configuration->getTemplate());
$request->attributes->set('_template_vars', $configuration->getVars());
$request->attributes->set('_template_streamable', $configuration->isStreamable());
}
return $request;
} | [
"public",
"function",
"matchContentRouteRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"requestParams",
"=",
"$",
"this",
"->",
"router",
"->",
"matchRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"requestParams",
")",
... | Fills the request object with the content route parameters if found.
@param Request $request
@return Request | [
"Fills",
"the",
"request",
"object",
"with",
"the",
"content",
"route",
"parameters",
"if",
"found",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L422-L440 |
42,339 | networking/init-cms-bundle | src/Helper/PageHelper.php | PageHelper.jsonPageIsActive | public function jsonPageIsActive($jsonString)
{
$page = json_decode($jsonString, true);
$now = new \DateTime();
$activeStart = array_key_exists('active_from', $page) ? new \DateTime($page['active_from']) : new \DateTime();
$activeEnd = array_key_exists('active_to', $page) ? new \DateTime($page['active_to']) : new \DateTime();
if ($now->getTimestamp() >= $activeStart->getTimestamp() &&
$now->getTimestamp() <= $activeEnd->getTimestamp()
) {
return $page['status'] == PageInterface::STATUS_PUBLISHED;
}
return false;
} | php | public function jsonPageIsActive($jsonString)
{
$page = json_decode($jsonString, true);
$now = new \DateTime();
$activeStart = array_key_exists('active_from', $page) ? new \DateTime($page['active_from']) : new \DateTime();
$activeEnd = array_key_exists('active_to', $page) ? new \DateTime($page['active_to']) : new \DateTime();
if ($now->getTimestamp() >= $activeStart->getTimestamp() &&
$now->getTimestamp() <= $activeEnd->getTimestamp()
) {
return $page['status'] == PageInterface::STATUS_PUBLISHED;
}
return false;
} | [
"public",
"function",
"jsonPageIsActive",
"(",
"$",
"jsonString",
")",
"{",
"$",
"page",
"=",
"json_decode",
"(",
"$",
"jsonString",
",",
"true",
")",
";",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"activeStart",
"=",
"array_key_exist... | Returns if a page is active or inactive based on json string from page snapshot.
@param $jsonString
@return bool | [
"Returns",
"if",
"a",
"page",
"is",
"active",
"or",
"inactive",
"based",
"on",
"json",
"string",
"from",
"page",
"snapshot",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Helper/PageHelper.php#L449-L465 |
42,340 | networking/init-cms-bundle | src/Admin/BaseAdmin.php | BaseAdmin.setUpTranslatableLocale | public function setUpTranslatableLocale()
{
/** @var \Gedmo\Translatable\TranslatableListener $translatable */
$translatableListener = $this->getContainer()->get('stof_doctrine_extensions.listener.translatable', ContainerInterface::NULL_ON_INVALID_REFERENCE);
if ($translatableListener) {
$translatableListener->setTranslatableLocale($this->getDefaultLocale());
}
} | php | public function setUpTranslatableLocale()
{
/** @var \Gedmo\Translatable\TranslatableListener $translatable */
$translatableListener = $this->getContainer()->get('stof_doctrine_extensions.listener.translatable', ContainerInterface::NULL_ON_INVALID_REFERENCE);
if ($translatableListener) {
$translatableListener->setTranslatableLocale($this->getDefaultLocale());
}
} | [
"public",
"function",
"setUpTranslatableLocale",
"(",
")",
"{",
"/** @var \\Gedmo\\Translatable\\TranslatableListener $translatable */",
"$",
"translatableListener",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'stof_doctrine_extensions.listener.translat... | Set up listner to make sure the correct locale is used. | [
"Set",
"up",
"listner",
"to",
"make",
"sure",
"the",
"correct",
"locale",
"is",
"used",
"."
] | 9c6e0f09de216e19795caac5840c197f46fde03d | https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/BaseAdmin.php#L53-L60 |
42,341 | wutongwan/laravel-lego | src/Lego/Foundation/Event.php | Event.register | public function register($event, $listener, \Closure $callback)
{
if (!isset($this->events[$event])) {
$this->events[$event] = [];
}
if ($listener) {
$this->events[$event][$listener] = $callback;
} else {
$this->events[$event][] = $callback;
$keys = array_keys($this->events[$event]);
$listener = array_pop($keys);
}
return $listener;
} | php | public function register($event, $listener, \Closure $callback)
{
if (!isset($this->events[$event])) {
$this->events[$event] = [];
}
if ($listener) {
$this->events[$event][$listener] = $callback;
} else {
$this->events[$event][] = $callback;
$keys = array_keys($this->events[$event]);
$listener = array_pop($keys);
}
return $listener;
} | [
"public",
"function",
"register",
"(",
"$",
"event",
",",
"$",
"listener",
",",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"this",
"->",
"even... | Register event.
@param string $event event name
@param string $listener listener name
@param \Closure $callback call when fire
@return string|int | [
"Register",
"event",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Foundation/Event.php#L25-L40 |
42,342 | wutongwan/laravel-lego | src/Lego/Foundation/Event.php | Event.once | public function once($event, $listener, \Closure $callback)
{
$realListener = $this->register($event, $listener, $callback);
if (!isset($this->once[$event])) {
$this->once[$event] = [];
}
$this->once[$event][$realListener] = true;
return $realListener;
} | php | public function once($event, $listener, \Closure $callback)
{
$realListener = $this->register($event, $listener, $callback);
if (!isset($this->once[$event])) {
$this->once[$event] = [];
}
$this->once[$event][$realListener] = true;
return $realListener;
} | [
"public",
"function",
"once",
"(",
"$",
"event",
",",
"$",
"listener",
",",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"$",
"realListener",
"=",
"$",
"this",
"->",
"register",
"(",
"$",
"event",
",",
"$",
"listener",
",",
"$",
"callback",
")",
";",
... | fire only once. | [
"fire",
"only",
"once",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Foundation/Event.php#L45-L55 |
42,343 | wutongwan/laravel-lego | src/Lego/Foundation/Button.php | Button.attribute | public function attribute($name, $value, $merge = true)
{
if (!$merge) {
$this->attributes[$name] = $value;
return $this;
}
$current = array_get($this->attributes, $name);
if (is_array($current) && is_array($value)) {
$current = array_unique(array_merge($current, $value));
} elseif (is_string($current) && is_string($value)) {
$current = trim($current) . ' ' . trim($value);
} else {
$current = $value;
}
$this->attributes[$name] = $current;
return $this;
} | php | public function attribute($name, $value, $merge = true)
{
if (!$merge) {
$this->attributes[$name] = $value;
return $this;
}
$current = array_get($this->attributes, $name);
if (is_array($current) && is_array($value)) {
$current = array_unique(array_merge($current, $value));
} elseif (is_string($current) && is_string($value)) {
$current = trim($current) . ' ' . trim($value);
} else {
$current = $value;
}
$this->attributes[$name] = $current;
return $this;
} | [
"public",
"function",
"attribute",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"merge",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"merge",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
... | set html attribute.
@param $name
@param $value
@param bool $merge if true, new `value` will be merge to current `value`
@return $this | [
"set",
"html",
"attribute",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Foundation/Button.php#L93-L112 |
42,344 | wutongwan/laravel-lego | src/Lego/Field/Concerns/HasValidation.php | HasValidation.unique | public function unique($id = null, $idColumn = null, $extra = null)
{
if (!$this->store instanceof \Lego\Operator\Eloquent\EloquentStore) {
throw new LegoException(
'Validation: `unique` rule only worked for Eloquent, ' .
'you can use `validator($closure)` implement unique validation.'
);
}
/**
* @var \Illuminate\Database\Eloquent\Model
* @var Field $this
*/
$model = $this->data;
$id = $id ?: $this->store->getKey() ?: 'NULL';
$idColumn = $idColumn ?: $this->store->getKeyName();
$parts = [
"unique:{$model->getConnectionName()}.{$model->getTable()}",
$this->column(),
$id,
$idColumn,
];
if ($extra) {
$parts[] = trim($extra, ',');
}
$this->rule(join(',', $parts));
return $this;
} | php | public function unique($id = null, $idColumn = null, $extra = null)
{
if (!$this->store instanceof \Lego\Operator\Eloquent\EloquentStore) {
throw new LegoException(
'Validation: `unique` rule only worked for Eloquent, ' .
'you can use `validator($closure)` implement unique validation.'
);
}
/**
* @var \Illuminate\Database\Eloquent\Model
* @var Field $this
*/
$model = $this->data;
$id = $id ?: $this->store->getKey() ?: 'NULL';
$idColumn = $idColumn ?: $this->store->getKeyName();
$parts = [
"unique:{$model->getConnectionName()}.{$model->getTable()}",
$this->column(),
$id,
$idColumn,
];
if ($extra) {
$parts[] = trim($extra, ',');
}
$this->rule(join(',', $parts));
return $this;
} | [
"public",
"function",
"unique",
"(",
"$",
"id",
"=",
"null",
",",
"$",
"idColumn",
"=",
"null",
",",
"$",
"extra",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"store",
"instanceof",
"\\",
"Lego",
"\\",
"Operator",
"\\",
"Eloquent",
"\... | Laravel Validation unique.
Auto except current model
https://laravel.com/docs/master/validation#rule-unique | [
"Laravel",
"Validation",
"unique",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Field/Concerns/HasValidation.php#L163-L195 |
42,345 | wutongwan/laravel-lego | src/Lego/Field/FieldNameSlicer.php | FieldNameSlicer.split | public static function split(string $name): array
{
$parts = explode(self::JSON_DELIMITER, $name, 2);
$jsonPath = count($parts) === 2 ? explode(self::JSON_DELIMITER, end($parts)) : [];
$relationParts = explode(self::RELATION_DELIMITER, $parts[0]);
return [
array_slice($relationParts, 0, -1),
end($relationParts),
$jsonPath,
];
} | php | public static function split(string $name): array
{
$parts = explode(self::JSON_DELIMITER, $name, 2);
$jsonPath = count($parts) === 2 ? explode(self::JSON_DELIMITER, end($parts)) : [];
$relationParts = explode(self::RELATION_DELIMITER, $parts[0]);
return [
array_slice($relationParts, 0, -1),
end($relationParts),
$jsonPath,
];
} | [
"public",
"static",
"function",
"split",
"(",
"string",
"$",
"name",
")",
":",
"array",
"{",
"$",
"parts",
"=",
"explode",
"(",
"self",
"::",
"JSON_DELIMITER",
",",
"$",
"name",
",",
"2",
")",
";",
"$",
"jsonPath",
"=",
"count",
"(",
"$",
"parts",
... | split name to relation, column and json path.
@param string $name field name, eg: school.city.column:json_key:sub_json_key
@return array eg: [ ['school', 'city'], 'column', ['json_key', 'sub_json_key'] ] | [
"split",
"name",
"to",
"relation",
"column",
"and",
"json",
"path",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Field/FieldNameSlicer.php#L23-L35 |
42,346 | wutongwan/laravel-lego | src/Lego/Operator/Query.php | Query.paginate | public function paginate(
$perPage = null,
$columns = null,
$pageName = null,
$page = null,
bool $lengthAware = true
) {
$perPage = is_null($perPage) ? config('lego.paginator.per-page') : $perPage;
$pageName = is_null($pageName) ? config('lego.paginator.page-name') : $pageName;
$columns = is_null($columns) ? ['*'] : $columns;
$page = $page ?: Request::query($pageName, 1);
if ($lengthAware) {
$this->paginator = $this->createLengthAwarePaginator($perPage, $columns, $pageName, $page);
} else {
$this->paginator = $this->createLengthNotAwarePaginator($perPage, $columns, $pageName, $page);
}
$this->paginator->setCollection(
$this->paginator->getCollection()->map(function ($row) {
return Finder::createStore($row);
})
);
return $this->paginator;
} | php | public function paginate(
$perPage = null,
$columns = null,
$pageName = null,
$page = null,
bool $lengthAware = true
) {
$perPage = is_null($perPage) ? config('lego.paginator.per-page') : $perPage;
$pageName = is_null($pageName) ? config('lego.paginator.page-name') : $pageName;
$columns = is_null($columns) ? ['*'] : $columns;
$page = $page ?: Request::query($pageName, 1);
if ($lengthAware) {
$this->paginator = $this->createLengthAwarePaginator($perPage, $columns, $pageName, $page);
} else {
$this->paginator = $this->createLengthNotAwarePaginator($perPage, $columns, $pageName, $page);
}
$this->paginator->setCollection(
$this->paginator->getCollection()->map(function ($row) {
return Finder::createStore($row);
})
);
return $this->paginator;
} | [
"public",
"function",
"paginate",
"(",
"$",
"perPage",
"=",
"null",
",",
"$",
"columns",
"=",
"null",
",",
"$",
"pageName",
"=",
"null",
",",
"$",
"page",
"=",
"null",
",",
"bool",
"$",
"lengthAware",
"=",
"true",
")",
"{",
"$",
"perPage",
"=",
"is... | Paginator API.
@param int $perPage 每页条数
@param array $columns 需要的字段列表
@param string $pageName 分页的 GET 参数名称
@param int $page 当前页码
@param bool $lengthAware 是否需要查询总页数
@return AbstractPaginator|Store[] | [
"Paginator",
"API",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Operator/Query.php#L214-L239 |
42,347 | wutongwan/laravel-lego | src/Lego/Widget/Grid/Concerns/HasCells.php | HasCells.remove | public function remove($names)
{
$names = is_array($names) ? $names : func_get_args();
foreach ($names as $name) {
unset($this->cells[$name]);
}
return $this;
} | php | public function remove($names)
{
$names = is_array($names) ? $names : func_get_args();
foreach ($names as $name) {
unset($this->cells[$name]);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"names",
")",
"{",
"$",
"names",
"=",
"is_array",
"(",
"$",
"names",
")",
"?",
"$",
"names",
":",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"unset",
"(",
"... | remove cell from grid. | [
"remove",
"cell",
"from",
"grid",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Grid/Concerns/HasCells.php#L54-L62 |
42,348 | wutongwan/laravel-lego | src/Lego/Widget/Concerns/HasBottomButtons.php | HasBottomButtons.submitText | public function submitText(string $submitText)
{
/** @var Button $btn */
$btn = $this->getButton($this->bottomLocation, $this->submitButtonKey);
$btn->text($submitText);
return $this;
} | php | public function submitText(string $submitText)
{
/** @var Button $btn */
$btn = $this->getButton($this->bottomLocation, $this->submitButtonKey);
$btn->text($submitText);
return $this;
} | [
"public",
"function",
"submitText",
"(",
"string",
"$",
"submitText",
")",
"{",
"/** @var Button $btn */",
"$",
"btn",
"=",
"$",
"this",
"->",
"getButton",
"(",
"$",
"this",
"->",
"bottomLocation",
",",
"$",
"this",
"->",
"submitButtonKey",
")",
";",
"$",
... | Set submit button text.
@param string $submitText
@return $this | [
"Set",
"submit",
"button",
"text",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasBottomButtons.php#L63-L70 |
42,349 | wutongwan/laravel-lego | src/Lego/Widget/Concerns/HasBottomButtons.php | HasBottomButtons.resetText | public function resetText(string $resetText)
{
/** @var Button $btn */
$btn = $this->getButton($this->bottomLocation, $this->resetButtonKey);
$btn->text($resetText);
return $this;
} | php | public function resetText(string $resetText)
{
/** @var Button $btn */
$btn = $this->getButton($this->bottomLocation, $this->resetButtonKey);
$btn->text($resetText);
return $this;
} | [
"public",
"function",
"resetText",
"(",
"string",
"$",
"resetText",
")",
"{",
"/** @var Button $btn */",
"$",
"btn",
"=",
"$",
"this",
"->",
"getButton",
"(",
"$",
"this",
"->",
"bottomLocation",
",",
"$",
"this",
"->",
"resetButtonKey",
")",
";",
"$",
"bt... | Set reset button text.
@param string $resetText
@return $this | [
"Set",
"reset",
"button",
"text",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasBottomButtons.php#L79-L86 |
42,350 | wutongwan/laravel-lego | src/Lego/Operator/Plastic/PlasticQuery.php | PlasticQuery.with | public function with(array $relations)
{
$this->with = array_unique(array_merge($this->with, $relations));
return $this;
} | php | public function with(array $relations)
{
$this->with = array_unique(array_merge($this->with, $relations));
return $this;
} | [
"public",
"function",
"with",
"(",
"array",
"$",
"relations",
")",
"{",
"$",
"this",
"->",
"with",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"with",
",",
"$",
"relations",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Query with eager loading.
@param array $relations
@return static | [
"Query",
"with",
"eager",
"loading",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Operator/Plastic/PlasticQuery.php#L44-L49 |
42,351 | wutongwan/laravel-lego | src/Lego/Widget/Grid/Cell.php | Cell.value | public function value()
{
$value = lego_default($this->getOriginalValue(), $this->default);
foreach ($this->pipes as $pipe) {
$value = $pipe->handle($value, $this->data, $this);
}
return new HtmlString((string) $value);
} | php | public function value()
{
$value = lego_default($this->getOriginalValue(), $this->default);
foreach ($this->pipes as $pipe) {
$value = $pipe->handle($value, $this->data, $this);
}
return new HtmlString((string) $value);
} | [
"public",
"function",
"value",
"(",
")",
"{",
"$",
"value",
"=",
"lego_default",
"(",
"$",
"this",
"->",
"getOriginalValue",
"(",
")",
",",
"$",
"this",
"->",
"default",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"pipes",
"as",
"$",
"pipe",
")",
... | cell value after pipes processed.
@return HtmlString | [
"cell",
"value",
"after",
"pipes",
"processed",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Grid/Cell.php#L123-L131 |
42,352 | wutongwan/laravel-lego | src/Lego/Widget/Concerns/HasFields.php | HasFields.editableFields | public function editableFields()
{
$ignored = [];
foreach ($this->groups() as $group) {
if ($group->getCondition() && $group->getCondition()->fail()) {
$ignored = array_merge($ignored, $group->fieldNames());
}
}
return $this->fields()->filter(function (Field $field) use ($ignored) {
return $field->isEditable() && !in_array($field->name(), $ignored);
});
} | php | public function editableFields()
{
$ignored = [];
foreach ($this->groups() as $group) {
if ($group->getCondition() && $group->getCondition()->fail()) {
$ignored = array_merge($ignored, $group->fieldNames());
}
}
return $this->fields()->filter(function (Field $field) use ($ignored) {
return $field->isEditable() && !in_array($field->name(), $ignored);
});
} | [
"public",
"function",
"editableFields",
"(",
")",
"{",
"$",
"ignored",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"groups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"$",
"group",
"->",
"getCondition",
"(",
")",
"&&",
"$",
"g... | only editable fields.
@return Collection|Field[] | [
"only",
"editable",
"fields",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasFields.php#L86-L98 |
42,353 | wutongwan/laravel-lego | src/Lego/Widget/Concerns/HasFields.php | HasFields.required | public function required($fields = [])
{
$fields = $fields ?: $this->fields();
foreach ($fields as $field) {
if (is_string($field)) {
$this->field($field)->required();
continue;
}
/* @var Field $field */
$field->required();
}
return $this;
} | php | public function required($fields = [])
{
$fields = $fields ?: $this->fields();
foreach ($fields as $field) {
if (is_string($field)) {
$this->field($field)->required();
continue;
}
/* @var Field $field */
$field->required();
}
return $this;
} | [
"public",
"function",
"required",
"(",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"$",
"fields",
"=",
"$",
"fields",
"?",
":",
"$",
"this",
"->",
"fields",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"is_... | Mark Fields as Required.
@param array[]|Field[] $fields
@return $this | [
"Mark",
"Fields",
"as",
"Required",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasFields.php#L135-L150 |
42,354 | wutongwan/laravel-lego | src/Lego/Widget/Form.php | Form.saveFieldsValueToStore | protected function saveFieldsValueToStore()
{
$this->editableFields()->each(function (Field $field) {
if ($field->isDoesntStore()) {
return;
}
$field->syncValueToStore();
});
$this->events->fire('saving', [$this->data, $this]);
if ($this->getStore()->save()) {
$this->syncFieldsValueFromStore();
$this->events->fire('saved', [$this->data, $this]);
return true;
}
return false;
} | php | protected function saveFieldsValueToStore()
{
$this->editableFields()->each(function (Field $field) {
if ($field->isDoesntStore()) {
return;
}
$field->syncValueToStore();
});
$this->events->fire('saving', [$this->data, $this]);
if ($this->getStore()->save()) {
$this->syncFieldsValueFromStore();
$this->events->fire('saved', [$this->data, $this]);
return true;
}
return false;
} | [
"protected",
"function",
"saveFieldsValueToStore",
"(",
")",
"{",
"$",
"this",
"->",
"editableFields",
"(",
")",
"->",
"each",
"(",
"function",
"(",
"Field",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"isDoesntStore",
"(",
")",
")",
"{",
"r... | sync field's value to source. | [
"sync",
"field",
"s",
"value",
"to",
"source",
"."
] | c9bf8443f5bafb97986315f45025d0ce742a1091 | https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Form.php#L168-L187 |
42,355 | yzalis/Supervisor | src/Supervisor/Process.php | Process.startProcess | public function startProcess($wait = true)
{
return $this->rpcClient->call('supervisor.startProcess', array($this->processGroup.':'.$this->processName, $wait));
} | php | public function startProcess($wait = true)
{
return $this->rpcClient->call('supervisor.startProcess', array($this->processGroup.':'.$this->processName, $wait));
} | [
"public",
"function",
"startProcess",
"(",
"$",
"wait",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"rpcClient",
"->",
"call",
"(",
"'supervisor.startProcess'",
",",
"array",
"(",
"$",
"this",
"->",
"processGroup",
".",
"':'",
".",
"$",
"this",
"... | Start a process
@param boolean $wait Wait for process to be fully started
@return boolean Always true unless error | [
"Start",
"a",
"process"
] | d73f228fadde179bf6590928450f71ea69509ce4 | https://github.com/yzalis/Supervisor/blob/d73f228fadde179bf6590928450f71ea69509ce4/src/Supervisor/Process.php#L78-L81 |
42,356 | yzalis/Supervisor | src/Supervisor/Process.php | Process.stopProcess | public function stopProcess($wait = true)
{
return $this->rpcClient->call('supervisor.stopProcess', array($this->processGroup.':'.$this->processName, $wait));
} | php | public function stopProcess($wait = true)
{
return $this->rpcClient->call('supervisor.stopProcess', array($this->processGroup.':'.$this->processName, $wait));
} | [
"public",
"function",
"stopProcess",
"(",
"$",
"wait",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"rpcClient",
"->",
"call",
"(",
"'supervisor.stopProcess'",
",",
"array",
"(",
"$",
"this",
"->",
"processGroup",
".",
"':'",
".",
"$",
"this",
"->... | Stop a process
@param boolean $wait Wait for process to be fully started
@return boolean Always true unless error | [
"Stop",
"a",
"process"
] | d73f228fadde179bf6590928450f71ea69509ce4 | https://github.com/yzalis/Supervisor/blob/d73f228fadde179bf6590928450f71ea69509ce4/src/Supervisor/Process.php#L90-L93 |
42,357 | yzalis/Supervisor | src/Supervisor/Supervisor.php | Supervisor.createKey | private function createKey($ipAdress, $port, $username = null, $password = null)
{
$this->key = hash('md5', serialize(array(
$ipAdress,
$port,
$username,
$password,
)));
} | php | private function createKey($ipAdress, $port, $username = null, $password = null)
{
$this->key = hash('md5', serialize(array(
$ipAdress,
$port,
$username,
$password,
)));
} | [
"private",
"function",
"createKey",
"(",
"$",
"ipAdress",
",",
"$",
"port",
",",
"$",
"username",
"=",
"null",
",",
"$",
"password",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"key",
"=",
"hash",
"(",
"'md5'",
",",
"serialize",
"(",
"array",
"(",
"$... | Create a unique key. It ll be used to retrieve a supervisor object.
@param string $ipAdress
@param string $username
@param string $password | [
"Create",
"a",
"unique",
"key",
".",
"It",
"ll",
"be",
"used",
"to",
"retrieve",
"a",
"supervisor",
"object",
"."
] | d73f228fadde179bf6590928450f71ea69509ce4 | https://github.com/yzalis/Supervisor/blob/d73f228fadde179bf6590928450f71ea69509ce4/src/Supervisor/Supervisor.php#L77-L85 |
42,358 | wikimedia/IPSet | src/IPSet.php | IPSet.addCidr | private function addCidr( $cidr ) {
// v4 or v6 check
if ( strpos( $cidr, ':' ) === false ) {
$node =& $this->root4;
$defMask = '32';
} else {
$node =& $this->root6;
$defMask = '128';
}
// Default to all-1's mask if no netmask in the input
if ( strpos( $cidr, '/' ) === false ) {
$net = $cidr;
$mask = $defMask;
} else {
list( $net, $mask ) = explode( '/', $cidr, 2 );
if ( !ctype_digit( $mask ) || intval( $mask ) > $defMask ) {
trigger_error( "IPSet: Bad mask '$mask' from '$cidr', ignored", E_USER_WARNING );
return false;
}
}
$mask = intval( $mask ); // explicit integer convert, checked above
// convert $net to an array of integer bytes, length 4 or 16:
$raw = AtEase::quietCall( 'inet_pton', $net );
if ( $raw === false ) {
return false;
}
$rawOrd = array_map( 'ord', str_split( $raw ) );
// iterate the bits of the address while walking the tree structure for inserts
// at the end, $snode will point to the highest node that could only lead to a
// successful match (and thus can be set to true)
$snode =& $node;
$curBit = 0;
while ( 1 ) {
if ( $node === true ) {
// already added a larger supernet, no need to go deeper
return;
} elseif ( $curBit == $mask ) {
// this may wipe out deeper subnets from earlier
$snode = true;
return;
} elseif ( $node === false ) {
// create new subarray to go deeper
if ( !( $curBit & 7 ) && $curBit <= $mask - 8 ) {
$node = [ 'comp' => $rawOrd[$curBit >> 3], 'next' => false ];
} else {
$node = [ false, false ];
}
}
if ( isset( $node['comp'] ) ) {
$comp = $node['comp'];
if ( $rawOrd[$curBit >> 3] == $comp && $curBit <= $mask - 8 ) {
// whole byte matches, skip over the compressed node
$node =& $node['next'];
$snode =& $node;
$curBit += 8;
continue;
} else {
// have to decompress the node and check individual bits
$unode = $node['next'];
for ( $i = 0; $i < 8; ++$i ) {
$unode = ( $comp & ( 1 << $i ) )
? [ false, $unode ]
: [ $unode, false ];
}
$node = $unode;
}
}
$maskShift = 7 - ( $curBit & 7 );
$index = ( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift;
if ( $node[$index ^ 1] !== true ) {
// no adjacent subnet, can't form a supernet at this level
$snode =& $node[$index];
}
$node =& $node[$index];
++$curBit;
} // Unreachable outside 'while'
} | php | private function addCidr( $cidr ) {
// v4 or v6 check
if ( strpos( $cidr, ':' ) === false ) {
$node =& $this->root4;
$defMask = '32';
} else {
$node =& $this->root6;
$defMask = '128';
}
// Default to all-1's mask if no netmask in the input
if ( strpos( $cidr, '/' ) === false ) {
$net = $cidr;
$mask = $defMask;
} else {
list( $net, $mask ) = explode( '/', $cidr, 2 );
if ( !ctype_digit( $mask ) || intval( $mask ) > $defMask ) {
trigger_error( "IPSet: Bad mask '$mask' from '$cidr', ignored", E_USER_WARNING );
return false;
}
}
$mask = intval( $mask ); // explicit integer convert, checked above
// convert $net to an array of integer bytes, length 4 or 16:
$raw = AtEase::quietCall( 'inet_pton', $net );
if ( $raw === false ) {
return false;
}
$rawOrd = array_map( 'ord', str_split( $raw ) );
// iterate the bits of the address while walking the tree structure for inserts
// at the end, $snode will point to the highest node that could only lead to a
// successful match (and thus can be set to true)
$snode =& $node;
$curBit = 0;
while ( 1 ) {
if ( $node === true ) {
// already added a larger supernet, no need to go deeper
return;
} elseif ( $curBit == $mask ) {
// this may wipe out deeper subnets from earlier
$snode = true;
return;
} elseif ( $node === false ) {
// create new subarray to go deeper
if ( !( $curBit & 7 ) && $curBit <= $mask - 8 ) {
$node = [ 'comp' => $rawOrd[$curBit >> 3], 'next' => false ];
} else {
$node = [ false, false ];
}
}
if ( isset( $node['comp'] ) ) {
$comp = $node['comp'];
if ( $rawOrd[$curBit >> 3] == $comp && $curBit <= $mask - 8 ) {
// whole byte matches, skip over the compressed node
$node =& $node['next'];
$snode =& $node;
$curBit += 8;
continue;
} else {
// have to decompress the node and check individual bits
$unode = $node['next'];
for ( $i = 0; $i < 8; ++$i ) {
$unode = ( $comp & ( 1 << $i ) )
? [ false, $unode ]
: [ $unode, false ];
}
$node = $unode;
}
}
$maskShift = 7 - ( $curBit & 7 );
$index = ( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift;
if ( $node[$index ^ 1] !== true ) {
// no adjacent subnet, can't form a supernet at this level
$snode =& $node[$index];
}
$node =& $node[$index];
++$curBit;
} // Unreachable outside 'while'
} | [
"private",
"function",
"addCidr",
"(",
"$",
"cidr",
")",
"{",
"// v4 or v6 check",
"if",
"(",
"strpos",
"(",
"$",
"cidr",
",",
"':'",
")",
"===",
"false",
")",
"{",
"$",
"node",
"=",
"&",
"$",
"this",
"->",
"root4",
";",
"$",
"defMask",
"=",
"'32'"... | Add a single CIDR spec to the internal matching trees
@param string $cidr String CIDR spec, IPv[46], optional /mask (def all-1's)
@return false|null Returns null on success, false on failure | [
"Add",
"a",
"single",
"CIDR",
"spec",
"to",
"the",
"internal",
"matching",
"trees"
] | 1913cc022f43a3cd03c17b386299aa488faf1e21 | https://github.com/wikimedia/IPSet/blob/1913cc022f43a3cd03c17b386299aa488faf1e21/src/IPSet.php#L112-L193 |
42,359 | wikimedia/IPSet | src/IPSet.php | IPSet.match | public function match( $ip ) {
$raw = AtEase::quietCall( 'inet_pton', $ip );
if ( $raw === false ) {
return false;
}
$rawOrd = array_map( 'ord', str_split( $raw ) );
if ( count( $rawOrd ) == 4 ) {
$node =& $this->root4;
} else {
$node =& $this->root6;
}
$curBit = 0;
while ( $node !== true && $node !== false ) {
if ( isset( $node['comp'] ) ) {
// compressed node, matches 1 whole byte on a byte boundary
if ( $rawOrd[$curBit >> 3] != $node['comp'] ) {
return false;
}
$curBit += 8;
$node =& $node['next'];
} else {
// uncompressed node, walk in the correct direction for the current bit-value
$maskShift = 7 - ( $curBit & 7 );
$node =& $node[( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift];
++$curBit;
}
}
return $node;
} | php | public function match( $ip ) {
$raw = AtEase::quietCall( 'inet_pton', $ip );
if ( $raw === false ) {
return false;
}
$rawOrd = array_map( 'ord', str_split( $raw ) );
if ( count( $rawOrd ) == 4 ) {
$node =& $this->root4;
} else {
$node =& $this->root6;
}
$curBit = 0;
while ( $node !== true && $node !== false ) {
if ( isset( $node['comp'] ) ) {
// compressed node, matches 1 whole byte on a byte boundary
if ( $rawOrd[$curBit >> 3] != $node['comp'] ) {
return false;
}
$curBit += 8;
$node =& $node['next'];
} else {
// uncompressed node, walk in the correct direction for the current bit-value
$maskShift = 7 - ( $curBit & 7 );
$node =& $node[( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift];
++$curBit;
}
}
return $node;
} | [
"public",
"function",
"match",
"(",
"$",
"ip",
")",
"{",
"$",
"raw",
"=",
"AtEase",
"::",
"quietCall",
"(",
"'inet_pton'",
",",
"$",
"ip",
")",
";",
"if",
"(",
"$",
"raw",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"rawOrd",
"=",... | Match an IP address against the set
If $ip is unparseable, inet_pton may issue an E_WARNING to that effect
@param string $ip string IPv[46] address
@return bool True is match success, false is match failure | [
"Match",
"an",
"IP",
"address",
"against",
"the",
"set"
] | 1913cc022f43a3cd03c17b386299aa488faf1e21 | https://github.com/wikimedia/IPSet/blob/1913cc022f43a3cd03c17b386299aa488faf1e21/src/IPSet.php#L203-L234 |
42,360 | hiqdev/hiam | src/base/Message.php | Message.renderHtmlBody | public function renderHtmlBody($view, array $params = [])
{
if (!array_key_exists('message', $params)) {
$params['message'] = $this;
}
return $this->setHtmlBody($this->render($view, $params, $this->mailer->htmlLayout));
} | php | public function renderHtmlBody($view, array $params = [])
{
if (!array_key_exists('message', $params)) {
$params['message'] = $this;
}
return $this->setHtmlBody($this->render($view, $params, $this->mailer->htmlLayout));
} | [
"public",
"function",
"renderHtmlBody",
"(",
"$",
"view",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'message'",
",",
"$",
"params",
")",
")",
"{",
"$",
"params",
"[",
"'message'",
"]",
"=",
"$",
... | Renders and sets message HTML content.
@param string|array|null $view the view to be used for rendering the message body
@param array $params the parameters (name-value pairs) that will be extracted and made available in the view file
@return $this self reference | [
"Renders",
"and",
"sets",
"message",
"HTML",
"content",
"."
] | 1cc20ae30599adc4044cffb34dc97c57075cbfe3 | https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/Message.php#L23-L30 |
42,361 | hiqdev/hiam | src/base/Message.php | Message.renderTextBody | public function renderTextBody($view, array $params = [])
{
if (!array_key_exists('message', $params)) {
$params['message'] = $this;
}
return $this->setTextBody($this->render($view, $params, $this->mailer->textLayout));
} | php | public function renderTextBody($view, array $params = [])
{
if (!array_key_exists('message', $params)) {
$params['message'] = $this;
}
return $this->setTextBody($this->render($view, $params, $this->mailer->textLayout));
} | [
"public",
"function",
"renderTextBody",
"(",
"$",
"view",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'message'",
",",
"$",
"params",
")",
")",
"{",
"$",
"params",
"[",
"'message'",
"]",
"=",
"$",
... | Renders and sets message plain text content.
@param string|array|null $view the view to be used for rendering the message body
@param array $params the parameters (name-value pairs) that will be extracted and made available in the view file
@return $this self reference | [
"Renders",
"and",
"sets",
"message",
"plain",
"text",
"content",
"."
] | 1cc20ae30599adc4044cffb34dc97c57075cbfe3 | https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/Message.php#L38-L45 |
42,362 | hiqdev/hiam | src/base/User.php | User.findIdentityByAuthClient | public function findIdentityByAuthClient(ClientInterface $client)
{
$remote = $this->getRemoteUser($client);
if (!$remote->provider) {
return null;
}
if ($remote->client_id) {
return $this->findIdentity($remote->client_id);
}
$email = $client->getUserAttributes()['email'];
$user = $this->findIdentityByEmail($email);
if (!$user) {
return null;
}
if ($remote->isTrustedEmail($email)) {
return $this->setRemoteUser($client, $user);
}
return null;
} | php | public function findIdentityByAuthClient(ClientInterface $client)
{
$remote = $this->getRemoteUser($client);
if (!$remote->provider) {
return null;
}
if ($remote->client_id) {
return $this->findIdentity($remote->client_id);
}
$email = $client->getUserAttributes()['email'];
$user = $this->findIdentityByEmail($email);
if (!$user) {
return null;
}
if ($remote->isTrustedEmail($email)) {
return $this->setRemoteUser($client, $user);
}
return null;
} | [
"public",
"function",
"findIdentityByAuthClient",
"(",
"ClientInterface",
"$",
"client",
")",
"{",
"$",
"remote",
"=",
"$",
"this",
"->",
"getRemoteUser",
"(",
"$",
"client",
")",
";",
"if",
"(",
"!",
"$",
"remote",
"->",
"provider",
")",
"{",
"return",
... | Finds user through RemoteUser.
@return IdentityInterface | [
"Finds",
"user",
"through",
"RemoteUser",
"."
] | 1cc20ae30599adc4044cffb34dc97c57075cbfe3 | https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/User.php#L94-L113 |
42,363 | hiqdev/hiam | src/base/User.php | User.setRemoteUser | public function setRemoteUser(ClientInterface $client, IdentityInterface $user)
{
$model = $this->getRemoteUser($client);
$model->client_id = $user->getId();
$model->save();
return $user;
} | php | public function setRemoteUser(ClientInterface $client, IdentityInterface $user)
{
$model = $this->getRemoteUser($client);
$model->client_id = $user->getId();
$model->save();
return $user;
} | [
"public",
"function",
"setRemoteUser",
"(",
"ClientInterface",
"$",
"client",
",",
"IdentityInterface",
"$",
"user",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getRemoteUser",
"(",
"$",
"client",
")",
";",
"$",
"model",
"->",
"client_id",
"=",
"$",
... | Inserts or updates RemoteUser.
@return IdentityInterface user | [
"Inserts",
"or",
"updates",
"RemoteUser",
"."
] | 1cc20ae30599adc4044cffb34dc97c57075cbfe3 | https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/User.php#L119-L126 |
42,364 | hiqdev/hiam | src/controllers/OauthController.php | OauthController.getRequestValue | public function getRequestValue($name, $default = null)
{
$request = $this->getModule()->getRequest();
return isset($request->request[$name]) ? $request->request[$name] : $request->query($name, $default);
} | php | public function getRequestValue($name, $default = null)
{
$request = $this->getModule()->getRequest();
return isset($request->request[$name]) ? $request->request[$name] : $request->query($name, $default);
} | [
"public",
"function",
"getRequestValue",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getModule",
"(",
")",
"->",
"getRequest",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"request",
"->",
"re... | Get request parameter from POST then GET.
@param string $name
@param string $default
@return string | [
"Get",
"request",
"parameter",
"from",
"POST",
"then",
"GET",
"."
] | 1cc20ae30599adc4044cffb34dc97c57075cbfe3 | https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/controllers/OauthController.php#L84-L89 |
42,365 | hiqdev/hiam | src/controllers/SiteController.php | SiteController.login | private function login(Identity $identity, $sessionDuration = 0): bool
{
$returnUrl = $this->user->getReturnUrl();
$result = $this->user->login($identity, $sessionDuration ? null : 0);
if ($result && $returnUrl !== null) {
$this->user->setReturnUrl($returnUrl);
}
return $result;
} | php | private function login(Identity $identity, $sessionDuration = 0): bool
{
$returnUrl = $this->user->getReturnUrl();
$result = $this->user->login($identity, $sessionDuration ? null : 0);
if ($result && $returnUrl !== null) {
$this->user->setReturnUrl($returnUrl);
}
return $result;
} | [
"private",
"function",
"login",
"(",
"Identity",
"$",
"identity",
",",
"$",
"sessionDuration",
"=",
"0",
")",
":",
"bool",
"{",
"$",
"returnUrl",
"=",
"$",
"this",
"->",
"user",
"->",
"getReturnUrl",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"-... | Logs user in and preserves return URL. | [
"Logs",
"user",
"in",
"and",
"preserves",
"return",
"URL",
"."
] | 1cc20ae30599adc4044cffb34dc97c57075cbfe3 | https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/controllers/SiteController.php#L163-L173 |
42,366 | hiqdev/hiam | src/models/RemoteUser.php | RemoteUser.isTrustedEmail | public function isTrustedEmail($email)
{
static $trustedEmails = [
'@gmail.com' => 'Google',
'@yandex.ru' => 'Yandex',
];
foreach ($trustedEmails as $domain => $trusted) {
if ($this->provider === static::toProvider($trusted) && substr($email, -strlen($domain)) === $domain) {
return true;
}
}
return false;
} | php | public function isTrustedEmail($email)
{
static $trustedEmails = [
'@gmail.com' => 'Google',
'@yandex.ru' => 'Yandex',
];
foreach ($trustedEmails as $domain => $trusted) {
if ($this->provider === static::toProvider($trusted) && substr($email, -strlen($domain)) === $domain) {
return true;
}
}
return false;
} | [
"public",
"function",
"isTrustedEmail",
"(",
"$",
"email",
")",
"{",
"static",
"$",
"trustedEmails",
"=",
"[",
"'@gmail.com'",
"=>",
"'Google'",
",",
"'@yandex.ru'",
"=>",
"'Yandex'",
",",
"]",
";",
"foreach",
"(",
"$",
"trustedEmails",
"as",
"$",
"domain",
... | Returns if given email is provided with appropriate service so it can be trusted.
@param string email address
@return bool is trusted | [
"Returns",
"if",
"given",
"email",
"is",
"provided",
"with",
"appropriate",
"service",
"so",
"it",
"can",
"be",
"trusted",
"."
] | 1cc20ae30599adc4044cffb34dc97c57075cbfe3 | https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/models/RemoteUser.php#L49-L62 |
42,367 | GeniusesOfSymfony/WebSocketPhpClient | Wamp/Client.php | Client.read | protected function read()
{
// Ignore first byte
fread($this->socket, 1);
// There is also masking bit, as MSB, bit it's 0
$payloadLength = ord(fread($this->socket, 1));
switch ($payloadLength) {
case 126:
$payloadLength = unpack('n', fread($this->socket, 2));
$payloadLength = $payloadLength[1];
break;
case 127:
//$this->stdout('error', "Next 8 bytes are 64bit uint payload length, not yet implemented, since PHP can't handle 64bit longs!");
break;
}
return fread($this->socket, $payloadLength);
} | php | protected function read()
{
// Ignore first byte
fread($this->socket, 1);
// There is also masking bit, as MSB, bit it's 0
$payloadLength = ord(fread($this->socket, 1));
switch ($payloadLength) {
case 126:
$payloadLength = unpack('n', fread($this->socket, 2));
$payloadLength = $payloadLength[1];
break;
case 127:
//$this->stdout('error', "Next 8 bytes are 64bit uint payload length, not yet implemented, since PHP can't handle 64bit longs!");
break;
}
return fread($this->socket, $payloadLength);
} | [
"protected",
"function",
"read",
"(",
")",
"{",
"// Ignore first byte",
"fread",
"(",
"$",
"this",
"->",
"socket",
",",
"1",
")",
";",
"// There is also masking bit, as MSB, bit it's 0",
"$",
"payloadLength",
"=",
"ord",
"(",
"fread",
"(",
"$",
"this",
"->",
"... | Read the buffer and return the oldest event in stack.
@see https://tools.ietf.org/html/rfc6455#section-5.2
@return string | [
"Read",
"the",
"buffer",
"and",
"return",
"the",
"oldest",
"event",
"in",
"stack",
"."
] | 64e4351d42acb77d5b6df748221c889a2f0adee4 | https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L194-L213 |
42,368 | GeniusesOfSymfony/WebSocketPhpClient | Wamp/Client.php | Client.send | protected function send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true)
{
$rawMessage = json_encode($data);
$payload = new WebsocketPayload();
$payload
->setOpcode($opcode)
->setMask($masked)
->setPayload($rawMessage);
$encoded = $payload->encodePayload();
if (0 === @fwrite($this->socket, $encoded)) { //connection reseted by peers, just reconnect.
$this->connected = false;
$this->connect($this->target);
fwrite($this->socket, $encoded);
}
return $this;
} | php | protected function send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true)
{
$rawMessage = json_encode($data);
$payload = new WebsocketPayload();
$payload
->setOpcode($opcode)
->setMask($masked)
->setPayload($rawMessage);
$encoded = $payload->encodePayload();
if (0 === @fwrite($this->socket, $encoded)) { //connection reseted by peers, just reconnect.
$this->connected = false;
$this->connect($this->target);
fwrite($this->socket, $encoded);
}
return $this;
} | [
"protected",
"function",
"send",
"(",
"$",
"data",
",",
"$",
"opcode",
"=",
"WebsocketPayload",
"::",
"OPCODE_TEXT",
",",
"$",
"masked",
"=",
"true",
")",
"{",
"$",
"rawMessage",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"payload",
"=",
"new... | Send message to the websocket.
@param array $data
@return $this|Client | [
"Send",
"message",
"to",
"the",
"websocket",
"."
] | 64e4351d42acb77d5b6df748221c889a2f0adee4 | https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L261-L280 |
42,369 | GeniusesOfSymfony/WebSocketPhpClient | Wamp/Client.php | Client.prefix | public function prefix($prefix, $uri)
{
$type = Protocol::MSG_PREFIX;
$data = [$type, $prefix, $uri];
$this->send($data);
} | php | public function prefix($prefix, $uri)
{
$type = Protocol::MSG_PREFIX;
$data = [$type, $prefix, $uri];
$this->send($data);
} | [
"public",
"function",
"prefix",
"(",
"$",
"prefix",
",",
"$",
"uri",
")",
"{",
"$",
"type",
"=",
"Protocol",
"::",
"MSG_PREFIX",
";",
"$",
"data",
"=",
"[",
"$",
"type",
",",
"$",
"prefix",
",",
"$",
"uri",
"]",
";",
"$",
"this",
"->",
"send",
... | Establish a prefix on server.
@see http://wamp.ws/spec#prefix_message
@param string $prefix
@param string $uri | [
"Establish",
"a",
"prefix",
"on",
"server",
"."
] | 64e4351d42acb77d5b6df748221c889a2f0adee4 | https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L290-L295 |
42,370 | GeniusesOfSymfony/WebSocketPhpClient | Wamp/Client.php | Client.call | public function call($procUri, $arguments = [])
{
$args = func_get_args();
array_shift($args);
$type = Protocol::MSG_CALL;
$callId = uniqid('', $moreEntropy = true);
$data = array_merge(array($type, $callId, $procUri), $args);
$this->send($data);
} | php | public function call($procUri, $arguments = [])
{
$args = func_get_args();
array_shift($args);
$type = Protocol::MSG_CALL;
$callId = uniqid('', $moreEntropy = true);
$data = array_merge(array($type, $callId, $procUri), $args);
$this->send($data);
} | [
"public",
"function",
"call",
"(",
"$",
"procUri",
",",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"type",
"=",
"Protocol",
"::",
"MSG_CALL",
";",
"$"... | Call a procedure on server.
@see http://wamp.ws/spec#call_message
@param string $procURI
@param mixed $arguments | [
"Call",
"a",
"procedure",
"on",
"server",
"."
] | 64e4351d42acb77d5b6df748221c889a2f0adee4 | https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L305-L314 |
42,371 | GeniusesOfSymfony/WebSocketPhpClient | Wamp/Client.php | Client.publish | public function publish($topicUri, $payload, $exclude = [], $eligible = [])
{
if (null !== $this->logger) {
$this->logger->info(sprintf(
'Publish in %s',
$topicUri
));
}
$data = array(Protocol::MSG_PUBLISH, $topicUri, $payload, $exclude, $eligible);
$this->send($data);
} | php | public function publish($topicUri, $payload, $exclude = [], $eligible = [])
{
if (null !== $this->logger) {
$this->logger->info(sprintf(
'Publish in %s',
$topicUri
));
}
$data = array(Protocol::MSG_PUBLISH, $topicUri, $payload, $exclude, $eligible);
$this->send($data);
} | [
"public",
"function",
"publish",
"(",
"$",
"topicUri",
",",
"$",
"payload",
",",
"$",
"exclude",
"=",
"[",
"]",
",",
"$",
"eligible",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"... | The client will send an event to all clients connected to the server who have subscribed to the topicURI.
@see http://wamp.ws/spec#publish_message
@param string $topicUri
@param string $payload
@param string $exclude
@param string $eligible | [
"The",
"client",
"will",
"send",
"an",
"event",
"to",
"all",
"clients",
"connected",
"to",
"the",
"server",
"who",
"have",
"subscribed",
"to",
"the",
"topicURI",
"."
] | 64e4351d42acb77d5b6df748221c889a2f0adee4 | https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L326-L337 |
42,372 | GeniusesOfSymfony/WebSocketPhpClient | Wamp/Client.php | Client.event | public function event($topicUri, $payload)
{
$type = Protocol::MSG_EVENT;
$data = array($type, $topicUri, $payload);
$this->send($data);
} | php | public function event($topicUri, $payload)
{
$type = Protocol::MSG_EVENT;
$data = array($type, $topicUri, $payload);
$this->send($data);
} | [
"public",
"function",
"event",
"(",
"$",
"topicUri",
",",
"$",
"payload",
")",
"{",
"$",
"type",
"=",
"Protocol",
"::",
"MSG_EVENT",
";",
"$",
"data",
"=",
"array",
"(",
"$",
"type",
",",
"$",
"topicUri",
",",
"$",
"payload",
")",
";",
"$",
"this",... | Subscribers receive PubSub events published by subscribers via the EVENT message. The EVENT message contains the topicURI, the topic under which the event was published, and event, the PubSub event payload.
@param string $topicUri
@param string $payload | [
"Subscribers",
"receive",
"PubSub",
"events",
"published",
"by",
"subscribers",
"via",
"the",
"EVENT",
"message",
".",
"The",
"EVENT",
"message",
"contains",
"the",
"topicURI",
"the",
"topic",
"under",
"which",
"the",
"event",
"was",
"published",
"and",
"event",... | 64e4351d42acb77d5b6df748221c889a2f0adee4 | https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L345-L350 |
42,373 | glensc/slack-unfurl | src/Command/UrlVerification.php | UrlVerification.execute | public function execute(array $payload): JsonResponse
{
$challenge = $payload['challenge'] ?? null;
if ($challenge) {
return new JsonResponse(['challenge' => $challenge]);
}
throw new RuntimeException();
} | php | public function execute(array $payload): JsonResponse
{
$challenge = $payload['challenge'] ?? null;
if ($challenge) {
return new JsonResponse(['challenge' => $challenge]);
}
throw new RuntimeException();
} | [
"public",
"function",
"execute",
"(",
"array",
"$",
"payload",
")",
":",
"JsonResponse",
"{",
"$",
"challenge",
"=",
"$",
"payload",
"[",
"'challenge'",
"]",
"??",
"null",
";",
"if",
"(",
"$",
"challenge",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
... | Handle Request URL Configuration & Verification
@param array $payload
@return JsonResponse
@see https://api.slack.com/events-api#request_url_configuration__amp__verification | [
"Handle",
"Request",
"URL",
"Configuration",
"&",
"Verification"
] | 5dabe632a728b40f1391479f6c32f93f7b4db860 | https://github.com/glensc/slack-unfurl/blob/5dabe632a728b40f1391479f6c32f93f7b4db860/src/Command/UrlVerification.php#L17-L25 |
42,374 | EFTEC/ValidationOne | lib/ValidationOne.php | ValidationOne.input | private function input() {
if ($this->input===null) {
$this->input=new ValidationInputOne($this->prefix,$this->messageList); // we used the same message list
}
return $this->input;
} | php | private function input() {
if ($this->input===null) {
$this->input=new ValidationInputOne($this->prefix,$this->messageList); // we used the same message list
}
return $this->input;
} | [
"private",
"function",
"input",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"input",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"new",
"ValidationInputOne",
"(",
"$",
"this",
"->",
"prefix",
",",
"$",
"this",
"->",
"messageList",
")",... | it's the injector of validationinputone.
@return ValidationInputOne | [
"it",
"s",
"the",
"injector",
"of",
"validationinputone",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L112-L117 |
42,375 | EFTEC/ValidationOne | lib/ValidationOne.php | ValidationOne.getTypeFamily | private function getTypeFamily($type) {
if (is_array($type)) {
$r=[];
foreach($type as $key=>$t) {
$r[$key]=$this->getTypeFamily($t);
}
} else {
switch (1 == 1) {
case (strpos($this->STRARR, $type) !== false):
$r = 1; // string
break;
case (strpos($this->DATARR, $type) !== false):
$r = 2; // date
break;
case ($type == 'boolean'):
$r = 3; // boolean
break;
case ($type == 'file'):
$r = 4; // file
break;
default:
$r = 0; // number
}
}
return $r;
} | php | private function getTypeFamily($type) {
if (is_array($type)) {
$r=[];
foreach($type as $key=>$t) {
$r[$key]=$this->getTypeFamily($t);
}
} else {
switch (1 == 1) {
case (strpos($this->STRARR, $type) !== false):
$r = 1; // string
break;
case (strpos($this->DATARR, $type) !== false):
$r = 2; // date
break;
case ($type == 'boolean'):
$r = 3; // boolean
break;
case ($type == 'file'):
$r = 4; // file
break;
default:
$r = 0; // number
}
}
return $r;
} | [
"private",
"function",
"getTypeFamily",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"type",
")",
")",
"{",
"$",
"r",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"type",
"as",
"$",
"key",
"=>",
"$",
"t",
")",
"{",
"$",
"r",
"[",
... | It returns the number of the family.
@param string|array $type=['integer','unixtime','boolean','decimal','float','varchar','string','date','datetime','file'][$i]
@return int|int[] 1=string,2=date,3=boolean,4=file,0=number | [
"It",
"returns",
"the",
"number",
"of",
"the",
"family",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L389-L414 |
42,376 | EFTEC/ValidationOne | lib/ValidationOne.php | ValidationOne.getMessage | public function getMessage($withWarning=false) {
if ($withWarning) return $this->messageList->firstErrorOrWarning();
return $this->messageList->firstErrorText();
} | php | public function getMessage($withWarning=false) {
if ($withWarning) return $this->messageList->firstErrorOrWarning();
return $this->messageList->firstErrorText();
} | [
"public",
"function",
"getMessage",
"(",
"$",
"withWarning",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"withWarning",
")",
"return",
"$",
"this",
"->",
"messageList",
"->",
"firstErrorOrWarning",
"(",
")",
";",
"return",
"$",
"this",
"->",
"messageList",
"->... | It gets the first error message available in the whole messagelist.
@param bool $withWarning
@return null|string | [
"It",
"gets",
"the",
"first",
"error",
"message",
"available",
"in",
"the",
"whole",
"messagelist",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L1261-L1264 |
42,377 | EFTEC/ValidationOne | lib/ValidationOne.php | ValidationOne.getMessages | public function getMessages($withWarning=false) {
if ($withWarning) $this->messageList->allErrorOrWarningArray();
return $this->messageList->allErrorArray();
} | php | public function getMessages($withWarning=false) {
if ($withWarning) $this->messageList->allErrorOrWarningArray();
return $this->messageList->allErrorArray();
} | [
"public",
"function",
"getMessages",
"(",
"$",
"withWarning",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"withWarning",
")",
"$",
"this",
"->",
"messageList",
"->",
"allErrorOrWarningArray",
"(",
")",
";",
"return",
"$",
"this",
"->",
"messageList",
"->",
"al... | It returns an array with all the errors of all "ids"
@param bool $withWarning
@return array | [
"It",
"returns",
"an",
"array",
"with",
"all",
"the",
"errors",
"of",
"all",
"ids"
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L1271-L1274 |
42,378 | devgeniem/wp-sanitize-accented-uploads | wp-cli-integration.php | Sanitize_Command.all | public function all($args, $assoc_args)
{
$result = self::replace_content($args,$assoc_args);
if ( isset($assoc_args['dry-run']) )
WP_CLI::success("Found {$result['replaced_count']} from {$result['considered_count']} attachments to replace.");
else
WP_CLI::success("Replaced {$result['replaced_count']} from {$result['considered_count']} attachments.");
} | php | public function all($args, $assoc_args)
{
$result = self::replace_content($args,$assoc_args);
if ( isset($assoc_args['dry-run']) )
WP_CLI::success("Found {$result['replaced_count']} from {$result['considered_count']} attachments to replace.");
else
WP_CLI::success("Replaced {$result['replaced_count']} from {$result['considered_count']} attachments.");
} | [
"public",
"function",
"all",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"replace_content",
"(",
"$",
"args",
",",
"$",
"assoc_args",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"assoc_args",
"[",
"'dry-run'",
"]... | Makes all currently uploaded filenames and urls sanitized. Also replaces corresponding files from wp_posts and wp_postmeta
// OPTIONS
[--dry-run]
: Only prints the changes without replacing.
[--verbose]
: More output from replacing.
[--without-sanitize]
: This doesn't make files to lower case and doesn't strip special chars
[--network]
: More output from replacing.
// EXAMPLES
wp sanitize all
wp sanitize all --dry-run
@synopsis [--dry-run] [--without-sanitize] [--verbose] [--network] | [
"Makes",
"all",
"currently",
"uploaded",
"filenames",
"and",
"urls",
"sanitized",
".",
"Also",
"replaces",
"corresponding",
"files",
"from",
"wp_posts",
"and",
"wp_postmeta"
] | 58c4f7a1adb568a37f98834c3eacb6d2c73b275e | https://github.com/devgeniem/wp-sanitize-accented-uploads/blob/58c4f7a1adb568a37f98834c3eacb6d2c73b275e/wp-cli-integration.php#L48-L56 |
42,379 | EFTEC/ValidationOne | lib/ValidationInputOne.php | ValidationInputOne.addMessageInternal | private function addMessageInternal($msg, $msg2, $fieldId, $value, $vcomp, $level='error') {
$txt=($msg)?$msg:$msg2;
if (is_array($vcomp)) {
$first=@$vcomp[0];
$second=@$vcomp[1];
$vcomp=@$vcomp[0]; // is not array anymore
} else {
$first=$vcomp;
$second=$vcomp;
}
if (is_array($this->originalValue)) {
$txt=str_replace(['%field','%realfield','%value','%comp','%first','%second']
,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId
,$value,$vcomp,$first,$second],$txt);
} else {
$txt=str_replace(['%field','%realfield','%value','%comp','%first','%second']
,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId
,$this->originalValue,$vcomp,$first,$second],$txt);
}
$this->messageList->addItem($fieldId,$txt, $level);
} | php | private function addMessageInternal($msg, $msg2, $fieldId, $value, $vcomp, $level='error') {
$txt=($msg)?$msg:$msg2;
if (is_array($vcomp)) {
$first=@$vcomp[0];
$second=@$vcomp[1];
$vcomp=@$vcomp[0]; // is not array anymore
} else {
$first=$vcomp;
$second=$vcomp;
}
if (is_array($this->originalValue)) {
$txt=str_replace(['%field','%realfield','%value','%comp','%first','%second']
,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId
,$value,$vcomp,$first,$second],$txt);
} else {
$txt=str_replace(['%field','%realfield','%value','%comp','%first','%second']
,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId
,$this->originalValue,$vcomp,$first,$second],$txt);
}
$this->messageList->addItem($fieldId,$txt, $level);
} | [
"private",
"function",
"addMessageInternal",
"(",
"$",
"msg",
",",
"$",
"msg2",
",",
"$",
"fieldId",
",",
"$",
"value",
",",
"$",
"vcomp",
",",
"$",
"level",
"=",
"'error'",
")",
"{",
"$",
"txt",
"=",
"(",
"$",
"msg",
")",
"?",
"$",
"msg",
":",
... | It adds an error
@param string $msg first message. If it's empty or null then it uses the second message<br>
Message could uses the next variables '%field','%realfield','%value','%comp','%first','%second'
@param string $msg2 second message
@param string $fieldId id of the field
@param mixed $value value supplied
@param mixed $vcomp value to compare.
@param string $level (error,warning,info,success) error level | [
"It",
"adds",
"an",
"error"
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationInputOne.php#L172-L192 |
42,380 | EFTEC/ValidationOne | lib/ValidationInputOne.php | ValidationInputOne.sanitizeFileName | public static function sanitizeFileName($filename) {
if (empty($filename)) return "";
if (function_exists("mb_ereg_replace")) {
$filename = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
$filename = mb_ereg_replace("([\.]{2,})", '', $filename);
} else {
$filename = preg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
$filename = preg_replace("([\.]{2,})", '', $filename);
}
return $filename;
} | php | public static function sanitizeFileName($filename) {
if (empty($filename)) return "";
if (function_exists("mb_ereg_replace")) {
$filename = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
$filename = mb_ereg_replace("([\.]{2,})", '', $filename);
} else {
$filename = preg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename);
$filename = preg_replace("([\.]{2,})", '', $filename);
}
return $filename;
} | [
"public",
"static",
"function",
"sanitizeFileName",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"filename",
")",
")",
"return",
"\"\"",
";",
"if",
"(",
"function_exists",
"(",
"\"mb_ereg_replace\"",
")",
")",
"{",
"$",
"filename",
"=",
... | Sanitize a filename removing .. and other nasty characters.
if mb_string is available then it also allows multibyte string characters such as accents.
@param string $filename
@return false|string|null | [
"Sanitize",
"a",
"filename",
"removing",
"..",
"and",
"other",
"nasty",
"characters",
".",
"if",
"mb_string",
"is",
"available",
"then",
"it",
"also",
"allows",
"multibyte",
"string",
"characters",
"such",
"as",
"accents",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationInputOne.php#L200-L210 |
42,381 | glensc/slack-unfurl | src/Command/LinkShared.php | LinkShared.execute | public function execute(array $data): JsonResponse
{
$this->debug('link_shared', ['event' => $data]);
/** @var UnfurlEvent $event */
$event = $this->dispatcher->dispatch(Events::SLACK_UNFURL, new UnfurlEvent($data));
$unfurls = $event->getUnfurls();
$this->debug('unfurls', ['channel' => $data['channel'], 'ts' => $data['message_ts'], 'unfurls' => $unfurls]);
if ($unfurls) {
$this->slackClient->unfurl($data['channel'], $data['message_ts'], $unfurls);
}
return new JsonResponse([]);
} | php | public function execute(array $data): JsonResponse
{
$this->debug('link_shared', ['event' => $data]);
/** @var UnfurlEvent $event */
$event = $this->dispatcher->dispatch(Events::SLACK_UNFURL, new UnfurlEvent($data));
$unfurls = $event->getUnfurls();
$this->debug('unfurls', ['channel' => $data['channel'], 'ts' => $data['message_ts'], 'unfurls' => $unfurls]);
if ($unfurls) {
$this->slackClient->unfurl($data['channel'], $data['message_ts'], $unfurls);
}
return new JsonResponse([]);
} | [
"public",
"function",
"execute",
"(",
"array",
"$",
"data",
")",
":",
"JsonResponse",
"{",
"$",
"this",
"->",
"debug",
"(",
"'link_shared'",
",",
"[",
"'event'",
"=>",
"$",
"data",
"]",
")",
";",
"/** @var UnfurlEvent $event */",
"$",
"event",
"=",
"$",
... | Handle Link Shared event
@param array $data
@return JsonResponse
@see https://api.slack.com/events/link_shared | [
"Handle",
"Link",
"Shared",
"event"
] | 5dabe632a728b40f1391479f6c32f93f7b4db860 | https://github.com/glensc/slack-unfurl/blob/5dabe632a728b40f1391479f6c32f93f7b4db860/src/Command/LinkShared.php#L38-L52 |
42,382 | EFTEC/ValidationOne | lib/MessageList.php | MessageList.allErrorArray | public function allErrorArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allError());
}
return $r;
} | php | public function allErrorArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allError());
}
return $r;
} | [
"public",
"function",
"allErrorArray",
"(",
")",
"{",
"$",
"r",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"v",
")",
"{",
"$",
"r",
"=",
"array_merge",
"(",
"$",
"r",
",",
"$",
"v",
"->",
"allError",
"("... | It returns an array with all messages of error of all containers.
@return string[] empty if there is none | [
"It",
"returns",
"an",
"array",
"with",
"all",
"messages",
"of",
"error",
"of",
"all",
"containers",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L167-L173 |
42,383 | EFTEC/ValidationOne | lib/MessageList.php | MessageList.allInfoArray | public function allInfoArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allInfo());
}
return $r;
} | php | public function allInfoArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allInfo());
}
return $r;
} | [
"public",
"function",
"allInfoArray",
"(",
")",
"{",
"$",
"r",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"v",
")",
"{",
"$",
"r",
"=",
"array_merge",
"(",
"$",
"r",
",",
"$",
"v",
"->",
"allInfo",
"(",
... | It returns an array with all messages of info of all containers.
@return string[] empty if there is none | [
"It",
"returns",
"an",
"array",
"with",
"all",
"messages",
"of",
"info",
"of",
"all",
"containers",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L178-L184 |
42,384 | EFTEC/ValidationOne | lib/MessageList.php | MessageList.allWarningArray | public function allWarningArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allWarning());
}
return $r;
} | php | public function allWarningArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allWarning());
}
return $r;
} | [
"public",
"function",
"allWarningArray",
"(",
")",
"{",
"$",
"r",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"v",
")",
"{",
"$",
"r",
"=",
"array_merge",
"(",
"$",
"r",
",",
"$",
"v",
"->",
"allWarning",
... | It returns an array with all messages of warning of all containers.
@return string[] empty if there is none | [
"It",
"returns",
"an",
"array",
"with",
"all",
"messages",
"of",
"warning",
"of",
"all",
"containers",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L189-L195 |
42,385 | EFTEC/ValidationOne | lib/MessageList.php | MessageList.AllSuccessArray | public function AllSuccessArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allSuccess());
}
return $r;
} | php | public function AllSuccessArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allSuccess());
}
return $r;
} | [
"public",
"function",
"AllSuccessArray",
"(",
")",
"{",
"$",
"r",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"v",
")",
"{",
"$",
"r",
"=",
"array_merge",
"(",
"$",
"r",
",",
"$",
"v",
"->",
"allSuccess",
... | It returns an array with all messages of success of all containers.
@return string[] empty if there is none | [
"It",
"returns",
"an",
"array",
"with",
"all",
"messages",
"of",
"success",
"of",
"all",
"containers",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L200-L206 |
42,386 | EFTEC/ValidationOne | lib/MessageList.php | MessageList.allArray | public function allArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allError());
$r=array_merge($r,$v->allWarning());
$r=array_merge($r,$v->allInfo());
$r=array_merge($r,$v->allSuccess());
}
return $r;
} | php | public function allArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allError());
$r=array_merge($r,$v->allWarning());
$r=array_merge($r,$v->allInfo());
$r=array_merge($r,$v->allSuccess());
}
return $r;
} | [
"public",
"function",
"allArray",
"(",
")",
"{",
"$",
"r",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"v",
")",
"{",
"$",
"r",
"=",
"array_merge",
"(",
"$",
"r",
",",
"$",
"v",
"->",
"allError",
"(",
"... | It returns an array with all messages of any type of all containers
@return string[] empty if there is none | [
"It",
"returns",
"an",
"array",
"with",
"all",
"messages",
"of",
"any",
"type",
"of",
"all",
"containers"
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L211-L220 |
42,387 | EFTEC/ValidationOne | lib/MessageList.php | MessageList.allErrorOrWarningArray | public function allErrorOrWarningArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allError());
$r=array_merge($r,$v->allWarning());
}
return $r;
} | php | public function allErrorOrWarningArray() {
$r=array();
foreach($this->items as $v) {
$r=array_merge($r,$v->allError());
$r=array_merge($r,$v->allWarning());
}
return $r;
} | [
"public",
"function",
"allErrorOrWarningArray",
"(",
")",
"{",
"$",
"r",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"v",
")",
"{",
"$",
"r",
"=",
"array_merge",
"(",
"$",
"r",
",",
"$",
"v",
"->",
"allErro... | It returns an array with all messages of errors and warnings of all containers.
@return string[] empty if there is none | [
"It",
"returns",
"an",
"array",
"with",
"all",
"messages",
"of",
"errors",
"and",
"warnings",
"of",
"all",
"containers",
"."
] | 420f335cdf355d520026e5f380f7a7e4d23412a2 | https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L225-L232 |
42,388 | monkeysuffrage/phpuri | phpuri.php | phpUri.parse | public static function parse( $url )
{
$uri = new phpUri( $url );
/**
* CHANGE:
* @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de>
* @since 24 Mai 2015 10:25 Uhr
* The base-url should always have a path
*/
if ( empty( $uri->path ) )
{
$uri->path = '/';
}
return $uri;
} | php | public static function parse( $url )
{
$uri = new phpUri( $url );
/**
* CHANGE:
* @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de>
* @since 24 Mai 2015 10:25 Uhr
* The base-url should always have a path
*/
if ( empty( $uri->path ) )
{
$uri->path = '/';
}
return $uri;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"url",
")",
"{",
"$",
"uri",
"=",
"new",
"phpUri",
"(",
"$",
"url",
")",
";",
"/**\r\n\t\t\t * CHANGE:\r\n\t\t\t * @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de>\r\n\t\t\t * @since 24 Mai 2015 10:25 Uhr\r\n\t\t\... | Parse an url string
@param string $url the url to parse
@return phpUri | [
"Parse",
"an",
"url",
"string"
] | 39da58b0a233d6c430f257d78da48e7ed339711d | https://github.com/monkeysuffrage/phpuri/blob/39da58b0a233d6c430f257d78da48e7ed339711d/phpuri.php#L133-L149 |
42,389 | monkeysuffrage/phpuri | phpuri.php | phpUri.join | public function join( $relative )
{
$uri = new phpUri( $relative );
switch ( TRUE )
{
case !empty( $uri->scheme ):
break;
case !empty( $uri->authority ):
break;
case empty( $uri->path ):
$uri->path = $this->path;
if ( empty( $uri->query ) )
{
$uri->query = $this->query;
}
break;
case strpos( $uri->path, '/' ) === 0:
break;
default:
$base_path = $this->path;
if ( strpos( $base_path, '/' ) === FALSE )
{
$base_path = '';
}
else
{
$base_path = preg_replace( '/\/[^\/]+$/', '/', $base_path );
}
if ( empty( $base_path ) && empty( $this->authority ) )
{
$base_path = '/';
}
$uri->path = $base_path . $uri->path;
}
if ( empty( $uri->scheme ) )
{
$uri->scheme = $this->scheme;
if ( empty( $uri->authority ) )
{
$uri->authority = $this->authority;
}
}
return $uri->to_str();
} | php | public function join( $relative )
{
$uri = new phpUri( $relative );
switch ( TRUE )
{
case !empty( $uri->scheme ):
break;
case !empty( $uri->authority ):
break;
case empty( $uri->path ):
$uri->path = $this->path;
if ( empty( $uri->query ) )
{
$uri->query = $this->query;
}
break;
case strpos( $uri->path, '/' ) === 0:
break;
default:
$base_path = $this->path;
if ( strpos( $base_path, '/' ) === FALSE )
{
$base_path = '';
}
else
{
$base_path = preg_replace( '/\/[^\/]+$/', '/', $base_path );
}
if ( empty( $base_path ) && empty( $this->authority ) )
{
$base_path = '/';
}
$uri->path = $base_path . $uri->path;
}
if ( empty( $uri->scheme ) )
{
$uri->scheme = $this->scheme;
if ( empty( $uri->authority ) )
{
$uri->authority = $this->authority;
}
}
return $uri->to_str();
} | [
"public",
"function",
"join",
"(",
"$",
"relative",
")",
"{",
"$",
"uri",
"=",
"new",
"phpUri",
"(",
"$",
"relative",
")",
";",
"switch",
"(",
"TRUE",
")",
"{",
"case",
"!",
"empty",
"(",
"$",
"uri",
"->",
"scheme",
")",
":",
"break",
";",
"case"... | Join with a relative url
@param string $relative the relative url to join
@return string | [
"Join",
"with",
"a",
"relative",
"url"
] | 39da58b0a233d6c430f257d78da48e7ed339711d | https://github.com/monkeysuffrage/phpuri/blob/39da58b0a233d6c430f257d78da48e7ed339711d/phpuri.php#L158-L207 |
42,390 | ramsey/uuid-console | src/Command/GenerateCommand.php | GenerateCommand.validateNamespace | protected function validateNamespace($namespace)
{
switch ($namespace) {
case 'ns:DNS':
return Uuid::NAMESPACE_DNS;
break;
case 'ns:URL':
return Uuid::NAMESPACE_URL;
break;
case 'ns:OID':
return Uuid::NAMESPACE_OID;
break;
case 'ns:X500':
return Uuid::NAMESPACE_X500;
break;
}
if (Uuid::isValid($namespace)) {
return $namespace;
}
throw new Exception(
'Invalid namespace. '
. 'May be either a UUID in string representation or an identifier '
. 'for internally pre-defined namespace UUIDs (currently known '
. 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").'
);
} | php | protected function validateNamespace($namespace)
{
switch ($namespace) {
case 'ns:DNS':
return Uuid::NAMESPACE_DNS;
break;
case 'ns:URL':
return Uuid::NAMESPACE_URL;
break;
case 'ns:OID':
return Uuid::NAMESPACE_OID;
break;
case 'ns:X500':
return Uuid::NAMESPACE_X500;
break;
}
if (Uuid::isValid($namespace)) {
return $namespace;
}
throw new Exception(
'Invalid namespace. '
. 'May be either a UUID in string representation or an identifier '
. 'for internally pre-defined namespace UUIDs (currently known '
. 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").'
);
} | [
"protected",
"function",
"validateNamespace",
"(",
"$",
"namespace",
")",
"{",
"switch",
"(",
"$",
"namespace",
")",
"{",
"case",
"'ns:DNS'",
":",
"return",
"Uuid",
"::",
"NAMESPACE_DNS",
";",
"break",
";",
"case",
"'ns:URL'",
":",
"return",
"Uuid",
"::",
... | Validates the namespace argument
@param string $namespace
@return string The namespace, if valid
@throws Exception | [
"Validates",
"the",
"namespace",
"argument"
] | 80594b4c02b8083c28236f2c906aac69094a6e9f | https://github.com/ramsey/uuid-console/blob/80594b4c02b8083c28236f2c906aac69094a6e9f/src/Command/GenerateCommand.php#L171-L198 |
42,391 | laravie/authen | src/AuthenUser.php | AuthenUser.scopeFindByIdentifiers | public function scopeFindByIdentifiers(Builder $query, $username): Builder
{
$identifiers = $this->getAuthIdentifiersName();
$query->where(function ($query) use ($identifiers, $username) {
foreach ($identifiers as $key) {
$query->orWhere($key, '=', $username);
}
});
return $query;
} | php | public function scopeFindByIdentifiers(Builder $query, $username): Builder
{
$identifiers = $this->getAuthIdentifiersName();
$query->where(function ($query) use ($identifiers, $username) {
foreach ($identifiers as $key) {
$query->orWhere($key, '=', $username);
}
});
return $query;
} | [
"public",
"function",
"scopeFindByIdentifiers",
"(",
"Builder",
"$",
"query",
",",
"$",
"username",
")",
":",
"Builder",
"{",
"$",
"identifiers",
"=",
"$",
"this",
"->",
"getAuthIdentifiersName",
"(",
")",
";",
"$",
"query",
"->",
"where",
"(",
"function",
... | Find by identifiers scope.
@param \Illuminate\Database\Eloquent\Builder $query
@param string|int $username
@return \Illuminate\Database\Eloquent\Builder | [
"Find",
"by",
"identifiers",
"scope",
"."
] | 96141e5ede07a478ce36c453ad555d246d032971 | https://github.com/laravie/authen/blob/96141e5ede07a478ce36c453ad555d246d032971/src/AuthenUser.php#L17-L28 |
42,392 | ramsey/uuid-console | src/Util/UuidFormatter.php | UuidFormatter.getContent | public function getContent(UuidInterface $uuid)
{
$formatter = self::$formatters[$uuid->getVersion()];
return $formatter->getContent($uuid);
} | php | public function getContent(UuidInterface $uuid)
{
$formatter = self::$formatters[$uuid->getVersion()];
return $formatter->getContent($uuid);
} | [
"public",
"function",
"getContent",
"(",
"UuidInterface",
"$",
"uuid",
")",
"{",
"$",
"formatter",
"=",
"self",
"::",
"$",
"formatters",
"[",
"$",
"uuid",
"->",
"getVersion",
"(",
")",
"]",
";",
"return",
"$",
"formatter",
"->",
"getContent",
"(",
"$",
... | Returns content as an array of rows, each row being an array containing column values. | [
"Returns",
"content",
"as",
"an",
"array",
"of",
"rows",
"each",
"row",
"being",
"an",
"array",
"containing",
"column",
"values",
"."
] | 80594b4c02b8083c28236f2c906aac69094a6e9f | https://github.com/ramsey/uuid-console/blob/80594b4c02b8083c28236f2c906aac69094a6e9f/src/Util/UuidFormatter.php#L92-L97 |
42,393 | laravie/authen | src/Authen.php | Authen.setIdentifierName | public static function setIdentifierName(string $identifier): void
{
if (empty($identifier)) {
throw new InvalidArgumentException("Identifier shouldn't be empty.");
} elseif (\in_array($identifier, ['password'])) {
throw new InvalidArgumentException("Identifier [{$identifier}] is not allowed!");
}
static::$identifier = $identifier;
} | php | public static function setIdentifierName(string $identifier): void
{
if (empty($identifier)) {
throw new InvalidArgumentException("Identifier shouldn't be empty.");
} elseif (\in_array($identifier, ['password'])) {
throw new InvalidArgumentException("Identifier [{$identifier}] is not allowed!");
}
static::$identifier = $identifier;
} | [
"public",
"static",
"function",
"setIdentifierName",
"(",
"string",
"$",
"identifier",
")",
":",
"void",
"{",
"if",
"(",
"empty",
"(",
"$",
"identifier",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Identifier shouldn't be empty.\"",
")",
"... | Set identifier name.
@param string $identifier
@throws \InvalidArgumentException | [
"Set",
"identifier",
"name",
"."
] | 96141e5ede07a478ce36c453ad555d246d032971 | https://github.com/laravie/authen/blob/96141e5ede07a478ce36c453ad555d246d032971/src/Authen.php#L33-L42 |
42,394 | laravie/authen | src/BootAuthenProvider.php | BootAuthenProvider.bootAuthenProvider | protected function bootAuthenProvider(): void
{
Auth::provider('authen', function ($app, array $config) {
return new AuthenUserProvider($app->make('hash'), $config['model']);
});
} | php | protected function bootAuthenProvider(): void
{
Auth::provider('authen', function ($app, array $config) {
return new AuthenUserProvider($app->make('hash'), $config['model']);
});
} | [
"protected",
"function",
"bootAuthenProvider",
"(",
")",
":",
"void",
"{",
"Auth",
"::",
"provider",
"(",
"'authen'",
",",
"function",
"(",
"$",
"app",
",",
"array",
"$",
"config",
")",
"{",
"return",
"new",
"AuthenUserProvider",
"(",
"$",
"app",
"->",
"... | Register authen user provider.
@return void | [
"Register",
"authen",
"user",
"provider",
"."
] | 96141e5ede07a478ce36c453ad555d246d032971 | https://github.com/laravie/authen/blob/96141e5ede07a478ce36c453ad555d246d032971/src/BootAuthenProvider.php#L14-L19 |
42,395 | GeniusesOfSymfony/PubSubRouterBundle | Matcher/Dumper/PhpMatcherDumper.php | PhpMatcherDumper.generateMatchMethod | private function generateMatchMethod(): string
{
// Group hosts by same-suffix, re-order when possible
$routes = new StaticPrefixCollection();
foreach ($this->getRoutes()->all() as $name => $route) {
$routes->addRoute('/(.*)', [$name, $route]);
}
$routes = $this->getRoutes();
$code = rtrim($this->compileRoutes($routes), "\n");
$code = <<<EOF
{
$code
EOF;
return " public function match(string \$channel): array\n".$code."\n throw new ResourceNotFoundException();\n }";
} | php | private function generateMatchMethod(): string
{
// Group hosts by same-suffix, re-order when possible
$routes = new StaticPrefixCollection();
foreach ($this->getRoutes()->all() as $name => $route) {
$routes->addRoute('/(.*)', [$name, $route]);
}
$routes = $this->getRoutes();
$code = rtrim($this->compileRoutes($routes), "\n");
$code = <<<EOF
{
$code
EOF;
return " public function match(string \$channel): array\n".$code."\n throw new ResourceNotFoundException();\n }";
} | [
"private",
"function",
"generateMatchMethod",
"(",
")",
":",
"string",
"{",
"// Group hosts by same-suffix, re-order when possible",
"$",
"routes",
"=",
"new",
"StaticPrefixCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRoutes",
"(",
")",
"->",
... | Generates the code for the match method implementing MatcherInterface. | [
"Generates",
"the",
"code",
"for",
"the",
"match",
"method",
"implementing",
"MatcherInterface",
"."
] | aad607c7a58131c9c44aefd02fbefefdfbe2dfc6 | https://github.com/GeniusesOfSymfony/PubSubRouterBundle/blob/aad607c7a58131c9c44aefd02fbefefdfbe2dfc6/Matcher/Dumper/PhpMatcherDumper.php#L59-L78 |
42,396 | GeniusesOfSymfony/PubSubRouterBundle | Router/RouteCompiler.php | RouteCompiler.determineStaticPrefix | private static function determineStaticPrefix(Route $route, array $tokens): string
{
if (!$tokens) {
return '';
}
if ('text' !== $tokens[0][0]) {
return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1];
}
$prefix = $tokens[0][1];
if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) {
$prefix .= $tokens[1][1];
}
return $prefix;
} | php | private static function determineStaticPrefix(Route $route, array $tokens): string
{
if (!$tokens) {
return '';
}
if ('text' !== $tokens[0][0]) {
return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1];
}
$prefix = $tokens[0][1];
if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) {
$prefix .= $tokens[1][1];
}
return $prefix;
} | [
"private",
"static",
"function",
"determineStaticPrefix",
"(",
"Route",
"$",
"route",
",",
"array",
"$",
"tokens",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"tokens",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"'text'",
"!==",
"$",
"tokens",
... | Determines the longest static prefix possible for a route. | [
"Determines",
"the",
"longest",
"static",
"prefix",
"possible",
"for",
"a",
"route",
"."
] | aad607c7a58131c9c44aefd02fbefefdfbe2dfc6 | https://github.com/GeniusesOfSymfony/PubSubRouterBundle/blob/aad607c7a58131c9c44aefd02fbefefdfbe2dfc6/Router/RouteCompiler.php#L228-L245 |
42,397 | photogabble/php-confusable-homoglyphs | src/Categories.php | Categories.aliasesCategories | public function aliasesCategories(string $chr) : array
{
$l = 0;
$r = count($this->categoriesData['code_points_ranges']);
$c = mb_ord($chr, $this->encoding);
// Binary Search
while ($r >= $l){
$m = floor(($l + $r) / 2);
if ($c < $this->categoriesData['code_points_ranges'][$m][0]) {
$r = $m - 1;
} else if ($c > $this->categoriesData['code_points_ranges'][$m][1]) {
$l = $m + 1;
} else {
return [
$this->categoriesData['iso_15924_aliases'][$this->categoriesData['code_points_ranges'][$m][2]],
$this->categoriesData['categories'][$this->categoriesData['code_points_ranges'][$m][3]],
];
}
}
return ['Unknown', 'Zzzz'];
} | php | public function aliasesCategories(string $chr) : array
{
$l = 0;
$r = count($this->categoriesData['code_points_ranges']);
$c = mb_ord($chr, $this->encoding);
// Binary Search
while ($r >= $l){
$m = floor(($l + $r) / 2);
if ($c < $this->categoriesData['code_points_ranges'][$m][0]) {
$r = $m - 1;
} else if ($c > $this->categoriesData['code_points_ranges'][$m][1]) {
$l = $m + 1;
} else {
return [
$this->categoriesData['iso_15924_aliases'][$this->categoriesData['code_points_ranges'][$m][2]],
$this->categoriesData['categories'][$this->categoriesData['code_points_ranges'][$m][3]],
];
}
}
return ['Unknown', 'Zzzz'];
} | [
"public",
"function",
"aliasesCategories",
"(",
"string",
"$",
"chr",
")",
":",
"array",
"{",
"$",
"l",
"=",
"0",
";",
"$",
"r",
"=",
"count",
"(",
"$",
"this",
"->",
"categoriesData",
"[",
"'code_points_ranges'",
"]",
")",
";",
"$",
"c",
"=",
"mb_or... | Retrieves the script block alias and unicode category for a unicode character.
e.g.
aliasesCategories('A') -> ['LATIN', 'L']
aliasesCategories('τ') -> ['GREEK', 'L']
aliasesCategories('-') -> ['COMMON', 'Pd']
@param string $chr A unicode character
@return array The script block alias and unicode category for a unicode character. | [
"Retrieves",
"the",
"script",
"block",
"alias",
"and",
"unicode",
"category",
"for",
"a",
"unicode",
"character",
"."
] | 80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688 | https://github.com/photogabble/php-confusable-homoglyphs/blob/80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688/src/Categories.php#L56-L78 |
42,398 | photogabble/php-confusable-homoglyphs | src/Categories.php | Categories.uniqueAliases | public function uniqueAliases(string $string) : array
{
$return = [];
foreach (preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) {
$alias = $this->alias($char);
if (! in_array($alias, $return)) {
array_push($return, $alias);
}
}
return $return;
} | php | public function uniqueAliases(string $string) : array
{
$return = [];
foreach (preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) {
$alias = $this->alias($char);
if (! in_array($alias, $return)) {
array_push($return, $alias);
}
}
return $return;
} | [
"public",
"function",
"uniqueAliases",
"(",
"string",
"$",
"string",
")",
":",
"array",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"preg_split",
"(",
"'//u'",
",",
"$",
"string",
",",
"-",
"1",
",",
"PREG_SPLIT_NO_EMPTY",
")",
"as",
"$",
... | Retrieves all unique script block aliases used in a unicode string.
e.g.
uniqueAliases('ABC') -> ['LATIN']
uniqueAliases('ρAτ-') -> ['GREEK', 'LATIN', 'COMMON']
@param string $string A unicode string
@return array A set of the script block aliases used in a unicode string. | [
"Retrieves",
"all",
"unique",
"script",
"block",
"aliases",
"used",
"in",
"a",
"unicode",
"string",
"."
] | 80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688 | https://github.com/photogabble/php-confusable-homoglyphs/blob/80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688/src/Categories.php#L127-L137 |
42,399 | GeniusesOfSymfony/PubSubRouterBundle | Matcher/Matcher.php | Matcher.mergeDefaults | protected function mergeDefaults(array $params, array $defaults): array
{
foreach ($params as $key => $value) {
if (!\is_int($key) && null !== $value) {
$defaults[$key] = $value;
}
}
return $defaults;
} | php | protected function mergeDefaults(array $params, array $defaults): array
{
foreach ($params as $key => $value) {
if (!\is_int($key) && null !== $value) {
$defaults[$key] = $value;
}
}
return $defaults;
} | [
"protected",
"function",
"mergeDefaults",
"(",
"array",
"$",
"params",
",",
"array",
"$",
"defaults",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"\\",
"is_int",
"(",
"$",
"... | Get merged default parameters.
@param array $params
@param array $defaults
@return array | [
"Get",
"merged",
"default",
"parameters",
"."
] | aad607c7a58131c9c44aefd02fbefefdfbe2dfc6 | https://github.com/GeniusesOfSymfony/PubSubRouterBundle/blob/aad607c7a58131c9c44aefd02fbefefdfbe2dfc6/Matcher/Matcher.php#L95-L104 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.