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 |
|---|---|---|---|---|---|---|---|---|---|---|
PHPixie/HTTP | src/PHPixie/HTTP/Request.php | Request.headers | public function headers()
{
if($this->headers === null) {
$data = $this->serverRequest->getHeaders();
$this->headers = $this->builder->headers($data);
}
return $this->headers;
} | php | public function headers()
{
if($this->headers === null) {
$data = $this->serverRequest->getHeaders();
$this->headers = $this->builder->headers($data);
}
return $this->headers;
} | [
"public",
"function",
"headers",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"headers",
"===",
"null",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"serverRequest",
"->",
"getHeaders",
"(",
")",
";",
"$",
"this",
"->",
"headers",
"=",
"$",
"this... | Headers
@return \PHPixie\HTTP\Data\Headers | [
"Headers"
] | train | https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Request.php#L109-L117 |
despark/ignicms | src/Http/Controllers/Admin/AdminController.php | AdminController.setSidebar | public function setSidebar()
{
$this->sidebarItems = config('admin.sidebar');
$responses = \Event::fire(new AfterSidebarSet($this->sidebarItems));
if (is_array($responses)) {
foreach ($responses as $response) {
if (is_array($response)) {
$this->sidebarItems = array_merge($this->sidebarItems, $response);
}
}
}
} | php | public function setSidebar()
{
$this->sidebarItems = config('admin.sidebar');
$responses = \Event::fire(new AfterSidebarSet($this->sidebarItems));
if (is_array($responses)) {
foreach ($responses as $response) {
if (is_array($response)) {
$this->sidebarItems = array_merge($this->sidebarItems, $response);
}
}
}
} | [
"public",
"function",
"setSidebar",
"(",
")",
"{",
"$",
"this",
"->",
"sidebarItems",
"=",
"config",
"(",
"'admin.sidebar'",
")",
";",
"$",
"responses",
"=",
"\\",
"Event",
"::",
"fire",
"(",
"new",
"AfterSidebarSet",
"(",
"$",
"this",
"->",
"sidebarItems"... | set sidebarMenu. | [
"set",
"sidebarMenu",
"."
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Http/Controllers/Admin/AdminController.php#L180-L191 |
bacart/guzzle-client | src/Middleware/ResponseCacheMiddleware.php | ResponseCacheMiddleware.getCacheItemKey | protected function getCacheItemKey(RequestInterface $request): string
{
$body = (string) $request->getBody();
rewind_body($request);
return static::CACHE_KEY_PREFIX.'|'.md5(serialize([
GuzzleClientMiddlewareInterface::BODY => $body,
GuzzleClientMiddlewareInterface::HEADERS => $request->getHeaders(),
GuzzleClientMiddlewareInterface::METHOD => $request->getMethod(),
GuzzleClientMiddlewareInterface::URI => (string) $request->getUri(),
]));
} | php | protected function getCacheItemKey(RequestInterface $request): string
{
$body = (string) $request->getBody();
rewind_body($request);
return static::CACHE_KEY_PREFIX.'|'.md5(serialize([
GuzzleClientMiddlewareInterface::BODY => $body,
GuzzleClientMiddlewareInterface::HEADERS => $request->getHeaders(),
GuzzleClientMiddlewareInterface::METHOD => $request->getMethod(),
GuzzleClientMiddlewareInterface::URI => (string) $request->getUri(),
]));
} | [
"protected",
"function",
"getCacheItemKey",
"(",
"RequestInterface",
"$",
"request",
")",
":",
"string",
"{",
"$",
"body",
"=",
"(",
"string",
")",
"$",
"request",
"->",
"getBody",
"(",
")",
";",
"rewind_body",
"(",
"$",
"request",
")",
";",
"return",
"s... | @param RequestInterface $request
@return string | [
"@param",
"RequestInterface",
"$request"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Middleware/ResponseCacheMiddleware.php#L123-L134 |
bacart/guzzle-client | src/Middleware/ResponseCacheMiddleware.php | ResponseCacheMiddleware.saveToCache | protected function saveToCache(
RequestInterface $request,
ResponseInterface $response
): bool {
$key = $this->getCacheItemKey($request);
try {
$body = (string) $response->getBody();
rewind_body($response);
$cacheItem = $this
->cache
->getItem($key)
->expiresAfter(new \DateInterval($this->cacheTtl))
->set([
GuzzleClientMiddlewareInterface::BODY => $body,
GuzzleClientMiddlewareInterface::HEADERS => $response->getHeaders(),
GuzzleClientMiddlewareInterface::STATUS => $response->getStatusCode(),
GuzzleClientMiddlewareInterface::REASON => $response->getReasonPhrase(),
GuzzleClientMiddlewareInterface::VERSION => $response->getProtocolVersion(),
]);
} catch (InvalidArgumentException | \Exception $e) {
if (null !== $this->logger) {
$this->logger->error($e->getMessage());
}
return false;
}
$result = $this->cache->save($cacheItem);
if ($result && null !== $this->logger) {
$this->logger->info('Guzzle request result is saved to cache', [
GuzzleClientMiddlewareInterface::URI => (string) $request->getUri(),
]);
}
return $result;
} | php | protected function saveToCache(
RequestInterface $request,
ResponseInterface $response
): bool {
$key = $this->getCacheItemKey($request);
try {
$body = (string) $response->getBody();
rewind_body($response);
$cacheItem = $this
->cache
->getItem($key)
->expiresAfter(new \DateInterval($this->cacheTtl))
->set([
GuzzleClientMiddlewareInterface::BODY => $body,
GuzzleClientMiddlewareInterface::HEADERS => $response->getHeaders(),
GuzzleClientMiddlewareInterface::STATUS => $response->getStatusCode(),
GuzzleClientMiddlewareInterface::REASON => $response->getReasonPhrase(),
GuzzleClientMiddlewareInterface::VERSION => $response->getProtocolVersion(),
]);
} catch (InvalidArgumentException | \Exception $e) {
if (null !== $this->logger) {
$this->logger->error($e->getMessage());
}
return false;
}
$result = $this->cache->save($cacheItem);
if ($result && null !== $this->logger) {
$this->logger->info('Guzzle request result is saved to cache', [
GuzzleClientMiddlewareInterface::URI => (string) $request->getUri(),
]);
}
return $result;
} | [
"protected",
"function",
"saveToCache",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
":",
"bool",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getCacheItemKey",
"(",
"$",
"request",
")",
";",
"try",
"{",
"$",
"body"... | @param RequestInterface $request
@param ResponseInterface $response
@return bool | [
"@param",
"RequestInterface",
"$request",
"@param",
"ResponseInterface",
"$response"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Middleware/ResponseCacheMiddleware.php#L142-L180 |
bacart/guzzle-client | src/Middleware/ResponseCacheMiddleware.php | ResponseCacheMiddleware.addDebugHeader | protected function addDebugHeader(
ResponseInterface $response,
string $value
): ResponseInterface {
if ($this->debug) {
try {
return $response->withHeader(static::DEBUG_HEADER, $value);
} catch (\InvalidArgumentException $e) {
if (null !== $this->logger) {
$this->logger->error($e->getMessage());
}
}
}
return $response;
} | php | protected function addDebugHeader(
ResponseInterface $response,
string $value
): ResponseInterface {
if ($this->debug) {
try {
return $response->withHeader(static::DEBUG_HEADER, $value);
} catch (\InvalidArgumentException $e) {
if (null !== $this->logger) {
$this->logger->error($e->getMessage());
}
}
}
return $response;
} | [
"protected",
"function",
"addDebugHeader",
"(",
"ResponseInterface",
"$",
"response",
",",
"string",
"$",
"value",
")",
":",
"ResponseInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"try",
"{",
"return",
"$",
"response",
"->",
"withHeader",... | @param ResponseInterface $response
@param string $value
@return ResponseInterface | [
"@param",
"ResponseInterface",
"$response",
"@param",
"string",
"$value"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Middleware/ResponseCacheMiddleware.php#L188-L203 |
makinacorpus/drupal-ucms | ucms_seo/src/StoreLocator/StoreLocatorFactory.php | StoreLocatorFactory.create | public function create(NodeInterface $node = null, $type = null, $subArea = null, $locality = null)
{
$class = variable_get('ucms_seo_store_locator_class', false);
if (!class_exists($class)) {
throw new \LogicException("Drupal variable 'ucms_seo_store_locator_class' must be defined.");
}
return new $class($this->service, $node, $type, $subArea, $locality);
} | php | public function create(NodeInterface $node = null, $type = null, $subArea = null, $locality = null)
{
$class = variable_get('ucms_seo_store_locator_class', false);
if (!class_exists($class)) {
throw new \LogicException("Drupal variable 'ucms_seo_store_locator_class' must be defined.");
}
return new $class($this->service, $node, $type, $subArea, $locality);
} | [
"public",
"function",
"create",
"(",
"NodeInterface",
"$",
"node",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"subArea",
"=",
"null",
",",
"$",
"locality",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"variable_get",
"(",
"'ucms_seo_store_locator... | @param NodeInterface $node
@param string $type
@param string $subArea
@param string $locality
@return StoreLocatorInterface | [
"@param",
"NodeInterface",
"$node",
"@param",
"string",
"$type",
"@param",
"string",
"$subArea",
"@param",
"string",
"$locality"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_seo/src/StoreLocator/StoreLocatorFactory.php#L29-L38 |
despark/ignicms | src/Admin/Traits/AdminModelTrait.php | AdminModelTrait.renderTableRow | public function renderTableRow($record, $col)
{
switch (array_get($col, 'type', 'text')) {
case 'yes_no':
return $record->yes_no($record->{$col['db_field']});
break;
case 'format_default_date':
return $record->formatDefaultData($record->{$col['db_field']});
break;
case 'sort':
return '<div class="fa fa-sort sortable-handle"></div>';
break;
case 'relation':
return $record->{$col['relation']}->{$col['db_field']};
break;
case 'translation':
$locale = config('app.locale', 'en');
$i18n = I18n::select('id')->where('locale', $locale)->first();
if ($i18n) {
$i18nId = $i18n->id;
return $record->translate(1)->{$col['db_field']};
}
return 'No translation';
break;
default:
return $record->{$col['db_field']};
break;
}
} | php | public function renderTableRow($record, $col)
{
switch (array_get($col, 'type', 'text')) {
case 'yes_no':
return $record->yes_no($record->{$col['db_field']});
break;
case 'format_default_date':
return $record->formatDefaultData($record->{$col['db_field']});
break;
case 'sort':
return '<div class="fa fa-sort sortable-handle"></div>';
break;
case 'relation':
return $record->{$col['relation']}->{$col['db_field']};
break;
case 'translation':
$locale = config('app.locale', 'en');
$i18n = I18n::select('id')->where('locale', $locale)->first();
if ($i18n) {
$i18nId = $i18n->id;
return $record->translate(1)->{$col['db_field']};
}
return 'No translation';
break;
default:
return $record->{$col['db_field']};
break;
}
} | [
"public",
"function",
"renderTableRow",
"(",
"$",
"record",
",",
"$",
"col",
")",
"{",
"switch",
"(",
"array_get",
"(",
"$",
"col",
",",
"'type'",
",",
"'text'",
")",
")",
"{",
"case",
"'yes_no'",
":",
"return",
"$",
"record",
"->",
"yes_no",
"(",
"$... | return model fields in proper way.
@param $record
@param $col
@return mixed | [
"return",
"model",
"fields",
"in",
"proper",
"way",
"."
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Admin/Traits/AdminModelTrait.php#L108-L138 |
despark/ignicms | src/Admin/Traits/AdminModelTrait.php | AdminModelTrait.searchText | public function searchText()
{
$query = $this->newQuery();
if (Request::get('admin_text_search')) {
foreach ($this->adminFilters['text_search']['db_fields'] as $field) {
$query->orWhere($field, 'LIKE', '%'.Request::get('admin_text_search').'%');
}
}
return $query;
} | php | public function searchText()
{
$query = $this->newQuery();
if (Request::get('admin_text_search')) {
foreach ($this->adminFilters['text_search']['db_fields'] as $field) {
$query->orWhere($field, 'LIKE', '%'.Request::get('admin_text_search').'%');
}
}
return $query;
} | [
"public",
"function",
"searchText",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"newQuery",
"(",
")",
";",
"if",
"(",
"Request",
"::",
"get",
"(",
"'admin_text_search'",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"adminFilters",
"[",
... | create query for list page. | [
"create",
"query",
"for",
"list",
"page",
"."
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Admin/Traits/AdminModelTrait.php#L153-L163 |
despark/ignicms | src/Admin/Traits/AdminModelTrait.php | AdminModelTrait.adminPreviewButton | public function adminPreviewButton()
{
if ($this->adminPreviewMode and $this->exists) {
$db_field = $this->adminPreviewUrlParams['db_field'];
return \Html::link(
route($this->adminPreviewUrlParams['route'], [$this->$db_field, 'preview_mode=1']),
'Preview',
['class' => 'btn btn-primary', 'target' => '_blank']
);
}
} | php | public function adminPreviewButton()
{
if ($this->adminPreviewMode and $this->exists) {
$db_field = $this->adminPreviewUrlParams['db_field'];
return \Html::link(
route($this->adminPreviewUrlParams['route'], [$this->$db_field, 'preview_mode=1']),
'Preview',
['class' => 'btn btn-primary', 'target' => '_blank']
);
}
} | [
"public",
"function",
"adminPreviewButton",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"adminPreviewMode",
"and",
"$",
"this",
"->",
"exists",
")",
"{",
"$",
"db_field",
"=",
"$",
"this",
"->",
"adminPreviewUrlParams",
"[",
"'db_field'",
"]",
";",
"retur... | Generate preview button for the CMS
$adminPreviewMode should be true.
@return string | [
"Generate",
"preview",
"button",
"for",
"the",
"CMS",
"$adminPreviewMode",
"should",
"be",
"true",
"."
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/src/Admin/Traits/AdminModelTrait.php#L263-L274 |
accompli/accompli | src/Task/FilePermissionTask.php | FilePermissionTask.onInstallReleaseUpdateFilePermissions | public function onInstallReleaseUpdateFilePermissions(InstallReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$host = $event->getRelease()->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updating permissions for the configured paths...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$releasePath = $event->getRelease()->getPath();
$result = true;
foreach ($this->paths as $path => $pathSettings) {
$result = $result && $this->updateFilePermissions($connection, $releasePath, $path, $pathSettings);
}
if ($result === true) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updated permissions for the configured paths.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
} else {
throw new TaskRuntimeException('Failed updating the permissions for the configured paths.', $this);
}
} | php | public function onInstallReleaseUpdateFilePermissions(InstallReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$host = $event->getRelease()->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updating permissions for the configured paths...', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_IN_PROGRESS)));
$releasePath = $event->getRelease()->getPath();
$result = true;
foreach ($this->paths as $path => $pathSettings) {
$result = $result && $this->updateFilePermissions($connection, $releasePath, $path, $pathSettings);
}
if ($result === true) {
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Updated permissions for the configured paths.', $eventName, $this, array('event.task.action' => TaskInterface::ACTION_COMPLETED, 'output.resetLine' => true)));
} else {
throw new TaskRuntimeException('Failed updating the permissions for the configured paths.', $this);
}
} | [
"public",
"function",
"onInstallReleaseUpdateFilePermissions",
"(",
"InstallReleaseEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"host",
"=",
"$",
"event",
"->",
"getRelease",
"(",
")",
"->",
"... | Sets the correct permissions and group for the configured path.
@param InstallReleaseEvent $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher
@throws TaskRuntimeException | [
"Sets",
"the",
"correct",
"permissions",
"and",
"group",
"for",
"the",
"configured",
"path",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/FilePermissionTask.php#L59-L78 |
accompli/accompli | src/Task/FilePermissionTask.php | FilePermissionTask.updateFilePermissions | private function updateFilePermissions(ConnectionAdapterInterface $connection, $releasePath, $path, $pathSettings)
{
$path = $releasePath.'/'.$path;
if (isset($pathSettings['permissions']) === false) {
return false;
}
$permissions = FilePermissionCalculator::fromStringRepresentation(str_pad($pathSettings['permissions'], 10, '-'))->getMode();
$recursive = false;
if (isset($pathSettings['recursive'])) {
$recursive = $pathSettings['recursive'];
}
return $connection->changePermissions($path, $permissions, $recursive);
} | php | private function updateFilePermissions(ConnectionAdapterInterface $connection, $releasePath, $path, $pathSettings)
{
$path = $releasePath.'/'.$path;
if (isset($pathSettings['permissions']) === false) {
return false;
}
$permissions = FilePermissionCalculator::fromStringRepresentation(str_pad($pathSettings['permissions'], 10, '-'))->getMode();
$recursive = false;
if (isset($pathSettings['recursive'])) {
$recursive = $pathSettings['recursive'];
}
return $connection->changePermissions($path, $permissions, $recursive);
} | [
"private",
"function",
"updateFilePermissions",
"(",
"ConnectionAdapterInterface",
"$",
"connection",
",",
"$",
"releasePath",
",",
"$",
"path",
",",
"$",
"pathSettings",
")",
"{",
"$",
"path",
"=",
"$",
"releasePath",
".",
"'/'",
".",
"$",
"path",
";",
"if"... | Update the file permissions per configured path.
@param ConnectionAdapterInterface $connection
@param string $releasePath
@param string $path
@param string $pathSettings
@return bool | [
"Update",
"the",
"file",
"permissions",
"per",
"configured",
"path",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/FilePermissionTask.php#L90-L106 |
makinacorpus/drupal-ucms | ucms_widget/src/DependencyInjection/WidgetRegistry.php | WidgetRegistry.registerAll | public function registerAll($map)
{
foreach ($map as $type => $id) {
if (isset($this->services[$type])) {
if ($this->debug) {
trigger_error(sprintf("Widget type '%s' redefinition, ignoring", $type), E_USER_ERROR);
}
}
$this->services[$type] = $id;
}
} | php | public function registerAll($map)
{
foreach ($map as $type => $id) {
if (isset($this->services[$type])) {
if ($this->debug) {
trigger_error(sprintf("Widget type '%s' redefinition, ignoring", $type), E_USER_ERROR);
}
}
$this->services[$type] = $id;
}
} | [
"public",
"function",
"registerAll",
"(",
"$",
"map",
")",
"{",
"foreach",
"(",
"$",
"map",
"as",
"$",
"type",
"=>",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"services",
"[",
"$",
"type",
"]",
")",
")",
"{",
"if",
"(",
... | Register a single instance
@param string[] $map
Keys are widget identifiers, values are service identifiers | [
"Register",
"a",
"single",
"instance"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_widget/src/DependencyInjection/WidgetRegistry.php#L42-L52 |
makinacorpus/drupal-ucms | ucms_widget/src/DependencyInjection/WidgetRegistry.php | WidgetRegistry.get | public function get($type)
{
if (!isset($this->instances[$type])) {
if (!isset($this->services[$type])) {
if ($this->debug) {
trigger_error(sprintf("Widget type '%s' does not exist, returning a null implementation", $type), E_USER_ERROR);
}
// This primarily meant to display stuff, we should never WSOD
// in the user's face, return a null object instead that will
// UI operations smooth and error tolerant.
return new NullWidget();
}
$this->instances[$type] = $this->container->get($this->services[$type]);
}
return $this->instances[$type];
} | php | public function get($type)
{
if (!isset($this->instances[$type])) {
if (!isset($this->services[$type])) {
if ($this->debug) {
trigger_error(sprintf("Widget type '%s' does not exist, returning a null implementation", $type), E_USER_ERROR);
}
// This primarily meant to display stuff, we should never WSOD
// in the user's face, return a null object instead that will
// UI operations smooth and error tolerant.
return new NullWidget();
}
$this->instances[$type] = $this->container->get($this->services[$type]);
}
return $this->instances[$type];
} | [
"public",
"function",
"get",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"instances",
"[",
"$",
"type",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"services",
"[",
"$",
"type",
"]",
"... | Get instance
@param string $type
@return WidgetInterface | [
"Get",
"instance"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_widget/src/DependencyInjection/WidgetRegistry.php#L73-L91 |
arastta/form | Base.php | Base.getAttributes | public function getAttributes($ignore = "")
{
$str = "";
if (!empty($this->attributes)) {
if (!is_array($ignore)) {
$ignore = array($ignore);
}
$attributes = array_diff(array_keys($this->attributes), $ignore);
foreach ($attributes as $attribute) {
$str .= ' ' . $attribute;
if ($this->attributes[$attribute] !== "") {
$str .= '="' . $this->filter($this->attributes[$attribute]) . '"';
}
}
}
return $str;
} | php | public function getAttributes($ignore = "")
{
$str = "";
if (!empty($this->attributes)) {
if (!is_array($ignore)) {
$ignore = array($ignore);
}
$attributes = array_diff(array_keys($this->attributes), $ignore);
foreach ($attributes as $attribute) {
$str .= ' ' . $attribute;
if ($this->attributes[$attribute] !== "") {
$str .= '="' . $this->filter($this->attributes[$attribute]) . '"';
}
}
}
return $str;
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"ignore",
"=",
"\"\"",
")",
"{",
"$",
"str",
"=",
"\"\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ignore",
")",
")"... | /*This method is used by the Form class and all Element classes to return a string of html
attributes. There is an ignore parameter that allows special attributes from being included. | [
"/",
"*",
"This",
"method",
"is",
"used",
"by",
"the",
"Form",
"class",
"and",
"all",
"Element",
"classes",
"to",
"return",
"a",
"string",
"of",
"html",
"attributes",
".",
"There",
"is",
"an",
"ignore",
"parameter",
"that",
"allows",
"special",
"attributes... | train | https://github.com/arastta/form/blob/ece7b53973f14399d86243600b821b6180a886a2/Base.php#L93-L114 |
makinacorpus/drupal-ucms | ucms_list/src/AbstractContentList.php | AbstractContentList.getViewModeList | private function getViewModeList()
{
$ret = [];
$entityInfo = entity_get_info('node');
foreach ($entityInfo['view modes'] as $viewMode => $info) {
$ret[$viewMode] = $info['label'];
}
return $ret;
} | php | private function getViewModeList()
{
$ret = [];
$entityInfo = entity_get_info('node');
foreach ($entityInfo['view modes'] as $viewMode => $info) {
$ret[$viewMode] = $info['label'];
}
return $ret;
} | [
"private",
"function",
"getViewModeList",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"entityInfo",
"=",
"entity_get_info",
"(",
"'node'",
")",
";",
"foreach",
"(",
"$",
"entityInfo",
"[",
"'view modes'",
"]",
"as",
"$",
"viewMode",
"=>",
"$",
... | Get view mode list
@return string[] | [
"Get",
"view",
"mode",
"list"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_list/src/AbstractContentList.php#L105-L115 |
makinacorpus/drupal-ucms | ucms_list/src/AbstractContentList.php | AbstractContentList.getFormatterOptionsForm | public function getFormatterOptionsForm($options = [])
{
$form = [];
$form['view_mode'] = [
'#type' => 'options',
'#options' => $this->getViewModeList(),
'#title' => $this->t("View mode"),
'#default_value' => $options['view_mode'],
'#required' => true,
];
$form['limit'] = [
'#type' => 'select',
'#title' => $this->t("Number of items to display"),
'#options' => drupal_map_assoc(range(1, 50)),
'#default_value' => $options['limit'],
'#required' => true,
];
$form['pager'] = [
'#type' => 'checkbox',
'#title' => $this->t("Use pager"),
'#default_value' => $options['pager'],
'#required' => true,
];
$form['order'] = [
'#type' => 'select',
'#options' => ['asc' => $this->t("Ascending"), 'desc' => $this->t("Descending")],
'#title' => $this->t("Order"),
'#default_value' => $options['order'],
'#required' => true,
];
$form['order_field'] = [
'#type' => 'textfield',
'#title' => $this->t("Order field"),
'#default_value' => $options['order_field'],
'#required' => true,
];
return $form;
} | php | public function getFormatterOptionsForm($options = [])
{
$form = [];
$form['view_mode'] = [
'#type' => 'options',
'#options' => $this->getViewModeList(),
'#title' => $this->t("View mode"),
'#default_value' => $options['view_mode'],
'#required' => true,
];
$form['limit'] = [
'#type' => 'select',
'#title' => $this->t("Number of items to display"),
'#options' => drupal_map_assoc(range(1, 50)),
'#default_value' => $options['limit'],
'#required' => true,
];
$form['pager'] = [
'#type' => 'checkbox',
'#title' => $this->t("Use pager"),
'#default_value' => $options['pager'],
'#required' => true,
];
$form['order'] = [
'#type' => 'select',
'#options' => ['asc' => $this->t("Ascending"), 'desc' => $this->t("Descending")],
'#title' => $this->t("Order"),
'#default_value' => $options['order'],
'#required' => true,
];
$form['order_field'] = [
'#type' => 'textfield',
'#title' => $this->t("Order field"),
'#default_value' => $options['order_field'],
'#required' => true,
];
return $form;
} | [
"public",
"function",
"getFormatterOptionsForm",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"form",
"=",
"[",
"]",
";",
"$",
"form",
"[",
"'view_mode'",
"]",
"=",
"[",
"'#type'",
"=>",
"'options'",
",",
"'#options'",
"=>",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_list/src/AbstractContentList.php#L120-L161 |
okwinza/CloudFlare-API | okw/CF/CF.php | CF.buildRequestParams | private function buildRequestParams($method, $parameters = array()) {
switch ($this->mode) {
case 'client':
$parameters['email'] = $this->email;
$parameters['tkn'] = $this->token;
$parameters['a'] = $method;
break;
case 'host':
$parameters['host_key'] = $this->host_key;
$parameters['act'] = $method;
break;
}
return $parameters;
} | php | private function buildRequestParams($method, $parameters = array()) {
switch ($this->mode) {
case 'client':
$parameters['email'] = $this->email;
$parameters['tkn'] = $this->token;
$parameters['a'] = $method;
break;
case 'host':
$parameters['host_key'] = $this->host_key;
$parameters['act'] = $method;
break;
}
return $parameters;
} | [
"private",
"function",
"buildRequestParams",
"(",
"$",
"method",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"mode",
")",
"{",
"case",
"'client'",
":",
"$",
"parameters",
"[",
"'email'",
"]",
"=",
"$",
... | Building parameters array
@param string $method
@param array $parameters
@return array | [
"Building",
"parameters",
"array",
"@param",
"string",
"$method",
"@param",
"array",
"$parameters"
] | train | https://github.com/okwinza/CloudFlare-API/blob/c3b3ace495c3ab7fd335ec56607aa6fa72868d4a/okw/CF/CF.php#L116-L132 |
okwinza/CloudFlare-API | okw/CF/CF.php | CF.executeRequest | private function executeRequest($parameters = array()) {
$curl_options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_CONNECTTIMEOUT => $this->curlTimeout,
CURLOPT_TIMEOUT => $this->curlConnectTimeout,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $parameters,
CURLOPT_URL => $this->apiUrl[$this->mode]
);
$ch = curl_init();
curl_setopt_array($ch, $curl_options);
$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($curl_error = curl_error($ch)) {
throw new CFException($curl_error, CFException::CURL_ERROR);
}
$json_decode = json_decode($result, true);
curl_close($ch);
// Handling API errors
if ((is_array($json_decode) && !empty($json_decode['err_code'])) || $json_decode['result'] == 'error') {
throw new BadResponseException($json_decode['msg']);
}
if ($http_code !== 200) {
throw new \HttpResponseException('HTTP Non-200 response', $http_code);
}
if (json_last_error() !== \JSON_ERROR_NONE) {
throw new DecodeException('JSON decoding error', json_last_error());
}
return $json_decode;
} | php | private function executeRequest($parameters = array()) {
$curl_options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_CONNECTTIMEOUT => $this->curlTimeout,
CURLOPT_TIMEOUT => $this->curlConnectTimeout,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $parameters,
CURLOPT_URL => $this->apiUrl[$this->mode]
);
$ch = curl_init();
curl_setopt_array($ch, $curl_options);
$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($curl_error = curl_error($ch)) {
throw new CFException($curl_error, CFException::CURL_ERROR);
}
$json_decode = json_decode($result, true);
curl_close($ch);
// Handling API errors
if ((is_array($json_decode) && !empty($json_decode['err_code'])) || $json_decode['result'] == 'error') {
throw new BadResponseException($json_decode['msg']);
}
if ($http_code !== 200) {
throw new \HttpResponseException('HTTP Non-200 response', $http_code);
}
if (json_last_error() !== \JSON_ERROR_NONE) {
throw new DecodeException('JSON decoding error', json_last_error());
}
return $json_decode;
} | [
"private",
"function",
"executeRequest",
"(",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"curl_options",
"=",
"array",
"(",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"CURLOPT_SSL_VERIFYPEER",
"=>",
"false",
",",
"CURLOPT_SSL_VERIFYHOST",
"=>",
... | @param array $parameters
@return mixed
@throws CFException
@throws \HttpException
@throws DecodeException
@throws BadResponseException
@return array | [
"@param",
"array",
"$parameters",
"@return",
"mixed"
] | train | https://github.com/okwinza/CloudFlare-API/blob/c3b3ace495c3ab7fd335ec56607aa6fa72868d4a/okw/CF/CF.php#L145-L184 |
lukevear/jwt-auth-guard | src/AuthGuard.php | AuthGuard.user | public function user()
{
/*
* If we have already retrieved the user for the current request we can
* just return it back immediately.
*/
if (! is_null($this->user)) {
return $this->user;
}
// Attempt to retrieve the token from the request
$token = $this->jwt->getToken();
if (! $token) {
return null;
}
// Get the user associated with the token
try {
$user = $this->jwt->toUser($token);
} catch (JWTException $e) {
return null;
}
return $this->user = $user;
} | php | public function user()
{
/*
* If we have already retrieved the user for the current request we can
* just return it back immediately.
*/
if (! is_null($this->user)) {
return $this->user;
}
// Attempt to retrieve the token from the request
$token = $this->jwt->getToken();
if (! $token) {
return null;
}
// Get the user associated with the token
try {
$user = $this->jwt->toUser($token);
} catch (JWTException $e) {
return null;
}
return $this->user = $user;
} | [
"public",
"function",
"user",
"(",
")",
"{",
"/*\n * If we have already retrieved the user for the current request we can\n * just return it back immediately.\n */",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"user",
")",
")",
"{",
"return",
"$... | Get the currently authenticated user.
@return \Illuminate\Contracts\Auth\Authenticatable|null | [
"Get",
"the",
"currently",
"authenticated",
"user",
"."
] | train | https://github.com/lukevear/jwt-auth-guard/blob/0e3966115cceeabd5672181c9dc8e8a0554dce96/src/AuthGuard.php#L54-L78 |
someline/starter-framework | src/Someline/Repository/Generators/RepositoryEloquentGenerator.php | RepositoryEloquentGenerator.getReplacements | public function getReplacements()
{
$repository = parent::getRootNamespace() . parent::getConfigGeneratorClassPath('interfaces') . '\\' . $this->name . 'Repository;';
$repository = str_replace([
"\\",
'/'
], '\\', $repository);
return array_merge(parent::getReplacements(), [
'fillable' => $this->getFillable(),
'use_validator' => $this->getValidatorUse(),
'validator' => $this->getValidatorMethod(),
'use_presenter' => $this->getPresenterUse(),
'root_namespace' => parent::getRootNamespace(),
'presenter' => $this->getPresenterMethod(),
'repository' => $repository,
'model' => isset($this->options['model']) ? $this->options['model'] : ''
]);
} | php | public function getReplacements()
{
$repository = parent::getRootNamespace() . parent::getConfigGeneratorClassPath('interfaces') . '\\' . $this->name . 'Repository;';
$repository = str_replace([
"\\",
'/'
], '\\', $repository);
return array_merge(parent::getReplacements(), [
'fillable' => $this->getFillable(),
'use_validator' => $this->getValidatorUse(),
'validator' => $this->getValidatorMethod(),
'use_presenter' => $this->getPresenterUse(),
'root_namespace' => parent::getRootNamespace(),
'presenter' => $this->getPresenterMethod(),
'repository' => $repository,
'model' => isset($this->options['model']) ? $this->options['model'] : ''
]);
} | [
"public",
"function",
"getReplacements",
"(",
")",
"{",
"$",
"repository",
"=",
"parent",
"::",
"getRootNamespace",
"(",
")",
".",
"parent",
"::",
"getConfigGeneratorClassPath",
"(",
"'interfaces'",
")",
".",
"'\\\\'",
".",
"$",
"this",
"->",
"name",
".",
"'... | Get array replacements.
@return array | [
"Get",
"array",
"replacements",
"."
] | train | https://github.com/someline/starter-framework/blob/38d3e97ca75dadb05bdc9020f73c78653dbecf15/src/Someline/Repository/Generators/RepositoryEloquentGenerator.php#L65-L83 |
makinacorpus/drupal-ucms | ucms_search/src/Datasource/ElasticNodeDataSource.php | ElasticNodeDataSource.getFilters | public function getFilters()
{
$ret = [];
// Apply rendering stuff for it to work
foreach ($this->getSearch()->getAggregations() as $facet) {
$ret[] = (new Filter($facet->getField(), $facet->getTitle(), true))->setChoicesMap($facet->getFormattedChoices());
}
return $ret;
} | php | public function getFilters()
{
$ret = [];
// Apply rendering stuff for it to work
foreach ($this->getSearch()->getAggregations() as $facet) {
$ret[] = (new Filter($facet->getField(), $facet->getTitle(), true))->setChoicesMap($facet->getFormattedChoices());
}
return $ret;
} | [
"public",
"function",
"getFilters",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"// Apply rendering stuff for it to work",
"foreach",
"(",
"$",
"this",
"->",
"getSearch",
"(",
")",
"->",
"getAggregations",
"(",
")",
"as",
"$",
"facet",
")",
"{",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Datasource/ElasticNodeDataSource.php#L146-L156 |
makinacorpus/drupal-ucms | ucms_search/src/Datasource/ElasticNodeDataSource.php | ElasticNodeDataSource.init | private function init(Query $query)
{
$filters = $query->all();
if ($filters) {
$filterQuery = $this->search->getFilterQuery();
foreach ($filters as $name => $value) {
if (is_array($value)) {
$filterQuery->matchTermCollection($name, $value);
} else {
$filterQuery->matchTerm($name, $value);
}
}
}
$this->createTermFacets();
} | php | private function init(Query $query)
{
$filters = $query->all();
if ($filters) {
$filterQuery = $this->search->getFilterQuery();
foreach ($filters as $name => $value) {
if (is_array($value)) {
$filterQuery->matchTermCollection($name, $value);
} else {
$filterQuery->matchTerm($name, $value);
}
}
}
$this->createTermFacets();
} | [
"private",
"function",
"init",
"(",
"Query",
"$",
"query",
")",
"{",
"$",
"filters",
"=",
"$",
"query",
"->",
"all",
"(",
")",
";",
"if",
"(",
"$",
"filters",
")",
"{",
"$",
"filterQuery",
"=",
"$",
"this",
"->",
"search",
"->",
"getFilterQuery",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Datasource/ElasticNodeDataSource.php#L184-L201 |
makinacorpus/drupal-ucms | ucms_search/src/Datasource/ElasticNodeDataSource.php | ElasticNodeDataSource.preloadDependencies | private function preloadDependencies(array $nodeList)
{
$userIdList = [];
$siteIdList = [];
foreach ($nodeList as $node) {
$userIdList[$node->uid] = $node->uid;
foreach ($node->ucms_sites as $siteId) {
$siteIdList[$siteId] = $siteId;
}
}
if ($userIdList) {
$this->entityManager->getStorage('user')->loadMultiple($userIdList);
}
if ($siteIdList) {
$this->manager->getStorage()->loadAll($siteIdList);
}
} | php | private function preloadDependencies(array $nodeList)
{
$userIdList = [];
$siteIdList = [];
foreach ($nodeList as $node) {
$userIdList[$node->uid] = $node->uid;
foreach ($node->ucms_sites as $siteId) {
$siteIdList[$siteId] = $siteId;
}
}
if ($userIdList) {
$this->entityManager->getStorage('user')->loadMultiple($userIdList);
}
if ($siteIdList) {
$this->manager->getStorage()->loadAll($siteIdList);
}
} | [
"private",
"function",
"preloadDependencies",
"(",
"array",
"$",
"nodeList",
")",
"{",
"$",
"userIdList",
"=",
"[",
"]",
";",
"$",
"siteIdList",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodeList",
"as",
"$",
"node",
")",
"{",
"$",
"userIdList",
"[",
... | Preload pretty much everything to make admin listing faster
@param NodeInterface[] | [
"Preload",
"pretty",
"much",
"everything",
"to",
"make",
"admin",
"listing",
"faster"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Datasource/ElasticNodeDataSource.php#L208-L226 |
makinacorpus/drupal-ucms | ucms_search/src/Datasource/ElasticNodeDataSource.php | ElasticNodeDataSource.getItems | public function getItems(Query $query)
{
if ($query->hasSortField()) {
$this->search->addSort($query->getSortField(), $query->getSortOrder());
}
$inputDefinition = $query->getInputDefinition();
$response = $this
->search
->setPageParameter($inputDefinition->getPagerParameter())
->setFulltextParameterName($inputDefinition->getSearchParameter())
->addField('_id')
->setLimit($query->getLimit())
->doSearch($query->getRouteParameters()) // FIXME this should be the sanitized filters + a few others (sort, etc...)
;
$nodeList = $this->entityManager->getStorage('node')->loadMultiple($response->getAllNodeIdentifiers());
$this->preloadDependencies($nodeList);
return $this->createResult($nodeList, $response->getTotal());
} | php | public function getItems(Query $query)
{
if ($query->hasSortField()) {
$this->search->addSort($query->getSortField(), $query->getSortOrder());
}
$inputDefinition = $query->getInputDefinition();
$response = $this
->search
->setPageParameter($inputDefinition->getPagerParameter())
->setFulltextParameterName($inputDefinition->getSearchParameter())
->addField('_id')
->setLimit($query->getLimit())
->doSearch($query->getRouteParameters()) // FIXME this should be the sanitized filters + a few others (sort, etc...)
;
$nodeList = $this->entityManager->getStorage('node')->loadMultiple($response->getAllNodeIdentifiers());
$this->preloadDependencies($nodeList);
return $this->createResult($nodeList, $response->getTotal());
} | [
"public",
"function",
"getItems",
"(",
"Query",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
"->",
"hasSortField",
"(",
")",
")",
"{",
"$",
"this",
"->",
"search",
"->",
"addSort",
"(",
"$",
"query",
"->",
"getSortField",
"(",
")",
",",
"$",
"q... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_search/src/Datasource/ElasticNodeDataSource.php#L231-L252 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.initSql | private function initSql()
{
$this->sql['start'] = null;
$this->sql['join'] = '';
$this->sql['where'] = '';
$this->sql['orderby'] = null;
$this->sql['limit'] = null;
$this->sql['offset'] = null;
} | php | private function initSql()
{
$this->sql['start'] = null;
$this->sql['join'] = '';
$this->sql['where'] = '';
$this->sql['orderby'] = null;
$this->sql['limit'] = null;
$this->sql['offset'] = null;
} | [
"private",
"function",
"initSql",
"(",
")",
"{",
"$",
"this",
"->",
"sql",
"[",
"'start'",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"sql",
"[",
"'join'",
"]",
"=",
"''",
";",
"$",
"this",
"->",
"sql",
"[",
"'where'",
"]",
"=",
"''",
";",
"$",
... | Initialiser la requête SQL | [
"Initialiser",
"la",
"requête",
"SQL"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L166-L174 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.getConnection | public function getConnection()
{
// Autre BDD que celle par defaut. soit avec un autre connector de la config, ou avec autre ID de connexion de la config
if ($this->dbConnector !== null || count($this->idConnection) > 0) {
$dbConnector = ($this->dbConnector !== null) ? $this->dbConnector : Config::get()['connection'];
$connector = 'DawPhpOrm\Database\Connectors\\'.ucfirst($dbConnector).'Connector';
$db = new $connector($this->idConnection);
return $db->getConnection();
}
// BDD par defaut avec connector de config et avec ID de config
if (self::$connection === null) {
$connector = 'DawPhpOrm\Database\Connectors\\'.ucfirst(Config::get()['connection']).'Connector';
$db = new $connector();
self::$connection = $db->getConnection();
}
return self::$connection;
} | php | public function getConnection()
{
// Autre BDD que celle par defaut. soit avec un autre connector de la config, ou avec autre ID de connexion de la config
if ($this->dbConnector !== null || count($this->idConnection) > 0) {
$dbConnector = ($this->dbConnector !== null) ? $this->dbConnector : Config::get()['connection'];
$connector = 'DawPhpOrm\Database\Connectors\\'.ucfirst($dbConnector).'Connector';
$db = new $connector($this->idConnection);
return $db->getConnection();
}
// BDD par defaut avec connector de config et avec ID de config
if (self::$connection === null) {
$connector = 'DawPhpOrm\Database\Connectors\\'.ucfirst(Config::get()['connection']).'Connector';
$db = new $connector();
self::$connection = $db->getConnection();
}
return self::$connection;
} | [
"public",
"function",
"getConnection",
"(",
")",
"{",
"// Autre BDD que celle par defaut. soit avec un autre connector de la config, ou avec autre ID de connexion de la config\r",
"if",
"(",
"$",
"this",
"->",
"dbConnector",
"!==",
"null",
"||",
"count",
"(",
"$",
"this",
"->... | Retourne connexion à une base de données
@return mixed | [
"Retourne",
"connexion",
"à",
"une",
"base",
"de",
"données"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L201-L222 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.setStartInsert | public function setStartInsert(array $data)
{
$columnsAndMarkers = $this->getColumnsAndGetMarkersForInsert($data);
$this->setStart(
"INSERT INTO ".$this->model->getDbTable()." (".$columnsAndMarkers['columns'].")
VALUES (".$columnsAndMarkers['markers'].")"
);
} | php | public function setStartInsert(array $data)
{
$columnsAndMarkers = $this->getColumnsAndGetMarkersForInsert($data);
$this->setStart(
"INSERT INTO ".$this->model->getDbTable()." (".$columnsAndMarkers['columns'].")
VALUES (".$columnsAndMarkers['markers'].")"
);
} | [
"public",
"function",
"setStartInsert",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"columnsAndMarkers",
"=",
"$",
"this",
"->",
"getColumnsAndGetMarkersForInsert",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setStart",
"(",
"\"INSERT INTO \"",
".",
"$",
"... | Initialiser une request SQL INSERT INTO
@param array $data - Colonnes où faire le INSERT, et valeurs à insérer | [
"Initialiser",
"une",
"request",
"SQL",
"INSERT",
"INTO"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L269-L277 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.setStartUpdate | public function setStartUpdate(array $data)
{
$this->setStart("UPDATE ".$this->model->getDbTable()." SET ".$this->getColumnsForUpdate($data));
} | php | public function setStartUpdate(array $data)
{
$this->setStart("UPDATE ".$this->model->getDbTable()." SET ".$this->getColumnsForUpdate($data));
} | [
"public",
"function",
"setStartUpdate",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"setStart",
"(",
"\"UPDATE \"",
".",
"$",
"this",
"->",
"model",
"->",
"getDbTable",
"(",
")",
".",
"\" SET \"",
".",
"$",
"this",
"->",
"getColumnsForUpdate",
... | Initialiser une request SQL UPDATE
@param array $data - Colonnes où faire le UPDATE, et valeurs à insérer | [
"Initialiser",
"une",
"request",
"SQL",
"UPDATE"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L284-L287 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.addWhere | public function addWhere(array $where)
{
if (count($where) !== 3) {
throw new OrmException('Method "where" must have 3 parameters.');
}
$this->wheres[] = $where;
$this->sql['where'] .= " ".$this->logicOperator." ".$this->addConditionsToSql()." ";
$this->logicOperator = " AND ";
} | php | public function addWhere(array $where)
{
if (count($where) !== 3) {
throw new OrmException('Method "where" must have 3 parameters.');
}
$this->wheres[] = $where;
$this->sql['where'] .= " ".$this->logicOperator." ".$this->addConditionsToSql()." ";
$this->logicOperator = " AND ";
} | [
"public",
"function",
"addWhere",
"(",
"array",
"$",
"where",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"where",
")",
"!==",
"3",
")",
"{",
"throw",
"new",
"OrmException",
"(",
"'Method \"where\" must have 3 parameters.'",
")",
";",
"}",
"$",
"this",
"->",
... | Pour éventuellement ajouter condition(s) avec WHERE (avec AND si plusieurs conditions)
@param array $where
@throws OrmException | [
"Pour",
"éventuellement",
"ajouter",
"condition",
"(",
"s",
")",
"avec",
"WHERE",
"(",
"avec",
"AND",
"si",
"plusieurs",
"conditions",
")"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L331-L342 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.addWhereIn | public function addWhereIn(string $column, array $values)
{
foreach ($values as $value) { // pour bindValue(s)
$this->wheresIn[][2] = $value;
}
$this->sql['where'] .= " ".$this->logicOperator." ".$column." IN ".$this->addConditionsToSqlWhithWhereIn()." ";
$this->logicOperator = " AND ";
} | php | public function addWhereIn(string $column, array $values)
{
foreach ($values as $value) { // pour bindValue(s)
$this->wheresIn[][2] = $value;
}
$this->sql['where'] .= " ".$this->logicOperator." ".$column." IN ".$this->addConditionsToSqlWhithWhereIn()." ";
$this->logicOperator = " AND ";
} | [
"public",
"function",
"addWhereIn",
"(",
"string",
"$",
"column",
",",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"// pour bindValue(s)\r",
"$",
"this",
"->",
"wheresIn",
"[",
"]",
"[",
"2",
"]",
"=",... | Pour ajouter condition(s) avec WHERE IN (et avec AND si plusieurs conditions)
@param string $column
@param array $values | [
"Pour",
"ajouter",
"condition",
"(",
"s",
")",
"avec",
"WHERE",
"IN",
"(",
"et",
"avec",
"AND",
"si",
"plusieurs",
"conditions",
")"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L363-L372 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.addOrWhereIn | public function addOrWhereIn(string $column, array $values)
{
$this->logicOperator = " OR ";
$this->addWhereIn($column, $values);
} | php | public function addOrWhereIn(string $column, array $values)
{
$this->logicOperator = " OR ";
$this->addWhereIn($column, $values);
} | [
"public",
"function",
"addOrWhereIn",
"(",
"string",
"$",
"column",
",",
"array",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"logicOperator",
"=",
"\" OR \"",
";",
"$",
"this",
"->",
"addWhereIn",
"(",
"$",
"column",
",",
"$",
"values",
")",
";",
"}"
... | Pour ajouter condition(s) avec WHERE IN (et avec OR si plusieurs conditions)
@param string $column
@param array $values | [
"Pour",
"ajouter",
"condition",
"(",
"s",
")",
"avec",
"WHERE",
"IN",
"(",
"et",
"avec",
"OR",
"si",
"plusieurs",
"conditions",
")"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L380-L385 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.addOrderBy | public function addOrderBy(string $orderBy, string $order)
{
if ($this->sql['orderby'] === null) {
$this->sql['orderby'] = " ORDER BY ".$orderBy." ".$order." ";
} else {
$this->sql['orderby'] .= " , ".$orderBy." ".$order." ";
}
} | php | public function addOrderBy(string $orderBy, string $order)
{
if ($this->sql['orderby'] === null) {
$this->sql['orderby'] = " ORDER BY ".$orderBy." ".$order." ";
} else {
$this->sql['orderby'] .= " , ".$orderBy." ".$order." ";
}
} | [
"public",
"function",
"addOrderBy",
"(",
"string",
"$",
"orderBy",
",",
"string",
"$",
"order",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sql",
"[",
"'orderby'",
"]",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"sql",
"[",
"'orderby'",
"]",
"=",
"\"... | Pour éventuellement ajouter un orderBy avec un order
@param string $orderBy - Afficher par
@param string $order - Ordre d'affichage | [
"Pour",
"éventuellement",
"ajouter",
"un",
"orderBy",
"avec",
"un",
"order"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L393-L400 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.addOnToSql | private function addOnToSql()
{
$paramsOn = '';
foreach ($this->ons as $on) {
$comporaisonOperator = $on[1];
if (!in_array($comporaisonOperator, self::COMPARAISON_OPERATORS)) {
throw new OrmException('Comparaison operator "'.$comporaisonOperator.'" not allowed.');
}
$paramsOn .= $on[0]." ".$comporaisonOperator." ".$on[2]." ";
}
$this->ons = [];
return $paramsOn;
} | php | private function addOnToSql()
{
$paramsOn = '';
foreach ($this->ons as $on) {
$comporaisonOperator = $on[1];
if (!in_array($comporaisonOperator, self::COMPARAISON_OPERATORS)) {
throw new OrmException('Comparaison operator "'.$comporaisonOperator.'" not allowed.');
}
$paramsOn .= $on[0]." ".$comporaisonOperator." ".$on[2]." ";
}
$this->ons = [];
return $paramsOn;
} | [
"private",
"function",
"addOnToSql",
"(",
")",
"{",
"$",
"paramsOn",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"ons",
"as",
"$",
"on",
")",
"{",
"$",
"comporaisonOperator",
"=",
"$",
"on",
"[",
"1",
"]",
";",
"if",
"(",
"!",
"in_array",
... | Pour les requetes SQL avec jointure(s) - Préciser la condition de la jointure
Boucle pour incrémenter les bindValue du ON, et des éventuels AND après le ON
@return string - Condition(s) de la jointure
@throws OrmException | [
"Pour",
"les",
"requetes",
"SQL",
"avec",
"jointure",
"(",
"s",
")",
"-",
"Préciser",
"la",
"condition",
"de",
"la",
"jointure",
"Boucle",
"pour",
"incrémenter",
"les",
"bindValue",
"du",
"ON",
"et",
"des",
"éventuels",
"AND",
"après",
"le",
"ON"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L459-L475 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.addConditionsToSql | private function addConditionsToSql(): string
{
$paramsWhere = '';
if (count($this->wheres) > 0) {
foreach ($this->wheres as $value) {
$comporaisonOperator = $value[1];
if (!in_array($comporaisonOperator, self::COMPARAISON_OPERATORS)) {
throw new OrmException('Comparaison operator "'.$comporaisonOperator.'" not allowed.');
}
$paramsWhere .= $value[0]." ".$comporaisonOperator." ? ";
$this->wheresBindValue[] = $value;
}
$this->wheres = [];
}
return $paramsWhere;
} | php | private function addConditionsToSql(): string
{
$paramsWhere = '';
if (count($this->wheres) > 0) {
foreach ($this->wheres as $value) {
$comporaisonOperator = $value[1];
if (!in_array($comporaisonOperator, self::COMPARAISON_OPERATORS)) {
throw new OrmException('Comparaison operator "'.$comporaisonOperator.'" not allowed.');
}
$paramsWhere .= $value[0]." ".$comporaisonOperator." ? ";
$this->wheresBindValue[] = $value;
}
$this->wheres = [];
}
return $paramsWhere;
} | [
"private",
"function",
"addConditionsToSql",
"(",
")",
":",
"string",
"{",
"$",
"paramsWhere",
"=",
"''",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"wheres",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"wheres",
"as",
"$",
"v... | Boucle pour si il y a condition(s) en WHERE - Incrémenter les champs à modifier + marquers de positionnement
WHERE- $value[0] : marqueur / $value[1] : opérateur arithmétique / $value[2] : valeur / $value[3] opérateur logique
@return string - Soit '', ou soit champ(s) où faire le(s) condition(s) + marquer(s) de positionnement
@throws OrmException | [
"Boucle",
"pour",
"si",
"il",
"y",
"a",
"condition",
"(",
"s",
")",
"en",
"WHERE",
"-",
"Incrémenter",
"les",
"champs",
"à",
"modifier",
"+",
"marquers",
"de",
"positionnement",
"WHERE",
"-",
"$value",
"[",
"0",
"]",
":",
"marqueur",
"/",
"$value",
"["... | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L484-L504 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.addConditionsToSqlWhithWhereIn | private function addConditionsToSqlWhithWhereIn(): string
{
if (count($this->wheresIn) === 0) {
throw new OrmException('Argument 2 passed to "whereIn()" can not be an empty array.');
}
$paramsWhereIn = " ( ";
foreach ($this->wheresIn as $value) {
$paramsWhereIn .= " ?, ";
$this->wheresBindValue[] = $value;
}
$this->wheresIn = [];
return rtrim($paramsWhereIn, ', ')." ) ";
} | php | private function addConditionsToSqlWhithWhereIn(): string
{
if (count($this->wheresIn) === 0) {
throw new OrmException('Argument 2 passed to "whereIn()" can not be an empty array.');
}
$paramsWhereIn = " ( ";
foreach ($this->wheresIn as $value) {
$paramsWhereIn .= " ?, ";
$this->wheresBindValue[] = $value;
}
$this->wheresIn = [];
return rtrim($paramsWhereIn, ', ')." ) ";
} | [
"private",
"function",
"addConditionsToSqlWhithWhereIn",
"(",
")",
":",
"string",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"wheresIn",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"OrmException",
"(",
"'Argument 2 passed to \"whereIn()\" can not be an empty ar... | Boucle pour si il y a condition(s) avec WHERE IN - Incrémenter les marquers de positionnement
@return string - Soit '', ou soit champ(s) où faire le(s) marquer(s) de positionnement | [
"Boucle",
"pour",
"si",
"il",
"y",
"a",
"condition",
"(",
"s",
")",
"avec",
"WHERE",
"IN",
"-",
"Incrémenter",
"les",
"marquers",
"de",
"positionnement"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L511-L528 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.query | public function query(string $sql, array $otpions = [])
{
$isAssociativeArray = function ($array) { // return true si c'est un array associatif
if (!is_array($array) || empty($array)) {
return false;
}
$keys = array_keys($array);
return (array_keys($keys) !== $keys);
};
$this->prepare($sql);
if ($otpions) {
if ($isAssociativeArray($otpions)) {
foreach ($otpions as $key => $value) {
$this->bind($key, $value, $this->bindDataType($value));
}
} else {
$i = 1;
foreach ($otpions as $value) {
$this->bind($i, $value, $this->bindDataType($value));
$i++;
}
}
}
$this->sqlQuery->execute();
return $this->sqlQuery;
} | php | public function query(string $sql, array $otpions = [])
{
$isAssociativeArray = function ($array) { // return true si c'est un array associatif
if (!is_array($array) || empty($array)) {
return false;
}
$keys = array_keys($array);
return (array_keys($keys) !== $keys);
};
$this->prepare($sql);
if ($otpions) {
if ($isAssociativeArray($otpions)) {
foreach ($otpions as $key => $value) {
$this->bind($key, $value, $this->bindDataType($value));
}
} else {
$i = 1;
foreach ($otpions as $value) {
$this->bind($i, $value, $this->bindDataType($value));
$i++;
}
}
}
$this->sqlQuery->execute();
return $this->sqlQuery;
} | [
"public",
"function",
"query",
"(",
"string",
"$",
"sql",
",",
"array",
"$",
"otpions",
"=",
"[",
"]",
")",
"{",
"$",
"isAssociativeArray",
"=",
"function",
"(",
"$",
"array",
")",
"{",
"// return true si c'est un array associatif\r",
"if",
"(",
"!",
"is_arr... | Pour les requetes SQL "complexes"
@param string $sql
@param array $otpions
@return mixed - Requete | [
"Pour",
"les",
"requetes",
"SQL",
"complexes"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L572-L603 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.prepare | public function prepare(string $sql = null)
{
$this->sqlQuery = $this->getConnection()->prepare($this->getSql($sql));
return $this;
} | php | public function prepare(string $sql = null)
{
$this->sqlQuery = $this->getConnection()->prepare($this->getSql($sql));
return $this;
} | [
"public",
"function",
"prepare",
"(",
"string",
"$",
"sql",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"sqlQuery",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"this",
"->",
"getSql",
"(",
"$",
"sql",
")",
")",
";",
... | Préparer la requete SQL
@param string|null $sql
@return $this | [
"Préparer",
"la",
"requete",
"SQL"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L611-L616 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.bind | private function bind($key, $value, $bindDataType)
{
$this->sqlQuery->bindValue($key, $value, $bindDataType);
} | php | private function bind($key, $value, $bindDataType)
{
$this->sqlQuery->bindValue($key, $value, $bindDataType);
} | [
"private",
"function",
"bind",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"bindDataType",
")",
"{",
"$",
"this",
"->",
"sqlQuery",
"->",
"bindValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"bindDataType",
")",
";",
"}"
] | Les bindValue
@param int|string $key
@param mixed $value
@param $bindDataTyp | [
"Les",
"bindValue"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L640-L643 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.bindWhere | public function bindWhere()
{
if (count($this->wheresBindValue) > 0) {
foreach ($this->wheresBindValue as $value) {
$bindDataType = $this->bindDataType($value[2]);
$this->sqlQuery->bindValue($this->positioningMarker, $value[2], $bindDataType);
$this->positioningMarker++;
}
}
return $this;
} | php | public function bindWhere()
{
if (count($this->wheresBindValue) > 0) {
foreach ($this->wheresBindValue as $value) {
$bindDataType = $this->bindDataType($value[2]);
$this->sqlQuery->bindValue($this->positioningMarker, $value[2], $bindDataType);
$this->positioningMarker++;
}
}
return $this;
} | [
"public",
"function",
"bindWhere",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"wheresBindValue",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"wheresBindValue",
"as",
"$",
"value",
")",
"{",
"$",
"bindDataType",
"=",
"$... | Boucle pour incrémenter les bindValue des WHERE
@return $this; | [
"Boucle",
"pour",
"incrémenter",
"les",
"bindValue",
"des",
"WHERE"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L650-L662 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.bindLimit | public function bindLimit()
{
if ($this->limit !== null) {
$this->sqlQuery->bindValue($this->positioningMarker, $this->limit, PDO::PARAM_INT);
$this->positioningMarker++;
$this->sqlQuery->bindValue($this->positioningMarker, $this->offset, PDO::PARAM_INT);
}
return $this;
} | php | public function bindLimit()
{
if ($this->limit !== null) {
$this->sqlQuery->bindValue($this->positioningMarker, $this->limit, PDO::PARAM_INT);
$this->positioningMarker++;
$this->sqlQuery->bindValue($this->positioningMarker, $this->offset, PDO::PARAM_INT);
}
return $this;
} | [
"public",
"function",
"bindLimit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"limit",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"sqlQuery",
"->",
"bindValue",
"(",
"$",
"this",
"->",
"positioningMarker",
",",
"$",
"this",
"->",
"limit",
",",
"PD... | Les bindValue du Limit
@return $this | [
"Les",
"bindValue",
"du",
"Limit"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L669-L678 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.bindDataType | private function bindDataType($value)
{
switch (true) {
case is_string($value):
return PDO::PARAM_STR;
case is_int($value):
return PDO::PARAM_INT;
case is_bool($value):
return PDO::PARAM_BOOL;
case is_null($value):
return PDO::PARAM_NULL;
default:
return false;
}
} | php | private function bindDataType($value)
{
switch (true) {
case is_string($value):
return PDO::PARAM_STR;
case is_int($value):
return PDO::PARAM_INT;
case is_bool($value):
return PDO::PARAM_BOOL;
case is_null($value):
return PDO::PARAM_NULL;
default:
return false;
}
} | [
"private",
"function",
"bindDataType",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_string",
"(",
"$",
"value",
")",
":",
"return",
"PDO",
"::",
"PARAM_STR",
";",
"case",
"is_int",
"(",
"$",
"value",
")",
":",
"return",
"... | Utile pour les bindValue des requetes SQL
@param string|int|bool|null $value
@return bool|int | [
"Utile",
"pour",
"les",
"bindValue",
"des",
"requetes",
"SQL"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L713-L727 |
stephweb/daw-php-orm | src/DawPhpOrm/Database/Query.php | Query.setRowCount | public function setRowCount(bool $runRowCount): ?int
{
if ($runRowCount === true) {
return $this->sqlQuery->rowCount();
}
return null;
} | php | public function setRowCount(bool $runRowCount): ?int
{
if ($runRowCount === true) {
return $this->sqlQuery->rowCount();
}
return null;
} | [
"public",
"function",
"setRowCount",
"(",
"bool",
"$",
"runRowCount",
")",
":",
"?",
"int",
"{",
"if",
"(",
"$",
"runRowCount",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"sqlQuery",
"->",
"rowCount",
"(",
")",
";",
"}",
"return",
"null",
... | Pour si on veut récupérer nombre de lignes affectées
@param bool $runRowCount
@return int|null | [
"Pour",
"si",
"on",
"veut",
"récupérer",
"nombre",
"de",
"lignes",
"affectées"
] | train | https://github.com/stephweb/daw-php-orm/blob/0c37e3baa1420cf9e3feff122016329de3764bcc/src/DawPhpOrm/Database/Query.php#L767-L774 |
accompli/accompli | src/Task/DeployReleaseTask.php | DeployReleaseTask.onPrepareDeployReleaseConstructReleaseInstances | public function onPrepareDeployReleaseConstructReleaseInstances(PrepareDeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$workspace = $event->getWorkspace();
$host = $workspace->getHost();
$connection = $this->ensureConnection($host);
$release = new Release($event->getVersion());
$workspace->addRelease($release);
if ($connection->isDirectory($release->getPath()) === false) {
throw new TaskRuntimeException(sprintf('The release "%s" is not installed within the workspace.', $release->getVersion()), $this);
}
$event->setRelease($release);
$currentRelease = null;
$releasePath = $host->getPath().'/'.$host->getStage();
if ($connection->isLink($releasePath)) {
$releaseRealPath = $connection->readLink($releasePath);
if (strpos($releaseRealPath, $workspace->getReleasesDirectory()) === 0) {
$currentRelease = new Release(substr($releaseRealPath, strlen($workspace->getReleasesDirectory())));
$workspace->addRelease($currentRelease);
$context = array('currentReleaseVersion' => $currentRelease->getVersion());
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Detected release version "{currentReleaseVersion}" currently deployed.', $eventName, $this, $context));
$event->setCurrentRelease($currentRelease);
}
}
} | php | public function onPrepareDeployReleaseConstructReleaseInstances(PrepareDeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$workspace = $event->getWorkspace();
$host = $workspace->getHost();
$connection = $this->ensureConnection($host);
$release = new Release($event->getVersion());
$workspace->addRelease($release);
if ($connection->isDirectory($release->getPath()) === false) {
throw new TaskRuntimeException(sprintf('The release "%s" is not installed within the workspace.', $release->getVersion()), $this);
}
$event->setRelease($release);
$currentRelease = null;
$releasePath = $host->getPath().'/'.$host->getStage();
if ($connection->isLink($releasePath)) {
$releaseRealPath = $connection->readLink($releasePath);
if (strpos($releaseRealPath, $workspace->getReleasesDirectory()) === 0) {
$currentRelease = new Release(substr($releaseRealPath, strlen($workspace->getReleasesDirectory())));
$workspace->addRelease($currentRelease);
$context = array('currentReleaseVersion' => $currentRelease->getVersion());
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Detected release version "{currentReleaseVersion}" currently deployed.', $eventName, $this, $context));
$event->setCurrentRelease($currentRelease);
}
}
} | [
"public",
"function",
"onPrepareDeployReleaseConstructReleaseInstances",
"(",
"PrepareDeployReleaseEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"workspace",
"=",
"$",
"event",
"->",
"getWorkspace",
... | Constructs a new Release instance for the release being deployed and the Release currently deployed (when available) sets the instances on the event.
@param PrepareDeployReleaseEvent $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher
@throws TaskRuntimeException when the version selected for deployment is not installed within the workspace. | [
"Constructs",
"a",
"new",
"Release",
"instance",
"for",
"the",
"release",
"being",
"deployed",
"and",
"the",
"Release",
"currently",
"deployed",
"(",
"when",
"available",
")",
"sets",
"the",
"instances",
"on",
"the",
"event",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/DeployReleaseTask.php#L48-L75 |
accompli/accompli | src/Task/DeployReleaseTask.php | DeployReleaseTask.onDeployOrRollbackReleaseLinkRelease | public function onDeployOrRollbackReleaseLinkRelease(DeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$release = $event->getRelease();
$host = $release->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$releasePath = $host->getPath().'/'.$host->getStage();
$context = array('linkTarget' => $releasePath, 'releaseVersion' => $release->getVersion(), 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
if ($connection->isLink($releasePath) === false || $connection->readLink($releasePath) !== $release->getPath()) {
if ($connection->isLink($releasePath)) {
$connection->delete($releasePath, false);
}
if ($connection->link($release->getPath(), $releasePath)) {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linked "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
} else {
$context['event.task.action'] = TaskInterface::ACTION_FAILED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}" failed.', $eventName, $this, $context));
throw new TaskRuntimeException(sprintf('Linking "%s" to release "%s" failed.', $context['linkTarget'], $context['releaseVersion']), $this);
}
} else {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Link "{linkTarget}" to release "{releaseVersion}" already exists.', $eventName, $this, $context));
}
} | php | public function onDeployOrRollbackReleaseLinkRelease(DeployReleaseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
$release = $event->getRelease();
$host = $release->getWorkspace()->getHost();
$connection = $this->ensureConnection($host);
$releasePath = $host->getPath().'/'.$host->getStage();
$context = array('linkTarget' => $releasePath, 'releaseVersion' => $release->getVersion(), 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
if ($connection->isLink($releasePath) === false || $connection->readLink($releasePath) !== $release->getPath()) {
if ($connection->isLink($releasePath)) {
$connection->delete($releasePath, false);
}
if ($connection->link($release->getPath(), $releasePath)) {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linked "{linkTarget}" to release "{releaseVersion}".', $eventName, $this, $context));
} else {
$context['event.task.action'] = TaskInterface::ACTION_FAILED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Linking "{linkTarget}" to release "{releaseVersion}" failed.', $eventName, $this, $context));
throw new TaskRuntimeException(sprintf('Linking "%s" to release "%s" failed.', $context['linkTarget'], $context['releaseVersion']), $this);
}
} else {
$context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
$context['output.resetLine'] = true;
$eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Link "{linkTarget}" to release "{releaseVersion}" already exists.', $eventName, $this, $context));
}
} | [
"public",
"function",
"onDeployOrRollbackReleaseLinkRelease",
"(",
"DeployReleaseEvent",
"$",
"event",
",",
"$",
"eventName",
",",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"release",
"=",
"$",
"event",
"->",
"getRelease",
"(",
")",
";",
"... | Links the release being deployed.
@param DeployReleaseEvent $event
@param string $eventName
@param EventDispatcherInterface $eventDispatcher | [
"Links",
"the",
"release",
"being",
"deployed",
"."
] | train | https://github.com/accompli/accompli/blob/618f28377448d8caa90d63bfa5865a3ee15e49e7/src/Task/DeployReleaseTask.php#L84-L119 |
makinacorpus/drupal-ucms | ucms_group/src/EventDispatcher/GroupContextSubscriber.php | GroupContextSubscriber.onSiteInit | public function onSiteInit(SiteInitEvent $event)
{
$group = $this->groupManager->getSiteGroup($event->getSite());
if ($group) {
$this->siteManager->setDependentContext('group', $group);
}
} | php | public function onSiteInit(SiteInitEvent $event)
{
$group = $this->groupManager->getSiteGroup($event->getSite());
if ($group) {
$this->siteManager->setDependentContext('group', $group);
}
} | [
"public",
"function",
"onSiteInit",
"(",
"SiteInitEvent",
"$",
"event",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"groupManager",
"->",
"getSiteGroup",
"(",
"$",
"event",
"->",
"getSite",
"(",
")",
")",
";",
"if",
"(",
"$",
"group",
")",
"{",
"... | Set current group context | [
"Set",
"current",
"group",
"context"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/EventDispatcher/GroupContextSubscriber.php#L56-L63 |
NicolasMahe/Laravel-SlackOutput | src/Library/ScheduledCommand.php | ScheduledCommand.output | static public function output(Event $event, $channel)
{
preg_match("/(artisan |'artisan' )(.*)/us", $event->command, $matches);
$eventCommand = $matches[2];
$event->sendOutputTo(base_path() . '/storage/logs/' . $eventCommand . '.txt');
if (is_null($event->output)) {
//if no output, don't send anything
return;
}
$event->then(function () use ($event, $eventCommand, $channel) {
$message = file_get_contents($event->output);
Artisan::call('slack:post', [
'to' => $channel,
'attach' => [
'color' => 'grey',
'title' => $eventCommand,
'text' => $message
]
]);
});
} | php | static public function output(Event $event, $channel)
{
preg_match("/(artisan |'artisan' )(.*)/us", $event->command, $matches);
$eventCommand = $matches[2];
$event->sendOutputTo(base_path() . '/storage/logs/' . $eventCommand . '.txt');
if (is_null($event->output)) {
//if no output, don't send anything
return;
}
$event->then(function () use ($event, $eventCommand, $channel) {
$message = file_get_contents($event->output);
Artisan::call('slack:post', [
'to' => $channel,
'attach' => [
'color' => 'grey',
'title' => $eventCommand,
'text' => $message
]
]);
});
} | [
"static",
"public",
"function",
"output",
"(",
"Event",
"$",
"event",
",",
"$",
"channel",
")",
"{",
"preg_match",
"(",
"\"/(artisan |'artisan' )(.*)/us\"",
",",
"$",
"event",
"->",
"command",
",",
"$",
"matches",
")",
";",
"$",
"eventCommand",
"=",
"$",
"... | Send to slack the results of a scheduled command.
@todo: add success tag to adjust the color
@param Event $event
@param $channel
@return void | [
"Send",
"to",
"slack",
"the",
"results",
"of",
"a",
"scheduled",
"command",
"."
] | train | https://github.com/NicolasMahe/Laravel-SlackOutput/blob/fc3722ba64a0ce4d833555bb1a27513e13959b34/src/Library/ScheduledCommand.php#L21-L44 |
makinacorpus/drupal-ucms | ucms_notification/src/DependencyInjection/Compiler/NotificationCompilerPass.php | NotificationCompilerPass.process | public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('ucms_contrib.type_handler')) {
$taggedServices = $container->findTaggedServiceIds('ucms_contrib.type_handler');
foreach ($taggedServices as $id => $attributes) {
$formatter = $container->getDefinition($id);
$formatter->addMethodCall(
'setTypeHandler',
[new Reference('ucms_contrib.type_handler')]
);
}
}
if ($container->hasDefinition('ucms_site.manager')) {
$taggedServices = $container->findTaggedServiceIds('ucms_site.manager');
foreach ($taggedServices as $id => $attributes) {
$definition = $container->getDefinition($id);
$definition->addMethodCall(
'setSiteManager',
[new Reference('ucms_site.manager')]
);
}
}
} | php | public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('ucms_contrib.type_handler')) {
$taggedServices = $container->findTaggedServiceIds('ucms_contrib.type_handler');
foreach ($taggedServices as $id => $attributes) {
$formatter = $container->getDefinition($id);
$formatter->addMethodCall(
'setTypeHandler',
[new Reference('ucms_contrib.type_handler')]
);
}
}
if ($container->hasDefinition('ucms_site.manager')) {
$taggedServices = $container->findTaggedServiceIds('ucms_site.manager');
foreach ($taggedServices as $id => $attributes) {
$definition = $container->getDefinition($id);
$definition->addMethodCall(
'setSiteManager',
[new Reference('ucms_site.manager')]
);
}
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"$",
"container",
"->",
"hasDefinition",
"(",
"'ucms_contrib.type_handler'",
")",
")",
"{",
"$",
"taggedServices",
"=",
"$",
"container",
"->",
"findTaggedServiceIds",... | You can modify the container here before it is dumped to PHP code.
@param ContainerBuilder $container | [
"You",
"can",
"modify",
"the",
"container",
"here",
"before",
"it",
"is",
"dumped",
"to",
"PHP",
"code",
"."
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_notification/src/DependencyInjection/Compiler/NotificationCompilerPass.php#L16-L43 |
makinacorpus/drupal-ucms | ucms_group/src/Form/SiteGroupAttach.php | SiteGroupAttach.buildForm | public function buildForm(array $form, FormStateInterface $form_state, Site $site = null)
{
if (null === $site) {
return $form;
}
$form['#form_horizontal'] = true;
$form['name'] = [
'#type' => 'textfield',
'#title' => $this->t("Group title..."),
'#description' => $this->t("Please make your choice in the suggestions list."),
'#autocomplete_path' => 'admin/dashboard/site/' . $site->getId() . '/group-attach/ac',
'#required' => true,
];
$form['site'] = [
'#type' => 'value',
'#value' => $site->getId(),
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Attach"),
];
return $form;
} | php | public function buildForm(array $form, FormStateInterface $form_state, Site $site = null)
{
if (null === $site) {
return $form;
}
$form['#form_horizontal'] = true;
$form['name'] = [
'#type' => 'textfield',
'#title' => $this->t("Group title..."),
'#description' => $this->t("Please make your choice in the suggestions list."),
'#autocomplete_path' => 'admin/dashboard/site/' . $site->getId() . '/group-attach/ac',
'#required' => true,
];
$form['site'] = [
'#type' => 'value',
'#value' => $site->getId(),
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Attach"),
];
return $form;
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
",",
"Site",
"$",
"site",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"site",
")",
"{",
"return",
"$",
"form",
";",
"}",
"$",
"form"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Form/SiteGroupAttach.php#L52-L80 |
makinacorpus/drupal-ucms | ucms_group/src/Form/SiteGroupAttach.php | SiteGroupAttach.validateForm | public function validateForm(array &$form, FormStateInterface $form_state)
{
$string = $form_state->getValue('name');
$matches = [];
if (preg_match('/\[(\d+)\]$/', $string, $matches) !== 1 || $matches[1] < 2) {
$form_state->setErrorByName('name', $this->t("The group can't be identified."));
} else {
$group = $this->groupManager->findOne($matches[1]);
if (null === $group) {
$form_state->setErrorByName('name', $this->t("The group doesn't exist."));
} else {
$form_state->setTemporaryValue('group', $group);
}
}
} | php | public function validateForm(array &$form, FormStateInterface $form_state)
{
$string = $form_state->getValue('name');
$matches = [];
if (preg_match('/\[(\d+)\]$/', $string, $matches) !== 1 || $matches[1] < 2) {
$form_state->setErrorByName('name', $this->t("The group can't be identified."));
} else {
$group = $this->groupManager->findOne($matches[1]);
if (null === $group) {
$form_state->setErrorByName('name', $this->t("The group doesn't exist."));
} else {
$form_state->setTemporaryValue('group', $group);
}
}
} | [
"public",
"function",
"validateForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"$",
"string",
"=",
"$",
"form_state",
"->",
"getValue",
"(",
"'name'",
")",
";",
"$",
"matches",
"=",
"[",
"]",
";",
"if",
"(... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Form/SiteGroupAttach.php#L85-L100 |
makinacorpus/drupal-ucms | ucms_group/src/Form/SiteGroupAttach.php | SiteGroupAttach.submitForm | public function submitForm(array &$form, FormStateInterface $form_state)
{
/** @var \MakinaCorpus\Ucms\Site\Group $group */
$group = $form_state->getTemporaryValue('group');
$siteId = $form_state->getValue('site');
$site = $this->siteManager->getStorage()->findOne($siteId);
if ($this->groupManager->addSite($group->getId(), $siteId, true)) {
drupal_set_message($this->t("%name has been added to group %group.", [
'%name' => $site->getAdminTitle(),
'%group' => $group->getTitle(),
]));
} else {
drupal_set_message($this->t("%name is already in this group %group.", [
'%name' => $site->getAdminTitle(),
'%group' => $group->getTitle(),
]));
}
} | php | public function submitForm(array &$form, FormStateInterface $form_state)
{
/** @var \MakinaCorpus\Ucms\Site\Group $group */
$group = $form_state->getTemporaryValue('group');
$siteId = $form_state->getValue('site');
$site = $this->siteManager->getStorage()->findOne($siteId);
if ($this->groupManager->addSite($group->getId(), $siteId, true)) {
drupal_set_message($this->t("%name has been added to group %group.", [
'%name' => $site->getAdminTitle(),
'%group' => $group->getTitle(),
]));
} else {
drupal_set_message($this->t("%name is already in this group %group.", [
'%name' => $site->getAdminTitle(),
'%group' => $group->getTitle(),
]));
}
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"/** @var \\MakinaCorpus\\Ucms\\Site\\Group $group */",
"$",
"group",
"=",
"$",
"form_state",
"->",
"getTemporaryValue",
"(",
"'group'",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Form/SiteGroupAttach.php#L105-L123 |
runcmf/runbb | src/RunBB/Core/Interfaces/DB.php | DB.forTable | public static function forTable($name=null, $connName = \ORM::DEFAULT_CONNECTION)
{
return \ORM::forTable(\ORM::getConfig('tablePrefix', $connName) . $name, $connName);
} | php | public static function forTable($name=null, $connName = \ORM::DEFAULT_CONNECTION)
{
return \ORM::forTable(\ORM::getConfig('tablePrefix', $connName) . $name, $connName);
} | [
"public",
"static",
"function",
"forTable",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"connName",
"=",
"\\",
"ORM",
"::",
"DEFAULT_CONNECTION",
")",
"{",
"return",
"\\",
"ORM",
"::",
"forTable",
"(",
"\\",
"ORM",
"::",
"getConfig",
"(",
"'tablePrefix'",
"... | Replace \ORM::forTable. Also work with multi-connections
@param null $name
@return \ORM | [
"Replace",
"\\",
"ORM",
"::",
"forTable",
".",
"Also",
"work",
"with",
"multi",
"-",
"connections"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Interfaces/DB.php#L32-L35 |
makinacorpus/drupal-ucms | ucms_contrib/src/Form/NodeAddToSite.php | NodeAddToSite.buildForm | public function buildForm(array $form, FormStateInterface $form_state, $type = null)
{
$user = $this->currentUser();
$canDoGlobal = $user->hasPermission(Access::PERM_CONTENT_MANAGE_GLOBAL) || $user->hasPermission(Access::PERM_CONTENT_MANAGE_CORPORATE);
if (!$type) {
$this->logger('form')->critical("No content type provided.");
return $form;
}
$form_state->setTemporaryValue('type', $type);
// Load the sites the user is webmaster or contributor
$roles = $this->siteManager->getAccess()->getUserRoles($user);
$sites = $this->siteManager->getStorage()->loadAll(array_keys($roles));
$options = [];
foreach ($sites as $site) {
// @todo should be done using node_access somehow ?
if (in_array($site->state, [SiteState::INIT, SiteState::OFF, SiteState::ON])) {
$options[$site->id] = check_plain($site->title);
}
}
$form['action'] = [
'#title' => $this->t("Where would you want to create this content ?"),
'#type' => 'radios',
'#options' => [
'global' => $this->t("Create a global content"),
'local' => $this->t("Create a content in one of my sites"),
],
'#default_value' => 'local',
];
// First set the site select if available, we will later add the #states
// property whenever it make sense
if ($options) {
$form['site'] = [
'#type' => count($options) < 11 ? 'radios' : 'select',
'#title' => $this->t("Select a site"),
'#options' => $options,
// If "create a global content" is selected, this widget does
// not serve any purpose, so we don't care about default value
'#default_value' => key($options),
'#required' => true,
];
}
if (empty($options)) {
if (!$canDoGlobal) {
throw new \LogicException("User cannot create content, this form should not be displayed");
}
// User may only create global content, just set a message
$form['help'] = [
'#markup' => $this->t("Do you want to create a global content ?"),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
$form['action'] = ['#type' => 'value', '#value' => 'global'];
} else {
if ($canDoGlobal) {
$form['site']['#states'] = ['visible' => [':input[name="action"]' => ['value' => 'local']]];
} else {
$form['action'] = ['#type' => 'value', '#value' => 'local'];
}
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Continue"),
'#weight' => -20,
];
if (isset($_GET['destination'])) {
$form['actions']['cancel'] = [
'#markup' => l(
$this->t("Cancel"),
$_GET['destination'],
['attributes' => ['class' => ['btn', 'btn-danger']]]
),
];
}
return $form;
} | php | public function buildForm(array $form, FormStateInterface $form_state, $type = null)
{
$user = $this->currentUser();
$canDoGlobal = $user->hasPermission(Access::PERM_CONTENT_MANAGE_GLOBAL) || $user->hasPermission(Access::PERM_CONTENT_MANAGE_CORPORATE);
if (!$type) {
$this->logger('form')->critical("No content type provided.");
return $form;
}
$form_state->setTemporaryValue('type', $type);
// Load the sites the user is webmaster or contributor
$roles = $this->siteManager->getAccess()->getUserRoles($user);
$sites = $this->siteManager->getStorage()->loadAll(array_keys($roles));
$options = [];
foreach ($sites as $site) {
// @todo should be done using node_access somehow ?
if (in_array($site->state, [SiteState::INIT, SiteState::OFF, SiteState::ON])) {
$options[$site->id] = check_plain($site->title);
}
}
$form['action'] = [
'#title' => $this->t("Where would you want to create this content ?"),
'#type' => 'radios',
'#options' => [
'global' => $this->t("Create a global content"),
'local' => $this->t("Create a content in one of my sites"),
],
'#default_value' => 'local',
];
// First set the site select if available, we will later add the #states
// property whenever it make sense
if ($options) {
$form['site'] = [
'#type' => count($options) < 11 ? 'radios' : 'select',
'#title' => $this->t("Select a site"),
'#options' => $options,
// If "create a global content" is selected, this widget does
// not serve any purpose, so we don't care about default value
'#default_value' => key($options),
'#required' => true,
];
}
if (empty($options)) {
if (!$canDoGlobal) {
throw new \LogicException("User cannot create content, this form should not be displayed");
}
// User may only create global content, just set a message
$form['help'] = [
'#markup' => $this->t("Do you want to create a global content ?"),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
$form['action'] = ['#type' => 'value', '#value' => 'global'];
} else {
if ($canDoGlobal) {
$form['site']['#states'] = ['visible' => [':input[name="action"]' => ['value' => 'local']]];
} else {
$form['action'] = ['#type' => 'value', '#value' => 'local'];
}
}
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t("Continue"),
'#weight' => -20,
];
if (isset($_GET['destination'])) {
$form['actions']['cancel'] = [
'#markup' => l(
$this->t("Cancel"),
$_GET['destination'],
['attributes' => ['class' => ['btn', 'btn-danger']]]
),
];
}
return $form;
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"currentUser",
"(",
")",
";",
"$",
"canDoGlobal",
"=",
"$",
"user"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_contrib/src/Form/NodeAddToSite.php#L58-L144 |
runcmf/runbb | src/RunBB/Controller/Extern.php | Extern.outputRss | protected function outputRss($feed)
{
// Send XML/no cache headers
header('Content-Type: application/xml; charset=utf-8');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
echo "\t" . '<channel>' . "\n";
echo "\t\t" . '<atom:link href="' .
Utils::escape(Url::current()) . '" rel="self" type="application/rss+xml" />' . "\n";
echo "\t\t" . '<title><![CDATA[' . $this->escapeCdata($feed['title']) . ']]></title>' . "\n";
echo "\t\t" . '<link>' . Utils::escape($feed['link']) . '</link>' . "\n";
echo "\t\t" . '<description><![CDATA[' .
$this->escapeCdata($feed['description']) . ']]></description>' . "\n";
echo "\t\t" . '<lastBuildDate>' . gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] :
time()) . '</lastBuildDate>' . "\n";
if (ForumSettings::get('o_show_version') == '1') {
echo "\t\t" . '<generator>RunBB ' . ForumSettings::get('o_cur_version') . '</generator>' . "\n";
} else {
echo "\t\t" . '<generator>RunBB</generator>' . "\n";
}
foreach ($feed['items'] as $item) {
echo "\t\t" . '<item>' . "\n";
echo "\t\t\t" . '<title><![CDATA[' . $this->escapeCdata($item['title']) . ']]></title>' . "\n";
echo "\t\t\t" . '<link>' . Utils::escape($item['link']) . '</link>' . "\n";
echo "\t\t\t" . '<description><![CDATA[' .
$this->escapeCdata($item['description']) . ']]></description>' . "\n";
echo "\t\t\t" . '<author><![CDATA[' . (isset($item['author']['email']) ?
$this->escapeCdata($item['author']['email']) : 'dummy@example.com') . ' (' .
$this->escapeCdata($item['author']['name']) . ')]]></author>' . "\n";
echo "\t\t\t" . '<pubDate>' . gmdate('r', $item['pubdate']) . '</pubDate>' . "\n";
echo "\t\t\t" . '<guid>' . Utils::escape($item['link']) . '</guid>' . "\n";
echo "\t\t" . '</item>' . "\n";
}
echo "\t" . '</channel>' . "\n";
echo '</rss>' . "\n";
} | php | protected function outputRss($feed)
{
// Send XML/no cache headers
header('Content-Type: application/xml; charset=utf-8');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">' . "\n";
echo "\t" . '<channel>' . "\n";
echo "\t\t" . '<atom:link href="' .
Utils::escape(Url::current()) . '" rel="self" type="application/rss+xml" />' . "\n";
echo "\t\t" . '<title><![CDATA[' . $this->escapeCdata($feed['title']) . ']]></title>' . "\n";
echo "\t\t" . '<link>' . Utils::escape($feed['link']) . '</link>' . "\n";
echo "\t\t" . '<description><![CDATA[' .
$this->escapeCdata($feed['description']) . ']]></description>' . "\n";
echo "\t\t" . '<lastBuildDate>' . gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] :
time()) . '</lastBuildDate>' . "\n";
if (ForumSettings::get('o_show_version') == '1') {
echo "\t\t" . '<generator>RunBB ' . ForumSettings::get('o_cur_version') . '</generator>' . "\n";
} else {
echo "\t\t" . '<generator>RunBB</generator>' . "\n";
}
foreach ($feed['items'] as $item) {
echo "\t\t" . '<item>' . "\n";
echo "\t\t\t" . '<title><![CDATA[' . $this->escapeCdata($item['title']) . ']]></title>' . "\n";
echo "\t\t\t" . '<link>' . Utils::escape($item['link']) . '</link>' . "\n";
echo "\t\t\t" . '<description><![CDATA[' .
$this->escapeCdata($item['description']) . ']]></description>' . "\n";
echo "\t\t\t" . '<author><![CDATA[' . (isset($item['author']['email']) ?
$this->escapeCdata($item['author']['email']) : 'dummy@example.com') . ' (' .
$this->escapeCdata($item['author']['name']) . ')]]></author>' . "\n";
echo "\t\t\t" . '<pubDate>' . gmdate('r', $item['pubdate']) . '</pubDate>' . "\n";
echo "\t\t\t" . '<guid>' . Utils::escape($item['link']) . '</guid>' . "\n";
echo "\t\t" . '</item>' . "\n";
}
echo "\t" . '</channel>' . "\n";
echo '</rss>' . "\n";
} | [
"protected",
"function",
"outputRss",
"(",
"$",
"feed",
")",
"{",
"// Send XML/no cache headers",
"header",
"(",
"'Content-Type: application/xml; charset=utf-8'",
")",
";",
"header",
"(",
"'Expires: '",
".",
"gmdate",
"(",
"'D, d M Y H:i:s'",
")",
".",
"' GMT'",
")",
... | Output $feed as RSS 2.0
@param $feed array | [
"Output",
"$feed",
"as",
"RSS",
"2",
".",
"0"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Controller/Extern.php#L681-L724 |
runcmf/runbb | src/RunBB/Controller/Extern.php | Extern.outputXml | protected function outputXml($feed)
{
// Send XML/no cache headers
header('Content-Type: application/xml; charset=utf-8');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
echo '<source>' . "\n";
echo "\t" . '<url>' . Utils::escape($feed['link']) . '</url>' . "\n";
$forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic';
foreach ($feed['items'] as $item) {
echo "\t" . '<' . $forum_tag . ' id="' . $item['id'] . '">' . "\n";
echo "\t\t" . '<title><![CDATA[' . $this->escapeCdata($item['title']) . ']]></title>' . "\n";
echo "\t\t" . '<link>' . Utils::escape($item['link']) . '</link>' . "\n";
echo "\t\t" . '<content><![CDATA[' . $this->escapeCdata($item['description']) . ']]></content>' . "\n";
echo "\t\t" . '<author>' . "\n";
echo "\t\t\t" . '<name><![CDATA[' . $this->escapeCdata($item['author']['name']) . ']]></name>' . "\n";
if (isset($item['author']['email'])) {
echo "\t\t\t" . '<email><![CDATA[' . $this->escapeCdata($item['author']['email']) .
']]></email>' . "\n";
}
if (isset($item['author']['uri'])) {
echo "\t\t\t" . '<uri>' . Utils::escape($item['author']['uri']) . '</uri>' . "\n";
}
echo "\t\t" . '</author>' . "\n";
echo "\t\t" . '<posted>' . gmdate('r', $item['pubdate']) . '</posted>' . "\n";
echo "\t" . '</' . $forum_tag . '>' . "\n";
}
echo '</source>' . "\n";
} | php | protected function outputXml($feed)
{
// Send XML/no cache headers
header('Content-Type: application/xml; charset=utf-8');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
echo '<source>' . "\n";
echo "\t" . '<url>' . Utils::escape($feed['link']) . '</url>' . "\n";
$forum_tag = ($feed['type'] == 'posts') ? 'post' : 'topic';
foreach ($feed['items'] as $item) {
echo "\t" . '<' . $forum_tag . ' id="' . $item['id'] . '">' . "\n";
echo "\t\t" . '<title><![CDATA[' . $this->escapeCdata($item['title']) . ']]></title>' . "\n";
echo "\t\t" . '<link>' . Utils::escape($item['link']) . '</link>' . "\n";
echo "\t\t" . '<content><![CDATA[' . $this->escapeCdata($item['description']) . ']]></content>' . "\n";
echo "\t\t" . '<author>' . "\n";
echo "\t\t\t" . '<name><![CDATA[' . $this->escapeCdata($item['author']['name']) . ']]></name>' . "\n";
if (isset($item['author']['email'])) {
echo "\t\t\t" . '<email><![CDATA[' . $this->escapeCdata($item['author']['email']) .
']]></email>' . "\n";
}
if (isset($item['author']['uri'])) {
echo "\t\t\t" . '<uri>' . Utils::escape($item['author']['uri']) . '</uri>' . "\n";
}
echo "\t\t" . '</author>' . "\n";
echo "\t\t" . '<posted>' . gmdate('r', $item['pubdate']) . '</posted>' . "\n";
echo "\t" . '</' . $forum_tag . '>' . "\n";
}
echo '</source>' . "\n";
} | [
"protected",
"function",
"outputXml",
"(",
"$",
"feed",
")",
"{",
"// Send XML/no cache headers",
"header",
"(",
"'Content-Type: application/xml; charset=utf-8'",
")",
";",
"header",
"(",
"'Expires: '",
".",
"gmdate",
"(",
"'D, d M Y H:i:s'",
")",
".",
"' GMT'",
")",
... | Output $feed as XML
@param $feed array | [
"Output",
"$feed",
"as",
"XML"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Controller/Extern.php#L791-L830 |
runcmf/runbb | src/RunBB/Controller/Extern.php | Extern.outputHtml | protected function outputHtml($feed)
{
// Send the Content-type header in case the web server is setup to send something else
header('Content-type: text/html; charset=utf-8');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
foreach ($feed['items'] as $item) {
if (utf8_strlen($item['title']) > FORUM_EXTERN_MAX_SUBJECT_LENGTH) {
$subject_truncated = Utils::escape(Utils::trim(utf8_substr(
$item['title'],
0,
(FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)
))) . ' …';
} else {
$subject_truncated = Utils::escape($item['title']);
}
echo '<li><a href="' . Utils::escape($item['link']) . '" title="' . Utils::escape($item['title']) . '">' .
$subject_truncated . '</a></li>' . "\n";
}
} | php | protected function outputHtml($feed)
{
// Send the Content-type header in case the web server is setup to send something else
header('Content-type: text/html; charset=utf-8');
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
foreach ($feed['items'] as $item) {
if (utf8_strlen($item['title']) > FORUM_EXTERN_MAX_SUBJECT_LENGTH) {
$subject_truncated = Utils::escape(Utils::trim(utf8_substr(
$item['title'],
0,
(FORUM_EXTERN_MAX_SUBJECT_LENGTH - 5)
))) . ' …';
} else {
$subject_truncated = Utils::escape($item['title']);
}
echo '<li><a href="' . Utils::escape($item['link']) . '" title="' . Utils::escape($item['title']) . '">' .
$subject_truncated . '</a></li>' . "\n";
}
} | [
"protected",
"function",
"outputHtml",
"(",
"$",
"feed",
")",
"{",
"// Send the Content-type header in case the web server is setup to send something else",
"header",
"(",
"'Content-type: text/html; charset=utf-8'",
")",
";",
"header",
"(",
"'Expires: '",
".",
"gmdate",
"(",
... | Output $feed as HTML (using <li> tags)
@param $feed array | [
"Output",
"$feed",
"as",
"HTML",
"(",
"using",
"<li",
">",
"tags",
")"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Controller/Extern.php#L836-L858 |
makinacorpus/drupal-ucms | ucms_extranet/src/Form/RegisterForm.php | RegisterForm.buildForm | public function buildForm(array $form, FormStateInterface $formState)
{
if (!$this->siteManager->hasContext()) {
return [];
}
$formState->setTemporaryValue('site', $this->siteManager->getContext());
$form['#form_horizontal'] = true;
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Lastname / Firstname'),
'#maxlength' => USERNAME_MAX_LENGTH,
'#required' => true,
'#weight' => -10,
);
$form['mail'] = array(
'#type' => 'textfield',
'#title' => $this->t('Email'),
'#maxlength' => EMAIL_MAX_LENGTH,
'#required' => true,
'#weight' => -5,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Register'),
);
return $form;
} | php | public function buildForm(array $form, FormStateInterface $formState)
{
if (!$this->siteManager->hasContext()) {
return [];
}
$formState->setTemporaryValue('site', $this->siteManager->getContext());
$form['#form_horizontal'] = true;
$form['name'] = array(
'#type' => 'textfield',
'#title' => $this->t('Lastname / Firstname'),
'#maxlength' => USERNAME_MAX_LENGTH,
'#required' => true,
'#weight' => -10,
);
$form['mail'] = array(
'#type' => 'textfield',
'#title' => $this->t('Email'),
'#maxlength' => EMAIL_MAX_LENGTH,
'#required' => true,
'#weight' => -5,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => $this->t('Register'),
);
return $form;
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"formState",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"siteManager",
"->",
"hasContext",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"formState... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_extranet/src/Form/RegisterForm.php#L84-L117 |
makinacorpus/drupal-ucms | ucms_extranet/src/Form/RegisterForm.php | RegisterForm.validateForm | public function validateForm(array &$form, FormStateInterface $formState)
{
// Validate the name and check if it is already taken by an existing user.
$name = $formState->getValue('name');
$name = trim($name);
$formState->setValue('name', $name);
if (!$name) {
$formState->setErrorByName('name', $this->t('You must enter your name.'));
}
elseif (drupal_strlen($name) > USERNAME_MAX_LENGTH) {
$formState->setErrorByName('name', $this->t('Your name is too long: it must be %max characters at the most.', ['%max' => USERNAME_MAX_LENGTH]));
}
elseif ((bool) db_select('users')
->fields('users', ['uid'])
->condition('name', db_like($name), 'LIKE')
->range(0, 1)
->execute()
->fetchField()
) {
$formState->setErrorByName('name', $this->t('The name %name is already taken.', ['%name' => $name]));
}
// Trim whitespace from mail, to prevent confusing 'e-mail not valid'
// warnings often caused by cutting and pasting.
$mail = $formState->getValue('mail');
$mail = trim($mail);
$formState->setValue('mail', $mail);
// Validate the e-mail address and check if it is already taken by an existing user.
if ($error = user_validate_mail($mail)) {
$formState->setErrorByName('mail', $error);
}
elseif ((bool) db_select('users')
->fields('users', ['uid'])
->condition('mail', db_like($mail), 'LIKE')
->range(0, 1)
->execute()
->fetchField()
) {
$formState->setErrorByName('mail', $this->t('The e-mail address %email is already taken.', ['%email' => $mail]));
}
} | php | public function validateForm(array &$form, FormStateInterface $formState)
{
// Validate the name and check if it is already taken by an existing user.
$name = $formState->getValue('name');
$name = trim($name);
$formState->setValue('name', $name);
if (!$name) {
$formState->setErrorByName('name', $this->t('You must enter your name.'));
}
elseif (drupal_strlen($name) > USERNAME_MAX_LENGTH) {
$formState->setErrorByName('name', $this->t('Your name is too long: it must be %max characters at the most.', ['%max' => USERNAME_MAX_LENGTH]));
}
elseif ((bool) db_select('users')
->fields('users', ['uid'])
->condition('name', db_like($name), 'LIKE')
->range(0, 1)
->execute()
->fetchField()
) {
$formState->setErrorByName('name', $this->t('The name %name is already taken.', ['%name' => $name]));
}
// Trim whitespace from mail, to prevent confusing 'e-mail not valid'
// warnings often caused by cutting and pasting.
$mail = $formState->getValue('mail');
$mail = trim($mail);
$formState->setValue('mail', $mail);
// Validate the e-mail address and check if it is already taken by an existing user.
if ($error = user_validate_mail($mail)) {
$formState->setErrorByName('mail', $error);
}
elseif ((bool) db_select('users')
->fields('users', ['uid'])
->condition('mail', db_like($mail), 'LIKE')
->range(0, 1)
->execute()
->fetchField()
) {
$formState->setErrorByName('mail', $this->t('The e-mail address %email is already taken.', ['%email' => $mail]));
}
} | [
"public",
"function",
"validateForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"formState",
")",
"{",
"// Validate the name and check if it is already taken by an existing user.",
"$",
"name",
"=",
"$",
"formState",
"->",
"getValue",
"(",
"'name'"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_extranet/src/Form/RegisterForm.php#L123-L165 |
makinacorpus/drupal-ucms | ucms_extranet/src/Form/RegisterForm.php | RegisterForm.submitForm | public function submitForm(array &$form, FormStateInterface $formState)
{
/** @var \Drupal\user\UserInterface $user */
$user = $this->entityManager->getStorage('user')->create();
/** @var \MakinaCorpus\Ucms\Site\Site $site */
$site = $formState->getTemporaryValue('site');
$user->setUsername($formState->getValue('name'));
$user->setEmail($formState->getValue('mail'));
$user->status = 0; // Ensures the user is disabled by default
require_once DRUPAL_ROOT . '/includes/password.inc';
$user->pass = user_hash_password(user_password(20));
// Records the user
$this->entityManager->getStorage('user')->save($user);
// Gives it the extranet member role
$this->siteManager->getAccess()->mergeUsersWithRole($site, $user->id(), ExtranetAccess::ROLE_EXTRANET_MEMBER);
// Sends an e-mail notification to the extranet webmasters
$accessRecords = $this->siteManager->getAccess()->listWebmasters($site);
foreach ($accessRecords as $record) {
$webmaster = $this->entityManager->getStorage('user')->load($record->getUserId());
$params = ['user' => $user, 'site' => $site];
drupal_mail('ucms_extranet', 'new-member-registered', $webmaster->getEmail(), $GLOBALS['language'], $params);
}
// Dispatches an event
$event = new ExtranetMemberEvent($user, $site);
$this->dispatcher->dispatch(ExtranetMemberEvent::EVENT_REGISTER, $event);
$formState->setRedirect('user/register/confirm');
} | php | public function submitForm(array &$form, FormStateInterface $formState)
{
/** @var \Drupal\user\UserInterface $user */
$user = $this->entityManager->getStorage('user')->create();
/** @var \MakinaCorpus\Ucms\Site\Site $site */
$site = $formState->getTemporaryValue('site');
$user->setUsername($formState->getValue('name'));
$user->setEmail($formState->getValue('mail'));
$user->status = 0; // Ensures the user is disabled by default
require_once DRUPAL_ROOT . '/includes/password.inc';
$user->pass = user_hash_password(user_password(20));
// Records the user
$this->entityManager->getStorage('user')->save($user);
// Gives it the extranet member role
$this->siteManager->getAccess()->mergeUsersWithRole($site, $user->id(), ExtranetAccess::ROLE_EXTRANET_MEMBER);
// Sends an e-mail notification to the extranet webmasters
$accessRecords = $this->siteManager->getAccess()->listWebmasters($site);
foreach ($accessRecords as $record) {
$webmaster = $this->entityManager->getStorage('user')->load($record->getUserId());
$params = ['user' => $user, 'site' => $site];
drupal_mail('ucms_extranet', 'new-member-registered', $webmaster->getEmail(), $GLOBALS['language'], $params);
}
// Dispatches an event
$event = new ExtranetMemberEvent($user, $site);
$this->dispatcher->dispatch(ExtranetMemberEvent::EVENT_REGISTER, $event);
$formState->setRedirect('user/register/confirm');
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"formState",
")",
"{",
"/** @var \\Drupal\\user\\UserInterface $user */",
"$",
"user",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'user'",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_extranet/src/Form/RegisterForm.php#L171-L203 |
oasmobile/php-aws-wrappers | src/AwsWrappers/StsClient.php | StsClient.getTemporaryCredential | public function getTemporaryCredential($durationInSeconds = 43200)
{
$now = time();
$expireAt = $now + $durationInSeconds;
$cmd = $this->getCommand(
"GetSessionToken",
[
"DurationSeconds" => $durationInSeconds,
]
);
$result = $this->execute($cmd);
$credential = new TemporaryCredential();
$credential->expireAt = $expireAt;
$credential->sessionToken = $result['Credentials']['SessionToken'];
$credential->accessKeyId = $result['Credentials']['AccessKeyId'];
$credential->secretAccessKey = $result['Credentials']['SecretAccessKey'];
$credential->expireDateTime = $result['Credentials']['Expiration'];
return $credential;
} | php | public function getTemporaryCredential($durationInSeconds = 43200)
{
$now = time();
$expireAt = $now + $durationInSeconds;
$cmd = $this->getCommand(
"GetSessionToken",
[
"DurationSeconds" => $durationInSeconds,
]
);
$result = $this->execute($cmd);
$credential = new TemporaryCredential();
$credential->expireAt = $expireAt;
$credential->sessionToken = $result['Credentials']['SessionToken'];
$credential->accessKeyId = $result['Credentials']['AccessKeyId'];
$credential->secretAccessKey = $result['Credentials']['SecretAccessKey'];
$credential->expireDateTime = $result['Credentials']['Expiration'];
return $credential;
} | [
"public",
"function",
"getTemporaryCredential",
"(",
"$",
"durationInSeconds",
"=",
"43200",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"$",
"expireAt",
"=",
"$",
"now",
"+",
"$",
"durationInSeconds",
";",
"$",
"cmd",
"=",
"$",
"this",
"->",
"ge... | @param int $durationInSeconds default to 43200 which is 12 hours
@return TemporaryCredential | [
"@param",
"int",
"$durationInSeconds",
"default",
"to",
"43200",
"which",
"is",
"12",
"hours"
] | train | https://github.com/oasmobile/php-aws-wrappers/blob/0f756dc60ef6f51e9a99f67c9125289e40f19e3f/src/AwsWrappers/StsClient.php#L30-L50 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.isCached | public function isCached($key)
{
if ($cachedData = $this->loadCache()) {
if (isset($cachedData[$key])) {
if (!$this->isExpired($cachedData[$key]['time'], $cachedData[$key]['expire'])) {
return true;
}
}
}
return false; // If cache file doesn't exist or cache is empty or key doesn't exist in array, key isn't cached
} | php | public function isCached($key)
{
if ($cachedData = $this->loadCache()) {
if (isset($cachedData[$key])) {
if (!$this->isExpired($cachedData[$key]['time'], $cachedData[$key]['expire'])) {
return true;
}
}
}
return false; // If cache file doesn't exist or cache is empty or key doesn't exist in array, key isn't cached
} | [
"public",
"function",
"isCached",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"cachedData",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cachedData",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",... | Check whether data is associated with a key
@param string $key
@return boolean | [
"Check",
"whether",
"data",
"is",
"associated",
"with",
"a",
"key"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L68-L78 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.store | public function store($key, $data, $expires = 0)
{
$new_data = [
'time' => time(),
'expire' => (int)$expires,
'data' => serialize($data)
];
if ($this->retrieve($key) !== null) {
$this->delete($key);
}
$cache = $this->loadCache();
if (is_array($cache)) {
$cache[(string)$key] = $new_data;
} else {
$cache = [(string)$key => $new_data];
}
$this->saveCache($cache);
return $this;
} | php | public function store($key, $data, $expires = 0)
{
$new_data = [
'time' => time(),
'expire' => (int)$expires,
'data' => serialize($data)
];
if ($this->retrieve($key) !== null) {
$this->delete($key);
}
$cache = $this->loadCache();
if (is_array($cache)) {
$cache[(string)$key] = $new_data;
} else {
$cache = [(string)$key => $new_data];
}
$this->saveCache($cache);
return $this;
} | [
"public",
"function",
"store",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"expires",
"=",
"0",
")",
"{",
"$",
"new_data",
"=",
"[",
"'time'",
"=>",
"time",
"(",
")",
",",
"'expire'",
"=>",
"(",
"int",
")",
"$",
"expires",
",",
"'data'",
"=>",
... | Store data in the cache
@param string $key
@param mixed $data
@param integer [optional] $expires
@return self | [
"Store",
"data",
"in",
"the",
"cache"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L88-L106 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.retrieve | public function retrieve($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
if (!$this->isExpired($cache[$key]['time'], $cache[$key]['expire'])) {
return unserialize($cache[$key]['data']);
}
}
}
return null;
} | php | public function retrieve($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
if (!$this->isExpired($cache[$key]['time'], $cache[$key]['expire'])) {
return unserialize($cache[$key]['data']);
}
}
}
return null;
} | [
"public",
"function",
"retrieve",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"if",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
"... | Retrieve cached data by key
@param string $key
@param boolean [optional] $timestamp
@return string | [
"Retrieve",
"cached",
"data",
"by",
"key"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L115-L126 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.retrieveAll | public function retrieveAll($raw = false)
{
if ($cache = $this->loadCache()) {
if (!$raw) {
$results = [];
foreach ($cache as $key => $value) {
$results[$key] = unserialize($value['data']);
}
return $results;
} else {
return $cache;
}
}
return null;
} | php | public function retrieveAll($raw = false)
{
if ($cache = $this->loadCache()) {
if (!$raw) {
$results = [];
foreach ($cache as $key => $value) {
$results[$key] = unserialize($value['data']);
}
return $results;
} else {
return $cache;
}
}
return null;
} | [
"public",
"function",
"retrieveAll",
"(",
"$",
"raw",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"raw",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",... | Retrieve all cached data
@param boolean [optional] $meta
@return array | null | [
"Retrieve",
"all",
"cached",
"data"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L134-L148 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.delete | public function delete($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
unset($cache[$key]);
$this->saveCache($cache);
return $this;
}
}
throw new RunBBException("Error: delete() - Key '{$key}' not found.");
} | php | public function delete($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
unset($cache[$key]);
$this->saveCache($cache);
return $this;
}
}
throw new RunBBException("Error: delete() - Key '{$key}' not found.");
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"if",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
"$"... | Delete cached entry by its key
@param string $key
@return object
@throws RunBBException for error delete cached key. | [
"Delete",
"cached",
"entry",
"by",
"its",
"key"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L157-L168 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.deleteExpired | public function deleteExpired()
{
$cache = $this->loadCache();
if (is_array($cache)) {
$i = 0;
$cache = array_map(function ($value) use (& $i) {
if (!$this->isExpired($value['time'], $value['expire'])) {
++$i;
return $value;
}
}, $cache);
if ($i > 0) {
$this->saveCache($cache);
}
}
return $this;
} | php | public function deleteExpired()
{
$cache = $this->loadCache();
if (is_array($cache)) {
$i = 0;
$cache = array_map(function ($value) use (& $i) {
if (!$this->isExpired($value['time'], $value['expire'])) {
++$i;
return $value;
}
}, $cache);
if ($i > 0) {
$this->saveCache($cache);
}
}
return $this;
} | [
"public",
"function",
"deleteExpired",
"(",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"cache",
")",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"cache",
"=",
"array_map",
"(",
"functi... | Erase all expired entries
@return object | [
"Erase",
"all",
"expired",
"entries"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L175-L191 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.increment | public function increment($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
$tmp = unserialize($cache[$key]['data']);
if (is_numeric($tmp)) {
++$tmp;
$cache[$key]['data'] = serialize($tmp);
$this->saveCache($cache);
return $this;
}
}
}
throw new RunBBException("Error: increment() - Key '{$key}' not found.");
} | php | public function increment($key)
{
$key = (string)$key;
if ($cache = $this->loadCache()) {
if (isset($cache[$key])) {
$tmp = unserialize($cache[$key]['data']);
if (is_numeric($tmp)) {
++$tmp;
$cache[$key]['data'] = serialize($tmp);
$this->saveCache($cache);
return $this;
}
}
}
throw new RunBBException("Error: increment() - Key '{$key}' not found.");
} | [
"public",
"function",
"increment",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"if",
"(",
"$",
"cache",
"=",
"$",
"this",
"->",
"loadCache",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"cache",
"[",
... | Increment key
@return object
@throws RunBBException for cache key increment. | [
"Increment",
"key"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L209-L224 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.loadCache | private function loadCache()
{
if (!is_null($this->cache)) {
return $this->cache;
}
if (file_exists($this->getCacheFile()) && !empty($this->getCacheFile())) {
$this->cache = json_decode(file_get_contents($this->getCacheFile()), true);
return $this->cache;
}
return null;
} | php | private function loadCache()
{
if (!is_null($this->cache)) {
return $this->cache;
}
if (file_exists($this->getCacheFile()) && !empty($this->getCacheFile())) {
$this->cache = json_decode(file_get_contents($this->getCacheFile()), true);
return $this->cache;
}
return null;
} | [
"private",
"function",
"loadCache",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"cache",
")",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"getCacheFile",
"(",
")"... | Load cache
@return cache if existing or not null / null otherwise | [
"Load",
"cache"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L252-L263 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.saveCache | private function saveCache(array $data)
{
$this->cache = $data; // Save new data in object to avoid useless I/O access
$opt = '';
if (ForumEnv::get('FEATHER_DEBUG')) {
$opt = JSON_PRETTY_PRINT;
}
return file_put_contents($this->getCacheFile(), json_encode($data, $opt));
} | php | private function saveCache(array $data)
{
$this->cache = $data; // Save new data in object to avoid useless I/O access
$opt = '';
if (ForumEnv::get('FEATHER_DEBUG')) {
$opt = JSON_PRETTY_PRINT;
}
return file_put_contents($this->getCacheFile(), json_encode($data, $opt));
} | [
"private",
"function",
"saveCache",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"$",
"data",
";",
"// Save new data in object to avoid useless I/O access",
"$",
"opt",
"=",
"''",
";",
"if",
"(",
"ForumEnv",
"::",
"get",
"(",
"'FEATH... | Save cache file
@param array $data
@return mixed number of bytes that were written to the file, or FALSE on failure. | [
"Save",
"cache",
"file"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L270-L278 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.checkCacheDir | protected function checkCacheDir()
{
if (!is_dir($this->getCachePath()) && !mkdir($this->getCachePath(), 0775, true)) {
throw new RunBBException('Unable to create cache directory ' . $this->getCachePath());
} elseif (!is_readable($this->getCachePath()) || !is_writable($this->getCachePath())) {
if (!chmod($this->getCachePath(), 0775)) {
throw new RunBBException($this->getCachePath() . ' must be readable and writeable');
}
}
return true;
} | php | protected function checkCacheDir()
{
if (!is_dir($this->getCachePath()) && !mkdir($this->getCachePath(), 0775, true)) {
throw new RunBBException('Unable to create cache directory ' . $this->getCachePath());
} elseif (!is_readable($this->getCachePath()) || !is_writable($this->getCachePath())) {
if (!chmod($this->getCachePath(), 0775)) {
throw new RunBBException($this->getCachePath() . ' must be readable and writeable');
}
}
return true;
} | [
"protected",
"function",
"checkCacheDir",
"(",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"getCachePath",
"(",
")",
")",
"&&",
"!",
"mkdir",
"(",
"$",
"this",
"->",
"getCachePath",
"(",
")",
",",
"0775",
",",
"true",
")",
")",
"{",... | Check if a writable cache directory exists and if not create a new one
@return boolean
@throws RunBBException for invalid creation or readable cache directory. | [
"Check",
"if",
"a",
"writable",
"cache",
"directory",
"exists",
"and",
"if",
"not",
"create",
"a",
"new",
"one"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L301-L311 |
runcmf/runbb | src/RunBB/Core/Cache.php | Cache.getCacheFile | public function getCacheFile()
{
if (!isset($this->filenames[$this->settings['name']])) {
if ($this->checkCacheDir()) {
$filename = preg_replace('/[^0-9a-z\.\_\-]/i', '', strtolower($this->settings['name']));
$this->filenames[$this->settings['name']] = $this->settings['path'] .
sha1($filename) .
$this->settings['extension'];
}
}
return $this->filenames[$this->settings['name']];
} | php | public function getCacheFile()
{
if (!isset($this->filenames[$this->settings['name']])) {
if ($this->checkCacheDir()) {
$filename = preg_replace('/[^0-9a-z\.\_\-]/i', '', strtolower($this->settings['name']));
$this->filenames[$this->settings['name']] = $this->settings['path'] .
sha1($filename) .
$this->settings['extension'];
}
}
return $this->filenames[$this->settings['name']];
} | [
"public",
"function",
"getCacheFile",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filenames",
"[",
"$",
"this",
"->",
"settings",
"[",
"'name'",
"]",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkCacheDir",
"(",
")",
... | Get the cache directory path
@return string | [
"Get",
"the",
"cache",
"directory",
"path"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Cache.php#L322-L333 |
bacart/guzzle-client | src/Middleware/RequestRetryMiddleware.php | RequestRetryMiddleware.decider | public function decider(
int $retries,
Request $request,
Response $response = null,
RequestException $exception = null
): bool {
$statusCode = null !== $response ? $response->getStatusCode() : 0;
$retryNeeded = $retries < $this->maxRetries
&& ($exception instanceof ConnectException
|| $statusCode > GuzzleClientInterface::HTTP_INTERNAL_SERVER_ERROR);
if ($retryNeeded && null !== $this->logger) {
$context = [
GuzzleClientMiddlewareInterface::STATUS => $statusCode,
GuzzleClientMiddlewareInterface::URI => (string) $request->getUri(),
GuzzleClientMiddlewareInterface::METHOD => $request->getMethod(),
];
$this->logger->warning(
sprintf('Guzzle request retry (%d)', $retries),
$context
);
}
return $retryNeeded;
} | php | public function decider(
int $retries,
Request $request,
Response $response = null,
RequestException $exception = null
): bool {
$statusCode = null !== $response ? $response->getStatusCode() : 0;
$retryNeeded = $retries < $this->maxRetries
&& ($exception instanceof ConnectException
|| $statusCode > GuzzleClientInterface::HTTP_INTERNAL_SERVER_ERROR);
if ($retryNeeded && null !== $this->logger) {
$context = [
GuzzleClientMiddlewareInterface::STATUS => $statusCode,
GuzzleClientMiddlewareInterface::URI => (string) $request->getUri(),
GuzzleClientMiddlewareInterface::METHOD => $request->getMethod(),
];
$this->logger->warning(
sprintf('Guzzle request retry (%d)', $retries),
$context
);
}
return $retryNeeded;
} | [
"public",
"function",
"decider",
"(",
"int",
"$",
"retries",
",",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
"=",
"null",
",",
"RequestException",
"$",
"exception",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"statusCode",
"=",
"null",
"!=... | @param int $retries
@param Request $request
@param Response|null $response
@param RequestException|null $exception
@return bool | [
"@param",
"int",
"$retries",
"@param",
"Request",
"$request",
"@param",
"Response|null",
"$response",
"@param",
"RequestException|null",
"$exception"
] | train | https://github.com/bacart/guzzle-client/blob/669e9aacaa2d14ad2eed560a9ed9ee20fded2853/src/Middleware/RequestRetryMiddleware.php#L60-L86 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Service/Standard.php | Standard.saveItems | public function saveItems( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$ids = [];
$manager = $this->getManager();
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $entry )
{
$item = $manager->createItem();
$item->fromArray( (array) $this->transformValues( $entry ) );
$item = $manager->saveItem( $item );
$ids[] = $item->getId();
}
$this->clearCache( $ids );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'service.id', $ids ) );
$search->setSlice( 0, count( $ids ) );
$result = $manager->searchItems( $search );
foreach( $result as $item ) {
$this->checkConfig( $item );
}
$items = $this->toArray( $result );
return array(
'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
'success' => true,
);
} | php | public function saveItems( \stdClass $params )
{
$this->checkParams( $params, array( 'site', 'items' ) );
$this->setLocale( $params->site );
$ids = [];
$manager = $this->getManager();
$items = ( !is_array( $params->items ) ? array( $params->items ) : $params->items );
foreach( $items as $entry )
{
$item = $manager->createItem();
$item->fromArray( (array) $this->transformValues( $entry ) );
$item = $manager->saveItem( $item );
$ids[] = $item->getId();
}
$this->clearCache( $ids );
$search = $manager->createSearch();
$search->setConditions( $search->compare( '==', 'service.id', $ids ) );
$search->setSlice( 0, count( $ids ) );
$result = $manager->searchItems( $search );
foreach( $result as $item ) {
$this->checkConfig( $item );
}
$items = $this->toArray( $result );
return array(
'items' => ( !is_array( $params->items ) ? reset( $items ) : $items ),
'success' => true,
);
} | [
"public",
"function",
"saveItems",
"(",
"\\",
"stdClass",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"checkParams",
"(",
"$",
"params",
",",
"array",
"(",
"'site'",
",",
"'items'",
")",
")",
";",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"params",
"... | Creates a new service item or updates an existing one or a list thereof.
@param \stdClass $params Associative array containing the service properties
@return array Associative list with nodes and success value | [
"Creates",
"a",
"new",
"service",
"item",
"or",
"updates",
"an",
"existing",
"one",
"or",
"a",
"list",
"thereof",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Service/Standard.php#L45-L79 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Service/Standard.php | Standard.checkConfig | protected function checkConfig( \Aimeos\MShop\Service\Item\Iface $item )
{
$msg = '';
$provider = $this->manager->getProvider( $item );
$result = $provider->checkConfigBE( $item->getConfig() );
foreach( $result as $key => $message )
{
if( $message !== null ) {
$msg .= sprintf( "- %1\$s : %2\$s\n", $key, $message );
}
}
if( $msg !== '' ) {
throw new \Aimeos\Controller\ExtJS\Exception( "Invalid configuration:\n" . $msg );
}
} | php | protected function checkConfig( \Aimeos\MShop\Service\Item\Iface $item )
{
$msg = '';
$provider = $this->manager->getProvider( $item );
$result = $provider->checkConfigBE( $item->getConfig() );
foreach( $result as $key => $message )
{
if( $message !== null ) {
$msg .= sprintf( "- %1\$s : %2\$s\n", $key, $message );
}
}
if( $msg !== '' ) {
throw new \Aimeos\Controller\ExtJS\Exception( "Invalid configuration:\n" . $msg );
}
} | [
"protected",
"function",
"checkConfig",
"(",
"\\",
"Aimeos",
"\\",
"MShop",
"\\",
"Service",
"\\",
"Item",
"\\",
"Iface",
"$",
"item",
")",
"{",
"$",
"msg",
"=",
"''",
";",
"$",
"provider",
"=",
"$",
"this",
"->",
"manager",
"->",
"getProvider",
"(",
... | Tests the configuration and throws an exception if it's invalid
@param \Aimeos\MShop\Service\Item\Iface $item Service item object
@throws \Aimeos\Controller\ExtJS\Exception If configuration is invalid | [
"Tests",
"the",
"configuration",
"and",
"throws",
"an",
"exception",
"if",
"it",
"s",
"invalid"
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Service/Standard.php#L116-L132 |
aimeos/ai-admin-extadm | controller/extjs/src/Controller/ExtJS/Attribute/Export/Text/Standard.php | Standard.addLanguage | protected function addLanguage( \Aimeos\MW\Container\Content\Iface $contentItem, $langid, array $ids )
{
$manager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( $this->getContext() );
$search = $manager->createSearch();
if( !empty( $ids ) ) {
$search->setConditions( $search->compare( '==', 'attribute.id', $ids ) );
}
$sort = array(
$search->sort( '+', 'attribute.siteid' ),
$search->sort( '+', 'attribute.domain' ),
$search->sort( '-', 'attribute.code' ),
$search->sort( '-', 'attribute.typeid' ),
);
$search->setSortations( $sort );
$start = 0;
do
{
$result = $manager->searchItems( $search, array( 'text' ) );
foreach( $result as $item ) {
$this->addItem( $contentItem, $item, $langid );
}
$count = count( $result );
$start += $count;
$search->setSlice( $start );
}
while( $count == $search->getSliceSize() );
} | php | protected function addLanguage( \Aimeos\MW\Container\Content\Iface $contentItem, $langid, array $ids )
{
$manager = \Aimeos\MShop\Attribute\Manager\Factory::createManager( $this->getContext() );
$search = $manager->createSearch();
if( !empty( $ids ) ) {
$search->setConditions( $search->compare( '==', 'attribute.id', $ids ) );
}
$sort = array(
$search->sort( '+', 'attribute.siteid' ),
$search->sort( '+', 'attribute.domain' ),
$search->sort( '-', 'attribute.code' ),
$search->sort( '-', 'attribute.typeid' ),
);
$search->setSortations( $sort );
$start = 0;
do
{
$result = $manager->searchItems( $search, array( 'text' ) );
foreach( $result as $item ) {
$this->addItem( $contentItem, $item, $langid );
}
$count = count( $result );
$start += $count;
$search->setSlice( $start );
}
while( $count == $search->getSliceSize() );
} | [
"protected",
"function",
"addLanguage",
"(",
"\\",
"Aimeos",
"\\",
"MW",
"\\",
"Container",
"\\",
"Content",
"\\",
"Iface",
"$",
"contentItem",
",",
"$",
"langid",
",",
"array",
"$",
"ids",
")",
"{",
"$",
"manager",
"=",
"\\",
"Aimeos",
"\\",
"MShop",
... | Adds data for the given language.
@param \Aimeos\MW\Container\Content\Iface $contentItem Content item
@param string $langid Language id
@param array $ids List of of item ids whose texts should be added | [
"Adds",
"data",
"for",
"the",
"given",
"language",
"."
] | train | https://github.com/aimeos/ai-admin-extadm/blob/594ee7cec90fd63a4773c05c93f353e66d9b3408/controller/extjs/src/Controller/ExtJS/Attribute/Export/Text/Standard.php#L280-L312 |
shopgate/cart-integration-sdk | src/helper/String.php | Shopgate_Helper_String.removeTagsFromString | public function removeTagsFromString($string, $removeTags = array(), $additionalAllowedTags = array())
{
// all tags available
$allowedTags = array(
"ADDRESS",
"AREA",
"A",
"BASE",
"BASEFONT",
"BIG",
"BLOCKQUOTE",
"BODY",
"BR",
"B",
"CAPTION",
"CENTER",
"CITE",
"CODE",
"DD",
"DFN",
"DIR",
"DIV",
"DL",
"DT",
"EM",
"FONT",
"FORM",
"H1",
"H2",
"H3",
"H4",
"H5",
"H6",
"HEAD",
"HR",
"HTML",
"IMG",
"INPUT",
"ISINDEX",
"I",
"KBD",
"LINK",
"LI",
"MAP",
"MENU",
"META",
"OL",
"OPTION",
"PARAM",
"PRE",
"P",
"SAMP",
"SELECT",
"SMALL",
"STRIKE",
"STRONG",
"STYLE",
"SUB",
"SUP",
"TABLE",
"TD",
"TEXTAREA",
"TH",
"TITLE",
"TR",
"TT",
"UL",
"U",
"VAR",
);
foreach ($allowedTags as &$t) {
$t = strtolower($t);
}
foreach ($removeTags as &$t) {
$t = strtolower($t);
}
foreach ($additionalAllowedTags as &$t) {
$t = strtolower($t);
}
// some tags must be removed completely (including content)
$string = preg_replace('#<script([^>]*?)>(.*?)</script>#is', '', $string);
$string = preg_replace('#<style([^>]*?)>(.*?)</style>#is', '', $string);
$string = preg_replace('#<link([^>]*?)>(.*?)</link>#is', '', $string);
$string = preg_replace('#<script([^>]*?)/>#is', '', $string);
$string = preg_replace('#<style([^>]*?)/>#is', '', $string);
$string = preg_replace('#<link([^>]*?)/>#is', '', $string);
// add the additional allowed tags to the list
$allowedTags = array_merge($allowedTags, $additionalAllowedTags);
// strip the disallowed tags from the list
$allowedTags = array_diff($allowedTags, $removeTags);
// add HTML brackets
foreach ($allowedTags as &$t) {
$t = "<$t>";
}
// let PHP sanitize the string and return it
return strip_tags($string, implode(",", $allowedTags));
} | php | public function removeTagsFromString($string, $removeTags = array(), $additionalAllowedTags = array())
{
// all tags available
$allowedTags = array(
"ADDRESS",
"AREA",
"A",
"BASE",
"BASEFONT",
"BIG",
"BLOCKQUOTE",
"BODY",
"BR",
"B",
"CAPTION",
"CENTER",
"CITE",
"CODE",
"DD",
"DFN",
"DIR",
"DIV",
"DL",
"DT",
"EM",
"FONT",
"FORM",
"H1",
"H2",
"H3",
"H4",
"H5",
"H6",
"HEAD",
"HR",
"HTML",
"IMG",
"INPUT",
"ISINDEX",
"I",
"KBD",
"LINK",
"LI",
"MAP",
"MENU",
"META",
"OL",
"OPTION",
"PARAM",
"PRE",
"P",
"SAMP",
"SELECT",
"SMALL",
"STRIKE",
"STRONG",
"STYLE",
"SUB",
"SUP",
"TABLE",
"TD",
"TEXTAREA",
"TH",
"TITLE",
"TR",
"TT",
"UL",
"U",
"VAR",
);
foreach ($allowedTags as &$t) {
$t = strtolower($t);
}
foreach ($removeTags as &$t) {
$t = strtolower($t);
}
foreach ($additionalAllowedTags as &$t) {
$t = strtolower($t);
}
// some tags must be removed completely (including content)
$string = preg_replace('#<script([^>]*?)>(.*?)</script>#is', '', $string);
$string = preg_replace('#<style([^>]*?)>(.*?)</style>#is', '', $string);
$string = preg_replace('#<link([^>]*?)>(.*?)</link>#is', '', $string);
$string = preg_replace('#<script([^>]*?)/>#is', '', $string);
$string = preg_replace('#<style([^>]*?)/>#is', '', $string);
$string = preg_replace('#<link([^>]*?)/>#is', '', $string);
// add the additional allowed tags to the list
$allowedTags = array_merge($allowedTags, $additionalAllowedTags);
// strip the disallowed tags from the list
$allowedTags = array_diff($allowedTags, $removeTags);
// add HTML brackets
foreach ($allowedTags as &$t) {
$t = "<$t>";
}
// let PHP sanitize the string and return it
return strip_tags($string, implode(",", $allowedTags));
} | [
"public",
"function",
"removeTagsFromString",
"(",
"$",
"string",
",",
"$",
"removeTags",
"=",
"array",
"(",
")",
",",
"$",
"additionalAllowedTags",
"=",
"array",
"(",
")",
")",
"{",
"// all tags available",
"$",
"allowedTags",
"=",
"array",
"(",
"\"ADDRESS\""... | Removes all disallowed HTML tags from a given string.
By default the following are allowed:
"ADDRESS", "AREA", "A", "BASE", "BASEFONT", "BIG", "BLOCKQUOTE", "BODY", "BR",
"B", "CAPTION", "CENTER", "CITE", "CODE", "DD", "DFN", "DIR", "DIV", "DL", "DT",
"EM", "FONT", "FORM", "H1", "H2", "H3", "H4", "H5", "H6", "HEAD", "HR", "HTML",
"ISINDEX", "I", "KBD", "LINK", "LI", "MAP", "MENU", "META", "OL", "OPTION", "PARAM", "PRE",
"IMG", "INPUT", "P", "SAMP", "SELECT", "SMALL", "STRIKE", "STRONG", "STYLE", "SUB", "SUP",
"TABLE", "TD", "TEXTAREA", "TH", "TITLE", "TR", "TT", "UL", "U", "VAR"
@param string $string The input string to be filtered.
@param string[] $removeTags The tags to be removed.
@param string[] $additionalAllowedTags Additional tags to be allowed.
@return string The sanitized string. | [
"Removes",
"all",
"disallowed",
"HTML",
"tags",
"from",
"a",
"given",
"string",
"."
] | train | https://github.com/shopgate/cart-integration-sdk/blob/cf12ecf8bdb8f4c407209000002fd00261e53b06/src/helper/String.php#L43-L146 |
makinacorpus/drupal-ucms | ucms_label/src/Form/LabelSubscribe.php | LabelSubscribe.buildForm | public function buildForm(array $form, FormStateInterface $form_state, \stdClass $label = null)
{
if ($label === null) {
return [];
}
$form_state->setTemporaryValue('label', $label);
$question = $this->t("Subscribe to the %name label notifications?", ['%name' => $label->name]);
return confirm_form($form, $question, 'admin/dashboard/label', '');
} | php | public function buildForm(array $form, FormStateInterface $form_state, \stdClass $label = null)
{
if ($label === null) {
return [];
}
$form_state->setTemporaryValue('label', $label);
$question = $this->t("Subscribe to the %name label notifications?", ['%name' => $label->name]);
return confirm_form($form, $question, 'admin/dashboard/label', '');
} | [
"public",
"function",
"buildForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
",",
"\\",
"stdClass",
"$",
"label",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"label",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_label/src/Form/LabelSubscribe.php#L69-L78 |
makinacorpus/drupal-ucms | ucms_label/src/Form/LabelSubscribe.php | LabelSubscribe.submitForm | public function submitForm(array &$form, FormStateInterface $form_state)
{
$label = $form_state->getTemporaryValue('label');
$this->notifService->subscribe($this->currentUser()->id(), 'label:' . $label->tid);
drupal_set_message($this->t("You subscribed to the %name label notifications.", array('%name' => $label->name)));
} | php | public function submitForm(array &$form, FormStateInterface $form_state)
{
$label = $form_state->getTemporaryValue('label');
$this->notifService->subscribe($this->currentUser()->id(), 'label:' . $label->tid);
drupal_set_message($this->t("You subscribed to the %name label notifications.", array('%name' => $label->name)));
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"$",
"label",
"=",
"$",
"form_state",
"->",
"getTemporaryValue",
"(",
"'label'",
")",
";",
"$",
"this",
"->",
"notifService",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_label/src/Form/LabelSubscribe.php#L84-L89 |
makinacorpus/drupal-ucms | ucms_group/src/Action/GroupActionProvider.php | GroupActionProvider.getActions | public function getActions($item, $primaryOnly = false, array $groups = [])
{
$ret = [];
/** @var \MakinaCorpus\Ucms\Site\Group $item */
$canView = $this->isGranted(Permission::VIEW, $item);
if ($canView) {
$ret[] = new Action($this->t("All members"), 'admin/dashboard/group/' . $item->getId() . '/members', [], 'user', 100, false, false, false, 'user');
}
if ($this->isGranted(Access::ACL_PERM_MANAGE_USERS, $item)) {
$ret[] = new Action($this->t("Add existing member"), 'admin/dashboard/group/' . $item->getId() . '/members/add', 'dialog', 'user', 110, false, true, false, 'user');
}
if ($canView) {
$ret[] = new Action($this->t("All sites"), 'admin/dashboard/group/' . $item->getId() . '/sites', [], 'cloud', 200, false, false, false, 'site');
}
if ($this->isGranted(Access::ACL_PERM_MANAGE_SITES, $item)) {
$ret[] = new Action($this->t("Add site"), 'admin/dashboard/group/' . $item->getId() . '/sites/add', 'dialog', 'cloud', 210, false, true, false, 'site');
}
if ($canView) {
$ret[] = new Action($this->t("View"), 'admin/dashboard/group/' . $item->getId(), [], 'eye', 0, true, false, false, 'edit');
}
if ($this->isGranted(Permission::UPDATE, $item)) {
$ret[] = new Action($this->t("Edit"), 'admin/dashboard/group/' . $item->getId() . '/edit', [], 'pencil', 400, false, true, false, 'edit');
}
return $ret;
} | php | public function getActions($item, $primaryOnly = false, array $groups = [])
{
$ret = [];
/** @var \MakinaCorpus\Ucms\Site\Group $item */
$canView = $this->isGranted(Permission::VIEW, $item);
if ($canView) {
$ret[] = new Action($this->t("All members"), 'admin/dashboard/group/' . $item->getId() . '/members', [], 'user', 100, false, false, false, 'user');
}
if ($this->isGranted(Access::ACL_PERM_MANAGE_USERS, $item)) {
$ret[] = new Action($this->t("Add existing member"), 'admin/dashboard/group/' . $item->getId() . '/members/add', 'dialog', 'user', 110, false, true, false, 'user');
}
if ($canView) {
$ret[] = new Action($this->t("All sites"), 'admin/dashboard/group/' . $item->getId() . '/sites', [], 'cloud', 200, false, false, false, 'site');
}
if ($this->isGranted(Access::ACL_PERM_MANAGE_SITES, $item)) {
$ret[] = new Action($this->t("Add site"), 'admin/dashboard/group/' . $item->getId() . '/sites/add', 'dialog', 'cloud', 210, false, true, false, 'site');
}
if ($canView) {
$ret[] = new Action($this->t("View"), 'admin/dashboard/group/' . $item->getId(), [], 'eye', 0, true, false, false, 'edit');
}
if ($this->isGranted(Permission::UPDATE, $item)) {
$ret[] = new Action($this->t("Edit"), 'admin/dashboard/group/' . $item->getId() . '/edit', [], 'pencil', 400, false, true, false, 'edit');
}
return $ret;
} | [
"public",
"function",
"getActions",
"(",
"$",
"item",
",",
"$",
"primaryOnly",
"=",
"false",
",",
"array",
"$",
"groups",
"=",
"[",
"]",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"/** @var \\MakinaCorpus\\Ucms\\Site\\Group $item */",
"$",
"canView",
"=",
"... | {inheritdoc} | [
"{",
"inheritdoc",
"}"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/Action/GroupActionProvider.php#L16-L45 |
shopgate/cart-integration-sdk | src/models/catalog/Property.php | Shopgate_Model_Catalog_Property.asXml | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $propertyNode
*/
$propertyNode = $itemNode->addChild('property');
$propertyNode->addAttribute('uid', $this->getUid());
$propertyNode->addChildWithCDATA('label', $this->getLabel());
$propertyNode->addChildWithCDATA('value', $this->getValue());
return $itemNode;
} | php | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $propertyNode
*/
$propertyNode = $itemNode->addChild('property');
$propertyNode->addAttribute('uid', $this->getUid());
$propertyNode->addChildWithCDATA('label', $this->getLabel());
$propertyNode->addChildWithCDATA('value', $this->getValue());
return $itemNode;
} | [
"public",
"function",
"asXml",
"(",
"Shopgate_Model_XmlResultObject",
"$",
"itemNode",
")",
"{",
"/**\n * @var Shopgate_Model_XmlResultObject $propertyNode\n */",
"$",
"propertyNode",
"=",
"$",
"itemNode",
"->",
"addChild",
"(",
"'property'",
")",
";",
"$",
... | @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/Property.php#L55-L66 |
makinacorpus/drupal-ucms | ucms_user/src/Form/UserDisable.php | UserDisable.submitForm | public function submitForm(array &$form, FormStateInterface $form_state)
{
/* @var $user UserInterface */
$user = $form_state->getTemporaryValue('user');
$user->status = 0;
if ($this->entityManager->getStorage('user')->save($user)) {
drupal_set_message($this->t("User @name has been disabled.", array('@name' => $user->getDisplayName())));
$this->dispatcher->dispatch('user:disable', new UserEvent($user->id(), $this->currentUser()->id()));
} else {
drupal_set_message($this->t("An error occured. Please try again."), 'error');
}
$form_state->setRedirect('admin/dashboard/user');
} | php | public function submitForm(array &$form, FormStateInterface $form_state)
{
/* @var $user UserInterface */
$user = $form_state->getTemporaryValue('user');
$user->status = 0;
if ($this->entityManager->getStorage('user')->save($user)) {
drupal_set_message($this->t("User @name has been disabled.", array('@name' => $user->getDisplayName())));
$this->dispatcher->dispatch('user:disable', new UserEvent($user->id(), $this->currentUser()->id()));
} else {
drupal_set_message($this->t("An error occured. Please try again."), 'error');
}
$form_state->setRedirect('admin/dashboard/user');
} | [
"public",
"function",
"submitForm",
"(",
"array",
"&",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"/* @var $user UserInterface */",
"$",
"user",
"=",
"$",
"form_state",
"->",
"getTemporaryValue",
"(",
"'user'",
")",
";",
"$",
"user",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_user/src/Form/UserDisable.php#L81-L95 |
BugBuster1701/botdetection | src/modules/ModuleBotDetection.php | ModuleBotDetection.BD_CheckBotAgent | public function BD_CheckBotAgent($UserAgent = false)
{
// Check if user agent present
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentSimple::checkAgent( $UserAgent );
} | php | public function BD_CheckBotAgent($UserAgent = false)
{
// Check if user agent present
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentSimple::checkAgent( $UserAgent );
} | [
"public",
"function",
"BD_CheckBotAgent",
"(",
"$",
"UserAgent",
"=",
"false",
")",
"{",
"// Check if user agent present",
"if",
"(",
"$",
"UserAgent",
"===",
"false",
")",
"{",
"$",
"UserAgent",
"=",
"trim",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'htt... | Spider Bot Agent Check
@param string UserAgent, optional for tests
@return boolean true when bot found
@deprecated Use the CheckBotAgentSimple class instead or the method checkBotAllTests | [
"Spider",
"Bot",
"Agent",
"Check"
] | train | https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBotDetection.php#L130-L138 |
BugBuster1701/botdetection | src/modules/ModuleBotDetection.php | ModuleBotDetection.BD_CheckBotIP | public function BD_CheckBotIP($UserIP = false)
{
// Check if IP present
if ($UserIP === false)
{
if (strpos(\Environment::get('ip'), ',') !== false) //first IP
{
$UserIP = trim(substr(\Environment::get('ip'), 0, strpos(\Environment::get('ip'), ',')));
}
else
{
$UserIP = trim(\Environment::get('ip'));
}
}
\BugBuster\BotDetection\CheckBotIp::setBotIpv4List(TL_ROOT . self::BOT_IP4_LIST);
\BugBuster\BotDetection\CheckBotIp::setBotIpv6List(TL_ROOT . self::BOT_IP6_LIST);
return \BugBuster\BotDetection\CheckBotIp::checkIP( $UserIP );
} | php | public function BD_CheckBotIP($UserIP = false)
{
// Check if IP present
if ($UserIP === false)
{
if (strpos(\Environment::get('ip'), ',') !== false) //first IP
{
$UserIP = trim(substr(\Environment::get('ip'), 0, strpos(\Environment::get('ip'), ',')));
}
else
{
$UserIP = trim(\Environment::get('ip'));
}
}
\BugBuster\BotDetection\CheckBotIp::setBotIpv4List(TL_ROOT . self::BOT_IP4_LIST);
\BugBuster\BotDetection\CheckBotIp::setBotIpv6List(TL_ROOT . self::BOT_IP6_LIST);
return \BugBuster\BotDetection\CheckBotIp::checkIP( $UserIP );
} | [
"public",
"function",
"BD_CheckBotIP",
"(",
"$",
"UserIP",
"=",
"false",
")",
"{",
"// Check if IP present",
"if",
"(",
"$",
"UserIP",
"===",
"false",
")",
"{",
"if",
"(",
"strpos",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'ip'",
")",
",",
"','",
"... | Spider Bot IP Check
@param string User IP, optional for tests
@return boolean true when bot found over IP
@deprecated Use the CheckBotIp class instead | [
"Spider",
"Bot",
"IP",
"Check"
] | train | https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBotDetection.php#L147-L164 |
BugBuster1701/botdetection | src/modules/ModuleBotDetection.php | ModuleBotDetection.BD_CheckBotAgentAdvanced | public function BD_CheckBotAgentAdvanced($UserAgent = false)
{
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentExtended::checkAgentName( $UserAgent );
} | php | public function BD_CheckBotAgentAdvanced($UserAgent = false)
{
if ($UserAgent === false)
{
$UserAgent = trim(\Environment::get('httpUserAgent'));
}
return \BugBuster\BotDetection\CheckBotAgentExtended::checkAgentName( $UserAgent );
} | [
"public",
"function",
"BD_CheckBotAgentAdvanced",
"(",
"$",
"UserAgent",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"UserAgent",
"===",
"false",
")",
"{",
"$",
"UserAgent",
"=",
"trim",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'httpUserAgent'",
")",
")",
... | Spider Bot Agent Check Advanced
@param string UserAgent, optional for tests
@return bool false (not bot) or true (bot), in old version the short Bot-Agentname
@deprecated Use the CheckBotAgentExtended class instead or the method checkBotAllTests | [
"Spider",
"Bot",
"Agent",
"Check",
"Advanced"
] | train | https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBotDetection.php#L173-L180 |
BugBuster1701/botdetection | src/modules/ModuleBotDetection.php | ModuleBotDetection.BD_CheckBotReferrer | public function BD_CheckBotReferrer($Referrer = false)
{
return \BugBuster\BotDetection\CheckBotReferrer::checkReferrer($Referrer, TL_ROOT . self::BOT_REFERRER_LIST);
} | php | public function BD_CheckBotReferrer($Referrer = false)
{
return \BugBuster\BotDetection\CheckBotReferrer::checkReferrer($Referrer, TL_ROOT . self::BOT_REFERRER_LIST);
} | [
"public",
"function",
"BD_CheckBotReferrer",
"(",
"$",
"Referrer",
"=",
"false",
")",
"{",
"return",
"\\",
"BugBuster",
"\\",
"BotDetection",
"\\",
"CheckBotReferrer",
"::",
"checkReferrer",
"(",
"$",
"Referrer",
",",
"TL_ROOT",
".",
"self",
"::",
"BOT_REFERRER_... | CheckBotReferrer
@param string $Referrer
@deprecated Use the CheckBotReferrer class instead or the method checkBotAllTests | [
"CheckBotReferrer"
] | train | https://github.com/BugBuster1701/botdetection/blob/b27cc1d80932af7d29b9f345da9132842d2adbce/src/modules/ModuleBotDetection.php#L188-L191 |
makinacorpus/drupal-ucms | ucms_group/src/EventDispatcher/NodeEventSubscriber.php | NodeEventSubscriber.onNodePrepare | public function onNodePrepare(NodeEvent $event)
{
$node = $event->getNode();
if (!empty($node->group_id)) {
return; // Someone took care of this for us
}
$node->group_id = $this->findMostRelevantGroupId();
$node->is_ghost = (int)$this->findMostRelevantGhostValue($node);
} | php | public function onNodePrepare(NodeEvent $event)
{
$node = $event->getNode();
if (!empty($node->group_id)) {
return; // Someone took care of this for us
}
$node->group_id = $this->findMostRelevantGroupId();
$node->is_ghost = (int)$this->findMostRelevantGhostValue($node);
} | [
"public",
"function",
"onNodePrepare",
"(",
"NodeEvent",
"$",
"event",
")",
"{",
"$",
"node",
"=",
"$",
"event",
"->",
"getNode",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"->",
"group_id",
")",
")",
"{",
"return",
";",
"// Someone to... | Sets the most relevant 'group_id' and 'is_ghost' property values | [
"Sets",
"the",
"most",
"relevant",
"group_id",
"and",
"is_ghost",
"property",
"values"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/EventDispatcher/NodeEventSubscriber.php#L34-L44 |
makinacorpus/drupal-ucms | ucms_group/src/EventDispatcher/NodeEventSubscriber.php | NodeEventSubscriber.onNodePresave | public function onNodePresave(NodeEvent $event)
{
$node = $event->getNode();
// When coming from the node form, node form has already been submitted
// case in which, if relevant, a group identifier has already been set
// and this code won't be execute. In the other hand, if the prepare
// hook has not been invoked, this will run and set things right.
// There is still a use case where the node comes from the node form but
// there is no contextual group, case in which this code will wrongly
// run, but hopefuly since it is just setting defaults, it won't change
// the normal behavior.
if (empty($node->group_id)) {
$groupId = $this->findMostRelevantGroupId();
if ($groupId) {
$node->group_id = $groupId;
}
$node->is_ghost = $this->findMostRelevantGhostValue($node);
}
} | php | public function onNodePresave(NodeEvent $event)
{
$node = $event->getNode();
// When coming from the node form, node form has already been submitted
// case in which, if relevant, a group identifier has already been set
// and this code won't be execute. In the other hand, if the prepare
// hook has not been invoked, this will run and set things right.
// There is still a use case where the node comes from the node form but
// there is no contextual group, case in which this code will wrongly
// run, but hopefuly since it is just setting defaults, it won't change
// the normal behavior.
if (empty($node->group_id)) {
$groupId = $this->findMostRelevantGroupId();
if ($groupId) {
$node->group_id = $groupId;
}
$node->is_ghost = $this->findMostRelevantGhostValue($node);
}
} | [
"public",
"function",
"onNodePresave",
"(",
"NodeEvent",
"$",
"event",
")",
"{",
"$",
"node",
"=",
"$",
"event",
"->",
"getNode",
"(",
")",
";",
"// When coming from the node form, node form has already been submitted",
"// case in which, if relevant, a group identifier has a... | Prepare hook is no always called, this is why we do reproduce what does
happen during the prepare hook in the presave hook, if no value has
already been provided | [
"Prepare",
"hook",
"is",
"no",
"always",
"called",
"this",
"is",
"why",
"we",
"do",
"reproduce",
"what",
"does",
"happen",
"during",
"the",
"prepare",
"hook",
"in",
"the",
"presave",
"hook",
"if",
"no",
"value",
"has",
"already",
"been",
"provided"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_group/src/EventDispatcher/NodeEventSubscriber.php#L51-L72 |
makinacorpus/drupal-ucms | ucms_tree/src/DependencyInjection/Compiler/TreeCompilerPass.php | TreeCompilerPass.process | public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('umenu.manager') || $container->hasAlias('umenu.manager')) {
$eventListener = $container->getDefinition('ucms_tree.site_event_subscriber');
$eventListener->addMethodCall(
'setTreeManager',
[new Reference('umenu.manager')]
);
}
} | php | public function process(ContainerBuilder $container)
{
if ($container->hasDefinition('umenu.manager') || $container->hasAlias('umenu.manager')) {
$eventListener = $container->getDefinition('ucms_tree.site_event_subscriber');
$eventListener->addMethodCall(
'setTreeManager',
[new Reference('umenu.manager')]
);
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"$",
"container",
"->",
"hasDefinition",
"(",
"'umenu.manager'",
")",
"||",
"$",
"container",
"->",
"hasAlias",
"(",
"'umenu.manager'",
")",
")",
"{",
"$",
"even... | You can modify the container here before it is dumped to PHP code.
@param ContainerBuilder $container | [
"You",
"can",
"modify",
"the",
"container",
"here",
"before",
"it",
"is",
"dumped",
"to",
"PHP",
"code",
"."
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_tree/src/DependencyInjection/Compiler/TreeCompilerPass.php#L16-L26 |
PHPixie/HTTP | src/PHPixie/HTTP/Builder.php | Builder.cookiesUpdate | public function cookiesUpdate(
$name,
$value,
$expires = null,
$path = '/',
$domain = null,
$secure = false,
$httpOnly = false
)
{
return new Context\Cookies\Update(
$name,
$value,
$expires,
$path,
$domain,
$secure,
$httpOnly
);
} | php | public function cookiesUpdate(
$name,
$value,
$expires = null,
$path = '/',
$domain = null,
$secure = false,
$httpOnly = false
)
{
return new Context\Cookies\Update(
$name,
$value,
$expires,
$path,
$domain,
$secure,
$httpOnly
);
} | [
"public",
"function",
"cookiesUpdate",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"expires",
"=",
"null",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"secure",
"=",
"false",
",",
"$",
"httpOnly",
"=",
"false",
")",
... | Build a single cookie update
@param $name
@param $value
@param null $expires
@param string $path
@param null $domain
@param bool $secure
@param bool $httpOnly
@return Context\Cookies\Update | [
"Build",
"a",
"single",
"cookie",
"update"
] | train | https://github.com/PHPixie/HTTP/blob/581c0df452fd07ca4ea0b3e24e8ddee8dddc2912/src/PHPixie/HTTP/Builder.php#L149-L168 |
runcmf/runbb | src/RunBB/Core/Track.php | Track.setTrackedTopics | public static function setTrackedTopics($tracked_topics = null)
{
if (!empty($tracked_topics)) {
// Sort the arrays (latest read first)
arsort($tracked_topics['topics'], SORT_NUMERIC);
arsort($tracked_topics['forums'], SORT_NUMERIC);
} else {
$tracked_topics = ['topics' => [], 'forums' => []];
}
return setcookie(
ForumSettings::get('cookie_name') . '_track',
json_encode($tracked_topics),
time() + ForumSettings::get('o_timeout_visit'),
'/',
'',
false,
true
);
} | php | public static function setTrackedTopics($tracked_topics = null)
{
if (!empty($tracked_topics)) {
// Sort the arrays (latest read first)
arsort($tracked_topics['topics'], SORT_NUMERIC);
arsort($tracked_topics['forums'], SORT_NUMERIC);
} else {
$tracked_topics = ['topics' => [], 'forums' => []];
}
return setcookie(
ForumSettings::get('cookie_name') . '_track',
json_encode($tracked_topics),
time() + ForumSettings::get('o_timeout_visit'),
'/',
'',
false,
true
);
} | [
"public",
"static",
"function",
"setTrackedTopics",
"(",
"$",
"tracked_topics",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"tracked_topics",
")",
")",
"{",
"// Sort the arrays (latest read first)",
"arsort",
"(",
"$",
"tracked_topics",
"[",
"'topi... | Save array of tracked topics in cookie
@param null $tracked_topics
@return bool | [
"Save",
"array",
"of",
"tracked",
"topics",
"in",
"cookie"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Track.php#L19-L38 |
runcmf/runbb | src/RunBB/Core/Track.php | Track.getTrackedTopics | public static function getTrackedTopics()
{
$cookie_raw = Container::get('cookie')->get(ForumSettings::get('cookie_name').'_track');
if (isset($cookie_raw)) {
$cookie_data = json_decode($cookie_raw, true);
return $cookie_data;
}
return ['topics' => [], 'forums' => []];
} | php | public static function getTrackedTopics()
{
$cookie_raw = Container::get('cookie')->get(ForumSettings::get('cookie_name').'_track');
if (isset($cookie_raw)) {
$cookie_data = json_decode($cookie_raw, true);
return $cookie_data;
}
return ['topics' => [], 'forums' => []];
} | [
"public",
"static",
"function",
"getTrackedTopics",
"(",
")",
"{",
"$",
"cookie_raw",
"=",
"Container",
"::",
"get",
"(",
"'cookie'",
")",
"->",
"get",
"(",
"ForumSettings",
"::",
"get",
"(",
"'cookie_name'",
")",
".",
"'_track'",
")",
";",
"if",
"(",
"i... | Extract array of tracked topics from cookie
@return array|mixed | [
"Extract",
"array",
"of",
"tracked",
"topics",
"from",
"cookie"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Core/Track.php#L44-L53 |
phlib/db | src/Adapter.php | Adapter.setDatabase | public function setDatabase($dbname)
{
$this->config->setDatabase($dbname);
if ($this->connection) {
try {
$this->query('USE ' . $this->quote()->identifier($dbname));
} catch (RuntimeException $exception) {
/** @var \PDOException $prevException */
$prevException = $exception->getPrevious();
if (UnknownDatabaseException::isUnknownDatabase($prevException)) {
throw UnknownDatabaseException::createFromUnknownDatabase($dbname, $prevException);
}
throw $exception;
}
}
return $this;
} | php | public function setDatabase($dbname)
{
$this->config->setDatabase($dbname);
if ($this->connection) {
try {
$this->query('USE ' . $this->quote()->identifier($dbname));
} catch (RuntimeException $exception) {
/** @var \PDOException $prevException */
$prevException = $exception->getPrevious();
if (UnknownDatabaseException::isUnknownDatabase($prevException)) {
throw UnknownDatabaseException::createFromUnknownDatabase($dbname, $prevException);
}
throw $exception;
}
}
return $this;
} | [
"public",
"function",
"setDatabase",
"(",
"$",
"dbname",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"setDatabase",
"(",
"$",
"dbname",
")",
";",
"if",
"(",
"$",
"this",
"->",
"connection",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"query",
"(",
"'... | Set database
@param string $dbname
@return Adapter
@throws UnknownDatabaseException | [
"Set",
"database"
] | train | https://github.com/phlib/db/blob/30c0fce5fb268766265cb03492c4209bcf916a40/src/Adapter.php#L140-L158 |
phlib/db | src/Adapter.php | Adapter.setCharset | public function setCharset($charset)
{
if ($this->config->getCharset() !== $charset) {
$this->config->setCharset($charset);
if ($this->connection) {
$this->query('SET NAMES ?', [$charset]);
}
}
return $this;
} | php | public function setCharset($charset)
{
if ($this->config->getCharset() !== $charset) {
$this->config->setCharset($charset);
if ($this->connection) {
$this->query('SET NAMES ?', [$charset]);
}
}
return $this;
} | [
"public",
"function",
"setCharset",
"(",
"$",
"charset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"getCharset",
"(",
")",
"!==",
"$",
"charset",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"setCharset",
"(",
"$",
"charset",
")",
";",
... | Set the character set on the connection.
@param string $charset
@return Adapter | [
"Set",
"the",
"character",
"set",
"on",
"the",
"connection",
"."
] | train | https://github.com/phlib/db/blob/30c0fce5fb268766265cb03492c4209bcf916a40/src/Adapter.php#L177-L187 |
phlib/db | src/Adapter.php | Adapter.setTimezone | public function setTimezone($timezone)
{
if ($this->config->getTimezone() !== $timezone) {
$this->config->setTimezone($timezone);
if ($this->connection) {
$this->query('SET time_zone = ?', [$timezone]);
}
}
return $this;
} | php | public function setTimezone($timezone)
{
if ($this->config->getTimezone() !== $timezone) {
$this->config->setTimezone($timezone);
if ($this->connection) {
$this->query('SET time_zone = ?', [$timezone]);
}
}
return $this;
} | [
"public",
"function",
"setTimezone",
"(",
"$",
"timezone",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"getTimezone",
"(",
")",
"!==",
"$",
"timezone",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"setTimezone",
"(",
"$",
"timezone",
")",
... | Set the timezone on the connection.
@param string $timezone
@return Adapter | [
"Set",
"the",
"timezone",
"on",
"the",
"connection",
"."
] | train | https://github.com/phlib/db/blob/30c0fce5fb268766265cb03492c4209bcf916a40/src/Adapter.php#L195-L205 |
phlib/db | src/Adapter.php | Adapter.execute | public function execute($statement, array $bind = [])
{
$stmt = $this->query($statement, $bind);
return $stmt->rowCount();
} | php | public function execute($statement, array $bind = [])
{
$stmt = $this->query($statement, $bind);
return $stmt->rowCount();
} | [
"public",
"function",
"execute",
"(",
"$",
"statement",
",",
"array",
"$",
"bind",
"=",
"[",
"]",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"statement",
",",
"$",
"bind",
")",
";",
"return",
"$",
"stmt",
"->",
"rowCount",
... | Execute an SQL statement
@param string $statement
@param array $bind
@return int | [
"Execute",
"an",
"SQL",
"statement"
] | train | https://github.com/phlib/db/blob/30c0fce5fb268766265cb03492c4209bcf916a40/src/Adapter.php#L299-L303 |
phlib/db | src/Adapter.php | Adapter.connect | private function connect()
{
if (is_null($this->connection)) {
$this->connection = call_user_func($this->connectionFactory, $this->config);
}
return $this;
} | php | private function connect()
{
if (is_null($this->connection)) {
$this->connection = call_user_func($this->connectionFactory, $this->config);
}
return $this;
} | [
"private",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"{",
"$",
"this",
"->",
"connection",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"connectionFactory",
",",
"$",
"this",
"->",
"co... | Connect
@return Adapter | [
"Connect"
] | train | https://github.com/phlib/db/blob/30c0fce5fb268766265cb03492c4209bcf916a40/src/Adapter.php#L346-L353 |
despark/ignicms | database/seeds/PermissionRoleTableSeeder.php | PermissionRoleTableSeeder.run | public function run()
{
// php artisan db:seed --class="PermissionRoleTableSeeder"
$permissions = Permission::all();
$adminRole = Role::whereName('admin')->first();
foreach ($permissions as $permission) {
if (! $adminRole->hasPermissionTo($permission)) {
$adminRole->givePermissionTo($permission->name);
}
}
$rolePermissions = ['manage_pages', 'access_admin'];
/** @var Role $editorRole */
$editorRole = Role::whereName('editor')->first();
foreach ($rolePermissions as $permission) {
if (! $editorRole->hasPermissionTo($permission)) {
$editorRole->givePermissionTo($permission);
}
}
} | php | public function run()
{
// php artisan db:seed --class="PermissionRoleTableSeeder"
$permissions = Permission::all();
$adminRole = Role::whereName('admin')->first();
foreach ($permissions as $permission) {
if (! $adminRole->hasPermissionTo($permission)) {
$adminRole->givePermissionTo($permission->name);
}
}
$rolePermissions = ['manage_pages', 'access_admin'];
/** @var Role $editorRole */
$editorRole = Role::whereName('editor')->first();
foreach ($rolePermissions as $permission) {
if (! $editorRole->hasPermissionTo($permission)) {
$editorRole->givePermissionTo($permission);
}
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"// php artisan db:seed --class=\"PermissionRoleTableSeeder\"",
"$",
"permissions",
"=",
"Permission",
"::",
"all",
"(",
")",
";",
"$",
"adminRole",
"=",
"Role",
"::",
"whereName",
"(",
"'admin'",
")",
"->",
"first",
"... | Run the database seeds. | [
"Run",
"the",
"database",
"seeds",
"."
] | train | https://github.com/despark/ignicms/blob/d55775a4656a7e99017d2ef3f8160599d600d2a7/database/seeds/PermissionRoleTableSeeder.php#L12-L32 |
shopgate/cart-integration-sdk | src/models/media/Image.php | Shopgate_Model_Media_Image.asXml | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $imageNode
*/
$imageNode = $itemNode->addChild('image');
$imageNode->addAttribute('uid', $this->getUid());
$imageNode->addAttribute('sort_order', $this->getSortOrder());
$imageNode->addAttribute('is_cover', $this->getIsCover());
$imageNode->addChildWithCDATA('url', $this->getUrl());
$imageNode->addChildWithCDATA('title', $this->getTitle(), false);
$imageNode->addChildWithCDATA('alt', $this->getAlt(), false);
return $itemNode;
} | php | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $imageNode
*/
$imageNode = $itemNode->addChild('image');
$imageNode->addAttribute('uid', $this->getUid());
$imageNode->addAttribute('sort_order', $this->getSortOrder());
$imageNode->addAttribute('is_cover', $this->getIsCover());
$imageNode->addChildWithCDATA('url', $this->getUrl());
$imageNode->addChildWithCDATA('title', $this->getTitle(), false);
$imageNode->addChildWithCDATA('alt', $this->getAlt(), false);
return $itemNode;
} | [
"public",
"function",
"asXml",
"(",
"Shopgate_Model_XmlResultObject",
"$",
"itemNode",
")",
"{",
"/**\n * @var Shopgate_Model_XmlResultObject $imageNode\n */",
"$",
"imageNode",
"=",
"$",
"itemNode",
"->",
"addChild",
"(",
"'image'",
")",
";",
"$",
"imageN... | @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/media/Image.php#L68-L82 |
runcmf/runbb | src/RunBB/Middleware/Core.php | Core.setHeaders | public function setHeaders($res)
{
foreach ($this->headers as $label => $value) {
$res = $res->withHeader($label, $value);
}
return $res->withHeader('X-Powered-By', $this->forum_env['FORUM_NAME']);
} | php | public function setHeaders($res)
{
foreach ($this->headers as $label => $value) {
$res = $res->withHeader($label, $value);
}
return $res->withHeader('X-Powered-By', $this->forum_env['FORUM_NAME']);
} | [
"public",
"function",
"setHeaders",
"(",
"$",
"res",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"label",
"=>",
"$",
"value",
")",
"{",
"$",
"res",
"=",
"$",
"res",
"->",
"withHeader",
"(",
"$",
"label",
",",
"$",
"value",
... | Headers | [
"Headers"
] | train | https://github.com/runcmf/runbb/blob/d4f4098bcece48b78ea2d1ae5eeead7ac9a8b463/src/RunBB/Middleware/Core.php#L125-L131 |
shopgate/cart-integration-sdk | src/models/media/Attachment.php | Shopgate_Model_Media_Attachment.asXml | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $attachmentNode
*/
$attachmentNode = $itemNode->addChild('attachment');
$attachmentNode->addAttribute('number', $this->getNumber());
$attachmentNode->addChildWithCDATA('url', $this->getUrl());
$attachmentNode->addChild('mime_type', $this->getMimeType());
$attachmentNode->addChild('file_name', $this->getFileName());
$attachmentNode->addChildWithCDATA('title', $this->getTitle());
$attachmentNode->addChildWithCDATA('description', $this->getDescription());
return $itemNode;
} | php | public function asXml(Shopgate_Model_XmlResultObject $itemNode)
{
/**
* @var Shopgate_Model_XmlResultObject $attachmentNode
*/
$attachmentNode = $itemNode->addChild('attachment');
$attachmentNode->addAttribute('number', $this->getNumber());
$attachmentNode->addChildWithCDATA('url', $this->getUrl());
$attachmentNode->addChild('mime_type', $this->getMimeType());
$attachmentNode->addChild('file_name', $this->getFileName());
$attachmentNode->addChildWithCDATA('title', $this->getTitle());
$attachmentNode->addChildWithCDATA('description', $this->getDescription());
return $itemNode;
} | [
"public",
"function",
"asXml",
"(",
"Shopgate_Model_XmlResultObject",
"$",
"itemNode",
")",
"{",
"/**\n * @var Shopgate_Model_XmlResultObject $attachmentNode\n */",
"$",
"attachmentNode",
"=",
"$",
"itemNode",
"->",
"addChild",
"(",
"'attachment'",
")",
";",
... | @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/media/Attachment.php#L53-L67 |
makinacorpus/drupal-ucms | ucms_site/src/Controller/DashboardController.php | DashboardController.siteArchiveListAction | public function siteArchiveListAction(Request $request)
{
$baseQuery = ['s.state' => SiteState::ARCHIVE];
if (!$this->isGranted([Access::PERM_SITE_GOD, Access::PERM_SITE_MANAGE_ALL, Access::PERM_SITE_VIEW_ALL])) {
$baseQuery['uid'] = $this->getCurrentUserId();
}
return $this->renderPage('ucms_site.list_all', $request, [
'base_query' => [
'uid' => $baseQuery,
],
]);
} | php | public function siteArchiveListAction(Request $request)
{
$baseQuery = ['s.state' => SiteState::ARCHIVE];
if (!$this->isGranted([Access::PERM_SITE_GOD, Access::PERM_SITE_MANAGE_ALL, Access::PERM_SITE_VIEW_ALL])) {
$baseQuery['uid'] = $this->getCurrentUserId();
}
return $this->renderPage('ucms_site.list_all', $request, [
'base_query' => [
'uid' => $baseQuery,
],
]);
} | [
"public",
"function",
"siteArchiveListAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"baseQuery",
"=",
"[",
"'s.state'",
"=>",
"SiteState",
"::",
"ARCHIVE",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isGranted",
"(",
"[",
"Access",
"::",
"PER... | List archived sites | [
"List",
"archived",
"sites"
] | train | https://github.com/makinacorpus/drupal-ucms/blob/6b8a84305472d2cad816102672f10274b3bbb535/ucms_site/src/Controller/DashboardController.php#L62-L75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.