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/Entity/Redirect.php | Redirect.setRedirectUrl | public function setRedirectUrl($redirectUrl)
{
if (!$this->getUrlValidator()->isValid($redirectUrl)) {
throw new InvalidArgumentException('URL provided is invalid');
}
$this->redirectUrl = $redirectUrl;
} | php | public function setRedirectUrl($redirectUrl)
{
if (!$this->getUrlValidator()->isValid($redirectUrl)) {
throw new InvalidArgumentException('URL provided is invalid');
}
$this->redirectUrl = $redirectUrl;
} | [
"public",
"function",
"setRedirectUrl",
"(",
"$",
"redirectUrl",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getUrlValidator",
"(",
")",
"->",
"isValid",
"(",
"$",
"redirectUrl",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'URL provide... | Set the Redirect URL
@param string $redirectUrl Redirect URL
@return void
@throws InvalidArgumentException | [
"Set",
"the",
"Redirect",
"URL"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Redirect.php#L187-L195 | train |
reliv/Rcm | core/src/Entity/Redirect.php | Redirect.setRequestUrl | public function setRequestUrl($requestUrl)
{
if (!$this->getUrlValidator()->isValid($requestUrl)) {
throw new InvalidArgumentException('URL provided is invalid');
}
$this->requestUrl = $requestUrl;
} | php | public function setRequestUrl($requestUrl)
{
if (!$this->getUrlValidator()->isValid($requestUrl)) {
throw new InvalidArgumentException('URL provided is invalid');
}
$this->requestUrl = $requestUrl;
} | [
"public",
"function",
"setRequestUrl",
"(",
"$",
"requestUrl",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getUrlValidator",
"(",
")",
"->",
"isValid",
"(",
"$",
"requestUrl",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'URL provided i... | Set the Request URL to redirect
@param string $requestUrl Request URL to redirect
@return void
@throws \Exception | [
"Set",
"the",
"Request",
"URL",
"to",
"redirect"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Redirect.php#L215-L222 | train |
reliv/Rcm | core/src/Entity/Redirect.php | Redirect.setSite | public function setSite($site)
{
if ($site === null) {
$this->siteId = null;
$this->site = null;
return;
}
$this->siteId = $site->getSiteId();
$this->site = $site;
} | php | public function setSite($site)
{
if ($site === null) {
$this->siteId = null;
$this->site = null;
return;
}
$this->siteId = $site->getSiteId();
$this->site = $site;
} | [
"public",
"function",
"setSite",
"(",
"$",
"site",
")",
"{",
"if",
"(",
"$",
"site",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"siteId",
"=",
"null",
";",
"$",
"this",
"->",
"site",
"=",
"null",
";",
"return",
";",
"}",
"$",
"this",
"->",
"si... | Set the Site the redirect belongs to
@param \Rcm\Entity\Site $site Site Entity
@return void | [
"Set",
"the",
"Site",
"the",
"redirect",
"belongs",
"to"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Entity/Redirect.php#L241-L252 | train |
dadajuice/zephyrus | src/Zephyrus/Application/Form.php | Form.removeMemorizedValue | public static function removeMemorizedValue($fieldId = null)
{
if (isset($_SESSION['_FIELDS'])) {
if (is_null($fieldId)) {
$_SESSION['_FIELDS'] = null;
unset($_SESSION['_FIELDS']);
} else {
unset($_SESSION['_FIELDS'][$fieldId]);
}
}
} | php | public static function removeMemorizedValue($fieldId = null)
{
if (isset($_SESSION['_FIELDS'])) {
if (is_null($fieldId)) {
$_SESSION['_FIELDS'] = null;
unset($_SESSION['_FIELDS']);
} else {
unset($_SESSION['_FIELDS'][$fieldId]);
}
}
} | [
"public",
"static",
"function",
"removeMemorizedValue",
"(",
"$",
"fieldId",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'_FIELDS'",
"]",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fieldId",
")",
")",
"{",
"$",
"_SESSI... | Removes the specified fieldId from memory or clears the entire memorized
fields if not set.
@param string $fieldId | [
"Removes",
"the",
"specified",
"fieldId",
"from",
"memory",
"or",
"clears",
"the",
"entire",
"memorized",
"fields",
"if",
"not",
"set",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Form.php#L59-L69 | train |
dadajuice/zephyrus | src/Zephyrus/Application/Form.php | Form.buildObject | public function buildObject($instance = null)
{
if (is_null($instance)) {
return (object) $this->fields;
}
foreach ($this->fields as $property => $value) {
$method = 'set' . ucwords($property);
if (is_callable([$instance, $method])) {
$instance->{$method}($value);
}
}
} | php | public function buildObject($instance = null)
{
if (is_null($instance)) {
return (object) $this->fields;
}
foreach ($this->fields as $property => $value) {
$method = 'set' . ucwords($property);
if (is_callable([$instance, $method])) {
$instance->{$method}($value);
}
}
} | [
"public",
"function",
"buildObject",
"(",
"$",
"instance",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"instance",
")",
")",
"{",
"return",
"(",
"object",
")",
"$",
"this",
"->",
"fields",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"fi... | Tries to set values to the specified object using available setter
methods.
@param object $instance | [
"Tries",
"to",
"set",
"values",
"to",
"the",
"specified",
"object",
"using",
"available",
"setter",
"methods",
"."
] | c5fc47d7ecd158adb451702f9486c0409d71d8b0 | https://github.com/dadajuice/zephyrus/blob/c5fc47d7ecd158adb451702f9486c0409d71d8b0/src/Zephyrus/Application/Form.php#L165-L176 | train |
phptuts/StarterBundleForSymfony | src/Security/Provider/SlackProvider.php | SlackProvider.loadUserByUsername | public function loadUserByUsername($username)
{
$slackUser = $this->client->getSlackUserFromOAuthCode($username);
if (!$slackUser->isValid()) {
throw new UsernameNotFoundException('No access token found.');
}
$user = $this->userService->findBySlackUserId($slackUser->getUserId());
if (!empty($user)) {
return $user;
}
$user = $this->userService->findUserByEmail($slackUser->getEmail());
if (!empty($user)) {
$user->setSlackUserId($slackUser->getUserId());
return $user;
}
return $this->registerUser($slackUser);
} | php | public function loadUserByUsername($username)
{
$slackUser = $this->client->getSlackUserFromOAuthCode($username);
if (!$slackUser->isValid()) {
throw new UsernameNotFoundException('No access token found.');
}
$user = $this->userService->findBySlackUserId($slackUser->getUserId());
if (!empty($user)) {
return $user;
}
$user = $this->userService->findUserByEmail($slackUser->getEmail());
if (!empty($user)) {
$user->setSlackUserId($slackUser->getUserId());
return $user;
}
return $this->registerUser($slackUser);
} | [
"public",
"function",
"loadUserByUsername",
"(",
"$",
"username",
")",
"{",
"$",
"slackUser",
"=",
"$",
"this",
"->",
"client",
"->",
"getSlackUserFromOAuthCode",
"(",
"$",
"username",
")",
";",
"if",
"(",
"!",
"$",
"slackUser",
"->",
"isValid",
"(",
")",
... | Fetches the user from slack
@param string $username
@return null|object|BaseUser | [
"Fetches",
"the",
"user",
"from",
"slack"
] | aa953fbafea512a0535ca20e94ecd7d318db1e13 | https://github.com/phptuts/StarterBundleForSymfony/blob/aa953fbafea512a0535ca20e94ecd7d318db1e13/src/Security/Provider/SlackProvider.php#L38-L61 | train |
webeweb/core-bundle | Twig/Extension/Plugin/MaterialDesignColorPaletteTwigExtension.php | MaterialDesignColorPaletteTwigExtension.materialDesignColorPaletteBackgroundFunction | public function materialDesignColorPaletteBackgroundFunction(array $args = []) {
return $this->materialDesignColorPalette("bg", ArrayHelper::get($args, "name"), ArrayHelper::get($args, "value"));
} | php | public function materialDesignColorPaletteBackgroundFunction(array $args = []) {
return $this->materialDesignColorPalette("bg", ArrayHelper::get($args, "name"), ArrayHelper::get($args, "value"));
} | [
"public",
"function",
"materialDesignColorPaletteBackgroundFunction",
"(",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"materialDesignColorPalette",
"(",
"\"bg\"",
",",
"ArrayHelper",
"::",
"get",
"(",
"$",
"args",
",",
"\"name\""... | Displays a Material Design Color Palette background.
@param array $args The arguments.
@return string Returns the Material Design Color Palette background. | [
"Displays",
"a",
"Material",
"Design",
"Color",
"Palette",
"background",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/MaterialDesignColorPaletteTwigExtension.php#L53-L55 | train |
webeweb/core-bundle | Twig/Extension/Plugin/MaterialDesignColorPaletteTwigExtension.php | MaterialDesignColorPaletteTwigExtension.materialDesignColorPaletteTextFunction | public function materialDesignColorPaletteTextFunction(array $args = []) {
return $this->materialDesignColorPalette("text", ArrayHelper::get($args, "name"), ArrayHelper::get($args, "value"));
} | php | public function materialDesignColorPaletteTextFunction(array $args = []) {
return $this->materialDesignColorPalette("text", ArrayHelper::get($args, "name"), ArrayHelper::get($args, "value"));
} | [
"public",
"function",
"materialDesignColorPaletteTextFunction",
"(",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"materialDesignColorPalette",
"(",
"\"text\"",
",",
"ArrayHelper",
"::",
"get",
"(",
"$",
"args",
",",
"\"name\"",
... | Displays a Material Design Color Palette text.
@param array $args The arguments.
@return string Returns the Material Design Color Palette text. | [
"Displays",
"a",
"Material",
"Design",
"Color",
"Palette",
"text",
"."
] | 2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5 | https://github.com/webeweb/core-bundle/blob/2c5b30798f7b0ffb23e65063d5e2f1ca8f35aed5/Twig/Extension/Plugin/MaterialDesignColorPaletteTwigExtension.php#L63-L65 | train |
ARCANEDEV/LaravelImpersonator | src/Guard/SessionGuard.php | SessionGuard.silentLogin | public function silentLogin(Authenticatable $user)
{
$this->updateSession($user->getAuthIdentifier());
$this->setUser($user);
} | php | public function silentLogin(Authenticatable $user)
{
$this->updateSession($user->getAuthIdentifier());
$this->setUser($user);
} | [
"public",
"function",
"silentLogin",
"(",
"Authenticatable",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"updateSession",
"(",
"$",
"user",
"->",
"getAuthIdentifier",
"(",
")",
")",
";",
"$",
"this",
"->",
"setUser",
"(",
"$",
"user",
")",
";",
"}"
] | Login the user into the app without firing the Login event.
@param \Illuminate\Contracts\Auth\Authenticatable $user | [
"Login",
"the",
"user",
"into",
"the",
"app",
"without",
"firing",
"the",
"Login",
"event",
"."
] | f72bc3f1bcd11530887b23f62a9975c6321efdf8 | https://github.com/ARCANEDEV/LaravelImpersonator/blob/f72bc3f1bcd11530887b23f62a9975c6321efdf8/src/Guard/SessionGuard.php#L24-L28 | train |
russsiq/bixbite | app/Http/Controllers/Admin/ArticlesController.php | ArticlesController.massUpdate | public function massUpdate(ArticlesRequest $request)
{
$this->authorize('otherUpdate', $this->model);
$articles = $this->model->whereIn('id', $request->articles);
$messages = [];
switch ($request->mass_action) {
case 'published':
if (! $articles->update(['state' => 'published'])) {
$messages[] = 'unable to published';
}
break;
case 'unpublished':
if (! $articles->update(['state' => 'unpublished'])) {
$messages[] = 'unable to unpublished';
}
break;
case 'draft':
if (! $articles->update(['state' => 'draft'])) {
$messages[] = 'unable to draft';
}
break;
case 'on_mainpage':
if (! $articles->update(['on_mainpage' => 1])) {
$messages[] = 'unable to mainpage';
}
break;
case 'not_on_mainpage':
if (! $articles->update(['on_mainpage' => 0])) {
$messages[] = 'unable to not_on_mainpage';
}
break;
case 'allow_com':
if (! $articles->update(['allow_com' => 1])) {
$messages[] = 'unable to allow_com';
}
break;
case 'disallow_com':
if (! $articles->update(['allow_com' => 0])) {
$messages[] = 'unable to disallow_com';
}
break;
case 'currdate':
$articles->timestamps = false;
if (! $articles->update(['created_at' => date('Y-m-d H:i:s'), 'updated_at' => null])) {
$messages[] = 'unable to currdate';
}
$articles->timestamps = true;
break;
case 'delete':
if (! $articles->get()->each->delete()) {
$messages[] = 'unable to delete';
}
break;
case 'delete_drafts':
if (! $articles->where('state', 'draft')->get()->each->delete()) {
$messages[] = 'unable to delete_drafts';
}
break;
}
$message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';
return $this->makeRedirect(true, 'admin.articles.index', $message);
} | php | public function massUpdate(ArticlesRequest $request)
{
$this->authorize('otherUpdate', $this->model);
$articles = $this->model->whereIn('id', $request->articles);
$messages = [];
switch ($request->mass_action) {
case 'published':
if (! $articles->update(['state' => 'published'])) {
$messages[] = 'unable to published';
}
break;
case 'unpublished':
if (! $articles->update(['state' => 'unpublished'])) {
$messages[] = 'unable to unpublished';
}
break;
case 'draft':
if (! $articles->update(['state' => 'draft'])) {
$messages[] = 'unable to draft';
}
break;
case 'on_mainpage':
if (! $articles->update(['on_mainpage' => 1])) {
$messages[] = 'unable to mainpage';
}
break;
case 'not_on_mainpage':
if (! $articles->update(['on_mainpage' => 0])) {
$messages[] = 'unable to not_on_mainpage';
}
break;
case 'allow_com':
if (! $articles->update(['allow_com' => 1])) {
$messages[] = 'unable to allow_com';
}
break;
case 'disallow_com':
if (! $articles->update(['allow_com' => 0])) {
$messages[] = 'unable to disallow_com';
}
break;
case 'currdate':
$articles->timestamps = false;
if (! $articles->update(['created_at' => date('Y-m-d H:i:s'), 'updated_at' => null])) {
$messages[] = 'unable to currdate';
}
$articles->timestamps = true;
break;
case 'delete':
if (! $articles->get()->each->delete()) {
$messages[] = 'unable to delete';
}
break;
case 'delete_drafts':
if (! $articles->where('state', 'draft')->get()->each->delete()) {
$messages[] = 'unable to delete_drafts';
}
break;
}
$message = empty($messages) ? 'msg.complete' : 'msg.complete_but_null';
return $this->makeRedirect(true, 'admin.articles.index', $message);
} | [
"public",
"function",
"massUpdate",
"(",
"ArticlesRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'otherUpdate'",
",",
"$",
"this",
"->",
"model",
")",
";",
"$",
"articles",
"=",
"$",
"this",
"->",
"model",
"->",
"whereIn",
"(",... | Mass updates to Article.
@param \BBCMS\Http\Requests\Admin\ArticlesRequest $request
@param \BBCMS\Models\Article $articles
@return \Illuminate\Http\Response | [
"Mass",
"updates",
"to",
"Article",
"."
] | f7d9dcdc81c1803406bf7b9374887578f10f9c08 | https://github.com/russsiq/bixbite/blob/f7d9dcdc81c1803406bf7b9374887578f10f9c08/app/Http/Controllers/Admin/ArticlesController.php#L141-L206 | train |
GoIntegro/hateoas | Util/RepositoryHelper.php | RepositoryHelper.findByRequestParams | public function findByRequestParams(Request\Params $params)
{
if (empty($params->pagination) &&
isset($params->resourceConfig) &&
isset($params->resourceConfig->defaults) &&
isset($params->resourceConfig->defaults->pagination) &&
!$params->resourceConfig->defaults->pagination
) {
return $this->findAll(
$params->primaryClass,
$params->filters,
$params->sorting,
$params->translatable
);
} else {
return $this->findPaginated(
$params->primaryClass,
$params->filters,
$params->sorting,
$params->getPageOffset(),
$params->getPageSize(),
$params->translatable
);
}
} | php | public function findByRequestParams(Request\Params $params)
{
if (empty($params->pagination) &&
isset($params->resourceConfig) &&
isset($params->resourceConfig->defaults) &&
isset($params->resourceConfig->defaults->pagination) &&
!$params->resourceConfig->defaults->pagination
) {
return $this->findAll(
$params->primaryClass,
$params->filters,
$params->sorting,
$params->translatable
);
} else {
return $this->findPaginated(
$params->primaryClass,
$params->filters,
$params->sorting,
$params->getPageOffset(),
$params->getPageSize(),
$params->translatable
);
}
} | [
"public",
"function",
"findByRequestParams",
"(",
"Request",
"\\",
"Params",
"$",
"params",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"params",
"->",
"pagination",
")",
"&&",
"isset",
"(",
"$",
"params",
"->",
"resourceConfig",
")",
"&&",
"isset",
"(",
"$"... | Helper method to paginate a query using the HATEOAS request parameters.
@param Request\Params $request
@return ArrayCollection|PaginatedCollection | [
"Helper",
"method",
"to",
"paginate",
"a",
"query",
"using",
"the",
"HATEOAS",
"request",
"parameters",
"."
] | 4799794294079f8bd3839e76175134219f876105 | https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Util/RepositoryHelper.php#L52-L76 | train |
GoIntegro/hateoas | Util/RepositoryHelper.php | RepositoryHelper.findPaginated | public function findPaginated(
$entityClass,
array $criteria,
$sorting = [],
$offset = Request\Params::DEFAULT_PAGE_OFFSET,
$limit = Request\Params::DEFAULT_PAGE_SIZE,
$translatable = false
)
{
$qb = $this->getQueryBuilder($entityClass, $criteria, $sorting, $translatable);
$qb->setFirstResult($offset)
->setMaxResults($limit);
$paginator = new Paginator($qb->getQuery());
$collection = new PaginatedCollection($paginator);
return $collection;
} | php | public function findPaginated(
$entityClass,
array $criteria,
$sorting = [],
$offset = Request\Params::DEFAULT_PAGE_OFFSET,
$limit = Request\Params::DEFAULT_PAGE_SIZE,
$translatable = false
)
{
$qb = $this->getQueryBuilder($entityClass, $criteria, $sorting, $translatable);
$qb->setFirstResult($offset)
->setMaxResults($limit);
$paginator = new Paginator($qb->getQuery());
$collection = new PaginatedCollection($paginator);
return $collection;
} | [
"public",
"function",
"findPaginated",
"(",
"$",
"entityClass",
",",
"array",
"$",
"criteria",
",",
"$",
"sorting",
"=",
"[",
"]",
",",
"$",
"offset",
"=",
"Request",
"\\",
"Params",
"::",
"DEFAULT_PAGE_OFFSET",
",",
"$",
"limit",
"=",
"Request",
"\\",
"... | Helper method to paginate "find by" queries.
@param string $entityClass
@param array $criteria
@param array $sort
@param integer $offset
@param integer $limit
@param boolean $translatable
@return PaginatedCollection | [
"Helper",
"method",
"to",
"paginate",
"find",
"by",
"queries",
"."
] | 4799794294079f8bd3839e76175134219f876105 | https://github.com/GoIntegro/hateoas/blob/4799794294079f8bd3839e76175134219f876105/Util/RepositoryHelper.php#L149-L167 | train |
reliv/Rcm | core/src/Block/Renderer/RendererBc.php | RendererBc.getPluginController | public function getPluginController($pluginName)
{
/*
* Deprecated. All controllers should come from the controller manager
* now and not the service manager.
*
* @todo Remove if statement once plugins have been converted.
*/
if ($this->serviceManager->has($pluginName)) {
$serviceManager = $this->serviceManager;
} else {
$serviceManager = $this->serviceManager->get('ControllerLoader');
}
if (!$serviceManager->has($pluginName)) {
throw new InvalidPluginException(
"Plugin $pluginName is not loaded or configured. Check
config/application.config.php"
);
}
$pluginController = $serviceManager->get($pluginName);
//Plugin controllers must implement this interface
if (!$pluginController instanceof PluginInterface) {
throw new InvalidPluginException(
'Class "' . get_class($pluginController) . '" for plugin "'
. $pluginName . '" does not implement '
. '\Rcm\Plugin\PluginInterface'
);
}
return $pluginController;
} | php | public function getPluginController($pluginName)
{
/*
* Deprecated. All controllers should come from the controller manager
* now and not the service manager.
*
* @todo Remove if statement once plugins have been converted.
*/
if ($this->serviceManager->has($pluginName)) {
$serviceManager = $this->serviceManager;
} else {
$serviceManager = $this->serviceManager->get('ControllerLoader');
}
if (!$serviceManager->has($pluginName)) {
throw new InvalidPluginException(
"Plugin $pluginName is not loaded or configured. Check
config/application.config.php"
);
}
$pluginController = $serviceManager->get($pluginName);
//Plugin controllers must implement this interface
if (!$pluginController instanceof PluginInterface) {
throw new InvalidPluginException(
'Class "' . get_class($pluginController) . '" for plugin "'
. $pluginName . '" does not implement '
. '\Rcm\Plugin\PluginInterface'
);
}
return $pluginController;
} | [
"public",
"function",
"getPluginController",
"(",
"$",
"pluginName",
")",
"{",
"/*\n * Deprecated. All controllers should come from the controller manager\n * now and not the service manager.\n *\n * @todo Remove if statement once plugins have been converted.\n ... | Get an instantiated plugin controller
@param string $pluginName Plugin Name
@return PluginInterface
@throws \Rcm\Exception\InvalidPluginException
@throws \Rcm\Exception\RuntimeException | [
"Get",
"an",
"instantiated",
"plugin",
"controller"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Block/Renderer/RendererBc.php#L114-L147 | train |
reliv/Rcm | core/src/Block/Renderer/RendererBc.php | RendererBc.handleResponseFromPluginController | public function handleResponseFromPluginController(ResponseInterface $response, $blockInstanceName)
{
// trigger_error( //@TODO remove all this and throw exception
// 'Returning responses from plugin controllers is no longer supported.
// The following plugin attempted this: ' . $blockInstanceName .
// ' Post to your own route to avoid this problem.',
// E_USER_WARNING
// );
foreach ($response->getHeaders() as $header) {
header($header->toString());
}
// //Some plugins used to return responses like this to signal a redirect to the login page
// if ($response->getStatusCode() == 401) {
// $href = '/login?redirect=' . urlencode($request->getUri()->getPath());;
// echo "You are not authorized to view this page. Try <a href=\"{$href}\">logging in</a> first.";
// exit;
// }
echo $response->getContent();
exit;
} | php | public function handleResponseFromPluginController(ResponseInterface $response, $blockInstanceName)
{
// trigger_error( //@TODO remove all this and throw exception
// 'Returning responses from plugin controllers is no longer supported.
// The following plugin attempted this: ' . $blockInstanceName .
// ' Post to your own route to avoid this problem.',
// E_USER_WARNING
// );
foreach ($response->getHeaders() as $header) {
header($header->toString());
}
// //Some plugins used to return responses like this to signal a redirect to the login page
// if ($response->getStatusCode() == 401) {
// $href = '/login?redirect=' . urlencode($request->getUri()->getPath());;
// echo "You are not authorized to view this page. Try <a href=\"{$href}\">logging in</a> first.";
// exit;
// }
echo $response->getContent();
exit;
} | [
"public",
"function",
"handleResponseFromPluginController",
"(",
"ResponseInterface",
"$",
"response",
",",
"$",
"blockInstanceName",
")",
"{",
"// trigger_error( //@TODO remove all this and throw exception",
"// 'Returning responses from plugin controllers is no longer s... | Handles the legacy support for the odd case where plugin controllers return
zf2 responses instead of view models | [
"Handles",
"the",
"legacy",
"support",
"for",
"the",
"odd",
"case",
"where",
"plugin",
"controllers",
"return",
"zf2",
"responses",
"instead",
"of",
"view",
"models"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Block/Renderer/RendererBc.php#L153-L175 | train |
reliv/Rcm | core/src/Repository/Container.php | Container.getRevisionDbInfo | public function getRevisionDbInfo($siteId, $name, $revisionId)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder()
->select(
'container,'
. 'publishedRevision.revisionId,'
. 'revision,'
. 'pluginWrappers,'
. 'pluginInstances'
)
->from(\Rcm\Entity\Container::class, 'container')
->leftJoin('container.publishedRevision', 'publishedRevision')
->leftJoin('container.site', 'site')
->leftJoin('container.revisions', 'revision')
->leftJoin('revision.pluginWrappers', 'pluginWrappers')
->leftJoin('pluginWrappers.instance', 'pluginInstances')
->where('site.siteId = :siteId')
->andWhere('container.name = :containerName')
->andWhere('revision.revisionId = :revisionId')
->orderBy('pluginWrappers.renderOrder', 'ASC')
->setParameter('siteId', $siteId)
->setParameter('containerName', $name)
->setParameter('revisionId', $revisionId);
$getData = $queryBuilder->getQuery()->getSingleResult(
Query::HYDRATE_ARRAY
);
$result = null;
if (!empty($getData)) {
$result = $getData[0];
$result['revision'] = $result['revisions'][$revisionId];
unset($result['revisions'], $getData);
}
return $result;
} | php | public function getRevisionDbInfo($siteId, $name, $revisionId)
{
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
$queryBuilder = $this->_em->createQueryBuilder()
->select(
'container,'
. 'publishedRevision.revisionId,'
. 'revision,'
. 'pluginWrappers,'
. 'pluginInstances'
)
->from(\Rcm\Entity\Container::class, 'container')
->leftJoin('container.publishedRevision', 'publishedRevision')
->leftJoin('container.site', 'site')
->leftJoin('container.revisions', 'revision')
->leftJoin('revision.pluginWrappers', 'pluginWrappers')
->leftJoin('pluginWrappers.instance', 'pluginInstances')
->where('site.siteId = :siteId')
->andWhere('container.name = :containerName')
->andWhere('revision.revisionId = :revisionId')
->orderBy('pluginWrappers.renderOrder', 'ASC')
->setParameter('siteId', $siteId)
->setParameter('containerName', $name)
->setParameter('revisionId', $revisionId);
$getData = $queryBuilder->getQuery()->getSingleResult(
Query::HYDRATE_ARRAY
);
$result = null;
if (!empty($getData)) {
$result = $getData[0];
$result['revision'] = $result['revisions'][$revisionId];
unset($result['revisions'], $getData);
}
return $result;
} | [
"public",
"function",
"getRevisionDbInfo",
"(",
"$",
"siteId",
",",
"$",
"name",
",",
"$",
"revisionId",
")",
"{",
"/** @var \\Doctrine\\ORM\\QueryBuilder $queryBuilder */",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"_em",
"->",
"createQueryBuilder",
"(",
")",
... | Get Revision DB Info
@param integer $siteId Site Id
@param string $name Page Name
@param string $revisionId Revision Id
@return null|array Database Result Set | [
"Get",
"Revision",
"DB",
"Info"
] | 18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb | https://github.com/reliv/Rcm/blob/18d3c2b0def3ade609c9f8d9ea45a8318ceac8bb/core/src/Repository/Container.php#L80-L118 | train |
opichon/UAMDatatablesBundle | Propel/EntityManagerTrait.php | EntityManagerTrait.getFilters | protected function getFilters(Request $request)
{
$type = $this->getFilterType($request);
if (!$type) {
return $request->query->get('search')['value'];
}
$filter = new $type();
$param = $filter->getBlockPrefix();
return $request->query->get($param);
} | php | protected function getFilters(Request $request)
{
$type = $this->getFilterType($request);
if (!$type) {
return $request->query->get('search')['value'];
}
$filter = new $type();
$param = $filter->getBlockPrefix();
return $request->query->get($param);
} | [
"protected",
"function",
"getFilters",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getFilterType",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"return",
"$",
"request",
"->",
"query",
"->"... | Extracts the filters from the request's query parameters.
@param Request $request the current request
@return Array the query parameters containng the filters | [
"Extracts",
"the",
"filters",
"from",
"the",
"request",
"s",
"query",
"parameters",
"."
] | 48a3fcee4d768837b568c3753527c47f57422dca | https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Propel/EntityManagerTrait.php#L146-L159 | train |
opichon/UAMDatatablesBundle | Propel/EntityManagerTrait.php | EntityManagerTrait.getLimit | protected function getLimit(Request $request)
{
return min(
$this->getMaxLimit($request),
$request->query->get(
'length',
$this->getDefaultLimit($request)
)
);
} | php | protected function getLimit(Request $request)
{
return min(
$this->getMaxLimit($request),
$request->query->get(
'length',
$this->getDefaultLimit($request)
)
);
} | [
"protected",
"function",
"getLimit",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"min",
"(",
"$",
"this",
"->",
"getMaxLimit",
"(",
"$",
"request",
")",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'length'",
",",
"$",
"this",
"->",
... | Defines the limit for the Propel query.
@param Request $request the current request
@return int the propel query limit | [
"Defines",
"the",
"limit",
"for",
"the",
"Propel",
"query",
"."
] | 48a3fcee4d768837b568c3753527c47f57422dca | https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Propel/EntityManagerTrait.php#L168-L177 | train |
opichon/UAMDatatablesBundle | Propel/EntityManagerTrait.php | EntityManagerTrait.getOffset | protected function getOffset(Request $request)
{
return max(
$request->query->get('start', 0),
$this->getDefaultOffset($request)
);
} | php | protected function getOffset(Request $request)
{
return max(
$request->query->get('start', 0),
$this->getDefaultOffset($request)
);
} | [
"protected",
"function",
"getOffset",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"max",
"(",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'start'",
",",
"0",
")",
",",
"$",
"this",
"->",
"getDefaultOffset",
"(",
"$",
"request",
")",
")",
... | Defines the offset for the Propel query.
@param Request $request the current request
@return int the propel query offset | [
"Defines",
"the",
"offset",
"for",
"the",
"Propel",
"query",
"."
] | 48a3fcee4d768837b568c3753527c47f57422dca | https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Propel/EntityManagerTrait.php#L185-L191 | train |
opichon/UAMDatatablesBundle | Propel/EntityManagerTrait.php | EntityManagerTrait.search | protected function search(ModelCriteria $query, Request $request)
{
$filters = $this->getFilters($request);
if (empty($filters)) {
return $query;
}
$conditions = array();
$columns = $this->getSearchColumns($request);
if (is_array($filters)) {
foreach ($columns as $name => $condition) {
$items = explode('.', $name);
$i = 0;
$values = $filters;
while (is_array($values) && array_key_exists($items[$i], $values)) {
$values = $values[$items[$i]];
$i++;
}
if (is_array($values)) {
continue;
} else {
$value = trim($values);
}
if (empty($value) && !is_numeric($value)) {
continue;
}
$query->condition(
'search_'.$name,
sprintf($condition, $value)
);
$conditions[] = 'search_'.$name;
}
if (!empty($conditions)) {
return $query->where($conditions, 'and');
}
} else {
$value = trim($filters);
foreach ($columns as $name => $condition) {
$query->condition(
'search_'.$name,
sprintf($condition, $value)
);
$conditions[] = 'search_'.$name;
}
if (!empty($conditions)) {
return $query->where($conditions, 'or');
}
}
} | php | protected function search(ModelCriteria $query, Request $request)
{
$filters = $this->getFilters($request);
if (empty($filters)) {
return $query;
}
$conditions = array();
$columns = $this->getSearchColumns($request);
if (is_array($filters)) {
foreach ($columns as $name => $condition) {
$items = explode('.', $name);
$i = 0;
$values = $filters;
while (is_array($values) && array_key_exists($items[$i], $values)) {
$values = $values[$items[$i]];
$i++;
}
if (is_array($values)) {
continue;
} else {
$value = trim($values);
}
if (empty($value) && !is_numeric($value)) {
continue;
}
$query->condition(
'search_'.$name,
sprintf($condition, $value)
);
$conditions[] = 'search_'.$name;
}
if (!empty($conditions)) {
return $query->where($conditions, 'and');
}
} else {
$value = trim($filters);
foreach ($columns as $name => $condition) {
$query->condition(
'search_'.$name,
sprintf($condition, $value)
);
$conditions[] = 'search_'.$name;
}
if (!empty($conditions)) {
return $query->where($conditions, 'or');
}
}
} | [
"protected",
"function",
"search",
"(",
"ModelCriteria",
"$",
"query",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"filters",
"=",
"$",
"this",
"->",
"getFilters",
"(",
"$",
"request",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"filters",
")",
")",
"... | Filters the database records. This method should be considered final for
all practical purposes.
@param ModelCriteria $query the Propel query
@param Request $request the current request | [
"Filters",
"the",
"database",
"records",
".",
"This",
"method",
"should",
"be",
"considered",
"final",
"for",
"all",
"practical",
"purposes",
"."
] | 48a3fcee4d768837b568c3753527c47f57422dca | https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Propel/EntityManagerTrait.php#L248-L308 | train |
opichon/UAMDatatablesBundle | Propel/EntityManagerTrait.php | EntityManagerTrait.sort | protected function sort(ModelCriteria $query, Request $request)
{
$order = $this->getSortOrder($request);
foreach ($order as $setting) {
$column = $setting[0];
$direction = $setting[1];
$query->orderBy($column, $direction);
}
return $query;
} | php | protected function sort(ModelCriteria $query, Request $request)
{
$order = $this->getSortOrder($request);
foreach ($order as $setting) {
$column = $setting[0];
$direction = $setting[1];
$query->orderBy($column, $direction);
}
return $query;
} | [
"protected",
"function",
"sort",
"(",
"ModelCriteria",
"$",
"query",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"order",
"=",
"$",
"this",
"->",
"getSortOrder",
"(",
"$",
"request",
")",
";",
"foreach",
"(",
"$",
"order",
"as",
"$",
"setting",
")",... | Sorts the database records. This method should be considered final for
all practical purposes.
@param ModelCriteria $query the Propel query
@param Request $request the current request
@return ModelCriteria the Propel query | [
"Sorts",
"the",
"database",
"records",
".",
"This",
"method",
"should",
"be",
"considered",
"final",
"for",
"all",
"practical",
"purposes",
"."
] | 48a3fcee4d768837b568c3753527c47f57422dca | https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Propel/EntityManagerTrait.php#L318-L329 | train |
opichon/UAMDatatablesBundle | Propel/EntityManagerTrait.php | EntityManagerTrait.getSortOrder | protected function getSortOrder(Request $request)
{
$sort = array();
$order = $request->query->get('order', array());
$columns = $this->getSortColumns($request);
foreach ($order as $setting) {
$index = $setting['column'];
if (array_key_exists($index, $columns)) {
$column = $columns[$index];
if (!is_array($column)) {
$column = array($column);
}
foreach ($column as $c) {
$sort[] = array(
$c,
$setting['dir'],
);
}
}
}
// Default sort order
if (empty($sort)) {
$sort = $this->getDefaultSortOrder($request);
}
return $sort;
} | php | protected function getSortOrder(Request $request)
{
$sort = array();
$order = $request->query->get('order', array());
$columns = $this->getSortColumns($request);
foreach ($order as $setting) {
$index = $setting['column'];
if (array_key_exists($index, $columns)) {
$column = $columns[$index];
if (!is_array($column)) {
$column = array($column);
}
foreach ($column as $c) {
$sort[] = array(
$c,
$setting['dir'],
);
}
}
}
// Default sort order
if (empty($sort)) {
$sort = $this->getDefaultSortOrder($request);
}
return $sort;
} | [
"protected",
"function",
"getSortOrder",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"sort",
"=",
"array",
"(",
")",
";",
"$",
"order",
"=",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'order'",
",",
"array",
"(",
")",
")",
";",
"$",
"colu... | Computes the sort order. This method should be considered final for
all practical purposes.
@param Request $request the current request
@return Array the sort order | [
"Computes",
"the",
"sort",
"order",
".",
"This",
"method",
"should",
"be",
"considered",
"final",
"for",
"all",
"practical",
"purposes",
"."
] | 48a3fcee4d768837b568c3753527c47f57422dca | https://github.com/opichon/UAMDatatablesBundle/blob/48a3fcee4d768837b568c3753527c47f57422dca/Propel/EntityManagerTrait.php#L338-L371 | train |
BlackBonjour/stdlib | src/Util/HashMap.php | HashMap.sort | public function sort(callable $callback, bool $keySort = false): self
{
$keys = $this->keys;
$values = $this->values;
if ($keySort) {
uasort($keys, $callback);
$values = array_replace($keys, $values);
} else {
uasort($values, $callback);
$keys = array_replace($values, $keys);
}
$this->keys = array_values($keys);
$this->values = array_values($values);
return $this;
} | php | public function sort(callable $callback, bool $keySort = false): self
{
$keys = $this->keys;
$values = $this->values;
if ($keySort) {
uasort($keys, $callback);
$values = array_replace($keys, $values);
} else {
uasort($values, $callback);
$keys = array_replace($values, $keys);
}
$this->keys = array_values($keys);
$this->values = array_values($values);
return $this;
} | [
"public",
"function",
"sort",
"(",
"callable",
"$",
"callback",
",",
"bool",
"$",
"keySort",
"=",
"false",
")",
":",
"self",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"keys",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"values",
";",
"if",
"(",
"... | Sorts this hash map using retrieved callback
@param callable $callback
@param boolean $keySort
@return static | [
"Sorts",
"this",
"hash",
"map",
"using",
"retrieved",
"callback"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Util/HashMap.php#L218-L235 | train |
BlackBonjour/stdlib | src/Util/HashMap.php | HashMap.stringifyArrayKey | private static function stringifyArrayKey(array $key): string
{
ksort($key);
foreach ($key as &$value) {
if (is_array($value)) {
$value = self::stringifyArrayKey($value);
} elseif (is_object($value)) {
$value = self::stringifyKey($value);
}
}
return json_encode($key);
} | php | private static function stringifyArrayKey(array $key): string
{
ksort($key);
foreach ($key as &$value) {
if (is_array($value)) {
$value = self::stringifyArrayKey($value);
} elseif (is_object($value)) {
$value = self::stringifyKey($value);
}
}
return json_encode($key);
} | [
"private",
"static",
"function",
"stringifyArrayKey",
"(",
"array",
"$",
"key",
")",
":",
"string",
"{",
"ksort",
"(",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"key",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")... | Calculates string representing specified array key
@param array $key
@return string | [
"Calculates",
"string",
"representing",
"specified",
"array",
"key"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Util/HashMap.php#L251-L264 | train |
BlackBonjour/stdlib | src/Util/HashMap.php | HashMap.stringifyKey | private static function stringifyKey($key): string
{
if ($key === null || is_scalar($key)) {
return (string) $key;
}
if (is_object($key)) {
return spl_object_hash($key);
}
return static::stringifyArrayKey($key);
} | php | private static function stringifyKey($key): string
{
if ($key === null || is_scalar($key)) {
return (string) $key;
}
if (is_object($key)) {
return spl_object_hash($key);
}
return static::stringifyArrayKey($key);
} | [
"private",
"static",
"function",
"stringifyKey",
"(",
"$",
"key",
")",
":",
"string",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
"||",
"is_scalar",
"(",
"$",
"key",
")",
")",
"{",
"return",
"(",
"string",
")",
"$",
"key",
";",
"}",
"if",
"(",
"is... | Calculates string representing specified key
@param mixed $key
@return string | [
"Calculates",
"string",
"representing",
"specified",
"key"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Util/HashMap.php#L272-L283 | train |
VitexSoftware/Ease-PHP-Bricks | src/Ease/ui/MainPageMenu.php | MainPageMenu.addMenuItem | public function addMenuItem($image, $title, $url)
{
return $this->row->addItem(
new \Ease\Html\ATag(
$url,
new \Ease\TWB\Col(2,
"$title<center><img class=\"img-responsive\" src=\"$image\" alt=\"$title\"></center>")
)
);
} | php | public function addMenuItem($image, $title, $url)
{
return $this->row->addItem(
new \Ease\Html\ATag(
$url,
new \Ease\TWB\Col(2,
"$title<center><img class=\"img-responsive\" src=\"$image\" alt=\"$title\"></center>")
)
);
} | [
"public",
"function",
"addMenuItem",
"(",
"$",
"image",
",",
"$",
"title",
",",
"$",
"url",
")",
"{",
"return",
"$",
"this",
"->",
"row",
"->",
"addItem",
"(",
"new",
"\\",
"Ease",
"\\",
"Html",
"\\",
"ATag",
"(",
"$",
"url",
",",
"new",
"\\",
"E... | Add Item to mainpage Menu
@param string $image url
@param string $title caption
@param string $url image link href url
@return \Ease\Html\ATag | [
"Add",
"Item",
"to",
"mainpage",
"Menu"
] | e1616d1b1baebf99cdb7f3ce6d71369d709278a7 | https://github.com/VitexSoftware/Ease-PHP-Bricks/blob/e1616d1b1baebf99cdb7f3ce6d71369d709278a7/src/Ease/ui/MainPageMenu.php#L52-L61 | train |
byteark/byteark-sdk-php | lib/Signer/ByteArkV2UrlSigner.php | ByteArkV2UrlSigner.sign | public function sign($url, $expires = null, $options = [])
{
if (parse_url($url, PHP_URL_QUERY)) {
throw new \InvalidArgumentException('This signer do not accept URL with query string');
}
if (!$expires) {
$expires = time() + $this->options['default_age'];
}
return $url . '?' . $this->makeQueryString($this->makeQueryParams($url, $expires, $options));
} | php | public function sign($url, $expires = null, $options = [])
{
if (parse_url($url, PHP_URL_QUERY)) {
throw new \InvalidArgumentException('This signer do not accept URL with query string');
}
if (!$expires) {
$expires = time() + $this->options['default_age'];
}
return $url . '?' . $this->makeQueryString($this->makeQueryParams($url, $expires, $options));
} | [
"public",
"function",
"sign",
"(",
"$",
"url",
",",
"$",
"expires",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_QUERY",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentExcepti... | Create a new URL Signer instance.
Available signed URL options:
array['client_ip'] (Optional) Defines client IP that are allowed to access.
array['method'] (Optional) Defines HTTP method that allows to use (Default is 'GET').
array['user_agent'] (Optional) Defines user agent in header that are allowed to access.
@param string $url Original URL to sign
@param int $expires The time that signed URL should expires in Unix timestamp in seconds
@param array $options Signed URL options (See above)
@return string Signed URL | [
"Create",
"a",
"new",
"URL",
"Signer",
"instance",
"."
] | d0d22762e295fddad520e60b420c0c3d86922f4a | https://github.com/byteark/byteark-sdk-php/blob/d0d22762e295fddad520e60b420c0c3d86922f4a/lib/Signer/ByteArkV2UrlSigner.php#L49-L60 | train |
opis/view | src/ViewRenderer.php | ViewRenderer.getDispatcher | protected function getDispatcher(): IDispatcher
{
if ($this->dispatcher === null) {
$this->dispatcher = new Dispatcher();
}
return $this->dispatcher;
} | php | protected function getDispatcher(): IDispatcher
{
if ($this->dispatcher === null) {
$this->dispatcher = new Dispatcher();
}
return $this->dispatcher;
} | [
"protected",
"function",
"getDispatcher",
"(",
")",
":",
"IDispatcher",
"{",
"if",
"(",
"$",
"this",
"->",
"dispatcher",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"=",
"new",
"Dispatcher",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->"... | Get the dispatcher
@return IDispatcher | [
"Get",
"the",
"dispatcher"
] | 8aaee4d1de4372539db2bc3ed82063438426e311 | https://github.com/opis/view/blob/8aaee4d1de4372539db2bc3ed82063438426e311/src/ViewRenderer.php#L108-L115 | train |
opis/view | src/ViewRenderer.php | ViewRenderer.handle | public function handle(string $pattern, callable $resolver, int $priority = 0): Route
{
$this->cache = [];
return $this->collection->createRoute($pattern, $resolver)->set('priority', $priority);
} | php | public function handle(string $pattern, callable $resolver, int $priority = 0): Route
{
$this->cache = [];
return $this->collection->createRoute($pattern, $resolver)->set('priority', $priority);
} | [
"public",
"function",
"handle",
"(",
"string",
"$",
"pattern",
",",
"callable",
"$",
"resolver",
",",
"int",
"$",
"priority",
"=",
"0",
")",
":",
"Route",
"{",
"$",
"this",
"->",
"cache",
"=",
"[",
"]",
";",
"return",
"$",
"this",
"->",
"collection",... | Register a new view
@param string $pattern
@param callable $resolver
@param int $priority
@return Route | [
"Register",
"a",
"new",
"view"
] | 8aaee4d1de4372539db2bc3ed82063438426e311 | https://github.com/opis/view/blob/8aaee4d1de4372539db2bc3ed82063438426e311/src/ViewRenderer.php#L156-L160 | train |
opis/view | src/ViewRenderer.php | ViewRenderer.resolveViewName | public function resolveViewName(string $name): ?string
{
if (!array_key_exists($name, $this->cache)) {
$this->collection->sort();
$view = $this->getRouter()->route(new Context($name));
if (!is_string($view)) {
$view = null;
}
$this->cache[$name] = $view;
}
return $this->cache[$name];
} | php | public function resolveViewName(string $name): ?string
{
if (!array_key_exists($name, $this->cache)) {
$this->collection->sort();
$view = $this->getRouter()->route(new Context($name));
if (!is_string($view)) {
$view = null;
}
$this->cache[$name] = $view;
}
return $this->cache[$name];
} | [
"public",
"function",
"resolveViewName",
"(",
"string",
"$",
"name",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"cache",
")",
")",
"{",
"$",
"this",
"->",
"collection",
"->",
"sort",
"(... | Resolve a view's name
@param string $name
@return string|null | [
"Resolve",
"a",
"view",
"s",
"name"
] | 8aaee4d1de4372539db2bc3ed82063438426e311 | https://github.com/opis/view/blob/8aaee4d1de4372539db2bc3ed82063438426e311/src/ViewRenderer.php#L206-L217 | train |
koolkode/async | src/Concurrent/Filesystem/PoolFilesystem.php | PoolFilesystem.scandirTask | protected function scandirTask(Context $context, string $path): \Generator
{
$entries = yield $this->pool->submit($context, new MethodCall(static::class, 'scandirJob', $path));
if ($entries === null) {
throw new FilesystemException(\sprintf('Failed to scan directory: "%s"', $path));
}
return $entries;
} | php | protected function scandirTask(Context $context, string $path): \Generator
{
$entries = yield $this->pool->submit($context, new MethodCall(static::class, 'scandirJob', $path));
if ($entries === null) {
throw new FilesystemException(\sprintf('Failed to scan directory: "%s"', $path));
}
return $entries;
} | [
"protected",
"function",
"scandirTask",
"(",
"Context",
"$",
"context",
",",
"string",
"$",
"path",
")",
":",
"\\",
"Generator",
"{",
"$",
"entries",
"=",
"yield",
"$",
"this",
"->",
"pool",
"->",
"submit",
"(",
"$",
"context",
",",
"new",
"MethodCall",
... | Scan the given directory for items.
@param Context $context Async execution context.
@param string $path Absolute path of the directory to be scanned.
@return array Absolute paths of all scanned items.
@throws FilesystemException When scanning the directory has failed. | [
"Scan",
"the",
"given",
"directory",
"for",
"items",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Filesystem/PoolFilesystem.php#L129-L138 | train |
koolkode/async | src/Concurrent/Filesystem/PoolFilesystem.php | PoolFilesystem.scandirJob | protected static function scandirJob(string $path): ?array
{
if (!\is_dir($path)) {
return null;
}
$entries = @\glob($path . \DIRECTORY_SEPARATOR . '*', \GLOB_NOSORT);
return ($entries === false) ? null : $entries;
} | php | protected static function scandirJob(string $path): ?array
{
if (!\is_dir($path)) {
return null;
}
$entries = @\glob($path . \DIRECTORY_SEPARATOR . '*', \GLOB_NOSORT);
return ($entries === false) ? null : $entries;
} | [
"protected",
"static",
"function",
"scandirJob",
"(",
"string",
"$",
"path",
")",
":",
"?",
"array",
"{",
"if",
"(",
"!",
"\\",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"entries",
"=",
"@",
"\\",
"glob",
"(",
"$... | Scan the given directory using sync fuctions. | [
"Scan",
"the",
"given",
"directory",
"using",
"sync",
"fuctions",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Filesystem/PoolFilesystem.php#L143-L152 | train |
koolkode/async | src/Concurrent/Filesystem/PoolFilesystem.php | PoolFilesystem.readStreamTask | protected function readStreamTask(Context $context, string $path): \Generator
{
if (!yield $this->pool->submit($context, new MethodCall(static::class, 'checkFileReadableJob', $path))) {
throw new FilesystemException(\sprintf('File is not readable: "%s"', $path));
}
if (!$this->fileTransferSupported) {
return new ReadableFileStream($this->pool, $path);
}
$file = yield $this->pool->submit($context, new MethodCall(FileDescriptor::class, 'open', $path, 'rb'));
return new ReadableDescriptorStream($this->pool, $path, $file);
} | php | protected function readStreamTask(Context $context, string $path): \Generator
{
if (!yield $this->pool->submit($context, new MethodCall(static::class, 'checkFileReadableJob', $path))) {
throw new FilesystemException(\sprintf('File is not readable: "%s"', $path));
}
if (!$this->fileTransferSupported) {
return new ReadableFileStream($this->pool, $path);
}
$file = yield $this->pool->submit($context, new MethodCall(FileDescriptor::class, 'open', $path, 'rb'));
return new ReadableDescriptorStream($this->pool, $path, $file);
} | [
"protected",
"function",
"readStreamTask",
"(",
"Context",
"$",
"context",
",",
"string",
"$",
"path",
")",
":",
"\\",
"Generator",
"{",
"if",
"(",
"!",
"yield",
"$",
"this",
"->",
"pool",
"->",
"submit",
"(",
"$",
"context",
",",
"new",
"MethodCall",
... | Open a file descriptor stream to be used for reading.
@param Context $context Async execution context.
@param string $path Absolute path to the target file.
@return ReadableDescriptorStream Async readable file stream. | [
"Open",
"a",
"file",
"descriptor",
"stream",
"to",
"be",
"used",
"for",
"reading",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Filesystem/PoolFilesystem.php#L169-L182 | train |
koolkode/async | src/Concurrent/Filesystem/PoolFilesystem.php | PoolFilesystem.checkFileReadableJob | protected static function checkFileReadableJob(string $path): bool
{
if (!\is_file($path) || !\is_readable($path)) {
return false;
}
return true;
} | php | protected static function checkFileReadableJob(string $path): bool
{
if (!\is_file($path) || !\is_readable($path)) {
return false;
}
return true;
} | [
"protected",
"static",
"function",
"checkFileReadableJob",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"\\",
"is_file",
"(",
"$",
"path",
")",
"||",
"!",
"\\",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
... | Check if the given path is a regular file that is readable. | [
"Check",
"if",
"the",
"given",
"path",
"is",
"a",
"regular",
"file",
"that",
"is",
"readable",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Filesystem/PoolFilesystem.php#L187-L194 | train |
koolkode/async | src/Concurrent/Filesystem/PoolFilesystem.php | PoolFilesystem.writeStreamTask | protected function writeStreamTask(Context $context, string $path, bool $append = false): \Generator
{
if (!yield $this->pool->submit($context, new MethodCall(static::class, 'checkFileWritableJob', $path, !$append && !$this->fileTransferSupported))) {
throw new FilesystemException(\sprintf('File is not writable: "%s"', $path));
}
if (!$this->fileTransferSupported) {
return new WritableFileStream($this->pool, $path);
}
$file = yield $this->pool->submit($context, new MethodCall(FileDescriptor::class, 'open', $path, $append ? 'ab' : 'wb'));
return new WritableDescriptorStream($this->pool, $path, $file);
} | php | protected function writeStreamTask(Context $context, string $path, bool $append = false): \Generator
{
if (!yield $this->pool->submit($context, new MethodCall(static::class, 'checkFileWritableJob', $path, !$append && !$this->fileTransferSupported))) {
throw new FilesystemException(\sprintf('File is not writable: "%s"', $path));
}
if (!$this->fileTransferSupported) {
return new WritableFileStream($this->pool, $path);
}
$file = yield $this->pool->submit($context, new MethodCall(FileDescriptor::class, 'open', $path, $append ? 'ab' : 'wb'));
return new WritableDescriptorStream($this->pool, $path, $file);
} | [
"protected",
"function",
"writeStreamTask",
"(",
"Context",
"$",
"context",
",",
"string",
"$",
"path",
",",
"bool",
"$",
"append",
"=",
"false",
")",
":",
"\\",
"Generator",
"{",
"if",
"(",
"!",
"yield",
"$",
"this",
"->",
"pool",
"->",
"submit",
"(",... | Open a file descriptor stream to be used for writing.
@param Context $context Async execution context.
@param string $path Absolute path to the target file.
@return WritableDescriptorStream Async readable file stream. | [
"Open",
"a",
"file",
"descriptor",
"stream",
"to",
"be",
"used",
"for",
"writing",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Filesystem/PoolFilesystem.php#L280-L293 | train |
koolkode/async | src/Concurrent/Filesystem/PoolFilesystem.php | PoolFilesystem.checkFileWritableJob | protected static function checkFileWritableJob(string $path, bool $truncate = false): bool
{
if (\file_exists($path) && (!\is_file($path) || !\is_writable($path))) {
return false;
}
if ($truncate && \is_file($path)) {
@\ftruncate(@\fopen($path, 'wb'), 0);
}
return true;
} | php | protected static function checkFileWritableJob(string $path, bool $truncate = false): bool
{
if (\file_exists($path) && (!\is_file($path) || !\is_writable($path))) {
return false;
}
if ($truncate && \is_file($path)) {
@\ftruncate(@\fopen($path, 'wb'), 0);
}
return true;
} | [
"protected",
"static",
"function",
"checkFileWritableJob",
"(",
"string",
"$",
"path",
",",
"bool",
"$",
"truncate",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"\\",
"file_exists",
"(",
"$",
"path",
")",
"&&",
"(",
"!",
"\\",
"is_file",
"(",
"$",
... | Check if the given path is a regular file that is writable. | [
"Check",
"if",
"the",
"given",
"path",
"is",
"a",
"regular",
"file",
"that",
"is",
"writable",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Filesystem/PoolFilesystem.php#L298-L309 | train |
fabiomlferreira/yii2-file-manager | Thumbnail.php | Thumbnail.url | public function url($file, array $params)
{
$cacheFileSrc = $this->make($file, $params);
return $cacheFileSrc ? $cacheFileSrc : null;
} | php | public function url($file, array $params)
{
$cacheFileSrc = $this->make($file, $params);
return $cacheFileSrc ? $cacheFileSrc : null;
} | [
"public",
"function",
"url",
"(",
"$",
"file",
",",
"array",
"$",
"params",
")",
"{",
"$",
"cacheFileSrc",
"=",
"$",
"this",
"->",
"make",
"(",
"$",
"file",
",",
"$",
"params",
")",
";",
"return",
"$",
"cacheFileSrc",
"?",
"$",
"cacheFileSrc",
":",
... | Creates and caches the image thumbnail and returns image url
@param string $file
@param array $params
@return string | [
"Creates",
"and",
"caches",
"the",
"image",
"thumbnail",
"and",
"returns",
"image",
"url"
] | 45cb1919254c6e0ecb1793240395169f4fc26819 | https://github.com/fabiomlferreira/yii2-file-manager/blob/45cb1919254c6e0ecb1793240395169f4fc26819/Thumbnail.php#L139-L144 | train |
fabiomlferreira/yii2-file-manager | Thumbnail.php | Thumbnail.urlPlaceholder | private function urlPlaceholder($width, $height, $text, $backgroundColor, $textColor, $textSize, $random, array
$options)
{
if ($random) {
$backgroundColor = $this->getRandomColor();
}
$src = 'https://placeholdit.imgix.net/~text?txtsize=' . $textSize . '&bg=' . str_replace('#', '',
$backgroundColor) . '&txtclr=' . str_replace('#', '', $textColor) . '&txt=' . $text . '&w=' . $width . '&h=' . $height;
if (!$this->options['placeholder']['cache']) {
return Html::img($src, $options);
}
$cacheFileName = md5($width . $height . $text . $backgroundColor . $textColor . $textSize);
$cacheFileExt = '.jpg';
$cacheFileDir = '/' . substr($cacheFileName, 0, 2);
$cacheFilePath = Yii::getAlias($this->cachePath) . $cacheFileDir;
$cacheFile = $cacheFilePath . '/' . $cacheFileName . $cacheFileExt;
$cacheUrl = str_replace('\\', '/', preg_replace('/^@[a-z]+/', '', $this->cachePath) . $cacheFileDir . '/'
. $cacheFileName . $cacheFileExt);
if (file_exists($cacheFile)) {
if ($this->cacheExpire !== 0 && (time() - filemtime($cacheFile)) > $this->cacheExpire) {
unlink($cacheFile);
} else {
return Html::img($cacheUrl, $options);
}
}
if (!is_dir($cacheFilePath)) {
mkdir($cacheFilePath, 0755, true);
}
$image = file_get_contents($src);
file_put_contents($cacheFile, $image);
return Html::img($cacheUrl, $options);
} | php | private function urlPlaceholder($width, $height, $text, $backgroundColor, $textColor, $textSize, $random, array
$options)
{
if ($random) {
$backgroundColor = $this->getRandomColor();
}
$src = 'https://placeholdit.imgix.net/~text?txtsize=' . $textSize . '&bg=' . str_replace('#', '',
$backgroundColor) . '&txtclr=' . str_replace('#', '', $textColor) . '&txt=' . $text . '&w=' . $width . '&h=' . $height;
if (!$this->options['placeholder']['cache']) {
return Html::img($src, $options);
}
$cacheFileName = md5($width . $height . $text . $backgroundColor . $textColor . $textSize);
$cacheFileExt = '.jpg';
$cacheFileDir = '/' . substr($cacheFileName, 0, 2);
$cacheFilePath = Yii::getAlias($this->cachePath) . $cacheFileDir;
$cacheFile = $cacheFilePath . '/' . $cacheFileName . $cacheFileExt;
$cacheUrl = str_replace('\\', '/', preg_replace('/^@[a-z]+/', '', $this->cachePath) . $cacheFileDir . '/'
. $cacheFileName . $cacheFileExt);
if (file_exists($cacheFile)) {
if ($this->cacheExpire !== 0 && (time() - filemtime($cacheFile)) > $this->cacheExpire) {
unlink($cacheFile);
} else {
return Html::img($cacheUrl, $options);
}
}
if (!is_dir($cacheFilePath)) {
mkdir($cacheFilePath, 0755, true);
}
$image = file_get_contents($src);
file_put_contents($cacheFile, $image);
return Html::img($cacheUrl, $options);
} | [
"private",
"function",
"urlPlaceholder",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"text",
",",
"$",
"backgroundColor",
",",
"$",
"textColor",
",",
"$",
"textSize",
",",
"$",
"random",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"$",
"r... | Return URL placeholder image
@param integer $width
@param integer $height
@param string $text
@param string $backgroundColor
@param string $textColor
@param array $options
@return string | [
"Return",
"URL",
"placeholder",
"image"
] | 45cb1919254c6e0ecb1793240395169f4fc26819 | https://github.com/fabiomlferreira/yii2-file-manager/blob/45cb1919254c6e0ecb1793240395169f4fc26819/Thumbnail.php#L200-L239 | train |
fabiomlferreira/yii2-file-manager | Thumbnail.php | Thumbnail.jsPlaceholder | private function jsPlaceholder($width, $height, $text, $backgroundColor, $textColor, $random, array $options)
{
$src = 'holder.js/' . $width . 'x' . $height . '?bg=' . $backgroundColor . '&fg=' . $textColor . '&text=' . $text;
if ($random) {
$src .= $src . '&random=yes';
}
return Html::img('', array_merge($options, ['data-src' => $src]));
} | php | private function jsPlaceholder($width, $height, $text, $backgroundColor, $textColor, $random, array $options)
{
$src = 'holder.js/' . $width . 'x' . $height . '?bg=' . $backgroundColor . '&fg=' . $textColor . '&text=' . $text;
if ($random) {
$src .= $src . '&random=yes';
}
return Html::img('', array_merge($options, ['data-src' => $src]));
} | [
"private",
"function",
"jsPlaceholder",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"text",
",",
"$",
"backgroundColor",
",",
"$",
"textColor",
",",
"$",
"random",
",",
"array",
"$",
"options",
")",
"{",
"$",
"src",
"=",
"'holder.js/'",
".",
"$",
... | Return JS placeholder image
@param integer $width
@param integer $height
@param string $text
@param string $backgroundColor
@param string $textColor
@param array $options
@return string | [
"Return",
"JS",
"placeholder",
"image"
] | 45cb1919254c6e0ecb1793240395169f4fc26819 | https://github.com/fabiomlferreira/yii2-file-manager/blob/45cb1919254c6e0ecb1793240395169f4fc26819/Thumbnail.php#L251-L260 | train |
fabiomlferreira/yii2-file-manager | Thumbnail.php | Thumbnail.thumbnail | private function thumbnail(array $params)
{
$mode = isset($params['mode']) ? $params['mode'] : self::THUMBNAIL_OUTBOUND;
$width = (isset($params['width']) && is_numeric($params['width'])) ? $params['width'] : null;
$height = (isset($params['height']) && is_numeric($params['height'])) ? $params['height'] : null;
if (is_null($width) || is_null($height)) {
throw new Exception('Wrong thumbnail width or height');
}
$this->image = $this->image->thumbnail(new Box($width, $height), $mode);
} | php | private function thumbnail(array $params)
{
$mode = isset($params['mode']) ? $params['mode'] : self::THUMBNAIL_OUTBOUND;
$width = (isset($params['width']) && is_numeric($params['width'])) ? $params['width'] : null;
$height = (isset($params['height']) && is_numeric($params['height'])) ? $params['height'] : null;
if (is_null($width) || is_null($height)) {
throw new Exception('Wrong thumbnail width or height');
}
$this->image = $this->image->thumbnail(new Box($width, $height), $mode);
} | [
"private",
"function",
"thumbnail",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"mode",
"=",
"isset",
"(",
"$",
"params",
"[",
"'mode'",
"]",
")",
"?",
"$",
"params",
"[",
"'mode'",
"]",
":",
"self",
"::",
"THUMBNAIL_OUTBOUND",
";",
"$",
"width",
"="... | Make thumbnail image
@param array $params | [
"Make",
"thumbnail",
"image"
] | 45cb1919254c6e0ecb1793240395169f4fc26819 | https://github.com/fabiomlferreira/yii2-file-manager/blob/45cb1919254c6e0ecb1793240395169f4fc26819/Thumbnail.php#L411-L423 | train |
nyeholt/silverstripe-frontend-dashboards | code/dashlets/Dashlet.php | Dashlet.getDashletFields | public function getDashletFields()
{
/**
* if you want to use jQuery color picker instead of HTML5
* <input type='color' />, uncomment out the lined which add
* the extra class, and comment out the lines which are setting
* the attribute to type => color
*/
$extraClasses = MultiValueTextField::create('ExtraClasses');
$fields = new FieldList(new TextField('Title', _t('Dashlet.TITLE', 'Title')), $extraClasses);
$this->extend('updateDashletFields', $fields);
return $fields;
} | php | public function getDashletFields()
{
/**
* if you want to use jQuery color picker instead of HTML5
* <input type='color' />, uncomment out the lined which add
* the extra class, and comment out the lines which are setting
* the attribute to type => color
*/
$extraClasses = MultiValueTextField::create('ExtraClasses');
$fields = new FieldList(new TextField('Title', _t('Dashlet.TITLE', 'Title')), $extraClasses);
$this->extend('updateDashletFields', $fields);
return $fields;
} | [
"public",
"function",
"getDashletFields",
"(",
")",
"{",
"/**\n *\tif you want to use jQuery color picker instead of HTML5\n *\t<input type='color' />, uncomment out the lined which add\n *\tthe extra class, and comment out the lines which are setting\n *\tthe attribute to ty... | Gets the fields used for editing this dashlet on the frontend
@return FieldSet | [
"Gets",
"the",
"fields",
"used",
"for",
"editing",
"this",
"dashlet",
"on",
"the",
"frontend"
] | 7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1 | https://github.com/nyeholt/silverstripe-frontend-dashboards/blob/7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1/code/dashlets/Dashlet.php#L77-L91 | train |
nyeholt/silverstripe-frontend-dashboards | code/dashlets/Dashlet.php | Dashlet.canCreate | public function canCreate($member=null)
{
if (!$member) {
$member = singleton('SecurityContext')->getMember();
}
if ($member) {
// check dashboard controller's allowed_dashlets
$allowed = Config::inst()->get('DashboardController', 'allowed_dashlets');
if (in_array(get_class($this), $allowed)) {
return true;
}
$config = SiteConfig::current_site_config();
$required = $this->requiredPermission();
if ($config->hasMethod('checkPerm') && $config->checkPerm($required)) {
return true;
}
}
return parent::canCreate($member);
} | php | public function canCreate($member=null)
{
if (!$member) {
$member = singleton('SecurityContext')->getMember();
}
if ($member) {
// check dashboard controller's allowed_dashlets
$allowed = Config::inst()->get('DashboardController', 'allowed_dashlets');
if (in_array(get_class($this), $allowed)) {
return true;
}
$config = SiteConfig::current_site_config();
$required = $this->requiredPermission();
if ($config->hasMethod('checkPerm') && $config->checkPerm($required)) {
return true;
}
}
return parent::canCreate($member);
} | [
"public",
"function",
"canCreate",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"singleton",
"(",
"'SecurityContext'",
")",
"->",
"getMember",
"(",
")",
";",
"}",
"if",
"(",
"$",
"member",
... | Can this dashlet be created by the current user?
@param type $member
@return type | [
"Can",
"this",
"dashlet",
"be",
"created",
"by",
"the",
"current",
"user?"
] | 7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1 | https://github.com/nyeholt/silverstripe-frontend-dashboards/blob/7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1/code/dashlets/Dashlet.php#L126-L148 | train |
nyeholt/silverstripe-frontend-dashboards | code/dashlets/Dashlet.php | Dashlet_Controller.save | public function save()
{
if ($this->widget && $this->widget->OwnerID && $this->widget->OwnerID != Member::currentUserID()) {
// check ownership, not just write access
return;
}
//Note : Gridster uses weird names... size_x? Why just not width, Argh...
// Admittedly, col and row makes sense since it's essentially
// using cells to align up objects.
$obj = self::get()->byID($this->request->param('ID'));
$obj->PosX = $this->request->postVar('col');
$obj->PosY = $this->request->postVar('row');
$obj->Width = $this->request->postVar('size_x');
$obj->Height = $this->request->postVar('size_y');
// only allow the owner access to write.
$obj->write();
} | php | public function save()
{
if ($this->widget && $this->widget->OwnerID && $this->widget->OwnerID != Member::currentUserID()) {
// check ownership, not just write access
return;
}
//Note : Gridster uses weird names... size_x? Why just not width, Argh...
// Admittedly, col and row makes sense since it's essentially
// using cells to align up objects.
$obj = self::get()->byID($this->request->param('ID'));
$obj->PosX = $this->request->postVar('col');
$obj->PosY = $this->request->postVar('row');
$obj->Width = $this->request->postVar('size_x');
$obj->Height = $this->request->postVar('size_y');
// only allow the owner access to write.
$obj->write();
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"widget",
"&&",
"$",
"this",
"->",
"widget",
"->",
"OwnerID",
"&&",
"$",
"this",
"->",
"widget",
"->",
"OwnerID",
"!=",
"Member",
"::",
"currentUserID",
"(",
")",
")",
"{",
... | Called on every instance of resize.stop and draggable.stop in dashboards.js
Takes the parameters and saves them to dashlet of the ID given.
Values are automatically escaped. | [
"Called",
"on",
"every",
"instance",
"of",
"resize",
".",
"stop",
"and",
"draggable",
".",
"stop",
"in",
"dashboards",
".",
"js",
"Takes",
"the",
"parameters",
"and",
"saves",
"them",
"to",
"dashlet",
"of",
"the",
"ID",
"given",
".",
"Values",
"are",
"au... | 7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1 | https://github.com/nyeholt/silverstripe-frontend-dashboards/blob/7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1/code/dashlets/Dashlet.php#L193-L211 | train |
nyeholt/silverstripe-frontend-dashboards | code/controllers/DashboardController.php | DashboardController.updateDashboard | public function updateDashboard()
{
$dashboardId = (int) $this->request->postVar('dashboard');
$items = (array) $this->request->postVar('order');
if ($dashboardId) {
$dashboard = $this->dataService->memberDashboardById($dashboardId);
if ($dashboard && $dashboard->exists()) {
$dashboard->Widgets()->removeAll();
if (is_array($items)) {
foreach ($items as $i => $widgetId) {
$widget = $this->dataService->dashletById($widgetId);
if ($widget) {
$widget->ParentID = $dashboard->ID;
$widget->Sort = $i+1; // need +1 here so there's no 0 sort val, otherwise onbeforewrite sets it automatically.
$widget->write();
}
}
}
}
}
} | php | public function updateDashboard()
{
$dashboardId = (int) $this->request->postVar('dashboard');
$items = (array) $this->request->postVar('order');
if ($dashboardId) {
$dashboard = $this->dataService->memberDashboardById($dashboardId);
if ($dashboard && $dashboard->exists()) {
$dashboard->Widgets()->removeAll();
if (is_array($items)) {
foreach ($items as $i => $widgetId) {
$widget = $this->dataService->dashletById($widgetId);
if ($widget) {
$widget->ParentID = $dashboard->ID;
$widget->Sort = $i+1; // need +1 here so there's no 0 sort val, otherwise onbeforewrite sets it automatically.
$widget->write();
}
}
}
}
}
} | [
"public",
"function",
"updateDashboard",
"(",
")",
"{",
"$",
"dashboardId",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"request",
"->",
"postVar",
"(",
"'dashboard'",
")",
";",
"$",
"items",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"request",
"->",
"... | Called to update a dashboard structure | [
"Called",
"to",
"update",
"a",
"dashboard",
"structure"
] | 7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1 | https://github.com/nyeholt/silverstripe-frontend-dashboards/blob/7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1/code/controllers/DashboardController.php#L317-L338 | train |
nyeholt/silverstripe-frontend-dashboards | code/controllers/DashboardController.php | DashboardController.getRecord | protected function getRecord()
{
$id = (int) $this->request->param('ID');
if (!$id) {
$id = (int) $this->request->requestVar('ID');
}
if ($id) {
$type = $this->stat('model_class');
$action = $this->request->param('Action');
if ($action == 'dashlet' || $action == 'widget') {
$type = 'Dashlet';
}
$item = $this->dataService->byId($type, $id);
if ($item instanceof DashboardPage) {
$item->setController($this);
}
return $item;
}
} | php | protected function getRecord()
{
$id = (int) $this->request->param('ID');
if (!$id) {
$id = (int) $this->request->requestVar('ID');
}
if ($id) {
$type = $this->stat('model_class');
$action = $this->request->param('Action');
if ($action == 'dashlet' || $action == 'widget') {
$type = 'Dashlet';
}
$item = $this->dataService->byId($type, $id);
if ($item instanceof DashboardPage) {
$item->setController($this);
}
return $item;
}
} | [
"protected",
"function",
"getRecord",
"(",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"request",
"->",
"param",
"(",
"'ID'",
")",
";",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"this",
"->",... | Overridden to make sure the dashboard page is attached to the correct controller
@return type | [
"Overridden",
"to",
"make",
"sure",
"the",
"dashboard",
"page",
"is",
"attached",
"to",
"the",
"correct",
"controller"
] | 7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1 | https://github.com/nyeholt/silverstripe-frontend-dashboards/blob/7a2ad8753164621d0bfcd95e3cf06c4261a2d5d1/code/controllers/DashboardController.php#L500-L519 | train |
scherersoftware/cake-cktools | src/Utility/TableUtilitiesTrait.php | TableUtilitiesTrait.updateField | public function updateField($primaryKey, $field, $value = null): bool
{
$query = $this->query()
->update()
->set([
$field => $value,
])
->where([
$this->primaryKey() => $primaryKey,
]);
$statement = $query->execute();
$success = $statement->rowCount() > 0;
$statement->closeCursor();
return $success;
} | php | public function updateField($primaryKey, $field, $value = null): bool
{
$query = $this->query()
->update()
->set([
$field => $value,
])
->where([
$this->primaryKey() => $primaryKey,
]);
$statement = $query->execute();
$success = $statement->rowCount() > 0;
$statement->closeCursor();
return $success;
} | [
"public",
"function",
"updateField",
"(",
"$",
"primaryKey",
",",
"$",
"field",
",",
"$",
"value",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"query",
"(",
")",
"->",
"update",
"(",
")",
"->",
"set",
"(",
"[",
"$",
... | Updates a single field for the given primaryKey
@param mixed $primaryKey The primary key
@param string $field field name
@param string $value string value
@return bool True if the row was affected | [
"Updates",
"a",
"single",
"field",
"for",
"the",
"given",
"primaryKey"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/TableUtilitiesTrait.php#L16-L32 | train |
shardimage/shardimage-php | src/services/SuperBackupService.php | SuperBackupService.index | public function index($params = [], $optParams = [])
{
if ($optParams instanceof IndexParams) {
$optParams = $optParams->toArray(true);
}
return $this->sendRequest([], [
'restAction' => 'index',
'params' => $params,
'getParams' => $optParams,
], function ($response) {
$backups = [];
if (isset($response->data['items'])) {
foreach ($response->data['items'] as $superbackup) {
$backups[] = new SuperBackup($superbackup);
}
}
return new Index([
'models' => $backups,
'nextPageToken' => $response->data['nextPageToken'],
]);
});
} | php | public function index($params = [], $optParams = [])
{
if ($optParams instanceof IndexParams) {
$optParams = $optParams->toArray(true);
}
return $this->sendRequest([], [
'restAction' => 'index',
'params' => $params,
'getParams' => $optParams,
], function ($response) {
$backups = [];
if (isset($response->data['items'])) {
foreach ($response->data['items'] as $superbackup) {
$backups[] = new SuperBackup($superbackup);
}
}
return new Index([
'models' => $backups,
'nextPageToken' => $response->data['nextPageToken'],
]);
});
} | [
"public",
"function",
"index",
"(",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"optParams",
"instanceof",
"IndexParams",
")",
"{",
"$",
"optParams",
"=",
"$",
"optParams",
"->",
"toArray",
"(",
"true... | Fetches all existing backups.
@param array $params Required API parameters
@param array $optParams Optional API parameters
@return Index | [
"Fetches",
"all",
"existing",
"backups",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/SuperBackupService.php#L32-L55 | train |
shardimage/shardimage-php | src/services/SuperBackupService.php | SuperBackupService.create | public function create($params, $optParams = [])
{
if (!$params instanceof SuperBackup) {
throw new InvalidParamException(SuperBackup::class.' is required!');
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
$optParams['cloud']['id'] = $params->cloud->id;
return $this->sendRequest([], [
'restAction' => 'create',
'uri' => '/c/<cloud.id>',
'postParams' => $params->toArray(),
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new SuperBackup($response->data) : $response;
});
} | php | public function create($params, $optParams = [])
{
if (!$params instanceof SuperBackup) {
throw new InvalidParamException(SuperBackup::class.' is required!');
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
$optParams['cloud']['id'] = $params->cloud->id;
return $this->sendRequest([], [
'restAction' => 'create',
'uri' => '/c/<cloud.id>',
'postParams' => $params->toArray(),
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new SuperBackup($response->data) : $response;
});
} | [
"public",
"function",
"create",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"params",
"instanceof",
"SuperBackup",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"SuperBackup",
"::",
"class",
".",
"' ... | Creates a new superbackup.
@param SuperBackup $params SuperBackup object
@param array $optParams Optional API parameters
@return SuperBackup|Response
@throws InvalidParamException | [
"Creates",
"a",
"new",
"superbackup",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/SuperBackupService.php#L67-L85 | train |
shardimage/shardimage-php | src/services/SuperBackupService.php | SuperBackupService.update | public function update($params, $optParams = [])
{
if (!$params instanceof SuperBackup) {
throw new InvalidParamException(SuperBackup::class.' is required!');
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
if ($params->task && is_string($params->task->type)) {
$params->task = $params->task->type;
}
$optParams['cloud']['id'] = $params->cloud->id;
return $this->sendRequest([], [
'restAction' => 'update',
'uri' => '/c/<cloud.id>',
'restId' => $params->id,
'postParams' => $params->toArray(),
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new SuperBackup($response->data) : $response;
});
} | php | public function update($params, $optParams = [])
{
if (!$params instanceof SuperBackup) {
throw new InvalidParamException(SuperBackup::class.' is required!');
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
if ($params->task && is_string($params->task->type)) {
$params->task = $params->task->type;
}
$optParams['cloud']['id'] = $params->cloud->id;
return $this->sendRequest([], [
'restAction' => 'update',
'uri' => '/c/<cloud.id>',
'restId' => $params->id,
'postParams' => $params->toArray(),
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new SuperBackup($response->data) : $response;
});
} | [
"public",
"function",
"update",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"params",
"instanceof",
"SuperBackup",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"SuperBackup",
"::",
"class",
".",
"' ... | Updates a superbackup.
@param SuperBackup $params SuperBackup object
@param array $optParams Optional API parameters
@return SuperBackup|Response
@throws InvalidParamException | [
"Updates",
"a",
"superbackup",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/SuperBackupService.php#L97-L118 | train |
shardimage/shardimage-php | src/services/SuperBackupService.php | SuperBackupService.delete | public function delete($params, $optParams = [])
{
if ($params instanceof SuperBackup) {
$params = $params->id;
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
$optParams['cloud']['id'] = $params;
return $this->sendRequest([], [
'restAction' => 'delete',
'uri' => '/c/<cloud.id>',
'restId' => $params,
'getParams' => $optParams,
], function ($response) {
return $response->success;
});
} | php | public function delete($params, $optParams = [])
{
if ($params instanceof SuperBackup) {
$params = $params->id;
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
$optParams['cloud']['id'] = $params;
return $this->sendRequest([], [
'restAction' => 'delete',
'uri' => '/c/<cloud.id>',
'restId' => $params,
'getParams' => $optParams,
], function ($response) {
return $response->success;
});
} | [
"public",
"function",
"delete",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"params",
"instanceof",
"SuperBackup",
")",
"{",
"$",
"params",
"=",
"$",
"params",
"->",
"id",
";",
"}",
"if",
"(",
"!",
"isset",
... | Deletes a superbackup.
@param SuperBackup|string $params SuperBackup object or SuperBackup ID
@param array $optParams Optional API parameters
@return bool | [
"Deletes",
"a",
"superbackup",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/SuperBackupService.php#L128-L145 | train |
shardimage/shardimage-php | src/services/SuperBackupService.php | SuperBackupService.view | public function view($params, $optParams = [])
{
if ($params instanceof SuperBackup) {
$params = $params->id;
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
$optParams['cloud']['id'] = $params;
return $this->sendRequest([], [
'restAction' => 'view',
'uri' => '/c/<cloud.id>',
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new SuperBackup($response->data) : $response;
});
} | php | public function view($params, $optParams = [])
{
if ($params instanceof SuperBackup) {
$params = $params->id;
}
if(!isset($optParams['cloud'])){
$optParams['cloud'] = [];
}
$optParams['cloud']['id'] = $params;
return $this->sendRequest([], [
'restAction' => 'view',
'uri' => '/c/<cloud.id>',
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new SuperBackup($response->data) : $response;
});
} | [
"public",
"function",
"view",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"params",
"instanceof",
"SuperBackup",
")",
"{",
"$",
"params",
"=",
"$",
"params",
"->",
"id",
";",
"}",
"if",
"(",
"!",
"isset",
"... | Fetches a superbackup.
@param SuperBackup|string $params SuperBackup object or SuperBackup ID
@param SuperBackup|array $optParams Optional API parameters
@return SuperBackup|Response | [
"Fetches",
"a",
"superbackup",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/SuperBackupService.php#L155-L171 | train |
brightnucleus/view | src/Views.php | Views.render | public static function render($view, array $context = [], $type = null)
{
$viewBuilder = static::getViewBuilder();
$viewObject = $viewBuilder->create($view, $type);
return $viewObject->render($context);
} | php | public static function render($view, array $context = [], $type = null)
{
$viewBuilder = static::getViewBuilder();
$viewObject = $viewBuilder->create($view, $type);
return $viewObject->render($context);
} | [
"public",
"static",
"function",
"render",
"(",
"$",
"view",
",",
"array",
"$",
"context",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"viewBuilder",
"=",
"static",
"::",
"getViewBuilder",
"(",
")",
";",
"$",
"viewObject",
"=",
"$",
... | Render a view for a given URI.
@since 0.1.0
@param string $view View identifier to create a view for.
@param array $context Optional. The context in which to render the view.
@param string|null $type Type of view to create.
@return string Rendered HTML content.
@throws FailedToProcessConfigException If the Config could not be processed. | [
"Render",
"a",
"view",
"for",
"a",
"given",
"URI",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/Views.php#L117-L123 | train |
widoz/wordpress-model | src/Utils/CssProperties.php | CssProperties.flat | public function flat(array $properties): string
{
Assert::isMap($properties);
return $this->arrayImploder->byGlue($properties, ';', ':');
} | php | public function flat(array $properties): string
{
Assert::isMap($properties);
return $this->arrayImploder->byGlue($properties, ';', ':');
} | [
"public",
"function",
"flat",
"(",
"array",
"$",
"properties",
")",
":",
"string",
"{",
"Assert",
"::",
"isMap",
"(",
"$",
"properties",
")",
";",
"return",
"$",
"this",
"->",
"arrayImploder",
"->",
"byGlue",
"(",
"$",
"properties",
",",
"';'",
",",
"'... | Flat a list of css properties. The list have to be in form of an associative array.
@uses ArrayImplode::byGlue to flat the array.
@param array $properties
@return string
@throws InvalidArgumentException | [
"Flat",
"a",
"list",
"of",
"css",
"properties",
".",
"The",
"list",
"have",
"to",
"be",
"in",
"form",
"of",
"an",
"associative",
"array",
"."
] | 273301de4b6946144b285c235aea0d79b867244c | https://github.com/widoz/wordpress-model/blob/273301de4b6946144b285c235aea0d79b867244c/src/Utils/CssProperties.php#L46-L51 | train |
abandroid/gcm | src/Client.php | Client.send | public function send($data, array $registrationIds = [], array $options = [])
{
$this->responses = [];
$data = array_merge($options, [
'data' => $data,
]);
if (isset($options['to'])) {
$this->responses[] = $this->browser->post($this->apiUrl, $this->getHeaders(), json_encode($data));
} elseif (count($registrationIds) > 0) {
// Chunk number of registration ID's according to the maximum allowed by GCM
$chunks = array_chunk($registrationIds, $this->registrationIdMaxCount);
// Perform the calls (in parallel)
foreach ($chunks as $registrationIds) {
$data['registration_ids'] = $registrationIds;
$this->responses[] = $this->browser->post($this->apiUrl, $this->getHeaders(), json_encode($data));
}
}
$this->client->flush();
foreach ($this->responses as $response) {
$message = json_decode($response->getContent());
if ($message === null || $message->success == 0 || $message->failure > 0) {
return false;
}
}
return true;
} | php | public function send($data, array $registrationIds = [], array $options = [])
{
$this->responses = [];
$data = array_merge($options, [
'data' => $data,
]);
if (isset($options['to'])) {
$this->responses[] = $this->browser->post($this->apiUrl, $this->getHeaders(), json_encode($data));
} elseif (count($registrationIds) > 0) {
// Chunk number of registration ID's according to the maximum allowed by GCM
$chunks = array_chunk($registrationIds, $this->registrationIdMaxCount);
// Perform the calls (in parallel)
foreach ($chunks as $registrationIds) {
$data['registration_ids'] = $registrationIds;
$this->responses[] = $this->browser->post($this->apiUrl, $this->getHeaders(), json_encode($data));
}
}
$this->client->flush();
foreach ($this->responses as $response) {
$message = json_decode($response->getContent());
if ($message === null || $message->success == 0 || $message->failure > 0) {
return false;
}
}
return true;
} | [
"public",
"function",
"send",
"(",
"$",
"data",
",",
"array",
"$",
"registrationIds",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"responses",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"array_merge",
"(",
... | Sends the message via the GCM server.
@param mixed $data
@param array $registrationIds
@param array $options
@return bool | [
"Sends",
"the",
"message",
"via",
"the",
"GCM",
"server",
"."
] | bc4734202d4ded6c4ccd5dfdc161218a3346b0d8 | https://github.com/abandroid/gcm/blob/bc4734202d4ded6c4ccd5dfdc161218a3346b0d8/src/Client.php#L76-L106 | train |
abandroid/gcm | src/Client.php | Client.sendTo | public function sendTo($data, $topic = '/topics/global', array $options = [])
{
$options['to'] = $topic;
return $this->send($data, [], $options);
} | php | public function sendTo($data, $topic = '/topics/global', array $options = [])
{
$options['to'] = $topic;
return $this->send($data, [], $options);
} | [
"public",
"function",
"sendTo",
"(",
"$",
"data",
",",
"$",
"topic",
"=",
"'/topics/global'",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"[",
"'to'",
"]",
"=",
"$",
"topic",
";",
"return",
"$",
"this",
"->",
"send",
"(",... | Sends the data to the given registration token, notification key, or topic via the GCM server.
@param mixed $data
@param string $topic The value must be a registration token, notification key, or topic. Default global topic.
@param array $options to add along with message, such as collapse_key, time_to_live, delay_while_idle
@return bool | [
"Sends",
"the",
"data",
"to",
"the",
"given",
"registration",
"token",
"notification",
"key",
"or",
"topic",
"via",
"the",
"GCM",
"server",
"."
] | bc4734202d4ded6c4ccd5dfdc161218a3346b0d8 | https://github.com/abandroid/gcm/blob/bc4734202d4ded6c4ccd5dfdc161218a3346b0d8/src/Client.php#L117-L122 | train |
klermonte/zerg | src/Zerg/Field/AbstractField.php | AbstractField.configure | public function configure(array $properties)
{
foreach ($properties as $name => $value) {
$methodName = 'set' . ucfirst(strtolower($name));
if (method_exists($this, $methodName)) {
$this->$methodName($value);
}
}
} | php | public function configure(array $properties)
{
foreach ($properties as $name => $value) {
$methodName = 'set' . ucfirst(strtolower($name));
if (method_exists($this, $methodName)) {
$this->$methodName($value);
}
}
} | [
"public",
"function",
"configure",
"(",
"array",
"$",
"properties",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"methodName",
"=",
"'set'",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"name",
")",... | Associate given values to appropriate class properties.
@param array $properties Associative array of properties values. | [
"Associate",
"given",
"values",
"to",
"appropriate",
"class",
"properties",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/AbstractField.php#L47-L55 | train |
klermonte/zerg | src/Zerg/Field/AbstractField.php | AbstractField.validate | public function validate($value)
{
$assert = $this->getAssert();
if ($assert !== null) {
if (is_callable($assert)) {
if (!call_user_func($assert, $value, $this)) {
throw new AssertException(
sprintf('Custom validation fail with value (%s) "%s"', gettype($value), print_r($value, true))
);
}
} else {
if ($value !== $assert) {
throw new AssertException(
sprintf(
'Failed asserting that actual value (%s) "%s" matches expected value (%s) "%s".',
gettype($value),
print_r($value, true),
gettype($assert),
print_r($assert, true)
)
);
}
}
}
return true;
} | php | public function validate($value)
{
$assert = $this->getAssert();
if ($assert !== null) {
if (is_callable($assert)) {
if (!call_user_func($assert, $value, $this)) {
throw new AssertException(
sprintf('Custom validation fail with value (%s) "%s"', gettype($value), print_r($value, true))
);
}
} else {
if ($value !== $assert) {
throw new AssertException(
sprintf(
'Failed asserting that actual value (%s) "%s" matches expected value (%s) "%s".',
gettype($value),
print_r($value, true),
gettype($assert),
print_r($assert, true)
)
);
}
}
}
return true;
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
"{",
"$",
"assert",
"=",
"$",
"this",
"->",
"getAssert",
"(",
")",
";",
"if",
"(",
"$",
"assert",
"!==",
"null",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"assert",
")",
")",
"{",
"if"... | Check that given value is valid.
@param $value mixed Checked value.
@return true On success validation.
@throws AssertException On assertion fail. | [
"Check",
"that",
"given",
"value",
"is",
"valid",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/AbstractField.php#L104-L130 | train |
klermonte/zerg | src/Zerg/Field/AbstractField.php | AbstractField.resolveProperty | protected function resolveProperty($name)
{
$value = $this->$name;
if (is_callable($value)) {
return call_user_func($value, $this);
}
return $this->resolveValue($value);
} | php | protected function resolveProperty($name)
{
$value = $this->$name;
if (is_callable($value)) {
return call_user_func($value, $this);
}
return $this->resolveValue($value);
} | [
"protected",
"function",
"resolveProperty",
"(",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"$",
"name",
";",
"if",
"(",
"is_callable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"value",
",",
"$",
"this... | Process, set and return given property.
Find given property in DataSet if it was set as path string and return it.
Otherwise already set value will be returned.
@param string $name Property name.
@return int|string|array|null Found or already set property value. | [
"Process",
"set",
"and",
"return",
"given",
"property",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/AbstractField.php#L141-L149 | train |
klermonte/zerg | src/Zerg/Field/AbstractField.php | AbstractField.resolveValue | private function resolveValue($value)
{
if (DataSet::isPath($value)) {
if (empty($this->dataSet)) {
throw new ConfigurationException('DataSet is required to resole value by path.');
}
$value = $this->dataSet->resolvePath($value);
}
if (is_array($value)) {
foreach ($value as $key => $subValue) {
$value[$key] = $this->resolveValue($subValue);
}
}
return $value;
} | php | private function resolveValue($value)
{
if (DataSet::isPath($value)) {
if (empty($this->dataSet)) {
throw new ConfigurationException('DataSet is required to resole value by path.');
}
$value = $this->dataSet->resolvePath($value);
}
if (is_array($value)) {
foreach ($value as $key => $subValue) {
$value[$key] = $this->resolveValue($subValue);
}
}
return $value;
} | [
"private",
"function",
"resolveValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"DataSet",
"::",
"isPath",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"dataSet",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
... | Find value in DataSet by given value if it is a path string.
Otherwise given value will be returned.
@param $value
@return array|int|null|string
@since 0.2 | [
"Find",
"value",
"in",
"DataSet",
"by",
"given",
"value",
"if",
"it",
"is",
"a",
"path",
"string",
".",
"Otherwise",
"given",
"value",
"will",
"be",
"returned",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/AbstractField.php#L159-L175 | train |
widoz/wordpress-model | src/Attachment/Image/Source.php | Source.bailIfConstructArguments | private function bailIfConstructArguments(string $source, int $width, int $height): void
{
if ($width <= 0) {
throw new InvalidArgumentException('Width cannot be less or equal than zero.');
}
if ($height <= 0) {
throw new InvalidArgumentException('Height cannot be less or equal than zero.');
}
if (!file_exists($source)) {
throw new InvalidArgumentException('Source file does not exists.');
}
} | php | private function bailIfConstructArguments(string $source, int $width, int $height): void
{
if ($width <= 0) {
throw new InvalidArgumentException('Width cannot be less or equal than zero.');
}
if ($height <= 0) {
throw new InvalidArgumentException('Height cannot be less or equal than zero.');
}
if (!file_exists($source)) {
throw new InvalidArgumentException('Source file does not exists.');
}
} | [
"private",
"function",
"bailIfConstructArguments",
"(",
"string",
"$",
"source",
",",
"int",
"$",
"width",
",",
"int",
"$",
"height",
")",
":",
"void",
"{",
"if",
"(",
"$",
"width",
"<=",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'... | Validate Arguments for Constructor
@param string $source
@param int $width
@param int $height
@throws InvalidArgumentException | [
"Validate",
"Arguments",
"for",
"Constructor"
] | 273301de4b6946144b285c235aea0d79b867244c | https://github.com/widoz/wordpress-model/blob/273301de4b6946144b285c235aea0d79b867244c/src/Attachment/Image/Source.php#L104-L115 | train |
kevintweber/HtmlTokenizer | src/Tokens/TokenFactory.php | TokenFactory.buildFromHtml | public static function buildFromHtml(string $html, Token $parent = null, bool $throwOnError = true)
{
$matchCriteria = array(
'Php' => "/^\s*<\?(php)?\s/i",
'Comment' => "/^\s*<!--/",
'CData' => "/^\s*<!\[CDATA\[/",
'DocType' => "/^\s*<!DOCTYPE /i",
'Element' => "/^\s*<[a-z]/i",
'Text' => "/^[^<]/"
);
foreach ($matchCriteria as $className => $regex) {
if (preg_match($regex, $html) === 1) {
$fullClassName = "Kevintweber\\HtmlTokenizer\\Tokens\\" . $className;
return new $fullClassName($parent, $throwOnError);
}
}
// Error condition
if ($throwOnError) {
throw new TokenMatchingException();
}
} | php | public static function buildFromHtml(string $html, Token $parent = null, bool $throwOnError = true)
{
$matchCriteria = array(
'Php' => "/^\s*<\?(php)?\s/i",
'Comment' => "/^\s*<!--/",
'CData' => "/^\s*<!\[CDATA\[/",
'DocType' => "/^\s*<!DOCTYPE /i",
'Element' => "/^\s*<[a-z]/i",
'Text' => "/^[^<]/"
);
foreach ($matchCriteria as $className => $regex) {
if (preg_match($regex, $html) === 1) {
$fullClassName = "Kevintweber\\HtmlTokenizer\\Tokens\\" . $className;
return new $fullClassName($parent, $throwOnError);
}
}
// Error condition
if ($throwOnError) {
throw new TokenMatchingException();
}
} | [
"public",
"static",
"function",
"buildFromHtml",
"(",
"string",
"$",
"html",
",",
"Token",
"$",
"parent",
"=",
"null",
",",
"bool",
"$",
"throwOnError",
"=",
"true",
")",
"{",
"$",
"matchCriteria",
"=",
"array",
"(",
"'Php'",
"=>",
"\"/^\\s*<\\?(php)?\\s/i\"... | Factory method to build the correct token.
@param string $html
@param Token|null $parent
@param bool $throwOnError
@return TokenInterface|null
@throws TokenMatchingException | [
"Factory",
"method",
"to",
"build",
"the",
"correct",
"token",
"."
] | 45b861d29f8c303ebf97533b883e2584811a89fc | https://github.com/kevintweber/HtmlTokenizer/blob/45b861d29f8c303ebf97533b883e2584811a89fc/src/Tokens/TokenFactory.php#L20-L42 | train |
koolkode/async | src/Concurrent/Pool/PoolTask.php | PoolTask.cloneStructure | private function cloneStructure(array & $struct): void
{
foreach ($struct as & $v) {
if (is_object($v)) {
$v = clone $v;
} elseif (is_array($v)) {
$this->cloneStructure($v);
}
}
} | php | private function cloneStructure(array & $struct): void
{
foreach ($struct as & $v) {
if (is_object($v)) {
$v = clone $v;
} elseif (is_array($v)) {
$this->cloneStructure($v);
}
}
} | [
"private",
"function",
"cloneStructure",
"(",
"array",
"&",
"$",
"struct",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"struct",
"as",
"&",
"$",
"v",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"v",
")",
")",
"{",
"$",
"v",
"=",
"clone",
"$",
"... | Clone all objects within the given array structure. | [
"Clone",
"all",
"objects",
"within",
"the",
"given",
"array",
"structure",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Pool/PoolTask.php#L75-L84 | train |
MichaelPavlista/palette | src/Effect/PictureEffect.php | PictureEffect.restore | public function restore(array $settings = array())
{
$settings = array_values($settings);
$reflection = new ReflectionMethod(get_class($this), '__construct');
$alreadySet = $reflection->getNumberOfParameters();
$index = 0;
foreach($this->settings as &$setting)
{
if($alreadySet > $index)
{
continue;
}
if(array_key_exists($index, $settings))
{
$setting = $settings[$index] === '' ? NULL : $settings[$index];
}
$index++;
}
} | php | public function restore(array $settings = array())
{
$settings = array_values($settings);
$reflection = new ReflectionMethod(get_class($this), '__construct');
$alreadySet = $reflection->getNumberOfParameters();
$index = 0;
foreach($this->settings as &$setting)
{
if($alreadySet > $index)
{
continue;
}
if(array_key_exists($index, $settings))
{
$setting = $settings[$index] === '' ? NULL : $settings[$index];
}
$index++;
}
} | [
"public",
"function",
"restore",
"(",
"array",
"$",
"settings",
"=",
"array",
"(",
")",
")",
"{",
"$",
"settings",
"=",
"array_values",
"(",
"$",
"settings",
")",
";",
"$",
"reflection",
"=",
"new",
"ReflectionMethod",
"(",
"get_class",
"(",
"$",
"this",... | Restore effect state from array
@param array $settings | [
"Restore",
"effect",
"state",
"from",
"array"
] | dfb8d0e1b98880932851233faa048e2bfc9abed5 | https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Effect/PictureEffect.php#L48-L71 | train |
MichaelPavlista/palette | src/Effect/PictureEffect.php | PictureEffect.hex2rgb | public function hex2rgb($hex, $returnString = FALSE)
{
$hex = str_replace('#', '', $hex);
if(strlen($hex) == 3)
{
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
}
else
{
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
if($returnString)
{
return implode(', ', array($r, $g, $b));
}
return array($r, $g, $b);
} | php | public function hex2rgb($hex, $returnString = FALSE)
{
$hex = str_replace('#', '', $hex);
if(strlen($hex) == 3)
{
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
}
else
{
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
if($returnString)
{
return implode(', ', array($r, $g, $b));
}
return array($r, $g, $b);
} | [
"public",
"function",
"hex2rgb",
"(",
"$",
"hex",
",",
"$",
"returnString",
"=",
"FALSE",
")",
"{",
"$",
"hex",
"=",
"str_replace",
"(",
"'#'",
",",
"''",
",",
"$",
"hex",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"hex",
")",
"==",
"3",
")",
"{"... | Hexadecimal color to RGB conversion
@param string $hex color
@param bool $returnString
@return array|string | [
"Hexadecimal",
"color",
"to",
"RGB",
"conversion"
] | dfb8d0e1b98880932851233faa048e2bfc9abed5 | https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Effect/PictureEffect.php#L151-L174 | train |
silvercommerce/shoppingcart | src/extensions/MemberExtension.php | MemberExtension.setCart | public function setCart(ShoppingCart $cart)
{
$curr = $this->getOwner()->getCart();
$contact = $this->getOwner()->Contact();
if (isset($curr) && $curr->ID != $cart->ID) {
$curr->delete();
}
$cart->CustomerID = $contact->ID;
return $this;
} | php | public function setCart(ShoppingCart $cart)
{
$curr = $this->getOwner()->getCart();
$contact = $this->getOwner()->Contact();
if (isset($curr) && $curr->ID != $cart->ID) {
$curr->delete();
}
$cart->CustomerID = $contact->ID;
return $this;
} | [
"public",
"function",
"setCart",
"(",
"ShoppingCart",
"$",
"cart",
")",
"{",
"$",
"curr",
"=",
"$",
"this",
"->",
"getOwner",
"(",
")",
"->",
"getCart",
"(",
")",
";",
"$",
"contact",
"=",
"$",
"this",
"->",
"getOwner",
"(",
")",
"->",
"Contact",
"... | Update the current cart. Also make sure no more than one is
set at any one time.
@return self | [
"Update",
"the",
"current",
"cart",
".",
"Also",
"make",
"sure",
"no",
"more",
"than",
"one",
"is",
"set",
"at",
"any",
"one",
"time",
"."
] | 11e1296c095f9c2d35395d8d3b9d30e8a9db745b | https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/extensions/MemberExtension.php#L34-L46 | train |
dmstr/yii2-cookie-button | CookieButton.php | CookieButton.renderButton | private function renderButton()
{
$this->params = Json::encode([
'btnName' => $this->options['id'],
'cookieName' => $this->cookie['name'],
'cookieValue' => addslashes($this->getHashedCookieValue($this->cookie['value'])),
'cookieOptions' => isset($this->cookie['options']) ? $this->cookie['options'] : null,
]);
if($this->cookie($this->cookie['name'])) {
Html::addCssClass($this->options, 'active');
}
echo Button::widget([
'label' => $this->encodeLabel ? Html::encode($this->label) : $this->label,
'encodeLabel' => $this->encodeLabel,
'options' => ArrayHelper::merge(['data-toggle' => 'button'], $this->options),
]);
} | php | private function renderButton()
{
$this->params = Json::encode([
'btnName' => $this->options['id'],
'cookieName' => $this->cookie['name'],
'cookieValue' => addslashes($this->getHashedCookieValue($this->cookie['value'])),
'cookieOptions' => isset($this->cookie['options']) ? $this->cookie['options'] : null,
]);
if($this->cookie($this->cookie['name'])) {
Html::addCssClass($this->options, 'active');
}
echo Button::widget([
'label' => $this->encodeLabel ? Html::encode($this->label) : $this->label,
'encodeLabel' => $this->encodeLabel,
'options' => ArrayHelper::merge(['data-toggle' => 'button'], $this->options),
]);
} | [
"private",
"function",
"renderButton",
"(",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"Json",
"::",
"encode",
"(",
"[",
"'btnName'",
"=>",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
",",
"'cookieName'",
"=>",
"$",
"this",
"->",
"cookie",
"[",
... | Renders the toggle button. | [
"Renders",
"the",
"toggle",
"button",
"."
] | 0ee34e4ec898d5b11750632cabe4d9a662529050 | https://github.com/dmstr/yii2-cookie-button/blob/0ee34e4ec898d5b11750632cabe4d9a662529050/CookieButton.php#L120-L138 | train |
dmstr/yii2-cookie-button | CookieButton.php | CookieButton.renderButtonGroup | private function renderButtonGroup()
{
$this->params = Json::encode([
'btnName' => $this->options['id'],
'cookieName' => $this->cookie['name'],
'cookieValue' => addslashes($this->getHashedCookieValue($this->cookie['value'])),
'cookieOptions' => isset($this->cookie['options']) ? $this->cookie['options'] : null,
'toggleClass' => isset($this->toggleClass) ? $this->toggleClass : null
]);
if($this->cookie($this->cookie['name'])) {
$isActive = true;
} else {
$isActive = false;
}
echo ButtonGroup::widget([
'id' => $this->options['id'],
'buttons' => [
[
'label' => $this->encodeLabel ? Html::encode($this->label[0]) : $this->label[0],
'options' => [
'class' => 'btn ' . ($isActive ? $this->toggleClass : 'btn-default') . ' ' . $this->options['class'] . ($isActive ? ' active' : '')
]
],
[
'label' => $this->encodeLabel ? Html::encode($this->label[1]) : $this->label[1],
'options' => [
'class' => 'btn ' . ($isActive ? 'btn-default' : $this->toggleClass) . ' ' . $this->options['class'] . ($isActive ? ' active' : '')
]
],
]
]);
} | php | private function renderButtonGroup()
{
$this->params = Json::encode([
'btnName' => $this->options['id'],
'cookieName' => $this->cookie['name'],
'cookieValue' => addslashes($this->getHashedCookieValue($this->cookie['value'])),
'cookieOptions' => isset($this->cookie['options']) ? $this->cookie['options'] : null,
'toggleClass' => isset($this->toggleClass) ? $this->toggleClass : null
]);
if($this->cookie($this->cookie['name'])) {
$isActive = true;
} else {
$isActive = false;
}
echo ButtonGroup::widget([
'id' => $this->options['id'],
'buttons' => [
[
'label' => $this->encodeLabel ? Html::encode($this->label[0]) : $this->label[0],
'options' => [
'class' => 'btn ' . ($isActive ? $this->toggleClass : 'btn-default') . ' ' . $this->options['class'] . ($isActive ? ' active' : '')
]
],
[
'label' => $this->encodeLabel ? Html::encode($this->label[1]) : $this->label[1],
'options' => [
'class' => 'btn ' . ($isActive ? 'btn-default' : $this->toggleClass) . ' ' . $this->options['class'] . ($isActive ? ' active' : '')
]
],
]
]);
} | [
"private",
"function",
"renderButtonGroup",
"(",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"Json",
"::",
"encode",
"(",
"[",
"'btnName'",
"=>",
"$",
"this",
"->",
"options",
"[",
"'id'",
"]",
",",
"'cookieName'",
"=>",
"$",
"this",
"->",
"cookie",
"[... | Renders the button group. | [
"Renders",
"the",
"button",
"group",
"."
] | 0ee34e4ec898d5b11750632cabe4d9a662529050 | https://github.com/dmstr/yii2-cookie-button/blob/0ee34e4ec898d5b11750632cabe4d9a662529050/CookieButton.php#L143-L176 | train |
dmstr/yii2-cookie-button | CookieButton.php | CookieButton.cookie | private function cookie($name, $value = null, $expire = 0, $domain = '', $path = '/', $secure = false)
{
if($value === false) {
\Yii::$app->response->cookies->remove($name);
} elseif($value === null) {
return \Yii::$app->request->cookies->getValue($name);
}
/*$options['name'] = $name;
$options['value'] = $value;
$options['expire'] = $expire; //$expire?:time()+86400*365
$options['domain'] = $domain;
$options['path'] = $path;
$options['secure'] = $secure;
$cookie = new \yii\web\Cookie($options);
\Yii::$app->response->cookies->add($cookie);*/
} | php | private function cookie($name, $value = null, $expire = 0, $domain = '', $path = '/', $secure = false)
{
if($value === false) {
\Yii::$app->response->cookies->remove($name);
} elseif($value === null) {
return \Yii::$app->request->cookies->getValue($name);
}
/*$options['name'] = $name;
$options['value'] = $value;
$options['expire'] = $expire; //$expire?:time()+86400*365
$options['domain'] = $domain;
$options['path'] = $path;
$options['secure'] = $secure;
$cookie = new \yii\web\Cookie($options);
\Yii::$app->response->cookies->add($cookie);*/
} | [
"private",
"function",
"cookie",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
",",
"$",
"expire",
"=",
"0",
",",
"$",
"domain",
"=",
"''",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"secure",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
... | Remove or return cookie value
@todo add cookie...
@param string $name the name of the cookie
@param string $value the cookie value, if false remove cookie, if null return value
@param number $expire the cookie expire date
@return string cookie value | [
"Remove",
"or",
"return",
"cookie",
"value"
] | 0ee34e4ec898d5b11750632cabe4d9a662529050 | https://github.com/dmstr/yii2-cookie-button/blob/0ee34e4ec898d5b11750632cabe4d9a662529050/CookieButton.php#L198-L214 | train |
klermonte/zerg | src/Zerg/Field/Factory.php | Factory.instantiate | private static function instantiate(array $declaration)
{
$fieldType = array_shift($declaration);
$class = "\\Zerg\\Field\\" . ucfirst(strtolower($fieldType));
if (class_exists($class)) {
$reflection = new \ReflectionClass($class);
return $reflection->newInstanceArgs($declaration);
}
throw new ConfigurationException("Field {$fieldType} doesn't exist");
} | php | private static function instantiate(array $declaration)
{
$fieldType = array_shift($declaration);
$class = "\\Zerg\\Field\\" . ucfirst(strtolower($fieldType));
if (class_exists($class)) {
$reflection = new \ReflectionClass($class);
return $reflection->newInstanceArgs($declaration);
}
throw new ConfigurationException("Field {$fieldType} doesn't exist");
} | [
"private",
"static",
"function",
"instantiate",
"(",
"array",
"$",
"declaration",
")",
"{",
"$",
"fieldType",
"=",
"array_shift",
"(",
"$",
"declaration",
")",
";",
"$",
"class",
"=",
"\"\\\\Zerg\\\\Field\\\\\"",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
... | Create field instance by its declaration.
@param array $declaration Field declaration.
@return AbstractField Field instance.
@throws ConfigurationException If invalid declaration is presented. | [
"Create",
"field",
"instance",
"by",
"its",
"declaration",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Factory.php#L20-L31 | train |
meritoo/common-bundle | src/DependencyInjection/Configuration.php | Configuration.getApplicationNode | private function getApplicationNode(): NodeDefinition
{
$treeBuilder = new TreeBuilder('application');
return $treeBuilder
->getRootNode()
->addDefaultsIfNotSet()
->children()
->arrayNode('version')
->addDefaultsIfNotSet()
->children()
->scalarNode('file_path')
->info('Path of a file who contains version of the application')
->defaultValue(sprintf('%%kernel.project_dir%%/%s', ApplicationService::VERSION_FILE_NAME))
->cannotBeEmpty()
->end()
->end()
->end()
->scalarNode('name')
->info('Name of application. May be displayed near logo.')
->defaultValue('')
->end()
->scalarNode('description')
->info('Description of application. May be displayed near logo.')
->defaultValue('')
->end()
->scalarNode('empty_value_replacement')
->info('Replacement of empty value. May be used to filter values in templates/views.')
->defaultValue('-')
->end()
->end()
;
} | php | private function getApplicationNode(): NodeDefinition
{
$treeBuilder = new TreeBuilder('application');
return $treeBuilder
->getRootNode()
->addDefaultsIfNotSet()
->children()
->arrayNode('version')
->addDefaultsIfNotSet()
->children()
->scalarNode('file_path')
->info('Path of a file who contains version of the application')
->defaultValue(sprintf('%%kernel.project_dir%%/%s', ApplicationService::VERSION_FILE_NAME))
->cannotBeEmpty()
->end()
->end()
->end()
->scalarNode('name')
->info('Name of application. May be displayed near logo.')
->defaultValue('')
->end()
->scalarNode('description')
->info('Description of application. May be displayed near logo.')
->defaultValue('')
->end()
->scalarNode('empty_value_replacement')
->info('Replacement of empty value. May be used to filter values in templates/views.')
->defaultValue('-')
->end()
->end()
;
} | [
"private",
"function",
"getApplicationNode",
"(",
")",
":",
"NodeDefinition",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
"'application'",
")",
";",
"return",
"$",
"treeBuilder",
"->",
"getRootNode",
"(",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
... | Returns the "application" node
@return NodeDefinition | [
"Returns",
"the",
"application",
"node"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/DependencyInjection/Configuration.php#L51-L83 | train |
meritoo/common-bundle | src/DependencyInjection/Configuration.php | Configuration.getFormNode | private function getFormNode(): NodeDefinition
{
$treeBuilder = new TreeBuilder('form');
return $treeBuilder
->getRootNode()
->addDefaultsIfNotSet()
->children()
->scalarNode('novalidate')
->info('Information if HTML5 inline validation is disabled')
->defaultFalse()
->end()
->end()
;
} | php | private function getFormNode(): NodeDefinition
{
$treeBuilder = new TreeBuilder('form');
return $treeBuilder
->getRootNode()
->addDefaultsIfNotSet()
->children()
->scalarNode('novalidate')
->info('Information if HTML5 inline validation is disabled')
->defaultFalse()
->end()
->end()
;
} | [
"private",
"function",
"getFormNode",
"(",
")",
":",
"NodeDefinition",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
"'form'",
")",
";",
"return",
"$",
"treeBuilder",
"->",
"getRootNode",
"(",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"chi... | Returns the "form" node
@return NodeDefinition | [
"Returns",
"the",
"form",
"node"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/DependencyInjection/Configuration.php#L90-L104 | train |
meritoo/common-bundle | src/DependencyInjection/Configuration.php | Configuration.getDateNode | private function getDateNode(): NodeDefinition
{
$treeBuilder = new TreeBuilder('date');
return $treeBuilder
->getRootNode()
->addDefaultsIfNotSet()
->children()
->arrayNode('format')
->addDefaultsIfNotSet()
->children()
->scalarNode(DateLength::DATE)
->info('Format of date without time')
->defaultValue('d.m.Y')
->end()
->scalarNode(DateLength::DATETIME)
->info('Format of date with time')
->defaultValue('d.m.Y H:i')
->end()
->scalarNode(DateLength::TIME)
->info('Format of time without date')
->defaultValue('H:i')
->end()
->end()
->end()
->end()
;
} | php | private function getDateNode(): NodeDefinition
{
$treeBuilder = new TreeBuilder('date');
return $treeBuilder
->getRootNode()
->addDefaultsIfNotSet()
->children()
->arrayNode('format')
->addDefaultsIfNotSet()
->children()
->scalarNode(DateLength::DATE)
->info('Format of date without time')
->defaultValue('d.m.Y')
->end()
->scalarNode(DateLength::DATETIME)
->info('Format of date with time')
->defaultValue('d.m.Y H:i')
->end()
->scalarNode(DateLength::TIME)
->info('Format of time without date')
->defaultValue('H:i')
->end()
->end()
->end()
->end()
;
} | [
"private",
"function",
"getDateNode",
"(",
")",
":",
"NodeDefinition",
"{",
"$",
"treeBuilder",
"=",
"new",
"TreeBuilder",
"(",
"'date'",
")",
";",
"return",
"$",
"treeBuilder",
"->",
"getRootNode",
"(",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"chi... | Returns the "date" node
@return NodeDefinition | [
"Returns",
"the",
"date",
"node"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/DependencyInjection/Configuration.php#L111-L138 | train |
BlackBonjour/stdlib | src/Util/Assert.php | Assert.empty | public static function empty(...$values): bool
{
self::handleInvalidArguments($values);
foreach ($values as $value) {
if (empty($value) === false) {
return false;
}
}
return true;
} | php | public static function empty(...$values): bool
{
self::handleInvalidArguments($values);
foreach ($values as $value) {
if (empty($value) === false) {
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"empty",
"(",
"...",
"$",
"values",
")",
":",
"bool",
"{",
"self",
"::",
"handleInvalidArguments",
"(",
"$",
"values",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$"... | Checks if specified values are empty
@param mixed ...$values
@return boolean
@throws TypeError | [
"Checks",
"if",
"specified",
"values",
"are",
"empty"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Util/Assert.php#L28-L39 | train |
BlackBonjour/stdlib | src/Util/Assert.php | Assert.typeOf | public static function typeOf($types, ...$values): bool
{
if (is_string($types)) {
$types = [$types];
}
if (is_array($types) === false) {
throw new InvalidArgumentException(sprintf(static::MSG_TYPE_MISMATCH, gettype($types)));
}
foreach ($values as $value) {
$isObject = is_object($value);
$match = false;
$valueType = gettype($value);
// Check if current value is one of the specified types or instances
foreach ($types as $type) {
if (($isObject && $value instanceof $type) xor ($isObject === false && $valueType === $type)) {
$match = true;
break;
}
}
// Throw type error
if ($match === false) {
if ($isObject) {
$message = 'Expected value to be an instance of %s, instance of %s given!';
$valueType = get_class($value);
} else {
$message = 'Expected value to be of type %s, %s given!';
}
throw new TypeError(sprintf($message, implode(' or ', $types), $valueType));
}
}
return true;
} | php | public static function typeOf($types, ...$values): bool
{
if (is_string($types)) {
$types = [$types];
}
if (is_array($types) === false) {
throw new InvalidArgumentException(sprintf(static::MSG_TYPE_MISMATCH, gettype($types)));
}
foreach ($values as $value) {
$isObject = is_object($value);
$match = false;
$valueType = gettype($value);
// Check if current value is one of the specified types or instances
foreach ($types as $type) {
if (($isObject && $value instanceof $type) xor ($isObject === false && $valueType === $type)) {
$match = true;
break;
}
}
// Throw type error
if ($match === false) {
if ($isObject) {
$message = 'Expected value to be an instance of %s, instance of %s given!';
$valueType = get_class($value);
} else {
$message = 'Expected value to be of type %s, %s given!';
}
throw new TypeError(sprintf($message, implode(' or ', $types), $valueType));
}
}
return true;
} | [
"public",
"static",
"function",
"typeOf",
"(",
"$",
"types",
",",
"...",
"$",
"values",
")",
":",
"bool",
"{",
"if",
"(",
"is_string",
"(",
"$",
"types",
")",
")",
"{",
"$",
"types",
"=",
"[",
"$",
"types",
"]",
";",
"}",
"if",
"(",
"is_array",
... | Checks if values are of specified types or instances
@param array|string $types
@param mixed $values
@return boolean
@throws InvalidArgumentException
@throws TypeError
@see http://php.net/manual/de/function.gettype.php | [
"Checks",
"if",
"values",
"are",
"of",
"specified",
"types",
"or",
"instances"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Util/Assert.php#L83-L120 | train |
Eden-PHP/Handlebars | src/Runtime.php | Runtime.unregisterHelper | public static function unregisterHelper($name)
{
//Argument 1 must be a string
Argument::i()->test(1, 'string');
if (isset(self::$helpers[$name])) {
unset(self::$helpers[$name]);
}
} | php | public static function unregisterHelper($name)
{
//Argument 1 must be a string
Argument::i()->test(1, 'string');
if (isset(self::$helpers[$name])) {
unset(self::$helpers[$name]);
}
} | [
"public",
"static",
"function",
"unregisterHelper",
"(",
"$",
"name",
")",
"{",
"//Argument 1 must be a string",
"Argument",
"::",
"i",
"(",
")",
"->",
"test",
"(",
"1",
",",
"'string'",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"helpers",
"[... | The opposite of registerHelper
@param *string $name the helper name | [
"The",
"opposite",
"of",
"registerHelper"
] | ad961e4a6d8505212c3e90edca66e408784c38bd | https://github.com/Eden-PHP/Handlebars/blob/ad961e4a6d8505212c3e90edca66e408784c38bd/src/Runtime.php#L160-L168 | train |
Eden-PHP/Handlebars | src/Runtime.php | Runtime.unregisterPartial | public static function unregisterPartial($name)
{
//Argument 1 must be a string
Argument::i()->test(1, 'string');
if (isset(self::$partials[$name])) {
unset(self::$partials[$name]);
}
} | php | public static function unregisterPartial($name)
{
//Argument 1 must be a string
Argument::i()->test(1, 'string');
if (isset(self::$partials[$name])) {
unset(self::$partials[$name]);
}
} | [
"public",
"static",
"function",
"unregisterPartial",
"(",
"$",
"name",
")",
"{",
"//Argument 1 must be a string",
"Argument",
"::",
"i",
"(",
")",
"->",
"test",
"(",
"1",
",",
"'string'",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"partials",
... | The opposite of registerPartial
@param *string $name the partial name | [
"The",
"opposite",
"of",
"registerPartial"
] | ad961e4a6d8505212c3e90edca66e408784c38bd | https://github.com/Eden-PHP/Handlebars/blob/ad961e4a6d8505212c3e90edca66e408784c38bd/src/Runtime.php#L175-L183 | train |
shardimage/shardimage-php | src/factories/Text.php | Text.addItem | private function addItem()
{
$args = func_get_args();
$this->items[$args[0]] = implode(':', array_slice($args, 1));
return $this;
} | php | private function addItem()
{
$args = func_get_args();
$this->items[$args[0]] = implode(':', array_slice($args, 1));
return $this;
} | [
"private",
"function",
"addItem",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"items",
"[",
"$",
"args",
"[",
"0",
"]",
"]",
"=",
"implode",
"(",
"':'",
",",
"array_slice",
"(",
"$",
"args",
",",
"1",
")",
... | Adds a new property item.
@return \self | [
"Adds",
"a",
"new",
"property",
"item",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Text.php#L317-L323 | train |
shardimage/shardimage-php | src/factories/Text.php | Text.render | private function render()
{
$parts = [];
if (!empty($this->items)) {
$parts[] = implode(',', $this->items);
}
$parts[] = isset($this->items['base64']) ? self::base64Encode($this->text) : urlencode($this->text);
return implode(':', $parts);
} | php | private function render()
{
$parts = [];
if (!empty($this->items)) {
$parts[] = implode(',', $this->items);
}
$parts[] = isset($this->items['base64']) ? self::base64Encode($this->text) : urlencode($this->text);
return implode(':', $parts);
} | [
"private",
"function",
"render",
"(",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"items",
")",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"items",
")... | Renders the text URL string.
@return string | [
"Renders",
"the",
"text",
"URL",
"string",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Text.php#L330-L339 | train |
shardimage/shardimage-php | src/services/FirewallService.php | FirewallService.index | public function index($params = [], $optParams = [])
{
if ($optParams instanceof IndexParams) {
$optParams = $optParams->toArray(true);
}
return $this->sendRequest([], [
'restAction' => 'index',
'params' => $params,
'getParams' => $optParams,
], function ($response) {
$firewalls = [];
foreach ($response->data['items'] as $firewall) {
$firewalls[] = new Firewall($firewall);
}
return new Index([
'models' => $firewalls,
'totalCount' => (int) $response->data['totalCount'],
'nextPageToken' => $response->data['nextPageToken'],
]);
});
} | php | public function index($params = [], $optParams = [])
{
if ($optParams instanceof IndexParams) {
$optParams = $optParams->toArray(true);
}
return $this->sendRequest([], [
'restAction' => 'index',
'params' => $params,
'getParams' => $optParams,
], function ($response) {
$firewalls = [];
foreach ($response->data['items'] as $firewall) {
$firewalls[] = new Firewall($firewall);
}
return new Index([
'models' => $firewalls,
'totalCount' => (int) $response->data['totalCount'],
'nextPageToken' => $response->data['nextPageToken'],
]);
});
} | [
"public",
"function",
"index",
"(",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"optParams",
"instanceof",
"IndexParams",
")",
"{",
"$",
"optParams",
"=",
"$",
"optParams",
"->",
"toArray",
"(",
"true... | Fetches all firewalls.
@param array $params Required API parameters
@param FirewallIndexParams|array $optParams Optional API parameters
<li>projection - an array of projection flags: noRules, noClouds, noCloudIds
<li>order - the order of results: name, -name, created, -created
<li>maxResults - number of results
<li>pageToken - token for next result page
@return Index | [
"Fetches",
"all",
"firewalls",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/FirewallService.php#L37-L59 | train |
shardimage/shardimage-php | src/services/FirewallService.php | FirewallService.create | public function create($params, $optParams = [])
{
if (!$params instanceof Firewall) {
throw new InvalidParamException(Firewall::class.' is required!');
}
return $this->sendRequest([], [
'restAction' => 'create',
'postParams' => $params->toArray(),
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new Firewall($response->data) : $response;
});
} | php | public function create($params, $optParams = [])
{
if (!$params instanceof Firewall) {
throw new InvalidParamException(Firewall::class.' is required!');
}
return $this->sendRequest([], [
'restAction' => 'create',
'postParams' => $params->toArray(),
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new Firewall($response->data) : $response;
});
} | [
"public",
"function",
"create",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"params",
"instanceof",
"Firewall",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"Firewall",
"::",
"class",
".",
"' is req... | Creates a firewall.
@param Firewall $params Firewall object
@param array $optParams Optional API parameters
@return Firewall|Response
@throws InvalidParamException | [
"Creates",
"a",
"firewall",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/FirewallService.php#L71-L84 | train |
shardimage/shardimage-php | src/services/FirewallService.php | FirewallService.view | public function view($params, $optParams = [])
{
if ($params instanceof Firewall) {
$params = $params->id;
}
return $this->sendRequest([], [
'restAction' => 'view',
'restId' => $params,
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new Firewall($response->data) : $response;
});
} | php | public function view($params, $optParams = [])
{
if ($params instanceof Firewall) {
$params = $params->id;
}
return $this->sendRequest([], [
'restAction' => 'view',
'restId' => $params,
'getParams' => $optParams,
], function ($response) {
return isset($response->data) ? new Firewall($response->data) : $response;
});
} | [
"public",
"function",
"view",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"params",
"instanceof",
"Firewall",
")",
"{",
"$",
"params",
"=",
"$",
"params",
"->",
"id",
";",
"}",
"return",
"$",
"this",
"->",
... | Fetches a firewall.
@param Firewall|string $params Firewall object or Firewall ID
@param array $optParams Optional API parameters
@return Firewall|Response | [
"Fetches",
"a",
"firewall",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/FirewallService.php#L143-L156 | train |
koolkode/async | src/DNS/Address.php | Address.mergeWith | public function mergeWith(Address $address): self
{
return new static(...\array_merge($this->ipv4, $address->ipv4), ...\array_merge($this->ipv6, $address->ipv6));
} | php | public function mergeWith(Address $address): self
{
return new static(...\array_merge($this->ipv4, $address->ipv4), ...\array_merge($this->ipv6, $address->ipv6));
} | [
"public",
"function",
"mergeWith",
"(",
"Address",
"$",
"address",
")",
":",
"self",
"{",
"return",
"new",
"static",
"(",
"...",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"ipv4",
",",
"$",
"address",
"->",
"ipv4",
")",
",",
"...",
"\\",
"array_merge... | Merge IP address with addresses from the given address. | [
"Merge",
"IP",
"address",
"with",
"addresses",
"from",
"the",
"given",
"address",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/Address.php#L114-L117 | train |
postalservice14/php-actuator | src/Health/Indicator/CompositeHealthIndicator.php | CompositeHealthIndicator.health | public function health()
{
$healths = [];
foreach ($this->indicators as $key => $indicator) {
$healths[$key] = $indicator->health();
}
return $this->healthAggregator->aggregate($healths);
} | php | public function health()
{
$healths = [];
foreach ($this->indicators as $key => $indicator) {
$healths[$key] = $indicator->health();
}
return $this->healthAggregator->aggregate($healths);
} | [
"public",
"function",
"health",
"(",
")",
"{",
"$",
"healths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"indicators",
"as",
"$",
"key",
"=>",
"$",
"indicator",
")",
"{",
"$",
"healths",
"[",
"$",
"key",
"]",
"=",
"$",
"indicator",
"... | Return an indication of health.
@return Health | [
"Return",
"an",
"indication",
"of",
"health",
"."
] | 08e0ab32fb0cdc24356aa8cc86245fab294ec841 | https://github.com/postalservice14/php-actuator/blob/08e0ab32fb0cdc24356aa8cc86245fab294ec841/src/Health/Indicator/CompositeHealthIndicator.php#L51-L59 | train |
christianblos/codedocs | src/Helper/Filesystem.php | Filesystem.purge | public function purge($dir)
{
if (!is_dir($dir)) {
return;
}
$files = scandir($dir);
if ($files !== false) {
foreach ($files as $file) {
if ($file === '.' || $file === '..') {
continue;
}
$path = $dir . '/' . $file;
if (is_dir($path)) {
$this->purge($path);
rmdir($path);
} else {
unlink($path);
}
}
}
} | php | public function purge($dir)
{
if (!is_dir($dir)) {
return;
}
$files = scandir($dir);
if ($files !== false) {
foreach ($files as $file) {
if ($file === '.' || $file === '..') {
continue;
}
$path = $dir . '/' . $file;
if (is_dir($path)) {
$this->purge($path);
rmdir($path);
} else {
unlink($path);
}
}
}
} | [
"public",
"function",
"purge",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"return",
";",
"}",
"$",
"files",
"=",
"scandir",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"$",
"files",
"!==",
"false",
")",
"{"... | Delete all files inside a directory.
@param string $dir
@return void | [
"Delete",
"all",
"files",
"inside",
"a",
"directory",
"."
] | f78e0803ad96605b463f2e40b8e9bfe06c5a3aab | https://github.com/christianblos/codedocs/blob/f78e0803ad96605b463f2e40b8e9bfe06c5a3aab/src/Helper/Filesystem.php#L86-L110 | train |
christianblos/codedocs | src/Helper/Filesystem.php | Filesystem.copy | public function copy($src, $dest)
{
if (is_dir($src)) {
$this->ensureDir($dest);
$files = scandir($src);
foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
$this->copy($src . '/' . $file, $dest . '/' . $file);
}
}
} else {
$this->ensureDir(dirname($dest));
copy($src, $dest);
}
} | php | public function copy($src, $dest)
{
if (is_dir($src)) {
$this->ensureDir($dest);
$files = scandir($src);
foreach ($files as $file) {
if ($file !== '.' && $file !== '..') {
$this->copy($src . '/' . $file, $dest . '/' . $file);
}
}
} else {
$this->ensureDir(dirname($dest));
copy($src, $dest);
}
} | [
"public",
"function",
"copy",
"(",
"$",
"src",
",",
"$",
"dest",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"src",
")",
")",
"{",
"$",
"this",
"->",
"ensureDir",
"(",
"$",
"dest",
")",
";",
"$",
"files",
"=",
"scandir",
"(",
"$",
"src",
")",
";... | Copy file and create directory if not exists.
@param string $src
@param string $dest
@throws RuntimeException | [
"Copy",
"file",
"and",
"create",
"directory",
"if",
"not",
"exists",
"."
] | f78e0803ad96605b463f2e40b8e9bfe06c5a3aab | https://github.com/christianblos/codedocs/blob/f78e0803ad96605b463f2e40b8e9bfe06c5a3aab/src/Helper/Filesystem.php#L136-L151 | train |
davedevelopment/dspec | src/DSpec/Provider/ConfigServiceProvider.php | ConfigServiceProvider.configMerge | public static function configMerge() {
$result = array();
$args = func_get_args();
foreach ($args as $arg) {
if (!is_array($arg)) {
continue;
}
foreach ($arg as $key => $value) {
if (is_numeric($key)) {
// Renumber numeric keys as array_merge() does.
$result[] = $value;
} elseif (array_key_exists($key, $result) && is_array($result[$key]) && is_array($value)) {
// Recurse only when both values are arrays.
$result[$key] = ConfigServiceProvider::configMerge($result[$key], $value);
} else {
// Otherwise, use the latter value.
$result[$key] = $value;
}
}
}
return $result;
} | php | public static function configMerge() {
$result = array();
$args = func_get_args();
foreach ($args as $arg) {
if (!is_array($arg)) {
continue;
}
foreach ($arg as $key => $value) {
if (is_numeric($key)) {
// Renumber numeric keys as array_merge() does.
$result[] = $value;
} elseif (array_key_exists($key, $result) && is_array($result[$key]) && is_array($value)) {
// Recurse only when both values are arrays.
$result[$key] = ConfigServiceProvider::configMerge($result[$key], $value);
} else {
// Otherwise, use the latter value.
$result[$key] = $value;
}
}
}
return $result;
} | [
"public",
"static",
"function",
"configMerge",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
... | Like array_merge_recursive, but good
@see https://drupal.org/files/issues/array_merge_recursive_sucks.patch | [
"Like",
"array_merge_recursive",
"but",
"good"
] | 6077b1d213dc09f1fbcf7b260f3926a7019a0618 | https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/Provider/ConfigServiceProvider.php#L133-L154 | train |
digbang/security | src/Activations/DoctrineActivationRepository.php | DoctrineActivationRepository.completed | public function completed(UserInterface $user)
{
$queryBuilder = $this->createQueryBuilder('a');
$queryBuilder
->where('a.user = :user')
->andWhere('a.completed = :completed');
$queryBuilder
->setParameters([
'user' => $user,
'completed' => true
]);
try
{
return $queryBuilder->getQuery()->getSingleResult();
}
catch (NoResultException $e)
{
return false;
}
} | php | public function completed(UserInterface $user)
{
$queryBuilder = $this->createQueryBuilder('a');
$queryBuilder
->where('a.user = :user')
->andWhere('a.completed = :completed');
$queryBuilder
->setParameters([
'user' => $user,
'completed' => true
]);
try
{
return $queryBuilder->getQuery()->getSingleResult();
}
catch (NoResultException $e)
{
return false;
}
} | [
"public",
"function",
"completed",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'a'",
")",
";",
"$",
"queryBuilder",
"->",
"where",
"(",
"'a.user = :user'",
")",
"->",
"andWhere",
"(",
... | Checks if a valid activation has been completed.
@param \Cartalyst\Sentinel\Users\UserInterface $user
@return bool|Activation | [
"Checks",
"if",
"a",
"valid",
"activation",
"has",
"been",
"completed",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Activations/DoctrineActivationRepository.php#L71-L93 | train |
koolkode/async | src/Concurrent/Executor.php | Executor.submit | public function submit(Context $context, $work, int $priority = 0): Promise
{
$job = new class($context) extends Placeholder {
public $priority;
public $generator;
};
$job->priority = $priority;
$job->generator = ($work instanceof \Generator) ? $work : Coroutine::generate($work, $context);
for ($inserted = null, $count = \count($this->jobs), $i = 0; $i < $count; $i++) {
if ($priority <= $this->jobs[$i]->priority) {
$inserted = \array_splice($this->jobs, $i, 0, [
$job
]);
break;
}
}
if ($inserted === null) {
$this->jobs[] = $job;
}
if ($this->running < $this->concurrency) {
$this->running++;
$context->getLoop()->defer(\Closure::fromCallable([
$this,
'executeNextJob'
]));
}
return $context->keepBusy($job->promise());
} | php | public function submit(Context $context, $work, int $priority = 0): Promise
{
$job = new class($context) extends Placeholder {
public $priority;
public $generator;
};
$job->priority = $priority;
$job->generator = ($work instanceof \Generator) ? $work : Coroutine::generate($work, $context);
for ($inserted = null, $count = \count($this->jobs), $i = 0; $i < $count; $i++) {
if ($priority <= $this->jobs[$i]->priority) {
$inserted = \array_splice($this->jobs, $i, 0, [
$job
]);
break;
}
}
if ($inserted === null) {
$this->jobs[] = $job;
}
if ($this->running < $this->concurrency) {
$this->running++;
$context->getLoop()->defer(\Closure::fromCallable([
$this,
'executeNextJob'
]));
}
return $context->keepBusy($job->promise());
} | [
"public",
"function",
"submit",
"(",
"Context",
"$",
"context",
",",
"$",
"work",
",",
"int",
"$",
"priority",
"=",
"0",
")",
":",
"Promise",
"{",
"$",
"job",
"=",
"new",
"class",
"(",
"$",
"context",
")",
"extends",
"Placeholder",
"{",
"public",
"$"... | Submit a job to the executor.
Jobs are callbacks that return a result value, a promise or are generators that will be run as coroutine.
@param mixed $work Callback or Generator object.
@param int $priority
@return mixed Result of the job callback.
@throws \Throwable Error thrown by the job. | [
"Submit",
"a",
"job",
"to",
"the",
"executor",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Executor.php#L85-L121 | train |
koolkode/async | src/Concurrent/Executor.php | Executor.executeNextJob | protected function executeNextJob(): void
{
while ($this->jobs) {
$job = \array_pop($this->jobs);
if ($job->state & AbstractPromise::PENDING) {
$done = false;
(new Coroutine($job->context, $job->generator))->when(function (?\Throwable $e, $v = null) use ($job, & $done) {
if ($e) {
$job->fail($e);
} else {
$job->resolve($v);
}
if ($done) {
$this->executeNextJob();
} else {
$done = true;
}
});
if (!$done) {
$done = true;
return;
}
}
}
$this->running--;
} | php | protected function executeNextJob(): void
{
while ($this->jobs) {
$job = \array_pop($this->jobs);
if ($job->state & AbstractPromise::PENDING) {
$done = false;
(new Coroutine($job->context, $job->generator))->when(function (?\Throwable $e, $v = null) use ($job, & $done) {
if ($e) {
$job->fail($e);
} else {
$job->resolve($v);
}
if ($done) {
$this->executeNextJob();
} else {
$done = true;
}
});
if (!$done) {
$done = true;
return;
}
}
}
$this->running--;
} | [
"protected",
"function",
"executeNextJob",
"(",
")",
":",
"void",
"{",
"while",
"(",
"$",
"this",
"->",
"jobs",
")",
"{",
"$",
"job",
"=",
"\\",
"array_pop",
"(",
"$",
"this",
"->",
"jobs",
")",
";",
"if",
"(",
"$",
"job",
"->",
"state",
"&",
"Ab... | Execute the queued job with the highest priority. | [
"Execute",
"the",
"queued",
"job",
"with",
"the",
"highest",
"priority",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Executor.php#L126-L157 | train |
thelia-modules/FeatureType | Model/Base/FeatureFeatureType.php | FeatureFeatureType.setFeature | public function setFeature(ChildFeature $v = null)
{
if ($v === null) {
$this->setFeatureId(NULL);
} else {
$this->setFeatureId($v->getId());
}
$this->aFeature = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildFeature object, it will not be re-added.
if ($v !== null) {
$v->addFeatureFeatureType($this);
}
return $this;
} | php | public function setFeature(ChildFeature $v = null)
{
if ($v === null) {
$this->setFeatureId(NULL);
} else {
$this->setFeatureId($v->getId());
}
$this->aFeature = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildFeature object, it will not be re-added.
if ($v !== null) {
$v->addFeatureFeatureType($this);
}
return $this;
} | [
"public",
"function",
"setFeature",
"(",
"ChildFeature",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setFeatureId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setFeatureId",
"... | Declares an association between this object and a ChildFeature object.
@param ChildFeature $v
@return \FeatureType\Model\FeatureFeatureType The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"ChildFeature",
"object",
"."
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureType.php#L1126-L1144 | train |
thelia-modules/FeatureType | Model/Base/FeatureFeatureType.php | FeatureFeatureType.getFeature | public function getFeature(ConnectionInterface $con = null)
{
if ($this->aFeature === null && ($this->feature_id !== null)) {
$this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aFeature->addFeatureFeatureTypes($this);
*/
}
return $this->aFeature;
} | php | public function getFeature(ConnectionInterface $con = null)
{
if ($this->aFeature === null && ($this->feature_id !== null)) {
$this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aFeature->addFeatureFeatureTypes($this);
*/
}
return $this->aFeature;
} | [
"public",
"function",
"getFeature",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aFeature",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"feature_id",
"!==",
"null",
")",
")",
"{",
"$",
"this",
"->",
"... | Get the associated ChildFeature object
@param ConnectionInterface $con Optional Connection object.
@return ChildFeature The associated ChildFeature object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildFeature",
"object"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureType.php#L1154-L1168 | train |
thelia-modules/FeatureType | Model/Base/FeatureFeatureType.php | FeatureFeatureType.initFeatureTypeAvMetas | public function initFeatureTypeAvMetas($overrideExisting = true)
{
if (null !== $this->collFeatureTypeAvMetas && !$overrideExisting) {
return;
}
$this->collFeatureTypeAvMetas = new ObjectCollection();
$this->collFeatureTypeAvMetas->setModel('\FeatureType\Model\FeatureTypeAvMeta');
} | php | public function initFeatureTypeAvMetas($overrideExisting = true)
{
if (null !== $this->collFeatureTypeAvMetas && !$overrideExisting) {
return;
}
$this->collFeatureTypeAvMetas = new ObjectCollection();
$this->collFeatureTypeAvMetas->setModel('\FeatureType\Model\FeatureTypeAvMeta');
} | [
"public",
"function",
"initFeatureTypeAvMetas",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collFeatureTypeAvMetas",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
... | Initializes the collFeatureTypeAvMetas collection.
By default this just sets the collFeatureTypeAvMetas collection to an empty array (like clearcollFeatureTypeAvMetas());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collFeatureTypeAvMetas",
"collection",
"."
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureType.php#L1271-L1278 | train |
thelia-modules/FeatureType | Model/Base/FeatureFeatureType.php | FeatureFeatureType.getFeatureTypeAvMetas | public function getFeatureTypeAvMetas($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collFeatureTypeAvMetasPartial && !$this->isNew();
if (null === $this->collFeatureTypeAvMetas || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collFeatureTypeAvMetas) {
// return empty collection
$this->initFeatureTypeAvMetas();
} else {
$collFeatureTypeAvMetas = ChildFeatureTypeAvMetaQuery::create(null, $criteria)
->filterByFeatureFeatureType($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collFeatureTypeAvMetasPartial && count($collFeatureTypeAvMetas)) {
$this->initFeatureTypeAvMetas(false);
foreach ($collFeatureTypeAvMetas as $obj) {
if (false == $this->collFeatureTypeAvMetas->contains($obj)) {
$this->collFeatureTypeAvMetas->append($obj);
}
}
$this->collFeatureTypeAvMetasPartial = true;
}
reset($collFeatureTypeAvMetas);
return $collFeatureTypeAvMetas;
}
if ($partial && $this->collFeatureTypeAvMetas) {
foreach ($this->collFeatureTypeAvMetas as $obj) {
if ($obj->isNew()) {
$collFeatureTypeAvMetas[] = $obj;
}
}
}
$this->collFeatureTypeAvMetas = $collFeatureTypeAvMetas;
$this->collFeatureTypeAvMetasPartial = false;
}
}
return $this->collFeatureTypeAvMetas;
} | php | public function getFeatureTypeAvMetas($criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collFeatureTypeAvMetasPartial && !$this->isNew();
if (null === $this->collFeatureTypeAvMetas || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collFeatureTypeAvMetas) {
// return empty collection
$this->initFeatureTypeAvMetas();
} else {
$collFeatureTypeAvMetas = ChildFeatureTypeAvMetaQuery::create(null, $criteria)
->filterByFeatureFeatureType($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collFeatureTypeAvMetasPartial && count($collFeatureTypeAvMetas)) {
$this->initFeatureTypeAvMetas(false);
foreach ($collFeatureTypeAvMetas as $obj) {
if (false == $this->collFeatureTypeAvMetas->contains($obj)) {
$this->collFeatureTypeAvMetas->append($obj);
}
}
$this->collFeatureTypeAvMetasPartial = true;
}
reset($collFeatureTypeAvMetas);
return $collFeatureTypeAvMetas;
}
if ($partial && $this->collFeatureTypeAvMetas) {
foreach ($this->collFeatureTypeAvMetas as $obj) {
if ($obj->isNew()) {
$collFeatureTypeAvMetas[] = $obj;
}
}
}
$this->collFeatureTypeAvMetas = $collFeatureTypeAvMetas;
$this->collFeatureTypeAvMetasPartial = false;
}
}
return $this->collFeatureTypeAvMetas;
} | [
"public",
"function",
"getFeatureTypeAvMetas",
"(",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collFeatureTypeAvMetasPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"... | Gets an array of ChildFeatureTypeAvMeta objects which contain a foreign key that references this object.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildFeatureFeatureType is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@return Collection|ChildFeatureTypeAvMeta[] List of ChildFeatureTypeAvMeta objects
@throws PropelException | [
"Gets",
"an",
"array",
"of",
"ChildFeatureTypeAvMeta",
"objects",
"which",
"contain",
"a",
"foreign",
"key",
"that",
"references",
"this",
"object",
"."
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureType.php#L1294-L1338 | train |
thelia-modules/FeatureType | Model/Base/FeatureFeatureType.php | FeatureFeatureType.countFeatureTypeAvMetas | public function countFeatureTypeAvMetas(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collFeatureTypeAvMetasPartial && !$this->isNew();
if (null === $this->collFeatureTypeAvMetas || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collFeatureTypeAvMetas) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getFeatureTypeAvMetas());
}
$query = ChildFeatureTypeAvMetaQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByFeatureFeatureType($this)
->count($con);
}
return count($this->collFeatureTypeAvMetas);
} | php | public function countFeatureTypeAvMetas(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collFeatureTypeAvMetasPartial && !$this->isNew();
if (null === $this->collFeatureTypeAvMetas || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collFeatureTypeAvMetas) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getFeatureTypeAvMetas());
}
$query = ChildFeatureTypeAvMetaQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByFeatureFeatureType($this)
->count($con);
}
return count($this->collFeatureTypeAvMetas);
} | [
"public",
"function",
"countFeatureTypeAvMetas",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"$",
"distinct",
"=",
"false",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collFeatureTypeAvMetasPa... | Returns the number of related FeatureTypeAvMeta objects.
@param Criteria $criteria
@param boolean $distinct
@param ConnectionInterface $con
@return int Count of related FeatureTypeAvMeta objects.
@throws PropelException | [
"Returns",
"the",
"number",
"of",
"related",
"FeatureTypeAvMeta",
"objects",
"."
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureType.php#L1381-L1404 | train |
thelia-modules/FeatureType | Model/Base/FeatureFeatureType.php | FeatureFeatureType.addFeatureTypeAvMeta | public function addFeatureTypeAvMeta(ChildFeatureTypeAvMeta $l)
{
if ($this->collFeatureTypeAvMetas === null) {
$this->initFeatureTypeAvMetas();
$this->collFeatureTypeAvMetasPartial = true;
}
if (!in_array($l, $this->collFeatureTypeAvMetas->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddFeatureTypeAvMeta($l);
}
return $this;
} | php | public function addFeatureTypeAvMeta(ChildFeatureTypeAvMeta $l)
{
if ($this->collFeatureTypeAvMetas === null) {
$this->initFeatureTypeAvMetas();
$this->collFeatureTypeAvMetasPartial = true;
}
if (!in_array($l, $this->collFeatureTypeAvMetas->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
$this->doAddFeatureTypeAvMeta($l);
}
return $this;
} | [
"public",
"function",
"addFeatureTypeAvMeta",
"(",
"ChildFeatureTypeAvMeta",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collFeatureTypeAvMetas",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initFeatureTypeAvMetas",
"(",
")",
";",
"$",
"this",
"->",
"... | Method called to associate a ChildFeatureTypeAvMeta object to this object
through the ChildFeatureTypeAvMeta foreign key attribute.
@param ChildFeatureTypeAvMeta $l ChildFeatureTypeAvMeta
@return \FeatureType\Model\FeatureFeatureType The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"ChildFeatureTypeAvMeta",
"object",
"to",
"this",
"object",
"through",
"the",
"ChildFeatureTypeAvMeta",
"foreign",
"key",
"attribute",
"."
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureType.php#L1413-L1425 | train |
thelia-modules/FeatureType | Model/Base/FeatureFeatureType.php | FeatureFeatureType.getFeatureTypeAvMetasJoinFeatureAv | public function getFeatureTypeAvMetasJoinFeatureAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildFeatureTypeAvMetaQuery::create(null, $criteria);
$query->joinWith('FeatureAv', $joinBehavior);
return $this->getFeatureTypeAvMetas($query, $con);
} | php | public function getFeatureTypeAvMetasJoinFeatureAv($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildFeatureTypeAvMetaQuery::create(null, $criteria);
$query->joinWith('FeatureAv', $joinBehavior);
return $this->getFeatureTypeAvMetas($query, $con);
} | [
"public",
"function",
"getFeatureTypeAvMetasJoinFeatureAv",
"(",
"$",
"criteria",
"=",
"null",
",",
"$",
"con",
"=",
"null",
",",
"$",
"joinBehavior",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"$",
"query",
"=",
"ChildFeatureTypeAvMetaQuery",
"::",
"create",... | If this collection has already been initialized with
an identical criteria, it returns the collection.
Otherwise if this FeatureFeatureType is new, it will return
an empty collection; or if this FeatureFeatureType has previously
been saved, it will retrieve related FeatureTypeAvMetas from storage.
This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in FeatureFeatureType.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
@return Collection|ChildFeatureTypeAvMeta[] List of ChildFeatureTypeAvMeta objects | [
"If",
"this",
"collection",
"has",
"already",
"been",
"initialized",
"with",
"an",
"identical",
"criteria",
"it",
"returns",
"the",
"collection",
".",
"Otherwise",
"if",
"this",
"FeatureFeatureType",
"is",
"new",
"it",
"will",
"return",
"an",
"empty",
"collectio... | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureType.php#L1472-L1478 | train |
mylukin/pscws4 | tools/xdb.class.php | XTreeDB.Put | function Put($key, $value)
{
// check the file description
if (!$this->fd || $this->mode != 'w')
{
trigger_error("XDB::Put(), null db handler or readonly.", E_USER_WARNING);
return false;
}
// check the length
$klen = strlen($key);
$vlen = strlen($value);
if (!$klen || $klen > XDB_MAXKLEN)
return false;
// try to find the old data
$rec = $this->_get_record($key);
if (isset($rec['vlen']) && ($vlen <= $rec['vlen']))
{
// update the old value & length
if ($vlen > 0)
{
fseek($this->fd, $rec['voff'], SEEK_SET);
fwrite($this->fd, $value, $vlen);
}
if ($vlen < $rec['vlen'])
{
$newlen = $rec['len'] + $vlen - $rec['vlen'];
$newbuf = pack('I', $newlen);
fseek($this->fd, $rec['poff'] + 4, SEEK_SET);
fwrite($this->fd, $newbuf, 4);
}
return true;
}
// 构造数据
$new = array('loff' => 0, 'llen' => 0, 'roff' => 0, 'rlen' => 0);
if (isset($rec['vlen']))
{
$new['loff'] = $rec['loff'];
$new['llen'] = $rec['llen'];
$new['roff'] = $rec['roff'];
$new['rlen'] = $rec['rlen'];
}
$buf = pack('IIIIC', $new['loff'], $new['llen'], $new['roff'], $new['rlen'], $klen);
$buf .= $key . $value;
$len = $klen + $vlen + 17;
$off = $this->fsize;
fseek($this->fd, $off, SEEK_SET);
fwrite($this->fd, $buf, $len);
$this->fsize += $len;
$pbuf = pack('II', $off, $len);
fseek($this->fd, $rec['poff'], SEEK_SET);
fwrite($this->fd, $pbuf, 8);
return true;
} | php | function Put($key, $value)
{
// check the file description
if (!$this->fd || $this->mode != 'w')
{
trigger_error("XDB::Put(), null db handler or readonly.", E_USER_WARNING);
return false;
}
// check the length
$klen = strlen($key);
$vlen = strlen($value);
if (!$klen || $klen > XDB_MAXKLEN)
return false;
// try to find the old data
$rec = $this->_get_record($key);
if (isset($rec['vlen']) && ($vlen <= $rec['vlen']))
{
// update the old value & length
if ($vlen > 0)
{
fseek($this->fd, $rec['voff'], SEEK_SET);
fwrite($this->fd, $value, $vlen);
}
if ($vlen < $rec['vlen'])
{
$newlen = $rec['len'] + $vlen - $rec['vlen'];
$newbuf = pack('I', $newlen);
fseek($this->fd, $rec['poff'] + 4, SEEK_SET);
fwrite($this->fd, $newbuf, 4);
}
return true;
}
// 构造数据
$new = array('loff' => 0, 'llen' => 0, 'roff' => 0, 'rlen' => 0);
if (isset($rec['vlen']))
{
$new['loff'] = $rec['loff'];
$new['llen'] = $rec['llen'];
$new['roff'] = $rec['roff'];
$new['rlen'] = $rec['rlen'];
}
$buf = pack('IIIIC', $new['loff'], $new['llen'], $new['roff'], $new['rlen'], $klen);
$buf .= $key . $value;
$len = $klen + $vlen + 17;
$off = $this->fsize;
fseek($this->fd, $off, SEEK_SET);
fwrite($this->fd, $buf, $len);
$this->fsize += $len;
$pbuf = pack('II', $off, $len);
fseek($this->fd, $rec['poff'], SEEK_SET);
fwrite($this->fd, $pbuf, 8);
return true;
} | [
"function",
"Put",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// check the file description",
"if",
"(",
"!",
"$",
"this",
"->",
"fd",
"||",
"$",
"this",
"->",
"mode",
"!=",
"'w'",
")",
"{",
"trigger_error",
"(",
"\"XDB::Put(), null db handler or readonl... | Insert Or Update the value | [
"Insert",
"Or",
"Update",
"the",
"value"
] | b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b | https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L198-L256 | train |
mylukin/pscws4 | tools/xdb.class.php | XTreeDB.Draw | function Draw($i = -1)
{
if ($i < 0 || $i >= $this->hash_prime)
{
$i = 0;
$j = $this->hash_prime;
}
else
{
$j = $i + 1;
}
echo "Draw the XDB data [$i ~ $j]. (" . trim($this->Version()) . ")\n\n";
while ($i < $j)
{
$poff = $i * 8 + 32;
fseek($this->fd, $poff, SEEK_SET);
$buf = fread($this->fd, 8);
if (strlen($buf) != 8) break;
$ptr = unpack('Ioff/Ilen', $buf);
$this->_cur_depth = 0;
$this->_node_num = 0;
$this->_draw_node($ptr['off'], $ptr['len']);
echo "-------------------------------------------\n";
echo "Tree(xdb) [$i] max_depth: {$this->_cur_depth} nodes_num: {$this->_node_num}\n";
$i++;
}
} | php | function Draw($i = -1)
{
if ($i < 0 || $i >= $this->hash_prime)
{
$i = 0;
$j = $this->hash_prime;
}
else
{
$j = $i + 1;
}
echo "Draw the XDB data [$i ~ $j]. (" . trim($this->Version()) . ")\n\n";
while ($i < $j)
{
$poff = $i * 8 + 32;
fseek($this->fd, $poff, SEEK_SET);
$buf = fread($this->fd, 8);
if (strlen($buf) != 8) break;
$ptr = unpack('Ioff/Ilen', $buf);
$this->_cur_depth = 0;
$this->_node_num = 0;
$this->_draw_node($ptr['off'], $ptr['len']);
echo "-------------------------------------------\n";
echo "Tree(xdb) [$i] max_depth: {$this->_cur_depth} nodes_num: {$this->_node_num}\n";
$i++;
}
} | [
"function",
"Draw",
"(",
"$",
"i",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"i",
"<",
"0",
"||",
"$",
"i",
">=",
"$",
"this",
"->",
"hash_prime",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"j",
"=",
"$",
"this",
"->",
"hash_prime",
";",
"}",... | Traversal every tree... & debug to test | [
"Traversal",
"every",
"tree",
"...",
"&",
"debug",
"to",
"test"
] | b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b | https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L341-L369 | train |
mylukin/pscws4 | tools/xdb.class.php | XTreeDB.Version | function Version()
{
$ver = (is_null($this) ? XDB_VERSION : $this->version);
$str = sprintf("%s/%d.%d", XDB_TAGNAME, ($ver >> 5), ($ver & 0x1f));
if (!is_null($this)) $str .= " <base={$this->hash_base}, prime={$this->hash_prime}>";
return $str;
} | php | function Version()
{
$ver = (is_null($this) ? XDB_VERSION : $this->version);
$str = sprintf("%s/%d.%d", XDB_TAGNAME, ($ver >> 5), ($ver & 0x1f));
if (!is_null($this)) $str .= " <base={$this->hash_base}, prime={$this->hash_prime}>";
return $str;
} | [
"function",
"Version",
"(",
")",
"{",
"$",
"ver",
"=",
"(",
"is_null",
"(",
"$",
"this",
")",
"?",
"XDB_VERSION",
":",
"$",
"this",
"->",
"version",
")",
";",
"$",
"str",
"=",
"sprintf",
"(",
"\"%s/%d.%d\"",
",",
"XDB_TAGNAME",
",",
"(",
"$",
"ver"... | Show the version | [
"Show",
"the",
"version"
] | b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b | https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L379-L385 | train |
mylukin/pscws4 | tools/xdb.class.php | XTreeDB.Close | function Close()
{
if (!$this->fd)
return;
if ($this->mode == 'w')
{
$buf = pack('I', $this->fsize);
fseek($this->fd, 12, SEEK_SET);
fwrite($this->fd, $buf, 4);
flock($this->fd, LOCK_UN);
}
fclose($this->fd);
$this->fd = false;
} | php | function Close()
{
if (!$this->fd)
return;
if ($this->mode == 'w')
{
$buf = pack('I', $this->fsize);
fseek($this->fd, 12, SEEK_SET);
fwrite($this->fd, $buf, 4);
flock($this->fd, LOCK_UN);
}
fclose($this->fd);
$this->fd = false;
} | [
"function",
"Close",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fd",
")",
"return",
";",
"if",
"(",
"$",
"this",
"->",
"mode",
"==",
"'w'",
")",
"{",
"$",
"buf",
"=",
"pack",
"(",
"'I'",
",",
"$",
"this",
"->",
"fsize",
")",
";",
"f... | Close the DB | [
"Close",
"the",
"DB"
] | b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b | https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L388-L402 | train |
mylukin/pscws4 | tools/xdb.class.php | XTreeDB.Optimize | function Optimize($i = -1)
{
// check the file description
if (!$this->fd || $this->mode != 'w')
{
trigger_error("XDB::Optimize(), null db handler or readonly.", E_USER_WARNING);
return false;
}
// get the index zone:
if ($i < 0 || $i >= $this->hash_prime)
{
$i = 0;
$j = $this->hash_prime;
}
else
{
$j = $i + 1;
}
// optimize every index
while ($i < $j)
{
$this->_optimize_index($i);
$i++;
}
} | php | function Optimize($i = -1)
{
// check the file description
if (!$this->fd || $this->mode != 'w')
{
trigger_error("XDB::Optimize(), null db handler or readonly.", E_USER_WARNING);
return false;
}
// get the index zone:
if ($i < 0 || $i >= $this->hash_prime)
{
$i = 0;
$j = $this->hash_prime;
}
else
{
$j = $i + 1;
}
// optimize every index
while ($i < $j)
{
$this->_optimize_index($i);
$i++;
}
} | [
"function",
"Optimize",
"(",
"$",
"i",
"=",
"-",
"1",
")",
"{",
"// check the file description",
"if",
"(",
"!",
"$",
"this",
"->",
"fd",
"||",
"$",
"this",
"->",
"mode",
"!=",
"'w'",
")",
"{",
"trigger_error",
"(",
"\"XDB::Optimize(), null db handler or rea... | Optimize the tree | [
"Optimize",
"the",
"tree"
] | b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b | https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L405-L431 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.