repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
heidelpay/PhpDoc | src/phpDocumentor/Plugin/Core/ServiceProvider.php | ServiceProvider.registerDependenciesOnXsltExtension | private function registerDependenciesOnXsltExtension(Application $app)
{
Xslt\Extension::$routers = $app['transformer.routing.queue'];
Xslt\Extension::$descriptorBuilder = $app['descriptor.builder'];
} | php | private function registerDependenciesOnXsltExtension(Application $app)
{
Xslt\Extension::$routers = $app['transformer.routing.queue'];
Xslt\Extension::$descriptorBuilder = $app['descriptor.builder'];
} | [
"private",
"function",
"registerDependenciesOnXsltExtension",
"(",
"Application",
"$",
"app",
")",
"{",
"Xslt",
"\\",
"Extension",
"::",
"$",
"routers",
"=",
"$",
"app",
"[",
"'transformer.routing.queue'",
"]",
";",
"Xslt",
"\\",
"Extension",
"::",
"$",
"descriptorBuilder",
"=",
"$",
"app",
"[",
"'descriptor.builder'",
"]",
";",
"}"
] | Registers the Routing Queue and Descriptor Builder objects on the XSLT Extension class.
In every template we use PHP helpers in order to be able to have routing that is universal between templates and
convert Markdown text into HTML (for example). The only way for XSL to do this is by having global functions or
static methods in a class because you cannot inject an object into an XSL processor.
With this method we make sure that all dependencies used by the static methods are injected as static properties.
@param Application $app
@return void | [
"Registers",
"the",
"Routing",
"Queue",
"and",
"Descriptor",
"Builder",
"objects",
"on",
"the",
"XSLT",
"Extension",
"class",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/ServiceProvider.php#L95-L99 |
hametuha/wpametu | src/WPametu/UI/Admin/EmptyMetaBox.php | EmptyMetaBox.adminMetaBoxes | public function adminMetaBoxes($post_type, $post){
if( false !== array_search($post_type, $this->post_types) ){
switch($this->hook){
case 'post_submitbox_misc_actions':
case 'post_submitbox_start':
add_action($this->hook, function() use ($post){
if( $this->nonce_key ){
wp_nonce_field($this->nonce_action, $this->nonce_key);
}
$this->editFormX($post);
}, $this->hook_priority);
break;
case 'post_edit_form_tag':
case 'edit_form_top':
case 'edit_form_before_permalink':
case 'edit_form_after_title':
case 'edit_form_after_editor':
case 'dbx_post_sidebar':
add_action($this->hook, function(\WP_Post $post){
if( $this->nonce_key ){
wp_nonce_field($this->nonce_action, $this->nonce_key);
}
$this->editFormX($post);
});
break;
default:
$s = explode('\\', get_called_class());
$name = $this->string->camel_to_hyphen($s[count($s) - 1]);
add_meta_box("metabox-$name", $this->title, function( \WP_Post $post, array $screen ){
if( $this->nonce_key ){
wp_nonce_field($this->nonce_action, $this->nonce_key);
}
$this->doMetaBox($post, $screen);
}, $post_type, $this->context, $this->priority);
break;
}
}
} | php | public function adminMetaBoxes($post_type, $post){
if( false !== array_search($post_type, $this->post_types) ){
switch($this->hook){
case 'post_submitbox_misc_actions':
case 'post_submitbox_start':
add_action($this->hook, function() use ($post){
if( $this->nonce_key ){
wp_nonce_field($this->nonce_action, $this->nonce_key);
}
$this->editFormX($post);
}, $this->hook_priority);
break;
case 'post_edit_form_tag':
case 'edit_form_top':
case 'edit_form_before_permalink':
case 'edit_form_after_title':
case 'edit_form_after_editor':
case 'dbx_post_sidebar':
add_action($this->hook, function(\WP_Post $post){
if( $this->nonce_key ){
wp_nonce_field($this->nonce_action, $this->nonce_key);
}
$this->editFormX($post);
});
break;
default:
$s = explode('\\', get_called_class());
$name = $this->string->camel_to_hyphen($s[count($s) - 1]);
add_meta_box("metabox-$name", $this->title, function( \WP_Post $post, array $screen ){
if( $this->nonce_key ){
wp_nonce_field($this->nonce_action, $this->nonce_key);
}
$this->doMetaBox($post, $screen);
}, $post_type, $this->context, $this->priority);
break;
}
}
} | [
"public",
"function",
"adminMetaBoxes",
"(",
"$",
"post_type",
",",
"$",
"post",
")",
"{",
"if",
"(",
"false",
"!==",
"array_search",
"(",
"$",
"post_type",
",",
"$",
"this",
"->",
"post_types",
")",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"hook",
")",
"{",
"case",
"'post_submitbox_misc_actions'",
":",
"case",
"'post_submitbox_start'",
":",
"add_action",
"(",
"$",
"this",
"->",
"hook",
",",
"function",
"(",
")",
"use",
"(",
"$",
"post",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nonce_key",
")",
"{",
"wp_nonce_field",
"(",
"$",
"this",
"->",
"nonce_action",
",",
"$",
"this",
"->",
"nonce_key",
")",
";",
"}",
"$",
"this",
"->",
"editFormX",
"(",
"$",
"post",
")",
";",
"}",
",",
"$",
"this",
"->",
"hook_priority",
")",
";",
"break",
";",
"case",
"'post_edit_form_tag'",
":",
"case",
"'edit_form_top'",
":",
"case",
"'edit_form_before_permalink'",
":",
"case",
"'edit_form_after_title'",
":",
"case",
"'edit_form_after_editor'",
":",
"case",
"'dbx_post_sidebar'",
":",
"add_action",
"(",
"$",
"this",
"->",
"hook",
",",
"function",
"(",
"\\",
"WP_Post",
"$",
"post",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nonce_key",
")",
"{",
"wp_nonce_field",
"(",
"$",
"this",
"->",
"nonce_action",
",",
"$",
"this",
"->",
"nonce_key",
")",
";",
"}",
"$",
"this",
"->",
"editFormX",
"(",
"$",
"post",
")",
";",
"}",
")",
";",
"break",
";",
"default",
":",
"$",
"s",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_called_class",
"(",
")",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"string",
"->",
"camel_to_hyphen",
"(",
"$",
"s",
"[",
"count",
"(",
"$",
"s",
")",
"-",
"1",
"]",
")",
";",
"add_meta_box",
"(",
"\"metabox-$name\"",
",",
"$",
"this",
"->",
"title",
",",
"function",
"(",
"\\",
"WP_Post",
"$",
"post",
",",
"array",
"$",
"screen",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"nonce_key",
")",
"{",
"wp_nonce_field",
"(",
"$",
"this",
"->",
"nonce_action",
",",
"$",
"this",
"->",
"nonce_key",
")",
";",
"}",
"$",
"this",
"->",
"doMetaBox",
"(",
"$",
"post",
",",
"$",
"screen",
")",
";",
"}",
",",
"$",
"post_type",
",",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"priority",
")",
";",
"break",
";",
"}",
"}",
"}"
] | Register meta boxes
@param string $post_type
@param \WP_Post $post | [
"Register",
"meta",
"boxes"
] | train | https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Admin/EmptyMetaBox.php#L116-L154 |
scherersoftware/cake-monitor | src/Controller/AppController.php | AppController.beforeFilter | public function beforeFilter(\Cake\Event\Event $event)
{
$this->_monitor = new MonitorHandler($this->request, $this->response);
$this->_monitor->handleAuth();
$this->_monitor->handleChecks();
} | php | public function beforeFilter(\Cake\Event\Event $event)
{
$this->_monitor = new MonitorHandler($this->request, $this->response);
$this->_monitor->handleAuth();
$this->_monitor->handleChecks();
} | [
"public",
"function",
"beforeFilter",
"(",
"\\",
"Cake",
"\\",
"Event",
"\\",
"Event",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"_monitor",
"=",
"new",
"MonitorHandler",
"(",
"$",
"this",
"->",
"request",
",",
"$",
"this",
"->",
"response",
")",
";",
"$",
"this",
"->",
"_monitor",
"->",
"handleAuth",
"(",
")",
";",
"$",
"this",
"->",
"_monitor",
"->",
"handleChecks",
"(",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/scherersoftware/cake-monitor/blob/dbe07a1aac41b3db15e631d9e59cf26214bf6938/src/Controller/AppController.php#L21-L28 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.fetchData | public function fetchData(
string $endpoint,
ParameterBuilderInterface $paramBuilder
): array {
$url = $this->getEndpoint($endpoint) . $paramBuilder->buildQueryString();
return $this->processResponse($this->sendRequest($url));
} | php | public function fetchData(
string $endpoint,
ParameterBuilderInterface $paramBuilder
): array {
$url = $this->getEndpoint($endpoint) . $paramBuilder->buildQueryString();
return $this->processResponse($this->sendRequest($url));
} | [
"public",
"function",
"fetchData",
"(",
"string",
"$",
"endpoint",
",",
"ParameterBuilderInterface",
"$",
"paramBuilder",
")",
":",
"array",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getEndpoint",
"(",
"$",
"endpoint",
")",
".",
"$",
"paramBuilder",
"->",
"buildQueryString",
"(",
")",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"url",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L86-L93 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.fetchDataAsJson | public function fetchDataAsJson(
string $endpoint,
ParameterBuilderInterface $paramBuilder
): string {
$url = $this->getEndpoint($endpoint) . $paramBuilder->buildQueryString();
$response = $this->sendRequest($url);
return $response->getBody()->getContents();
} | php | public function fetchDataAsJson(
string $endpoint,
ParameterBuilderInterface $paramBuilder
): string {
$url = $this->getEndpoint($endpoint) . $paramBuilder->buildQueryString();
$response = $this->sendRequest($url);
return $response->getBody()->getContents();
} | [
"public",
"function",
"fetchDataAsJson",
"(",
"string",
"$",
"endpoint",
",",
"ParameterBuilderInterface",
"$",
"paramBuilder",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getEndpoint",
"(",
"$",
"endpoint",
")",
".",
"$",
"paramBuilder",
"->",
"buildQueryString",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"url",
")",
";",
"return",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L98-L107 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.scroll | public function scroll(string $endpoint): array
{
$url = $this->baseUrl . $endpoint;
return $this->processResponse($this->sendRequest($url));
} | php | public function scroll(string $endpoint): array
{
$url = $this->baseUrl . $endpoint;
return $this->processResponse($this->sendRequest($url));
} | [
"public",
"function",
"scroll",
"(",
"string",
"$",
"endpoint",
")",
":",
"array",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"baseUrl",
".",
"$",
"endpoint",
";",
"return",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"url",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L112-L117 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.scrollJson | public function scrollJson(string $endpoint): string
{
$url = $this->baseUrl . $endpoint;
return $this->sendRequest($url)->getBody()->getContents();
} | php | public function scrollJson(string $endpoint): string
{
$url = $this->baseUrl . $endpoint;
return $this->sendRequest($url)->getBody()->getContents();
} | [
"public",
"function",
"scrollJson",
"(",
"string",
"$",
"endpoint",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"baseUrl",
".",
"$",
"endpoint",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"url",
")",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L122-L127 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.getScrollNextPage | public function getScrollNextPage(
ResponseInterface $response = null
): string {
if (null === $response) {
$response = $this->response;
}
return $this->getScrollHeader($response, self::SCROLL_NEXT_PAGE);
} | php | public function getScrollNextPage(
ResponseInterface $response = null
): string {
if (null === $response) {
$response = $this->response;
}
return $this->getScrollHeader($response, self::SCROLL_NEXT_PAGE);
} | [
"public",
"function",
"getScrollNextPage",
"(",
"ResponseInterface",
"$",
"response",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"response",
";",
"}",
"return",
"$",
"this",
"->",
"getScrollHeader",
"(",
"$",
"response",
",",
"self",
"::",
"SCROLL_NEXT_PAGE",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L132-L140 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.getScrollCount | public function getScrollCount(ResponseInterface $response = null): int
{
if (null === $response) {
$response = $this->response;
}
return (int)$this->getScrollHeader($response, self::SCROLL_COUNT);
} | php | public function getScrollCount(ResponseInterface $response = null): int
{
if (null === $response) {
$response = $this->response;
}
return (int)$this->getScrollHeader($response, self::SCROLL_COUNT);
} | [
"public",
"function",
"getScrollCount",
"(",
"ResponseInterface",
"$",
"response",
"=",
"null",
")",
":",
"int",
"{",
"if",
"(",
"null",
"===",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"response",
";",
"}",
"return",
"(",
"int",
")",
"$",
"this",
"->",
"getScrollHeader",
"(",
"$",
"response",
",",
"self",
"::",
"SCROLL_COUNT",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L145-L152 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.search | public function search(
string $search,
string $endpoint,
ParameterBuilderInterface $paramBuilder
): array {
$paramBuilder->setSearch($search);
return $this->fetchData($endpoint, $paramBuilder);
} | php | public function search(
string $search,
string $endpoint,
ParameterBuilderInterface $paramBuilder
): array {
$paramBuilder->setSearch($search);
return $this->fetchData($endpoint, $paramBuilder);
} | [
"public",
"function",
"search",
"(",
"string",
"$",
"search",
",",
"string",
"$",
"endpoint",
",",
"ParameterBuilderInterface",
"$",
"paramBuilder",
")",
":",
"array",
"{",
"$",
"paramBuilder",
"->",
"setSearch",
"(",
"$",
"search",
")",
";",
"return",
"$",
"this",
"->",
"fetchData",
"(",
"$",
"endpoint",
",",
"$",
"paramBuilder",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L157-L165 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.sendRequest | public function sendRequest(string $url): ResponseInterface
{
try {
$response = $this->httpClient->request('GET', $url, [
'headers' => [
'user-key' => $this->apiKey,
'Accept' => 'application/json',
],
]);
} catch (BadResponseException $e) {
$response = $e->getResponse();
}
$this->response = $response;
return $response;
} | php | public function sendRequest(string $url): ResponseInterface
{
try {
$response = $this->httpClient->request('GET', $url, [
'headers' => [
'user-key' => $this->apiKey,
'Accept' => 'application/json',
],
]);
} catch (BadResponseException $e) {
$response = $e->getResponse();
}
$this->response = $response;
return $response;
} | [
"public",
"function",
"sendRequest",
"(",
"string",
"$",
"url",
")",
":",
"ResponseInterface",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
",",
"[",
"'headers'",
"=>",
"[",
"'user-key'",
"=>",
"$",
"this",
"->",
"apiKey",
",",
"'Accept'",
"=>",
"'application/json'",
",",
"]",
",",
"]",
")",
";",
"}",
"catch",
"(",
"BadResponseException",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
";",
"}",
"$",
"this",
"->",
"response",
"=",
"$",
"response",
";",
"return",
"$",
"response",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L394-L410 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.processResponse | public function processResponse(ResponseInterface $response): array
{
$contents = $response->getBody()->getContents();
$decodedJson = json_decode($contents, true);
if (null === $decodedJson) {
// When API returns a string, return type doesn't change (returns array with the string inside)
$decodedJson = [$contents];
}
return $decodedJson;
} | php | public function processResponse(ResponseInterface $response): array
{
$contents = $response->getBody()->getContents();
$decodedJson = json_decode($contents, true);
if (null === $decodedJson) {
// When API returns a string, return type doesn't change (returns array with the string inside)
$decodedJson = [$contents];
}
return $decodedJson;
} | [
"public",
"function",
"processResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"array",
"{",
"$",
"contents",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"$",
"decodedJson",
"=",
"json_decode",
"(",
"$",
"contents",
",",
"true",
")",
";",
"if",
"(",
"null",
"===",
"$",
"decodedJson",
")",
"{",
"// When API returns a string, return type doesn't change (returns array with the string inside)",
"$",
"decodedJson",
"=",
"[",
"$",
"contents",
"]",
";",
"}",
"return",
"$",
"decodedJson",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L415-L426 |
EmanuelNikolov/IgdbApiBundle | Igdb/IgdbWrapper.php | IgdbWrapper.getScrollHeader | public function getScrollHeader(
ResponseInterface $response,
string $header
): string {
$headerData = $response->getHeader($header);
if (empty($headerData)) {
throw new ScrollHeaderNotFoundException($header . " Header doesn't exist.");
}
return $headerData[0];
} | php | public function getScrollHeader(
ResponseInterface $response,
string $header
): string {
$headerData = $response->getHeader($header);
if (empty($headerData)) {
throw new ScrollHeaderNotFoundException($header . " Header doesn't exist.");
}
return $headerData[0];
} | [
"public",
"function",
"getScrollHeader",
"(",
"ResponseInterface",
"$",
"response",
",",
"string",
"$",
"header",
")",
":",
"string",
"{",
"$",
"headerData",
"=",
"$",
"response",
"->",
"getHeader",
"(",
"$",
"header",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"headerData",
")",
")",
"{",
"throw",
"new",
"ScrollHeaderNotFoundException",
"(",
"$",
"header",
".",
"\" Header doesn't exist.\"",
")",
";",
"}",
"return",
"$",
"headerData",
"[",
"0",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/EmanuelNikolov/IgdbApiBundle/blob/eedfc80298064a424990ebc5924649afdeaa00c8/Igdb/IgdbWrapper.php#L456-L467 |
austinkregel/laravel-identicon | src/Identicon/IdenticonServiceProvider.php | IdenticonServiceProvider.register | public function register()
{
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
// Register the alias.
$loader->alias('Identicon', \Identicon\Identicon::class);
} | php | public function register()
{
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
// Register the alias.
$loader->alias('Identicon', \Identicon\Identicon::class);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"loader",
"=",
"\\",
"Illuminate",
"\\",
"Foundation",
"\\",
"AliasLoader",
"::",
"getInstance",
"(",
")",
";",
"// Register the alias.",
"$",
"loader",
"->",
"alias",
"(",
"'Identicon'",
",",
"\\",
"Identicon",
"\\",
"Identicon",
"::",
"class",
")",
";",
"}"
] | Register the service provider. | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/austinkregel/laravel-identicon/blob/4f49af23730785e935184157641b15b0b78ac999/src/Identicon/IdenticonServiceProvider.php#L19-L24 |
austinkregel/laravel-identicon | src/Identicon/IdenticonServiceProvider.php | IdenticonServiceProvider.boot | public function boot()
{
$this->app->booted(function () {
if (!$this->app->routesAreCached() && !config('kregel.identicon.local-routes')) {
require __DIR__.'/Http/routes.php';
}
});
$this->publishes([
__DIR__.'/../config/config.php' => config_path('kregel/identicon.php'),
], 'config');
} | php | public function boot()
{
$this->app->booted(function () {
if (!$this->app->routesAreCached() && !config('kregel.identicon.local-routes')) {
require __DIR__.'/Http/routes.php';
}
});
$this->publishes([
__DIR__.'/../config/config.php' => config_path('kregel/identicon.php'),
], 'config');
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"booted",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"routesAreCached",
"(",
")",
"&&",
"!",
"config",
"(",
"'kregel.identicon.local-routes'",
")",
")",
"{",
"require",
"__DIR__",
".",
"'/Http/routes.php'",
";",
"}",
"}",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../config/config.php'",
"=>",
"config_path",
"(",
"'kregel/identicon.php'",
")",
",",
"]",
",",
"'config'",
")",
";",
"}"
] | Bootstrap any application services. | [
"Bootstrap",
"any",
"application",
"services",
"."
] | train | https://github.com/austinkregel/laravel-identicon/blob/4f49af23730785e935184157641b15b0b78ac999/src/Identicon/IdenticonServiceProvider.php#L29-L39 |
InactiveProjects/limoncello-illuminate | app/Api/UsersApi.php | UsersApi.indexPosts | public function indexPosts($userId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index user posts started.', [User::FIELD_ID => $userId]);
$result = $this->indexRelationship($userId, User::REL_POSTS, $parameters);
$this->getLogger()->debug('Index user posts completed.');
return $result;
} | php | public function indexPosts($userId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index user posts started.', [User::FIELD_ID => $userId]);
$result = $this->indexRelationship($userId, User::REL_POSTS, $parameters);
$this->getLogger()->debug('Index user posts completed.');
return $result;
} | [
"public",
"function",
"indexPosts",
"(",
"$",
"userId",
",",
"EncodingParametersInterface",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index user posts started.'",
",",
"[",
"User",
"::",
"FIELD_ID",
"=>",
"$",
"userId",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"indexRelationship",
"(",
"$",
"userId",
",",
"User",
"::",
"REL_POSTS",
",",
"$",
"parameters",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index user posts completed.'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | @param int|string $userId
@param EncodingParametersInterface $parameters
@return PagedDataInterface | [
"@param",
"int|string",
"$userId",
"@param",
"EncodingParametersInterface",
"$parameters"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/UsersApi.php#L49-L58 |
InactiveProjects/limoncello-illuminate | app/Api/UsersApi.php | UsersApi.indexComments | public function indexComments($userId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index user comments started.', [User::FIELD_ID => $userId]);
$result = $this->indexRelationship($userId, User::REL_COMMENTS, $parameters);
$this->getLogger()->debug('Index user comments completed.');
return $result;
} | php | public function indexComments($userId, EncodingParametersInterface $parameters)
{
$this->getLogger()->debug('Index user comments started.', [User::FIELD_ID => $userId]);
$result = $this->indexRelationship($userId, User::REL_COMMENTS, $parameters);
$this->getLogger()->debug('Index user comments completed.');
return $result;
} | [
"public",
"function",
"indexComments",
"(",
"$",
"userId",
",",
"EncodingParametersInterface",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index user comments started.'",
",",
"[",
"User",
"::",
"FIELD_ID",
"=>",
"$",
"userId",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"indexRelationship",
"(",
"$",
"userId",
",",
"User",
"::",
"REL_COMMENTS",
",",
"$",
"parameters",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Index user comments completed.'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | @param int|string $userId
@param EncodingParametersInterface $parameters
@return PagedDataInterface | [
"@param",
"int|string",
"$userId",
"@param",
"EncodingParametersInterface",
"$parameters"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/UsersApi.php#L66-L75 |
gdbots/iam-php | src/GetAppHistoryRequestHandler.php | GetAppHistoryRequestHandler.canReadStream | protected function canReadStream(GetEventsRequest $request, Pbjx $pbjx): bool
{
/** @var StreamId $streamId */
$streamId = $request->get('stream_id');
$validTopics = [];
/** @var Schema $schema */
foreach (AppV1Mixin::findAll() as $schema) {
$qname = $schema->getQName();
// e.g. "sms-app.history", "ios-app.history"
$validTopics[$qname->getMessage() . '.history'] = true;
}
return isset($validTopics[$streamId->getTopic()]);
} | php | protected function canReadStream(GetEventsRequest $request, Pbjx $pbjx): bool
{
/** @var StreamId $streamId */
$streamId = $request->get('stream_id');
$validTopics = [];
/** @var Schema $schema */
foreach (AppV1Mixin::findAll() as $schema) {
$qname = $schema->getQName();
// e.g. "sms-app.history", "ios-app.history"
$validTopics[$qname->getMessage() . '.history'] = true;
}
return isset($validTopics[$streamId->getTopic()]);
} | [
"protected",
"function",
"canReadStream",
"(",
"GetEventsRequest",
"$",
"request",
",",
"Pbjx",
"$",
"pbjx",
")",
":",
"bool",
"{",
"/** @var StreamId $streamId */",
"$",
"streamId",
"=",
"$",
"request",
"->",
"get",
"(",
"'stream_id'",
")",
";",
"$",
"validTopics",
"=",
"[",
"]",
";",
"/** @var Schema $schema */",
"foreach",
"(",
"AppV1Mixin",
"::",
"findAll",
"(",
")",
"as",
"$",
"schema",
")",
"{",
"$",
"qname",
"=",
"$",
"schema",
"->",
"getQName",
"(",
")",
";",
"// e.g. \"sms-app.history\", \"ios-app.history\"",
"$",
"validTopics",
"[",
"$",
"qname",
"->",
"getMessage",
"(",
")",
".",
"'.history'",
"]",
"=",
"true",
";",
"}",
"return",
"isset",
"(",
"$",
"validTopics",
"[",
"$",
"streamId",
"->",
"getTopic",
"(",
")",
"]",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/GetAppHistoryRequestHandler.php#L19-L33 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.lookup | public function lookup($context, $path, $require = false)
{
if (empty($path)) {
throw new \InvalidArgumentException("Passed lookup path is empty.");
}
if (empty($context)) {
throw new \InvalidArgumentException("Specified context is empty while resolving path " . json_encode($path));
}
return PropertyAccessor::getByPath($context, $this->path($path), $require);
} | php | public function lookup($context, $path, $require = false)
{
if (empty($path)) {
throw new \InvalidArgumentException("Passed lookup path is empty.");
}
if (empty($context)) {
throw new \InvalidArgumentException("Specified context is empty while resolving path " . json_encode($path));
}
return PropertyAccessor::getByPath($context, $this->path($path), $require);
} | [
"public",
"function",
"lookup",
"(",
"$",
"context",
",",
"$",
"path",
",",
"$",
"require",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Passed lookup path is empty.\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"context",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Specified context is empty while resolving path \"",
".",
"json_encode",
"(",
"$",
"path",
")",
")",
";",
"}",
"return",
"PropertyAccessor",
"::",
"getByPath",
"(",
"$",
"context",
",",
"$",
"this",
"->",
"path",
"(",
"$",
"path",
")",
",",
"$",
"require",
")",
";",
"}"
] | Looks up a path in the specified context
@param array $context
@param array $path
@param bool $require
@return string
@throws \RuntimeException
@throws \InvalidArgumentException | [
"Looks",
"up",
"a",
"path",
"in",
"the",
"specified",
"context"
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L216-L225 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.resolve | public function resolve($id, $required = false)
{
$id = $this->path($id);
try {
if (in_array($id, $this->resolutionStack)) {
$path = array_map(
function ($a) {
return join('.', $a);
},
$this->resolutionStack
);
throw new CircularReferenceException(
sprintf(
"Circular reference detected: %s -> %s",
implode(' -> ', $path),
join('.', $id)
)
);
}
array_push($this->resolutionStack, $id);
$ret = $this->value($this->lookup($this->values, $id, $required));
array_pop($this->resolutionStack);
return $ret;
} catch (\Exception $e) {
if ($e instanceof CircularReferenceException) {
throw $e;
}
throw new \RuntimeException("While resolving value " . join(".", $id), 0, $e);
}
} | php | public function resolve($id, $required = false)
{
$id = $this->path($id);
try {
if (in_array($id, $this->resolutionStack)) {
$path = array_map(
function ($a) {
return join('.', $a);
},
$this->resolutionStack
);
throw new CircularReferenceException(
sprintf(
"Circular reference detected: %s -> %s",
implode(' -> ', $path),
join('.', $id)
)
);
}
array_push($this->resolutionStack, $id);
$ret = $this->value($this->lookup($this->values, $id, $required));
array_pop($this->resolutionStack);
return $ret;
} catch (\Exception $e) {
if ($e instanceof CircularReferenceException) {
throw $e;
}
throw new \RuntimeException("While resolving value " . join(".", $id), 0, $e);
}
} | [
"public",
"function",
"resolve",
"(",
"$",
"id",
",",
"$",
"required",
"=",
"false",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"id",
")",
";",
"try",
"{",
"if",
"(",
"in_array",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"resolutionStack",
")",
")",
"{",
"$",
"path",
"=",
"array_map",
"(",
"function",
"(",
"$",
"a",
")",
"{",
"return",
"join",
"(",
"'.'",
",",
"$",
"a",
")",
";",
"}",
",",
"$",
"this",
"->",
"resolutionStack",
")",
";",
"throw",
"new",
"CircularReferenceException",
"(",
"sprintf",
"(",
"\"Circular reference detected: %s -> %s\"",
",",
"implode",
"(",
"' -> '",
",",
"$",
"path",
")",
",",
"join",
"(",
"'.'",
",",
"$",
"id",
")",
")",
")",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"resolutionStack",
",",
"$",
"id",
")",
";",
"$",
"ret",
"=",
"$",
"this",
"->",
"value",
"(",
"$",
"this",
"->",
"lookup",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"id",
",",
"$",
"required",
")",
")",
";",
"array_pop",
"(",
"$",
"this",
"->",
"resolutionStack",
")",
";",
"return",
"$",
"ret",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"CircularReferenceException",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"While resolving value \"",
".",
"join",
"(",
"\".\"",
",",
"$",
"id",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Resolve the specified path. If the resulting value is a Closure, it's assumed a declaration and therefore
executed
@param array|string $id
@param bool $required
@return string
@throws \RuntimeException
@throws CircularReferenceException | [
"Resolve",
"the",
"specified",
"path",
".",
"If",
"the",
"resulting",
"value",
"is",
"a",
"Closure",
"it",
"s",
"assumed",
"a",
"declaration",
"and",
"therefore",
"executed"
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L238-L270 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.set | public function set($path, $value)
{
PropertyAccessor::setByPath($this->values, $this->path($path), $value);
} | php | public function set($path, $value)
{
PropertyAccessor::setByPath($this->values, $this->path($path), $value);
} | [
"public",
"function",
"set",
"(",
"$",
"path",
",",
"$",
"value",
")",
"{",
"PropertyAccessor",
"::",
"setByPath",
"(",
"$",
"this",
"->",
"values",
",",
"$",
"this",
"->",
"path",
"(",
"$",
"path",
")",
",",
"$",
"value",
")",
";",
"}"
] | Set the value at the specified path
@param array|string $path
@param mixed $value
@return void
@throws \UnexpectedValueException | [
"Set",
"the",
"value",
"at",
"the",
"specified",
"path"
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L282-L285 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.helperExec | public function helperExec($cmd)
{
if ($this->resolve('EXPLAIN')) {
$this->output->writeln("# Task needs the following helper command:");
$this->output->writeln("# " . str_replace("\n", "\\n", $cmd));
}
$ret = '';
$this->executor->execute($cmd, $ret);
return $ret;
} | php | public function helperExec($cmd)
{
if ($this->resolve('EXPLAIN')) {
$this->output->writeln("# Task needs the following helper command:");
$this->output->writeln("# " . str_replace("\n", "\\n", $cmd));
}
$ret = '';
$this->executor->execute($cmd, $ret);
return $ret;
} | [
"public",
"function",
"helperExec",
"(",
"$",
"cmd",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'EXPLAIN'",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"\"# Task needs the following helper command:\"",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"\"# \"",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
",",
"$",
"cmd",
")",
")",
";",
"}",
"$",
"ret",
"=",
"''",
";",
"$",
"this",
"->",
"executor",
"->",
"execute",
"(",
"$",
"cmd",
",",
"$",
"ret",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | This is useful for commands that need the shell regardless of the 'explain' value setting.
@param string $cmd
@return mixed | [
"This",
"is",
"useful",
"for",
"commands",
"that",
"need",
"the",
"shell",
"regardless",
"of",
"the",
"explain",
"value",
"setting",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L293-L302 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.fn | public function fn($id, $callable = null, $needsContainer = false)
{
if ($callable === null) {
$callable = $id;
}
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Not callable");
}
$this->set($id, array($callable, $needsContainer));
} | php | public function fn($id, $callable = null, $needsContainer = false)
{
if ($callable === null) {
$callable = $id;
}
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Not callable");
}
$this->set($id, array($callable, $needsContainer));
} | [
"public",
"function",
"fn",
"(",
"$",
"id",
",",
"$",
"callable",
"=",
"null",
",",
"$",
"needsContainer",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"callable",
"===",
"null",
")",
"{",
"$",
"callable",
"=",
"$",
"id",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Not callable\"",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"$",
"id",
",",
"array",
"(",
"$",
"callable",
",",
"$",
"needsContainer",
")",
")",
";",
"}"
] | Set a function at the specified path.
@param array|string $id
@param callable $callable
@param bool $needsContainer
@return void
@throws \InvalidArgumentException | [
"Set",
"a",
"function",
"at",
"the",
"specified",
"path",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L331-L340 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.decl | public function decl($id, $callable)
{
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Passed declaration is not callable");
}
$this->set($id, function (Container $c) use($callable, $id) {
Debug::enterScope(join('.', (array)$id));
if (null !== ($value = call_user_func($callable, $c))) {
$c->set($id, $value);
}
Debug::exitScope(join('.', (array)$id));
return $value;
});
} | php | public function decl($id, $callable)
{
if (!is_callable($callable)) {
throw new \InvalidArgumentException("Passed declaration is not callable");
}
$this->set($id, function (Container $c) use($callable, $id) {
Debug::enterScope(join('.', (array)$id));
if (null !== ($value = call_user_func($callable, $c))) {
$c->set($id, $value);
}
Debug::exitScope(join('.', (array)$id));
return $value;
});
} | [
"public",
"function",
"decl",
"(",
"$",
"id",
",",
"$",
"callable",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Passed declaration is not callable\"",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"$",
"id",
",",
"function",
"(",
"Container",
"$",
"c",
")",
"use",
"(",
"$",
"callable",
",",
"$",
"id",
")",
"{",
"Debug",
"::",
"enterScope",
"(",
"join",
"(",
"'.'",
",",
"(",
"array",
")",
"$",
"id",
")",
")",
";",
"if",
"(",
"null",
"!==",
"(",
"$",
"value",
"=",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"c",
")",
")",
")",
"{",
"$",
"c",
"->",
"set",
"(",
"$",
"id",
",",
"$",
"value",
")",
";",
"}",
"Debug",
"::",
"exitScope",
"(",
"join",
"(",
"'.'",
",",
"(",
"array",
")",
"$",
"id",
")",
")",
";",
"return",
"$",
"value",
";",
"}",
")",
";",
"}"
] | Does a declaration, i.e., the first time the declaration is called, it's resulting value overwrites the
declaration.
@param array|string $id
@param callable $callable
@return void
@throws \InvalidArgumentException | [
"Does",
"a",
"declaration",
"i",
".",
"e",
".",
"the",
"first",
"time",
"the",
"declaration",
"is",
"called",
"it",
"s",
"resulting",
"value",
"overwrites",
"the",
"declaration",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L366-L379 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.evaluate | public function evaluate($expression, &$code = null)
{
$exprcompiler = new ScriptCompiler(new ExpressionParser(), new ExpressionTokenizer());
$z = $this;
$_value = null;
$code = '$z->set(array(\'_\'), ' . $exprcompiler->compile($expression) . ');';
eval($code);
return $z->resolve(array('_'));
} | php | public function evaluate($expression, &$code = null)
{
$exprcompiler = new ScriptCompiler(new ExpressionParser(), new ExpressionTokenizer());
$z = $this;
$_value = null;
$code = '$z->set(array(\'_\'), ' . $exprcompiler->compile($expression) . ');';
eval($code);
return $z->resolve(array('_'));
} | [
"public",
"function",
"evaluate",
"(",
"$",
"expression",
",",
"&",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"exprcompiler",
"=",
"new",
"ScriptCompiler",
"(",
"new",
"ExpressionParser",
"(",
")",
",",
"new",
"ExpressionTokenizer",
"(",
")",
")",
";",
"$",
"z",
"=",
"$",
"this",
";",
"$",
"_value",
"=",
"null",
";",
"$",
"code",
"=",
"'$z->set(array(\\'_\\'), '",
".",
"$",
"exprcompiler",
"->",
"compile",
"(",
"$",
"expression",
")",
".",
"');'",
";",
"eval",
"(",
"$",
"code",
")",
";",
"return",
"$",
"z",
"->",
"resolve",
"(",
"array",
"(",
"'_'",
")",
")",
";",
"}"
] | Does an on-the-fly evaluation of the specified expression.
The compilation result will be stored in $code.
@param string $expression
@param string &$code
@return string | [
"Does",
"an",
"on",
"-",
"the",
"-",
"fly",
"evaluation",
"of",
"the",
"specified",
"expression",
".",
"The",
"compilation",
"result",
"will",
"be",
"stored",
"in",
"$code",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L402-L412 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.has | public function has($id)
{
try {
$existing = $this->get($id);
} catch (\OutOfBoundsException $e) {
return false;
}
return Util::typeOf($existing);
} | php | public function has($id)
{
try {
$existing = $this->get($id);
} catch (\OutOfBoundsException $e) {
return false;
}
return Util::typeOf($existing);
} | [
"public",
"function",
"has",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"existing",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"\\",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Util",
"::",
"typeOf",
"(",
"$",
"existing",
")",
";",
"}"
] | Checks for existence of the specified path.
@param string $id
@return string | [
"Checks",
"for",
"existence",
"of",
"the",
"specified",
"path",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L421-L429 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.isEmpty | public function isEmpty($path)
{
try {
$value = $this->get($path);
} catch (\OutOfBoundsException $e) {
return true;
}
return '' === $value || null === $value;
} | php | public function isEmpty($path)
{
try {
$value = $this->get($path);
} catch (\OutOfBoundsException $e) {
return true;
}
return '' === $value || null === $value;
} | [
"public",
"function",
"isEmpty",
"(",
"$",
"path",
")",
"{",
"try",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"\\",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"return",
"true",
";",
"}",
"return",
"''",
"===",
"$",
"value",
"||",
"null",
"===",
"$",
"value",
";",
"}"
] | Checks if a value is empty.
@param mixed $path
@return bool | [
"Checks",
"if",
"a",
"value",
"is",
"empty",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L438-L446 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.call | public function call()
{
$args = func_get_args();
$service = array_shift($args);
if (!is_array($service)) {
throw new \RuntimeException("Expected an array");
}
if (!is_callable($service[0])) {
throw new \InvalidArgumentException("Can not use service '{$service[0]}' as a function, it is not callable");
}
// if the service needs the container, it is specified in the decl() call as the second param:
if ($service[1]) {
array_unshift($args, $this);
}
return call_user_func_array($service[0], $args);
} | php | public function call()
{
$args = func_get_args();
$service = array_shift($args);
if (!is_array($service)) {
throw new \RuntimeException("Expected an array");
}
if (!is_callable($service[0])) {
throw new \InvalidArgumentException("Can not use service '{$service[0]}' as a function, it is not callable");
}
// if the service needs the container, it is specified in the decl() call as the second param:
if ($service[1]) {
array_unshift($args, $this);
}
return call_user_func_array($service[0], $args);
} | [
"public",
"function",
"call",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"service",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"service",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Expected an array\"",
")",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"service",
"[",
"0",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Can not use service '{$service[0]}' as a function, it is not callable\"",
")",
";",
"}",
"// if the service needs the container, it is specified in the decl() call as the second param:",
"if",
"(",
"$",
"service",
"[",
"1",
"]",
")",
"{",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"this",
")",
";",
"}",
"return",
"call_user_func_array",
"(",
"$",
"service",
"[",
"0",
"]",
",",
"$",
"args",
")",
";",
"}"
] | Separate helper for calling a service as a function.
@return mixed
@throws \InvalidArgumentException | [
"Separate",
"helper",
"for",
"calling",
"a",
"service",
"as",
"a",
"function",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L456-L472 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.setOutputPrefix | private function setOutputPrefix($prefix)
{
if (!($this->output->getFormatter() instanceof PrefixFormatter)) {
return;
}
$this->output->getFormatter()->prefix = $prefix;
} | php | private function setOutputPrefix($prefix)
{
if (!($this->output->getFormatter() instanceof PrefixFormatter)) {
return;
}
$this->output->getFormatter()->prefix = $prefix;
} | [
"private",
"function",
"setOutputPrefix",
"(",
"$",
"prefix",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
"instanceof",
"PrefixFormatter",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
"->",
"prefix",
"=",
"$",
"prefix",
";",
"}"
] | Helper to set prefix if the output if PrefixFormatter
@param string $prefix
@return void | [
"Helper",
"to",
"set",
"prefix",
"if",
"the",
"output",
"if",
"PrefixFormatter"
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L480-L487 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.exec | public function exec($cmd)
{
if (trim($cmd)) {
$this->setOutputPrefix('');
if ($this->resolve('DEBUG')) {
$this->output->writeln('<comment># ' . join('::', Debug::$scope) . "</comment>");
}
if ($this->resolve('EXPLAIN')) {
if ($this->resolve('INTERACTIVE')) {
$this->notice('interactive shell:');
$line = '( /bin/bash -c \'' . trim($cmd) . '\' )';
} else {
$line = 'echo ' . escapeshellarg(trim($cmd)) . ' | ' . $this->resolve(array('SHELL'));
}
$this->output->writeln($line);
} else {
$this->executor->execute($cmd);
}
}
} | php | public function exec($cmd)
{
if (trim($cmd)) {
$this->setOutputPrefix('');
if ($this->resolve('DEBUG')) {
$this->output->writeln('<comment># ' . join('::', Debug::$scope) . "</comment>");
}
if ($this->resolve('EXPLAIN')) {
if ($this->resolve('INTERACTIVE')) {
$this->notice('interactive shell:');
$line = '( /bin/bash -c \'' . trim($cmd) . '\' )';
} else {
$line = 'echo ' . escapeshellarg(trim($cmd)) . ' | ' . $this->resolve(array('SHELL'));
}
$this->output->writeln($line);
} else {
$this->executor->execute($cmd);
}
}
} | [
"public",
"function",
"exec",
"(",
"$",
"cmd",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"cmd",
")",
")",
"{",
"$",
"this",
"->",
"setOutputPrefix",
"(",
"''",
")",
";",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'DEBUG'",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'<comment># '",
".",
"join",
"(",
"'::'",
",",
"Debug",
"::",
"$",
"scope",
")",
".",
"\"</comment>\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'EXPLAIN'",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'INTERACTIVE'",
")",
")",
"{",
"$",
"this",
"->",
"notice",
"(",
"'interactive shell:'",
")",
";",
"$",
"line",
"=",
"'( /bin/bash -c \\''",
".",
"trim",
"(",
"$",
"cmd",
")",
".",
"'\\' )'",
";",
"}",
"else",
"{",
"$",
"line",
"=",
"'echo '",
".",
"escapeshellarg",
"(",
"trim",
"(",
"$",
"cmd",
")",
")",
".",
"' | '",
".",
"$",
"this",
"->",
"resolve",
"(",
"array",
"(",
"'SHELL'",
")",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"line",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"executor",
"->",
"execute",
"(",
"$",
"cmd",
")",
";",
"}",
"}",
"}"
] | Executes a script snippet using the 'executor' service.
@param string $cmd
@return void | [
"Executes",
"a",
"script",
"snippet",
"using",
"the",
"executor",
"service",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L496-L517 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.cmd | public function cmd($cmd)
{
$cmd = ltrim($cmd);
if (substr($cmd, 0, 1) === '@') {
return $this->resolve(array_merge(array('tasks'), explode('.', substr($cmd, 1))));
} else {
$this->exec($cmd);
return null;
}
} | php | public function cmd($cmd)
{
$cmd = ltrim($cmd);
if (substr($cmd, 0, 1) === '@') {
return $this->resolve(array_merge(array('tasks'), explode('.', substr($cmd, 1))));
} else {
$this->exec($cmd);
return null;
}
} | [
"public",
"function",
"cmd",
"(",
"$",
"cmd",
")",
"{",
"$",
"cmd",
"=",
"ltrim",
"(",
"$",
"cmd",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"cmd",
",",
"0",
",",
"1",
")",
"===",
"'@'",
")",
"{",
"return",
"$",
"this",
"->",
"resolve",
"(",
"array_merge",
"(",
"array",
"(",
"'tasks'",
")",
",",
"explode",
"(",
"'.'",
",",
"substr",
"(",
"$",
"cmd",
",",
"1",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"exec",
"(",
"$",
"cmd",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Execute a command. This is a wrapper for 'exec', so that a task prefixed with '@' can be passed as well.
@param string $cmd
@return string|null | [
"Execute",
"a",
"command",
".",
"This",
"is",
"a",
"wrapper",
"for",
"exec",
"so",
"that",
"a",
"task",
"prefixed",
"with",
"@",
"can",
"be",
"passed",
"as",
"well",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L525-L534 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.str | public function str($value)
{
if (is_array($value)) {
$allScalar = function ($a, $b) {
return $a && is_scalar($b);
};
if (!array_reduce($value, $allScalar, true)) {
throw new UnexpectedValueException("Unexpected complex type " . Util::toPhp($value));
}
return join(' ', $value);
}
return (string)$value;
} | php | public function str($value)
{
if (is_array($value)) {
$allScalar = function ($a, $b) {
return $a && is_scalar($b);
};
if (!array_reduce($value, $allScalar, true)) {
throw new UnexpectedValueException("Unexpected complex type " . Util::toPhp($value));
}
return join(' ', $value);
}
return (string)$value;
} | [
"public",
"function",
"str",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"allScalar",
"=",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"$",
"a",
"&&",
"is_scalar",
"(",
"$",
"b",
")",
";",
"}",
";",
"if",
"(",
"!",
"array_reduce",
"(",
"$",
"value",
",",
"$",
"allScalar",
",",
"true",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"\"Unexpected complex type \"",
".",
"Util",
"::",
"toPhp",
"(",
"$",
"value",
")",
")",
";",
"}",
"return",
"join",
"(",
"' '",
",",
"$",
"value",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}"
] | Convert the value to a string.
@param mixed $value
@return string
@throws \UnexpectedValueException | [
"Convert",
"the",
"value",
"to",
"a",
"string",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L561-L573 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.push | public function push($varName, $tail)
{
if (false === $this->has($varName)) {
$this->set($varName, null);
}
if (!isset($this->varStack[json_encode($varName)])) {
$this->varStack[json_encode($varName)] = array();
}
array_push($this->varStack[json_encode($varName)], $this->get($varName));
$this->set($varName, $tail);
} | php | public function push($varName, $tail)
{
if (false === $this->has($varName)) {
$this->set($varName, null);
}
if (!isset($this->varStack[json_encode($varName)])) {
$this->varStack[json_encode($varName)] = array();
}
array_push($this->varStack[json_encode($varName)], $this->get($varName));
$this->set($varName, $tail);
} | [
"public",
"function",
"push",
"(",
"$",
"varName",
",",
"$",
"tail",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"has",
"(",
"$",
"varName",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"varName",
",",
"null",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
"=",
"array",
"(",
")",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
",",
"$",
"this",
"->",
"get",
"(",
"$",
"varName",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"varName",
",",
"$",
"tail",
")",
";",
"}"
] | Push a var on a local stack by it's name.
@param string $varName
@param string $tail
@return void | [
"Push",
"a",
"var",
"on",
"a",
"local",
"stack",
"by",
"it",
"s",
"name",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L650-L660 |
zicht/z | src/Zicht/Tool/Container/Container.php | Container.pop | public function pop($varName)
{
$this->set($varName, array_pop($this->varStack[json_encode($varName)]));
} | php | public function pop($varName)
{
$this->set($varName, array_pop($this->varStack[json_encode($varName)]));
} | [
"public",
"function",
"pop",
"(",
"$",
"varName",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"varName",
",",
"array_pop",
"(",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
")",
")",
";",
"}"
] | Pop a var from a local var stack.
@param string $varName
@return void | [
"Pop",
"a",
"var",
"from",
"a",
"local",
"var",
"stack",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L669-L672 |
mothership-ec/composer | src/Composer/Repository/Vcs/GitBitbucketDriver.php | GitBitbucketDriver.getRootIdentifier | public function getRootIdentifier()
{
if (null === $this->rootIdentifier) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository;
$repoData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->rootIdentifier = !empty($repoData['main_branch']) ? $repoData['main_branch'] : 'master';
}
return $this->rootIdentifier;
} | php | public function getRootIdentifier()
{
if (null === $this->rootIdentifier) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository;
$repoData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->rootIdentifier = !empty($repoData['main_branch']) ? $repoData['main_branch'] : 'master';
}
return $this->rootIdentifier;
} | [
"public",
"function",
"getRootIdentifier",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"rootIdentifier",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://api.bitbucket.org/1.0/repositories/'",
".",
"$",
"this",
"->",
"owner",
".",
"'/'",
".",
"$",
"this",
"->",
"repository",
";",
"$",
"repoData",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"this",
"->",
"getContents",
"(",
"$",
"resource",
")",
",",
"$",
"resource",
")",
";",
"$",
"this",
"->",
"rootIdentifier",
"=",
"!",
"empty",
"(",
"$",
"repoData",
"[",
"'main_branch'",
"]",
")",
"?",
"$",
"repoData",
"[",
"'main_branch'",
"]",
":",
"'master'",
";",
"}",
"return",
"$",
"this",
"->",
"rootIdentifier",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/GitBitbucketDriver.php#L45-L54 |
mothership-ec/composer | src/Composer/Repository/Vcs/GitBitbucketDriver.php | GitBitbucketDriver.getComposerInformation | public function getComposerInformation($identifier)
{
if (!isset($this->infoCache[$identifier])) {
$resource = $this->getScheme() . '://bitbucket.org/'.$this->owner.'/'.$this->repository.'/raw/'.$identifier.'/composer.json';
$composer = $this->getContents($resource);
if (!$composer) {
return;
}
$composer = JsonFile::parseJson($composer, $resource);
if (empty($composer['time'])) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/changesets/'.$identifier;
$changeset = JsonFile::parseJson($this->getContents($resource), $resource);
$composer['time'] = $changeset['timestamp'];
}
$this->infoCache[$identifier] = $composer;
}
return $this->infoCache[$identifier];
} | php | public function getComposerInformation($identifier)
{
if (!isset($this->infoCache[$identifier])) {
$resource = $this->getScheme() . '://bitbucket.org/'.$this->owner.'/'.$this->repository.'/raw/'.$identifier.'/composer.json';
$composer = $this->getContents($resource);
if (!$composer) {
return;
}
$composer = JsonFile::parseJson($composer, $resource);
if (empty($composer['time'])) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/changesets/'.$identifier;
$changeset = JsonFile::parseJson($this->getContents($resource), $resource);
$composer['time'] = $changeset['timestamp'];
}
$this->infoCache[$identifier] = $composer;
}
return $this->infoCache[$identifier];
} | [
"public",
"function",
"getComposerInformation",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://bitbucket.org/'",
".",
"$",
"this",
"->",
"owner",
".",
"'/'",
".",
"$",
"this",
"->",
"repository",
".",
"'/raw/'",
".",
"$",
"identifier",
".",
"'/composer.json'",
";",
"$",
"composer",
"=",
"$",
"this",
"->",
"getContents",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"$",
"composer",
")",
"{",
"return",
";",
"}",
"$",
"composer",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"composer",
",",
"$",
"resource",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"composer",
"[",
"'time'",
"]",
")",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://api.bitbucket.org/1.0/repositories/'",
".",
"$",
"this",
"->",
"owner",
".",
"'/'",
".",
"$",
"this",
"->",
"repository",
".",
"'/changesets/'",
".",
"$",
"identifier",
";",
"$",
"changeset",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"this",
"->",
"getContents",
"(",
"$",
"resource",
")",
",",
"$",
"resource",
")",
";",
"$",
"composer",
"[",
"'time'",
"]",
"=",
"$",
"changeset",
"[",
"'timestamp'",
"]",
";",
"}",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
"=",
"$",
"composer",
";",
"}",
"return",
"$",
"this",
"->",
"infoCache",
"[",
"$",
"identifier",
"]",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/GitBitbucketDriver.php#L85-L105 |
mothership-ec/composer | src/Composer/Repository/Vcs/GitBitbucketDriver.php | GitBitbucketDriver.getTags | public function getTags()
{
if (null === $this->tags) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
$tagsData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->tags = array();
foreach ($tagsData as $tag => $data) {
$this->tags[$tag] = $data['raw_node'];
}
}
return $this->tags;
} | php | public function getTags()
{
if (null === $this->tags) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/tags';
$tagsData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->tags = array();
foreach ($tagsData as $tag => $data) {
$this->tags[$tag] = $data['raw_node'];
}
}
return $this->tags;
} | [
"public",
"function",
"getTags",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"tags",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://api.bitbucket.org/1.0/repositories/'",
".",
"$",
"this",
"->",
"owner",
".",
"'/'",
".",
"$",
"this",
"->",
"repository",
".",
"'/tags'",
";",
"$",
"tagsData",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"this",
"->",
"getContents",
"(",
"$",
"resource",
")",
",",
"$",
"resource",
")",
";",
"$",
"this",
"->",
"tags",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tagsData",
"as",
"$",
"tag",
"=>",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
"=",
"$",
"data",
"[",
"'raw_node'",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"tags",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/GitBitbucketDriver.php#L110-L122 |
mothership-ec/composer | src/Composer/Repository/Vcs/GitBitbucketDriver.php | GitBitbucketDriver.getBranches | public function getBranches()
{
if (null === $this->branches) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/branches';
$branchData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->branches = array();
foreach ($branchData as $branch => $data) {
$this->branches[$branch] = $data['raw_node'];
}
}
return $this->branches;
} | php | public function getBranches()
{
if (null === $this->branches) {
$resource = $this->getScheme() . '://api.bitbucket.org/1.0/repositories/'.$this->owner.'/'.$this->repository.'/branches';
$branchData = JsonFile::parseJson($this->getContents($resource), $resource);
$this->branches = array();
foreach ($branchData as $branch => $data) {
$this->branches[$branch] = $data['raw_node'];
}
}
return $this->branches;
} | [
"public",
"function",
"getBranches",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"branches",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
".",
"'://api.bitbucket.org/1.0/repositories/'",
".",
"$",
"this",
"->",
"owner",
".",
"'/'",
".",
"$",
"this",
"->",
"repository",
".",
"'/branches'",
";",
"$",
"branchData",
"=",
"JsonFile",
"::",
"parseJson",
"(",
"$",
"this",
"->",
"getContents",
"(",
"$",
"resource",
")",
",",
"$",
"resource",
")",
";",
"$",
"this",
"->",
"branches",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"branchData",
"as",
"$",
"branch",
"=>",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"branches",
"[",
"$",
"branch",
"]",
"=",
"$",
"data",
"[",
"'raw_node'",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"branches",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Vcs/GitBitbucketDriver.php#L127-L139 |
FriendsOfApi/phraseapp | src/Model/Translation/User.php | User.createFromArray | public static function createFromArray(array $data)
{
$self = new self();
if (isset($data['id'])) {
$self->setId($data['id']);
}
if (isset($data['username'])) {
$self->setUsername($data['username']);
}
if (isset($data['name'])) {
$self->setName($data['name']);
}
return $self;
} | php | public static function createFromArray(array $data)
{
$self = new self();
if (isset($data['id'])) {
$self->setId($data['id']);
}
if (isset($data['username'])) {
$self->setUsername($data['username']);
}
if (isset($data['name'])) {
$self->setName($data['name']);
}
return $self;
} | [
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"self",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setId",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'username'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setUsername",
"(",
"$",
"data",
"[",
"'username'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setName",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
";",
"}",
"return",
"$",
"self",
";",
"}"
] | @param array $data
@return User | [
"@param",
"array",
"$data"
] | train | https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Model/Translation/User.php#L39-L54 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.indexAction | public function indexAction(Request $request)
{
return $this->processView($action = 'index', $this->view($this->find($action, false)));
} | php | public function indexAction(Request $request)
{
return $this->processView($action = 'index', $this->view($this->find($action, false)));
} | [
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"$",
"this",
"->",
"processView",
"(",
"$",
"action",
"=",
"'index'",
",",
"$",
"this",
"->",
"view",
"(",
"$",
"this",
"->",
"find",
"(",
"$",
"action",
",",
"false",
")",
")",
")",
";",
"}"
] | @param Request $request
@return Response | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L64-L67 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.gridAction | public function gridAction(Request $request)
{
return $this->processView('grid', $this->view([
'form' => $form = $this->submitGrid($grid = $this->buildGrid(), $request),
'grid' => $this->getGridHandler()->handle($grid, $form),
]));
} | php | public function gridAction(Request $request)
{
return $this->processView('grid', $this->view([
'form' => $form = $this->submitGrid($grid = $this->buildGrid(), $request),
'grid' => $this->getGridHandler()->handle($grid, $form),
]));
} | [
"public",
"function",
"gridAction",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"$",
"this",
"->",
"processView",
"(",
"'grid'",
",",
"$",
"this",
"->",
"view",
"(",
"[",
"'form'",
"=>",
"$",
"form",
"=",
"$",
"this",
"->",
"submitGrid",
"(",
"$",
"grid",
"=",
"$",
"this",
"->",
"buildGrid",
"(",
")",
",",
"$",
"request",
")",
",",
"'grid'",
"=>",
"$",
"this",
"->",
"getGridHandler",
"(",
")",
"->",
"handle",
"(",
"$",
"grid",
",",
"$",
"form",
")",
",",
"]",
")",
")",
";",
"}"
] | @param Request $request
@return Response | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L74-L80 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.batchAction | public function batchAction(Request $request)
{
$view = $this->getGridHandler()->handle(
$grid = $this->buildGrid(),
$form = $this->submitGrid($grid, $request)
);
if (($api = $this->getParameterResolver()->resolveApi()) && !$form->isValid()) {
return $this->processAction('batch', $form);
}
$batchForm = $this->buildForm(GridBatchType::class, null, ['grid' => $view]);
if ($this->submitForm($batchForm, $request)->isValid() && $form->isValid()) {
try {
$this->getGridBatcher()->batch($grid, $batchForm);
} catch (DomainException $e) {
$this->processException($e);
}
}
if (!$api && !$batchForm->isValid()) {
return $this->processView('batch', $this->view([
'batch_form' => $batchForm,
'form' => $form,
'grid' => $view,
]));
}
return $this->processAction('batch', $batchForm);
} | php | public function batchAction(Request $request)
{
$view = $this->getGridHandler()->handle(
$grid = $this->buildGrid(),
$form = $this->submitGrid($grid, $request)
);
if (($api = $this->getParameterResolver()->resolveApi()) && !$form->isValid()) {
return $this->processAction('batch', $form);
}
$batchForm = $this->buildForm(GridBatchType::class, null, ['grid' => $view]);
if ($this->submitForm($batchForm, $request)->isValid() && $form->isValid()) {
try {
$this->getGridBatcher()->batch($grid, $batchForm);
} catch (DomainException $e) {
$this->processException($e);
}
}
if (!$api && !$batchForm->isValid()) {
return $this->processView('batch', $this->view([
'batch_form' => $batchForm,
'form' => $form,
'grid' => $view,
]));
}
return $this->processAction('batch', $batchForm);
} | [
"public",
"function",
"batchAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getGridHandler",
"(",
")",
"->",
"handle",
"(",
"$",
"grid",
"=",
"$",
"this",
"->",
"buildGrid",
"(",
")",
",",
"$",
"form",
"=",
"$",
"this",
"->",
"submitGrid",
"(",
"$",
"grid",
",",
"$",
"request",
")",
")",
";",
"if",
"(",
"(",
"$",
"api",
"=",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveApi",
"(",
")",
")",
"&&",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processAction",
"(",
"'batch'",
",",
"$",
"form",
")",
";",
"}",
"$",
"batchForm",
"=",
"$",
"this",
"->",
"buildForm",
"(",
"GridBatchType",
"::",
"class",
",",
"null",
",",
"[",
"'grid'",
"=>",
"$",
"view",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"submitForm",
"(",
"$",
"batchForm",
",",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getGridBatcher",
"(",
")",
"->",
"batch",
"(",
"$",
"grid",
",",
"$",
"batchForm",
")",
";",
"}",
"catch",
"(",
"DomainException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"processException",
"(",
"$",
"e",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"api",
"&&",
"!",
"$",
"batchForm",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processView",
"(",
"'batch'",
",",
"$",
"this",
"->",
"view",
"(",
"[",
"'batch_form'",
"=>",
"$",
"batchForm",
",",
"'form'",
"=>",
"$",
"form",
",",
"'grid'",
"=>",
"$",
"view",
",",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"processAction",
"(",
"'batch'",
",",
"$",
"batchForm",
")",
";",
"}"
] | @param Request $request
@return Response | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L87-L117 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.showAction | public function showAction(Request $request)
{
return $this->processView($action = 'show', $this->view($this->find($action)));
} | php | public function showAction(Request $request)
{
return $this->processView($action = 'show', $this->view($this->find($action)));
} | [
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"$",
"this",
"->",
"processView",
"(",
"$",
"action",
"=",
"'show'",
",",
"$",
"this",
"->",
"view",
"(",
"$",
"this",
"->",
"find",
"(",
"$",
"action",
")",
")",
")",
";",
"}"
] | @param Request $request
@return Response | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L124-L127 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.createAction | public function createAction(Request $request)
{
$form = $this->buildForm();
if ($request->isMethod('POST') && $this->submitForm($form, $request)->isValid()) {
try {
$this->getDomainManager()->create($form->getData());
} catch (DomainException $e) {
$this->processException($e);
}
}
return $this->processAction('create', $form, Response::HTTP_CREATED);
} | php | public function createAction(Request $request)
{
$form = $this->buildForm();
if ($request->isMethod('POST') && $this->submitForm($form, $request)->isValid()) {
try {
$this->getDomainManager()->create($form->getData());
} catch (DomainException $e) {
$this->processException($e);
}
}
return $this->processAction('create', $form, Response::HTTP_CREATED);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"buildForm",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isMethod",
"(",
"'POST'",
")",
"&&",
"$",
"this",
"->",
"submitForm",
"(",
"$",
"form",
",",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getDomainManager",
"(",
")",
"->",
"create",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
")",
";",
"}",
"catch",
"(",
"DomainException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"processException",
"(",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"processAction",
"(",
"'create'",
",",
"$",
"form",
",",
"Response",
"::",
"HTTP_CREATED",
")",
";",
"}"
] | @param Request $request
@return Response | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L134-L147 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.updateAction | public function updateAction(Request $request)
{
$form = $this->buildForm(null, $this->find($action = 'update'));
if (in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true)
&& $this->submitForm($form, $request)->isValid()) {
try {
$this->getDomainManager()->update($form->getData());
} catch (DomainException $e) {
$this->processException($e);
}
}
return $this->processAction($action, $form);
} | php | public function updateAction(Request $request)
{
$form = $this->buildForm(null, $this->find($action = 'update'));
if (in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true)
&& $this->submitForm($form, $request)->isValid()) {
try {
$this->getDomainManager()->update($form->getData());
} catch (DomainException $e) {
$this->processException($e);
}
}
return $this->processAction($action, $form);
} | [
"public",
"function",
"updateAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"buildForm",
"(",
"null",
",",
"$",
"this",
"->",
"find",
"(",
"$",
"action",
"=",
"'update'",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
",",
"[",
"'POST'",
",",
"'PUT'",
",",
"'PATCH'",
"]",
",",
"true",
")",
"&&",
"$",
"this",
"->",
"submitForm",
"(",
"$",
"form",
",",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getDomainManager",
"(",
")",
"->",
"update",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
")",
";",
"}",
"catch",
"(",
"DomainException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"processException",
"(",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"processAction",
"(",
"$",
"action",
",",
"$",
"form",
")",
";",
"}"
] | @param Request $request
@return Response | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L154-L168 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.deleteAction | public function deleteAction(Request $request)
{
if ($this->submitForm($this->buildForm(CsrfProtectionType::class), $request)->isValid()) {
try {
$this->getDomainManager()->delete($this->find('delete'));
} catch (DomainException $e) {
$this->processException($e);
}
}
return $this->processAction('delete');
} | php | public function deleteAction(Request $request)
{
if ($this->submitForm($this->buildForm(CsrfProtectionType::class), $request)->isValid()) {
try {
$this->getDomainManager()->delete($this->find('delete'));
} catch (DomainException $e) {
$this->processException($e);
}
}
return $this->processAction('delete');
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"submitForm",
"(",
"$",
"this",
"->",
"buildForm",
"(",
"CsrfProtectionType",
"::",
"class",
")",
",",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getDomainManager",
"(",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"find",
"(",
"'delete'",
")",
")",
";",
"}",
"catch",
"(",
"DomainException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"processException",
"(",
"$",
"e",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"processAction",
"(",
"'delete'",
")",
";",
"}"
] | @param Request $request
@return Response | [
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L175-L186 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.find | protected function find($action, $mandatory = true)
{
$repositoryMethod = $this->getParameterResolver()->resolveRepositoryMethod($action);
$criteria = $this->getParameterResolver()->resolveCriteria($mandatory);
$sorting = $this->getParameterResolver()->resolveSorting();
if (($result = $this->getDomainManager()->find($action, $repositoryMethod, $criteria, $sorting)) === null) {
throw $this->createNotFoundException(sprintf(
'The %s does not exist (%s) (%s).',
str_replace('_', ' ', $this->resource->getName()),
json_encode($criteria),
json_encode($sorting)
));
}
if ($result instanceof Pagerfanta) {
$result->setCurrentPage($this->getParameterResolver()->resolveCurrentPage());
$result->setMaxPerPage($this->getParameterResolver()->resolveMaxPerPage());
} elseif (!$this->getSecurityChecker()->isGranted($action, $result)) {
throw $this->createAccessDeniedException();
}
return $result;
} | php | protected function find($action, $mandatory = true)
{
$repositoryMethod = $this->getParameterResolver()->resolveRepositoryMethod($action);
$criteria = $this->getParameterResolver()->resolveCriteria($mandatory);
$sorting = $this->getParameterResolver()->resolveSorting();
if (($result = $this->getDomainManager()->find($action, $repositoryMethod, $criteria, $sorting)) === null) {
throw $this->createNotFoundException(sprintf(
'The %s does not exist (%s) (%s).',
str_replace('_', ' ', $this->resource->getName()),
json_encode($criteria),
json_encode($sorting)
));
}
if ($result instanceof Pagerfanta) {
$result->setCurrentPage($this->getParameterResolver()->resolveCurrentPage());
$result->setMaxPerPage($this->getParameterResolver()->resolveMaxPerPage());
} elseif (!$this->getSecurityChecker()->isGranted($action, $result)) {
throw $this->createAccessDeniedException();
}
return $result;
} | [
"protected",
"function",
"find",
"(",
"$",
"action",
",",
"$",
"mandatory",
"=",
"true",
")",
"{",
"$",
"repositoryMethod",
"=",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveRepositoryMethod",
"(",
"$",
"action",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveCriteria",
"(",
"$",
"mandatory",
")",
";",
"$",
"sorting",
"=",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveSorting",
"(",
")",
";",
"if",
"(",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"getDomainManager",
"(",
")",
"->",
"find",
"(",
"$",
"action",
",",
"$",
"repositoryMethod",
",",
"$",
"criteria",
",",
"$",
"sorting",
")",
")",
"===",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"sprintf",
"(",
"'The %s does not exist (%s) (%s).'",
",",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"this",
"->",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"json_encode",
"(",
"$",
"criteria",
")",
",",
"json_encode",
"(",
"$",
"sorting",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"result",
"instanceof",
"Pagerfanta",
")",
"{",
"$",
"result",
"->",
"setCurrentPage",
"(",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveCurrentPage",
"(",
")",
")",
";",
"$",
"result",
"->",
"setMaxPerPage",
"(",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveMaxPerPage",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"getSecurityChecker",
"(",
")",
"->",
"isGranted",
"(",
"$",
"action",
",",
"$",
"result",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createAccessDeniedException",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | @param string $action
@param bool $mandatory
@return object|object[] | [
"@param",
"string",
"$action",
"@param",
"bool",
"$mandatory"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L194-L217 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.buildForm | protected function buildForm($form = null, $object = null, array $options = [])
{
return $this->getFormFactory()->create($form ?: $this->resource, $object, $options);
} | php | protected function buildForm($form = null, $object = null, array $options = [])
{
return $this->getFormFactory()->create($form ?: $this->resource, $object, $options);
} | [
"protected",
"function",
"buildForm",
"(",
"$",
"form",
"=",
"null",
",",
"$",
"object",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getFormFactory",
"(",
")",
"->",
"create",
"(",
"$",
"form",
"?",
":",
"$",
"this",
"->",
"resource",
",",
"$",
"object",
",",
"$",
"options",
")",
";",
"}"
] | @param string|object|null $form
@param object|null $object
@param mixed[] $options
@return FormInterface | [
"@param",
"string|object|null",
"$form",
"@param",
"object|null",
"$object",
"@param",
"mixed",
"[]",
"$options"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L226-L229 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.submitForm | protected function submitForm(FormInterface $form, Request $request)
{
$bag = $request->isMethod('GET') || $form->getConfig()->getMethod() === 'GET'
? $request->query
: $request->request;
if ($this->getParameterResolver()->resolveApi()) {
$data = array_merge($bag->all(), $request->files->all());
} else {
$data = array_merge($bag->get($form->getName(), []), $request->files->get($form->getName(), []));
}
array_walk_recursive($data, function (&$value) {
if ($value === false) {
$value = 'false';
}
});
return $form->submit($data, !$request->isMethod('PATCH'));
} | php | protected function submitForm(FormInterface $form, Request $request)
{
$bag = $request->isMethod('GET') || $form->getConfig()->getMethod() === 'GET'
? $request->query
: $request->request;
if ($this->getParameterResolver()->resolveApi()) {
$data = array_merge($bag->all(), $request->files->all());
} else {
$data = array_merge($bag->get($form->getName(), []), $request->files->get($form->getName(), []));
}
array_walk_recursive($data, function (&$value) {
if ($value === false) {
$value = 'false';
}
});
return $form->submit($data, !$request->isMethod('PATCH'));
} | [
"protected",
"function",
"submitForm",
"(",
"FormInterface",
"$",
"form",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"bag",
"=",
"$",
"request",
"->",
"isMethod",
"(",
"'GET'",
")",
"||",
"$",
"form",
"->",
"getConfig",
"(",
")",
"->",
"getMethod",
"(",
")",
"===",
"'GET'",
"?",
"$",
"request",
"->",
"query",
":",
"$",
"request",
"->",
"request",
";",
"if",
"(",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveApi",
"(",
")",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"bag",
"->",
"all",
"(",
")",
",",
"$",
"request",
"->",
"files",
"->",
"all",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"bag",
"->",
"get",
"(",
"$",
"form",
"->",
"getName",
"(",
")",
",",
"[",
"]",
")",
",",
"$",
"request",
"->",
"files",
"->",
"get",
"(",
"$",
"form",
"->",
"getName",
"(",
")",
",",
"[",
"]",
")",
")",
";",
"}",
"array_walk_recursive",
"(",
"$",
"data",
",",
"function",
"(",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"$",
"value",
"=",
"'false'",
";",
"}",
"}",
")",
";",
"return",
"$",
"form",
"->",
"submit",
"(",
"$",
"data",
",",
"!",
"$",
"request",
"->",
"isMethod",
"(",
"'PATCH'",
")",
")",
";",
"}"
] | @param FormInterface $form
@param Request $request
@return FormInterface | [
"@param",
"FormInterface",
"$form",
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L237-L256 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.submitGrid | protected function submitGrid(GridInterface $grid, Request $request)
{
return $this->submitForm($this->buildForm(GridType::class, null, ['grid' => $grid]), $request);
} | php | protected function submitGrid(GridInterface $grid, Request $request)
{
return $this->submitForm($this->buildForm(GridType::class, null, ['grid' => $grid]), $request);
} | [
"protected",
"function",
"submitGrid",
"(",
"GridInterface",
"$",
"grid",
",",
"Request",
"$",
"request",
")",
"{",
"return",
"$",
"this",
"->",
"submitForm",
"(",
"$",
"this",
"->",
"buildForm",
"(",
"GridType",
"::",
"class",
",",
"null",
",",
"[",
"'grid'",
"=>",
"$",
"grid",
"]",
")",
",",
"$",
"request",
")",
";",
"}"
] | @param GridInterface $grid
@param Request $request
@return FormInterface | [
"@param",
"GridInterface",
"$grid",
"@param",
"Request",
"$request"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L272-L275 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.processAction | protected function processAction($action, FormInterface $form = null, $statusCode = Response::HTTP_NO_CONTENT)
{
$statusCode = $this->getParameterResolver()->resolveStatusCode($statusCode);
$this->getRestEventDispatcher()->dispatch(
RestEvents::ACTION,
$event = new ActionEvent($this->resource, $action, $form, $statusCode)
);
$view = $event->getView();
$statusCode = $view->getStatusCode();
return $statusCode >= 300 && $statusCode < 400
? $this->handleView($view)
: $this->processView($action, $view);
} | php | protected function processAction($action, FormInterface $form = null, $statusCode = Response::HTTP_NO_CONTENT)
{
$statusCode = $this->getParameterResolver()->resolveStatusCode($statusCode);
$this->getRestEventDispatcher()->dispatch(
RestEvents::ACTION,
$event = new ActionEvent($this->resource, $action, $form, $statusCode)
);
$view = $event->getView();
$statusCode = $view->getStatusCode();
return $statusCode >= 300 && $statusCode < 400
? $this->handleView($view)
: $this->processView($action, $view);
} | [
"protected",
"function",
"processAction",
"(",
"$",
"action",
",",
"FormInterface",
"$",
"form",
"=",
"null",
",",
"$",
"statusCode",
"=",
"Response",
"::",
"HTTP_NO_CONTENT",
")",
"{",
"$",
"statusCode",
"=",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveStatusCode",
"(",
"$",
"statusCode",
")",
";",
"$",
"this",
"->",
"getRestEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"RestEvents",
"::",
"ACTION",
",",
"$",
"event",
"=",
"new",
"ActionEvent",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"action",
",",
"$",
"form",
",",
"$",
"statusCode",
")",
")",
";",
"$",
"view",
"=",
"$",
"event",
"->",
"getView",
"(",
")",
";",
"$",
"statusCode",
"=",
"$",
"view",
"->",
"getStatusCode",
"(",
")",
";",
"return",
"$",
"statusCode",
">=",
"300",
"&&",
"$",
"statusCode",
"<",
"400",
"?",
"$",
"this",
"->",
"handleView",
"(",
"$",
"view",
")",
":",
"$",
"this",
"->",
"processView",
"(",
"$",
"action",
",",
"$",
"view",
")",
";",
"}"
] | @param string $action
@param FormInterface|null $form
@param int $statusCode
@return Response | [
"@param",
"string",
"$action",
"@param",
"FormInterface|null",
"$form",
"@param",
"int",
"$statusCode"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L284-L299 |
php-lug/lug | src/Bundle/ResourceBundle/Controller/Controller.php | Controller.processView | protected function processView($action, View $view)
{
$this->getRestEventDispatcher()->dispatch(
RestEvents::VIEW,
$event = new ViewEvent($this->resource, $action, $view)
);
return $this->handleView($event->getView());
} | php | protected function processView($action, View $view)
{
$this->getRestEventDispatcher()->dispatch(
RestEvents::VIEW,
$event = new ViewEvent($this->resource, $action, $view)
);
return $this->handleView($event->getView());
} | [
"protected",
"function",
"processView",
"(",
"$",
"action",
",",
"View",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"getRestEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"RestEvents",
"::",
"VIEW",
",",
"$",
"event",
"=",
"new",
"ViewEvent",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"action",
",",
"$",
"view",
")",
")",
";",
"return",
"$",
"this",
"->",
"handleView",
"(",
"$",
"event",
"->",
"getView",
"(",
")",
")",
";",
"}"
] | @param string $action
@param View $view
@return Response | [
"@param",
"string",
"$action",
"@param",
"View",
"$view"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Controller/Controller.php#L307-L315 |
eloquent/phony-kahlan | src/ArgumentFactory.php | ArgumentFactory.argumentsForCallback | public function argumentsForCallback(callable $callback): array
{
$definition = new ReflectionFunction($callback);
$arguments = [];
foreach ($definition->getParameters() as $parameter) {
if ($type = $parameter->getType()) {
$arguments[] = Phony::emptyValue($type);
} else {
$arguments[] = null;
}
}
return $arguments;
} | php | public function argumentsForCallback(callable $callback): array
{
$definition = new ReflectionFunction($callback);
$arguments = [];
foreach ($definition->getParameters() as $parameter) {
if ($type = $parameter->getType()) {
$arguments[] = Phony::emptyValue($type);
} else {
$arguments[] = null;
}
}
return $arguments;
} | [
"public",
"function",
"argumentsForCallback",
"(",
"callable",
"$",
"callback",
")",
":",
"array",
"{",
"$",
"definition",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"$",
"arguments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"definition",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"$",
"type",
"=",
"$",
"parameter",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"Phony",
"::",
"emptyValue",
"(",
"$",
"type",
")",
";",
"}",
"else",
"{",
"$",
"arguments",
"[",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"arguments",
";",
"}"
] | Returns an argument list of test doubles for the supplied callback.
@param callable $callback The callback.
@return array The arguments. | [
"Returns",
"an",
"argument",
"list",
"of",
"test",
"doubles",
"for",
"the",
"supplied",
"callback",
"."
] | train | https://github.com/eloquent/phony-kahlan/blob/a4654a7edf58268b492acc751ecbeddded9b176f/src/ArgumentFactory.php#L21-L35 |
old-town/workflow-designer-server | src/Factory/SendApiProblemResponseListenerFactory.php | SendApiProblemResponseListenerFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
/** @var array $config */
$config = $serviceLocator->get('Config');
$displayExceptions = array_key_exists('view_manager', $config)
&& array_key_exists('display_exceptions', $config['view_manager'])
&& $config['view_manager']['display_exceptions'];
$listener = new SendApiProblemResponseListener();
$listener->setDisplayExceptions($displayExceptions);
if ($serviceLocator->has('Response')) {
$response = $serviceLocator->get('Response');
if ($response instanceof HttpResponse) {
$listener->setApplicationResponse($response);
}
}
if ($serviceLocator->has('Application')) {
/** @var Application $app */
$app = $serviceLocator->get('Application');
$mvcEvent = $app->getMvcEvent();
if ($mvcEvent instanceof MvcEvent) {
$listener->setMvcEvent($mvcEvent);
}
}
return $listener;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
/** @var array $config */
$config = $serviceLocator->get('Config');
$displayExceptions = array_key_exists('view_manager', $config)
&& array_key_exists('display_exceptions', $config['view_manager'])
&& $config['view_manager']['display_exceptions'];
$listener = new SendApiProblemResponseListener();
$listener->setDisplayExceptions($displayExceptions);
if ($serviceLocator->has('Response')) {
$response = $serviceLocator->get('Response');
if ($response instanceof HttpResponse) {
$listener->setApplicationResponse($response);
}
}
if ($serviceLocator->has('Application')) {
/** @var Application $app */
$app = $serviceLocator->get('Application');
$mvcEvent = $app->getMvcEvent();
if ($mvcEvent instanceof MvcEvent) {
$listener->setMvcEvent($mvcEvent);
}
}
return $listener;
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"/** @var array $config */",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"$",
"displayExceptions",
"=",
"array_key_exists",
"(",
"'view_manager'",
",",
"$",
"config",
")",
"&&",
"array_key_exists",
"(",
"'display_exceptions'",
",",
"$",
"config",
"[",
"'view_manager'",
"]",
")",
"&&",
"$",
"config",
"[",
"'view_manager'",
"]",
"[",
"'display_exceptions'",
"]",
";",
"$",
"listener",
"=",
"new",
"SendApiProblemResponseListener",
"(",
")",
";",
"$",
"listener",
"->",
"setDisplayExceptions",
"(",
"$",
"displayExceptions",
")",
";",
"if",
"(",
"$",
"serviceLocator",
"->",
"has",
"(",
"'Response'",
")",
")",
"{",
"$",
"response",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Response'",
")",
";",
"if",
"(",
"$",
"response",
"instanceof",
"HttpResponse",
")",
"{",
"$",
"listener",
"->",
"setApplicationResponse",
"(",
"$",
"response",
")",
";",
"}",
"}",
"if",
"(",
"$",
"serviceLocator",
"->",
"has",
"(",
"'Application'",
")",
")",
"{",
"/** @var Application $app */",
"$",
"app",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Application'",
")",
";",
"$",
"mvcEvent",
"=",
"$",
"app",
"->",
"getMvcEvent",
"(",
")",
";",
"if",
"(",
"$",
"mvcEvent",
"instanceof",
"MvcEvent",
")",
"{",
"$",
"listener",
"->",
"setMvcEvent",
"(",
"$",
"mvcEvent",
")",
";",
"}",
"}",
"return",
"$",
"listener",
";",
"}"
] | {@inheritDoc}
@return SendApiProblemResponseListener
@throws \Zend\ServiceManager\Exception\ServiceNotFoundException | [
"{",
"@inheritDoc",
"}",
"@return",
"SendApiProblemResponseListener"
] | train | https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/Factory/SendApiProblemResponseListenerFactory.php#L29-L60 |
InactiveProjects/limoncello-illuminate | app/Database/Models/User.php | User.setPasswordAttribute | public function setPasswordAttribute($value)
{
/** @var Hasher $hasher */
$hasher = app(Hasher::class);
$hash = $hasher->make($value);
$this->attributes[self::FIELD_PASSWORD_HASH] = $hash;
} | php | public function setPasswordAttribute($value)
{
/** @var Hasher $hasher */
$hasher = app(Hasher::class);
$hash = $hasher->make($value);
$this->attributes[self::FIELD_PASSWORD_HASH] = $hash;
} | [
"public",
"function",
"setPasswordAttribute",
"(",
"$",
"value",
")",
"{",
"/** @var Hasher $hasher */",
"$",
"hasher",
"=",
"app",
"(",
"Hasher",
"::",
"class",
")",
";",
"$",
"hash",
"=",
"$",
"hasher",
"->",
"make",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"self",
"::",
"FIELD_PASSWORD_HASH",
"]",
"=",
"$",
"hash",
";",
"}"
] | Set password (hashes automatically).
@param string $value | [
"Set",
"password",
"(",
"hashes",
"automatically",
")",
"."
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Database/Models/User.php#L240-L247 |
zhouyl/mellivora | Mellivora/Console/GeneratorCommand.php | GeneratorCommand.fire | public function fire()
{
$name = $this->qualifyClass($this->getNameInput());
$path = $this->getPath($name);
// First we will check to see if the class already exists. If it does, we don't want
// to create the class and overwrite the user's code. So, we will bail out so the
// code is untouched. Otherwise, we will continue generating this class' files.
if ($this->alreadyExists($this->getNameInput())) {
$this->error($this->type . ' already exists!');
return false;
}
// Next, we will generate the path to the location where this class' file should get
// written. Then, we will build the class and make the proper replacements on the
// stub files so that it gets the correctly formatted namespace and class name.
$this->makeDirectory($path);
file_put_contents($path, $this->buildClass($name));
$this->info($this->type . ' created successfully.');
} | php | public function fire()
{
$name = $this->qualifyClass($this->getNameInput());
$path = $this->getPath($name);
// First we will check to see if the class already exists. If it does, we don't want
// to create the class and overwrite the user's code. So, we will bail out so the
// code is untouched. Otherwise, we will continue generating this class' files.
if ($this->alreadyExists($this->getNameInput())) {
$this->error($this->type . ' already exists!');
return false;
}
// Next, we will generate the path to the location where this class' file should get
// written. Then, we will build the class and make the proper replacements on the
// stub files so that it gets the correctly formatted namespace and class name.
$this->makeDirectory($path);
file_put_contents($path, $this->buildClass($name));
$this->info($this->type . ' created successfully.');
} | [
"public",
"function",
"fire",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"qualifyClass",
"(",
"$",
"this",
"->",
"getNameInput",
"(",
")",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"name",
")",
";",
"// First we will check to see if the class already exists. If it does, we don't want",
"// to create the class and overwrite the user's code. So, we will bail out so the",
"// code is untouched. Otherwise, we will continue generating this class' files.",
"if",
"(",
"$",
"this",
"->",
"alreadyExists",
"(",
"$",
"this",
"->",
"getNameInput",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"$",
"this",
"->",
"type",
".",
"' already exists!'",
")",
";",
"return",
"false",
";",
"}",
"// Next, we will generate the path to the location where this class' file should get",
"// written. Then, we will build the class and make the proper replacements on the",
"// stub files so that it gets the correctly formatted namespace and class name.",
"$",
"this",
"->",
"makeDirectory",
"(",
"$",
"path",
")",
";",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"buildClass",
"(",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"info",
"(",
"$",
"this",
"->",
"type",
".",
"' created successfully.'",
")",
";",
"}"
] | Execute the console command.
@return null|bool | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/GeneratorCommand.php#L29-L52 |
zhouyl/mellivora | Mellivora/Console/GeneratorCommand.php | GeneratorCommand.qualifyClass | protected function qualifyClass($name)
{
$rootNamespace = $this->rootNamespace();
if (Str::startsWith($name, $rootNamespace . '\\')) {
return $name;
}
$name = str_replace('/', '\\', $name);
return $this->qualifyClass(
$this->getDefaultNamespace(trim($rootNamespace, '\\')) . '\\' . $name
);
} | php | protected function qualifyClass($name)
{
$rootNamespace = $this->rootNamespace();
if (Str::startsWith($name, $rootNamespace . '\\')) {
return $name;
}
$name = str_replace('/', '\\', $name);
return $this->qualifyClass(
$this->getDefaultNamespace(trim($rootNamespace, '\\')) . '\\' . $name
);
} | [
"protected",
"function",
"qualifyClass",
"(",
"$",
"name",
")",
"{",
"$",
"rootNamespace",
"=",
"$",
"this",
"->",
"rootNamespace",
"(",
")",
";",
"if",
"(",
"Str",
"::",
"startsWith",
"(",
"$",
"name",
",",
"$",
"rootNamespace",
".",
"'\\\\'",
")",
")",
"{",
"return",
"$",
"name",
";",
"}",
"$",
"name",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"qualifyClass",
"(",
"$",
"this",
"->",
"getDefaultNamespace",
"(",
"trim",
"(",
"$",
"rootNamespace",
",",
"'\\\\'",
")",
")",
".",
"'\\\\'",
".",
"$",
"name",
")",
";",
"}"
] | Parse the class name and format according to the root namespace.
@param string $name
@return string | [
"Parse",
"the",
"class",
"name",
"and",
"format",
"according",
"to",
"the",
"root",
"namespace",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/GeneratorCommand.php#L61-L74 |
zhouyl/mellivora | Mellivora/Console/GeneratorCommand.php | GeneratorCommand.makeDirectory | protected function makeDirectory($path)
{
if (!is_dir(dirname($path))) {
mkdir(dirname($path), 0777, true);
}
return $path;
} | php | protected function makeDirectory($path)
{
if (!is_dir(dirname($path))) {
mkdir(dirname($path), 0777, true);
}
return $path;
} | [
"protected",
"function",
"makeDirectory",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"path",
")",
",",
"0777",
",",
"true",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Build the directory for the class if necessary.
@param string $path
@return string | [
"Build",
"the",
"directory",
"for",
"the",
"class",
"if",
"necessary",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/GeneratorCommand.php#L123-L130 |
zhouyl/mellivora | Mellivora/Console/GeneratorCommand.php | GeneratorCommand.buildClass | protected function buildClass($name)
{
$stub = file_get_contents($this->getStub());
return $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
} | php | protected function buildClass($name)
{
$stub = file_get_contents($this->getStub());
return $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
} | [
"protected",
"function",
"buildClass",
"(",
"$",
"name",
")",
"{",
"$",
"stub",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"getStub",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"replaceNamespace",
"(",
"$",
"stub",
",",
"$",
"name",
")",
"->",
"replaceClass",
"(",
"$",
"stub",
",",
"$",
"name",
")",
";",
"}"
] | Build the class with the given name.
@param string $name
@return string | [
"Build",
"the",
"class",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/GeneratorCommand.php#L139-L144 |
zhouyl/mellivora | Mellivora/Console/GeneratorCommand.php | GeneratorCommand.getNameInput | protected function getNameInput()
{
$name = Str::studly($this->argument('name'));
$suffix = $this->getNameSuffix();
if ($suffix && !Str::endsWith($name, $suffix)) {
$name .= $suffix;
}
return $name;
} | php | protected function getNameInput()
{
$name = Str::studly($this->argument('name'));
$suffix = $this->getNameSuffix();
if ($suffix && !Str::endsWith($name, $suffix)) {
$name .= $suffix;
}
return $name;
} | [
"protected",
"function",
"getNameInput",
"(",
")",
"{",
"$",
"name",
"=",
"Str",
"::",
"studly",
"(",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
";",
"$",
"suffix",
"=",
"$",
"this",
"->",
"getNameSuffix",
"(",
")",
";",
"if",
"(",
"$",
"suffix",
"&&",
"!",
"Str",
"::",
"endsWith",
"(",
"$",
"name",
",",
"$",
"suffix",
")",
")",
"{",
"$",
"name",
".=",
"$",
"suffix",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Get the desired class name from the input.
@return string | [
"Get",
"the",
"desired",
"class",
"name",
"from",
"the",
"input",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/GeneratorCommand.php#L197-L207 |
amenophis/WHMCS-Connector | src/Amenophis/WHMCS/Adapter/Manager.php | Manager.get | public function get($name = null)
{
if(count($this->connectors) > 0)
{
if(!is_null($name))
{
if(!isset($this->connectors[$name]))
throw new \Exception("unknown Connector: $name");
return $this->connectors[$name];
}
return current($this->connectors);
}
throw new \Exception('No Connectors found');
} | php | public function get($name = null)
{
if(count($this->connectors) > 0)
{
if(!is_null($name))
{
if(!isset($this->connectors[$name]))
throw new \Exception("unknown Connector: $name");
return $this->connectors[$name];
}
return current($this->connectors);
}
throw new \Exception('No Connectors found');
} | [
"public",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"connectors",
")",
">",
"0",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"connectors",
"[",
"$",
"name",
"]",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"\"unknown Connector: $name\"",
")",
";",
"return",
"$",
"this",
"->",
"connectors",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"current",
"(",
"$",
"this",
"->",
"connectors",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'No Connectors found'",
")",
";",
"}"
] | get an Connector by its name or it will return the default Connector
@param string $name Index of the chosen Connector
@return FP\WHMCS\Connector | [
"get",
"an",
"Connector",
"by",
"its",
"name",
"or",
"it",
"will",
"return",
"the",
"default",
"Connector"
] | train | https://github.com/amenophis/WHMCS-Connector/blob/eb608e6652aca8a46dd80dd04159142a7e2d2f9b/src/Amenophis/WHMCS/Adapter/Manager.php#L50-L65 |
grozzzny/catalog | models/DataProperties.php | DataProperties.parseValueMulticategory | public static function parseValueMulticategory($value)
{
$values = (is_array($value)) ? $value : [$value];
$categories_arr = [];
$classCategory = static::getClassCategory();
foreach ($values as $val) {
$categories_arr = ArrayHelper::merge($categories_arr, [$val] + $classCategory::getOnlyParentId($val));
}
return $categories_arr;
} | php | public static function parseValueMulticategory($value)
{
$values = (is_array($value)) ? $value : [$value];
$categories_arr = [];
$classCategory = static::getClassCategory();
foreach ($values as $val) {
$categories_arr = ArrayHelper::merge($categories_arr, [$val] + $classCategory::getOnlyParentId($val));
}
return $categories_arr;
} | [
"public",
"static",
"function",
"parseValueMulticategory",
"(",
"$",
"value",
")",
"{",
"$",
"values",
"=",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"?",
"$",
"value",
":",
"[",
"$",
"value",
"]",
";",
"$",
"categories_arr",
"=",
"[",
"]",
";",
"$",
"classCategory",
"=",
"static",
"::",
"getClassCategory",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"val",
")",
"{",
"$",
"categories_arr",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"categories_arr",
",",
"[",
"$",
"val",
"]",
"+",
"$",
"classCategory",
"::",
"getOnlyParentId",
"(",
"$",
"val",
")",
")",
";",
"}",
"return",
"$",
"categories_arr",
";",
"}"
] | } | [
"}"
] | train | https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/models/DataProperties.php#L171-L180 |
grozzzny/catalog | models/DataProperties.php | DataProperties.saveData | public function saveData($item)
{
$attributes = $item->dataProperties->getAttributesForSave($item->id);
if(empty($attributes)) return false;
$classData = static::getClassData();
foreach ($attributes as $slug => $values)
{
$classData::deleteAll(['item_id' => $item->id, 'property_slug' => $slug]);
$values = (is_array($values)) ? $values : [$values];
foreach ($values as $value){
$value = (is_array($value)) ? array_values($value)[0] : $value;
$data = new $classData;
$data->value = $value;
$data->property_slug = $slug;
$data->item_id = $item->id;
if(!empty($value)) $data->save();
}
}
} | php | public function saveData($item)
{
$attributes = $item->dataProperties->getAttributesForSave($item->id);
if(empty($attributes)) return false;
$classData = static::getClassData();
foreach ($attributes as $slug => $values)
{
$classData::deleteAll(['item_id' => $item->id, 'property_slug' => $slug]);
$values = (is_array($values)) ? $values : [$values];
foreach ($values as $value){
$value = (is_array($value)) ? array_values($value)[0] : $value;
$data = new $classData;
$data->value = $value;
$data->property_slug = $slug;
$data->item_id = $item->id;
if(!empty($value)) $data->save();
}
}
} | [
"public",
"function",
"saveData",
"(",
"$",
"item",
")",
"{",
"$",
"attributes",
"=",
"$",
"item",
"->",
"dataProperties",
"->",
"getAttributesForSave",
"(",
"$",
"item",
"->",
"id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"attributes",
")",
")",
"return",
"false",
";",
"$",
"classData",
"=",
"static",
"::",
"getClassData",
"(",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"slug",
"=>",
"$",
"values",
")",
"{",
"$",
"classData",
"::",
"deleteAll",
"(",
"[",
"'item_id'",
"=>",
"$",
"item",
"->",
"id",
",",
"'property_slug'",
"=>",
"$",
"slug",
"]",
")",
";",
"$",
"values",
"=",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"?",
"$",
"values",
":",
"[",
"$",
"values",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"?",
"array_values",
"(",
"$",
"value",
")",
"[",
"0",
"]",
":",
"$",
"value",
";",
"$",
"data",
"=",
"new",
"$",
"classData",
";",
"$",
"data",
"->",
"value",
"=",
"$",
"value",
";",
"$",
"data",
"->",
"property_slug",
"=",
"$",
"slug",
";",
"$",
"data",
"->",
"item_id",
"=",
"$",
"item",
"->",
"id",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"$",
"data",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}"
] | Сохранение значений в таблицу "Data"
@return bool | [
"Сохранение",
"значений",
"в",
"таблицу",
"Data"
] | train | https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/models/DataProperties.php#L214-L238 |
tttptd/laravel-responder | src/ResponderServiceProvider.php | ResponderServiceProvider.boot | public function boot()
{
if ($this->app instanceof Laravel && $this->app->runningInConsole()) {
$this->bootLaravelApplication();
} elseif ($this->app instanceof Lumen) {
$this->bootLumenApplication();
}
$this->mergeConfigFrom(__DIR__ . '/../resources/config/responder.php', 'responder');
$this->commands([
MakeTransformer::class
]);
include __DIR__ . '/helpers.php';
} | php | public function boot()
{
if ($this->app instanceof Laravel && $this->app->runningInConsole()) {
$this->bootLaravelApplication();
} elseif ($this->app instanceof Lumen) {
$this->bootLumenApplication();
}
$this->mergeConfigFrom(__DIR__ . '/../resources/config/responder.php', 'responder');
$this->commands([
MakeTransformer::class
]);
include __DIR__ . '/helpers.php';
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"instanceof",
"Laravel",
"&&",
"$",
"this",
"->",
"app",
"->",
"runningInConsole",
"(",
")",
")",
"{",
"$",
"this",
"->",
"bootLaravelApplication",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"app",
"instanceof",
"Lumen",
")",
"{",
"$",
"this",
"->",
"bootLumenApplication",
"(",
")",
";",
"}",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"__DIR__",
".",
"'/../resources/config/responder.php'",
",",
"'responder'",
")",
";",
"$",
"this",
"->",
"commands",
"(",
"[",
"MakeTransformer",
"::",
"class",
"]",
")",
";",
"include",
"__DIR__",
".",
"'/helpers.php'",
";",
"}"
] | Bootstrap the application events.
@return void | [
"Bootstrap",
"the",
"application",
"events",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L44-L60 |
tttptd/laravel-responder | src/ResponderServiceProvider.php | ResponderServiceProvider.register | public function register()
{
$this->registerFractal();
$this->registerResponseBuilders();
$this->app->bind(Responder::class, function ($app) {
return new Responder($app[SuccessResponseBuilder::class], $app[ErrorResponseBuilder::class]);
});
$this->registerAliases();
} | php | public function register()
{
$this->registerFractal();
$this->registerResponseBuilders();
$this->app->bind(Responder::class, function ($app) {
return new Responder($app[SuccessResponseBuilder::class], $app[ErrorResponseBuilder::class]);
});
$this->registerAliases();
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"registerFractal",
"(",
")",
";",
"$",
"this",
"->",
"registerResponseBuilders",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"Responder",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Responder",
"(",
"$",
"app",
"[",
"SuccessResponseBuilder",
"::",
"class",
"]",
",",
"$",
"app",
"[",
"ErrorResponseBuilder",
"::",
"class",
"]",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"registerAliases",
"(",
")",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L67-L77 |
tttptd/laravel-responder | src/ResponderServiceProvider.php | ResponderServiceProvider.registerFractal | protected function registerFractal()
{
$this->app->bind(SerializerAbstract::class, function ($app) {
$serializer = $app->config->get('responder.serializer');
return new $serializer;
});
$this->app->bind(Manager::class, function ($app) {
return (new Manager())->setSerializer($app[SerializerAbstract::class]);
});
$this->app->bind(ResourceFactory::class, function () {
return new ResourceFactory();
});
} | php | protected function registerFractal()
{
$this->app->bind(SerializerAbstract::class, function ($app) {
$serializer = $app->config->get('responder.serializer');
return new $serializer;
});
$this->app->bind(Manager::class, function ($app) {
return (new Manager())->setSerializer($app[SerializerAbstract::class]);
});
$this->app->bind(ResourceFactory::class, function () {
return new ResourceFactory();
});
} | [
"protected",
"function",
"registerFractal",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"SerializerAbstract",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"serializer",
"=",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.serializer'",
")",
";",
"return",
"new",
"$",
"serializer",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"Manager",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"(",
"new",
"Manager",
"(",
")",
")",
"->",
"setSerializer",
"(",
"$",
"app",
"[",
"SerializerAbstract",
"::",
"class",
"]",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"ResourceFactory",
"::",
"class",
",",
"function",
"(",
")",
"{",
"return",
"new",
"ResourceFactory",
"(",
")",
";",
"}",
")",
";",
"}"
] | Register Fractal serializer, manager and a factory to generate Fractal
resource instances.
@return void | [
"Register",
"Fractal",
"serializer",
"manager",
"and",
"a",
"factory",
"to",
"generate",
"Fractal",
"resource",
"instances",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L95-L110 |
tttptd/laravel-responder | src/ResponderServiceProvider.php | ResponderServiceProvider.registerResponseBuilders | protected function registerResponseBuilders()
{
$this->app->bind(SuccessResponseBuilder::class, function ($app) {
$builder = new SuccessResponseBuilder(response(), $app[ResourceFactory::class], $app[Manager::class]);
if ($parameter = $app->config->get('responder.load_relations_from_parameter')) {
$builder->include($this->app[Request::class]->input($parameter, []));
}
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
$this->app->bind(ErrorResponseBuilder::class, function ($app) {
$builder = new ErrorResponseBuilder(response(), $app['translator']);
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
} | php | protected function registerResponseBuilders()
{
$this->app->bind(SuccessResponseBuilder::class, function ($app) {
$builder = new SuccessResponseBuilder(response(), $app[ResourceFactory::class], $app[Manager::class]);
if ($parameter = $app->config->get('responder.load_relations_from_parameter')) {
$builder->include($this->app[Request::class]->input($parameter, []));
}
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
$this->app->bind(ErrorResponseBuilder::class, function ($app) {
$builder = new ErrorResponseBuilder(response(), $app['translator']);
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
} | [
"protected",
"function",
"registerResponseBuilders",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"SuccessResponseBuilder",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"builder",
"=",
"new",
"SuccessResponseBuilder",
"(",
"response",
"(",
")",
",",
"$",
"app",
"[",
"ResourceFactory",
"::",
"class",
"]",
",",
"$",
"app",
"[",
"Manager",
"::",
"class",
"]",
")",
";",
"if",
"(",
"$",
"parameter",
"=",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.load_relations_from_parameter'",
")",
")",
"{",
"$",
"builder",
"->",
"include",
"(",
"$",
"this",
"->",
"app",
"[",
"Request",
"::",
"class",
"]",
"->",
"input",
"(",
"$",
"parameter",
",",
"[",
"]",
")",
")",
";",
"}",
"$",
"builder",
"->",
"setIncludeSuccessFlag",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_success_flag'",
")",
")",
";",
"return",
"$",
"builder",
"->",
"setIncludeStatusCode",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_status_code'",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"ErrorResponseBuilder",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"builder",
"=",
"new",
"ErrorResponseBuilder",
"(",
"response",
"(",
")",
",",
"$",
"app",
"[",
"'translator'",
"]",
")",
";",
"$",
"builder",
"->",
"setIncludeSuccessFlag",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_success_flag'",
")",
")",
";",
"return",
"$",
"builder",
"->",
"setIncludeStatusCode",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_status_code'",
")",
")",
";",
"}",
")",
";",
"}"
] | Register success and error response builders.
@return void | [
"Register",
"success",
"and",
"error",
"response",
"builders",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L117-L136 |
tttptd/laravel-responder | src/ResponderServiceProvider.php | ResponderServiceProvider.registerAliases | protected function registerAliases()
{
$this->app->alias(Responder::class, 'responder');
$this->app->alias(SuccessResponseBuilder::class, 'responder.success');
$this->app->alias(ErrorResponseBuilder::class, 'responder.error');
$this->app->alias(Manager::class, 'responder.manager');
$this->app->alias(Manager::class, 'responder.serializer');
} | php | protected function registerAliases()
{
$this->app->alias(Responder::class, 'responder');
$this->app->alias(SuccessResponseBuilder::class, 'responder.success');
$this->app->alias(ErrorResponseBuilder::class, 'responder.error');
$this->app->alias(Manager::class, 'responder.manager');
$this->app->alias(Manager::class, 'responder.serializer');
} | [
"protected",
"function",
"registerAliases",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"Responder",
"::",
"class",
",",
"'responder'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"SuccessResponseBuilder",
"::",
"class",
",",
"'responder.success'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"ErrorResponseBuilder",
"::",
"class",
",",
"'responder.error'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"Manager",
"::",
"class",
",",
"'responder.manager'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"Manager",
"::",
"class",
",",
"'responder.serializer'",
")",
";",
"}"
] | Set aliases for the provided services.
@return void | [
"Set",
"aliases",
"for",
"the",
"provided",
"services",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L143-L150 |
kecik-framework/kecik | example/app/controllers/welcome.php | Welcome.Form | public function Form( $id = '' ) {
if ( $id == '' ) {
$url = $this->url->linkTo( 'index.php/save' );
} else {
$url = $this->url->linkTo( 'index.php/update/' . $id );
}
return $this->view( 'form', array( 'id' => $id, 'url' => $url ) );
} | php | public function Form( $id = '' ) {
if ( $id == '' ) {
$url = $this->url->linkTo( 'index.php/save' );
} else {
$url = $this->url->linkTo( 'index.php/update/' . $id );
}
return $this->view( 'form', array( 'id' => $id, 'url' => $url ) );
} | [
"public",
"function",
"Form",
"(",
"$",
"id",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"id",
"==",
"''",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
"->",
"linkTo",
"(",
"'index.php/save'",
")",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
"->",
"linkTo",
"(",
"'index.php/update/'",
".",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
"->",
"view",
"(",
"'form'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'url'",
"=>",
"$",
"url",
")",
")",
";",
"}"
] | @param string $id
@return string | [
"@param",
"string",
"$id"
] | train | https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/example/app/controllers/welcome.php#L43-L51 |
php-lug/lug | src/Component/Locale/Provider/LocaleProvider.php | LocaleProvider.getDefaultLocale | public function getDefaultLocale()
{
if (!isset($this->cache['default_locale'])) {
$this->cache['default_locale'] = $this->localeRepository->findOneBy(
$this->createCriteria(['code' => $code = $this->defaultLocale])
);
if ($this->cache['default_locale'] === null) {
throw new LocaleNotFoundException(sprintf(
'The default locale "%s" could not be found.',
$code
));
}
}
return $this->cache['default_locale'];
} | php | public function getDefaultLocale()
{
if (!isset($this->cache['default_locale'])) {
$this->cache['default_locale'] = $this->localeRepository->findOneBy(
$this->createCriteria(['code' => $code = $this->defaultLocale])
);
if ($this->cache['default_locale'] === null) {
throw new LocaleNotFoundException(sprintf(
'The default locale "%s" could not be found.',
$code
));
}
}
return $this->cache['default_locale'];
} | [
"public",
"function",
"getDefaultLocale",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"'default_locale'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"'default_locale'",
"]",
"=",
"$",
"this",
"->",
"localeRepository",
"->",
"findOneBy",
"(",
"$",
"this",
"->",
"createCriteria",
"(",
"[",
"'code'",
"=>",
"$",
"code",
"=",
"$",
"this",
"->",
"defaultLocale",
"]",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"[",
"'default_locale'",
"]",
"===",
"null",
")",
"{",
"throw",
"new",
"LocaleNotFoundException",
"(",
"sprintf",
"(",
"'The default locale \"%s\" could not be found.'",
",",
"$",
"code",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"'default_locale'",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Locale/Provider/LocaleProvider.php#L51-L67 |
php-lug/lug | src/Component/Locale/Provider/LocaleProvider.php | LocaleProvider.getLocales | public function getLocales()
{
if (!isset($this->cache['locales'])) {
$this->cache['locales'] = $this->localeRepository->findBy($this->createCriteria());
}
return $this->cache['locales'];
} | php | public function getLocales()
{
if (!isset($this->cache['locales'])) {
$this->cache['locales'] = $this->localeRepository->findBy($this->createCriteria());
}
return $this->cache['locales'];
} | [
"public",
"function",
"getLocales",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"'locales'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"'locales'",
"]",
"=",
"$",
"this",
"->",
"localeRepository",
"->",
"findBy",
"(",
"$",
"this",
"->",
"createCriteria",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"'locales'",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Locale/Provider/LocaleProvider.php#L72-L79 |
php-lug/lug | src/Component/Locale/Provider/LocaleProvider.php | LocaleProvider.getRequiredLocales | public function getRequiredLocales()
{
if (!isset($this->cache['required_locales'])) {
$requiredLocales = [];
foreach ($this->getLocales() as $locale) {
if ($locale->isRequired()) {
$requiredLocales[] = $locale;
}
}
$this->cache['required_locales'] = $requiredLocales;
}
return $this->cache['required_locales'];
} | php | public function getRequiredLocales()
{
if (!isset($this->cache['required_locales'])) {
$requiredLocales = [];
foreach ($this->getLocales() as $locale) {
if ($locale->isRequired()) {
$requiredLocales[] = $locale;
}
}
$this->cache['required_locales'] = $requiredLocales;
}
return $this->cache['required_locales'];
} | [
"public",
"function",
"getRequiredLocales",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"'required_locales'",
"]",
")",
")",
"{",
"$",
"requiredLocales",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getLocales",
"(",
")",
"as",
"$",
"locale",
")",
"{",
"if",
"(",
"$",
"locale",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"requiredLocales",
"[",
"]",
"=",
"$",
"locale",
";",
"}",
"}",
"$",
"this",
"->",
"cache",
"[",
"'required_locales'",
"]",
"=",
"$",
"requiredLocales",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"'required_locales'",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Locale/Provider/LocaleProvider.php#L84-L99 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/BlockTranslationController.php | BlockTranslationController.index | public function index($id)
{
$this->authorize('readList', Block::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$block = $this->repository->getById($id);
if (!empty($block)) {
$results = $this->repository->getTranslations(
$block,
$params['filter'],
$params['orderBy'],
$params['page'],
$params['perPage']
);
return $this->respondWithSuccess($results, new BlockTranslationTransformer);
} else {
return $this->respondNotFound();
}
} | php | public function index($id)
{
$this->authorize('readList', Block::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$block = $this->repository->getById($id);
if (!empty($block)) {
$results = $this->repository->getTranslations(
$block,
$params['filter'],
$params['orderBy'],
$params['page'],
$params['perPage']
);
return $this->respondWithSuccess($results, new BlockTranslationTransformer);
} else {
return $this->respondNotFound();
}
} | [
"public",
"function",
"index",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'readList'",
",",
"Block",
"::",
"class",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"'list'",
")",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"processor",
"->",
"process",
"(",
"$",
"input",
")",
"->",
"getProcessedFields",
"(",
")",
";",
"$",
"block",
"=",
"$",
"this",
"->",
"repository",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"repository",
"->",
"getTranslations",
"(",
"$",
"block",
",",
"$",
"params",
"[",
"'filter'",
"]",
",",
"$",
"params",
"[",
"'orderBy'",
"]",
",",
"$",
"params",
"[",
"'page'",
"]",
",",
"$",
"params",
"[",
"'perPage'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"results",
",",
"new",
"BlockTranslationTransformer",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}",
"}"
] | Display a listing of the resource.
@param int|null $id Id used for nested resources
@return \Illuminate\Http\JsonResponse | [
"Display",
"a",
"listing",
"of",
"the",
"resource",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/BlockTranslationController.php#L62-L80 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/BlockTranslationController.php | BlockTranslationController.show | public function show($id, $translationId)
{
$block = $this->getBlock($id);
if (!empty($block)) {
$this->authorize('read', $block);
$translation = $this->repository->getBlockTranslationById($block, $translationId);
if (!empty($translation)) {
return $this->respondWithSuccess($translation, new BlockTranslationTransformer);
}
}
return $this->respondNotFound();
} | php | public function show($id, $translationId)
{
$block = $this->getBlock($id);
if (!empty($block)) {
$this->authorize('read', $block);
$translation = $this->repository->getBlockTranslationById($block, $translationId);
if (!empty($translation)) {
return $this->respondWithSuccess($translation, new BlockTranslationTransformer);
}
}
return $this->respondNotFound();
} | [
"public",
"function",
"show",
"(",
"$",
"id",
",",
"$",
"translationId",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"getBlock",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'read'",
",",
"$",
"block",
")",
";",
"$",
"translation",
"=",
"$",
"this",
"->",
"repository",
"->",
"getBlockTranslationById",
"(",
"$",
"block",
",",
"$",
"translationId",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"translation",
")",
")",
"{",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"translation",
",",
"new",
"BlockTranslationTransformer",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}"
] | Display a specified resource.
@param int $id Id of the block
@param int $translationId Id of the block translation
@return \Illuminate\Http\JsonResponse | [
"Display",
"a",
"specified",
"resource",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/BlockTranslationController.php#L90-L101 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/BlockTranslationController.php | BlockTranslationController.store | public function store($id)
{
$block = $this->getBlock($id);
if (!empty($block)) {
$this->authorize('create', $block);
$this->authorize('update', $block);
$input = $this->validator->validate('create');
$translation = $this->repository->createTranslation($block, $input);
return $this->respondWithSuccess($translation, new BlockTranslationTransformer);
}
return $this->respondNotFound();
} | php | public function store($id)
{
$block = $this->getBlock($id);
if (!empty($block)) {
$this->authorize('create', $block);
$this->authorize('update', $block);
$input = $this->validator->validate('create');
$translation = $this->repository->createTranslation($block, $input);
return $this->respondWithSuccess($translation, new BlockTranslationTransformer);
}
return $this->respondNotFound();
} | [
"public",
"function",
"store",
"(",
"$",
"id",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"getBlock",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'create'",
",",
"$",
"block",
")",
";",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"block",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"'create'",
")",
";",
"$",
"translation",
"=",
"$",
"this",
"->",
"repository",
"->",
"createTranslation",
"(",
"$",
"block",
",",
"$",
"input",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"translation",
",",
"new",
"BlockTranslationTransformer",
")",
";",
"}",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}"
] | Stores newly created translation for specified block entity in database.
@param int $id Id of the block
@return \Illuminate\Http\JsonResponse | [
"Stores",
"newly",
"created",
"translation",
"for",
"specified",
"block",
"entity",
"in",
"database",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/BlockTranslationController.php#L110-L121 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/BlockTranslationController.php | BlockTranslationController.destroy | public function destroy($id, $translationId)
{
$block = $this->getBlock($id);
if (!empty($block)) {
$this->authorize('delete', $block);
$translation = $this->repository->getBlockTranslationById($block, $translationId);
if (!empty($translation)) {
try {
$this->repository->deleteTranslation($translation);
return $this->respondWithSimpleSuccess(['success' => true]);
} catch (RepositoryValidationException $e) {
return $this->respondWithError($e->getMessage());
}
}
}
return $this->respondNotFound();
} | php | public function destroy($id, $translationId)
{
$block = $this->getBlock($id);
if (!empty($block)) {
$this->authorize('delete', $block);
$translation = $this->repository->getBlockTranslationById($block, $translationId);
if (!empty($translation)) {
try {
$this->repository->deleteTranslation($translation);
return $this->respondWithSimpleSuccess(['success' => true]);
} catch (RepositoryValidationException $e) {
return $this->respondWithError($e->getMessage());
}
}
}
return $this->respondNotFound();
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
",",
"$",
"translationId",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"getBlock",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"$",
"block",
")",
";",
"$",
"translation",
"=",
"$",
"this",
"->",
"repository",
"->",
"getBlockTranslationById",
"(",
"$",
"block",
",",
"$",
"translationId",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"translation",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"repository",
"->",
"deleteTranslation",
"(",
"$",
"translation",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSimpleSuccess",
"(",
"[",
"'success'",
"=>",
"true",
"]",
")",
";",
"}",
"catch",
"(",
"RepositoryValidationException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"respondWithError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}"
] | Remove the specified resource from database.
@param int $id Id of the block
@param int $translationId Id of the block translation
@return \Illuminate\Http\JsonResponse | [
"Remove",
"the",
"specified",
"resource",
"from",
"database",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/BlockTranslationController.php#L143-L159 |
phPoirot/psr7 | Response/PhpServer.php | PhpServer.setMessageObject | function setMessageObject(ResponseInterface $httpMessage)
{
if (!$httpMessage instanceof ResponseInterface)
throw new \InvalidArgumentException(sprintf(
'This plugin need response object instance of iHttpResponse, "%s" given.'
, get_class($httpMessage)
));
$this->messageObject = $httpMessage;
return $this;
} | php | function setMessageObject(ResponseInterface $httpMessage)
{
if (!$httpMessage instanceof ResponseInterface)
throw new \InvalidArgumentException(sprintf(
'This plugin need response object instance of iHttpResponse, "%s" given.'
, get_class($httpMessage)
));
$this->messageObject = $httpMessage;
return $this;
} | [
"function",
"setMessageObject",
"(",
"ResponseInterface",
"$",
"httpMessage",
")",
"{",
"if",
"(",
"!",
"$",
"httpMessage",
"instanceof",
"ResponseInterface",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'This plugin need response object instance of iHttpResponse, \"%s\" given.'",
",",
"get_class",
"(",
"$",
"httpMessage",
")",
")",
")",
";",
"$",
"this",
"->",
"messageObject",
"=",
"$",
"httpMessage",
";",
"return",
"$",
"this",
";",
"}"
] | Set Http Message Object (Request|Response)
note: so services can have access to http message instance
@param ResponseInterface $httpMessage
@return $this | [
"Set",
"Http",
"Message",
"Object",
"(",
"Request|Response",
")"
] | train | https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/Response/PhpServer.php#L43-L53 |
phPoirot/psr7 | Response/PhpServer.php | PhpServer.sendHeaders | function sendHeaders()
{
if ($this->isHeadersSent())
throw new \Exception('Headers was sent.');
$response = $this->getMessageObject();
// Step 1: Send the "status line".
$statusLine = sprintf('HTTP/%s %s %s'
, $response->getProtocolVersion()
, $response->getStatusCode()
, $response->getReasonPhrase()
);
header($statusLine, true); /* The header replaces a previous similar header. */
// Step 2: Send the response headers from the headers list.
foreach ($response->getHeaders() as $name => $values) {
$responseHeader = sprintf('%s: %s'
, $name
, $response->getHeaderLine($name)
);
header($responseHeader, false); /* The header doesn't replace a previous similar header. */
}
$this->isHeadersSent = true;
return $this;
} | php | function sendHeaders()
{
if ($this->isHeadersSent())
throw new \Exception('Headers was sent.');
$response = $this->getMessageObject();
// Step 1: Send the "status line".
$statusLine = sprintf('HTTP/%s %s %s'
, $response->getProtocolVersion()
, $response->getStatusCode()
, $response->getReasonPhrase()
);
header($statusLine, true); /* The header replaces a previous similar header. */
// Step 2: Send the response headers from the headers list.
foreach ($response->getHeaders() as $name => $values) {
$responseHeader = sprintf('%s: %s'
, $name
, $response->getHeaderLine($name)
);
header($responseHeader, false); /* The header doesn't replace a previous similar header. */
}
$this->isHeadersSent = true;
return $this;
} | [
"function",
"sendHeaders",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isHeadersSent",
"(",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Headers was sent.'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getMessageObject",
"(",
")",
";",
"// Step 1: Send the \"status line\".",
"$",
"statusLine",
"=",
"sprintf",
"(",
"'HTTP/%s %s %s'",
",",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
",",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"$",
"response",
"->",
"getReasonPhrase",
"(",
")",
")",
";",
"header",
"(",
"$",
"statusLine",
",",
"true",
")",
";",
"/* The header replaces a previous similar header. */",
"// Step 2: Send the response headers from the headers list.",
"foreach",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"$",
"responseHeader",
"=",
"sprintf",
"(",
"'%s: %s'",
",",
"$",
"name",
",",
"$",
"response",
"->",
"getHeaderLine",
"(",
"$",
"name",
")",
")",
";",
"header",
"(",
"$",
"responseHeader",
",",
"false",
")",
";",
"/* The header doesn't replace a previous similar header. */",
"}",
"$",
"this",
"->",
"isHeadersSent",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Send HTTP headers
@return $this
@throws \Exception headers sent | [
"Send",
"HTTP",
"headers"
] | train | https://github.com/phPoirot/psr7/blob/e90295e806dc2eb0cc422f315075f673c63a0780/Response/PhpServer.php#L87-L114 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.getConfiguration | public function getConfiguration(array $config, ContainerBuilder $container)
{
if (!class_exists($class = ClassUtils::getNamespace($this).'\\Configuration')) {
$class = ResourceConfiguration::class;
}
return new $class($this->bundle);
} | php | public function getConfiguration(array $config, ContainerBuilder $container)
{
if (!class_exists($class = ClassUtils::getNamespace($this).'\\Configuration')) {
$class = ResourceConfiguration::class;
}
return new $class($this->bundle);
} | [
"public",
"function",
"getConfiguration",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
"=",
"ClassUtils",
"::",
"getNamespace",
"(",
"$",
"this",
")",
".",
"'\\\\Configuration'",
")",
")",
"{",
"$",
"class",
"=",
"ResourceConfiguration",
"::",
"class",
";",
"}",
"return",
"new",
"$",
"class",
"(",
"$",
"this",
"->",
"bundle",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L44-L51 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.loadInternal | protected function loadInternal(array $config, ContainerBuilder $container)
{
foreach ($this->bundle->getResources() as $resource) {
$resourceConfig = $config['resources'][$resource->getName()];
$this->configureResource($resource, $resourceConfig);
$this->loadResource($resource, $container);
foreach ($resource->getRelations() as $name => $relation) {
$this->configureResource($relation, $resourceConfig[$name]);
$this->loadResource($relation, $container);
}
}
$this->loadBundle($config, $container);
} | php | protected function loadInternal(array $config, ContainerBuilder $container)
{
foreach ($this->bundle->getResources() as $resource) {
$resourceConfig = $config['resources'][$resource->getName()];
$this->configureResource($resource, $resourceConfig);
$this->loadResource($resource, $container);
foreach ($resource->getRelations() as $name => $relation) {
$this->configureResource($relation, $resourceConfig[$name]);
$this->loadResource($relation, $container);
}
}
$this->loadBundle($config, $container);
} | [
"protected",
"function",
"loadInternal",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"bundle",
"->",
"getResources",
"(",
")",
"as",
"$",
"resource",
")",
"{",
"$",
"resourceConfig",
"=",
"$",
"config",
"[",
"'resources'",
"]",
"[",
"$",
"resource",
"->",
"getName",
"(",
")",
"]",
";",
"$",
"this",
"->",
"configureResource",
"(",
"$",
"resource",
",",
"$",
"resourceConfig",
")",
";",
"$",
"this",
"->",
"loadResource",
"(",
"$",
"resource",
",",
"$",
"container",
")",
";",
"foreach",
"(",
"$",
"resource",
"->",
"getRelations",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"relation",
")",
"{",
"$",
"this",
"->",
"configureResource",
"(",
"$",
"relation",
",",
"$",
"resourceConfig",
"[",
"$",
"name",
"]",
")",
";",
"$",
"this",
"->",
"loadResource",
"(",
"$",
"relation",
",",
"$",
"container",
")",
";",
"}",
"}",
"$",
"this",
"->",
"loadBundle",
"(",
"$",
"config",
",",
"$",
"container",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L64-L79 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createResourceDefinition | private function createResourceDefinition(ResourceInterface $resource)
{
$definition = new Definition(Resource::class, [
$resource->getName(),
$resource->getInterfaces(),
$resource->getModel(),
]);
$definition
->addMethodCall('setDriver', [$resource->getDriver()])
->addMethodCall('setDriverManager', [$resource->getDriverManager()])
->addMethodCall('setDriverMappingPath', [$resource->getDriverMappingPath()])
->addMethodCall('setDriverMappingFormat', [$resource->getDriverMappingFormat()])
->addMethodCall('setRepository', [$resource->getRepository()])
->addMethodCall('setFactory', [$resource->getFactory()])
->addMethodCall('setForm', [$resource->getForm()])
->addMethodCall('setChoiceForm', [$resource->getChoiceForm()])
->addMethodCall('setDomainManager', [$resource->getDomainManager()])
->addMethodCall('setController', [$resource->getController()])
->addMethodCall('setIdPropertyPath', [$resource->getIdPropertyPath()])
->addMethodCall('setLabelPropertyPath', [$resource->getLabelPropertyPath()])
->addTag('lug.resource');
foreach ($resource->getRelations() as $name => $relation) {
$definition->addMethodCall('addRelation', [$name, new Reference('lug.resource.'.$relation->getName())]);
}
return $definition;
} | php | private function createResourceDefinition(ResourceInterface $resource)
{
$definition = new Definition(Resource::class, [
$resource->getName(),
$resource->getInterfaces(),
$resource->getModel(),
]);
$definition
->addMethodCall('setDriver', [$resource->getDriver()])
->addMethodCall('setDriverManager', [$resource->getDriverManager()])
->addMethodCall('setDriverMappingPath', [$resource->getDriverMappingPath()])
->addMethodCall('setDriverMappingFormat', [$resource->getDriverMappingFormat()])
->addMethodCall('setRepository', [$resource->getRepository()])
->addMethodCall('setFactory', [$resource->getFactory()])
->addMethodCall('setForm', [$resource->getForm()])
->addMethodCall('setChoiceForm', [$resource->getChoiceForm()])
->addMethodCall('setDomainManager', [$resource->getDomainManager()])
->addMethodCall('setController', [$resource->getController()])
->addMethodCall('setIdPropertyPath', [$resource->getIdPropertyPath()])
->addMethodCall('setLabelPropertyPath', [$resource->getLabelPropertyPath()])
->addTag('lug.resource');
foreach ($resource->getRelations() as $name => $relation) {
$definition->addMethodCall('addRelation', [$name, new Reference('lug.resource.'.$relation->getName())]);
}
return $definition;
} | [
"private",
"function",
"createResourceDefinition",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"Resource",
"::",
"class",
",",
"[",
"$",
"resource",
"->",
"getName",
"(",
")",
",",
"$",
"resource",
"->",
"getInterfaces",
"(",
")",
",",
"$",
"resource",
"->",
"getModel",
"(",
")",
",",
"]",
")",
";",
"$",
"definition",
"->",
"addMethodCall",
"(",
"'setDriver'",
",",
"[",
"$",
"resource",
"->",
"getDriver",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setDriverManager'",
",",
"[",
"$",
"resource",
"->",
"getDriverManager",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setDriverMappingPath'",
",",
"[",
"$",
"resource",
"->",
"getDriverMappingPath",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setDriverMappingFormat'",
",",
"[",
"$",
"resource",
"->",
"getDriverMappingFormat",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setRepository'",
",",
"[",
"$",
"resource",
"->",
"getRepository",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setFactory'",
",",
"[",
"$",
"resource",
"->",
"getFactory",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setForm'",
",",
"[",
"$",
"resource",
"->",
"getForm",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setChoiceForm'",
",",
"[",
"$",
"resource",
"->",
"getChoiceForm",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setDomainManager'",
",",
"[",
"$",
"resource",
"->",
"getDomainManager",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setController'",
",",
"[",
"$",
"resource",
"->",
"getController",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setIdPropertyPath'",
",",
"[",
"$",
"resource",
"->",
"getIdPropertyPath",
"(",
")",
"]",
")",
"->",
"addMethodCall",
"(",
"'setLabelPropertyPath'",
",",
"[",
"$",
"resource",
"->",
"getLabelPropertyPath",
"(",
")",
"]",
")",
"->",
"addTag",
"(",
"'lug.resource'",
")",
";",
"foreach",
"(",
"$",
"resource",
"->",
"getRelations",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"relation",
")",
"{",
"$",
"definition",
"->",
"addMethodCall",
"(",
"'addRelation'",
",",
"[",
"$",
"name",
",",
"new",
"Reference",
"(",
"'lug.resource.'",
".",
"$",
"relation",
"->",
"getName",
"(",
")",
")",
"]",
")",
";",
"}",
"return",
"$",
"definition",
";",
"}"
] | @param ResourceInterface $resource
@return Definition | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L193-L221 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createManagerAlias | private function createManagerAlias(ResourceInterface $resource)
{
return $resource->getDriver() === ResourceInterface::DRIVER_DOCTRINE_MONGODB
? 'doctrine_mongodb.odm.'.$resource->getDriverManager().'_document_manager'
: 'doctrine.orm.'.$resource->getDriverManager().'_entity_manager';
} | php | private function createManagerAlias(ResourceInterface $resource)
{
return $resource->getDriver() === ResourceInterface::DRIVER_DOCTRINE_MONGODB
? 'doctrine_mongodb.odm.'.$resource->getDriverManager().'_document_manager'
: 'doctrine.orm.'.$resource->getDriverManager().'_entity_manager';
} | [
"private",
"function",
"createManagerAlias",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"return",
"$",
"resource",
"->",
"getDriver",
"(",
")",
"===",
"ResourceInterface",
"::",
"DRIVER_DOCTRINE_MONGODB",
"?",
"'doctrine_mongodb.odm.'",
".",
"$",
"resource",
"->",
"getDriverManager",
"(",
")",
".",
"'_document_manager'",
":",
"'doctrine.orm.'",
".",
"$",
"resource",
"->",
"getDriverManager",
"(",
")",
".",
"'_entity_manager'",
";",
"}"
] | @param ResourceInterface $resource
@return string | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L228-L233 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createFactoryDefinition | private function createFactoryDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getFactory(), [
new Reference('lug.resource.'.$resource->getName()),
new Reference('property_accessor'),
]);
$definition->addTag('lug.factory', ['resource' => $resource->getName()]);
return $definition;
} | php | private function createFactoryDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getFactory(), [
new Reference('lug.resource.'.$resource->getName()),
new Reference('property_accessor'),
]);
$definition->addTag('lug.factory', ['resource' => $resource->getName()]);
return $definition;
} | [
"private",
"function",
"createFactoryDefinition",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"resource",
"->",
"getFactory",
"(",
")",
",",
"[",
"new",
"Reference",
"(",
"'lug.resource.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"new",
"Reference",
"(",
"'property_accessor'",
")",
",",
"]",
")",
";",
"$",
"definition",
"->",
"addTag",
"(",
"'lug.factory'",
",",
"[",
"'resource'",
"=>",
"$",
"resource",
"->",
"getName",
"(",
")",
"]",
")",
";",
"return",
"$",
"definition",
";",
"}"
] | @param ResourceInterface $resource
@return Definition | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L240-L250 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createRepositoryDefinition | private function createRepositoryDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getRepository(), [$resource->getModel()]);
$definition->setFactory([new Reference('lug.manager.'.$resource->getName()), 'getRepository']);
$definition->addTag('lug.repository', ['resource' => $resource->getName()]);
return $definition;
} | php | private function createRepositoryDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getRepository(), [$resource->getModel()]);
$definition->setFactory([new Reference('lug.manager.'.$resource->getName()), 'getRepository']);
$definition->addTag('lug.repository', ['resource' => $resource->getName()]);
return $definition;
} | [
"private",
"function",
"createRepositoryDefinition",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"resource",
"->",
"getRepository",
"(",
")",
",",
"[",
"$",
"resource",
"->",
"getModel",
"(",
")",
"]",
")",
";",
"$",
"definition",
"->",
"setFactory",
"(",
"[",
"new",
"Reference",
"(",
"'lug.manager.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"'getRepository'",
"]",
")",
";",
"$",
"definition",
"->",
"addTag",
"(",
"'lug.repository'",
",",
"[",
"'resource'",
"=>",
"$",
"resource",
"->",
"getName",
"(",
")",
"]",
")",
";",
"return",
"$",
"definition",
";",
"}"
] | @param ResourceInterface $resource
@return Definition | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L257-L264 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createFormDefinition | private function createFormDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getForm(), [
new Reference('lug.resource.'.$resource->getName()),
new Reference('lug.factory.'.$resource->getName()),
]);
$definition->addTag('form.type');
return $definition;
} | php | private function createFormDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getForm(), [
new Reference('lug.resource.'.$resource->getName()),
new Reference('lug.factory.'.$resource->getName()),
]);
$definition->addTag('form.type');
return $definition;
} | [
"private",
"function",
"createFormDefinition",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"resource",
"->",
"getForm",
"(",
")",
",",
"[",
"new",
"Reference",
"(",
"'lug.resource.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"new",
"Reference",
"(",
"'lug.factory.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"]",
")",
";",
"$",
"definition",
"->",
"addTag",
"(",
"'form.type'",
")",
";",
"return",
"$",
"definition",
";",
"}"
] | @param ResourceInterface $resource
@return Definition | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L271-L281 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createChoiceFormDefinition | private function createChoiceFormDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getChoiceForm(), [
new Reference('lug.resource.'.$resource->getName()),
]);
$definition->addTag('form.type');
return $definition;
} | php | private function createChoiceFormDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getChoiceForm(), [
new Reference('lug.resource.'.$resource->getName()),
]);
$definition->addTag('form.type');
return $definition;
} | [
"private",
"function",
"createChoiceFormDefinition",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"resource",
"->",
"getChoiceForm",
"(",
")",
",",
"[",
"new",
"Reference",
"(",
"'lug.resource.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"]",
")",
";",
"$",
"definition",
"->",
"addTag",
"(",
"'form.type'",
")",
";",
"return",
"$",
"definition",
";",
"}"
] | @param ResourceInterface $resource
@return Definition | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L288-L297 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createDomainManagerDefinition | private function createDomainManagerDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getDomainManager(), [
new Reference('lug.resource.'.$resource->getName()),
new Reference('lug.resource.domain.event_dispatcher'),
new Reference('lug.manager.'.$resource->getName()),
new Reference('lug.repository.'.$resource->getName()),
]);
$definition->addTag('lug.domain_manager', ['resource' => $resource->getName()]);
return $definition;
} | php | private function createDomainManagerDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getDomainManager(), [
new Reference('lug.resource.'.$resource->getName()),
new Reference('lug.resource.domain.event_dispatcher'),
new Reference('lug.manager.'.$resource->getName()),
new Reference('lug.repository.'.$resource->getName()),
]);
$definition->addTag('lug.domain_manager', ['resource' => $resource->getName()]);
return $definition;
} | [
"private",
"function",
"createDomainManagerDefinition",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"resource",
"->",
"getDomainManager",
"(",
")",
",",
"[",
"new",
"Reference",
"(",
"'lug.resource.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"new",
"Reference",
"(",
"'lug.resource.domain.event_dispatcher'",
")",
",",
"new",
"Reference",
"(",
"'lug.manager.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"new",
"Reference",
"(",
"'lug.repository.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"]",
")",
";",
"$",
"definition",
"->",
"addTag",
"(",
"'lug.domain_manager'",
",",
"[",
"'resource'",
"=>",
"$",
"resource",
"->",
"getName",
"(",
")",
"]",
")",
";",
"return",
"$",
"definition",
";",
"}"
] | @param ResourceInterface $resource
@return Definition | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L304-L316 |
php-lug/lug | src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php | ResourceExtension.createControllerDefinition | private function createControllerDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getController(), [
new Reference('lug.resource.'.$resource->getName()),
]);
$definition->addMethodCall('setContainer', [new Reference('service_container')]);
$definition->addTag('lug.controller', ['resource' => $resource->getName()]);
return $definition;
} | php | private function createControllerDefinition(ResourceInterface $resource)
{
$definition = new Definition($resource->getController(), [
new Reference('lug.resource.'.$resource->getName()),
]);
$definition->addMethodCall('setContainer', [new Reference('service_container')]);
$definition->addTag('lug.controller', ['resource' => $resource->getName()]);
return $definition;
} | [
"private",
"function",
"createControllerDefinition",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"resource",
"->",
"getController",
"(",
")",
",",
"[",
"new",
"Reference",
"(",
"'lug.resource.'",
".",
"$",
"resource",
"->",
"getName",
"(",
")",
")",
",",
"]",
")",
";",
"$",
"definition",
"->",
"addMethodCall",
"(",
"'setContainer'",
",",
"[",
"new",
"Reference",
"(",
"'service_container'",
")",
"]",
")",
";",
"$",
"definition",
"->",
"addTag",
"(",
"'lug.controller'",
",",
"[",
"'resource'",
"=>",
"$",
"resource",
"->",
"getName",
"(",
")",
"]",
")",
";",
"return",
"$",
"definition",
";",
"}"
] | @param ResourceInterface $resource
@return Definition | [
"@param",
"ResourceInterface",
"$resource"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Extension/ResourceExtension.php#L323-L333 |
antaresproject/notifications | src/Event/EventDispatcher.php | EventDispatcher.run | public function run(array $notification, array $variables = null, array $recipients = null)
{
$typeName = Arr::get($notification, 'type.name');
switch ($typeName) {
case 'email':
$instance = app(EmailNotification::class);
break;
case 'sms':
$instance = app(SmsNotification::class);
break;
default:
$instance = app(CustomNotification::class);
break;
}
$instance->setPredefinedVariables($variables);
$instance->setModel($notification);
if ($instance instanceof SendableNotification) {
$instance->setRecipients($recipients);
if (!$this->validate($instance)) {
return false;
}
$type = $instance->getType();
$job = $instance->onConnection('database')->onQueue($type);
$this->dispatch($job);
} else {
return $instance->handle();
}
} | php | public function run(array $notification, array $variables = null, array $recipients = null)
{
$typeName = Arr::get($notification, 'type.name');
switch ($typeName) {
case 'email':
$instance = app(EmailNotification::class);
break;
case 'sms':
$instance = app(SmsNotification::class);
break;
default:
$instance = app(CustomNotification::class);
break;
}
$instance->setPredefinedVariables($variables);
$instance->setModel($notification);
if ($instance instanceof SendableNotification) {
$instance->setRecipients($recipients);
if (!$this->validate($instance)) {
return false;
}
$type = $instance->getType();
$job = $instance->onConnection('database')->onQueue($type);
$this->dispatch($job);
} else {
return $instance->handle();
}
} | [
"public",
"function",
"run",
"(",
"array",
"$",
"notification",
",",
"array",
"$",
"variables",
"=",
"null",
",",
"array",
"$",
"recipients",
"=",
"null",
")",
"{",
"$",
"typeName",
"=",
"Arr",
"::",
"get",
"(",
"$",
"notification",
",",
"'type.name'",
")",
";",
"switch",
"(",
"$",
"typeName",
")",
"{",
"case",
"'email'",
":",
"$",
"instance",
"=",
"app",
"(",
"EmailNotification",
"::",
"class",
")",
";",
"break",
";",
"case",
"'sms'",
":",
"$",
"instance",
"=",
"app",
"(",
"SmsNotification",
"::",
"class",
")",
";",
"break",
";",
"default",
":",
"$",
"instance",
"=",
"app",
"(",
"CustomNotification",
"::",
"class",
")",
";",
"break",
";",
"}",
"$",
"instance",
"->",
"setPredefinedVariables",
"(",
"$",
"variables",
")",
";",
"$",
"instance",
"->",
"setModel",
"(",
"$",
"notification",
")",
";",
"if",
"(",
"$",
"instance",
"instanceof",
"SendableNotification",
")",
"{",
"$",
"instance",
"->",
"setRecipients",
"(",
"$",
"recipients",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
"$",
"instance",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"type",
"=",
"$",
"instance",
"->",
"getType",
"(",
")",
";",
"$",
"job",
"=",
"$",
"instance",
"->",
"onConnection",
"(",
"'database'",
")",
"->",
"onQueue",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"job",
")",
";",
"}",
"else",
"{",
"return",
"$",
"instance",
"->",
"handle",
"(",
")",
";",
"}",
"}"
] | Sends notification.
@param array $notification
@param array|null $variables
@param array|null $recipients
@return bool|\Symfony\Component\HttpFoundation\Response | [
"Sends",
"notification",
"."
] | train | https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Event/EventDispatcher.php#L45-L75 |
mothership-ec/composer | src/Composer/Downloader/DownloadManager.php | DownloadManager.getDownloaderForInstalledPackage | public function getDownloaderForInstalledPackage(PackageInterface $package)
{
$installationSource = $package->getInstallationSource();
if ('metapackage' === $package->getType()) {
return;
}
if ('dist' === $installationSource) {
$downloader = $this->getDownloader($package->getDistType());
} elseif ('source' === $installationSource) {
$downloader = $this->getDownloader($package->getSourceType());
} else {
throw new \InvalidArgumentException(
'Package '.$package.' seems not been installed properly'
);
}
if ($installationSource !== $downloader->getInstallationSource()) {
throw new \LogicException(sprintf(
'Downloader "%s" is a %s type downloader and can not be used to download %s',
get_class($downloader), $downloader->getInstallationSource(), $installationSource
));
}
return $downloader;
} | php | public function getDownloaderForInstalledPackage(PackageInterface $package)
{
$installationSource = $package->getInstallationSource();
if ('metapackage' === $package->getType()) {
return;
}
if ('dist' === $installationSource) {
$downloader = $this->getDownloader($package->getDistType());
} elseif ('source' === $installationSource) {
$downloader = $this->getDownloader($package->getSourceType());
} else {
throw new \InvalidArgumentException(
'Package '.$package.' seems not been installed properly'
);
}
if ($installationSource !== $downloader->getInstallationSource()) {
throw new \LogicException(sprintf(
'Downloader "%s" is a %s type downloader and can not be used to download %s',
get_class($downloader), $downloader->getInstallationSource(), $installationSource
));
}
return $downloader;
} | [
"public",
"function",
"getDownloaderForInstalledPackage",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"installationSource",
"=",
"$",
"package",
"->",
"getInstallationSource",
"(",
")",
";",
"if",
"(",
"'metapackage'",
"===",
"$",
"package",
"->",
"getType",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"'dist'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"downloader",
"=",
"$",
"this",
"->",
"getDownloader",
"(",
"$",
"package",
"->",
"getDistType",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"'source'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"downloader",
"=",
"$",
"this",
"->",
"getDownloader",
"(",
"$",
"package",
"->",
"getSourceType",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Package '",
".",
"$",
"package",
".",
"' seems not been installed properly'",
")",
";",
"}",
"if",
"(",
"$",
"installationSource",
"!==",
"$",
"downloader",
"->",
"getInstallationSource",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Downloader \"%s\" is a %s type downloader and can not be used to download %s'",
",",
"get_class",
"(",
"$",
"downloader",
")",
",",
"$",
"downloader",
"->",
"getInstallationSource",
"(",
")",
",",
"$",
"installationSource",
")",
")",
";",
"}",
"return",
"$",
"downloader",
";",
"}"
] | Returns downloader for already installed package.
@param PackageInterface $package package instance
@return DownloaderInterface|null
@throws \InvalidArgumentException if package has no installation source specified
@throws \LogicException if specific downloader used to load package with
wrong type | [
"Returns",
"downloader",
"for",
"already",
"installed",
"package",
"."
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/DownloadManager.php#L131-L157 |
mothership-ec/composer | src/Composer/Downloader/DownloadManager.php | DownloadManager.update | public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
{
$downloader = $this->getDownloaderForInstalledPackage($initial);
if (!$downloader) {
return;
}
$installationSource = $initial->getInstallationSource();
if ('dist' === $installationSource) {
$initialType = $initial->getDistType();
$targetType = $target->getDistType();
} else {
$initialType = $initial->getSourceType();
$targetType = $target->getSourceType();
}
// upgrading from a dist stable package to a dev package, force source reinstall
if ($target->isDev() && 'dist' === $installationSource) {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir);
return;
}
if ($initialType === $targetType) {
$target->setInstallationSource($installationSource);
$downloader->update($initial, $target, $targetDir);
} else {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir, 'source' === $installationSource);
}
} | php | public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
{
$downloader = $this->getDownloaderForInstalledPackage($initial);
if (!$downloader) {
return;
}
$installationSource = $initial->getInstallationSource();
if ('dist' === $installationSource) {
$initialType = $initial->getDistType();
$targetType = $target->getDistType();
} else {
$initialType = $initial->getSourceType();
$targetType = $target->getSourceType();
}
// upgrading from a dist stable package to a dev package, force source reinstall
if ($target->isDev() && 'dist' === $installationSource) {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir);
return;
}
if ($initialType === $targetType) {
$target->setInstallationSource($installationSource);
$downloader->update($initial, $target, $targetDir);
} else {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir, 'source' === $installationSource);
}
} | [
"public",
"function",
"update",
"(",
"PackageInterface",
"$",
"initial",
",",
"PackageInterface",
"$",
"target",
",",
"$",
"targetDir",
")",
"{",
"$",
"downloader",
"=",
"$",
"this",
"->",
"getDownloaderForInstalledPackage",
"(",
"$",
"initial",
")",
";",
"if",
"(",
"!",
"$",
"downloader",
")",
"{",
"return",
";",
"}",
"$",
"installationSource",
"=",
"$",
"initial",
"->",
"getInstallationSource",
"(",
")",
";",
"if",
"(",
"'dist'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"initialType",
"=",
"$",
"initial",
"->",
"getDistType",
"(",
")",
";",
"$",
"targetType",
"=",
"$",
"target",
"->",
"getDistType",
"(",
")",
";",
"}",
"else",
"{",
"$",
"initialType",
"=",
"$",
"initial",
"->",
"getSourceType",
"(",
")",
";",
"$",
"targetType",
"=",
"$",
"target",
"->",
"getSourceType",
"(",
")",
";",
"}",
"// upgrading from a dist stable package to a dev package, force source reinstall",
"if",
"(",
"$",
"target",
"->",
"isDev",
"(",
")",
"&&",
"'dist'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"downloader",
"->",
"remove",
"(",
"$",
"initial",
",",
"$",
"targetDir",
")",
";",
"$",
"this",
"->",
"download",
"(",
"$",
"target",
",",
"$",
"targetDir",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"initialType",
"===",
"$",
"targetType",
")",
"{",
"$",
"target",
"->",
"setInstallationSource",
"(",
"$",
"installationSource",
")",
";",
"$",
"downloader",
"->",
"update",
"(",
"$",
"initial",
",",
"$",
"target",
",",
"$",
"targetDir",
")",
";",
"}",
"else",
"{",
"$",
"downloader",
"->",
"remove",
"(",
"$",
"initial",
",",
"$",
"targetDir",
")",
";",
"$",
"this",
"->",
"download",
"(",
"$",
"target",
",",
"$",
"targetDir",
",",
"'source'",
"===",
"$",
"installationSource",
")",
";",
"}",
"}"
] | Updates package from initial to target version.
@param PackageInterface $initial initial package version
@param PackageInterface $target target package version
@param string $targetDir target dir
@throws \InvalidArgumentException if initial package is not installed | [
"Updates",
"package",
"from",
"initial",
"to",
"target",
"version",
"."
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/DownloadManager.php#L228-L260 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.initialize | protected function initialize() {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$this->_plugin_data = $this->app->is_theme ? wp_get_theme() : get_plugin_data( $this->app->plugin_file, false, false );
} | php | protected function initialize() {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$this->_plugin_data = $this->app->is_theme ? wp_get_theme() : get_plugin_data( $this->app->plugin_file, false, false );
} | [
"protected",
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'get_plugin_data'",
")",
")",
"{",
"require_once",
"ABSPATH",
".",
"'wp-admin/includes/plugin.php'",
";",
"}",
"$",
"this",
"->",
"_plugin_data",
"=",
"$",
"this",
"->",
"app",
"->",
"is_theme",
"?",
"wp_get_theme",
"(",
")",
":",
"get_plugin_data",
"(",
"$",
"this",
"->",
"app",
"->",
"plugin_file",
",",
"false",
",",
"false",
")",
";",
"}"
] | initialize
@since 2.10.1 Improved: for theme (#115) | [
"initialize"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L147-L152 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.load_class | public function load_class( $class ) {
$class = ltrim( $class, '\\' );
$dir = null;
if ( ! isset( $this->_property_instances['define'] ) ) {
$namespace = ucfirst( TECHNOTE_PLUGIN );
if ( preg_match( "#\A{$namespace}#", $class ) ) {
$class = preg_replace( "#\A{$namespace}#", '', $class );
$dir = $this->app->get_library_directory() . DS . 'src';
}
} elseif ( preg_match( "#\A{$this->define->plugin_namespace}#", $class ) ) {
$class = preg_replace( "#\A{$this->define->plugin_namespace}#", '', $class );
$dir = $this->define->plugin_src_dir;
} elseif ( preg_match( "#\A{$this->define->lib_namespace}#", $class ) ) {
$class = preg_replace( "#\A{$this->define->lib_namespace}#", '', $class );
$dir = $this->define->lib_src_dir;
}
if ( isset( $dir ) ) {
$class = ltrim( $class, '\\' );
$class = strtolower( $class );
$path = $dir . DS . str_replace( '\\', DS, $class ) . '.php';
if ( is_readable( $path ) ) {
/** @noinspection PhpIncludeInspection */
require_once $path;
return true;
}
}
return false;
} | php | public function load_class( $class ) {
$class = ltrim( $class, '\\' );
$dir = null;
if ( ! isset( $this->_property_instances['define'] ) ) {
$namespace = ucfirst( TECHNOTE_PLUGIN );
if ( preg_match( "#\A{$namespace}#", $class ) ) {
$class = preg_replace( "#\A{$namespace}#", '', $class );
$dir = $this->app->get_library_directory() . DS . 'src';
}
} elseif ( preg_match( "#\A{$this->define->plugin_namespace}#", $class ) ) {
$class = preg_replace( "#\A{$this->define->plugin_namespace}#", '', $class );
$dir = $this->define->plugin_src_dir;
} elseif ( preg_match( "#\A{$this->define->lib_namespace}#", $class ) ) {
$class = preg_replace( "#\A{$this->define->lib_namespace}#", '', $class );
$dir = $this->define->lib_src_dir;
}
if ( isset( $dir ) ) {
$class = ltrim( $class, '\\' );
$class = strtolower( $class );
$path = $dir . DS . str_replace( '\\', DS, $class ) . '.php';
if ( is_readable( $path ) ) {
/** @noinspection PhpIncludeInspection */
require_once $path;
return true;
}
}
return false;
} | [
"public",
"function",
"load_class",
"(",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"ltrim",
"(",
"$",
"class",
",",
"'\\\\'",
")",
";",
"$",
"dir",
"=",
"null",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_property_instances",
"[",
"'define'",
"]",
")",
")",
"{",
"$",
"namespace",
"=",
"ucfirst",
"(",
"TECHNOTE_PLUGIN",
")",
";",
"if",
"(",
"preg_match",
"(",
"\"#\\A{$namespace}#\"",
",",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"preg_replace",
"(",
"\"#\\A{$namespace}#\"",
",",
"''",
",",
"$",
"class",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"app",
"->",
"get_library_directory",
"(",
")",
".",
"DS",
".",
"'src'",
";",
"}",
"}",
"elseif",
"(",
"preg_match",
"(",
"\"#\\A{$this->define->plugin_namespace}#\"",
",",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"preg_replace",
"(",
"\"#\\A{$this->define->plugin_namespace}#\"",
",",
"''",
",",
"$",
"class",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"define",
"->",
"plugin_src_dir",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"\"#\\A{$this->define->lib_namespace}#\"",
",",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"preg_replace",
"(",
"\"#\\A{$this->define->lib_namespace}#\"",
",",
"''",
",",
"$",
"class",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"define",
"->",
"lib_src_dir",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"class",
"=",
"ltrim",
"(",
"$",
"class",
",",
"'\\\\'",
")",
";",
"$",
"class",
"=",
"strtolower",
"(",
"$",
"class",
")",
";",
"$",
"path",
"=",
"$",
"dir",
".",
"DS",
".",
"str_replace",
"(",
"'\\\\'",
",",
"DS",
",",
"$",
"class",
")",
".",
"'.php'",
";",
"if",
"(",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"require_once",
"$",
"path",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | @since 2.10.0 Improved: performance
@param string $class
@return bool | [
"@since",
"2",
".",
"10",
".",
"0",
"Improved",
":",
"performance"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L161-L192 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.main_init | public function main_init() {
if ( $this->_initialized ) {
return;
}
$this->_initialized = true;
$this->filter->do_action( 'app_initialize', $this );
$this->setup_property();
$this->setup_textdomain();
$this->setup_settings();
$this->filter->do_action( 'app_initialized', $this );
} | php | public function main_init() {
if ( $this->_initialized ) {
return;
}
$this->_initialized = true;
$this->filter->do_action( 'app_initialize', $this );
$this->setup_property();
$this->setup_textdomain();
$this->setup_settings();
$this->filter->do_action( 'app_initialized', $this );
} | [
"public",
"function",
"main_init",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_initialized",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_initialized",
"=",
"true",
";",
"$",
"this",
"->",
"filter",
"->",
"do_action",
"(",
"'app_initialize'",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"setup_property",
"(",
")",
";",
"$",
"this",
"->",
"setup_textdomain",
"(",
")",
";",
"$",
"this",
"->",
"setup_settings",
"(",
")",
";",
"$",
"this",
"->",
"filter",
"->",
"do_action",
"(",
"'app_initialized'",
",",
"$",
"this",
")",
";",
"}"
] | main init
@since 2.10.0 Deleted: $uninstall parameter | [
"main",
"init"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L198-L209 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.setup_textdomain | private function setup_textdomain() {
if ( ! self::$_lib_language_loaded ) {
self::$_lib_language_loaded = true;
load_plugin_textdomain( $this->define->lib_textdomain, false, $this->define->lib_languages_rel_path );
}
$text_domain = $this->get_text_domain();
if ( ! empty( $text_domain ) ) {
load_plugin_textdomain( $text_domain, false, $this->define->plugin_languages_rel_path );
}
} | php | private function setup_textdomain() {
if ( ! self::$_lib_language_loaded ) {
self::$_lib_language_loaded = true;
load_plugin_textdomain( $this->define->lib_textdomain, false, $this->define->lib_languages_rel_path );
}
$text_domain = $this->get_text_domain();
if ( ! empty( $text_domain ) ) {
load_plugin_textdomain( $text_domain, false, $this->define->plugin_languages_rel_path );
}
} | [
"private",
"function",
"setup_textdomain",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_lib_language_loaded",
")",
"{",
"self",
"::",
"$",
"_lib_language_loaded",
"=",
"true",
";",
"load_plugin_textdomain",
"(",
"$",
"this",
"->",
"define",
"->",
"lib_textdomain",
",",
"false",
",",
"$",
"this",
"->",
"define",
"->",
"lib_languages_rel_path",
")",
";",
"}",
"$",
"text_domain",
"=",
"$",
"this",
"->",
"get_text_domain",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"text_domain",
")",
")",
"{",
"load_plugin_textdomain",
"(",
"$",
"text_domain",
",",
"false",
",",
"$",
"this",
"->",
"define",
"->",
"plugin_languages_rel_path",
")",
";",
"}",
"}"
] | setup textdomain | [
"setup",
"textdomain"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L234-L244 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.setup_settings | private function setup_settings() {
if ( defined( 'TECHNOTE_MOCK_REST_REQUEST' ) && TECHNOTE_MOCK_REST_REQUEST ) {
$this->setting->remove_setting( 'use_admin_ajax' );
}
if ( $this->loader->api->is_empty() ) {
$this->setting->remove_setting( 'use_admin_ajax' );
$this->setting->remove_setting( 'get_nonce_check_referer' );
$this->setting->remove_setting( 'check_referer_host' );
}
$key = $this->app->is_theme ? 'ThemeURI' : 'PluginURI';
if ( ! empty( $this->_plugin_data[ $key ] ) && $this->utility->starts_with( $this->_plugin_data[ $key ], 'https://wordpress.org' ) ) {
$this->setting->edit_setting( 'check_update', 'default', false );
}
if ( ! $this->log->is_valid() ) {
$this->setting->remove_setting( 'save___log_term' );
$this->setting->remove_setting( 'delete___log_interval' );
$this->setting->remove_setting( 'capture_shutdown_error' );
}
if ( $this->get_config( 'config', 'prevent_use_log' ) ) {
$this->setting->remove_setting( 'is_valid_log' );
}
} | php | private function setup_settings() {
if ( defined( 'TECHNOTE_MOCK_REST_REQUEST' ) && TECHNOTE_MOCK_REST_REQUEST ) {
$this->setting->remove_setting( 'use_admin_ajax' );
}
if ( $this->loader->api->is_empty() ) {
$this->setting->remove_setting( 'use_admin_ajax' );
$this->setting->remove_setting( 'get_nonce_check_referer' );
$this->setting->remove_setting( 'check_referer_host' );
}
$key = $this->app->is_theme ? 'ThemeURI' : 'PluginURI';
if ( ! empty( $this->_plugin_data[ $key ] ) && $this->utility->starts_with( $this->_plugin_data[ $key ], 'https://wordpress.org' ) ) {
$this->setting->edit_setting( 'check_update', 'default', false );
}
if ( ! $this->log->is_valid() ) {
$this->setting->remove_setting( 'save___log_term' );
$this->setting->remove_setting( 'delete___log_interval' );
$this->setting->remove_setting( 'capture_shutdown_error' );
}
if ( $this->get_config( 'config', 'prevent_use_log' ) ) {
$this->setting->remove_setting( 'is_valid_log' );
}
} | [
"private",
"function",
"setup_settings",
"(",
")",
"{",
"if",
"(",
"defined",
"(",
"'TECHNOTE_MOCK_REST_REQUEST'",
")",
"&&",
"TECHNOTE_MOCK_REST_REQUEST",
")",
"{",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'use_admin_ajax'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"loader",
"->",
"api",
"->",
"is_empty",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'use_admin_ajax'",
")",
";",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'get_nonce_check_referer'",
")",
";",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'check_referer_host'",
")",
";",
"}",
"$",
"key",
"=",
"$",
"this",
"->",
"app",
"->",
"is_theme",
"?",
"'ThemeURI'",
":",
"'PluginURI'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_plugin_data",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"this",
"->",
"utility",
"->",
"starts_with",
"(",
"$",
"this",
"->",
"_plugin_data",
"[",
"$",
"key",
"]",
",",
"'https://wordpress.org'",
")",
")",
"{",
"$",
"this",
"->",
"setting",
"->",
"edit_setting",
"(",
"'check_update'",
",",
"'default'",
",",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"log",
"->",
"is_valid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'save___log_term'",
")",
";",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'delete___log_interval'",
")",
";",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'capture_shutdown_error'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"get_config",
"(",
"'config'",
",",
"'prevent_use_log'",
")",
")",
"{",
"$",
"this",
"->",
"setting",
"->",
"remove_setting",
"(",
"'is_valid_log'",
")",
";",
"}",
"}"
] | setup settings
@since 2.1.0 Changed: set default value of check_update when the plugin is registered as official
@since 2.10.1 Improved: remove capture_shutdown_error if log is not valid (#128)
@since 2.10.1 Improved: for theme (#115) | [
"setup",
"settings"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L252-L273 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.get_plugin_data | public function get_plugin_data( $key = null ) {
return empty( $key ) ? $this->_plugin_data : $this->_plugin_data[ $key ];
} | php | public function get_plugin_data( $key = null ) {
return empty( $key ) ? $this->_plugin_data : $this->_plugin_data[ $key ];
} | [
"public",
"function",
"get_plugin_data",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"return",
"empty",
"(",
"$",
"key",
")",
"?",
"$",
"this",
"->",
"_plugin_data",
":",
"$",
"this",
"->",
"_plugin_data",
"[",
"$",
"key",
"]",
";",
"}"
] | @since 2.10.0
@param string|null $key
@return array|string | [
"@since",
"2",
".",
"10",
".",
"0"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L289-L291 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.translate | public function translate( $value ) {
$text_domain = $this->get_text_domain();
if ( ! empty( $text_domain ) ) {
$translated = __( $value, $text_domain );
if ( $value !== $translated ) {
return $translated;
}
}
return __( $value, $this->define->lib_textdomain );
} | php | public function translate( $value ) {
$text_domain = $this->get_text_domain();
if ( ! empty( $text_domain ) ) {
$translated = __( $value, $text_domain );
if ( $value !== $translated ) {
return $translated;
}
}
return __( $value, $this->define->lib_textdomain );
} | [
"public",
"function",
"translate",
"(",
"$",
"value",
")",
"{",
"$",
"text_domain",
"=",
"$",
"this",
"->",
"get_text_domain",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"text_domain",
")",
")",
"{",
"$",
"translated",
"=",
"__",
"(",
"$",
"value",
",",
"$",
"text_domain",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"$",
"translated",
")",
"{",
"return",
"$",
"translated",
";",
"}",
"}",
"return",
"__",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"define",
"->",
"lib_textdomain",
")",
";",
"}"
] | @param string $value
@return string | [
"@param",
"string",
"$value"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L315-L325 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.get_shared_object | public function get_shared_object( $key, $target = null ) {
! isset( $target ) and $target = $this->app->plugin_name;
return isset( self::$_shared_object[ $target ][ $key ] ) ? self::$_shared_object[ $target ][ $key ] : null;
} | php | public function get_shared_object( $key, $target = null ) {
! isset( $target ) and $target = $this->app->plugin_name;
return isset( self::$_shared_object[ $target ][ $key ] ) ? self::$_shared_object[ $target ][ $key ] : null;
} | [
"public",
"function",
"get_shared_object",
"(",
"$",
"key",
",",
"$",
"target",
"=",
"null",
")",
"{",
"!",
"isset",
"(",
"$",
"target",
")",
"and",
"$",
"target",
"=",
"$",
"this",
"->",
"app",
"->",
"plugin_name",
";",
"return",
"isset",
"(",
"self",
"::",
"$",
"_shared_object",
"[",
"$",
"target",
"]",
"[",
"$",
"key",
"]",
")",
"?",
"self",
"::",
"$",
"_shared_object",
"[",
"$",
"target",
"]",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | @param string $key
@param string|null $target
@return mixed | [
"@param",
"string",
"$key",
"@param",
"string|null",
"$target"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L422-L426 |
technote-space/wordpress-plugin-base | src/classes/models/lib/main.php | Main.isset_shared_object | public function isset_shared_object( $key, $target = null ) {
! isset( $target ) and $target = $this->app->plugin_name;
return isset( self::$_shared_object[ $target ] ) && array_key_exists( $key, self::$_shared_object[ $target ] );
} | php | public function isset_shared_object( $key, $target = null ) {
! isset( $target ) and $target = $this->app->plugin_name;
return isset( self::$_shared_object[ $target ] ) && array_key_exists( $key, self::$_shared_object[ $target ] );
} | [
"public",
"function",
"isset_shared_object",
"(",
"$",
"key",
",",
"$",
"target",
"=",
"null",
")",
"{",
"!",
"isset",
"(",
"$",
"target",
")",
"and",
"$",
"target",
"=",
"$",
"this",
"->",
"app",
"->",
"plugin_name",
";",
"return",
"isset",
"(",
"self",
"::",
"$",
"_shared_object",
"[",
"$",
"target",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"_shared_object",
"[",
"$",
"target",
"]",
")",
";",
"}"
] | @param string $key
@param string|null $target
@return bool | [
"@param",
"string",
"$key",
"@param",
"string|null",
"$target"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/main.php#L444-L448 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.