id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,500 | firebrandhq/silverstripe-hail | src/Models/Image.php | Image.getRelativeCenterY | public function getRelativeCenterY()
{
$pos = 50;
if ($this->FaceCentreY > 0 && $this->OriginalHeight > 0) {
$pos = $this->FaceCentreY / $this->OriginalHeight * 100;
$pos = ($pos > 100 || $pos < 0) ? 50 : $pos;
}
return $pos;
} | php | public function getRelativeCenterY()
{
$pos = 50;
if ($this->FaceCentreY > 0 && $this->OriginalHeight > 0) {
$pos = $this->FaceCentreY / $this->OriginalHeight * 100;
$pos = ($pos > 100 || $pos < 0) ? 50 : $pos;
}
return $pos;
} | [
"public",
"function",
"getRelativeCenterY",
"(",
")",
"{",
"$",
"pos",
"=",
"50",
";",
"if",
"(",
"$",
"this",
"->",
"FaceCentreY",
">",
"0",
"&&",
"$",
"this",
"->",
"OriginalHeight",
">",
"0",
")",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"FaceCentreY",
"/",
"$",
"this",
"->",
"OriginalHeight",
"*",
"100",
";",
"$",
"pos",
"=",
"(",
"$",
"pos",
">",
"100",
"||",
"$",
"pos",
"<",
"0",
")",
"?",
"50",
":",
"$",
"pos",
";",
"}",
"return",
"$",
"pos",
";",
"}"
] | Get the Y axis for the relative center of this image
@return int | [
"Get",
"the",
"Y",
"axis",
"for",
"the",
"relative",
"center",
"of",
"this",
"image"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Image.php#L209-L218 |
32,501 | oasmobile/php-http | src/ServiceProviders/Security/AbstractSimplePreAuthenticator.php | AbstractSimplePreAuthenticator.createAuthenticatedToken | protected function createAuthenticatedToken($user, $credentials, $providerKey)
{
return new PreAuthenticatedToken($user, $credentials, $providerKey, $user->getRoles());
} | php | protected function createAuthenticatedToken($user, $credentials, $providerKey)
{
return new PreAuthenticatedToken($user, $credentials, $providerKey, $user->getRoles());
} | [
"protected",
"function",
"createAuthenticatedToken",
"(",
"$",
"user",
",",
"$",
"credentials",
",",
"$",
"providerKey",
")",
"{",
"return",
"new",
"PreAuthenticatedToken",
"(",
"$",
"user",
",",
"$",
"credentials",
",",
"$",
"providerKey",
",",
"$",
"user",
"->",
"getRoles",
"(",
")",
")",
";",
"}"
] | Creates an authenticated token upon authentication success.
Inherited class can override this method to provide their own pre-authenticated token implementation
@param string|UserInterface $user The user
@param mixed $credentials The user credentials
@param string $providerKey The provider key
@return PreAuthenticatedToken | [
"Creates",
"an",
"authenticated",
"token",
"upon",
"authentication",
"success",
"."
] | a7570893742286c30222c393891aeb6857064f37 | https://github.com/oasmobile/php-http/blob/a7570893742286c30222c393891aeb6857064f37/src/ServiceProviders/Security/AbstractSimplePreAuthenticator.php#L79-L82 |
32,502 | arillo/silverstripe-elements | src/VersionedGridFieldItemRequestExtension.php | VersionedGridFieldItemRequestExtension.updateFormActions | public function updateFormActions(FieldList $actions)
{
if (is_a($this->owner->getRecord(), ElementBase::class))
{
$actions->removeByName('action_doUnpublish');
if ($archive = $actions->fieldByName('action_doArchive'))
{
$archive
->setTitle(_t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Delete', 'Delete'))
->setUseButtonTag(true)
->addExtraClass('btn-outline-danger btn-hide-outline font-icon-trash-bin action-delete')
;
}
}
return $actions;
} | php | public function updateFormActions(FieldList $actions)
{
if (is_a($this->owner->getRecord(), ElementBase::class))
{
$actions->removeByName('action_doUnpublish');
if ($archive = $actions->fieldByName('action_doArchive'))
{
$archive
->setTitle(_t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Delete', 'Delete'))
->setUseButtonTag(true)
->addExtraClass('btn-outline-danger btn-hide-outline font-icon-trash-bin action-delete')
;
}
}
return $actions;
} | [
"public",
"function",
"updateFormActions",
"(",
"FieldList",
"$",
"actions",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"this",
"->",
"owner",
"->",
"getRecord",
"(",
")",
",",
"ElementBase",
"::",
"class",
")",
")",
"{",
"$",
"actions",
"->",
"removeByName",
"(",
"'action_doUnpublish'",
")",
";",
"if",
"(",
"$",
"archive",
"=",
"$",
"actions",
"->",
"fieldByName",
"(",
"'action_doArchive'",
")",
")",
"{",
"$",
"archive",
"->",
"setTitle",
"(",
"_t",
"(",
"'SilverStripe\\\\Forms\\\\GridField\\\\GridFieldDetailForm.Delete'",
",",
"'Delete'",
")",
")",
"->",
"setUseButtonTag",
"(",
"true",
")",
"->",
"addExtraClass",
"(",
"'btn-outline-danger btn-hide-outline font-icon-trash-bin action-delete'",
")",
";",
"}",
"}",
"return",
"$",
"actions",
";",
"}"
] | Remove unpublish action
@param FieldList $actions
@return FieldList | [
"Remove",
"unpublish",
"action"
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/VersionedGridFieldItemRequestExtension.php#L13-L30 |
32,503 | appaydin/pd-mailer | DependencyInjection/PdMailerExtension.php | PdMailerExtension.load | public function load(array $configs, ContainerBuilder $container)
{
// Load Configuration
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
// Set Parameters
$container->setParameter('pd_mailer.logger_active', $config['logger_active']);
$container->setParameter('pd_mailer.mail_log_class', $config['mail_log_class']);
$container->setParameter('pd_mailer.mail_template_class', $config['mail_template_class']);
$container->setParameter('pd_mailer.mail_template_type', $config['mail_template_type']);
$container->setParameter('pd_mailer.template_active', $config['template_active']);
$container->setParameter('pd_mailer.sender_address', $config['sender_address']);
$container->setParameter('pd_mailer.sender_name', $config['sender_name']);
$container->setParameter('pd_mailer.list_count', $config['list_count']);
$container->setParameter('pd_mailer.active_language', $config['active_language']);
$container->setParameter('pd_mailer.base_template', $config['base_template']);
// Load Services
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yaml');
// Replace Service Tags
$menuListener = $container->getDefinition(MainNavListener::class);
$tags = $menuListener->getTag('kernel.event_listener');
$tags[0]['event'] = $config['menu_root_name'] . '.event';
$menuListener
->setTags([
'kernel.event_listener' => $tags
])
->setArguments([$config['menu_name']]);
} | php | public function load(array $configs, ContainerBuilder $container)
{
// Load Configuration
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
// Set Parameters
$container->setParameter('pd_mailer.logger_active', $config['logger_active']);
$container->setParameter('pd_mailer.mail_log_class', $config['mail_log_class']);
$container->setParameter('pd_mailer.mail_template_class', $config['mail_template_class']);
$container->setParameter('pd_mailer.mail_template_type', $config['mail_template_type']);
$container->setParameter('pd_mailer.template_active', $config['template_active']);
$container->setParameter('pd_mailer.sender_address', $config['sender_address']);
$container->setParameter('pd_mailer.sender_name', $config['sender_name']);
$container->setParameter('pd_mailer.list_count', $config['list_count']);
$container->setParameter('pd_mailer.active_language', $config['active_language']);
$container->setParameter('pd_mailer.base_template', $config['base_template']);
// Load Services
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yaml');
// Replace Service Tags
$menuListener = $container->getDefinition(MainNavListener::class);
$tags = $menuListener->getTag('kernel.event_listener');
$tags[0]['event'] = $config['menu_root_name'] . '.event';
$menuListener
->setTags([
'kernel.event_listener' => $tags
])
->setArguments([$config['menu_name']]);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"// Load Configuration",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"configuration",
",",
"$",
"configs",
")",
";",
"// Set Parameters",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.logger_active'",
",",
"$",
"config",
"[",
"'logger_active'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.mail_log_class'",
",",
"$",
"config",
"[",
"'mail_log_class'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.mail_template_class'",
",",
"$",
"config",
"[",
"'mail_template_class'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.mail_template_type'",
",",
"$",
"config",
"[",
"'mail_template_type'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.template_active'",
",",
"$",
"config",
"[",
"'template_active'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.sender_address'",
",",
"$",
"config",
"[",
"'sender_address'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.sender_name'",
",",
"$",
"config",
"[",
"'sender_name'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.list_count'",
",",
"$",
"config",
"[",
"'list_count'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.active_language'",
",",
"$",
"config",
"[",
"'active_language'",
"]",
")",
";",
"$",
"container",
"->",
"setParameter",
"(",
"'pd_mailer.base_template'",
",",
"$",
"config",
"[",
"'base_template'",
"]",
")",
";",
"// Load Services",
"$",
"loader",
"=",
"new",
"Loader",
"\\",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"'services.yaml'",
")",
";",
"// Replace Service Tags",
"$",
"menuListener",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"MainNavListener",
"::",
"class",
")",
";",
"$",
"tags",
"=",
"$",
"menuListener",
"->",
"getTag",
"(",
"'kernel.event_listener'",
")",
";",
"$",
"tags",
"[",
"0",
"]",
"[",
"'event'",
"]",
"=",
"$",
"config",
"[",
"'menu_root_name'",
"]",
".",
"'.event'",
";",
"$",
"menuListener",
"->",
"setTags",
"(",
"[",
"'kernel.event_listener'",
"=>",
"$",
"tags",
"]",
")",
"->",
"setArguments",
"(",
"[",
"$",
"config",
"[",
"'menu_name'",
"]",
"]",
")",
";",
"}"
] | Load Bundle Config and Services.
@param array $configs
@param ContainerBuilder $container
@throws \Exception | [
"Load",
"Bundle",
"Config",
"and",
"Services",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/DependencyInjection/PdMailerExtension.php#L37-L68 |
32,504 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Base.php | Base.find | protected function find($directory)
{
if (!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) {
return false;
}
$iterator = new \RecursiveDirectoryIterator(realpath($directory));
return new \RecursiveIteratorIterator($iterator);
} | php | protected function find($directory)
{
if (!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) {
return false;
}
$iterator = new \RecursiveDirectoryIterator(realpath($directory));
return new \RecursiveIteratorIterator($iterator);
} | [
"protected",
"function",
"find",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"directory",
")",
"||",
"!",
"is_dir",
"(",
"$",
"directory",
")",
"||",
"!",
"is_readable",
"(",
"$",
"directory",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"realpath",
"(",
"$",
"directory",
")",
")",
";",
"return",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"iterator",
")",
";",
"}"
] | Lists the package contents.
@param string $directory
@return RecursiveIteratorIterator|bool | [
"Lists",
"the",
"package",
"contents",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Base.php#L84-L92 |
32,505 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Base.php | Base.package | protected function package()
{
foreach ((array) $this->plugin as $plugin) {
$this->package[] = base64_encode(gzencode(serialize((array) $plugin)));
}
} | php | protected function package()
{
foreach ((array) $this->plugin as $plugin) {
$this->package[] = base64_encode(gzencode(serialize((array) $plugin)));
}
} | [
"protected",
"function",
"package",
"(",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"plugin",
"as",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"package",
"[",
"]",
"=",
"base64_encode",
"(",
"gzencode",
"(",
"serialize",
"(",
"(",
"array",
")",
"$",
"plugin",
")",
")",
")",
";",
"}",
"}"
] | Packages the plugin data. | [
"Packages",
"the",
"plugin",
"data",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Base.php#L97-L102 |
32,506 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Base.php | Base.update | public function update()
{
foreach ((array) $this->package as $package) {
$_POST['plugin64'] = $package;
ob_start();
plugin_install();
ob_end_clean();
}
} | php | public function update()
{
foreach ((array) $this->package as $package) {
$_POST['plugin64'] = $package;
ob_start();
plugin_install();
ob_end_clean();
}
} | [
"public",
"function",
"update",
"(",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"package",
"as",
"$",
"package",
")",
"{",
"$",
"_POST",
"[",
"'plugin64'",
"]",
"=",
"$",
"package",
";",
"ob_start",
"(",
")",
";",
"plugin_install",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"}",
"}"
] | Updates a plugin. | [
"Updates",
"a",
"plugin",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Base.php#L119-L127 |
32,507 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Base.php | Base.path | protected function path($path)
{
if (strpos($path, './') === 0) {
return $this->dir . '/' . substr($path, 2);
}
if (strpos($path, '../') === 0) {
return dirname($this->dir) . '/' . substr($path, 3);
}
return $path;
} | php | protected function path($path)
{
if (strpos($path, './') === 0) {
return $this->dir . '/' . substr($path, 2);
}
if (strpos($path, '../') === 0) {
return dirname($this->dir) . '/' . substr($path, 3);
}
return $path;
} | [
"protected",
"function",
"path",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'./'",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"dir",
".",
"'/'",
".",
"substr",
"(",
"$",
"path",
",",
"2",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'../'",
")",
"===",
"0",
")",
"{",
"return",
"dirname",
"(",
"$",
"this",
"->",
"dir",
")",
".",
"'/'",
".",
"substr",
"(",
"$",
"path",
",",
"3",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Forms absolute file path.
@param string $path
@return string | [
"Forms",
"absolute",
"file",
"path",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Base.php#L152-L163 |
32,508 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Base.php | Base.getRelativePath | protected function getRelativePath($from, $to)
{
$from = explode('/', str_replace('\\', '/', $from));
$to = explode('/', str_replace('\\', '/', $to));
foreach ($from as $depth => $dir) {
if (isset($to[$depth]) && $dir === $to[$depth]) {
unset($to[$depth], $from[$depth]);
}
}
for ($i = 0; $i < count($from) - 1; $i++) {
array_unshift($to, '..');
}
return implode('/', $to);
} | php | protected function getRelativePath($from, $to)
{
$from = explode('/', str_replace('\\', '/', $from));
$to = explode('/', str_replace('\\', '/', $to));
foreach ($from as $depth => $dir) {
if (isset($to[$depth]) && $dir === $to[$depth]) {
unset($to[$depth], $from[$depth]);
}
}
for ($i = 0; $i < count($from) - 1; $i++) {
array_unshift($to, '..');
}
return implode('/', $to);
} | [
"protected",
"function",
"getRelativePath",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"$",
"from",
"=",
"explode",
"(",
"'/'",
",",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"from",
")",
")",
";",
"$",
"to",
"=",
"explode",
"(",
"'/'",
",",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"to",
")",
")",
";",
"foreach",
"(",
"$",
"from",
"as",
"$",
"depth",
"=>",
"$",
"dir",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"to",
"[",
"$",
"depth",
"]",
")",
"&&",
"$",
"dir",
"===",
"$",
"to",
"[",
"$",
"depth",
"]",
")",
"{",
"unset",
"(",
"$",
"to",
"[",
"$",
"depth",
"]",
",",
"$",
"from",
"[",
"$",
"depth",
"]",
")",
";",
"}",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"from",
")",
"-",
"1",
";",
"$",
"i",
"++",
")",
"{",
"array_unshift",
"(",
"$",
"to",
",",
"'..'",
")",
";",
"}",
"return",
"implode",
"(",
"'/'",
",",
"$",
"to",
")",
";",
"}"
] | Gets a relative path to a file.
@param string $from The path from
@param string $to The path to
@return string | [
"Gets",
"a",
"relative",
"path",
"to",
"a",
"file",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Base.php#L172-L188 |
32,509 | appaydin/pd-mailer | Controller/MailController.php | MailController.list | public function list(Request $request, PaginatorInterface $paginator)
{
// Get Query
$query = $this->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_template_class'))
->createQueryBuilder('m');
// Get Result
$pagination = $paginator->paginate(
$query,
$request->query->getInt('page', 1),
$request->query->getInt('limit', $this->getParameter('pd_mailer.list_count'))
);
// Set Back URL
$this->get('session')->set('backUrl', $request->getRequestUri());
// Render Page
return $this->render('@PdMailer/list.html.twig', [
'templates' => $pagination,
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | php | public function list(Request $request, PaginatorInterface $paginator)
{
// Get Query
$query = $this->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_template_class'))
->createQueryBuilder('m');
// Get Result
$pagination = $paginator->paginate(
$query,
$request->query->getInt('page', 1),
$request->query->getInt('limit', $this->getParameter('pd_mailer.list_count'))
);
// Set Back URL
$this->get('session')->set('backUrl', $request->getRequestUri());
// Render Page
return $this->render('@PdMailer/list.html.twig', [
'templates' => $pagination,
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | [
"public",
"function",
"list",
"(",
"Request",
"$",
"request",
",",
"PaginatorInterface",
"$",
"paginator",
")",
"{",
"// Get Query",
"$",
"query",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_template_class'",
")",
")",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
";",
"// Get Result",
"$",
"pagination",
"=",
"$",
"paginator",
"->",
"paginate",
"(",
"$",
"query",
",",
"$",
"request",
"->",
"query",
"->",
"getInt",
"(",
"'page'",
",",
"1",
")",
",",
"$",
"request",
"->",
"query",
"->",
"getInt",
"(",
"'limit'",
",",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.list_count'",
")",
")",
")",
";",
"// Set Back URL",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"set",
"(",
"'backUrl'",
",",
"$",
"request",
"->",
"getRequestUri",
"(",
")",
")",
";",
"// Render Page",
"return",
"$",
"this",
"->",
"render",
"(",
"'@PdMailer/list.html.twig'",
",",
"[",
"'templates'",
"=>",
"$",
"pagination",
",",
"'base_template'",
"=>",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.base_template'",
")",
"]",
")",
";",
"}"
] | List Mail Templates.
@param Request $request
@IsGranted("ROLE_MAIL_TEMPLATELIST")
@return \Symfony\Component\HttpFoundation\Response | [
"List",
"Mail",
"Templates",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L42-L64 |
32,510 | appaydin/pd-mailer | Controller/MailController.php | MailController.addTemplate | public function addTemplate(Request $request, ParameterBagInterface $bag, $id = null)
{
// Find Template
$mailLog = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_log_class'))
->findOneBy(['id' => $id]);
// Create New Mail Log
if (null === $mailLog) {
$class = $this->getParameter('pd_mailer.mail_log_class');
$mailLog = new $class;
}
// Create Mail Template
$class = $this->getParameter('pd_mailer.mail_template_class');
$template = new $class;
$template->setTemplateId($mailLog->getTemplateId() ?? ' ');
$template->setSubject($mailLog->getSubject());
// Create Form
$form = $this->createForm($this->getParameter('pd_mailer.mail_template_type'), $template, ['parameters' => $bag]);
// Handle Request
$form->handleRequest($request);
// Submit & Valid Form
if ($form->isSubmitted() && $form->isValid()) {
// Add object
$template->setTemplateData($mailLog->getBody());
// Save
$em = $this->getDoctrine()->getManager();
$em->persist($template);
$em->flush();
// Message
$this->addFlash('success', 'changes_saved');
// Return Edit Page
$this->redirectToRoute('admin_mail_template_edit', ['id' => $template->getId()]);
}
// Render Page
return $this->render('@PdMailer/template.html.twig', [
'form' => $form->createView(),
'objects' => @unserialize($mailLog->getBody()),
'title' => 'mail_manager_template_add',
'description' => 'mail_manager_template_add_desc',
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | php | public function addTemplate(Request $request, ParameterBagInterface $bag, $id = null)
{
// Find Template
$mailLog = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_log_class'))
->findOneBy(['id' => $id]);
// Create New Mail Log
if (null === $mailLog) {
$class = $this->getParameter('pd_mailer.mail_log_class');
$mailLog = new $class;
}
// Create Mail Template
$class = $this->getParameter('pd_mailer.mail_template_class');
$template = new $class;
$template->setTemplateId($mailLog->getTemplateId() ?? ' ');
$template->setSubject($mailLog->getSubject());
// Create Form
$form = $this->createForm($this->getParameter('pd_mailer.mail_template_type'), $template, ['parameters' => $bag]);
// Handle Request
$form->handleRequest($request);
// Submit & Valid Form
if ($form->isSubmitted() && $form->isValid()) {
// Add object
$template->setTemplateData($mailLog->getBody());
// Save
$em = $this->getDoctrine()->getManager();
$em->persist($template);
$em->flush();
// Message
$this->addFlash('success', 'changes_saved');
// Return Edit Page
$this->redirectToRoute('admin_mail_template_edit', ['id' => $template->getId()]);
}
// Render Page
return $this->render('@PdMailer/template.html.twig', [
'form' => $form->createView(),
'objects' => @unserialize($mailLog->getBody()),
'title' => 'mail_manager_template_add',
'description' => 'mail_manager_template_add_desc',
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | [
"public",
"function",
"addTemplate",
"(",
"Request",
"$",
"request",
",",
"ParameterBagInterface",
"$",
"bag",
",",
"$",
"id",
"=",
"null",
")",
"{",
"// Find Template",
"$",
"mailLog",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_log_class'",
")",
")",
"->",
"findOneBy",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
";",
"// Create New Mail Log",
"if",
"(",
"null",
"===",
"$",
"mailLog",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_log_class'",
")",
";",
"$",
"mailLog",
"=",
"new",
"$",
"class",
";",
"}",
"// Create Mail Template",
"$",
"class",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_template_class'",
")",
";",
"$",
"template",
"=",
"new",
"$",
"class",
";",
"$",
"template",
"->",
"setTemplateId",
"(",
"$",
"mailLog",
"->",
"getTemplateId",
"(",
")",
"??",
"' '",
")",
";",
"$",
"template",
"->",
"setSubject",
"(",
"$",
"mailLog",
"->",
"getSubject",
"(",
")",
")",
";",
"// Create Form",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_template_type'",
")",
",",
"$",
"template",
",",
"[",
"'parameters'",
"=>",
"$",
"bag",
"]",
")",
";",
"// Handle Request",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"// Submit & Valid Form",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"// Add object",
"$",
"template",
"->",
"setTemplateData",
"(",
"$",
"mailLog",
"->",
"getBody",
"(",
")",
")",
";",
"// Save",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"template",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"// Message",
"$",
"this",
"->",
"addFlash",
"(",
"'success'",
",",
"'changes_saved'",
")",
";",
"// Return Edit Page",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'admin_mail_template_edit'",
",",
"[",
"'id'",
"=>",
"$",
"template",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}",
"// Render Page",
"return",
"$",
"this",
"->",
"render",
"(",
"'@PdMailer/template.html.twig'",
",",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'objects'",
"=>",
"@",
"unserialize",
"(",
"$",
"mailLog",
"->",
"getBody",
"(",
")",
")",
",",
"'title'",
"=>",
"'mail_manager_template_add'",
",",
"'description'",
"=>",
"'mail_manager_template_add_desc'",
",",
"'base_template'",
"=>",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.base_template'",
")",
"]",
")",
";",
"}"
] | Add Templates.
@param Request $request
@param MailLog $mailLog
@IsGranted("ROLE_MAIL_TEMPLATEADD")
@return \Symfony\Component\HttpFoundation\Response | [
"Add",
"Templates",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L76-L127 |
32,511 | appaydin/pd-mailer | Controller/MailController.php | MailController.editTemplate | public function editTemplate(Request $request, ParameterBagInterface $bag, $id)
{
// Find Template
$mailTemplate = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_template_class'))
->findOneBy(['id' => $id]);
if (!$mailTemplate) throw $this->createNotFoundException();
// Create Form
$form = $this->createForm($this->getParameter('pd_mailer.mail_template_type'), $mailTemplate, ['parameters' => $bag]);
// Handle Request
$form->handleRequest($request);
// Submit & Valid Form
if ($form->isSubmitted() && $form->isValid()) {
// Save
$em = $this->getDoctrine()->getManager();
$em->persist($mailTemplate);
$em->flush();
// Message
$this->addFlash('success', 'changes_saved');
}
// Render Page
return $this->render('@PdMailer/template.html.twig', [
'form' => $form->createView(),
'objects' => @unserialize($mailTemplate->getTemplateData()),
'title' => 'mail_manager_template_edit',
'description' => 'mail_manager_template_edit_desc',
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | php | public function editTemplate(Request $request, ParameterBagInterface $bag, $id)
{
// Find Template
$mailTemplate = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_template_class'))
->findOneBy(['id' => $id]);
if (!$mailTemplate) throw $this->createNotFoundException();
// Create Form
$form = $this->createForm($this->getParameter('pd_mailer.mail_template_type'), $mailTemplate, ['parameters' => $bag]);
// Handle Request
$form->handleRequest($request);
// Submit & Valid Form
if ($form->isSubmitted() && $form->isValid()) {
// Save
$em = $this->getDoctrine()->getManager();
$em->persist($mailTemplate);
$em->flush();
// Message
$this->addFlash('success', 'changes_saved');
}
// Render Page
return $this->render('@PdMailer/template.html.twig', [
'form' => $form->createView(),
'objects' => @unserialize($mailTemplate->getTemplateData()),
'title' => 'mail_manager_template_edit',
'description' => 'mail_manager_template_edit_desc',
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | [
"public",
"function",
"editTemplate",
"(",
"Request",
"$",
"request",
",",
"ParameterBagInterface",
"$",
"bag",
",",
"$",
"id",
")",
"{",
"// Find Template",
"$",
"mailTemplate",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_template_class'",
")",
")",
"->",
"findOneBy",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
";",
"if",
"(",
"!",
"$",
"mailTemplate",
")",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
")",
";",
"// Create Form",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_template_type'",
")",
",",
"$",
"mailTemplate",
",",
"[",
"'parameters'",
"=>",
"$",
"bag",
"]",
")",
";",
"// Handle Request",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"// Submit & Valid Form",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
"&&",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"// Save",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"mailTemplate",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"// Message",
"$",
"this",
"->",
"addFlash",
"(",
"'success'",
",",
"'changes_saved'",
")",
";",
"}",
"// Render Page",
"return",
"$",
"this",
"->",
"render",
"(",
"'@PdMailer/template.html.twig'",
",",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'objects'",
"=>",
"@",
"unserialize",
"(",
"$",
"mailTemplate",
"->",
"getTemplateData",
"(",
")",
")",
",",
"'title'",
"=>",
"'mail_manager_template_edit'",
",",
"'description'",
"=>",
"'mail_manager_template_edit_desc'",
",",
"'base_template'",
"=>",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.base_template'",
")",
"]",
")",
";",
"}"
] | Edit Templates.
@param Request $request
@param MailTemplate $mailTemplate
@IsGranted("ROLE_MAIL_TEMPLATEEDIT")
@return \Symfony\Component\HttpFoundation\Response | [
"Edit",
"Templates",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L139-L173 |
32,512 | appaydin/pd-mailer | Controller/MailController.php | MailController.deleteTemplate | public function deleteTemplate(Request $request, $id)
{
// Find Template
$mailTemplate = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_template_class'))
->findOneBy(['id' => $id]);
// Not Found
if (null === $mailTemplate) {
$this->addFlash('error', 'sorry_not_existing');
return $this->redirectToRoute('admin_mail_list');
}
// Remove Template
$em = $this->getDoctrine()->getManager();
$em->remove($mailTemplate);
$em->flush();
// Redirect Back
return $this->redirect($request->headers->get('referer') ?? $this->generateUrl('admin_mail_list'));
} | php | public function deleteTemplate(Request $request, $id)
{
// Find Template
$mailTemplate = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_template_class'))
->findOneBy(['id' => $id]);
// Not Found
if (null === $mailTemplate) {
$this->addFlash('error', 'sorry_not_existing');
return $this->redirectToRoute('admin_mail_list');
}
// Remove Template
$em = $this->getDoctrine()->getManager();
$em->remove($mailTemplate);
$em->flush();
// Redirect Back
return $this->redirect($request->headers->get('referer') ?? $this->generateUrl('admin_mail_list'));
} | [
"public",
"function",
"deleteTemplate",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"// Find Template",
"$",
"mailTemplate",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_template_class'",
")",
")",
"->",
"findOneBy",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
";",
"// Not Found",
"if",
"(",
"null",
"===",
"$",
"mailTemplate",
")",
"{",
"$",
"this",
"->",
"addFlash",
"(",
"'error'",
",",
"'sorry_not_existing'",
")",
";",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'admin_mail_list'",
")",
";",
"}",
"// Remove Template",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"remove",
"(",
"$",
"mailTemplate",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"// Redirect Back",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'referer'",
")",
"??",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_mail_list'",
")",
")",
";",
"}"
] | Delete Templates.
@param Request $request
@param MailTemplate $mailTemplate
@IsGranted("ROLE_MAIL_TEMPLATEDELETE")
@return \Symfony\Component\HttpFoundation\Response | [
"Delete",
"Templates",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L185-L207 |
32,513 | appaydin/pd-mailer | Controller/MailController.php | MailController.logger | public function logger(Request $request, PaginatorInterface $paginator)
{
// Get Logs
$query = $this->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_log_class'))
->createQueryBuilder('m')
->orderBy('m.id', 'DESC')
->getQuery();
// Get Result
$mailLog = $paginator->paginate(
$query,
$request->query->getInt('page', 1),
$request->query->getInt('limit', $this->getParameter('pd_mailer.list_count'))
);
// Render Page
return $this->render('@PdMailer/logger.html.twig', [
'maillogs' => $mailLog,
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | php | public function logger(Request $request, PaginatorInterface $paginator)
{
// Get Logs
$query = $this->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_log_class'))
->createQueryBuilder('m')
->orderBy('m.id', 'DESC')
->getQuery();
// Get Result
$mailLog = $paginator->paginate(
$query,
$request->query->getInt('page', 1),
$request->query->getInt('limit', $this->getParameter('pd_mailer.list_count'))
);
// Render Page
return $this->render('@PdMailer/logger.html.twig', [
'maillogs' => $mailLog,
'base_template' => $this->getParameter('pd_mailer.base_template')
]);
} | [
"public",
"function",
"logger",
"(",
"Request",
"$",
"request",
",",
"PaginatorInterface",
"$",
"paginator",
")",
"{",
"// Get Logs",
"$",
"query",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_log_class'",
")",
")",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
"->",
"orderBy",
"(",
"'m.id'",
",",
"'DESC'",
")",
"->",
"getQuery",
"(",
")",
";",
"// Get Result",
"$",
"mailLog",
"=",
"$",
"paginator",
"->",
"paginate",
"(",
"$",
"query",
",",
"$",
"request",
"->",
"query",
"->",
"getInt",
"(",
"'page'",
",",
"1",
")",
",",
"$",
"request",
"->",
"query",
"->",
"getInt",
"(",
"'limit'",
",",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.list_count'",
")",
")",
")",
";",
"// Render Page",
"return",
"$",
"this",
"->",
"render",
"(",
"'@PdMailer/logger.html.twig'",
",",
"[",
"'maillogs'",
"=>",
"$",
"mailLog",
",",
"'base_template'",
"=>",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.base_template'",
")",
"]",
")",
";",
"}"
] | View Mail Logs.
@param Request $request
@IsGranted("ROLE_MAIL_LOGGER")
@return \Symfony\Component\HttpFoundation\Response | [
"View",
"Mail",
"Logs",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L252-L273 |
32,514 | appaydin/pd-mailer | Controller/MailController.php | MailController.viewLog | public function viewLog(TranslatorInterface $translator, $id)
{
// Find Template
$log = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_log_class'))
->findOneBy(['id' => $id]);
if (!$log) throw $this->createNotFoundException();
$data = [
$translator->trans('mail_templateid') => $log->getTemplateId(),
$translator->trans('mail_mid') => $log->getMailId(),
$translator->trans('mail_to') => implode(PHP_EOL, $this->implodeKeyValue($log->getTo(), ' -> ')),
$translator->trans('mail_from') => implode(PHP_EOL, $this->implodeKeyValue($log->getFrom(), ' -> ')),
$translator->trans('mail_subject') => $log->getSubject(),
$translator->trans('mail_language') => $log->getLanguage(),
$translator->trans('mail_content_type') => $log->getContentType(),
$translator->trans('date') => date('Y-m-d H:i:s', $log->getDate()->getTimestamp()),
$translator->trans('mail_reply_to') => $log->getReplyTo(),
$translator->trans('mail_header') => '<code>' . str_replace(PHP_EOL, '<br/>', htmlspecialchars($log->getHeader())) . '</code>',
$translator->trans('mail_status') => $log->getStatus() . ' = ' . $this->swiftEventFilter($translator, $log->getStatus()),
$translator->trans('mail_exception') => str_replace(PHP_EOL, '<br/>', htmlspecialchars($log->getException())),
];
// JSON Response
return $this->json($data);
} | php | public function viewLog(TranslatorInterface $translator, $id)
{
// Find Template
$log = $this
->getDoctrine()
->getRepository($this->getParameter('pd_mailer.mail_log_class'))
->findOneBy(['id' => $id]);
if (!$log) throw $this->createNotFoundException();
$data = [
$translator->trans('mail_templateid') => $log->getTemplateId(),
$translator->trans('mail_mid') => $log->getMailId(),
$translator->trans('mail_to') => implode(PHP_EOL, $this->implodeKeyValue($log->getTo(), ' -> ')),
$translator->trans('mail_from') => implode(PHP_EOL, $this->implodeKeyValue($log->getFrom(), ' -> ')),
$translator->trans('mail_subject') => $log->getSubject(),
$translator->trans('mail_language') => $log->getLanguage(),
$translator->trans('mail_content_type') => $log->getContentType(),
$translator->trans('date') => date('Y-m-d H:i:s', $log->getDate()->getTimestamp()),
$translator->trans('mail_reply_to') => $log->getReplyTo(),
$translator->trans('mail_header') => '<code>' . str_replace(PHP_EOL, '<br/>', htmlspecialchars($log->getHeader())) . '</code>',
$translator->trans('mail_status') => $log->getStatus() . ' = ' . $this->swiftEventFilter($translator, $log->getStatus()),
$translator->trans('mail_exception') => str_replace(PHP_EOL, '<br/>', htmlspecialchars($log->getException())),
];
// JSON Response
return $this->json($data);
} | [
"public",
"function",
"viewLog",
"(",
"TranslatorInterface",
"$",
"translator",
",",
"$",
"id",
")",
"{",
"// Find Template",
"$",
"log",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_log_class'",
")",
")",
"->",
"findOneBy",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
";",
"if",
"(",
"!",
"$",
"log",
")",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
")",
";",
"$",
"data",
"=",
"[",
"$",
"translator",
"->",
"trans",
"(",
"'mail_templateid'",
")",
"=>",
"$",
"log",
"->",
"getTemplateId",
"(",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_mid'",
")",
"=>",
"$",
"log",
"->",
"getMailId",
"(",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_to'",
")",
"=>",
"implode",
"(",
"PHP_EOL",
",",
"$",
"this",
"->",
"implodeKeyValue",
"(",
"$",
"log",
"->",
"getTo",
"(",
")",
",",
"' -> '",
")",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_from'",
")",
"=>",
"implode",
"(",
"PHP_EOL",
",",
"$",
"this",
"->",
"implodeKeyValue",
"(",
"$",
"log",
"->",
"getFrom",
"(",
")",
",",
"' -> '",
")",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_subject'",
")",
"=>",
"$",
"log",
"->",
"getSubject",
"(",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_language'",
")",
"=>",
"$",
"log",
"->",
"getLanguage",
"(",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_content_type'",
")",
"=>",
"$",
"log",
"->",
"getContentType",
"(",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'date'",
")",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"log",
"->",
"getDate",
"(",
")",
"->",
"getTimestamp",
"(",
")",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_reply_to'",
")",
"=>",
"$",
"log",
"->",
"getReplyTo",
"(",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_header'",
")",
"=>",
"'<code>'",
".",
"str_replace",
"(",
"PHP_EOL",
",",
"'<br/>'",
",",
"htmlspecialchars",
"(",
"$",
"log",
"->",
"getHeader",
"(",
")",
")",
")",
".",
"'</code>'",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_status'",
")",
"=>",
"$",
"log",
"->",
"getStatus",
"(",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"swiftEventFilter",
"(",
"$",
"translator",
",",
"$",
"log",
"->",
"getStatus",
"(",
")",
")",
",",
"$",
"translator",
"->",
"trans",
"(",
"'mail_exception'",
")",
"=>",
"str_replace",
"(",
"PHP_EOL",
",",
"'<br/>'",
",",
"htmlspecialchars",
"(",
"$",
"log",
"->",
"getException",
"(",
")",
")",
")",
",",
"]",
";",
"// JSON Response",
"return",
"$",
"this",
"->",
"json",
"(",
"$",
"data",
")",
";",
"}"
] | View Log.
@param MailLog $log
@IsGranted("ROLE_MAIL_VIEWLOG")
@return \Symfony\Component\HttpFoundation\Response | [
"View",
"Log",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L284-L310 |
32,515 | appaydin/pd-mailer | Controller/MailController.php | MailController.deleteLog | public function deleteLog(Request $request, $mailLog)
{
// Not Found
if (null === $mailLog && !$request->request->has('id')) {
$this->addFlash('error', 'sorry_not_existing');
return $this->redirectToRoute('admin_mail_logger');
}
// Convert Array
$mailLog = $request->request->has('id') ? $request->request->get('id') : [$mailLog];
// Remove Mail Log
if ($mailLog) {
$em = $this->getDoctrine()->getManager();
$em->createQueryBuilder('')
->delete($this->getParameter('pd_mailer.mail_log_class'), 'log')
->add('where', $em->getExpressionBuilder()->in('log.id', ':logId'))
->setParameter(':logId', $mailLog)
->getQuery()
->execute();
}
// Redirect Back
return $this->redirect($request->headers->get('referer') ?? $this->generateUrl('admin_mail_logger'));
} | php | public function deleteLog(Request $request, $mailLog)
{
// Not Found
if (null === $mailLog && !$request->request->has('id')) {
$this->addFlash('error', 'sorry_not_existing');
return $this->redirectToRoute('admin_mail_logger');
}
// Convert Array
$mailLog = $request->request->has('id') ? $request->request->get('id') : [$mailLog];
// Remove Mail Log
if ($mailLog) {
$em = $this->getDoctrine()->getManager();
$em->createQueryBuilder('')
->delete($this->getParameter('pd_mailer.mail_log_class'), 'log')
->add('where', $em->getExpressionBuilder()->in('log.id', ':logId'))
->setParameter(':logId', $mailLog)
->getQuery()
->execute();
}
// Redirect Back
return $this->redirect($request->headers->get('referer') ?? $this->generateUrl('admin_mail_logger'));
} | [
"public",
"function",
"deleteLog",
"(",
"Request",
"$",
"request",
",",
"$",
"mailLog",
")",
"{",
"// Not Found",
"if",
"(",
"null",
"===",
"$",
"mailLog",
"&&",
"!",
"$",
"request",
"->",
"request",
"->",
"has",
"(",
"'id'",
")",
")",
"{",
"$",
"this",
"->",
"addFlash",
"(",
"'error'",
",",
"'sorry_not_existing'",
")",
";",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'admin_mail_logger'",
")",
";",
"}",
"// Convert Array",
"$",
"mailLog",
"=",
"$",
"request",
"->",
"request",
"->",
"has",
"(",
"'id'",
")",
"?",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'id'",
")",
":",
"[",
"$",
"mailLog",
"]",
";",
"// Remove Mail Log",
"if",
"(",
"$",
"mailLog",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"createQueryBuilder",
"(",
"''",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'pd_mailer.mail_log_class'",
")",
",",
"'log'",
")",
"->",
"add",
"(",
"'where'",
",",
"$",
"em",
"->",
"getExpressionBuilder",
"(",
")",
"->",
"in",
"(",
"'log.id'",
",",
"':logId'",
")",
")",
"->",
"setParameter",
"(",
"':logId'",
",",
"$",
"mailLog",
")",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}",
"// Redirect Back",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'referer'",
")",
"??",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_mail_logger'",
")",
")",
";",
"}"
] | Delete Logs.
@param Request $request
@param $mailLog
@IsGranted("ROLE_MAIL_LOGDELETE")
@return \Symfony\Component\HttpFoundation\Response | [
"Delete",
"Logs",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L322-L347 |
32,516 | appaydin/pd-mailer | Controller/MailController.php | MailController.swiftEventFilter | private function swiftEventFilter(TranslatorInterface $translator, $event): string
{
switch ($event) {
case \Swift_Events_SendEvent::RESULT_SUCCESS:
return $translator->trans('RESULT_SUCCESS');
case \Swift_Events_SendEvent::RESULT_FAILED:
return $translator->trans('RESULT_FAILED');
case \Swift_Events_SendEvent::RESULT_SPOOLED:
return $translator->trans('RESULT_SPOOLED');
case \Swift_Events_SendEvent::RESULT_PENDING:
return $translator->trans('RESULT_PENDING');
case \Swift_Events_SendEvent::RESULT_TENTATIVE:
return $translator->trans('RESULT_TENTATIVE');
case -1:
return $translator->trans('RESULT_DELETED');
}
return '';
} | php | private function swiftEventFilter(TranslatorInterface $translator, $event): string
{
switch ($event) {
case \Swift_Events_SendEvent::RESULT_SUCCESS:
return $translator->trans('RESULT_SUCCESS');
case \Swift_Events_SendEvent::RESULT_FAILED:
return $translator->trans('RESULT_FAILED');
case \Swift_Events_SendEvent::RESULT_SPOOLED:
return $translator->trans('RESULT_SPOOLED');
case \Swift_Events_SendEvent::RESULT_PENDING:
return $translator->trans('RESULT_PENDING');
case \Swift_Events_SendEvent::RESULT_TENTATIVE:
return $translator->trans('RESULT_TENTATIVE');
case -1:
return $translator->trans('RESULT_DELETED');
}
return '';
} | [
"private",
"function",
"swiftEventFilter",
"(",
"TranslatorInterface",
"$",
"translator",
",",
"$",
"event",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"event",
")",
"{",
"case",
"\\",
"Swift_Events_SendEvent",
"::",
"RESULT_SUCCESS",
":",
"return",
"$",
"translator",
"->",
"trans",
"(",
"'RESULT_SUCCESS'",
")",
";",
"case",
"\\",
"Swift_Events_SendEvent",
"::",
"RESULT_FAILED",
":",
"return",
"$",
"translator",
"->",
"trans",
"(",
"'RESULT_FAILED'",
")",
";",
"case",
"\\",
"Swift_Events_SendEvent",
"::",
"RESULT_SPOOLED",
":",
"return",
"$",
"translator",
"->",
"trans",
"(",
"'RESULT_SPOOLED'",
")",
";",
"case",
"\\",
"Swift_Events_SendEvent",
"::",
"RESULT_PENDING",
":",
"return",
"$",
"translator",
"->",
"trans",
"(",
"'RESULT_PENDING'",
")",
";",
"case",
"\\",
"Swift_Events_SendEvent",
"::",
"RESULT_TENTATIVE",
":",
"return",
"$",
"translator",
"->",
"trans",
"(",
"'RESULT_TENTATIVE'",
")",
";",
"case",
"-",
"1",
":",
"return",
"$",
"translator",
"->",
"trans",
"(",
"'RESULT_DELETED'",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Swift Event.
@param $event
@return string | [
"Swift",
"Event",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Controller/MailController.php#L376-L394 |
32,517 | arillo/silverstripe-elements | src/ElementBase.php | ElementBase.generateElementSortForHolder | public function generateElementSortForHolder()
{
if (!$this->Sort)
{
$holderFilter = ['PageID' => $this->PageID];
if ($this->ElementID) $holderFilter = ['ElementID' => $this->ElementID];
$this->Sort = self::get()
->filter($holderFilter)
->max('Sort') + 1
;
}
return $this;
} | php | public function generateElementSortForHolder()
{
if (!$this->Sort)
{
$holderFilter = ['PageID' => $this->PageID];
if ($this->ElementID) $holderFilter = ['ElementID' => $this->ElementID];
$this->Sort = self::get()
->filter($holderFilter)
->max('Sort') + 1
;
}
return $this;
} | [
"public",
"function",
"generateElementSortForHolder",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"Sort",
")",
"{",
"$",
"holderFilter",
"=",
"[",
"'PageID'",
"=>",
"$",
"this",
"->",
"PageID",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"ElementID",
")",
"$",
"holderFilter",
"=",
"[",
"'ElementID'",
"=>",
"$",
"this",
"->",
"ElementID",
"]",
";",
"$",
"this",
"->",
"Sort",
"=",
"self",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"$",
"holderFilter",
")",
"->",
"max",
"(",
"'Sort'",
")",
"+",
"1",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Generate next Sort value on element creation.
@return ElementBase | [
"Generate",
"next",
"Sort",
"value",
"on",
"element",
"creation",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementBase.php#L129-L142 |
32,518 | arillo/silverstripe-elements | src/ElementBase.php | ElementBase.getCMSTypeInfo | public function getCMSTypeInfo()
{
$data = ArrayData::create([
'Icon' => $this->config()->icon,
'Type' => $this->getType(),
]);
// Add versioned states (rendered as a circle over the icon)
if ($this->hasExtension(Versioned::class)) {
$data->IsVersioned = true;
if ($this->isOnDraftOnly()) {
$data->VersionState = 'draft';
$data->VersionStateTitle = _t(
'SilverStripe\\Versioned\\VersionedGridFieldState\\VersionedGridFieldState.ADDEDTODRAFTHELP',
'Item has not been published yet'
);
} elseif ($this->isModifiedOnDraft()) {
$data->VersionState = 'modified';
$data->VersionStateTitle = $data->VersionStateTitle = _t(
'SilverStripe\\Versioned\\VersionedGridFieldState\\VersionedGridFieldState.MODIFIEDONDRAFTHELP',
'Item has unpublished changes'
);
}
}
return $data->renderWith('Arillo\\Elements\\TypeInfo');
} | php | public function getCMSTypeInfo()
{
$data = ArrayData::create([
'Icon' => $this->config()->icon,
'Type' => $this->getType(),
]);
// Add versioned states (rendered as a circle over the icon)
if ($this->hasExtension(Versioned::class)) {
$data->IsVersioned = true;
if ($this->isOnDraftOnly()) {
$data->VersionState = 'draft';
$data->VersionStateTitle = _t(
'SilverStripe\\Versioned\\VersionedGridFieldState\\VersionedGridFieldState.ADDEDTODRAFTHELP',
'Item has not been published yet'
);
} elseif ($this->isModifiedOnDraft()) {
$data->VersionState = 'modified';
$data->VersionStateTitle = $data->VersionStateTitle = _t(
'SilverStripe\\Versioned\\VersionedGridFieldState\\VersionedGridFieldState.MODIFIEDONDRAFTHELP',
'Item has unpublished changes'
);
}
}
return $data->renderWith('Arillo\\Elements\\TypeInfo');
} | [
"public",
"function",
"getCMSTypeInfo",
"(",
")",
"{",
"$",
"data",
"=",
"ArrayData",
"::",
"create",
"(",
"[",
"'Icon'",
"=>",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"icon",
",",
"'Type'",
"=>",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"]",
")",
";",
"// Add versioned states (rendered as a circle over the icon)",
"if",
"(",
"$",
"this",
"->",
"hasExtension",
"(",
"Versioned",
"::",
"class",
")",
")",
"{",
"$",
"data",
"->",
"IsVersioned",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"isOnDraftOnly",
"(",
")",
")",
"{",
"$",
"data",
"->",
"VersionState",
"=",
"'draft'",
";",
"$",
"data",
"->",
"VersionStateTitle",
"=",
"_t",
"(",
"'SilverStripe\\\\Versioned\\\\VersionedGridFieldState\\\\VersionedGridFieldState.ADDEDTODRAFTHELP'",
",",
"'Item has not been published yet'",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isModifiedOnDraft",
"(",
")",
")",
"{",
"$",
"data",
"->",
"VersionState",
"=",
"'modified'",
";",
"$",
"data",
"->",
"VersionStateTitle",
"=",
"$",
"data",
"->",
"VersionStateTitle",
"=",
"_t",
"(",
"'SilverStripe\\\\Versioned\\\\VersionedGridFieldState\\\\VersionedGridFieldState.MODIFIEDONDRAFTHELP'",
",",
"'Item has unpublished changes'",
")",
";",
"}",
"}",
"return",
"$",
"data",
"->",
"renderWith",
"(",
"'Arillo\\\\Elements\\\\TypeInfo'",
")",
";",
"}"
] | Type info for GridField usage.
@return string | [
"Type",
"info",
"for",
"GridField",
"usage",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementBase.php#L207-L233 |
32,519 | arillo/silverstripe-elements | src/ElementBase.php | ElementBase.getHolderPage | public function getHolderPage()
{
if (!$this->PageID && !$this->ElementID) return null;
$holder = $this->getHolder();
while (
$holder
&& $holder->exists()
&& !is_a($holder, SiteTree::class)
) {
$holder = $holder->getHolder();
}
return $holder;
} | php | public function getHolderPage()
{
if (!$this->PageID && !$this->ElementID) return null;
$holder = $this->getHolder();
while (
$holder
&& $holder->exists()
&& !is_a($holder, SiteTree::class)
) {
$holder = $holder->getHolder();
}
return $holder;
} | [
"public",
"function",
"getHolderPage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"PageID",
"&&",
"!",
"$",
"this",
"->",
"ElementID",
")",
"return",
"null",
";",
"$",
"holder",
"=",
"$",
"this",
"->",
"getHolder",
"(",
")",
";",
"while",
"(",
"$",
"holder",
"&&",
"$",
"holder",
"->",
"exists",
"(",
")",
"&&",
"!",
"is_a",
"(",
"$",
"holder",
",",
"SiteTree",
"::",
"class",
")",
")",
"{",
"$",
"holder",
"=",
"$",
"holder",
"->",
"getHolder",
"(",
")",
";",
"}",
"return",
"$",
"holder",
";",
"}"
] | Recursive look up for holder page. | [
"Recursive",
"look",
"up",
"for",
"holder",
"page",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementBase.php#L327-L341 |
32,520 | arillo/silverstripe-elements | src/ElementBase.php | ElementBase.Render | public function Render(
$IsPos = null,
$IsFirst = null,
$IsLast = null,
$IsEvenOdd = null
) {
$this->IsPos = $IsPos;
$this->IsFirst = $IsFirst;
$this->IsLast = $IsLast;
$this->IsEvenOdd = $IsEvenOdd;
$controller = Controller::curr();
return $controller
->customise($this)
->renderWith($this->ClassName)
;
} | php | public function Render(
$IsPos = null,
$IsFirst = null,
$IsLast = null,
$IsEvenOdd = null
) {
$this->IsPos = $IsPos;
$this->IsFirst = $IsFirst;
$this->IsLast = $IsLast;
$this->IsEvenOdd = $IsEvenOdd;
$controller = Controller::curr();
return $controller
->customise($this)
->renderWith($this->ClassName)
;
} | [
"public",
"function",
"Render",
"(",
"$",
"IsPos",
"=",
"null",
",",
"$",
"IsFirst",
"=",
"null",
",",
"$",
"IsLast",
"=",
"null",
",",
"$",
"IsEvenOdd",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"IsPos",
"=",
"$",
"IsPos",
";",
"$",
"this",
"->",
"IsFirst",
"=",
"$",
"IsFirst",
";",
"$",
"this",
"->",
"IsLast",
"=",
"$",
"IsLast",
";",
"$",
"this",
"->",
"IsEvenOdd",
"=",
"$",
"IsEvenOdd",
";",
"$",
"controller",
"=",
"Controller",
"::",
"curr",
"(",
")",
";",
"return",
"$",
"controller",
"->",
"customise",
"(",
"$",
"this",
")",
"->",
"renderWith",
"(",
"$",
"this",
"->",
"ClassName",
")",
";",
"}"
] | Render for template useage.
@param int $IsPos
@param bool $IsFirst
@param bool $IsLast
@param bool $IsEvenOdd | [
"Render",
"for",
"template",
"useage",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementBase.php#L463-L478 |
32,521 | arillo/silverstripe-elements | src/ElementBase.php | ElementBase.publishPage | public function publishPage()
{
$look = true;
$parent = $this;
while($look)
{
if ($parent = $parent->getHolder())
{
if (is_a($parent, SiteTree::class))
{
$look = false;
}
} else {
$look = false;
}
}
if ($parent->doPublish())
{
return _t(__CLASS__ . '.PageAndElementsPublished', 'Page & elements published');
}
return _t(__CLASS__ . '.PageAndElementsPublishError', 'There was an error publishing the page');
} | php | public function publishPage()
{
$look = true;
$parent = $this;
while($look)
{
if ($parent = $parent->getHolder())
{
if (is_a($parent, SiteTree::class))
{
$look = false;
}
} else {
$look = false;
}
}
if ($parent->doPublish())
{
return _t(__CLASS__ . '.PageAndElementsPublished', 'Page & elements published');
}
return _t(__CLASS__ . '.PageAndElementsPublishError', 'There was an error publishing the page');
} | [
"public",
"function",
"publishPage",
"(",
")",
"{",
"$",
"look",
"=",
"true",
";",
"$",
"parent",
"=",
"$",
"this",
";",
"while",
"(",
"$",
"look",
")",
"{",
"if",
"(",
"$",
"parent",
"=",
"$",
"parent",
"->",
"getHolder",
"(",
")",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"parent",
",",
"SiteTree",
"::",
"class",
")",
")",
"{",
"$",
"look",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"look",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"parent",
"->",
"doPublish",
"(",
")",
")",
"{",
"return",
"_t",
"(",
"__CLASS__",
".",
"'.PageAndElementsPublished'",
",",
"'Page & elements published'",
")",
";",
"}",
"return",
"_t",
"(",
"__CLASS__",
".",
"'.PageAndElementsPublishError'",
",",
"'There was an error publishing the page'",
")",
";",
"}"
] | Publish holder page, trigger publish all sub elements. | [
"Publish",
"holder",
"page",
"trigger",
"publish",
"all",
"sub",
"elements",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementBase.php#L483-L505 |
32,522 | arillo/silverstripe-elements | src/ElementBase.php | ElementBase.deleteLocalisedRecords | public function deleteLocalisedRecords()
{
if ($this->hasExtension(self::FLUENT_CLASS))
{
$localisedTables = $this->getLocalisedTables();
$tableClasses = ClassInfo::ancestry($this->owner, true);
foreach ($tableClasses as $class)
{
$table = DataObject::getSchema()->tableName($class);
$rootTable = $this->getLocalisedTable($table);
$rootDelete = SQLDelete::create("\"{$rootTable}\"")
->addWhere(["\"{$rootTable}\".\"ID\"" => $this->ID]);
// If table isn't localised, simple delete
if (!isset($localisedTables[$table]))
{
$baseTable = $this->getLocalisedTable($this->baseTable());
// The base table isn't localised? Delete the record then.
if ($baseTable === $rootTable)
{
$rootDelete->execute();
continue;
}
$rootDelete
->setDelete("\"{$rootTable}\"")
->addLeftJoin(
$baseTable,
"\"{$rootTable}\".\"ID\" = \"{$baseTable}\".\"ID\""
)
// Only when join matches no localisations is it safe to delete
->addWhere("\"{$baseTable}\".\"ID\" IS NULL")
->execute();
continue;
}
$localisedTable = $this->getLocalisedTable($table);
$localisedDelete = SQLDelete::create(
"\"{$localisedTable}\"",
[
'"RecordID"' => $this->ID,
]
);
$localisedDelete->execute();
}
}
return $this;
} | php | public function deleteLocalisedRecords()
{
if ($this->hasExtension(self::FLUENT_CLASS))
{
$localisedTables = $this->getLocalisedTables();
$tableClasses = ClassInfo::ancestry($this->owner, true);
foreach ($tableClasses as $class)
{
$table = DataObject::getSchema()->tableName($class);
$rootTable = $this->getLocalisedTable($table);
$rootDelete = SQLDelete::create("\"{$rootTable}\"")
->addWhere(["\"{$rootTable}\".\"ID\"" => $this->ID]);
// If table isn't localised, simple delete
if (!isset($localisedTables[$table]))
{
$baseTable = $this->getLocalisedTable($this->baseTable());
// The base table isn't localised? Delete the record then.
if ($baseTable === $rootTable)
{
$rootDelete->execute();
continue;
}
$rootDelete
->setDelete("\"{$rootTable}\"")
->addLeftJoin(
$baseTable,
"\"{$rootTable}\".\"ID\" = \"{$baseTable}\".\"ID\""
)
// Only when join matches no localisations is it safe to delete
->addWhere("\"{$baseTable}\".\"ID\" IS NULL")
->execute();
continue;
}
$localisedTable = $this->getLocalisedTable($table);
$localisedDelete = SQLDelete::create(
"\"{$localisedTable}\"",
[
'"RecordID"' => $this->ID,
]
);
$localisedDelete->execute();
}
}
return $this;
} | [
"public",
"function",
"deleteLocalisedRecords",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasExtension",
"(",
"self",
"::",
"FLUENT_CLASS",
")",
")",
"{",
"$",
"localisedTables",
"=",
"$",
"this",
"->",
"getLocalisedTables",
"(",
")",
";",
"$",
"tableClasses",
"=",
"ClassInfo",
"::",
"ancestry",
"(",
"$",
"this",
"->",
"owner",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"tableClasses",
"as",
"$",
"class",
")",
"{",
"$",
"table",
"=",
"DataObject",
"::",
"getSchema",
"(",
")",
"->",
"tableName",
"(",
"$",
"class",
")",
";",
"$",
"rootTable",
"=",
"$",
"this",
"->",
"getLocalisedTable",
"(",
"$",
"table",
")",
";",
"$",
"rootDelete",
"=",
"SQLDelete",
"::",
"create",
"(",
"\"\\\"{$rootTable}\\\"\"",
")",
"->",
"addWhere",
"(",
"[",
"\"\\\"{$rootTable}\\\".\\\"ID\\\"\"",
"=>",
"$",
"this",
"->",
"ID",
"]",
")",
";",
"// If table isn't localised, simple delete",
"if",
"(",
"!",
"isset",
"(",
"$",
"localisedTables",
"[",
"$",
"table",
"]",
")",
")",
"{",
"$",
"baseTable",
"=",
"$",
"this",
"->",
"getLocalisedTable",
"(",
"$",
"this",
"->",
"baseTable",
"(",
")",
")",
";",
"// The base table isn't localised? Delete the record then.",
"if",
"(",
"$",
"baseTable",
"===",
"$",
"rootTable",
")",
"{",
"$",
"rootDelete",
"->",
"execute",
"(",
")",
";",
"continue",
";",
"}",
"$",
"rootDelete",
"->",
"setDelete",
"(",
"\"\\\"{$rootTable}\\\"\"",
")",
"->",
"addLeftJoin",
"(",
"$",
"baseTable",
",",
"\"\\\"{$rootTable}\\\".\\\"ID\\\" = \\\"{$baseTable}\\\".\\\"ID\\\"\"",
")",
"// Only when join matches no localisations is it safe to delete",
"->",
"addWhere",
"(",
"\"\\\"{$baseTable}\\\".\\\"ID\\\" IS NULL\"",
")",
"->",
"execute",
"(",
")",
";",
"continue",
";",
"}",
"$",
"localisedTable",
"=",
"$",
"this",
"->",
"getLocalisedTable",
"(",
"$",
"table",
")",
";",
"$",
"localisedDelete",
"=",
"SQLDelete",
"::",
"create",
"(",
"\"\\\"{$localisedTable}\\\"\"",
",",
"[",
"'\"RecordID\"'",
"=>",
"$",
"this",
"->",
"ID",
",",
"]",
")",
";",
"$",
"localisedDelete",
"->",
"execute",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Execute record deletion, even when localised records in non-current locale exist.
@return ElementBase | [
"Execute",
"record",
"deletion",
"even",
"when",
"localised",
"records",
"in",
"non",
"-",
"current",
"locale",
"exist",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementBase.php#L533-L585 |
32,523 | appaydin/pd-mailer | Menu/MailerMenu.php | MailerMenu.createMenu | public function createMenu(array $options = []): ItemInterface
{
// Create Root
$menu = $this->createRoot('mail_manager')->setChildAttr([
'class' => 'nav nav-pills',
'data-parent' => 'admin_mail_list',
]);
// Create Menu Items
$menu
->addChild('nav_mail_template')
->setLabel('nav_mail_template')
->setRoute('admin_mail_list')
->setRoles(['ROLE_MAIL_TEMPLATELIST'])
// Logger
->addChildParent('nav_mail_logger')
->setLabel('nav_mail_logger')
->setRoute('admin_mail_logger')
->setRoles(['ROLE_MAIL_LOGGER']);
return $menu;
} | php | public function createMenu(array $options = []): ItemInterface
{
// Create Root
$menu = $this->createRoot('mail_manager')->setChildAttr([
'class' => 'nav nav-pills',
'data-parent' => 'admin_mail_list',
]);
// Create Menu Items
$menu
->addChild('nav_mail_template')
->setLabel('nav_mail_template')
->setRoute('admin_mail_list')
->setRoles(['ROLE_MAIL_TEMPLATELIST'])
// Logger
->addChildParent('nav_mail_logger')
->setLabel('nav_mail_logger')
->setRoute('admin_mail_logger')
->setRoles(['ROLE_MAIL_LOGGER']);
return $menu;
} | [
"public",
"function",
"createMenu",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"ItemInterface",
"{",
"// Create Root",
"$",
"menu",
"=",
"$",
"this",
"->",
"createRoot",
"(",
"'mail_manager'",
")",
"->",
"setChildAttr",
"(",
"[",
"'class'",
"=>",
"'nav nav-pills'",
",",
"'data-parent'",
"=>",
"'admin_mail_list'",
",",
"]",
")",
";",
"// Create Menu Items",
"$",
"menu",
"->",
"addChild",
"(",
"'nav_mail_template'",
")",
"->",
"setLabel",
"(",
"'nav_mail_template'",
")",
"->",
"setRoute",
"(",
"'admin_mail_list'",
")",
"->",
"setRoles",
"(",
"[",
"'ROLE_MAIL_TEMPLATELIST'",
"]",
")",
"// Logger",
"->",
"addChildParent",
"(",
"'nav_mail_logger'",
")",
"->",
"setLabel",
"(",
"'nav_mail_logger'",
")",
"->",
"setRoute",
"(",
"'admin_mail_logger'",
")",
"->",
"setRoles",
"(",
"[",
"'ROLE_MAIL_LOGGER'",
"]",
")",
";",
"return",
"$",
"menu",
";",
"}"
] | Mail Manager Custom Menus.
@param array $options
@return ItemInterface | [
"Mail",
"Manager",
"Custom",
"Menus",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Menu/MailerMenu.php#L33-L54 |
32,524 | davidecesarano/Embryo-Http | Embryo/Http/Factory/UriFactory.php | UriFactory.createUriFromServer | public function createUriFromServer(array $server): UriInterface
{
// scheme, host, post, user, pass
$scheme = (empty($server['HTTPS']) || $server['HTTPS'] === 'off') ? 'http' : 'https';
$host = (isset($server['HTTP_HOST'])) ? $server['HTTP_HOST'] : $server['SERVER_NAME'];
$port = (isset($server['SERVER_PORT'])) ? (int) $server['SERVER_PORT'] : 80;
$user = (isset($server['PHP_AUTH_USER'])) ? $server['PHP_AUTH_USER'] : '';
$pass = (isset($server['PHP_AUTH_PW'])) ? $server['PHP_AUTH_PW'] : '';
// path
$path = parse_url('http://example.com' . $server['REQUEST_URI'], PHP_URL_PATH);
$path = rawurldecode($path);
// query
$query = (isset($server['QUERY_STRING'])) ? $server['QUERY_STRING'] : '';
// fragment (not available in $_SERVER)
$fragment = '';
$uri = new Uri('');
$uri = $uri->withScheme($scheme);
$uri = $uri->withHost($host);
$uri = $uri->withPort($port);
$uri = $uri->withUserInfo($user, $pass);
$uri = $uri->withPath($path);
$uri = $uri->withQuery($query);
$uri = $uri->withFragment($fragment);
return $uri;
} | php | public function createUriFromServer(array $server): UriInterface
{
// scheme, host, post, user, pass
$scheme = (empty($server['HTTPS']) || $server['HTTPS'] === 'off') ? 'http' : 'https';
$host = (isset($server['HTTP_HOST'])) ? $server['HTTP_HOST'] : $server['SERVER_NAME'];
$port = (isset($server['SERVER_PORT'])) ? (int) $server['SERVER_PORT'] : 80;
$user = (isset($server['PHP_AUTH_USER'])) ? $server['PHP_AUTH_USER'] : '';
$pass = (isset($server['PHP_AUTH_PW'])) ? $server['PHP_AUTH_PW'] : '';
// path
$path = parse_url('http://example.com' . $server['REQUEST_URI'], PHP_URL_PATH);
$path = rawurldecode($path);
// query
$query = (isset($server['QUERY_STRING'])) ? $server['QUERY_STRING'] : '';
// fragment (not available in $_SERVER)
$fragment = '';
$uri = new Uri('');
$uri = $uri->withScheme($scheme);
$uri = $uri->withHost($host);
$uri = $uri->withPort($port);
$uri = $uri->withUserInfo($user, $pass);
$uri = $uri->withPath($path);
$uri = $uri->withQuery($query);
$uri = $uri->withFragment($fragment);
return $uri;
} | [
"public",
"function",
"createUriFromServer",
"(",
"array",
"$",
"server",
")",
":",
"UriInterface",
"{",
"// scheme, host, post, user, pass",
"$",
"scheme",
"=",
"(",
"empty",
"(",
"$",
"server",
"[",
"'HTTPS'",
"]",
")",
"||",
"$",
"server",
"[",
"'HTTPS'",
"]",
"===",
"'off'",
")",
"?",
"'http'",
":",
"'https'",
";",
"$",
"host",
"=",
"(",
"isset",
"(",
"$",
"server",
"[",
"'HTTP_HOST'",
"]",
")",
")",
"?",
"$",
"server",
"[",
"'HTTP_HOST'",
"]",
":",
"$",
"server",
"[",
"'SERVER_NAME'",
"]",
";",
"$",
"port",
"=",
"(",
"isset",
"(",
"$",
"server",
"[",
"'SERVER_PORT'",
"]",
")",
")",
"?",
"(",
"int",
")",
"$",
"server",
"[",
"'SERVER_PORT'",
"]",
":",
"80",
";",
"$",
"user",
"=",
"(",
"isset",
"(",
"$",
"server",
"[",
"'PHP_AUTH_USER'",
"]",
")",
")",
"?",
"$",
"server",
"[",
"'PHP_AUTH_USER'",
"]",
":",
"''",
";",
"$",
"pass",
"=",
"(",
"isset",
"(",
"$",
"server",
"[",
"'PHP_AUTH_PW'",
"]",
")",
")",
"?",
"$",
"server",
"[",
"'PHP_AUTH_PW'",
"]",
":",
"''",
";",
"// path",
"$",
"path",
"=",
"parse_url",
"(",
"'http://example.com'",
".",
"$",
"server",
"[",
"'REQUEST_URI'",
"]",
",",
"PHP_URL_PATH",
")",
";",
"$",
"path",
"=",
"rawurldecode",
"(",
"$",
"path",
")",
";",
"// query",
"$",
"query",
"=",
"(",
"isset",
"(",
"$",
"server",
"[",
"'QUERY_STRING'",
"]",
")",
")",
"?",
"$",
"server",
"[",
"'QUERY_STRING'",
"]",
":",
"''",
";",
"// fragment (not available in $_SERVER)",
"$",
"fragment",
"=",
"''",
";",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"''",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withScheme",
"(",
"$",
"scheme",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withHost",
"(",
"$",
"host",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withPort",
"(",
"$",
"port",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withUserInfo",
"(",
"$",
"user",
",",
"$",
"pass",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withPath",
"(",
"$",
"path",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withQuery",
"(",
"$",
"query",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withFragment",
"(",
"$",
"fragment",
")",
";",
"return",
"$",
"uri",
";",
"}"
] | Creates new Uri from array.
@param array $server
@return UriInterface | [
"Creates",
"new",
"Uri",
"from",
"array",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Factory/UriFactory.php#L38-L66 |
32,525 | firebrandhq/silverstripe-hail | src/Models/Video.php | Video.importingColor | protected function importingColor($SSName, $data)
{
$color = $this->{$SSName};
if (!$color) {
$color = new Color();
}
$this->Fetched = date("Y-m-d H:i:s");
$color->OrganisationID = $this->OrganisationID;
$color->HailOrgID = $this->HailOrgID;
$color->HailOrgName = $this->HailOrgName;
$this->{$SSName} = $color;
} | php | protected function importingColor($SSName, $data)
{
$color = $this->{$SSName};
if (!$color) {
$color = new Color();
}
$this->Fetched = date("Y-m-d H:i:s");
$color->OrganisationID = $this->OrganisationID;
$color->HailOrgID = $this->HailOrgID;
$color->HailOrgName = $this->HailOrgName;
$this->{$SSName} = $color;
} | [
"protected",
"function",
"importingColor",
"(",
"$",
"SSName",
",",
"$",
"data",
")",
"{",
"$",
"color",
"=",
"$",
"this",
"->",
"{",
"$",
"SSName",
"}",
";",
"if",
"(",
"!",
"$",
"color",
")",
"{",
"$",
"color",
"=",
"new",
"Color",
"(",
")",
";",
"}",
"$",
"this",
"->",
"Fetched",
"=",
"date",
"(",
"\"Y-m-d H:i:s\"",
")",
";",
"$",
"color",
"->",
"OrganisationID",
"=",
"$",
"this",
"->",
"OrganisationID",
";",
"$",
"color",
"->",
"HailOrgID",
"=",
"$",
"this",
"->",
"HailOrgID",
";",
"$",
"color",
"->",
"HailOrgName",
"=",
"$",
"this",
"->",
"HailOrgName",
";",
"$",
"this",
"->",
"{",
"$",
"SSName",
"}",
"=",
"$",
"color",
";",
"}"
] | Process the colors
@param $SSName
@param $data | [
"Process",
"the",
"colors"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Video.php#L218-L230 |
32,526 | oasmobile/php-http | src/ServiceProviders/Security/AbstractSimplePreAuthenticationPolicy.php | AbstractSimplePreAuthenticationPolicy.getAuthenticationProvider | public function getAuthenticationProvider(Container $app, $firewallName, $options)
{
return new SimpleAuthenticationProvider(
$this->getPreAuthenticator(),
$this->getUserProvider($app, $firewallName),
$firewallName
);
} | php | public function getAuthenticationProvider(Container $app, $firewallName, $options)
{
return new SimpleAuthenticationProvider(
$this->getPreAuthenticator(),
$this->getUserProvider($app, $firewallName),
$firewallName
);
} | [
"public",
"function",
"getAuthenticationProvider",
"(",
"Container",
"$",
"app",
",",
"$",
"firewallName",
",",
"$",
"options",
")",
"{",
"return",
"new",
"SimpleAuthenticationProvider",
"(",
"$",
"this",
"->",
"getPreAuthenticator",
"(",
")",
",",
"$",
"this",
"->",
"getUserProvider",
"(",
"$",
"app",
",",
"$",
"firewallName",
")",
",",
"$",
"firewallName",
")",
";",
"}"
] | If string is returned, it must be either "anonymous" or "dao"
@param Container $app
@param $firewallName
@param $options
@return string|AuthenticationProviderInterface | [
"If",
"string",
"is",
"returned",
"it",
"must",
"be",
"either",
"anonymous",
"or",
"dao"
] | a7570893742286c30222c393891aeb6857064f37 | https://github.com/oasmobile/php-http/blob/a7570893742286c30222c393891aeb6857064f37/src/ServiceProviders/Security/AbstractSimplePreAuthenticationPolicy.php#L35-L42 |
32,527 | oasmobile/php-http | src/ExtendedArgumentValueResolver.php | ExtendedArgumentValueResolver.supports | public function supports(Request $request, ArgumentMetadata $argument)
{
$classname = $argument->getType();
if (!\class_exists($classname)) {
return false;
}
if (\array_key_exists($classname, $this->mappingParameters)) {
return true;
}
else {
foreach ($this->mappingParameters as $value) {
if ($value instanceof $classname) {
return true;
}
}
return false;
}
} | php | public function supports(Request $request, ArgumentMetadata $argument)
{
$classname = $argument->getType();
if (!\class_exists($classname)) {
return false;
}
if (\array_key_exists($classname, $this->mappingParameters)) {
return true;
}
else {
foreach ($this->mappingParameters as $value) {
if ($value instanceof $classname) {
return true;
}
}
return false;
}
} | [
"public",
"function",
"supports",
"(",
"Request",
"$",
"request",
",",
"ArgumentMetadata",
"$",
"argument",
")",
"{",
"$",
"classname",
"=",
"$",
"argument",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"classname",
",",
"$",
"this",
"->",
"mappingParameters",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"mappingParameters",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"$",
"classname",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"}"
] | Whether this resolver can resolve the value for the given ArgumentMetadata.
@param Request $request
@param ArgumentMetadata $argument
@return bool | [
"Whether",
"this",
"resolver",
"can",
"resolve",
"the",
"value",
"for",
"the",
"given",
"ArgumentMetadata",
"."
] | a7570893742286c30222c393891aeb6857064f37 | https://github.com/oasmobile/php-http/blob/a7570893742286c30222c393891aeb6857064f37/src/ExtendedArgumentValueResolver.php#L37-L55 |
32,528 | appaydin/pd-mailer | SwiftMailer/PdSwiftMessage.php | PdSwiftMessage.setTemplateId | public function setTemplateId(string $templateId = null)
{
if (!$this->setHeaderFieldModel('TemplateID', $templateId)) {
$this->getHeaders()->addTextHeader('TemplateID', $templateId);
}
return $this;
} | php | public function setTemplateId(string $templateId = null)
{
if (!$this->setHeaderFieldModel('TemplateID', $templateId)) {
$this->getHeaders()->addTextHeader('TemplateID', $templateId);
}
return $this;
} | [
"public",
"function",
"setTemplateId",
"(",
"string",
"$",
"templateId",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"setHeaderFieldModel",
"(",
"'TemplateID'",
",",
"$",
"templateId",
")",
")",
"{",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"->",
"addTextHeader",
"(",
"'TemplateID'",
",",
"$",
"templateId",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set Message Content Template ID.
@param string|null $templateId
@return $this | [
"Set",
"Message",
"Content",
"Template",
"ID",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/SwiftMailer/PdSwiftMessage.php#L30-L37 |
32,529 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Installer/Base.php | Base.install | public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
new Textpattern();
parent::install($repo, $package);
$plugin = new $this->textpatternPackager($this->getInstallPath($package), $package);
$plugin->install();
} | php | public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
new Textpattern();
parent::install($repo, $package);
$plugin = new $this->textpatternPackager($this->getInstallPath($package), $package);
$plugin->install();
} | [
"public",
"function",
"install",
"(",
"InstalledRepositoryInterface",
"$",
"repo",
",",
"PackageInterface",
"$",
"package",
")",
"{",
"new",
"Textpattern",
"(",
")",
";",
"parent",
"::",
"install",
"(",
"$",
"repo",
",",
"$",
"package",
")",
";",
"$",
"plugin",
"=",
"new",
"$",
"this",
"->",
"textpatternPackager",
"(",
"$",
"this",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
",",
"$",
"package",
")",
";",
"$",
"plugin",
"->",
"install",
"(",
")",
";",
"}"
] | Writes the plugin package to the database on install.
@param InstalledRepositoryInterface $repo
@param PackageInterface $package | [
"Writes",
"the",
"plugin",
"package",
"to",
"the",
"database",
"on",
"install",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Installer/Base.php#L68-L74 |
32,530 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Installer/Base.php | Base.update | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
new Textpattern();
parent::update($repo, $initial, $target);
$plugin = new $this->textpatternPackager($this->getInstallPath($target), $target);
$plugin->update();
} | php | public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
new Textpattern();
parent::update($repo, $initial, $target);
$plugin = new $this->textpatternPackager($this->getInstallPath($target), $target);
$plugin->update();
} | [
"public",
"function",
"update",
"(",
"InstalledRepositoryInterface",
"$",
"repo",
",",
"PackageInterface",
"$",
"initial",
",",
"PackageInterface",
"$",
"target",
")",
"{",
"new",
"Textpattern",
"(",
")",
";",
"parent",
"::",
"update",
"(",
"$",
"repo",
",",
"$",
"initial",
",",
"$",
"target",
")",
";",
"$",
"plugin",
"=",
"new",
"$",
"this",
"->",
"textpatternPackager",
"(",
"$",
"this",
"->",
"getInstallPath",
"(",
"$",
"target",
")",
",",
"$",
"target",
")",
";",
"$",
"plugin",
"->",
"update",
"(",
")",
";",
"}"
] | Runs updater on package updates.
@param InstalledRepositoryInterface $repo
@param PackageInterface $initial
@param PackageInterface $target | [
"Runs",
"updater",
"on",
"package",
"updates",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Installer/Base.php#L83-L89 |
32,531 | davidecesarano/Embryo-Http | Embryo/Http/Message/UploadedFile.php | UploadedFile.getStream | public function getStream(): StreamInterface
{
if ($this->moved) {
throw new \RuntimeException(sprintf('Uploaded file %1s has already been moved', $this->clientFilename));
}
return $this->file;
} | php | public function getStream(): StreamInterface
{
if ($this->moved) {
throw new \RuntimeException(sprintf('Uploaded file %1s has already been moved', $this->clientFilename));
}
return $this->file;
} | [
"public",
"function",
"getStream",
"(",
")",
":",
"StreamInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"moved",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Uploaded file %1s has already been moved'",
",",
"$",
"this",
"->",
"clientFilename",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"file",
";",
"}"
] | Retrieves a stream representing the uploaded file.
This method returns a StreamInterface instance, representing the
uploaded file.
@return StreamInterface
@throws RuntimeException | [
"Retrieves",
"a",
"stream",
"representing",
"the",
"uploaded",
"file",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/UploadedFile.php#L84-L90 |
32,532 | davidecesarano/Embryo-Http | Embryo/Http/Message/UploadedFile.php | UploadedFile.moveTo | public function moveTo($targetPath)
{
if ($this->moved) {
throw new \RuntimeException('Uploaded file already moved');
}
if (!is_string($targetPath) || $targetPath === '') {
throw new \InvalidArgumentException('Target path must be a non empty string');
}
$stream = $this->getStream();
$file = $stream->getMetadata('uri');
if (is_dir($targetPath)) {
if (!is_writable($targetPath)) {
throw new \InvalidArgumentException('Target path is not writable');
}
$target = rtrim($targetPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->clientFilename;
} else {
if (!is_writable(dirname($targetPath))) {
throw new \InvalidArgumentException('Target path is not writable');
}
$target = $targetPath;
}
if (!copy($file, $target)) {
throw new \RuntimeException(sprintf('Error coping uploaded file %1s to %2s', $this->clientFilename, $targetPath));
}
$this->moved = true;
if (!$this->moved) {
throw new \RuntimeException(sprintf('Uploaded file could not be moved to %s', $targetPath));
}
} | php | public function moveTo($targetPath)
{
if ($this->moved) {
throw new \RuntimeException('Uploaded file already moved');
}
if (!is_string($targetPath) || $targetPath === '') {
throw new \InvalidArgumentException('Target path must be a non empty string');
}
$stream = $this->getStream();
$file = $stream->getMetadata('uri');
if (is_dir($targetPath)) {
if (!is_writable($targetPath)) {
throw new \InvalidArgumentException('Target path is not writable');
}
$target = rtrim($targetPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->clientFilename;
} else {
if (!is_writable(dirname($targetPath))) {
throw new \InvalidArgumentException('Target path is not writable');
}
$target = $targetPath;
}
if (!copy($file, $target)) {
throw new \RuntimeException(sprintf('Error coping uploaded file %1s to %2s', $this->clientFilename, $targetPath));
}
$this->moved = true;
if (!$this->moved) {
throw new \RuntimeException(sprintf('Uploaded file could not be moved to %s', $targetPath));
}
} | [
"public",
"function",
"moveTo",
"(",
"$",
"targetPath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"moved",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Uploaded file already moved'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"targetPath",
")",
"||",
"$",
"targetPath",
"===",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Target path must be a non empty string'",
")",
";",
"}",
"$",
"stream",
"=",
"$",
"this",
"->",
"getStream",
"(",
")",
";",
"$",
"file",
"=",
"$",
"stream",
"->",
"getMetadata",
"(",
"'uri'",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"targetPath",
")",
")",
"{",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"targetPath",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Target path is not writable'",
")",
";",
"}",
"$",
"target",
"=",
"rtrim",
"(",
"$",
"targetPath",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"clientFilename",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_writable",
"(",
"dirname",
"(",
"$",
"targetPath",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Target path is not writable'",
")",
";",
"}",
"$",
"target",
"=",
"$",
"targetPath",
";",
"}",
"if",
"(",
"!",
"copy",
"(",
"$",
"file",
",",
"$",
"target",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Error coping uploaded file %1s to %2s'",
",",
"$",
"this",
"->",
"clientFilename",
",",
"$",
"targetPath",
")",
")",
";",
"}",
"$",
"this",
"->",
"moved",
"=",
"true",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"moved",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Uploaded file could not be moved to %s'",
",",
"$",
"targetPath",
")",
")",
";",
"}",
"}"
] | Moves the uploaded file to a new location.
@see http://php.net/is_uploaded_file
@see http://php.net/move_uploaded_file
@param string $targetPath
@throws InvalidArgumentException
@throws RuntimeException | [
"Moves",
"the",
"uploaded",
"file",
"to",
"a",
"new",
"location",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/UploadedFile.php#L101-L138 |
32,533 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Manifest.php | Manifest.find | protected function find($directory)
{
if ($iterator = parent::find($directory)) {
new Textpattern();
foreach ($this->manifestNames as $manifestName) {
foreach ($iterator as $file) {
if (basename($file) === $manifestName && $this->isManifest($file)) {
$this->dir = dirname($file);
$this->import();
}
}
if (!empty($this->plugin)) {
return true;
}
}
}
return false;
} | php | protected function find($directory)
{
if ($iterator = parent::find($directory)) {
new Textpattern();
foreach ($this->manifestNames as $manifestName) {
foreach ($iterator as $file) {
if (basename($file) === $manifestName && $this->isManifest($file)) {
$this->dir = dirname($file);
$this->import();
}
}
if (!empty($this->plugin)) {
return true;
}
}
}
return false;
} | [
"protected",
"function",
"find",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"$",
"iterator",
"=",
"parent",
"::",
"find",
"(",
"$",
"directory",
")",
")",
"{",
"new",
"Textpattern",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"manifestNames",
"as",
"$",
"manifestName",
")",
"{",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"basename",
"(",
"$",
"file",
")",
"===",
"$",
"manifestName",
"&&",
"$",
"this",
"->",
"isManifest",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"dir",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"import",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"plugin",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Find the plugin project directory and manifest from the package.
@param string $directory
@return bool | [
"Find",
"the",
"plugin",
"project",
"directory",
"and",
"manifest",
"from",
"the",
"package",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Manifest.php#L75-L95 |
32,534 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Manifest.php | Manifest.isManifest | protected function isManifest($file)
{
if (is_file($file) && is_readable($file)) {
if ($contents = file_get_contents($file)) {
$this->manifest = @json_decode($contents);
if ($this->manifest && isset($this->manifest->name) && is_string($this->manifest->name)) {
$this->manifest->name = basename($this->manifest->name);
if ($this->manifest->name === basename(dirname($file))) {
return (bool) preg_match($this->pluginNamePattern, $this->manifest->name);
}
}
}
}
return false;
} | php | protected function isManifest($file)
{
if (is_file($file) && is_readable($file)) {
if ($contents = file_get_contents($file)) {
$this->manifest = @json_decode($contents);
if ($this->manifest && isset($this->manifest->name) && is_string($this->manifest->name)) {
$this->manifest->name = basename($this->manifest->name);
if ($this->manifest->name === basename(dirname($file))) {
return (bool) preg_match($this->pluginNamePattern, $this->manifest->name);
}
}
}
}
return false;
} | [
"protected",
"function",
"isManifest",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
"&&",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"if",
"(",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"manifest",
"=",
"@",
"json_decode",
"(",
"$",
"contents",
")",
";",
"if",
"(",
"$",
"this",
"->",
"manifest",
"&&",
"isset",
"(",
"$",
"this",
"->",
"manifest",
"->",
"name",
")",
"&&",
"is_string",
"(",
"$",
"this",
"->",
"manifest",
"->",
"name",
")",
")",
"{",
"$",
"this",
"->",
"manifest",
"->",
"name",
"=",
"basename",
"(",
"$",
"this",
"->",
"manifest",
"->",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"manifest",
"->",
"name",
"===",
"basename",
"(",
"dirname",
"(",
"$",
"file",
")",
")",
")",
"{",
"return",
"(",
"bool",
")",
"preg_match",
"(",
"$",
"this",
"->",
"pluginNamePattern",
",",
"$",
"this",
"->",
"manifest",
"->",
"name",
")",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Whether a file is a valid plugin manifest.
This function makes sure the file contains JSON, the name property
follows plugin naming convention and the parent directory is the same
as the name property.
A valid plugin name follows the pattern {pfx}_{pluginName}, where the
{pfx} is the plugin author prefix and the {pluginName} is the name of
the plugin consisting of up to 64 ASCII letter and numbers.
@param string $file Full resolved pathname to the file
@return bool TRUE if valid, FALSE otherwise | [
"Whether",
"a",
"file",
"is",
"a",
"valid",
"plugin",
"manifest",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Manifest.php#L111-L128 |
32,535 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Manifest.php | Manifest.code | protected function code()
{
$files = $out = [];
if (isset($this->manifest->code->file)) {
$files = array_map([$this, 'path'], (array) $this->manifest->code->file);
} else {
if (($cwd = getcwd()) !== false && chdir($this->dir)) {
$files = (array) glob('*.php');
}
}
$pathFrom = (string) new FindTextpattern() . '/index.php';
foreach ($files as $path) {
if (file_exists($path) && is_file($path) && is_readable($path)) {
$includePath = $this->getRelativePath($pathFrom, realpath($path));
if ($includePath !== $path) {
$out[] = "include txpath.'/".addslashes($includePath)."';";
} else {
$out[] = "include '".addslashes($includePath)."';";
}
}
}
if (isset($cwd) && $cwd !== false) {
chdir($cwd);
}
return implode("\n", $out);
} | php | protected function code()
{
$files = $out = [];
if (isset($this->manifest->code->file)) {
$files = array_map([$this, 'path'], (array) $this->manifest->code->file);
} else {
if (($cwd = getcwd()) !== false && chdir($this->dir)) {
$files = (array) glob('*.php');
}
}
$pathFrom = (string) new FindTextpattern() . '/index.php';
foreach ($files as $path) {
if (file_exists($path) && is_file($path) && is_readable($path)) {
$includePath = $this->getRelativePath($pathFrom, realpath($path));
if ($includePath !== $path) {
$out[] = "include txpath.'/".addslashes($includePath)."';";
} else {
$out[] = "include '".addslashes($includePath)."';";
}
}
}
if (isset($cwd) && $cwd !== false) {
chdir($cwd);
}
return implode("\n", $out);
} | [
"protected",
"function",
"code",
"(",
")",
"{",
"$",
"files",
"=",
"$",
"out",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"manifest",
"->",
"code",
"->",
"file",
")",
")",
"{",
"$",
"files",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'path'",
"]",
",",
"(",
"array",
")",
"$",
"this",
"->",
"manifest",
"->",
"code",
"->",
"file",
")",
";",
"}",
"else",
"{",
"if",
"(",
"(",
"$",
"cwd",
"=",
"getcwd",
"(",
")",
")",
"!==",
"false",
"&&",
"chdir",
"(",
"$",
"this",
"->",
"dir",
")",
")",
"{",
"$",
"files",
"=",
"(",
"array",
")",
"glob",
"(",
"'*.php'",
")",
";",
"}",
"}",
"$",
"pathFrom",
"=",
"(",
"string",
")",
"new",
"FindTextpattern",
"(",
")",
".",
"'/index.php'",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
"&&",
"is_file",
"(",
"$",
"path",
")",
"&&",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"$",
"includePath",
"=",
"$",
"this",
"->",
"getRelativePath",
"(",
"$",
"pathFrom",
",",
"realpath",
"(",
"$",
"path",
")",
")",
";",
"if",
"(",
"$",
"includePath",
"!==",
"$",
"path",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"\"include txpath.'/\"",
".",
"addslashes",
"(",
"$",
"includePath",
")",
".",
"\"';\"",
";",
"}",
"else",
"{",
"$",
"out",
"[",
"]",
"=",
"\"include '\"",
".",
"addslashes",
"(",
"$",
"includePath",
")",
".",
"\"';\"",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"cwd",
")",
"&&",
"$",
"cwd",
"!==",
"false",
")",
"{",
"chdir",
"(",
"$",
"cwd",
")",
";",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"out",
")",
";",
"}"
] | Plugin code template.
Generates PHP source code that either imports
.php files in the directory or the files
specified with the 'file' property of 'code'.
@return string | [
"Plugin",
"code",
"template",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Manifest.php#L213-L244 |
32,536 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Manifest.php | Manifest.textpack | protected function textpack()
{
$textpacks = $this->dir . '/textpacks';
if (!file_exists($textpacks) || !is_dir($textpacks) || !is_readable($textpacks)) {
return '';
}
if (($cwd = getcwd()) === false || !chdir($textpacks)) {
return '';
}
$out = [];
foreach ((array) glob('*.textpack', GLOB_NOSORT) as $file) {
if (!is_file($file) || !is_readable($file)) {
continue;
}
$file = file_get_contents($file);
if (!preg_match('/^#@language|\n#@language\s/', $file)) {
array_unshift($out, $file);
continue;
}
$out[] = $file;
}
chdir($cwd);
return implode("\n", $out);
} | php | protected function textpack()
{
$textpacks = $this->dir . '/textpacks';
if (!file_exists($textpacks) || !is_dir($textpacks) || !is_readable($textpacks)) {
return '';
}
if (($cwd = getcwd()) === false || !chdir($textpacks)) {
return '';
}
$out = [];
foreach ((array) glob('*.textpack', GLOB_NOSORT) as $file) {
if (!is_file($file) || !is_readable($file)) {
continue;
}
$file = file_get_contents($file);
if (!preg_match('/^#@language|\n#@language\s/', $file)) {
array_unshift($out, $file);
continue;
}
$out[] = $file;
}
chdir($cwd);
return implode("\n", $out);
} | [
"protected",
"function",
"textpack",
"(",
")",
"{",
"$",
"textpacks",
"=",
"$",
"this",
"->",
"dir",
".",
"'/textpacks'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"textpacks",
")",
"||",
"!",
"is_dir",
"(",
"$",
"textpacks",
")",
"||",
"!",
"is_readable",
"(",
"$",
"textpacks",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"(",
"$",
"cwd",
"=",
"getcwd",
"(",
")",
")",
"===",
"false",
"||",
"!",
"chdir",
"(",
"$",
"textpacks",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"glob",
"(",
"'*.textpack'",
",",
"GLOB_NOSORT",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
"||",
"!",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"continue",
";",
"}",
"$",
"file",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^#@language|\\n#@language\\s/'",
",",
"$",
"file",
")",
")",
"{",
"array_unshift",
"(",
"$",
"out",
",",
"$",
"file",
")",
";",
"continue",
";",
"}",
"$",
"out",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"chdir",
"(",
"$",
"cwd",
")",
";",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"out",
")",
";",
"}"
] | Gets Textpacks.
@return string | [
"Gets",
"Textpacks",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Manifest.php#L251-L282 |
32,537 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Manifest.php | Manifest.help | protected function help()
{
$out = [];
if (isset($this->manifest->help) && is_string($this->manifest->help)) {
return (string) $this->manifest->help;
}
if (empty($this->manifest->help->file)) {
$files = $this->helpNames;
} else {
$files = $this->manifest->help->file;
}
foreach ((array) $files as $file) {
$file = $this->path($file);
if (file_exists($file) && is_file($file) && is_readable($file)) {
$out[strtolower($file)] = file_get_contents($file);
}
}
return implode("\n\n", $out);
} | php | protected function help()
{
$out = [];
if (isset($this->manifest->help) && is_string($this->manifest->help)) {
return (string) $this->manifest->help;
}
if (empty($this->manifest->help->file)) {
$files = $this->helpNames;
} else {
$files = $this->manifest->help->file;
}
foreach ((array) $files as $file) {
$file = $this->path($file);
if (file_exists($file) && is_file($file) && is_readable($file)) {
$out[strtolower($file)] = file_get_contents($file);
}
}
return implode("\n\n", $out);
} | [
"protected",
"function",
"help",
"(",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"manifest",
"->",
"help",
")",
"&&",
"is_string",
"(",
"$",
"this",
"->",
"manifest",
"->",
"help",
")",
")",
"{",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"manifest",
"->",
"help",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"manifest",
"->",
"help",
"->",
"file",
")",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"helpNames",
";",
"}",
"else",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"manifest",
"->",
"help",
"->",
"file",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"file",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"is_file",
"(",
"$",
"file",
")",
"&&",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"$",
"out",
"[",
"strtolower",
"(",
"$",
"file",
")",
"]",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"\"\\n\\n\"",
",",
"$",
"out",
")",
";",
"}"
] | Gets help files.
@return string | [
"Gets",
"help",
"files",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Manifest.php#L289-L312 |
32,538 | flipboxfactory/craft-ember | src/objects/SiteMutatorTrait.php | SiteMutatorTrait.getSiteId | public function getSiteId()
{
if (null === $this->siteId && null !== $this->site) {
$this->siteId = $this->site->id;
}
return $this->siteId;
} | php | public function getSiteId()
{
if (null === $this->siteId && null !== $this->site) {
$this->siteId = $this->site->id;
}
return $this->siteId;
} | [
"public",
"function",
"getSiteId",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"siteId",
"&&",
"null",
"!==",
"$",
"this",
"->",
"site",
")",
"{",
"$",
"this",
"->",
"siteId",
"=",
"$",
"this",
"->",
"site",
"->",
"id",
";",
"}",
"return",
"$",
"this",
"->",
"siteId",
";",
"}"
] | Get associated siteId
@return int|null | [
"Get",
"associated",
"siteId"
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/objects/SiteMutatorTrait.php#L45-L52 |
32,539 | ninjify/nunjuck | src/Environment.php | Environment.setup | public static function setup(string $dir): void
{
self::setupTester();
self::setupTimezone();
self::setupVariables($dir);
self::setupGlobalVariables();
} | php | public static function setup(string $dir): void
{
self::setupTester();
self::setupTimezone();
self::setupVariables($dir);
self::setupGlobalVariables();
} | [
"public",
"static",
"function",
"setup",
"(",
"string",
"$",
"dir",
")",
":",
"void",
"{",
"self",
"::",
"setupTester",
"(",
")",
";",
"self",
"::",
"setupTimezone",
"(",
")",
";",
"self",
"::",
"setupVariables",
"(",
"$",
"dir",
")",
";",
"self",
"::",
"setupGlobalVariables",
"(",
")",
";",
"}"
] | Magic setup method | [
"Magic",
"setup",
"method"
] | 0381d3330e769c4712ab063b32200a1d52333a5c | https://github.com/ninjify/nunjuck/blob/0381d3330e769c4712ab063b32200a1d52333a5c/src/Environment.php#L30-L36 |
32,540 | ninjify/nunjuck | src/Environment.php | Environment.setupGlobalVariables | public static function setupGlobalVariables(): void
{
$_SERVER = array_intersect_key($_SERVER, array_flip([
'PHP_SELF',
'SCRIPT_NAME',
'SERVER_ADDR',
'SERVER_SOFTWARE',
'HTTP_HOST',
'DOCUMENT_ROOT',
'OS',
'argc',
'argv',
]));
$_SERVER['REQUEST_TIME'] = 1234567890;
$_ENV = $_GET = $_POST = [];
} | php | public static function setupGlobalVariables(): void
{
$_SERVER = array_intersect_key($_SERVER, array_flip([
'PHP_SELF',
'SCRIPT_NAME',
'SERVER_ADDR',
'SERVER_SOFTWARE',
'HTTP_HOST',
'DOCUMENT_ROOT',
'OS',
'argc',
'argv',
]));
$_SERVER['REQUEST_TIME'] = 1234567890;
$_ENV = $_GET = $_POST = [];
} | [
"public",
"static",
"function",
"setupGlobalVariables",
"(",
")",
":",
"void",
"{",
"$",
"_SERVER",
"=",
"array_intersect_key",
"(",
"$",
"_SERVER",
",",
"array_flip",
"(",
"[",
"'PHP_SELF'",
",",
"'SCRIPT_NAME'",
",",
"'SERVER_ADDR'",
",",
"'SERVER_SOFTWARE'",
",",
"'HTTP_HOST'",
",",
"'DOCUMENT_ROOT'",
",",
"'OS'",
",",
"'argc'",
",",
"'argv'",
",",
"]",
")",
")",
";",
"$",
"_SERVER",
"[",
"'REQUEST_TIME'",
"]",
"=",
"1234567890",
";",
"$",
"_ENV",
"=",
"$",
"_GET",
"=",
"$",
"_POST",
"=",
"[",
"]",
";",
"}"
] | Configure global variables | [
"Configure",
"global",
"variables"
] | 0381d3330e769c4712ab063b32200a1d52333a5c | https://github.com/ninjify/nunjuck/blob/0381d3330e769c4712ab063b32200a1d52333a5c/src/Environment.php#L104-L119 |
32,541 | ninjify/nunjuck | src/Environment.php | Environment.setupRobotLoader | public static function setupRobotLoader(?callable $callback = null): void
{
$loader = new RobotLoader();
$loader->setTempDirectory(CACHE_DIR);
if ($callback !== null) {
$callback($loader);
} else {
$loader->addDirectory(ENGINE_DIR);
$loader->addDirectory(APP_DIR);
$loader->setAutoRefresh(true);
}
$loader->register();
} | php | public static function setupRobotLoader(?callable $callback = null): void
{
$loader = new RobotLoader();
$loader->setTempDirectory(CACHE_DIR);
if ($callback !== null) {
$callback($loader);
} else {
$loader->addDirectory(ENGINE_DIR);
$loader->addDirectory(APP_DIR);
$loader->setAutoRefresh(true);
}
$loader->register();
} | [
"public",
"static",
"function",
"setupRobotLoader",
"(",
"?",
"callable",
"$",
"callback",
"=",
"null",
")",
":",
"void",
"{",
"$",
"loader",
"=",
"new",
"RobotLoader",
"(",
")",
";",
"$",
"loader",
"->",
"setTempDirectory",
"(",
"CACHE_DIR",
")",
";",
"if",
"(",
"$",
"callback",
"!==",
"null",
")",
"{",
"$",
"callback",
"(",
"$",
"loader",
")",
";",
"}",
"else",
"{",
"$",
"loader",
"->",
"addDirectory",
"(",
"ENGINE_DIR",
")",
";",
"$",
"loader",
"->",
"addDirectory",
"(",
"APP_DIR",
")",
";",
"$",
"loader",
"->",
"setAutoRefresh",
"(",
"true",
")",
";",
"}",
"$",
"loader",
"->",
"register",
"(",
")",
";",
"}"
] | Configure robot loader | [
"Configure",
"robot",
"loader"
] | 0381d3330e769c4712ab063b32200a1d52333a5c | https://github.com/ninjify/nunjuck/blob/0381d3330e769c4712ab063b32200a1d52333a5c/src/Environment.php#L124-L138 |
32,542 | firebrandhq/silverstripe-hail | src/Forms/GridFieldFetchButton.php | GridFieldFetchButton.getHTMLFragments | public function getHTMLFragments($gridField)
{
//Disable button if there is already a job running, and add a class to the progress button to trigger the display
$jobs = FetchJob::get()->filter(['Status:not' => ['Done', 'Error']]);
$current = $jobs->First();
$global = $current && $current->ToFetch === "*" ? "global-fetch" : "";
$disabled = $jobs->Count() > 0 ? "disabled" : "";
$running = $jobs->Count() > 0 ? "hail-fetch-running" : "";
$active = $jobs->Count() > 0 ? "state-active" : "";
$vd = new ViewableData();
$rendered = $vd
->customise([
'Disabled' => $disabled,
'Running' => $running,
'Active' => $active,
'Global' => $global,
])
->renderWith('GridFieldFetchButton')
->getValue();
return [
$this->targetFragment => $rendered,
];
} | php | public function getHTMLFragments($gridField)
{
//Disable button if there is already a job running, and add a class to the progress button to trigger the display
$jobs = FetchJob::get()->filter(['Status:not' => ['Done', 'Error']]);
$current = $jobs->First();
$global = $current && $current->ToFetch === "*" ? "global-fetch" : "";
$disabled = $jobs->Count() > 0 ? "disabled" : "";
$running = $jobs->Count() > 0 ? "hail-fetch-running" : "";
$active = $jobs->Count() > 0 ? "state-active" : "";
$vd = new ViewableData();
$rendered = $vd
->customise([
'Disabled' => $disabled,
'Running' => $running,
'Active' => $active,
'Global' => $global,
])
->renderWith('GridFieldFetchButton')
->getValue();
return [
$this->targetFragment => $rendered,
];
} | [
"public",
"function",
"getHTMLFragments",
"(",
"$",
"gridField",
")",
"{",
"//Disable button if there is already a job running, and add a class to the progress button to trigger the display",
"$",
"jobs",
"=",
"FetchJob",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"[",
"'Status:not'",
"=>",
"[",
"'Done'",
",",
"'Error'",
"]",
"]",
")",
";",
"$",
"current",
"=",
"$",
"jobs",
"->",
"First",
"(",
")",
";",
"$",
"global",
"=",
"$",
"current",
"&&",
"$",
"current",
"->",
"ToFetch",
"===",
"\"*\"",
"?",
"\"global-fetch\"",
":",
"\"\"",
";",
"$",
"disabled",
"=",
"$",
"jobs",
"->",
"Count",
"(",
")",
">",
"0",
"?",
"\"disabled\"",
":",
"\"\"",
";",
"$",
"running",
"=",
"$",
"jobs",
"->",
"Count",
"(",
")",
">",
"0",
"?",
"\"hail-fetch-running\"",
":",
"\"\"",
";",
"$",
"active",
"=",
"$",
"jobs",
"->",
"Count",
"(",
")",
">",
"0",
"?",
"\"state-active\"",
":",
"\"\"",
";",
"$",
"vd",
"=",
"new",
"ViewableData",
"(",
")",
";",
"$",
"rendered",
"=",
"$",
"vd",
"->",
"customise",
"(",
"[",
"'Disabled'",
"=>",
"$",
"disabled",
",",
"'Running'",
"=>",
"$",
"running",
",",
"'Active'",
"=>",
"$",
"active",
",",
"'Global'",
"=>",
"$",
"global",
",",
"]",
")",
"->",
"renderWith",
"(",
"'GridFieldFetchButton'",
")",
"->",
"getValue",
"(",
")",
";",
"return",
"[",
"$",
"this",
"->",
"targetFragment",
"=>",
"$",
"rendered",
",",
"]",
";",
"}"
] | Returns the Fetch Button html
@param GridField $gridField
@return array | [
"Returns",
"the",
"Fetch",
"Button",
"html"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Forms/GridFieldFetchButton.php#L37-L60 |
32,543 | flipboxfactory/craft-ember | src/queries/OrderByTrait.php | OrderByTrait.applyOrderByParams | protected function applyOrderByParams(Connection $db)
{
if ($this->orderBy === null) {
return;
}
// Any other empty value means we should set it
if (empty($this->orderBy)) {
$this->applyEmptyOrderByParams($db);
}
$this->orderBy($this->orderBy);
} | php | protected function applyOrderByParams(Connection $db)
{
if ($this->orderBy === null) {
return;
}
// Any other empty value means we should set it
if (empty($this->orderBy)) {
$this->applyEmptyOrderByParams($db);
}
$this->orderBy($this->orderBy);
} | [
"protected",
"function",
"applyOrderByParams",
"(",
"Connection",
"$",
"db",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"orderBy",
"===",
"null",
")",
"{",
"return",
";",
"}",
"// Any other empty value means we should set it",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"orderBy",
")",
")",
"{",
"$",
"this",
"->",
"applyEmptyOrderByParams",
"(",
"$",
"db",
")",
";",
"}",
"$",
"this",
"->",
"orderBy",
"(",
"$",
"this",
"->",
"orderBy",
")",
";",
"}"
] | Applies the 'fixedOrder' and 'orderBy' params to the query being prepared.
@param Connection|null $db The database connection used to generate the SQL statement.
If this parameter is not given, the `db` application component will be used. | [
"Applies",
"the",
"fixedOrder",
"and",
"orderBy",
"params",
"to",
"the",
"query",
"being",
"prepared",
"."
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/queries/OrderByTrait.php#L52-L64 |
32,544 | firebrandhq/silverstripe-hail | src/Models/Article.php | Article.fetchImages | public function fetchImages()
{
try {
$api_client = new Client();
$list = $api_client->getImagesByArticles($this->HailID);
} catch (\Exception $ex) {
return;
}
$hailIdList = [];
// Clean before importing
$this->ImageGallery()->removeAll();
foreach ($list as $hailData) {
// Build up Hail ID list
$hailIdList[] = $hailData['id'];
// Check if we can find an existing item.
$hailObj = Image::get()->filter(['HailID' => $hailData['id']])->First();
if (!$hailObj) {
$hailObj = new Image();
}
$hailObj->OrganisationID = $this->OrganisationID;
$hailObj->HailOrgID = $this->HailOrgID;
$hailObj->HailOrgName = $this->HailOrgName;
$hailObj->importHailData($hailData);
$this->ImageGallery()->add($hailObj);
}
} | php | public function fetchImages()
{
try {
$api_client = new Client();
$list = $api_client->getImagesByArticles($this->HailID);
} catch (\Exception $ex) {
return;
}
$hailIdList = [];
// Clean before importing
$this->ImageGallery()->removeAll();
foreach ($list as $hailData) {
// Build up Hail ID list
$hailIdList[] = $hailData['id'];
// Check if we can find an existing item.
$hailObj = Image::get()->filter(['HailID' => $hailData['id']])->First();
if (!$hailObj) {
$hailObj = new Image();
}
$hailObj->OrganisationID = $this->OrganisationID;
$hailObj->HailOrgID = $this->HailOrgID;
$hailObj->HailOrgName = $this->HailOrgName;
$hailObj->importHailData($hailData);
$this->ImageGallery()->add($hailObj);
}
} | [
"public",
"function",
"fetchImages",
"(",
")",
"{",
"try",
"{",
"$",
"api_client",
"=",
"new",
"Client",
"(",
")",
";",
"$",
"list",
"=",
"$",
"api_client",
"->",
"getImagesByArticles",
"(",
"$",
"this",
"->",
"HailID",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"return",
";",
"}",
"$",
"hailIdList",
"=",
"[",
"]",
";",
"// Clean before importing\r",
"$",
"this",
"->",
"ImageGallery",
"(",
")",
"->",
"removeAll",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"hailData",
")",
"{",
"// Build up Hail ID list\r",
"$",
"hailIdList",
"[",
"]",
"=",
"$",
"hailData",
"[",
"'id'",
"]",
";",
"// Check if we can find an existing item.\r",
"$",
"hailObj",
"=",
"Image",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"[",
"'HailID'",
"=>",
"$",
"hailData",
"[",
"'id'",
"]",
"]",
")",
"->",
"First",
"(",
")",
";",
"if",
"(",
"!",
"$",
"hailObj",
")",
"{",
"$",
"hailObj",
"=",
"new",
"Image",
"(",
")",
";",
"}",
"$",
"hailObj",
"->",
"OrganisationID",
"=",
"$",
"this",
"->",
"OrganisationID",
";",
"$",
"hailObj",
"->",
"HailOrgID",
"=",
"$",
"this",
"->",
"HailOrgID",
";",
"$",
"hailObj",
"->",
"HailOrgName",
"=",
"$",
"this",
"->",
"HailOrgName",
";",
"$",
"hailObj",
"->",
"importHailData",
"(",
"$",
"hailData",
")",
";",
"$",
"this",
"->",
"ImageGallery",
"(",
")",
"->",
"add",
"(",
"$",
"hailObj",
")",
";",
"}",
"}"
] | Fetch the image gallery of this article from the Hail API
@return void
@throws | [
"Fetch",
"the",
"image",
"gallery",
"of",
"this",
"article",
"from",
"the",
"Hail",
"API"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Article.php#L187-L218 |
32,545 | firebrandhq/silverstripe-hail | src/Models/Article.php | Article.fetchVideos | public function fetchVideos()
{
try {
$api_client = new Client();
$list = $api_client->getVideosByArticles($this->HailID);
} catch (\Exception $ex) {
return;
}
$hailIdList = [];
// CLean before importing
$this->VideoGallery()->removeAll();
foreach ($list as $hailData) {
// Build up Hail ID list
$hailIdList[] = $hailData['id'];
// Check if we can find an existing item.
$hailObj = Video::get()->filter(['HailID' => $hailData['id']])->First();
if (!$hailObj) {
$hailObj = new Video();
}
$hailObj->OrganisationID = $this->OrganisationID;
$hailObj->HailOrgID = $this->HailOrgID;
$hailObj->HailOrgName = $this->HailOrgName;
$hailObj->importHailData($hailData);
$this->VideoGallery()->add($hailObj);
}
} | php | public function fetchVideos()
{
try {
$api_client = new Client();
$list = $api_client->getVideosByArticles($this->HailID);
} catch (\Exception $ex) {
return;
}
$hailIdList = [];
// CLean before importing
$this->VideoGallery()->removeAll();
foreach ($list as $hailData) {
// Build up Hail ID list
$hailIdList[] = $hailData['id'];
// Check if we can find an existing item.
$hailObj = Video::get()->filter(['HailID' => $hailData['id']])->First();
if (!$hailObj) {
$hailObj = new Video();
}
$hailObj->OrganisationID = $this->OrganisationID;
$hailObj->HailOrgID = $this->HailOrgID;
$hailObj->HailOrgName = $this->HailOrgName;
$hailObj->importHailData($hailData);
$this->VideoGallery()->add($hailObj);
}
} | [
"public",
"function",
"fetchVideos",
"(",
")",
"{",
"try",
"{",
"$",
"api_client",
"=",
"new",
"Client",
"(",
")",
";",
"$",
"list",
"=",
"$",
"api_client",
"->",
"getVideosByArticles",
"(",
"$",
"this",
"->",
"HailID",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"return",
";",
"}",
"$",
"hailIdList",
"=",
"[",
"]",
";",
"// CLean before importing\r",
"$",
"this",
"->",
"VideoGallery",
"(",
")",
"->",
"removeAll",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"hailData",
")",
"{",
"// Build up Hail ID list\r",
"$",
"hailIdList",
"[",
"]",
"=",
"$",
"hailData",
"[",
"'id'",
"]",
";",
"// Check if we can find an existing item.\r",
"$",
"hailObj",
"=",
"Video",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"[",
"'HailID'",
"=>",
"$",
"hailData",
"[",
"'id'",
"]",
"]",
")",
"->",
"First",
"(",
")",
";",
"if",
"(",
"!",
"$",
"hailObj",
")",
"{",
"$",
"hailObj",
"=",
"new",
"Video",
"(",
")",
";",
"}",
"$",
"hailObj",
"->",
"OrganisationID",
"=",
"$",
"this",
"->",
"OrganisationID",
";",
"$",
"hailObj",
"->",
"HailOrgID",
"=",
"$",
"this",
"->",
"HailOrgID",
";",
"$",
"hailObj",
"->",
"HailOrgName",
"=",
"$",
"this",
"->",
"HailOrgName",
";",
"$",
"hailObj",
"->",
"importHailData",
"(",
"$",
"hailData",
")",
";",
"$",
"this",
"->",
"VideoGallery",
"(",
")",
"->",
"add",
"(",
"$",
"hailObj",
")",
";",
"}",
"}"
] | Fetch the video gallery of this article from the Hail API
@return void
@throws | [
"Fetch",
"the",
"video",
"gallery",
"of",
"this",
"article",
"from",
"the",
"Hail",
"API"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Article.php#L226-L255 |
32,546 | firebrandhq/silverstripe-hail | src/Models/Article.php | Article.Link | public function Link()
{
$ctrl = Controller::curr();
if ($ctrl instanceof HailPageController) {
$link = $ctrl->Link();
} else {
//If outside HailPageController try to find the first Hail Page
$page = HailPage::get()->first();
if (!empty($page)) {
$link = $page->Link();
}
}
if (!isset($link)) {
return "";
}
return $link . "article/" . $this->HailID . '/' . Convert::raw2url($this->Title);
} | php | public function Link()
{
$ctrl = Controller::curr();
if ($ctrl instanceof HailPageController) {
$link = $ctrl->Link();
} else {
//If outside HailPageController try to find the first Hail Page
$page = HailPage::get()->first();
if (!empty($page)) {
$link = $page->Link();
}
}
if (!isset($link)) {
return "";
}
return $link . "article/" . $this->HailID . '/' . Convert::raw2url($this->Title);
} | [
"public",
"function",
"Link",
"(",
")",
"{",
"$",
"ctrl",
"=",
"Controller",
"::",
"curr",
"(",
")",
";",
"if",
"(",
"$",
"ctrl",
"instanceof",
"HailPageController",
")",
"{",
"$",
"link",
"=",
"$",
"ctrl",
"->",
"Link",
"(",
")",
";",
"}",
"else",
"{",
"//If outside HailPageController try to find the first Hail Page\r",
"$",
"page",
"=",
"HailPage",
"::",
"get",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"page",
")",
")",
"{",
"$",
"link",
"=",
"$",
"page",
"->",
"Link",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"link",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"return",
"$",
"link",
".",
"\"article/\"",
".",
"$",
"this",
"->",
"HailID",
".",
"'/'",
".",
"Convert",
"::",
"raw2url",
"(",
"$",
"this",
"->",
"Title",
")",
";",
"}"
] | Return the Article link for the current HailPageController
@return string | [
"Return",
"the",
"Article",
"link",
"for",
"the",
"current",
"HailPageController"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Article.php#L262-L280 |
32,547 | firebrandhq/silverstripe-hail | src/Models/Article.php | Article.getLinkForPage | public function getLinkForPage($page)
{
return $page->Link() . "article/" . $this->HailID . '/' . Convert::raw2url($this->Title);
} | php | public function getLinkForPage($page)
{
return $page->Link() . "article/" . $this->HailID . '/' . Convert::raw2url($this->Title);
} | [
"public",
"function",
"getLinkForPage",
"(",
"$",
"page",
")",
"{",
"return",
"$",
"page",
"->",
"Link",
"(",
")",
".",
"\"article/\"",
".",
"$",
"this",
"->",
"HailID",
".",
"'/'",
".",
"Convert",
"::",
"raw2url",
"(",
"$",
"this",
"->",
"Title",
")",
";",
"}"
] | Return the Article link for specified HailPage
@param HailPage $page
@return string | [
"Return",
"the",
"Article",
"link",
"for",
"specified",
"HailPage"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Article.php#L288-L291 |
32,548 | firebrandhq/silverstripe-hail | src/Models/Article.php | Article.getTagList | public function getTagList()
{
$string = '';
foreach ($this->PublicTags() as $t) {
$string .= Convert::raw2url($t->Name) . ' ';
}
return trim($string);
} | php | public function getTagList()
{
$string = '';
foreach ($this->PublicTags() as $t) {
$string .= Convert::raw2url($t->Name) . ' ';
}
return trim($string);
} | [
"public",
"function",
"getTagList",
"(",
")",
"{",
"$",
"string",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"PublicTags",
"(",
")",
"as",
"$",
"t",
")",
"{",
"$",
"string",
".=",
"Convert",
"::",
"raw2url",
"(",
"$",
"t",
"->",
"Name",
")",
".",
"' '",
";",
"}",
"return",
"trim",
"(",
"$",
"string",
")",
";",
"}"
] | List of this Article's public tag names separated by spaces.
Suitable to be used as CSS classes.
@return string | [
"List",
"of",
"this",
"Article",
"s",
"public",
"tag",
"names",
"separated",
"by",
"spaces",
"."
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Article.php#L340-L347 |
32,549 | firebrandhq/silverstripe-hail | src/Models/Article.php | Article.getAllImages | public function getAllImages()
{
$images = new ArrayList();
if ($this->hasHeroImage()) {
$images->push($this->HeroImage());
}
if ($this->hasGalleryImages()) {
$images->merge($this->ImageGallery());
}
$images->removeDuplicates('HailID');
return $images;
} | php | public function getAllImages()
{
$images = new ArrayList();
if ($this->hasHeroImage()) {
$images->push($this->HeroImage());
}
if ($this->hasGalleryImages()) {
$images->merge($this->ImageGallery());
}
$images->removeDuplicates('HailID');
return $images;
} | [
"public",
"function",
"getAllImages",
"(",
")",
"{",
"$",
"images",
"=",
"new",
"ArrayList",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasHeroImage",
"(",
")",
")",
"{",
"$",
"images",
"->",
"push",
"(",
"$",
"this",
"->",
"HeroImage",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasGalleryImages",
"(",
")",
")",
"{",
"$",
"images",
"->",
"merge",
"(",
"$",
"this",
"->",
"ImageGallery",
"(",
")",
")",
";",
"}",
"$",
"images",
"->",
"removeDuplicates",
"(",
"'HailID'",
")",
";",
"return",
"$",
"images",
";",
"}"
] | List of this Article's images
Includes the Hero Image
@return ArrayList | [
"List",
"of",
"this",
"Article",
"s",
"images"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Article.php#L356-L368 |
32,550 | firebrandhq/silverstripe-hail | src/Models/Article.php | Article.getAllVideos | public function getAllVideos()
{
$videos = new ArrayList();
if ($this->hasHeroVideo()) {
$videos->push($this->HeroVideo());
}
if ($this->hasGalleryVideos()) {
$videos->merge($this->VideoGallery());
}
$videos->removeDuplicates('HailID');
return $videos;
} | php | public function getAllVideos()
{
$videos = new ArrayList();
if ($this->hasHeroVideo()) {
$videos->push($this->HeroVideo());
}
if ($this->hasGalleryVideos()) {
$videos->merge($this->VideoGallery());
}
$videos->removeDuplicates('HailID');
return $videos;
} | [
"public",
"function",
"getAllVideos",
"(",
")",
"{",
"$",
"videos",
"=",
"new",
"ArrayList",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasHeroVideo",
"(",
")",
")",
"{",
"$",
"videos",
"->",
"push",
"(",
"$",
"this",
"->",
"HeroVideo",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasGalleryVideos",
"(",
")",
")",
"{",
"$",
"videos",
"->",
"merge",
"(",
"$",
"this",
"->",
"VideoGallery",
"(",
")",
")",
";",
"}",
"$",
"videos",
"->",
"removeDuplicates",
"(",
"'HailID'",
")",
";",
"return",
"$",
"videos",
";",
"}"
] | List of this Article's videos
Includes the Hero Video
@return ArrayList | [
"List",
"of",
"this",
"Article",
"s",
"videos"
] | fd655b7a568f8d5f6a8f888f39368618596f794e | https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Article.php#L377-L389 |
32,551 | czim/laravel-processor | src/PipelineProcessor.php | PipelineProcessor.doProcessing | protected function doProcessing()
{
$this->prepareProcessContext();
// initialization process pipeline
$initSteps = $this->initProcessSteps();
if ( ! empty($initSteps)) {
$this->context = app(Pipeline::class)
->send($this->context)
->through($initSteps)
->then(function (ProcessContextInterface $context) {
return $context;
});
$this->afterInitSteps();
}
// main pipeline (actual processing)
$steps = $this->processSteps();
if ($this->databaseTransaction) DB::beginTransaction();
try {
$this->context = app(Pipeline::class)
->send($this->context)
->through($steps)
->then(function(ProcessContextInterface $context) {
if ($this->databaseTransaction) DB::commit();
return $context;
});
} catch (Exception $e) {
if ($this->databaseTransaction) DB::rollBack();
$this->onExceptionInPipeline($e);
throw $e;
}
$this->afterPipeline();
$this->populateResult();
} | php | protected function doProcessing()
{
$this->prepareProcessContext();
// initialization process pipeline
$initSteps = $this->initProcessSteps();
if ( ! empty($initSteps)) {
$this->context = app(Pipeline::class)
->send($this->context)
->through($initSteps)
->then(function (ProcessContextInterface $context) {
return $context;
});
$this->afterInitSteps();
}
// main pipeline (actual processing)
$steps = $this->processSteps();
if ($this->databaseTransaction) DB::beginTransaction();
try {
$this->context = app(Pipeline::class)
->send($this->context)
->through($steps)
->then(function(ProcessContextInterface $context) {
if ($this->databaseTransaction) DB::commit();
return $context;
});
} catch (Exception $e) {
if ($this->databaseTransaction) DB::rollBack();
$this->onExceptionInPipeline($e);
throw $e;
}
$this->afterPipeline();
$this->populateResult();
} | [
"protected",
"function",
"doProcessing",
"(",
")",
"{",
"$",
"this",
"->",
"prepareProcessContext",
"(",
")",
";",
"// initialization process pipeline",
"$",
"initSteps",
"=",
"$",
"this",
"->",
"initProcessSteps",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"initSteps",
")",
")",
"{",
"$",
"this",
"->",
"context",
"=",
"app",
"(",
"Pipeline",
"::",
"class",
")",
"->",
"send",
"(",
"$",
"this",
"->",
"context",
")",
"->",
"through",
"(",
"$",
"initSteps",
")",
"->",
"then",
"(",
"function",
"(",
"ProcessContextInterface",
"$",
"context",
")",
"{",
"return",
"$",
"context",
";",
"}",
")",
";",
"$",
"this",
"->",
"afterInitSteps",
"(",
")",
";",
"}",
"// main pipeline (actual processing)",
"$",
"steps",
"=",
"$",
"this",
"->",
"processSteps",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"databaseTransaction",
")",
"DB",
"::",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"context",
"=",
"app",
"(",
"Pipeline",
"::",
"class",
")",
"->",
"send",
"(",
"$",
"this",
"->",
"context",
")",
"->",
"through",
"(",
"$",
"steps",
")",
"->",
"then",
"(",
"function",
"(",
"ProcessContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"databaseTransaction",
")",
"DB",
"::",
"commit",
"(",
")",
";",
"return",
"$",
"context",
";",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"databaseTransaction",
")",
"DB",
"::",
"rollBack",
"(",
")",
";",
"$",
"this",
"->",
"onExceptionInPipeline",
"(",
"$",
"e",
")",
";",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"afterPipeline",
"(",
")",
";",
"$",
"this",
"->",
"populateResult",
"(",
")",
";",
"}"
] | Performs the actual processing | [
"Performs",
"the",
"actual",
"processing"
] | 3d0025cd463653b7a8981ff52cebdafbe978f000 | https://github.com/czim/laravel-processor/blob/3d0025cd463653b7a8981ff52cebdafbe978f000/src/PipelineProcessor.php#L77-L131 |
32,552 | flipboxfactory/craft-ember | src/helpers/ObjectHelper.php | ObjectHelper.findClassFromConfig | public static function findClassFromConfig(&$config, bool $removeClass = false)
{
// Normalize the config
if (is_string($config)) {
// Set as class
$class = $config;
// Clear class from config
$config = '';
} elseif (is_object($config)) {
return get_class($config);
} else {
// Force Array
if (!is_array($config)) {
$config = ArrayHelper::toArray($config, [], false);
}
if ($removeClass) {
if (!$class = ArrayHelper::remove($config, 'class')) {
$class = ArrayHelper::remove($config, 'type');
}
} else {
$class = ArrayHelper::getValue(
$config,
'class',
ArrayHelper::getValue($config, 'type')
);
}
}
return $class;
} | php | public static function findClassFromConfig(&$config, bool $removeClass = false)
{
// Normalize the config
if (is_string($config)) {
// Set as class
$class = $config;
// Clear class from config
$config = '';
} elseif (is_object($config)) {
return get_class($config);
} else {
// Force Array
if (!is_array($config)) {
$config = ArrayHelper::toArray($config, [], false);
}
if ($removeClass) {
if (!$class = ArrayHelper::remove($config, 'class')) {
$class = ArrayHelper::remove($config, 'type');
}
} else {
$class = ArrayHelper::getValue(
$config,
'class',
ArrayHelper::getValue($config, 'type')
);
}
}
return $class;
} | [
"public",
"static",
"function",
"findClassFromConfig",
"(",
"&",
"$",
"config",
",",
"bool",
"$",
"removeClass",
"=",
"false",
")",
"{",
"// Normalize the config",
"if",
"(",
"is_string",
"(",
"$",
"config",
")",
")",
"{",
"// Set as class",
"$",
"class",
"=",
"$",
"config",
";",
"// Clear class from config",
"$",
"config",
"=",
"''",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"config",
")",
")",
"{",
"return",
"get_class",
"(",
"$",
"config",
")",
";",
"}",
"else",
"{",
"// Force Array",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"ArrayHelper",
"::",
"toArray",
"(",
"$",
"config",
",",
"[",
"]",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"removeClass",
")",
"{",
"if",
"(",
"!",
"$",
"class",
"=",
"ArrayHelper",
"::",
"remove",
"(",
"$",
"config",
",",
"'class'",
")",
")",
"{",
"$",
"class",
"=",
"ArrayHelper",
"::",
"remove",
"(",
"$",
"config",
",",
"'type'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"class",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"config",
",",
"'class'",
",",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"config",
",",
"'type'",
")",
")",
";",
"}",
"}",
"return",
"$",
"class",
";",
"}"
] | Find a class from a config
@param $config
@param bool $removeClass
@return null|string | [
"Find",
"a",
"class",
"from",
"a",
"config"
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/ObjectHelper.php#L126-L157 |
32,553 | flipboxfactory/craft-ember | src/records/FieldAttributeTrait.php | FieldAttributeTrait.getFieldId | public function getFieldId()
{
$fieldId = $this->getAttribute('fieldId');
if (null === $fieldId && null !== $this->field) {
$fieldId = $this->$fieldId = $this->field->id;
}
return $fieldId;
} | php | public function getFieldId()
{
$fieldId = $this->getAttribute('fieldId');
if (null === $fieldId && null !== $this->field) {
$fieldId = $this->$fieldId = $this->field->id;
}
return $fieldId;
} | [
"public",
"function",
"getFieldId",
"(",
")",
"{",
"$",
"fieldId",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'fieldId'",
")",
";",
"if",
"(",
"null",
"===",
"$",
"fieldId",
"&&",
"null",
"!==",
"$",
"this",
"->",
"field",
")",
"{",
"$",
"fieldId",
"=",
"$",
"this",
"->",
"$",
"fieldId",
"=",
"$",
"this",
"->",
"field",
"->",
"id",
";",
"}",
"return",
"$",
"fieldId",
";",
"}"
] | Get associated fieldId
@return int|null | [
"Get",
"associated",
"fieldId"
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/FieldAttributeTrait.php#L54-L62 |
32,554 | faustbrian/Laravel-Alert | src/Alert.php | Alert.success | public function success($message, ?string $title = null): self
{
return $this->flash($message, config('laravel-alert.classes.success'), $title);
} | php | public function success($message, ?string $title = null): self
{
return $this->flash($message, config('laravel-alert.classes.success'), $title);
} | [
"public",
"function",
"success",
"(",
"$",
"message",
",",
"?",
"string",
"$",
"title",
"=",
"null",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"flash",
"(",
"$",
"message",
",",
"config",
"(",
"'laravel-alert.classes.success'",
")",
",",
"$",
"title",
")",
";",
"}"
] | Flash a success alert.
@param string|array $message
@param string|null $title
@return \BrianFaust\Alert\Alert | [
"Flash",
"a",
"success",
"alert",
"."
] | d9a039b0395130e882f44b4ceb63b1d77a5429f6 | https://github.com/faustbrian/Laravel-Alert/blob/d9a039b0395130e882f44b4ceb63b1d77a5429f6/src/Alert.php#L71-L74 |
32,555 | davidecesarano/Embryo-Http | Embryo/Http/Message/Traits/RequestTrait.php | RequestTrait.setRequestTarget | protected function setRequestTarget(string $path, string $query)
{
$target = $path;
if ($target === '') {
$target = '/';
}
if ($query != '') {
$target .= '?'.$query;
}
return $target;
} | php | protected function setRequestTarget(string $path, string $query)
{
$target = $path;
if ($target === '') {
$target = '/';
}
if ($query != '') {
$target .= '?'.$query;
}
return $target;
} | [
"protected",
"function",
"setRequestTarget",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"query",
")",
"{",
"$",
"target",
"=",
"$",
"path",
";",
"if",
"(",
"$",
"target",
"===",
"''",
")",
"{",
"$",
"target",
"=",
"'/'",
";",
"}",
"if",
"(",
"$",
"query",
"!=",
"''",
")",
"{",
"$",
"target",
".=",
"'?'",
".",
"$",
"query",
";",
"}",
"return",
"$",
"target",
";",
"}"
] | Sets request target.
@param string $path
@param string $query
@return string | [
"Sets",
"request",
"target",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Traits/RequestTrait.php#L48-L59 |
32,556 | appaydin/pd-mailer | Form/TemplateForm.php | TemplateForm.getLanguageList | public function getLanguageList(ParameterBagInterface $bag)
{
$allLangs = Intl::getLanguageBundle()->getLanguageNames();
return array_flip(array_intersect_key($allLangs, array_flip($bag->get('pd_mailer.active_language'))));
} | php | public function getLanguageList(ParameterBagInterface $bag)
{
$allLangs = Intl::getLanguageBundle()->getLanguageNames();
return array_flip(array_intersect_key($allLangs, array_flip($bag->get('pd_mailer.active_language'))));
} | [
"public",
"function",
"getLanguageList",
"(",
"ParameterBagInterface",
"$",
"bag",
")",
"{",
"$",
"allLangs",
"=",
"Intl",
"::",
"getLanguageBundle",
"(",
")",
"->",
"getLanguageNames",
"(",
")",
";",
"return",
"array_flip",
"(",
"array_intersect_key",
"(",
"$",
"allLangs",
",",
"array_flip",
"(",
"$",
"bag",
"->",
"get",
"(",
"'pd_mailer.active_language'",
")",
")",
")",
")",
";",
"}"
] | Return Active Language List.
@param ParameterBagInterface $bag
@return array|bool | [
"Return",
"Active",
"Language",
"List",
"."
] | c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f | https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/Form/TemplateForm.php#L94-L99 |
32,557 | Ifnot/statistics | src/Interval.php | Interval.step | public function step($step = null)
{
if (isset($step)) {
$this->step = $step;
return $this;
} else {
return $this->step;
}
} | php | public function step($step = null)
{
if (isset($step)) {
$this->step = $step;
return $this;
} else {
return $this->step;
}
} | [
"public",
"function",
"step",
"(",
"$",
"step",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"step",
")",
")",
"{",
"$",
"this",
"->",
"step",
"=",
"$",
"step",
";",
"return",
"$",
"this",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"step",
";",
"}",
"}"
] | Set or get the step of the interval
@param null $step
@return $this|null | [
"Set",
"or",
"get",
"the",
"step",
"of",
"the",
"interval"
] | 9aba4b193b76cfdd87547b6d319917815704e5b1 | https://github.com/Ifnot/statistics/blob/9aba4b193b76cfdd87547b6d319917815704e5b1/src/Interval.php#L44-L52 |
32,558 | Ifnot/statistics | src/Interval.php | Interval.start | public function start(Carbon $date = null)
{
if (isset($date)) {
$date->hour = 0;
$date->minute = 0;
$date->second = 0;
$this->start = $date;
return $this;
} else {
return $this->start;
}
} | php | public function start(Carbon $date = null)
{
if (isset($date)) {
$date->hour = 0;
$date->minute = 0;
$date->second = 0;
$this->start = $date;
return $this;
} else {
return $this->start;
}
} | [
"public",
"function",
"start",
"(",
"Carbon",
"$",
"date",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"date",
")",
")",
"{",
"$",
"date",
"->",
"hour",
"=",
"0",
";",
"$",
"date",
"->",
"minute",
"=",
"0",
";",
"$",
"date",
"->",
"second",
"=",
"0",
";",
"$",
"this",
"->",
"start",
"=",
"$",
"date",
";",
"return",
"$",
"this",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"start",
";",
"}",
"}"
] | Set or get the start date of the interval
@param Carbon|null $date
@return $this|Carbon | [
"Set",
"or",
"get",
"the",
"start",
"date",
"of",
"the",
"interval"
] | 9aba4b193b76cfdd87547b6d319917815704e5b1 | https://github.com/Ifnot/statistics/blob/9aba4b193b76cfdd87547b6d319917815704e5b1/src/Interval.php#L60-L73 |
32,559 | Ifnot/statistics | src/Interval.php | Interval.getStepIndexFromDate | public function getStepIndexFromDate(Carbon $date)
{
switch ($this->step) {
case "yearly":
$date->month = 1;
case "monthly":
$date->day = 1;
case "daily":
$date->hour = 0;
case "hourly":
$date->minute = 0;
default:
$date->second = 0;
break;
}
return $date->format($this->getStepFormat());
} | php | public function getStepIndexFromDate(Carbon $date)
{
switch ($this->step) {
case "yearly":
$date->month = 1;
case "monthly":
$date->day = 1;
case "daily":
$date->hour = 0;
case "hourly":
$date->minute = 0;
default:
$date->second = 0;
break;
}
return $date->format($this->getStepFormat());
} | [
"public",
"function",
"getStepIndexFromDate",
"(",
"Carbon",
"$",
"date",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"step",
")",
"{",
"case",
"\"yearly\"",
":",
"$",
"date",
"->",
"month",
"=",
"1",
";",
"case",
"\"monthly\"",
":",
"$",
"date",
"->",
"day",
"=",
"1",
";",
"case",
"\"daily\"",
":",
"$",
"date",
"->",
"hour",
"=",
"0",
";",
"case",
"\"hourly\"",
":",
"$",
"date",
"->",
"minute",
"=",
"0",
";",
"default",
":",
"$",
"date",
"->",
"second",
"=",
"0",
";",
"break",
";",
"}",
"return",
"$",
"date",
"->",
"format",
"(",
"$",
"this",
"->",
"getStepFormat",
"(",
")",
")",
";",
"}"
] | Converting a date to his step index according to the step precision of the interval
@param Carbon $date
@return string | [
"Converting",
"a",
"date",
"to",
"his",
"step",
"index",
"according",
"to",
"the",
"step",
"precision",
"of",
"the",
"interval"
] | 9aba4b193b76cfdd87547b6d319917815704e5b1 | https://github.com/Ifnot/statistics/blob/9aba4b193b76cfdd87547b6d319917815704e5b1/src/Interval.php#L123-L140 |
32,560 | Ifnot/statistics | src/Interval.php | Interval.getStepFormat | public function getStepFormat()
{
if ($this->lang == 'en') {
switch ($this->step) {
case self::$YEARLY:
return 'Y';
break;
case self::$MONTHLY:
return 'Y-m';
break;
case self::$DAILY:
return 'Y-m-d';
break;
case self::$HOURLY:
return 'Y-m-d H:00';
break;
}
} elseif ($this->lang == 'fr') {
switch ($this->step) {
case self::$YEARLY:
return 'Y';
break;
case self::$MONTHLY:
return 'm/Y';
break;
case self::$DAILY:
return 'd/m/Y';
break;
case self::$HOURLY:
return 'd/m/Y H:00';
break;
}
}
return false;
} | php | public function getStepFormat()
{
if ($this->lang == 'en') {
switch ($this->step) {
case self::$YEARLY:
return 'Y';
break;
case self::$MONTHLY:
return 'Y-m';
break;
case self::$DAILY:
return 'Y-m-d';
break;
case self::$HOURLY:
return 'Y-m-d H:00';
break;
}
} elseif ($this->lang == 'fr') {
switch ($this->step) {
case self::$YEARLY:
return 'Y';
break;
case self::$MONTHLY:
return 'm/Y';
break;
case self::$DAILY:
return 'd/m/Y';
break;
case self::$HOURLY:
return 'd/m/Y H:00';
break;
}
}
return false;
} | [
"public",
"function",
"getStepFormat",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lang",
"==",
"'en'",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"step",
")",
"{",
"case",
"self",
"::",
"$",
"YEARLY",
":",
"return",
"'Y'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"MONTHLY",
":",
"return",
"'Y-m'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"DAILY",
":",
"return",
"'Y-m-d'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"HOURLY",
":",
"return",
"'Y-m-d H:00'",
";",
"break",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"lang",
"==",
"'fr'",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"step",
")",
"{",
"case",
"self",
"::",
"$",
"YEARLY",
":",
"return",
"'Y'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"MONTHLY",
":",
"return",
"'m/Y'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"DAILY",
":",
"return",
"'d/m/Y'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"HOURLY",
":",
"return",
"'d/m/Y H:00'",
";",
"break",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Get the step index format of the step precision
@return array | [
"Get",
"the",
"step",
"index",
"format",
"of",
"the",
"step",
"precision"
] | 9aba4b193b76cfdd87547b6d319917815704e5b1 | https://github.com/Ifnot/statistics/blob/9aba4b193b76cfdd87547b6d319917815704e5b1/src/Interval.php#L147-L182 |
32,561 | Ifnot/statistics | src/Interval.php | Interval.getStepIncrement | public function getStepIncrement()
{
switch ($this->step) {
case self::$YEARLY:
return '+1 year';
break;
case self::$MONTHLY:
return '+1 month';
break;
case self::$DAILY:
return '+1 day';
break;
case self::$HOURLY:
return '+1 hour';
break;
}
} | php | public function getStepIncrement()
{
switch ($this->step) {
case self::$YEARLY:
return '+1 year';
break;
case self::$MONTHLY:
return '+1 month';
break;
case self::$DAILY:
return '+1 day';
break;
case self::$HOURLY:
return '+1 hour';
break;
}
} | [
"public",
"function",
"getStepIncrement",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"step",
")",
"{",
"case",
"self",
"::",
"$",
"YEARLY",
":",
"return",
"'+1 year'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"MONTHLY",
":",
"return",
"'+1 month'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"DAILY",
":",
"return",
"'+1 day'",
";",
"break",
";",
"case",
"self",
"::",
"$",
"HOURLY",
":",
"return",
"'+1 hour'",
";",
"break",
";",
"}",
"}"
] | Get the string corresponding to the incrementation of each steps
@return string | [
"Get",
"the",
"string",
"corresponding",
"to",
"the",
"incrementation",
"of",
"each",
"steps"
] | 9aba4b193b76cfdd87547b6d319917815704e5b1 | https://github.com/Ifnot/statistics/blob/9aba4b193b76cfdd87547b6d319917815704e5b1/src/Interval.php#L189-L205 |
32,562 | davidecesarano/Embryo-Http | Embryo/Http/Factory/ServerRequestFactory.php | ServerRequestFactory.createServerRequestFromServer | public function createServerRequestFromServer(): ServerRequestInterface
{
$method = $_SERVER['REQUEST_METHOD'];
$uri = (new UriFactory)->createUriFromServer($_SERVER);
$files = (new UploadedFileFactory)->createUploadedFileFromServer($_FILES);
$request = $this->createServerRequest($method, $uri, $_SERVER);
$request = $request->withQueryParams($_GET);
$request = $request->withParsedBody($_POST);
$request = $request->withCookieParams($_COOKIE);
$request = $request->withUploadedFiles($files);
return $request;
} | php | public function createServerRequestFromServer(): ServerRequestInterface
{
$method = $_SERVER['REQUEST_METHOD'];
$uri = (new UriFactory)->createUriFromServer($_SERVER);
$files = (new UploadedFileFactory)->createUploadedFileFromServer($_FILES);
$request = $this->createServerRequest($method, $uri, $_SERVER);
$request = $request->withQueryParams($_GET);
$request = $request->withParsedBody($_POST);
$request = $request->withCookieParams($_COOKIE);
$request = $request->withUploadedFiles($files);
return $request;
} | [
"public",
"function",
"createServerRequestFromServer",
"(",
")",
":",
"ServerRequestInterface",
"{",
"$",
"method",
"=",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
";",
"$",
"uri",
"=",
"(",
"new",
"UriFactory",
")",
"->",
"createUriFromServer",
"(",
"$",
"_SERVER",
")",
";",
"$",
"files",
"=",
"(",
"new",
"UploadedFileFactory",
")",
"->",
"createUploadedFileFromServer",
"(",
"$",
"_FILES",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"createServerRequest",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"_SERVER",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withQueryParams",
"(",
"$",
"_GET",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withParsedBody",
"(",
"$",
"_POST",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withCookieParams",
"(",
"$",
"_COOKIE",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withUploadedFiles",
"(",
"$",
"files",
")",
";",
"return",
"$",
"request",
";",
"}"
] | Creates a new server-side request from server.
@return ServerRequestInterface | [
"Creates",
"a",
"new",
"server",
"-",
"side",
"request",
"from",
"server",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Factory/ServerRequestFactory.php#L39-L51 |
32,563 | Vectorface/cache | src/SQLCache.php | SQLCache.get | public function get($key)
{
try {
$stmt = $this->getStatement(__METHOD__, self::GET_SQL);
$stmt->execute(array($key));
} catch (\PDOException $e) {
return false;
}
$result = $stmt->fetchColumn();
return empty($result) ? false : unserialize($result);
} | php | public function get($key)
{
try {
$stmt = $this->getStatement(__METHOD__, self::GET_SQL);
$stmt->execute(array($key));
} catch (\PDOException $e) {
return false;
}
$result = $stmt->fetchColumn();
return empty($result) ? false : unserialize($result);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"try",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"getStatement",
"(",
"__METHOD__",
",",
"self",
"::",
"GET_SQL",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"array",
"(",
"$",
"key",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"$",
"stmt",
"->",
"fetchColumn",
"(",
")",
";",
"return",
"empty",
"(",
"$",
"result",
")",
"?",
"false",
":",
"unserialize",
"(",
"$",
"result",
")",
";",
"}"
] | Attempt to retrieve an entry from the cache.
The value will be unserialized before it is returned.
@return mixed Returns the value stored for the given key, or false on failure. | [
"Attempt",
"to",
"retrieve",
"an",
"entry",
"from",
"the",
"cache",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/SQLCache.php#L95-L105 |
32,564 | Vectorface/cache | src/SQLCache.php | SQLCache.clean | public function clean()
{
try {
$this->conn->exec(self::CLEAN_SQL);
} catch (\PDOException $e) {
return false;
}
return true;
} | php | public function clean()
{
try {
$this->conn->exec(self::CLEAN_SQL);
} catch (\PDOException $e) {
return false;
}
return true;
} | [
"public",
"function",
"clean",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"conn",
"->",
"exec",
"(",
"self",
"::",
"CLEAN_SQL",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Remove any expired items from the cache.
@return bool True if successful, false otherwise. | [
"Remove",
"any",
"expired",
"items",
"from",
"the",
"cache",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/SQLCache.php#L156-L164 |
32,565 | Vectorface/cache | src/SQLCache.php | SQLCache.flush | public function flush()
{
try {
$this->conn->exec(self::FLUSH_SQL);
} catch (\PDOException $e) {
return false;
}
return true;
} | php | public function flush()
{
try {
$this->conn->exec(self::FLUSH_SQL);
} catch (\PDOException $e) {
return false;
}
return true;
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"conn",
"->",
"exec",
"(",
"self",
"::",
"FLUSH_SQL",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Flush the cache; Empty it of all entries.
@return bool True if successful, false otherwise. | [
"Flush",
"the",
"cache",
";",
"Empty",
"it",
"of",
"all",
"entries",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/SQLCache.php#L171-L179 |
32,566 | Vectorface/cache | src/SQLCache.php | SQLCache.getStatement | private function getStatement($method, $sql)
{
if (empty($this->statements[$method])) {
$this->statements[$method] = $this->conn->prepare($sql);
}
return $this->statements[$method];
} | php | private function getStatement($method, $sql)
{
if (empty($this->statements[$method])) {
$this->statements[$method] = $this->conn->prepare($sql);
}
return $this->statements[$method];
} | [
"private",
"function",
"getStatement",
"(",
"$",
"method",
",",
"$",
"sql",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"statements",
"[",
"$",
"method",
"]",
")",
")",
"{",
"$",
"this",
"->",
"statements",
"[",
"$",
"method",
"]",
"=",
"$",
"this",
"->",
"conn",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"}",
"return",
"$",
"this",
"->",
"statements",
"[",
"$",
"method",
"]",
";",
"}"
] | Get a prepared statement for the given method's SQL.
The result is stored internally to limit repeated preparing of SQL.
@param string $method The method name to for which this statement applies.
@param string $sql The SQL statement associated with the given method.
@return \PDOStatement Returns the prepared statement for the given method. | [
"Get",
"a",
"prepared",
"statement",
"for",
"the",
"given",
"method",
"s",
"SQL",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/SQLCache.php#L190-L196 |
32,567 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Plugin/Package.php | Package.find | protected function find($directory)
{
if ($iterator = parent::find($directory)) {
foreach ($iterator as $file) {
if (is_file($file) && is_readable($file) && $contents = file_get_contents($file)) {
if (preg_match($this->packageNamePattern, basename($file))) {
$plugin = (object) null;
$plugin->name = implode('_v', array_slice(explode('_v', basename($file, '.txt')), 0, -1));
$this->plugin[] = $plugin;
$this->package[] = $contents;
}
}
}
}
return !empty($this->plugin);
} | php | protected function find($directory)
{
if ($iterator = parent::find($directory)) {
foreach ($iterator as $file) {
if (is_file($file) && is_readable($file) && $contents = file_get_contents($file)) {
if (preg_match($this->packageNamePattern, basename($file))) {
$plugin = (object) null;
$plugin->name = implode('_v', array_slice(explode('_v', basename($file, '.txt')), 0, -1));
$this->plugin[] = $plugin;
$this->package[] = $contents;
}
}
}
}
return !empty($this->plugin);
} | [
"protected",
"function",
"find",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"$",
"iterator",
"=",
"parent",
"::",
"find",
"(",
"$",
"directory",
")",
")",
"{",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
"&&",
"is_readable",
"(",
"$",
"file",
")",
"&&",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"this",
"->",
"packageNamePattern",
",",
"basename",
"(",
"$",
"file",
")",
")",
")",
"{",
"$",
"plugin",
"=",
"(",
"object",
")",
"null",
";",
"$",
"plugin",
"->",
"name",
"=",
"implode",
"(",
"'_v'",
",",
"array_slice",
"(",
"explode",
"(",
"'_v'",
",",
"basename",
"(",
"$",
"file",
",",
"'.txt'",
")",
")",
",",
"0",
",",
"-",
"1",
")",
")",
";",
"$",
"this",
"->",
"plugin",
"[",
"]",
"=",
"$",
"plugin",
";",
"$",
"this",
"->",
"package",
"[",
"]",
"=",
"$",
"contents",
";",
"}",
"}",
"}",
"}",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"plugin",
")",
";",
"}"
] | Finds plugin packages.
@param string $directory
@return bool | [
"Finds",
"plugin",
"packages",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Plugin/Package.php#L47-L63 |
32,568 | davidecesarano/Embryo-Http | Embryo/Http/Message/Response.php | Response.withStatus | public function withStatus($status, $reasonPhrase = '')
{
$status = $this->filterStatus($status);
$reasonPhrase = $this->filterReasonPhrase($status, $reasonPhrase);
$clone = clone $this;
$clone->status = $status;
$clone->reasonPhrase = $reasonPhrase;
return $clone;
} | php | public function withStatus($status, $reasonPhrase = '')
{
$status = $this->filterStatus($status);
$reasonPhrase = $this->filterReasonPhrase($status, $reasonPhrase);
$clone = clone $this;
$clone->status = $status;
$clone->reasonPhrase = $reasonPhrase;
return $clone;
} | [
"public",
"function",
"withStatus",
"(",
"$",
"status",
",",
"$",
"reasonPhrase",
"=",
"''",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"filterStatus",
"(",
"$",
"status",
")",
";",
"$",
"reasonPhrase",
"=",
"$",
"this",
"->",
"filterReasonPhrase",
"(",
"$",
"status",
",",
"$",
"reasonPhrase",
")",
";",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"$",
"clone",
"->",
"status",
"=",
"$",
"status",
";",
"$",
"clone",
"->",
"reasonPhrase",
"=",
"$",
"reasonPhrase",
";",
"return",
"$",
"clone",
";",
"}"
] | Returns an instance with the specified status code and, optionally, reason phrase.
@param int $status
@param string $reasonPhrase
@return static
@throws InvalidArgumentException | [
"Returns",
"an",
"instance",
"with",
"the",
"specified",
"status",
"code",
"and",
"optionally",
"reason",
"phrase",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Response.php#L68-L77 |
32,569 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Installer/AdminTheme.php | AdminTheme.getInstallPath | public function getInstallPath(PackageInterface $package)
{
$textpattern = new Textpattern();
$path = $textpattern->getRelativePath();
$themes = $path . '/admin-themes';
// Textpattern <= 4.5.x uses 'theme' directory.
if (!file_exists($themes)) {
$themes = $path . '/theme';
}
return $themes . '/' . basename($package->getPrettyName());
} | php | public function getInstallPath(PackageInterface $package)
{
$textpattern = new Textpattern();
$path = $textpattern->getRelativePath();
$themes = $path . '/admin-themes';
// Textpattern <= 4.5.x uses 'theme' directory.
if (!file_exists($themes)) {
$themes = $path . '/theme';
}
return $themes . '/' . basename($package->getPrettyName());
} | [
"public",
"function",
"getInstallPath",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"textpattern",
"=",
"new",
"Textpattern",
"(",
")",
";",
"$",
"path",
"=",
"$",
"textpattern",
"->",
"getRelativePath",
"(",
")",
";",
"$",
"themes",
"=",
"$",
"path",
".",
"'/admin-themes'",
";",
"// Textpattern <= 4.5.x uses 'theme' directory.",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"themes",
")",
")",
"{",
"$",
"themes",
"=",
"$",
"path",
".",
"'/theme'",
";",
"}",
"return",
"$",
"themes",
".",
"'/'",
".",
"basename",
"(",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
")",
";",
"}"
] | Points the package to the theme directory.
@param PackageInterface $package
@return string | [
"Points",
"the",
"package",
"to",
"the",
"theme",
"directory",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Installer/AdminTheme.php#L54-L66 |
32,570 | CradlePHP/cradle-system | src/Fieldset/Validator.php | Validator.getUpdateErrors | public static function getUpdateErrors(array $data, array $errors = [])
{
if (isset($data['singular']) && empty($data['singular'])) {
$errors['singular'] = 'Singular is required';
}
if (isset($data['plural']) && empty($data['plural'])) {
$errors['plural'] = 'Plural is required';
}
if (isset($data['name']) && empty($data['name'])) {
$errors['name'] = 'Keyword is required';
}
if (!isset($data['fields']) || empty($data['fields'])) {
$errors['fields'] = 'Fields is required';
}
return self::getOptionalErrors($data, $errors);
} | php | public static function getUpdateErrors(array $data, array $errors = [])
{
if (isset($data['singular']) && empty($data['singular'])) {
$errors['singular'] = 'Singular is required';
}
if (isset($data['plural']) && empty($data['plural'])) {
$errors['plural'] = 'Plural is required';
}
if (isset($data['name']) && empty($data['name'])) {
$errors['name'] = 'Keyword is required';
}
if (!isset($data['fields']) || empty($data['fields'])) {
$errors['fields'] = 'Fields is required';
}
return self::getOptionalErrors($data, $errors);
} | [
"public",
"static",
"function",
"getUpdateErrors",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"errors",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'singular'",
"]",
")",
"&&",
"empty",
"(",
"$",
"data",
"[",
"'singular'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"'singular'",
"]",
"=",
"'Singular is required'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'plural'",
"]",
")",
"&&",
"empty",
"(",
"$",
"data",
"[",
"'plural'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"'plural'",
"]",
"=",
"'Plural is required'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
"&&",
"empty",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"'name'",
"]",
"=",
"'Keyword is required'",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'fields'",
"]",
")",
"||",
"empty",
"(",
"$",
"data",
"[",
"'fields'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"'fields'",
"]",
"=",
"'Fields is required'",
";",
"}",
"return",
"self",
"::",
"getOptionalErrors",
"(",
"$",
"data",
",",
"$",
"errors",
")",
";",
"}"
] | Returns Table Update Errors
@param *array $data
@param array $errors
@return array | [
"Returns",
"Table",
"Update",
"Errors"
] | 3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c | https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset/Validator.php#L72-L91 |
32,571 | Vectorface/cache | src/TempFileCache.php | TempFileCache.getTempDir | private function getTempDir($directory)
{
if (empty($directory) || !is_string($directory)) {
$classParts = explode("\\", get_called_class());
return sys_get_temp_dir() . '/' . end($classParts);
} elseif (strpos($directory, '/') !== 0) {
return sys_get_temp_dir() . '/' . $directory;
} else {
return $directory;
}
} | php | private function getTempDir($directory)
{
if (empty($directory) || !is_string($directory)) {
$classParts = explode("\\", get_called_class());
return sys_get_temp_dir() . '/' . end($classParts);
} elseif (strpos($directory, '/') !== 0) {
return sys_get_temp_dir() . '/' . $directory;
} else {
return $directory;
}
} | [
"private",
"function",
"getTempDir",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"directory",
")",
"||",
"!",
"is_string",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"classParts",
"=",
"explode",
"(",
"\"\\\\\"",
",",
"get_called_class",
"(",
")",
")",
";",
"return",
"sys_get_temp_dir",
"(",
")",
".",
"'/'",
".",
"end",
"(",
"$",
"classParts",
")",
";",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"directory",
",",
"'/'",
")",
"!==",
"0",
")",
"{",
"return",
"sys_get_temp_dir",
"(",
")",
".",
"'/'",
".",
"$",
"directory",
";",
"}",
"else",
"{",
"return",
"$",
"directory",
";",
"}",
"}"
] | Generate a consistent temporary directory based on a requested directory name.
@param string $directory The name or path of a temporary directory.
@return string The directory name, resolved to a full path. | [
"Generate",
"a",
"consistent",
"temporary",
"directory",
"based",
"on",
"a",
"requested",
"directory",
"name",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/TempFileCache.php#L50-L60 |
32,572 | Vectorface/cache | src/TempFileCache.php | TempFileCache.getCacheFiles | private function getCacheFiles()
{
if (!($files = @scandir($this->directory, 1))) {
return false;
}
$negExtLen = -1 * strlen($this->extension);
$return = array();
foreach ($files as $file) {
if (substr($file, $negExtLen) === $this->extension) {
$return[] = $this->directory . '/' . $file;
}
}
return $return;
} | php | private function getCacheFiles()
{
if (!($files = @scandir($this->directory, 1))) {
return false;
}
$negExtLen = -1 * strlen($this->extension);
$return = array();
foreach ($files as $file) {
if (substr($file, $negExtLen) === $this->extension) {
$return[] = $this->directory . '/' . $file;
}
}
return $return;
} | [
"private",
"function",
"getCacheFiles",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"files",
"=",
"@",
"scandir",
"(",
"$",
"this",
"->",
"directory",
",",
"1",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"negExtLen",
"=",
"-",
"1",
"*",
"strlen",
"(",
"$",
"this",
"->",
"extension",
")",
";",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"$",
"negExtLen",
")",
"===",
"$",
"this",
"->",
"extension",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"this",
"->",
"directory",
".",
"'/'",
".",
"$",
"file",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] | Finds all files with the cache extension in the cache directory
@return Array Returns an array of filenames that represent cached entries. | [
"Finds",
"all",
"files",
"with",
"the",
"cache",
"extension",
"in",
"the",
"cache",
"directory"
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/TempFileCache.php#L166-L180 |
32,573 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Textpattern/Find.php | Find.find | public function find($directory)
{
if (($path = $this->isConfig('./textpattern/config.php')) !== false) {
return realpath($path);
}
if (!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) {
return false;
}
$iterator = new \RecursiveDirectoryIterator(realpath($directory));
$iterator = new \RecursiveIteratorIterator($iterator);
foreach ($iterator as $file) {
if (($path = $this->isConfig($file)) !== false) {
return $path;
}
}
return false;
} | php | public function find($directory)
{
if (($path = $this->isConfig('./textpattern/config.php')) !== false) {
return realpath($path);
}
if (!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) {
return false;
}
$iterator = new \RecursiveDirectoryIterator(realpath($directory));
$iterator = new \RecursiveIteratorIterator($iterator);
foreach ($iterator as $file) {
if (($path = $this->isConfig($file)) !== false) {
return $path;
}
}
return false;
} | [
"public",
"function",
"find",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"isConfig",
"(",
"'./textpattern/config.php'",
")",
")",
"!==",
"false",
")",
"{",
"return",
"realpath",
"(",
"$",
"path",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"directory",
")",
"||",
"!",
"is_dir",
"(",
"$",
"directory",
")",
"||",
"!",
"is_readable",
"(",
"$",
"directory",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"realpath",
"(",
"$",
"directory",
")",
")",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"iterator",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"isConfig",
"(",
"$",
"file",
")",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"path",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Finds the closest Textpattern installation path.
@param string The directory
@return string|bool The path, or FALSE | [
"Finds",
"the",
"closest",
"Textpattern",
"installation",
"path",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Textpattern/Find.php#L74-L94 |
32,574 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Textpattern/Find.php | Find.isConfig | protected function isConfig($file)
{
if (basename($file) === 'config.php' && is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);
if ($contents && strpos($contents, 'txpcfg') !== false && file_exists(dirname($file) . '/publish.php')) {
return dirname($file);
}
}
return false;
} | php | protected function isConfig($file)
{
if (basename($file) === 'config.php' && is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);
if ($contents && strpos($contents, 'txpcfg') !== false && file_exists(dirname($file) . '/publish.php')) {
return dirname($file);
}
}
return false;
} | [
"protected",
"function",
"isConfig",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"basename",
"(",
"$",
"file",
")",
"===",
"'config.php'",
"&&",
"is_file",
"(",
"$",
"file",
")",
"&&",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"contents",
"&&",
"strpos",
"(",
"$",
"contents",
",",
"'txpcfg'",
")",
"!==",
"false",
"&&",
"file_exists",
"(",
"dirname",
"(",
"$",
"file",
")",
".",
"'/publish.php'",
")",
")",
"{",
"return",
"dirname",
"(",
"$",
"file",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Whether the file is a config.php.
@param string $file The filename
@return string|bool Path to the directory, or FALSE | [
"Whether",
"the",
"file",
"is",
"a",
"config",
".",
"php",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Textpattern/Find.php#L102-L113 |
32,575 | gocom/textpattern-installer | src/Textpattern/Composer/Installer/Textpattern/Find.php | Find.getRelativePath | public function getRelativePath()
{
$current = realpath('./');
if ($current !== false && strpos(self::$path.'/', $current.'/') === 0) {
return rtrim('./' . substr(self::$path, strlen($current) + 1), '\\/');
}
throw new \InvalidArgumentException(
'Unable to resolve relative path to Textpattern installation location '.
'from the current working directory.'
);
} | php | public function getRelativePath()
{
$current = realpath('./');
if ($current !== false && strpos(self::$path.'/', $current.'/') === 0) {
return rtrim('./' . substr(self::$path, strlen($current) + 1), '\\/');
}
throw new \InvalidArgumentException(
'Unable to resolve relative path to Textpattern installation location '.
'from the current working directory.'
);
} | [
"public",
"function",
"getRelativePath",
"(",
")",
"{",
"$",
"current",
"=",
"realpath",
"(",
"'./'",
")",
";",
"if",
"(",
"$",
"current",
"!==",
"false",
"&&",
"strpos",
"(",
"self",
"::",
"$",
"path",
".",
"'/'",
",",
"$",
"current",
".",
"'/'",
")",
"===",
"0",
")",
"{",
"return",
"rtrim",
"(",
"'./'",
".",
"substr",
"(",
"self",
"::",
"$",
"path",
",",
"strlen",
"(",
"$",
"current",
")",
"+",
"1",
")",
",",
"'\\\\/'",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unable to resolve relative path to Textpattern installation location '",
".",
"'from the current working directory.'",
")",
";",
"}"
] | Gets relative path to the Textpattern installation.
The path is relative to the current working directory.
@return string The path
@throws \InvalidArgumentException | [
"Gets",
"relative",
"path",
"to",
"the",
"Textpattern",
"installation",
"."
] | 804271de54177ebd294a4a19d409ae7fc2317935 | https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Textpattern/Find.php#L123-L135 |
32,576 | peterkahl/Apple-iOS-build | src/iOSbuild.php | iOSbuild.getVersion | public static function getVersion($needle) {
self::populate();
if (array_key_exists($needle, self::$BuildVer)) {
return self::$BuildVer[$needle];
}
$builds = array();
$versions = array();
foreach (self::$BuildVer as $code => $val) {
$builds[] = $code;
$versions[] = $val;
}
$candidate = false;
if (preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $needle, $matchNeedle)) {
# Walk backwards
$count = count($builds);
for ($key = $count - 1; $key >= 0; $key--) {
preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $builds[$key], $matchCode);
if ($matchCode[1] . $matchCode[2] . $matchCode[3] == $matchNeedle[1] . $matchNeedle[2] . $matchNeedle[3]) {
return $versions[$key];
}
if ($matchCode[1] . $matchCode[2] == $matchNeedle[1] . $matchNeedle[2] && $matchNeedle[3] > $matchCode[3]) {
$candidate = $versions[$key];
}
}
}
if (!empty($candidate)) {
return preg_replace('/b\d+$/', '', $candidate);
}
return $candidate;
} | php | public static function getVersion($needle) {
self::populate();
if (array_key_exists($needle, self::$BuildVer)) {
return self::$BuildVer[$needle];
}
$builds = array();
$versions = array();
foreach (self::$BuildVer as $code => $val) {
$builds[] = $code;
$versions[] = $val;
}
$candidate = false;
if (preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $needle, $matchNeedle)) {
# Walk backwards
$count = count($builds);
for ($key = $count - 1; $key >= 0; $key--) {
preg_match('/^(\d+)([A-Z])(\d+)([a-z])?$/', $builds[$key], $matchCode);
if ($matchCode[1] . $matchCode[2] . $matchCode[3] == $matchNeedle[1] . $matchNeedle[2] . $matchNeedle[3]) {
return $versions[$key];
}
if ($matchCode[1] . $matchCode[2] == $matchNeedle[1] . $matchNeedle[2] && $matchNeedle[3] > $matchCode[3]) {
$candidate = $versions[$key];
}
}
}
if (!empty($candidate)) {
return preg_replace('/b\d+$/', '', $candidate);
}
return $candidate;
} | [
"public",
"static",
"function",
"getVersion",
"(",
"$",
"needle",
")",
"{",
"self",
"::",
"populate",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"needle",
",",
"self",
"::",
"$",
"BuildVer",
")",
")",
"{",
"return",
"self",
"::",
"$",
"BuildVer",
"[",
"$",
"needle",
"]",
";",
"}",
"$",
"builds",
"=",
"array",
"(",
")",
";",
"$",
"versions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"BuildVer",
"as",
"$",
"code",
"=>",
"$",
"val",
")",
"{",
"$",
"builds",
"[",
"]",
"=",
"$",
"code",
";",
"$",
"versions",
"[",
"]",
"=",
"$",
"val",
";",
"}",
"$",
"candidate",
"=",
"false",
";",
"if",
"(",
"preg_match",
"(",
"'/^(\\d+)([A-Z])(\\d+)([a-z])?$/'",
",",
"$",
"needle",
",",
"$",
"matchNeedle",
")",
")",
"{",
"# Walk backwards",
"$",
"count",
"=",
"count",
"(",
"$",
"builds",
")",
";",
"for",
"(",
"$",
"key",
"=",
"$",
"count",
"-",
"1",
";",
"$",
"key",
">=",
"0",
";",
"$",
"key",
"--",
")",
"{",
"preg_match",
"(",
"'/^(\\d+)([A-Z])(\\d+)([a-z])?$/'",
",",
"$",
"builds",
"[",
"$",
"key",
"]",
",",
"$",
"matchCode",
")",
";",
"if",
"(",
"$",
"matchCode",
"[",
"1",
"]",
".",
"$",
"matchCode",
"[",
"2",
"]",
".",
"$",
"matchCode",
"[",
"3",
"]",
"==",
"$",
"matchNeedle",
"[",
"1",
"]",
".",
"$",
"matchNeedle",
"[",
"2",
"]",
".",
"$",
"matchNeedle",
"[",
"3",
"]",
")",
"{",
"return",
"$",
"versions",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"matchCode",
"[",
"1",
"]",
".",
"$",
"matchCode",
"[",
"2",
"]",
"==",
"$",
"matchNeedle",
"[",
"1",
"]",
".",
"$",
"matchNeedle",
"[",
"2",
"]",
"&&",
"$",
"matchNeedle",
"[",
"3",
"]",
">",
"$",
"matchCode",
"[",
"3",
"]",
")",
"{",
"$",
"candidate",
"=",
"$",
"versions",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"candidate",
")",
")",
"{",
"return",
"preg_replace",
"(",
"'/b\\d+$/'",
",",
"''",
",",
"$",
"candidate",
")",
";",
"}",
"return",
"$",
"candidate",
";",
"}"
] | Takes iOS build code and returns corresponding iOS version.
@param string $needle
@return mixed
@throws \Exception | [
"Takes",
"iOS",
"build",
"code",
"and",
"returns",
"corresponding",
"iOS",
"version",
"."
] | 90c0e0db5e87f2f4487048ecb6b81a3395e33cab | https://github.com/peterkahl/Apple-iOS-build/blob/90c0e0db5e87f2f4487048ecb6b81a3395e33cab/src/iOSbuild.php#L49-L78 |
32,577 | peterkahl/Apple-iOS-build | src/iOSbuild.php | iOSbuild.populate | private static function populate() {
$arr = array();
$epoch = 0;
if (!isset(self::$BuildVer) || !is_array(self::$BuildVer)) {
require __DIR__ .'/data.php';
if (empty($arr) || !is_array($arr) || empty($epoch)) {
throw new \Exception('Error fetching file data.php');
}
self::$DataTimestamp = $epoch;
self::$BuildVer = $arr;
}
} | php | private static function populate() {
$arr = array();
$epoch = 0;
if (!isset(self::$BuildVer) || !is_array(self::$BuildVer)) {
require __DIR__ .'/data.php';
if (empty($arr) || !is_array($arr) || empty($epoch)) {
throw new \Exception('Error fetching file data.php');
}
self::$DataTimestamp = $epoch;
self::$BuildVer = $arr;
}
} | [
"private",
"static",
"function",
"populate",
"(",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"$",
"epoch",
"=",
"0",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"BuildVer",
")",
"||",
"!",
"is_array",
"(",
"self",
"::",
"$",
"BuildVer",
")",
")",
"{",
"require",
"__DIR__",
".",
"'/data.php'",
";",
"if",
"(",
"empty",
"(",
"$",
"arr",
")",
"||",
"!",
"is_array",
"(",
"$",
"arr",
")",
"||",
"empty",
"(",
"$",
"epoch",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Error fetching file data.php'",
")",
";",
"}",
"self",
"::",
"$",
"DataTimestamp",
"=",
"$",
"epoch",
";",
"self",
"::",
"$",
"BuildVer",
"=",
"$",
"arr",
";",
"}",
"}"
] | Populates associative array of iOS versions.
@throws \Exception | [
"Populates",
"associative",
"array",
"of",
"iOS",
"versions",
"."
] | 90c0e0db5e87f2f4487048ecb6b81a3395e33cab | https://github.com/peterkahl/Apple-iOS-build/blob/90c0e0db5e87f2f4487048ecb6b81a3395e33cab/src/iOSbuild.php#L87-L98 |
32,578 | peterkahl/Apple-iOS-build | src/iOSbuild.php | iOSbuild.getCalendarUA | public static function getCalendarUA($min = '5.0') {
if (strpos($min, '.') === false && ctype_digit($min)) {
$mins[0] = $min;
$mins[1] = 0;
}
else {
$mins = explode('.', $min);
}
$builds = array();
$versions = array();
$n = 0;
self::populate();
foreach (self::$BuildVer as $code => $val) {
$parts = explode('.', $val);
if ($parts[0] >= $mins[0] && $parts[1] >= $mins[1]) {
$builds[$n] = $code;
$versions[$n] = $val;
$n++;
}
}
$ran = mt_rand(0, $n - 1);
$ver = preg_replace('/b\d+$/', '', $versions[$ran]);
return 'iOS/' . $ver . ' (' . $builds[$ran] . ') dataaccessd/1.0';
} | php | public static function getCalendarUA($min = '5.0') {
if (strpos($min, '.') === false && ctype_digit($min)) {
$mins[0] = $min;
$mins[1] = 0;
}
else {
$mins = explode('.', $min);
}
$builds = array();
$versions = array();
$n = 0;
self::populate();
foreach (self::$BuildVer as $code => $val) {
$parts = explode('.', $val);
if ($parts[0] >= $mins[0] && $parts[1] >= $mins[1]) {
$builds[$n] = $code;
$versions[$n] = $val;
$n++;
}
}
$ran = mt_rand(0, $n - 1);
$ver = preg_replace('/b\d+$/', '', $versions[$ran]);
return 'iOS/' . $ver . ' (' . $builds[$ran] . ') dataaccessd/1.0';
} | [
"public",
"static",
"function",
"getCalendarUA",
"(",
"$",
"min",
"=",
"'5.0'",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"min",
",",
"'.'",
")",
"===",
"false",
"&&",
"ctype_digit",
"(",
"$",
"min",
")",
")",
"{",
"$",
"mins",
"[",
"0",
"]",
"=",
"$",
"min",
";",
"$",
"mins",
"[",
"1",
"]",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"mins",
"=",
"explode",
"(",
"'.'",
",",
"$",
"min",
")",
";",
"}",
"$",
"builds",
"=",
"array",
"(",
")",
";",
"$",
"versions",
"=",
"array",
"(",
")",
";",
"$",
"n",
"=",
"0",
";",
"self",
"::",
"populate",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"BuildVer",
"as",
"$",
"code",
"=>",
"$",
"val",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"val",
")",
";",
"if",
"(",
"$",
"parts",
"[",
"0",
"]",
">=",
"$",
"mins",
"[",
"0",
"]",
"&&",
"$",
"parts",
"[",
"1",
"]",
">=",
"$",
"mins",
"[",
"1",
"]",
")",
"{",
"$",
"builds",
"[",
"$",
"n",
"]",
"=",
"$",
"code",
";",
"$",
"versions",
"[",
"$",
"n",
"]",
"=",
"$",
"val",
";",
"$",
"n",
"++",
";",
"}",
"}",
"$",
"ran",
"=",
"mt_rand",
"(",
"0",
",",
"$",
"n",
"-",
"1",
")",
";",
"$",
"ver",
"=",
"preg_replace",
"(",
"'/b\\d+$/'",
",",
"''",
",",
"$",
"versions",
"[",
"$",
"ran",
"]",
")",
";",
"return",
"'iOS/'",
".",
"$",
"ver",
".",
"' ('",
".",
"$",
"builds",
"[",
"$",
"ran",
"]",
".",
"') dataaccessd/1.0'",
";",
"}"
] | Returns a randomly chosen iOS Calendar User Agent string.
@param string $min .... minimum version
Format: 'MAJOR.MINOR' (1 dot only)
@return string
@throws \Exception | [
"Returns",
"a",
"randomly",
"chosen",
"iOS",
"Calendar",
"User",
"Agent",
"string",
"."
] | 90c0e0db5e87f2f4487048ecb6b81a3395e33cab | https://github.com/peterkahl/Apple-iOS-build/blob/90c0e0db5e87f2f4487048ecb6b81a3395e33cab/src/iOSbuild.php#L133-L156 |
32,579 | davidecesarano/Embryo-Http | Embryo/Http/Message/Traits/ResponseTrait.php | ResponseTrait.filterStatus | protected function filterStatus(int $status)
{
$messages = $this->getMessages();
if (!isset($messages[$status])) {
throw new \InvalidArgumentException('Invalid HTTP status code');
}
return $status;
} | php | protected function filterStatus(int $status)
{
$messages = $this->getMessages();
if (!isset($messages[$status])) {
throw new \InvalidArgumentException('Invalid HTTP status code');
}
return $status;
} | [
"protected",
"function",
"filterStatus",
"(",
"int",
"$",
"status",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"getMessages",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"messages",
"[",
"$",
"status",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid HTTP status code'",
")",
";",
"}",
"return",
"$",
"status",
";",
"}"
] | Validates Http status code.
@param int $status
@return int
@throws InvalidArgumentException | [
"Validates",
"Http",
"status",
"code",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Traits/ResponseTrait.php#L103-L110 |
32,580 | davidecesarano/Embryo-Http | Embryo/Http/Message/Traits/ResponseTrait.php | ResponseTrait.filterReasonPhrase | protected function filterReasonPhrase(int $status, string $reasonPhrase = '')
{
$messages = $this->getMessages();
if ($reasonPhrase === '' && isset($messages[$status])) {
$reasonPhrase = $messages[$status];
}
return $reasonPhrase;
} | php | protected function filterReasonPhrase(int $status, string $reasonPhrase = '')
{
$messages = $this->getMessages();
if ($reasonPhrase === '' && isset($messages[$status])) {
$reasonPhrase = $messages[$status];
}
return $reasonPhrase;
} | [
"protected",
"function",
"filterReasonPhrase",
"(",
"int",
"$",
"status",
",",
"string",
"$",
"reasonPhrase",
"=",
"''",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"getMessages",
"(",
")",
";",
"if",
"(",
"$",
"reasonPhrase",
"===",
"''",
"&&",
"isset",
"(",
"$",
"messages",
"[",
"$",
"status",
"]",
")",
")",
"{",
"$",
"reasonPhrase",
"=",
"$",
"messages",
"[",
"$",
"status",
"]",
";",
"}",
"return",
"$",
"reasonPhrase",
";",
"}"
] | Validates Http status reason phrase
@param int $status
@param string $reasonPhrase
@return string
@throws InvalidArgumentException | [
"Validates",
"Http",
"status",
"reason",
"phrase"
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Traits/ResponseTrait.php#L120-L127 |
32,581 | davidecesarano/Embryo-Http | Embryo/Http/Message/Traits/ResponseTrait.php | ResponseTrait.withRedirect | public function withRedirect($url, $status = null)
{
$response = $this->withHeader('Location', (string)$url);
if (is_null($status) && $this->getStatusCode() === 200) {
$status = 302;
}
if (!is_null($status)) {
return $response->withStatus($status);
}
return $response;
} | php | public function withRedirect($url, $status = null)
{
$response = $this->withHeader('Location', (string)$url);
if (is_null($status) && $this->getStatusCode() === 200) {
$status = 302;
}
if (!is_null($status)) {
return $response->withStatus($status);
}
return $response;
} | [
"public",
"function",
"withRedirect",
"(",
"$",
"url",
",",
"$",
"status",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"withHeader",
"(",
"'Location'",
",",
"(",
"string",
")",
"$",
"url",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"status",
")",
"&&",
"$",
"this",
"->",
"getStatusCode",
"(",
")",
"===",
"200",
")",
"{",
"$",
"status",
"=",
"302",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"status",
")",
")",
"{",
"return",
"$",
"response",
"->",
"withStatus",
"(",
"$",
"status",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Prepares the response object to return an HTTP redirect
response to the client.
@param string|UriInterface $url
@param int|null $status
@return static | [
"Prepares",
"the",
"response",
"object",
"to",
"return",
"an",
"HTTP",
"redirect",
"response",
"to",
"the",
"client",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Traits/ResponseTrait.php#L149-L159 |
32,582 | davidecesarano/Embryo-Http | Embryo/Http/Message/Traits/ResponseTrait.php | ResponseTrait.withJson | public function withJson($data, int $status = null, int $options = 0)
{
$json = json_encode($data, $options);
if ($json === false) {
throw new \RuntimeException(json_last_error_msg(), json_last_error());
}
$response = $this->write($json);
$response = $response->withHeader('Content-Type', 'application/json;charset=utf-8');
if (isset($status)) {
return $response->withStatus($status);
}
return $response;
} | php | public function withJson($data, int $status = null, int $options = 0)
{
$json = json_encode($data, $options);
if ($json === false) {
throw new \RuntimeException(json_last_error_msg(), json_last_error());
}
$response = $this->write($json);
$response = $response->withHeader('Content-Type', 'application/json;charset=utf-8');
if (isset($status)) {
return $response->withStatus($status);
}
return $response;
} | [
"public",
"function",
"withJson",
"(",
"$",
"data",
",",
"int",
"$",
"status",
"=",
"null",
",",
"int",
"$",
"options",
"=",
"0",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"data",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"json",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"json_last_error_msg",
"(",
")",
",",
"json_last_error",
"(",
")",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"write",
"(",
"$",
"json",
")",
";",
"$",
"response",
"=",
"$",
"response",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"'application/json;charset=utf-8'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"status",
")",
")",
"{",
"return",
"$",
"response",
"->",
"withStatus",
"(",
"$",
"status",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Prepares the response object to return an HTTP json
response to the client.
@param mixed $data
@param int $status
@param int $options
@return static
@throws RuntimeException | [
"Prepares",
"the",
"response",
"object",
"to",
"return",
"an",
"HTTP",
"json",
"response",
"to",
"the",
"client",
"."
] | 5ff81c07fbff3abed051d710f0837544465887c8 | https://github.com/davidecesarano/Embryo-Http/blob/5ff81c07fbff3abed051d710f0837544465887c8/Embryo/Http/Message/Traits/ResponseTrait.php#L171-L185 |
32,583 | flipboxfactory/craft-ember | src/elements/ExplicitElementTrait.php | ExplicitElementTrait.getOne | public static function getOne($criteria)
{
if (null === ($element = static::findOne($criteria))) {
throw new ElementNotFoundException(
sprintf(
"Organization not found with the following criteria: %s",
Json::encode($criteria)
)
);
}
return $element;
} | php | public static function getOne($criteria)
{
if (null === ($element = static::findOne($criteria))) {
throw new ElementNotFoundException(
sprintf(
"Organization not found with the following criteria: %s",
Json::encode($criteria)
)
);
}
return $element;
} | [
"public",
"static",
"function",
"getOne",
"(",
"$",
"criteria",
")",
"{",
"if",
"(",
"null",
"===",
"(",
"$",
"element",
"=",
"static",
"::",
"findOne",
"(",
"$",
"criteria",
")",
")",
")",
"{",
"throw",
"new",
"ElementNotFoundException",
"(",
"sprintf",
"(",
"\"Organization not found with the following criteria: %s\"",
",",
"Json",
"::",
"encode",
"(",
"$",
"criteria",
")",
")",
")",
";",
"}",
"return",
"$",
"element",
";",
"}"
] | Returns a single element instance by a primary key or a set of element criteria parameters.
The method accepts:
- an int: query by a single ID value and return the corresponding element (or null if not found).
- an array of name-value pairs: query by a set of parameter values and return the first element
matching all of them (or null if not found).
Note that this method will automatically call the `one()` method and return an
[[ElementInterface|\craft\base\Element]] instance. For example,
```php
// find a single entry whose ID is 10
$entry = Entry::findOne(10);
// the above code is equivalent to:
$entry = Entry::find->id(10)->one();
// find the first user whose email ends in "example.com"
$user = User::findOne(['email' => '*example.com']);
// the above code is equivalent to:
$user = User::find()->email('*example.com')->one();
```
@param mixed $criteria The element ID or a set of element criteria parameters
@return static Element instance matching the condition, or null if nothing matches.
@throws ElementNotFoundException | [
"Returns",
"a",
"single",
"element",
"instance",
"by",
"a",
"primary",
"key",
"or",
"a",
"set",
"of",
"element",
"criteria",
"parameters",
"."
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/elements/ExplicitElementTrait.php#L112-L124 |
32,584 | Vectorface/cache | src/TieredCache.php | TieredCache.get | public function get($entry)
{
$value = false;
foreach ($this->caches as $cache) {
$value = $cache->get($entry);
if ($value !== false) {
return $value;
}
}
return $value;
} | php | public function get($entry)
{
$value = false;
foreach ($this->caches as $cache) {
$value = $cache->get($entry);
if ($value !== false) {
return $value;
}
}
return $value;
} | [
"public",
"function",
"get",
"(",
"$",
"entry",
")",
"{",
"$",
"value",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"caches",
"as",
"$",
"cache",
")",
"{",
"$",
"value",
"=",
"$",
"cache",
"->",
"get",
"(",
"$",
"entry",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"false",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | Get an entry from the first cache that can provide a value.
@param string $entry The cache key.
@return mixed The cached value, or FALSE if not found. | [
"Get",
"an",
"entry",
"from",
"the",
"first",
"cache",
"that",
"can",
"provide",
"a",
"value",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/TieredCache.php#L63-L74 |
32,585 | Vectorface/cache | src/TieredCache.php | TieredCache.set | public function set($entry, $value, $ttl = false)
{
$setCallback = function ($setSuccess, $cache) use ($entry, $value, $ttl) {
return $setSuccess || $cache->set($entry, $value, $ttl);
};
return array_reduce($this->caches, $setCallback, false);
} | php | public function set($entry, $value, $ttl = false)
{
$setCallback = function ($setSuccess, $cache) use ($entry, $value, $ttl) {
return $setSuccess || $cache->set($entry, $value, $ttl);
};
return array_reduce($this->caches, $setCallback, false);
} | [
"public",
"function",
"set",
"(",
"$",
"entry",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"false",
")",
"{",
"$",
"setCallback",
"=",
"function",
"(",
"$",
"setSuccess",
",",
"$",
"cache",
")",
"use",
"(",
"$",
"entry",
",",
"$",
"value",
",",
"$",
"ttl",
")",
"{",
"return",
"$",
"setSuccess",
"||",
"$",
"cache",
"->",
"set",
"(",
"$",
"entry",
",",
"$",
"value",
",",
"$",
"ttl",
")",
";",
"}",
";",
"return",
"array_reduce",
"(",
"$",
"this",
"->",
"caches",
",",
"$",
"setCallback",
",",
"false",
")",
";",
"}"
] | Set an entry in all caches in the stack.
@param string $entry The cache key.
@param mixed $value The value to be stored.
@param int $ttl The time-to-live for the cache entry.
@return bool Returns true if saving succeeded to any cache in the stack. | [
"Set",
"an",
"entry",
"in",
"all",
"caches",
"in",
"the",
"stack",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/TieredCache.php#L84-L90 |
32,586 | Vectorface/cache | src/TieredCache.php | TieredCache.clean | public function clean()
{
$cleanCallback = function ($allCleaned, $cache) {
return $allCleaned && $cache->clean();
};
return array_reduce($this->caches, $cleanCallback, true);
} | php | public function clean()
{
$cleanCallback = function ($allCleaned, $cache) {
return $allCleaned && $cache->clean();
};
return array_reduce($this->caches, $cleanCallback, true);
} | [
"public",
"function",
"clean",
"(",
")",
"{",
"$",
"cleanCallback",
"=",
"function",
"(",
"$",
"allCleaned",
",",
"$",
"cache",
")",
"{",
"return",
"$",
"allCleaned",
"&&",
"$",
"cache",
"->",
"clean",
"(",
")",
";",
"}",
";",
"return",
"array_reduce",
"(",
"$",
"this",
"->",
"caches",
",",
"$",
"cleanCallback",
",",
"true",
")",
";",
"}"
] | Perform a clean operation on all caches.
@return bool Returns true if clean succeeded on all caches in the stack. | [
"Perform",
"a",
"clean",
"operation",
"on",
"all",
"caches",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/TieredCache.php#L111-L117 |
32,587 | Vectorface/cache | src/TieredCache.php | TieredCache.flush | public function flush()
{
$flushCallback = function ($allFlushed, $cache) {
return $allFlushed && $cache->flush();
};
return array_reduce($this->caches, $flushCallback, true);
} | php | public function flush()
{
$flushCallback = function ($allFlushed, $cache) {
return $allFlushed && $cache->flush();
};
return array_reduce($this->caches, $flushCallback, true);
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"$",
"flushCallback",
"=",
"function",
"(",
"$",
"allFlushed",
",",
"$",
"cache",
")",
"{",
"return",
"$",
"allFlushed",
"&&",
"$",
"cache",
"->",
"flush",
"(",
")",
";",
"}",
";",
"return",
"array_reduce",
"(",
"$",
"this",
"->",
"caches",
",",
"$",
"flushCallback",
",",
"true",
")",
";",
"}"
] | Perform a flush operation on all caches.
@return bool Returns true if flush succeeded on all caches in the stack. | [
"Perform",
"a",
"flush",
"operation",
"on",
"all",
"caches",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/TieredCache.php#L124-L130 |
32,588 | flipboxfactory/craft-ember | src/objects/ElementMutatorTrait.php | ElementMutatorTrait.setElement | public function setElement($element = null)
{
$this->element = null;
if (!$element = $this->internalResolveElement($element)) {
$this->element = $this->elementId = null;
} else {
/** @var Element $element */
$this->elementId = $element->id;
$this->element = $element;
}
return $this;
} | php | public function setElement($element = null)
{
$this->element = null;
if (!$element = $this->internalResolveElement($element)) {
$this->element = $this->elementId = null;
} else {
/** @var Element $element */
$this->elementId = $element->id;
$this->element = $element;
}
return $this;
} | [
"public",
"function",
"setElement",
"(",
"$",
"element",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"element",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"element",
"=",
"$",
"this",
"->",
"internalResolveElement",
"(",
"$",
"element",
")",
")",
"{",
"$",
"this",
"->",
"element",
"=",
"$",
"this",
"->",
"elementId",
"=",
"null",
";",
"}",
"else",
"{",
"/** @var Element $element */",
"$",
"this",
"->",
"elementId",
"=",
"$",
"element",
"->",
"id",
";",
"$",
"this",
"->",
"element",
"=",
"$",
"element",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Associate a element
@param mixed $element
@return $this | [
"Associate",
"a",
"element"
] | 9185b885b404b1cb272a0983023eb7c6c0df61c8 | https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/objects/ElementMutatorTrait.php#L61-L74 |
32,589 | arillo/silverstripe-elements | src/ElementsExtension.php | ElementsExtension.move_elements_manager | public static function move_elements_manager(
FieldList $fields,
string $relationName,
string $newTabName = 'Root.Main',
string $insertBefore = null
): FieldList
{
$itemsGf = $fields->dataFieldByName($relationName);
$fields
->removeByName($relationName)
->addFieldToTab($newTabName, $itemsGf, $insertBefore)
;
return $fields;
} | php | public static function move_elements_manager(
FieldList $fields,
string $relationName,
string $newTabName = 'Root.Main',
string $insertBefore = null
): FieldList
{
$itemsGf = $fields->dataFieldByName($relationName);
$fields
->removeByName($relationName)
->addFieldToTab($newTabName, $itemsGf, $insertBefore)
;
return $fields;
} | [
"public",
"static",
"function",
"move_elements_manager",
"(",
"FieldList",
"$",
"fields",
",",
"string",
"$",
"relationName",
",",
"string",
"$",
"newTabName",
"=",
"'Root.Main'",
",",
"string",
"$",
"insertBefore",
"=",
"null",
")",
":",
"FieldList",
"{",
"$",
"itemsGf",
"=",
"$",
"fields",
"->",
"dataFieldByName",
"(",
"$",
"relationName",
")",
";",
"$",
"fields",
"->",
"removeByName",
"(",
"$",
"relationName",
")",
"->",
"addFieldToTab",
"(",
"$",
"newTabName",
",",
"$",
"itemsGf",
",",
"$",
"insertBefore",
")",
";",
"return",
"$",
"fields",
";",
"}"
] | Move an elements gridfield to an other tab.
@param FieldList $fields
@param string $relationName
@param string $newTabName
@param string $insertBefore optional: insert before an other field
@return FieldList the altered fields | [
"Move",
"an",
"elements",
"gridfield",
"to",
"an",
"other",
"tab",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementsExtension.php#L86-L100 |
32,590 | arillo/silverstripe-elements | src/ElementsExtension.php | ElementsExtension.create_default_elements | public static function create_default_elements(SiteTree $record): int
{
$count = 0;
if (!$record || !$record->ID)
{
throw new SS_HTTPResponse_Exception("Bad record ID #" . (int)$data['ID'], 404);
}
if ($relationNames = ElementsExtension::page_element_relation_names($record))
{
$defaultElements = $record->getDefaultElements();
if (count($relationNames) > 0)
{
foreach ($relationNames as $relationName => $elementsClasses)
{
if (isset($defaultElements[$relationName]))
{
$elementClasses = $defaultElements[$relationName];
foreach ($elementClasses as $className)
{
$definedElements = $record->ElementsByRelation($relationName)->map('ClassName', 'ClassName');
if (!isset($definedElements[$className]))
{
$element = new $className;
$element->populate('PageID', $record->ID, $relationName);
$element->write();
$count++;
}
}
}
}
}
}
return $count;
} | php | public static function create_default_elements(SiteTree $record): int
{
$count = 0;
if (!$record || !$record->ID)
{
throw new SS_HTTPResponse_Exception("Bad record ID #" . (int)$data['ID'], 404);
}
if ($relationNames = ElementsExtension::page_element_relation_names($record))
{
$defaultElements = $record->getDefaultElements();
if (count($relationNames) > 0)
{
foreach ($relationNames as $relationName => $elementsClasses)
{
if (isset($defaultElements[$relationName]))
{
$elementClasses = $defaultElements[$relationName];
foreach ($elementClasses as $className)
{
$definedElements = $record->ElementsByRelation($relationName)->map('ClassName', 'ClassName');
if (!isset($definedElements[$className]))
{
$element = new $className;
$element->populate('PageID', $record->ID, $relationName);
$element->write();
$count++;
}
}
}
}
}
}
return $count;
} | [
"public",
"static",
"function",
"create_default_elements",
"(",
"SiteTree",
"$",
"record",
")",
":",
"int",
"{",
"$",
"count",
"=",
"0",
";",
"if",
"(",
"!",
"$",
"record",
"||",
"!",
"$",
"record",
"->",
"ID",
")",
"{",
"throw",
"new",
"SS_HTTPResponse_Exception",
"(",
"\"Bad record ID #\"",
".",
"(",
"int",
")",
"$",
"data",
"[",
"'ID'",
"]",
",",
"404",
")",
";",
"}",
"if",
"(",
"$",
"relationNames",
"=",
"ElementsExtension",
"::",
"page_element_relation_names",
"(",
"$",
"record",
")",
")",
"{",
"$",
"defaultElements",
"=",
"$",
"record",
"->",
"getDefaultElements",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"relationNames",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"relationNames",
"as",
"$",
"relationName",
"=>",
"$",
"elementsClasses",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"defaultElements",
"[",
"$",
"relationName",
"]",
")",
")",
"{",
"$",
"elementClasses",
"=",
"$",
"defaultElements",
"[",
"$",
"relationName",
"]",
";",
"foreach",
"(",
"$",
"elementClasses",
"as",
"$",
"className",
")",
"{",
"$",
"definedElements",
"=",
"$",
"record",
"->",
"ElementsByRelation",
"(",
"$",
"relationName",
")",
"->",
"map",
"(",
"'ClassName'",
",",
"'ClassName'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"definedElements",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"element",
"=",
"new",
"$",
"className",
";",
"$",
"element",
"->",
"populate",
"(",
"'PageID'",
",",
"$",
"record",
"->",
"ID",
",",
"$",
"relationName",
")",
";",
"$",
"element",
"->",
"write",
"(",
")",
";",
"$",
"count",
"++",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] | Create_default elements , if setup via config @see self::getDefaultElements().
@param SiteTree $record
@return int | [
"Create_default",
"elements",
"if",
"setup",
"via",
"config"
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementsExtension.php#L107-L141 |
32,591 | arillo/silverstripe-elements | src/ElementsExtension.php | ElementsExtension.validate_class_inheritance | public static function validate_class_inheritance(array $relation): array
{
return array_filter($relation, function($className)
{
if (
ClassInfo::exists($className)
&& (is_a(singleton($className), ElementBase::class))
) {
return $className;
}
user_error('Your element needs to extend from ' . ElementBase::class, E_USER_WARNING);
});
} | php | public static function validate_class_inheritance(array $relation): array
{
return array_filter($relation, function($className)
{
if (
ClassInfo::exists($className)
&& (is_a(singleton($className), ElementBase::class))
) {
return $className;
}
user_error('Your element needs to extend from ' . ElementBase::class, E_USER_WARNING);
});
} | [
"public",
"static",
"function",
"validate_class_inheritance",
"(",
"array",
"$",
"relation",
")",
":",
"array",
"{",
"return",
"array_filter",
"(",
"$",
"relation",
",",
"function",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"ClassInfo",
"::",
"exists",
"(",
"$",
"className",
")",
"&&",
"(",
"is_a",
"(",
"singleton",
"(",
"$",
"className",
")",
",",
"ElementBase",
"::",
"class",
")",
")",
")",
"{",
"return",
"$",
"className",
";",
"}",
"user_error",
"(",
"'Your element needs to extend from '",
".",
"ElementBase",
"::",
"class",
",",
"E_USER_WARNING",
")",
";",
"}",
")",
";",
"}"
] | Check if all provied classes derive from ElementBase.
@param array $relation
@return array | [
"Check",
"if",
"all",
"provied",
"classes",
"derive",
"from",
"ElementBase",
"."
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementsExtension.php#L148-L160 |
32,592 | arillo/silverstripe-elements | src/ElementsExtension.php | ElementsExtension.onAfterDelete | public function onAfterDelete()
{
$staged = Versioned::get_by_stage($this->owner->ClassName, Versioned::DRAFT)
->byID($this->owner->ID)
;
$live = Versioned::get_by_stage($this->owner->ClassName, Versioned::LIVE)
->byID($this->owner->ID)
;
if (!$staged && !$live)
{
foreach($this->owner->Elements() as $element)
{
$element->deleteFromStage(Versioned::LIVE);
$element->deleteFromStage(Versioned::DRAFT);
$element->delete();
}
}
parent::onAfterDelete();
} | php | public function onAfterDelete()
{
$staged = Versioned::get_by_stage($this->owner->ClassName, Versioned::DRAFT)
->byID($this->owner->ID)
;
$live = Versioned::get_by_stage($this->owner->ClassName, Versioned::LIVE)
->byID($this->owner->ID)
;
if (!$staged && !$live)
{
foreach($this->owner->Elements() as $element)
{
$element->deleteFromStage(Versioned::LIVE);
$element->deleteFromStage(Versioned::DRAFT);
$element->delete();
}
}
parent::onAfterDelete();
} | [
"public",
"function",
"onAfterDelete",
"(",
")",
"{",
"$",
"staged",
"=",
"Versioned",
"::",
"get_by_stage",
"(",
"$",
"this",
"->",
"owner",
"->",
"ClassName",
",",
"Versioned",
"::",
"DRAFT",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"owner",
"->",
"ID",
")",
";",
"$",
"live",
"=",
"Versioned",
"::",
"get_by_stage",
"(",
"$",
"this",
"->",
"owner",
"->",
"ClassName",
",",
"Versioned",
"::",
"LIVE",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"owner",
"->",
"ID",
")",
";",
"if",
"(",
"!",
"$",
"staged",
"&&",
"!",
"$",
"live",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"owner",
"->",
"Elements",
"(",
")",
"as",
"$",
"element",
")",
"{",
"$",
"element",
"->",
"deleteFromStage",
"(",
"Versioned",
"::",
"LIVE",
")",
";",
"$",
"element",
"->",
"deleteFromStage",
"(",
"Versioned",
"::",
"DRAFT",
")",
";",
"$",
"element",
"->",
"delete",
"(",
")",
";",
"}",
"}",
"parent",
"::",
"onAfterDelete",
"(",
")",
";",
"}"
] | Remove all related elements | [
"Remove",
"all",
"related",
"elements"
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementsExtension.php#L273-L293 |
32,593 | arillo/silverstripe-elements | src/ElementsExtension.php | ElementsExtension.ElementsByRelation | public function ElementsByRelation(string $relationName)
{
$filter = [ 'RelationName' => $relationName ];
if (
$this->owner->hasExtension(ElementBase::FLUENT_CLASS)
&& !is_a(Controller::curr(), LeftAndMain::class)
) {
$filter['Visible'] = true;
}
return $this->owner
->Elements()
->filter($filter)
;
} | php | public function ElementsByRelation(string $relationName)
{
$filter = [ 'RelationName' => $relationName ];
if (
$this->owner->hasExtension(ElementBase::FLUENT_CLASS)
&& !is_a(Controller::curr(), LeftAndMain::class)
) {
$filter['Visible'] = true;
}
return $this->owner
->Elements()
->filter($filter)
;
} | [
"public",
"function",
"ElementsByRelation",
"(",
"string",
"$",
"relationName",
")",
"{",
"$",
"filter",
"=",
"[",
"'RelationName'",
"=>",
"$",
"relationName",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"hasExtension",
"(",
"ElementBase",
"::",
"FLUENT_CLASS",
")",
"&&",
"!",
"is_a",
"(",
"Controller",
"::",
"curr",
"(",
")",
",",
"LeftAndMain",
"::",
"class",
")",
")",
"{",
"$",
"filter",
"[",
"'Visible'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"owner",
"->",
"Elements",
"(",
")",
"->",
"filter",
"(",
"$",
"filter",
")",
";",
"}"
] | Getter for items by relation name
@param string $relationName
@return DataList | [
"Getter",
"for",
"items",
"by",
"relation",
"name"
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementsExtension.php#L324-L338 |
32,594 | arillo/silverstripe-elements | src/ElementsExtension.php | ElementsExtension.gridFieldForElementRelation | public function gridFieldForElementRelation(
FieldList $fields,
$relationName,
$relation
) {
// sort relations
asort($relation);
$config = GridFieldConfig_RelationEditor::create()
->removeComponentsByType(GridFieldDeleteAction::class)
->removeComponentsByType(GridFieldAddExistingAutocompleter::class)
->addComponent(new GridFieldOrderableRows('Sort'))
->addComponent(new GridFieldDeleteAction())
;
// attach default elements action
if (
$this->owner->canEdit()
&& !$this->defaultsCreated()
&& $this->owner->getDefaultElements()
&& isset($this->owner->getDefaultElements()[$relationName])
) {
$config->addComponent(new GridFieldDefaultElementsButton());
}
if (count($relation) > 1)
{
$config
->removeComponentsByType(GridFieldAddNewButton::class)
->addComponent($multiClass = new GridFieldAddNewMultiClass())
;
$multiClass->setClasses(ElementsExtension::map_classnames($relation));
}
$config
->getComponentByType(GridFieldPaginator::class)
->setItemsPerPage(150)
;
$columns = [
'CMSTypeInfo' => _t(__CLASS__ . '.CMSTypeInfo', 'Type'),
'CMSSummary' => _t(__CLASS__ . '.CMSSummary', 'Summary'),
];
if ($this->owner->hasExtension(ElementBase::FLUENT_CLASS))
{
$columns['Languages'] = _t(__CLASS__ . '.Languages', 'Lang');
}
if (count($relation) == 1
&& $summaryFields = singleton($relation[0])->summaryFields()
) {
$columns = array_merge($columns, $summaryFields);
}
$config
->getComponentByType(GridFieldDataColumns::class)
->setDisplayFields($columns)
;
$tabName = "Root.{$relationName}";
// if only one relation is set, add gridfield to main tab
if (count($this->elementRelations) == 1) $tabName = "Root.Main";
$label = _t("Element_Relations.{$relationName}", $relationName);
$config
->getComponentByType(GridFieldDetailForm::class)
->setItemRequestClass(VersionedElement_ItemRequest::class)
;
$fields->addFieldToTab(
$tabName,
$gridField = GridField::create(
$relationName,
$label,
$this->owner->ElementsByRelation($relationName),
$config
)
);
$gridField->addExtraClass('elements-gridfield');
if (count($relation) == 1) $gridField->setModelClass($relation[0]);
if (count($this->elementRelations) > 1)
{
$fields
->findOrMakeTab($tabName)
->setTitle($label)
;
}
return $this->owner;
} | php | public function gridFieldForElementRelation(
FieldList $fields,
$relationName,
$relation
) {
// sort relations
asort($relation);
$config = GridFieldConfig_RelationEditor::create()
->removeComponentsByType(GridFieldDeleteAction::class)
->removeComponentsByType(GridFieldAddExistingAutocompleter::class)
->addComponent(new GridFieldOrderableRows('Sort'))
->addComponent(new GridFieldDeleteAction())
;
// attach default elements action
if (
$this->owner->canEdit()
&& !$this->defaultsCreated()
&& $this->owner->getDefaultElements()
&& isset($this->owner->getDefaultElements()[$relationName])
) {
$config->addComponent(new GridFieldDefaultElementsButton());
}
if (count($relation) > 1)
{
$config
->removeComponentsByType(GridFieldAddNewButton::class)
->addComponent($multiClass = new GridFieldAddNewMultiClass())
;
$multiClass->setClasses(ElementsExtension::map_classnames($relation));
}
$config
->getComponentByType(GridFieldPaginator::class)
->setItemsPerPage(150)
;
$columns = [
'CMSTypeInfo' => _t(__CLASS__ . '.CMSTypeInfo', 'Type'),
'CMSSummary' => _t(__CLASS__ . '.CMSSummary', 'Summary'),
];
if ($this->owner->hasExtension(ElementBase::FLUENT_CLASS))
{
$columns['Languages'] = _t(__CLASS__ . '.Languages', 'Lang');
}
if (count($relation) == 1
&& $summaryFields = singleton($relation[0])->summaryFields()
) {
$columns = array_merge($columns, $summaryFields);
}
$config
->getComponentByType(GridFieldDataColumns::class)
->setDisplayFields($columns)
;
$tabName = "Root.{$relationName}";
// if only one relation is set, add gridfield to main tab
if (count($this->elementRelations) == 1) $tabName = "Root.Main";
$label = _t("Element_Relations.{$relationName}", $relationName);
$config
->getComponentByType(GridFieldDetailForm::class)
->setItemRequestClass(VersionedElement_ItemRequest::class)
;
$fields->addFieldToTab(
$tabName,
$gridField = GridField::create(
$relationName,
$label,
$this->owner->ElementsByRelation($relationName),
$config
)
);
$gridField->addExtraClass('elements-gridfield');
if (count($relation) == 1) $gridField->setModelClass($relation[0]);
if (count($this->elementRelations) > 1)
{
$fields
->findOrMakeTab($tabName)
->setTitle($label)
;
}
return $this->owner;
} | [
"public",
"function",
"gridFieldForElementRelation",
"(",
"FieldList",
"$",
"fields",
",",
"$",
"relationName",
",",
"$",
"relation",
")",
"{",
"// sort relations",
"asort",
"(",
"$",
"relation",
")",
";",
"$",
"config",
"=",
"GridFieldConfig_RelationEditor",
"::",
"create",
"(",
")",
"->",
"removeComponentsByType",
"(",
"GridFieldDeleteAction",
"::",
"class",
")",
"->",
"removeComponentsByType",
"(",
"GridFieldAddExistingAutocompleter",
"::",
"class",
")",
"->",
"addComponent",
"(",
"new",
"GridFieldOrderableRows",
"(",
"'Sort'",
")",
")",
"->",
"addComponent",
"(",
"new",
"GridFieldDeleteAction",
"(",
")",
")",
";",
"// attach default elements action",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"canEdit",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"defaultsCreated",
"(",
")",
"&&",
"$",
"this",
"->",
"owner",
"->",
"getDefaultElements",
"(",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"owner",
"->",
"getDefaultElements",
"(",
")",
"[",
"$",
"relationName",
"]",
")",
")",
"{",
"$",
"config",
"->",
"addComponent",
"(",
"new",
"GridFieldDefaultElementsButton",
"(",
")",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"relation",
")",
">",
"1",
")",
"{",
"$",
"config",
"->",
"removeComponentsByType",
"(",
"GridFieldAddNewButton",
"::",
"class",
")",
"->",
"addComponent",
"(",
"$",
"multiClass",
"=",
"new",
"GridFieldAddNewMultiClass",
"(",
")",
")",
";",
"$",
"multiClass",
"->",
"setClasses",
"(",
"ElementsExtension",
"::",
"map_classnames",
"(",
"$",
"relation",
")",
")",
";",
"}",
"$",
"config",
"->",
"getComponentByType",
"(",
"GridFieldPaginator",
"::",
"class",
")",
"->",
"setItemsPerPage",
"(",
"150",
")",
";",
"$",
"columns",
"=",
"[",
"'CMSTypeInfo'",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.CMSTypeInfo'",
",",
"'Type'",
")",
",",
"'CMSSummary'",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.CMSSummary'",
",",
"'Summary'",
")",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"hasExtension",
"(",
"ElementBase",
"::",
"FLUENT_CLASS",
")",
")",
"{",
"$",
"columns",
"[",
"'Languages'",
"]",
"=",
"_t",
"(",
"__CLASS__",
".",
"'.Languages'",
",",
"'Lang'",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"relation",
")",
"==",
"1",
"&&",
"$",
"summaryFields",
"=",
"singleton",
"(",
"$",
"relation",
"[",
"0",
"]",
")",
"->",
"summaryFields",
"(",
")",
")",
"{",
"$",
"columns",
"=",
"array_merge",
"(",
"$",
"columns",
",",
"$",
"summaryFields",
")",
";",
"}",
"$",
"config",
"->",
"getComponentByType",
"(",
"GridFieldDataColumns",
"::",
"class",
")",
"->",
"setDisplayFields",
"(",
"$",
"columns",
")",
";",
"$",
"tabName",
"=",
"\"Root.{$relationName}\"",
";",
"// if only one relation is set, add gridfield to main tab",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"elementRelations",
")",
"==",
"1",
")",
"$",
"tabName",
"=",
"\"Root.Main\"",
";",
"$",
"label",
"=",
"_t",
"(",
"\"Element_Relations.{$relationName}\"",
",",
"$",
"relationName",
")",
";",
"$",
"config",
"->",
"getComponentByType",
"(",
"GridFieldDetailForm",
"::",
"class",
")",
"->",
"setItemRequestClass",
"(",
"VersionedElement_ItemRequest",
"::",
"class",
")",
";",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"$",
"tabName",
",",
"$",
"gridField",
"=",
"GridField",
"::",
"create",
"(",
"$",
"relationName",
",",
"$",
"label",
",",
"$",
"this",
"->",
"owner",
"->",
"ElementsByRelation",
"(",
"$",
"relationName",
")",
",",
"$",
"config",
")",
")",
";",
"$",
"gridField",
"->",
"addExtraClass",
"(",
"'elements-gridfield'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"relation",
")",
"==",
"1",
")",
"$",
"gridField",
"->",
"setModelClass",
"(",
"$",
"relation",
"[",
"0",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"elementRelations",
")",
">",
"1",
")",
"{",
"$",
"fields",
"->",
"findOrMakeTab",
"(",
"$",
"tabName",
")",
"->",
"setTitle",
"(",
"$",
"label",
")",
";",
"}",
"return",
"$",
"this",
"->",
"owner",
";",
"}"
] | Adds a GridField for a elements relation
@param FieldList $fields
@param string $relationName
@return DataObject | [
"Adds",
"a",
"GridField",
"for",
"a",
"elements",
"relation"
] | faa95a6487efe6e28101db5319529aa7e575fa90 | https://github.com/arillo/silverstripe-elements/blob/faa95a6487efe6e28101db5319529aa7e575fa90/src/ElementsExtension.php#L347-L443 |
32,595 | jmikola/WildcardEventDispatcher | src/Jmikola/WildcardEventDispatcher/LazyListenerPattern.php | LazyListenerPattern.getListener | public function getListener()
{
if (!isset($this->listener) && isset($this->listenerProvider)) {
$this->listener = call_user_func($this->listenerProvider);
unset($this->listenerProvider);
}
return $this->listener;
} | php | public function getListener()
{
if (!isset($this->listener) && isset($this->listenerProvider)) {
$this->listener = call_user_func($this->listenerProvider);
unset($this->listenerProvider);
}
return $this->listener;
} | [
"public",
"function",
"getListener",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"listener",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"listenerProvider",
")",
")",
"{",
"$",
"this",
"->",
"listener",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"listenerProvider",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"listenerProvider",
")",
";",
"}",
"return",
"$",
"this",
"->",
"listener",
";",
"}"
] | Get the pattern listener, initializing it lazily from its provider.
@return callback | [
"Get",
"the",
"pattern",
"listener",
"initializing",
"it",
"lazily",
"from",
"its",
"provider",
"."
] | cc3257181cfc25a025b049348c5f9053e83ec627 | https://github.com/jmikola/WildcardEventDispatcher/blob/cc3257181cfc25a025b049348c5f9053e83ec627/src/Jmikola/WildcardEventDispatcher/LazyListenerPattern.php#L36-L44 |
32,596 | JanDC/css-from-html-extractor | src/Css/Processor.php | Processor.getCssFromStyleTags | public function getCssFromStyleTags($html)
{
$css = '';
$matches = array();
preg_match_all('|<style(?:\s.*)?>(.*)</style>|isU', $html, $matches);
if (!empty($matches[1])) {
foreach ($matches[1] as $match) {
$css .= trim($match) . "\n";
}
}
return $css;
} | php | public function getCssFromStyleTags($html)
{
$css = '';
$matches = array();
preg_match_all('|<style(?:\s.*)?>(.*)</style>|isU', $html, $matches);
if (!empty($matches[1])) {
foreach ($matches[1] as $match) {
$css .= trim($match) . "\n";
}
}
return $css;
} | [
"public",
"function",
"getCssFromStyleTags",
"(",
"$",
"html",
")",
"{",
"$",
"css",
"=",
"''",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match_all",
"(",
"'|<style(?:\\s.*)?>(.*)</style>|isU'",
",",
"$",
"html",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"matches",
"[",
"1",
"]",
"as",
"$",
"match",
")",
"{",
"$",
"css",
".=",
"trim",
"(",
"$",
"match",
")",
".",
"\"\\n\"",
";",
"}",
"}",
"return",
"$",
"css",
";",
"}"
] | Get the CSS from the style-tags in the given HTML-string
@param string $html
@return string | [
"Get",
"the",
"CSS",
"from",
"the",
"style",
"-",
"tags",
"in",
"the",
"given",
"HTML",
"-",
"string"
] | e471a1e9ea00f800cb20e014079050cb2d9ad57c | https://github.com/JanDC/css-from-html-extractor/blob/e471a1e9ea00f800cb20e014079050cb2d9ad57c/src/Css/Processor.php#L43-L56 |
32,597 | Vectorface/cache | src/PHPCache.php | PHPCache.get | public function get($key)
{
if (isset($this->cache[$key])) {
list($expires, $value) = $this->cache[$key];
if (!$expires || ($expires >= microtime(true))) {
return $value;
}
unset($this->cache[$key]);
}
return false;
} | php | public function get($key)
{
if (isset($this->cache[$key])) {
list($expires, $value) = $this->cache[$key];
if (!$expires || ($expires >= microtime(true))) {
return $value;
}
unset($this->cache[$key]);
}
return false;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"list",
"(",
"$",
"expires",
",",
"$",
"value",
")",
"=",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"!",
"$",
"expires",
"||",
"(",
"$",
"expires",
">=",
"microtime",
"(",
"true",
")",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Fetch a cache entry by key.
@param String $key The key for the entry to fetch
@return mixed The value stored in the cache for $key | [
"Fetch",
"a",
"cache",
"entry",
"by",
"key",
"."
] | 159f4aeaf639da7a1f7e1d4e5e719a279442658b | https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/PHPCache.php#L30-L40 |
32,598 | czim/laravel-processor | src/AbstractProcessor.php | AbstractProcessor.process | public function process(DataObjectInterface $data = null)
{
if ( ! is_null($data)) {
$this->data = $data;
}
$this->before();
$this->doProcessing();
$this->after();
return $this->getResult();
} | php | public function process(DataObjectInterface $data = null)
{
if ( ! is_null($data)) {
$this->data = $data;
}
$this->before();
$this->doProcessing();
$this->after();
return $this->getResult();
} | [
"public",
"function",
"process",
"(",
"DataObjectInterface",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"}",
"$",
"this",
"->",
"before",
"(",
")",
";",
"$",
"this",
"->",
"doProcessing",
"(",
")",
";",
"$",
"this",
"->",
"after",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getResult",
"(",
")",
";",
"}"
] | Process the data sent
@param DataObjectInterface $data
@return ProcessorResult | [
"Process",
"the",
"data",
"sent"
] | 3d0025cd463653b7a8981ff52cebdafbe978f000 | https://github.com/czim/laravel-processor/blob/3d0025cd463653b7a8981ff52cebdafbe978f000/src/AbstractProcessor.php#L62-L75 |
32,599 | czim/laravel-processor | src/AbstractProcessor.php | AbstractProcessor.setExtraData | public function setExtraData($data)
{
if (is_a($data, Arrayable::class)) {
$data = $data->toArray();
}
if ( ! is_array($data)) {
$data = [ $data ];
}
$this->extraData = $data;
return $this;
} | php | public function setExtraData($data)
{
if (is_a($data, Arrayable::class)) {
$data = $data->toArray();
}
if ( ! is_array($data)) {
$data = [ $data ];
}
$this->extraData = $data;
return $this;
} | [
"public",
"function",
"setExtraData",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"data",
",",
"Arrayable",
"::",
"class",
")",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"[",
"$",
"data",
"]",
";",
"}",
"$",
"this",
"->",
"extraData",
"=",
"$",
"data",
";",
"return",
"$",
"this",
";",
"}"
] | Set extra data that the processor should use during the import
@param array|Arrayable $data
@return $this | [
"Set",
"extra",
"data",
"that",
"the",
"processor",
"should",
"use",
"during",
"the",
"import"
] | 3d0025cd463653b7a8981ff52cebdafbe978f000 | https://github.com/czim/laravel-processor/blob/3d0025cd463653b7a8981ff52cebdafbe978f000/src/AbstractProcessor.php#L84-L97 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.