repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/JsonRpc.php | JsonRpc.processRequest | protected function processRequest( array $reqparams )
{
try
{
if( !isset( $reqparams['params'] ) || ( $params = json_decode( $reqparams['params'] ) ) === null ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'Required parameters are missing or not JSON encoded' );
}
if( ( $result = $this->callMethod( $reqparams['method'], $params ) ) !== null ) {
return json_encode( $result );
}
}
catch( \Exception $e )
{
$response = array(
'error' => array(
'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
'message' => $e->getMessage(),
),
'status' => 'failure'
);
return json_encode( $response );
}
return null;
} | php | protected function processRequest( array $reqparams )
{
try
{
if( !isset( $reqparams['params'] ) || ( $params = json_decode( $reqparams['params'] ) ) === null ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'Required parameters are missing or not JSON encoded' );
}
if( ( $result = $this->callMethod( $reqparams['method'], $params ) ) !== null ) {
return json_encode( $result );
}
}
catch( \Exception $e )
{
$response = array(
'error' => array(
'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
'message' => $e->getMessage(),
),
'status' => 'failure'
);
return json_encode( $response );
}
return null;
} | [
"protected",
"function",
"processRequest",
"(",
"array",
"$",
"reqparams",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"reqparams",
"[",
"'params'",
"]",
")",
"||",
"(",
"$",
"params",
"=",
"json_decode",
"(",
"$",
"reqparams",
"[",
"'para... | Processes a request using the request paramters.
@param array $reqparams Associative list of request parameters (usually $_REQUEST)
@return string|null JSON RPC 2.0 message response | [
"Processes",
"a",
"request",
"using",
"the",
"request",
"paramters",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L143-L169 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/JsonRpc.php | JsonRpc.processStream | protected function processStream( $content )
{
$response = [];
try
{
if( ( $request = json_decode( $content ) ) === null ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'Invalid JSON encoded request', -32700 );
}
if( is_array( $request ) )
{
foreach( $request as $item )
{
if( ( $result = $this->processJson( $item ) ) !== null ) {
$response[] = $result;
}
}
}
else if( is_object( $request ) )
{
if( ( $result = $this->processJson( $request ) ) !== null ) {
$response = $result;
}
}
else
{
throw new \Aimeos\Controller\ExtJS\Exception( 'Invalid JSON RPC request', -32600 );
}
}
catch( \Exception $e )
{
$response = array(
'error' => array(
'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
'message' => $e->getMessage(),
),
'id' => null,
);
}
if( !empty( $response ) ) {
return json_encode( $response );
}
return null;
} | php | protected function processStream( $content )
{
$response = [];
try
{
if( ( $request = json_decode( $content ) ) === null ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'Invalid JSON encoded request', -32700 );
}
if( is_array( $request ) )
{
foreach( $request as $item )
{
if( ( $result = $this->processJson( $item ) ) !== null ) {
$response[] = $result;
}
}
}
else if( is_object( $request ) )
{
if( ( $result = $this->processJson( $request ) ) !== null ) {
$response = $result;
}
}
else
{
throw new \Aimeos\Controller\ExtJS\Exception( 'Invalid JSON RPC request', -32600 );
}
}
catch( \Exception $e )
{
$response = array(
'error' => array(
'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
'message' => $e->getMessage(),
),
'id' => null,
);
}
if( !empty( $response ) ) {
return json_encode( $response );
}
return null;
} | [
"protected",
"function",
"processStream",
"(",
"$",
"content",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"try",
"{",
"if",
"(",
"(",
"$",
"request",
"=",
"json_decode",
"(",
"$",
"content",
")",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"\... | Processes a request using the input stream.
@param string $content Content sent with the HTTP request
@return string|null JSON RPC 2.0 message response | [
"Processes",
"a",
"request",
"using",
"the",
"input",
"stream",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L178-L224 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/JsonRpc.php | JsonRpc.processJson | protected function processJson( \stdClass $request )
{
$response = array(
'jsonrpc' => '2.0',
);
try
{
if( !isset( $request->method ) )
{
$msg = sprintf( 'Required attribute "%1$s" missing in request', 'method' );
throw new \Aimeos\Controller\ExtJS\Exception( $msg, -32600 );
}
if( !isset( $request->params ) ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'Required parameters are missing in request', -32600 );
}
$response['result'] = $this->callMethod( $request->method, $request->params );
}
catch( \Exception $e )
{
$response['error'] = array(
'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
'message' => $e->getMessage(),
);
}
if( !isset( $request->id ) ) {
return null;
}
$response['id'] = $request->id;
return $response;
} | php | protected function processJson( \stdClass $request )
{
$response = array(
'jsonrpc' => '2.0',
);
try
{
if( !isset( $request->method ) )
{
$msg = sprintf( 'Required attribute "%1$s" missing in request', 'method' );
throw new \Aimeos\Controller\ExtJS\Exception( $msg, -32600 );
}
if( !isset( $request->params ) ) {
throw new \Aimeos\Controller\ExtJS\Exception( 'Required parameters are missing in request', -32600 );
}
$response['result'] = $this->callMethod( $request->method, $request->params );
}
catch( \Exception $e )
{
$response['error'] = array(
'code' => ( $e->getCode() != 0 ? $e->getCode() : -1 ),
'message' => $e->getMessage(),
);
}
if( !isset( $request->id ) ) {
return null;
}
$response['id'] = $request->id;
return $response;
} | [
"protected",
"function",
"processJson",
"(",
"\\",
"stdClass",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"'jsonrpc'",
"=>",
"'2.0'",
",",
")",
";",
"try",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"request",
"->",
"method",
")",
")"... | Processes a single JSON RPC request.
@param \stdClass $request Object with attributes of JSON RPC request
@return Associative array with JSON RPC response or NULL in case of JSON RPC notifications | [
"Processes",
"a",
"single",
"JSON",
"RPC",
"request",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L233-L267 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/JsonRpc.php | JsonRpc.callMethod | protected function callMethod( $classmethod, \stdClass $params )
{
$parts = explode( '.', $classmethod );
if( count( $parts ) !== 2 ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid method "%1$s" in request', $classmethod ), -32602 );
}
$method = $parts[1];
$class = str_replace( '_', '\\', $parts[0] );
$name = $this->getClassPrefix() . '\\' . $class . '\\Factory';
if( preg_match( '/^[\\a-zA-Z0-9]+$/', $name ) !== 1 ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid controller factory name "%1$s"', $name ), -32602 );
}
if( class_exists( $name ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Class "%1$s" not found', $name ) );
}
if( ( $controller = call_user_func_array( $name . '::createController', array( $this->context ) ) ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Factory "%1$s" not found', $name ), -32602 );
}
if( method_exists( $controller, $method ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Method "%1$s" not found', $classmethod ), -32602 );
}
return $controller->$method( $params );
} | php | protected function callMethod( $classmethod, \stdClass $params )
{
$parts = explode( '.', $classmethod );
if( count( $parts ) !== 2 ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid method "%1$s" in request', $classmethod ), -32602 );
}
$method = $parts[1];
$class = str_replace( '_', '\\', $parts[0] );
$name = $this->getClassPrefix() . '\\' . $class . '\\Factory';
if( preg_match( '/^[\\a-zA-Z0-9]+$/', $name ) !== 1 ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid controller factory name "%1$s"', $name ), -32602 );
}
if( class_exists( $name ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Class "%1$s" not found', $name ) );
}
if( ( $controller = call_user_func_array( $name . '::createController', array( $this->context ) ) ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Factory "%1$s" not found', $name ), -32602 );
}
if( method_exists( $controller, $method ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Method "%1$s" not found', $classmethod ), -32602 );
}
return $controller->$method( $params );
} | [
"protected",
"function",
"callMethod",
"(",
"$",
"classmethod",
",",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"classmethod",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"!==",
"2",
")",
... | Calls the givven method of the specified controller.
@param string $classmethod Controller/method as "controller.method"
@param \stdClass $params Associative array of parameters
@return array Array of results generated by the controller method
@throws \Exception If controller or method couldn't be found or an error occured | [
"Calls",
"the",
"givven",
"method",
"of",
"the",
"specified",
"controller",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L278-L308 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/JsonRpc.php | JsonRpc.getControllers | protected function getControllers()
{
if( $this->controllers === [] )
{
$subFolder = substr( str_replace( '\\', DIRECTORY_SEPARATOR, $this->getClassPrefix() ), 7 );
foreach( $this->cntlPaths as $path => $list )
{
foreach( $list as $relpath )
{
$path .= DIRECTORY_SEPARATOR . $relpath . DIRECTORY_SEPARATOR . $subFolder;
if( is_dir( $path ) ) {
$this->addControllers( new \DirectoryIterator( $path ) );
}
}
}
}
return $this->controllers;
} | php | protected function getControllers()
{
if( $this->controllers === [] )
{
$subFolder = substr( str_replace( '\\', DIRECTORY_SEPARATOR, $this->getClassPrefix() ), 7 );
foreach( $this->cntlPaths as $path => $list )
{
foreach( $list as $relpath )
{
$path .= DIRECTORY_SEPARATOR . $relpath . DIRECTORY_SEPARATOR . $subFolder;
if( is_dir( $path ) ) {
$this->addControllers( new \DirectoryIterator( $path ) );
}
}
}
}
return $this->controllers;
} | [
"protected",
"function",
"getControllers",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"controllers",
"===",
"[",
"]",
")",
"{",
"$",
"subFolder",
"=",
"substr",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"get... | Returns all available controller instances.
@return array Associative list of base controller name (\Aimeos\Controller\ExtJS\Admin\Log\Standard becomes Admin_Log)
as key and the class instance as value | [
"Returns",
"all",
"available",
"controller",
"instances",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L328-L348 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/JsonRpc.php | JsonRpc.addControllers | protected function addControllers( \DirectoryIterator $dir, $prefix = '' )
{
$classprefix = $this->getClassPrefix();
foreach( $dir as $entry )
{
if( $entry->getType() === 'dir' && $entry->isDot() === false )
{
$subdir = new \DirectoryIterator( $entry->getPathName() );
$this->addControllers( $subdir, ( $prefix !== '' ? $prefix . '_' : '' ) . $entry->getBaseName() );
}
else if( $prefix !== '' && $entry->getType() === 'file'
&& ( $name = $entry->getBaseName( '.php' ) ) === 'Factory' )
{
$name = $classprefix . '\\' . str_replace( '_', '\\', $prefix ) . '\\Factory';
if( preg_match( '/^[\\a-zA-Z0-9]+$/', $name ) !== 1 ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid controller factory name "%1$s"', $name ) );
}
if( class_exists( $name ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Class "%1$s" not found', $name ) );
}
$controller = call_user_func_array( array( $name, 'createController' ), array( $this->context ) );
if( $controller === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid factory "%1$s"', $name ) );
}
$this->controllers[$prefix] = $controller;
}
}
} | php | protected function addControllers( \DirectoryIterator $dir, $prefix = '' )
{
$classprefix = $this->getClassPrefix();
foreach( $dir as $entry )
{
if( $entry->getType() === 'dir' && $entry->isDot() === false )
{
$subdir = new \DirectoryIterator( $entry->getPathName() );
$this->addControllers( $subdir, ( $prefix !== '' ? $prefix . '_' : '' ) . $entry->getBaseName() );
}
else if( $prefix !== '' && $entry->getType() === 'file'
&& ( $name = $entry->getBaseName( '.php' ) ) === 'Factory' )
{
$name = $classprefix . '\\' . str_replace( '_', '\\', $prefix ) . '\\Factory';
if( preg_match( '/^[\\a-zA-Z0-9]+$/', $name ) !== 1 ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid controller factory name "%1$s"', $name ) );
}
if( class_exists( $name ) === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Class "%1$s" not found', $name ) );
}
$controller = call_user_func_array( array( $name, 'createController' ), array( $this->context ) );
if( $controller === false ) {
throw new \Aimeos\Controller\ExtJS\Exception( sprintf( 'Invalid factory "%1$s"', $name ) );
}
$this->controllers[$prefix] = $controller;
}
}
} | [
"protected",
"function",
"addControllers",
"(",
"\\",
"DirectoryIterator",
"$",
"dir",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"$",
"classprefix",
"=",
"$",
"this",
"->",
"getClassPrefix",
"(",
")",
";",
"foreach",
"(",
"$",
"dir",
"as",
"$",
"entry",
... | Instantiates all found factories and stores the controller instances in the class variable.
@param \DirectoryIterator $dir Iterator over the (sub-)directory which might contain a factory
@param string $prefix Part of the class name between "\Aimeos\Controller\ExtJS" and "Factory"
@throws \Aimeos\Controller\ExtJS\Exception If factory name is invalid or if the controller couldn't be instantiated | [
"Instantiates",
"all",
"found",
"factories",
"and",
"stores",
"the",
"controller",
"instances",
"in",
"the",
"class",
"variable",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/JsonRpc.php#L358-L391 |
qloog/yaf-library | src/Mvc/Controller/Api.php | Api.handleException | public function handleException($e)
{
if ($e instanceof Action) {
return $this->error(Code::NOT_FOUND);
}
return $this->error($e->getCode(), $e->getMessage());
} | php | public function handleException($e)
{
if ($e instanceof Action) {
return $this->error(Code::NOT_FOUND);
}
return $this->error($e->getCode(), $e->getMessage());
} | [
"public",
"function",
"handleException",
"(",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"Action",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"Code",
"::",
"NOT_FOUND",
")",
";",
"}",
"return",
"$",
"this",
"->",
"error",
"(",
... | 异常处理
@param \Exception $e 异常
@return bool | [
"异常处理"
] | train | https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Mvc/Controller/Api.php#L35-L42 |
makinacorpus/drupal-ucms | ucms_notification/src/EventDispatcher/ExtranetMemberEventSubscriber.php | ExtranetMemberEventSubscriber.notify | protected function notify(ExtranetMemberEvent $event, $action)
{
$userId = $event->getSubject()->id();
$siteId = $event->getSite()->getId();
$this->notificationService->notifyChannel('site:' . $siteId, 'member', $userId, $action, $event->getArguments());
} | php | protected function notify(ExtranetMemberEvent $event, $action)
{
$userId = $event->getSubject()->id();
$siteId = $event->getSite()->getId();
$this->notificationService->notifyChannel('site:' . $siteId, 'member', $userId, $action, $event->getArguments());
} | [
"protected",
"function",
"notify",
"(",
"ExtranetMemberEvent",
"$",
"event",
",",
"$",
"action",
")",
"{",
"$",
"userId",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
"->",
"id",
"(",
")",
";",
"$",
"siteId",
"=",
"$",
"event",
"->",
"getSite",
"... | Sends a notification on the site's channel.
@param ExtranetMemberEvent $event
@param string $action | [
"Sends",
"a",
"notification",
"on",
"the",
"site",
"s",
"channel",
"."
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/EventDispatcher/ExtranetMemberEventSubscriber.php#L66-L72 |
artkonekt/gears | src/Registry/SettingsRegistry.php | SettingsRegistry.addByKey | public function addByKey(string $key): Setting
{
$setting = new SimpleSetting($key);
$this->add($setting);
return $setting;
} | php | public function addByKey(string $key): Setting
{
$setting = new SimpleSetting($key);
$this->add($setting);
return $setting;
} | [
"public",
"function",
"addByKey",
"(",
"string",
"$",
"key",
")",
":",
"Setting",
"{",
"$",
"setting",
"=",
"new",
"SimpleSetting",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"add",
"(",
"$",
"setting",
")",
";",
"return",
"$",
"setting",
";",
"... | Adds a setting by passing only the key
@param string $key
@return Setting Returns the created and registered Setting object | [
"Adds",
"a",
"setting",
"by",
"passing",
"only",
"the",
"key"
] | train | https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Registry/SettingsRegistry.php#L43-L50 |
makinacorpus/drupal-ucms | ucms_notification/src/NotificationService.php | NotificationService.getUserAccount | private function getUserAccount($userId)
{
$user = $this->entityManager->getStorage('user')->load($userId);
if (!$user) {
throw new \InvalidArgumentException(sprintf("User %d does not exist", $userId));
}
return $user;
} | php | private function getUserAccount($userId)
{
$user = $this->entityManager->getStorage('user')->load($userId);
if (!$user) {
throw new \InvalidArgumentException(sprintf("User %d does not exist", $userId));
}
return $user;
} | [
"private",
"function",
"getUserAccount",
"(",
"$",
"userId",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'user'",
")",
"->",
"load",
"(",
"$",
"userId",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
... | Get user account
@param int $userId
@return \Drupal\Core\Session\AccountInterface | [
"Get",
"user",
"account"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/NotificationService.php#L47-L56 |
makinacorpus/drupal-ucms | ucms_notification/src/NotificationService.php | NotificationService.refreshSubscriptionsFor | public function refreshSubscriptionsFor($userId)
{
$valid = ['client:' . $userId];
$account = $this->getUserAccount($userId);
$default = [
'admin:client',
'admin:content',
'admin:label',
'admin:seo',
'admin:site',
];
if (!$account->isAuthenticated() || !$account->status) {
// Do not allow deactivated or anymous user to incidently have
// subscribed channels, it would be terrible performance loss
// for pretty much no reason.
$valid = [];
} else {
// Must handle user groupes instead
if ($this->groupManager) {
// @todo We MUST handle a role within the group instead of using
// global permissions, this must be fixed in a near future.
$accessList = $this->groupManager->getUserGroups($account);
if ($accessList) {
// Add group sites to user, but do not add anything else, when
// using the platform with groups, user with no groups are not
// considered and must not receive anything.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
foreach ($accessList as $access) {
$valid[] = 'admin:content:' . $access->getGroupId();
}
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
foreach ($accessList as $access) {
$valid[] = 'admin:site:' . $access->getGroupId();
}
}
}
} else {
// Normal behaviors, when the group module is not enabled.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
$valid[] = 'admin:content';
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
$valid[] = 'admin:site';
}
}
// Those three, as of today, are not group-dependent.
if ($account->hasPermission(Access::PERM_NOTIF_LABEL)) {
$valid[] = 'admin:label';
}
if ($account->hasPermission(Access::PERM_NOTIF_SEO)) {
$valid[] = 'admin:seo';
}
if ($account->hasPermission(Access::PERM_NOTIF_USER)) {
$valid[] = 'admin:client';
}
}
$remove = array_diff($default, $valid);
if ($valid) {
$subscriber = $this->notificationService->getSubscriber($userId);
foreach ($valid as $chanId) {
if ($subscriber->hasSubscriptionFor($chanId)) {
continue;
}
try {
$subscriber->subscribe($chanId);
} catch (ChannelDoesNotExistException $e) {
$this->notificationService->getBackend()->createChannel($chanId);
$subscriber->subscribe($chanId);
}
}
}
if ($remove) {
$this->deleteSubscriptionsFor($userId, $remove);
}
} | php | public function refreshSubscriptionsFor($userId)
{
$valid = ['client:' . $userId];
$account = $this->getUserAccount($userId);
$default = [
'admin:client',
'admin:content',
'admin:label',
'admin:seo',
'admin:site',
];
if (!$account->isAuthenticated() || !$account->status) {
// Do not allow deactivated or anymous user to incidently have
// subscribed channels, it would be terrible performance loss
// for pretty much no reason.
$valid = [];
} else {
// Must handle user groupes instead
if ($this->groupManager) {
// @todo We MUST handle a role within the group instead of using
// global permissions, this must be fixed in a near future.
$accessList = $this->groupManager->getUserGroups($account);
if ($accessList) {
// Add group sites to user, but do not add anything else, when
// using the platform with groups, user with no groups are not
// considered and must not receive anything.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
foreach ($accessList as $access) {
$valid[] = 'admin:content:' . $access->getGroupId();
}
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
foreach ($accessList as $access) {
$valid[] = 'admin:site:' . $access->getGroupId();
}
}
}
} else {
// Normal behaviors, when the group module is not enabled.
if ($account->hasPermission(Access::PERM_NOTIF_CONTENT)) {
$valid[] = 'admin:content';
}
if ($account->hasPermission(Access::PERM_NOTIF_SITE)) {
$valid[] = 'admin:site';
}
}
// Those three, as of today, are not group-dependent.
if ($account->hasPermission(Access::PERM_NOTIF_LABEL)) {
$valid[] = 'admin:label';
}
if ($account->hasPermission(Access::PERM_NOTIF_SEO)) {
$valid[] = 'admin:seo';
}
if ($account->hasPermission(Access::PERM_NOTIF_USER)) {
$valid[] = 'admin:client';
}
}
$remove = array_diff($default, $valid);
if ($valid) {
$subscriber = $this->notificationService->getSubscriber($userId);
foreach ($valid as $chanId) {
if ($subscriber->hasSubscriptionFor($chanId)) {
continue;
}
try {
$subscriber->subscribe($chanId);
} catch (ChannelDoesNotExistException $e) {
$this->notificationService->getBackend()->createChannel($chanId);
$subscriber->subscribe($chanId);
}
}
}
if ($remove) {
$this->deleteSubscriptionsFor($userId, $remove);
}
} | [
"public",
"function",
"refreshSubscriptionsFor",
"(",
"$",
"userId",
")",
"{",
"$",
"valid",
"=",
"[",
"'client:'",
".",
"$",
"userId",
"]",
";",
"$",
"account",
"=",
"$",
"this",
"->",
"getUserAccount",
"(",
"$",
"userId",
")",
";",
"$",
"default",
"=... | Ensure user mandatory subscriptions
Always remember that having the view notifications permissions does not
imply that you can see the content, so users might receive notifications
about content they cannot see; doing otherwise would mean to recheck
all permissions/access rights for all users on every content update which
is not something doable at all.
@param int $userId | [
"Ensure",
"user",
"mandatory",
"subscriptions"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/NotificationService.php#L69-L154 |
makinacorpus/drupal-ucms | ucms_notification/src/NotificationService.php | NotificationService.deleteSubscriptionsFor | public function deleteSubscriptionsFor($userId, $chanIdList = null)
{
$conditions = [
Field::SUBER_NAME => $this
->notificationService
->getSubscriberName($userId),
];
if ($chanIdList) {
$conditions[Field::CHAN_ID] = $chanIdList;
}
$this
->notificationService
->getBackend()
->fetchSubscriptions($conditions)
->delete()
;
} | php | public function deleteSubscriptionsFor($userId, $chanIdList = null)
{
$conditions = [
Field::SUBER_NAME => $this
->notificationService
->getSubscriberName($userId),
];
if ($chanIdList) {
$conditions[Field::CHAN_ID] = $chanIdList;
}
$this
->notificationService
->getBackend()
->fetchSubscriptions($conditions)
->delete()
;
} | [
"public",
"function",
"deleteSubscriptionsFor",
"(",
"$",
"userId",
",",
"$",
"chanIdList",
"=",
"null",
")",
"{",
"$",
"conditions",
"=",
"[",
"Field",
"::",
"SUBER_NAME",
"=>",
"$",
"this",
"->",
"notificationService",
"->",
"getSubscriberName",
"(",
"$",
... | Delete user subscriptions
@param int $userId
@param string[] $chanIdList | [
"Delete",
"user",
"subscriptions"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/NotificationService.php#L162-L180 |
bitExpert/adroit | src/bitExpert/Adroit/Resolver/ContainerResolver.php | ContainerResolver.resolve | public function resolve($identifier)
{
if (!$this->container->has($identifier)) {
$this->logger->error(
sprintf(
'Could not find object defined by id "%s"',
$identifier
)
);
return null;
}
return $this->container->get($identifier);
} | php | public function resolve($identifier)
{
if (!$this->container->has($identifier)) {
$this->logger->error(
sprintf(
'Could not find object defined by id "%s"',
$identifier
)
);
return null;
}
return $this->container->get($identifier);
} | [
"public",
"function",
"resolve",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"identifier",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"'Could not find obj... | {@inheritDoc}
@throws \Psr\Container\ContainerExceptionInterface | [
"{"
] | train | https://github.com/bitExpert/adroit/blob/ecba7e59b864c88bd4639c87194ad842320e5f76/src/bitExpert/Adroit/Resolver/ContainerResolver.php#L49-L63 |
shopgate/cart-integration-sdk | src/models/catalog/Tag.php | Shopgate_Model_Catalog_Tag.asXml | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $tagNode
*/
$tagNode = $itemNode->addChildWithCDATA('tag', $this->getValue());
$tagNode->addAttribute('uid', $this->getUid());
return $itemNode;
} | php | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $tagNode
*/
$tagNode = $itemNode->addChildWithCDATA('tag', $this->getValue());
$tagNode->addAttribute('uid', $this->getUid());
return $itemNode;
} | [
"public",
"function",
"asXml",
"(",
"Shopgate_Model_XmlResultObject",
"$",
"itemNode",
")",
"{",
"/**\n * @var Shopgate_Model_XmlResultObject $tagNode\n */",
"$",
"tagNode",
"=",
"$",
"itemNode",
"->",
"addChildWithCDATA",
"(",
"'tag'",
",",
"$",
"this",
"... | @param Shopgate_Model_XmlResultObject $itemNode
@return Shopgate_Model_XmlResultObject | [
"@param",
"Shopgate_Model_XmlResultObject",
"$itemNode"
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/models/catalog/Tag.php#L51-L60 |
amphp/loop | lib/NativeLoop.php | NativeLoop.onSignal | public function onSignal($signo, callable $callback, $data = null) {
if (!$this->signalHandling) {
throw new UnsupportedFeatureException("Signal handling requires the pcntl extension");
}
return parent::onSignal($signo, $callback, $data);
} | php | public function onSignal($signo, callable $callback, $data = null) {
if (!$this->signalHandling) {
throw new UnsupportedFeatureException("Signal handling requires the pcntl extension");
}
return parent::onSignal($signo, $callback, $data);
} | [
"public",
"function",
"onSignal",
"(",
"$",
"signo",
",",
"callable",
"$",
"callback",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"signalHandling",
")",
"{",
"throw",
"new",
"UnsupportedFeatureException",
"(",
"\"Signal han... | {@inheritdoc}
@throws \AsyncInterop\Loop\UnsupportedFeatureException If the pcntl extension is not available.
@throws \RuntimeException If creating the backend signal handler fails. | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/amphp/loop/blob/c7fbdfb7125e03b5653b13db1950fb45344e8e1b/lib/NativeLoop.php#L173-L179 |
amphp/loop | lib/NativeLoop.php | NativeLoop.activate | protected function activate(array $watchers) {
foreach ($watchers as $watcher) {
switch ($watcher->type) {
case Watcher::READABLE:
$streamId = (int) $watcher->value;
$this->readWatchers[$streamId][$watcher->id] = $watcher;
$this->readStreams[$streamId] = $watcher->value;
break;
case Watcher::WRITABLE:
$streamId = (int) $watcher->value;
$this->writeWatchers[$streamId][$watcher->id] = $watcher;
$this->writeStreams[$streamId] = $watcher->value;
break;
case Watcher::DELAY:
case Watcher::REPEAT:
$expiration = (int) (\microtime(true) * self::MILLISEC_PER_SEC) + $watcher->value;
$this->timerExpires[$watcher->id] = $expiration;
$this->timerQueue->insert([$watcher, $expiration], -$expiration);
break;
case Watcher::SIGNAL:
if (!isset($this->signalWatchers[$watcher->value])) {
if (!@\pcntl_signal($watcher->value, [$this, 'handleSignal'])) {
throw new \RuntimeException("Failed to register signal handler");
}
}
$this->signalWatchers[$watcher->value][$watcher->id] = $watcher;
break;
default:
throw new \DomainException("Unknown watcher type");
}
}
} | php | protected function activate(array $watchers) {
foreach ($watchers as $watcher) {
switch ($watcher->type) {
case Watcher::READABLE:
$streamId = (int) $watcher->value;
$this->readWatchers[$streamId][$watcher->id] = $watcher;
$this->readStreams[$streamId] = $watcher->value;
break;
case Watcher::WRITABLE:
$streamId = (int) $watcher->value;
$this->writeWatchers[$streamId][$watcher->id] = $watcher;
$this->writeStreams[$streamId] = $watcher->value;
break;
case Watcher::DELAY:
case Watcher::REPEAT:
$expiration = (int) (\microtime(true) * self::MILLISEC_PER_SEC) + $watcher->value;
$this->timerExpires[$watcher->id] = $expiration;
$this->timerQueue->insert([$watcher, $expiration], -$expiration);
break;
case Watcher::SIGNAL:
if (!isset($this->signalWatchers[$watcher->value])) {
if (!@\pcntl_signal($watcher->value, [$this, 'handleSignal'])) {
throw new \RuntimeException("Failed to register signal handler");
}
}
$this->signalWatchers[$watcher->value][$watcher->id] = $watcher;
break;
default:
throw new \DomainException("Unknown watcher type");
}
}
} | [
"protected",
"function",
"activate",
"(",
"array",
"$",
"watchers",
")",
"{",
"foreach",
"(",
"$",
"watchers",
"as",
"$",
"watcher",
")",
"{",
"switch",
"(",
"$",
"watcher",
"->",
"type",
")",
"{",
"case",
"Watcher",
"::",
"READABLE",
":",
"$",
"stream... | {@inheritdoc} | [
"{"
] | train | https://github.com/amphp/loop/blob/c7fbdfb7125e03b5653b13db1950fb45344e8e1b/lib/NativeLoop.php#L184-L220 |
amphp/loop | lib/NativeLoop.php | NativeLoop.deactivate | protected function deactivate(Watcher $watcher) {
switch ($watcher->type) {
case Watcher::READABLE:
$streamId = (int) $watcher->value;
unset($this->readWatchers[$streamId][$watcher->id]);
if (empty($this->readWatchers[$streamId])) {
unset($this->readWatchers[$streamId], $this->readStreams[$streamId]);
}
break;
case Watcher::WRITABLE:
$streamId = (int) $watcher->value;
unset($this->writeWatchers[$streamId][$watcher->id]);
if (empty($this->writeWatchers[$streamId])) {
unset($this->writeWatchers[$streamId], $this->writeStreams[$streamId]);
}
break;
case Watcher::DELAY:
case Watcher::REPEAT:
unset($this->timerExpires[$watcher->id]);
break;
case Watcher::SIGNAL:
if (isset($this->signalWatchers[$watcher->value])) {
unset($this->signalWatchers[$watcher->value][$watcher->id]);
if (empty($this->signalWatchers[$watcher->value])) {
unset($this->signalWatchers[$watcher->value]);
@\pcntl_signal($watcher->value, \SIG_DFL);
}
}
break;
default: throw new \DomainException("Unknown watcher type");
}
} | php | protected function deactivate(Watcher $watcher) {
switch ($watcher->type) {
case Watcher::READABLE:
$streamId = (int) $watcher->value;
unset($this->readWatchers[$streamId][$watcher->id]);
if (empty($this->readWatchers[$streamId])) {
unset($this->readWatchers[$streamId], $this->readStreams[$streamId]);
}
break;
case Watcher::WRITABLE:
$streamId = (int) $watcher->value;
unset($this->writeWatchers[$streamId][$watcher->id]);
if (empty($this->writeWatchers[$streamId])) {
unset($this->writeWatchers[$streamId], $this->writeStreams[$streamId]);
}
break;
case Watcher::DELAY:
case Watcher::REPEAT:
unset($this->timerExpires[$watcher->id]);
break;
case Watcher::SIGNAL:
if (isset($this->signalWatchers[$watcher->value])) {
unset($this->signalWatchers[$watcher->value][$watcher->id]);
if (empty($this->signalWatchers[$watcher->value])) {
unset($this->signalWatchers[$watcher->value]);
@\pcntl_signal($watcher->value, \SIG_DFL);
}
}
break;
default: throw new \DomainException("Unknown watcher type");
}
} | [
"protected",
"function",
"deactivate",
"(",
"Watcher",
"$",
"watcher",
")",
"{",
"switch",
"(",
"$",
"watcher",
"->",
"type",
")",
"{",
"case",
"Watcher",
"::",
"READABLE",
":",
"$",
"streamId",
"=",
"(",
"int",
")",
"$",
"watcher",
"->",
"value",
";",... | {@inheritdoc} | [
"{"
] | train | https://github.com/amphp/loop/blob/c7fbdfb7125e03b5653b13db1950fb45344e8e1b/lib/NativeLoop.php#L225-L261 |
accompli/accompli | src/Console/Command/InitCommand.php | InitCommand.interact | protected function interact(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO($input, $output);
$io->write(Accompli::LOGO);
$io->writeln(' =========================');
$io->writeln(' Configuration generator');
$io->writeln(' =========================');
$accompli = new Accompli(new ParameterBag());
$accompli->initializeStreamWrapper();
$recipe = $io->choice('Select a recipe to extend from', $this->getAvailableRecipes(), 'defaults.json');
if ($recipe === 'Other') {
$this->configuration['$extend'] = $io->ask('Enter the path to the recipe');
} elseif ($recipe === 'None') {
unset($this->configuration['$extend']);
} else {
$this->configuration['$extend'] = 'accompli://recipe/'.$recipe;
}
$this->interactForHostConfigurations($io);
$this->interactForTaskConfigurations($io);
$io->writeln(' The generator will create the following configuration:');
$io->writeln($this->getJsonEncodedConfiguration());
$io->confirm('Do you wish to continue?');
} | php | protected function interact(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO($input, $output);
$io->write(Accompli::LOGO);
$io->writeln(' =========================');
$io->writeln(' Configuration generator');
$io->writeln(' =========================');
$accompli = new Accompli(new ParameterBag());
$accompli->initializeStreamWrapper();
$recipe = $io->choice('Select a recipe to extend from', $this->getAvailableRecipes(), 'defaults.json');
if ($recipe === 'Other') {
$this->configuration['$extend'] = $io->ask('Enter the path to the recipe');
} elseif ($recipe === 'None') {
unset($this->configuration['$extend']);
} else {
$this->configuration['$extend'] = 'accompli://recipe/'.$recipe;
}
$this->interactForHostConfigurations($io);
$this->interactForTaskConfigurations($io);
$io->writeln(' The generator will create the following configuration:');
$io->writeln($this->getJsonEncodedConfiguration());
$io->confirm('Do you wish to continue?');
} | [
"protected",
"function",
"interact",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"$",
"this",
"->",
"getIO",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"io",
"->",
"write",
"(",
"Ac... | Interacts with the user to retrieve the configuration for an accompli.json file.
@param InputInterface $input
@param OutputInterface $output | [
"Interacts",
"with",
"the",
"user",
"to",
"retrieve",
"the",
"configuration",
"for",
"an",
"accompli",
".",
"json",
"file",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L66-L92 |
accompli/accompli | src/Console/Command/InitCommand.php | InitCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO($input, $output);
$configurationFile = $input->getOption('working-dir').'/accompli.json';
$filesystem = new Filesystem();
if ($filesystem->exists($configurationFile) === false || $io->confirm('An Accompli configuration file already exists. Do you wish to overwrite it?')) {
$filesystem->dumpFile($configurationFile, $this->getJsonEncodedConfiguration());
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$io = $this->getIO($input, $output);
$configurationFile = $input->getOption('working-dir').'/accompli.json';
$filesystem = new Filesystem();
if ($filesystem->exists($configurationFile) === false || $io->confirm('An Accompli configuration file already exists. Do you wish to overwrite it?')) {
$filesystem->dumpFile($configurationFile, $this->getJsonEncodedConfiguration());
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"$",
"this",
"->",
"getIO",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"configurationFile",
"=",
"$",
"... | Executes this command.
@param InputInterface $input
@param OutputInterface $output | [
"Executes",
"this",
"command",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L100-L110 |
accompli/accompli | src/Console/Command/InitCommand.php | InitCommand.interactForHostConfigurations | private function interactForHostConfigurations(OutputStyle $io)
{
$io->writeln(' Add host configurations:');
$addHost = true;
while ($addHost) {
$stage = $io->choice('Stage', array(
Host::STAGE_PRODUCTION,
Host::STAGE_ACCEPTANCE,
Host::STAGE_TEST,
));
$hostname = $io->ask('Hostname');
$path = $io->ask('Workspace path');
$connectionType = $io->ask('Connection type (eg. local or ssh)');
$this->configuration['hosts'][] = array(
'stage' => $stage,
'connectionType' => $connectionType,
'hostname' => $hostname,
'path' => $path,
);
$addHost = $io->confirm('Add another host?');
}
} | php | private function interactForHostConfigurations(OutputStyle $io)
{
$io->writeln(' Add host configurations:');
$addHost = true;
while ($addHost) {
$stage = $io->choice('Stage', array(
Host::STAGE_PRODUCTION,
Host::STAGE_ACCEPTANCE,
Host::STAGE_TEST,
));
$hostname = $io->ask('Hostname');
$path = $io->ask('Workspace path');
$connectionType = $io->ask('Connection type (eg. local or ssh)');
$this->configuration['hosts'][] = array(
'stage' => $stage,
'connectionType' => $connectionType,
'hostname' => $hostname,
'path' => $path,
);
$addHost = $io->confirm('Add another host?');
}
} | [
"private",
"function",
"interactForHostConfigurations",
"(",
"OutputStyle",
"$",
"io",
")",
"{",
"$",
"io",
"->",
"writeln",
"(",
"' Add host configurations:'",
")",
";",
"$",
"addHost",
"=",
"true",
";",
"while",
"(",
"$",
"addHost",
")",
"{",
"$",
"stage",... | Interacts with the user to retrieve host configurations.
@param OutputStyle $io | [
"Interacts",
"with",
"the",
"user",
"to",
"retrieve",
"host",
"configurations",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L117-L141 |
accompli/accompli | src/Console/Command/InitCommand.php | InitCommand.interactForTaskConfigurations | private function interactForTaskConfigurations(OutputStyle $io)
{
$io->writeln(' Add tasks:');
$addTask = true;
while ($addTask) {
$taskQuestion = new Question('Search for a task');
$taskQuestion->setAutocompleterValues($this->getAvailableTasks());
$taskQuestion->setValidator(function ($answer) {
if (class_exists($answer) === false && class_exists('Accompli\\Task\\'.$answer) === true) {
$answer = 'Accompli\\Task\\'.$answer;
}
if (class_exists($answer) === false || in_array(TaskInterface::class, class_implements($answer)) === false) {
throw new InvalidArgumentException(sprintf('The task "%s" does not exist.', $answer));
}
return $answer;
});
$task = $io->askQuestion($taskQuestion);
$taskConfiguration = array_merge(
array(
'class' => $task,
),
$this->getTaskConfigurationParameters($task)
);
$this->configuration['events']['subscribers'][] = $taskConfiguration;
$addTask = $io->confirm('Add another task?');
}
} | php | private function interactForTaskConfigurations(OutputStyle $io)
{
$io->writeln(' Add tasks:');
$addTask = true;
while ($addTask) {
$taskQuestion = new Question('Search for a task');
$taskQuestion->setAutocompleterValues($this->getAvailableTasks());
$taskQuestion->setValidator(function ($answer) {
if (class_exists($answer) === false && class_exists('Accompli\\Task\\'.$answer) === true) {
$answer = 'Accompli\\Task\\'.$answer;
}
if (class_exists($answer) === false || in_array(TaskInterface::class, class_implements($answer)) === false) {
throw new InvalidArgumentException(sprintf('The task "%s" does not exist.', $answer));
}
return $answer;
});
$task = $io->askQuestion($taskQuestion);
$taskConfiguration = array_merge(
array(
'class' => $task,
),
$this->getTaskConfigurationParameters($task)
);
$this->configuration['events']['subscribers'][] = $taskConfiguration;
$addTask = $io->confirm('Add another task?');
}
} | [
"private",
"function",
"interactForTaskConfigurations",
"(",
"OutputStyle",
"$",
"io",
")",
"{",
"$",
"io",
"->",
"writeln",
"(",
"' Add tasks:'",
")",
";",
"$",
"addTask",
"=",
"true",
";",
"while",
"(",
"$",
"addTask",
")",
"{",
"$",
"taskQuestion",
"=",... | Interacts with the user to retrieve task configurations.
@param OutputStyle $io | [
"Interacts",
"with",
"the",
"user",
"to",
"retrieve",
"task",
"configurations",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L148-L180 |
accompli/accompli | src/Console/Command/InitCommand.php | InitCommand.getTaskConfigurationParameters | private function getTaskConfigurationParameters($taskClass)
{
$parameters = array();
$reflectionClass = new ReflectionClass($taskClass);
$reflectionConstructorMethod = $reflectionClass->getConstructor();
if ($reflectionConstructorMethod instanceof ReflectionMethod) {
foreach ($reflectionConstructorMethod->getParameters() as $reflectionParameter) {
if ($reflectionParameter instanceof ReflectionParameter && $reflectionParameter->isDefaultValueAvailable() === false) {
$parameterValue = '';
if ($reflectionParameter->isArray()) {
$parameterValue = array();
}
$parameters[$reflectionParameter->getName()] = $parameterValue;
}
}
}
return $parameters;
} | php | private function getTaskConfigurationParameters($taskClass)
{
$parameters = array();
$reflectionClass = new ReflectionClass($taskClass);
$reflectionConstructorMethod = $reflectionClass->getConstructor();
if ($reflectionConstructorMethod instanceof ReflectionMethod) {
foreach ($reflectionConstructorMethod->getParameters() as $reflectionParameter) {
if ($reflectionParameter instanceof ReflectionParameter && $reflectionParameter->isDefaultValueAvailable() === false) {
$parameterValue = '';
if ($reflectionParameter->isArray()) {
$parameterValue = array();
}
$parameters[$reflectionParameter->getName()] = $parameterValue;
}
}
}
return $parameters;
} | [
"private",
"function",
"getTaskConfigurationParameters",
"(",
"$",
"taskClass",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
")",
";",
"$",
"reflectionClass",
"=",
"new",
"ReflectionClass",
"(",
"$",
"taskClass",
")",
";",
"$",
"reflectionConstructorMethod",
... | Returns the required configuration parameters of the task.
@param string $taskClass
@return array | [
"Returns",
"the",
"required",
"configuration",
"parameters",
"of",
"the",
"task",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L189-L209 |
accompli/accompli | src/Console/Command/InitCommand.php | InitCommand.getIO | private function getIO(InputInterface $input, OutputInterface $output)
{
if ($this->io instanceof OutputStyle === false) {
$this->io = new SymfonyStyle($input, $output);
}
return $this->io;
} | php | private function getIO(InputInterface $input, OutputInterface $output)
{
if ($this->io instanceof OutputStyle === false) {
$this->io = new SymfonyStyle($input, $output);
}
return $this->io;
} | [
"private",
"function",
"getIO",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"io",
"instanceof",
"OutputStyle",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"io",
"=",
"new",
"Symfony... | Returns the instance handling input and output of this command.
@param InputInterface $input
@param OutputInterface $output
@return OutputStyle | [
"Returns",
"the",
"instance",
"handling",
"input",
"and",
"output",
"of",
"this",
"command",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L229-L236 |
accompli/accompli | src/Console/Command/InitCommand.php | InitCommand.getAvailableTasks | private function getAvailableTasks()
{
$tasks = array_map(function ($task) {
return substr($task, 0, -4);
}, array_diff(scandir(__DIR__.'/../../Task'), array('.', '..')));
sort($tasks);
return $tasks;
} | php | private function getAvailableTasks()
{
$tasks = array_map(function ($task) {
return substr($task, 0, -4);
}, array_diff(scandir(__DIR__.'/../../Task'), array('.', '..')));
sort($tasks);
return $tasks;
} | [
"private",
"function",
"getAvailableTasks",
"(",
")",
"{",
"$",
"tasks",
"=",
"array_map",
"(",
"function",
"(",
"$",
"task",
")",
"{",
"return",
"substr",
"(",
"$",
"task",
",",
"0",
",",
"-",
"4",
")",
";",
"}",
",",
"array_diff",
"(",
"scandir",
... | Returns the available tasks within Accompli.
@return array | [
"Returns",
"the",
"available",
"tasks",
"within",
"Accompli",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Console/Command/InitCommand.php#L258-L267 |
makinacorpus/drupal-ucms | ucms_seo/src/Path/RedirectStorage.php | RedirectStorage.save | public function save($path, $node_id, $site_id = null, $id = null)
{
if (!$site_id) {
if (!$this->siteManager->hasContext()) {
return false;
}
$site_id = $this->siteManager->getContext()->getId();
}
$redirect = [
'path' => $path,
'nid' => $node_id,
'site_id' => $site_id,
];
if ($id) {
$redirect['id'] = $id;
$this
->database
->merge('ucms_seo_redirect')
->key(['id' => $id])
->fields($redirect)
->execute()
;
$this->moduleHandler->invokeAll('redirect_insert', [$redirect]);
} else {
$this
->database
->insert('ucms_seo_redirect')
->fields($redirect)
->execute()
;
$this->moduleHandler->invokeAll('redirect_update', [$redirect]);
}
return $redirect;
} | php | public function save($path, $node_id, $site_id = null, $id = null)
{
if (!$site_id) {
if (!$this->siteManager->hasContext()) {
return false;
}
$site_id = $this->siteManager->getContext()->getId();
}
$redirect = [
'path' => $path,
'nid' => $node_id,
'site_id' => $site_id,
];
if ($id) {
$redirect['id'] = $id;
$this
->database
->merge('ucms_seo_redirect')
->key(['id' => $id])
->fields($redirect)
->execute()
;
$this->moduleHandler->invokeAll('redirect_insert', [$redirect]);
} else {
$this
->database
->insert('ucms_seo_redirect')
->fields($redirect)
->execute()
;
$this->moduleHandler->invokeAll('redirect_update', [$redirect]);
}
return $redirect;
} | [
"public",
"function",
"save",
"(",
"$",
"path",
",",
"$",
"node_id",
",",
"$",
"site_id",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"site_id",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"siteManager",
"->",
"has... | {@inheritDoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/RedirectStorage.php#L45-L86 |
makinacorpus/drupal-ucms | ucms_seo/src/Path/RedirectStorage.php | RedirectStorage.load | public function load($conditions)
{
$select = $this->database->select('ucms_seo_redirect', 'u');
foreach ($conditions as $field => $value) {
if ($field == 'path') {
// Use LIKE for case-insensitive matching (stupid).
$select->condition('u.'.$field, $this->database->escapeLike($value), 'LIKE');
} else {
$select->condition('u.'.$field, $value);
}
}
return $select
->fields('u')
->orderBy('u.id', 'DESC')
->range(0, 1)
->execute()
->fetchObject(Redirect::class)
;
} | php | public function load($conditions)
{
$select = $this->database->select('ucms_seo_redirect', 'u');
foreach ($conditions as $field => $value) {
if ($field == 'path') {
// Use LIKE for case-insensitive matching (stupid).
$select->condition('u.'.$field, $this->database->escapeLike($value), 'LIKE');
} else {
$select->condition('u.'.$field, $value);
}
}
return $select
->fields('u')
->orderBy('u.id', 'DESC')
->range(0, 1)
->execute()
->fetchObject(Redirect::class)
;
} | [
"public",
"function",
"load",
"(",
"$",
"conditions",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"database",
"->",
"select",
"(",
"'ucms_seo_redirect'",
",",
"'u'",
")",
";",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"field",
"=>",
"$",
"valu... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/RedirectStorage.php#L91-L111 |
makinacorpus/drupal-ucms | ucms_seo/src/Path/RedirectStorage.php | RedirectStorage.delete | public function delete($conditions)
{
$path = $this->load($conditions);
$query = $this->database->delete('ucms_seo_redirect');
foreach ($conditions as $field => $value) {
if ($field == 'path') {
// Use LIKE for case-insensitive matching (still stupid).
$query->condition($field, $this->database->escapeLike($value), 'LIKE');
} else {
$query->condition($field, $value);
}
}
$deleted = $query->execute();
$this->moduleHandler->invokeAll('redirect_delete', [$path]);
return $deleted;
} | php | public function delete($conditions)
{
$path = $this->load($conditions);
$query = $this->database->delete('ucms_seo_redirect');
foreach ($conditions as $field => $value) {
if ($field == 'path') {
// Use LIKE for case-insensitive matching (still stupid).
$query->condition($field, $this->database->escapeLike($value), 'LIKE');
} else {
$query->condition($field, $value);
}
}
$deleted = $query->execute();
$this->moduleHandler->invokeAll('redirect_delete', [$path]);
return $deleted;
} | [
"public",
"function",
"delete",
"(",
"$",
"conditions",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"load",
"(",
"$",
"conditions",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"database",
"->",
"delete",
"(",
"'ucms_seo_redirect'",
")",
";",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/RedirectStorage.php#L116-L135 |
makinacorpus/drupal-ucms | ucms_seo/src/Path/RedirectStorage.php | RedirectStorage.redirectExists | public function redirectExists($path, $node_id, $site_id = null)
{
if (!$site_id) {
if (!$this->siteManager->hasContext()) {
return false;
}
$site_id = $this->siteManager->getContext()->getId();
}
// Use LIKE and NOT LIKE for case-insensitive matching (stupid).
$query = $this
->database
->select('ucms_seo_redirect', 'u')
->condition('u.path', $this->database->escapeLike($path), 'LIKE')
->condition('u.nid', $node_id)
->condition('u.site_id', $site_id)
;
$query->addExpression('1');
return (bool)$query
->range(0, 1)
->execute()
->fetchField()
;
} | php | public function redirectExists($path, $node_id, $site_id = null)
{
if (!$site_id) {
if (!$this->siteManager->hasContext()) {
return false;
}
$site_id = $this->siteManager->getContext()->getId();
}
// Use LIKE and NOT LIKE for case-insensitive matching (stupid).
$query = $this
->database
->select('ucms_seo_redirect', 'u')
->condition('u.path', $this->database->escapeLike($path), 'LIKE')
->condition('u.nid', $node_id)
->condition('u.site_id', $site_id)
;
$query->addExpression('1');
return (bool)$query
->range(0, 1)
->execute()
->fetchField()
;
} | [
"public",
"function",
"redirectExists",
"(",
"$",
"path",
",",
"$",
"node_id",
",",
"$",
"site_id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"site_id",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"siteManager",
"->",
"hasContext",
"(",
")",
")"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/Path/RedirectStorage.php#L140-L165 |
jeremyFreeAgent/Bitter | src/FreeAgent/Bitter/Bitter.php | Bitter.mark | public function mark($eventName, $id, DateTime $dateTime = null)
{
$dateTime = is_null($dateTime) ? new DateTime : $dateTime;
$eventData = array(
new Year($eventName, $dateTime),
new Month($eventName, $dateTime),
new Week($eventName, $dateTime),
new Day($eventName, $dateTime),
new Hour($eventName, $dateTime),
);
foreach ($eventData as $event) {
$key = $this->prefixKey . $event->getKey();
$this->getRedisClient()->setbit($key, $id, 1);
$this->getRedisClient()->sadd($this->prefixKey . 'keys', $key);
}
return $this;
} | php | public function mark($eventName, $id, DateTime $dateTime = null)
{
$dateTime = is_null($dateTime) ? new DateTime : $dateTime;
$eventData = array(
new Year($eventName, $dateTime),
new Month($eventName, $dateTime),
new Week($eventName, $dateTime),
new Day($eventName, $dateTime),
new Hour($eventName, $dateTime),
);
foreach ($eventData as $event) {
$key = $this->prefixKey . $event->getKey();
$this->getRedisClient()->setbit($key, $id, 1);
$this->getRedisClient()->sadd($this->prefixKey . 'keys', $key);
}
return $this;
} | [
"public",
"function",
"mark",
"(",
"$",
"eventName",
",",
"$",
"id",
",",
"DateTime",
"$",
"dateTime",
"=",
"null",
")",
"{",
"$",
"dateTime",
"=",
"is_null",
"(",
"$",
"dateTime",
")",
"?",
"new",
"DateTime",
":",
"$",
"dateTime",
";",
"$",
"eventDa... | Marks an event for hours, days, weeks and months
@param string $eventName The name of the event, could be "active" or "new_signups"
@param integer $id An unique id, typically user id. The id should not be huge, read Redis documentation why (bitmaps)
@param DateTime $dateTime Which date should be used as a reference point, default is now | [
"Marks",
"an",
"event",
"for",
"hours",
"days",
"weeks",
"and",
"months"
] | train | https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L62-L81 |
jeremyFreeAgent/Bitter | src/FreeAgent/Bitter/Bitter.php | Bitter.in | public function in($id, $key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (bool) $this->getRedisClient()->getbit($key, $id);
} | php | public function in($id, $key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (bool) $this->getRedisClient()->getbit($key, $id);
} | [
"public",
"function",
"in",
"(",
"$",
"id",
",",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"instanceof",
"UnitOfTimeInterface",
"?",
"$",
"this",
"->",
"prefixKey",
".",
"$",
"key",
"->",
"getKey",
"(",
")",
":",
"$",
"this",
"->",
"prefix... | Makes it possible to see if an id has been marked
@param integer $id An unique id
@param mixed $key The key or the event
@return boolean True if the id has been marked | [
"Makes",
"it",
"possible",
"to",
"see",
"if",
"an",
"id",
"has",
"been",
"marked"
] | train | https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L90-L95 |
jeremyFreeAgent/Bitter | src/FreeAgent/Bitter/Bitter.php | Bitter.count | public function count($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (int) $this->getRedisClient()->bitcount($key);
} | php | public function count($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
return (int) $this->getRedisClient()->bitcount($key);
} | [
"public",
"function",
"count",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"instanceof",
"UnitOfTimeInterface",
"?",
"$",
"this",
"->",
"prefixKey",
".",
"$",
"key",
"->",
"getKey",
"(",
")",
":",
"$",
"this",
"->",
"prefixTempKey",
".",
... | Counts the number of marks
@param mixed $key The key or the event
@return integer The value of the count result | [
"Counts",
"the",
"number",
"of",
"marks"
] | train | https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L103-L108 |
jeremyFreeAgent/Bitter | src/FreeAgent/Bitter/Bitter.php | Bitter.getIds | public function getIds($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
$string = $this->getRedisClient()->get($key);
$data = $this->bitsetToString($string);
$ids = array();
while (false !== ($pos = strpos($data, '1'))) {
$data[$pos] = 0;
$ids[] = (int)($pos/8)*8 + abs(7-($pos%8));
}
sort($ids);
return $ids;
} | php | public function getIds($key)
{
$key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;
$string = $this->getRedisClient()->get($key);
$data = $this->bitsetToString($string);
$ids = array();
while (false !== ($pos = strpos($data, '1'))) {
$data[$pos] = 0;
$ids[] = (int)($pos/8)*8 + abs(7-($pos%8));
}
sort($ids);
return $ids;
} | [
"public",
"function",
"getIds",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"$",
"key",
"instanceof",
"UnitOfTimeInterface",
"?",
"$",
"this",
"->",
"prefixKey",
".",
"$",
"key",
"->",
"getKey",
"(",
")",
":",
"$",
"this",
"->",
"prefixTempKey",
".",
... | Returns the ids of an key or event
@param mixed $key The key or the event
@return array The ids array | [
"Returns",
"the",
"ids",
"of",
"an",
"key",
"or",
"event"
] | train | https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L199-L216 |
jeremyFreeAgent/Bitter | src/FreeAgent/Bitter/Bitter.php | Bitter.removeAll | public function removeAll()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
} | php | public function removeAll()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
} | [
"public",
"function",
"removeAll",
"(",
")",
"{",
"$",
"keys_chunk",
"=",
"array_chunk",
"(",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"smembers",
"(",
"$",
"this",
"->",
"prefixKey",
".",
"'keys'",
")",
",",
"100",
")",
";",
"foreach",
"("... | Removes all Bitter keys | [
"Removes",
"all",
"Bitter",
"keys"
] | train | https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L226-L235 |
jeremyFreeAgent/Bitter | src/FreeAgent/Bitter/Bitter.php | Bitter.removeTemp | public function removeTemp()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixTempKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
} | php | public function removeTemp()
{
$keys_chunk = array_chunk($this->getRedisClient()->smembers($this->prefixTempKey . 'keys'), 100);
foreach ($keys_chunk as $keys) {
$this->getRedisClient()->del($keys);
}
return $this;
} | [
"public",
"function",
"removeTemp",
"(",
")",
"{",
"$",
"keys_chunk",
"=",
"array_chunk",
"(",
"$",
"this",
"->",
"getRedisClient",
"(",
")",
"->",
"smembers",
"(",
"$",
"this",
"->",
"prefixTempKey",
".",
"'keys'",
")",
",",
"100",
")",
";",
"foreach",
... | Removes all Bitter temp keys | [
"Removes",
"all",
"Bitter",
"temp",
"keys"
] | train | https://github.com/jeremyFreeAgent/Bitter/blob/018742b098c937039909997e005f47201161686f/src/FreeAgent/Bitter/Bitter.php#L240-L249 |
shpasser/GaeSupport | src/Shpasser/GaeSupport/Setup/SetupCommand.php | SetupCommand.fire | public function fire()
{
$configurator = new Configurator($this);
$configurator->configure(
$this->argument('app-id'),
$this->option('config'),
$this->option('bucket'));
} | php | public function fire()
{
$configurator = new Configurator($this);
$configurator->configure(
$this->argument('app-id'),
$this->option('config'),
$this->option('bucket'));
} | [
"public",
"function",
"fire",
"(",
")",
"{",
"$",
"configurator",
"=",
"new",
"Configurator",
"(",
"$",
"this",
")",
";",
"$",
"configurator",
"->",
"configure",
"(",
"$",
"this",
"->",
"argument",
"(",
"'app-id'",
")",
",",
"$",
"this",
"->",
"option"... | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/shpasser/GaeSupport/blob/7f37f2bf177a4e8f1cbefdf04f49b51016e85ae3/src/Shpasser/GaeSupport/Setup/SetupCommand.php#L36-L43 |
potsky/microsoft-translator-php-sdk | src/MicrosoftTranslator/Http.php | Http.get | public function get($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'GET', $access_token, $parameters, $contentType);
} | php | public function get($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'GET', $access_token, $parameters, $contentType);
} | [
"public",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'GET'",... | GET API endpoint
@param string $url
@param string|null $access_token
@param array $parameters
@param string $contentType
@return array | [
"GET",
"API",
"endpoint"
] | train | https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L126-L129 |
potsky/microsoft-translator-php-sdk | src/MicrosoftTranslator/Http.php | Http.post | public function post($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'POST', $access_token, $parameters, $contentType);
} | php | public function post($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'POST', $access_token, $parameters, $contentType);
} | [
"public",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'POST'... | POST API endpoint
@param string $url
@param string|null $access_token
@param string|array $parameters
@param string $contentType
@return array | [
"POST",
"API",
"endpoint"
] | train | https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L141-L144 |
potsky/microsoft-translator-php-sdk | src/MicrosoftTranslator/Http.php | Http.put | public function put($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'PUT', $access_token, $parameters, $contentType);
} | php | public function put($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'PUT', $access_token, $parameters, $contentType);
} | [
"public",
"function",
"put",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'PUT'",... | PUT API endpoint
@param string $url
@param string|null $access_token
@param string|array $parameters
@param string $contentType
@return array | [
"PUT",
"API",
"endpoint"
] | train | https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L156-L159 |
potsky/microsoft-translator-php-sdk | src/MicrosoftTranslator/Http.php | Http.delete | public function delete($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'DELETE', $access_token, $parameters, $contentType);
} | php | public function delete($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
return $this->doApiCall($url, 'DELETE', $access_token, $parameters, $contentType);
} | [
"public",
"function",
"delete",
"(",
"$",
"url",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"return",
"$",
"this",
"->",
"doApiCall",
"(",
"$",
"url",
",",
"'DEL... | DELETE API endpoint
@param string $url
@param string|null $access_token
@param string|array $parameters
@param string $contentType
@return array | [
"DELETE",
"API",
"endpoint"
] | train | https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L171-L174 |
potsky/microsoft-translator-php-sdk | src/MicrosoftTranslator/Http.php | Http.execCurl | public function execCurl(array $config)
{
$config[CURLOPT_VERBOSE] = false;
$config[CURLOPT_SSL_VERIFYPEER] = false;
$config[CURLOPT_RETURNTRANSFER] = true;
if (defined('CURLOPT_IPRESOLVE')) // PHP5.3
{
$config[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
}
$ch = curl_init();
foreach ($config as $key => $value) {
curl_setopt($ch, $key, $value);
}
$result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
$error_code = curl_errno($ch);
curl_close($ch);
return [$result, $status_code, $error, $error_code];
} | php | public function execCurl(array $config)
{
$config[CURLOPT_VERBOSE] = false;
$config[CURLOPT_SSL_VERIFYPEER] = false;
$config[CURLOPT_RETURNTRANSFER] = true;
if (defined('CURLOPT_IPRESOLVE')) // PHP5.3
{
$config[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4;
}
$ch = curl_init();
foreach ($config as $key => $value) {
curl_setopt($ch, $key, $value);
}
$result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
$error_code = curl_errno($ch);
curl_close($ch);
return [$result, $status_code, $error, $error_code];
} | [
"public",
"function",
"execCurl",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"config",
"[",
"CURLOPT_VERBOSE",
"]",
"=",
"false",
";",
"$",
"config",
"[",
"CURLOPT_SSL_VERIFYPEER",
"]",
"=",
"false",
";",
"$",
"config",
"[",
"CURLOPT_RETURNTRANSFER",
"]",
... | Execute the request with cURL
Made public for unit tests, you can publicly call it but this method is not really interesting!
@param array $config
@return array | [
"Execute",
"the",
"request",
"with",
"cURL"
] | train | https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L185-L210 |
potsky/microsoft-translator-php-sdk | src/MicrosoftTranslator/Http.php | Http.doApiCall | private function doApiCall($url, $method, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
$request = [];
$headers = [];
$request[CURLOPT_TIMEOUT] = (int) $this->http_timeout;
$request[CURLOPT_USERAGENT] = str_replace('%VERSION%', Client::VERSION, $this->http_user_agent);
$request[CURLOPT_CUSTOMREQUEST] = $method;
if (isset($parameters['Ocp-Apim-Subscription-Key'])) {
$headers[] = "Ocp-Apim-Subscription-Key: ".$parameters['Ocp-Apim-Subscription-Key'];
$headers[] = "Content-Length: 0";
unset($parameters['Ocp-Apim-Subscription-Key']);
}
if (! empty($parameters)) {
if ($method === 'GET') {
$url = Tools::httpBuildUrl($url, ["query" => http_build_query($parameters)], Tools::HTTP_URL_JOIN_QUERY);
} else {
if (is_array($parameters)) {
$request[CURLOPT_POSTFIELDS] = http_build_query($parameters);
} else {
if (is_string($parameters)) {
$request[CURLOPT_POSTFIELDS] = $parameters;
}
}
}
}
$request[CURLOPT_URL] = $url;
if (! is_null($contentType)) {
$headers[] = "Content-Type: $contentType";
}
if (! is_null($access_token)) {
$headers[] = 'Authorization: Bearer '.$access_token;
}
if (! empty($this->http_proxy_host)) {
$request[CURLOPT_PROXY] = $this->http_proxy_host;
if (! empty($this->http_proxy_port)) {
$request[CURLOPT_PROXYPORT] = $this->http_proxy_port;
}
if (! empty($this->http_proxy_type)) {
$request[CURLOPT_PROXYTYPE] = $this->http_proxy_type;
}
if (! empty($this->http_proxy_auth)) {
$request[CURLOPT_PROXYAUTH] = $this->http_proxy_auth;
}
if (! empty($this->http_proxy_user)) {
$request[CURLOPT_PROXYUSERPWD] = $this->http_proxy_user.':'.$this->http_proxy_pass;
}
}
$request[CURLOPT_HTTPHEADER] = $headers;
$this->logger->info(__CLASS__, 'api', sprintf('%s %s', $method, $url));
$start = microtime(true);
@list($result, $status_code, $error, $errno) = $this->execCurl($request);
$end = microtime(true);
$duration = (int) round(($end - $start) * 1000);
if ($errno === 0) {
$return = [
'http_code' => $status_code,
'http_body' => $result,
'duration' => $duration,
];
if ($status_code >= 400) {
$this->logger->error(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
} else {
if ($status_code >= 300) {
$this->logger->warning(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
} else {
$this->logger->info(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms', $status_code, strlen($result), $duration));
}
}
} else {
$return = [
'error_msg' => $error,
'error_num' => $errno,
'duration' => $duration,
];
$this->logger->error(__CLASS__, 'api', sprintf('cURL error #%s : %s', $errno, $error));
}
return $return;
} | php | private function doApiCall($url, $method, $access_token = null, $parameters = [], $contentType = 'text/xml')
{
$request = [];
$headers = [];
$request[CURLOPT_TIMEOUT] = (int) $this->http_timeout;
$request[CURLOPT_USERAGENT] = str_replace('%VERSION%', Client::VERSION, $this->http_user_agent);
$request[CURLOPT_CUSTOMREQUEST] = $method;
if (isset($parameters['Ocp-Apim-Subscription-Key'])) {
$headers[] = "Ocp-Apim-Subscription-Key: ".$parameters['Ocp-Apim-Subscription-Key'];
$headers[] = "Content-Length: 0";
unset($parameters['Ocp-Apim-Subscription-Key']);
}
if (! empty($parameters)) {
if ($method === 'GET') {
$url = Tools::httpBuildUrl($url, ["query" => http_build_query($parameters)], Tools::HTTP_URL_JOIN_QUERY);
} else {
if (is_array($parameters)) {
$request[CURLOPT_POSTFIELDS] = http_build_query($parameters);
} else {
if (is_string($parameters)) {
$request[CURLOPT_POSTFIELDS] = $parameters;
}
}
}
}
$request[CURLOPT_URL] = $url;
if (! is_null($contentType)) {
$headers[] = "Content-Type: $contentType";
}
if (! is_null($access_token)) {
$headers[] = 'Authorization: Bearer '.$access_token;
}
if (! empty($this->http_proxy_host)) {
$request[CURLOPT_PROXY] = $this->http_proxy_host;
if (! empty($this->http_proxy_port)) {
$request[CURLOPT_PROXYPORT] = $this->http_proxy_port;
}
if (! empty($this->http_proxy_type)) {
$request[CURLOPT_PROXYTYPE] = $this->http_proxy_type;
}
if (! empty($this->http_proxy_auth)) {
$request[CURLOPT_PROXYAUTH] = $this->http_proxy_auth;
}
if (! empty($this->http_proxy_user)) {
$request[CURLOPT_PROXYUSERPWD] = $this->http_proxy_user.':'.$this->http_proxy_pass;
}
}
$request[CURLOPT_HTTPHEADER] = $headers;
$this->logger->info(__CLASS__, 'api', sprintf('%s %s', $method, $url));
$start = microtime(true);
@list($result, $status_code, $error, $errno) = $this->execCurl($request);
$end = microtime(true);
$duration = (int) round(($end - $start) * 1000);
if ($errno === 0) {
$return = [
'http_code' => $status_code,
'http_body' => $result,
'duration' => $duration,
];
if ($status_code >= 400) {
$this->logger->error(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
} else {
if ($status_code >= 300) {
$this->logger->warning(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms on endpoint %s %s', $status_code, strlen($result), $duration, $method, $url));
} else {
$this->logger->info(__CLASS__, 'api', sprintf('Response HTTP code %s, body length %s bytes, duration %sms', $status_code, strlen($result), $duration));
}
}
} else {
$return = [
'error_msg' => $error,
'error_num' => $errno,
'duration' => $duration,
];
$this->logger->error(__CLASS__, 'api', sprintf('cURL error #%s : %s', $errno, $error));
}
return $return;
} | [
"private",
"function",
"doApiCall",
"(",
"$",
"url",
",",
"$",
"method",
",",
"$",
"access_token",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"contentType",
"=",
"'text/xml'",
")",
"{",
"$",
"request",
"=",
"[",
"]",
";",
"$",
"h... | @param string $url
@param string $method
@param string|null $access_token
@param string|array $parameters
@param string $contentType
@return array | [
"@param",
"string",
"$url",
"@param",
"string",
"$method",
"@param",
"string|null",
"$access_token",
"@param",
"string|array",
"$parameters",
"@param",
"string",
"$contentType"
] | train | https://github.com/potsky/microsoft-translator-php-sdk/blob/102f2411be5abb0e57a73c475f8e9e185a9f4859/src/MicrosoftTranslator/Http.php#L221-L317 |
makinacorpus/drupal-ucms | ucms_contrib/src/Form/NodeMakeGlobal.php | NodeMakeGlobal.buildForm | public function buildForm(array $form, FormStateInterface $formState, NodeInterface $node = null)
{
$formState->setTemporaryValue('node', $node);
return confirm_form($form, $this->t("Add %title to global contents?", ['%title' => $node->title]), 'node/' . $node->id(), '');
} | php | public function buildForm(array $form, FormStateInterface $formState, NodeInterface $node = null)
{
$formState->setTemporaryValue('node', $node);
return confirm_form($form, $this->t("Add %title to global contents?", ['%title' => $node->title]), 'node/' . $node->id(), '');
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"formState",
",",
"NodeInterface",
"$",
"node",
"=",
"null",
")",
"{",
"$",
"formState",
"->",
"setTemporaryValue",
"(",
"'node'",
",",
"$",
"node",
")",
";",
"re... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Form/NodeMakeGlobal.php#L44-L49 |
makinacorpus/drupal-ucms | ucms_contrib/src/Form/NodeMakeGlobal.php | NodeMakeGlobal.submitForm | public function submitForm(array &$form, FormStateInterface $formState)
{
$original = $formState->getTemporaryValue('node');
$node = $this->nodeManager->createAndSaveClone($original, [
'uid' => $this->currentUser()->id(),
'site_id' => null,
'is_global' => 1,
]);
drupal_set_message($this->t("%title has been added to global contents.", ['%title' => $node->title]));
$formState->setRedirect('node/' . $node->id());
} | php | public function submitForm(array &$form, FormStateInterface $formState)
{
$original = $formState->getTemporaryValue('node');
$node = $this->nodeManager->createAndSaveClone($original, [
'uid' => $this->currentUser()->id(),
'site_id' => null,
'is_global' => 1,
]);
drupal_set_message($this->t("%title has been added to global contents.", ['%title' => $node->title]));
$formState->setRedirect('node/' . $node->id());
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"formState",
")",
"{",
"$",
"original",
"=",
"$",
"formState",
"->",
"getTemporaryValue",
"(",
"'node'",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"n... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Form/NodeMakeGlobal.php#L54-L66 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php | Standard.createJob | public function createJob( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$context = $this->getContext();
$items = (array) $params->items;
$lang = ( property_exists( $params, 'lang' ) ) ? (array) $params->lang : [];
$languages = ( !empty( $lang ) ) ? implode( $lang, '-' ) : 'all';
$result = (object) array(
'site' => $params->site,
'items' => array(
(object) array(
'job.label' => 'Product text export: ' . $languages,
'job.method' => 'Product_Export_Text.exportFile',
'job.parameter' => array(
'site' => $params->site,
'items' => $items,
'lang' => $params->lang,
),
'job.status' => 1,
),
),
);
$jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController( $context );
$jobController->saveItems( $result );
return array(
'items' => $items,
'success' => true,
);
} | php | public function createJob( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$context = $this->getContext();
$items = (array) $params->items;
$lang = ( property_exists( $params, 'lang' ) ) ? (array) $params->lang : [];
$languages = ( !empty( $lang ) ) ? implode( $lang, '-' ) : 'all';
$result = (object) array(
'site' => $params->site,
'items' => array(
(object) array(
'job.label' => 'Product text export: ' . $languages,
'job.method' => 'Product_Export_Text.exportFile',
'job.parameter' => array(
'site' => $params->site,
'items' => $items,
'lang' => $params->lang,
),
'job.status' => 1,
),
),
);
$jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController( $context );
$jobController->saveItems( $result );
return array(
'items' => $items,
'success' => true,
);
} | [
"public",
"function",
"createJob",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
",",
"'items'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
"... | Creates a new job to export a file.
@param \stdClass $params Object containing the properties, e.g. the list of product IDs | [
"Creates",
"a",
"new",
"job",
"to",
"export",
"a",
"file",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php#L42-L77 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php | Standard.exportFile | public function exportFile( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$context = $this->getContext();
$items = (array) $params->items;
$lang = ( property_exists( $params, 'lang' ) ) ? (array) $params->lang : [];
$config = $context->getConfig();
/** controller/extjs/product/export/text/standard/downloaddir
* Directory where the exported files can be found through the web
*
* The exported files are stored in this directory.
*
* The download directory must be relative to the document root of your
* virtual host. If the document root is
*
* /var/www/test/htdocs
*
* and the exported files will be in
*
* /var/www/test/htdocs/files/exports
*
* then the configuration for the download directory must be
*
* files/exports
*
* Avoid leading and trailing slashes for the export directory string!
*
* @param string Relative path in the URL
* @since 2014.03
* @category Developer
*/
$downloaddir = $config->get( 'controller/extjs/product/export/text/standard/downloaddir', 'uploads' );
$foldername = 'product-text-export_' . date( 'Y-m-d_H:i:s' ) . '_' . md5( time() . getmypid() );
$tmppath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $foldername;
$filename = $this->exportData( $items, $lang, $tmppath );
$downloadFile = $downloaddir . '/' . basename( $filename );
$fs = $context->getFilesystemManager()->get( 'fs-admin' );
$fs->writef( basename( $filename ), $filename );
return array(
'file' => '<a href="' . $downloadFile . '">Download</a>',
);
} | php | public function exportFile( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$context = $this->getContext();
$items = (array) $params->items;
$lang = ( property_exists( $params, 'lang' ) ) ? (array) $params->lang : [];
$config = $context->getConfig();
/** controller/extjs/product/export/text/standard/downloaddir
* Directory where the exported files can be found through the web
*
* The exported files are stored in this directory.
*
* The download directory must be relative to the document root of your
* virtual host. If the document root is
*
* /var/www/test/htdocs
*
* and the exported files will be in
*
* /var/www/test/htdocs/files/exports
*
* then the configuration for the download directory must be
*
* files/exports
*
* Avoid leading and trailing slashes for the export directory string!
*
* @param string Relative path in the URL
* @since 2014.03
* @category Developer
*/
$downloaddir = $config->get( 'controller/extjs/product/export/text/standard/downloaddir', 'uploads' );
$foldername = 'product-text-export_' . date( 'Y-m-d_H:i:s' ) . '_' . md5( time() . getmypid() );
$tmppath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $foldername;
$filename = $this->exportData( $items, $lang, $tmppath );
$downloadFile = $downloaddir . '/' . basename( $filename );
$fs = $context->getFilesystemManager()->get( 'fs-admin' );
$fs->writef( basename( $filename ), $filename );
return array(
'file' => '<a href="' . $downloadFile . '">Download</a>',
);
} | [
"public",
"function",
"exportFile",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
",",
"'items'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
... | Exports content files in container.
@param \stdClass $params Object containing the properties, e.g. the list of product IDs | [
"Exports",
"content",
"files",
"in",
"container",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php#L85-L134 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php | Standard.addItem | protected function addItem( \Aimeos\MW\Container\Content\Iface $contentItem, \Aimeos\MShop\Product\Item\Iface $item, $langid )
{
$listTypes = [];
foreach( $item->getListItems( 'text' ) as $listItem ) {
$listTypes[$listItem->getRefId()] = $listItem->getType();
}
foreach( $this->getTextTypes( 'product' ) as $textTypeItem )
{
$textItems = $item->getRefItems( 'text', $textTypeItem->getCode() );
if( !empty( $textItems ) )
{
foreach( $textItems as $textItem )
{
$listType = ( isset( $listTypes[$textItem->getId()] ) ? $listTypes[$textItem->getId()] : '' );
$items = array( $langid, $item->getType(), $item->getCode(), $listType, $textTypeItem->getCode(), '', '' );
// use language of the text item because it may be null
if( ( $textItem->getLanguageId() == $langid || is_null( $textItem->getLanguageId() ) )
&& $textItem->getTypeId() == $textTypeItem->getId() )
{
$items[0] = $textItem->getLanguageId();
$items[5] = $textItem->getId();
$items[6] = $textItem->getContent();
}
$contentItem->add( $items );
}
}
else
{
$items = array( $langid, $item->getType(), $item->getCode(), 'default', $textTypeItem->getCode(), '', '' );
$contentItem->add( $items );
}
}
} | php | protected function addItem( \Aimeos\MW\Container\Content\Iface $contentItem, \Aimeos\MShop\Product\Item\Iface $item, $langid )
{
$listTypes = [];
foreach( $item->getListItems( 'text' ) as $listItem ) {
$listTypes[$listItem->getRefId()] = $listItem->getType();
}
foreach( $this->getTextTypes( 'product' ) as $textTypeItem )
{
$textItems = $item->getRefItems( 'text', $textTypeItem->getCode() );
if( !empty( $textItems ) )
{
foreach( $textItems as $textItem )
{
$listType = ( isset( $listTypes[$textItem->getId()] ) ? $listTypes[$textItem->getId()] : '' );
$items = array( $langid, $item->getType(), $item->getCode(), $listType, $textTypeItem->getCode(), '', '' );
// use language of the text item because it may be null
if( ( $textItem->getLanguageId() == $langid || is_null( $textItem->getLanguageId() ) )
&& $textItem->getTypeId() == $textTypeItem->getId() )
{
$items[0] = $textItem->getLanguageId();
$items[5] = $textItem->getId();
$items[6] = $textItem->getContent();
}
$contentItem->add( $items );
}
}
else
{
$items = array( $langid, $item->getType(), $item->getCode(), 'default', $textTypeItem->getCode(), '', '' );
$contentItem->add( $items );
}
}
} | [
"protected",
"function",
"addItem",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Container",
"\\",
"Content",
"\\",
"Iface",
"$",
"contentItem",
",",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Product",
"\\",
"Item",
"\\",
"Iface",
"$",
"item",
",",
"$",
"langid",... | Adds all texts belonging to an product item.
@param \Aimeos\MW\Container\Content\Iface $contentItem Content item
@param \Aimeos\MShop\Product\Item\Iface $item product item object
@param string $langid Language id | [
"Adds",
"all",
"texts",
"belonging",
"to",
"an",
"product",
"item",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Product/Export/Text/Standard.php#L315-L351 |
makinacorpus/drupal-ucms | ucms_tree/src/Datasource/TreeAdminDatasource.php | TreeAdminDatasource.getWebmasterSites | private function getWebmasterSites()
{
$ret = [];
foreach ($this->siteManager->loadWebmasterSites($this->account) as $site) {
$ret[$site->getId()] = check_plain($site->title);
}
return $ret;
} | php | private function getWebmasterSites()
{
$ret = [];
foreach ($this->siteManager->loadWebmasterSites($this->account) as $site) {
$ret[$site->getId()] = check_plain($site->title);
}
return $ret;
} | [
"private",
"function",
"getWebmasterSites",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"siteManager",
"->",
"loadWebmasterSites",
"(",
"$",
"this",
"->",
"account",
")",
"as",
"$",
"site",
")",
"{",
"$",
"ret",
... | Get current account sites he's webmaster on
@return string[] | [
"Get",
"current",
"account",
"sites",
"he",
"s",
"webmaster",
"on"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/Datasource/TreeAdminDatasource.php#L40-L49 |
makinacorpus/drupal-ucms | ucms_tree/src/Datasource/TreeAdminDatasource.php | TreeAdminDatasource.getFilters | public function getFilters()
{
$sites = $this->getWebmasterSites();
if (count($sites) < 2) {
return [];
}
return [
(new Filter('site', $this->t("Site")))->setChoicesMap($sites),
];
} | php | public function getFilters()
{
$sites = $this->getWebmasterSites();
if (count($sites) < 2) {
return [];
}
return [
(new Filter('site', $this->t("Site")))->setChoicesMap($sites),
];
} | [
"public",
"function",
"getFilters",
"(",
")",
"{",
"$",
"sites",
"=",
"$",
"this",
"->",
"getWebmasterSites",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"sites",
")",
"<",
"2",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"[",
"(",
"new",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/Datasource/TreeAdminDatasource.php#L54-L65 |
makinacorpus/drupal-ucms | ucms_tree/src/Datasource/TreeAdminDatasource.php | TreeAdminDatasource.getItems | public function getItems(Query $query)
{
$sites = $this->getWebmasterSites();
// User is not webmaster of any site, he can't see this
if (empty($sites)) {
return $this->createEmptyResult();
}
$conditions = [];
if ($query->has('site')) {
$siteId = $query->get('site');
// User is not webmaster of the current site, disallow
if (!isset($sites[$siteId])) {
return [];
}
$conditions['site_id'] = $siteId;
} else {
$conditions['site_id'] = array_keys($sites);
}
$items = $this->menuStorage->loadWithConditions($conditions);
return $this->createResult($items);
} | php | public function getItems(Query $query)
{
$sites = $this->getWebmasterSites();
// User is not webmaster of any site, he can't see this
if (empty($sites)) {
return $this->createEmptyResult();
}
$conditions = [];
if ($query->has('site')) {
$siteId = $query->get('site');
// User is not webmaster of the current site, disallow
if (!isset($sites[$siteId])) {
return [];
}
$conditions['site_id'] = $siteId;
} else {
$conditions['site_id'] = array_keys($sites);
}
$items = $this->menuStorage->loadWithConditions($conditions);
return $this->createResult($items);
} | [
"public",
"function",
"getItems",
"(",
"Query",
"$",
"query",
")",
"{",
"$",
"sites",
"=",
"$",
"this",
"->",
"getWebmasterSites",
"(",
")",
";",
"// User is not webmaster of any site, he can't see this",
"if",
"(",
"empty",
"(",
"$",
"sites",
")",
")",
"{",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/Datasource/TreeAdminDatasource.php#L70-L95 |
scriptotek/php-oai-pmh-client | src/Client.php | Client.getHttpOptions | public function getHttpOptions()
{
$options = array(
'headers' => $this->getHttpHeaders(),
'connect_timeout' => $this->timeout,
'timeout' => $this->timeout,
);
if ($this->credentials) {
$options['auth'] = $this->credentials;
}
if ($this->proxy) {
$options['proxy'] = $this->proxy;
}
return $options;
} | php | public function getHttpOptions()
{
$options = array(
'headers' => $this->getHttpHeaders(),
'connect_timeout' => $this->timeout,
'timeout' => $this->timeout,
);
if ($this->credentials) {
$options['auth'] = $this->credentials;
}
if ($this->proxy) {
$options['proxy'] = $this->proxy;
}
return $options;
} | [
"public",
"function",
"getHttpOptions",
"(",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'headers'",
"=>",
"$",
"this",
"->",
"getHttpHeaders",
"(",
")",
",",
"'connect_timeout'",
"=>",
"$",
"this",
"->",
"timeout",
",",
"'timeout'",
"=>",
"$",
"this",
... | Get HTTP client configuration options (authentication, proxy)
@return array | [
"Get",
"HTTP",
"client",
"configuration",
"options",
"(",
"authentication",
"proxy",
")"
] | train | https://github.com/scriptotek/php-oai-pmh-client/blob/c1da394ccad86962d0f1c2bc120152092e4c1c88/src/Client.php#L86-L100 |
scriptotek/php-oai-pmh-client | src/Client.php | Client.urlBuilder | public function urlBuilder($verb, $arguments = array())
{
$qs = array(
'verb' => $verb,
'metadataPrefix' => $this->schema,
);
foreach ($arguments as $key => $value) {
$qs[$key] = $value;
if (is_null($value)) {
// Allow removal of default arguments like 'metadataPrefix'
unset($qs[$key]);
}
}
return $this->url . '?' . http_build_query($qs);
} | php | public function urlBuilder($verb, $arguments = array())
{
$qs = array(
'verb' => $verb,
'metadataPrefix' => $this->schema,
);
foreach ($arguments as $key => $value) {
$qs[$key] = $value;
if (is_null($value)) {
// Allow removal of default arguments like 'metadataPrefix'
unset($qs[$key]);
}
}
return $this->url . '?' . http_build_query($qs);
} | [
"public",
"function",
"urlBuilder",
"(",
"$",
"verb",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"qs",
"=",
"array",
"(",
"'verb'",
"=>",
"$",
"verb",
",",
"'metadataPrefix'",
"=>",
"$",
"this",
"->",
"schema",
",",
")",
";",
"fo... | Construct the URL for an OAI-PMH query
@param string $verb The OAI-PMH verb
@param array $arguments OAI-PMH arguments
@return string | [
"Construct",
"the",
"URL",
"for",
"an",
"OAI",
"-",
"PMH",
"query"
] | train | https://github.com/scriptotek/php-oai-pmh-client/blob/c1da394ccad86962d0f1c2bc120152092e4c1c88/src/Client.php#L125-L141 |
scriptotek/php-oai-pmh-client | src/Client.php | Client.request | public function request($verb, $arguments)
{
$this->emit('request.start', array(
'verb' => $verb,
'arguments' => $arguments
));
$url = $this->urlBuilder($verb, $arguments);
$attempt = 0;
while (true) {
try {
$res = $this->httpClient->get($url, $this->getHttpOptions());
break;
} catch (\GuzzleHttp\Exception\ConnectException $e) {
// Thrown in case of a networking error (connection timeout, DNS errors, etc.)
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
} catch (\GuzzleHttp\Exception\ServerException $e) {
// Thrown in case of 500 errors
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
}
$attempt++;
if ($attempt > $this->maxRetries) {
throw new ConnectionError('Failed to get a response from the server. Max retries (' . $this->maxRetries . ') exceeded.');
}
}
$body = (string) $res->getBody();
$this->emit('request.complete', array(
'verb' => $verb,
'arguments' => $arguments,
'response' => $body
));
return $body;
} | php | public function request($verb, $arguments)
{
$this->emit('request.start', array(
'verb' => $verb,
'arguments' => $arguments
));
$url = $this->urlBuilder($verb, $arguments);
$attempt = 0;
while (true) {
try {
$res = $this->httpClient->get($url, $this->getHttpOptions());
break;
} catch (\GuzzleHttp\Exception\ConnectException $e) {
// Thrown in case of a networking error (connection timeout, DNS errors, etc.)
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
} catch (\GuzzleHttp\Exception\ServerException $e) {
// Thrown in case of 500 errors
$this->emit('request.error', array(
'message' => $e->getMessage(),
));
time_nanosleep(intval($this->sleepTimeOnError), intval($this->sleepTimeOnError * 1000000000));
}
$attempt++;
if ($attempt > $this->maxRetries) {
throw new ConnectionError('Failed to get a response from the server. Max retries (' . $this->maxRetries . ') exceeded.');
}
}
$body = (string) $res->getBody();
$this->emit('request.complete', array(
'verb' => $verb,
'arguments' => $arguments,
'response' => $body
));
return $body;
} | [
"public",
"function",
"request",
"(",
"$",
"verb",
",",
"$",
"arguments",
")",
"{",
"$",
"this",
"->",
"emit",
"(",
"'request.start'",
",",
"array",
"(",
"'verb'",
"=>",
"$",
"verb",
",",
"'arguments'",
"=>",
"$",
"arguments",
")",
")",
";",
"$",
"ur... | Perform a single OAI-PMH request
@param string $verb The OAI-PMH verb
@param array $arguments OAI-PMH arguments
@return string
@throws ConnectionError | [
"Perform",
"a",
"single",
"OAI",
"-",
"PMH",
"request"
] | train | https://github.com/scriptotek/php-oai-pmh-client/blob/c1da394ccad86962d0f1c2bc120152092e4c1c88/src/Client.php#L151-L188 |
scriptotek/php-oai-pmh-client | src/Client.php | Client.records | public function records($from, $until, $set, $resumptionToken = null, $extraParams = array())
{
return new Records($from, $until, $set, $this, $resumptionToken, $extraParams);
} | php | public function records($from, $until, $set, $resumptionToken = null, $extraParams = array())
{
return new Records($from, $until, $set, $this, $resumptionToken, $extraParams);
} | [
"public",
"function",
"records",
"(",
"$",
"from",
",",
"$",
"until",
",",
"$",
"set",
",",
"$",
"resumptionToken",
"=",
"null",
",",
"$",
"extraParams",
"=",
"array",
"(",
")",
")",
"{",
"return",
"new",
"Records",
"(",
"$",
"from",
",",
"$",
"unt... | Perform a ListRecords request and return an iterator over the records
@param string $from Start date
@param string $until End date
@param string $set Data set
@param string $resumptionToken To resume a harvest
@param array $extraParams Extra GET parameters
@return Records | [
"Perform",
"a",
"ListRecords",
"request",
"and",
"return",
"an",
"iterator",
"over",
"the",
"records"
] | train | https://github.com/scriptotek/php-oai-pmh-client/blob/c1da394ccad86962d0f1c2bc120152092e4c1c88/src/Client.php#L212-L215 |
makinacorpus/drupal-ucms | ucms_site/ucms_site.container.php | ServiceProvider.register | public function register(ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('pages.yml');
$container->addCompilerPass(new CompatibilityPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 50 /* Run before calista */);
} | php | public function register(ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/config'));
$loader->load('pages.yml');
$container->addCompilerPass(new CompatibilityPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 50 /* Run before calista */);
} | [
"public",
"function",
"register",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"loader",
"=",
"new",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/config'",
")",
")",
";",
"$",
"loader",
"->",
"loa... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/ucms_site.container.php#L17-L23 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.term | public function term()
{
$terminal = Terminal::whereUserId($this->userId())->first();
if (!$terminal) {
$terminal = new Terminal;
$terminal->user_id = $this->userId();
$terminal->secret = md5($terminal->user_id . time() . uniqid());
$terminal->mode = Terminal::C_STATE_OFFLINE;
$terminal->save();
}
$this->make('term', compact('terminal'));
} | php | public function term()
{
$terminal = Terminal::whereUserId($this->userId())->first();
if (!$terminal) {
$terminal = new Terminal;
$terminal->user_id = $this->userId();
$terminal->secret = md5($terminal->user_id . time() . uniqid());
$terminal->mode = Terminal::C_STATE_OFFLINE;
$terminal->save();
}
$this->make('term', compact('terminal'));
} | [
"public",
"function",
"term",
"(",
")",
"{",
"$",
"terminal",
"=",
"Terminal",
"::",
"whereUserId",
"(",
"$",
"this",
"->",
"userId",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"terminal",
")",
"{",
"$",
"terminal",
"=",
"n... | Terminal info
auto-create new term if not exists | [
"Terminal",
"info",
"auto",
"-",
"create",
"new",
"term",
"if",
"not",
"exists"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L52-L64 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.postTerm | public function postTerm()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$inputs = Input::get('input');
if (empty($inputs['url'])) {
$inputs['url'] = '';
}
if (empty($inputs['email'])) {
$inputs['email'] = '';
}
$validator = Validator::make(
$inputs,
array(
'url' => 'url',
'email' => 'email',
)
);
if ($terminal && $validator->passes()) {
$terminal->url = $inputs['url'];
$terminal->email = $inputs['email'];
$terminal->save();
return 'ok';
}
return 'error';
} | php | public function postTerm()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$inputs = Input::get('input');
if (empty($inputs['url'])) {
$inputs['url'] = '';
}
if (empty($inputs['email'])) {
$inputs['email'] = '';
}
$validator = Validator::make(
$inputs,
array(
'url' => 'url',
'email' => 'email',
)
);
if ($terminal && $validator->passes()) {
$terminal->url = $inputs['url'];
$terminal->email = $inputs['email'];
$terminal->save();
return 'ok';
}
return 'error';
} | [
"public",
"function",
"postTerm",
"(",
")",
"{",
"$",
"terminal",
"=",
"Terminal",
"::",
"whereUserId",
"(",
"$",
"this",
"->",
"userId",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"$",
"inputs",
"=",
"Input",
"::",
"get",
"(",
"'input'",
")",
";... | Change term options
@return string | [
"Change",
"term",
"options"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L71-L101 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.sign | public function sign()
{
$type = Input::get('type');
$input = Input::get('input');
$termId = $input['term'];
$term = Terminal::find($termId);
$input = Type::clearInput($type, $input);
Secure::sign($input, $type, $term->secret);
return $input['sign'];
} | php | public function sign()
{
$type = Input::get('type');
$input = Input::get('input');
$termId = $input['term'];
$term = Terminal::find($termId);
$input = Type::clearInput($type, $input);
Secure::sign($input, $type, $term->secret);
return $input['sign'];
} | [
"public",
"function",
"sign",
"(",
")",
"{",
"$",
"type",
"=",
"Input",
"::",
"get",
"(",
"'type'",
")",
";",
"$",
"input",
"=",
"Input",
"::",
"get",
"(",
"'input'",
")",
";",
"$",
"termId",
"=",
"$",
"input",
"[",
"'term'",
"]",
";",
"$",
"te... | Create signature for payment form | [
"Create",
"signature",
"for",
"payment",
"form"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L114-L126 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.callback | public function callback()
{
Log::info('callback.url.pull', array(
'message' => 'Request callback url',
'rawInput' => Input::all(),
));
$input = $this->getVerifiedInput('callback', Input::get('type'), Input::all(), true);
if ($input) {
// your business processing
}
} | php | public function callback()
{
Log::info('callback.url.pull', array(
'message' => 'Request callback url',
'rawInput' => Input::all(),
));
$input = $this->getVerifiedInput('callback', Input::get('type'), Input::all(), true);
if ($input) {
// your business processing
}
} | [
"public",
"function",
"callback",
"(",
")",
"{",
"Log",
"::",
"info",
"(",
"'callback.url.pull'",
",",
"array",
"(",
"'message'",
"=>",
"'Request callback url'",
",",
"'rawInput'",
"=>",
"Input",
"::",
"all",
"(",
")",
",",
")",
")",
";",
"$",
"input",
"... | Pull payment callbacks | [
"Pull",
"payment",
"callbacks"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L131-L144 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.payments | public function payments()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$payments = Payment::orderBy('id', 'desc')->whereTerm($terminal->id)->paginate(50);
$this->make('payments', compact('payments'));
} | php | public function payments()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$payments = Payment::orderBy('id', 'desc')->whereTerm($terminal->id)->paginate(50);
$this->make('payments', compact('payments'));
} | [
"public",
"function",
"payments",
"(",
")",
"{",
"$",
"terminal",
"=",
"Terminal",
"::",
"whereUserId",
"(",
"$",
"this",
"->",
"userId",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"$",
"payments",
"=",
"Payment",
"::",
"orderBy",
"(",
"'id'",
",",... | Payments log | [
"Payments",
"log"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L149-L155 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.endpoint | public function endpoint()
{
/**
* @var Processor $processor
*/
$type = Type::ENDPOINT;
$input = $this->getVerifiedInput('endpoint', $type, Input::all());
$errorMessage = 'Request error';
$urlBack = '';
if ($input) {
$errorMessage = '';
$urlBack = $input['back'];
$opType = new Type($type, $input);
try {
$opType->validate();
} catch (ProcessorException $e) {
$errorMessage = $e->getMessage();
}
}
if ($errorMessage) {
return Redirect::route('ff-bank-em-error')->with(array(
'errorMessage' => $errorMessage,
'errorUrl' => Views::url($urlBack, array('resultBankEmulatorPayment' => 'error')),
'errorUrlName' => 'вернуться в магазин',
));
}
$term = Terminal::find($input['term']);
$paymentParams = $this->getPaymentFields($input);
Secure::sign($paymentParams, $type, $term->secret);
$this->layout = View::make('ff-bank-em::layouts.endpoint');
return $this->layout->nest('content', 'ff-bank-em::demo.endpoint', compact('paymentParams'));
} | php | public function endpoint()
{
/**
* @var Processor $processor
*/
$type = Type::ENDPOINT;
$input = $this->getVerifiedInput('endpoint', $type, Input::all());
$errorMessage = 'Request error';
$urlBack = '';
if ($input) {
$errorMessage = '';
$urlBack = $input['back'];
$opType = new Type($type, $input);
try {
$opType->validate();
} catch (ProcessorException $e) {
$errorMessage = $e->getMessage();
}
}
if ($errorMessage) {
return Redirect::route('ff-bank-em-error')->with(array(
'errorMessage' => $errorMessage,
'errorUrl' => Views::url($urlBack, array('resultBankEmulatorPayment' => 'error')),
'errorUrlName' => 'вернуться в магазин',
));
}
$term = Terminal::find($input['term']);
$paymentParams = $this->getPaymentFields($input);
Secure::sign($paymentParams, $type, $term->secret);
$this->layout = View::make('ff-bank-em::layouts.endpoint');
return $this->layout->nest('content', 'ff-bank-em::demo.endpoint', compact('paymentParams'));
} | [
"public",
"function",
"endpoint",
"(",
")",
"{",
"/**\n\t\t * @var Processor $processor\n\t\t */",
"$",
"type",
"=",
"Type",
"::",
"ENDPOINT",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"getVerifiedInput",
"(",
"'endpoint'",
",",
"$",
"type",
",",
"Input",
"::... | Production gate
Public access | [
"Production",
"gate",
"Public",
"access"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L246-L289 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.endpointAuth | public function endpointAuth()
{
/**
* @var Processor $processor
*/
$type = Type::PAYMENT;
$input = Input::all();
$input = Type::clearInput($type, $input);
$term = Terminal::find($input['term']);
Secure::sign($input, $type, $term->secret);
$processor = $this->makeProcessor($type, $input);
$errorMessage = null;
try {
$response = $processor->response();
if ($response->rc !== '00') {
$errorMessage = ProcessorException::getCodeMessage($response->rc);
}
// need auth
if ($response->auth()) {
return Redirect::to($response->auth());
}
} catch (ProcessorException $e) {
$errorMessage = $e->getMessage();
}
if (!$errorMessage) {
return Views::reload(
Views::url(
$input['back'],
array('resultBankEmulatorPayment' => 'success')
),
array(
'Платеж принят!',
'Ждите перехода в интернет-магазин',
),
'success'
);
}
return Views::reload(
Views::url(
$input['back'],
array('resultBankEmulatorPayment' => 'error')
),
array(
$errorMessage,
'Ждите перехода в интернет-магазин',
),
'danger'
);
} | php | public function endpointAuth()
{
/**
* @var Processor $processor
*/
$type = Type::PAYMENT;
$input = Input::all();
$input = Type::clearInput($type, $input);
$term = Terminal::find($input['term']);
Secure::sign($input, $type, $term->secret);
$processor = $this->makeProcessor($type, $input);
$errorMessage = null;
try {
$response = $processor->response();
if ($response->rc !== '00') {
$errorMessage = ProcessorException::getCodeMessage($response->rc);
}
// need auth
if ($response->auth()) {
return Redirect::to($response->auth());
}
} catch (ProcessorException $e) {
$errorMessage = $e->getMessage();
}
if (!$errorMessage) {
return Views::reload(
Views::url(
$input['back'],
array('resultBankEmulatorPayment' => 'success')
),
array(
'Платеж принят!',
'Ждите перехода в интернет-магазин',
),
'success'
);
}
return Views::reload(
Views::url(
$input['back'],
array('resultBankEmulatorPayment' => 'error')
),
array(
$errorMessage,
'Ждите перехода в интернет-магазин',
),
'danger'
);
} | [
"public",
"function",
"endpointAuth",
"(",
")",
"{",
"/**\n\t\t * @var Processor $processor\n\t\t */",
"$",
"type",
"=",
"Type",
"::",
"PAYMENT",
";",
"$",
"input",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"input",
"=",
"Type",
"::",
"clearInput",
"(",... | Endpoint 'payment' request | [
"Endpoint",
"payment",
"request"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L295-L354 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.endpointAuthResult | public function endpointAuthResult()
{
$result = Input::get('result');
$result = Crypt::decrypt($result);
$result = explode(';', $result);
$payment = null;
$paymentId = null;
if (!empty($result[0])) {
$paymentId = $result[0];
$payment = Processor::findPayment($paymentId);
}
if (!$payment) {
App::abort(406, 'Unrecognized Payment Information');
}
$processor = Processor::makePayment($paymentId);
$url = $processor->getBackUrl();
// success authorization
if (!empty($result[1]) && $result[1] === 'OK') {
$processor->setPaymentSuccessAuthorisation($paymentId);
return Views::reload(
Views::url(
$url,
array('resultBankEmulatorPayment' => 'success')
),
array(
'Платеж принят и авторизован',
'Ждите перехода в интернет-магазин',
),
'success'
);
}
// fail
$processor->setPaymentErrorAuthorisation();
return Views::reload(
Views::url(
$url,
array('resultBankEmulatorPayment' => 'error')
),
array(
'Error Payment Authorization',
'Ждите перехода в интернет-магазин',
),
'danger'
);
} | php | public function endpointAuthResult()
{
$result = Input::get('result');
$result = Crypt::decrypt($result);
$result = explode(';', $result);
$payment = null;
$paymentId = null;
if (!empty($result[0])) {
$paymentId = $result[0];
$payment = Processor::findPayment($paymentId);
}
if (!$payment) {
App::abort(406, 'Unrecognized Payment Information');
}
$processor = Processor::makePayment($paymentId);
$url = $processor->getBackUrl();
// success authorization
if (!empty($result[1]) && $result[1] === 'OK') {
$processor->setPaymentSuccessAuthorisation($paymentId);
return Views::reload(
Views::url(
$url,
array('resultBankEmulatorPayment' => 'success')
),
array(
'Платеж принят и авторизован',
'Ждите перехода в интернет-магазин',
),
'success'
);
}
// fail
$processor->setPaymentErrorAuthorisation();
return Views::reload(
Views::url(
$url,
array('resultBankEmulatorPayment' => 'error')
),
array(
'Error Payment Authorization',
'Ждите перехода в интернет-магазин',
),
'danger'
);
} | [
"public",
"function",
"endpointAuthResult",
"(",
")",
"{",
"$",
"result",
"=",
"Input",
"::",
"get",
"(",
"'result'",
")",
";",
"$",
"result",
"=",
"Crypt",
"::",
"decrypt",
"(",
"$",
"result",
")",
";",
"$",
"result",
"=",
"explode",
"(",
"';'",
","... | Endpoint result authorization | [
"Endpoint",
"result",
"authorization"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L359-L414 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.auth | public function auth($payment, $url)
{
// decrypt payment identify
$paymentId = Crypt::decrypt($payment);
// check request
$this->payAuthValidateRequest($paymentId, $url);
// check payment status
$processor = Processor::makePayment($paymentId);
if (!$processor->isAuthStatus()) {
App::abort(406, 'Unrecognized Payment Status');
}
// check input hint value and go back with result
$redirect = $this->payAuthProcessHint($paymentId, $url);
if ($redirect) {
return $redirect;
}
$this->layout = View::make('ff-bank-em::layouts.authorization');
$this->make('authorization');
return null;
} | php | public function auth($payment, $url)
{
// decrypt payment identify
$paymentId = Crypt::decrypt($payment);
// check request
$this->payAuthValidateRequest($paymentId, $url);
// check payment status
$processor = Processor::makePayment($paymentId);
if (!$processor->isAuthStatus()) {
App::abort(406, 'Unrecognized Payment Status');
}
// check input hint value and go back with result
$redirect = $this->payAuthProcessHint($paymentId, $url);
if ($redirect) {
return $redirect;
}
$this->layout = View::make('ff-bank-em::layouts.authorization');
$this->make('authorization');
return null;
} | [
"public",
"function",
"auth",
"(",
"$",
"payment",
",",
"$",
"url",
")",
"{",
"// decrypt payment identify",
"$",
"paymentId",
"=",
"Crypt",
"::",
"decrypt",
"(",
"$",
"payment",
")",
";",
"// check request",
"$",
"this",
"->",
"payAuthValidateRequest",
"(",
... | Payment authorization (check code) | [
"Payment",
"authorization",
"(",
"check",
"code",
")"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L420-L446 |
fintech-fab/bank-emulator | src/controllers/DemoController.php | DemoController.shop | public function shop()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$endpointParams = $this->getEndpointFields($terminal);
$status = Input::get('resultBankEmulatorPayment');
$statusSuccess = ($status === 'success');
$statusError = ($status === 'error');
$this->make('shop', compact(
'terminal',
'endpointParams',
'statusSuccess',
'statusError'
));
} | php | public function shop()
{
$terminal = Terminal::whereUserId($this->userId())->first();
$endpointParams = $this->getEndpointFields($terminal);
$status = Input::get('resultBankEmulatorPayment');
$statusSuccess = ($status === 'success');
$statusError = ($status === 'error');
$this->make('shop', compact(
'terminal',
'endpointParams',
'statusSuccess',
'statusError'
));
} | [
"public",
"function",
"shop",
"(",
")",
"{",
"$",
"terminal",
"=",
"Terminal",
"::",
"whereUserId",
"(",
"$",
"this",
"->",
"userId",
"(",
")",
")",
"->",
"first",
"(",
")",
";",
"$",
"endpointParams",
"=",
"$",
"this",
"->",
"getEndpointFields",
"(",
... | E-shop order page | [
"E",
"-",
"shop",
"order",
"page"
] | train | https://github.com/fintech-fab/bank-emulator/blob/6256be98509de0ff8e96b5683a0b0197acd67b9e/src/controllers/DemoController.php#L451-L468 |
makinacorpus/drupal-ucms | ucms_search/src/Aggs/AbstractFacet.php | AbstractFacet.prepareQuery | public function prepareQuery(Search $search, $query)
{
$values = $this->getQueryParam($query, $this->getParameterName());
if (isset($values)) {
if (!is_array($values)) {
$values = [$values];
}
$this->setSelectedValues($values);
}
if (isset($values)) {
if ($this->isPostFilter) {
$query = $search->getPostFilterQuery();
} else {
$query = $search->getFilterQuery();
}
$query
->matchTermCollection(
$this->getField(),
$values,
null,
$this->getOperator()
)
;
}
} | php | public function prepareQuery(Search $search, $query)
{
$values = $this->getQueryParam($query, $this->getParameterName());
if (isset($values)) {
if (!is_array($values)) {
$values = [$values];
}
$this->setSelectedValues($values);
}
if (isset($values)) {
if ($this->isPostFilter) {
$query = $search->getPostFilterQuery();
} else {
$query = $search->getFilterQuery();
}
$query
->matchTermCollection(
$this->getField(),
$values,
null,
$this->getOperator()
)
;
}
} | [
"public",
"function",
"prepareQuery",
"(",
"Search",
"$",
"search",
",",
"$",
"query",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"getQueryParam",
"(",
"$",
"query",
",",
"$",
"this",
"->",
"getParameterName",
"(",
")",
")",
";",
"if",
"(",
"is... | {@inheritDoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Aggs/AbstractFacet.php#L195-L222 |
makinacorpus/drupal-ucms | ucms_search/src/Aggs/AbstractFacet.php | AbstractFacet.buildQueryData | public function buildQueryData(Search $search, $query)
{
return [
$this->getParameterName() => [
$this->getType() => [
'field' => $this->getField(),
'size' => 100,
],
]
];
} | php | public function buildQueryData(Search $search, $query)
{
return [
$this->getParameterName() => [
$this->getType() => [
'field' => $this->getField(),
'size' => 100,
],
]
];
} | [
"public",
"function",
"buildQueryData",
"(",
"Search",
"$",
"search",
",",
"$",
"query",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"getParameterName",
"(",
")",
"=>",
"[",
"$",
"this",
"->",
"getType",
"(",
")",
"=>",
"[",
"'field'",
"=>",
"$",
"th... | {@inheritDoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Aggs/AbstractFacet.php#L227-L237 |
shopgate/cart-integration-sdk | src/helper/DataStructure.php | Shopgate_Helper_DataStructure.arrayCross | public function arrayCross(array $src, $enableFirstRow = false)
{
$result = array();
$firstRow = array();
if ($enableFirstRow) {
$firstRow[0] = array_keys($src);
}
foreach ($src as $key => $valArr) {
// elements are copied for appending data, so the actual count is needed as the base-element-count
$copyCount = count($result);
// start by using the first array as a resultset (in case of only one array the result of the cross-product is the first input-array)
if (empty($result)) {
foreach ($valArr as $optionSelection) {
$result[] = array($key => $optionSelection);
}
} else {
$i = 0;
foreach ($valArr as $optionSelection) {
for ($j = 0; $j < $copyCount; $j++) {
// in case of $i==0 it copies itself, so it's correct in all cases if $i
$result[$i * $copyCount + $j] = $result[$j];
$result[$i * $copyCount + $j][$key] = $optionSelection;
}
$i++;
}
}
}
return array_merge($firstRow, $result);
} | php | public function arrayCross(array $src, $enableFirstRow = false)
{
$result = array();
$firstRow = array();
if ($enableFirstRow) {
$firstRow[0] = array_keys($src);
}
foreach ($src as $key => $valArr) {
// elements are copied for appending data, so the actual count is needed as the base-element-count
$copyCount = count($result);
// start by using the first array as a resultset (in case of only one array the result of the cross-product is the first input-array)
if (empty($result)) {
foreach ($valArr as $optionSelection) {
$result[] = array($key => $optionSelection);
}
} else {
$i = 0;
foreach ($valArr as $optionSelection) {
for ($j = 0; $j < $copyCount; $j++) {
// in case of $i==0 it copies itself, so it's correct in all cases if $i
$result[$i * $copyCount + $j] = $result[$j];
$result[$i * $copyCount + $j][$key] = $optionSelection;
}
$i++;
}
}
}
return array_merge($firstRow, $result);
} | [
"public",
"function",
"arrayCross",
"(",
"array",
"$",
"src",
",",
"$",
"enableFirstRow",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"firstRow",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"enableFirstRow",
")",
"{",
... | Takes an array of arrays that contain all elements which are taken to create a cross-product of all elements.
The resulting array is an array-list with each possible combination as array. An Element itself can be anything
(including a whole array that is not torn apart, but instead treated as a whole) By setting the second parameter
to true, the keys of the source array is added as an array at the front of the resulting array
Sample input: array(
'group-1-key' => array('a', 'b'),
'group-2-key' => array('x'),
7 => array('l', 'm', 'n'),
);
Output of sample: Array (
[0] => Array (
[group-1-key] => a
[group-2-key] => x
[7] => l
)
[1] => Array (
[group-1-key] => b
[group-2-key] => x
[7] => l
)
[2] => Array (
[group-1-key] => a
[group-2-key] => x
[7] => m
)
[...] and so on ... (total of count(src[0])*count(src[1])*...*count(src[N]) elements) [=> 2*1*3 elements
in this case]
)
@param array $src : The (at least) double dimensioned array input
@param bool $enableFirstRow : Disabled by default
@return array[][]: | [
"Takes",
"an",
"array",
"of",
"arrays",
"that",
"contain",
"all",
"elements",
"which",
"are",
"taken",
"to",
"create",
"a",
"cross",
"-",
"product",
"of",
"all",
"elements",
".",
"The",
"resulting",
"array",
"is",
"an",
"array",
"-",
"list",
"with",
"eac... | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/DataStructure.php#L60-L92 |
shopgate/cart-integration-sdk | src/helper/DataStructure.php | Shopgate_Helper_DataStructure.jsonEncode | public function jsonEncode($value)
{
// if json_encode exists use that
if (extension_loaded('json') && function_exists('json_encode')) {
$encodedValue = json_encode($value);
if (!empty($encodedValue)) {
return $encodedValue;
}
}
try {
return \Zend\Json\Encoder::encode($value);
} catch (Exception $exception) {
return false;
}
} | php | public function jsonEncode($value)
{
// if json_encode exists use that
if (extension_loaded('json') && function_exists('json_encode')) {
$encodedValue = json_encode($value);
if (!empty($encodedValue)) {
return $encodedValue;
}
}
try {
return \Zend\Json\Encoder::encode($value);
} catch (Exception $exception) {
return false;
}
} | [
"public",
"function",
"jsonEncode",
"(",
"$",
"value",
")",
"{",
"// if json_encode exists use that",
"if",
"(",
"extension_loaded",
"(",
"'json'",
")",
"&&",
"function_exists",
"(",
"'json_encode'",
")",
")",
"{",
"$",
"encodedValue",
"=",
"json_encode",
"(",
"... | Creates a JSON string from any passed value.
Uses json_encode() if present, otherwise falls back to Zend's JSON encoder.
@param mixed $value
@return string | bool in case an error happened false will be returned | [
"Creates",
"a",
"JSON",
"string",
"from",
"any",
"passed",
"value",
".",
"Uses",
"json_encode",
"()",
"if",
"present",
"otherwise",
"falls",
"back",
"to",
"Zend",
"s",
"JSON",
"encoder",
"."
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/DataStructure.php#L102-L117 |
shopgate/cart-integration-sdk | src/helper/DataStructure.php | Shopgate_Helper_DataStructure.jsonDecode | public function jsonDecode($json, $assoc = false)
{
// if json_decode exists use that
if (extension_loaded('json') && function_exists('json_decode')) {
$decodedValue = json_decode($json, $assoc);
if (!empty($decodedValue)) {
return $decodedValue;
}
}
try {
return \Zend\Json\Decoder::decode(
$json,
$assoc
? \Zend\Json\Json::TYPE_ARRAY
: \Zend\Json\Json::TYPE_OBJECT
);
} catch (Exception $exception) {
// if a string is no valid json this call will throw Zend\Json\Exception\RuntimeException
return null;
}
} | php | public function jsonDecode($json, $assoc = false)
{
// if json_decode exists use that
if (extension_loaded('json') && function_exists('json_decode')) {
$decodedValue = json_decode($json, $assoc);
if (!empty($decodedValue)) {
return $decodedValue;
}
}
try {
return \Zend\Json\Decoder::decode(
$json,
$assoc
? \Zend\Json\Json::TYPE_ARRAY
: \Zend\Json\Json::TYPE_OBJECT
);
} catch (Exception $exception) {
// if a string is no valid json this call will throw Zend\Json\Exception\RuntimeException
return null;
}
} | [
"public",
"function",
"jsonDecode",
"(",
"$",
"json",
",",
"$",
"assoc",
"=",
"false",
")",
"{",
"// if json_decode exists use that",
"if",
"(",
"extension_loaded",
"(",
"'json'",
")",
"&&",
"function_exists",
"(",
"'json_decode'",
")",
")",
"{",
"$",
"decoded... | Creates a variable, array or object from any passed JSON string.
Uses json_decode() if present, otherwise falls back to Zend's JSON decoder.
@param string $json
@param bool $assoc
@return mixed | [
"Creates",
"a",
"variable",
"array",
"or",
"object",
"from",
"any",
"passed",
"JSON",
"string",
".",
"Uses",
"json_decode",
"()",
"if",
"present",
"otherwise",
"falls",
"back",
"to",
"Zend",
"s",
"JSON",
"decoder",
"."
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/DataStructure.php#L128-L149 |
makinacorpus/drupal-ucms | ucms_list/src/Impl/TypeContentListWidget.php | TypeContentListWidget.fetch | public function fetch(EntityInterface $entity, Site $site, Query $query, $options = [])
{
$typeList = $options['type'];
if (empty($typeList)) {
return [];
}
$exclude = [];
$limit = $query->getLimit();
// @todo fixme
$usePager = false; //$query->
// Exclude current node whenever it matches the conditions
if (($current = menu_get_object()) && in_array($current->bundle(), $typeList)) {
$exclude[] = $current->id();
}
$select = db_select('node', 'n');
$select->join('ucms_site_node', 'un', 'un.nid = n.nid');
if ($exclude) {
$select->condition('n.nid', $exclude, 'NOT IN');
}
if ($options['tags']) {
$select->groupBy('n.nid');
$select->join('taxonomy_index', 'i', 'i.nid = n.nid');
$select->condition('i.tid', $options['tags']);
}
$select
->fields('n', ['nid'])
->condition('n.type', $typeList)
->condition('n.status', NODE_PUBLISHED)
->condition('un.site_id', $site->getId())
;
if ($query->hasSortField()) {
$select->orderBy('n.' . $query->getSortField(), $query->getSortOrder());
}
$select
->addMetaData('entity', $entity)
->addMetaData('ucms_list', $typeList)
->addTag('node_access')
;
if ($usePager) {
// execute() method must run on the query extender and not the
// original query itself, do not change this
$select = $query->extend('PagerDefault');
$select->limit($limit);
} else {
$select->range(0, $limit);
}
return $select->execute()->fetchCol();
} | php | public function fetch(EntityInterface $entity, Site $site, Query $query, $options = [])
{
$typeList = $options['type'];
if (empty($typeList)) {
return [];
}
$exclude = [];
$limit = $query->getLimit();
// @todo fixme
$usePager = false; //$query->
// Exclude current node whenever it matches the conditions
if (($current = menu_get_object()) && in_array($current->bundle(), $typeList)) {
$exclude[] = $current->id();
}
$select = db_select('node', 'n');
$select->join('ucms_site_node', 'un', 'un.nid = n.nid');
if ($exclude) {
$select->condition('n.nid', $exclude, 'NOT IN');
}
if ($options['tags']) {
$select->groupBy('n.nid');
$select->join('taxonomy_index', 'i', 'i.nid = n.nid');
$select->condition('i.tid', $options['tags']);
}
$select
->fields('n', ['nid'])
->condition('n.type', $typeList)
->condition('n.status', NODE_PUBLISHED)
->condition('un.site_id', $site->getId())
;
if ($query->hasSortField()) {
$select->orderBy('n.' . $query->getSortField(), $query->getSortOrder());
}
$select
->addMetaData('entity', $entity)
->addMetaData('ucms_list', $typeList)
->addTag('node_access')
;
if ($usePager) {
// execute() method must run on the query extender and not the
// original query itself, do not change this
$select = $query->extend('PagerDefault');
$select->limit($limit);
} else {
$select->range(0, $limit);
}
return $select->execute()->fetchCol();
} | [
"public",
"function",
"fetch",
"(",
"EntityInterface",
"$",
"entity",
",",
"Site",
"$",
"site",
",",
"Query",
"$",
"query",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"typeList",
"=",
"$",
"options",
"[",
"'type'",
"]",
";",
"if",
"(",
"emp... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_list/src/Impl/TypeContentListWidget.php#L32-L90 |
makinacorpus/drupal-ucms | ucms_list/src/Impl/TypeContentListWidget.php | TypeContentListWidget.getContentTagsList | protected function getContentTagsList()
{
$ret = [];
if (!$this->labelManager) {
return;
}
$tagList = $this->labelManager->loadAllLabels();
if ($tagList) {
foreach ($tagList as $tag) {
$ret[$tag->tid] = $tag->name;
}
}
return $ret;
} | php | protected function getContentTagsList()
{
$ret = [];
if (!$this->labelManager) {
return;
}
$tagList = $this->labelManager->loadAllLabels();
if ($tagList) {
foreach ($tagList as $tag) {
$ret[$tag->tid] = $tag->name;
}
}
return $ret;
} | [
"protected",
"function",
"getContentTagsList",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"labelManager",
")",
"{",
"return",
";",
"}",
"$",
"tagList",
"=",
"$",
"this",
"->",
"labelManager",
"->",
"loadAllLabels"... | Get allowed tags list. | [
"Get",
"allowed",
"tags",
"list",
"."
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_list/src/Impl/TypeContentListWidget.php#L114-L131 |
makinacorpus/drupal-ucms | ucms_list/src/Impl/TypeContentListWidget.php | TypeContentListWidget.getOptionsForm | public function getOptionsForm($options = [])
{
$ret = parent::getOptionsForm($options);
$ret = [
'type' => [
'#type' => 'select',
'#title' => $this->t("Content types to display"),
'#options' => $this->getContentTypeList(),
'#default_value' => $options['type'],
'#element_validate' => ['ucms_list_element_validate_filter'],
'#multiple' => true,
]
];
$tagOptions = $this->getContentTagsList();
if ($tagOptions) {
$ret['tags'] = [
'#type' => 'select',
'#title' => $this->t("Tags for which content should be displayed"),
'#options' => $tagOptions,
'#default_value' => $options['tags'],
'#element_validate' => ['ucms_list_element_validate_filter'],
'#multiple' => true,
];
}
return $ret;
} | php | public function getOptionsForm($options = [])
{
$ret = parent::getOptionsForm($options);
$ret = [
'type' => [
'#type' => 'select',
'#title' => $this->t("Content types to display"),
'#options' => $this->getContentTypeList(),
'#default_value' => $options['type'],
'#element_validate' => ['ucms_list_element_validate_filter'],
'#multiple' => true,
]
];
$tagOptions = $this->getContentTagsList();
if ($tagOptions) {
$ret['tags'] = [
'#type' => 'select',
'#title' => $this->t("Tags for which content should be displayed"),
'#options' => $tagOptions,
'#default_value' => $options['tags'],
'#element_validate' => ['ucms_list_element_validate_filter'],
'#multiple' => true,
];
}
return $ret;
} | [
"public",
"function",
"getOptionsForm",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"ret",
"=",
"parent",
"::",
"getOptionsForm",
"(",
"$",
"options",
")",
";",
"$",
"ret",
"=",
"[",
"'type'",
"=>",
"[",
"'#type'",
"=>",
"'select'",
",",
"'#ti... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_list/src/Impl/TypeContentListWidget.php#L136-L164 |
mosbth/Anax-MVC | src/TConfigure.php | TConfigure.configure | public function configure($what)
{
if (is_array($what)) {
$options = $what;
} elseif (is_readable($what)) {
$options = include $what;
} else {
throw new Exception("Configure item '" . htmlentities($what)
. "' is not an array nor a readable file.");
}
$this->config = array_merge($this->config, $options);
return $this->config;
} | php | public function configure($what)
{
if (is_array($what)) {
$options = $what;
} elseif (is_readable($what)) {
$options = include $what;
} else {
throw new Exception("Configure item '" . htmlentities($what)
. "' is not an array nor a readable file.");
}
$this->config = array_merge($this->config, $options);
return $this->config;
} | [
"public",
"function",
"configure",
"(",
"$",
"what",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"what",
")",
")",
"{",
"$",
"options",
"=",
"$",
"what",
";",
"}",
"elseif",
"(",
"is_readable",
"(",
"$",
"what",
")",
")",
"{",
"$",
"options",
"=",... | Read configuration from file or array'.
@param array/string $what is an array with key/value config options or a file
to be included which returns such an array.
@return $this for chaining.
@throws Exception | [
"Read",
"configuration",
"from",
"file",
"or",
"array",
"."
] | train | https://github.com/mosbth/Anax-MVC/blob/5574d105bcec9df8e57532a321585f6521b4581c/src/TConfigure.php#L27-L40 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.normalizePath | protected function normalizePath($path)
{
$path = parent::normalizePath($path);
return $this->getMultiRepositoryPath($path) ?: $path;
} | php | protected function normalizePath($path)
{
$path = parent::normalizePath($path);
return $this->getMultiRepositoryPath($path) ?: $path;
} | [
"protected",
"function",
"normalizePath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"parent",
"::",
"normalizePath",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
"->",
"getMultiRepositoryPath",
"(",
"$",
"path",
")",
"?",
":",
"$",
"path",
";... | Normalize path
Return path of general multi-repository if possible
@param string $path
@return string | [
"Normalize",
"path"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L73-L77 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.getMultiRepositoryPath | protected function getMultiRepositoryPath($path)
{
if ($this->isPathOfMultiRepository($path)) {
return $path;
}
$packageDir = pathinfo($path, PATHINFO_BASENAME);
if (!strpos($packageDir, self::MULTI_REPO_DELIMITER)) {
//package cannot be used in multi-repo
return null;
}
$this->defaultPath = $path;
$arr = explode(self::MULTI_REPO_DELIMITER, $packageDir);
$baseName = array_shift($arr);
$customDir = $this->getParentMultiRepoDir();
if ($customDir) {
//get vendor name
$vendor = pathinfo(dirname($path), PATHINFO_BASENAME);
//get path based upon custom parent dir
$newPath = $customDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR
. $baseName . self::MULTI_REPO_DIRECTORY_SUFFIX;
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository custom path found.');
}
} else {
//make full path to new general multi-repo directory
$newPath = str_replace(
$packageDir,
$baseName . self::MULTI_REPO_DIRECTORY_SUFFIX, //make repo dir name
$path
);
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be within the current vendor directory.');
}
}
$this->filesystem->ensureDirectoryExists($newPath);
return $newPath;
} | php | protected function getMultiRepositoryPath($path)
{
if ($this->isPathOfMultiRepository($path)) {
return $path;
}
$packageDir = pathinfo($path, PATHINFO_BASENAME);
if (!strpos($packageDir, self::MULTI_REPO_DELIMITER)) {
//package cannot be used in multi-repo
return null;
}
$this->defaultPath = $path;
$arr = explode(self::MULTI_REPO_DELIMITER, $packageDir);
$baseName = array_shift($arr);
$customDir = $this->getParentMultiRepoDir();
if ($customDir) {
//get vendor name
$vendor = pathinfo(dirname($path), PATHINFO_BASENAME);
//get path based upon custom parent dir
$newPath = $customDir . DIRECTORY_SEPARATOR . $vendor . DIRECTORY_SEPARATOR
. $baseName . self::MULTI_REPO_DIRECTORY_SUFFIX;
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository custom path found.');
}
} else {
//make full path to new general multi-repo directory
$newPath = str_replace(
$packageDir,
$baseName . self::MULTI_REPO_DIRECTORY_SUFFIX, //make repo dir name
$path
);
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be within the current vendor directory.');
}
}
$this->filesystem->ensureDirectoryExists($newPath);
return $newPath;
} | [
"protected",
"function",
"getMultiRepositoryPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPathOfMultiRepository",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
";",
"}",
"$",
"packageDir",
"=",
"pathinfo",
"(",
"$",
"path"... | Get multi repository directory path
@param string $path
@return string | [
"Get",
"multi",
"repository",
"directory",
"path"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L85-L124 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.getParentMultiRepoDir | protected function getParentMultiRepoDir()
{
$rootConfig = $this->config->get('root_extra_config');
if (!empty($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR])) {
$rootConfig[self::KEY_MULTI_REPO_PARENT_DIR] = rtrim($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR], '\\/');
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in custom parent directory.');
}
return $rootConfig[self::KEY_MULTI_REPO_PARENT_DIR];
}
if (!isset($rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) || $rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) {
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in "cache-repo-dir".');
}
return $this->config->get('cache-repo-dir');
}
return null;
} | php | protected function getParentMultiRepoDir()
{
$rootConfig = $this->config->get('root_extra_config');
if (!empty($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR])) {
$rootConfig[self::KEY_MULTI_REPO_PARENT_DIR] = rtrim($rootConfig[self::KEY_MULTI_REPO_PARENT_DIR], '\\/');
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in custom parent directory.');
}
return $rootConfig[self::KEY_MULTI_REPO_PARENT_DIR];
}
if (!isset($rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) || $rootConfig[self::KEY_MULTI_REPO_IN_CACHE]) {
if ($this->io->isVeryVerbose()) {
$this->io->write(' Multi-repository path will be in "cache-repo-dir".');
}
return $this->config->get('cache-repo-dir');
}
return null;
} | [
"protected",
"function",
"getParentMultiRepoDir",
"(",
")",
"{",
"$",
"rootConfig",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'root_extra_config'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"rootConfig",
"[",
"self",
"::",
"KEY_MULTI_REPO_PAREN... | Get custom parent multi repository directory
@return string|null | [
"Get",
"custom",
"parent",
"multi",
"repository",
"directory"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L131-L148 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.copyFilesToDefaultPath | protected function copyFilesToDefaultPath($source)
{
$target = $this->defaultPath;
if (!$target || $target == $source) {
return $this;
}
if (is_file($source)) {
//copy file
copy($source, $target);
return $this;
}
$it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
$this->cleanUpDir($target);
/** @var \SplFileInfo $file */
foreach ($ri as $file) {
if ('.git' . DIRECTORY_SEPARATOR == substr($ri->getSubPathName(), 0, 5)
|| '.git' == $ri->getSubPathName()
) {
//skip .git directory
continue;
}
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
if ($file->isDir()) {
$this->filesystem->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}
}
return $this;
} | php | protected function copyFilesToDefaultPath($source)
{
$target = $this->defaultPath;
if (!$target || $target == $source) {
return $this;
}
if (is_file($source)) {
//copy file
copy($source, $target);
return $this;
}
$it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
$ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
$this->cleanUpDir($target);
/** @var \SplFileInfo $file */
foreach ($ri as $file) {
if ('.git' . DIRECTORY_SEPARATOR == substr($ri->getSubPathName(), 0, 5)
|| '.git' == $ri->getSubPathName()
) {
//skip .git directory
continue;
}
$targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
if ($file->isDir()) {
$this->filesystem->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}
}
return $this;
} | [
"protected",
"function",
"copyFilesToDefaultPath",
"(",
"$",
"source",
")",
"{",
"$",
"target",
"=",
"$",
"this",
"->",
"defaultPath",
";",
"if",
"(",
"!",
"$",
"target",
"||",
"$",
"target",
"==",
"$",
"source",
")",
"{",
"return",
"$",
"this",
";",
... | Copy files to default package directory
@param $source
@return $this | [
"Copy",
"files",
"to",
"default",
"package",
"directory"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L156-L190 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.doDownload | public function doDownload(PackageInterface $package, $path, $url)
{
GitUtil::cleanEnv();
$path = $this->normalizePath($path);
if (!$this->isRequiredRepository($path, $url)) {
throw new FilesystemException('Unknown repository installed into ' . $path);
}
$ref = $package->getSourceReference();
if ($this->io->isVerbose()) {
$this->io->write(' Multi-repository path: ' . $path);
}
if (!$this->isRepositoryCloned($path)) {
$this->io->write(' Multi-repository GIT directory not found. Cloning...');
$this->cloneRepository($package, $path, $url);
} else {
$this->io->write(' Multi-repository GIT directory found. Fetching changes...');
$this->fetchRepositoryUpdates($package, $path, $url);
}
if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
if ($package->getDistReference() === $package->getSourceReference()) {
$package->setDistReference($newRef);
}
$package->setSourceReference($newRef);
}
//copy file into required directory
$this->copyFilesToDefaultPath($path);
} | php | public function doDownload(PackageInterface $package, $path, $url)
{
GitUtil::cleanEnv();
$path = $this->normalizePath($path);
if (!$this->isRequiredRepository($path, $url)) {
throw new FilesystemException('Unknown repository installed into ' . $path);
}
$ref = $package->getSourceReference();
if ($this->io->isVerbose()) {
$this->io->write(' Multi-repository path: ' . $path);
}
if (!$this->isRepositoryCloned($path)) {
$this->io->write(' Multi-repository GIT directory not found. Cloning...');
$this->cloneRepository($package, $path, $url);
} else {
$this->io->write(' Multi-repository GIT directory found. Fetching changes...');
$this->fetchRepositoryUpdates($package, $path, $url);
}
if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
if ($package->getDistReference() === $package->getSourceReference()) {
$package->setDistReference($newRef);
}
$package->setSourceReference($newRef);
}
//copy file into required directory
$this->copyFilesToDefaultPath($path);
} | [
"public",
"function",
"doDownload",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
"{",
"GitUtil",
"::",
"cleanEnv",
"(",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"i... | Downloads specific package into specific folder
VCS repository will be created in a separated folder.
@param PackageInterface $package
@param string $path
@param string $url
@throws FilesystemException | [
"Downloads",
"specific",
"package",
"into",
"specific",
"folder"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L202-L232 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.initGitUtil | protected function initGitUtil()
{
$this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
return $this;
} | php | protected function initGitUtil()
{
$this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
return $this;
} | [
"protected",
"function",
"initGitUtil",
"(",
")",
"{",
"$",
"this",
"->",
"gitUtil",
"=",
"new",
"GitUtil",
"(",
"$",
"this",
"->",
"io",
",",
"$",
"this",
"->",
"config",
",",
"$",
"this",
"->",
"process",
",",
"$",
"this",
"->",
"filesystem",
")",
... | Init GitUtil object
@return $this | [
"Init",
"GitUtil",
"object"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L257-L261 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.getCloneCommandCallback | protected function getCloneCommandCallback($path, $ref, $command)
{
return function ($url) use ($ref, $path, $command) {
return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref));
};
} | php | protected function getCloneCommandCallback($path, $ref, $command)
{
return function ($url) use ($ref, $path, $command) {
return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref));
};
} | [
"protected",
"function",
"getCloneCommandCallback",
"(",
"$",
"path",
",",
"$",
"ref",
",",
"$",
"command",
")",
"{",
"return",
"function",
"(",
"$",
"url",
")",
"use",
"(",
"$",
"ref",
",",
"$",
"path",
",",
"$",
"command",
")",
"{",
"return",
"spri... | Get command callback for cloning
@param string $path
@param string $ref
@param string $command
@return callable | [
"Get",
"command",
"callback",
"for",
"cloning"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L280-L285 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.fetchRepositoryUpdates | protected function fetchRepositoryUpdates(PackageInterface $package, $path, $url)
{
/**
* Copy-pasted from doUpdate
*
* @see GitDownloader::doUpdate()
*/
$this->io->write(' Checking out ' . $package->getSourceReference());
$command = $this->getFetchCommand();
$commandCallable = function ($url) use ($command) {
return sprintf($command, ProcessExecutor::escape($url));
};
$this->gitUtil->runCommand($commandCallable, $url, $path);
return $this;
} | php | protected function fetchRepositoryUpdates(PackageInterface $package, $path, $url)
{
/**
* Copy-pasted from doUpdate
*
* @see GitDownloader::doUpdate()
*/
$this->io->write(' Checking out ' . $package->getSourceReference());
$command = $this->getFetchCommand();
$commandCallable = function ($url) use ($command) {
return sprintf($command, ProcessExecutor::escape($url));
};
$this->gitUtil->runCommand($commandCallable, $url, $path);
return $this;
} | [
"protected",
"function",
"fetchRepositoryUpdates",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
"{",
"/**\n * Copy-pasted from doUpdate\n *\n * @see GitDownloader::doUpdate()\n */",
"$",
"this",
"->",
"io",
"... | Fetch remote VCS repository updates
@param PackageInterface $package
@param string $path
@param string $url
@return $this | [
"Fetch",
"remote",
"VCS",
"repository",
"updates"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L305-L319 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.cloneRepository | protected function cloneRepository(PackageInterface $package, $path, $url)
{
$command = $this->getCloneCommand();
$this->io->write(" Cloning " . $package->getSourceReference());
$commandCallable = $this->getCloneCommandCallback($path, $package->getSourceReference(), $command);
$this->gitUtil->runCommand($commandCallable, $url, $path, true);
if ($url !== $package->getSourceUrl()) {
$url = $package->getSourceUrl();
$this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
}
$this->setPushUrl($path, $url);
return $this;
} | php | protected function cloneRepository(PackageInterface $package, $path, $url)
{
$command = $this->getCloneCommand();
$this->io->write(" Cloning " . $package->getSourceReference());
$commandCallable = $this->getCloneCommandCallback($path, $package->getSourceReference(), $command);
$this->gitUtil->runCommand($commandCallable, $url, $path, true);
if ($url !== $package->getSourceUrl()) {
$url = $package->getSourceUrl();
$this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
}
$this->setPushUrl($path, $url);
return $this;
} | [
"protected",
"function",
"cloneRepository",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"getCloneCommand",
"(",
")",
";",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"\"... | Clone repository
@param PackageInterface $package
@param string $path
@param string $url
@return $this | [
"Clone",
"repository"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L329-L343 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.isRequiredRepository | protected function isRequiredRepository($path, $url)
{
if ($this->isMultiRepository() && $this->isRepositoryCloned($path)) {
$this->process->execute(sprintf('git config --get remote.origin.url'), $output, $path);
return $url == trim($output);
}
return true; //empty directory
} | php | protected function isRequiredRepository($path, $url)
{
if ($this->isMultiRepository() && $this->isRepositoryCloned($path)) {
$this->process->execute(sprintf('git config --get remote.origin.url'), $output, $path);
return $url == trim($output);
}
return true; //empty directory
} | [
"protected",
"function",
"isRequiredRepository",
"(",
"$",
"path",
",",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isMultiRepository",
"(",
")",
"&&",
"$",
"this",
"->",
"isRepositoryCloned",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->"... | Check mismatch of exists repository URL in remote origin
@param string $path
@param string $url
@return bool | [
"Check",
"mismatch",
"of",
"exists",
"repository",
"URL",
"in",
"remote",
"origin"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L361-L368 |
andkirby/multi-repo-composer | src/Downloader/GitMultiRepoDownloader.php | GitMultiRepoDownloader.cleanUpDir | protected function cleanUpDir($directory)
{
$this->filesystem->removeDirectory($directory);
$this->filesystem->ensureDirectoryExists($directory);
return $this;
} | php | protected function cleanUpDir($directory)
{
$this->filesystem->removeDirectory($directory);
$this->filesystem->ensureDirectoryExists($directory);
return $this;
} | [
"protected",
"function",
"cleanUpDir",
"(",
"$",
"directory",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"removeDirectory",
"(",
"$",
"directory",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"ensureDirectoryExists",
"(",
"$",
"directory",
")",
";"... | Clean up directory
@param string $directory
@return $this | [
"Clean",
"up",
"directory"
] | train | https://github.com/andkirby/multi-repo-composer/blob/2d9fed02edf7601f56f2998f9d99e646b713aef6/src/Downloader/GitMultiRepoDownloader.php#L386-L391 |
qloog/yaf-library | src/Validators/RangeValidator.php | RangeValidator.validator | public function validator($field, array $data)
{
$value = isset($data[$field]) ? $data[$field] : null;
if ($value === '' || $value === null) {
return $this->allowEmpty ? true : $this->message('{fieldName}不在允许的范围内!', [
'{fieldName}' => $this->getName($field),
], 'emptyMsg');
}
if (in_array($value, $this->range, $this->isStrict)) {
return true;
}
return $this->message('{fieldName}不在允许的范围内!', [
'{fieldName}' => $this->getName($field),
]);
} | php | public function validator($field, array $data)
{
$value = isset($data[$field]) ? $data[$field] : null;
if ($value === '' || $value === null) {
return $this->allowEmpty ? true : $this->message('{fieldName}不在允许的范围内!', [
'{fieldName}' => $this->getName($field),
], 'emptyMsg');
}
if (in_array($value, $this->range, $this->isStrict)) {
return true;
}
return $this->message('{fieldName}不在允许的范围内!', [
'{fieldName}' => $this->getName($field),
]);
} | [
"public",
"function",
"validator",
"(",
"$",
"field",
",",
"array",
"$",
"data",
")",
"{",
"$",
"value",
"=",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"field",
"]",
":",
"null",
";",
"if",
"(",
"$",
... | 验证
@param string $field
@param array $data
@return bool|string | [
"验证"
] | train | https://github.com/qloog/yaf-library/blob/8e7dc276ffb335adfb298dffce9c0b533e14bd93/src/Validators/RangeValidator.php#L39-L55 |
makinacorpus/drupal-ucms | ucms_contrib/src/DependencyInjection/Compiler/EntityLinkFilterRegisterPass.php | EntityLinkFilterRegisterPass.process | public function process(ContainerBuilder $container)
{
if (class_exists('MakinaCorpus\ULink\EventDispatcher\EntityLinkFilterEvent')) {
$definition = new Definition('MakinaCorpus\Ucms\Contrib\EventDispatcher\EntityLinkFilterEventSubscriber');
$definition->setArguments([new Reference("ucms_site.manager"), new Reference("ucms_site.node_manager")]);
$definition->addTag('event_subscriber');
$container->addDefinitions(['ucms_contrib.entity_link_filter_event_subscriber' => $definition]);
}
} | php | public function process(ContainerBuilder $container)
{
if (class_exists('MakinaCorpus\ULink\EventDispatcher\EntityLinkFilterEvent')) {
$definition = new Definition('MakinaCorpus\Ucms\Contrib\EventDispatcher\EntityLinkFilterEventSubscriber');
$definition->setArguments([new Reference("ucms_site.manager"), new Reference("ucms_site.node_manager")]);
$definition->addTag('event_subscriber');
$container->addDefinitions(['ucms_contrib.entity_link_filter_event_subscriber' => $definition]);
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'MakinaCorpus\\ULink\\EventDispatcher\\EntityLinkFilterEvent'",
")",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"'MakinaCorpus\\Ucms\\... | {@inheritDoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/DependencyInjection/Compiler/EntityLinkFilterRegisterPass.php#L16-L24 |
umpirsky/list-generator | src/Umpirsky/ListGenerator/Exporter/Format/Csv.php | Csv.export | public function export(array $data)
{
$outstream = fopen('php://temp', 'r+');
fputcsv($outstream, array('id', 'value'));
foreach ($data as $iso => $name) {
fputcsv($outstream, array($iso, $name));
}
rewind($outstream);
$csv = stream_get_contents($outstream);
fclose($outstream);
return $csv;
} | php | public function export(array $data)
{
$outstream = fopen('php://temp', 'r+');
fputcsv($outstream, array('id', 'value'));
foreach ($data as $iso => $name) {
fputcsv($outstream, array($iso, $name));
}
rewind($outstream);
$csv = stream_get_contents($outstream);
fclose($outstream);
return $csv;
} | [
"public",
"function",
"export",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"outstream",
"=",
"fopen",
"(",
"'php://temp'",
",",
"'r+'",
")",
";",
"fputcsv",
"(",
"$",
"outstream",
",",
"array",
"(",
"'id'",
",",
"'value'",
")",
")",
";",
"foreach",
"(... | {@inheritdoc} | [
"{"
] | train | https://github.com/umpirsky/list-generator/blob/103182faf6e48611901263a49e7a9ba33e7515b8/src/Umpirsky/ListGenerator/Exporter/Format/Csv.php#L12-L24 |
despark/ignicms | public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Benchmark.php | CI_Benchmark.elapsed_time | function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
{
if ($point1 == '')
{
return '{elapsed_time}';
}
if ( ! isset($this->marker[$point1]))
{
return '';
}
if ( ! isset($this->marker[$point2]))
{
$this->marker[$point2] = microtime();
}
list($sm, $ss) = explode(' ', $this->marker[$point1]);
list($em, $es) = explode(' ', $this->marker[$point2]);
return number_format(($em + $es) - ($sm + $ss), $decimals);
} | php | function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
{
if ($point1 == '')
{
return '{elapsed_time}';
}
if ( ! isset($this->marker[$point1]))
{
return '';
}
if ( ! isset($this->marker[$point2]))
{
$this->marker[$point2] = microtime();
}
list($sm, $ss) = explode(' ', $this->marker[$point1]);
list($em, $es) = explode(' ', $this->marker[$point2]);
return number_format(($em + $es) - ($sm + $ss), $decimals);
} | [
"function",
"elapsed_time",
"(",
"$",
"point1",
"=",
"''",
",",
"$",
"point2",
"=",
"''",
",",
"$",
"decimals",
"=",
"4",
")",
"{",
"if",
"(",
"$",
"point1",
"==",
"''",
")",
"{",
"return",
"'{elapsed_time}'",
";",
"}",
"if",
"(",
"!",
"isset",
"... | Calculates the time difference between two marked points.
If the first parameter is empty this function instead returns the
{elapsed_time} pseudo-variable. This permits the full system
execution time to be shown in a template. The output class will
swap the real value for this variable.
@access public
@param string a particular marked point
@param string a particular marked point
@param integer the number of decimal places
@return mixed | [
"Calculates",
"the",
"time",
"difference",
"between",
"two",
"marked",
"points",
"."
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/public/admin_assets/plugins/tinymce/plugins/jbimages/ci/system/core/Benchmark.php#L72-L93 |
runcmf/runbb | src/RunBB/Core/Statical/Manager.php | Manager.addProxyService | public function addProxyService($alias, $proxy, $container, $id = null, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
$container = Input::checkContainer($container);
$id = $id ?: strtolower($alias);
$this->addProxy($proxy, $id, $container);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
} | php | public function addProxyService($alias, $proxy, $container, $id = null, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
$container = Input::checkContainer($container);
$id = $id ?: strtolower($alias);
$this->addProxy($proxy, $id, $container);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
} | [
"public",
"function",
"addProxyService",
"(",
"$",
"alias",
",",
"$",
"proxy",
",",
"$",
"container",
",",
"$",
"id",
"=",
"null",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"proxy",
"=",
"Input",
"::",
"checkNamespace",
"(",
"$",
"proxy",
")... | Adds a service as a proxy target
If $id is null then the lower-cased alias will be used.
@param string $alias The statical name you call
@param string $proxy The namespaced proxy class
@param mixed $container Reference to a container
@param mixed $id The id of the target in the container
@param mixed $namespace Optional namespace | [
"Adds",
"a",
"service",
"as",
"a",
"proxy",
"target"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Statical/Manager.php#L99-L111 |
runcmf/runbb | src/RunBB/Core/Statical/Manager.php | Manager.addProxyInstance | public function addProxyInstance($alias, $proxy, $target, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
if (!is_object($target)) {
throw new \InvalidArgumentException('Target must be an instance or closure.');
}
$this->addProxy($proxy, null, $target);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
} | php | public function addProxyInstance($alias, $proxy, $target, $namespace = null)
{
$proxy = Input::checkNamespace($proxy);
if (!is_object($target)) {
throw new \InvalidArgumentException('Target must be an instance or closure.');
}
$this->addProxy($proxy, null, $target);
$this->aliasManager->add($proxy, $alias);
if ($namespace) {
$this->addNamespace($alias, $namespace);
}
} | [
"public",
"function",
"addProxyInstance",
"(",
"$",
"alias",
",",
"$",
"proxy",
",",
"$",
"target",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"proxy",
"=",
"Input",
"::",
"checkNamespace",
"(",
"$",
"proxy",
")",
";",
"if",
"(",
"!",
"is_obj... | Adds an instance or closure as a proxy target
@param string $alias The statical name you call
@param string $proxy The namespaced proxy class
@param mixed $target The target instance or closure
@param mixed $namespace Optional namespace | [
"Adds",
"an",
"instance",
"or",
"closure",
"as",
"a",
"proxy",
"target"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Statical/Manager.php#L121-L135 |
runcmf/runbb | src/RunBB/Core/Statical/Manager.php | Manager.addNamespaceGroup | public function addNamespaceGroup($group, $alias, $namespace = null)
{
$namespace = Input::formatNamespace($namespace, $group);
$this->aliasManager->addNamespace($alias, $namespace);
} | php | public function addNamespaceGroup($group, $alias, $namespace = null)
{
$namespace = Input::formatNamespace($namespace, $group);
$this->aliasManager->addNamespace($alias, $namespace);
} | [
"public",
"function",
"addNamespaceGroup",
"(",
"$",
"group",
",",
"$",
"alias",
",",
"$",
"namespace",
"=",
"null",
")",
"{",
"$",
"namespace",
"=",
"Input",
"::",
"formatNamespace",
"(",
"$",
"namespace",
",",
"$",
"group",
")",
";",
"$",
"this",
"->... | Adds a namespace group for a single, or all aliases
The $alias can either be a single value or the wildcard '*' value, which
allows any registered alias in the namespace.
The group can be one of the following:
'name' - the alias can be called in the $namespace
'path' - the alias can be called in the $namespace and any descendants
'any' - the alias can be called in any namespace
Namespace can either be a single string value, an array of values, or
missing in the case of group 'any'.
@param string $group
@param string $alias
@param mixed $namespace | [
"Adds",
"a",
"namespace",
"group",
"for",
"a",
"single",
"or",
"all",
"aliases"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Statical/Manager.php#L178-L182 |
makinacorpus/drupal-ucms | ucms_tree/src/Action/TreeSetMainProcessor.php | TreeSetMainProcessor.processAll | public function processAll($items)
{
foreach ($items as $item) {
$this->menuStorage->toggleMainStatus($item->getName(), true);
}
return $this->formatPlural(
count($item),
"Menu has been set as main site menu",
"@count menus have been set as main site menu"
);
} | php | public function processAll($items)
{
foreach ($items as $item) {
$this->menuStorage->toggleMainStatus($item->getName(), true);
}
return $this->formatPlural(
count($item),
"Menu has been set as main site menu",
"@count menus have been set as main site menu"
);
} | [
"public",
"function",
"processAll",
"(",
"$",
"items",
")",
"{",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"->",
"menuStorage",
"->",
"toggleMainStatus",
"(",
"$",
"item",
"->",
"getName",
"(",
")",
",",
"true",
")",
";"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/Action/TreeSetMainProcessor.php#L68-L79 |
NicolasMahe/Laravel-SlackOutput | src/Library/JobFailed.php | JobFailed.output | static public function output(JB $event, $channel)
{
$message = "Job '" . $event->job->getName() . "' failed.";
Artisan::call('slack:post', [
'to' => $channel,
'message' => $message
]);
} | php | static public function output(JB $event, $channel)
{
$message = "Job '" . $event->job->getName() . "' failed.";
Artisan::call('slack:post', [
'to' => $channel,
'message' => $message
]);
} | [
"static",
"public",
"function",
"output",
"(",
"JB",
"$",
"event",
",",
"$",
"channel",
")",
"{",
"$",
"message",
"=",
"\"Job '\"",
".",
"$",
"event",
"->",
"job",
"->",
"getName",
"(",
")",
".",
"\"' failed.\"",
";",
"Artisan",
"::",
"call",
"(",
"'... | Output a failed job to slack
@param JB $event
@param $channel | [
"Output",
"a",
"failed",
"job",
"to",
"slack"
] | train | https://github.com/NicolasMahe/Laravel-SlackOutput/blob/fc3722ba64a0ce4d833555bb1a27513e13959b34/src/Library/JobFailed.php#L17-L24 |
BugBuster1701/botdetection | src/modules/ModuleFrontendDemo1.php | ModuleFrontendDemo1.compile | protected function compile()
{
//einzel tests direkt aufgerufen
$test01 = CheckBotAgentSimple::checkAgent( \Environment::get('httpUserAgent') ); // own Browser
CheckBotIp::setBotIpv4List(TL_ROOT . self::BOT_IP4_LIST);
CheckBotIp::setBotIpv6List(TL_ROOT . self::BOT_IP6_LIST);
$test02 = CheckBotIp::checkIP( \Environment::get('ip') ); // own IP
$test03 = CheckBotAgentExtended::checkAgent( \Environment::get('httpUserAgent') ); // own Browser
//for fe template
$arrDemo[] = array(
'type' => 'agent',
'test' => '01',
'theoretical' => 'false',
'actual' => var_export($test01,true),
'comment' => '<br />'.\Environment::get('httpUserAgent'),
'color' => ($test01 === false) ? 'green' : 'red'
);
$arrDemo[] = array(
'type' => 'ip',
'test' => '02',
'theoretical' => 'false',
'actual' => var_export($test02,true),
'comment' => '<br />'.\Environment::get('ip'),
'color' => ($test02 === false) ? 'green' : 'red'
);
$arrDemo[] = array(
'type' => 'agentadvanced',
'test' => '03',
'theoretical' => 'false',
'actual' => var_export($test03,true),
'comment' => '<br />'.\Environment::get('httpUserAgent'),
'color' => ((bool)$test03 === false) ? 'green' : 'red'
);
//Gesamt Test Aufruf
$this->ModuleBotDetection = new \BotDetection\ModuleBotDetection();
$test04 = $this->ModuleBotDetection->checkBotAllTests( \Environment::get('httpUserAgent') );
$arrDemo[] = array(
'type' => 'alltests',
'test' => '04',
'theoretical' => 'false',
'actual' => var_export($test04,true),
'comment' => '<br />'.\Environment::get('httpUserAgent'),
'color' => ($test04 === false) ? 'green' : 'red'
);
$this->Template->demos = $arrDemo;
// get module version
$this->Template->version = $this->ModuleBotDetection->getVersion();
} | php | protected function compile()
{
//einzel tests direkt aufgerufen
$test01 = CheckBotAgentSimple::checkAgent( \Environment::get('httpUserAgent') ); // own Browser
CheckBotIp::setBotIpv4List(TL_ROOT . self::BOT_IP4_LIST);
CheckBotIp::setBotIpv6List(TL_ROOT . self::BOT_IP6_LIST);
$test02 = CheckBotIp::checkIP( \Environment::get('ip') ); // own IP
$test03 = CheckBotAgentExtended::checkAgent( \Environment::get('httpUserAgent') ); // own Browser
//for fe template
$arrDemo[] = array(
'type' => 'agent',
'test' => '01',
'theoretical' => 'false',
'actual' => var_export($test01,true),
'comment' => '<br />'.\Environment::get('httpUserAgent'),
'color' => ($test01 === false) ? 'green' : 'red'
);
$arrDemo[] = array(
'type' => 'ip',
'test' => '02',
'theoretical' => 'false',
'actual' => var_export($test02,true),
'comment' => '<br />'.\Environment::get('ip'),
'color' => ($test02 === false) ? 'green' : 'red'
);
$arrDemo[] = array(
'type' => 'agentadvanced',
'test' => '03',
'theoretical' => 'false',
'actual' => var_export($test03,true),
'comment' => '<br />'.\Environment::get('httpUserAgent'),
'color' => ((bool)$test03 === false) ? 'green' : 'red'
);
//Gesamt Test Aufruf
$this->ModuleBotDetection = new \BotDetection\ModuleBotDetection();
$test04 = $this->ModuleBotDetection->checkBotAllTests( \Environment::get('httpUserAgent') );
$arrDemo[] = array(
'type' => 'alltests',
'test' => '04',
'theoretical' => 'false',
'actual' => var_export($test04,true),
'comment' => '<br />'.\Environment::get('httpUserAgent'),
'color' => ($test04 === false) ? 'green' : 'red'
);
$this->Template->demos = $arrDemo;
// get module version
$this->Template->version = $this->ModuleBotDetection->getVersion();
} | [
"protected",
"function",
"compile",
"(",
")",
"{",
"//einzel tests direkt aufgerufen",
"$",
"test01",
"=",
"CheckBotAgentSimple",
"::",
"checkAgent",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'httpUserAgent'",
")",
")",
";",
"// own Browser",
"CheckBotIp",
"::",
... | Generate module | [
"Generate",
"module"
] | train | https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleFrontendDemo1.php#L67-L118 |
makinacorpus/drupal-ucms | ucms_label/src/Action/LabelNotificationsActionProvider.php | LabelNotificationsActionProvider.getActions | public function getActions($item, $primaryOnly = false, array $groups = [])
{
$actions = [];
if (!$this->manager->isRootLabel($item)) {
if (!$this->notifService->isSubscribedTo($this->currentUser->id(), 'label:' . $item->tid)) {
$actions[] = new Action($this->t("Subscribe to the notifications"), 'admin/dashboard/label/' . $item->tid . '/subscribe', 'dialog', 'bell', -30, true, true);
} else {
$actions[] = new Action($this->t("Unsubscribe from the notifications"), 'admin/dashboard/label/' . $item->tid . '/unsubscribe', 'dialog', 'remove', -30, true, true);
}
}
return $actions;
} | php | public function getActions($item, $primaryOnly = false, array $groups = [])
{
$actions = [];
if (!$this->manager->isRootLabel($item)) {
if (!$this->notifService->isSubscribedTo($this->currentUser->id(), 'label:' . $item->tid)) {
$actions[] = new Action($this->t("Subscribe to the notifications"), 'admin/dashboard/label/' . $item->tid . '/subscribe', 'dialog', 'bell', -30, true, true);
} else {
$actions[] = new Action($this->t("Unsubscribe from the notifications"), 'admin/dashboard/label/' . $item->tid . '/unsubscribe', 'dialog', 'remove', -30, true, true);
}
}
return $actions;
} | [
"public",
"function",
"getActions",
"(",
"$",
"item",
",",
"$",
"primaryOnly",
"=",
"false",
",",
"array",
"$",
"groups",
"=",
"[",
"]",
")",
"{",
"$",
"actions",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"manager",
"->",
"isRootLabel"... | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_label/src/Action/LabelNotificationsActionProvider.php#L37-L50 |
makinacorpus/drupal-ucms | ucms_label/src/Action/LabelNotificationsActionProvider.php | LabelNotificationsActionProvider.supports | public function supports($item)
{
return isset($item->vocabulary_machine_name) && ($item->vocabulary_machine_name === $this->manager->getVocabularyMachineName());
} | php | public function supports($item)
{
return isset($item->vocabulary_machine_name) && ($item->vocabulary_machine_name === $this->manager->getVocabularyMachineName());
} | [
"public",
"function",
"supports",
"(",
"$",
"item",
")",
"{",
"return",
"isset",
"(",
"$",
"item",
"->",
"vocabulary_machine_name",
")",
"&&",
"(",
"$",
"item",
"->",
"vocabulary_machine_name",
"===",
"$",
"this",
"->",
"manager",
"->",
"getVocabularyMachineNa... | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_label/src/Action/LabelNotificationsActionProvider.php#L55-L58 |
artkonekt/gears | src/Repository/PreferenceRepository.php | PreferenceRepository.get | public function get($key, $user = null)
{
$preference = $this->getPreferenceOrFail($key);
$value = $this->backend->getPreference($key, $this->getUserId($user));
return is_null($value) ? $preference->default() : $value;
} | php | public function get($key, $user = null)
{
$preference = $this->getPreferenceOrFail($key);
$value = $this->backend->getPreference($key, $this->getUserId($user));
return is_null($value) ? $preference->default() : $value;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"preference",
"=",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"backend",
"->",
"getPreference"... | Returns the value of a preference
@param string $key
@param int|Authenticatable|null $user
@return mixed
@throws UnregisteredPreferenceException | [
"Returns",
"the",
"value",
"of",
"a",
"preference"
] | train | https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L48-L55 |
artkonekt/gears | src/Repository/PreferenceRepository.php | PreferenceRepository.set | public function set($key, $value, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->setPreference($key, $value, $this->getUserId($user));
} | php | public function set($key, $value, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->setPreference($key, $value, $this->getUserId($user));
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"backend",
"->",
"setPreference",
"(",
"$",
"key",
","... | Updates the value of a preference
@param string $key
@param mixed $value
@param int|Authenticatable|null $user
@throws UnregisteredPreferenceException | [
"Updates",
"the",
"value",
"of",
"a",
"preference"
] | train | https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L65-L70 |
artkonekt/gears | src/Repository/PreferenceRepository.php | PreferenceRepository.forget | public function forget($key, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->removePreference($key, $this->getUserId($user));
} | php | public function forget($key, $user = null)
{
$this->getPreferenceOrFail($key);
$this->backend->removePreference($key, $this->getUserId($user));
} | [
"public",
"function",
"forget",
"(",
"$",
"key",
",",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"getPreferenceOrFail",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"backend",
"->",
"removePreference",
"(",
"$",
"key",
",",
"$",
"this",
... | Deletes the value of a preference
@param string $key
@param int|Authenticatable|null $user
@throws UnregisteredPreferenceException | [
"Deletes",
"the",
"value",
"of",
"a",
"preference"
] | train | https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L79-L84 |
artkonekt/gears | src/Repository/PreferenceRepository.php | PreferenceRepository.all | public function all($user = null)
{
return array_merge(
$this->registry->allDefaults(),
$this->backend->allPreferences($this->getUserId($user))->all()
);
} | php | public function all($user = null)
{
return array_merge(
$this->registry->allDefaults(),
$this->backend->allPreferences($this->getUserId($user))->all()
);
} | [
"public",
"function",
"all",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"registry",
"->",
"allDefaults",
"(",
")",
",",
"$",
"this",
"->",
"backend",
"->",
"allPreferences",
"(",
"$",
"this",
"->",
"getUse... | Returns all the saved preference values for a given user as key/value pairs
@param int|Authenticatable|null $user
@return array | [
"Returns",
"all",
"the",
"saved",
"preference",
"values",
"for",
"a",
"given",
"user",
"as",
"key",
"/",
"value",
"pairs"
] | train | https://github.com/artkonekt/gears/blob/6c006a3e8e334d8100aab768a2a5e807bcac5695/src/Repository/PreferenceRepository.php#L93-L99 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.