repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
reliv/Rcm | core/src/Service/LayoutManager.php | LayoutManager.getThemeConfig | public function getThemeConfig($theme)
{
$themesConfig = $this->getThemesConfig();
if (!empty($themesConfig[$theme])) {
return $themesConfig[$theme];
} elseif (!empty($themesConfig['generic'])) {
return $themesConfig['generic'];
}
throw new RuntimeException(
'No theme config found for ' . $theme
. ' and no default theme found'
);
} | php | public function getThemeConfig($theme)
{
$themesConfig = $this->getThemesConfig();
if (!empty($themesConfig[$theme])) {
return $themesConfig[$theme];
} elseif (!empty($themesConfig['generic'])) {
return $themesConfig['generic'];
}
throw new RuntimeException(
'No theme config found for ' . $theme
. ' and no default theme found'
);
} | [
"public",
"function",
"getThemeConfig",
"(",
"$",
"theme",
")",
"{",
"$",
"themesConfig",
"=",
"$",
"this",
"->",
"getThemesConfig",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"themesConfig",
"[",
"$",
"theme",
"]",
")",
")",
"{",
"return",
"$... | Get a themes config
@param string $theme Theme name to search for
@return array
@throws \Rcm\Exception\RuntimeException | [
"Get",
"a",
"themes",
"config"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/LayoutManager.php#L72-L86 | train |
reliv/Rcm | core/src/Service/LayoutManager.php | LayoutManager.getSiteLayout | public function getSiteLayout(Site $site, $layout = null)
{
$themeLayoutConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());
if (empty($layout)) {
$layout = $site->getSiteLayout();
}
if (!empty($themeLayoutConfig[$layout])
&& !empty($themeLayoutConfig[$layout]['file'])
) {
return $themeLayoutConfig[$layout]['file'];
} elseif (!empty($themeLayoutConfig['default'])
&& !empty($themeLayoutConfig['default']['file'])
) {
return $themeLayoutConfig['default']['file'];
}
throw new RuntimeException('No Layouts Found in config');
} | php | public function getSiteLayout(Site $site, $layout = null)
{
$themeLayoutConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());
if (empty($layout)) {
$layout = $site->getSiteLayout();
}
if (!empty($themeLayoutConfig[$layout])
&& !empty($themeLayoutConfig[$layout]['file'])
) {
return $themeLayoutConfig[$layout]['file'];
} elseif (!empty($themeLayoutConfig['default'])
&& !empty($themeLayoutConfig['default']['file'])
) {
return $themeLayoutConfig['default']['file'];
}
throw new RuntimeException('No Layouts Found in config');
} | [
"public",
"function",
"getSiteLayout",
"(",
"Site",
"$",
"site",
",",
"$",
"layout",
"=",
"null",
")",
"{",
"$",
"themeLayoutConfig",
"=",
"$",
"this",
"->",
"getSiteThemeLayoutsConfig",
"(",
"$",
"site",
"->",
"getTheme",
"(",
")",
")",
";",
"if",
"(",
... | Get Layout method will attempt to locate and fetch the correct layout
for the site and page. If found it will pass back the path to correct
view template so that the indexAction can pass that value on to the
renderer.
@param string|null $layout Layout to find
@param Site $site Site to lookup
@return string
@throws RuntimeException
@throws InvalidArgumentException | [
"Get",
"Layout",
"method",
"will",
"attempt",
"to",
"locate",
"and",
"fetch",
"the",
"correct",
"layout",
"for",
"the",
"site",
"and",
"page",
".",
"If",
"found",
"it",
"will",
"pass",
"back",
"the",
"path",
"to",
"correct",
"view",
"template",
"so",
"th... | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/LayoutManager.php#L135-L154 | train |
reliv/Rcm | core/src/Service/LayoutManager.php | LayoutManager.getSitePageTemplateConfig | public function getSitePageTemplateConfig(Site $site, $template = null)
{
$themePageConfig = $this->getSiteThemePagesTemplateConfig($site);
if (!empty($themePageConfig[$template])) {
return $themePageConfig[$template];
} elseif (!empty($themePageConfig['default'])) {
return $themePageConfig['default'];
}
throw new RuntimeException('No Page Template Found in config');
} | php | public function getSitePageTemplateConfig(Site $site, $template = null)
{
$themePageConfig = $this->getSiteThemePagesTemplateConfig($site);
if (!empty($themePageConfig[$template])) {
return $themePageConfig[$template];
} elseif (!empty($themePageConfig['default'])) {
return $themePageConfig['default'];
}
throw new RuntimeException('No Page Template Found in config');
} | [
"public",
"function",
"getSitePageTemplateConfig",
"(",
"Site",
"$",
"site",
",",
"$",
"template",
"=",
"null",
")",
"{",
"$",
"themePageConfig",
"=",
"$",
"this",
"->",
"getSiteThemePagesTemplateConfig",
"(",
"$",
"site",
")",
";",
"if",
"(",
"!",
"empty",
... | Get Page Template method will attempt to locate and fetch the correct template
config for the page. Default page template is set by the themes
configuration and can also be set per page.
@param Site $site Site to lookup
@param string|null $template Template to find
@return string
@throws RuntimeException
@throws InvalidArgumentException | [
"Get",
"Page",
"Template",
"method",
"will",
"attempt",
"to",
"locate",
"and",
"fetch",
"the",
"correct",
"template",
"config",
"for",
"the",
"page",
".",
"Default",
"page",
"template",
"is",
"set",
"by",
"the",
"themes",
"configuration",
"and",
"can",
"also... | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/LayoutManager.php#L195-L206 | train |
reliv/Rcm | core/src/Service/LayoutManager.php | LayoutManager.getSitePageTemplate | public function getSitePageTemplate(Site $site, $template = null)
{
$themePageConfig = $this->getSitePageTemplateConfig($site, $template);
if (empty($themePageConfig['file'])) {
throw new RuntimeException('No Page Template Found in config');
}
return $themePageConfig['file'];
} | php | public function getSitePageTemplate(Site $site, $template = null)
{
$themePageConfig = $this->getSitePageTemplateConfig($site, $template);
if (empty($themePageConfig['file'])) {
throw new RuntimeException('No Page Template Found in config');
}
return $themePageConfig['file'];
} | [
"public",
"function",
"getSitePageTemplate",
"(",
"Site",
"$",
"site",
",",
"$",
"template",
"=",
"null",
")",
"{",
"$",
"themePageConfig",
"=",
"$",
"this",
"->",
"getSitePageTemplateConfig",
"(",
"$",
"site",
",",
"$",
"template",
")",
";",
"if",
"(",
... | Get Page Template method will attempt to locate and fetch the correct template
for the page. If found it will pass back the path to correct
view template so that the indexAction can pass that value on to the
renderer. Default page template is set by the themes configuration and can
also be set per page.
@param Site $site Site to lookup
@param string|null $template Template to find
@return string
@throws RuntimeException
@throws InvalidArgumentException | [
"Get",
"Page",
"Template",
"method",
"will",
"attempt",
"to",
"locate",
"and",
"fetch",
"the",
"correct",
"template",
"for",
"the",
"page",
".",
"If",
"found",
"it",
"will",
"pass",
"back",
"the",
"path",
"to",
"correct",
"view",
"template",
"so",
"that",
... | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/LayoutManager.php#L222-L231 | train |
reliv/Rcm | core/src/Service/LayoutManager.php | LayoutManager.isLayoutValid | public function isLayoutValid(Site $site, $layoutKey)
{
$themesConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());
if (!empty($themesConfig[$layoutKey])) {
return true;
}
return false;
} | php | public function isLayoutValid(Site $site, $layoutKey)
{
$themesConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());
if (!empty($themesConfig[$layoutKey])) {
return true;
}
return false;
} | [
"public",
"function",
"isLayoutValid",
"(",
"Site",
"$",
"site",
",",
"$",
"layoutKey",
")",
"{",
"$",
"themesConfig",
"=",
"$",
"this",
"->",
"getSiteThemeLayoutsConfig",
"(",
"$",
"site",
"->",
"getTheme",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
... | Check to see if a layout is valid and available for a theme
@param Site $site Site to lookup
@param string $layoutKey Layout name to search
@return boolean
@throws InvalidArgumentException | [
"Check",
"to",
"see",
"if",
"a",
"layout",
"is",
"valid",
"and",
"available",
"for",
"a",
"theme"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/LayoutManager.php#L242-L251 | train |
GoIntegro/hateoas | Collections/ResourceEntityCollection.php | ResourceEntityCollection.canAdd | public function canAdd(ResourceEntityInterface $entity)
{
return empty($this->className)
|| get_class($entity) == $this->className;
} | php | public function canAdd(ResourceEntityInterface $entity)
{
return empty($this->className)
|| get_class($entity) == $this->className;
} | [
"public",
"function",
"canAdd",
"(",
"ResourceEntityInterface",
"$",
"entity",
")",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"className",
")",
"||",
"get_class",
"(",
"$",
"entity",
")",
"==",
"$",
"this",
"->",
"className",
";",
"}"
] | Verifica que la entidad sea del tipo correcto.
@param ResourceEntityInterface $entity
@return boolean | [
"Verifica",
"que",
"la",
"entidad",
"sea",
"del",
"tipo",
"correcto",
"."
] | 4799794294079f8bd3839e76175134219f876105 | https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Collections/ResourceEntityCollection.php#L61-L65 | train |
webeweb/core-bundle | Twig/Extension/RendererTwigExtension.php | RendererTwigExtension.coreScriptFilter | public function coreScriptFilter($content) {
$attributes = [];
$attributes["type"] = "text/javascript";
$innerHTML = null !== $content ? implode("", ["\n", $content, "\n"]) : "";
return static::coreHTMLElement("script", $innerHTML, $attributes);
} | php | public function coreScriptFilter($content) {
$attributes = [];
$attributes["type"] = "text/javascript";
$innerHTML = null !== $content ? implode("", ["\n", $content, "\n"]) : "";
return static::coreHTMLElement("script", $innerHTML, $attributes);
} | [
"public",
"function",
"coreScriptFilter",
"(",
"$",
"content",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"$",
"attributes",
"[",
"\"type\"",
"]",
"=",
"\"text/javascript\"",
";",
"$",
"innerHTML",
"=",
"null",
"!==",
"$",
"content",
"?",
"implode",
... | Displays a script.
@param string $content The content.
@return string Returns a script. | [
"Displays",
"a",
"script",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/RendererTwigExtension.php#L41-L50 | train |
dadajuice/zephyrus | src/Zephyrus/Utilities/Uploaders/FileUploader.php | FileUploader.setDestinationDirectory | final public function setDestinationDirectory(string $destinationDirectory)
{
if ($destinationDirectory[strlen($destinationDirectory) - 1] != DIRECTORY_SEPARATOR) {
$destinationDirectory .= DIRECTORY_SEPARATOR;
}
$this->destinationDirectory = $destinationDirectory;
} | php | final public function setDestinationDirectory(string $destinationDirectory)
{
if ($destinationDirectory[strlen($destinationDirectory) - 1] != DIRECTORY_SEPARATOR) {
$destinationDirectory .= DIRECTORY_SEPARATOR;
}
$this->destinationDirectory = $destinationDirectory;
} | [
"final",
"public",
"function",
"setDestinationDirectory",
"(",
"string",
"$",
"destinationDirectory",
")",
"{",
"if",
"(",
"$",
"destinationDirectory",
"[",
"strlen",
"(",
"$",
"destinationDirectory",
")",
"-",
"1",
"]",
"!=",
"DIRECTORY_SEPARATOR",
")",
"{",
"$... | Apply the uploaded file directory to be used as a destination. Specified
path starts from the project root directory. Will trim unnecessary
leading slashes.
@param string $destinationDirectory | [
"Apply",
"the",
"uploaded",
"file",
"directory",
"to",
"be",
"used",
"as",
"a",
"destination",
".",
"Specified",
"path",
"starts",
"from",
"the",
"project",
"root",
"directory",
".",
"Will",
"trim",
"unnecessary",
"leading",
"slashes",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Utilities/Uploaders/FileUploader.php#L170-L176 | train |
dadajuice/zephyrus | src/Zephyrus/Utilities/Uploaders/FileUploader.php | FileUploader.setDestinationFilename | final public function setDestinationFilename(string $filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (empty($extension) && !empty($this->uploadFile->getExtension())) {
$filename .= '.' . $this->uploadFile->getExtension();
}
$this->destinationFilename = $filename;
} | php | final public function setDestinationFilename(string $filename)
{
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if (empty($extension) && !empty($this->uploadFile->getExtension())) {
$filename .= '.' . $this->uploadFile->getExtension();
}
$this->destinationFilename = $filename;
} | [
"final",
"public",
"function",
"setDestinationFilename",
"(",
"string",
"$",
"filename",
")",
"{",
"$",
"extension",
"=",
"pathinfo",
"(",
"$",
"filename",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"extension",
")",
"&&",
"!",
"emp... | Apply the uploaded filename to be used in the destination directory. To
keep the same extension, simply omit to specify it in the filename.
@param string $filename | [
"Apply",
"the",
"uploaded",
"filename",
"to",
"be",
"used",
"in",
"the",
"destination",
"directory",
".",
"To",
"keep",
"the",
"same",
"extension",
"simply",
"omit",
"to",
"specify",
"it",
"in",
"the",
"filename",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Utilities/Uploaders/FileUploader.php#L192-L199 | train |
RogerWaters/react-thread-pool | src/Protocol/BinaryBuffer.php | BinaryBuffer.receiveHeader | protected function receiveHeader()
{
if(strlen($this->bufferData) > 8)
{
$header = substr($this->bufferData,0,8);
$this->waitingFor = intval($header);
$this->bufferData = substr($this->bufferData,8);
$this->headerReceived = true;
return strlen($this->bufferData) > 0;
}
return false;
} | php | protected function receiveHeader()
{
if(strlen($this->bufferData) > 8)
{
$header = substr($this->bufferData,0,8);
$this->waitingFor = intval($header);
$this->bufferData = substr($this->bufferData,8);
$this->headerReceived = true;
return strlen($this->bufferData) > 0;
}
return false;
} | [
"protected",
"function",
"receiveHeader",
"(",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"bufferData",
")",
">",
"8",
")",
"{",
"$",
"header",
"=",
"substr",
"(",
"$",
"this",
"->",
"bufferData",
",",
"0",
",",
"8",
")",
";",
"$",
"t... | Try to receive header from buffer
on success the next operation is receiveBody
@return bool | [
"Try",
"to",
"receive",
"header",
"from",
"buffer",
"on",
"success",
"the",
"next",
"operation",
"is",
"receiveBody"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/Protocol/BinaryBuffer.php#L82-L93 | train |
RogerWaters/react-thread-pool | src/Protocol/BinaryBuffer.php | BinaryBuffer.receiveBody | protected function receiveBody()
{
if(strlen($this->bufferData) >= $this->waitingFor)
{
$this->messages[] = substr($this->bufferData,0,$this->waitingFor);
$this->bufferData = substr($this->bufferData,$this->waitingFor);
$this->headerReceived = false;
return strlen($this->bufferData) > 0;
}
return false;
} | php | protected function receiveBody()
{
if(strlen($this->bufferData) >= $this->waitingFor)
{
$this->messages[] = substr($this->bufferData,0,$this->waitingFor);
$this->bufferData = substr($this->bufferData,$this->waitingFor);
$this->headerReceived = false;
return strlen($this->bufferData) > 0;
}
return false;
} | [
"protected",
"function",
"receiveBody",
"(",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"bufferData",
")",
">=",
"$",
"this",
"->",
"waitingFor",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"]",
"=",
"substr",
"(",
"$",
"this",
"->",
... | Try to read the number of bytes given from header into message
On success the next operation is receiveHeader
@return bool | [
"Try",
"to",
"read",
"the",
"number",
"of",
"bytes",
"given",
"from",
"header",
"into",
"message",
"On",
"success",
"the",
"next",
"operation",
"is",
"receiveHeader"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/Protocol/BinaryBuffer.php#L100-L110 | train |
RogerWaters/react-thread-pool | src/Protocol/BinaryBuffer.php | BinaryBuffer.encodeMessage | public static function encodeMessage($message)
{
$waitingData = strlen($message);
$header = str_pad((string)$waitingData,8,'0',STR_PAD_LEFT);
return $header.$message;
} | php | public static function encodeMessage($message)
{
$waitingData = strlen($message);
$header = str_pad((string)$waitingData,8,'0',STR_PAD_LEFT);
return $header.$message;
} | [
"public",
"static",
"function",
"encodeMessage",
"(",
"$",
"message",
")",
"{",
"$",
"waitingData",
"=",
"strlen",
"(",
"$",
"message",
")",
";",
"$",
"header",
"=",
"str_pad",
"(",
"(",
"string",
")",
"$",
"waitingData",
",",
"8",
",",
"'0'",
",",
"... | Encode the message with header and body to directly write to any socket
@param string $message
@return string | [
"Encode",
"the",
"message",
"with",
"header",
"and",
"body",
"to",
"directly",
"write",
"to",
"any",
"socket"
] | cdbbe172f5953c84f6b412a7cea94e425ff065df | https://github.com/RogerWaters/react-thread-pool/blob/cdbbe172f5953c84f6b412a7cea94e425ff065df/src/Protocol/BinaryBuffer.php#L128-L133 | train |
webeweb/core-bundle | Navigation/FOSUserBreadcrumbNodes.php | FOSUserBreadcrumbNodes.getFontAwesomeBreadcrumbNodes | public static function getFontAwesomeBreadcrumbNodes() {
$breadcrumbNodes = [];
$breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "fa:user", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.show_profile", "fa:user", "fos_user_profile_show", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.change_password", "fa:lock", "fos_user_change_password", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
return $breadcrumbNodes;
} | php | public static function getFontAwesomeBreadcrumbNodes() {
$breadcrumbNodes = [];
$breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "fa:user", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.show_profile", "fa:user", "fos_user_profile_show", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.change_password", "fa:lock", "fos_user_change_password", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
return $breadcrumbNodes;
} | [
"public",
"static",
"function",
"getFontAwesomeBreadcrumbNodes",
"(",
")",
"{",
"$",
"breadcrumbNodes",
"=",
"[",
"]",
";",
"$",
"breadcrumbNodes",
"[",
"]",
"=",
"new",
"BreadcrumbNode",
"(",
"\"label.edit_profile\"",
",",
"\"fa:user\"",
",",
"\"fos_user_profile_ed... | Get a FOSUser breadcrumb node with Font Awesome icons.
@return BreadcrumbNode[] Returns the FOSUser breadcrumb node. | [
"Get",
"a",
"FOSUser",
"breadcrumb",
"node",
"with",
"Font",
"Awesome",
"icons",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Navigation/FOSUserBreadcrumbNodes.php#L27-L36 | train |
webeweb/core-bundle | Navigation/FOSUserBreadcrumbNodes.php | FOSUserBreadcrumbNodes.getMaterialDesignIconicFontBreadcrumbNodes | public static function getMaterialDesignIconicFontBreadcrumbNodes() {
$breadcrumbNodes = [];
$breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "zmdi:account", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.show_profile", "zmdi:account", "fos_user_profile_show", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.change_password", "zmdi:lock", "fos_user_change_password", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
return $breadcrumbNodes;
} | php | public static function getMaterialDesignIconicFontBreadcrumbNodes() {
$breadcrumbNodes = [];
$breadcrumbNodes[] = new BreadcrumbNode("label.edit_profile", "zmdi:account", "fos_user_profile_edit", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.show_profile", "zmdi:account", "fos_user_profile_show", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
$breadcrumbNodes[] = new BreadcrumbNode("label.change_password", "zmdi:lock", "fos_user_change_password", NavigationInterface::NAVIGATION_MATCHER_ROUTER);
return $breadcrumbNodes;
} | [
"public",
"static",
"function",
"getMaterialDesignIconicFontBreadcrumbNodes",
"(",
")",
"{",
"$",
"breadcrumbNodes",
"=",
"[",
"]",
";",
"$",
"breadcrumbNodes",
"[",
"]",
"=",
"new",
"BreadcrumbNode",
"(",
"\"label.edit_profile\"",
",",
"\"zmdi:account\"",
",",
"\"f... | Get a FOSUser breadcrumb node with Material Design Iconic Font icons.
@return BreadcrumbNode[] Returns the FOSUser breadcrumb node. | [
"Get",
"a",
"FOSUser",
"breadcrumb",
"node",
"with",
"Material",
"Design",
"Iconic",
"Font",
"icons",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Navigation/FOSUserBreadcrumbNodes.php#L43-L52 | train |
russsiq/bixbite | app/Support/PageInfo.php | PageInfo.scriptVariables | public function scriptVariables()
{
$data = json_encode([
'locale' => $this->get('locale'),
'app_name' => $this->get('app_name'),
'app_skin' => $this->get('app_skin'),
'app_theme' => $this->get('app_theme'),
'app_url' => $this->get('app_url'),
]);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \RuntimeException(json_last_error_msg());
}
return $data;
} | php | public function scriptVariables()
{
$data = json_encode([
'locale' => $this->get('locale'),
'app_name' => $this->get('app_name'),
'app_skin' => $this->get('app_skin'),
'app_theme' => $this->get('app_theme'),
'app_url' => $this->get('app_url'),
]);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new \RuntimeException(json_last_error_msg());
}
return $data;
} | [
"public",
"function",
"scriptVariables",
"(",
")",
"{",
"$",
"data",
"=",
"json_encode",
"(",
"[",
"'locale'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'locale'",
")",
",",
"'app_name'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'app_name'",
")",
",",
"'app_s... | Get the variables for vue.js or another javascript.
@return string | [
"Get",
"the",
"variables",
"for",
"vue",
".",
"js",
"or",
"another",
"javascript",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Support/PageInfo.php#L61-L76 | train |
webeweb/core-bundle | Twig/Extension/AbstractTwigExtension.php | AbstractTwigExtension.coreHTMLElement | public static function coreHTMLElement($element, $content, array $attrs = []) {
$template = "<%element%%attributes%>%innerHTML%</%element%>";
$attributes = trim(StringHelper::parseArray($attrs));
if (0 < strlen($attributes)) {
$attributes = " " . $attributes;
}
$innerHTML = null !== $content ? trim($content, " ") : "";
return StringHelper::replace($template, ["%element%", "%attributes%", "%innerHTML%"], [trim($element), $attributes, $innerHTML]);
} | php | public static function coreHTMLElement($element, $content, array $attrs = []) {
$template = "<%element%%attributes%>%innerHTML%</%element%>";
$attributes = trim(StringHelper::parseArray($attrs));
if (0 < strlen($attributes)) {
$attributes = " " . $attributes;
}
$innerHTML = null !== $content ? trim($content, " ") : "";
return StringHelper::replace($template, ["%element%", "%attributes%", "%innerHTML%"], [trim($element), $attributes, $innerHTML]);
} | [
"public",
"static",
"function",
"coreHTMLElement",
"(",
"$",
"element",
",",
"$",
"content",
",",
"array",
"$",
"attrs",
"=",
"[",
"]",
")",
"{",
"$",
"template",
"=",
"\"<%element%%attributes%>%innerHTML%</%element%>\"",
";",
"$",
"attributes",
"=",
"trim",
"... | Displays an HTML element.
@param string $element The object.
@param string $content The content.
@param array $attrs The attributes.
@return string Returns the HTML element. | [
"Displays",
"an",
"HTML",
"element",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/AbstractTwigExtension.php#L62-L74 | train |
andreas-glaser/php-helpers | src/TimerHelper.php | TimerHelper.start | public static function start($alias)
{
if (isset(self::$timers[$alias])) {
throw new \RuntimeException('Timer has already been started.');
}
self::$timers[$alias] = microtime();
} | php | public static function start($alias)
{
if (isset(self::$timers[$alias])) {
throw new \RuntimeException('Timer has already been started.');
}
self::$timers[$alias] = microtime();
} | [
"public",
"static",
"function",
"start",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"timers",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Timer has already been started.'",
")",
";... | Starts timer.
@param $alias
@throws \RuntimeException | [
"Starts",
"timer",
"."
] | 84d8b98b72d01c262a5df0fb8545cb80a63afcc4 | https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/TimerHelper.php#L25-L32 | train |
andreas-glaser/php-helpers | src/TimerHelper.php | TimerHelper.getDifference | public static function getDifference($alias)
{
if (!isset(self::$timers[$alias])) {
throw new \RuntimeException('Timer has not been started');
}
return microtime() - self::$timers[$alias];
} | php | public static function getDifference($alias)
{
if (!isset(self::$timers[$alias])) {
throw new \RuntimeException('Timer has not been started');
}
return microtime() - self::$timers[$alias];
} | [
"public",
"static",
"function",
"getDifference",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"timers",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Timer has not been started'",
... | Gets current time passed since start.
@param $alias
@return mixed
@throws \RuntimeException | [
"Gets",
"current",
"time",
"passed",
"since",
"start",
"."
] | 84d8b98b72d01c262a5df0fb8545cb80a63afcc4 | https://github.com/andreas-glaser/php-helpers/blob/84d8b98b72d01c262a5df0fb8545cb80a63afcc4/src/TimerHelper.php#L44-L51 | train |
russsiq/bixbite | app/Models/Observers/FileObserver.php | FileObserver.originalPath | protected function originalPath(File $file, string $thumbSize = null)
{
return $file->getOriginal('type')
.DS.$file->getOriginal('category')
.($thumbSize ? DS.$thumbSize : '')
.DS.$file->getOriginal('name').'.'.$file->getOriginal('extension');
} | php | protected function originalPath(File $file, string $thumbSize = null)
{
return $file->getOriginal('type')
.DS.$file->getOriginal('category')
.($thumbSize ? DS.$thumbSize : '')
.DS.$file->getOriginal('name').'.'.$file->getOriginal('extension');
} | [
"protected",
"function",
"originalPath",
"(",
"File",
"$",
"file",
",",
"string",
"$",
"thumbSize",
"=",
"null",
")",
"{",
"return",
"$",
"file",
"->",
"getOriginal",
"(",
"'type'",
")",
".",
"DS",
".",
"$",
"file",
"->",
"getOriginal",
"(",
"'category'"... | Get original path to file.
@param string|null $thumbSize
@return string | [
"Get",
"original",
"path",
"to",
"file",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Observers/FileObserver.php#L15-L21 | train |
webeweb/core-bundle | Renderer/DateTimeRenderer.php | DateTimeRenderer.renderAge | public static function renderAge(DateTime $birthDate, DateTime $refDate = null) {
// Use the current date/time.
if (null === $refDate) {
$refDate = new DateTime();
}
$diff = $refDate->getTimestamp() - $birthDate->getTimestamp();
$years = new DateTime("@" . $diff);
return intval($years->format("Y")) - 1970;
} | php | public static function renderAge(DateTime $birthDate, DateTime $refDate = null) {
// Use the current date/time.
if (null === $refDate) {
$refDate = new DateTime();
}
$diff = $refDate->getTimestamp() - $birthDate->getTimestamp();
$years = new DateTime("@" . $diff);
return intval($years->format("Y")) - 1970;
} | [
"public",
"static",
"function",
"renderAge",
"(",
"DateTime",
"$",
"birthDate",
",",
"DateTime",
"$",
"refDate",
"=",
"null",
")",
"{",
"// Use the current date/time.",
"if",
"(",
"null",
"===",
"$",
"refDate",
")",
"{",
"$",
"refDate",
"=",
"new",
"DateTime... | Render an age.
@param DateTime $birthDate The birth date.
@param DateTime|null $refDate The reference date.
@return int Returns the age.
@throws Exception Throws an exception if an errors occurs. | [
"Render",
"an",
"age",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Renderer/DateTimeRenderer.php#L40-L51 | train |
russsiq/bixbite | app/Models/Traits/CacheForgetByKeys.php | CacheForgetByKeys.cacheForgetByKeys | protected function cacheForgetByKeys($entity = null)
{
$keys = $this->keysToForgetCache;
if (is_array($keys) and array_diff_key($keys, array_keys(array_keys($keys)))) {
foreach ($keys as $key => $method) {
cache()->forget($key);
if (is_subclass_of($entity, ParentModel::class)) {
if (method_exists($model = $entity->getModel(), $method)) {
$model->$method();
}
}
}
}
} | php | protected function cacheForgetByKeys($entity = null)
{
$keys = $this->keysToForgetCache;
if (is_array($keys) and array_diff_key($keys, array_keys(array_keys($keys)))) {
foreach ($keys as $key => $method) {
cache()->forget($key);
if (is_subclass_of($entity, ParentModel::class)) {
if (method_exists($model = $entity->getModel(), $method)) {
$model->$method();
}
}
}
}
} | [
"protected",
"function",
"cacheForgetByKeys",
"(",
"$",
"entity",
"=",
"null",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"keysToForgetCache",
";",
"if",
"(",
"is_array",
"(",
"$",
"keys",
")",
"and",
"array_diff_key",
"(",
"$",
"keys",
",",
"array_k... | Clearing cache by keys. | [
"Clearing",
"cache",
"by",
"keys",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Traits/CacheForgetByKeys.php#L20-L34 | train |
reliv/Rcm | core/src/Entity/Site.php | Site.setDomain | public function setDomain(Domain $domain)
{
$this->domain = $domain;
$this->domainId = $domain->getDomainId();
} | php | public function setDomain(Domain $domain)
{
$this->domain = $domain;
$this->domainId = $domain->getDomainId();
} | [
"public",
"function",
"setDomain",
"(",
"Domain",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"domain",
"=",
"$",
"domain",
";",
"$",
"this",
"->",
"domainId",
"=",
"$",
"domain",
"->",
"getDomainId",
"(",
")",
";",
"}"
] | Add a domain to the site
@param Domain $domain Domain object to add
@return void | [
"Add",
"a",
"domain",
"to",
"the",
"site"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Site.php#L479-L483 | train |
reliv/Rcm | core/src/Entity/Site.php | Site.setLanguage | public function setLanguage(Language $language)
{
$this->language = $language;
$this->languageId = $language->getLanguageId();
} | php | public function setLanguage(Language $language)
{
$this->language = $language;
$this->languageId = $language->getLanguageId();
} | [
"public",
"function",
"setLanguage",
"(",
"Language",
"$",
"language",
")",
"{",
"$",
"this",
"->",
"language",
"=",
"$",
"language",
";",
"$",
"this",
"->",
"languageId",
"=",
"$",
"language",
"->",
"getLanguageId",
"(",
")",
";",
"}"
] | Sets the Language property
@param Language $language Language Entity
@return void | [
"Sets",
"the",
"Language",
"property"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Site.php#L526-L530 | train |
reliv/Rcm | core/src/Entity/Site.php | Site.getContainer | public function getContainer($name)
{
$container = $this->containers->get($name);
if (empty($container)) {
return null;
}
return $container;
} | php | public function getContainer($name)
{
$container = $this->containers->get($name);
if (empty($container)) {
return null;
}
return $container;
} | [
"public",
"function",
"getContainer",
"(",
"$",
"name",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"containers",
"->",
"get",
"(",
"$",
"name",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"container",
")",
")",
"{",
"return",
"null",
";",
"}",... | Get all the page entities for the site.
@param string $name Name of container
@return Container Container Entity | [
"Get",
"all",
"the",
"page",
"entities",
"for",
"the",
"site",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Site.php#L749-L758 | train |
LaNetscouade/SocialFeed | src/Fixer/PhpDocFullyQualifiedParamHintFixer.php | PhpDocFullyQualifiedParamHintFixer.getMatches | private function getMatches($line, $matchCommentOnly = false)
{
if (preg_match($this->regex, $line, $matches)) {
if (!empty($matches['tag2'])) {
$matches['tag'] = $matches['tag2'];
$matches['hint'] = $matches['hint2'];
}
return $matches;
}
if ($matchCommentOnly && preg_match($this->regexCommentLine, $line, $matches)) {
$matches['tag'] = null;
$matches['var'] = '';
$matches['hint'] = '';
return $matches;
}
} | php | private function getMatches($line, $matchCommentOnly = false)
{
if (preg_match($this->regex, $line, $matches)) {
if (!empty($matches['tag2'])) {
$matches['tag'] = $matches['tag2'];
$matches['hint'] = $matches['hint2'];
}
return $matches;
}
if ($matchCommentOnly && preg_match($this->regexCommentLine, $line, $matches)) {
$matches['tag'] = null;
$matches['var'] = '';
$matches['hint'] = '';
return $matches;
}
} | [
"private",
"function",
"getMatches",
"(",
"$",
"line",
",",
"$",
"matchCommentOnly",
"=",
"false",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"regex",
",",
"$",
"line",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(... | Get all matches.
@param string $line
@param bool $matchCommentOnly
@return string[]|null | [
"Get",
"all",
"matches",
"."
] | 3d0b463acb0fe1a7d7131de6284cdbf64056dc93 | https://github.com/LaNetscouade/SocialFeed/blob/3d0b463acb0fe1a7d7131de6284cdbf64056dc93/src/Fixer/PhpDocFullyQualifiedParamHintFixer.php#L237-L254 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.getPageByName | public function getPageByName(
SiteEntity $site,
$pageName,
$pageType = PageTypes::NORMAL
) {
$results = $this->getPagesByName(
$site,
$pageName,
$pageType
);
if (empty($results)) {
return null;
}
return $results[0];
} | php | public function getPageByName(
SiteEntity $site,
$pageName,
$pageType = PageTypes::NORMAL
) {
$results = $this->getPagesByName(
$site,
$pageName,
$pageType
);
if (empty($results)) {
return null;
}
return $results[0];
} | [
"public",
"function",
"getPageByName",
"(",
"SiteEntity",
"$",
"site",
",",
"$",
"pageName",
",",
"$",
"pageType",
"=",
"PageTypes",
"::",
"NORMAL",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"getPagesByName",
"(",
"$",
"site",
",",
"$",
"pageName... | Get a page entity by name
@param SiteEntity $site Site to lookup
@param string $pageName Page Name
@param string $pageType Page Type
@return null|PageEntity | [
"Get",
"a",
"page",
"entity",
"by",
"name"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L49-L65 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.getPublishedRevisionId | public function getPublishedRevisionId($siteId, $name, $type = PageTypes::NORMAL)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('publishedRevision.revisionId')
->from(\Rcm\Entity\Page::class, 'page')
->join('page.publishedRevision', 'publishedRevision')
->join('page.site', 'site')
->where('site.siteId = :siteId')
->andWhere('page.name = :pageName')
->andWhere('page.pageType = :pageType')
->setParameter('siteId', $siteId)
->setParameter('pageName', $name)
->setParameter('pageType', $type);
try {
return $queryBuilder->getQuery()->getSingleScalarResult();
} catch (NoResultException $e) {
return null;
}
} | php | public function getPublishedRevisionId($siteId, $name, $type = PageTypes::NORMAL)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('publishedRevision.revisionId')
->from(\Rcm\Entity\Page::class, 'page')
->join('page.publishedRevision', 'publishedRevision')
->join('page.site', 'site')
->where('site.siteId = :siteId')
->andWhere('page.name = :pageName')
->andWhere('page.pageType = :pageType')
->setParameter('siteId', $siteId)
->setParameter('pageName', $name)
->setParameter('pageType', $type);
try {
return $queryBuilder->getQuery()->getSingleScalarResult();
} catch (NoResultException $e) {
return null;
}
} | [
"public",
"function",
"getPublishedRevisionId",
"(",
"$",
"siteId",
",",
"$",
"name",
",",
"$",
"type",
"=",
"PageTypes",
"::",
"NORMAL",
")",
"{",
"/** @var \\Doctrine\\ORM\\QueryBuilder $queryBuilder */",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"_em",
"->",... | Gets the DB result of the Published Revision
@param integer $siteId Site Id
@param string $name Name of the container
@param string $type Type of the container. Currently only used by the page
container.
@return mixed | [
"Gets",
"the",
"DB",
"result",
"of",
"the",
"Published",
"Revision"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L105-L125 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.getAllPageIdsAndNamesBySiteThenType | public function getAllPageIdsAndNamesBySiteThenType($siteId, $type)
{
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('page.name, page.pageId')
->from(\Rcm\Entity\Page::class, 'page')
->join('page.site', 'site')
->where('page.pageType = :pageType')
->andWhere('site.siteId = :siteId')
->setParameter('pageType', $type)
->setParameter('siteId', $siteId);
$result = $queryBuilder->getQuery()->getArrayResult();
if (empty($result)) {
return null;
}
$return = [];
foreach ($result as &$page) {
$return[$page['pageId']] = $page['name'];
}
return $return;
} | php | public function getAllPageIdsAndNamesBySiteThenType($siteId, $type)
{
$queryBuilder = $this->_em->createQueryBuilder();
$queryBuilder->select('page.name, page.pageId')
->from(\Rcm\Entity\Page::class, 'page')
->join('page.site', 'site')
->where('page.pageType = :pageType')
->andWhere('site.siteId = :siteId')
->setParameter('pageType', $type)
->setParameter('siteId', $siteId);
$result = $queryBuilder->getQuery()->getArrayResult();
if (empty($result)) {
return null;
}
$return = [];
foreach ($result as &$page) {
$return[$page['pageId']] = $page['name'];
}
return $return;
} | [
"public",
"function",
"getAllPageIdsAndNamesBySiteThenType",
"(",
"$",
"siteId",
",",
"$",
"type",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'page.name, p... | Get a list of page id's and page names by a given type
@param integer $siteId SiteId
@param string $type Page Type to Search By
@return array | [
"Get",
"a",
"list",
"of",
"page",
"id",
"s",
"and",
"page",
"names",
"by",
"a",
"given",
"type"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L224-L249 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.setPageDeleted | public function setPageDeleted(
PageEntity $page,
string $modifiedByUserId,
string $modifiedReason = Tracking::UNKNOWN_REASON
) {
$pageType = $page->getPageType();
if (strpos($pageType, self::PAGE_TYPE_DELETED) !== false) {
return;//This page is already deleted so we don't need to do anything further
}
$page->setPageType(self::PAGE_TYPE_DELETED . $pageType);
$page->setModifiedByUserId(
$modifiedByUserId,
$modifiedReason
);
$this->_em->persist($page);
$this->_em->flush($page);
} | php | public function setPageDeleted(
PageEntity $page,
string $modifiedByUserId,
string $modifiedReason = Tracking::UNKNOWN_REASON
) {
$pageType = $page->getPageType();
if (strpos($pageType, self::PAGE_TYPE_DELETED) !== false) {
return;//This page is already deleted so we don't need to do anything further
}
$page->setPageType(self::PAGE_TYPE_DELETED . $pageType);
$page->setModifiedByUserId(
$modifiedByUserId,
$modifiedReason
);
$this->_em->persist($page);
$this->_em->flush($page);
} | [
"public",
"function",
"setPageDeleted",
"(",
"PageEntity",
"$",
"page",
",",
"string",
"$",
"modifiedByUserId",
",",
"string",
"$",
"modifiedReason",
"=",
"Tracking",
"::",
"UNKNOWN_REASON",
")",
"{",
"$",
"pageType",
"=",
"$",
"page",
"->",
"getPageType",
"("... | setPageDeleted - A way of making pages appear deleted without deleting the DB entries
@param PageEntity $page
@param string $modifiedByUserId
@param string $modifiedReason
@return bool | [
"setPageDeleted",
"-",
"A",
"way",
"of",
"making",
"pages",
"appear",
"deleted",
"without",
"deleting",
"the",
"DB",
"entries"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L332-L351 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.copyPage | public function copyPage(
SiteEntity $destinationSite,
PageEntity $pageToCopy,
$pageData,
$pageRevisionId = null,
$publishNewPage = false,
$doFlush = true
) {
if (empty($pageData['name'])) {
throw new InvalidArgumentException(
'Missing needed information (name) to create page copy.'
);
}
if (empty($pageData['createdByUserId'])) {
throw new InvalidArgumentException(
'Missing needed information (createdByUserId) to create page copy.'
);
}
if (empty($pageData['createdReason'])) {
$pageData['createdReason'] = 'Copy page in ' . get_class($this);
}
if (empty($pageData['author'])) {
throw new InvalidArgumentException(
'Missing needed information (author) to create page copy.'
);
}
// Values cannot be changed
unset($pageData['pageId']);
unset($pageData['createdDate']);
unset($pageData['lastPublished']);
$pageData['site'] = $destinationSite;
$clonedPage = $pageToCopy->newInstance(
$pageData['createdByUserId'],
$pageData['createdReason']
);
$clonedPage->populate($pageData);
$this->assertCanCreateSitePage(
$clonedPage->getSite(),
$clonedPage->getName(),
$clonedPage->getPageType()
);
$revisionToUse = $clonedPage->getStagedRevision();
if (!empty($pageRevisionId)) {
$sourceRevision = $pageToCopy->getRevisionById($pageRevisionId);
if (empty($sourceRevision)) {
throw new PageNotFoundException(
'Page revision not found.'
);
}
$revisionToUse = $sourceRevision->newInstance(
$pageData['createdByUserId'],
$pageData['createdReason']
);
$clonedPage->setRevisions([]);
$clonedPage->addRevision($revisionToUse);
}
if (empty($revisionToUse)) {
throw new RuntimeException(
'Page revision not found.'
);
}
if ($publishNewPage) {
$clonedPage->setPublishedRevision($revisionToUse);
} else {
$clonedPage->setStagedRevision($revisionToUse);
}
$destinationSite->addPage($clonedPage);
$this->_em->persist($clonedPage);
if ($doFlush) {
$this->_em->flush($clonedPage);
}
return $clonedPage;
} | php | public function copyPage(
SiteEntity $destinationSite,
PageEntity $pageToCopy,
$pageData,
$pageRevisionId = null,
$publishNewPage = false,
$doFlush = true
) {
if (empty($pageData['name'])) {
throw new InvalidArgumentException(
'Missing needed information (name) to create page copy.'
);
}
if (empty($pageData['createdByUserId'])) {
throw new InvalidArgumentException(
'Missing needed information (createdByUserId) to create page copy.'
);
}
if (empty($pageData['createdReason'])) {
$pageData['createdReason'] = 'Copy page in ' . get_class($this);
}
if (empty($pageData['author'])) {
throw new InvalidArgumentException(
'Missing needed information (author) to create page copy.'
);
}
// Values cannot be changed
unset($pageData['pageId']);
unset($pageData['createdDate']);
unset($pageData['lastPublished']);
$pageData['site'] = $destinationSite;
$clonedPage = $pageToCopy->newInstance(
$pageData['createdByUserId'],
$pageData['createdReason']
);
$clonedPage->populate($pageData);
$this->assertCanCreateSitePage(
$clonedPage->getSite(),
$clonedPage->getName(),
$clonedPage->getPageType()
);
$revisionToUse = $clonedPage->getStagedRevision();
if (!empty($pageRevisionId)) {
$sourceRevision = $pageToCopy->getRevisionById($pageRevisionId);
if (empty($sourceRevision)) {
throw new PageNotFoundException(
'Page revision not found.'
);
}
$revisionToUse = $sourceRevision->newInstance(
$pageData['createdByUserId'],
$pageData['createdReason']
);
$clonedPage->setRevisions([]);
$clonedPage->addRevision($revisionToUse);
}
if (empty($revisionToUse)) {
throw new RuntimeException(
'Page revision not found.'
);
}
if ($publishNewPage) {
$clonedPage->setPublishedRevision($revisionToUse);
} else {
$clonedPage->setStagedRevision($revisionToUse);
}
$destinationSite->addPage($clonedPage);
$this->_em->persist($clonedPage);
if ($doFlush) {
$this->_em->flush($clonedPage);
}
return $clonedPage;
} | [
"public",
"function",
"copyPage",
"(",
"SiteEntity",
"$",
"destinationSite",
",",
"PageEntity",
"$",
"pageToCopy",
",",
"$",
"pageData",
",",
"$",
"pageRevisionId",
"=",
"null",
",",
"$",
"publishNewPage",
"=",
"false",
",",
"$",
"doFlush",
"=",
"true",
")",... | Copy a page
@param SiteEntity $destinationSite Site Entity to copy page to
@param PageEntity $pageToCopy Page Entity to copy
@param array $pageData Array of data to populate the page entity
@param null $pageRevisionId Page Revision ID to use for copy. Defaults to currently published
@param bool $publishNewPage Publish page instead of setting to staged
@param bool $doFlush Force flush
@return PageEntity | [
"Copy",
"a",
"page"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L446-L536 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.publishPageRevision | public function publishPageRevision(
$siteId,
$pageName,
$pageType,
$revisionId,
string $modifiedByUserId,
string $modifiedReason = Tracking::UNKNOWN_REASON
) {
//Query is needed to ensure revision belongs to the page in question
$pageQueryBuilder = $this->_em->createQueryBuilder();
$pageQueryBuilder->select('page, revision')
->from(\Rcm\Entity\Page::class, 'page')
->join('page.revisions', 'revision')
->where('page.name = :pageName')
->andWhere('page.pageType = :pageType')
->andWhere('page.site = :siteId')
->andWhere('revision.revisionId = :revisionId')
->setParameter('pageName', $pageName)
->setParameter('pageType', $pageType)
->setParameter('siteId', $siteId)
->setParameter('revisionId', $revisionId);
try {
/** @var \Rcm\Entity\Page $page */
$page = $pageQueryBuilder->getQuery()->getSingleResult();
} catch (NoResultException $e) {
throw new PageNotFoundException(
'Unable to locate page by revision. ' . json_encode([
'revisionId' => $revisionId,
'siteId' => $siteId,
'pageName' => $pageName,
'pageType' => $pageType,
])
);
}
$revision = $page->getRevisionById($revisionId);
if (empty($revision)) {
throw new RuntimeException(
'Revision not found. ' . json_encode([
'revisionId' => $revisionId,
'pageId' => $page->getPageId()
])
);
}
$page->setPublishedRevision($revision);
$page->setModifiedByUserId(
$modifiedByUserId,
$modifiedReason
);
$revision->setModifiedByUserId(
$modifiedByUserId,
$modifiedReason
);
$this->_em->flush(
[
$revision,
$page
]
);
return $page;
} | php | public function publishPageRevision(
$siteId,
$pageName,
$pageType,
$revisionId,
string $modifiedByUserId,
string $modifiedReason = Tracking::UNKNOWN_REASON
) {
//Query is needed to ensure revision belongs to the page in question
$pageQueryBuilder = $this->_em->createQueryBuilder();
$pageQueryBuilder->select('page, revision')
->from(\Rcm\Entity\Page::class, 'page')
->join('page.revisions', 'revision')
->where('page.name = :pageName')
->andWhere('page.pageType = :pageType')
->andWhere('page.site = :siteId')
->andWhere('revision.revisionId = :revisionId')
->setParameter('pageName', $pageName)
->setParameter('pageType', $pageType)
->setParameter('siteId', $siteId)
->setParameter('revisionId', $revisionId);
try {
/** @var \Rcm\Entity\Page $page */
$page = $pageQueryBuilder->getQuery()->getSingleResult();
} catch (NoResultException $e) {
throw new PageNotFoundException(
'Unable to locate page by revision. ' . json_encode([
'revisionId' => $revisionId,
'siteId' => $siteId,
'pageName' => $pageName,
'pageType' => $pageType,
])
);
}
$revision = $page->getRevisionById($revisionId);
if (empty($revision)) {
throw new RuntimeException(
'Revision not found. ' . json_encode([
'revisionId' => $revisionId,
'pageId' => $page->getPageId()
])
);
}
$page->setPublishedRevision($revision);
$page->setModifiedByUserId(
$modifiedByUserId,
$modifiedReason
);
$revision->setModifiedByUserId(
$modifiedByUserId,
$modifiedReason
);
$this->_em->flush(
[
$revision,
$page
]
);
return $page;
} | [
"public",
"function",
"publishPageRevision",
"(",
"$",
"siteId",
",",
"$",
"pageName",
",",
"$",
"pageType",
",",
"$",
"revisionId",
",",
"string",
"$",
"modifiedByUserId",
",",
"string",
"$",
"modifiedReason",
"=",
"Tracking",
"::",
"UNKNOWN_REASON",
")",
"{"... | Get a page entity containing a Revision Id.
@param int $siteId Site Id
@param string $pageName Name of page
@param string $pageType Page Type
@param int $revisionId Revision Id to search for
@param string $modifiedByUserId
@param string $modifiedReason
@return \Rcm\Entity\Page
@throws PageNotFoundException
@throws RuntimeException | [
"Get",
"a",
"page",
"entity",
"containing",
"a",
"Revision",
"Id",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L576-L642 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.getSitePage | public function getSitePage(
SiteEntity $site,
$pageId
) {
try {
/** @var \Rcm\Entity\Page $page */
$page = $this->findOneBy(
[
'site' => $site,
'pageId' => $pageId
]
);
} catch (\Exception $e) {
$page = null;
}
return $page;
} | php | public function getSitePage(
SiteEntity $site,
$pageId
) {
try {
/** @var \Rcm\Entity\Page $page */
$page = $this->findOneBy(
[
'site' => $site,
'pageId' => $pageId
]
);
} catch (\Exception $e) {
$page = null;
}
return $page;
} | [
"public",
"function",
"getSitePage",
"(",
"SiteEntity",
"$",
"site",
",",
"$",
"pageId",
")",
"{",
"try",
"{",
"/** @var \\Rcm\\Entity\\Page $page */",
"$",
"page",
"=",
"$",
"this",
"->",
"findOneBy",
"(",
"[",
"'site'",
"=>",
"$",
"site",
",",
"'pageId'",
... | get Site Page
@param SiteEntity $site
@param int $pageId
@return \Rcm\Entity\Page|null | [
"get",
"Site",
"Page"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L896-L913 | train |
reliv/Rcm | core/src/Repository/Page.php | Page.sitePageExists | public function sitePageExists(
SiteEntity $site,
$pageName,
$pageType
) {
try {
$page = $this->getPageByName(
$site,
$pageName,
$pageType
);
} catch (\Exception $e) {
$page = null;
}
return !empty($page);
} | php | public function sitePageExists(
SiteEntity $site,
$pageName,
$pageType
) {
try {
$page = $this->getPageByName(
$site,
$pageName,
$pageType
);
} catch (\Exception $e) {
$page = null;
}
return !empty($page);
} | [
"public",
"function",
"sitePageExists",
"(",
"SiteEntity",
"$",
"site",
",",
"$",
"pageName",
",",
"$",
"pageType",
")",
"{",
"try",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getPageByName",
"(",
"$",
"site",
",",
"$",
"pageName",
",",
"$",
"pageType"... | Site has page
@param SiteEntity $site
@param string $pageName
@param string $pageType
@return bool | [
"Site",
"has",
"page"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Page.php#L924-L940 | train |
reliv/Rcm | core/src/Validator/MainLayout.php | MainLayout.isValid | public function isValid($value)
{
$this->setValue($value);
if (!$this->layoutManager->isLayoutValid($this->currentSite, $value)) {
$this->error(self::MAIN_LAYOUT);
return false;
}
return true;
} | php | public function isValid($value)
{
$this->setValue($value);
if (!$this->layoutManager->isLayoutValid($this->currentSite, $value)) {
$this->error(self::MAIN_LAYOUT);
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"layoutManager",
"->",
"isLayoutValid",
"(",
"$",
"this",
"->",
"currentSite",
",",
"$",
"val... | Is the layout valid?
@param string $value Page to validate
@return bool | [
"Is",
"the",
"layout",
"valid?"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Validator/MainLayout.php#L72-L83 | train |
reliv/Rcm | core/src/Service/PluginManager.php | PluginManager.getPluginViewData | public function getPluginViewData(
$pluginName,
$pluginInstanceId,
$forcedAlternativeInstanceConfig = null
) {
$request = ServerRequestFactory::fromGlobals();
$blockConfig = $this->blockConfigRepository->findById($pluginName);
if ($pluginInstanceId < 0) {
$instanceWithData = new InstanceWithDataBasic(
$pluginInstanceId,
$pluginName,
$blockConfig->getDefaultConfig(),
null //@TODO run the dataprovider here instead of returning null
);
} else {
$instanceWithData = $this->instanceWithDataService->__invoke($pluginInstanceId, $request);
}
if ($forcedAlternativeInstanceConfig !== null) {
$instanceWithData = new InstanceWithDataBasic(
$instanceWithData->getId(),
$instanceWithData->getName(),
$forcedAlternativeInstanceConfig,
//@TODO we should have got the data from the data provider with the forced instance config as an input
$instanceWithData->getData()
);
}
$html = $this->blockRendererService->__invoke($instanceWithData);
/**
* @var $blockConfig Config
*/
$return = [
'html' => $html,
'css' => [],
'js' => [],
'editJs' => '',
'editCss' => '',
'displayName' => $blockConfig->getLabel(),
'tooltip' => $blockConfig->getDescription(),
'icon' => $blockConfig->getIcon(),
'siteWide' => false, // @deprecated <deprecated-site-wide-plugin>
'md5' => '',
'fromCache' => false,
'canCache' => $blockConfig->getCache(),
'pluginName' => $blockConfig->getName(),
'pluginInstanceId' => $pluginInstanceId,
];
return $return;
} | php | public function getPluginViewData(
$pluginName,
$pluginInstanceId,
$forcedAlternativeInstanceConfig = null
) {
$request = ServerRequestFactory::fromGlobals();
$blockConfig = $this->blockConfigRepository->findById($pluginName);
if ($pluginInstanceId < 0) {
$instanceWithData = new InstanceWithDataBasic(
$pluginInstanceId,
$pluginName,
$blockConfig->getDefaultConfig(),
null //@TODO run the dataprovider here instead of returning null
);
} else {
$instanceWithData = $this->instanceWithDataService->__invoke($pluginInstanceId, $request);
}
if ($forcedAlternativeInstanceConfig !== null) {
$instanceWithData = new InstanceWithDataBasic(
$instanceWithData->getId(),
$instanceWithData->getName(),
$forcedAlternativeInstanceConfig,
//@TODO we should have got the data from the data provider with the forced instance config as an input
$instanceWithData->getData()
);
}
$html = $this->blockRendererService->__invoke($instanceWithData);
/**
* @var $blockConfig Config
*/
$return = [
'html' => $html,
'css' => [],
'js' => [],
'editJs' => '',
'editCss' => '',
'displayName' => $blockConfig->getLabel(),
'tooltip' => $blockConfig->getDescription(),
'icon' => $blockConfig->getIcon(),
'siteWide' => false, // @deprecated <deprecated-site-wide-plugin>
'md5' => '',
'fromCache' => false,
'canCache' => $blockConfig->getCache(),
'pluginName' => $blockConfig->getName(),
'pluginInstanceId' => $pluginInstanceId,
];
return $return;
} | [
"public",
"function",
"getPluginViewData",
"(",
"$",
"pluginName",
",",
"$",
"pluginInstanceId",
",",
"$",
"forcedAlternativeInstanceConfig",
"=",
"null",
")",
"{",
"$",
"request",
"=",
"ServerRequestFactory",
"::",
"fromGlobals",
"(",
")",
";",
"$",
"blockConfig"... | Get a plugin instance rendered view.
@param string $pluginName Plugin name
@param integer $pluginInstanceId Plugin Instance Id
@param null $forcedAlternativeInstanceConfig Not normally used. Useful for previewing changes
@return array
@throws \Rcm\Exception\InvalidPluginException
@throws \Rcm\Exception\PluginReturnedResponseException | [
"Get",
"a",
"plugin",
"instance",
"rendered",
"view",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/PluginManager.php#L164-L218 | train |
reliv/Rcm | core/src/Service/PluginManager.php | PluginManager.getDefaultInstanceConfig | public function getDefaultInstanceConfig($pluginName)
{
$blockConfig = $this->blockConfigRepository->findById($pluginName);
if (empty($blockConfig)) {
throw new \Exception('Block config not found for ' . $pluginName); //@TODO throw custom exception class
}
return $blockConfig->getDefaultConfig();
} | php | public function getDefaultInstanceConfig($pluginName)
{
$blockConfig = $this->blockConfigRepository->findById($pluginName);
if (empty($blockConfig)) {
throw new \Exception('Block config not found for ' . $pluginName); //@TODO throw custom exception class
}
return $blockConfig->getDefaultConfig();
} | [
"public",
"function",
"getDefaultInstanceConfig",
"(",
"$",
"pluginName",
")",
"{",
"$",
"blockConfig",
"=",
"$",
"this",
"->",
"blockConfigRepository",
"->",
"findById",
"(",
"$",
"pluginName",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"blockConfig",
")",
")"... | Default instance configs are NOT required anymore
@param string $pluginName the plugins module name
@return array | [
"Default",
"instance",
"configs",
"are",
"NOT",
"required",
"anymore"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/PluginManager.php#L247-L256 | train |
reliv/Rcm | core/src/Service/PluginManager.php | PluginManager.listAvailablePluginsByType | public function listAvailablePluginsByType()
{
$list = [];
foreach ($this->config['rcmPlugin'] as $name => $data) {
$displayName = $name;
$type = 'Misc';
$icon = $this->config['Rcm']['defaultPluginIcon'];
if (isset($data['type'])) {
$type = $data['type'];
}
if (isset($data['display'])) {
$displayName = $data['display'];
}
if (isset($data['icon']) && !empty($data['icon'])) {
$icon = $data['icon'];
}
$list[$type][$name] = [
'name' => $name,
'displayName' => $displayName,
'icon' => $icon,
'siteWide' => false // @deprecated <deprecated-site-wide-plugin>
];
}
return $list;
} | php | public function listAvailablePluginsByType()
{
$list = [];
foreach ($this->config['rcmPlugin'] as $name => $data) {
$displayName = $name;
$type = 'Misc';
$icon = $this->config['Rcm']['defaultPluginIcon'];
if (isset($data['type'])) {
$type = $data['type'];
}
if (isset($data['display'])) {
$displayName = $data['display'];
}
if (isset($data['icon']) && !empty($data['icon'])) {
$icon = $data['icon'];
}
$list[$type][$name] = [
'name' => $name,
'displayName' => $displayName,
'icon' => $icon,
'siteWide' => false // @deprecated <deprecated-site-wide-plugin>
];
}
return $list;
} | [
"public",
"function",
"listAvailablePluginsByType",
"(",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"[",
"'rcmPlugin'",
"]",
"as",
"$",
"name",
"=>",
"$",
"data",
")",
"{",
"$",
"displayName",
"=",
"$",
"n... | Returns an array the represents the available plugins
@return array | [
"Returns",
"an",
"array",
"the",
"represents",
"the",
"available",
"plugins"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/PluginManager.php#L263-L288 | train |
phptuts/StarterBundleForSymfony | src/Security/Provider/GoogleProvider.php | GoogleProvider.loadUserByUsername | public function loadUserByUsername($username)
{
try {
$payload = $this->googleClient->verifyIdToken($username);
$email = $payload['email'];
$googleUserId = $payload['sub'];
$user = $this->userService->findByGoogleUserId($googleUserId);
if (!empty($user)) {
return $user;
}
$user = $this->userService->findUserByEmail($email);
// This means that the user is registering for the first time
if (!empty($user)) {
$this->updateUserWithGoogleUserId($user, $googleUserId);
return $user;
}
return $this->registerUser($email, $googleUserId);
}
catch (\LogicException $ex) {
throw new UsernameNotFoundException("Google AuthToken Did Not validate, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::GOOGLE_USER_PROVIDER_LOGIC_EXCEPTION);
}
catch (\Exception $ex) {
throw new UsernameNotFoundException("Google AuthToken Did Not validate, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::GOOGLE_USER_PROVIDER_EXCEPTION);
}
} | php | public function loadUserByUsername($username)
{
try {
$payload = $this->googleClient->verifyIdToken($username);
$email = $payload['email'];
$googleUserId = $payload['sub'];
$user = $this->userService->findByGoogleUserId($googleUserId);
if (!empty($user)) {
return $user;
}
$user = $this->userService->findUserByEmail($email);
// This means that the user is registering for the first time
if (!empty($user)) {
$this->updateUserWithGoogleUserId($user, $googleUserId);
return $user;
}
return $this->registerUser($email, $googleUserId);
}
catch (\LogicException $ex) {
throw new UsernameNotFoundException("Google AuthToken Did Not validate, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::GOOGLE_USER_PROVIDER_LOGIC_EXCEPTION);
}
catch (\Exception $ex) {
throw new UsernameNotFoundException("Google AuthToken Did Not validate, ERROR MESSAGE " . $ex->getMessage(), ProgrammerException::GOOGLE_USER_PROVIDER_EXCEPTION);
}
} | [
"public",
"function",
"loadUserByUsername",
"(",
"$",
"username",
")",
"{",
"try",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"googleClient",
"->",
"verifyIdToken",
"(",
"$",
"username",
")",
";",
"$",
"email",
"=",
"$",
"payload",
"[",
"'email'",
"]",... | 1) We validate the access token by fetching the user information
2) We search for google user id and if one is found we return that user
3) Then we search by email and if one is found we update the user to have that google user id
4) If nothing is found we register the user with google user id
@param string $username
@return BaseUser | [
"1",
")",
"We",
"validate",
"the",
"access",
"token",
"by",
"fetching",
"the",
"user",
"information",
"2",
")",
"We",
"search",
"for",
"google",
"user",
"id",
"and",
"if",
"one",
"is",
"found",
"we",
"return",
"that",
"user",
"3",
")",
"Then",
"we",
... | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/GoogleProvider.php#L43-L73 | train |
phptuts/StarterBundleForSymfony | src/Security/Provider/GoogleProvider.php | GoogleProvider.updateUserWithGoogleUserId | protected function updateUserWithGoogleUserId(BaseUser $user, $googleUserId)
{
$user->setGoogleUserId($googleUserId);
$this->userService->save($user);
} | php | protected function updateUserWithGoogleUserId(BaseUser $user, $googleUserId)
{
$user->setGoogleUserId($googleUserId);
$this->userService->save($user);
} | [
"protected",
"function",
"updateUserWithGoogleUserId",
"(",
"BaseUser",
"$",
"user",
",",
"$",
"googleUserId",
")",
"{",
"$",
"user",
"->",
"setGoogleUserId",
"(",
"$",
"googleUserId",
")",
";",
"$",
"this",
"->",
"userService",
"->",
"save",
"(",
"$",
"user... | Updates the user with their google id creating a link between their google account and user information.
@param BaseUser $user
@param string $googleUserId | [
"Updates",
"the",
"user",
"with",
"their",
"google",
"id",
"creating",
"a",
"link",
"between",
"their",
"google",
"account",
"and",
"user",
"information",
"."
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/GoogleProvider.php#L81-L85 | train |
lsv/rejseplan-php-api | src/Services/Journey.php | Journey.setUrl | public function setUrl($url): self
{
if (\is_string($url)) {
$this->options['url'] = $url;
return $this;
}
if ($url instanceof Leg) {
$this->setUrlFromLeg($url);
return $this;
}
if ($url instanceof BoardData) {
$this->setUrlFromBoardData($url);
return $this;
}
throw new \InvalidArgumentException(
sprintf('setUrl must be a string, Leg or BoardData object')
);
} | php | public function setUrl($url): self
{
if (\is_string($url)) {
$this->options['url'] = $url;
return $this;
}
if ($url instanceof Leg) {
$this->setUrlFromLeg($url);
return $this;
}
if ($url instanceof BoardData) {
$this->setUrlFromBoardData($url);
return $this;
}
throw new \InvalidArgumentException(
sprintf('setUrl must be a string, Leg or BoardData object')
);
} | [
"public",
"function",
"setUrl",
"(",
"$",
"url",
")",
":",
"self",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"url",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'url'",
"]",
"=",
"$",
"url",
";",
"return",
"$",
"this",
";",
"}",
"if",
... | Set journey details from a URL.
@param string|Leg|BoardData $url
@return $this | [
"Set",
"journey",
"details",
"from",
"a",
"URL",
"."
] | f09add92e160f167a19ff2a290951d202d7ece67 | https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/Journey.php#L28-L51 | train |
russsiq/bixbite | app/Http/Controllers/Admin/CommentsController.php | CommentsController.massUpdate | public function massUpdate(CommentsRequest $request)
{
$this->authorize('otherUpdate', $this->model);
$comments = $this->model->whereIn('id', $request->comments);
$messages = [];
switch ($request->mass_action) {
case 'published':
if (! $comments->update(['is_approved' => true])) {
$messages[] = 'unable to published';
}
break;
case 'unpublished':
if (! $comments->update(['is_approved' => false])) {
$messages[] = 'unable to unpublished';
}
break;
case 'delete':
if (! $comments->get()->each->delete()) {
$messages[] = 'unable to delete';
}
break;
}
$message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';
return $this->makeRedirect(true, 'admin.comments.index', $message);
} | php | public function massUpdate(CommentsRequest $request)
{
$this->authorize('otherUpdate', $this->model);
$comments = $this->model->whereIn('id', $request->comments);
$messages = [];
switch ($request->mass_action) {
case 'published':
if (! $comments->update(['is_approved' => true])) {
$messages[] = 'unable to published';
}
break;
case 'unpublished':
if (! $comments->update(['is_approved' => false])) {
$messages[] = 'unable to unpublished';
}
break;
case 'delete':
if (! $comments->get()->each->delete()) {
$messages[] = 'unable to delete';
}
break;
}
$message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';
return $this->makeRedirect(true, 'admin.comments.index', $message);
} | [
"public",
"function",
"massUpdate",
"(",
"CommentsRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'otherUpdate'",
",",
"$",
"this",
"->",
"model",
")",
";",
"$",
"comments",
"=",
"$",
"this",
"->",
"model",
"->",
"whereIn",
"(",... | Mass updates to Comment.
@param \BBCMS\Http\Requests\Admin\CommentsRequest $request
@param \BBCMS\Models\Comment $comment
@return \Illuminate\Http\Response | [
"Mass",
"updates",
"to",
"Comment",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/Admin/CommentsController.php#L93-L121 | train |
nathanjdunn/chargebee-php-sdk | src/Api/TimeMachines/TimeMachine.php | TimeMachine.find | public function find(string $id, array $headers = [])
{
$url = $this->url('time_machines/%s', $id);
return $this->get($url, [], $headers);
} | php | public function find(string $id, array $headers = [])
{
$url = $this->url('time_machines/%s', $id);
return $this->get($url, [], $headers);
} | [
"public",
"function",
"find",
"(",
"string",
"$",
"id",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
"(",
"'time_machines/%s'",
",",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"get",
"("... | Retrieves a specified time machine.
@param string $id
@param array $headers
@throws Exception
@return array|string | [
"Retrieves",
"a",
"specified",
"time",
"machine",
"."
] | 65cf68c040b33ee50c3173db9bf25c3f8da6a852 | https://github.com/nathanjdunn/chargebee-php-sdk/blob/65cf68c040b33ee50c3173db9bf25c3f8da6a852/src/Api/TimeMachines/TimeMachine.php#L20-L25 | train |
nathanjdunn/chargebee-php-sdk | src/Api/TimeMachines/TimeMachine.php | TimeMachine.startAfresh | public function startAfresh(string $id, array $data, array $headers = [])
{
$url = $this->url('time_machines/%s/start_afresh', $id);
return $this->post($url, $data, $headers);
} | php | public function startAfresh(string $id, array $data, array $headers = [])
{
$url = $this->url('time_machines/%s/start_afresh', $id);
return $this->post($url, $data, $headers);
} | [
"public",
"function",
"startAfresh",
"(",
"string",
"$",
"id",
",",
"array",
"$",
"data",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
"(",
"'time_machines/%s/start_afresh'",
",",
"$",
"id",
")",
"... | Restart the time machine.
@param string $id
@param array $data
@param array $headers
@throws Exception
@return array|string | [
"Restart",
"the",
"time",
"machine",
"."
] | 65cf68c040b33ee50c3173db9bf25c3f8da6a852 | https://github.com/nathanjdunn/chargebee-php-sdk/blob/65cf68c040b33ee50c3173db9bf25c3f8da6a852/src/Api/TimeMachines/TimeMachine.php#L38-L43 | train |
nathanjdunn/chargebee-php-sdk | src/Api/TimeMachines/TimeMachine.php | TimeMachine.travelForward | public function travelForward(string $id, array $data, array $headers = [])
{
$url = $this->url('time_machines/%s/travel_forward', $id);
return $this->post($url, $data, $headers);
} | php | public function travelForward(string $id, array $data, array $headers = [])
{
$url = $this->url('time_machines/%s/travel_forward', $id);
return $this->post($url, $data, $headers);
} | [
"public",
"function",
"travelForward",
"(",
"string",
"$",
"id",
",",
"array",
"$",
"data",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
"(",
"'time_machines/%s/travel_forward'",
",",
"$",
"id",
")",... | Travel forward in time.
@param string $id
@param array $data
@param array $headers
@throws Exception
@return array|string | [
"Travel",
"forward",
"in",
"time",
"."
] | 65cf68c040b33ee50c3173db9bf25c3f8da6a852 | https://github.com/nathanjdunn/chargebee-php-sdk/blob/65cf68c040b33ee50c3173db9bf25c3f8da6a852/src/Api/TimeMachines/TimeMachine.php#L56-L61 | train |
dadajuice/zephyrus | src/Zephyrus/Security/ContentSecurityPolicy.php | ContentSecurityPolicy.send | public function send()
{
$header = $this->buildCompleteHeader();
$reportOnly = ($this->reportOnly) ? "-Report-Only" : "";
header("Content-Security-Policy$reportOnly: " . $header);
if ($this->compatible) {
header("X-Content-Security-Policy$reportOnly: " . $header);
}
} | php | public function send()
{
$header = $this->buildCompleteHeader();
$reportOnly = ($this->reportOnly) ? "-Report-Only" : "";
header("Content-Security-Policy$reportOnly: " . $header);
if ($this->compatible) {
header("X-Content-Security-Policy$reportOnly: " . $header);
}
} | [
"public",
"function",
"send",
"(",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"buildCompleteHeader",
"(",
")",
";",
"$",
"reportOnly",
"=",
"(",
"$",
"this",
"->",
"reportOnly",
")",
"?",
"\"-Report-Only\"",
":",
"\"\"",
";",
"header",
"(",
"\"Co... | Build and send the complete CSP security header according to the object
specified data. | [
"Build",
"and",
"send",
"the",
"complete",
"CSP",
"security",
"header",
"according",
"to",
"the",
"object",
"specified",
"data",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/ContentSecurityPolicy.php#L99-L107 | train |
dadajuice/zephyrus | src/Zephyrus/Security/ContentSecurityPolicy.php | ContentSecurityPolicy.buildCompleteHeader | private function buildCompleteHeader(): string
{
$header = "";
foreach ($this->headers as $sourceType => $value) {
$header .= $this->buildHeaderLine($sourceType, $value);
}
if (!empty($this->reportUri)) {
$header .= 'report-uri ' . $this->reportUri . ';';
}
return $header;
} | php | private function buildCompleteHeader(): string
{
$header = "";
foreach ($this->headers as $sourceType => $value) {
$header .= $this->buildHeaderLine($sourceType, $value);
}
if (!empty($this->reportUri)) {
$header .= 'report-uri ' . $this->reportUri . ';';
}
return $header;
} | [
"private",
"function",
"buildCompleteHeader",
"(",
")",
":",
"string",
"{",
"$",
"header",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"sourceType",
"=>",
"$",
"value",
")",
"{",
"$",
"header",
".=",
"$",
"this",
"->",
... | Generates the complete CSP header base on object data.
@return string | [
"Generates",
"the",
"complete",
"CSP",
"header",
"base",
"on",
"object",
"data",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/ContentSecurityPolicy.php#L308-L318 | train |
dadajuice/zephyrus | src/Zephyrus/Security/ContentSecurityPolicy.php | ContentSecurityPolicy.buildHeaderLine | private function buildHeaderLine(string $name, array $sources): string
{
$header = '';
if (!empty($sources)) {
$value = "";
foreach ($sources as $source) {
if (!empty($value)) {
$value .= ' ';
}
$value .= $source;
}
$header = ($name == "script-src" && !empty(self::$nonce))
? "$name $value 'nonce-" . self::$nonce . "';"
: "$name $value;";
}
return $header;
} | php | private function buildHeaderLine(string $name, array $sources): string
{
$header = '';
if (!empty($sources)) {
$value = "";
foreach ($sources as $source) {
if (!empty($value)) {
$value .= ' ';
}
$value .= $source;
}
$header = ($name == "script-src" && !empty(self::$nonce))
? "$name $value 'nonce-" . self::$nonce . "';"
: "$name $value;";
}
return $header;
} | [
"private",
"function",
"buildHeaderLine",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"sources",
")",
":",
"string",
"{",
"$",
"header",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sources",
")",
")",
"{",
"$",
"value",
"=",
"\"\"",
";",... | Retrieve a specific CSP line based on the provided sources.
@param string $name
@param string[] $sources
@return string | [
"Retrieve",
"a",
"specific",
"CSP",
"line",
"based",
"on",
"the",
"provided",
"sources",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/ContentSecurityPolicy.php#L327-L343 | train |
reliv/Rcm | admin/src/Controller/ApiAdminSitesCloneController.php | ApiAdminSitesCloneController.create | public function create($data)
{
/* ACCESS CHECK */
if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
$this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
return $this->getResponse();
}
/* */
$inputFilter = new SiteDuplicateInputFilter();
$inputFilter->setData($data);
if (!$inputFilter->isValid()) {
return new ApiJsonModel(
[],
1,
'Some values are missing or invalid.',
$inputFilter->getMessages()
);
}
$data = $inputFilter->getValues();
$siteManager = $this->getSiteManager();
try {
$data = $siteManager->prepareSiteData($data);
/** @var \Rcm\Repository\Domain $domainRepo */
$domainRepo = $this->getEntityManager()->getRepository(
\Rcm\Entity\Domain::class
);
$domain = $domainRepo->createDomain(
$data['domainName'],
$this->getCurrentUserId(),
'Create new domain in ' . get_class($this),
null,
true
);
} catch (\Exception $e) {
return new ApiJsonModel(null, 1, $e->getMessage());
}
$entityManager = $this->getEntityManager();
/** @var \Rcm\Repository\Site $siteRepo */
$siteRepo = $entityManager->getRepository(\Rcm\Entity\Site::class);
/** @var \Rcm\Entity\Site $existingSite */
$existingSite = $siteRepo->find($data['siteId']);
if (empty($existingSite)) {
return new ApiJsonModel(null, 1, "Site {$data['siteId']} not found.");
}
try {
$copySite = $siteManager->copySiteAndPopulate(
$existingSite,
$domain,
$data
);
} catch (\Exception $exception) {
// Remove domain if error occurs
if ($entityManager->contains($domain)) {
$entityManager->remove($domain);
}
throw $exception;
}
return new ApiJsonModel($copySite, 0, 'Success');
} | php | public function create($data)
{
/* ACCESS CHECK */
if (!$this->isAllowed(ResourceName::RESOURCE_SITES, 'admin')) {
$this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
return $this->getResponse();
}
/* */
$inputFilter = new SiteDuplicateInputFilter();
$inputFilter->setData($data);
if (!$inputFilter->isValid()) {
return new ApiJsonModel(
[],
1,
'Some values are missing or invalid.',
$inputFilter->getMessages()
);
}
$data = $inputFilter->getValues();
$siteManager = $this->getSiteManager();
try {
$data = $siteManager->prepareSiteData($data);
/** @var \Rcm\Repository\Domain $domainRepo */
$domainRepo = $this->getEntityManager()->getRepository(
\Rcm\Entity\Domain::class
);
$domain = $domainRepo->createDomain(
$data['domainName'],
$this->getCurrentUserId(),
'Create new domain in ' . get_class($this),
null,
true
);
} catch (\Exception $e) {
return new ApiJsonModel(null, 1, $e->getMessage());
}
$entityManager = $this->getEntityManager();
/** @var \Rcm\Repository\Site $siteRepo */
$siteRepo = $entityManager->getRepository(\Rcm\Entity\Site::class);
/** @var \Rcm\Entity\Site $existingSite */
$existingSite = $siteRepo->find($data['siteId']);
if (empty($existingSite)) {
return new ApiJsonModel(null, 1, "Site {$data['siteId']} not found.");
}
try {
$copySite = $siteManager->copySiteAndPopulate(
$existingSite,
$domain,
$data
);
} catch (\Exception $exception) {
// Remove domain if error occurs
if ($entityManager->contains($domain)) {
$entityManager->remove($domain);
}
throw $exception;
}
return new ApiJsonModel($copySite, 0, 'Success');
} | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"/* ACCESS CHECK */",
"if",
"(",
"!",
"$",
"this",
"->",
"isAllowed",
"(",
"ResourceName",
"::",
"RESOURCE_SITES",
",",
"'admin'",
")",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->"... | create - Clone a site
@param array $data - see buildSiteApiResponse()
@return ApiJsonModel|\Zend\Stdlib\ResponseInterface
@throws \Exception | [
"create",
"-",
"Clone",
"a",
"site"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Controller/ApiAdminSitesCloneController.php#L43-L113 | train |
proem/proem | lib/Proem/Routing/Route.php | Route.compileRegex | protected function compileRegex($rule)
{
$regex = '^' . preg_replace_callback(
'@\{[\w]+\??\}@',
function ($matches) {
$optional = false;
$key = str_replace(['{', '}'], '', $matches[0]);
if (substr($key, -1) == '?') {
// Flag this token as optional.
$optional = true;
}
if (isset($this->customFilters[$key])) {
if (isset($this->defaultFilters[$this->customFilters[$key]])) {
return '(' . $this->defaultFilters[$this->customFilters[$key]] . ')' . (($optional) ? '?' : '');
} else {
if (
substr($this->customFilters[$key], 0, 1) == '{' &&
substr($this->customFilters[$key], -1) == '}'
) {
throw new \RuntimeException(
"The custom filter named \"{$key}\" references a
non-existent builtin filter named \"{$this->customFilters[$key]}\"."
);
} else {
return '(' . $this->customFilters[$key] . ')' . (($optional) ? '?' : '');
}
}
} elseif (isset($this->defaultTokens[$key])) {
return '(' . $this->defaultTokens[$key] . ')' . (($optional) ? '?' : '');
} else {
return '(' . $this->defaultFilters['{default}'] . ')' . (($optional) ? '?' : '');
}
},
$rule
) . '$';
// Fix slash delimeters in regards to optional handling.
$regex = str_replace(['?/', '??'], ['?/?', '?'], $regex);
return $regex;
} | php | protected function compileRegex($rule)
{
$regex = '^' . preg_replace_callback(
'@\{[\w]+\??\}@',
function ($matches) {
$optional = false;
$key = str_replace(['{', '}'], '', $matches[0]);
if (substr($key, -1) == '?') {
// Flag this token as optional.
$optional = true;
}
if (isset($this->customFilters[$key])) {
if (isset($this->defaultFilters[$this->customFilters[$key]])) {
return '(' . $this->defaultFilters[$this->customFilters[$key]] . ')' . (($optional) ? '?' : '');
} else {
if (
substr($this->customFilters[$key], 0, 1) == '{' &&
substr($this->customFilters[$key], -1) == '}'
) {
throw new \RuntimeException(
"The custom filter named \"{$key}\" references a
non-existent builtin filter named \"{$this->customFilters[$key]}\"."
);
} else {
return '(' . $this->customFilters[$key] . ')' . (($optional) ? '?' : '');
}
}
} elseif (isset($this->defaultTokens[$key])) {
return '(' . $this->defaultTokens[$key] . ')' . (($optional) ? '?' : '');
} else {
return '(' . $this->defaultFilters['{default}'] . ')' . (($optional) ? '?' : '');
}
},
$rule
) . '$';
// Fix slash delimeters in regards to optional handling.
$regex = str_replace(['?/', '??'], ['?/?', '?'], $regex);
return $regex;
} | [
"protected",
"function",
"compileRegex",
"(",
"$",
"rule",
")",
"{",
"$",
"regex",
"=",
"'^'",
".",
"preg_replace_callback",
"(",
"'@\\{[\\w]+\\??\\}@'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"$",
"optional",
"=",
"false",
";",
"$",
"key",
"=",
... | Build a regular expression from the given rule.
@param string $rule | [
"Build",
"a",
"regular",
"expression",
"from",
"the",
"given",
"rule",
"."
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Routing/Route.php#L106-L146 | train |
proem/proem | lib/Proem/Routing/Route.php | Route.process | public function process(Request $request)
{
$results = [];
// Test hostname rule.
if (isset($this->options['hostname'])) {
$regex = $this->compileRegex($this->options['hostname']);
$tokens = $this->compileTokens($this->options['hostname']);
$hostnameResults = $this->compileResults($regex, $tokens, $request->getHttpHost());
if ($hostnameResults === false) {
return false;
} else {
$results = array_merge($results, $hostnameResults);
}
}
// Test the main url rule.
$regex = $this->compileRegex($this->rule);
$tokens = $this->compileTokens($this->rule);
$urlResults = $this->compileResults($regex, $tokens, $request->getRequestUri());
if ($urlResults === false) {
return false;
} else {
$results = array_merge($results, $urlResults);
}
if (isset($this->options['targets'])) {
$results = array_merge($results, $this->options['targets']);
}
$this->payload = $results;
return true;
} | php | public function process(Request $request)
{
$results = [];
// Test hostname rule.
if (isset($this->options['hostname'])) {
$regex = $this->compileRegex($this->options['hostname']);
$tokens = $this->compileTokens($this->options['hostname']);
$hostnameResults = $this->compileResults($regex, $tokens, $request->getHttpHost());
if ($hostnameResults === false) {
return false;
} else {
$results = array_merge($results, $hostnameResults);
}
}
// Test the main url rule.
$regex = $this->compileRegex($this->rule);
$tokens = $this->compileTokens($this->rule);
$urlResults = $this->compileResults($regex, $tokens, $request->getRequestUri());
if ($urlResults === false) {
return false;
} else {
$results = array_merge($results, $urlResults);
}
if (isset($this->options['targets'])) {
$results = array_merge($results, $this->options['targets']);
}
$this->payload = $results;
return true;
} | [
"public",
"function",
"process",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"// Test hostname rule.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'hostname'",
"]",
")",
")",
"{",
"$",
"regex",
"=",
... | Process this route.
Takes a simplified series of patterns such as {controller} and
replaces them with more complex regular expressions which are then used
to match against a given *haystack* string.
@param Proem\Http\Request $request
@return false|array False on fail to match, otherwise array of results. | [
"Process",
"this",
"route",
"."
] | 31e00b315a12d6bfa65803ad49b3117d8b9c4da4 | https://github.com/proem/proem/blob/31e00b315a12d6bfa65803ad49b3117d8b9c4da4/lib/Proem/Routing/Route.php#L220-L254 | train |
dadajuice/zephyrus | src/Zephyrus/Security/SecuritySession.php | SecuritySession.start | public function start(): bool
{
if (!is_null($this->expiration)) {
$this->expiration->start();
}
if (!is_null($this->fingerprint)) {
$this->fingerprint->start();
}
if (!isset($_SESSION['__HANDLER_INITIATED'])) {
return $this->initialSessionStart();
} else {
return $this->laterSessionStart();
}
} | php | public function start(): bool
{
if (!is_null($this->expiration)) {
$this->expiration->start();
}
if (!is_null($this->fingerprint)) {
$this->fingerprint->start();
}
if (!isset($_SESSION['__HANDLER_INITIATED'])) {
return $this->initialSessionStart();
} else {
return $this->laterSessionStart();
}
} | [
"public",
"function",
"start",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"expiration",
")",
")",
"{",
"$",
"this",
"->",
"expiration",
"->",
"start",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
... | Throws an exception if the fingerprint mismatch.
@throws \Exception | [
"Throws",
"an",
"exception",
"if",
"the",
"fingerprint",
"mismatch",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/SecuritySession.php#L49-L62 | train |
dadajuice/zephyrus | src/Zephyrus/Security/SecuritySession.php | SecuritySession.laterSessionStart | private function laterSessionStart()
{
if (!is_null($this->fingerprint) && !$this->fingerprint->hasValidFingerprint()) {
throw new \Exception("Session fingerprint doesn't match"); // @codeCoverageIgnore
}
if (!is_null($this->expiration) && $this->expiration->isObsolete()) {
return true;
}
return false;
} | php | private function laterSessionStart()
{
if (!is_null($this->fingerprint) && !$this->fingerprint->hasValidFingerprint()) {
throw new \Exception("Session fingerprint doesn't match"); // @codeCoverageIgnore
}
if (!is_null($this->expiration) && $this->expiration->isObsolete()) {
return true;
}
return false;
} | [
"private",
"function",
"laterSessionStart",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"fingerprint",
")",
"&&",
"!",
"$",
"this",
"->",
"fingerprint",
"->",
"hasValidFingerprint",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Excepti... | Should be used for every session starts if the handlers has been
previously initiated. Validates if the session identifier should be
regenerated and validates current fingerprint.
@throws \Exception | [
"Should",
"be",
"used",
"for",
"every",
"session",
"starts",
"if",
"the",
"handlers",
"has",
"been",
"previously",
"initiated",
".",
"Validates",
"if",
"the",
"session",
"identifier",
"should",
"be",
"regenerated",
"and",
"validates",
"current",
"fingerprint",
"... | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Security/SecuritySession.php#L91-L100 | train |
Mihai-P/yii2-core | components/StringHelper.php | StringHelper.hideEmail | public static function hideEmail($email) {
$character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
$key = str_shuffle($character_set); $cipher_text = ''; $id = 'e'.rand(1,999999999);
for ($i=0;$i<strlen($email);$i+=1) $cipher_text.= $key[strpos($character_set,$email[$i])];
$script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d="";';
$script.= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
$script.= 'document.getElementById("'.$id.'").innerHTML="<a href=\\"mailto:"+d+"\\">"+d+"</a>"';
$script = "eval(\"".str_replace(["\\",'"'],["\\\\",'\"'], $script)."\")";
$script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>';
return '<span id="'.$id.'">[javascript protected email address]</span>'.$script;
} | php | public static function hideEmail($email) {
$character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
$key = str_shuffle($character_set); $cipher_text = ''; $id = 'e'.rand(1,999999999);
for ($i=0;$i<strlen($email);$i+=1) $cipher_text.= $key[strpos($character_set,$email[$i])];
$script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d="";';
$script.= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
$script.= 'document.getElementById("'.$id.'").innerHTML="<a href=\\"mailto:"+d+"\\">"+d+"</a>"';
$script = "eval(\"".str_replace(["\\",'"'],["\\\\",'\"'], $script)."\")";
$script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>';
return '<span id="'.$id.'">[javascript protected email address]</span>'.$script;
} | [
"public",
"static",
"function",
"hideEmail",
"(",
"$",
"email",
")",
"{",
"$",
"character_set",
"=",
"'+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz'",
";",
"$",
"key",
"=",
"str_shuffle",
"(",
"$",
"character_set",
")",
";",
"$",
"cipher_text",
... | Protects the email from bots
@reference http://www.maurits.vdschee.nl/php_hide_email/
@param string $email the email address
@return string | [
"Protects",
"the",
"email",
"from",
"bots"
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/StringHelper.php#L31-L43 | train |
Mihai-P/yii2-core | components/StringHelper.php | StringHelper.summary | public static function summary($str, $limit=100, $strip = false) {
$str = ($strip == true) ? strip_tags($str) : $str;
return static::truncate($str, $limit - 3, '...');
} | php | public static function summary($str, $limit=100, $strip = false) {
$str = ($strip == true) ? strip_tags($str) : $str;
return static::truncate($str, $limit - 3, '...');
} | [
"public",
"static",
"function",
"summary",
"(",
"$",
"str",
",",
"$",
"limit",
"=",
"100",
",",
"$",
"strip",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"(",
"$",
"strip",
"==",
"true",
")",
"?",
"strip_tags",
"(",
"$",
"str",
")",
":",
"$",
"str... | Get the first x chars from a string. If the string is bigger it pads it with ...
@see truncate
@param string $str the string
@param integer $limit the number of characters
@param boolean $strip should we strip tags or not
@return string | [
"Get",
"the",
"first",
"x",
"chars",
"from",
"a",
"string",
".",
"If",
"the",
"string",
"is",
"bigger",
"it",
"pads",
"it",
"with",
"..."
] | c52753c9c8e133b2f1ca708ae02178b51eb2e5a3 | https://github.com/Mihai-P/yii2-core/blob/c52753c9c8e133b2f1ca708ae02178b51eb2e5a3/components/StringHelper.php#L55-L58 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.find | public function find($modelitemId)
{
$this->model = $this->model->findOrFail($modelitemId);
return $this->model;
} | php | public function find($modelitemId)
{
$this->model = $this->model->findOrFail($modelitemId);
return $this->model;
} | [
"public",
"function",
"find",
"(",
"$",
"modelitemId",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"this",
"->",
"model",
"->",
"findOrFail",
"(",
"$",
"modelitemId",
")",
";",
"return",
"$",
"this",
"->",
"model",
";",
"}"
] | Finds an existing Model entry and sets it to the current model.
@param int $modelitemId
@return | [
"Finds",
"an",
"existing",
"Model",
"entry",
"and",
"sets",
"it",
"to",
"the",
"current",
"model",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L79-L84 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.query | private function query($count)
{
$this->applyQueryFilters();
if ($this->hasTranslating()) {
$this->applyTranslationFilter();
}
if ($this->orderBy()) {
$this->query = $this->query->orderBy(
$this->orderBy(),
$this->sortBy()
);
}
if ($count) {
return $this->query->count();
}
if ($this->perPage > 0) {
return $this->query->paginate($this->perPage);
}
return $this->query->get();
} | php | private function query($count)
{
$this->applyQueryFilters();
if ($this->hasTranslating()) {
$this->applyTranslationFilter();
}
if ($this->orderBy()) {
$this->query = $this->query->orderBy(
$this->orderBy(),
$this->sortBy()
);
}
if ($count) {
return $this->query->count();
}
if ($this->perPage > 0) {
return $this->query->paginate($this->perPage);
}
return $this->query->get();
} | [
"private",
"function",
"query",
"(",
"$",
"count",
")",
"{",
"$",
"this",
"->",
"applyQueryFilters",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasTranslating",
"(",
")",
")",
"{",
"$",
"this",
"->",
"applyTranslationFilter",
"(",
")",
";",
"}",
"... | Performs the Model Query.
@return \Illuminate\Database\Eloquent\Collection | [
"Performs",
"the",
"Model",
"Query",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L144-L168 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.totals | public function totals()
{
if ($this->hasSoftDeleting()) {
return [
'all' => $this->items($count = true),
'with_trashed' => $this->allItems($count = true),
'only_trashed' => $this->onlyTrashedItems($count = true),
];
}
return ['all' => $this->items($count = true)];
} | php | public function totals()
{
if ($this->hasSoftDeleting()) {
return [
'all' => $this->items($count = true),
'with_trashed' => $this->allItems($count = true),
'only_trashed' => $this->onlyTrashedItems($count = true),
];
}
return ['all' => $this->items($count = true)];
} | [
"public",
"function",
"totals",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasSoftDeleting",
"(",
")",
")",
"{",
"return",
"[",
"'all'",
"=>",
"$",
"this",
"->",
"items",
"(",
"$",
"count",
"=",
"true",
")",
",",
"'with_trashed'",
"=>",
"$",
"th... | Return Totals of All, With Trashed and Only Trashed.
@return array | [
"Return",
"Totals",
"of",
"All",
"With",
"Trashed",
"and",
"Only",
"Trashed",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L175-L186 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.orderBy | public function orderBy()
{
if (Request::input('order')) {
return Request::input('order');
}
if ($this->orderBy) {
return $this->orderBy;
}
return $this->model->getKeyName();
} | php | public function orderBy()
{
if (Request::input('order')) {
return Request::input('order');
}
if ($this->orderBy) {
return $this->orderBy;
}
return $this->model->getKeyName();
} | [
"public",
"function",
"orderBy",
"(",
")",
"{",
"if",
"(",
"Request",
"::",
"input",
"(",
"'order'",
")",
")",
"{",
"return",
"Request",
"::",
"input",
"(",
"'order'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"orderBy",
")",
"{",
"return",
"$",... | Return Managed Model OrderBy.
Primary key is default.
@return string | [
"Return",
"Managed",
"Model",
"OrderBy",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L195-L206 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.applyQueryFilters | private function applyQueryFilters()
{
if (is_array($this->queryFilter())) {
$this->createQueryFilter();
} else {
$this->queryFilter();
}
$this->queryFilterRequest();
} | php | private function applyQueryFilters()
{
if (is_array($this->queryFilter())) {
$this->createQueryFilter();
} else {
$this->queryFilter();
}
$this->queryFilterRequest();
} | [
"private",
"function",
"applyQueryFilters",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"queryFilter",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"createQueryFilter",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"queryFilter",... | Apply the Query Filters.
@return | [
"Apply",
"the",
"Query",
"Filters",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L253-L262 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.queryFilterRequest | private function queryFilterRequest()
{
if (!$safeFilter = Request::get('filter')) {
return false;
}
if (!isset($this->safeFilters()[$safeFilter])) {
return false;
}
return $this->query = $this->filters()[$this->safeFilters()[$safeFilter]];
} | php | private function queryFilterRequest()
{
if (!$safeFilter = Request::get('filter')) {
return false;
}
if (!isset($this->safeFilters()[$safeFilter])) {
return false;
}
return $this->query = $this->filters()[$this->safeFilters()[$safeFilter]];
} | [
"private",
"function",
"queryFilterRequest",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"safeFilter",
"=",
"Request",
"::",
"get",
"(",
"'filter'",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"safeFilters",
"... | Apply the Query Filters specific to this Request.
@return | [
"Apply",
"the",
"Query",
"Filters",
"specific",
"to",
"this",
"Request",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L269-L280 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.createQueryFilter | private function createQueryFilter()
{
if (count($this->queryFilter()) > 0) {
foreach ($this->queryFilter() as $filter => $parameters) {
if (!is_array($parameters)) {
$parameters = [$parameters];
}
$this->query = call_user_func_array([$this->query, $filter], $parameters);
}
}
} | php | private function createQueryFilter()
{
if (count($this->queryFilter()) > 0) {
foreach ($this->queryFilter() as $filter => $parameters) {
if (!is_array($parameters)) {
$parameters = [$parameters];
}
$this->query = call_user_func_array([$this->query, $filter], $parameters);
}
}
} | [
"private",
"function",
"createQueryFilter",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"queryFilter",
"(",
")",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"queryFilter",
"(",
")",
"as",
"$",
"filter",
"=>",
"$",
"pa... | Create the Query Filter from Array.
@return | [
"Create",
"the",
"Query",
"Filter",
"from",
"Array",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L287-L297 | train |
laravelflare/flare | src/Flare/Admin/Models/Traits/ModelQuerying.php | ModelQuerying.safeFilters | public function safeFilters()
{
$filters = [];
foreach ($this->filters() as $filterName => $query) {
$filters[str_slug($filterName)] = $filterName;
}
return $filters;
} | php | public function safeFilters()
{
$filters = [];
foreach ($this->filters() as $filterName => $query) {
$filters[str_slug($filterName)] = $filterName;
}
return $filters;
} | [
"public",
"function",
"safeFilters",
"(",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"(",
")",
"as",
"$",
"filterName",
"=>",
"$",
"query",
")",
"{",
"$",
"filters",
"[",
"str_slug",
"(",
"$",
"filte... | Associative array of safe filter names to
their corresponding normal counterpart.
@return | [
"Associative",
"array",
"of",
"safe",
"filter",
"names",
"to",
"their",
"corresponding",
"normal",
"counterpart",
"."
] | 9b40388e0a28a92e8a9ba5196c28603e4a230dde | https://github.com/laravelflare/flare/blob/9b40388e0a28a92e8a9ba5196c28603e4a230dde/src/Flare/Admin/Models/Traits/ModelQuerying.php#L325-L334 | train |
reliv/Rcm | core/src/Factory/SessionManagerFactory.php | SessionManagerFactory.getSessionConfig | protected function getSessionConfig(
ServiceLocatorInterface $serviceLocator,
$sessionConfig
) {
if (empty($sessionConfig)
|| empty($sessionConfig['config'])
) {
return new SessionConfig();
}
$class = '\Zend\Session\Config\SessionConfig';
$options = [];
if (isset($sessionConfig['config']['class'])
) {
$class = $sessionConfig['config']['class'];
}
if (isset($sessionConfig['config']['options'])
) {
$options = $sessionConfig['config']['options'];
}
/** @var \Zend\Session\Config\ConfigInterface $sessionConfigObject */
if ($serviceLocator->has($class)) {
$sessionConfigObject = $serviceLocator->get($class);
} else {
$sessionConfigObject = new $class();
}
if (!$sessionConfigObject instanceof ConfigInterface) {
throw new InvalidArgumentException(
'Session Config class must implement '
. '\Zend\Session\Config\ConfigInterface'
);
}
$sessionConfigObject->setOptions($options);
return $sessionConfigObject;
} | php | protected function getSessionConfig(
ServiceLocatorInterface $serviceLocator,
$sessionConfig
) {
if (empty($sessionConfig)
|| empty($sessionConfig['config'])
) {
return new SessionConfig();
}
$class = '\Zend\Session\Config\SessionConfig';
$options = [];
if (isset($sessionConfig['config']['class'])
) {
$class = $sessionConfig['config']['class'];
}
if (isset($sessionConfig['config']['options'])
) {
$options = $sessionConfig['config']['options'];
}
/** @var \Zend\Session\Config\ConfigInterface $sessionConfigObject */
if ($serviceLocator->has($class)) {
$sessionConfigObject = $serviceLocator->get($class);
} else {
$sessionConfigObject = new $class();
}
if (!$sessionConfigObject instanceof ConfigInterface) {
throw new InvalidArgumentException(
'Session Config class must implement '
. '\Zend\Session\Config\ConfigInterface'
);
}
$sessionConfigObject->setOptions($options);
return $sessionConfigObject;
} | [
"protected",
"function",
"getSessionConfig",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
",",
"$",
"sessionConfig",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"sessionConfig",
")",
"||",
"empty",
"(",
"$",
"sessionConfig",
"[",
"'config'",
"]",
")",
")... | Build the session config object
@param ServiceLocatorInterface $serviceLocator Zend Service Locator
@param array $sessionConfig Session Config
@return \Zend\Session\Config\ConfigInterface|SessionConfig
@throws InvalidArgumentException | [
"Build",
"the",
"session",
"config",
"object"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Factory/SessionManagerFactory.php#L97-L137 | train |
reliv/Rcm | core/src/Factory/SessionManagerFactory.php | SessionManagerFactory.getSessionSaveHandler | protected function getSessionSaveHandler(
ServiceLocatorInterface $serviceLocator,
$sessionConfig
) {
if (!isset($sessionConfig['save_handler'])) {
return null;
}
// Setting with invokable currently not implemented. No session
// Save handler available in ZF2 that's currently invokable is available
// for testing.
/** @var SaveHandlerInterface $sessionSaveHandler */
$saveHandler = $serviceLocator->get($sessionConfig['save_handler']);
if (!$saveHandler instanceof SaveHandlerInterface) {
throw new InvalidArgumentException(
'Session Save Handler class must implement '
. 'Zend\Session\Storage\StorageInterface'
);
}
return $saveHandler;
} | php | protected function getSessionSaveHandler(
ServiceLocatorInterface $serviceLocator,
$sessionConfig
) {
if (!isset($sessionConfig['save_handler'])) {
return null;
}
// Setting with invokable currently not implemented. No session
// Save handler available in ZF2 that's currently invokable is available
// for testing.
/** @var SaveHandlerInterface $sessionSaveHandler */
$saveHandler = $serviceLocator->get($sessionConfig['save_handler']);
if (!$saveHandler instanceof SaveHandlerInterface) {
throw new InvalidArgumentException(
'Session Save Handler class must implement '
. 'Zend\Session\Storage\StorageInterface'
);
}
return $saveHandler;
} | [
"protected",
"function",
"getSessionSaveHandler",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
",",
"$",
"sessionConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"sessionConfig",
"[",
"'save_handler'",
"]",
")",
")",
"{",
"return",
"null",
";",
... | Get the Session Save Handler
@param ServiceLocatorInterface $serviceLocator Zend Service Locator
@param array $sessionConfig Session Config Array
@return null|SaveHandlerInterface
@throws InvalidArgumentException | [
"Get",
"the",
"Session",
"Save",
"Handler"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Factory/SessionManagerFactory.php#L181-L204 | train |
reliv/Rcm | core/src/Factory/SessionManagerFactory.php | SessionManagerFactory.setValidatorChain | protected function setValidatorChain(
SessionManager $sessionManager,
ServiceLocatorInterface $serviceLocator,
$sessionConfig
) {
if (!isset($sessionConfig['validators'])
|| !is_array($sessionConfig['validators'])
) {
return;
}
$chain = $sessionManager->getValidatorChain();
foreach ($sessionConfig['validators'] as &$validator) {
if ($serviceLocator->has($validator)) {
$validator = $serviceLocator->get($validator);
} else {
$validator = new $validator();
}
if (!$validator instanceof ValidatorInterface) {
throw new InvalidArgumentException(
'Session Save Handler class must implement '
. 'Zend\Session\Validator\ValidatorInterface'
);
}
$chain->attach(
'session.validate',
[$validator, 'isValid']
);
}
} | php | protected function setValidatorChain(
SessionManager $sessionManager,
ServiceLocatorInterface $serviceLocator,
$sessionConfig
) {
if (!isset($sessionConfig['validators'])
|| !is_array($sessionConfig['validators'])
) {
return;
}
$chain = $sessionManager->getValidatorChain();
foreach ($sessionConfig['validators'] as &$validator) {
if ($serviceLocator->has($validator)) {
$validator = $serviceLocator->get($validator);
} else {
$validator = new $validator();
}
if (!$validator instanceof ValidatorInterface) {
throw new InvalidArgumentException(
'Session Save Handler class must implement '
. 'Zend\Session\Validator\ValidatorInterface'
);
}
$chain->attach(
'session.validate',
[$validator, 'isValid']
);
}
} | [
"protected",
"function",
"setValidatorChain",
"(",
"SessionManager",
"$",
"sessionManager",
",",
"ServiceLocatorInterface",
"$",
"serviceLocator",
",",
"$",
"sessionConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"sessionConfig",
"[",
"'validators'",
"]",
")... | Attach the Service Validators to the Session
@param SessionManager $sessionManager Zend Session Manager
@param ServiceLocatorInterface $serviceLocator Zend Service Locator
@param array $sessionConfig Session Config Array
@return void
@throws InvalidArgumentException | [
"Attach",
"the",
"Service",
"Validators",
"to",
"the",
"Session"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Factory/SessionManagerFactory.php#L216-L248 | train |
CHECK24/apitk-common-bundle | ParamConverter/EntityAwareParamConverterTrait.php | EntityAwareParamConverterTrait.callRepositoryMethod | protected function callRepositoryMethod(string $method, ...$args)
{
$om = $this->getManager();
$repo = $om->getRepository($this->getEntity());
if (!method_exists($repo, $method) || !is_callable([$repo, $method])) {
throw new \InvalidArgumentException(
sprintf(
'Method "%s" doesn\'t exist or isn\'t callable in EntityRepository "%s"',
$method,
get_class($repo)
)
);
}
return $repo->$method(...$args);
} | php | protected function callRepositoryMethod(string $method, ...$args)
{
$om = $this->getManager();
$repo = $om->getRepository($this->getEntity());
if (!method_exists($repo, $method) || !is_callable([$repo, $method])) {
throw new \InvalidArgumentException(
sprintf(
'Method "%s" doesn\'t exist or isn\'t callable in EntityRepository "%s"',
$method,
get_class($repo)
)
);
}
return $repo->$method(...$args);
} | [
"protected",
"function",
"callRepositoryMethod",
"(",
"string",
"$",
"method",
",",
"...",
"$",
"args",
")",
"{",
"$",
"om",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
";",
"$",
"repo",
"=",
"$",
"om",
"->",
"getRepository",
"(",
"$",
"this",
"-... | Call a given method on an EntityRepository.
@param string $method
@param mixed ...$args
@return mixed | [
"Call",
"a",
"given",
"method",
"on",
"an",
"EntityRepository",
"."
] | 4b312eaf26f368db77d2e786c1acf144244c0d21 | https://github.com/CHECK24/apitk-common-bundle/blob/4b312eaf26f368db77d2e786c1acf144244c0d21/ParamConverter/EntityAwareParamConverterTrait.php#L72-L88 | train |
phptuts/StarterBundleForSymfony | src/Security/Guard/Login/AccessTokenGuard.php | AccessTokenGuard.supports | public function supports(Request $request)
{
$post = json_decode($request->getContent(), true);
return !empty($post[self::TOKEN_FIELD]);
} | php | public function supports(Request $request)
{
$post = json_decode($request->getContent(), true);
return !empty($post[self::TOKEN_FIELD]);
} | [
"public",
"function",
"supports",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"post",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"getContent",
"(",
")",
",",
"true",
")",
";",
"return",
"!",
"empty",
"(",
"$",
"post",
"[",
"self",
"::",
"TOKEN... | 1) Returns true if the request has json body with token in it
@param Request $request
@return bool | [
"1",
")",
"Returns",
"true",
"if",
"the",
"request",
"has",
"json",
"body",
"with",
"token",
"in",
"it"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/Login/AccessTokenGuard.php#L37-L42 | train |
phptuts/StarterBundleForSymfony | src/Security/Guard/Login/AccessTokenGuard.php | AccessTokenGuard.getCredentials | public function getCredentials(Request $request)
{
$post = json_decode($request->getContent(), true);
return new CredentialTokenModel($post[self::TOKEN_FIELD]);
} | php | public function getCredentials(Request $request)
{
$post = json_decode($request->getContent(), true);
return new CredentialTokenModel($post[self::TOKEN_FIELD]);
} | [
"public",
"function",
"getCredentials",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"post",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"getContent",
"(",
")",
",",
"true",
")",
";",
"return",
"new",
"CredentialTokenModel",
"(",
"$",
"post",
"[",
"... | 2) Returns CredentialTokenModel with json field token
@param Request $request
@return CredentialTokenModel | [
"2",
")",
"Returns",
"CredentialTokenModel",
"with",
"json",
"field",
"token"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/Login/AccessTokenGuard.php#L50-L55 | train |
dadajuice/zephyrus | src/Zephyrus/Application/RouterEngine.php | RouterEngine.run | final public function run(Request $request)
{
$this->request = $request;
$path = $this->request->getUri()->getPath();
$this->requestedUri = ($path != "/") ? rtrim($path, "/") : "/";
$this->requestedMethod = strtoupper($this->request->getMethod());
$this->requestedRepresentation = $this->request->getAccept();
$this->verifyRequestMethod();
$route = $this->findRouteFromRequest();
$this->prepareResponse($route);
} | php | final public function run(Request $request)
{
$this->request = $request;
$path = $this->request->getUri()->getPath();
$this->requestedUri = ($path != "/") ? rtrim($path, "/") : "/";
$this->requestedMethod = strtoupper($this->request->getMethod());
$this->requestedRepresentation = $this->request->getAccept();
$this->verifyRequestMethod();
$route = $this->findRouteFromRequest();
$this->prepareResponse($route);
} | [
"final",
"public",
"function",
"run",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"$",
... | Launch the routing process to determine, according to the
initiated request, the best route to execute. Cannot be overridden.
@param Request $request
@throws \Exception | [
"Launch",
"the",
"routing",
"process",
"to",
"determine",
"according",
"to",
"the",
"initiated",
"request",
"the",
"best",
"route",
"to",
"execute",
".",
"Cannot",
"be",
"overridden",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/RouterEngine.php#L43-L53 | train |
dadajuice/zephyrus | src/Zephyrus/Application/RouterEngine.php | RouterEngine.addRoute | final protected function addRoute($method, $uri, $callback, $acceptedFormats)
{
$this->routes[$method][] = [
'route' => new Route($uri),
'callback' => $callback,
'acceptedRequestFormats' => $acceptedFormats
];
} | php | final protected function addRoute($method, $uri, $callback, $acceptedFormats)
{
$this->routes[$method][] = [
'route' => new Route($uri),
'callback' => $callback,
'acceptedRequestFormats' => $acceptedFormats
];
} | [
"final",
"protected",
"function",
"addRoute",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"callback",
",",
"$",
"acceptedFormats",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"$",
"method",
"]",
"[",
"]",
"=",
"[",
"'route'",
"=>",
"new",
"Route",... | Add a new route for the application. Make sure to create the
adequate structure with corresponding parameters regex pattern if
needed. Cannot be overridden.
@param string $method
@param string $uri
@param callable $callback
@param string | array | null $acceptedFormats | [
"Add",
"a",
"new",
"route",
"for",
"the",
"application",
".",
"Make",
"sure",
"to",
"create",
"the",
"adequate",
"structure",
"with",
"corresponding",
"parameters",
"regex",
"pattern",
"if",
"needed",
".",
"Cannot",
"be",
"overridden",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/RouterEngine.php#L73-L80 | train |
dadajuice/zephyrus | src/Zephyrus/Application/RouterEngine.php | RouterEngine.createResponse | private function createResponse($route): ?Response
{
$controller = $this->getRouteControllerInstance($route);
if (!is_null($controller)) {
$responseBefore = $controller->before();
if ($responseBefore instanceof Response) {
return $responseBefore;
}
}
$values = $route['route']->getArguments($this->requestedUri);
$this->loadRequestParameters($values);
$callback = new Callback($route['callback']);
$arguments = $this->getFunctionArguments($callback->getReflection(), array_values($values));
$response = $callback->executeArray($arguments);
if (!is_null($controller)) {
$responseAfter = $controller->after($response);
if ($responseAfter instanceof Response) {
return $responseAfter;
}
}
return $response;
} | php | private function createResponse($route): ?Response
{
$controller = $this->getRouteControllerInstance($route);
if (!is_null($controller)) {
$responseBefore = $controller->before();
if ($responseBefore instanceof Response) {
return $responseBefore;
}
}
$values = $route['route']->getArguments($this->requestedUri);
$this->loadRequestParameters($values);
$callback = new Callback($route['callback']);
$arguments = $this->getFunctionArguments($callback->getReflection(), array_values($values));
$response = $callback->executeArray($arguments);
if (!is_null($controller)) {
$responseAfter = $controller->after($response);
if ($responseAfter instanceof Response) {
return $responseAfter;
}
}
return $response;
} | [
"private",
"function",
"createResponse",
"(",
"$",
"route",
")",
":",
"?",
"Response",
"{",
"$",
"controller",
"=",
"$",
"this",
"->",
"getRouteControllerInstance",
"(",
"$",
"route",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"controller",
")",
")",... | Creates the response to return while executing the before and after
methods if they are available.
@param $route
@throws \Exception
@return Response | null | [
"Creates",
"the",
"response",
"to",
"return",
"while",
"executing",
"the",
"before",
"and",
"after",
"methods",
"if",
"they",
"are",
"available",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/RouterEngine.php#L182-L205 | train |
dadajuice/zephyrus | src/Zephyrus/Application/RouterEngine.php | RouterEngine.loadRequestParameters | private function loadRequestParameters($values)
{
foreach ($values as $param => $value) {
$this->request->prependParameter($param, $value);
}
} | php | private function loadRequestParameters($values)
{
foreach ($values as $param => $value) {
$this->request->prependParameter($param, $value);
}
} | [
"private",
"function",
"loadRequestParameters",
"(",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"prependParameter",
"(",
"$",
"param",
",",
"$",
"value",
... | Load parameters located inside the request object.
@param mixed[] $values
@throws \Exception | [
"Load",
"parameters",
"located",
"inside",
"the",
"request",
"object",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/RouterEngine.php#L242-L247 | train |
reliv/Rcm | core/src/EventListener/RouteListener.php | RouteListener.checkDomain | public function checkDomain(MvcEvent $event)
{
if ($this->isConsoleRequest()) {
return null;
}
$currentDomain = $this->siteService->getCurrentDomain();
$site = $this->siteService->getCurrentSite($currentDomain);
$redirectUrl = $this->domainRedirectService->getSiteNotAvailableRedirectUrl($site);
if (!$site->isSiteAvailable() && empty($redirectUrl)) {
$response = new Response();
$response->setStatusCode(404);
$event->stopPropagation(true);
return $response;
}
if ($redirectUrl) {
$response = new Response();
$response->setStatusCode(302);
$response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);
$event->stopPropagation(true);
return $response;
}
$redirectUrl = $this->domainRedirectService->getPrimaryRedirectUrl($site);
if ($redirectUrl) {
$response = new Response();
$response->setStatusCode(302);
$response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);
$event->stopPropagation(true);
return $response;
}
return null;
} | php | public function checkDomain(MvcEvent $event)
{
if ($this->isConsoleRequest()) {
return null;
}
$currentDomain = $this->siteService->getCurrentDomain();
$site = $this->siteService->getCurrentSite($currentDomain);
$redirectUrl = $this->domainRedirectService->getSiteNotAvailableRedirectUrl($site);
if (!$site->isSiteAvailable() && empty($redirectUrl)) {
$response = new Response();
$response->setStatusCode(404);
$event->stopPropagation(true);
return $response;
}
if ($redirectUrl) {
$response = new Response();
$response->setStatusCode(302);
$response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);
$event->stopPropagation(true);
return $response;
}
$redirectUrl = $this->domainRedirectService->getPrimaryRedirectUrl($site);
if ($redirectUrl) {
$response = new Response();
$response->setStatusCode(302);
$response->getHeaders()->addHeaderLine('Location', '//' . $redirectUrl);
$event->stopPropagation(true);
return $response;
}
return null;
} | [
"public",
"function",
"checkDomain",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isConsoleRequest",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"currentDomain",
"=",
"$",
"this",
"->",
"siteService",
"->",
"getCurrent... | Check the domain is a known domain for the CMS. If not the primary, it will
redirect the user to the primary domain. Useful for multiple domain sites.
@param MvcEvent $event Zend MVC Event
@return null|Response | [
"Check",
"the",
"domain",
"is",
"a",
"known",
"domain",
"for",
"the",
"CMS",
".",
"If",
"not",
"the",
"primary",
"it",
"will",
"redirect",
"the",
"user",
"to",
"the",
"primary",
"domain",
".",
"Useful",
"for",
"multiple",
"domain",
"sites",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/EventListener/RouteListener.php#L83-L126 | train |
reliv/Rcm | core/src/EventListener/RouteListener.php | RouteListener.checkRedirect | public function checkRedirect(MvcEvent $event)
{
if ($this->isConsoleRequest()) {
return null;
}
// User defaults
$redirectUrl = $this->redirectService->getRedirectUrl();
if (empty($redirectUrl)) {
return null;
}
$queryParams = $event->getRequest()->getQuery()->toArray();
header(
'Location: ' . $redirectUrl . (count($queryParams) ? '?' . http_build_query($queryParams) : null),
true,
302
);
exit;
/* Below is the ZF2 way but Response is not short-circuiting the event like it should *
$response = new Response();
$response->setStatusCode(302);
$response->getHeaders()
->addHeaderLine(
'Location',
$redirect->getRedirectUrl()
);
$event->stopPropagation(true);
return $response;
*/
} | php | public function checkRedirect(MvcEvent $event)
{
if ($this->isConsoleRequest()) {
return null;
}
// User defaults
$redirectUrl = $this->redirectService->getRedirectUrl();
if (empty($redirectUrl)) {
return null;
}
$queryParams = $event->getRequest()->getQuery()->toArray();
header(
'Location: ' . $redirectUrl . (count($queryParams) ? '?' . http_build_query($queryParams) : null),
true,
302
);
exit;
/* Below is the ZF2 way but Response is not short-circuiting the event like it should *
$response = new Response();
$response->setStatusCode(302);
$response->getHeaders()
->addHeaderLine(
'Location',
$redirect->getRedirectUrl()
);
$event->stopPropagation(true);
return $response;
*/
} | [
"public",
"function",
"checkRedirect",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isConsoleRequest",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"// User defaults",
"$",
"redirectUrl",
"=",
"$",
"this",
"->",
"redirectServi... | Check the defined redirects. If requested URL is found, redirect to the
new location.
@param MvcEvent $event Zend MVC Event
@return null|Response | [
"Check",
"the",
"defined",
"redirects",
".",
"If",
"requested",
"URL",
"is",
"found",
"redirect",
"to",
"the",
"new",
"location",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/EventListener/RouteListener.php#L136-L171 | train |
reliv/Rcm | core/src/EventListener/RouteListener.php | RouteListener.addLocale | public function addLocale(MvcEvent $event)
{
$locale = $this->siteService->getCurrentSite()->getLocale();
$this->localeService->setLocale($locale);
return null;
} | php | public function addLocale(MvcEvent $event)
{
$locale = $this->siteService->getCurrentSite()->getLocale();
$this->localeService->setLocale($locale);
return null;
} | [
"public",
"function",
"addLocale",
"(",
"MvcEvent",
"$",
"event",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"siteService",
"->",
"getCurrentSite",
"(",
")",
"->",
"getLocale",
"(",
")",
";",
"$",
"this",
"->",
"localeService",
"->",
"setLocale",
"... | Set the system locale to Site Requirements
@param MvcEvent $event
@return null | [
"Set",
"the",
"system",
"locale",
"to",
"Site",
"Requirements"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/EventListener/RouteListener.php#L180-L187 | train |
7php/SavantPHP | src/SavantPHP.php | SavantPHP.getConfigList | public function getConfigList($key = null)
{
if (is_null($key)) {
return $this->configList; // no key requested, return the entire configuration bag
} elseif (empty($this->configList[$key])) {
return null; // no such key
} else {
return $this->configList[$key]; // return the requested key
}
} | php | public function getConfigList($key = null)
{
if (is_null($key)) {
return $this->configList; // no key requested, return the entire configuration bag
} elseif (empty($this->configList[$key])) {
return null; // no such key
} else {
return $this->configList[$key]; // return the requested key
}
} | [
"public",
"function",
"getConfigList",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configList",
";",
"// no key requested, return the entire configuration bag",
"}",
"elseif",
"(",... | Returns the SavantPHP configuration parameter bag.
@param string $key The specific configuration key to return. If null, returns the entire configuration array.
@return mixed | [
"Returns",
"the",
"SavantPHP",
"configuration",
"parameter",
"bag",
"."
] | 4a968be6637675a0b78043357e8153ae5f65dbc6 | https://github.com/7php/SavantPHP/blob/4a968be6637675a0b78043357e8153ae5f65dbc6/src/SavantPHP.php#L108-L117 | train |
7php/SavantPHP | src/SavantPHP.php | SavantPHP.setPath | public function setPath($path)
{
// clear out the prior search dirs
$this->configList[self::TPL_PATH_LIST] = [];
// always add the fallback directories as last resort
$this->addPath('.');
// actually add the user-specified directory
$this->addPath($path);
} | php | public function setPath($path)
{
// clear out the prior search dirs
$this->configList[self::TPL_PATH_LIST] = [];
// always add the fallback directories as last resort
$this->addPath('.');
// actually add the user-specified directory
$this->addPath($path);
} | [
"public",
"function",
"setPath",
"(",
"$",
"path",
")",
"{",
"// clear out the prior search dirs",
"$",
"this",
"->",
"configList",
"[",
"self",
"::",
"TPL_PATH_LIST",
"]",
"=",
"[",
"]",
";",
"// always add the fallback directories as last resort",
"$",
"this",
"->... | Sets an entire array of possible search paths for templates
@param string|array $path | [
"Sets",
"an",
"entire",
"array",
"of",
"possible",
"search",
"paths",
"for",
"templates"
] | 4a968be6637675a0b78043357e8153ae5f65dbc6 | https://github.com/7php/SavantPHP/blob/4a968be6637675a0b78043357e8153ae5f65dbc6/src/SavantPHP.php#L194-L202 | train |
7php/SavantPHP | src/SavantPHP.php | SavantPHP.fetch | public function fetch($tpl = null)
{
// make sure we have a template source to work with
if (is_null($tpl)) {
$tpl = $this->configList[self::TPL_FILE];
}
$result = $this->getPathToTemplate($tpl);
if (! $result || $this->isError($result)) { //if no path
return $result;
} else {
$this->configList[self::FETCHED_TPL_FILE] = $result;
unset($result);
unset($tpl);
// buffer output so we can return it instead of displaying.
ob_start();
include $this->configList[self::FETCHED_TPL_FILE];
$this->configList[self::FETCHED_TPL_FILE] = null; //flush fetched script value
return ob_get_clean();
}
} | php | public function fetch($tpl = null)
{
// make sure we have a template source to work with
if (is_null($tpl)) {
$tpl = $this->configList[self::TPL_FILE];
}
$result = $this->getPathToTemplate($tpl);
if (! $result || $this->isError($result)) { //if no path
return $result;
} else {
$this->configList[self::FETCHED_TPL_FILE] = $result;
unset($result);
unset($tpl);
// buffer output so we can return it instead of displaying.
ob_start();
include $this->configList[self::FETCHED_TPL_FILE];
$this->configList[self::FETCHED_TPL_FILE] = null; //flush fetched script value
return ob_get_clean();
}
} | [
"public",
"function",
"fetch",
"(",
"$",
"tpl",
"=",
"null",
")",
"{",
"// make sure we have a template source to work with",
"if",
"(",
"is_null",
"(",
"$",
"tpl",
")",
")",
"{",
"$",
"tpl",
"=",
"$",
"this",
"->",
"configList",
"[",
"self",
"::",
"TPL_FI... | Gets & executes a template source.
@access public
@param string $tpl The template to process; if null, uses the
default template set with setTemplate().
@return mixed The template output string, or a SavantPHPerror. | [
"Gets",
"&",
"executes",
"a",
"template",
"source",
"."
] | 4a968be6637675a0b78043357e8153ae5f65dbc6 | https://github.com/7php/SavantPHP/blob/4a968be6637675a0b78043357e8153ae5f65dbc6/src/SavantPHP.php#L313-L336 | train |
7php/SavantPHP | src/SavantPHP.php | SavantPHP.error | public function error($code, $info = [], $level = E_USER_ERROR, $trace = true)
{
if ($this->configList[self::EXCEPTIONS]) {
throw new SavantPHPexception($code);
}
// the error config array
$config = [
'code' => $code,
'info' => (array) $info,
'level' => $level,
'trace' => $trace
];
return new SavantPHPerror($config);
} | php | public function error($code, $info = [], $level = E_USER_ERROR, $trace = true)
{
if ($this->configList[self::EXCEPTIONS]) {
throw new SavantPHPexception($code);
}
// the error config array
$config = [
'code' => $code,
'info' => (array) $info,
'level' => $level,
'trace' => $trace
];
return new SavantPHPerror($config);
} | [
"public",
"function",
"error",
"(",
"$",
"code",
",",
"$",
"info",
"=",
"[",
"]",
",",
"$",
"level",
"=",
"E_USER_ERROR",
",",
"$",
"trace",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"configList",
"[",
"self",
"::",
"EXCEPTIONS",
"]",
... | Returns an error object or throws an exception.
@param $code
@param array $info
@param int $level
@param bool $trace
@return SavantPHPerror
@throws SavantPHPexception | [
"Returns",
"an",
"error",
"object",
"or",
"throws",
"an",
"exception",
"."
] | 4a968be6637675a0b78043357e8153ae5f65dbc6 | https://github.com/7php/SavantPHP/blob/4a968be6637675a0b78043357e8153ae5f65dbc6/src/SavantPHP.php#L400-L413 | train |
7php/SavantPHP | src/SavantPHP.php | SavantPHP.isError | public function isError($obj)
{
// is it even an object?
if (! is_object($obj)) { // if not an object, can't even be a SavantPHPerror object
return false;
} else {
// now compare the parentage
$is = $obj instanceof SavantPHPerror;
$sub = is_subclass_of($obj, 'SavantPHPerror');
return ($is || $sub);
}
} | php | public function isError($obj)
{
// is it even an object?
if (! is_object($obj)) { // if not an object, can't even be a SavantPHPerror object
return false;
} else {
// now compare the parentage
$is = $obj instanceof SavantPHPerror;
$sub = is_subclass_of($obj, 'SavantPHPerror');
return ($is || $sub);
}
} | [
"public",
"function",
"isError",
"(",
"$",
"obj",
")",
"{",
"// is it even an object?",
"if",
"(",
"!",
"is_object",
"(",
"$",
"obj",
")",
")",
"{",
"// if not an object, can't even be a SavantPHPerror object",
"return",
"false",
";",
"}",
"else",
"{",
"// now com... | Tests if an object is of the SavantPHPerror class.
@param $obj
@return bool | [
"Tests",
"if",
"an",
"object",
"is",
"of",
"the",
"SavantPHPerror",
"class",
"."
] | 4a968be6637675a0b78043357e8153ae5f65dbc6 | https://github.com/7php/SavantPHP/blob/4a968be6637675a0b78043357e8153ae5f65dbc6/src/SavantPHP.php#L421-L432 | train |
GoIntegro/hateoas | JsonApi/ResourceCollection.php | ResourceCollection.buildFromArray | public static function buildFromArray(array $resources)
{
$resource = @$resources[0];
if (!$resource instanceof EntityResource) {
throw new LogicException(self::ERROR_EMPTY_ARRAY);
}
return new static($resources, $resource->getMetadata());
} | php | public static function buildFromArray(array $resources)
{
$resource = @$resources[0];
if (!$resource instanceof EntityResource) {
throw new LogicException(self::ERROR_EMPTY_ARRAY);
}
return new static($resources, $resource->getMetadata());
} | [
"public",
"static",
"function",
"buildFromArray",
"(",
"array",
"$",
"resources",
")",
"{",
"$",
"resource",
"=",
"@",
"$",
"resources",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"$",
"resource",
"instanceof",
"EntityResource",
")",
"{",
"throw",
"new",
"Logic... | Factory method para construir a partir de un array de EntityResource.
@param arary $resources | [
"Factory",
"method",
"para",
"construir",
"a",
"partir",
"de",
"un",
"array",
"de",
"EntityResource",
"."
] | 4799794294079f8bd3839e76175134219f876105 | https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/JsonApi/ResourceCollection.php#L52-L61 | train |
russsiq/bixbite | app/Models/Relations/Commentable.php | Commentable.getComments | public function getComments(bool $nested = false)
{
$comments = $this->comments()->get();
// If at least one comment is left by a registered user
if ($comments->firstWhere('user_id', '>', 'null')) {
$comments->load(['user:users.id,users.name,users.email,users.avatar']);
}
return $comments->treated($nested, $this->getAttributes());
} | php | public function getComments(bool $nested = false)
{
$comments = $this->comments()->get();
// If at least one comment is left by a registered user
if ($comments->firstWhere('user_id', '>', 'null')) {
$comments->load(['user:users.id,users.name,users.email,users.avatar']);
}
return $comments->treated($nested, $this->getAttributes());
} | [
"public",
"function",
"getComments",
"(",
"bool",
"$",
"nested",
"=",
"false",
")",
"{",
"$",
"comments",
"=",
"$",
"this",
"->",
"comments",
"(",
")",
"->",
"get",
"(",
")",
";",
"// If at least one comment is left by a registered user",
"if",
"(",
"$",
"co... | Get a list comments with user relation, if need
@param boolean $nested
@return mixed Collection | [
"Get",
"a",
"list",
"comments",
"with",
"user",
"relation",
"if",
"need"
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Models/Relations/Commentable.php#L20-L30 | train |
reliv/Rcm | core/src/Service/ResponseHandler.php | ResponseHandler.processResponse | public function processResponse(ResponseInterface $response)
{
if (!$response instanceof Response
|| !$this->getRequest()
) {
return;
}
$response = $this->handleResponse($response);
$this->renderResponse($response);
$this->terminateApp();
} | php | public function processResponse(ResponseInterface $response)
{
if (!$response instanceof Response
|| !$this->getRequest()
) {
return;
}
$response = $this->handleResponse($response);
$this->renderResponse($response);
$this->terminateApp();
} | [
"public",
"function",
"processResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"$",
"response",
"instanceof",
"Response",
"||",
"!",
"$",
"this",
"->",
"getRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"response",
... | Process Rcm Response objects or simply return if response is a normal
Zend Response.
@param ResponseInterface $response Zend Response Object.
@return void | [
"Process",
"Rcm",
"Response",
"objects",
"or",
"simply",
"return",
"if",
"response",
"is",
"a",
"normal",
"Zend",
"Response",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/ResponseHandler.php#L83-L94 | train |
reliv/Rcm | core/src/Service/ResponseHandler.php | ResponseHandler.handleResponse | protected function handleResponse(Response $response)
{
$statusCode = $response->getStatusCode();
switch ($statusCode) {
case 401:
$response = $this->processNotAuthorized();
break;
}
return $response;
} | php | protected function handleResponse(Response $response)
{
$statusCode = $response->getStatusCode();
switch ($statusCode) {
case 401:
$response = $this->processNotAuthorized();
break;
}
return $response;
} | [
"protected",
"function",
"handleResponse",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"switch",
"(",
"$",
"statusCode",
")",
"{",
"case",
"401",
":",
"$",
"response",
"=",
"$... | Handle the RCM Response object
@param Response $response Rcm Response Object
@return Response | [
"Handle",
"the",
"RCM",
"Response",
"object"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/ResponseHandler.php#L103-L114 | train |
reliv/Rcm | core/src/Service/ResponseHandler.php | ResponseHandler.processNotAuthorized | protected function processNotAuthorized()
{
$loginPage = $this->currentSite->getLoginPage();
$notAuthorized = $this->currentSite->getNotAuthorizedPage();
$returnToUrl = urlencode($this->request->getServer('REQUEST_URI'));
$newResponse = new Response();
$newResponse->setStatusCode('302');
if (!$this->userService->hasIdentity()) {
$newResponse->getHeaders()
->addHeaderLine(
'Location: ' . $loginPage . '?redirect=' . $returnToUrl
);
} else {
$newResponse->getHeaders()
->addHeaderLine(
'Location: ' . $notAuthorized
);
}
return $newResponse;
} | php | protected function processNotAuthorized()
{
$loginPage = $this->currentSite->getLoginPage();
$notAuthorized = $this->currentSite->getNotAuthorizedPage();
$returnToUrl = urlencode($this->request->getServer('REQUEST_URI'));
$newResponse = new Response();
$newResponse->setStatusCode('302');
if (!$this->userService->hasIdentity()) {
$newResponse->getHeaders()
->addHeaderLine(
'Location: ' . $loginPage . '?redirect=' . $returnToUrl
);
} else {
$newResponse->getHeaders()
->addHeaderLine(
'Location: ' . $notAuthorized
);
}
return $newResponse;
} | [
"protected",
"function",
"processNotAuthorized",
"(",
")",
"{",
"$",
"loginPage",
"=",
"$",
"this",
"->",
"currentSite",
"->",
"getLoginPage",
"(",
")",
";",
"$",
"notAuthorized",
"=",
"$",
"this",
"->",
"currentSite",
"->",
"getNotAuthorizedPage",
"(",
")",
... | Process 401 Response Objects. This will redirect the visitor to the
sites configured login page.
@return Response | [
"Process",
"401",
"Response",
"Objects",
".",
"This",
"will",
"redirect",
"the",
"visitor",
"to",
"the",
"sites",
"configured",
"login",
"page",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/ResponseHandler.php#L122-L143 | train |
reliv/Rcm | core/src/Service/ResponseHandler.php | ResponseHandler.renderResponse | protected function renderResponse(Response $response)
{
$sendEvent = new SendResponseEvent();
$sendEvent->setResponse($response);
$this->responseSender->__invoke($sendEvent);
} | php | protected function renderResponse(Response $response)
{
$sendEvent = new SendResponseEvent();
$sendEvent->setResponse($response);
$this->responseSender->__invoke($sendEvent);
} | [
"protected",
"function",
"renderResponse",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"sendEvent",
"=",
"new",
"SendResponseEvent",
"(",
")",
";",
"$",
"sendEvent",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"responseSender... | Renders the Response object.
@param Response $response Rcm Response Object
@return void | [
"Renders",
"the",
"Response",
"object",
"."
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Service/ResponseHandler.php#L152-L158 | train |
webeweb/core-bundle | Twig/Extension/Plugin/AbstractFontAwesomeTwigExtension.php | AbstractFontAwesomeTwigExtension.fontAwesomeIcon | protected function fontAwesomeIcon(FontAwesomeIconInterface $icon) {
$attributes = [];
$attributes["class"][] = FontAwesomeIconRenderer::renderFont($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderName($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderSize($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderFixedWidth($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderBordered($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderPull($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderAnimation($icon);
$attributes["style"] = FontAwesomeIconRenderer::renderStyle($icon);
return static::coreHTMLElement("i", null, $attributes);
} | php | protected function fontAwesomeIcon(FontAwesomeIconInterface $icon) {
$attributes = [];
$attributes["class"][] = FontAwesomeIconRenderer::renderFont($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderName($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderSize($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderFixedWidth($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderBordered($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderPull($icon);
$attributes["class"][] = FontAwesomeIconRenderer::renderAnimation($icon);
$attributes["style"] = FontAwesomeIconRenderer::renderStyle($icon);
return static::coreHTMLElement("i", null, $attributes);
} | [
"protected",
"function",
"fontAwesomeIcon",
"(",
"FontAwesomeIconInterface",
"$",
"icon",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"$",
"attributes",
"[",
"\"class\"",
"]",
"[",
"]",
"=",
"FontAwesomeIconRenderer",
"::",
"renderFont",
"(",
"$",
"icon",... | Displays a Font Awesome icon.
@param FontAwesomeIconInterface $icon The icon.
@return string Returns the Font Awesome icon. | [
"Displays",
"a",
"Font",
"Awesome",
"icon",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/AbstractFontAwesomeTwigExtension.php#L33-L47 | train |
webeweb/core-bundle | Twig/Extension/Plugin/AbstractFontAwesomeTwigExtension.php | AbstractFontAwesomeTwigExtension.fontAwesomeList | protected function fontAwesomeList($items) {
$innerHTML = true === is_array($items) ? implode("\n", $items) : $items;
return static::coreHTMLElement("ul", $innerHTML, ["class" => "fa-ul"]);
} | php | protected function fontAwesomeList($items) {
$innerHTML = true === is_array($items) ? implode("\n", $items) : $items;
return static::coreHTMLElement("ul", $innerHTML, ["class" => "fa-ul"]);
} | [
"protected",
"function",
"fontAwesomeList",
"(",
"$",
"items",
")",
"{",
"$",
"innerHTML",
"=",
"true",
"===",
"is_array",
"(",
"$",
"items",
")",
"?",
"implode",
"(",
"\"\\n\"",
",",
"$",
"items",
")",
":",
"$",
"items",
";",
"return",
"static",
"::",... | Displays a Font Awesome list.
@param array|string $items The items.
@return string Returns the Font Awesome list. | [
"Displays",
"a",
"Font",
"Awesome",
"list",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/AbstractFontAwesomeTwigExtension.php#L55-L60 | train |
webeweb/core-bundle | Twig/Extension/Plugin/AbstractFontAwesomeTwigExtension.php | AbstractFontAwesomeTwigExtension.fontAwesomeListIcon | protected function fontAwesomeListIcon($icon, $content) {
$glyphicon = static::coreHTMLElement("span", $icon, ["class" => "fa-li"]);
$innerHTML = null !== $content ? $content : "";
return static::coreHTMLElement("li", $glyphicon . $innerHTML);
} | php | protected function fontAwesomeListIcon($icon, $content) {
$glyphicon = static::coreHTMLElement("span", $icon, ["class" => "fa-li"]);
$innerHTML = null !== $content ? $content : "";
return static::coreHTMLElement("li", $glyphicon . $innerHTML);
} | [
"protected",
"function",
"fontAwesomeListIcon",
"(",
"$",
"icon",
",",
"$",
"content",
")",
"{",
"$",
"glyphicon",
"=",
"static",
"::",
"coreHTMLElement",
"(",
"\"span\"",
",",
"$",
"icon",
",",
"[",
"\"class\"",
"=>",
"\"fa-li\"",
"]",
")",
";",
"$",
"i... | Displays a Font Awesome list icon.
@param string $icon The icon.
@param string $content The content.
@return string Returns the Font Awesome list icon. | [
"Displays",
"a",
"Font",
"Awesome",
"list",
"icon",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/AbstractFontAwesomeTwigExtension.php#L69-L75 | train |
webeweb/core-bundle | Command/UnzipAssetsCommand.php | UnzipAssetsCommand.displayFooter | protected function displayFooter(StyleInterface $io, $exitCode, $count) {
if (0 < $exitCode) {
$io->error("Some errors occurred while unzipping assets");
return;
}
if (0 === $count) {
$io->success("No assets were provided by any bundle");
return;
}
$io->success("All assets were successfully unzipped");
} | php | protected function displayFooter(StyleInterface $io, $exitCode, $count) {
if (0 < $exitCode) {
$io->error("Some errors occurred while unzipping assets");
return;
}
if (0 === $count) {
$io->success("No assets were provided by any bundle");
return;
}
$io->success("All assets were successfully unzipped");
} | [
"protected",
"function",
"displayFooter",
"(",
"StyleInterface",
"$",
"io",
",",
"$",
"exitCode",
",",
"$",
"count",
")",
"{",
"if",
"(",
"0",
"<",
"$",
"exitCode",
")",
"{",
"$",
"io",
"->",
"error",
"(",
"\"Some errors occurred while unzipping assets\"",
"... | Display the footer.
@param StyleInterface $io The I/O.
@param int $exitCode The exit code.
@param int $count The count.
@return void | [
"Display",
"the",
"footer",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Command/UnzipAssetsCommand.php#L66-L76 | train |
webeweb/core-bundle | Command/UnzipAssetsCommand.php | UnzipAssetsCommand.displayResult | protected function displayResult(StyleInterface $io, array $results) {
$exitCode = 0;
$rows = [];
$success = $this->getCheckbox(true);
$warning = $this->getCheckbox(false);
// Handle each result.
foreach ($results as $bundle => $assets) {
foreach ($assets as $asset => $result) {
$rows[] = [
true === $result ? $success : $warning,
$bundle,
basename($asset),
];
$exitCode += true === $result ? 0 : 1;
}
}
// Displays a table.
$io->table(["", "Bundle", "Asset"], $rows);
return $exitCode;
} | php | protected function displayResult(StyleInterface $io, array $results) {
$exitCode = 0;
$rows = [];
$success = $this->getCheckbox(true);
$warning = $this->getCheckbox(false);
// Handle each result.
foreach ($results as $bundle => $assets) {
foreach ($assets as $asset => $result) {
$rows[] = [
true === $result ? $success : $warning,
$bundle,
basename($asset),
];
$exitCode += true === $result ? 0 : 1;
}
}
// Displays a table.
$io->table(["", "Bundle", "Asset"], $rows);
return $exitCode;
} | [
"protected",
"function",
"displayResult",
"(",
"StyleInterface",
"$",
"io",
",",
"array",
"$",
"results",
")",
"{",
"$",
"exitCode",
"=",
"0",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"getCheckbox",
"(",
"true",
"... | Displays the result.
@param StyleInterface $io The I/O.
@param array $results The results.
@return int Returns the exit code. | [
"Displays",
"the",
"result",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Command/UnzipAssetsCommand.php#L97-L124 | train |
phptuts/StarterBundleForSymfony | src/Security/Guard/StateLess/AbstractStateLessGuard.php | AbstractStateLessGuard.supports | public function supports(Request $request)
{
return !empty($request->headers->get(self::AUTHORIZATION_HEADER)) || !empty($request->cookies->get(AuthResponseService::AUTH_COOKIE));
} | php | public function supports(Request $request)
{
return !empty($request->headers->get(self::AUTHORIZATION_HEADER)) || !empty($request->cookies->get(AuthResponseService::AUTH_COOKIE));
} | [
"public",
"function",
"supports",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"self",
"::",
"AUTHORIZATION_HEADER",
")",
")",
"||",
"!",
"empty",
"(",
"$",
"request",
"->",
"... | 1) Returns true if the guard
@param Request $request
@return bool | [
"1",
")",
"Returns",
"true",
"if",
"the",
"guard"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/StateLess/AbstractStateLessGuard.php#L50-L53 | train |
phptuts/StarterBundleForSymfony | src/Security/Guard/StateLess/AbstractStateLessGuard.php | AbstractStateLessGuard.getCredentials | public function getCredentials(Request $request)
{
$token = !empty($request->headers->get(self::AUTHORIZATION_HEADER)) ?
$request->headers->get(self::AUTHORIZATION_HEADER) :
$request->cookies->get(AuthResponseService::AUTH_COOKIE);
return new CredentialTokenModel(str_replace(self::BEARER, '', $token));
} | php | public function getCredentials(Request $request)
{
$token = !empty($request->headers->get(self::AUTHORIZATION_HEADER)) ?
$request->headers->get(self::AUTHORIZATION_HEADER) :
$request->cookies->get(AuthResponseService::AUTH_COOKIE);
return new CredentialTokenModel(str_replace(self::BEARER, '', $token));
} | [
"public",
"function",
"getCredentials",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"token",
"=",
"!",
"empty",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"self",
"::",
"AUTHORIZATION_HEADER",
")",
")",
"?",
"$",
"request",
"->",
"headers... | 2) Gets the token from header and creates a CredentialToken Model
@param Request $request
@return null|CredentialTokenModel | [
"2",
")",
"Gets",
"the",
"token",
"from",
"header",
"and",
"creates",
"a",
"CredentialToken",
"Model"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Guard/StateLess/AbstractStateLessGuard.php#L61-L68 | train |
reliv/Rcm | admin/src/Controller/AdminPanelController.php | AdminPanelController.getAdminWrapperAction | public function getAdminWrapperAction()
{
$allowed = $this->cmsPermissionChecks->siteAdminCheck($this->currentSite);
if (!$allowed) {
return null;
}
/** @var RouteMatch $routeMatch */
$routeMatch = $this->getEvent()->getRouteMatch();
$siteId = $this->currentSite->getSiteId();
$sourcePageName = $routeMatch->getParam('page', 'index');
if ($sourcePageName instanceof Page) {
$sourcePageName = $sourcePageName->getName();
}
$pageType = $routeMatch->getParam('pageType', 'n');
$view = new ViewModel();
$view->setVariable('restrictions', false);
if ($this->cmsPermissionChecks->isPageRestricted($siteId, $pageType, $sourcePageName, 'read') == true) {
$view->setVariable('restrictions', true);
}
$view->setVariable('adminMenu', $this->adminPanelConfig);
$view->setTemplate('rcm-admin/admin/admin');
return $view;
} | php | public function getAdminWrapperAction()
{
$allowed = $this->cmsPermissionChecks->siteAdminCheck($this->currentSite);
if (!$allowed) {
return null;
}
/** @var RouteMatch $routeMatch */
$routeMatch = $this->getEvent()->getRouteMatch();
$siteId = $this->currentSite->getSiteId();
$sourcePageName = $routeMatch->getParam('page', 'index');
if ($sourcePageName instanceof Page) {
$sourcePageName = $sourcePageName->getName();
}
$pageType = $routeMatch->getParam('pageType', 'n');
$view = new ViewModel();
$view->setVariable('restrictions', false);
if ($this->cmsPermissionChecks->isPageRestricted($siteId, $pageType, $sourcePageName, 'read') == true) {
$view->setVariable('restrictions', true);
}
$view->setVariable('adminMenu', $this->adminPanelConfig);
$view->setTemplate('rcm-admin/admin/admin');
return $view;
} | [
"public",
"function",
"getAdminWrapperAction",
"(",
")",
"{",
"$",
"allowed",
"=",
"$",
"this",
"->",
"cmsPermissionChecks",
"->",
"siteAdminCheck",
"(",
"$",
"this",
"->",
"currentSite",
")",
";",
"if",
"(",
"!",
"$",
"allowed",
")",
"{",
"return",
"null"... | Get the Admin Menu Bar
@return mixed | [
"Get",
"the",
"Admin",
"Menu",
"Bar"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/admin/src/Controller/AdminPanelController.php#L63-L92 | train |
reliv/Rcm | core/src/Entity/Page.php | Page.setName | public function setName($name)
{
$name = strtolower($name);
//Check for everything except letters and dashes. Throw exception if any are found.
if (preg_match("/[^a-z\-0-9\.]/", $name)) {
throw new InvalidArgumentException(
'Page names can only contain letters, numbers, dots, and dashes.'
. ' No spaces. This page name is invalid: ' . $name
);
}
$this->name = $name;
} | php | public function setName($name)
{
$name = strtolower($name);
//Check for everything except letters and dashes. Throw exception if any are found.
if (preg_match("/[^a-z\-0-9\.]/", $name)) {
throw new InvalidArgumentException(
'Page names can only contain letters, numbers, dots, and dashes.'
. ' No spaces. This page name is invalid: ' . $name
);
}
$this->name = $name;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"//Check for everything except letters and dashes. Throw exception if any are found.",
"if",
"(",
"preg_match",
"(",
"\"/[^a-z\\-0-9\\.]/\"",
",",
... | Sets the Name property
@param string $name Name of Page. Should be URL friendly and should not
included spaces.
@return void
@throws InvalidArgumentException Exception thrown if name contains spaces. | [
"Sets",
"the",
"Name",
"property"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Page.php#L339-L352 | train |
reliv/Rcm | core/src/Entity/Page.php | Page.setParent | public function setParent(Page $parent)
{
$this->parent = $parent;
$this->parentId = $parent->getPageId();
} | php | public function setParent(Page $parent)
{
$this->parent = $parent;
$this->parentId = $parent->getPageId();
} | [
"public",
"function",
"setParent",
"(",
"Page",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"parent",
"=",
"$",
"parent",
";",
"$",
"this",
"->",
"parentId",
"=",
"$",
"parent",
"->",
"getPageId",
"(",
")",
";",
"}"
] | Set the parent page. Used to generate breadcrumbs or navigation
@param Page $parent Parent Page Entity
@return void | [
"Set",
"the",
"parent",
"page",
".",
"Used",
"to",
"generate",
"breadcrumbs",
"or",
"navigation"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Page.php#L529-L534 | train |
dadajuice/zephyrus | src/Zephyrus/Application/Rule.php | Rule.isValid | public function isValid($value, array $fields = []): bool
{
$callback = new Callback($this->validation);
$arguments = $this->getFunctionArguments($callback->getReflection(), $value, $fields);
return $callback->executeArray($arguments);
} | php | public function isValid($value, array $fields = []): bool
{
$callback = new Callback($this->validation);
$arguments = $this->getFunctionArguments($callback->getReflection(), $value, $fields);
return $callback->executeArray($arguments);
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"callback",
"=",
"new",
"Callback",
"(",
"$",
"this",
"->",
"validation",
")",
";",
"$",
"arguments",
"=",
"$",
"this",
"->"... | Determines if the specified value matched the defined rule validation.
@param mixed $value
@param array $fields
@return bool | [
"Determines",
"if",
"the",
"specified",
"value",
"matched",
"the",
"defined",
"rule",
"validation",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Rule.php#L126-L131 | train |
lsv/rejseplan-php-api | src/Services/AbstractServiceCall.php | AbstractServiceCall.getRequest | public function getRequest(): RequestInterface
{
if (!$this->request) {
$this->resolveOptions();
$this->request = $this->createRequest();
}
return parent::getRequest();
} | php | public function getRequest(): RequestInterface
{
if (!$this->request) {
$this->resolveOptions();
$this->request = $this->createRequest();
}
return parent::getRequest();
} | [
"public",
"function",
"getRequest",
"(",
")",
":",
"RequestInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
")",
"{",
"$",
"this",
"->",
"resolveOptions",
"(",
")",
";",
"$",
"this",
"->",
"request",
"=",
"$",
"this",
"->",
"createRequest... | Get the request object. | [
"Get",
"the",
"request",
"object",
"."
] | f09add92e160f167a19ff2a290951d202d7ece67 | https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/AbstractServiceCall.php#L17-L25 | train |
lsv/rejseplan-php-api | src/Services/AbstractServiceCall.php | AbstractServiceCall.doCall | protected function doCall()
{
$this->resolveOptions();
$this->request = $this->createRequest();
$this->response = $this->client->send($this->request);
return $this->generateResponse($this->response);
} | php | protected function doCall()
{
$this->resolveOptions();
$this->request = $this->createRequest();
$this->response = $this->client->send($this->request);
return $this->generateResponse($this->response);
} | [
"protected",
"function",
"doCall",
"(",
")",
"{",
"$",
"this",
"->",
"resolveOptions",
"(",
")",
";",
"$",
"this",
"->",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
")",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"client... | Return the generated response.
@throws GuzzleException | [
"Return",
"the",
"generated",
"response",
"."
] | f09add92e160f167a19ff2a290951d202d7ece67 | https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/AbstractServiceCall.php#L44-L51 | train |
lsv/rejseplan-php-api | src/Services/AbstractServiceCall.php | AbstractServiceCall.resolveOptions | protected function resolveOptions(): void
{
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$this->options = $resolver->resolve($this->options);
} | php | protected function resolveOptions(): void
{
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$this->options = $resolver->resolve($this->options);
} | [
"protected",
"function",
"resolveOptions",
"(",
")",
":",
"void",
"{",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"this",
"->",
"configureOptions",
"(",
"$",
"resolver",
")",
";",
"$",
"this",
"->",
"options",
"=",
"$",
"resolver... | Resolve options. | [
"Resolve",
"options",
"."
] | f09add92e160f167a19ff2a290951d202d7ece67 | https://github.com/lsv/rejseplan-php-api/blob/f09add92e160f167a19ff2a290951d202d7ece67/src/Services/AbstractServiceCall.php#L56-L61 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.