repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
a2c/BaconAclBundle | Controller/ModuleController.php | ModuleController.showAction | public function showAction(Request $request, Module $entity)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'SHOW')) {
throw $this->createAccessDeniedException();
}
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem([
'title' => 'Module',
'route' => 'module',
]);
$breadcumbs->addItem([
'title' => 'Details',
'route' => '',
]);
$deleteForm = $this->createDeleteForm('module_delete', $entity);
return [
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
];
} | php | public function showAction(Request $request, Module $entity)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'SHOW')) {
throw $this->createAccessDeniedException();
}
$breadcumbs = $this->container->get('bacon_breadcrumbs');
$breadcumbs->addItem([
'title' => 'Module',
'route' => 'module',
]);
$breadcumbs->addItem([
'title' => 'Details',
'route' => '',
]);
$deleteForm = $this->createDeleteForm('module_delete', $entity);
return [
'entity' => $entity,
'delete_form' => $deleteForm->createView(),
];
} | [
"public",
"function",
"showAction",
"(",
"Request",
"$",
"request",
",",
"Module",
"$",
"entity",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",... | Finds and displays a Module entity.
@Route("/{id}", name="module_show")
@Method("GET")
@Security("has_role('ROLE_ADMIN')")
@Template() | [
"Finds",
"and",
"displays",
"a",
"Module",
"entity",
"."
] | ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c | https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L216-L242 | train |
a2c/BaconAclBundle | Controller/ModuleController.php | ModuleController.deleteAction | public function deleteAction(Module $entity)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'DELETE')) {
throw $this->createAccessDeniedException();
}
$handler = new ModuleFormHandler(
$this->createDeleteForm('module_delete', $entity),
$this->get('doctrine')->getManager(),
$this->get('session')->getFlashBag()
);
$handler->delete($entity);
return $this->redirect($this->generateUrl('module'));
} | php | public function deleteAction(Module $entity)
{
$acl = $this->get('bacon_acl.service.authorization');
if (!$acl->authorize('module', 'DELETE')) {
throw $this->createAccessDeniedException();
}
$handler = new ModuleFormHandler(
$this->createDeleteForm('module_delete', $entity),
$this->get('doctrine')->getManager(),
$this->get('session')->getFlashBag()
);
$handler->delete($entity);
return $this->redirect($this->generateUrl('module'));
} | [
"public",
"function",
"deleteAction",
"(",
"Module",
"$",
"entity",
")",
"{",
"$",
"acl",
"=",
"$",
"this",
"->",
"get",
"(",
"'bacon_acl.service.authorization'",
")",
";",
"if",
"(",
"!",
"$",
"acl",
"->",
"authorize",
"(",
"'module'",
",",
"'DELETE'",
... | Deletes a Module entity.
@Route("/{id}", name="module_delete")
@Security("has_role('ROLE_ADMIN')")
@Method("DELETE") | [
"Deletes",
"a",
"Module",
"entity",
"."
] | ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c | https://github.com/a2c/BaconAclBundle/blob/ed4d2fe25e8f08bfb70a0d50a504ec2878dd2e6c/Controller/ModuleController.php#L250-L267 | train |
alxmsl/Connection | source/Redis/RedisFactory.php | RedisFactory.createRedisByConfig | public static function createRedisByConfig(array $config) {
$Redis = new Connection();
$Redis->setHost(@$config['host'])
->setPort(@$config['port']);
(isset($config['persistent'])) && $Redis->setPersistent($config['persistent']);
(isset($config['connect_timeout'])) && $Redis->setConnectTimeout($config['connect_timeout']);
(isset($config['connect_tries'])) && $Redis->setConnectTries($config['connect_tries']);
return $Redis;
} | php | public static function createRedisByConfig(array $config) {
$Redis = new Connection();
$Redis->setHost(@$config['host'])
->setPort(@$config['port']);
(isset($config['persistent'])) && $Redis->setPersistent($config['persistent']);
(isset($config['connect_timeout'])) && $Redis->setConnectTimeout($config['connect_timeout']);
(isset($config['connect_tries'])) && $Redis->setConnectTries($config['connect_tries']);
return $Redis;
} | [
"public",
"static",
"function",
"createRedisByConfig",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"Redis",
"=",
"new",
"Connection",
"(",
")",
";",
"$",
"Redis",
"->",
"setHost",
"(",
"@",
"$",
"config",
"[",
"'host'",
"]",
")",
"->",
"setPort",
"(",
... | Create PhpRedis instance by array config
@param array $config array configuration
@throws InvalidArgumentException | [
"Create",
"PhpRedis",
"instance",
"by",
"array",
"config"
] | f686efeb795a5450112a04792876b2198829fd32 | https://github.com/alxmsl/Connection/blob/f686efeb795a5450112a04792876b2198829fd32/source/Redis/RedisFactory.php#L32-L40 | train |
zepi/turbo-base | Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php | ExecuteInstallation.execute | public function execute(Framework $framework, CliRequest $request, Response $response)
{
// Configure turbo
$this->configure();
// Save the settings
$this->configurationManager->saveConfigurationFile();
// Execute the DataSource setups
$dataSourceManager = $framework->getDataSourceManager();
foreach ($dataSourceManager->getDataSourceTypeClasses() as $type) {
$dataSource = $dataSourceManager->getDataSource($type);
$dataSource->setup();
}
} | php | public function execute(Framework $framework, CliRequest $request, Response $response)
{
// Configure turbo
$this->configure();
// Save the settings
$this->configurationManager->saveConfigurationFile();
// Execute the DataSource setups
$dataSourceManager = $framework->getDataSourceManager();
foreach ($dataSourceManager->getDataSourceTypeClasses() as $type) {
$dataSource = $dataSourceManager->getDataSource($type);
$dataSource->setup();
}
} | [
"public",
"function",
"execute",
"(",
"Framework",
"$",
"framework",
",",
"CliRequest",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"// Configure turbo",
"$",
"this",
"->",
"configure",
"(",
")",
";",
"// Save the settings",
"$",
"this",
"->",
... | Execute the installation of Turbo
@access public
@param \Zepi\Turbo\Framework $framework
@param \Zepi\Turbo\Request\CliRequest $request
@param \Zepi\Turbo\Response\Response $response | [
"Execute",
"the",
"installation",
"of",
"Turbo"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L88-L102 | train |
zepi/turbo-base | Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php | ExecuteInstallation.configure | protected function configure()
{
$configureSettingGroup = $this->cliHelper->confirmAction('Would you like to change the settings?');
if (!$configureSettingGroup) {
return;
}
$this->configureSettings($this->configurationManager->getSettings());
} | php | protected function configure()
{
$configureSettingGroup = $this->cliHelper->confirmAction('Would you like to change the settings?');
if (!$configureSettingGroup) {
return;
}
$this->configureSettings($this->configurationManager->getSettings());
} | [
"protected",
"function",
"configure",
"(",
")",
"{",
"$",
"configureSettingGroup",
"=",
"$",
"this",
"->",
"cliHelper",
"->",
"confirmAction",
"(",
"'Would you like to change the settings?'",
")",
";",
"if",
"(",
"!",
"$",
"configureSettingGroup",
")",
"{",
"retur... | Iterates trough all configuration settings and asks the user for a
value. | [
"Iterates",
"trough",
"all",
"configuration",
"settings",
"and",
"asks",
"the",
"user",
"for",
"a",
"value",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L108-L116 | train |
zepi/turbo-base | Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php | ExecuteInstallation.configureSettings | protected function configureSettings($settings, $path = '')
{
foreach ($settings as $key => $node) {
if (is_array($node)) {
$this->configureSettings($node, $path . $key . '.');
} else {
$this->configureSetting($path . $key, $node);
}
}
} | php | protected function configureSettings($settings, $path = '')
{
foreach ($settings as $key => $node) {
if (is_array($node)) {
$this->configureSettings($node, $path . $key . '.');
} else {
$this->configureSetting($path . $key, $node);
}
}
} | [
"protected",
"function",
"configureSettings",
"(",
"$",
"settings",
",",
"$",
"path",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"key",
"=>",
"$",
"node",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"node",
")",
")",
"{",
"$",
... | Configures one settings group
@access protected
@param array $settings | [
"Configures",
"one",
"settings",
"group"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L124-L133 | train |
zepi/turbo-base | Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php | ExecuteInstallation.configureSetting | protected function configureSetting($path, $value)
{
$newValue = $this->cliHelper->inputText('Please enter the value for "' . $path . '":', $value);
if ($newValue === $value) {
return;
}
$this->configurationManager->setSetting($path, $newValue);
} | php | protected function configureSetting($path, $value)
{
$newValue = $this->cliHelper->inputText('Please enter the value for "' . $path . '":', $value);
if ($newValue === $value) {
return;
}
$this->configurationManager->setSetting($path, $newValue);
} | [
"protected",
"function",
"configureSetting",
"(",
"$",
"path",
",",
"$",
"value",
")",
"{",
"$",
"newValue",
"=",
"$",
"this",
"->",
"cliHelper",
"->",
"inputText",
"(",
"'Please enter the value for \"'",
".",
"$",
"path",
".",
"'\":'",
",",
"$",
"value",
... | Configures one setting
@access protected
@param string $path
@param string $value | [
"Configures",
"one",
"setting"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Installation/Turbo/src/EventHandler/ExecuteInstallation.php#L142-L151 | train |
vip9008/yii2-googleapisclient | service/MapsEngine.php | MapsEngine_RasterCollectionsRasters_Resource.batchDelete | public function batchDelete($id, MapsEngine_RasterCollectionsRasterBatchDeleteRequest $postBody, $optParams = array())
{
$params = array('id' => $id, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('batchDelete', array($params), "MapsEngine_RasterCollectionsRastersBatchDeleteResponse");
} | php | public function batchDelete($id, MapsEngine_RasterCollectionsRasterBatchDeleteRequest $postBody, $optParams = array())
{
$params = array('id' => $id, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('batchDelete', array($params), "MapsEngine_RasterCollectionsRastersBatchDeleteResponse");
} | [
"public",
"function",
"batchDelete",
"(",
"$",
"id",
",",
"MapsEngine_RasterCollectionsRasterBatchDeleteRequest",
"$",
"postBody",
",",
"$",
"optParams",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'post... | Remove rasters from an existing raster collection.
Up to 50 rasters can be included in a single batchDelete request. Each
batchDelete request is atomic. (rasters.batchDelete)
@param string $id The ID of the raster collection to which these rasters
belong.
@param Google_RasterCollectionsRasterBatchDeleteRequest $postBody
@param array $optParams Optional parameters.
@return MapsEngine_RasterCollectionsRastersBatchDeleteResponse | [
"Remove",
"rasters",
"from",
"an",
"existing",
"raster",
"collection",
"."
] | b6aae1c490d84a6004ed7dccb5d4176184032b57 | https://github.com/vip9008/yii2-googleapisclient/blob/b6aae1c490d84a6004ed7dccb5d4176184032b57/service/MapsEngine.php#L2567-L2572 | train |
webriq/core | module/Core/src/Grid/Core/Model/Module/Model.php | Model.onModules | public function onModules( ModulesEvent $event )
{
$saved = 0;
$model = $event->getTarget();
$mapper = $model->getMapper();
$modules = $event->getParams();
foreach ( $modules as $name => $enabled )
{
if ( empty( $name ) )
{
continue;
}
$name = (string) $name;
$module = $model->findByName( $name );
if ( empty( $module ) )
{
$module = $model->create( array(
'module' => $name,
'enabled' => $enabled,
) );
}
else
{
$module->enabled = $enabled;
}
$saved += $mapper->save( $module );
}
return $saved;
} | php | public function onModules( ModulesEvent $event )
{
$saved = 0;
$model = $event->getTarget();
$mapper = $model->getMapper();
$modules = $event->getParams();
foreach ( $modules as $name => $enabled )
{
if ( empty( $name ) )
{
continue;
}
$name = (string) $name;
$module = $model->findByName( $name );
if ( empty( $module ) )
{
$module = $model->create( array(
'module' => $name,
'enabled' => $enabled,
) );
}
else
{
$module->enabled = $enabled;
}
$saved += $mapper->save( $module );
}
return $saved;
} | [
"public",
"function",
"onModules",
"(",
"ModulesEvent",
"$",
"event",
")",
"{",
"$",
"saved",
"=",
"0",
";",
"$",
"model",
"=",
"$",
"event",
"->",
"getTarget",
"(",
")",
";",
"$",
"mapper",
"=",
"$",
"model",
"->",
"getMapper",
"(",
")",
";",
"$",... | Default action on modules-set event
@param ModulesEvent $event
@return int | [
"Default",
"action",
"on",
"modules",
"-",
"set",
"event"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Module/Model.php#L107-L140 | train |
bugotech/foundation | src/Env.php | Env.load | public function load($path, $file = '.env')
{
try {
$env = new \Dotenv\Dotenv($path, $file);
$env->load();
return true;
} catch (\Dotenv\Exception\InvalidPathException $e) {
return false;
}
} | php | public function load($path, $file = '.env')
{
try {
$env = new \Dotenv\Dotenv($path, $file);
$env->load();
return true;
} catch (\Dotenv\Exception\InvalidPathException $e) {
return false;
}
} | [
"public",
"function",
"load",
"(",
"$",
"path",
",",
"$",
"file",
"=",
"'.env'",
")",
"{",
"try",
"{",
"$",
"env",
"=",
"new",
"\\",
"Dotenv",
"\\",
"Dotenv",
"(",
"$",
"path",
",",
"$",
"file",
")",
";",
"$",
"env",
"->",
"load",
"(",
")",
"... | Load file .env.
@param $path
@param string $file
@return bool | [
"Load",
"file",
".",
"env",
"."
] | e4b96cd1cef117e9c5f2c6f5671d260853317658 | https://github.com/bugotech/foundation/blob/e4b96cd1cef117e9c5f2c6f5671d260853317658/src/Env.php#L14-L24 | train |
tenside/core-bundle | src/DependencyInjection/Factory/LoggerFactory.php | LoggerFactory.create | public static function create(
$kernel,
$filename,
$maxFiles = 0,
$level = Logger::DEBUG,
$bubble = true,
$filePermission = null,
$useLocking = false
) {
return new RotatingFileHandler(
$kernel->getLogDir() . DIRECTORY_SEPARATOR . $filename,
$maxFiles,
$level,
$bubble,
$filePermission,
$useLocking
);
} | php | public static function create(
$kernel,
$filename,
$maxFiles = 0,
$level = Logger::DEBUG,
$bubble = true,
$filePermission = null,
$useLocking = false
) {
return new RotatingFileHandler(
$kernel->getLogDir() . DIRECTORY_SEPARATOR . $filename,
$maxFiles,
$level,
$bubble,
$filePermission,
$useLocking
);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"kernel",
",",
"$",
"filename",
",",
"$",
"maxFiles",
"=",
"0",
",",
"$",
"level",
"=",
"Logger",
"::",
"DEBUG",
",",
"$",
"bubble",
"=",
"true",
",",
"$",
"filePermission",
"=",
"null",
",",
"$",
... | Create the logger service.
@param Kernel $kernel The kernel to retrieve the log dir from.
@param string $filename The filename.
@param int $maxFiles The maximal amount of files to keep (0 means unlimited).
@param int $level The minimum logging level at which this handler will be triggered.
@param bool $bubble Whether the messages that are handled can bubble up the stack or not.
@param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write).
@param bool $useLocking Try to lock log file before doing any writes.
@return RotatingFileHandler | [
"Create",
"the",
"logger",
"service",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/DependencyInjection/Factory/LoggerFactory.php#L53-L70 | train |
franckysolo/octopush-sdk | src/Octopush/Client.php | Client.send | public function send($message, array $options = [])
{
$sms = new Message($options);
$this->request('sms', $sms->getParams());
$response = $this->getResponse();
if ($response['error_code'] !== '000') {
$this->errors[] = $response['error_code'];
return false;
}
return true;
} | php | public function send($message, array $options = [])
{
$sms = new Message($options);
$this->request('sms', $sms->getParams());
$response = $this->getResponse();
if ($response['error_code'] !== '000') {
$this->errors[] = $response['error_code'];
return false;
}
return true;
} | [
"public",
"function",
"send",
"(",
"$",
"message",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"sms",
"=",
"new",
"Message",
"(",
"$",
"options",
")",
";",
"$",
"this",
"->",
"request",
"(",
"'sms'",
",",
"$",
"sms",
"->",
"getPar... | Send a sms message
@param string $message The string message
@param array $options The array options
@return bool true if message is send otherwise false | [
"Send",
"a",
"sms",
"message"
] | 3797e53d51474a64b65fbf437e5dd46e288f2ef8 | https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L88-L100 | train |
franckysolo/octopush-sdk | src/Octopush/Client.php | Client.request | public function request($url, array $params = [])
{
$curl = new Curl();
$query = $this->buildQuery($params);
$curl->setOptions($this->url . $url, $query, $this->port);
$response = $curl->exec();
$this->setResponse($response);
$this->setErrors($response);
return $this;
} | php | public function request($url, array $params = [])
{
$curl = new Curl();
$query = $this->buildQuery($params);
$curl->setOptions($this->url . $url, $query, $this->port);
$response = $curl->exec();
$this->setResponse($response);
$this->setErrors($response);
return $this;
} | [
"public",
"function",
"request",
"(",
"$",
"url",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"curl",
"=",
"new",
"Curl",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"buildQuery",
"(",
"$",
"params",
")",
";",
"$",
"curl... | Send a curl request
@param string $url The url API
@param array $params The query params
@return \Octopush\Client | [
"Send",
"a",
"curl",
"request"
] | 3797e53d51474a64b65fbf437e5dd46e288f2ef8 | https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L109-L118 | train |
franckysolo/octopush-sdk | src/Octopush/Client.php | Client.buildQuery | public function buildQuery(array $params = [])
{
$params = array_merge($params, [
'user_login' => $this->login,
'api_key' => $this->apiKey
]);
return http_build_query($params);
} | php | public function buildQuery(array $params = [])
{
$params = array_merge($params, [
'user_login' => $this->login,
'api_key' => $this->apiKey
]);
return http_build_query($params);
} | [
"public",
"function",
"buildQuery",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"params",
",",
"[",
"'user_login'",
"=>",
"$",
"this",
"->",
"login",
",",
"'api_key'",
"=>",
"$",
"this",
"->",
"a... | Merge the credentials and params then returns the string query
@param array $params The params array
@return string The query string | [
"Merge",
"the",
"credentials",
"and",
"params",
"then",
"returns",
"the",
"string",
"query"
] | 3797e53d51474a64b65fbf437e5dd46e288f2ef8 | https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L126-L133 | train |
franckysolo/octopush-sdk | src/Octopush/Client.php | Client.setErrors | protected function setErrors($response)
{
libxml_use_internal_errors(true);
$doc = new \DOMDocument('1.0', 'utf-8');
$doc->loadXML($response);
$errors = libxml_get_errors();
if (!empty($errors)) {
$this->errors[] = 'Xml response is invalid';
}
return $this;
} | php | protected function setErrors($response)
{
libxml_use_internal_errors(true);
$doc = new \DOMDocument('1.0', 'utf-8');
$doc->loadXML($response);
$errors = libxml_get_errors();
if (!empty($errors)) {
$this->errors[] = 'Xml response is invalid';
}
return $this;
} | [
"protected",
"function",
"setErrors",
"(",
"$",
"response",
")",
"{",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
"'1.0'",
",",
"'utf-8'",
")",
";",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"respon... | Set the xml errors
@param string $response
@return \Octopush\Client | [
"Set",
"the",
"xml",
"errors"
] | 3797e53d51474a64b65fbf437e5dd46e288f2ef8 | https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Client.php#L195-L208 | train |
strident/Trident | src/Trident/Component/HttpKernel/Controller/ControllerResolver.php | ControllerResolver.getController | public function getController(Request $request, array $matched)
{
if (null !== $request->attributes->get('_controller')) {
return $this->createController($request->attributes->get('_controller'));
}
if ( ! $controller = $matched['_controller']) {
throw new \InvalidArgumentException('Unable to look for controller as the "_controller" parameter is missing');
}
$callable = $this->createController($controller);
if ( ! is_callable($callable)) {
throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request));
}
return $callable;
} | php | public function getController(Request $request, array $matched)
{
if (null !== $request->attributes->get('_controller')) {
return $this->createController($request->attributes->get('_controller'));
}
if ( ! $controller = $matched['_controller']) {
throw new \InvalidArgumentException('Unable to look for controller as the "_controller" parameter is missing');
}
$callable = $this->createController($controller);
if ( ! is_callable($callable)) {
throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request));
}
return $callable;
} | [
"public",
"function",
"getController",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"matched",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_controller'",
")",
")",
"{",
"return",
"$",
"this",
"->",
... | Get a callable controller
@param Request $request
@param array $matched
@return callable | [
"Get",
"a",
"callable",
"controller"
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/HttpKernel/Controller/ControllerResolver.php#L46-L63 | train |
strident/Trident | src/Trident/Component/HttpKernel/Controller/ControllerResolver.php | ControllerResolver.createController | protected function createController($controller)
{
if (false === strpos($controller, '::')) {
throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
}
list($class, $method) = explode('::', $controller, 2);
if ($this->container->has($class)) {
$controller = $this->container->get($class);
} else {
if ( ! class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}
$controller = new $class();
}
if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container);
}
return array($controller, $method);
} | php | protected function createController($controller)
{
if (false === strpos($controller, '::')) {
throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
}
list($class, $method) = explode('::', $controller, 2);
if ($this->container->has($class)) {
$controller = $this->container->get($class);
} else {
if ( ! class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}
$controller = new $class();
}
if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container);
}
return array($controller, $method);
} | [
"protected",
"function",
"createController",
"(",
"$",
"controller",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"controller",
",",
"'::'",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unable to find cont... | Creates the callable from the controller string
@param string $controller
@return callable | [
"Creates",
"the",
"callable",
"from",
"the",
"controller",
"string"
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/HttpKernel/Controller/ControllerResolver.php#L71-L94 | train |
strident/Trident | src/Trident/Component/HttpKernel/Controller/ControllerResolver.php | ControllerResolver.getArguments | public function getArguments(Request $request, array $controller, array $matched)
{
$reflection = new \ReflectionMethod($controller[0], $controller[1]);
$attributes = $request->attributes->all();
$arguments = [];
foreach ($reflection->getParameters() as $param) {
if (array_key_exists($param->name, $matched)) {
$arguments[] = $matched[$param->name];
} elseif (array_key_exists($param->name, $attributes)) {
$arguments[] = $attributes[$param->name];
} elseif ($param->isDefaultValueAvailable()) {
$arguments[] = $param->getDefaultValue();
} else {
$controller = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (either because there is no default value, or because there is a non-optional argument after this one).', $controller, $param->name));
}
}
return $arguments;
} | php | public function getArguments(Request $request, array $controller, array $matched)
{
$reflection = new \ReflectionMethod($controller[0], $controller[1]);
$attributes = $request->attributes->all();
$arguments = [];
foreach ($reflection->getParameters() as $param) {
if (array_key_exists($param->name, $matched)) {
$arguments[] = $matched[$param->name];
} elseif (array_key_exists($param->name, $attributes)) {
$arguments[] = $attributes[$param->name];
} elseif ($param->isDefaultValueAvailable()) {
$arguments[] = $param->getDefaultValue();
} else {
$controller = sprintf('%s::%s()', get_class($controller[0]), $controller[1]);
throw new \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (either because there is no default value, or because there is a non-optional argument after this one).', $controller, $param->name));
}
}
return $arguments;
} | [
"public",
"function",
"getArguments",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"controller",
",",
"array",
"$",
"matched",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"controller",
"[",
"0",
"]",
",",
"$",
"cont... | Get controller action arguments
@param Request $request
@param array $controller
@param array $matched
@return array | [
"Get",
"controller",
"action",
"arguments"
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/HttpKernel/Controller/ControllerResolver.php#L104-L124 | train |
wearenolte/wp-endpoints-post | src/Inc/Type.php | Type.get | public static function get( $post ) {
$post = is_a( $post, 'WP_Post' ) ? $post : get_post( $post );
$type = $post->post_type;
if ( 'page' === $type ) {
$template_slug = get_page_template_slug( $post->ID );
if ( ! empty( $template_slug ) ) {
$type .= '-' . wp_basename( $template_slug, '.php' );
}
}
return $type;
} | php | public static function get( $post ) {
$post = is_a( $post, 'WP_Post' ) ? $post : get_post( $post );
$type = $post->post_type;
if ( 'page' === $type ) {
$template_slug = get_page_template_slug( $post->ID );
if ( ! empty( $template_slug ) ) {
$type .= '-' . wp_basename( $template_slug, '.php' );
}
}
return $type;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"post",
")",
"{",
"$",
"post",
"=",
"is_a",
"(",
"$",
"post",
",",
"'WP_Post'",
")",
"?",
"$",
"post",
":",
"get_post",
"(",
"$",
"post",
")",
";",
"$",
"type",
"=",
"$",
"post",
"->",
"post_type",... | Returns the type for the post, the term template applies to what type of
post is or what type of template is using.
@param Int|\WP_Post $post The post
@return string | [
"Returns",
"the",
"type",
"for",
"the",
"post",
"the",
"term",
"template",
"applies",
"to",
"what",
"type",
"of",
"post",
"is",
"or",
"what",
"type",
"of",
"template",
"is",
"using",
"."
] | 11f17af89a3164faade5bd05be714cc3ab6e3c08 | https://github.com/wearenolte/wp-endpoints-post/blob/11f17af89a3164faade5bd05be714cc3ab6e3c08/src/Inc/Type.php#L17-L27 | train |
lembarek/auth | src/Controllers/AuthController.php | AuthController.postRegister | public function postRegister(RegisterRequest $request)
{
$inputs = $request->except('_token');
$inputs['password'] = Hash::make($inputs['password']);
$user = $this->userRepo->create($inputs);
Event::fire(new UserHasCreated($user));
return Redirect::to('/');
} | php | public function postRegister(RegisterRequest $request)
{
$inputs = $request->except('_token');
$inputs['password'] = Hash::make($inputs['password']);
$user = $this->userRepo->create($inputs);
Event::fire(new UserHasCreated($user));
return Redirect::to('/');
} | [
"public",
"function",
"postRegister",
"(",
"RegisterRequest",
"$",
"request",
")",
"{",
"$",
"inputs",
"=",
"$",
"request",
"->",
"except",
"(",
"'_token'",
")",
";",
"$",
"inputs",
"[",
"'password'",
"]",
"=",
"Hash",
"::",
"make",
"(",
"$",
"inputs",
... | create a new user in DB
@return Response | [
"create",
"a",
"new",
"user",
"in",
"DB"
] | 783aad2bcde9d8014be34092ba0cbe38b2bbc60a | https://github.com/lembarek/auth/blob/783aad2bcde9d8014be34092ba0cbe38b2bbc60a/src/Controllers/AuthController.php#L41-L50 | train |
lembarek/auth | src/Controllers/AuthController.php | AuthController.postLogin | public function postLogin(LoginRequest $request)
{
$inputs = $request->except('_token','rememberme');
$rememberme = $request->get('rememberme');
$attemp = Auth::attempt($inputs, !!$rememberme);
if (!$attemp) {
$request->session()->flash('error', trans('auth.failed'));
return Redirect::back();
}
return Redirect::intended('/');
} | php | public function postLogin(LoginRequest $request)
{
$inputs = $request->except('_token','rememberme');
$rememberme = $request->get('rememberme');
$attemp = Auth::attempt($inputs, !!$rememberme);
if (!$attemp) {
$request->session()->flash('error', trans('auth.failed'));
return Redirect::back();
}
return Redirect::intended('/');
} | [
"public",
"function",
"postLogin",
"(",
"LoginRequest",
"$",
"request",
")",
"{",
"$",
"inputs",
"=",
"$",
"request",
"->",
"except",
"(",
"'_token'",
",",
"'rememberme'",
")",
";",
"$",
"rememberme",
"=",
"$",
"request",
"->",
"get",
"(",
"'rememberme'",
... | try to login the user
@return Response | [
"try",
"to",
"login",
"the",
"user"
] | 783aad2bcde9d8014be34092ba0cbe38b2bbc60a | https://github.com/lembarek/auth/blob/783aad2bcde9d8014be34092ba0cbe38b2bbc60a/src/Controllers/AuthController.php#L69-L84 | train |
zepi/turbo-base | Zepi/Web/General/src/Manager/TemplatesManager.php | TemplatesManager.loadTemplates | protected function loadTemplates()
{
$templates = $this->templatesObjectBackend->loadObject();
if (!is_array($templates)) {
$templates = array();
}
$this->templates = $templates;
} | php | protected function loadTemplates()
{
$templates = $this->templatesObjectBackend->loadObject();
if (!is_array($templates)) {
$templates = array();
}
$this->templates = $templates;
} | [
"protected",
"function",
"loadTemplates",
"(",
")",
"{",
"$",
"templates",
"=",
"$",
"this",
"->",
"templatesObjectBackend",
"->",
"loadObject",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"templates",
")",
")",
"{",
"$",
"templates",
"=",
"arra... | Loads the templates from the object backend
@access public | [
"Loads",
"the",
"templates",
"from",
"the",
"object",
"backend"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L106-L114 | train |
zepi/turbo-base | Zepi/Web/General/src/Manager/TemplatesManager.php | TemplatesManager.addTemplate | public function addTemplate($key, $file, $priority = 10)
{
// If the file does not exists we can't add the file
// to the templates...
if (!file_exists($file) || !is_readable($file)) {
return false;
}
// Create the arrays, if they are not existing
if (!isset($this->templates[$key]) || !is_array($this->templates[$key])) {
$this->templates[$key] = array();
}
$this->templates[$key][$priority] = $file;
ksort($this->templates[$key]);
$this->saveTemplates();
return true;
} | php | public function addTemplate($key, $file, $priority = 10)
{
// If the file does not exists we can't add the file
// to the templates...
if (!file_exists($file) || !is_readable($file)) {
return false;
}
// Create the arrays, if they are not existing
if (!isset($this->templates[$key]) || !is_array($this->templates[$key])) {
$this->templates[$key] = array();
}
$this->templates[$key][$priority] = $file;
ksort($this->templates[$key]);
$this->saveTemplates();
return true;
} | [
"public",
"function",
"addTemplate",
"(",
"$",
"key",
",",
"$",
"file",
",",
"$",
"priority",
"=",
"10",
")",
"{",
"// If the file does not exists we can't add the file",
"// to the templates...",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
"||",
"!",
... | Adds a new template file to the given key with the given priority.
@access public
@param string $key
@param string $file
@param integer $priority
@return boolean | [
"Adds",
"a",
"new",
"template",
"file",
"to",
"the",
"given",
"key",
"with",
"the",
"given",
"priority",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L135-L155 | train |
zepi/turbo-base | Zepi/Web/General/src/Manager/TemplatesManager.php | TemplatesManager.removeTemplate | public function removeTemplate($key, $file, $priority = 10)
{
// If we can't find the template file we do not have to remove anything.
if (!isset($this->templates[$key][$priority])) {
return false;
}
// Remove the template file.
unset($this->templates[$key][$priority]);
} | php | public function removeTemplate($key, $file, $priority = 10)
{
// If we can't find the template file we do not have to remove anything.
if (!isset($this->templates[$key][$priority])) {
return false;
}
// Remove the template file.
unset($this->templates[$key][$priority]);
} | [
"public",
"function",
"removeTemplate",
"(",
"$",
"key",
",",
"$",
"file",
",",
"$",
"priority",
"=",
"10",
")",
"{",
"// If we can't find the template file we do not have to remove anything.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"templates",
"[",
"... | Removes the template file for the given key and priority.
@access public
@param string $key
@param string $file
@param integer $priority | [
"Removes",
"the",
"template",
"file",
"for",
"the",
"given",
"key",
"and",
"priority",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L165-L174 | train |
zepi/turbo-base | Zepi/Web/General/src/Manager/TemplatesManager.php | TemplatesManager.addRenderer | public function addRenderer(RendererAbstract $renderer)
{
$extension = $renderer->getExtension();
if (isset($this->renderer[$extension])) {
return false;
}
$this->renderer[$extension] = $renderer;
return true;
} | php | public function addRenderer(RendererAbstract $renderer)
{
$extension = $renderer->getExtension();
if (isset($this->renderer[$extension])) {
return false;
}
$this->renderer[$extension] = $renderer;
return true;
} | [
"public",
"function",
"addRenderer",
"(",
"RendererAbstract",
"$",
"renderer",
")",
"{",
"$",
"extension",
"=",
"$",
"renderer",
"->",
"getExtension",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"renderer",
"[",
"$",
"extension",
"]",
")",... | Add a renderer.
@access public
@param \Zepi\Web\General\Template\RendererAbstract $renderer
@return boolean | [
"Add",
"a",
"renderer",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L183-L193 | train |
zepi/turbo-base | Zepi/Web/General/src/Manager/TemplatesManager.php | TemplatesManager.renderTemplate | public function renderTemplate($key, $additionalData = array())
{
if (!isset($this->templates[$key])) {
return '';
}
$output = '';
// Render the template files
foreach ($this->templates[$key] as $priority => $templateFile) {
$output .= $this->searchRendererAndRenderTemplate($templateFile, $additionalData);
}
return $output;
} | php | public function renderTemplate($key, $additionalData = array())
{
if (!isset($this->templates[$key])) {
return '';
}
$output = '';
// Render the template files
foreach ($this->templates[$key] as $priority => $templateFile) {
$output .= $this->searchRendererAndRenderTemplate($templateFile, $additionalData);
}
return $output;
} | [
"public",
"function",
"renderTemplate",
"(",
"$",
"key",
",",
"$",
"additionalData",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$... | Renders all template files for the given template key.
@access public
@param string $key
@param array $additionalData
@return string | [
"Renders",
"all",
"template",
"files",
"for",
"the",
"given",
"template",
"key",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L203-L217 | train |
zepi/turbo-base | Zepi/Web/General/src/Manager/TemplatesManager.php | TemplatesManager.searchRendererAndRenderTemplate | protected function searchRendererAndRenderTemplate($templateFile, $additionalData = array())
{
// Get the file information for the template file
$fileInfo = pathinfo($templateFile);
$extension = $fileInfo['extension'];
// If we haven't a renderer for this extension we return an
// empty string to prevent everything from failing.
if (!isset($this->renderer[$extension])) {
return '';
}
// Take the renderer...
$renderer = $this->renderer[$extension];
// ...and render the template file.
return $renderer->renderTemplateFile(
$templateFile,
$this->framework,
$this->framework->getRequest(),
$this->framework->getResponse(),
$additionalData
);
} | php | protected function searchRendererAndRenderTemplate($templateFile, $additionalData = array())
{
// Get the file information for the template file
$fileInfo = pathinfo($templateFile);
$extension = $fileInfo['extension'];
// If we haven't a renderer for this extension we return an
// empty string to prevent everything from failing.
if (!isset($this->renderer[$extension])) {
return '';
}
// Take the renderer...
$renderer = $this->renderer[$extension];
// ...and render the template file.
return $renderer->renderTemplateFile(
$templateFile,
$this->framework,
$this->framework->getRequest(),
$this->framework->getResponse(),
$additionalData
);
} | [
"protected",
"function",
"searchRendererAndRenderTemplate",
"(",
"$",
"templateFile",
",",
"$",
"additionalData",
"=",
"array",
"(",
")",
")",
"{",
"// Get the file information for the template file",
"$",
"fileInfo",
"=",
"pathinfo",
"(",
"$",
"templateFile",
")",
";... | Searches a renderer for the given template file and renders the
file.
@access protected
@param string $templateFile
@param array $additionalData
@return string | [
"Searches",
"a",
"renderer",
"for",
"the",
"given",
"template",
"file",
"and",
"renders",
"the",
"file",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/TemplatesManager.php#L228-L251 | train |
10usb/css-lib | autoloader.php | Autoloader.load | public static function load($name){
if(substr($name, 0, 7)!='csslib\\') return false;
$filename = __DIR__.'/src/'.implode('/', array_slice(explode('\\', $name), 1)).'.php';
if(!file_exists($filename)) throw new \Exception('File "'.$filename.'" not found');
require_once $filename;
if(class_exists($name) || interface_exists($name)) return true;
throw new \Exception('Class or Interface "'.$name.'" not exists');
} | php | public static function load($name){
if(substr($name, 0, 7)!='csslib\\') return false;
$filename = __DIR__.'/src/'.implode('/', array_slice(explode('\\', $name), 1)).'.php';
if(!file_exists($filename)) throw new \Exception('File "'.$filename.'" not found');
require_once $filename;
if(class_exists($name) || interface_exists($name)) return true;
throw new \Exception('Class or Interface "'.$name.'" not exists');
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"7",
")",
"!=",
"'csslib\\\\'",
")",
"return",
"false",
";",
"$",
"filename",
"=",
"__DIR__",
".",
"'/src/'",
".",
"implode",
... | Load a class or interface by its name, ain't that cool?
@param string $name Class name
@throws \Exception
@return boolean | [
"Load",
"a",
"class",
"or",
"interface",
"by",
"its",
"name",
"ain",
"t",
"that",
"cool?"
] | 6370b1404bae3eecb44c214ed4eaaf33113858dd | https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/autoloader.php#L22-L35 | train |
prototypemvc/prototypemvc | Core/Model.php | Model.load | public static function load($model = false) {
$path = DOC_ROOT . Config::get('paths', 'modules');
if ($model && File::isFile($path . $model . '.php')) {
$array = explode('/', $model);
$modelName = end($array);
require $path . $model . '.php';
return new $modelName();
}
return false;
} | php | public static function load($model = false) {
$path = DOC_ROOT . Config::get('paths', 'modules');
if ($model && File::isFile($path . $model . '.php')) {
$array = explode('/', $model);
$modelName = end($array);
require $path . $model . '.php';
return new $modelName();
}
return false;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"model",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"DOC_ROOT",
".",
"Config",
"::",
"get",
"(",
"'paths'",
",",
"'modules'",
")",
";",
"if",
"(",
"$",
"model",
"&&",
"File",
"::",
"isFile",
"(",
"$"... | Load a given model.
@param string path to file
@example load('blog/model/blog')
@example load('blog/model/blog.php')
@return object | [
"Load",
"a",
"given",
"model",
"."
] | 039e238857d4b627e40ba681a376583b0821cd36 | https://github.com/prototypemvc/prototypemvc/blob/039e238857d4b627e40ba681a376583b0821cd36/Core/Model.php#L17-L32 | train |
Silvestra/Silvestra | src/Silvestra/Component/Media/Templating/ImageTemplatingHelper.php | ImageTemplatingHelper.getImagePath | private function getImagePath($path)
{
if ($path && file_exists($this->filesystem->getRootDir() . $path)) {
return $path;
}
return $this->noImagePath;
} | php | private function getImagePath($path)
{
if ($path && file_exists($this->filesystem->getRootDir() . $path)) {
return $path;
}
return $this->noImagePath;
} | [
"private",
"function",
"getImagePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"&&",
"file_exists",
"(",
"$",
"this",
"->",
"filesystem",
"->",
"getRootDir",
"(",
")",
".",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"r... | Get image path.
@param string $path
@return string | [
"Get",
"image",
"path",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Media/Templating/ImageTemplatingHelper.php#L89-L96 | train |
xpl-php/Common | src/Storage/Registry.php | Registry.set | public function set($key, $object) {
if (! is_object($object)) {
throw new \InvalidArgumentException("Registry only accepts objects, given: ".gettype($object));
}
$this->_data[$key] = $object;
return $this;
} | php | public function set($key, $object) {
if (! is_object($object)) {
throw new \InvalidArgumentException("Registry only accepts objects, given: ".gettype($object));
}
$this->_data[$key] = $object;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Registry only accepts objects, given: \"",
".",
"gettype",
"... | Sets an object.
@param string $key Item key.
@param object $object Object instance.
@return $this | [
"Sets",
"an",
"object",
"."
] | 0669bdcca29f1f8835297c2397c62fee3be5dce3 | https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L28-L37 | train |
xpl-php/Common | src/Storage/Registry.php | Registry.add | public function add(array $items) {
foreach($items as $name => $object) {
$this->set($name, $object);
}
return $this;
} | php | public function add(array $items) {
foreach($items as $name => $object) {
$this->set($name, $object);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"array",
"$",
"items",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"name",
"=>",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"object",
")",
";",
"}",
"return",
"$",
"th... | Adds an array of items.
@param array $items
@return $this | [
"Adds",
"an",
"array",
"of",
"items",
"."
] | 0669bdcca29f1f8835297c2397c62fee3be5dce3 | https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L46-L53 | train |
xpl-php/Common | src/Storage/Registry.php | Registry.get | public function get($key) {
if (isset($this->_data[$key])) {
return $this->_data[$key];
}
if (isset($this->registered[$key])) {
return $this->_data[$key] = call_user_func($this->registered[$key], $this);
}
return null;
} | php | public function get($key) {
if (isset($this->_data[$key])) {
return $this->_data[$key];
}
if (isset($this->registered[$key])) {
return $this->_data[$key] = call_user_func($this->registered[$key], $this);
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
... | Returns a registered value.
@param string $key Item key.
@return mixed | [
"Returns",
"a",
"registered",
"value",
"."
] | 0669bdcca29f1f8835297c2397c62fee3be5dce3 | https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L62-L73 | train |
xpl-php/Common | src/Storage/Registry.php | Registry.exists | public function exists($key) {
return isset($this->_data[$key]) || isset($this->registered[$key]);
} | php | public function exists($key) {
return isset($this->_data[$key]) || isset($this->registered[$key]);
} | [
"public",
"function",
"exists",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"key",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"registered",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | Checks whether an key can be resolved to an object or registered closure.
@param string $key Item key.
@return boolean True if the item can be resolved to an object. | [
"Checks",
"whether",
"an",
"key",
"can",
"be",
"resolved",
"to",
"an",
"object",
"or",
"registered",
"closure",
"."
] | 0669bdcca29f1f8835297c2397c62fee3be5dce3 | https://github.com/xpl-php/Common/blob/0669bdcca29f1f8835297c2397c62fee3be5dce3/src/Storage/Registry.php#L124-L126 | train |
lfalmeida/lbase | src/Controllers/ApiBaseController.php | ApiBaseController.paginate | protected function paginate(Request $request)
{
$fields = $request->input('fields') ? explode(',', $request->input('fields')) : ['*'];
$pageSize = $request->input('pageSize') ? (int)$request->input('pageSize') : null;
$sort = $request->input('sort') ? $request->input('sort') : null;
$order = $request->input('order') ? $request->input('order') : 'asc';
$pagination = $this->repository->paginate($pageSize, $fields, $sort, $order);
$pagination->appends($request->except(['page']));
return Response::apiResponse([
'data' => $pagination
]);
} | php | protected function paginate(Request $request)
{
$fields = $request->input('fields') ? explode(',', $request->input('fields')) : ['*'];
$pageSize = $request->input('pageSize') ? (int)$request->input('pageSize') : null;
$sort = $request->input('sort') ? $request->input('sort') : null;
$order = $request->input('order') ? $request->input('order') : 'asc';
$pagination = $this->repository->paginate($pageSize, $fields, $sort, $order);
$pagination->appends($request->except(['page']));
return Response::apiResponse([
'data' => $pagination
]);
} | [
"protected",
"function",
"paginate",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"fields",
"=",
"$",
"request",
"->",
"input",
"(",
"'fields'",
")",
"?",
"explode",
"(",
"','",
",",
"$",
"request",
"->",
"input",
"(",
"'fields'",
")",
")",
":",
"[... | Retorna os resultados paginados.
Este método aceita os seguintes parâmetros fornecidos via Request: **fields, pageSize, sort, order**.
- **fields**: String com as colunas desejadas no retorno, separadas por vírgula.
- **pageSise**: Inteiro indicando a quantidade de resultados por página.
- **sort**: Coluna para ordenação
- **order**: Direção da ordenação
@internal Este método não é exposto via url, sendo acessado via método index
@param Request $request | [
"Retorna",
"os",
"resultados",
"paginados",
"."
] | d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37 | https://github.com/lfalmeida/lbase/blob/d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37/src/Controllers/ApiBaseController.php#L151-L165 | train |
lfalmeida/lbase | src/Controllers/ApiBaseController.php | ApiBaseController.update | public function update(Request $request, $id)
{
$response = $this->repository->update($id, $request->all());
return Response::apiResponse([
'data' => $response
]);
} | php | public function update(Request $request, $id)
{
$response = $this->repository->update($id, $request->all());
return Response::apiResponse([
'data' => $response
]);
} | [
"public",
"function",
"update",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"repository",
"->",
"update",
"(",
"$",
"id",
",",
"$",
"request",
"->",
"all",
"(",
")",
")",
";",
"return",
"Respon... | Atualiza os dados de uma entidade com base nos dados obtidos no Request.
@param \Illuminate\Http\Request $request
@param int $id Id da entidade a ser atualizada
@return \Illuminate\Http\Response | [
"Atualiza",
"os",
"dados",
"de",
"uma",
"entidade",
"com",
"base",
"nos",
"dados",
"obtidos",
"no",
"Request",
"."
] | d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37 | https://github.com/lfalmeida/lbase/blob/d2ed4b7b9c74c849dde4fd9953e6aca1f4092e37/src/Controllers/ApiBaseController.php#L223-L230 | train |
prestaconcept/PrestaComposerPublicBundle | Command/BlendCommand.php | BlendCommand.getBundlesToBlend | private function getBundlesToBlend()
{
$toBlend = array();
foreach ($this->config['blend'] as $key => $params) {
$vendor = isset($params['vendor']) ? $params['vendor'] : null;
$name = isset($params['name']) ? $params['name'] : null;
$path = isset($params['path']) ? $params['path'] : null;
if (!$vendor && !$name) {
list($vendor, $name) = explode('/', $key, 2);
}
if (!isset($toBlend[$vendor][$name])) {
$toBlend[$vendor][$name] = $path;
}
}
return $toBlend;
} | php | private function getBundlesToBlend()
{
$toBlend = array();
foreach ($this->config['blend'] as $key => $params) {
$vendor = isset($params['vendor']) ? $params['vendor'] : null;
$name = isset($params['name']) ? $params['name'] : null;
$path = isset($params['path']) ? $params['path'] : null;
if (!$vendor && !$name) {
list($vendor, $name) = explode('/', $key, 2);
}
if (!isset($toBlend[$vendor][$name])) {
$toBlend[$vendor][$name] = $path;
}
}
return $toBlend;
} | [
"private",
"function",
"getBundlesToBlend",
"(",
")",
"{",
"$",
"toBlend",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"[",
"'blend'",
"]",
"as",
"$",
"key",
"=>",
"$",
"params",
")",
"{",
"$",
"vendor",
"=",
"isset",
... | Extract bundles to blend from config
@return array | [
"Extract",
"bundles",
"to",
"blend",
"from",
"config"
] | 2d7da2998141c4777301910f912a19d4cc5e8a74 | https://github.com/prestaconcept/PrestaComposerPublicBundle/blob/2d7da2998141c4777301910f912a19d4cc5e8a74/Command/BlendCommand.php#L71-L90 | train |
prestaconcept/PrestaComposerPublicBundle | Command/BlendCommand.php | BlendCommand.blend | private function blend($toBlend, OutputInterface $output)
{
$fs = new Filesystem();
$vendorDir = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor';
foreach ($toBlend as $vendor => $names) {
foreach ($names as $name => $path) {
$originPath = realpath($vendorDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR));
$targetDir = realpath($this->bundlePath) . DIRECTORY_SEPARATOR . $vendor;
$targetPath = $targetDir . DIRECTORY_SEPARATOR . $name;
if (!$originPath) {
throw new \InvalidArgumentException(sprintf('The origin path for "%s" does not exist : "%s"', "$vendor/$name", $originPath));
}
if (!$fs->exists($targetDir)) {
$fs->mkdir($targetDir);
}
// Switch for symlink to hard copy or from hard copy to symlink
if (is_link($targetPath) && (!isset($this->config['symlink']) || !$this->config['symlink'])
||
is_dir($targetPath) && isset($this->config['symlink']) && $this->config['symlink']
) {
$fs->remove($targetPath);
}
if (isset($this->config['symlink']) && $this->config['symlink']) {
$fs->symlink($originPath, $targetPath);
} else {
$fs->mirror($originPath, $targetPath, null, array('delete' => true, 'override' => true));
}
$output->writeln(sprintf('The library <info>%s/%s</info> has been added', $vendor, $name));
}
}
} | php | private function blend($toBlend, OutputInterface $output)
{
$fs = new Filesystem();
$vendorDir = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor';
foreach ($toBlend as $vendor => $names) {
foreach ($names as $name => $path) {
$originPath = realpath($vendorDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR . $name . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR));
$targetDir = realpath($this->bundlePath) . DIRECTORY_SEPARATOR . $vendor;
$targetPath = $targetDir . DIRECTORY_SEPARATOR . $name;
if (!$originPath) {
throw new \InvalidArgumentException(sprintf('The origin path for "%s" does not exist : "%s"', "$vendor/$name", $originPath));
}
if (!$fs->exists($targetDir)) {
$fs->mkdir($targetDir);
}
// Switch for symlink to hard copy or from hard copy to symlink
if (is_link($targetPath) && (!isset($this->config['symlink']) || !$this->config['symlink'])
||
is_dir($targetPath) && isset($this->config['symlink']) && $this->config['symlink']
) {
$fs->remove($targetPath);
}
if (isset($this->config['symlink']) && $this->config['symlink']) {
$fs->symlink($originPath, $targetPath);
} else {
$fs->mirror($originPath, $targetPath, null, array('delete' => true, 'override' => true));
}
$output->writeln(sprintf('The library <info>%s/%s</info> has been added', $vendor, $name));
}
}
} | [
"private",
"function",
"blend",
"(",
"$",
"toBlend",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"fs",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"vendorDir",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'k... | Blend bundles into prestaComposer vendor directory
@param $toBlend
@param OutputInterface $output
@throws \InvalidArgumentException | [
"Blend",
"bundles",
"into",
"prestaComposer",
"vendor",
"directory"
] | 2d7da2998141c4777301910f912a19d4cc5e8a74 | https://github.com/prestaconcept/PrestaComposerPublicBundle/blob/2d7da2998141c4777301910f912a19d4cc5e8a74/Command/BlendCommand.php#L99-L135 | train |
n0m4dz/laracasa | Zend/Gdata/Spreadsheets/ListQuery.php | Zend_Gdata_Spreadsheets_ListQuery.setSpreadsheetQuery | public function setSpreadsheetQuery($value)
{
if ($value != null) {
$this->_params['sq'] = $value;
} else {
unset($this->_params['sq']);
}
return $this;
} | php | public function setSpreadsheetQuery($value)
{
if ($value != null) {
$this->_params['sq'] = $value;
} else {
unset($this->_params['sq']);
}
return $this;
} | [
"public",
"function",
"setSpreadsheetQuery",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_params",
"[",
"'sq'",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
... | Sets the spreadsheet key for this query.
@param string $value
@return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface | [
"Sets",
"the",
"spreadsheet",
"key",
"for",
"this",
"query",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListQuery.php#L170-L178 | train |
n0m4dz/laracasa | Zend/Gdata/Spreadsheets/ListQuery.php | Zend_Gdata_Spreadsheets_ListQuery.setReverse | public function setReverse($value)
{
if ($value != null) {
$this->_params['reverse'] = $value;
} else {
unset($this->_params['reverse']);
}
return $this;
} | php | public function setReverse($value)
{
if ($value != null) {
$this->_params['reverse'] = $value;
} else {
unset($this->_params['reverse']);
}
return $this;
} | [
"public",
"function",
"setReverse",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_params",
"[",
"'reverse'",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"_pa... | Sets the reverse attribute for this query.
@param string $value
@return Zend_Gdata_Spreadsheets_DocumentQuery Provides a fluent interface | [
"Sets",
"the",
"reverse",
"attribute",
"for",
"this",
"query",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListQuery.php#L226-L234 | train |
znframework/package-image | Thumb.php | Thumb.size | public function size(Int $width, Int $height) : Thumb
{
$this->sets['width'] = $width;
$this->sets['height'] = $height;
return $this;
} | php | public function size(Int $width, Int $height) : Thumb
{
$this->sets['width'] = $width;
$this->sets['height'] = $height;
return $this;
} | [
"public",
"function",
"size",
"(",
"Int",
"$",
"width",
",",
"Int",
"$",
"height",
")",
":",
"Thumb",
"{",
"$",
"this",
"->",
"sets",
"[",
"'width'",
"]",
"=",
"$",
"width",
";",
"$",
"this",
"->",
"sets",
"[",
"'height'",
"]",
"=",
"$",
"height"... | Sets image size
@param int $width
@param int $height
@return Thumb | [
"Sets",
"image",
"size"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L109-L115 | train |
znframework/package-image | Thumb.php | Thumb.resize | public function resize(Int $width, Int $height) : Thumb
{
$this->sets['rewidth'] = $width;
$this->sets['reheight'] = $height;
return $this;
} | php | public function resize(Int $width, Int $height) : Thumb
{
$this->sets['rewidth'] = $width;
$this->sets['reheight'] = $height;
return $this;
} | [
"public",
"function",
"resize",
"(",
"Int",
"$",
"width",
",",
"Int",
"$",
"height",
")",
":",
"Thumb",
"{",
"$",
"this",
"->",
"sets",
"[",
"'rewidth'",
"]",
"=",
"$",
"width",
";",
"$",
"this",
"->",
"sets",
"[",
"'reheight'",
"]",
"=",
"$",
"h... | Sets image resize
@param int $width
@param int $height
@return Thumb | [
"Sets",
"image",
"resize"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L125-L131 | train |
znframework/package-image | Thumb.php | Thumb.prosize | public function prosize(Int $width, Int $height = 0) : Thumb
{
$this->sets['prowidth'] = $width;
$this->sets['proheight'] = $height;
return $this;
} | php | public function prosize(Int $width, Int $height = 0) : Thumb
{
$this->sets['prowidth'] = $width;
$this->sets['proheight'] = $height;
return $this;
} | [
"public",
"function",
"prosize",
"(",
"Int",
"$",
"width",
",",
"Int",
"$",
"height",
"=",
"0",
")",
":",
"Thumb",
"{",
"$",
"this",
"->",
"sets",
"[",
"'prowidth'",
"]",
"=",
"$",
"width",
";",
"$",
"this",
"->",
"sets",
"[",
"'proheight'",
"]",
... | Sets image proportional size
@param int $width
@param int $height
@return Thumb | [
"Sets",
"image",
"proportional",
"size"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L141-L147 | train |
znframework/package-image | Thumb.php | Thumb.create | public function create(String $path = NULL) : String
{
if( isset($this->sets['filePath']) )
{
$path = $this->sets['filePath'];
}
# It keeps the used filters belonging to the GD class.
# [5.7.8]added
$this->sets['filters'] = $this->filters;
$settings = $this->sets;
$this->sets = [];
return $this->image->thumb($path, $settings);
} | php | public function create(String $path = NULL) : String
{
if( isset($this->sets['filePath']) )
{
$path = $this->sets['filePath'];
}
# It keeps the used filters belonging to the GD class.
# [5.7.8]added
$this->sets['filters'] = $this->filters;
$settings = $this->sets;
$this->sets = [];
return $this->image->thumb($path, $settings);
} | [
"public",
"function",
"create",
"(",
"String",
"$",
"path",
"=",
"NULL",
")",
":",
"String",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"sets",
"[",
"'filePath'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"sets",
"[",
"'fileP... | Create new image
@param string $path = NULL
@return string | [
"Create",
"new",
"image"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L156-L172 | train |
znframework/package-image | Thumb.php | Thumb.getProsize | public function getProsize(Int $width = 0, Int $height = 0)
{
if( ! isset($this->sets['filePath']) )
{
return false;
}
return $this->image->getProsize($this->sets['filePath'], $width, $height);
} | php | public function getProsize(Int $width = 0, Int $height = 0)
{
if( ! isset($this->sets['filePath']) )
{
return false;
}
return $this->image->getProsize($this->sets['filePath'], $width, $height);
} | [
"public",
"function",
"getProsize",
"(",
"Int",
"$",
"width",
"=",
"0",
",",
"Int",
"$",
"height",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"sets",
"[",
"'filePath'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
... | Get proportional size
@param int $width = 0
@param int $height = 0
@return object|false | [
"Get",
"proportional",
"size"
] | a4eee7468e2c8b9334b121bd358ab8acbccf11a2 | https://github.com/znframework/package-image/blob/a4eee7468e2c8b9334b121bd358ab8acbccf11a2/Thumb.php#L182-L190 | train |
jaeger-app/log | src/Traits/Log.php | Log.getPathToLogFile | public function getPathToLogFile($name = 'm62')
{
if (is_null($this->log_path)) {
$this->log_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'logs') . DIRECTORY_SEPARATOR . $name . '.log';
}
return $this->log_path;
} | php | public function getPathToLogFile($name = 'm62')
{
if (is_null($this->log_path)) {
$this->log_path = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'logs') . DIRECTORY_SEPARATOR . $name . '.log';
}
return $this->log_path;
} | [
"public",
"function",
"getPathToLogFile",
"(",
"$",
"name",
"=",
"'m62'",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"log_path",
")",
")",
"{",
"$",
"this",
"->",
"log_path",
"=",
"realpath",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"D... | Returns the path to the log file
@param string $name
The name of the log file to use
@return \mithra62\Traits::$log_path | [
"Returns",
"the",
"path",
"to",
"the",
"log",
"file"
] | 8b8f81d142cdce5806fc611342441f2d47f15578 | https://github.com/jaeger-app/log/blob/8b8f81d142cdce5806fc611342441f2d47f15578/src/Traits/Log.php#L115-L122 | train |
jaeger-app/log | src/Traits/Log.php | Log.removeLogFile | public function removeLogFile()
{
if (file_exists($this->log_path)) {
$this->logger = null;
unlink($this->log_path);
}
return $this;
} | php | public function removeLogFile()
{
if (file_exists($this->log_path)) {
$this->logger = null;
unlink($this->log_path);
}
return $this;
} | [
"public",
"function",
"removeLogFile",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"log_path",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"=",
"null",
";",
"unlink",
"(",
"$",
"this",
"->",
"log_path",
")",
";",
"}",
"return",
... | Removes the logging file
@return \mithra62\Traits\Log | [
"Removes",
"the",
"logging",
"file"
] | 8b8f81d142cdce5806fc611342441f2d47f15578 | https://github.com/jaeger-app/log/blob/8b8f81d142cdce5806fc611342441f2d47f15578/src/Traits/Log.php#L143-L151 | train |
elumina-elearning/event | src/Emitter.php | Emitter.ensureListener | protected function ensureListener($listener)
{
if ($listener instanceof ListenerInterface) {
return $listener;
}
if (is_callable($listener)) {
return CallbackListener::fromCallable($listener);
}
throw new InvalidArgumentException('Listeners should be be ListenerInterface, Closure or callable. Received type: '.gettype($listener));
} | php | protected function ensureListener($listener)
{
if ($listener instanceof ListenerInterface) {
return $listener;
}
if (is_callable($listener)) {
return CallbackListener::fromCallable($listener);
}
throw new InvalidArgumentException('Listeners should be be ListenerInterface, Closure or callable. Received type: '.gettype($listener));
} | [
"protected",
"function",
"ensureListener",
"(",
"$",
"listener",
")",
"{",
"if",
"(",
"$",
"listener",
"instanceof",
"ListenerInterface",
")",
"{",
"return",
"$",
"listener",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"listener",
")",
")",
"{",
"return"... | Ensure the input is a listener.
@param ListenerInterface|callable $listener
@throws InvalidArgumentException
@return ListenerInterface | [
"Ensure",
"the",
"input",
"is",
"a",
"listener",
"."
] | e311372ee4b62388aee3629fb4b3ea530b42d17f | https://github.com/elumina-elearning/event/blob/e311372ee4b62388aee3629fb4b3ea530b42d17f/src/Emitter.php#L106-L117 | train |
Flowpack/Flowpack.SingleSignOn.Server | Classes/Flowpack/SingleSignOn/Server/Controller/SessionController.php | SessionController.touchAction | public function touchAction($sessionId) {
if ($this->request->getHttpRequest()->getMethod() !== 'POST') {
$this->response->setStatus(405);
$this->response->setHeader('Allow', 'POST');
return;
}
$session = $this->sessionManager->getSession($sessionId);
if ($session !== NULL) {
$session->touch();
if ($this->ssoLogger !== NULL) {
$this->ssoLogger->log('Touched session "' . $sessionId . '"' , LOG_DEBUG);
}
$this->view->assign('value', array('success' => TRUE));
} else {
$this->response->setStatus(404);
$this->view->assign('value', array('error' => 'SessionNotFound'));
}
} | php | public function touchAction($sessionId) {
if ($this->request->getHttpRequest()->getMethod() !== 'POST') {
$this->response->setStatus(405);
$this->response->setHeader('Allow', 'POST');
return;
}
$session = $this->sessionManager->getSession($sessionId);
if ($session !== NULL) {
$session->touch();
if ($this->ssoLogger !== NULL) {
$this->ssoLogger->log('Touched session "' . $sessionId . '"' , LOG_DEBUG);
}
$this->view->assign('value', array('success' => TRUE));
} else {
$this->response->setStatus(404);
$this->view->assign('value', array('error' => 'SessionNotFound'));
}
} | [
"public",
"function",
"touchAction",
"(",
"$",
"sessionId",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"getHttpRequest",
"(",
")",
"->",
"getMethod",
"(",
")",
"!==",
"'POST'",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"setStatus",
"... | Touch a session to refresh the last active timestamp
POST /sso/session/xyz-123/touch
@param string $sessionId The session id | [
"Touch",
"a",
"session",
"to",
"refresh",
"the",
"last",
"active",
"timestamp"
] | b1fa014f31d0d101a79cb95d5585b9973f35347d | https://github.com/Flowpack/Flowpack.SingleSignOn.Server/blob/b1fa014f31d0d101a79cb95d5585b9973f35347d/Classes/Flowpack/SingleSignOn/Server/Controller/SessionController.php#L73-L94 | train |
Thuata/FrameworkBundle | Repository/RepositoryFactory.php | RepositoryFactory.getRepositoryForEntity | public function getRepositoryForEntity(string $entityName, string $connectionName = null): AbstractRepository
{
/** @var AbstractRepository $repository */
$repository = $this->loadFactorableInstance($entityName);
if (is_string($connectionName)) {
$entityManager = $this->getContainer()->get('doctrine')->getManager($connectionName);
$repository->setEntityManager($entityManager);
}
$this->onFactorableLoaded($repository);
return $repository;
} | php | public function getRepositoryForEntity(string $entityName, string $connectionName = null): AbstractRepository
{
/** @var AbstractRepository $repository */
$repository = $this->loadFactorableInstance($entityName);
if (is_string($connectionName)) {
$entityManager = $this->getContainer()->get('doctrine')->getManager($connectionName);
$repository->setEntityManager($entityManager);
}
$this->onFactorableLoaded($repository);
return $repository;
} | [
"public",
"function",
"getRepositoryForEntity",
"(",
"string",
"$",
"entityName",
",",
"string",
"$",
"connectionName",
"=",
"null",
")",
":",
"AbstractRepository",
"{",
"/** @var AbstractRepository $repository */",
"$",
"repository",
"=",
"$",
"this",
"->",
"loadFact... | Gets a repository for an entity
@param string $entityName
@param string $connectionName
@return AbstractRepository | [
"Gets",
"a",
"repository",
"for",
"an",
"entity"
] | 78c38a5103256d829d7f7574b4e15c9087d0cfd9 | https://github.com/Thuata/FrameworkBundle/blob/78c38a5103256d829d7f7574b4e15c9087d0cfd9/Repository/RepositoryFactory.php#L130-L143 | train |
Flowpack/Flowpack.SingleSignOn.Client | Classes/Flowpack/SingleSignOn/Client/Domain/Factory/SsoClientFactory.php | SsoClientFactory.create | public function create() {
$ssoClient = new \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient();
if ((string)$this->clientServiceBaseUri === '') {
throw new Exception('Missing Flowpack.SingleSignOn.Client.client.serviceBaseUri setting', 1351075078);
}
$ssoClient->setServiceBaseUri($this->clientServiceBaseUri);
if ((string)$this->clientPublicKeyFingerprint === '') {
throw new Exception('Missing Flowpack.SingleSignOn.Client.client.publicKeyFingerprint setting', 1351075159);
}
$ssoClient->setPublicKeyFingerprint($this->clientPublicKeyFingerprint);
return $ssoClient;
} | php | public function create() {
$ssoClient = new \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient();
if ((string)$this->clientServiceBaseUri === '') {
throw new Exception('Missing Flowpack.SingleSignOn.Client.client.serviceBaseUri setting', 1351075078);
}
$ssoClient->setServiceBaseUri($this->clientServiceBaseUri);
if ((string)$this->clientPublicKeyFingerprint === '') {
throw new Exception('Missing Flowpack.SingleSignOn.Client.client.publicKeyFingerprint setting', 1351075159);
}
$ssoClient->setPublicKeyFingerprint($this->clientPublicKeyFingerprint);
return $ssoClient;
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"ssoClient",
"=",
"new",
"\\",
"Flowpack",
"\\",
"SingleSignOn",
"\\",
"Client",
"\\",
"Domain",
"\\",
"Model",
"\\",
"SsoClient",
"(",
")",
";",
"if",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"c... | Build a SSO client instance from settings
Note: Every SSO entry point and authentication provider uses the same SSO client.
@return \Flowpack\SingleSignOn\Client\Domain\Model\SsoClient | [
"Build",
"a",
"SSO",
"client",
"instance",
"from",
"settings"
] | 0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00 | https://github.com/Flowpack/Flowpack.SingleSignOn.Client/blob/0512b66bba7cf31fd03c9608a1e4c67a7c1c0e00/Classes/Flowpack/SingleSignOn/Client/Domain/Factory/SsoClientFactory.php#L51-L62 | train |
novuso/common | src/Domain/Type/StringObject.php | StringObject.delimitString | private static function delimitString(string $string, string $delimiter): string
{
$output = [];
if (preg_match('/\A[a-z0-9]+\z/ui', $string) && strtoupper($string) !== $string) {
$parts = self::explodeOnCaps($string);
} else {
$parts = self::explodeOnDelims($string);
}
foreach ($parts as $part) {
$output[] = $part.$delimiter;
}
return rtrim(implode('', $output), $delimiter);
} | php | private static function delimitString(string $string, string $delimiter): string
{
$output = [];
if (preg_match('/\A[a-z0-9]+\z/ui', $string) && strtoupper($string) !== $string) {
$parts = self::explodeOnCaps($string);
} else {
$parts = self::explodeOnDelims($string);
}
foreach ($parts as $part) {
$output[] = $part.$delimiter;
}
return rtrim(implode('', $output), $delimiter);
} | [
"private",
"static",
"function",
"delimitString",
"(",
"string",
"$",
"string",
",",
"string",
"$",
"delimiter",
")",
":",
"string",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'/\\A[a-z0-9]+\\z/ui'",
",",
"$",
"string",
")",
"... | Applies delimiter formatting to a string
@param string $string The original string
@param string $delimiter The delimiter
@return string | [
"Applies",
"delimiter",
"formatting",
"to",
"a",
"string"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Type/StringObject.php#L909-L924 | train |
novuso/common | src/Domain/Type/StringObject.php | StringObject.explodeOnCaps | private static function explodeOnCaps(string $string): array
{
$string = preg_replace('/\B([A-Z])/', '_\1', $string);
$string = preg_replace('/([0-9]+)/', '_\1', $string);
$string = preg_replace('/_+/', '_', $string);
$string = trim($string, '_');
return explode('_', $string);
} | php | private static function explodeOnCaps(string $string): array
{
$string = preg_replace('/\B([A-Z])/', '_\1', $string);
$string = preg_replace('/([0-9]+)/', '_\1', $string);
$string = preg_replace('/_+/', '_', $string);
$string = trim($string, '_');
return explode('_', $string);
} | [
"private",
"static",
"function",
"explodeOnCaps",
"(",
"string",
"$",
"string",
")",
":",
"array",
"{",
"$",
"string",
"=",
"preg_replace",
"(",
"'/\\B([A-Z])/'",
",",
"'_\\1'",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"'/([0-... | Splits a string into a list on capital letters
@param string $string The input string
@return array | [
"Splits",
"a",
"string",
"into",
"a",
"list",
"on",
"capital",
"letters"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Type/StringObject.php#L933-L941 | train |
novuso/common | src/Domain/Type/StringObject.php | StringObject.explodeOnDelims | private static function explodeOnDelims(string $string): array
{
$string = preg_replace('/[^a-z0-9]+/i', '_', $string);
$string = trim($string, '_');
return explode('_', $string);
} | php | private static function explodeOnDelims(string $string): array
{
$string = preg_replace('/[^a-z0-9]+/i', '_', $string);
$string = trim($string, '_');
return explode('_', $string);
} | [
"private",
"static",
"function",
"explodeOnDelims",
"(",
"string",
"$",
"string",
")",
":",
"array",
"{",
"$",
"string",
"=",
"preg_replace",
"(",
"'/[^a-z0-9]+/i'",
",",
"'_'",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"trim",
"(",
"$",
"string"... | Splits a string into a list on non-word breaks
@param string $string The input string
@return array | [
"Splits",
"a",
"string",
"into",
"a",
"list",
"on",
"non",
"-",
"word",
"breaks"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Type/StringObject.php#L950-L956 | train |
gibboncms/gibbon | src/Modules/ModuleBag.php | ModuleBag.get | public function get($key = null)
{
if ($key === null) {
return $this;
}
if (!isset($this->modules[$key])) {
throw new ModuleDoesntExistException($key);
}
return $this->modules[$key];
} | php | public function get($key = null)
{
if ($key === null) {
return $this;
}
if (!isset($this->modules[$key])) {
throw new ModuleDoesntExistException($key);
}
return $this->modules[$key];
} | [
"public",
"function",
"get",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modules",
"[",
"$",
"key",
"]",
")",
")",
... | Retrieve a registered module
@param string|null $key
@return \GibbonCms\Gibbon\Modules\Module|self | [
"Retrieve",
"a",
"registered",
"module"
] | 2905e90b2902149b3358b385264e98b97cf4fc00 | https://github.com/gibboncms/gibbon/blob/2905e90b2902149b3358b385264e98b97cf4fc00/src/Modules/ModuleBag.php#L32-L43 | train |
JumpGateio/Menu | src/JumpGate/Menu/Traits/Linkable.php | Linkable.insertMenuObject | private function insertMenuObject($slug, $callback, $object)
{
$object->slug = $this->snakeName($slug);
$object->menu = $this->getMenu();
call_user_func($callback, $object);
if (! $object->insert) {
$this->links[] = $object;
}
} | php | private function insertMenuObject($slug, $callback, $object)
{
$object->slug = $this->snakeName($slug);
$object->menu = $this->getMenu();
call_user_func($callback, $object);
if (! $object->insert) {
$this->links[] = $object;
}
} | [
"private",
"function",
"insertMenuObject",
"(",
"$",
"slug",
",",
"$",
"callback",
",",
"$",
"object",
")",
"{",
"$",
"object",
"->",
"slug",
"=",
"$",
"this",
"->",
"snakeName",
"(",
"$",
"slug",
")",
";",
"$",
"object",
"->",
"menu",
"=",
"$",
"t... | Insert an object into the menu
@param $slug
@param $callback
@param $object | [
"Insert",
"an",
"object",
"into",
"the",
"menu"
] | 53e339cc0a070e3b8a8332fe32850699663fa215 | https://github.com/JumpGateio/Menu/blob/53e339cc0a070e3b8a8332fe32850699663fa215/src/JumpGate/Menu/Traits/Linkable.php#L101-L111 | train |
lexide/reposition | src/Repository/AbstractRepository.php | AbstractRepository.configureMetadata | protected function configureMetadata()
{
$this->entityMetadata->setCollection($this->collectionName);
if (!empty($this->primaryKey)) {
$this->entityMetadata->setPrimaryKey($this->primaryKey);
}
} | php | protected function configureMetadata()
{
$this->entityMetadata->setCollection($this->collectionName);
if (!empty($this->primaryKey)) {
$this->entityMetadata->setPrimaryKey($this->primaryKey);
}
} | [
"protected",
"function",
"configureMetadata",
"(",
")",
"{",
"$",
"this",
"->",
"entityMetadata",
"->",
"setCollection",
"(",
"$",
"this",
"->",
"collectionName",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"primaryKey",
")",
")",
"{",
"$"... | Configure the metadata for the entity this repository interacts with
Override this method to set additional fields or define relationships with other entities | [
"Configure",
"the",
"metadata",
"for",
"the",
"entity",
"this",
"repository",
"interacts",
"with"
] | aa02735271f0c0ee4a3fb679093d4d3823963b3a | https://github.com/lexide/reposition/blob/aa02735271f0c0ee4a3fb679093d4d3823963b3a/src/Repository/AbstractRepository.php#L97-L103 | train |
jc21/filelist | src/jc21/FileList.php | FileList.sort | protected function sort($items, $type = self::TYPE_BOTH, $by = self::KEY_NAME, $direction = self::ASC)
{
$returnArray = array();
if (count($items) > 0) {
$tmpArray = array();
foreach($items as $key => $value) {
$tmpArray[$key] = $value[$by];
}
natcasesort($tmpArray);
if ($direction == self::DESC) {
$tmpArray = array_reverse($tmpArray, true);
}
foreach($tmpArray as $key => $value) {
$returnArray[] = $items[$key];
}
// If sorting by name, lets seperate the files from the dirs.
if ($by == self::KEY_NAME && $type == self::TYPE_BOTH) {
$files = array();
$dirs = array();
foreach ($returnArray as $value) {
if ($value[self::KEY_TYPE] == self::TYPE_FILE) {
$files[] = $value;
} elseif ($value[self::KEY_TYPE] == self::TYPE_DIR) {
$dirs[] = $value;
}
}
if ($direction == self::DESC) {
$returnArray = array_merge($files, $dirs);
} else {
$returnArray = array_merge($dirs, $files);
}
}
}
return $returnArray;
} | php | protected function sort($items, $type = self::TYPE_BOTH, $by = self::KEY_NAME, $direction = self::ASC)
{
$returnArray = array();
if (count($items) > 0) {
$tmpArray = array();
foreach($items as $key => $value) {
$tmpArray[$key] = $value[$by];
}
natcasesort($tmpArray);
if ($direction == self::DESC) {
$tmpArray = array_reverse($tmpArray, true);
}
foreach($tmpArray as $key => $value) {
$returnArray[] = $items[$key];
}
// If sorting by name, lets seperate the files from the dirs.
if ($by == self::KEY_NAME && $type == self::TYPE_BOTH) {
$files = array();
$dirs = array();
foreach ($returnArray as $value) {
if ($value[self::KEY_TYPE] == self::TYPE_FILE) {
$files[] = $value;
} elseif ($value[self::KEY_TYPE] == self::TYPE_DIR) {
$dirs[] = $value;
}
}
if ($direction == self::DESC) {
$returnArray = array_merge($files, $dirs);
} else {
$returnArray = array_merge($dirs, $files);
}
}
}
return $returnArray;
} | [
"protected",
"function",
"sort",
"(",
"$",
"items",
",",
"$",
"type",
"=",
"self",
"::",
"TYPE_BOTH",
",",
"$",
"by",
"=",
"self",
"::",
"KEY_NAME",
",",
"$",
"direction",
"=",
"self",
"::",
"ASC",
")",
"{",
"$",
"returnArray",
"=",
"array",
"(",
"... | Order the results of a directory listing
@param array $items
@param string $type
@param string $by
@param string $direction
@return array | [
"Order",
"the",
"results",
"of",
"a",
"directory",
"listing"
] | 240c4c20e5ec584e7c5f35305cdec3f95fd48ffc | https://github.com/jc21/filelist/blob/240c4c20e5ec584e7c5f35305cdec3f95fd48ffc/src/jc21/FileList.php#L76-L116 | train |
jc21/filelist | src/jc21/FileList.php | FileList.get | public function get($directory, $type = self::TYPE_BOTH, $order = self::KEY_NAME, $direction = self::ASC, $limit = null, $fileExtensions = array()) {
// Get the contents of the dir
$items = array();
$directory = rtrim($directory,'/');
// Check Dir
if (!is_dir($directory)) {
throw new \Exception('Directory does not exist: ' . $directory);
}
// Get Raw Listing
$directoryHandle = opendir($directory);
while (false !== ($file = readdir($directoryHandle))) {
// skip anything that starts with a '.' i.e.:('.', '..', or any hidden file)
if (substr($file, 0, 1) != '.') {
// Directories
if (is_dir($directory . '/' . $file) && ($type == self::TYPE_BOTH || $type == self::TYPE_DIR)) {
$items[] = array(
self::KEY_TYPE => self::TYPE_DIR,
self::KEY_NAME => $file,
self::KEY_DATE => filemtime($directory.'/'.$file),
self::KEY_SIZE => filesize($directory.'/'.$file),
self::KEY_EXT => ''
);
// Files
} else if (is_file($directory.'/'.$file) && ($type == self::TYPE_BOTH || $type == self::TYPE_FILE)) {
if (!count($fileExtensions) || in_array(self::getExtension($file), $fileExtensions)) {
$items[] = array(
self::KEY_TYPE => self::TYPE_FILE,
self::KEY_NAME => $file,
self::KEY_DATE => filemtime($directory.'/'.$file),
self::KEY_SIZE => filesize($directory.'/'.$file),
self::KEY_EXT => self::getExtension($file)
);
}
}
}
// Impose Limit, if specified
if ($limit && count($items) >= $limit) {
break;
}
}
closedir($directoryHandle);
// Sorting
$items = $this->sort($items, $type, $order, $direction);
// Callbacks
if ($this->filterCallback) {
$items = call_user_func($this->filterCallback, $items);
}
// Total Size
$totalSize = 0;
foreach ($items as $item) {
$totalSize += $item[self::KEY_SIZE];
}
$this->lastSize = $totalSize;
$this->lastItemCount = count($items);
return $items;
} | php | public function get($directory, $type = self::TYPE_BOTH, $order = self::KEY_NAME, $direction = self::ASC, $limit = null, $fileExtensions = array()) {
// Get the contents of the dir
$items = array();
$directory = rtrim($directory,'/');
// Check Dir
if (!is_dir($directory)) {
throw new \Exception('Directory does not exist: ' . $directory);
}
// Get Raw Listing
$directoryHandle = opendir($directory);
while (false !== ($file = readdir($directoryHandle))) {
// skip anything that starts with a '.' i.e.:('.', '..', or any hidden file)
if (substr($file, 0, 1) != '.') {
// Directories
if (is_dir($directory . '/' . $file) && ($type == self::TYPE_BOTH || $type == self::TYPE_DIR)) {
$items[] = array(
self::KEY_TYPE => self::TYPE_DIR,
self::KEY_NAME => $file,
self::KEY_DATE => filemtime($directory.'/'.$file),
self::KEY_SIZE => filesize($directory.'/'.$file),
self::KEY_EXT => ''
);
// Files
} else if (is_file($directory.'/'.$file) && ($type == self::TYPE_BOTH || $type == self::TYPE_FILE)) {
if (!count($fileExtensions) || in_array(self::getExtension($file), $fileExtensions)) {
$items[] = array(
self::KEY_TYPE => self::TYPE_FILE,
self::KEY_NAME => $file,
self::KEY_DATE => filemtime($directory.'/'.$file),
self::KEY_SIZE => filesize($directory.'/'.$file),
self::KEY_EXT => self::getExtension($file)
);
}
}
}
// Impose Limit, if specified
if ($limit && count($items) >= $limit) {
break;
}
}
closedir($directoryHandle);
// Sorting
$items = $this->sort($items, $type, $order, $direction);
// Callbacks
if ($this->filterCallback) {
$items = call_user_func($this->filterCallback, $items);
}
// Total Size
$totalSize = 0;
foreach ($items as $item) {
$totalSize += $item[self::KEY_SIZE];
}
$this->lastSize = $totalSize;
$this->lastItemCount = count($items);
return $items;
} | [
"public",
"function",
"get",
"(",
"$",
"directory",
",",
"$",
"type",
"=",
"self",
"::",
"TYPE_BOTH",
",",
"$",
"order",
"=",
"self",
"::",
"KEY_NAME",
",",
"$",
"direction",
"=",
"self",
"::",
"ASC",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"file... | Return the listing of a directory
@param string $directory
@param string $type
@param string $order
@param string $direction
@param int $limit
@param array $fileExtensions
@return array
@throws \Exception | [
"Return",
"the",
"listing",
"of",
"a",
"directory"
] | 240c4c20e5ec584e7c5f35305cdec3f95fd48ffc | https://github.com/jc21/filelist/blob/240c4c20e5ec584e7c5f35305cdec3f95fd48ffc/src/jc21/FileList.php#L131-L196 | train |
jc21/filelist | src/jc21/FileList.php | FileList.getExtension | protected function getExtension($file)
{
if (strpos($file, '.') !== false) {
$tempExt = strtolower(substr($file, strrpos($file, '.') + 1, strlen($file) - strrpos($file, '.')));
return strtolower(trim($tempExt,'/'));
}
return '';
} | php | protected function getExtension($file)
{
if (strpos($file, '.') !== false) {
$tempExt = strtolower(substr($file, strrpos($file, '.') + 1, strlen($file) - strrpos($file, '.')));
return strtolower(trim($tempExt,'/'));
}
return '';
} | [
"protected",
"function",
"getExtension",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"file",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"tempExt",
"=",
"strtolower",
"(",
"substr",
"(",
"$",
"file",
",",
"strrpos",
"(",
"$",
"fi... | Returns the extension of a file, lowercase
@param string $file
@return string | [
"Returns",
"the",
"extension",
"of",
"a",
"file",
"lowercase"
] | 240c4c20e5ec584e7c5f35305cdec3f95fd48ffc | https://github.com/jc21/filelist/blob/240c4c20e5ec584e7c5f35305cdec3f95fd48ffc/src/jc21/FileList.php#L205-L212 | train |
cubiclab/project-cube | controllers/SriController.php | SriController.actionTaskstatusindex | public function actionTaskstatusindex()
{
$searchModel = new SRITaskstatusSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('taskstatus_index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
} | php | public function actionTaskstatusindex()
{
$searchModel = new SRITaskstatusSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('taskstatus_index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
} | [
"public",
"function",
"actionTaskstatusindex",
"(",
")",
"{",
"$",
"searchModel",
"=",
"new",
"SRITaskstatusSearch",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"queryParam... | Lists all SRITaskstatus models.
@return mixed | [
"Lists",
"all",
"SRITaskstatus",
"models",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/SriController.php#L38-L47 | train |
cubiclab/project-cube | controllers/SriController.php | SriController.actionTaskstatuscreate | public function actionTaskstatuscreate()
{
$model = new SRI_Taskstatus();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['taskstatusview', 'id' => $model->id]);
} else {
return $this->render('taskstatus_create', [
'model' => $model,
]);
}
} | php | public function actionTaskstatuscreate()
{
$model = new SRI_Taskstatus();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['taskstatusview', 'id' => $model->id]);
} else {
return $this->render('taskstatus_create', [
'model' => $model,
]);
}
} | [
"public",
"function",
"actionTaskstatuscreate",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"SRI_Taskstatus",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
... | Creates a new SRITaskstatus model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed | [
"Creates",
"a",
"new",
"SRITaskstatus",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/SriController.php#L66-L77 | train |
cubiclab/project-cube | controllers/SriController.php | SriController.actionTaskstatusupdate | public function actionTaskstatusupdate($id)
{
$model = $this->findTaskstatusmodel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['taskstatusview', 'id' => $model->id]);
} else {
return $this->render('taskstatus_update', [
'model' => $model,
]);
}
} | php | public function actionTaskstatusupdate($id)
{
$model = $this->findTaskstatusmodel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['taskstatusview', 'id' => $model->id]);
} else {
return $this->render('taskstatus_update', [
'model' => $model,
]);
}
} | [
"public",
"function",
"actionTaskstatusupdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findTaskstatusmodel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->... | Updates an existing SRITaskstatus model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed | [
"Updates",
"an",
"existing",
"SRITaskstatus",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/SriController.php#L85-L96 | train |
easy-system/es-http | src/Uploading/UploadTarget.php | UploadTarget.set | public function set($target)
{
if (! is_string($target) || empty($target)) {
throw new InvalidArgumentException(
'Invalid target provided. Must be an non-empty string.'
);
}
$this->target = $target;
} | php | public function set($target)
{
if (! is_string($target) || empty($target)) {
throw new InvalidArgumentException(
'Invalid target provided. Must be an non-empty string.'
);
}
$this->target = $target;
} | [
"public",
"function",
"set",
"(",
"$",
"target",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"target",
")",
"||",
"empty",
"(",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid target provided. Must be an non-empty ... | Sets the target of upload.
@param string $target The target of upload
@throws \InvalidArgumentException If the target is not string or empty string | [
"Sets",
"the",
"target",
"of",
"upload",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/UploadTarget.php#L43-L51 | train |
Briareos/mongodb-odm | lib/Doctrine/ODM/MongoDB/Query/Expr.php | Expr.references | public function references($document)
{
if ($this->currentField) {
$mapping = $this->class->getFieldMapping($this->currentField);
$dbRef = $this->dm->createDBRef($document, $mapping);
if (isset($mapping['simple']) && $mapping['simple']) {
$this->query[$mapping['name']] = $dbRef;
} else {
$keys = array('ref' => true, 'id' => true, 'db' => true);
if (isset($mapping['targetDocument'])) {
unset($keys['ref'], $keys['db']);
}
foreach ($keys as $key => $value) {
$this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key];
}
}
} else {
$dbRef = $this->dm->createDBRef($document);
$this->query = $dbRef;
}
return $this;
} | php | public function references($document)
{
if ($this->currentField) {
$mapping = $this->class->getFieldMapping($this->currentField);
$dbRef = $this->dm->createDBRef($document, $mapping);
if (isset($mapping['simple']) && $mapping['simple']) {
$this->query[$mapping['name']] = $dbRef;
} else {
$keys = array('ref' => true, 'id' => true, 'db' => true);
if (isset($mapping['targetDocument'])) {
unset($keys['ref'], $keys['db']);
}
foreach ($keys as $key => $value) {
$this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key];
}
}
} else {
$dbRef = $this->dm->createDBRef($document);
$this->query = $dbRef;
}
return $this;
} | [
"public",
"function",
"references",
"(",
"$",
"document",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentField",
")",
"{",
"$",
"mapping",
"=",
"$",
"this",
"->",
"class",
"->",
"getFieldMapping",
"(",
"$",
"this",
"->",
"currentField",
")",
";",
"$",... | Checks that the value of the current field is a reference to the supplied document. | [
"Checks",
"that",
"the",
"value",
"of",
"the",
"current",
"field",
"is",
"a",
"reference",
"to",
"the",
"supplied",
"document",
"."
] | 29e28bed9a265efd7d05473b0a909fb7c83f76e0 | https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Query/Expr.php#L60-L85 | train |
northern/PHP-Common | src/Northern/Common/Util/ObjectUtil.php | ObjectUtil.apply | public static function apply($object, array $values)
{
foreach ($values as $property => $value) {
// Check if the value is a map (associative array) by checking for
// a zero index.
if (is_array($value) and ! isset($value[0])) {
$method = "get".ucfirst($property);
if (method_exists($object, $method)) {
//$object->{$method}()->apply( $value );
static::apply($object->{$method}(), $value);
}
} elseif (is_array($value) and isset($value[0])) {
// Check if the value is a collection, i.e. an indexed array. If this
// is the case then the $value is an interable array. If the object
// has an "add" method for the property then we call this x times.
$method = "add".ucfirst($property);
if (method_exists($object, $method)) {
foreach ($value as $arguments) {
if (! is_array($arguments)) {
$arguments = array( $arguments );
}
call_user_func_array(array( $object, $method ), $arguments);
}
}
} else {
// Check if the value has a corresponding setter method
// on the object.
$method = "set".ucfirst($property);
if (method_exists($object, $method)) {
$object->{$method}($value);
}
}
}
} | php | public static function apply($object, array $values)
{
foreach ($values as $property => $value) {
// Check if the value is a map (associative array) by checking for
// a zero index.
if (is_array($value) and ! isset($value[0])) {
$method = "get".ucfirst($property);
if (method_exists($object, $method)) {
//$object->{$method}()->apply( $value );
static::apply($object->{$method}(), $value);
}
} elseif (is_array($value) and isset($value[0])) {
// Check if the value is a collection, i.e. an indexed array. If this
// is the case then the $value is an interable array. If the object
// has an "add" method for the property then we call this x times.
$method = "add".ucfirst($property);
if (method_exists($object, $method)) {
foreach ($value as $arguments) {
if (! is_array($arguments)) {
$arguments = array( $arguments );
}
call_user_func_array(array( $object, $method ), $arguments);
}
}
} else {
// Check if the value has a corresponding setter method
// on the object.
$method = "set".ucfirst($property);
if (method_exists($object, $method)) {
$object->{$method}($value);
}
}
}
} | [
"public",
"static",
"function",
"apply",
"(",
"$",
"object",
",",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"// Check if the value is a map (associative array) by checking for",
"// a zero... | This method applies a given set of values to a given object.
The array with values supplied must be actual values of the
object and must be exposed through a corresponding setter method.
E.g. if you wish to set the value on a property called 'firstname'
then the object needs to have a 'setFirstname' setter method. If
the setter is not available the property will not be set and the
corresponding value will not be applied.
@param object $object
@param array $values | [
"This",
"method",
"applies",
"a",
"given",
"set",
"of",
"values",
"to",
"a",
"given",
"object",
"."
] | 7c63ef19252fd540fb412a18af956b8563afaa55 | https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ObjectUtil.php#L98-L135 | train |
northern/PHP-Common | src/Northern/Common/Util/ObjectUtil.php | ObjectUtil.validate | public static function validate($object, array $values, array $constraints)
{
$errors = array();
// Build a validator and get the entity constraints from the
// entity object.
$validatorBuilder = new ValidatorBuilder();
$validator = $validatorBuilder->getValidator();
// Loop through all the passed in values. Each $value represents a
// value of a $property on the object.
foreach ($values as $property => $value) {
// Check if we have contraints for this property. If not, test next property.
if (! isset($constraints[ $property ])) {
continue;
}
// Check if the $value is a map (i.e. an array without a zero index). If so,
// then we're dealing with a complex object into which we need to recurse into.
if (is_array($value) and ! isset($value[0])) {
// We're going to recurise into the sub-object but to get access to it we
// need to construct it's "getter" method.
$method = "get".ucfirst($property);
// Check if the "getter" method exists on the and the property exists in the
// constraints before calling it. If either doesn't exist we fail silently
// and skip to the next property.
if (method_exists($object, $method) and array_key_exists($property, $constraints)) {
// The method exists so we can recurse into it. The $value represents an
// array of property/value pairs that must be set on the sub-object.
$results = static::validate($object->{$method}(), $value, $constraints[ $property ]);
// The $results represent the errors that were caused by the validation
// of the sub-entity. If we have errors, then apply them to the error
// object.
if (! empty($results)) {
$errors[ $property ] = $results;
}
}
} else {
// We're dealing with a simple property. The $value represents the new
// value that the property must be set to and we grab the contraints
// based on the property name.
$results = $validator->validateValue($value, $constraints[ $property ]);
// A property can have many constraints. E.g. an email address must be
// a valid email address and cannot be blank. This means that the validation
// can return multiple errors for a single field. Here we add each individual
// error for the validated property.
if ($results->count() > 0) {
foreach ($results as $result) {
$errors[ $property ][] = $result->getMessage();
}
}
}
}
return $errors;
} | php | public static function validate($object, array $values, array $constraints)
{
$errors = array();
// Build a validator and get the entity constraints from the
// entity object.
$validatorBuilder = new ValidatorBuilder();
$validator = $validatorBuilder->getValidator();
// Loop through all the passed in values. Each $value represents a
// value of a $property on the object.
foreach ($values as $property => $value) {
// Check if we have contraints for this property. If not, test next property.
if (! isset($constraints[ $property ])) {
continue;
}
// Check if the $value is a map (i.e. an array without a zero index). If so,
// then we're dealing with a complex object into which we need to recurse into.
if (is_array($value) and ! isset($value[0])) {
// We're going to recurise into the sub-object but to get access to it we
// need to construct it's "getter" method.
$method = "get".ucfirst($property);
// Check if the "getter" method exists on the and the property exists in the
// constraints before calling it. If either doesn't exist we fail silently
// and skip to the next property.
if (method_exists($object, $method) and array_key_exists($property, $constraints)) {
// The method exists so we can recurse into it. The $value represents an
// array of property/value pairs that must be set on the sub-object.
$results = static::validate($object->{$method}(), $value, $constraints[ $property ]);
// The $results represent the errors that were caused by the validation
// of the sub-entity. If we have errors, then apply them to the error
// object.
if (! empty($results)) {
$errors[ $property ] = $results;
}
}
} else {
// We're dealing with a simple property. The $value represents the new
// value that the property must be set to and we grab the contraints
// based on the property name.
$results = $validator->validateValue($value, $constraints[ $property ]);
// A property can have many constraints. E.g. an email address must be
// a valid email address and cannot be blank. This means that the validation
// can return multiple errors for a single field. Here we add each individual
// error for the validated property.
if ($results->count() > 0) {
foreach ($results as $result) {
$errors[ $property ][] = $result->getMessage();
}
}
}
}
return $errors;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"object",
",",
"array",
"$",
"values",
",",
"array",
"$",
"constraints",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"// Build a validator and get the entity constraints from the",
"// entity object.",
... | This method will validate an object with the specified values.
If any of the values does not validate an array with errors will
be returned. The error message will be generated by the constraints
which are defined in the entity getConstraints method.
@param array $values
@throws \Btq\Core\Exception\MethodDoesNotExistException
@return array | [
"This",
"method",
"will",
"validate",
"an",
"object",
"with",
"the",
"specified",
"values",
"."
] | 7c63ef19252fd540fb412a18af956b8563afaa55 | https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ObjectUtil.php#L148-L206 | train |
jhorlima/wp-mocabonita | src/tools/MbResponse.php | MbResponse.redirect | public function redirect($url, array $params = [], $status = 302)
{
if (!empty($params)) {
$url = rtrim(preg_replace('/\?.*/', '', $url), '/');
$url .= "?" . http_build_query($params);
}
$this->statusCode = $status;
$this->headers->set('Location', $url);
$this->getMbAudit()->setResponseType('redirect');
$this->getMbAudit()->setResponseData([
'url' => $url,
]);
return true;
} | php | public function redirect($url, array $params = [], $status = 302)
{
if (!empty($params)) {
$url = rtrim(preg_replace('/\?.*/', '', $url), '/');
$url .= "?" . http_build_query($params);
}
$this->statusCode = $status;
$this->headers->set('Location', $url);
$this->getMbAudit()->setResponseType('redirect');
$this->getMbAudit()->setResponseData([
'url' => $url,
]);
return true;
} | [
"public",
"function",
"redirect",
"(",
"$",
"url",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"status",
"=",
"302",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"$",
"url",
"=",
"rtrim",
"(",
"preg_replace",
... | Redirect a page
@param string $url
@param array $params
@param int $status
@return bool | [
"Redirect",
"a",
"page"
] | a864b40d5452bc9b892f02a6bb28c02639f25fa8 | https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L175-L191 | train |
jhorlima/wp-mocabonita | src/tools/MbResponse.php | MbResponse.ajaxContent | protected function ajaxContent($content)
{
$message = null;
$this->header('Content-Type', 'application/json');
if ($content instanceof Arrayable) {
$content = $content->toArray();
} elseif (is_string($content)) {
$content = ['content' => $content];
} elseif (!is_array($content) && !$content instanceof \Exception) {
return $this->ajaxContent(new \Exception("No valid content has been submitted!", BaseResponse::HTTP_BAD_REQUEST));
} elseif ($content instanceof \Exception) {
$this->setStatusCode($content->getCode() < 300 ? BaseResponse::HTTP_BAD_REQUEST : $content->getCode());
$message = $content->getMessage();
if ($content instanceof MbException) {
$content = $content->getMessages();
} else {
$content = null;
}
}
$this->original = [
'meta' => [
'code' => $this->getStatusCode(),
'message' => $message,
],
'data' => $content,
];
$this->getMbAudit()->setResponseType('ajax');
$this->getMbAudit()->setResponseData($this->original);
return $this->original;
} | php | protected function ajaxContent($content)
{
$message = null;
$this->header('Content-Type', 'application/json');
if ($content instanceof Arrayable) {
$content = $content->toArray();
} elseif (is_string($content)) {
$content = ['content' => $content];
} elseif (!is_array($content) && !$content instanceof \Exception) {
return $this->ajaxContent(new \Exception("No valid content has been submitted!", BaseResponse::HTTP_BAD_REQUEST));
} elseif ($content instanceof \Exception) {
$this->setStatusCode($content->getCode() < 300 ? BaseResponse::HTTP_BAD_REQUEST : $content->getCode());
$message = $content->getMessage();
if ($content instanceof MbException) {
$content = $content->getMessages();
} else {
$content = null;
}
}
$this->original = [
'meta' => [
'code' => $this->getStatusCode(),
'message' => $message,
],
'data' => $content,
];
$this->getMbAudit()->setResponseType('ajax');
$this->getMbAudit()->setResponseData($this->original);
return $this->original;
} | [
"protected",
"function",
"ajaxContent",
"(",
"$",
"content",
")",
"{",
"$",
"message",
"=",
"null",
";",
"$",
"this",
"->",
"header",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"if",
"(",
"$",
"content",
"instanceof",
"Arrayable",
")",
"{"... | Format content for json output
@param array|\Exception $content
@return array[] | [
"Format",
"content",
"for",
"json",
"output"
] | a864b40d5452bc9b892f02a6bb28c02639f25fa8 | https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L200-L237 | train |
jhorlima/wp-mocabonita | src/tools/MbResponse.php | MbResponse.htmlContent | protected function htmlContent($content)
{
try {
$this->getMbAudit()->setResponseType('html');
if ($content instanceof \Exception) {
throw $content;
} elseif ($content instanceof \SplFileInfo && !$this->getMbRequest()->isBlogAdmin()) {
$this->downloadFile($content);
} elseif (!is_string($content) && !$content instanceof Renderable) {
$this->getMbAudit()->setResponseType('debug');
$this->getMbAudit()->setResponseData($content);
ob_start();
(new Dumper)->dump($content);
$this->original = ob_get_contents();
ob_end_clean();
} else {
$this->getMbAudit()->setResponseData($content);
$this->original = $content;
}
parent::setContent($this->original);
} catch (\Exception $e) {
$this->getMbAudit()->setResponseData($e->getMessage());
if ($this->getMbRequest()->isBlogAdmin()) {
$this->adminNotice($e->getMessage(), 'error');
} else {
$this->original = "<strong>Erro:</strong> {$e->getMessage()}<br>";
}
parent::setContent($this->original);
}
} | php | protected function htmlContent($content)
{
try {
$this->getMbAudit()->setResponseType('html');
if ($content instanceof \Exception) {
throw $content;
} elseif ($content instanceof \SplFileInfo && !$this->getMbRequest()->isBlogAdmin()) {
$this->downloadFile($content);
} elseif (!is_string($content) && !$content instanceof Renderable) {
$this->getMbAudit()->setResponseType('debug');
$this->getMbAudit()->setResponseData($content);
ob_start();
(new Dumper)->dump($content);
$this->original = ob_get_contents();
ob_end_clean();
} else {
$this->getMbAudit()->setResponseData($content);
$this->original = $content;
}
parent::setContent($this->original);
} catch (\Exception $e) {
$this->getMbAudit()->setResponseData($e->getMessage());
if ($this->getMbRequest()->isBlogAdmin()) {
$this->adminNotice($e->getMessage(), 'error');
} else {
$this->original = "<strong>Erro:</strong> {$e->getMessage()}<br>";
}
parent::setContent($this->original);
}
} | [
"protected",
"function",
"htmlContent",
"(",
"$",
"content",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getMbAudit",
"(",
")",
"->",
"setResponseType",
"(",
"'html'",
")",
";",
"if",
"(",
"$",
"content",
"instanceof",
"\\",
"Exception",
")",
"{",
"throw",... | Format content for html output
@param $content
@return void | [
"Format",
"content",
"for",
"html",
"output"
] | a864b40d5452bc9b892f02a6bb28c02639f25fa8 | https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L246-L291 | train |
jhorlima/wp-mocabonita | src/tools/MbResponse.php | MbResponse.adminNotice | public function adminNotice($message, $type = 'success')
{
MbWPActionHook::addActionCallback('admin_notices', function () use ($message, $type) {
echo self::adminNoticeTemplate($message, $type);
});
} | php | public function adminNotice($message, $type = 'success')
{
MbWPActionHook::addActionCallback('admin_notices', function () use ($message, $type) {
echo self::adminNoticeTemplate($message, $type);
});
} | [
"public",
"function",
"adminNotice",
"(",
"$",
"message",
",",
"$",
"type",
"=",
"'success'",
")",
"{",
"MbWPActionHook",
"::",
"addActionCallback",
"(",
"'admin_notices'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"message",
",",
"$",
"type",
")",
"{",
... | Post an admin notice on the dashboard
@param string $message
@param string $type | [
"Post",
"an",
"admin",
"notice",
"on",
"the",
"dashboard"
] | a864b40d5452bc9b892f02a6bb28c02639f25fa8 | https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbResponse.php#L372-L377 | train |
ronanchilvers/silex-spot2-provider | src/Provider/Spot2ServiceProvider.php | Spot2ServiceProvider.register | public function register(Container $container)
{
$container['spot2.connections'] = [];
$container['spot2.connections.default'] = null;
$container['spot2.config'] = function (Container $container) {
$config = new Config();
foreach ($container['spot2.connections'] as $name => $data) {
$default = ($container['spot2.connections.default'] === $name) ? true : false ;
$config->addConnection($name, $data, $default);
}
return $config;
};
$container['spot2.locator'] = function (Container $container) {
return new Locator($container['spot2.config']);
};
} | php | public function register(Container $container)
{
$container['spot2.connections'] = [];
$container['spot2.connections.default'] = null;
$container['spot2.config'] = function (Container $container) {
$config = new Config();
foreach ($container['spot2.connections'] as $name => $data) {
$default = ($container['spot2.connections.default'] === $name) ? true : false ;
$config->addConnection($name, $data, $default);
}
return $config;
};
$container['spot2.locator'] = function (Container $container) {
return new Locator($container['spot2.config']);
};
} | [
"public",
"function",
"register",
"(",
"Container",
"$",
"container",
")",
"{",
"$",
"container",
"[",
"'spot2.connections'",
"]",
"=",
"[",
"]",
";",
"$",
"container",
"[",
"'spot2.connections.default'",
"]",
"=",
"null",
";",
"$",
"container",
"[",
"'spot2... | Register this provider.
The spot2.connections array can have an arbitrary number of connections in
it. The array should use the following format:
<code>
$connections = [
'my_sqlite' => 'sqlite://path/to/my_database.sqlite',
'my_sqlite' => [
'dbname' => 'my_database',
'user' => 'username',
'password' => 'sshhh-secret',
'host' => 'localhost',
'drivers' => 'pdo_mysql'
]
];
</code>
@param Pimple\Container $container
@author Ronan Chilvers <ronan@d3r.com> | [
"Register",
"this",
"provider",
"."
] | 9b13856d9560f13604ad885ee4c94e374d5e3635 | https://github.com/ronanchilvers/silex-spot2-provider/blob/9b13856d9560f13604ad885ee4c94e374d5e3635/src/Provider/Spot2ServiceProvider.php#L45-L61 | train |
setrun/setrun-component-sys | src/controllers/backend/LanguageController.php | LanguageController.actionEdit | public function actionEdit($id)
{
$model = $this->findModel($id);
$form = new LanguageForm($model);
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())){
if (!$errors = ActiveForm::validate($form)) {
try {
$this->service->edit($form->id, $form);
$this->output['status'] = 1;
} catch (YiiException $e) {
$errors = ErrorHelper::checkModel($e->data, $form);
}
}
return $this->output['errors'] = $errors;
}
return $this->render('edit', ['model' => $form]);
} | php | public function actionEdit($id)
{
$model = $this->findModel($id);
$form = new LanguageForm($model);
if (Yii::$app->request->isAjax && $form->load(Yii::$app->request->post())){
if (!$errors = ActiveForm::validate($form)) {
try {
$this->service->edit($form->id, $form);
$this->output['status'] = 1;
} catch (YiiException $e) {
$errors = ErrorHelper::checkModel($e->data, $form);
}
}
return $this->output['errors'] = $errors;
}
return $this->render('edit', ['model' => $form]);
} | [
"public",
"function",
"actionEdit",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"form",
"=",
"new",
"LanguageForm",
"(",
"$",
"model",
")",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
... | Edites an existing Language model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed | [
"Edites",
"an",
"existing",
"Language",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | ad9a6442a2921e0f061ed4e455b050c56029d565 | https://github.com/setrun/setrun-component-sys/blob/ad9a6442a2921e0f061ed4e455b050c56029d565/src/controllers/backend/LanguageController.php#L96-L112 | train |
n0m4dz/laracasa | Zend/Gdata/AuthSub.php | Zend_Gdata_AuthSub.getAuthSubTokenUri | public static function getAuthSubTokenUri($next, $scope, $secure=0, $session=0,
$request_uri = self::AUTHSUB_REQUEST_URI)
{
$querystring = '?next=' . urlencode($next)
. '&scope=' . urldecode($scope)
. '&secure=' . urlencode($secure)
. '&session=' . urlencode($session);
return $request_uri . $querystring;
} | php | public static function getAuthSubTokenUri($next, $scope, $secure=0, $session=0,
$request_uri = self::AUTHSUB_REQUEST_URI)
{
$querystring = '?next=' . urlencode($next)
. '&scope=' . urldecode($scope)
. '&secure=' . urlencode($secure)
. '&session=' . urlencode($session);
return $request_uri . $querystring;
} | [
"public",
"static",
"function",
"getAuthSubTokenUri",
"(",
"$",
"next",
",",
"$",
"scope",
",",
"$",
"secure",
"=",
"0",
",",
"$",
"session",
"=",
"0",
",",
"$",
"request_uri",
"=",
"self",
"::",
"AUTHSUB_REQUEST_URI",
")",
"{",
"$",
"querystring",
"=",
... | Creates a URI to request a single-use AuthSub token.
@param string $next (required) URL identifying the service to be
accessed.
The resulting token will enable access to the specified service only.
Some services may limit scope further, such as read-only access.
@param string $scope (required) URL identifying the service to be
accessed. The resulting token will enable
access to the specified service only.
Some services may limit scope further, such
as read-only access.
@param int $secure (optional) Boolean flag indicating whether the
authentication transaction should issue a secure
token (1) or a non-secure token (0). Secure tokens
are available to registered applications only.
@param int $session (optional) Boolean flag indicating whether
the one-time-use token may be exchanged for
a session token (1) or not (0).
@param string $request_uri (optional) URI to which to direct the
authentication request. | [
"Creates",
"a",
"URI",
"to",
"request",
"a",
"single",
"-",
"use",
"AuthSub",
"token",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L79-L87 | train |
n0m4dz/laracasa | Zend/Gdata/AuthSub.php | Zend_Gdata_AuthSub.getAuthSubSessionToken | public static function getAuthSubSessionToken(
$token, $client = null,
$request_uri = self::AUTHSUB_SESSION_TOKEN_URI)
{
$client = self::getHttpClient($token, $client);
if ($client instanceof Zend_Gdata_HttpClient) {
$filterResult = $client->filterHttpRequest('GET', $request_uri);
$url = $filterResult['url'];
$headers = $filterResult['headers'];
$client->setHeaders($headers);
$client->setUri($url);
} else {
$client->setUri($request_uri);
}
try {
$response = $client->request('GET');
} catch (Zend_Http_Client_Exception $e) {
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
}
// Parse Google's response
if ($response->isSuccessful()) {
$goog_resp = array();
foreach (explode("\n", $response->getBody()) as $l) {
$l = chop($l);
if ($l) {
list($key, $val) = explode('=', chop($l), 2);
$goog_resp[$key] = $val;
}
}
return $goog_resp['Token'];
} else {
require_once 'Zend/Gdata/App/AuthException.php';
throw new Zend_Gdata_App_AuthException(
'Token upgrade failed. Reason: ' . $response->getBody());
}
} | php | public static function getAuthSubSessionToken(
$token, $client = null,
$request_uri = self::AUTHSUB_SESSION_TOKEN_URI)
{
$client = self::getHttpClient($token, $client);
if ($client instanceof Zend_Gdata_HttpClient) {
$filterResult = $client->filterHttpRequest('GET', $request_uri);
$url = $filterResult['url'];
$headers = $filterResult['headers'];
$client->setHeaders($headers);
$client->setUri($url);
} else {
$client->setUri($request_uri);
}
try {
$response = $client->request('GET');
} catch (Zend_Http_Client_Exception $e) {
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
}
// Parse Google's response
if ($response->isSuccessful()) {
$goog_resp = array();
foreach (explode("\n", $response->getBody()) as $l) {
$l = chop($l);
if ($l) {
list($key, $val) = explode('=', chop($l), 2);
$goog_resp[$key] = $val;
}
}
return $goog_resp['Token'];
} else {
require_once 'Zend/Gdata/App/AuthException.php';
throw new Zend_Gdata_App_AuthException(
'Token upgrade failed. Reason: ' . $response->getBody());
}
} | [
"public",
"static",
"function",
"getAuthSubSessionToken",
"(",
"$",
"token",
",",
"$",
"client",
"=",
"null",
",",
"$",
"request_uri",
"=",
"self",
"::",
"AUTHSUB_SESSION_TOKEN_URI",
")",
"{",
"$",
"client",
"=",
"self",
"::",
"getHttpClient",
"(",
"$",
"tok... | Upgrades a single use token to a session token
@param string $token The single use token which is to be upgraded
@param Zend_Http_Client $client (optional) HTTP client to use to
make the request
@param string $request_uri (optional) URI to which to direct
the session token upgrade
@return string The upgraded token value
@throws Zend_Gdata_App_AuthException
@throws Zend_Gdata_App_HttpException | [
"Upgrades",
"a",
"single",
"use",
"token",
"to",
"a",
"session",
"token"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L102-L141 | train |
n0m4dz/laracasa | Zend/Gdata/AuthSub.php | Zend_Gdata_AuthSub.AuthSubRevokeToken | public static function AuthSubRevokeToken($token, $client = null,
$request_uri = self::AUTHSUB_REVOKE_TOKEN_URI)
{
$client = self::getHttpClient($token, $client);
if ($client instanceof Zend_Gdata_HttpClient) {
$filterResult = $client->filterHttpRequest('GET', $request_uri);
$url = $filterResult['url'];
$headers = $filterResult['headers'];
$client->setHeaders($headers);
$client->setUri($url);
$client->resetParameters();
} else {
$client->setUri($request_uri);
}
ob_start();
try {
$response = $client->request('GET');
} catch (Zend_Http_Client_Exception $e) {
ob_end_clean();
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
}
ob_end_clean();
// Parse Google's response
if ($response->isSuccessful()) {
return true;
} else {
return false;
}
} | php | public static function AuthSubRevokeToken($token, $client = null,
$request_uri = self::AUTHSUB_REVOKE_TOKEN_URI)
{
$client = self::getHttpClient($token, $client);
if ($client instanceof Zend_Gdata_HttpClient) {
$filterResult = $client->filterHttpRequest('GET', $request_uri);
$url = $filterResult['url'];
$headers = $filterResult['headers'];
$client->setHeaders($headers);
$client->setUri($url);
$client->resetParameters();
} else {
$client->setUri($request_uri);
}
ob_start();
try {
$response = $client->request('GET');
} catch (Zend_Http_Client_Exception $e) {
ob_end_clean();
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
}
ob_end_clean();
// Parse Google's response
if ($response->isSuccessful()) {
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"AuthSubRevokeToken",
"(",
"$",
"token",
",",
"$",
"client",
"=",
"null",
",",
"$",
"request_uri",
"=",
"self",
"::",
"AUTHSUB_REVOKE_TOKEN_URI",
")",
"{",
"$",
"client",
"=",
"self",
"::",
"getHttpClient",
"(",
"$",
"token",
... | Revoke a token
@param string $token The token to revoke
@param Zend_Http_Client $client (optional) HTTP client to use to make the request
@param string $request_uri (optional) URI to which to direct the revokation request
@return boolean Whether the revokation was successful
@throws Zend_Gdata_App_HttpException | [
"Revoke",
"a",
"token"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L152-L183 | train |
n0m4dz/laracasa | Zend/Gdata/AuthSub.php | Zend_Gdata_AuthSub.getAuthSubTokenInfo | public static function getAuthSubTokenInfo(
$token, $client = null, $request_uri = self::AUTHSUB_TOKEN_INFO_URI)
{
$client = self::getHttpClient($token, $client);
if ($client instanceof Zend_Gdata_HttpClient) {
$filterResult = $client->filterHttpRequest('GET', $request_uri);
$url = $filterResult['url'];
$headers = $filterResult['headers'];
$client->setHeaders($headers);
$client->setUri($url);
} else {
$client->setUri($request_uri);
}
ob_start();
try {
$response = $client->request('GET');
} catch (Zend_Http_Client_Exception $e) {
ob_end_clean();
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
}
ob_end_clean();
return $response->getBody();
} | php | public static function getAuthSubTokenInfo(
$token, $client = null, $request_uri = self::AUTHSUB_TOKEN_INFO_URI)
{
$client = self::getHttpClient($token, $client);
if ($client instanceof Zend_Gdata_HttpClient) {
$filterResult = $client->filterHttpRequest('GET', $request_uri);
$url = $filterResult['url'];
$headers = $filterResult['headers'];
$client->setHeaders($headers);
$client->setUri($url);
} else {
$client->setUri($request_uri);
}
ob_start();
try {
$response = $client->request('GET');
} catch (Zend_Http_Client_Exception $e) {
ob_end_clean();
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException($e->getMessage(), $e);
}
ob_end_clean();
return $response->getBody();
} | [
"public",
"static",
"function",
"getAuthSubTokenInfo",
"(",
"$",
"token",
",",
"$",
"client",
"=",
"null",
",",
"$",
"request_uri",
"=",
"self",
"::",
"AUTHSUB_TOKEN_INFO_URI",
")",
"{",
"$",
"client",
"=",
"self",
"::",
"getHttpClient",
"(",
"$",
"token",
... | get token information
@param string $token The token to retrieve information about
@param Zend_Http_Client $client (optional) HTTP client to use to
make the request
@param string $request_uri (optional) URI to which to direct
the information request | [
"get",
"token",
"information"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L195-L220 | train |
n0m4dz/laracasa | Zend/Gdata/AuthSub.php | Zend_Gdata_AuthSub.getHttpClient | public static function getHttpClient($token, $client = null)
{
if ($client == null) {
$client = new Zend_Gdata_HttpClient();
}
if (!$client instanceof Zend_Gdata_HttpClient) {
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException('Client is not an instance of Zend_Gdata_HttpClient.');
}
$useragent = 'Zend_Framework_Gdata/' . Zend_Version::VERSION;
$client->setConfig(array(
'strictredirects' => true,
'useragent' => $useragent
)
);
$client->setAuthSubToken($token);
return $client;
} | php | public static function getHttpClient($token, $client = null)
{
if ($client == null) {
$client = new Zend_Gdata_HttpClient();
}
if (!$client instanceof Zend_Gdata_HttpClient) {
require_once 'Zend/Gdata/App/HttpException.php';
throw new Zend_Gdata_App_HttpException('Client is not an instance of Zend_Gdata_HttpClient.');
}
$useragent = 'Zend_Framework_Gdata/' . Zend_Version::VERSION;
$client->setConfig(array(
'strictredirects' => true,
'useragent' => $useragent
)
);
$client->setAuthSubToken($token);
return $client;
} | [
"public",
"static",
"function",
"getHttpClient",
"(",
"$",
"token",
",",
"$",
"client",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"client",
"==",
"null",
")",
"{",
"$",
"client",
"=",
"new",
"Zend_Gdata_HttpClient",
"(",
")",
";",
"}",
"if",
"(",
"!",
... | Retrieve a HTTP client object with AuthSub credentials attached
as the Authorization header
@param string $token The token to retrieve information about
@param Zend_Gdata_HttpClient $client (optional) HTTP client to use to make the request | [
"Retrieve",
"a",
"HTTP",
"client",
"object",
"with",
"AuthSub",
"credentials",
"attached",
"as",
"the",
"Authorization",
"header"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/AuthSub.php#L229-L246 | train |
easy-system/es-dispatcher | src/Listener/DispatchesControllerListener.php | DispatchesControllerListener.onDispatch | public function onDispatch(SystemEvent $event)
{
$server = $this->getServer();
$request = $server->getRequest();
$controllerName = $request->getAttribute('controller');
if (! $controllerName) {
throw new RuntimeException(
'Unable to dispatch the system event, the server request not '
. 'contains the "controller" attribute.'
);
}
$actionName = $request->getAttribute('action', 'index');
$events = $this->getEvents();
$controllers = $this->getControllers();
$controller = $controllers->get($controllerName);
$event->setContext($controller);
$dispatchEvent = new DispatchEvent(
$controller, $controllerName, $actionName, $event->getParams()
);
$events->trigger($dispatchEvent);
$result = $dispatchEvent->getResult();
$target = SystemEvent::DISPATCH;
if ($result instanceof ResponseInterface) {
$target = SystemEvent::FINISH;
}
$event->setResult($target, $result);
} | php | public function onDispatch(SystemEvent $event)
{
$server = $this->getServer();
$request = $server->getRequest();
$controllerName = $request->getAttribute('controller');
if (! $controllerName) {
throw new RuntimeException(
'Unable to dispatch the system event, the server request not '
. 'contains the "controller" attribute.'
);
}
$actionName = $request->getAttribute('action', 'index');
$events = $this->getEvents();
$controllers = $this->getControllers();
$controller = $controllers->get($controllerName);
$event->setContext($controller);
$dispatchEvent = new DispatchEvent(
$controller, $controllerName, $actionName, $event->getParams()
);
$events->trigger($dispatchEvent);
$result = $dispatchEvent->getResult();
$target = SystemEvent::DISPATCH;
if ($result instanceof ResponseInterface) {
$target = SystemEvent::FINISH;
}
$event->setResult($target, $result);
} | [
"public",
"function",
"onDispatch",
"(",
"SystemEvent",
"$",
"event",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"getServer",
"(",
")",
";",
"$",
"request",
"=",
"$",
"server",
"->",
"getRequest",
"(",
")",
";",
"$",
"controllerName",
"=",
"$",
... | Triggers the DispatchEvent.
@param \Es\System\SystemEvent $event The system event
@throws \RuntimeException If the ServerRequest not contain the
"controller" attribute | [
"Triggers",
"the",
"DispatchEvent",
"."
] | 3a2420113c72e544e15c1500717c918e7d5d4bf8 | https://github.com/easy-system/es-dispatcher/blob/3a2420113c72e544e15c1500717c918e7d5d4bf8/src/Listener/DispatchesControllerListener.php#L35-L66 | train |
easy-system/es-dispatcher | src/Listener/DispatchesControllerListener.php | DispatchesControllerListener.doDispatch | public function doDispatch(DispatchEvent $event)
{
$controller = $event->getContext();
$action = $event->getParam('action') . 'Action';
$server = $this->getServer();
$request = $server->getRequest()->withAddedAttributes($event->getParams());
$response = $server->getResponse();
$result = call_user_func_array([$controller, $action], [$request, $response]);
$event->setResult($result);
} | php | public function doDispatch(DispatchEvent $event)
{
$controller = $event->getContext();
$action = $event->getParam('action') . 'Action';
$server = $this->getServer();
$request = $server->getRequest()->withAddedAttributes($event->getParams());
$response = $server->getResponse();
$result = call_user_func_array([$controller, $action], [$request, $response]);
$event->setResult($result);
} | [
"public",
"function",
"doDispatch",
"(",
"DispatchEvent",
"$",
"event",
")",
"{",
"$",
"controller",
"=",
"$",
"event",
"->",
"getContext",
"(",
")",
";",
"$",
"action",
"=",
"$",
"event",
"->",
"getParam",
"(",
"'action'",
")",
".",
"'Action'",
";",
"... | Dispatch the controller.
@param \Es\Dispatcher\DispatchEvent $event The event of dispatch | [
"Dispatch",
"the",
"controller",
"."
] | 3a2420113c72e544e15c1500717c918e7d5d4bf8 | https://github.com/easy-system/es-dispatcher/blob/3a2420113c72e544e15c1500717c918e7d5d4bf8/src/Listener/DispatchesControllerListener.php#L73-L84 | train |
phossa2/libs | src/Phossa2/Cache/Utility/CachedCallable.php | CachedCallable.getTtlAndKey | protected function getTtlAndKey(array &$args)/*# : array */
{
if (is_numeric($args[0])) {
$ttl = (int) array_shift($args);
$key = $this->generateKey($args);
} else {
$key = $this->generateKey($args);
$ttl = $this->ttl;
}
return [$ttl, $key];
} | php | protected function getTtlAndKey(array &$args)/*# : array */
{
if (is_numeric($args[0])) {
$ttl = (int) array_shift($args);
$key = $this->generateKey($args);
} else {
$key = $this->generateKey($args);
$ttl = $this->ttl;
}
return [$ttl, $key];
} | [
"protected",
"function",
"getTtlAndKey",
"(",
"array",
"&",
"$",
"args",
")",
"/*# : array */",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"args",
"[",
"0",
"]",
")",
")",
"{",
"$",
"ttl",
"=",
"(",
"int",
")",
"array_shift",
"(",
"$",
"args",
")",
";... | Get TTL and unique key
@param array &$args
@return array
@access protected | [
"Get",
"TTL",
"and",
"unique",
"key"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Utility/CachedCallable.php#L112-L122 | train |
browserfs/base | src/Event.php | Event.create | public static function create( $eventName, $eventArgs = null ) {
if ( !is_string( $eventName ) ) {
throw new \browserfs\Exception('Invalid argument $eventName: string expected!');
}
if ( null !== $eventArgs && !is_array( $eventArgs ) ) {
throw new \browserfs\Exception('Invalid argument $eventArgs: any[] | null expected');
}
return new static( $eventName, null === $eventArgs ? [] : array_values( $eventArgs ) );
} | php | public static function create( $eventName, $eventArgs = null ) {
if ( !is_string( $eventName ) ) {
throw new \browserfs\Exception('Invalid argument $eventName: string expected!');
}
if ( null !== $eventArgs && !is_array( $eventArgs ) ) {
throw new \browserfs\Exception('Invalid argument $eventArgs: any[] | null expected');
}
return new static( $eventName, null === $eventArgs ? [] : array_values( $eventArgs ) );
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"eventName",
",",
"$",
"eventArgs",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"eventName",
")",
")",
"{",
"throw",
"new",
"\\",
"browserfs",
"\\",
"Exception",
"(",
"'Invalid argumen... | Creates a new event. Static constructor.
@param eventName - string - the name of the event
@param eventArgs - any[] | null - event arguments.
@throws \browserfs\Exception - if arguments are invalid
@return \browserfs\Event | [
"Creates",
"a",
"new",
"event",
".",
"Static",
"constructor",
"."
] | d98550b5cf6f6e9083f99f39d17fd1b79d61db55 | https://github.com/browserfs/base/blob/d98550b5cf6f6e9083f99f39d17fd1b79d61db55/src/Event.php#L84-L95 | train |
monomelodies/dabble | src/Adapter.php | Adapter.select | public function select($table, $fields, $where = [], $options = [])
{
if (is_scalar($fields)) {
$fields = explode(',', $fields);
}
$query = new Select(
$this,
$table,
$fields,
new Where($where),
new Options($options)
);
return $query->execute();
} | php | public function select($table, $fields, $where = [], $options = [])
{
if (is_scalar($fields)) {
$fields = explode(',', $fields);
}
$query = new Select(
$this,
$table,
$fields,
new Where($where),
new Options($options)
);
return $query->execute();
} | [
"public",
"function",
"select",
"(",
"$",
"table",
",",
"$",
"fields",
",",
"$",
"where",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"explode",
"("... | Select rows from a table.
@param string $table The table(s) to query.
@param mixed $fields The field (column) to query.
@param mixed $where The where-clause.
@param mixed $options The options (limit, offset etc.).
@return function A lambda allowing you to access the found rows.
@throws Dabble\Query\SelectException when no rows found.
@throws Dabble\Query\SqlException on error. | [
"Select",
"rows",
"from",
"a",
"table",
"."
] | 4ba771cf90116b61821af8d15652cb6e5665e4b7 | https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L213-L226 | train |
monomelodies/dabble | src/Adapter.php | Adapter.fetch | public function fetch($table, $fields, $where = null, $options = [])
{
$options['limit'] = 1;
if (!isset($options['offset'])) {
$options['offset'] = 0;
}
$result = $this->select($table, $fields, $where, $options);
foreach ($result as $row) {
return $row;
}
} | php | public function fetch($table, $fields, $where = null, $options = [])
{
$options['limit'] = 1;
if (!isset($options['offset'])) {
$options['offset'] = 0;
}
$result = $this->select($table, $fields, $where, $options);
foreach ($result as $row) {
return $row;
}
} | [
"public",
"function",
"fetch",
"(",
"$",
"table",
",",
"$",
"fields",
",",
"$",
"where",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"[",
"'limit'",
"]",
"=",
"1",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options"... | Retrieve a single row from the database.
@param string $table The table(s) to query.
@param string|array $fields The field(s) (column(s)) to query.
@param array $where An SQL where-array.
@param array $options Array of options.
@return array An array containing the result.
@throws Dabble\Query\SelectException when no row was found.
@throws Dabble\Query\SqlException on error. | [
"Retrieve",
"a",
"single",
"row",
"from",
"the",
"database",
"."
] | 4ba771cf90116b61821af8d15652cb6e5665e4b7 | https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L272-L282 | train |
monomelodies/dabble | src/Adapter.php | Adapter.column | public function column($table, $field, $where = null, $options = null)
{
$results = $this->fetch($table, $field, $where, $options);
return array_shift($results);
} | php | public function column($table, $field, $where = null, $options = null)
{
$results = $this->fetch($table, $field, $where, $options);
return array_shift($results);
} | [
"public",
"function",
"column",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"where",
"=",
"null",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"... | Retrieve a single value from a single column.
@param string $table The table(s) to query.
@param string $field The field (column) to query.
@param array $where An SQL where-array.
@param array $options Array of options.
@return mixed A scalar containing the result, or null.
@throws Dabble\Query\SelectException when no row was found.
@throws Dabble\Query\SqlException on error. | [
"Retrieve",
"a",
"single",
"value",
"from",
"a",
"single",
"column",
"."
] | 4ba771cf90116b61821af8d15652cb6e5665e4b7 | https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L295-L299 | train |
monomelodies/dabble | src/Adapter.php | Adapter.fetchObject | public function fetchObject(
$class = null,
$table,
$fields,
$where = null,
$options = []
)
{
if (is_null($class)) {
$class = 'StdClass';
} elseif (is_object($class)) {
$class = get_class($class);
}
if (is_scalar($fields)) {
$fields = explode(',', $fields);
}
$query = new Select(
$this,
$table,
$fields,
new Where($where),
new Options($options)
);
$stmt = $this->prepare($query->__toString());
$stmt->execute($query->getBindings());
$result = $stmt->fetchObject($class);
if (!$result) {
throw new SelectException($stmt->queryString);
}
return $result;
} | php | public function fetchObject(
$class = null,
$table,
$fields,
$where = null,
$options = []
)
{
if (is_null($class)) {
$class = 'StdClass';
} elseif (is_object($class)) {
$class = get_class($class);
}
if (is_scalar($fields)) {
$fields = explode(',', $fields);
}
$query = new Select(
$this,
$table,
$fields,
new Where($where),
new Options($options)
);
$stmt = $this->prepare($query->__toString());
$stmt->execute($query->getBindings());
$result = $stmt->fetchObject($class);
if (!$result) {
throw new SelectException($stmt->queryString);
}
return $result;
} | [
"public",
"function",
"fetchObject",
"(",
"$",
"class",
"=",
"null",
",",
"$",
"table",
",",
"$",
"fields",
",",
"$",
"where",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"class",
")",
")",
"{",
"$... | Retrieve a single row as an object.
@param mixed $class Classname, object or null (defaults to StdClass) to
select into.
@param string $table The table(s) to query.
@param string $field The field (column) to query.
@param array $where An SQL where-array.
@param array $options Array of options.
@return mixed An object of the desired class initialized with the row's
values.
@throws Dabble\Query\SelectException when no row was found.
@throws Dabble\Query\SqlException on error. | [
"Retrieve",
"a",
"single",
"row",
"as",
"an",
"object",
"."
] | 4ba771cf90116b61821af8d15652cb6e5665e4b7 | https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L324-L354 | train |
monomelodies/dabble | src/Adapter.php | Adapter.update | public function update($table, array $fields, $where, $options = null)
{
$query = new Update(
$this,
$table,
$fields,
new Where($where),
new Options($options)
);
return $query->execute();
} | php | public function update($table, array $fields, $where, $options = null)
{
$query = new Update(
$this,
$table,
$fields,
new Where($where),
new Options($options)
);
return $query->execute();
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"array",
"$",
"fields",
",",
"$",
"where",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"new",
"Update",
"(",
"$",
"this",
",",
"$",
"table",
",",
"$",
"fields",
",",
"new"... | Update one or more rows in the database.
@param string $table The table to update.
@param array $fields Array Field => value pairs to update.
@param array $where Array of where statements to limit updates.
@return integer The number of affected (updated) rows.
@throws Dabble\Query\UpdateException if no rows were updated.
@throws Dabble\Query\SqlException on error. | [
"Update",
"one",
"or",
"more",
"rows",
"in",
"the",
"database",
"."
] | 4ba771cf90116b61821af8d15652cb6e5665e4b7 | https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L392-L402 | train |
monomelodies/dabble | src/Adapter.php | Adapter.delete | public function delete($table, array $where)
{
$query = new Delete($this, $table, new Where($where));
return $query->execute();
} | php | public function delete($table, array $where)
{
$query = new Delete($this, $table, new Where($where));
return $query->execute();
} | [
"public",
"function",
"delete",
"(",
"$",
"table",
",",
"array",
"$",
"where",
")",
"{",
"$",
"query",
"=",
"new",
"Delete",
"(",
"$",
"this",
",",
"$",
"table",
",",
"new",
"Where",
"(",
"$",
"where",
")",
")",
";",
"return",
"$",
"query",
"->",... | Delete a row from the database.
@param string $table The table to delete from.
@param array $where Array of where statements to limit deletes.
@return int The number of deleted rows.
@throws Dabble\Query\DeleteException if no rows were deleted.
@throws Dabble\Query\SqlException on error. | [
"Delete",
"a",
"row",
"from",
"the",
"database",
"."
] | 4ba771cf90116b61821af8d15652cb6e5665e4b7 | https://github.com/monomelodies/dabble/blob/4ba771cf90116b61821af8d15652cb6e5665e4b7/src/Adapter.php#L413-L417 | train |
rollun-com/rollun-permission | src/Permission/src/ConfigProvider.php | ConfigProvider.getDependencies | protected function getDependencies()
{
return [
'factories' => [
PermissionMiddleware::class => PermissionMiddlewareFactory::class,
ExpressiveRouteName::class => InvokableFactory::class,
PermissionMiddleware::class => PermissionMiddlewareFactory::class,
ResourceResolver::class => ResourceResolverAbstractFactory::class,
RoleResolver::class => RoleResolverFactory::class,
AclMiddleware::class => AclMiddlewareFactory::class,
Acl::class => AclFromDataStoreFactory::class,
UserRepository::class => UserRepositoryFactory::class,
GuestAuthentication::class => GuestAuthenticationFactory::class,
RedirectMiddleware::class => RedirectMiddlewareFactory::class,
GoogleClient::class => GoogleClientFactory::class,
],
'aliases' => [
ConfigProvider::AUTHENTICATION_MIDDLEWARE_SERVICE => AuthenticationMiddleware::class,
AuthenticationInterface::class => 'authenticationServiceChain',
UserRepositoryInterface::class => UserRepository::class,
self::RULE_DATASTORE_SERVICE => AclRulesTable::class,
self::ROLE_DATASTORE_SERVICE => AclRolesTable::class,
self::RESOURCE_DATASTORE_SERVICE => AclResourceTable::class,
self::PRIVILEGE_DATASTORE_SERVICE => AclPrivilegeTable::class,
self::USER_DATASTORE_SERVICE => AclUsersTable::class,
self::USER_ROLE_DATASTORE_SERVICE => AclUserRolesTable::class,
],
'abstract_factories' => [
ResourceResolverAbstractFactory::class,
RouteAttributeAbstractFactory::class,
RouteNameAbstractFactory::class,
MiddlewarePipeAbstractFactory::class,
AuthenticationChainAbstractFactory::class,
BasicAccessAbstractFactory::class,
PhpSessionAbstractFactory::class,
CredentialMiddlewareAbstractFactory::class,
],
'invokables' => [
PrivilegeResolver::class => PrivilegeResolver::class,
AccessForbiddenHandler::class => AccessForbiddenHandler::class,
ExpressiveRouteName::class => ExpressiveRouteName::class,
],
];
} | php | protected function getDependencies()
{
return [
'factories' => [
PermissionMiddleware::class => PermissionMiddlewareFactory::class,
ExpressiveRouteName::class => InvokableFactory::class,
PermissionMiddleware::class => PermissionMiddlewareFactory::class,
ResourceResolver::class => ResourceResolverAbstractFactory::class,
RoleResolver::class => RoleResolverFactory::class,
AclMiddleware::class => AclMiddlewareFactory::class,
Acl::class => AclFromDataStoreFactory::class,
UserRepository::class => UserRepositoryFactory::class,
GuestAuthentication::class => GuestAuthenticationFactory::class,
RedirectMiddleware::class => RedirectMiddlewareFactory::class,
GoogleClient::class => GoogleClientFactory::class,
],
'aliases' => [
ConfigProvider::AUTHENTICATION_MIDDLEWARE_SERVICE => AuthenticationMiddleware::class,
AuthenticationInterface::class => 'authenticationServiceChain',
UserRepositoryInterface::class => UserRepository::class,
self::RULE_DATASTORE_SERVICE => AclRulesTable::class,
self::ROLE_DATASTORE_SERVICE => AclRolesTable::class,
self::RESOURCE_DATASTORE_SERVICE => AclResourceTable::class,
self::PRIVILEGE_DATASTORE_SERVICE => AclPrivilegeTable::class,
self::USER_DATASTORE_SERVICE => AclUsersTable::class,
self::USER_ROLE_DATASTORE_SERVICE => AclUserRolesTable::class,
],
'abstract_factories' => [
ResourceResolverAbstractFactory::class,
RouteAttributeAbstractFactory::class,
RouteNameAbstractFactory::class,
MiddlewarePipeAbstractFactory::class,
AuthenticationChainAbstractFactory::class,
BasicAccessAbstractFactory::class,
PhpSessionAbstractFactory::class,
CredentialMiddlewareAbstractFactory::class,
],
'invokables' => [
PrivilegeResolver::class => PrivilegeResolver::class,
AccessForbiddenHandler::class => AccessForbiddenHandler::class,
ExpressiveRouteName::class => ExpressiveRouteName::class,
],
];
} | [
"protected",
"function",
"getDependencies",
"(",
")",
"{",
"return",
"[",
"'factories'",
"=>",
"[",
"PermissionMiddleware",
"::",
"class",
"=>",
"PermissionMiddlewareFactory",
"::",
"class",
",",
"ExpressiveRouteName",
"::",
"class",
"=>",
"InvokableFactory",
"::",
... | Returns the container dependencies
@return array | [
"Returns",
"the",
"container",
"dependencies"
] | 9f58c814337fcfd1e52ecfbf496f95d276d8217e | https://github.com/rollun-com/rollun-permission/blob/9f58c814337fcfd1e52ecfbf496f95d276d8217e/src/Permission/src/ConfigProvider.php#L140-L184 | train |
binsoul/common | src/PropertyGenerator.php | PropertyGenerator.getGeneratedProperties | protected function getGeneratedProperties(): array
{
$reflectionObject = new \ReflectionObject($this);
$properties = $reflectionObject->getProperties(\ReflectionProperty::IS_PUBLIC);
$result = [];
foreach ($properties as $property) {
if (!$property->isPublic() || @$property->isDefault()) {
continue;
}
$result[] = $property;
}
return $result;
} | php | protected function getGeneratedProperties(): array
{
$reflectionObject = new \ReflectionObject($this);
$properties = $reflectionObject->getProperties(\ReflectionProperty::IS_PUBLIC);
$result = [];
foreach ($properties as $property) {
if (!$property->isPublic() || @$property->isDefault()) {
continue;
}
$result[] = $property;
}
return $result;
} | [
"protected",
"function",
"getGeneratedProperties",
"(",
")",
":",
"array",
"{",
"$",
"reflectionObject",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"this",
")",
";",
"$",
"properties",
"=",
"$",
"reflectionObject",
"->",
"getProperties",
"(",
"\\",
"Refle... | Returns an array of generated public properties.
@return \ReflectionProperty[] | [
"Returns",
"an",
"array",
"of",
"generated",
"public",
"properties",
"."
] | 668a62dada22727c0b75e9484dce587d7a490889 | https://github.com/binsoul/common/blob/668a62dada22727c0b75e9484dce587d7a490889/src/PropertyGenerator.php#L70-L84 | train |
binsoul/common | src/PropertyGenerator.php | PropertyGenerator.removeGeneratedProperties | protected function removeGeneratedProperties()
{
$properties = $this->getGeneratedProperties();
foreach ($properties as $property) {
$name = $property->getName();
unset($this->{$name});
}
} | php | protected function removeGeneratedProperties()
{
$properties = $this->getGeneratedProperties();
foreach ($properties as $property) {
$name = $property->getName();
unset($this->{$name});
}
} | [
"protected",
"function",
"removeGeneratedProperties",
"(",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"getGeneratedProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"name",
"=",
"$",
"property",
... | Removes all generated public properties. | [
"Removes",
"all",
"generated",
"public",
"properties",
"."
] | 668a62dada22727c0b75e9484dce587d7a490889 | https://github.com/binsoul/common/blob/668a62dada22727c0b75e9484dce587d7a490889/src/PropertyGenerator.php#L89-L97 | train |
vitodtagliente/pure-template | View.php | View.namespace | public static function namespace($key, $path){
if(!array_key_exists($key, self::$namespaces))
self::$namespaces[$key] = $path;
} | php | public static function namespace($key, $path){
if(!array_key_exists($key, self::$namespaces))
self::$namespaces[$key] = $path;
} | [
"public",
"static",
"function",
"namespace",
"(",
"$",
"key",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"namespaces",
")",
")",
"self",
"::",
"$",
"namespaces",
"[",
"$",
"key",
"]",
"=... | specifica di namespace per le path | [
"specifica",
"di",
"namespace",
"per",
"le",
"path"
] | d3f3e38d7e425a5f9f6e17df405037f6001ff3e9 | https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/View.php#L54-L57 | train |
vitodtagliente/pure-template | View.php | View.render | public function render($direct_output = true)
{
// controlla che il file esista
if($this->exists() == false)
return false;
// Carica il contenuto e imposta i parametri settati
// come variabili di contesto
extract($this->params);
ob_start();
include($this->filename);
$content = ob_get_contents();
ob_end_clean();
// view engines
foreach($this->engines as $key => $engine)
{
$content = $engine->map($content, $this->params);
}
// pulisci l'output di eventuali sezioni non sovrascritte
if($this->can_clear)
{
foreach (ViewUtility::find_rules($content, '@section', ')') as $rule) {
$content = str_replace($rule, '', $content);
}
}
// controlla se occorre produrre a schermo
// o semplicemente ritornare il contenuto
if($direct_output)
{
echo $content;
return true;
}
else return $content;
} | php | public function render($direct_output = true)
{
// controlla che il file esista
if($this->exists() == false)
return false;
// Carica il contenuto e imposta i parametri settati
// come variabili di contesto
extract($this->params);
ob_start();
include($this->filename);
$content = ob_get_contents();
ob_end_clean();
// view engines
foreach($this->engines as $key => $engine)
{
$content = $engine->map($content, $this->params);
}
// pulisci l'output di eventuali sezioni non sovrascritte
if($this->can_clear)
{
foreach (ViewUtility::find_rules($content, '@section', ')') as $rule) {
$content = str_replace($rule, '', $content);
}
}
// controlla se occorre produrre a schermo
// o semplicemente ritornare il contenuto
if($direct_output)
{
echo $content;
return true;
}
else return $content;
} | [
"public",
"function",
"render",
"(",
"$",
"direct_output",
"=",
"true",
")",
"{",
"// controlla che il file esista",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
")",
"==",
"false",
")",
"return",
"false",
";",
"// Carica il contenuto e imposta i parametri settati",... | genera la vista | [
"genera",
"la",
"vista"
] | d3f3e38d7e425a5f9f6e17df405037f6001ff3e9 | https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/View.php#L92-L128 | train |
vitodtagliente/pure-template | View.php | View.make | public static function make($filename, $params = array(), $direct_output = true){
$view = new View($filename, $params);
return $view->render($direct_output);
} | php | public static function make($filename, $params = array(), $direct_output = true){
$view = new View($filename, $params);
return $view->render($direct_output);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"filename",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"direct_output",
"=",
"true",
")",
"{",
"$",
"view",
"=",
"new",
"View",
"(",
"$",
"filename",
",",
"$",
"params",
")",
";",
"return... | funzione statica per la generazione di viste immediate | [
"funzione",
"statica",
"per",
"la",
"generazione",
"di",
"viste",
"immediate"
] | d3f3e38d7e425a5f9f6e17df405037f6001ff3e9 | https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/View.php#L139-L142 | train |
tacowordpress/util | src/Util/Html.php | Html.attribs | public static function attribs($attribs, $leading_space = true)
{
if (!Arr::iterable($attribs)) {
return '';
}
$out = array();
foreach ($attribs as $k => $v) {
$v = (is_array($v)) ? join(' ', $v) : $v;
$out[] = $k . '="' . str_replace('"', '\"', $v) . '"';
}
return (($leading_space) ? ' ' : '') . join(' ', $out);
} | php | public static function attribs($attribs, $leading_space = true)
{
if (!Arr::iterable($attribs)) {
return '';
}
$out = array();
foreach ($attribs as $k => $v) {
$v = (is_array($v)) ? join(' ', $v) : $v;
$out[] = $k . '="' . str_replace('"', '\"', $v) . '"';
}
return (($leading_space) ? ' ' : '') . join(' ', $out);
} | [
"public",
"static",
"function",
"attribs",
"(",
"$",
"attribs",
",",
"$",
"leading_space",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"attribs",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"out",
"=",
"array",
"(",
... | Get a string of attributes given the attributes as an array
@param array $attribs
@param $leading_space
@return string | [
"Get",
"a",
"string",
"of",
"attributes",
"given",
"the",
"attributes",
"as",
"an",
"array"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L17-L29 | train |
tacowordpress/util | src/Util/Html.php | Html.image | public static function image($src, $alt = null, $attribs = array())
{
$attribs = array_merge(array('src'=>$src), $attribs);
if ($alt) {
$attribs['alt'] = htmlentities($alt);
}
return self::tag('img', null, $attribs);
} | php | public static function image($src, $alt = null, $attribs = array())
{
$attribs = array_merge(array('src'=>$src), $attribs);
if ($alt) {
$attribs['alt'] = htmlentities($alt);
}
return self::tag('img', null, $attribs);
} | [
"public",
"static",
"function",
"image",
"(",
"$",
"src",
",",
"$",
"alt",
"=",
"null",
",",
"$",
"attribs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attribs",
"=",
"array_merge",
"(",
"array",
"(",
"'src'",
"=>",
"$",
"src",
")",
",",
"$",
"attri... | Generate an img tag
@param string $src
@param string $alt
@param array $attribs
@return string | [
"Generate",
"an",
"img",
"tag"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L74-L82 | train |
tacowordpress/util | src/Util/Html.php | Html.listy | public static function listy($items, $attribs = array(), $type = 'ul')
{
if (!Arr::iterable($items)) {
return '';
}
$htmls = array();
$htmls[] = '<' . $type . self::attribs($attribs) . '>';
foreach ($items as $item) {
$htmls[] = '<li>' . $item . '</li>';
}
$htmls[] = '</' . $type . '>';
return join("\n", $htmls);
} | php | public static function listy($items, $attribs = array(), $type = 'ul')
{
if (!Arr::iterable($items)) {
return '';
}
$htmls = array();
$htmls[] = '<' . $type . self::attribs($attribs) . '>';
foreach ($items as $item) {
$htmls[] = '<li>' . $item . '</li>';
}
$htmls[] = '</' . $type . '>';
return join("\n", $htmls);
} | [
"public",
"static",
"function",
"listy",
"(",
"$",
"items",
",",
"$",
"attribs",
"=",
"array",
"(",
")",
",",
"$",
"type",
"=",
"'ul'",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"items",
")",
")",
"{",
"return",
"''",
";",
"}... | Get an HTML list
@param array $items
@param array $attribs
@param string $type | [
"Get",
"an",
"HTML",
"list"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L144-L157 | train |
tacowordpress/util | src/Util/Html.php | Html.alisty | public static function alisty($items, $attribs = array(), $type = 'ul', $active_title = null)
{
if (!Arr::iterable($items)) {
return '';
}
$htmls = array();
$htmls[] = '<' . $type . self::attribs($attribs) . '>';
foreach ($items as $title => $href) {
$body = (is_array($href)) ? Html::a($title, $href) : Html::link($href, $title);
$classes = array(Str::machine($title));
if ($active_title === $title) {
$classes[] = 'active';
}
$htmls[] = sprintf('<li class="%s">', join(' ', $classes)) . $body . '</li>';
}
$htmls[] = '</' . $type . '>';
return join("\n", $htmls);
} | php | public static function alisty($items, $attribs = array(), $type = 'ul', $active_title = null)
{
if (!Arr::iterable($items)) {
return '';
}
$htmls = array();
$htmls[] = '<' . $type . self::attribs($attribs) . '>';
foreach ($items as $title => $href) {
$body = (is_array($href)) ? Html::a($title, $href) : Html::link($href, $title);
$classes = array(Str::machine($title));
if ($active_title === $title) {
$classes[] = 'active';
}
$htmls[] = sprintf('<li class="%s">', join(' ', $classes)) . $body . '</li>';
}
$htmls[] = '</' . $type . '>';
return join("\n", $htmls);
} | [
"public",
"static",
"function",
"alisty",
"(",
"$",
"items",
",",
"$",
"attribs",
"=",
"array",
"(",
")",
",",
"$",
"type",
"=",
"'ul'",
",",
"$",
"active_title",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"iterable",
"(",
"$",
"items",
... | Get an HTML list of links
@param array $items
@param array $attribs
@param string $type
@param string $active_title | [
"Get",
"an",
"HTML",
"list",
"of",
"links"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L167-L187 | train |
tacowordpress/util | src/Util/Html.php | Html.selecty | public static function selecty($options, $selected = null, $attribs = array())
{
$htmls = array();
$htmls[] = self::select(null, $attribs, false);
if (Arr::iterable($options)) {
foreach ($options as $value => $title) {
$option_attribs = array('value'=>$value);
if ((string) $selected === (string) $value) {
$option_attribs['selected'] = 'selected';
}
$htmls[] = self::option($title, $option_attribs);
}
}
$htmls[] = '</select>';
return join("\n", $htmls);
} | php | public static function selecty($options, $selected = null, $attribs = array())
{
$htmls = array();
$htmls[] = self::select(null, $attribs, false);
if (Arr::iterable($options)) {
foreach ($options as $value => $title) {
$option_attribs = array('value'=>$value);
if ((string) $selected === (string) $value) {
$option_attribs['selected'] = 'selected';
}
$htmls[] = self::option($title, $option_attribs);
}
}
$htmls[] = '</select>';
return join("\n", $htmls);
} | [
"public",
"static",
"function",
"selecty",
"(",
"$",
"options",
",",
"$",
"selected",
"=",
"null",
",",
"$",
"attribs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"htmls",
"=",
"array",
"(",
")",
";",
"$",
"htmls",
"[",
"]",
"=",
"self",
"::",
"selec... | Get a select list
@param array $options
@param string $selected
@param array $attribs
@return string | [
"Get",
"a",
"select",
"list"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L197-L213 | train |
tacowordpress/util | src/Util/Html.php | Html.tably | public static function tably($records)
{
if (count($records) === 0) {
return null;
}
$htmls = array();
$htmls[] = '<table>';
foreach ($records as $record) {
$htmls[] = '<tr>';
foreach ($record as $k => $v) {
$htmls[] = sprintf('<td class="%s">%s</td>', Str::machine($k), $v);
}
$htmls[] = '</tr>';
}
$htmls[] = '</table>';
return join("\n", $htmls);
} | php | public static function tably($records)
{
if (count($records) === 0) {
return null;
}
$htmls = array();
$htmls[] = '<table>';
foreach ($records as $record) {
$htmls[] = '<tr>';
foreach ($record as $k => $v) {
$htmls[] = sprintf('<td class="%s">%s</td>', Str::machine($k), $v);
}
$htmls[] = '</tr>';
}
$htmls[] = '</table>';
return join("\n", $htmls);
} | [
"public",
"static",
"function",
"tably",
"(",
"$",
"records",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"records",
")",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"$",
"htmls",
"=",
"array",
"(",
")",
";",
"$",
"htmls",
"[",
"]",
"=",
"'<t... | Get a table
@param array $records
@return string | [
"Get",
"a",
"table"
] | a27f6f1c3f96a908c7480f359fd44028e89f26c3 | https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Html.php#L221-L238 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.