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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
223,600
|
nilportugues/php-sitemap
|
src/SubmitSitemap.php
|
SubmitSitemap.submitSitemap
|
protected static function submitSitemap($url)
{
$response = [];
foreach (self::$sites as $site => $baseUrl) {
$submitUrl = \str_replace('{{sitemap}}', $url, $baseUrl);
$response = self::executeCurl($submitUrl, $response, $site);
}
return $response;
}
|
php
|
protected static function submitSitemap($url)
{
$response = [];
foreach (self::$sites as $site => $baseUrl) {
$submitUrl = \str_replace('{{sitemap}}', $url, $baseUrl);
$response = self::executeCurl($submitUrl, $response, $site);
}
return $response;
}
|
[
"protected",
"static",
"function",
"submitSitemap",
"(",
"$",
"url",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"$",
"sites",
"as",
"$",
"site",
"=>",
"$",
"baseUrl",
")",
"{",
"$",
"submitUrl",
"=",
"\\",
"str_replace",
"(",
"'{{sitemap}}'",
",",
"$",
"url",
",",
"$",
"baseUrl",
")",
";",
"$",
"response",
"=",
"self",
"::",
"executeCurl",
"(",
"$",
"submitUrl",
",",
"$",
"response",
",",
"$",
"site",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Submits a sitemap to the search engines using file_get_contents.
@param $url string Valid URL being submitted.
@return array Array with the search engine submission success status as a boolean.
|
[
"Submits",
"a",
"sitemap",
"to",
"the",
"search",
"engines",
"using",
"file_get_contents",
"."
] |
b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd
|
https://github.com/nilportugues/php-sitemap/blob/b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd/src/SubmitSitemap.php#L51-L61
|
223,601
|
madeyourday/contao-rocksolid-frontend-helper
|
src/FrontendHooks.php
|
FrontendHooks.checkLogin
|
public static function checkLogin()
{
// Only try to authenticate in the front end
if (TL_MODE !== 'FE') {
return false;
}
// Do not create a user instance if there is no authentication cookie
if (! is_subclass_of('BackendUser', UserInterface::class) && ! \Input::cookie('BE_USER_AUTH')) {
return false;
}
$User = FrontendHelperUser::getInstance();
if (! $User->authenticate()) {
return false;
}
if (! $User->rocksolidFrontendHelper) {
return false;
}
if ($User->isAdmin) {
return array('feModules', 'beModules', 'pages', 'articles', 'contents', 'infos', 'rstAssistant', 'tpl_editor');
}
$permissions = array();
if (is_array($User->rocksolidFrontendHelperOperations)) {
$permissions = array_merge($permissions, $User->rocksolidFrontendHelperOperations);
}
if ($User->hasAccess('rocksolid_theme_assistant', 'modules')) {
$permissions[] = 'rstAssistant';
}
if ($User->hasAccess('tpl_editor', 'modules')) {
$permissions[] = 'tpl_editor';
}
if (count($permissions)) {
return $permissions;
}
return false;
}
|
php
|
public static function checkLogin()
{
// Only try to authenticate in the front end
if (TL_MODE !== 'FE') {
return false;
}
// Do not create a user instance if there is no authentication cookie
if (! is_subclass_of('BackendUser', UserInterface::class) && ! \Input::cookie('BE_USER_AUTH')) {
return false;
}
$User = FrontendHelperUser::getInstance();
if (! $User->authenticate()) {
return false;
}
if (! $User->rocksolidFrontendHelper) {
return false;
}
if ($User->isAdmin) {
return array('feModules', 'beModules', 'pages', 'articles', 'contents', 'infos', 'rstAssistant', 'tpl_editor');
}
$permissions = array();
if (is_array($User->rocksolidFrontendHelperOperations)) {
$permissions = array_merge($permissions, $User->rocksolidFrontendHelperOperations);
}
if ($User->hasAccess('rocksolid_theme_assistant', 'modules')) {
$permissions[] = 'rstAssistant';
}
if ($User->hasAccess('tpl_editor', 'modules')) {
$permissions[] = 'tpl_editor';
}
if (count($permissions)) {
return $permissions;
}
return false;
}
|
[
"public",
"static",
"function",
"checkLogin",
"(",
")",
"{",
"// Only try to authenticate in the front end",
"if",
"(",
"TL_MODE",
"!==",
"'FE'",
")",
"{",
"return",
"false",
";",
"}",
"// Do not create a user instance if there is no authentication cookie",
"if",
"(",
"!",
"is_subclass_of",
"(",
"'BackendUser'",
",",
"UserInterface",
"::",
"class",
")",
"&&",
"!",
"\\",
"Input",
"::",
"cookie",
"(",
"'BE_USER_AUTH'",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"User",
"=",
"FrontendHelperUser",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"User",
"->",
"authenticate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"User",
"->",
"rocksolidFrontendHelper",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"User",
"->",
"isAdmin",
")",
"{",
"return",
"array",
"(",
"'feModules'",
",",
"'beModules'",
",",
"'pages'",
",",
"'articles'",
",",
"'contents'",
",",
"'infos'",
",",
"'rstAssistant'",
",",
"'tpl_editor'",
")",
";",
"}",
"$",
"permissions",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"User",
"->",
"rocksolidFrontendHelperOperations",
")",
")",
"{",
"$",
"permissions",
"=",
"array_merge",
"(",
"$",
"permissions",
",",
"$",
"User",
"->",
"rocksolidFrontendHelperOperations",
")",
";",
"}",
"if",
"(",
"$",
"User",
"->",
"hasAccess",
"(",
"'rocksolid_theme_assistant'",
",",
"'modules'",
")",
")",
"{",
"$",
"permissions",
"[",
"]",
"=",
"'rstAssistant'",
";",
"}",
"if",
"(",
"$",
"User",
"->",
"hasAccess",
"(",
"'tpl_editor'",
",",
"'modules'",
")",
")",
"{",
"$",
"permissions",
"[",
"]",
"=",
"'tpl_editor'",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"permissions",
")",
")",
"{",
"return",
"$",
"permissions",
";",
"}",
"return",
"false",
";",
"}"
] |
checks if a Backend User is logged in
@return array|boolean false if the user isn't logged in otherwise the permissions array
|
[
"checks",
"if",
"a",
"Backend",
"User",
"is",
"logged",
"in"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/FrontendHooks.php#L652-L694
|
223,602
|
madeyourday/contao-rocksolid-frontend-helper
|
src/FrontendHooks.php
|
FrontendHooks.getBackendModuleLabel
|
public function getBackendModuleLabel($config, $id = null, $withParentTable = false)
{
if ($withParentTable) {
\Controller::loadDataContainer($config['table']);
if (!empty($GLOBALS['TL_DCA'][$config['table']]['config']['ptable'])) {
$ptable = $GLOBALS['TL_DCA'][$config['table']]['config']['ptable'];
\System::loadLanguageFile($ptable);
if ($id && !empty($GLOBALS['TL_LANG'][$ptable]['edit'][1])) {
return sprintf($GLOBALS['TL_LANG'][$ptable]['edit'][1], $id);
}
if (!empty($GLOBALS['TL_LANG'][$ptable]['edit'][0])) {
return $GLOBALS['TL_LANG'][$ptable]['edit'][0];
}
if (!empty($GLOBALS['TL_LANG'][$ptable]['editheader'][0])) {
return $GLOBALS['TL_LANG'][$ptable]['editheader'][0];
}
}
}
\System::loadLanguageFile($config['table']);
if (!empty($GLOBALS['TL_LANG'][$config['table']]['editheader'][0])) {
return $GLOBALS['TL_LANG'][$config['table']]['editheader'][0];
}
if ($id && !empty($GLOBALS['TL_LANG'][$config['table']]['edit'][1])) {
return sprintf($GLOBALS['TL_LANG'][$config['table']]['edit'][1], $id);
}
if (!empty($GLOBALS['TL_LANG'][$config['table']]['edit'][0])) {
return $GLOBALS['TL_LANG'][$config['table']]['edit'][0];
}
if ($id) {
return sprintf($GLOBALS['TL_LANG']['MSC']['editRecord'], $id);
}
return $GLOBALS['TL_LANG']['MSC']['editElement'];
}
|
php
|
public function getBackendModuleLabel($config, $id = null, $withParentTable = false)
{
if ($withParentTable) {
\Controller::loadDataContainer($config['table']);
if (!empty($GLOBALS['TL_DCA'][$config['table']]['config']['ptable'])) {
$ptable = $GLOBALS['TL_DCA'][$config['table']]['config']['ptable'];
\System::loadLanguageFile($ptable);
if ($id && !empty($GLOBALS['TL_LANG'][$ptable]['edit'][1])) {
return sprintf($GLOBALS['TL_LANG'][$ptable]['edit'][1], $id);
}
if (!empty($GLOBALS['TL_LANG'][$ptable]['edit'][0])) {
return $GLOBALS['TL_LANG'][$ptable]['edit'][0];
}
if (!empty($GLOBALS['TL_LANG'][$ptable]['editheader'][0])) {
return $GLOBALS['TL_LANG'][$ptable]['editheader'][0];
}
}
}
\System::loadLanguageFile($config['table']);
if (!empty($GLOBALS['TL_LANG'][$config['table']]['editheader'][0])) {
return $GLOBALS['TL_LANG'][$config['table']]['editheader'][0];
}
if ($id && !empty($GLOBALS['TL_LANG'][$config['table']]['edit'][1])) {
return sprintf($GLOBALS['TL_LANG'][$config['table']]['edit'][1], $id);
}
if (!empty($GLOBALS['TL_LANG'][$config['table']]['edit'][0])) {
return $GLOBALS['TL_LANG'][$config['table']]['edit'][0];
}
if ($id) {
return sprintf($GLOBALS['TL_LANG']['MSC']['editRecord'], $id);
}
return $GLOBALS['TL_LANG']['MSC']['editElement'];
}
|
[
"public",
"function",
"getBackendModuleLabel",
"(",
"$",
"config",
",",
"$",
"id",
"=",
"null",
",",
"$",
"withParentTable",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"withParentTable",
")",
"{",
"\\",
"Controller",
"::",
"loadDataContainer",
"(",
"$",
"config",
"[",
"'table'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'config'",
"]",
"[",
"'ptable'",
"]",
")",
")",
"{",
"$",
"ptable",
"=",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'config'",
"]",
"[",
"'ptable'",
"]",
";",
"\\",
"System",
"::",
"loadLanguageFile",
"(",
"$",
"ptable",
")",
";",
"if",
"(",
"$",
"id",
"&&",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"ptable",
"]",
"[",
"'edit'",
"]",
"[",
"1",
"]",
")",
")",
"{",
"return",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"ptable",
"]",
"[",
"'edit'",
"]",
"[",
"1",
"]",
",",
"$",
"id",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"ptable",
"]",
"[",
"'edit'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"ptable",
"]",
"[",
"'edit'",
"]",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"ptable",
"]",
"[",
"'editheader'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"ptable",
"]",
"[",
"'editheader'",
"]",
"[",
"0",
"]",
";",
"}",
"}",
"}",
"\\",
"System",
"::",
"loadLanguageFile",
"(",
"$",
"config",
"[",
"'table'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'editheader'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'editheader'",
"]",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"$",
"id",
"&&",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'edit'",
"]",
"[",
"1",
"]",
")",
")",
"{",
"return",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'edit'",
"]",
"[",
"1",
"]",
",",
"$",
"id",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'edit'",
"]",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"$",
"config",
"[",
"'table'",
"]",
"]",
"[",
"'edit'",
"]",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"$",
"id",
")",
"{",
"return",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'MSC'",
"]",
"[",
"'editRecord'",
"]",
",",
"$",
"id",
")",
";",
"}",
"return",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'MSC'",
"]",
"[",
"'editElement'",
"]",
";",
"}"
] |
get the label for a backend module link
@param array $config backend module configuration
@param int $id id of the entry to edit
@param boolean $withParentTable use the edit label from the parent table if possible
@return string the label
|
[
"get",
"the",
"label",
"for",
"a",
"backend",
"module",
"link"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/FrontendHooks.php#L704-L736
|
223,603
|
madeyourday/contao-rocksolid-frontend-helper
|
src/FrontendHooks.php
|
FrontendHooks.addTemplateURL
|
protected static function addTemplateURL($data)
{
if (substr($data['templatePath'], 0, 10) === 'templates/') {
$data['templateURL'] = static::getBackendURL('tpl_editor', null, $data['templatePath'], 'source');
\System::loadLanguageFile('tl_files');
$data['templateLabel'] = sprintf($GLOBALS['TL_LANG']['tl_files']['source'][1], basename($data['templatePath']));
}
else {
$data['templateURL'] = static::getBackendURL('tpl_editor', null, null, null, array(
'key' => 'new_tpl',
'original' => $data['templatePath'],
'target' => $GLOBALS['objPage']->templateGroup ?: 'templates',
));
\System::loadLanguageFile('tl_templates');
$data['templateLabel'] = $GLOBALS['TL_LANG']['tl_templates']['new_tpl'][1];
}
return $data;
}
|
php
|
protected static function addTemplateURL($data)
{
if (substr($data['templatePath'], 0, 10) === 'templates/') {
$data['templateURL'] = static::getBackendURL('tpl_editor', null, $data['templatePath'], 'source');
\System::loadLanguageFile('tl_files');
$data['templateLabel'] = sprintf($GLOBALS['TL_LANG']['tl_files']['source'][1], basename($data['templatePath']));
}
else {
$data['templateURL'] = static::getBackendURL('tpl_editor', null, null, null, array(
'key' => 'new_tpl',
'original' => $data['templatePath'],
'target' => $GLOBALS['objPage']->templateGroup ?: 'templates',
));
\System::loadLanguageFile('tl_templates');
$data['templateLabel'] = $GLOBALS['TL_LANG']['tl_templates']['new_tpl'][1];
}
return $data;
}
|
[
"protected",
"static",
"function",
"addTemplateURL",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"data",
"[",
"'templatePath'",
"]",
",",
"0",
",",
"10",
")",
"===",
"'templates/'",
")",
"{",
"$",
"data",
"[",
"'templateURL'",
"]",
"=",
"static",
"::",
"getBackendURL",
"(",
"'tpl_editor'",
",",
"null",
",",
"$",
"data",
"[",
"'templatePath'",
"]",
",",
"'source'",
")",
";",
"\\",
"System",
"::",
"loadLanguageFile",
"(",
"'tl_files'",
")",
";",
"$",
"data",
"[",
"'templateLabel'",
"]",
"=",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_files'",
"]",
"[",
"'source'",
"]",
"[",
"1",
"]",
",",
"basename",
"(",
"$",
"data",
"[",
"'templatePath'",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'templateURL'",
"]",
"=",
"static",
"::",
"getBackendURL",
"(",
"'tpl_editor'",
",",
"null",
",",
"null",
",",
"null",
",",
"array",
"(",
"'key'",
"=>",
"'new_tpl'",
",",
"'original'",
"=>",
"$",
"data",
"[",
"'templatePath'",
"]",
",",
"'target'",
"=>",
"$",
"GLOBALS",
"[",
"'objPage'",
"]",
"->",
"templateGroup",
"?",
":",
"'templates'",
",",
")",
")",
";",
"\\",
"System",
"::",
"loadLanguageFile",
"(",
"'tl_templates'",
")",
";",
"$",
"data",
"[",
"'templateLabel'",
"]",
"=",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_templates'",
"]",
"[",
"'new_tpl'",
"]",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Add templateURL and templateLabel to data array
@param array $data data array
@return array modified data array
|
[
"Add",
"templateURL",
"and",
"templateLabel",
"to",
"data",
"array"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/FrontendHooks.php#L744-L768
|
223,604
|
madeyourday/contao-rocksolid-frontend-helper
|
src/FrontendHooks.php
|
FrontendHooks.getThemeAssistantStylesheet
|
protected function getThemeAssistantStylesheet()
{
if (!$GLOBALS['objPage'] || !$GLOBALS['objPage']->getRelated('layout')) {
return null;
}
if (!$stylesheets = $GLOBALS['objPage']->getRelated('layout')->external) {
return null;
}
$stylesheets = \StringUtil::deserialize($stylesheets);
foreach ($stylesheets as $stylesheet) {
$file = \FilesModel::findByUuid($stylesheet);
if ($file && $file->path && file_exists(TL_ROOT . '/' . $file->path . '.base')) {
return $file->path . '.base';
}
}
return null;
}
|
php
|
protected function getThemeAssistantStylesheet()
{
if (!$GLOBALS['objPage'] || !$GLOBALS['objPage']->getRelated('layout')) {
return null;
}
if (!$stylesheets = $GLOBALS['objPage']->getRelated('layout')->external) {
return null;
}
$stylesheets = \StringUtil::deserialize($stylesheets);
foreach ($stylesheets as $stylesheet) {
$file = \FilesModel::findByUuid($stylesheet);
if ($file && $file->path && file_exists(TL_ROOT . '/' . $file->path . '.base')) {
return $file->path . '.base';
}
}
return null;
}
|
[
"protected",
"function",
"getThemeAssistantStylesheet",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"GLOBALS",
"[",
"'objPage'",
"]",
"||",
"!",
"$",
"GLOBALS",
"[",
"'objPage'",
"]",
"->",
"getRelated",
"(",
"'layout'",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"stylesheets",
"=",
"$",
"GLOBALS",
"[",
"'objPage'",
"]",
"->",
"getRelated",
"(",
"'layout'",
")",
"->",
"external",
")",
"{",
"return",
"null",
";",
"}",
"$",
"stylesheets",
"=",
"\\",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"stylesheets",
")",
";",
"foreach",
"(",
"$",
"stylesheets",
"as",
"$",
"stylesheet",
")",
"{",
"$",
"file",
"=",
"\\",
"FilesModel",
"::",
"findByUuid",
"(",
"$",
"stylesheet",
")",
";",
"if",
"(",
"$",
"file",
"&&",
"$",
"file",
"->",
"path",
"&&",
"file_exists",
"(",
"TL_ROOT",
".",
"'/'",
".",
"$",
"file",
"->",
"path",
".",
"'.base'",
")",
")",
"{",
"return",
"$",
"file",
"->",
"path",
".",
"'.base'",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get path to the .css.base file of the current layout
@return string|null Path to the .css.base file or null
|
[
"Get",
"path",
"to",
"the",
".",
"css",
".",
"base",
"file",
"of",
"the",
"current",
"layout"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/FrontendHooks.php#L775-L793
|
223,605
|
madeyourday/contao-rocksolid-frontend-helper
|
src/FrontendHooks.php
|
FrontendHooks.getBackendURL
|
protected static function getBackendURL($do, $table, $id, $act = 'edit', array $params = array())
{
$addParams = array();
foreach (array('do', 'table', 'act', 'id') as $key) {
if ($$key) {
$addParams[$key] = $$key;
}
}
// This is necessary because Contao wants the parameters to be in the right order.
// E.g. `?node=2&do=article` doesn’t work while `?do=article&node=2` does.
$params = array_merge($addParams, $params);
$params['rt'] = REQUEST_TOKEN;
$params['rsfhr'] = 1;
$url = \System::getContainer()->get('router')->generate('contao_backend');
// Third parameter is required because of arg_separator.output
$url .= '?' . http_build_query($params, null, '&');
return $url;
}
|
php
|
protected static function getBackendURL($do, $table, $id, $act = 'edit', array $params = array())
{
$addParams = array();
foreach (array('do', 'table', 'act', 'id') as $key) {
if ($$key) {
$addParams[$key] = $$key;
}
}
// This is necessary because Contao wants the parameters to be in the right order.
// E.g. `?node=2&do=article` doesn’t work while `?do=article&node=2` does.
$params = array_merge($addParams, $params);
$params['rt'] = REQUEST_TOKEN;
$params['rsfhr'] = 1;
$url = \System::getContainer()->get('router')->generate('contao_backend');
// Third parameter is required because of arg_separator.output
$url .= '?' . http_build_query($params, null, '&');
return $url;
}
|
[
"protected",
"static",
"function",
"getBackendURL",
"(",
"$",
"do",
",",
"$",
"table",
",",
"$",
"id",
",",
"$",
"act",
"=",
"'edit'",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"addParams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array",
"(",
"'do'",
",",
"'table'",
",",
"'act'",
",",
"'id'",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"$",
"key",
")",
"{",
"$",
"addParams",
"[",
"$",
"key",
"]",
"=",
"$",
"$",
"key",
";",
"}",
"}",
"// This is necessary because Contao wants the parameters to be in the right order.",
"// E.g. `?node=2&do=article` doesn’t work while `?do=article&node=2` does.",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"addParams",
",",
"$",
"params",
")",
";",
"$",
"params",
"[",
"'rt'",
"]",
"=",
"REQUEST_TOKEN",
";",
"$",
"params",
"[",
"'rsfhr'",
"]",
"=",
"1",
";",
"$",
"url",
"=",
"\\",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'contao_backend'",
")",
";",
"// Third parameter is required because of arg_separator.output",
"$",
"url",
".=",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
",",
"null",
",",
"'&'",
")",
";",
"return",
"$",
"url",
";",
"}"
] |
create backend edit URL
@param string $do
@param string $table
@param string $id
@param string $act
@return string
|
[
"create",
"backend",
"edit",
"URL"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/FrontendHooks.php#L804-L826
|
223,606
|
puli/manager
|
src/Transaction/Transaction.php
|
Transaction.rollback
|
public function rollback()
{
for ($i = count($this->completedOperations) - 1; $i >= 0; --$i) {
$this->completedOperations[$i]->rollback();
}
$this->completedOperations = array();
}
|
php
|
public function rollback()
{
for ($i = count($this->completedOperations) - 1; $i >= 0; --$i) {
$this->completedOperations[$i]->rollback();
}
$this->completedOperations = array();
}
|
[
"public",
"function",
"rollback",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"this",
"->",
"completedOperations",
")",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"--",
"$",
"i",
")",
"{",
"$",
"this",
"->",
"completedOperations",
"[",
"$",
"i",
"]",
"->",
"rollback",
"(",
")",
";",
"}",
"$",
"this",
"->",
"completedOperations",
"=",
"array",
"(",
")",
";",
"}"
] |
Rolls back all executed operations.
Only operations that executed successfully are rolled back.
|
[
"Rolls",
"back",
"all",
"executed",
"operations",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Transaction/Transaction.php#L53-L60
|
223,607
|
puli/manager
|
src/Api/Server/ServerCollection.php
|
ServerCollection.get
|
public function get($serverName)
{
if (!isset($this->servers[$serverName])) {
throw NoSuchServerException::forServerName($serverName);
}
return $this->servers[$serverName];
}
|
php
|
public function get($serverName)
{
if (!isset($this->servers[$serverName])) {
throw NoSuchServerException::forServerName($serverName);
}
return $this->servers[$serverName];
}
|
[
"public",
"function",
"get",
"(",
"$",
"serverName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"servers",
"[",
"$",
"serverName",
"]",
")",
")",
"{",
"throw",
"NoSuchServerException",
"::",
"forServerName",
"(",
"$",
"serverName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"servers",
"[",
"$",
"serverName",
"]",
";",
"}"
] |
Returns the server with the given name.
@param string $serverName The server name.
@return Server The server.
@throws NoSuchServerException If the server does not exist.
|
[
"Returns",
"the",
"server",
"with",
"the",
"given",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Server/ServerCollection.php#L64-L71
|
223,608
|
bitverseio/identicon
|
src/Bitverse/Identicon/Color/Color.php
|
Color.parseHex
|
public static function parseHex($color)
{
if (!preg_match('/^#[A-Fa-f0-9]{6}$/', $color)) {
throw new WrongColorFormatException($color);
}
return new Color(
hexdec(substr($color, 1, 2)),
hexdec(substr($color, 3, 2)),
hexdec(substr($color, 5, 2))
);
}
|
php
|
public static function parseHex($color)
{
if (!preg_match('/^#[A-Fa-f0-9]{6}$/', $color)) {
throw new WrongColorFormatException($color);
}
return new Color(
hexdec(substr($color, 1, 2)),
hexdec(substr($color, 3, 2)),
hexdec(substr($color, 5, 2))
);
}
|
[
"public",
"static",
"function",
"parseHex",
"(",
"$",
"color",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^#[A-Fa-f0-9]{6}$/'",
",",
"$",
"color",
")",
")",
"{",
"throw",
"new",
"WrongColorFormatException",
"(",
"$",
"color",
")",
";",
"}",
"return",
"new",
"Color",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"1",
",",
"2",
")",
")",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"3",
",",
"2",
")",
")",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"5",
",",
"2",
")",
")",
")",
";",
"}"
] |
Parses a hex string to create a Color object.
@throws WrongColorFormatException Thrown if the given string is in the wrong format.
@param string $color
@return Color
|
[
"Parses",
"a",
"hex",
"string",
"to",
"create",
"a",
"Color",
"object",
"."
] |
5a015546e7f29d537807e0877446e2cd704ca438
|
https://github.com/bitverseio/identicon/blob/5a015546e7f29d537807e0877446e2cd704ca438/src/Bitverse/Identicon/Color/Color.php#L30-L41
|
223,609
|
apoutchika/MediaBundle
|
Filesystem/BaseFilesystem.php
|
BaseFilesystem.makeFilesystem
|
public function makeFilesystem(array $configs)
{
$adapter = $this->getAdapter($configs);
if (!$adapter instanceof Adapter) {
throw new \Exception('The adapter must has instance of Gaufrette\Adapter');
}
$this->filesystem = new Filesystem($adapter);
return $this;
}
|
php
|
public function makeFilesystem(array $configs)
{
$adapter = $this->getAdapter($configs);
if (!$adapter instanceof Adapter) {
throw new \Exception('The adapter must has instance of Gaufrette\Adapter');
}
$this->filesystem = new Filesystem($adapter);
return $this;
}
|
[
"public",
"function",
"makeFilesystem",
"(",
"array",
"$",
"configs",
")",
"{",
"$",
"adapter",
"=",
"$",
"this",
"->",
"getAdapter",
"(",
"$",
"configs",
")",
";",
"if",
"(",
"!",
"$",
"adapter",
"instanceof",
"Adapter",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The adapter must has instance of Gaufrette\\Adapter'",
")",
";",
"}",
"$",
"this",
"->",
"filesystem",
"=",
"new",
"Filesystem",
"(",
"$",
"adapter",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Make Gaufrette filesystem.
@param array $configs Parameters in filesystems name, injected in gaufrette adapter
@return FilesystemInterface
|
[
"Make",
"Gaufrette",
"filesystem",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Filesystem/BaseFilesystem.php#L58-L69
|
223,610
|
apoutchika/MediaBundle
|
Filesystem/BaseFilesystem.php
|
BaseFilesystem.setUrl
|
public function setUrl($url)
{
$this->urlAbsolute = preg_replace('#/$#', '', $url);
if ($this->urlRelative === null) {
$this->urlRelative = $this->urlAbsolute;
}
return $this;
}
|
php
|
public function setUrl($url)
{
$this->urlAbsolute = preg_replace('#/$#', '', $url);
if ($this->urlRelative === null) {
$this->urlRelative = $this->urlAbsolute;
}
return $this;
}
|
[
"public",
"function",
"setUrl",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"urlAbsolute",
"=",
"preg_replace",
"(",
"'#/$#'",
",",
"''",
",",
"$",
"url",
")",
";",
"if",
"(",
"$",
"this",
"->",
"urlRelative",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"urlRelative",
"=",
"$",
"this",
"->",
"urlAbsolute",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set absolute url.
@param string $url
@return FilesystemInterface
|
[
"Set",
"absolute",
"url",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Filesystem/BaseFilesystem.php#L78-L87
|
223,611
|
puli/manager
|
src/Discovery/Type/SyncTypeName.php
|
SyncTypeName.takeSnapshot
|
public function takeSnapshot()
{
$this->enabledTypeBefore = null;
if ($this->typeDescriptors->contains($this->typeName)) {
foreach ($this->typeDescriptors->listByTypeName($this->typeName) as $typeDescriptor) {
if ($typeDescriptor->isEnabled()) {
$this->enabledTypeBefore = $typeDescriptor;
}
}
}
$this->snapshotTaken = true;
}
|
php
|
public function takeSnapshot()
{
$this->enabledTypeBefore = null;
if ($this->typeDescriptors->contains($this->typeName)) {
foreach ($this->typeDescriptors->listByTypeName($this->typeName) as $typeDescriptor) {
if ($typeDescriptor->isEnabled()) {
$this->enabledTypeBefore = $typeDescriptor;
}
}
}
$this->snapshotTaken = true;
}
|
[
"public",
"function",
"takeSnapshot",
"(",
")",
"{",
"$",
"this",
"->",
"enabledTypeBefore",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"typeDescriptors",
"->",
"contains",
"(",
"$",
"this",
"->",
"typeName",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"typeDescriptors",
"->",
"listByTypeName",
"(",
"$",
"this",
"->",
"typeName",
")",
"as",
"$",
"typeDescriptor",
")",
"{",
"if",
"(",
"$",
"typeDescriptor",
"->",
"isEnabled",
"(",
")",
")",
"{",
"$",
"this",
"->",
"enabledTypeBefore",
"=",
"$",
"typeDescriptor",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"snapshotTaken",
"=",
"true",
";",
"}"
] |
Records whether the type name is currently enabled.
|
[
"Records",
"whether",
"the",
"type",
"name",
"is",
"currently",
"enabled",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Discovery/Type/SyncTypeName.php#L76-L89
|
223,612
|
ongr-io/FilterManagerBundle
|
DependencyInjection/Configuration.php
|
Configuration.buildRelationsTree
|
private function buildRelationsTree($relationType)
{
$filter = new ArrayNodeDefinition($relationType);
$filter
->validate()
->ifTrue(
function ($v) {
return empty($v['include']) && empty($v['exclude']);
}
)
->thenInvalid('Relation must have "include" or "exclude" fields specified.')
->end()
->validate()
->ifTrue(
function ($v) {
return !empty($v['include']) && !empty($v['exclude']);
}
)
->thenInvalid('Relation must have only "include" or "exclude" fields specified.')
->end()
->children()
->arrayNode('include')
->beforeNormalization()
->ifString()
->then(
function ($v) {
return [$v];
}
)->end()
->prototype('scalar')->end()
->end()
->arrayNode('exclude')
->beforeNormalization()
->ifString()
->then(
function ($v) {
return [$v];
}
)
->end()
->prototype('scalar')->end()
->end()
->end();
return $filter;
}
|
php
|
private function buildRelationsTree($relationType)
{
$filter = new ArrayNodeDefinition($relationType);
$filter
->validate()
->ifTrue(
function ($v) {
return empty($v['include']) && empty($v['exclude']);
}
)
->thenInvalid('Relation must have "include" or "exclude" fields specified.')
->end()
->validate()
->ifTrue(
function ($v) {
return !empty($v['include']) && !empty($v['exclude']);
}
)
->thenInvalid('Relation must have only "include" or "exclude" fields specified.')
->end()
->children()
->arrayNode('include')
->beforeNormalization()
->ifString()
->then(
function ($v) {
return [$v];
}
)->end()
->prototype('scalar')->end()
->end()
->arrayNode('exclude')
->beforeNormalization()
->ifString()
->then(
function ($v) {
return [$v];
}
)
->end()
->prototype('scalar')->end()
->end()
->end();
return $filter;
}
|
[
"private",
"function",
"buildRelationsTree",
"(",
"$",
"relationType",
")",
"{",
"$",
"filter",
"=",
"new",
"ArrayNodeDefinition",
"(",
"$",
"relationType",
")",
";",
"$",
"filter",
"->",
"validate",
"(",
")",
"->",
"ifTrue",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"empty",
"(",
"$",
"v",
"[",
"'include'",
"]",
")",
"&&",
"empty",
"(",
"$",
"v",
"[",
"'exclude'",
"]",
")",
";",
"}",
")",
"->",
"thenInvalid",
"(",
"'Relation must have \"include\" or \"exclude\" fields specified.'",
")",
"->",
"end",
"(",
")",
"->",
"validate",
"(",
")",
"->",
"ifTrue",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"v",
"[",
"'include'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"v",
"[",
"'exclude'",
"]",
")",
";",
"}",
")",
"->",
"thenInvalid",
"(",
"'Relation must have only \"include\" or \"exclude\" fields specified.'",
")",
"->",
"end",
"(",
")",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'include'",
")",
"->",
"beforeNormalization",
"(",
")",
"->",
"ifString",
"(",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"[",
"$",
"v",
"]",
";",
"}",
")",
"->",
"end",
"(",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'exclude'",
")",
"->",
"beforeNormalization",
"(",
")",
"->",
"ifString",
"(",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"[",
"$",
"v",
"]",
";",
"}",
")",
"->",
"end",
"(",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"filter",
";",
"}"
] |
Builds relations config tree for given relation name.
@param string $relationType
@return ArrayNodeDefinition
|
[
"Builds",
"relations",
"config",
"tree",
"for",
"given",
"relation",
"name",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/DependencyInjection/Configuration.php#L108-L154
|
223,613
|
apoutchika/MediaBundle
|
Listener/MediaContentListener.php
|
MediaContentListener.addContent
|
public function addContent(FilterResponseEvent $event)
{
if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
return;
}
$response = $event->getResponse();
$content = $response->getContent();
if (strpos($content, 'data-apoutchika-media="') !== false) {
$js = array();
// Include libs
$libs = array(
'jquery', 'jqueryui',
'underscore', 'backbone', 'backbonejjrelational', 'mustache',
'dropzone', 'jcrop',
);
foreach ($libs as $lib) {
if ($this->include[$lib] === true) {
$js[] = 'bundles/apoutchikamedia/js/libs/'.$lib.'.js';
}
}
// Include apps
$apps = array(
'init',
'models', 'collections',
'viewAdd', 'viewEditor', 'viewField', 'viewList',
'router', 'app',
);
foreach ($apps as $app) {
$js[] = 'bundles/apoutchikamedia/js/'.$app.'.js';
}
$content_js = '';
foreach ($js as $n) {
$content_js .= '<script src="';
$content_js .= $this->assetsHelper->getUrl($n);
$content_js .= '" type="text/javascript"></script>';
}
$css = array();
$css[] = ($this->css !== null) ?
$this->css : 'bundles/apoutchikamedia/css/main.css';
if ($this->include['jcrop'] === true) {
$css[] = 'bundles/apoutchikamedia/css/jcrop.css';
}
$content_css = '';
foreach ($css as $n) {
$content_css .= '<link rel="stylesheet" type="text/css" href="';
$content_css .= $this->assetsHelper->getUrl($n);
$content_css .= '" />';
}
$html = $this->templating->render('ApoutchikaMediaBundle:Media:media.html.twig');
$content = preg_replace('#</head>#', $content_css.'</head>', $content);
$content = preg_replace('#</body>#', $html.$content_js.'</body>', $content);
$response->setContent($content);
$event->setResponse($response);
}
}
|
php
|
public function addContent(FilterResponseEvent $event)
{
if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
return;
}
$response = $event->getResponse();
$content = $response->getContent();
if (strpos($content, 'data-apoutchika-media="') !== false) {
$js = array();
// Include libs
$libs = array(
'jquery', 'jqueryui',
'underscore', 'backbone', 'backbonejjrelational', 'mustache',
'dropzone', 'jcrop',
);
foreach ($libs as $lib) {
if ($this->include[$lib] === true) {
$js[] = 'bundles/apoutchikamedia/js/libs/'.$lib.'.js';
}
}
// Include apps
$apps = array(
'init',
'models', 'collections',
'viewAdd', 'viewEditor', 'viewField', 'viewList',
'router', 'app',
);
foreach ($apps as $app) {
$js[] = 'bundles/apoutchikamedia/js/'.$app.'.js';
}
$content_js = '';
foreach ($js as $n) {
$content_js .= '<script src="';
$content_js .= $this->assetsHelper->getUrl($n);
$content_js .= '" type="text/javascript"></script>';
}
$css = array();
$css[] = ($this->css !== null) ?
$this->css : 'bundles/apoutchikamedia/css/main.css';
if ($this->include['jcrop'] === true) {
$css[] = 'bundles/apoutchikamedia/css/jcrop.css';
}
$content_css = '';
foreach ($css as $n) {
$content_css .= '<link rel="stylesheet" type="text/css" href="';
$content_css .= $this->assetsHelper->getUrl($n);
$content_css .= '" />';
}
$html = $this->templating->render('ApoutchikaMediaBundle:Media:media.html.twig');
$content = preg_replace('#</head>#', $content_css.'</head>', $content);
$content = preg_replace('#</body>#', $html.$content_js.'</body>', $content);
$response->setContent($content);
$event->setResponse($response);
}
}
|
[
"public",
"function",
"addContent",
"(",
"FilterResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"HttpKernel",
"::",
"MASTER_REQUEST",
"!=",
"$",
"event",
"->",
"getRequestType",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"response",
"=",
"$",
"event",
"->",
"getResponse",
"(",
")",
";",
"$",
"content",
"=",
"$",
"response",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"content",
",",
"'data-apoutchika-media=\"'",
")",
"!==",
"false",
")",
"{",
"$",
"js",
"=",
"array",
"(",
")",
";",
"// Include libs",
"$",
"libs",
"=",
"array",
"(",
"'jquery'",
",",
"'jqueryui'",
",",
"'underscore'",
",",
"'backbone'",
",",
"'backbonejjrelational'",
",",
"'mustache'",
",",
"'dropzone'",
",",
"'jcrop'",
",",
")",
";",
"foreach",
"(",
"$",
"libs",
"as",
"$",
"lib",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"include",
"[",
"$",
"lib",
"]",
"===",
"true",
")",
"{",
"$",
"js",
"[",
"]",
"=",
"'bundles/apoutchikamedia/js/libs/'",
".",
"$",
"lib",
".",
"'.js'",
";",
"}",
"}",
"// Include apps",
"$",
"apps",
"=",
"array",
"(",
"'init'",
",",
"'models'",
",",
"'collections'",
",",
"'viewAdd'",
",",
"'viewEditor'",
",",
"'viewField'",
",",
"'viewList'",
",",
"'router'",
",",
"'app'",
",",
")",
";",
"foreach",
"(",
"$",
"apps",
"as",
"$",
"app",
")",
"{",
"$",
"js",
"[",
"]",
"=",
"'bundles/apoutchikamedia/js/'",
".",
"$",
"app",
".",
"'.js'",
";",
"}",
"$",
"content_js",
"=",
"''",
";",
"foreach",
"(",
"$",
"js",
"as",
"$",
"n",
")",
"{",
"$",
"content_js",
".=",
"'<script src=\"'",
";",
"$",
"content_js",
".=",
"$",
"this",
"->",
"assetsHelper",
"->",
"getUrl",
"(",
"$",
"n",
")",
";",
"$",
"content_js",
".=",
"'\" type=\"text/javascript\"></script>'",
";",
"}",
"$",
"css",
"=",
"array",
"(",
")",
";",
"$",
"css",
"[",
"]",
"=",
"(",
"$",
"this",
"->",
"css",
"!==",
"null",
")",
"?",
"$",
"this",
"->",
"css",
":",
"'bundles/apoutchikamedia/css/main.css'",
";",
"if",
"(",
"$",
"this",
"->",
"include",
"[",
"'jcrop'",
"]",
"===",
"true",
")",
"{",
"$",
"css",
"[",
"]",
"=",
"'bundles/apoutchikamedia/css/jcrop.css'",
";",
"}",
"$",
"content_css",
"=",
"''",
";",
"foreach",
"(",
"$",
"css",
"as",
"$",
"n",
")",
"{",
"$",
"content_css",
".=",
"'<link rel=\"stylesheet\" type=\"text/css\" href=\"'",
";",
"$",
"content_css",
".=",
"$",
"this",
"->",
"assetsHelper",
"->",
"getUrl",
"(",
"$",
"n",
")",
";",
"$",
"content_css",
".=",
"'\" />'",
";",
"}",
"$",
"html",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"'ApoutchikaMediaBundle:Media:media.html.twig'",
")",
";",
"$",
"content",
"=",
"preg_replace",
"(",
"'#</head>#'",
",",
"$",
"content_css",
".",
"'</head>'",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"preg_replace",
"(",
"'#</body>#'",
",",
"$",
"html",
".",
"$",
"content_js",
".",
"'</body>'",
",",
"$",
"content",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"content",
")",
";",
"$",
"event",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"}",
"}"
] |
Detect if the response has media field in her content,
and add css, js and templates for mustaches.
@param FilterResponseEvent $event
@return FilterResponseEvent
|
[
"Detect",
"if",
"the",
"response",
"has",
"media",
"field",
"in",
"her",
"content",
"and",
"add",
"css",
"js",
"and",
"templates",
"for",
"mustaches",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Listener/MediaContentListener.php#L83-L151
|
223,614
|
puli/manager
|
src/Discovery/Binding/AbstractReloadBindingDescriptors.php
|
AbstractReloadBindingDescriptors.reloadBindingDescriptor
|
protected function reloadBindingDescriptor(BindingDescriptor $bindingDescriptor)
{
if (!$bindingDescriptor->isLoaded()) {
return;
}
// Keep backup of containing module before calling unload()
$containingModule = $bindingDescriptor->getContainingModule();
$typeName = $bindingDescriptor->getTypeName();
$typeDescriptor = $this->typeDescriptors->getEnabled($typeName);
// never fails with the check in the beginning
$bindingDescriptor->unload();
// never fails after unloading, given that the type name matches
// (which we can guarantee here)
$bindingDescriptor->load($containingModule, $typeDescriptor);
$this->reloadedDescriptors[] = $bindingDescriptor;
}
|
php
|
protected function reloadBindingDescriptor(BindingDescriptor $bindingDescriptor)
{
if (!$bindingDescriptor->isLoaded()) {
return;
}
// Keep backup of containing module before calling unload()
$containingModule = $bindingDescriptor->getContainingModule();
$typeName = $bindingDescriptor->getTypeName();
$typeDescriptor = $this->typeDescriptors->getEnabled($typeName);
// never fails with the check in the beginning
$bindingDescriptor->unload();
// never fails after unloading, given that the type name matches
// (which we can guarantee here)
$bindingDescriptor->load($containingModule, $typeDescriptor);
$this->reloadedDescriptors[] = $bindingDescriptor;
}
|
[
"protected",
"function",
"reloadBindingDescriptor",
"(",
"BindingDescriptor",
"$",
"bindingDescriptor",
")",
"{",
"if",
"(",
"!",
"$",
"bindingDescriptor",
"->",
"isLoaded",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Keep backup of containing module before calling unload()",
"$",
"containingModule",
"=",
"$",
"bindingDescriptor",
"->",
"getContainingModule",
"(",
")",
";",
"$",
"typeName",
"=",
"$",
"bindingDescriptor",
"->",
"getTypeName",
"(",
")",
";",
"$",
"typeDescriptor",
"=",
"$",
"this",
"->",
"typeDescriptors",
"->",
"getEnabled",
"(",
"$",
"typeName",
")",
";",
"// never fails with the check in the beginning",
"$",
"bindingDescriptor",
"->",
"unload",
"(",
")",
";",
"// never fails after unloading, given that the type name matches",
"// (which we can guarantee here)",
"$",
"bindingDescriptor",
"->",
"load",
"(",
"$",
"containingModule",
",",
"$",
"typeDescriptor",
")",
";",
"$",
"this",
"->",
"reloadedDescriptors",
"[",
"]",
"=",
"$",
"bindingDescriptor",
";",
"}"
] |
Unloads and loads a binding descriptor.
The descriptor is remembered and reloaded again in {@link postRollback()}
if the intercepted operation needs to be rolled back.
@param BindingDescriptor $bindingDescriptor The descriptor to reload.
|
[
"Unloads",
"and",
"loads",
"a",
"binding",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Discovery/Binding/AbstractReloadBindingDescriptors.php#L70-L89
|
223,615
|
puli/manager
|
src/Discovery/Type/BindingTypeDescriptorCollection.php
|
BindingTypeDescriptorCollection.add
|
public function add(BindingTypeDescriptor $typeDescriptor)
{
$this->map->set($typeDescriptor->getTypeName(), $typeDescriptor->getContainingModule()->getName(), $typeDescriptor);
}
|
php
|
public function add(BindingTypeDescriptor $typeDescriptor)
{
$this->map->set($typeDescriptor->getTypeName(), $typeDescriptor->getContainingModule()->getName(), $typeDescriptor);
}
|
[
"public",
"function",
"add",
"(",
"BindingTypeDescriptor",
"$",
"typeDescriptor",
")",
"{",
"$",
"this",
"->",
"map",
"->",
"set",
"(",
"$",
"typeDescriptor",
"->",
"getTypeName",
"(",
")",
",",
"$",
"typeDescriptor",
"->",
"getContainingModule",
"(",
")",
"->",
"getName",
"(",
")",
",",
"$",
"typeDescriptor",
")",
";",
"}"
] |
Adds a type descriptor.
@param BindingTypeDescriptor $typeDescriptor The type descriptor.
|
[
"Adds",
"a",
"type",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Discovery/Type/BindingTypeDescriptorCollection.php#L53-L56
|
223,616
|
puli/manager
|
src/Discovery/Type/BindingTypeDescriptorCollection.php
|
BindingTypeDescriptorCollection.getEnabled
|
public function getEnabled($typeName)
{
if (!$this->contains($typeName)) {
return null;
}
foreach ($this->listByTypeName($typeName) as $typeDescriptor) {
if ($typeDescriptor->isEnabled()) {
return $typeDescriptor;
}
}
return null;
}
|
php
|
public function getEnabled($typeName)
{
if (!$this->contains($typeName)) {
return null;
}
foreach ($this->listByTypeName($typeName) as $typeDescriptor) {
if ($typeDescriptor->isEnabled()) {
return $typeDescriptor;
}
}
return null;
}
|
[
"public",
"function",
"getEnabled",
"(",
"$",
"typeName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"contains",
"(",
"$",
"typeName",
")",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"listByTypeName",
"(",
"$",
"typeName",
")",
"as",
"$",
"typeDescriptor",
")",
"{",
"if",
"(",
"$",
"typeDescriptor",
"->",
"isEnabled",
"(",
")",
")",
"{",
"return",
"$",
"typeDescriptor",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the enabled type descriptor for a given type name.
@param string $typeName The name of the type.
@return BindingTypeDescriptor|null The enabled type descriptor or `null`
if no enabled descriptor was found.
|
[
"Returns",
"the",
"enabled",
"type",
"descriptor",
"for",
"a",
"given",
"type",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Discovery/Type/BindingTypeDescriptorCollection.php#L110-L123
|
223,617
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarsTable.php
|
CalendarsTable.getCalendars
|
public function getCalendars(array $options = []): array
{
$result = $conditions = [];
if (!empty($options['conditions'])) {
$conditions = $options['conditions'];
}
$query = $this->find()
->where($conditions)
->order(['name' => 'ASC'])
->all();
$result = $query->toArray();
if (empty($result)) {
return $result;
}
foreach ($result as $item) {
$item->event_types = $this->getEventTypes($item->event_types);
}
return $result;
}
|
php
|
public function getCalendars(array $options = []): array
{
$result = $conditions = [];
if (!empty($options['conditions'])) {
$conditions = $options['conditions'];
}
$query = $this->find()
->where($conditions)
->order(['name' => 'ASC'])
->all();
$result = $query->toArray();
if (empty($result)) {
return $result;
}
foreach ($result as $item) {
$item->event_types = $this->getEventTypes($item->event_types);
}
return $result;
}
|
[
"public",
"function",
"getCalendars",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"$",
"conditions",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"conditions",
"=",
"$",
"options",
"[",
"'conditions'",
"]",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"$",
"conditions",
")",
"->",
"order",
"(",
"[",
"'name'",
"=>",
"'ASC'",
"]",
")",
"->",
"all",
"(",
")",
";",
"$",
"result",
"=",
"$",
"query",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"foreach",
"(",
"$",
"result",
"as",
"$",
"item",
")",
"{",
"$",
"item",
"->",
"event_types",
"=",
"$",
"this",
"->",
"getEventTypes",
"(",
"$",
"item",
"->",
"event_types",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get Calendar entities.
@param mixed[] $options for filtering calendars
@return mixed[] $result containing calendar entities with event_types
|
[
"Get",
"Calendar",
"entities",
"."
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarsTable.php#L176-L199
|
223,618
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarsTable.php
|
CalendarsTable.getColor
|
public function getColor(?EntityInterface $entity = null): string
{
$color = Configure::read('Calendar.Configs.color');
if ($entity instanceof EntityInterface && !empty($entity->get('color'))) {
$color = $entity->get('color');
}
if (!$color) {
$color = '#337ab7';
}
return $color;
}
|
php
|
public function getColor(?EntityInterface $entity = null): string
{
$color = Configure::read('Calendar.Configs.color');
if ($entity instanceof EntityInterface && !empty($entity->get('color'))) {
$color = $entity->get('color');
}
if (!$color) {
$color = '#337ab7';
}
return $color;
}
|
[
"public",
"function",
"getColor",
"(",
"?",
"EntityInterface",
"$",
"entity",
"=",
"null",
")",
":",
"string",
"{",
"$",
"color",
"=",
"Configure",
"::",
"read",
"(",
"'Calendar.Configs.color'",
")",
";",
"if",
"(",
"$",
"entity",
"instanceof",
"EntityInterface",
"&&",
"!",
"empty",
"(",
"$",
"entity",
"->",
"get",
"(",
"'color'",
")",
")",
")",
"{",
"$",
"color",
"=",
"$",
"entity",
"->",
"get",
"(",
"'color'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"color",
")",
"{",
"$",
"color",
"=",
"'#337ab7'",
";",
"}",
"return",
"$",
"color",
";",
"}"
] |
Get Default calendar color.
@param \Cake\Datasource\EntityInterface|null $entity of the current calendar
@return string $color containing hexadecimal color notation.
|
[
"Get",
"Default",
"calendar",
"color",
"."
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarsTable.php#L207-L220
|
223,619
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarsTable.php
|
CalendarsTable.getByAllowedEventTypes
|
public function getByAllowedEventTypes(?string $tableName = null, array $options = []): array
{
$result = [];
$query = $this->find();
$query->execute();
$query->all();
if (!$query->count()) {
return $result;
}
$resultSet = $query->all();
foreach ($resultSet as $calendar) {
if (empty($calendar->event_types)) {
continue;
}
$event_types = json_decode($calendar->event_types, true);
$found = array_filter($event_types, function ($item) use ($tableName) {
if (preg_match("/$tableName::/", $item, $matches)) {
return $item;
}
});
if (!empty($found)) {
$result[] = $calendar;
}
}
return $result;
}
|
php
|
public function getByAllowedEventTypes(?string $tableName = null, array $options = []): array
{
$result = [];
$query = $this->find();
$query->execute();
$query->all();
if (!$query->count()) {
return $result;
}
$resultSet = $query->all();
foreach ($resultSet as $calendar) {
if (empty($calendar->event_types)) {
continue;
}
$event_types = json_decode($calendar->event_types, true);
$found = array_filter($event_types, function ($item) use ($tableName) {
if (preg_match("/$tableName::/", $item, $matches)) {
return $item;
}
});
if (!empty($found)) {
$result[] = $calendar;
}
}
return $result;
}
|
[
"public",
"function",
"getByAllowedEventTypes",
"(",
"?",
"string",
"$",
"tableName",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
";",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"$",
"query",
"->",
"all",
"(",
")",
";",
"if",
"(",
"!",
"$",
"query",
"->",
"count",
"(",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"resultSet",
"=",
"$",
"query",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"resultSet",
"as",
"$",
"calendar",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"calendar",
"->",
"event_types",
")",
")",
"{",
"continue",
";",
"}",
"$",
"event_types",
"=",
"json_decode",
"(",
"$",
"calendar",
"->",
"event_types",
",",
"true",
")",
";",
"$",
"found",
"=",
"array_filter",
"(",
"$",
"event_types",
",",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"tableName",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/$tableName::/\"",
",",
"$",
"item",
",",
"$",
"matches",
")",
")",
"{",
"return",
"$",
"item",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"found",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"calendar",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the list of Calendar instances
Getting the list of calendars where following module is listed
in event_types field. For instance: Users::birthdays.
@param string $tableName of the app's module
@param mixed[] $options with extra data
@return mixed[] $result with calendar instances
|
[
"Get",
"the",
"list",
"of",
"Calendar",
"instances"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarsTable.php#L266-L298
|
223,620
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarsTable.php
|
CalendarsTable.saveCalendarEntity
|
public function saveCalendarEntity(array $calendar = [], array $options = []): array
{
$response = [
'errors' => [],
'status' => false,
'entity' => null,
];
$query = $this->find()
->where($options['conditions']);
$query->execute();
if (!$query->count()) {
$entity = $this->newEntity();
$entity = $this->patchEntity($entity, $calendar);
} else {
/** @var \Cake\Datasource\EntityInterface $calEntity */
$calEntity = $query->firstOrFail();
$entity = $this->patchEntity($calEntity, $calendar);
}
$saved = $this->save($entity);
if ($saved) {
$response['status'] = true;
$response['entity'] = $saved;
} else {
$response['errors'] = $entity->getErrors();
}
return $response;
}
|
php
|
public function saveCalendarEntity(array $calendar = [], array $options = []): array
{
$response = [
'errors' => [],
'status' => false,
'entity' => null,
];
$query = $this->find()
->where($options['conditions']);
$query->execute();
if (!$query->count()) {
$entity = $this->newEntity();
$entity = $this->patchEntity($entity, $calendar);
} else {
/** @var \Cake\Datasource\EntityInterface $calEntity */
$calEntity = $query->firstOrFail();
$entity = $this->patchEntity($calEntity, $calendar);
}
$saved = $this->save($entity);
if ($saved) {
$response['status'] = true;
$response['entity'] = $saved;
} else {
$response['errors'] = $entity->getErrors();
}
return $response;
}
|
[
"public",
"function",
"saveCalendarEntity",
"(",
"array",
"$",
"calendar",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"response",
"=",
"[",
"'errors'",
"=>",
"[",
"]",
",",
"'status'",
"=>",
"false",
",",
"'entity'",
"=>",
"null",
",",
"]",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"$",
"options",
"[",
"'conditions'",
"]",
")",
";",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"$",
"query",
"->",
"count",
"(",
")",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"newEntity",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"patchEntity",
"(",
"$",
"entity",
",",
"$",
"calendar",
")",
";",
"}",
"else",
"{",
"/** @var \\Cake\\Datasource\\EntityInterface $calEntity */",
"$",
"calEntity",
"=",
"$",
"query",
"->",
"firstOrFail",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"patchEntity",
"(",
"$",
"calEntity",
",",
"$",
"calendar",
")",
";",
"}",
"$",
"saved",
"=",
"$",
"this",
"->",
"save",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"$",
"saved",
")",
"{",
"$",
"response",
"[",
"'status'",
"]",
"=",
"true",
";",
"$",
"response",
"[",
"'entity'",
"]",
"=",
"$",
"saved",
";",
"}",
"else",
"{",
"$",
"response",
"[",
"'errors'",
"]",
"=",
"$",
"entity",
"->",
"getErrors",
"(",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Save Calendar Entity
@param mixed[] $calendar data to be saved
@param mixed[] $options in case any extras required for conditions
@return mixed[] $response containing the state of save operation
|
[
"Save",
"Calendar",
"Entity"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarsTable.php#L308-L340
|
223,621
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarsTable.php
|
CalendarsTable.getEventTypes
|
protected function getEventTypes(?string $data = null): array
{
$result = [];
if (empty($data)) {
return $result;
}
$result = json_decode($data, true);
return $result;
}
|
php
|
protected function getEventTypes(?string $data = null): array
{
$result = [];
if (empty($data)) {
return $result;
}
$result = json_decode($data, true);
return $result;
}
|
[
"protected",
"function",
"getEventTypes",
"(",
"?",
"string",
"$",
"data",
"=",
"null",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Get Event Types saved within Calendar
@param string|null $data of the event type
@return mixed[] $result with event types decoded.
|
[
"Get",
"Event",
"Types",
"saved",
"within",
"Calendar"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarsTable.php#L348-L359
|
223,622
|
QoboLtd/cakephp-calendar
|
src/Object/Objects/AbstractObject.php
|
AbstractObject.toEntity
|
public function toEntity(): EntityInterface
{
$data = [];
$entityProvider = $this->getEntityProvider();
foreach (get_object_vars($this) as $property => $value) {
$method = Inflector::variable('get ' . $property);
if (method_exists($this, $method) && is_callable([$this, $method])) {
$field = Inflector::underscore($property);
$data[$field] = $this->$method();
}
}
$entity = new $entityProvider($data);
return $entity;
}
|
php
|
public function toEntity(): EntityInterface
{
$data = [];
$entityProvider = $this->getEntityProvider();
foreach (get_object_vars($this) as $property => $value) {
$method = Inflector::variable('get ' . $property);
if (method_exists($this, $method) && is_callable([$this, $method])) {
$field = Inflector::underscore($property);
$data[$field] = $this->$method();
}
}
$entity = new $entityProvider($data);
return $entity;
}
|
[
"public",
"function",
"toEntity",
"(",
")",
":",
"EntityInterface",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"entityProvider",
"=",
"$",
"this",
"->",
"getEntityProvider",
"(",
")",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"Inflector",
"::",
"variable",
"(",
"'get '",
".",
"$",
"property",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
")",
")",
"{",
"$",
"field",
"=",
"Inflector",
"::",
"underscore",
"(",
"$",
"property",
")",
";",
"$",
"data",
"[",
"$",
"field",
"]",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"}",
"}",
"$",
"entity",
"=",
"new",
"$",
"entityProvider",
"(",
"$",
"data",
")",
";",
"return",
"$",
"entity",
";",
"}"
] |
Convert Generic Object to corresponding Cake\ORM\Entity
Entity is assembled based on Cake\ORM\Entity and
prepopulated with the data of a given object instance
via getters.
@return \Cake\Datasource\EntityInterface $entity of the calendar
|
[
"Convert",
"Generic",
"Object",
"to",
"corresponding",
"Cake",
"\\",
"ORM",
"\\",
"Entity"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Object/Objects/AbstractObject.php#L99-L116
|
223,623
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.createReference
|
public function createReference(MediaInterface $media)
{
$allowed = false;
foreach ($this->contexts as $context) {
if (in_array($media->getExtension(), $context)) {
$allowed = true;
break;
}
}
if ($allowed === false) {
$this->error = array('error.extensionNotAllowed', array('%extension%' => $media->getExtension()));
return false;
}
// secure extension for reference
if (!in_array($media->getExtension(), $this->trustedExtensions)) {
$media->setExtension($media->getExtension().'.txt');
$media->setType($media::OTHER);
}
do {
$media->setReference(sha1(microtime(true).mt_rand()).'.'.$media->getExtension());
} while ($this->filesystemManipulator->has($this->originalDir.'/'.$media->getReference()));
return true;
}
|
php
|
public function createReference(MediaInterface $media)
{
$allowed = false;
foreach ($this->contexts as $context) {
if (in_array($media->getExtension(), $context)) {
$allowed = true;
break;
}
}
if ($allowed === false) {
$this->error = array('error.extensionNotAllowed', array('%extension%' => $media->getExtension()));
return false;
}
// secure extension for reference
if (!in_array($media->getExtension(), $this->trustedExtensions)) {
$media->setExtension($media->getExtension().'.txt');
$media->setType($media::OTHER);
}
do {
$media->setReference(sha1(microtime(true).mt_rand()).'.'.$media->getExtension());
} while ($this->filesystemManipulator->has($this->originalDir.'/'.$media->getReference()));
return true;
}
|
[
"public",
"function",
"createReference",
"(",
"MediaInterface",
"$",
"media",
")",
"{",
"$",
"allowed",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"contexts",
"as",
"$",
"context",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"media",
"->",
"getExtension",
"(",
")",
",",
"$",
"context",
")",
")",
"{",
"$",
"allowed",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"allowed",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"array",
"(",
"'error.extensionNotAllowed'",
",",
"array",
"(",
"'%extension%'",
"=>",
"$",
"media",
"->",
"getExtension",
"(",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"// secure extension for reference",
"if",
"(",
"!",
"in_array",
"(",
"$",
"media",
"->",
"getExtension",
"(",
")",
",",
"$",
"this",
"->",
"trustedExtensions",
")",
")",
"{",
"$",
"media",
"->",
"setExtension",
"(",
"$",
"media",
"->",
"getExtension",
"(",
")",
".",
"'.txt'",
")",
";",
"$",
"media",
"->",
"setType",
"(",
"$",
"media",
"::",
"OTHER",
")",
";",
"}",
"do",
"{",
"$",
"media",
"->",
"setReference",
"(",
"sha1",
"(",
"microtime",
"(",
"true",
")",
".",
"mt_rand",
"(",
")",
")",
".",
"'.'",
".",
"$",
"media",
"->",
"getExtension",
"(",
")",
")",
";",
"}",
"while",
"(",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"has",
"(",
"$",
"this",
"->",
"originalDir",
".",
"'/'",
".",
"$",
"media",
"->",
"getReference",
"(",
")",
")",
")",
";",
"return",
"true",
";",
"}"
] |
Create reference for media.
@param MediaInterface $media
@return bool
|
[
"Create",
"reference",
"for",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L150-L177
|
223,624
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.search
|
public function search($filterKey, $q = null, $type = null)
{
if ($type == 0) {
$type = null;
}
if (!$this->filter->has($filterKey)) {
return array();
}
$qb = $this->entityManager->getRepository($this->class)->createQueryBuilder('m')
->select('m.id as id')
;
$filter = $this->filter->get($filterKey);
if ($filter === null) {
$qb->where('m.filter IS NULL');
} else {
$qb->where('m.filter = :filter')
->setParameter('filter', $filter)
;
}
if ($q !== null) {
foreach (explode(' ', $q) as $i => $word) {
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->like('m.name', ':q'.$i),
$qb->expr()->like('m.description', ':q'.$i),
$qb->expr()->like('m.alt', ':q'.$i)
)
)
->setParameter('q'.$i, '%'.$word.'%')
;
}
}
if ($type != null) {
$qb->andWhere('m.type = :type')
->setParameter('type', $type)
;
}
$results = $qb->getQuery()
->getArrayResult();
$ids = array();
foreach ($results as $media) {
$ids[] = $media['id'];
}
return $ids;
}
|
php
|
public function search($filterKey, $q = null, $type = null)
{
if ($type == 0) {
$type = null;
}
if (!$this->filter->has($filterKey)) {
return array();
}
$qb = $this->entityManager->getRepository($this->class)->createQueryBuilder('m')
->select('m.id as id')
;
$filter = $this->filter->get($filterKey);
if ($filter === null) {
$qb->where('m.filter IS NULL');
} else {
$qb->where('m.filter = :filter')
->setParameter('filter', $filter)
;
}
if ($q !== null) {
foreach (explode(' ', $q) as $i => $word) {
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->like('m.name', ':q'.$i),
$qb->expr()->like('m.description', ':q'.$i),
$qb->expr()->like('m.alt', ':q'.$i)
)
)
->setParameter('q'.$i, '%'.$word.'%')
;
}
}
if ($type != null) {
$qb->andWhere('m.type = :type')
->setParameter('type', $type)
;
}
$results = $qb->getQuery()
->getArrayResult();
$ids = array();
foreach ($results as $media) {
$ids[] = $media['id'];
}
return $ids;
}
|
[
"public",
"function",
"search",
"(",
"$",
"filterKey",
",",
"$",
"q",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"0",
")",
"{",
"$",
"type",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"filter",
"->",
"has",
"(",
"$",
"filterKey",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"qb",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"class",
")",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
"->",
"select",
"(",
"'m.id as id'",
")",
";",
"$",
"filter",
"=",
"$",
"this",
"->",
"filter",
"->",
"get",
"(",
"$",
"filterKey",
")",
";",
"if",
"(",
"$",
"filter",
"===",
"null",
")",
"{",
"$",
"qb",
"->",
"where",
"(",
"'m.filter IS NULL'",
")",
";",
"}",
"else",
"{",
"$",
"qb",
"->",
"where",
"(",
"'m.filter = :filter'",
")",
"->",
"setParameter",
"(",
"'filter'",
",",
"$",
"filter",
")",
";",
"}",
"if",
"(",
"$",
"q",
"!==",
"null",
")",
"{",
"foreach",
"(",
"explode",
"(",
"' '",
",",
"$",
"q",
")",
"as",
"$",
"i",
"=>",
"$",
"word",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'m.name'",
",",
"':q'",
".",
"$",
"i",
")",
",",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'m.description'",
",",
"':q'",
".",
"$",
"i",
")",
",",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"like",
"(",
"'m.alt'",
",",
"':q'",
".",
"$",
"i",
")",
")",
")",
"->",
"setParameter",
"(",
"'q'",
".",
"$",
"i",
",",
"'%'",
".",
"$",
"word",
".",
"'%'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"type",
"!=",
"null",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'m.type = :type'",
")",
"->",
"setParameter",
"(",
"'type'",
",",
"$",
"type",
")",
";",
"}",
"$",
"results",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getArrayResult",
"(",
")",
";",
"$",
"ids",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"media",
")",
"{",
"$",
"ids",
"[",
"]",
"=",
"$",
"media",
"[",
"'id'",
"]",
";",
"}",
"return",
"$",
"ids",
";",
"}"
] |
Query for search medias with keywords and type.
@param string $filterKey Allowed filter for this search
@param string $q keywords
@param int $type Type of media, constant of MediaInterface
@return array list id of medias matches with query
|
[
"Query",
"for",
"search",
"medias",
"with",
"keywords",
"and",
"type",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L188-L240
|
223,625
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.findAllByFiltersKeys
|
public function findAllByFiltersKeys(array $filtersKeys)
{
$qb = $this->entityManager->getRepository($this->class)->createQueryBuilder('m');
$filters = array();
$addNull = false;
$inversedfilters = array();
foreach ($filtersKeys as $filter) {
if ($this->filter->has($filter)) {
$value = $this->filter->get($filter);
$inversedfilters[$value] = $filter;
if ($value === null) {
$addNull = true;
} else {
$filters[] = $value;
}
}
}
if ($addNull === false && empty($filters)) {
return array();
}
if (!empty($filters)) {
$qb
->select('m')
->where($qb->expr()->in('m.filter', $filters))
;
}
if ($addNull === true) {
$qb->orWhere('m.filter IS NULL');
}
$medias = $qb->orderBy('m.createdAt', 'DESC')
->getQuery()
->getResult()
;
foreach ($medias as $media) {
$media->setCryptedFilter($inversedfilters[$media->getFilter()]);
}
return $medias;
}
|
php
|
public function findAllByFiltersKeys(array $filtersKeys)
{
$qb = $this->entityManager->getRepository($this->class)->createQueryBuilder('m');
$filters = array();
$addNull = false;
$inversedfilters = array();
foreach ($filtersKeys as $filter) {
if ($this->filter->has($filter)) {
$value = $this->filter->get($filter);
$inversedfilters[$value] = $filter;
if ($value === null) {
$addNull = true;
} else {
$filters[] = $value;
}
}
}
if ($addNull === false && empty($filters)) {
return array();
}
if (!empty($filters)) {
$qb
->select('m')
->where($qb->expr()->in('m.filter', $filters))
;
}
if ($addNull === true) {
$qb->orWhere('m.filter IS NULL');
}
$medias = $qb->orderBy('m.createdAt', 'DESC')
->getQuery()
->getResult()
;
foreach ($medias as $media) {
$media->setCryptedFilter($inversedfilters[$media->getFilter()]);
}
return $medias;
}
|
[
"public",
"function",
"findAllByFiltersKeys",
"(",
"array",
"$",
"filtersKeys",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"class",
")",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
";",
"$",
"filters",
"=",
"array",
"(",
")",
";",
"$",
"addNull",
"=",
"false",
";",
"$",
"inversedfilters",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"filtersKeys",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"filter",
"->",
"has",
"(",
"$",
"filter",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"filter",
"->",
"get",
"(",
"$",
"filter",
")",
";",
"$",
"inversedfilters",
"[",
"$",
"value",
"]",
"=",
"$",
"filter",
";",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"addNull",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"filters",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"addNull",
"===",
"false",
"&&",
"empty",
"(",
"$",
"filters",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"filters",
")",
")",
"{",
"$",
"qb",
"->",
"select",
"(",
"'m'",
")",
"->",
"where",
"(",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"in",
"(",
"'m.filter'",
",",
"$",
"filters",
")",
")",
";",
"}",
"if",
"(",
"$",
"addNull",
"===",
"true",
")",
"{",
"$",
"qb",
"->",
"orWhere",
"(",
"'m.filter IS NULL'",
")",
";",
"}",
"$",
"medias",
"=",
"$",
"qb",
"->",
"orderBy",
"(",
"'m.createdAt'",
",",
"'DESC'",
")",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"foreach",
"(",
"$",
"medias",
"as",
"$",
"media",
")",
"{",
"$",
"media",
"->",
"setCryptedFilter",
"(",
"$",
"inversedfilters",
"[",
"$",
"media",
"->",
"getFilter",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"medias",
";",
"}"
] |
Custom find all, sort by createAt desc.
@param array $filtersKeys List medias in this filters
|
[
"Custom",
"find",
"all",
"sort",
"by",
"createAt",
"desc",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L247-L292
|
223,626
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.delete
|
public function delete($media, $flush = true)
{
parent::delete($media, $flush);
foreach ($this->filesystemManipulator->keys() as $key) {
if (preg_match('#/'.$media->getReference().'$#', $key)) {
$this->filesystemManipulator->delete($key);
}
}
}
|
php
|
public function delete($media, $flush = true)
{
parent::delete($media, $flush);
foreach ($this->filesystemManipulator->keys() as $key) {
if (preg_match('#/'.$media->getReference().'$#', $key)) {
$this->filesystemManipulator->delete($key);
}
}
}
|
[
"public",
"function",
"delete",
"(",
"$",
"media",
",",
"$",
"flush",
"=",
"true",
")",
"{",
"parent",
"::",
"delete",
"(",
"$",
"media",
",",
"$",
"flush",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"keys",
"(",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#/'",
".",
"$",
"media",
"->",
"getReference",
"(",
")",
".",
"'$#'",
",",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"delete",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}"
] |
Delete media entity and files.
@param MediaInterface $media
@param bool $flush
|
[
"Delete",
"media",
"entity",
"and",
"files",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L300-L309
|
223,627
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.saveFile
|
private function saveFile(MediaInterface $media)
{
$file = $media->getFile();
$fileInfo = new FileInfo($file);
$type = $fileInfo->getType();
$media->setType($type);
if ($media->getName() === null) {
$media->setName($fileInfo->getName());
$media->setAlt($fileInfo->getName());
}
$media
->setMimeType($fileInfo->getMimeType())
->setExtension($fileInfo->getExtension())
;
if (!$this->createReference($media)) {
return false;
}
$key = $this->originalDir.'/'.$media->getReference();
$this->filesystemManipulator->save($key, $file->getPathname());
$this->setSizeWidthAndHeight($media);
$media->setFile();
if ($this->limit === null || $media->getType() !== $media::IMAGE) {
return $media;
}
// resize if image > limit
if ($media->getWidth() > $this->limit || $media->getHeight() > $this->limit) {
$resize = new Resize($this, $media);
$resize->setTargetSize($this->limit, $this->limit);
$resize->apply();
}
return $media;
}
|
php
|
private function saveFile(MediaInterface $media)
{
$file = $media->getFile();
$fileInfo = new FileInfo($file);
$type = $fileInfo->getType();
$media->setType($type);
if ($media->getName() === null) {
$media->setName($fileInfo->getName());
$media->setAlt($fileInfo->getName());
}
$media
->setMimeType($fileInfo->getMimeType())
->setExtension($fileInfo->getExtension())
;
if (!$this->createReference($media)) {
return false;
}
$key = $this->originalDir.'/'.$media->getReference();
$this->filesystemManipulator->save($key, $file->getPathname());
$this->setSizeWidthAndHeight($media);
$media->setFile();
if ($this->limit === null || $media->getType() !== $media::IMAGE) {
return $media;
}
// resize if image > limit
if ($media->getWidth() > $this->limit || $media->getHeight() > $this->limit) {
$resize = new Resize($this, $media);
$resize->setTargetSize($this->limit, $this->limit);
$resize->apply();
}
return $media;
}
|
[
"private",
"function",
"saveFile",
"(",
"MediaInterface",
"$",
"media",
")",
"{",
"$",
"file",
"=",
"$",
"media",
"->",
"getFile",
"(",
")",
";",
"$",
"fileInfo",
"=",
"new",
"FileInfo",
"(",
"$",
"file",
")",
";",
"$",
"type",
"=",
"$",
"fileInfo",
"->",
"getType",
"(",
")",
";",
"$",
"media",
"->",
"setType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"media",
"->",
"getName",
"(",
")",
"===",
"null",
")",
"{",
"$",
"media",
"->",
"setName",
"(",
"$",
"fileInfo",
"->",
"getName",
"(",
")",
")",
";",
"$",
"media",
"->",
"setAlt",
"(",
"$",
"fileInfo",
"->",
"getName",
"(",
")",
")",
";",
"}",
"$",
"media",
"->",
"setMimeType",
"(",
"$",
"fileInfo",
"->",
"getMimeType",
"(",
")",
")",
"->",
"setExtension",
"(",
"$",
"fileInfo",
"->",
"getExtension",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"createReference",
"(",
"$",
"media",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"key",
"=",
"$",
"this",
"->",
"originalDir",
".",
"'/'",
".",
"$",
"media",
"->",
"getReference",
"(",
")",
";",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"save",
"(",
"$",
"key",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"$",
"this",
"->",
"setSizeWidthAndHeight",
"(",
"$",
"media",
")",
";",
"$",
"media",
"->",
"setFile",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"limit",
"===",
"null",
"||",
"$",
"media",
"->",
"getType",
"(",
")",
"!==",
"$",
"media",
"::",
"IMAGE",
")",
"{",
"return",
"$",
"media",
";",
"}",
"// resize if image > limit",
"if",
"(",
"$",
"media",
"->",
"getWidth",
"(",
")",
">",
"$",
"this",
"->",
"limit",
"||",
"$",
"media",
"->",
"getHeight",
"(",
")",
">",
"$",
"this",
"->",
"limit",
")",
"{",
"$",
"resize",
"=",
"new",
"Resize",
"(",
"$",
"this",
",",
"$",
"media",
")",
";",
"$",
"resize",
"->",
"setTargetSize",
"(",
"$",
"this",
"->",
"limit",
",",
"$",
"this",
"->",
"limit",
")",
";",
"$",
"resize",
"->",
"apply",
"(",
")",
";",
"}",
"return",
"$",
"media",
";",
"}"
] |
Save new file.
@param MediaInterface $media
@return MediaInterface
|
[
"Save",
"new",
"file",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L318-L360
|
223,628
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.setSizeWidthAndHeight
|
public function setSizeWidthAndHeight(MediaInterface $media)
{
$key = $this->originalDir.'/'.$media->getReference();
$media->setSize($this->filesystemManipulator->size($key));
if ($media->getType() === $media::IMAGE) {
$image = $this->imagine->load(
$this->filesystemManipulator->read($key)
);
$size = $image->getSize();
$media->setWidth($size->getWidth());
$media->setHeight($size->getHeight());
}
return $this;
}
|
php
|
public function setSizeWidthAndHeight(MediaInterface $media)
{
$key = $this->originalDir.'/'.$media->getReference();
$media->setSize($this->filesystemManipulator->size($key));
if ($media->getType() === $media::IMAGE) {
$image = $this->imagine->load(
$this->filesystemManipulator->read($key)
);
$size = $image->getSize();
$media->setWidth($size->getWidth());
$media->setHeight($size->getHeight());
}
return $this;
}
|
[
"public",
"function",
"setSizeWidthAndHeight",
"(",
"MediaInterface",
"$",
"media",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"originalDir",
".",
"'/'",
".",
"$",
"media",
"->",
"getReference",
"(",
")",
";",
"$",
"media",
"->",
"setSize",
"(",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"size",
"(",
"$",
"key",
")",
")",
";",
"if",
"(",
"$",
"media",
"->",
"getType",
"(",
")",
"===",
"$",
"media",
"::",
"IMAGE",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"imagine",
"->",
"load",
"(",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"read",
"(",
"$",
"key",
")",
")",
";",
"$",
"size",
"=",
"$",
"image",
"->",
"getSize",
"(",
")",
";",
"$",
"media",
"->",
"setWidth",
"(",
"$",
"size",
"->",
"getWidth",
"(",
")",
")",
";",
"$",
"media",
"->",
"setHeight",
"(",
"$",
"size",
"->",
"getHeight",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set size of file, if it's image, set width and height.
@param MediaInterface $media
@return MediaInterface
|
[
"Set",
"size",
"of",
"file",
"if",
"it",
"s",
"image",
"set",
"width",
"and",
"height",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L369-L385
|
223,629
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.getUrl
|
public function getUrl(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->url($this->getAliasAndKey($media, $alias));
}
|
php
|
public function getUrl(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->url($this->getAliasAndKey($media, $alias));
}
|
[
"public",
"function",
"getUrl",
"(",
"MediaInterface",
"$",
"media",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"url",
"(",
"$",
"this",
"->",
"getAliasAndKey",
"(",
"$",
"media",
",",
"$",
"alias",
")",
")",
";",
"}"
] |
Get relative url of media.
@param MediaInterface $media
@param string|array|null $alias
return string relative Url of media ex: /medias/123x456_focus/9485990a0e13c3ef2adddb69a75a64d44c40caa7.jpg
|
[
"Get",
"relative",
"url",
"of",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L395-L398
|
223,630
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.getAbsoluteUrl
|
public function getAbsoluteUrl(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->url($this->getAliasAndKey($media, $alias), true);
}
|
php
|
public function getAbsoluteUrl(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->url($this->getAliasAndKey($media, $alias), true);
}
|
[
"public",
"function",
"getAbsoluteUrl",
"(",
"MediaInterface",
"$",
"media",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"url",
"(",
"$",
"this",
"->",
"getAliasAndKey",
"(",
"$",
"media",
",",
"$",
"alias",
")",
",",
"true",
")",
";",
"}"
] |
Get absolute url of media.
@param MediaInterface $media
@param string|array|null $alias
return string Url of media ex: http://www.exemple.tld/medias/123x456_focus/9485990a0e13c3ef2adddb69a75a64d44c40caa7.jpg
|
[
"Get",
"absolute",
"url",
"of",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L408-L411
|
223,631
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.getPath
|
public function getPath(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->path($this->getAliasAndKey($media, $alias));
}
|
php
|
public function getPath(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->path($this->getAliasAndKey($media, $alias));
}
|
[
"public",
"function",
"getPath",
"(",
"MediaInterface",
"$",
"media",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"path",
"(",
"$",
"this",
"->",
"getAliasAndKey",
"(",
"$",
"media",
",",
"$",
"alias",
")",
")",
";",
"}"
] |
Get path of media.
@param MediaInterface $media
@param string|array|null $alias
return string path of media ex: /var/www/exemple.tld/web/medias/123x456_focus/9485990a0e13c3ef2adddb69a75a64d44c40caa7.jpg
|
[
"Get",
"path",
"of",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L421-L424
|
223,632
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.getContent
|
public function getContent(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->read($this->getAliasAndKey($media, $alias));
}
|
php
|
public function getContent(MediaInterface $media, $alias = null)
{
return $this->filesystemManipulator->read($this->getAliasAndKey($media, $alias));
}
|
[
"public",
"function",
"getContent",
"(",
"MediaInterface",
"$",
"media",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"read",
"(",
"$",
"this",
"->",
"getAliasAndKey",
"(",
"$",
"media",
",",
"$",
"alias",
")",
")",
";",
"}"
] |
Get content of file.
@param MediaInterface $media
@param string|array|null $alias
@return string
|
[
"Get",
"content",
"of",
"file",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L434-L437
|
223,633
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.getAliasAndKey
|
public function getAliasAndKey(MediaInterface $media, $alias = null)
{
$aliasManipulator = $this->aliasManipulatorFactory->setAlias($alias);
if ($media->getType() === $media::IMAGE) {
$alias = $aliasManipulator->getAliasName();
if ($alias !== $this->originalDir) {
$this->cropImage($media, $aliasManipulator);
}
} else {
$alias = $this->originalDir;
}
return $alias.'/'.$media->getReference();
}
|
php
|
public function getAliasAndKey(MediaInterface $media, $alias = null)
{
$aliasManipulator = $this->aliasManipulatorFactory->setAlias($alias);
if ($media->getType() === $media::IMAGE) {
$alias = $aliasManipulator->getAliasName();
if ($alias !== $this->originalDir) {
$this->cropImage($media, $aliasManipulator);
}
} else {
$alias = $this->originalDir;
}
return $alias.'/'.$media->getReference();
}
|
[
"public",
"function",
"getAliasAndKey",
"(",
"MediaInterface",
"$",
"media",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"aliasManipulator",
"=",
"$",
"this",
"->",
"aliasManipulatorFactory",
"->",
"setAlias",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"media",
"->",
"getType",
"(",
")",
"===",
"$",
"media",
"::",
"IMAGE",
")",
"{",
"$",
"alias",
"=",
"$",
"aliasManipulator",
"->",
"getAliasName",
"(",
")",
";",
"if",
"(",
"$",
"alias",
"!==",
"$",
"this",
"->",
"originalDir",
")",
"{",
"$",
"this",
"->",
"cropImage",
"(",
"$",
"media",
",",
"$",
"aliasManipulator",
")",
";",
"}",
"}",
"else",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"originalDir",
";",
"}",
"return",
"$",
"alias",
".",
"'/'",
".",
"$",
"media",
"->",
"getReference",
"(",
")",
";",
"}"
] |
Get key of media for filesystem. If image with alias, crop it.
@param MediaInterface $media
@param string|array|null $alias
@return string
|
[
"Get",
"key",
"of",
"media",
"for",
"filesystem",
".",
"If",
"image",
"with",
"alias",
"crop",
"it",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L447-L462
|
223,634
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.cropImage
|
private function cropImage(MediaInterface $media, AliasManipulator $aliasManipulator)
{
$aliasName = $aliasManipulator->getAliasName();
$aliasArray = $aliasManipulator->getAliasArray();
$mediaPath = $aliasName.'/'.$media->getReference();
if ($this->filesystemManipulator->has($mediaPath)) {
return true;
}
$mediaOriginalPath = $this->originalDir.'/'.$media->getReference();
if (!$this->filesystemManipulator->has($mediaOriginalPath)) {
throw new \Exception('The file \''.$mediaOriginalPath.'\' is not found.');
}
if ($aliasArray['focus'] === true) {
$magicFocus = new Focus($this, $media);
$magicFocus
->setTargetSize($aliasArray['width'], $aliasArray['height'])
->setFocus($media->getFocusLeft(), $media->getFocusTop())
->apply($aliasName)
;
return true;
}
$resize = new Resize($this, $media);
$resize
->setTargetSize($aliasArray['width'], $aliasArray['height'])
->apply($aliasName)
;
return true;
}
|
php
|
private function cropImage(MediaInterface $media, AliasManipulator $aliasManipulator)
{
$aliasName = $aliasManipulator->getAliasName();
$aliasArray = $aliasManipulator->getAliasArray();
$mediaPath = $aliasName.'/'.$media->getReference();
if ($this->filesystemManipulator->has($mediaPath)) {
return true;
}
$mediaOriginalPath = $this->originalDir.'/'.$media->getReference();
if (!$this->filesystemManipulator->has($mediaOriginalPath)) {
throw new \Exception('The file \''.$mediaOriginalPath.'\' is not found.');
}
if ($aliasArray['focus'] === true) {
$magicFocus = new Focus($this, $media);
$magicFocus
->setTargetSize($aliasArray['width'], $aliasArray['height'])
->setFocus($media->getFocusLeft(), $media->getFocusTop())
->apply($aliasName)
;
return true;
}
$resize = new Resize($this, $media);
$resize
->setTargetSize($aliasArray['width'], $aliasArray['height'])
->apply($aliasName)
;
return true;
}
|
[
"private",
"function",
"cropImage",
"(",
"MediaInterface",
"$",
"media",
",",
"AliasManipulator",
"$",
"aliasManipulator",
")",
"{",
"$",
"aliasName",
"=",
"$",
"aliasManipulator",
"->",
"getAliasName",
"(",
")",
";",
"$",
"aliasArray",
"=",
"$",
"aliasManipulator",
"->",
"getAliasArray",
"(",
")",
";",
"$",
"mediaPath",
"=",
"$",
"aliasName",
".",
"'/'",
".",
"$",
"media",
"->",
"getReference",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"has",
"(",
"$",
"mediaPath",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"mediaOriginalPath",
"=",
"$",
"this",
"->",
"originalDir",
".",
"'/'",
".",
"$",
"media",
"->",
"getReference",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"has",
"(",
"$",
"mediaOriginalPath",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The file \\''",
".",
"$",
"mediaOriginalPath",
".",
"'\\' is not found.'",
")",
";",
"}",
"if",
"(",
"$",
"aliasArray",
"[",
"'focus'",
"]",
"===",
"true",
")",
"{",
"$",
"magicFocus",
"=",
"new",
"Focus",
"(",
"$",
"this",
",",
"$",
"media",
")",
";",
"$",
"magicFocus",
"->",
"setTargetSize",
"(",
"$",
"aliasArray",
"[",
"'width'",
"]",
",",
"$",
"aliasArray",
"[",
"'height'",
"]",
")",
"->",
"setFocus",
"(",
"$",
"media",
"->",
"getFocusLeft",
"(",
")",
",",
"$",
"media",
"->",
"getFocusTop",
"(",
")",
")",
"->",
"apply",
"(",
"$",
"aliasName",
")",
";",
"return",
"true",
";",
"}",
"$",
"resize",
"=",
"new",
"Resize",
"(",
"$",
"this",
",",
"$",
"media",
")",
";",
"$",
"resize",
"->",
"setTargetSize",
"(",
"$",
"aliasArray",
"[",
"'width'",
"]",
",",
"$",
"aliasArray",
"[",
"'height'",
"]",
")",
"->",
"apply",
"(",
"$",
"aliasName",
")",
";",
"return",
"true",
";",
"}"
] |
Crop image if is not exists in alias.
@param MediaInterface $media
@param AliasManipulator $aliasManipulator
|
[
"Crop",
"image",
"if",
"is",
"not",
"exists",
"in",
"alias",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L470-L504
|
223,635
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.getHtml
|
public function getHtml(MediaInterface $media, $alias = null)
{
if ($media->getType() == $media::IMAGE) {
$template = 'ApoutchikaMediaBundle:Render:image.html.twig';
} elseif ($media->getType() == $media::VIDEO) {
$template = 'ApoutchikaMediaBundle:Render:video.html.twig';
} elseif ($media->getType() == $media::AUDIO) {
$template = 'ApoutchikaMediaBundle:Render:audio.html.twig';
} else {
$template = 'ApoutchikaMediaBundle:Render:other.html.twig';
}
return $this->container->get('templating')->render($template, array(
'media' => $media,
'alias' => $alias,
'url' => $this->getAbsoluteUrl($media, $alias),
));
}
|
php
|
public function getHtml(MediaInterface $media, $alias = null)
{
if ($media->getType() == $media::IMAGE) {
$template = 'ApoutchikaMediaBundle:Render:image.html.twig';
} elseif ($media->getType() == $media::VIDEO) {
$template = 'ApoutchikaMediaBundle:Render:video.html.twig';
} elseif ($media->getType() == $media::AUDIO) {
$template = 'ApoutchikaMediaBundle:Render:audio.html.twig';
} else {
$template = 'ApoutchikaMediaBundle:Render:other.html.twig';
}
return $this->container->get('templating')->render($template, array(
'media' => $media,
'alias' => $alias,
'url' => $this->getAbsoluteUrl($media, $alias),
));
}
|
[
"public",
"function",
"getHtml",
"(",
"MediaInterface",
"$",
"media",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"media",
"->",
"getType",
"(",
")",
"==",
"$",
"media",
"::",
"IMAGE",
")",
"{",
"$",
"template",
"=",
"'ApoutchikaMediaBundle:Render:image.html.twig'",
";",
"}",
"elseif",
"(",
"$",
"media",
"->",
"getType",
"(",
")",
"==",
"$",
"media",
"::",
"VIDEO",
")",
"{",
"$",
"template",
"=",
"'ApoutchikaMediaBundle:Render:video.html.twig'",
";",
"}",
"elseif",
"(",
"$",
"media",
"->",
"getType",
"(",
")",
"==",
"$",
"media",
"::",
"AUDIO",
")",
"{",
"$",
"template",
"=",
"'ApoutchikaMediaBundle:Render:audio.html.twig'",
";",
"}",
"else",
"{",
"$",
"template",
"=",
"'ApoutchikaMediaBundle:Render:other.html.twig'",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"render",
"(",
"$",
"template",
",",
"array",
"(",
"'media'",
"=>",
"$",
"media",
",",
"'alias'",
"=>",
"$",
"alias",
",",
"'url'",
"=>",
"$",
"this",
"->",
"getAbsoluteUrl",
"(",
"$",
"media",
",",
"$",
"alias",
")",
",",
")",
")",
";",
"}"
] |
Render html of media.
@param MediaInterface $media
@param string|array|null $alias
@return string render of media html
|
[
"Render",
"html",
"of",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L514-L531
|
223,636
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.reset
|
public function reset(MediaInterface $media = null, $onlyFocus = false)
{
if ($onlyFocus === true) {
$regex = '#^\d*x\d*_focus/';
} else {
$regex = '#^\d*x\d*(_focus)?/';
}
$regex .= ($media !== null) ? $media->getReference() : '.*';
$regex .= '$#';
foreach ($this->filesystemManipulator->keys() as $file) {
if (preg_match($regex, $file)) {
$this->filesystemManipulator->delete($file);
}
}
}
|
php
|
public function reset(MediaInterface $media = null, $onlyFocus = false)
{
if ($onlyFocus === true) {
$regex = '#^\d*x\d*_focus/';
} else {
$regex = '#^\d*x\d*(_focus)?/';
}
$regex .= ($media !== null) ? $media->getReference() : '.*';
$regex .= '$#';
foreach ($this->filesystemManipulator->keys() as $file) {
if (preg_match($regex, $file)) {
$this->filesystemManipulator->delete($file);
}
}
}
|
[
"public",
"function",
"reset",
"(",
"MediaInterface",
"$",
"media",
"=",
"null",
",",
"$",
"onlyFocus",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"onlyFocus",
"===",
"true",
")",
"{",
"$",
"regex",
"=",
"'#^\\d*x\\d*_focus/'",
";",
"}",
"else",
"{",
"$",
"regex",
"=",
"'#^\\d*x\\d*(_focus)?/'",
";",
"}",
"$",
"regex",
".=",
"(",
"$",
"media",
"!==",
"null",
")",
"?",
"$",
"media",
"->",
"getReference",
"(",
")",
":",
"'.*'",
";",
"$",
"regex",
".=",
"'$#'",
";",
"foreach",
"(",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"keys",
"(",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"filesystemManipulator",
"->",
"delete",
"(",
"$",
"file",
")",
";",
"}",
"}",
"}"
] |
Remove empty directory
Remove cache of media.
@param MediaInterface|null $media If is defined, only cache of this file is removed
@param bool $onlyFocus Remove media only for focus cache
|
[
"Remove",
"empty",
"directory",
"Remove",
"cache",
"of",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L540-L556
|
223,637
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.save
|
public function save($media, $flush = true)
{
if ($media->getFile() !== null) {
if ($this->saveFile($media) === false) {
return false;
}
}
if ($media->getFocusIsEdited() === true) {
$this->reset($media, true);
$media->setFocusIsEdited(false);
}
$media->setUpdatedAt(new \Datetime());
parent::save($media, $flush);
return true;
}
|
php
|
public function save($media, $flush = true)
{
if ($media->getFile() !== null) {
if ($this->saveFile($media) === false) {
return false;
}
}
if ($media->getFocusIsEdited() === true) {
$this->reset($media, true);
$media->setFocusIsEdited(false);
}
$media->setUpdatedAt(new \Datetime());
parent::save($media, $flush);
return true;
}
|
[
"public",
"function",
"save",
"(",
"$",
"media",
",",
"$",
"flush",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"media",
"->",
"getFile",
"(",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"media",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"media",
"->",
"getFocusIsEdited",
"(",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"reset",
"(",
"$",
"media",
",",
"true",
")",
";",
"$",
"media",
"->",
"setFocusIsEdited",
"(",
"false",
")",
";",
"}",
"$",
"media",
"->",
"setUpdatedAt",
"(",
"new",
"\\",
"Datetime",
"(",
")",
")",
";",
"parent",
"::",
"save",
"(",
"$",
"media",
",",
"$",
"flush",
")",
";",
"return",
"true",
";",
"}"
] |
Save media.
@param MediaInterface $media
@param bool $flush
@return bool If return false (when add new file), the error is in $error attribute
|
[
"Save",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L566-L584
|
223,638
|
apoutchika/MediaBundle
|
Manager/MediaManager.php
|
MediaManager.create
|
public function create($path = null)
{
$media = new $this->class();
if ($path !== null) {
$media->setFile(new \Symfony\Component\HttpFoundation\File\File($path));
}
return $media;
}
|
php
|
public function create($path = null)
{
$media = new $this->class();
if ($path !== null) {
$media->setFile(new \Symfony\Component\HttpFoundation\File\File($path));
}
return $media;
}
|
[
"public",
"function",
"create",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"media",
"=",
"new",
"$",
"this",
"->",
"class",
"(",
")",
";",
"if",
"(",
"$",
"path",
"!==",
"null",
")",
"{",
"$",
"media",
"->",
"setFile",
"(",
"new",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"HttpFoundation",
"\\",
"File",
"\\",
"File",
"(",
"$",
"path",
")",
")",
";",
"}",
"return",
"$",
"media",
";",
"}"
] |
Create media object.
@param string $path path of media
@return MediaInterface
|
[
"Create",
"media",
"object",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Manager/MediaManager.php#L633-L642
|
223,639
|
puli/manager
|
src/Module/ModuleManagerImpl.php
|
ModuleManagerImpl.loadModules
|
private function loadModules()
{
$this->modules = new ModuleList();
$this->modules->add(new RootModule($this->rootModuleFile, $this->rootDir));
foreach ($this->rootModuleFile->getInstallInfos() as $installInfo) {
$this->modules->add($this->loadModule($installInfo));
}
}
|
php
|
private function loadModules()
{
$this->modules = new ModuleList();
$this->modules->add(new RootModule($this->rootModuleFile, $this->rootDir));
foreach ($this->rootModuleFile->getInstallInfos() as $installInfo) {
$this->modules->add($this->loadModule($installInfo));
}
}
|
[
"private",
"function",
"loadModules",
"(",
")",
"{",
"$",
"this",
"->",
"modules",
"=",
"new",
"ModuleList",
"(",
")",
";",
"$",
"this",
"->",
"modules",
"->",
"add",
"(",
"new",
"RootModule",
"(",
"$",
"this",
"->",
"rootModuleFile",
",",
"$",
"this",
"->",
"rootDir",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"rootModuleFile",
"->",
"getInstallInfos",
"(",
")",
"as",
"$",
"installInfo",
")",
"{",
"$",
"this",
"->",
"modules",
"->",
"add",
"(",
"$",
"this",
"->",
"loadModule",
"(",
"$",
"installInfo",
")",
")",
";",
"}",
"}"
] |
Loads all modules referenced by the install file.
@throws FileNotFoundException If the install path of a module not exist.
@throws NoDirectoryException If the install path of a module points to a
file.
@throws InvalidConfigException If a module is not configured correctly.
@throws NameConflictException If a module has the same name as another
loaded module.
|
[
"Loads",
"all",
"modules",
"referenced",
"by",
"the",
"install",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Module/ModuleManagerImpl.php#L343-L351
|
223,640
|
puli/manager
|
src/Module/ModuleManagerImpl.php
|
ModuleManagerImpl.loadModule
|
private function loadModule(InstallInfo $installInfo)
{
$installPath = Path::makeAbsolute($installInfo->getInstallPath(), $this->rootDir);
$moduleFile = null;
$loadError = null;
// Catch and log exceptions so that single modules cannot break
// the whole repository
try {
$moduleFile = $this->loadModuleFile($installPath);
} catch (InvalidConfigException $loadError) {
} catch (UnsupportedVersionException $loadError) {
} catch (FileNotFoundException $loadError) {
} catch (NoDirectoryException $loadError) {
}
$loadErrors = $loadError ? array($loadError) : array();
return new Module($moduleFile, $installPath, $installInfo, $loadErrors);
}
|
php
|
private function loadModule(InstallInfo $installInfo)
{
$installPath = Path::makeAbsolute($installInfo->getInstallPath(), $this->rootDir);
$moduleFile = null;
$loadError = null;
// Catch and log exceptions so that single modules cannot break
// the whole repository
try {
$moduleFile = $this->loadModuleFile($installPath);
} catch (InvalidConfigException $loadError) {
} catch (UnsupportedVersionException $loadError) {
} catch (FileNotFoundException $loadError) {
} catch (NoDirectoryException $loadError) {
}
$loadErrors = $loadError ? array($loadError) : array();
return new Module($moduleFile, $installPath, $installInfo, $loadErrors);
}
|
[
"private",
"function",
"loadModule",
"(",
"InstallInfo",
"$",
"installInfo",
")",
"{",
"$",
"installPath",
"=",
"Path",
"::",
"makeAbsolute",
"(",
"$",
"installInfo",
"->",
"getInstallPath",
"(",
")",
",",
"$",
"this",
"->",
"rootDir",
")",
";",
"$",
"moduleFile",
"=",
"null",
";",
"$",
"loadError",
"=",
"null",
";",
"// Catch and log exceptions so that single modules cannot break",
"// the whole repository",
"try",
"{",
"$",
"moduleFile",
"=",
"$",
"this",
"->",
"loadModuleFile",
"(",
"$",
"installPath",
")",
";",
"}",
"catch",
"(",
"InvalidConfigException",
"$",
"loadError",
")",
"{",
"}",
"catch",
"(",
"UnsupportedVersionException",
"$",
"loadError",
")",
"{",
"}",
"catch",
"(",
"FileNotFoundException",
"$",
"loadError",
")",
"{",
"}",
"catch",
"(",
"NoDirectoryException",
"$",
"loadError",
")",
"{",
"}",
"$",
"loadErrors",
"=",
"$",
"loadError",
"?",
"array",
"(",
"$",
"loadError",
")",
":",
"array",
"(",
")",
";",
"return",
"new",
"Module",
"(",
"$",
"moduleFile",
",",
"$",
"installPath",
",",
"$",
"installInfo",
",",
"$",
"loadErrors",
")",
";",
"}"
] |
Loads a module for the given install info.
@param InstallInfo $installInfo The install info.
@return Module The module.
|
[
"Loads",
"a",
"module",
"for",
"the",
"given",
"install",
"info",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Module/ModuleManagerImpl.php#L360-L379
|
223,641
|
puli/manager
|
src/Module/ModuleManagerImpl.php
|
ModuleManagerImpl.loadModuleFile
|
private function loadModuleFile($installPath)
{
if (!file_exists($installPath)) {
throw FileNotFoundException::forPath($installPath);
}
if (!is_dir($installPath)) {
throw new NoDirectoryException(sprintf(
'The path %s is a file. Expected a directory.',
$installPath
));
}
try {
return $this->jsonStorage->loadModuleFile($installPath.'/puli.json');
} catch (FileNotFoundException $e) {
// Modules without module files are ok
return null;
}
}
|
php
|
private function loadModuleFile($installPath)
{
if (!file_exists($installPath)) {
throw FileNotFoundException::forPath($installPath);
}
if (!is_dir($installPath)) {
throw new NoDirectoryException(sprintf(
'The path %s is a file. Expected a directory.',
$installPath
));
}
try {
return $this->jsonStorage->loadModuleFile($installPath.'/puli.json');
} catch (FileNotFoundException $e) {
// Modules without module files are ok
return null;
}
}
|
[
"private",
"function",
"loadModuleFile",
"(",
"$",
"installPath",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"installPath",
")",
")",
"{",
"throw",
"FileNotFoundException",
"::",
"forPath",
"(",
"$",
"installPath",
")",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"installPath",
")",
")",
"{",
"throw",
"new",
"NoDirectoryException",
"(",
"sprintf",
"(",
"'The path %s is a file. Expected a directory.'",
",",
"$",
"installPath",
")",
")",
";",
"}",
"try",
"{",
"return",
"$",
"this",
"->",
"jsonStorage",
"->",
"loadModuleFile",
"(",
"$",
"installPath",
".",
"'/puli.json'",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"$",
"e",
")",
"{",
"// Modules without module files are ok",
"return",
"null",
";",
"}",
"}"
] |
Loads the module file for the module at the given install path.
@param string $installPath The absolute install path of the module
@return ModuleFile|null The loaded module file or `null` if none
could be found.
|
[
"Loads",
"the",
"module",
"file",
"for",
"the",
"module",
"at",
"the",
"given",
"install",
"path",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Module/ModuleManagerImpl.php#L389-L408
|
223,642
|
puli/manager
|
src/Discovery/Binding/BindingDescriptorCollection.php
|
BindingDescriptorCollection.get
|
public function get(Uuid $uuid)
{
if (!isset($this->map[$uuid->toString()])) {
throw new OutOfBoundsException(sprintf(
'The binding with UUID "%s" does not exist.',
$uuid->toString()
));
}
return $this->map[$uuid->toString()];
}
|
php
|
public function get(Uuid $uuid)
{
if (!isset($this->map[$uuid->toString()])) {
throw new OutOfBoundsException(sprintf(
'The binding with UUID "%s" does not exist.',
$uuid->toString()
));
}
return $this->map[$uuid->toString()];
}
|
[
"public",
"function",
"get",
"(",
"Uuid",
"$",
"uuid",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"uuid",
"->",
"toString",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The binding with UUID \"%s\" does not exist.'",
",",
"$",
"uuid",
"->",
"toString",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"map",
"[",
"$",
"uuid",
"->",
"toString",
"(",
")",
"]",
";",
"}"
] |
Returns a binding descriptor.
@param Uuid $uuid The UUID of the binding descriptor.
@return BindingDescriptor The binding descriptor.
@throws OutOfBoundsException If no binding descriptor was set for the
given UUID.
|
[
"Returns",
"a",
"binding",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Discovery/Binding/BindingDescriptorCollection.php#L72-L82
|
223,643
|
puli/manager
|
src/Discovery/Binding/BindingDescriptorCollection.php
|
BindingDescriptorCollection.getUuids
|
public function getUuids()
{
$uuids = array();
foreach ($this->map as $bindingDescriptor) {
$uuids[] = $bindingDescriptor->getUuid();
}
return $uuids;
}
|
php
|
public function getUuids()
{
$uuids = array();
foreach ($this->map as $bindingDescriptor) {
$uuids[] = $bindingDescriptor->getUuid();
}
return $uuids;
}
|
[
"public",
"function",
"getUuids",
"(",
")",
"{",
"$",
"uuids",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"map",
"as",
"$",
"bindingDescriptor",
")",
"{",
"$",
"uuids",
"[",
"]",
"=",
"$",
"bindingDescriptor",
"->",
"getUuid",
"(",
")",
";",
"}",
"return",
"$",
"uuids",
";",
"}"
] |
Returns the UUIDs of all binding descriptors.
@return Uuid[] The UUIDs of the stored bindings.
|
[
"Returns",
"the",
"UUIDs",
"of",
"all",
"binding",
"descriptors",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Discovery/Binding/BindingDescriptorCollection.php#L102-L111
|
223,644
|
madeyourday/contao-rocksolid-columns
|
src/Element/ColumnStart.php
|
ColumnStart.compile
|
public function compile()
{
if (TL_MODE == 'BE') {
$this->strTemplate = 'be_wildcard';
$this->Template = new \BackendTemplate($this->strTemplate);
$this->Template->title = $this->headline;
}
else {
$this->Template = new \FrontendTemplate($this->strTemplate);
$this->Template->setData($this->arrData);
}
}
|
php
|
public function compile()
{
if (TL_MODE == 'BE') {
$this->strTemplate = 'be_wildcard';
$this->Template = new \BackendTemplate($this->strTemplate);
$this->Template->title = $this->headline;
}
else {
$this->Template = new \FrontendTemplate($this->strTemplate);
$this->Template->setData($this->arrData);
}
}
|
[
"public",
"function",
"compile",
"(",
")",
"{",
"if",
"(",
"TL_MODE",
"==",
"'BE'",
")",
"{",
"$",
"this",
"->",
"strTemplate",
"=",
"'be_wildcard'",
";",
"$",
"this",
"->",
"Template",
"=",
"new",
"\\",
"BackendTemplate",
"(",
"$",
"this",
"->",
"strTemplate",
")",
";",
"$",
"this",
"->",
"Template",
"->",
"title",
"=",
"$",
"this",
"->",
"headline",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Template",
"=",
"new",
"\\",
"FrontendTemplate",
"(",
"$",
"this",
"->",
"strTemplate",
")",
";",
"$",
"this",
"->",
"Template",
"->",
"setData",
"(",
"$",
"this",
"->",
"arrData",
")",
";",
"}",
"}"
] |
Compile the content element
@return void
|
[
"Compile",
"the",
"content",
"element"
] |
35ca1f9b17c19fd0b774ed3307a85b58fa4b2705
|
https://github.com/madeyourday/contao-rocksolid-columns/blob/35ca1f9b17c19fd0b774ed3307a85b58fa4b2705/src/Element/ColumnStart.php#L68-L79
|
223,645
|
puli/manager
|
src/Api/Module/InstallInfo.php
|
InstallInfo.setEnvironment
|
public function setEnvironment($env)
{
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
$this->env = $env;
}
|
php
|
public function setEnvironment($env)
{
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
$this->env = $env;
}
|
[
"public",
"function",
"setEnvironment",
"(",
"$",
"env",
")",
"{",
"Assert",
"::",
"oneOf",
"(",
"$",
"env",
",",
"Environment",
"::",
"all",
"(",
")",
",",
"'The environment must be one of: %2$s. Got: %s'",
")",
";",
"$",
"this",
"->",
"env",
"=",
"$",
"env",
";",
"}"
] |
Sets the environment that the module is installed in.
@param string $env One of the {@link Environment} constants.
|
[
"Sets",
"the",
"environment",
"that",
"the",
"module",
"is",
"installed",
"in",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/InstallInfo.php#L180-L185
|
223,646
|
apoutchika/MediaBundle
|
Controller/MediaRestController.php
|
MediaRestController.getMediasAction
|
public function getMediasAction(Request $request)
{
if (!$request->query->has('filters')) {
return $this->createResponse(array());
}
$mediaManager = $this->getMediaManager();
$filtersKeys = explode(',', $request->query->get('filters'));
$medias = $mediaManager->findAllByFiltersKeys($filtersKeys);
return $this->createResponse($medias);
}
|
php
|
public function getMediasAction(Request $request)
{
if (!$request->query->has('filters')) {
return $this->createResponse(array());
}
$mediaManager = $this->getMediaManager();
$filtersKeys = explode(',', $request->query->get('filters'));
$medias = $mediaManager->findAllByFiltersKeys($filtersKeys);
return $this->createResponse($medias);
}
|
[
"public",
"function",
"getMediasAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"'filters'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createResponse",
"(",
"array",
"(",
")",
")",
";",
"}",
"$",
"mediaManager",
"=",
"$",
"this",
"->",
"getMediaManager",
"(",
")",
";",
"$",
"filtersKeys",
"=",
"explode",
"(",
"','",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'filters'",
")",
")",
";",
"$",
"medias",
"=",
"$",
"mediaManager",
"->",
"findAllByFiltersKeys",
"(",
"$",
"filtersKeys",
")",
";",
"return",
"$",
"this",
"->",
"createResponse",
"(",
"$",
"medias",
")",
";",
"}"
] |
Get all medias.
@param Request $request
@return Response array of medias
|
[
"Get",
"all",
"medias",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Controller/MediaRestController.php#L102-L114
|
223,647
|
apoutchika/MediaBundle
|
Controller/MediaRestController.php
|
MediaRestController.postMediaAction
|
public function postMediaAction(Request $request)
{
$response = $this->getFilter($request);
if ($response['success'] === false) {
return $response['value'];
}
$filter = $response['value'];
$mm = $this->getMediaManager();
$media = $mm->create();
$media
->setFilter($filter)
->setCryptedFilter($response['crypted'])
;
if (!$request->files->has('file')) {
return new Response($this->get('translator')->trans('error.fileNotFound', array(), 'ApoutchikaMediaBundle'), 500);
}
$media->setFile($request->files->get('file'));
if ($mm->save($media) === false) {
$error = $mm->getError();
return new Response($this->get('translator')->trans($error[0], $error[1], 'ApoutchikaMediaBundle'), 500);
}
return $this->createResponse($media, $request->request->has('iframe'));
}
|
php
|
public function postMediaAction(Request $request)
{
$response = $this->getFilter($request);
if ($response['success'] === false) {
return $response['value'];
}
$filter = $response['value'];
$mm = $this->getMediaManager();
$media = $mm->create();
$media
->setFilter($filter)
->setCryptedFilter($response['crypted'])
;
if (!$request->files->has('file')) {
return new Response($this->get('translator')->trans('error.fileNotFound', array(), 'ApoutchikaMediaBundle'), 500);
}
$media->setFile($request->files->get('file'));
if ($mm->save($media) === false) {
$error = $mm->getError();
return new Response($this->get('translator')->trans($error[0], $error[1], 'ApoutchikaMediaBundle'), 500);
}
return $this->createResponse($media, $request->request->has('iframe'));
}
|
[
"public",
"function",
"postMediaAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getFilter",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"response",
"[",
"'success'",
"]",
"===",
"false",
")",
"{",
"return",
"$",
"response",
"[",
"'value'",
"]",
";",
"}",
"$",
"filter",
"=",
"$",
"response",
"[",
"'value'",
"]",
";",
"$",
"mm",
"=",
"$",
"this",
"->",
"getMediaManager",
"(",
")",
";",
"$",
"media",
"=",
"$",
"mm",
"->",
"create",
"(",
")",
";",
"$",
"media",
"->",
"setFilter",
"(",
"$",
"filter",
")",
"->",
"setCryptedFilter",
"(",
"$",
"response",
"[",
"'crypted'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"request",
"->",
"files",
"->",
"has",
"(",
"'file'",
")",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'error.fileNotFound'",
",",
"array",
"(",
")",
",",
"'ApoutchikaMediaBundle'",
")",
",",
"500",
")",
";",
"}",
"$",
"media",
"->",
"setFile",
"(",
"$",
"request",
"->",
"files",
"->",
"get",
"(",
"'file'",
")",
")",
";",
"if",
"(",
"$",
"mm",
"->",
"save",
"(",
"$",
"media",
")",
"===",
"false",
")",
"{",
"$",
"error",
"=",
"$",
"mm",
"->",
"getError",
"(",
")",
";",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"$",
"error",
"[",
"0",
"]",
",",
"$",
"error",
"[",
"1",
"]",
",",
"'ApoutchikaMediaBundle'",
")",
",",
"500",
")",
";",
"}",
"return",
"$",
"this",
"->",
"createResponse",
"(",
"$",
"media",
",",
"$",
"request",
"->",
"request",
"->",
"has",
"(",
"'iframe'",
")",
")",
";",
"}"
] |
Add new media.
@param Request $request
@return Response media
|
[
"Add",
"new",
"media",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Controller/MediaRestController.php#L153-L182
|
223,648
|
apoutchika/MediaBundle
|
Controller/MediaRestController.php
|
MediaRestController.getFilter
|
private function getFilter(Request $request)
{
$success = false;
$filter = null;
if ($request->query->has('filter')) {
$filter = $request->query->get('filter');
$type = 'query';
} elseif ($request->request->has('filter')) {
$filter = $request->request->get('filter');
$type = 'request';
} elseif ($request->getMethod() === 'PUT') {
$_PUT = json_decode($request->getContent(), true);
if (!empty($_PUT['filter'])) {
$filter = $_PUT['filter'];
$type = 'put';
}
}
if ($filter === null) {
if ($this->container->getParameter('kernel.environment') === 'dev') {
$value = new Response($this->get('translator')->trans('error.requestMustHasFilter', array(), 'ApoutchikaMediaBundle'), 500);
} else {
$value = new Response($this->get('translator')->trans('error.requestMustHasFilterProd', array(), 'ApoutchikaMediaBundle'), 500);
}
} elseif (!$this->get('apoutchika_media.filter')->has($filter)) {
if ($this->container->getParameter('kernel.environment') === 'dev') {
$value = new Response($this->get('translator')->trans('error.requestMustHasCorrectFilter', array(), 'ApoutchikaMediaBundle'), 500);
} else {
$value = new Response($this->get('translator')->trans('error.requestMustHasCorrectFilterProd', array(), 'ApoutchikaMediaBundle'), 500);
}
} else {
$success = true;
$value = $this->get('apoutchika_media.filter')->get($filter);
}
return array(
'success' => $success,
'value' => $value,
'crypted' => $filter,
);
}
|
php
|
private function getFilter(Request $request)
{
$success = false;
$filter = null;
if ($request->query->has('filter')) {
$filter = $request->query->get('filter');
$type = 'query';
} elseif ($request->request->has('filter')) {
$filter = $request->request->get('filter');
$type = 'request';
} elseif ($request->getMethod() === 'PUT') {
$_PUT = json_decode($request->getContent(), true);
if (!empty($_PUT['filter'])) {
$filter = $_PUT['filter'];
$type = 'put';
}
}
if ($filter === null) {
if ($this->container->getParameter('kernel.environment') === 'dev') {
$value = new Response($this->get('translator')->trans('error.requestMustHasFilter', array(), 'ApoutchikaMediaBundle'), 500);
} else {
$value = new Response($this->get('translator')->trans('error.requestMustHasFilterProd', array(), 'ApoutchikaMediaBundle'), 500);
}
} elseif (!$this->get('apoutchika_media.filter')->has($filter)) {
if ($this->container->getParameter('kernel.environment') === 'dev') {
$value = new Response($this->get('translator')->trans('error.requestMustHasCorrectFilter', array(), 'ApoutchikaMediaBundle'), 500);
} else {
$value = new Response($this->get('translator')->trans('error.requestMustHasCorrectFilterProd', array(), 'ApoutchikaMediaBundle'), 500);
}
} else {
$success = true;
$value = $this->get('apoutchika_media.filter')->get($filter);
}
return array(
'success' => $success,
'value' => $value,
'crypted' => $filter,
);
}
|
[
"private",
"function",
"getFilter",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"success",
"=",
"false",
";",
"$",
"filter",
"=",
"null",
";",
"if",
"(",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"'filter'",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'filter'",
")",
";",
"$",
"type",
"=",
"'query'",
";",
"}",
"elseif",
"(",
"$",
"request",
"->",
"request",
"->",
"has",
"(",
"'filter'",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'filter'",
")",
";",
"$",
"type",
"=",
"'request'",
";",
"}",
"elseif",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"===",
"'PUT'",
")",
"{",
"$",
"_PUT",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"getContent",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"_PUT",
"[",
"'filter'",
"]",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"_PUT",
"[",
"'filter'",
"]",
";",
"$",
"type",
"=",
"'put'",
";",
"}",
"}",
"if",
"(",
"$",
"filter",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'kernel.environment'",
")",
"===",
"'dev'",
")",
"{",
"$",
"value",
"=",
"new",
"Response",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'error.requestMustHasFilter'",
",",
"array",
"(",
")",
",",
"'ApoutchikaMediaBundle'",
")",
",",
"500",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"new",
"Response",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'error.requestMustHasFilterProd'",
",",
"array",
"(",
")",
",",
"'ApoutchikaMediaBundle'",
")",
",",
"500",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"get",
"(",
"'apoutchika_media.filter'",
")",
"->",
"has",
"(",
"$",
"filter",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'kernel.environment'",
")",
"===",
"'dev'",
")",
"{",
"$",
"value",
"=",
"new",
"Response",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'error.requestMustHasCorrectFilter'",
",",
"array",
"(",
")",
",",
"'ApoutchikaMediaBundle'",
")",
",",
"500",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"new",
"Response",
"(",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'error.requestMustHasCorrectFilterProd'",
",",
"array",
"(",
")",
",",
"'ApoutchikaMediaBundle'",
")",
",",
"500",
")",
";",
"}",
"}",
"else",
"{",
"$",
"success",
"=",
"true",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"'apoutchika_media.filter'",
")",
"->",
"get",
"(",
"$",
"filter",
")",
";",
"}",
"return",
"array",
"(",
"'success'",
"=>",
"$",
"success",
",",
"'value'",
"=>",
"$",
"value",
",",
"'crypted'",
"=>",
"$",
"filter",
",",
")",
";",
"}"
] |
Get is filter is send and verify if is a valid filter.
@param Request $request
@return Array
|
[
"Get",
"is",
"filter",
"is",
"send",
"and",
"verify",
"if",
"is",
"a",
"valid",
"filter",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Controller/MediaRestController.php#L316-L356
|
223,649
|
apoutchika/MediaBundle
|
Controller/MediaRestController.php
|
MediaRestController.searchMediaAction
|
public function searchMediaAction(Request $request)
{
$response = $this->getFilter($request);
if ($response['success'] === false) {
return $response['value'];
}
$filter = $response['crypted'];
$mm = $this->getMediaManager();
$q = ($request->query->has('q')) ? $request->query->get('q') : null;
$type = ($request->query->has('type')) ? $request->query->get('type') : null;
$medias = $mm->search($filter, $q, $type);
return $this->createResponse($medias);
}
|
php
|
public function searchMediaAction(Request $request)
{
$response = $this->getFilter($request);
if ($response['success'] === false) {
return $response['value'];
}
$filter = $response['crypted'];
$mm = $this->getMediaManager();
$q = ($request->query->has('q')) ? $request->query->get('q') : null;
$type = ($request->query->has('type')) ? $request->query->get('type') : null;
$medias = $mm->search($filter, $q, $type);
return $this->createResponse($medias);
}
|
[
"public",
"function",
"searchMediaAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getFilter",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"response",
"[",
"'success'",
"]",
"===",
"false",
")",
"{",
"return",
"$",
"response",
"[",
"'value'",
"]",
";",
"}",
"$",
"filter",
"=",
"$",
"response",
"[",
"'crypted'",
"]",
";",
"$",
"mm",
"=",
"$",
"this",
"->",
"getMediaManager",
"(",
")",
";",
"$",
"q",
"=",
"(",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"'q'",
")",
")",
"?",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'q'",
")",
":",
"null",
";",
"$",
"type",
"=",
"(",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"'type'",
")",
")",
"?",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'type'",
")",
":",
"null",
";",
"$",
"medias",
"=",
"$",
"mm",
"->",
"search",
"(",
"$",
"filter",
",",
"$",
"q",
",",
"$",
"type",
")",
";",
"return",
"$",
"this",
"->",
"createResponse",
"(",
"$",
"medias",
")",
";",
"}"
] |
Search medias.
@param Request $request
@return Response array of medias
|
[
"Search",
"medias",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Controller/MediaRestController.php#L365-L381
|
223,650
|
puli/manager
|
src/Repository/Mapping/PathMappingCollection.php
|
PathMappingCollection.set
|
public function set($repositoryPath, PathMapping $mapping)
{
$this->map->set($repositoryPath, $mapping->getContainingModule()->getName(), $mapping);
$this->primaryKeysSorted = false;
}
|
php
|
public function set($repositoryPath, PathMapping $mapping)
{
$this->map->set($repositoryPath, $mapping->getContainingModule()->getName(), $mapping);
$this->primaryKeysSorted = false;
}
|
[
"public",
"function",
"set",
"(",
"$",
"repositoryPath",
",",
"PathMapping",
"$",
"mapping",
")",
"{",
"$",
"this",
"->",
"map",
"->",
"set",
"(",
"$",
"repositoryPath",
",",
"$",
"mapping",
"->",
"getContainingModule",
"(",
")",
"->",
"getName",
"(",
")",
",",
"$",
"mapping",
")",
";",
"$",
"this",
"->",
"primaryKeysSorted",
"=",
"false",
";",
"}"
] |
Sets a path mapping for a specific repository path.
@param string $repositoryPath The repository path.
@param PathMapping $mapping The path mapping.
|
[
"Sets",
"a",
"path",
"mapping",
"for",
"a",
"specific",
"repository",
"path",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Repository/Mapping/PathMappingCollection.php#L67-L71
|
223,651
|
puli/manager
|
src/Repository/Mapping/PathMappingCollection.php
|
PathMappingCollection.listByModuleName
|
public function listByModuleName($moduleName)
{
if ($this->primaryKeysSorted) {
$this->lazySortPrimaryKeys();
}
return $this->map->listBySecondaryKey($moduleName);
}
|
php
|
public function listByModuleName($moduleName)
{
if ($this->primaryKeysSorted) {
$this->lazySortPrimaryKeys();
}
return $this->map->listBySecondaryKey($moduleName);
}
|
[
"public",
"function",
"listByModuleName",
"(",
"$",
"moduleName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"primaryKeysSorted",
")",
"{",
"$",
"this",
"->",
"lazySortPrimaryKeys",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"map",
"->",
"listBySecondaryKey",
"(",
"$",
"moduleName",
")",
";",
"}"
] |
Returns all path mappings set for the given module name.
@param string $moduleName The module name.
@return PathMapping[] The path mappings.
@throws OutOfBoundsException If no path mapping was set for the
given module name.
|
[
"Returns",
"all",
"path",
"mappings",
"set",
"for",
"the",
"given",
"module",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Repository/Mapping/PathMappingCollection.php#L142-L149
|
223,652
|
apoutchika/MediaBundle
|
Services/Image/Focus.php
|
Focus.getStartCrop
|
public function getStartCrop($origin, $target, $focus)
{
$focusPx = round(($origin * $focus) / 100);
$start = $focusPx - ($target / 2);
if ($start <= 0) {
return 0;
}
if (($start + $target) >= $origin) {
return $origin - $target;
}
return $start;
}
|
php
|
public function getStartCrop($origin, $target, $focus)
{
$focusPx = round(($origin * $focus) / 100);
$start = $focusPx - ($target / 2);
if ($start <= 0) {
return 0;
}
if (($start + $target) >= $origin) {
return $origin - $target;
}
return $start;
}
|
[
"public",
"function",
"getStartCrop",
"(",
"$",
"origin",
",",
"$",
"target",
",",
"$",
"focus",
")",
"{",
"$",
"focusPx",
"=",
"round",
"(",
"(",
"$",
"origin",
"*",
"$",
"focus",
")",
"/",
"100",
")",
";",
"$",
"start",
"=",
"$",
"focusPx",
"-",
"(",
"$",
"target",
"/",
"2",
")",
";",
"if",
"(",
"$",
"start",
"<=",
"0",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"(",
"$",
"start",
"+",
"$",
"target",
")",
">=",
"$",
"origin",
")",
"{",
"return",
"$",
"origin",
"-",
"$",
"target",
";",
"}",
"return",
"$",
"start",
";",
"}"
] |
Get start to crop by focus.
@param int $origin
@param int $target
@param int $focus
@return int
|
[
"Get",
"start",
"to",
"crop",
"by",
"focus",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/Image/Focus.php#L181-L195
|
223,653
|
puli/manager
|
src/Discovery/Binding/SyncBindingUuid.php
|
SyncBindingUuid.takeSnapshot
|
public function takeSnapshot()
{
$this->enabledBindingBefore = null;
if ($this->bindingDescriptors->contains($this->uuid)) {
$bindingDescriptor = $this->bindingDescriptors->get($this->uuid);
if ($bindingDescriptor->isEnabled()) {
// Clone so that rollback() works if the binding is unloaded
$this->enabledBindingBefore = clone $bindingDescriptor;
}
}
$this->snapshotTaken = true;
}
|
php
|
public function takeSnapshot()
{
$this->enabledBindingBefore = null;
if ($this->bindingDescriptors->contains($this->uuid)) {
$bindingDescriptor = $this->bindingDescriptors->get($this->uuid);
if ($bindingDescriptor->isEnabled()) {
// Clone so that rollback() works if the binding is unloaded
$this->enabledBindingBefore = clone $bindingDescriptor;
}
}
$this->snapshotTaken = true;
}
|
[
"public",
"function",
"takeSnapshot",
"(",
")",
"{",
"$",
"this",
"->",
"enabledBindingBefore",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"bindingDescriptors",
"->",
"contains",
"(",
"$",
"this",
"->",
"uuid",
")",
")",
"{",
"$",
"bindingDescriptor",
"=",
"$",
"this",
"->",
"bindingDescriptors",
"->",
"get",
"(",
"$",
"this",
"->",
"uuid",
")",
";",
"if",
"(",
"$",
"bindingDescriptor",
"->",
"isEnabled",
"(",
")",
")",
"{",
"// Clone so that rollback() works if the binding is unloaded",
"$",
"this",
"->",
"enabledBindingBefore",
"=",
"clone",
"$",
"bindingDescriptor",
";",
"}",
"}",
"$",
"this",
"->",
"snapshotTaken",
"=",
"true",
";",
"}"
] |
Records whether the UUID is currently enabled.
|
[
"Records",
"whether",
"the",
"UUID",
"is",
"currently",
"enabled",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Discovery/Binding/SyncBindingUuid.php#L77-L91
|
223,654
|
nilportugues/php-sitemap
|
src/AbstractSitemap.php
|
AbstractSitemap.isSurpassingFileSizeLimit
|
protected function isSurpassingFileSizeLimit($stringData)
{
$expectedFileSize = $this->accommulatedFileSize + $this->getStringSize($stringData);
return $this->maxFilesize < $expectedFileSize;
}
|
php
|
protected function isSurpassingFileSizeLimit($stringData)
{
$expectedFileSize = $this->accommulatedFileSize + $this->getStringSize($stringData);
return $this->maxFilesize < $expectedFileSize;
}
|
[
"protected",
"function",
"isSurpassingFileSizeLimit",
"(",
"$",
"stringData",
")",
"{",
"$",
"expectedFileSize",
"=",
"$",
"this",
"->",
"accommulatedFileSize",
"+",
"$",
"this",
"->",
"getStringSize",
"(",
"$",
"stringData",
")",
";",
"return",
"$",
"this",
"->",
"maxFilesize",
"<",
"$",
"expectedFileSize",
";",
"}"
] |
Before appending data we need to check if we'll surpass the file size limit or not.
@param $stringData
@return bool
|
[
"Before",
"appending",
"data",
"we",
"need",
"to",
"check",
"if",
"we",
"ll",
"surpass",
"the",
"file",
"size",
"limit",
"or",
"not",
"."
] |
b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd
|
https://github.com/nilportugues/php-sitemap/blob/b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd/src/AbstractSitemap.php#L186-L191
|
223,655
|
nilportugues/php-sitemap
|
src/AbstractSitemap.php
|
AbstractSitemap.build
|
public function build()
{
$this->appendToFile($this->getFooter());
if ($this->gzipOutput) {
$this->writeGZipFile();
}
\fclose($this->filePointer);
}
|
php
|
public function build()
{
$this->appendToFile($this->getFooter());
if ($this->gzipOutput) {
$this->writeGZipFile();
}
\fclose($this->filePointer);
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"appendToFile",
"(",
"$",
"this",
"->",
"getFooter",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"gzipOutput",
")",
"{",
"$",
"this",
"->",
"writeGZipFile",
"(",
")",
";",
"}",
"\\",
"fclose",
"(",
"$",
"this",
"->",
"filePointer",
")",
";",
"}"
] |
Generates sitemap file.
@return mixed
|
[
"Generates",
"sitemap",
"file",
"."
] |
b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd
|
https://github.com/nilportugues/php-sitemap/blob/b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd/src/AbstractSitemap.php#L225-L234
|
223,656
|
middlewares/negotiation
|
src/ContentLanguage.php
|
ContentLanguage.detectFromPath
|
private function detectFromPath(string $path)
{
if (!$this->usePath) {
return null;
}
$dirs = explode('/', ltrim($path, '/'), 2);
$first = strtolower((string) array_shift($dirs));
if (!empty($first) && in_array($first, $this->languages, true)) {
return $first;
}
}
|
php
|
private function detectFromPath(string $path)
{
if (!$this->usePath) {
return null;
}
$dirs = explode('/', ltrim($path, '/'), 2);
$first = strtolower((string) array_shift($dirs));
if (!empty($first) && in_array($first, $this->languages, true)) {
return $first;
}
}
|
[
"private",
"function",
"detectFromPath",
"(",
"string",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"usePath",
")",
"{",
"return",
"null",
";",
"}",
"$",
"dirs",
"=",
"explode",
"(",
"'/'",
",",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
",",
"2",
")",
";",
"$",
"first",
"=",
"strtolower",
"(",
"(",
"string",
")",
"array_shift",
"(",
"$",
"dirs",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"first",
")",
"&&",
"in_array",
"(",
"$",
"first",
",",
"$",
"this",
"->",
"languages",
",",
"true",
")",
")",
"{",
"return",
"$",
"first",
";",
"}",
"}"
] |
Returns the language from the first part of the path if it's in the allowed languages.
@return null|string
|
[
"Returns",
"the",
"language",
"from",
"the",
"first",
"part",
"of",
"the",
"path",
"if",
"it",
"s",
"in",
"the",
"allowed",
"languages",
"."
] |
107d31132cd5af446be97827bfd0202f15189a34
|
https://github.com/middlewares/negotiation/blob/107d31132cd5af446be97827bfd0202f15189a34/src/ContentLanguage.php#L98-L110
|
223,657
|
middlewares/negotiation
|
src/ContentLanguage.php
|
ContentLanguage.detectFromHeader
|
private function detectFromHeader(ServerRequestInterface $request)
{
$accept = $request->getHeaderLine('Accept-Language');
$language = $this->negotiateHeader($accept, new LanguageNegotiator(), $this->languages);
if (empty($language)) {
return isset($this->languages[0]) ? $this->languages[0] : '';
}
return $language;
}
|
php
|
private function detectFromHeader(ServerRequestInterface $request)
{
$accept = $request->getHeaderLine('Accept-Language');
$language = $this->negotiateHeader($accept, new LanguageNegotiator(), $this->languages);
if (empty($language)) {
return isset($this->languages[0]) ? $this->languages[0] : '';
}
return $language;
}
|
[
"private",
"function",
"detectFromHeader",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"accept",
"=",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'Accept-Language'",
")",
";",
"$",
"language",
"=",
"$",
"this",
"->",
"negotiateHeader",
"(",
"$",
"accept",
",",
"new",
"LanguageNegotiator",
"(",
")",
",",
"$",
"this",
"->",
"languages",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"language",
")",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"languages",
"[",
"0",
"]",
")",
"?",
"$",
"this",
"->",
"languages",
"[",
"0",
"]",
":",
"''",
";",
"}",
"return",
"$",
"language",
";",
"}"
] |
Returns the format using the Accept-Language header.
@return null|string
|
[
"Returns",
"the",
"format",
"using",
"the",
"Accept",
"-",
"Language",
"header",
"."
] |
107d31132cd5af446be97827bfd0202f15189a34
|
https://github.com/middlewares/negotiation/blob/107d31132cd5af446be97827bfd0202f15189a34/src/ContentLanguage.php#L117-L127
|
223,658
|
puli/manager
|
src/Api/Repository/NoSuchPathMappingException.php
|
NoSuchPathMappingException.forRepositoryPathAndModule
|
public static function forRepositoryPathAndModule($path, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The repository path "%s" is not mapped in module "%s".',
$path,
$moduleName
), 0, $cause);
}
|
php
|
public static function forRepositoryPathAndModule($path, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The repository path "%s" is not mapped in module "%s".',
$path,
$moduleName
), 0, $cause);
}
|
[
"public",
"static",
"function",
"forRepositoryPathAndModule",
"(",
"$",
"path",
",",
"$",
"moduleName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The repository path \"%s\" is not mapped in module \"%s\".'",
",",
"$",
"path",
",",
"$",
"moduleName",
")",
",",
"0",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for a repository path and a module name.
@param string $path The repository path.
@param string $moduleName The name of the containing module.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"a",
"repository",
"path",
"and",
"a",
"module",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/NoSuchPathMappingException.php#L52-L59
|
223,659
|
puli/manager
|
src/Util/System.php
|
System.parseHomeDirectory
|
public static function parseHomeDirectory()
{
if ($value = getenv('PULI_HOME')) {
$homeDir = $value;
$env = 'PULI_HOME';
} elseif ($value = getenv('HOME')) {
$homeDir = $value;
$env = 'HOME';
} elseif ($value = getenv('APPDATA')) {
$homeDir = $value;
$env = 'APPDATA';
} else {
throw new InvalidConfigException(sprintf(
'Either the context variable PULI_HOME or %s must be set for '.
'Puli to run.',
defined('PHP_WINDOWS_VERSION_MAJOR') ? 'APPDATA' : 'HOME'
));
}
$homeDir = strtr($homeDir, array('\\' => '/'));
if (!file_exists($homeDir)) {
throw new FileNotFoundException(sprintf(
'The home path %s defined in the context variable %s '.
'does not exist.',
$homeDir,
$env
));
}
if (is_file($homeDir)) {
throw new NoDirectoryException(sprintf(
'The home path %s defined in the context variable %s '.
'points to a file. Expected a directory path.',
$homeDir,
$env
));
}
switch ($env) {
case 'PULI_HOME':
return $homeDir; // user defined
case 'HOME':
return $homeDir.'/.puli'; // Linux/Mac
default:
return $homeDir.'/Puli'; // Windows
}
}
|
php
|
public static function parseHomeDirectory()
{
if ($value = getenv('PULI_HOME')) {
$homeDir = $value;
$env = 'PULI_HOME';
} elseif ($value = getenv('HOME')) {
$homeDir = $value;
$env = 'HOME';
} elseif ($value = getenv('APPDATA')) {
$homeDir = $value;
$env = 'APPDATA';
} else {
throw new InvalidConfigException(sprintf(
'Either the context variable PULI_HOME or %s must be set for '.
'Puli to run.',
defined('PHP_WINDOWS_VERSION_MAJOR') ? 'APPDATA' : 'HOME'
));
}
$homeDir = strtr($homeDir, array('\\' => '/'));
if (!file_exists($homeDir)) {
throw new FileNotFoundException(sprintf(
'The home path %s defined in the context variable %s '.
'does not exist.',
$homeDir,
$env
));
}
if (is_file($homeDir)) {
throw new NoDirectoryException(sprintf(
'The home path %s defined in the context variable %s '.
'points to a file. Expected a directory path.',
$homeDir,
$env
));
}
switch ($env) {
case 'PULI_HOME':
return $homeDir; // user defined
case 'HOME':
return $homeDir.'/.puli'; // Linux/Mac
default:
return $homeDir.'/Puli'; // Windows
}
}
|
[
"public",
"static",
"function",
"parseHomeDirectory",
"(",
")",
"{",
"if",
"(",
"$",
"value",
"=",
"getenv",
"(",
"'PULI_HOME'",
")",
")",
"{",
"$",
"homeDir",
"=",
"$",
"value",
";",
"$",
"env",
"=",
"'PULI_HOME'",
";",
"}",
"elseif",
"(",
"$",
"value",
"=",
"getenv",
"(",
"'HOME'",
")",
")",
"{",
"$",
"homeDir",
"=",
"$",
"value",
";",
"$",
"env",
"=",
"'HOME'",
";",
"}",
"elseif",
"(",
"$",
"value",
"=",
"getenv",
"(",
"'APPDATA'",
")",
")",
"{",
"$",
"homeDir",
"=",
"$",
"value",
";",
"$",
"env",
"=",
"'APPDATA'",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"sprintf",
"(",
"'Either the context variable PULI_HOME or %s must be set for '",
".",
"'Puli to run.'",
",",
"defined",
"(",
"'PHP_WINDOWS_VERSION_MAJOR'",
")",
"?",
"'APPDATA'",
":",
"'HOME'",
")",
")",
";",
"}",
"$",
"homeDir",
"=",
"strtr",
"(",
"$",
"homeDir",
",",
"array",
"(",
"'\\\\'",
"=>",
"'/'",
")",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"homeDir",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"sprintf",
"(",
"'The home path %s defined in the context variable %s '",
".",
"'does not exist.'",
",",
"$",
"homeDir",
",",
"$",
"env",
")",
")",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"homeDir",
")",
")",
"{",
"throw",
"new",
"NoDirectoryException",
"(",
"sprintf",
"(",
"'The home path %s defined in the context variable %s '",
".",
"'points to a file. Expected a directory path.'",
",",
"$",
"homeDir",
",",
"$",
"env",
")",
")",
";",
"}",
"switch",
"(",
"$",
"env",
")",
"{",
"case",
"'PULI_HOME'",
":",
"return",
"$",
"homeDir",
";",
"// user defined",
"case",
"'HOME'",
":",
"return",
"$",
"homeDir",
".",
"'/.puli'",
";",
"// Linux/Mac",
"default",
":",
"return",
"$",
"homeDir",
".",
"'/Puli'",
";",
"// Windows",
"}",
"}"
] |
Parses context variables for Puli's home directory.
This method scans the context variables "PULI_HOME", "HOME" and
"APPDATA" to determine Puli's home directory:
* If "PULI_HOME" is found, that directory is used.
* If "HOME" is found, a directory ".puli" is created inside. This
variable contains the path of the user's home directory by default
on Unix based systems.
* If "APPDATA" is found, a directory "Puli" is created inside. This
variable contains the path of the application data by default on
Windows.
@return string The path to Puli's home directory.
@throws InvalidConfigException If no context variable can be found to
determine the home directory.
@throws FileNotFoundException If the home directory is not found.
@throws NoDirectoryException If the home directory is not a directory.
|
[
"Parses",
"context",
"variables",
"for",
"Puli",
"s",
"home",
"directory",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/System.php#L49-L96
|
223,660
|
puli/manager
|
src/Util/System.php
|
System.denyWebAccess
|
public static function denyWebAccess($directory)
{
if (!file_exists($directory.'/.htaccess')) {
if (!is_dir($directory)) {
$filesystem = new Filesystem();
$filesystem->mkdir($directory);
}
@file_put_contents($directory.'/.htaccess', 'Deny from all');
}
}
|
php
|
public static function denyWebAccess($directory)
{
if (!file_exists($directory.'/.htaccess')) {
if (!is_dir($directory)) {
$filesystem = new Filesystem();
$filesystem->mkdir($directory);
}
@file_put_contents($directory.'/.htaccess', 'Deny from all');
}
}
|
[
"public",
"static",
"function",
"denyWebAccess",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"directory",
".",
"'/.htaccess'",
")",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"filesystem",
"->",
"mkdir",
"(",
"$",
"directory",
")",
";",
"}",
"@",
"file_put_contents",
"(",
"$",
"directory",
".",
"'/.htaccess'",
",",
"'Deny from all'",
")",
";",
"}",
"}"
] |
Denies web access to a directory path.
A .htaccess file with the contents "Deny from all" is placed in the
directory, unless a .htaccess file exists already.
@param string $directory The path to a directory.
|
[
"Denies",
"web",
"access",
"to",
"a",
"directory",
"path",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/System.php#L106-L116
|
223,661
|
apoutchika/MediaBundle
|
Services/AliasManipulator.php
|
AliasManipulator.valideAliasName
|
public function valideAliasName($aliasName)
{
if ($aliasName === null || $aliasName === $this->originalDir) {
return $this->originalDir;
}
if (array_key_exists($aliasName, $this->alias)) {
return $this->aliasArrayToName($this->alias[$aliasName]);
}
if (!preg_match('#^(\d*)x(\d*)(_focus)?$#', $aliasName)) {
throw new \Exception($aliasName.' is not valid alias name');
}
if (preg_match('#^(x\d+|\d+x)_focus$#', $aliasName)) {
return str_replace('_focus', '', $aliasName);
}
return $aliasName;
}
|
php
|
public function valideAliasName($aliasName)
{
if ($aliasName === null || $aliasName === $this->originalDir) {
return $this->originalDir;
}
if (array_key_exists($aliasName, $this->alias)) {
return $this->aliasArrayToName($this->alias[$aliasName]);
}
if (!preg_match('#^(\d*)x(\d*)(_focus)?$#', $aliasName)) {
throw new \Exception($aliasName.' is not valid alias name');
}
if (preg_match('#^(x\d+|\d+x)_focus$#', $aliasName)) {
return str_replace('_focus', '', $aliasName);
}
return $aliasName;
}
|
[
"public",
"function",
"valideAliasName",
"(",
"$",
"aliasName",
")",
"{",
"if",
"(",
"$",
"aliasName",
"===",
"null",
"||",
"$",
"aliasName",
"===",
"$",
"this",
"->",
"originalDir",
")",
"{",
"return",
"$",
"this",
"->",
"originalDir",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"aliasName",
",",
"$",
"this",
"->",
"alias",
")",
")",
"{",
"return",
"$",
"this",
"->",
"aliasArrayToName",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"aliasName",
"]",
")",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'#^(\\d*)x(\\d*)(_focus)?$#'",
",",
"$",
"aliasName",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"aliasName",
".",
"' is not valid alias name'",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'#^(x\\d+|\\d+x)_focus$#'",
",",
"$",
"aliasName",
")",
")",
"{",
"return",
"str_replace",
"(",
"'_focus'",
",",
"''",
",",
"$",
"aliasName",
")",
";",
"}",
"return",
"$",
"aliasName",
";",
"}"
] |
Verify if the alias name is valid.
@param string $aliasName
@return string (alias name);
|
[
"Verify",
"if",
"the",
"alias",
"name",
"is",
"valid",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/AliasManipulator.php#L101-L120
|
223,662
|
apoutchika/MediaBundle
|
Services/AliasManipulator.php
|
AliasManipulator.valideAliasArray
|
public function valideAliasArray($aliasArray)
{
$aliasArray = array_replace(array('width' => null, 'height' => null), $aliasArray);
foreach ($aliasArray as $name => $value) {
if (!in_array($name, array('width', 'height', 'focus'))) {
throw new \Exception($name.' is not a good key');
}
if (in_array($name, array('width', 'height')) && (!preg_match('#^\d+$#', $value) && $value !== null)) {
throw new \Exception($value.' must be a integer or null');
}
if ($name === 'focus' && !is_bool($value)) {
throw new \Exception($value.' must be a boolean');
}
}
if ($aliasArray['width'] === null || $aliasArray['height'] === null) {
$aliasArray['focus'] = false;
} elseif (!isset($aliasArray['focus']) && $aliasArray['width'] !== null && $aliasArray['height'] !== null) {
$aliasArray['focus'] = true;
}
return $aliasArray;
}
|
php
|
public function valideAliasArray($aliasArray)
{
$aliasArray = array_replace(array('width' => null, 'height' => null), $aliasArray);
foreach ($aliasArray as $name => $value) {
if (!in_array($name, array('width', 'height', 'focus'))) {
throw new \Exception($name.' is not a good key');
}
if (in_array($name, array('width', 'height')) && (!preg_match('#^\d+$#', $value) && $value !== null)) {
throw new \Exception($value.' must be a integer or null');
}
if ($name === 'focus' && !is_bool($value)) {
throw new \Exception($value.' must be a boolean');
}
}
if ($aliasArray['width'] === null || $aliasArray['height'] === null) {
$aliasArray['focus'] = false;
} elseif (!isset($aliasArray['focus']) && $aliasArray['width'] !== null && $aliasArray['height'] !== null) {
$aliasArray['focus'] = true;
}
return $aliasArray;
}
|
[
"public",
"function",
"valideAliasArray",
"(",
"$",
"aliasArray",
")",
"{",
"$",
"aliasArray",
"=",
"array_replace",
"(",
"array",
"(",
"'width'",
"=>",
"null",
",",
"'height'",
"=>",
"null",
")",
",",
"$",
"aliasArray",
")",
";",
"foreach",
"(",
"$",
"aliasArray",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"array",
"(",
"'width'",
",",
"'height'",
",",
"'focus'",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"name",
".",
"' is not a good key'",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"array",
"(",
"'width'",
",",
"'height'",
")",
")",
"&&",
"(",
"!",
"preg_match",
"(",
"'#^\\d+$#'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
"!==",
"null",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"value",
".",
"' must be a integer or null'",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"'focus'",
"&&",
"!",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"value",
".",
"' must be a boolean'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"aliasArray",
"[",
"'width'",
"]",
"===",
"null",
"||",
"$",
"aliasArray",
"[",
"'height'",
"]",
"===",
"null",
")",
"{",
"$",
"aliasArray",
"[",
"'focus'",
"]",
"=",
"false",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"aliasArray",
"[",
"'focus'",
"]",
")",
"&&",
"$",
"aliasArray",
"[",
"'width'",
"]",
"!==",
"null",
"&&",
"$",
"aliasArray",
"[",
"'height'",
"]",
"!==",
"null",
")",
"{",
"$",
"aliasArray",
"[",
"'focus'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"aliasArray",
";",
"}"
] |
Verify alias array.
@param array $aliasArray
@return array ($aliasArray)
|
[
"Verify",
"alias",
"array",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/AliasManipulator.php#L129-L154
|
223,663
|
apoutchika/MediaBundle
|
Services/AliasManipulator.php
|
AliasManipulator.aliasArrayToName
|
private function aliasArrayToName(array $aliasArray)
{
if ($aliasArray === null || (empty($aliasArray['width']) && empty($aliasArray['height']))) {
return $this->originalDir;
}
if (!empty($aliasArray['focus'])) {
if (!in_array($aliasArray['focus'], array(true, false))) {
throw new \Exception('Focus must be a boolean type');
}
$end = ($aliasArray['focus'] === true) ? '_focus' : '';
} else {
$end = '';
}
if (!empty($aliasArray['width']) && !empty($aliasArray['height'])) {
return $aliasArray['width'].'x'.$aliasArray['height'].$end;
}
if (!empty($aliasArray['width'])) {
return $aliasArray['width'].'x';
}
if (!empty($aliasArray['height'])) {
return 'x'.$aliasArray['height'];
}
}
|
php
|
private function aliasArrayToName(array $aliasArray)
{
if ($aliasArray === null || (empty($aliasArray['width']) && empty($aliasArray['height']))) {
return $this->originalDir;
}
if (!empty($aliasArray['focus'])) {
if (!in_array($aliasArray['focus'], array(true, false))) {
throw new \Exception('Focus must be a boolean type');
}
$end = ($aliasArray['focus'] === true) ? '_focus' : '';
} else {
$end = '';
}
if (!empty($aliasArray['width']) && !empty($aliasArray['height'])) {
return $aliasArray['width'].'x'.$aliasArray['height'].$end;
}
if (!empty($aliasArray['width'])) {
return $aliasArray['width'].'x';
}
if (!empty($aliasArray['height'])) {
return 'x'.$aliasArray['height'];
}
}
|
[
"private",
"function",
"aliasArrayToName",
"(",
"array",
"$",
"aliasArray",
")",
"{",
"if",
"(",
"$",
"aliasArray",
"===",
"null",
"||",
"(",
"empty",
"(",
"$",
"aliasArray",
"[",
"'width'",
"]",
")",
"&&",
"empty",
"(",
"$",
"aliasArray",
"[",
"'height'",
"]",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"originalDir",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"aliasArray",
"[",
"'focus'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"aliasArray",
"[",
"'focus'",
"]",
",",
"array",
"(",
"true",
",",
"false",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Focus must be a boolean type'",
")",
";",
"}",
"$",
"end",
"=",
"(",
"$",
"aliasArray",
"[",
"'focus'",
"]",
"===",
"true",
")",
"?",
"'_focus'",
":",
"''",
";",
"}",
"else",
"{",
"$",
"end",
"=",
"''",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"aliasArray",
"[",
"'width'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"aliasArray",
"[",
"'height'",
"]",
")",
")",
"{",
"return",
"$",
"aliasArray",
"[",
"'width'",
"]",
".",
"'x'",
".",
"$",
"aliasArray",
"[",
"'height'",
"]",
".",
"$",
"end",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"aliasArray",
"[",
"'width'",
"]",
")",
")",
"{",
"return",
"$",
"aliasArray",
"[",
"'width'",
"]",
".",
"'x'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"aliasArray",
"[",
"'height'",
"]",
")",
")",
"{",
"return",
"'x'",
".",
"$",
"aliasArray",
"[",
"'height'",
"]",
";",
"}",
"}"
] |
Transform aliass array to name.
@param array $aliasArray
@return string
|
[
"Transform",
"aliass",
"array",
"to",
"name",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/AliasManipulator.php#L163-L190
|
223,664
|
apoutchika/MediaBundle
|
Services/AliasManipulator.php
|
AliasManipulator.aliasNameToArray
|
private function aliasNameToArray($aliasName)
{
if (!empty($aliasName) && isset($this->alias[$aliasName])) {
$aliasName = $this->aliasArrayToName($this->alias[$aliasName]);
} elseif (is_array($aliasName)) {
$aliasName = $this->aliasArrayToName($aliasName);
}
$aliasArray = array();
$width = preg_replace('#^(\d*)x.*$#', '$1', $aliasName);
$aliasArray['width'] = (!empty($width)) ? intval($width) : null;
$height = preg_replace('#^\d*x(\d*)(_focus)?$#', '$1', $aliasName);
$aliasArray['height'] = (!empty($height)) ? intval($height) : null;
if ($aliasArray['width'] !== null && $aliasArray['height'] !== null) {
$aliasArray['focus'] = (preg_match('#_focus$#', $aliasName)) ? true : false;
} else {
$aliasArray['focus'] = false;
}
return $aliasArray;
}
|
php
|
private function aliasNameToArray($aliasName)
{
if (!empty($aliasName) && isset($this->alias[$aliasName])) {
$aliasName = $this->aliasArrayToName($this->alias[$aliasName]);
} elseif (is_array($aliasName)) {
$aliasName = $this->aliasArrayToName($aliasName);
}
$aliasArray = array();
$width = preg_replace('#^(\d*)x.*$#', '$1', $aliasName);
$aliasArray['width'] = (!empty($width)) ? intval($width) : null;
$height = preg_replace('#^\d*x(\d*)(_focus)?$#', '$1', $aliasName);
$aliasArray['height'] = (!empty($height)) ? intval($height) : null;
if ($aliasArray['width'] !== null && $aliasArray['height'] !== null) {
$aliasArray['focus'] = (preg_match('#_focus$#', $aliasName)) ? true : false;
} else {
$aliasArray['focus'] = false;
}
return $aliasArray;
}
|
[
"private",
"function",
"aliasNameToArray",
"(",
"$",
"aliasName",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"aliasName",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"aliasName",
"]",
")",
")",
"{",
"$",
"aliasName",
"=",
"$",
"this",
"->",
"aliasArrayToName",
"(",
"$",
"this",
"->",
"alias",
"[",
"$",
"aliasName",
"]",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"aliasName",
")",
")",
"{",
"$",
"aliasName",
"=",
"$",
"this",
"->",
"aliasArrayToName",
"(",
"$",
"aliasName",
")",
";",
"}",
"$",
"aliasArray",
"=",
"array",
"(",
")",
";",
"$",
"width",
"=",
"preg_replace",
"(",
"'#^(\\d*)x.*$#'",
",",
"'$1'",
",",
"$",
"aliasName",
")",
";",
"$",
"aliasArray",
"[",
"'width'",
"]",
"=",
"(",
"!",
"empty",
"(",
"$",
"width",
")",
")",
"?",
"intval",
"(",
"$",
"width",
")",
":",
"null",
";",
"$",
"height",
"=",
"preg_replace",
"(",
"'#^\\d*x(\\d*)(_focus)?$#'",
",",
"'$1'",
",",
"$",
"aliasName",
")",
";",
"$",
"aliasArray",
"[",
"'height'",
"]",
"=",
"(",
"!",
"empty",
"(",
"$",
"height",
")",
")",
"?",
"intval",
"(",
"$",
"height",
")",
":",
"null",
";",
"if",
"(",
"$",
"aliasArray",
"[",
"'width'",
"]",
"!==",
"null",
"&&",
"$",
"aliasArray",
"[",
"'height'",
"]",
"!==",
"null",
")",
"{",
"$",
"aliasArray",
"[",
"'focus'",
"]",
"=",
"(",
"preg_match",
"(",
"'#_focus$#'",
",",
"$",
"aliasName",
")",
")",
"?",
"true",
":",
"false",
";",
"}",
"else",
"{",
"$",
"aliasArray",
"[",
"'focus'",
"]",
"=",
"false",
";",
"}",
"return",
"$",
"aliasArray",
";",
"}"
] |
Transform alias name to array.
@param string $aliasName
@return array
|
[
"Transform",
"alias",
"name",
"to",
"array",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/AliasManipulator.php#L199-L222
|
223,665
|
puli/manager
|
src/Api/Installer/InstallerDescriptor.php
|
InstallerDescriptor.getParameter
|
public function getParameter($parameterName)
{
if (!isset($this->parameters[$parameterName])) {
throw NoSuchParameterException::forParameterName($parameterName, $this->name);
}
return $this->parameters[$parameterName];
}
|
php
|
public function getParameter($parameterName)
{
if (!isset($this->parameters[$parameterName])) {
throw NoSuchParameterException::forParameterName($parameterName, $this->name);
}
return $this->parameters[$parameterName];
}
|
[
"public",
"function",
"getParameter",
"(",
"$",
"parameterName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"$",
"parameterName",
"]",
")",
")",
"{",
"throw",
"NoSuchParameterException",
"::",
"forParameterName",
"(",
"$",
"parameterName",
",",
"$",
"this",
"->",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"parameters",
"[",
"$",
"parameterName",
"]",
";",
"}"
] |
Returns an installer parameter.
@param string $parameterName The parameter name.
@return InstallerParameter The installer parameter.
@throws NoSuchParameterException If the parameter does not exist.
|
[
"Returns",
"an",
"installer",
"parameter",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installer/InstallerDescriptor.php#L122-L129
|
223,666
|
puli/manager
|
src/Api/Installer/InstallerDescriptor.php
|
InstallerDescriptor.getParameterValues
|
public function getParameterValues()
{
$values = array();
foreach ($this->parameters as $name => $parameter) {
if (!$parameter->isRequired()) {
$values[$name] = $parameter->getDefaultValue();
}
}
return $values;
}
|
php
|
public function getParameterValues()
{
$values = array();
foreach ($this->parameters as $name => $parameter) {
if (!$parameter->isRequired()) {
$values[$name] = $parameter->getDefaultValue();
}
}
return $values;
}
|
[
"public",
"function",
"getParameterValues",
"(",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"name",
"=>",
"$",
"parameter",
")",
"{",
"if",
"(",
"!",
"$",
"parameter",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"values",
"[",
"$",
"name",
"]",
"=",
"$",
"parameter",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] |
Returns the default values of all optional parameters.
@return array The default values.
|
[
"Returns",
"the",
"default",
"values",
"of",
"all",
"optional",
"parameters",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installer/InstallerDescriptor.php#L192-L203
|
223,667
|
puli/manager
|
src/Api/Module/RootModuleFile.php
|
RootModuleFile.setInstallInfos
|
public function setInstallInfos(array $installInfos)
{
$this->installInfos = array();
foreach ($installInfos as $installInfo) {
$this->addInstallInfo($installInfo);
}
}
|
php
|
public function setInstallInfos(array $installInfos)
{
$this->installInfos = array();
foreach ($installInfos as $installInfo) {
$this->addInstallInfo($installInfo);
}
}
|
[
"public",
"function",
"setInstallInfos",
"(",
"array",
"$",
"installInfos",
")",
"{",
"$",
"this",
"->",
"installInfos",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"installInfos",
"as",
"$",
"installInfo",
")",
"{",
"$",
"this",
"->",
"addInstallInfo",
"(",
"$",
"installInfo",
")",
";",
"}",
"}"
] |
Sets the install infos of all installed modules.
@param InstallInfo[] The install infos.
|
[
"Sets",
"the",
"install",
"infos",
"of",
"all",
"installed",
"modules",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/RootModuleFile.php#L114-L121
|
223,668
|
puli/manager
|
src/Api/Module/RootModuleFile.php
|
RootModuleFile.getInstallInfo
|
public function getInstallInfo($moduleName)
{
if (!isset($this->installInfos[$moduleName])) {
throw new NoSuchModuleException(sprintf(
'Could not get install info: The module "%s" is not installed.',
$moduleName
));
}
return $this->installInfos[$moduleName];
}
|
php
|
public function getInstallInfo($moduleName)
{
if (!isset($this->installInfos[$moduleName])) {
throw new NoSuchModuleException(sprintf(
'Could not get install info: The module "%s" is not installed.',
$moduleName
));
}
return $this->installInfos[$moduleName];
}
|
[
"public",
"function",
"getInstallInfo",
"(",
"$",
"moduleName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"installInfos",
"[",
"$",
"moduleName",
"]",
")",
")",
"{",
"throw",
"new",
"NoSuchModuleException",
"(",
"sprintf",
"(",
"'Could not get install info: The module \"%s\" is not installed.'",
",",
"$",
"moduleName",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"installInfos",
"[",
"$",
"moduleName",
"]",
";",
"}"
] |
Returns the install info of an installed module.
@param string $moduleName The module name.
@return InstallInfo The install info.
@throws NoSuchModuleException If no module is installed with that name.
|
[
"Returns",
"the",
"install",
"info",
"of",
"an",
"installed",
"module",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/RootModuleFile.php#L160-L170
|
223,669
|
puli/manager
|
src/Api/Installation/InstallationParams.php
|
InstallationParams.getServerPathForResource
|
public function getServerPathForResource(PuliResource $resource)
{
$relPath = Path::makeRelative($resource->getRepositoryPath(), $this->basePath);
return '/'.trim($this->mapping->getServerPath().'/'.$relPath, '/');
}
|
php
|
public function getServerPathForResource(PuliResource $resource)
{
$relPath = Path::makeRelative($resource->getRepositoryPath(), $this->basePath);
return '/'.trim($this->mapping->getServerPath().'/'.$relPath, '/');
}
|
[
"public",
"function",
"getServerPathForResource",
"(",
"PuliResource",
"$",
"resource",
")",
"{",
"$",
"relPath",
"=",
"Path",
"::",
"makeRelative",
"(",
"$",
"resource",
"->",
"getRepositoryPath",
"(",
")",
",",
"$",
"this",
"->",
"basePath",
")",
";",
"return",
"'/'",
".",
"trim",
"(",
"$",
"this",
"->",
"mapping",
"->",
"getServerPath",
"(",
")",
".",
"'/'",
".",
"$",
"relPath",
",",
"'/'",
")",
";",
"}"
] |
Returns the path where a resource is going to be installed.
This is a path relative to the document root of the target server.
@param PuliResource $resource The resource.
@return string The server path.
|
[
"Returns",
"the",
"path",
"where",
"a",
"resource",
"is",
"going",
"to",
"be",
"installed",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installation/InstallationParams.php#L205-L210
|
223,670
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.setRecurrenceEventId
|
public function setRecurrenceEventId($entity = null): string
{
$start = $entity instanceof EntityInterface ? $entity->get('start_date') : $entity['start_date'];
$end = $entity instanceof EntityInterface ? $entity->get('end_date') : $entity['end_date'];
$id = $entity instanceof EntityInterface ? $entity->get('id') : $entity['id'];
$result = sprintf("%s__%s_%s", $id, strtotime($start), strtotime($end));
return $result;
}
|
php
|
public function setRecurrenceEventId($entity = null): string
{
$start = $entity instanceof EntityInterface ? $entity->get('start_date') : $entity['start_date'];
$end = $entity instanceof EntityInterface ? $entity->get('end_date') : $entity['end_date'];
$id = $entity instanceof EntityInterface ? $entity->get('id') : $entity['id'];
$result = sprintf("%s__%s_%s", $id, strtotime($start), strtotime($end));
return $result;
}
|
[
"public",
"function",
"setRecurrenceEventId",
"(",
"$",
"entity",
"=",
"null",
")",
":",
"string",
"{",
"$",
"start",
"=",
"$",
"entity",
"instanceof",
"EntityInterface",
"?",
"$",
"entity",
"->",
"get",
"(",
"'start_date'",
")",
":",
"$",
"entity",
"[",
"'start_date'",
"]",
";",
"$",
"end",
"=",
"$",
"entity",
"instanceof",
"EntityInterface",
"?",
"$",
"entity",
"->",
"get",
"(",
"'end_date'",
")",
":",
"$",
"entity",
"[",
"'end_date'",
"]",
";",
"$",
"id",
"=",
"$",
"entity",
"instanceof",
"EntityInterface",
"?",
"$",
"entity",
"->",
"get",
"(",
"'id'",
")",
":",
"$",
"entity",
"[",
"'id'",
"]",
";",
"$",
"result",
"=",
"sprintf",
"(",
"\"%s__%s_%s\"",
",",
"$",
"id",
",",
"strtotime",
"(",
"$",
"start",
")",
",",
"strtotime",
"(",
"$",
"end",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Set ID suffix for recurring events
We attach timestamp suffix for recurring events
that haven't been saved in the DB yet.
@param \Cake\Datasource\EntityInterface|array $entity of the event
@return string $result with suffix.
|
[
"Set",
"ID",
"suffix",
"for",
"recurring",
"events"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L132-L141
|
223,671
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getRecurrenceEventId
|
public function getRecurrenceEventId(?string $id = null): array
{
$result = [];
if (empty($id)) {
return $result;
}
if (preg_match('/(^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})(__(\d+)?_(\d+)?)?/', $id, $matches)) {
$result['id'] = $matches[1];
$result['start'] = !empty($matches[3]) ? date('Y-m-d H:i:s', $matches[3]) : null;
$result['end'] = !empty($matches[4]) ? date('Y-m-d H:i:s', $matches[4]) : null;
}
return $result;
}
|
php
|
public function getRecurrenceEventId(?string $id = null): array
{
$result = [];
if (empty($id)) {
return $result;
}
if (preg_match('/(^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})(__(\d+)?_(\d+)?)?/', $id, $matches)) {
$result['id'] = $matches[1];
$result['start'] = !empty($matches[3]) ? date('Y-m-d H:i:s', $matches[3]) : null;
$result['end'] = !empty($matches[4]) ? date('Y-m-d H:i:s', $matches[4]) : null;
}
return $result;
}
|
[
"public",
"function",
"getRecurrenceEventId",
"(",
"?",
"string",
"$",
"id",
"=",
"null",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/(^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})(__(\\d+)?_(\\d+)?)?/'",
",",
"$",
"id",
",",
"$",
"matches",
")",
")",
"{",
"$",
"result",
"[",
"'id'",
"]",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"result",
"[",
"'start'",
"]",
"=",
"!",
"empty",
"(",
"$",
"matches",
"[",
"3",
"]",
")",
"?",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"matches",
"[",
"3",
"]",
")",
":",
"null",
";",
"$",
"result",
"[",
"'end'",
"]",
"=",
"!",
"empty",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
"?",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"matches",
"[",
"4",
"]",
")",
":",
"null",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Parse recurrent event id suffix
@param string $id containing date suffix
@return mixed[] $result containing start/end pair.
|
[
"Parse",
"recurrent",
"event",
"id",
"suffix"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L149-L164
|
223,672
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getEvents
|
public function getEvents(?EntityInterface $calendar, array $options = [], bool $isInfinite = true): array
{
$result = [];
if (!$calendar) {
return $result;
}
$events = $this->findCalendarEvents($options);
/** @var \Cake\Datasource\EntityInterface $event */
foreach ($events as $event) {
$eventItem = $this->prepareEventData($event->toArray(), $calendar);
if (empty($eventItem['recurrence'])) {
array_push($result, $eventItem);
continue;
}
$recurrence = $this->getRRuleConfiguration($eventItem['recurrence']);
if (empty($recurrence)) {
continue;
}
$intervals = $this->getRecurrence($recurrence, [
'start' => $eventItem['start_date'],
'end' => $eventItem['end_date'],
]);
foreach ($intervals as $interval) {
$entity = $this->prepareRecurringEventData($eventItem, $interval, $calendar);
if (empty($entity)) {
continue;
}
array_push($result, $entity->toArray());
}
}
$infiniteEvents = $this->getInfiniteEvents($events, $options, $isInfinite);
foreach ($infiniteEvents as $event) {
$eventItem = $this->prepareEventData($event->toArray(), $calendar);
$recurrence = $this->getRRuleConfiguration($eventItem['recurrence']);
if (empty($recurrence)) {
continue;
}
$intervals = $this->getRecurrence($recurrence, [
'start' => $eventItem['start_date'],
'end' => $options['period']['end_date'],
'from' => $options['period']['start_date'],
'fixTime' => true,
]);
foreach ($intervals as $interval) {
$entity = $this->prepareRecurringEventData($eventItem, $interval, $calendar);
if (empty($entity)) {
continue;
}
array_push($result, $entity->toArray());
}
}
return $result;
}
|
php
|
public function getEvents(?EntityInterface $calendar, array $options = [], bool $isInfinite = true): array
{
$result = [];
if (!$calendar) {
return $result;
}
$events = $this->findCalendarEvents($options);
/** @var \Cake\Datasource\EntityInterface $event */
foreach ($events as $event) {
$eventItem = $this->prepareEventData($event->toArray(), $calendar);
if (empty($eventItem['recurrence'])) {
array_push($result, $eventItem);
continue;
}
$recurrence = $this->getRRuleConfiguration($eventItem['recurrence']);
if (empty($recurrence)) {
continue;
}
$intervals = $this->getRecurrence($recurrence, [
'start' => $eventItem['start_date'],
'end' => $eventItem['end_date'],
]);
foreach ($intervals as $interval) {
$entity = $this->prepareRecurringEventData($eventItem, $interval, $calendar);
if (empty($entity)) {
continue;
}
array_push($result, $entity->toArray());
}
}
$infiniteEvents = $this->getInfiniteEvents($events, $options, $isInfinite);
foreach ($infiniteEvents as $event) {
$eventItem = $this->prepareEventData($event->toArray(), $calendar);
$recurrence = $this->getRRuleConfiguration($eventItem['recurrence']);
if (empty($recurrence)) {
continue;
}
$intervals = $this->getRecurrence($recurrence, [
'start' => $eventItem['start_date'],
'end' => $options['period']['end_date'],
'from' => $options['period']['start_date'],
'fixTime' => true,
]);
foreach ($intervals as $interval) {
$entity = $this->prepareRecurringEventData($eventItem, $interval, $calendar);
if (empty($entity)) {
continue;
}
array_push($result, $entity->toArray());
}
}
return $result;
}
|
[
"public",
"function",
"getEvents",
"(",
"?",
"EntityInterface",
"$",
"calendar",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"bool",
"$",
"isInfinite",
"=",
"true",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"calendar",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"events",
"=",
"$",
"this",
"->",
"findCalendarEvents",
"(",
"$",
"options",
")",
";",
"/** @var \\Cake\\Datasource\\EntityInterface $event */",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"$",
"eventItem",
"=",
"$",
"this",
"->",
"prepareEventData",
"(",
"$",
"event",
"->",
"toArray",
"(",
")",
",",
"$",
"calendar",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"eventItem",
"[",
"'recurrence'",
"]",
")",
")",
"{",
"array_push",
"(",
"$",
"result",
",",
"$",
"eventItem",
")",
";",
"continue",
";",
"}",
"$",
"recurrence",
"=",
"$",
"this",
"->",
"getRRuleConfiguration",
"(",
"$",
"eventItem",
"[",
"'recurrence'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"recurrence",
")",
")",
"{",
"continue",
";",
"}",
"$",
"intervals",
"=",
"$",
"this",
"->",
"getRecurrence",
"(",
"$",
"recurrence",
",",
"[",
"'start'",
"=>",
"$",
"eventItem",
"[",
"'start_date'",
"]",
",",
"'end'",
"=>",
"$",
"eventItem",
"[",
"'end_date'",
"]",
",",
"]",
")",
";",
"foreach",
"(",
"$",
"intervals",
"as",
"$",
"interval",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"prepareRecurringEventData",
"(",
"$",
"eventItem",
",",
"$",
"interval",
",",
"$",
"calendar",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"entity",
")",
")",
"{",
"continue",
";",
"}",
"array_push",
"(",
"$",
"result",
",",
"$",
"entity",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"}",
"$",
"infiniteEvents",
"=",
"$",
"this",
"->",
"getInfiniteEvents",
"(",
"$",
"events",
",",
"$",
"options",
",",
"$",
"isInfinite",
")",
";",
"foreach",
"(",
"$",
"infiniteEvents",
"as",
"$",
"event",
")",
"{",
"$",
"eventItem",
"=",
"$",
"this",
"->",
"prepareEventData",
"(",
"$",
"event",
"->",
"toArray",
"(",
")",
",",
"$",
"calendar",
")",
";",
"$",
"recurrence",
"=",
"$",
"this",
"->",
"getRRuleConfiguration",
"(",
"$",
"eventItem",
"[",
"'recurrence'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"recurrence",
")",
")",
"{",
"continue",
";",
"}",
"$",
"intervals",
"=",
"$",
"this",
"->",
"getRecurrence",
"(",
"$",
"recurrence",
",",
"[",
"'start'",
"=>",
"$",
"eventItem",
"[",
"'start_date'",
"]",
",",
"'end'",
"=>",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'end_date'",
"]",
",",
"'from'",
"=>",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'start_date'",
"]",
",",
"'fixTime'",
"=>",
"true",
",",
"]",
")",
";",
"foreach",
"(",
"$",
"intervals",
"as",
"$",
"interval",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"prepareRecurringEventData",
"(",
"$",
"eventItem",
",",
"$",
"interval",
",",
"$",
"calendar",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"entity",
")",
")",
"{",
"continue",
";",
"}",
"array_push",
"(",
"$",
"result",
",",
"$",
"entity",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get Events of specific calendar
@param \Cake\Datasource\EntityInterface|null $calendar record
@param mixed[] $options with filter params
@param bool $isInfinite flag to find inifinite events like birthdays
@return mixed[] $result of events (minimal structure)
|
[
"Get",
"Events",
"of",
"specific",
"calendar"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L175-L244
|
223,673
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getEventRange
|
public function getEventRange(array $options = []): array
{
$result = [];
if (empty($options['period'])) {
return $result;
}
//@NOTE: sqlite doesn't support date_format or month functions
if (!empty($options['period']['start_date'])) {
$result['start'] = [
'MONTH(start_date) >=' => date('m', strtotime($options['period']['start_date']))
];
}
if (!empty($options['period']['end_date'])) {
$result['end'] = [
'MONTH(end_date) <=' => date('m', strtotime($options['period']['end_date']))
];
}
return $result;
}
|
php
|
public function getEventRange(array $options = []): array
{
$result = [];
if (empty($options['period'])) {
return $result;
}
//@NOTE: sqlite doesn't support date_format or month functions
if (!empty($options['period']['start_date'])) {
$result['start'] = [
'MONTH(start_date) >=' => date('m', strtotime($options['period']['start_date']))
];
}
if (!empty($options['period']['end_date'])) {
$result['end'] = [
'MONTH(end_date) <=' => date('m', strtotime($options['period']['end_date']))
];
}
return $result;
}
|
[
"public",
"function",
"getEventRange",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'period'",
"]",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"//@NOTE: sqlite doesn't support date_format or month functions",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'start_date'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"'start'",
"]",
"=",
"[",
"'MONTH(start_date) >='",
"=>",
"date",
"(",
"'m'",
",",
"strtotime",
"(",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'start_date'",
"]",
")",
")",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'end_date'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"'end'",
"]",
"=",
"[",
"'MONTH(end_date) <='",
"=>",
"date",
"(",
"'m'",
",",
"strtotime",
"(",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'end_date'",
"]",
")",
")",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get Event Range condition
@param mixed[] $options containiner period with start_date/end_date params
@return mixed[] $result containing start/end keys with month dates.
|
[
"Get",
"Event",
"Range",
"condition"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L252-L274
|
223,674
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getInfiniteEvents
|
public function getInfiniteEvents(array $events, array $options = [], bool $isInfinite = true): array
{
$result = $existingEventIds = [];
$query = $this->findCalendarEvents($options, $isInfinite);
if (!$query) {
return $result;
}
if (!empty($events)) {
$existingEventIds = array_map(function ($item) {
return $item->id;
}, $events);
}
foreach ($query as $item) {
if (in_array($item->id, $existingEventIds) || empty($item->recurrence)) {
continue;
}
$rule = $this->getRRuleConfiguration($item->recurrence);
$rrule = new RRule($rule);
if ($rrule->isInfinite()) {
array_push($result, $item);
}
}
return $result;
}
|
php
|
public function getInfiniteEvents(array $events, array $options = [], bool $isInfinite = true): array
{
$result = $existingEventIds = [];
$query = $this->findCalendarEvents($options, $isInfinite);
if (!$query) {
return $result;
}
if (!empty($events)) {
$existingEventIds = array_map(function ($item) {
return $item->id;
}, $events);
}
foreach ($query as $item) {
if (in_array($item->id, $existingEventIds) || empty($item->recurrence)) {
continue;
}
$rule = $this->getRRuleConfiguration($item->recurrence);
$rrule = new RRule($rule);
if ($rrule->isInfinite()) {
array_push($result, $item);
}
}
return $result;
}
|
[
"public",
"function",
"getInfiniteEvents",
"(",
"array",
"$",
"events",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"bool",
"$",
"isInfinite",
"=",
"true",
")",
":",
"array",
"{",
"$",
"result",
"=",
"$",
"existingEventIds",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"findCalendarEvents",
"(",
"$",
"options",
",",
"$",
"isInfinite",
")",
";",
"if",
"(",
"!",
"$",
"query",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"events",
")",
")",
"{",
"$",
"existingEventIds",
"=",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"->",
"id",
";",
"}",
",",
"$",
"events",
")",
";",
"}",
"foreach",
"(",
"$",
"query",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"item",
"->",
"id",
",",
"$",
"existingEventIds",
")",
"||",
"empty",
"(",
"$",
"item",
"->",
"recurrence",
")",
")",
"{",
"continue",
";",
"}",
"$",
"rule",
"=",
"$",
"this",
"->",
"getRRuleConfiguration",
"(",
"$",
"item",
"->",
"recurrence",
")",
";",
"$",
"rrule",
"=",
"new",
"RRule",
"(",
"$",
"rule",
")",
";",
"if",
"(",
"$",
"rrule",
"->",
"isInfinite",
"(",
")",
")",
"{",
"array_push",
"(",
"$",
"result",
",",
"$",
"item",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get infinite calendar events for given calendar
@param mixed[] $events from findCalendarEvents
@param mixed[] $options containing month viewport (end/start interval).
@param bool $isInfinite flag for infinite events like birthdays
@return mixed[] $result containing event records
|
[
"Get",
"infinite",
"calendar",
"events",
"for",
"given",
"calendar"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L285-L314
|
223,675
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getRRuleConfiguration
|
public function getRRuleConfiguration(string $recurrence = null): ?string
{
$result = null;
if (empty($recurrence)) {
return $result;
}
$result = preg_match('/^RRULE:/', $recurrence) ? $recurrence : 'RRULE:' . $recurrence;
return $result;
}
|
php
|
public function getRRuleConfiguration(string $recurrence = null): ?string
{
$result = null;
if (empty($recurrence)) {
return $result;
}
$result = preg_match('/^RRULE:/', $recurrence) ? $recurrence : 'RRULE:' . $recurrence;
return $result;
}
|
[
"public",
"function",
"getRRuleConfiguration",
"(",
"string",
"$",
"recurrence",
"=",
"null",
")",
":",
"?",
"string",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"recurrence",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"preg_match",
"(",
"'/^RRULE:/'",
",",
"$",
"recurrence",
")",
"?",
"$",
"recurrence",
":",
"'RRULE:'",
".",
"$",
"recurrence",
";",
"return",
"$",
"result",
";",
"}"
] |
Get RRULE configuration from the event
@param string $recurrence received from the calendar
@return string|null $result containing the RRULE
|
[
"Get",
"RRULE",
"configuration",
"from",
"the",
"event"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L323-L334
|
223,676
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.setRRuleConfiguration
|
public function setRRuleConfiguration(string $recurrence = null): ?string
{
$result = null;
if (empty($recurrence)) {
return $result;
}
if (!preg_match('/RRULE:/', $recurrence)) {
$result = 'RRULE:' . $recurrence;
}
return $result;
}
|
php
|
public function setRRuleConfiguration(string $recurrence = null): ?string
{
$result = null;
if (empty($recurrence)) {
return $result;
}
if (!preg_match('/RRULE:/', $recurrence)) {
$result = 'RRULE:' . $recurrence;
}
return $result;
}
|
[
"public",
"function",
"setRRuleConfiguration",
"(",
"string",
"$",
"recurrence",
"=",
"null",
")",
":",
"?",
"string",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"recurrence",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'/RRULE:/'",
",",
"$",
"recurrence",
")",
")",
"{",
"$",
"result",
"=",
"'RRULE:'",
".",
"$",
"recurrence",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Set valid RRULE string
@param string $recurrence from the UI
@return string|null $result json encoded array with RRULE
|
[
"Set",
"valid",
"RRULE",
"string"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L342-L355
|
223,677
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getEventTypes
|
public function getEventTypes(array $options = []): array
{
$result = [];
if (!empty($options['calendar'])) {
$types = json_decode($options['calendar']->event_types, true);
foreach ($types as $type) {
$result[$type] = $type;
}
asort($result);
return $result;
}
$event = new Event('App.Calendars.getCalendarEventTypes', $this, [
'user' => $options['user'],
]);
EventManager::instance()->dispatch($event);
if (!empty($event->result)) {
$result = array_merge($result, $event->result);
}
$configEventTypes = $this->getEventTypeBy();
$result = array_merge($result, $configEventTypes);
return $result;
}
|
php
|
public function getEventTypes(array $options = []): array
{
$result = [];
if (!empty($options['calendar'])) {
$types = json_decode($options['calendar']->event_types, true);
foreach ($types as $type) {
$result[$type] = $type;
}
asort($result);
return $result;
}
$event = new Event('App.Calendars.getCalendarEventTypes', $this, [
'user' => $options['user'],
]);
EventManager::instance()->dispatch($event);
if (!empty($event->result)) {
$result = array_merge($result, $event->result);
}
$configEventTypes = $this->getEventTypeBy();
$result = array_merge($result, $configEventTypes);
return $result;
}
|
[
"public",
"function",
"getEventTypes",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'calendar'",
"]",
")",
")",
"{",
"$",
"types",
"=",
"json_decode",
"(",
"$",
"options",
"[",
"'calendar'",
"]",
"->",
"event_types",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"result",
"[",
"$",
"type",
"]",
"=",
"$",
"type",
";",
"}",
"asort",
"(",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}",
"$",
"event",
"=",
"new",
"Event",
"(",
"'App.Calendars.getCalendarEventTypes'",
",",
"$",
"this",
",",
"[",
"'user'",
"=>",
"$",
"options",
"[",
"'user'",
"]",
",",
"]",
")",
";",
"EventManager",
"::",
"instance",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"event",
"->",
"result",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"event",
"->",
"result",
")",
";",
"}",
"$",
"configEventTypes",
"=",
"$",
"this",
"->",
"getEventTypeBy",
"(",
")",
";",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"configEventTypes",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Get Event types for the calendar event
@param mixed[] $options of the data including user
@return mixed[] $result with event types.
|
[
"Get",
"Event",
"types",
"for",
"the",
"calendar",
"event"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L409-L438
|
223,678
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getEventTypeName
|
public function getEventTypeName(array $data = [], array $options = []): ?string
{
if (empty($data['name'])) {
return null;
}
$prefix = !empty($options['prefix']) ? $options['prefix'] : 'Config';
$type = !empty($data['type']) ? $data['type'] : 'default';
$delimiter = '::';
$name = $prefix . $delimiter . $data['name'] . $delimiter . Inflector::camelize($type);
return $name;
}
|
php
|
public function getEventTypeName(array $data = [], array $options = []): ?string
{
if (empty($data['name'])) {
return null;
}
$prefix = !empty($options['prefix']) ? $options['prefix'] : 'Config';
$type = !empty($data['type']) ? $data['type'] : 'default';
$delimiter = '::';
$name = $prefix . $delimiter . $data['name'] . $delimiter . Inflector::camelize($type);
return $name;
}
|
[
"public",
"function",
"getEventTypeName",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"?",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"prefix",
"=",
"!",
"empty",
"(",
"$",
"options",
"[",
"'prefix'",
"]",
")",
"?",
"$",
"options",
"[",
"'prefix'",
"]",
":",
"'Config'",
";",
"$",
"type",
"=",
"!",
"empty",
"(",
"$",
"data",
"[",
"'type'",
"]",
")",
"?",
"$",
"data",
"[",
"'type'",
"]",
":",
"'default'",
";",
"$",
"delimiter",
"=",
"'::'",
";",
"$",
"name",
"=",
"$",
"prefix",
".",
"$",
"delimiter",
".",
"$",
"data",
"[",
"'name'",
"]",
".",
"$",
"delimiter",
".",
"Inflector",
"::",
"camelize",
"(",
"$",
"type",
")",
";",
"return",
"$",
"name",
";",
"}"
] |
Get Event Type name
@param mixed[] $data with name parts
@param mixed[] $options for extra settings if needed
@return string|null $name containing event type definition.
|
[
"Get",
"Event",
"Type",
"name"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L448-L461
|
223,679
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getEventInfo
|
public function getEventInfo(?string $id = null, ?EntityInterface $calendar = null)
{
$result = [];
if (empty($id)) {
return $result;
}
$options = $this->getRecurrenceEventId($id);
/** @var \Cake\ORM\Query $query */
$query = $this->find()
->where(['id' => $options['id']])
->contain(['CalendarAttendees']);
$result = $query->first();
if (!($result instanceof EntityInterface)) {
return [];
}
//@NOTE: we're faking the start/end intervals for recurring events
if (!empty($options['end'])) {
$time = Time::parse($options['end']);
$result->set('end_date', $time);
$result->set('end', $time);
unset($time);
}
if (!empty($options['start'])) {
$time = Time::parse($options['start']);
$result->set('start_date', $time);
$result->set('start', $time);
unset($time);
}
if ($calendar) {
if (empty($result->calendar_id)) {
$result->set('calendar_id', $calendar->id);
}
}
$result->set('color', $this->Calendars->getColor($calendar));
return $result;
}
|
php
|
public function getEventInfo(?string $id = null, ?EntityInterface $calendar = null)
{
$result = [];
if (empty($id)) {
return $result;
}
$options = $this->getRecurrenceEventId($id);
/** @var \Cake\ORM\Query $query */
$query = $this->find()
->where(['id' => $options['id']])
->contain(['CalendarAttendees']);
$result = $query->first();
if (!($result instanceof EntityInterface)) {
return [];
}
//@NOTE: we're faking the start/end intervals for recurring events
if (!empty($options['end'])) {
$time = Time::parse($options['end']);
$result->set('end_date', $time);
$result->set('end', $time);
unset($time);
}
if (!empty($options['start'])) {
$time = Time::parse($options['start']);
$result->set('start_date', $time);
$result->set('start', $time);
unset($time);
}
if ($calendar) {
if (empty($result->calendar_id)) {
$result->set('calendar_id', $calendar->id);
}
}
$result->set('color', $this->Calendars->getColor($calendar));
return $result;
}
|
[
"public",
"function",
"getEventInfo",
"(",
"?",
"string",
"$",
"id",
"=",
"null",
",",
"?",
"EntityInterface",
"$",
"calendar",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"options",
"=",
"$",
"this",
"->",
"getRecurrenceEventId",
"(",
"$",
"id",
")",
";",
"/** @var \\Cake\\ORM\\Query $query */",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'id'",
"=>",
"$",
"options",
"[",
"'id'",
"]",
"]",
")",
"->",
"contain",
"(",
"[",
"'CalendarAttendees'",
"]",
")",
";",
"$",
"result",
"=",
"$",
"query",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"result",
"instanceof",
"EntityInterface",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"//@NOTE: we're faking the start/end intervals for recurring events",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'end'",
"]",
")",
")",
"{",
"$",
"time",
"=",
"Time",
"::",
"parse",
"(",
"$",
"options",
"[",
"'end'",
"]",
")",
";",
"$",
"result",
"->",
"set",
"(",
"'end_date'",
",",
"$",
"time",
")",
";",
"$",
"result",
"->",
"set",
"(",
"'end'",
",",
"$",
"time",
")",
";",
"unset",
"(",
"$",
"time",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'start'",
"]",
")",
")",
"{",
"$",
"time",
"=",
"Time",
"::",
"parse",
"(",
"$",
"options",
"[",
"'start'",
"]",
")",
";",
"$",
"result",
"->",
"set",
"(",
"'start_date'",
",",
"$",
"time",
")",
";",
"$",
"result",
"->",
"set",
"(",
"'start'",
",",
"$",
"time",
")",
";",
"unset",
"(",
"$",
"time",
")",
";",
"}",
"if",
"(",
"$",
"calendar",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"result",
"->",
"calendar_id",
")",
")",
"{",
"$",
"result",
"->",
"set",
"(",
"'calendar_id'",
",",
"$",
"calendar",
"->",
"id",
")",
";",
"}",
"}",
"$",
"result",
"->",
"set",
"(",
"'color'",
",",
"$",
"this",
"->",
"Calendars",
"->",
"getColor",
"(",
"$",
"calendar",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Get Event info
@param string $id of the record
@param \Cake\Datasource\EntityInterface $calendar instance
@return array|\Cake\Datasource\EntityInterface $result containing record data
|
[
"Get",
"Event",
"info"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L471-L515
|
223,680
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.prepareRecurringEventData
|
public function prepareRecurringEventData(array $event = [], array $interval = [], EntityInterface $calendar = null): ?EntityInterface
{
$entity = null;
if (empty($event)) {
return $entity;
}
$entity = $this->newEntity();
$entity = $this->patchEntity($entity, $event);
$entity->set('start_date', $interval['start']);
$entity->set('end_date', $interval['end']);
$entity->set('start', $entity->get('start_date')->i18nFormat('yyyy-MM-dd HH:mm:ss'));
$entity->set('end', $entity->get('end_date')->i18nFormat('yyyy-MM-dd HH:mm:ss'));
$entity->set('id', $event['id']);
$entity->set('id', $this->setRecurrenceEventId($entity));
$entity->set('color', $this->Calendars->getColor($calendar));
return $entity;
}
|
php
|
public function prepareRecurringEventData(array $event = [], array $interval = [], EntityInterface $calendar = null): ?EntityInterface
{
$entity = null;
if (empty($event)) {
return $entity;
}
$entity = $this->newEntity();
$entity = $this->patchEntity($entity, $event);
$entity->set('start_date', $interval['start']);
$entity->set('end_date', $interval['end']);
$entity->set('start', $entity->get('start_date')->i18nFormat('yyyy-MM-dd HH:mm:ss'));
$entity->set('end', $entity->get('end_date')->i18nFormat('yyyy-MM-dd HH:mm:ss'));
$entity->set('id', $event['id']);
$entity->set('id', $this->setRecurrenceEventId($entity));
$entity->set('color', $this->Calendars->getColor($calendar));
return $entity;
}
|
[
"public",
"function",
"prepareRecurringEventData",
"(",
"array",
"$",
"event",
"=",
"[",
"]",
",",
"array",
"$",
"interval",
"=",
"[",
"]",
",",
"EntityInterface",
"$",
"calendar",
"=",
"null",
")",
":",
"?",
"EntityInterface",
"{",
"$",
"entity",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"event",
")",
")",
"{",
"return",
"$",
"entity",
";",
"}",
"$",
"entity",
"=",
"$",
"this",
"->",
"newEntity",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"patchEntity",
"(",
"$",
"entity",
",",
"$",
"event",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"'start_date'",
",",
"$",
"interval",
"[",
"'start'",
"]",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"'end_date'",
",",
"$",
"interval",
"[",
"'end'",
"]",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"'start'",
",",
"$",
"entity",
"->",
"get",
"(",
"'start_date'",
")",
"->",
"i18nFormat",
"(",
"'yyyy-MM-dd HH:mm:ss'",
")",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"'end'",
",",
"$",
"entity",
"->",
"get",
"(",
"'end_date'",
")",
"->",
"i18nFormat",
"(",
"'yyyy-MM-dd HH:mm:ss'",
")",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"'id'",
",",
"$",
"event",
"[",
"'id'",
"]",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"'id'",
",",
"$",
"this",
"->",
"setRecurrenceEventId",
"(",
"$",
"entity",
")",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"'color'",
",",
"$",
"this",
"->",
"Calendars",
"->",
"getColor",
"(",
"$",
"calendar",
")",
")",
";",
"return",
"$",
"entity",
";",
"}"
] |
Prepare Recurring Event Data
Substitute original dates with recurring dates
@param mixed[] $event of the original instance
@param mixed[] $interval pair with start/end dates to be used
@param \Cake\Datasource\EntityInterface $calendar instance
@return \Cake\Datasource\EntityInterface|null $entity of the recurring event
|
[
"Prepare",
"Recurring",
"Event",
"Data"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L528-L549
|
223,681
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.setEventTitle
|
public function setEventTitle(array $data, EntityInterface $calendar): string
{
$title = (!empty($data['CalendarEvents']['title']) ? $data['CalendarEvents']['title'] : '');
if (empty($title)) {
$title .= !empty($calendar->name) ? $calendar->name : '';
if (!empty($data['CalendarEvents']['event_type'])) {
$title .= ' - ' . Inflector::humanize($data['CalendarEvents']['event_type']);
} else {
$title .= ' Event';
}
}
return $title;
}
|
php
|
public function setEventTitle(array $data, EntityInterface $calendar): string
{
$title = (!empty($data['CalendarEvents']['title']) ? $data['CalendarEvents']['title'] : '');
if (empty($title)) {
$title .= !empty($calendar->name) ? $calendar->name : '';
if (!empty($data['CalendarEvents']['event_type'])) {
$title .= ' - ' . Inflector::humanize($data['CalendarEvents']['event_type']);
} else {
$title .= ' Event';
}
}
return $title;
}
|
[
"public",
"function",
"setEventTitle",
"(",
"array",
"$",
"data",
",",
"EntityInterface",
"$",
"calendar",
")",
":",
"string",
"{",
"$",
"title",
"=",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'CalendarEvents'",
"]",
"[",
"'title'",
"]",
")",
"?",
"$",
"data",
"[",
"'CalendarEvents'",
"]",
"[",
"'title'",
"]",
":",
"''",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"title",
")",
")",
"{",
"$",
"title",
".=",
"!",
"empty",
"(",
"$",
"calendar",
"->",
"name",
")",
"?",
"$",
"calendar",
"->",
"name",
":",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'CalendarEvents'",
"]",
"[",
"'event_type'",
"]",
")",
")",
"{",
"$",
"title",
".=",
"' - '",
".",
"Inflector",
"::",
"humanize",
"(",
"$",
"data",
"[",
"'CalendarEvents'",
"]",
"[",
"'event_type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"title",
".=",
"' Event'",
";",
"}",
"}",
"return",
"$",
"title",
";",
"}"
] |
Set Event Title
@param mixed[] $data from the request
@param \Cake\Datasource\EntityInterface $calendar from db
@return string $title with the event content
|
[
"Set",
"Event",
"Title"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L648-L663
|
223,682
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getEventTitle
|
public function getEventTitle(array $event = []): string
{
$extra = [];
if (!empty($event['calendar_attendees'])) {
foreach ($event['calendar_attendees'] as $att) {
if ($att instanceof EntityInterface) {
array_push($extra, $att->get('display_name'));
}
}
}
if (!empty($extra)) {
$event['title'] .= ' - ' . implode("\n", $extra);
}
return $event['title'];
}
|
php
|
public function getEventTitle(array $event = []): string
{
$extra = [];
if (!empty($event['calendar_attendees'])) {
foreach ($event['calendar_attendees'] as $att) {
if ($att instanceof EntityInterface) {
array_push($extra, $att->get('display_name'));
}
}
}
if (!empty($extra)) {
$event['title'] .= ' - ' . implode("\n", $extra);
}
return $event['title'];
}
|
[
"public",
"function",
"getEventTitle",
"(",
"array",
"$",
"event",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"extra",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"event",
"[",
"'calendar_attendees'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"event",
"[",
"'calendar_attendees'",
"]",
"as",
"$",
"att",
")",
"{",
"if",
"(",
"$",
"att",
"instanceof",
"EntityInterface",
")",
"{",
"array_push",
"(",
"$",
"extra",
",",
"$",
"att",
"->",
"get",
"(",
"'display_name'",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"extra",
")",
")",
"{",
"$",
"event",
"[",
"'title'",
"]",
".=",
"' - '",
".",
"implode",
"(",
"\"\\n\"",
",",
"$",
"extra",
")",
";",
"}",
"return",
"$",
"event",
"[",
"'title'",
"]",
";",
"}"
] |
Get Event Title based on the Event information
@param mixed[] $event of the calendar event instance
@return string $event[title] with new title if extras present
|
[
"Get",
"Event",
"Title",
"based",
"on",
"the",
"Event",
"information"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L672-L689
|
223,683
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.sync
|
public function sync(EntityInterface $calendar, array $options = []): array
{
$result = [];
if (empty($calendar)) {
return $result;
}
$event = new Event((string)EventName::PLUGIN_CALENDAR_MODEL_GET_EVENTS(), $this, [
'calendar' => $calendar,
'options' => $options,
]);
EventManager::instance()->dispatch($event);
$calendarEvents = $event->result;
if (empty($calendarEvents)) {
return $result;
}
foreach ($calendarEvents as $calendarInfo) {
if (empty($calendarInfo['events'])) {
continue;
}
}
return $result;
}
|
php
|
public function sync(EntityInterface $calendar, array $options = []): array
{
$result = [];
if (empty($calendar)) {
return $result;
}
$event = new Event((string)EventName::PLUGIN_CALENDAR_MODEL_GET_EVENTS(), $this, [
'calendar' => $calendar,
'options' => $options,
]);
EventManager::instance()->dispatch($event);
$calendarEvents = $event->result;
if (empty($calendarEvents)) {
return $result;
}
foreach ($calendarEvents as $calendarInfo) {
if (empty($calendarInfo['events'])) {
continue;
}
}
return $result;
}
|
[
"public",
"function",
"sync",
"(",
"EntityInterface",
"$",
"calendar",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"calendar",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"event",
"=",
"new",
"Event",
"(",
"(",
"string",
")",
"EventName",
"::",
"PLUGIN_CALENDAR_MODEL_GET_EVENTS",
"(",
")",
",",
"$",
"this",
",",
"[",
"'calendar'",
"=>",
"$",
"calendar",
",",
"'options'",
"=>",
"$",
"options",
",",
"]",
")",
";",
"EventManager",
"::",
"instance",
"(",
")",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"$",
"calendarEvents",
"=",
"$",
"event",
"->",
"result",
";",
"if",
"(",
"empty",
"(",
"$",
"calendarEvents",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"foreach",
"(",
"$",
"calendarEvents",
"as",
"$",
"calendarInfo",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"calendarInfo",
"[",
"'events'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Synchronize calendar events
@param \Cake\Datasource\EntityInterface $calendar instance from the db
@param mixed[] $options with extra configs
@return mixed[] $result with events responses.
|
[
"Synchronize",
"calendar",
"events"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L699-L726
|
223,684
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.saveEvent
|
public function saveEvent(EntityInterface $entity): array
{
$response = [
'status' => false,
'errors' => [],
'entity' => null,
];
if ($entity instanceof EntityInterface) {
$entity = $entity->toArray();
}
if (empty($entity['id'])) {
unset($entity['id']);
}
$query = $this->find()
->where([
//'source' => empty($entity['source']) ? null : $entity['source'],
'source_id' => $entity['source_id'],
'calendar_id' => $entity['calendar_id'],
]);
$query->execute();
/** @var EntityInterface $event */
$event = (!$query->count()) ? $this->newEntity() : $query->first();
$event = $this->patchEntity($event, $entity);
$saved = $this->save($event);
if ($saved) {
$response['status'] = true;
$response['entity'] = $saved;
} else {
$response['errors'] = $event->getErrors();
}
return $response;
}
|
php
|
public function saveEvent(EntityInterface $entity): array
{
$response = [
'status' => false,
'errors' => [],
'entity' => null,
];
if ($entity instanceof EntityInterface) {
$entity = $entity->toArray();
}
if (empty($entity['id'])) {
unset($entity['id']);
}
$query = $this->find()
->where([
//'source' => empty($entity['source']) ? null : $entity['source'],
'source_id' => $entity['source_id'],
'calendar_id' => $entity['calendar_id'],
]);
$query->execute();
/** @var EntityInterface $event */
$event = (!$query->count()) ? $this->newEntity() : $query->first();
$event = $this->patchEntity($event, $entity);
$saved = $this->save($event);
if ($saved) {
$response['status'] = true;
$response['entity'] = $saved;
} else {
$response['errors'] = $event->getErrors();
}
return $response;
}
|
[
"public",
"function",
"saveEvent",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"array",
"{",
"$",
"response",
"=",
"[",
"'status'",
"=>",
"false",
",",
"'errors'",
"=>",
"[",
"]",
",",
"'entity'",
"=>",
"null",
",",
"]",
";",
"if",
"(",
"$",
"entity",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"entity",
"=",
"$",
"entity",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"entity",
"[",
"'id'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"entity",
"[",
"'id'",
"]",
")",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"//'source' => empty($entity['source']) ? null : $entity['source'],",
"'source_id'",
"=>",
"$",
"entity",
"[",
"'source_id'",
"]",
",",
"'calendar_id'",
"=>",
"$",
"entity",
"[",
"'calendar_id'",
"]",
",",
"]",
")",
";",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"/** @var EntityInterface $event */",
"$",
"event",
"=",
"(",
"!",
"$",
"query",
"->",
"count",
"(",
")",
")",
"?",
"$",
"this",
"->",
"newEntity",
"(",
")",
":",
"$",
"query",
"->",
"first",
"(",
")",
";",
"$",
"event",
"=",
"$",
"this",
"->",
"patchEntity",
"(",
"$",
"event",
",",
"$",
"entity",
")",
";",
"$",
"saved",
"=",
"$",
"this",
"->",
"save",
"(",
"$",
"event",
")",
";",
"if",
"(",
"$",
"saved",
")",
"{",
"$",
"response",
"[",
"'status'",
"]",
"=",
"true",
";",
"$",
"response",
"[",
"'entity'",
"]",
"=",
"$",
"saved",
";",
"}",
"else",
"{",
"$",
"response",
"[",
"'errors'",
"]",
"=",
"$",
"event",
"->",
"getErrors",
"(",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Save Calendar Event wrapper
@param \Cake\Datasource\EntityInterface $entity of generic entity object
@return mixed[] $response containing saving state of entity.
|
[
"Save",
"Calendar",
"Event",
"wrapper"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L734-L773
|
223,685
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.getEventsFromEntities
|
public function getEventsFromEntities(Table $table, array $calendars, ArrayObject $options): array
{
$entities = [];
if (empty($calendars)) {
return $entities;
}
$map = ObjectFactory::getConfig($table->alias(), 'Event', $options['event_type']);
foreach ($calendars as $calendar) {
$options = array_merge($options->getArrayCopy(), ['calendar' => $calendar]);
$options = new ArrayObject($options);
$entity = $options['entity'];
// The following is a temporary solution until the ObjectTrait is being used
if (!method_exists($table, 'getObjectInstance')) {
continue;
}
$eventObject = $table->getObjectInstance($entity, $map, $options);
$calendarEntity = $eventObject->toEntity();
if (!$calendarEntity) {
continue;
}
$entities[] = $calendarEntity;
}
return $entities;
}
|
php
|
public function getEventsFromEntities(Table $table, array $calendars, ArrayObject $options): array
{
$entities = [];
if (empty($calendars)) {
return $entities;
}
$map = ObjectFactory::getConfig($table->alias(), 'Event', $options['event_type']);
foreach ($calendars as $calendar) {
$options = array_merge($options->getArrayCopy(), ['calendar' => $calendar]);
$options = new ArrayObject($options);
$entity = $options['entity'];
// The following is a temporary solution until the ObjectTrait is being used
if (!method_exists($table, 'getObjectInstance')) {
continue;
}
$eventObject = $table->getObjectInstance($entity, $map, $options);
$calendarEntity = $eventObject->toEntity();
if (!$calendarEntity) {
continue;
}
$entities[] = $calendarEntity;
}
return $entities;
}
|
[
"public",
"function",
"getEventsFromEntities",
"(",
"Table",
"$",
"table",
",",
"array",
"$",
"calendars",
",",
"ArrayObject",
"$",
"options",
")",
":",
"array",
"{",
"$",
"entities",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"calendars",
")",
")",
"{",
"return",
"$",
"entities",
";",
"}",
"$",
"map",
"=",
"ObjectFactory",
"::",
"getConfig",
"(",
"$",
"table",
"->",
"alias",
"(",
")",
",",
"'Event'",
",",
"$",
"options",
"[",
"'event_type'",
"]",
")",
";",
"foreach",
"(",
"$",
"calendars",
"as",
"$",
"calendar",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"options",
"->",
"getArrayCopy",
"(",
")",
",",
"[",
"'calendar'",
"=>",
"$",
"calendar",
"]",
")",
";",
"$",
"options",
"=",
"new",
"ArrayObject",
"(",
"$",
"options",
")",
";",
"$",
"entity",
"=",
"$",
"options",
"[",
"'entity'",
"]",
";",
"// The following is a temporary solution until the ObjectTrait is being used",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"table",
",",
"'getObjectInstance'",
")",
")",
"{",
"continue",
";",
"}",
"$",
"eventObject",
"=",
"$",
"table",
"->",
"getObjectInstance",
"(",
"$",
"entity",
",",
"$",
"map",
",",
"$",
"options",
")",
";",
"$",
"calendarEntity",
"=",
"$",
"eventObject",
"->",
"toEntity",
"(",
")",
";",
"if",
"(",
"!",
"$",
"calendarEntity",
")",
"{",
"continue",
";",
"}",
"$",
"entities",
"[",
"]",
"=",
"$",
"calendarEntity",
";",
"}",
"return",
"$",
"entities",
";",
"}"
] |
Convert incoming ORM Entities to CalendarEvent entities
We create multiple entities for each calendar to avoid accidential
crossing of instances.
@param \Cake\ORM\Table $table instance of original entity table
@param mixed[] $calendars that it might be saved to
@param \ArrayObject $options originally received from event caught
@return mixed[] $entities of converted CalendarEvent entitites.
|
[
"Convert",
"incoming",
"ORM",
"Entities",
"to",
"CalendarEvent",
"entities"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L787-L817
|
223,686
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarEventsTable.php
|
CalendarEventsTable.setCalendarEventData
|
public function setCalendarEventData(array $data = [], ?EntityInterface $calendar = null): array
{
$result = [
'CalendarEvents' => [],
];
$result['CalendarEvents'] = $data;
if (!empty($data['recurrence'])) {
$recurrence = $this->setRRuleConfiguration($data['recurrence']);
$result['CalendarEvents']['is_recurring'] = true;
$result['CalendarEvents']['recurrence'] = $recurrence;
}
if (!empty($data['attendees_ids'])) {
$result['calendar_attendees']['_ids'] = $data['attendees_ids'];
unset($result['CalendarEvents']['attendees_ids']);
}
if (empty($data['title']) && $calendar instanceof EntityInterface) {
$result['CalendarEvents']['title'] = $this->setEventTitle($data, $calendar);
}
return $result;
}
|
php
|
public function setCalendarEventData(array $data = [], ?EntityInterface $calendar = null): array
{
$result = [
'CalendarEvents' => [],
];
$result['CalendarEvents'] = $data;
if (!empty($data['recurrence'])) {
$recurrence = $this->setRRuleConfiguration($data['recurrence']);
$result['CalendarEvents']['is_recurring'] = true;
$result['CalendarEvents']['recurrence'] = $recurrence;
}
if (!empty($data['attendees_ids'])) {
$result['calendar_attendees']['_ids'] = $data['attendees_ids'];
unset($result['CalendarEvents']['attendees_ids']);
}
if (empty($data['title']) && $calendar instanceof EntityInterface) {
$result['CalendarEvents']['title'] = $this->setEventTitle($data, $calendar);
}
return $result;
}
|
[
"public",
"function",
"setCalendarEventData",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"?",
"EntityInterface",
"$",
"calendar",
"=",
"null",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"'CalendarEvents'",
"=>",
"[",
"]",
",",
"]",
";",
"$",
"result",
"[",
"'CalendarEvents'",
"]",
"=",
"$",
"data",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'recurrence'",
"]",
")",
")",
"{",
"$",
"recurrence",
"=",
"$",
"this",
"->",
"setRRuleConfiguration",
"(",
"$",
"data",
"[",
"'recurrence'",
"]",
")",
";",
"$",
"result",
"[",
"'CalendarEvents'",
"]",
"[",
"'is_recurring'",
"]",
"=",
"true",
";",
"$",
"result",
"[",
"'CalendarEvents'",
"]",
"[",
"'recurrence'",
"]",
"=",
"$",
"recurrence",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'attendees_ids'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"'calendar_attendees'",
"]",
"[",
"'_ids'",
"]",
"=",
"$",
"data",
"[",
"'attendees_ids'",
"]",
";",
"unset",
"(",
"$",
"result",
"[",
"'CalendarEvents'",
"]",
"[",
"'attendees_ids'",
"]",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'title'",
"]",
")",
"&&",
"$",
"calendar",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"result",
"[",
"'CalendarEvents'",
"]",
"[",
"'title'",
"]",
"=",
"$",
"this",
"->",
"setEventTitle",
"(",
"$",
"data",
",",
"$",
"calendar",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Set Calendar Event Post data
@param mixed[] $data from the POST
@param \Cake\Datasource\EntityInterface $calendar record
@return mixed[] $result to be saved in ORM
|
[
"Set",
"Calendar",
"Event",
"Post",
"data"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarEventsTable.php#L874-L897
|
223,687
|
ongr-io/FilterManagerBundle
|
Filter/Widget/Choice/SingleTermChoice.php
|
SingleTermChoice.addPriorityChoices
|
protected function addPriorityChoices(array $unsortedChoices, ChoicesAwareViewData $data)
{
foreach ($this->getSortPriority() as $name) {
if (array_key_exists($name, $unsortedChoices)) {
$data->addChoice($unsortedChoices[$name]);
unset($unsortedChoices[$name]);
}
}
return $unsortedChoices;
}
|
php
|
protected function addPriorityChoices(array $unsortedChoices, ChoicesAwareViewData $data)
{
foreach ($this->getSortPriority() as $name) {
if (array_key_exists($name, $unsortedChoices)) {
$data->addChoice($unsortedChoices[$name]);
unset($unsortedChoices[$name]);
}
}
return $unsortedChoices;
}
|
[
"protected",
"function",
"addPriorityChoices",
"(",
"array",
"$",
"unsortedChoices",
",",
"ChoicesAwareViewData",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSortPriority",
"(",
")",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"unsortedChoices",
")",
")",
"{",
"$",
"data",
"->",
"addChoice",
"(",
"$",
"unsortedChoices",
"[",
"$",
"name",
"]",
")",
";",
"unset",
"(",
"$",
"unsortedChoices",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"return",
"$",
"unsortedChoices",
";",
"}"
] |
Adds prioritized choices.
@param array $unsortedChoices
@param ChoicesAwareViewData $data
@return array
|
[
"Adds",
"prioritized",
"choices",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Filter/Widget/Choice/SingleTermChoice.php#L155-L165
|
223,688
|
puli/manager
|
src/Api/Installer/Validation/InstallerParameterValidator.php
|
InstallerParameterValidator.validate
|
public function validate(array $parameterValues, InstallerDescriptor $descriptor)
{
$violations = array();
foreach ($parameterValues as $name => $value) {
if (!$descriptor->hasParameter($name)) {
$violations[] = new ConstraintViolation(
ConstraintViolation::NO_SUCH_PARAMETER,
$value,
$descriptor->getName(),
$name
);
}
}
foreach ($descriptor->getParameters() as $parameter) {
if (!isset($parameterValues[$parameter->getName()])) {
if ($parameter->isRequired()) {
$violations[] = new ConstraintViolation(
ConstraintViolation::MISSING_PARAMETER,
$parameterValues,
$descriptor->getName(),
$parameter->getName()
);
}
}
}
return $violations;
}
|
php
|
public function validate(array $parameterValues, InstallerDescriptor $descriptor)
{
$violations = array();
foreach ($parameterValues as $name => $value) {
if (!$descriptor->hasParameter($name)) {
$violations[] = new ConstraintViolation(
ConstraintViolation::NO_SUCH_PARAMETER,
$value,
$descriptor->getName(),
$name
);
}
}
foreach ($descriptor->getParameters() as $parameter) {
if (!isset($parameterValues[$parameter->getName()])) {
if ($parameter->isRequired()) {
$violations[] = new ConstraintViolation(
ConstraintViolation::MISSING_PARAMETER,
$parameterValues,
$descriptor->getName(),
$parameter->getName()
);
}
}
}
return $violations;
}
|
[
"public",
"function",
"validate",
"(",
"array",
"$",
"parameterValues",
",",
"InstallerDescriptor",
"$",
"descriptor",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parameterValues",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"descriptor",
"->",
"hasParameter",
"(",
"$",
"name",
")",
")",
"{",
"$",
"violations",
"[",
"]",
"=",
"new",
"ConstraintViolation",
"(",
"ConstraintViolation",
"::",
"NO_SUCH_PARAMETER",
",",
"$",
"value",
",",
"$",
"descriptor",
"->",
"getName",
"(",
")",
",",
"$",
"name",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"descriptor",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameterValues",
"[",
"$",
"parameter",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"if",
"(",
"$",
"parameter",
"->",
"isRequired",
"(",
")",
")",
"{",
"$",
"violations",
"[",
"]",
"=",
"new",
"ConstraintViolation",
"(",
"ConstraintViolation",
"::",
"MISSING_PARAMETER",
",",
"$",
"parameterValues",
",",
"$",
"descriptor",
"->",
"getName",
"(",
")",
",",
"$",
"parameter",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"violations",
";",
"}"
] |
Returns whether the given parameter values are valid.
@param array $parameterValues The parameter values to
validate.
@param InstallerDescriptor $descriptor The installer descriptor to
validate the values for.
@return ConstraintViolation[] The found violations. If no violations were
found, an empty array is returned.
|
[
"Returns",
"whether",
"the",
"given",
"parameter",
"values",
"are",
"valid",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installer/Validation/InstallerParameterValidator.php#L36-L65
|
223,689
|
puli/manager
|
src/Api/Discovery/BindingDescriptor.php
|
BindingDescriptor.load
|
public function load(Module $containingModule, BindingTypeDescriptor $typeDescriptor = null)
{
if (null !== $this->state) {
throw new AlreadyLoadedException('The binding descriptor is already loaded.');
}
$this->loadErrors = array();
if ($typeDescriptor && $typeDescriptor->isLoaded() && $typeDescriptor->isEnabled()) {
try {
$this->binding->initialize($typeDescriptor->getType());
} catch (Exception $e) {
$this->loadErrors[] = $e;
}
}
$this->containingModule = $containingModule;
$this->typeDescriptor = $typeDescriptor;
$this->refreshState();
}
|
php
|
public function load(Module $containingModule, BindingTypeDescriptor $typeDescriptor = null)
{
if (null !== $this->state) {
throw new AlreadyLoadedException('The binding descriptor is already loaded.');
}
$this->loadErrors = array();
if ($typeDescriptor && $typeDescriptor->isLoaded() && $typeDescriptor->isEnabled()) {
try {
$this->binding->initialize($typeDescriptor->getType());
} catch (Exception $e) {
$this->loadErrors[] = $e;
}
}
$this->containingModule = $containingModule;
$this->typeDescriptor = $typeDescriptor;
$this->refreshState();
}
|
[
"public",
"function",
"load",
"(",
"Module",
"$",
"containingModule",
",",
"BindingTypeDescriptor",
"$",
"typeDescriptor",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"AlreadyLoadedException",
"(",
"'The binding descriptor is already loaded.'",
")",
";",
"}",
"$",
"this",
"->",
"loadErrors",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"typeDescriptor",
"&&",
"$",
"typeDescriptor",
"->",
"isLoaded",
"(",
")",
"&&",
"$",
"typeDescriptor",
"->",
"isEnabled",
"(",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"binding",
"->",
"initialize",
"(",
"$",
"typeDescriptor",
"->",
"getType",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"loadErrors",
"[",
"]",
"=",
"$",
"e",
";",
"}",
"}",
"$",
"this",
"->",
"containingModule",
"=",
"$",
"containingModule",
";",
"$",
"this",
"->",
"typeDescriptor",
"=",
"$",
"typeDescriptor",
";",
"$",
"this",
"->",
"refreshState",
"(",
")",
";",
"}"
] |
Loads the binding descriptor.
@param Module $containingModule The module that
contains the
descriptor.
@param BindingTypeDescriptor|null $typeDescriptor The type descriptor.
@throws AlreadyLoadedException If the descriptor is already loaded.
|
[
"Loads",
"the",
"binding",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/BindingDescriptor.php#L82-L102
|
223,690
|
puli/manager
|
src/Api/Discovery/BindingDescriptor.php
|
BindingDescriptor.unload
|
public function unload()
{
if (null === $this->state) {
throw new NotLoadedException('The binding descriptor is not loaded.');
}
$this->containingModule = null;
$this->typeDescriptor = null;
$this->loadErrors = array();
$this->state = null;
}
|
php
|
public function unload()
{
if (null === $this->state) {
throw new NotLoadedException('The binding descriptor is not loaded.');
}
$this->containingModule = null;
$this->typeDescriptor = null;
$this->loadErrors = array();
$this->state = null;
}
|
[
"public",
"function",
"unload",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The binding descriptor is not loaded.'",
")",
";",
"}",
"$",
"this",
"->",
"containingModule",
"=",
"null",
";",
"$",
"this",
"->",
"typeDescriptor",
"=",
"null",
";",
"$",
"this",
"->",
"loadErrors",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"state",
"=",
"null",
";",
"}"
] |
Unloads the binding descriptor.
All memory allocated during {@link load()} is freed.
@throws NotLoadedException If the descriptor is not loaded.
|
[
"Unloads",
"the",
"binding",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/BindingDescriptor.php#L111-L121
|
223,691
|
puli/manager
|
src/Api/Php/Method.php
|
Method.getArgument
|
public function getArgument($name)
{
if (!isset($this->arguments[$name])) {
throw new OutOfBoundsException(sprintf(
'The argument "%s" does not exist.',
$name
));
}
return $this->arguments[$name];
}
|
php
|
public function getArgument($name)
{
if (!isset($this->arguments[$name])) {
throw new OutOfBoundsException(sprintf(
'The argument "%s" does not exist.',
$name
));
}
return $this->arguments[$name];
}
|
[
"public",
"function",
"getArgument",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The argument \"%s\" does not exist.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"arguments",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns the argument with the given name.
@param string $name The argument name.
@return Argument The argument.
@throws OutOfBoundsException If the argument does not exist.
|
[
"Returns",
"the",
"argument",
"with",
"the",
"given",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Method.php#L147-L157
|
223,692
|
puli/manager
|
src/Api/Php/Method.php
|
Method.addBody
|
public function addBody($body)
{
Assert::stringNotEmpty($body, 'The method body must be a non-empty string. Got: %s');
if ($this->body) {
$this->body .= "\n".$body;
} else {
$this->body = $body;
}
return $this;
}
|
php
|
public function addBody($body)
{
Assert::stringNotEmpty($body, 'The method body must be a non-empty string. Got: %s');
if ($this->body) {
$this->body .= "\n".$body;
} else {
$this->body = $body;
}
return $this;
}
|
[
"public",
"function",
"addBody",
"(",
"$",
"body",
")",
"{",
"Assert",
"::",
"stringNotEmpty",
"(",
"$",
"body",
",",
"'The method body must be a non-empty string. Got: %s'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"body",
")",
"{",
"$",
"this",
"->",
"body",
".=",
"\"\\n\"",
".",
"$",
"body",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"body",
"=",
"$",
"body",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds source code to the method body.
A newline is inserted between the current code and the added code.
@param string $body The source code to add.
@return static The current instance.
|
[
"Adds",
"source",
"code",
"to",
"the",
"method",
"body",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Method.php#L346-L357
|
223,693
|
ongr-io/FilterManagerBundle
|
Search/FilterManager.php
|
FilterManager.search
|
public function search(SearchRequest $request)
{
$this->eventDispatcher->dispatch(ONGRFilterManagerEvents::PRE_SEARCH, new PreSearchEvent($request));
$search = $this->container->buildSearch($request);
/** @var FilterInterface $filter */
foreach ($this->container->all() as $name => $filter) {
$relatedSearch = new Search();
if ($filter->isRelated()) {
// We simply exclude not related filters and current filter itself.
$relatedFilters = $this->container->getFiltersByRelation(
new AndRelation([$filter->getSearchRelation(), new ExcludeRelation([$name])])
);
$relatedSearch = $this->container->buildSearch($request, $relatedFilters);
}
$this->eventDispatcher->dispatch(
ONGRFilterManagerEvents::PRE_PROCESS_SEARCH,
new PreProcessSearchEvent($request->get($name), $relatedSearch)
);
$filter->preProcessSearch(
$search,
$relatedSearch,
$request->get($name)
);
}
$result = $this->repository->findDocuments($search);
$this->eventDispatcher->dispatch(ONGRFilterManagerEvents::SEARCH_RESPONSE, new SearchResponseEvent($result));
return new SearchResponse(
$this->getFiltersViewData($result, $request),
$result,
$this->composeUrlParameters($request),
$this->serializer
);
}
|
php
|
public function search(SearchRequest $request)
{
$this->eventDispatcher->dispatch(ONGRFilterManagerEvents::PRE_SEARCH, new PreSearchEvent($request));
$search = $this->container->buildSearch($request);
/** @var FilterInterface $filter */
foreach ($this->container->all() as $name => $filter) {
$relatedSearch = new Search();
if ($filter->isRelated()) {
// We simply exclude not related filters and current filter itself.
$relatedFilters = $this->container->getFiltersByRelation(
new AndRelation([$filter->getSearchRelation(), new ExcludeRelation([$name])])
);
$relatedSearch = $this->container->buildSearch($request, $relatedFilters);
}
$this->eventDispatcher->dispatch(
ONGRFilterManagerEvents::PRE_PROCESS_SEARCH,
new PreProcessSearchEvent($request->get($name), $relatedSearch)
);
$filter->preProcessSearch(
$search,
$relatedSearch,
$request->get($name)
);
}
$result = $this->repository->findDocuments($search);
$this->eventDispatcher->dispatch(ONGRFilterManagerEvents::SEARCH_RESPONSE, new SearchResponseEvent($result));
return new SearchResponse(
$this->getFiltersViewData($result, $request),
$result,
$this->composeUrlParameters($request),
$this->serializer
);
}
|
[
"public",
"function",
"search",
"(",
"SearchRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"ONGRFilterManagerEvents",
"::",
"PRE_SEARCH",
",",
"new",
"PreSearchEvent",
"(",
"$",
"request",
")",
")",
";",
"$",
"search",
"=",
"$",
"this",
"->",
"container",
"->",
"buildSearch",
"(",
"$",
"request",
")",
";",
"/** @var FilterInterface $filter */",
"foreach",
"(",
"$",
"this",
"->",
"container",
"->",
"all",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"filter",
")",
"{",
"$",
"relatedSearch",
"=",
"new",
"Search",
"(",
")",
";",
"if",
"(",
"$",
"filter",
"->",
"isRelated",
"(",
")",
")",
"{",
"// We simply exclude not related filters and current filter itself.",
"$",
"relatedFilters",
"=",
"$",
"this",
"->",
"container",
"->",
"getFiltersByRelation",
"(",
"new",
"AndRelation",
"(",
"[",
"$",
"filter",
"->",
"getSearchRelation",
"(",
")",
",",
"new",
"ExcludeRelation",
"(",
"[",
"$",
"name",
"]",
")",
"]",
")",
")",
";",
"$",
"relatedSearch",
"=",
"$",
"this",
"->",
"container",
"->",
"buildSearch",
"(",
"$",
"request",
",",
"$",
"relatedFilters",
")",
";",
"}",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"ONGRFilterManagerEvents",
"::",
"PRE_PROCESS_SEARCH",
",",
"new",
"PreProcessSearchEvent",
"(",
"$",
"request",
"->",
"get",
"(",
"$",
"name",
")",
",",
"$",
"relatedSearch",
")",
")",
";",
"$",
"filter",
"->",
"preProcessSearch",
"(",
"$",
"search",
",",
"$",
"relatedSearch",
",",
"$",
"request",
"->",
"get",
"(",
"$",
"name",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"repository",
"->",
"findDocuments",
"(",
"$",
"search",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"ONGRFilterManagerEvents",
"::",
"SEARCH_RESPONSE",
",",
"new",
"SearchResponseEvent",
"(",
"$",
"result",
")",
")",
";",
"return",
"new",
"SearchResponse",
"(",
"$",
"this",
"->",
"getFiltersViewData",
"(",
"$",
"result",
",",
"$",
"request",
")",
",",
"$",
"result",
",",
"$",
"this",
"->",
"composeUrlParameters",
"(",
"$",
"request",
")",
",",
"$",
"this",
"->",
"serializer",
")",
";",
"}"
] |
Executes search.
@param SearchRequest $request
@return SearchResponse
|
[
"Executes",
"search",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Search/FilterManager.php#L90-L129
|
223,694
|
ongr-io/FilterManagerBundle
|
Search/FilterManager.php
|
FilterManager.composeUrlParameters
|
protected function composeUrlParameters(SearchRequest $request, FilterInterface $filter = null, $exclude = [])
{
$out = [];
$and = [];
if ($filter) {
$and[] = $filter->getResetRelation();
}
if (!empty($exclude)) {
$and[] = new ExcludeRelation($exclude);
}
/** @var FilterState[] $states */
$states = new FilterIterator(new \IteratorIterator($request), new AndRelation($and));
foreach ($states as $state) {
$out = array_merge($out, $state->getUrlParameters());
}
return $out;
}
|
php
|
protected function composeUrlParameters(SearchRequest $request, FilterInterface $filter = null, $exclude = [])
{
$out = [];
$and = [];
if ($filter) {
$and[] = $filter->getResetRelation();
}
if (!empty($exclude)) {
$and[] = new ExcludeRelation($exclude);
}
/** @var FilterState[] $states */
$states = new FilterIterator(new \IteratorIterator($request), new AndRelation($and));
foreach ($states as $state) {
$out = array_merge($out, $state->getUrlParameters());
}
return $out;
}
|
[
"protected",
"function",
"composeUrlParameters",
"(",
"SearchRequest",
"$",
"request",
",",
"FilterInterface",
"$",
"filter",
"=",
"null",
",",
"$",
"exclude",
"=",
"[",
"]",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"$",
"and",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"filter",
")",
"{",
"$",
"and",
"[",
"]",
"=",
"$",
"filter",
"->",
"getResetRelation",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"exclude",
")",
")",
"{",
"$",
"and",
"[",
"]",
"=",
"new",
"ExcludeRelation",
"(",
"$",
"exclude",
")",
";",
"}",
"/** @var FilterState[] $states */",
"$",
"states",
"=",
"new",
"FilterIterator",
"(",
"new",
"\\",
"IteratorIterator",
"(",
"$",
"request",
")",
",",
"new",
"AndRelation",
"(",
"$",
"and",
")",
")",
";",
"foreach",
"(",
"$",
"states",
"as",
"$",
"state",
")",
"{",
"$",
"out",
"=",
"array_merge",
"(",
"$",
"out",
",",
"$",
"state",
"->",
"getUrlParameters",
"(",
")",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Composes url parameters related to given filter.
@param SearchRequest $request Search request.
@param FilterInterface $filter Filter.
@param array $exclude Additional names of filters to exclude.
@return array
|
[
"Composes",
"url",
"parameters",
"related",
"to",
"given",
"filter",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Search/FilterManager.php#L140-L162
|
223,695
|
ongr-io/FilterManagerBundle
|
Search/FilterManager.php
|
FilterManager.getFiltersViewData
|
protected function getFiltersViewData(DocumentIterator $result, SearchRequest $request)
{
$out = [];
/** @var FilterInterface[] $filters */
$filters = $this->container->all();
foreach ($filters as $name => $filter) {
if ($filter instanceof ViewDataFactoryInterface) {
$viewData = $filter->createViewData();
} else {
$viewData = new ViewData();
}
$viewData->setName($name);
$viewData->setUrlParameters($this->composeUrlParameters($request, $filter));
$viewData->setState($request->get($name));
$viewData->setTags($filter->getTags());
$viewData->setResetUrlParameters($this->composeUrlParameters($request, $filter, [$name]));
$out[$name] = $filter->getViewData($result, $viewData);
}
return $out;
}
|
php
|
protected function getFiltersViewData(DocumentIterator $result, SearchRequest $request)
{
$out = [];
/** @var FilterInterface[] $filters */
$filters = $this->container->all();
foreach ($filters as $name => $filter) {
if ($filter instanceof ViewDataFactoryInterface) {
$viewData = $filter->createViewData();
} else {
$viewData = new ViewData();
}
$viewData->setName($name);
$viewData->setUrlParameters($this->composeUrlParameters($request, $filter));
$viewData->setState($request->get($name));
$viewData->setTags($filter->getTags());
$viewData->setResetUrlParameters($this->composeUrlParameters($request, $filter, [$name]));
$out[$name] = $filter->getViewData($result, $viewData);
}
return $out;
}
|
[
"protected",
"function",
"getFiltersViewData",
"(",
"DocumentIterator",
"$",
"result",
",",
"SearchRequest",
"$",
"request",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"/** @var FilterInterface[] $filters */",
"$",
"filters",
"=",
"$",
"this",
"->",
"container",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"name",
"=>",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"instanceof",
"ViewDataFactoryInterface",
")",
"{",
"$",
"viewData",
"=",
"$",
"filter",
"->",
"createViewData",
"(",
")",
";",
"}",
"else",
"{",
"$",
"viewData",
"=",
"new",
"ViewData",
"(",
")",
";",
"}",
"$",
"viewData",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"viewData",
"->",
"setUrlParameters",
"(",
"$",
"this",
"->",
"composeUrlParameters",
"(",
"$",
"request",
",",
"$",
"filter",
")",
")",
";",
"$",
"viewData",
"->",
"setState",
"(",
"$",
"request",
"->",
"get",
"(",
"$",
"name",
")",
")",
";",
"$",
"viewData",
"->",
"setTags",
"(",
"$",
"filter",
"->",
"getTags",
"(",
")",
")",
";",
"$",
"viewData",
"->",
"setResetUrlParameters",
"(",
"$",
"this",
"->",
"composeUrlParameters",
"(",
"$",
"request",
",",
"$",
"filter",
",",
"[",
"$",
"name",
"]",
")",
")",
";",
"$",
"out",
"[",
"$",
"name",
"]",
"=",
"$",
"filter",
"->",
"getViewData",
"(",
"$",
"result",
",",
"$",
"viewData",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] |
Creates view data for each filter.
@param DocumentIterator $result
@param SearchRequest $request
@return ViewData[]
|
[
"Creates",
"view",
"data",
"for",
"each",
"filter",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Search/FilterManager.php#L172-L194
|
223,696
|
puli/manager
|
src/Util/DistinguishedName.php
|
DistinguishedName.add
|
public function add($name, $value)
{
Assert::string($name, 'The attribute name must be a string. Got: %s');
Assert::notEmpty($name, 'The attribute name must not be empty.');
Assert::startsWithLetter($name, 'The attribute name %s must start with a letter.');
Assert::true((bool) preg_match('~^[a-zA-Z][a-zA-Z0-9\-]*$~', $name), sprintf(
'The attribute name must contain letters, numbers and hyphens only. Got: "%s"',
$name
));
Assert::string($value, 'The attribute value must be a string. Got: %s');
$this->attributes[$name] = $value;
}
|
php
|
public function add($name, $value)
{
Assert::string($name, 'The attribute name must be a string. Got: %s');
Assert::notEmpty($name, 'The attribute name must not be empty.');
Assert::startsWithLetter($name, 'The attribute name %s must start with a letter.');
Assert::true((bool) preg_match('~^[a-zA-Z][a-zA-Z0-9\-]*$~', $name), sprintf(
'The attribute name must contain letters, numbers and hyphens only. Got: "%s"',
$name
));
Assert::string($value, 'The attribute value must be a string. Got: %s');
$this->attributes[$name] = $value;
}
|
[
"public",
"function",
"add",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"Assert",
"::",
"string",
"(",
"$",
"name",
",",
"'The attribute name must be a string. Got: %s'",
")",
";",
"Assert",
"::",
"notEmpty",
"(",
"$",
"name",
",",
"'The attribute name must not be empty.'",
")",
";",
"Assert",
"::",
"startsWithLetter",
"(",
"$",
"name",
",",
"'The attribute name %s must start with a letter.'",
")",
";",
"Assert",
"::",
"true",
"(",
"(",
"bool",
")",
"preg_match",
"(",
"'~^[a-zA-Z][a-zA-Z0-9\\-]*$~'",
",",
"$",
"name",
")",
",",
"sprintf",
"(",
"'The attribute name must contain letters, numbers and hyphens only. Got: \"%s\"'",
",",
"$",
"name",
")",
")",
";",
"Assert",
"::",
"string",
"(",
"$",
"value",
",",
"'The attribute value must be a string. Got: %s'",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] |
Adds an attribute to the name.
@param string $name The attribute name. Must start with a letter and
contain letters, digits and hyphens only.
@param string $value The attribute value. Any non-empty string is
allowed.
@see merge()
|
[
"Adds",
"an",
"attribute",
"to",
"the",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/DistinguishedName.php#L54-L66
|
223,697
|
puli/manager
|
src/Util/DistinguishedName.php
|
DistinguishedName.merge
|
public function merge(array $attributes)
{
foreach ($attributes as $name => $value) {
$this->add($name, $value);
}
}
|
php
|
public function merge(array $attributes)
{
foreach ($attributes as $name => $value) {
$this->add($name, $value);
}
}
|
[
"public",
"function",
"merge",
"(",
"array",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Adds multiple attributes to the name.
@param array $attributes The attributes to add.
@see add()
|
[
"Adds",
"multiple",
"attributes",
"to",
"the",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/DistinguishedName.php#L75-L80
|
223,698
|
puli/manager
|
src/Util/DistinguishedName.php
|
DistinguishedName.toString
|
public function toString()
{
$stringAttr = array();
foreach ($this->attributes as $name => $value) {
$stringAttr[] = $name.'='.$this->escape($value);
}
return implode(',', $stringAttr);
}
|
php
|
public function toString()
{
$stringAttr = array();
foreach ($this->attributes as $name => $value) {
$stringAttr[] = $name.'='.$this->escape($value);
}
return implode(',', $stringAttr);
}
|
[
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"stringAttr",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"stringAttr",
"[",
"]",
"=",
"$",
"name",
".",
"'='",
".",
"$",
"this",
"->",
"escape",
"(",
"$",
"value",
")",
";",
"}",
"return",
"implode",
"(",
"','",
",",
"$",
"stringAttr",
")",
";",
"}"
] |
Returns the distinguished name as string.
Attribute values are always enquoted with '"'. Quotation marks and
backslashes are escaped with a prefix backslash in the values.
@return string The string form of the distinguished name.
|
[
"Returns",
"the",
"distinguished",
"name",
"as",
"string",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/DistinguishedName.php#L147-L156
|
223,699
|
puli/manager
|
src/Api/Installation/NotInstallableException.php
|
NotInstallableException.missingParameter
|
public static function missingParameter($parameterName, $installerName, Exception $cause = null)
{
return new static(sprintf(
'The parameter "%s" is required for the installer "%s".',
$parameterName,
$installerName
), self::MISSING_PARAMETER, $cause);
}
|
php
|
public static function missingParameter($parameterName, $installerName, Exception $cause = null)
{
return new static(sprintf(
'The parameter "%s" is required for the installer "%s".',
$parameterName,
$installerName
), self::MISSING_PARAMETER, $cause);
}
|
[
"public",
"static",
"function",
"missingParameter",
"(",
"$",
"parameterName",
",",
"$",
"installerName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The parameter \"%s\" is required for the installer \"%s\".'",
",",
"$",
"parameterName",
",",
"$",
"installerName",
")",
",",
"self",
"::",
"MISSING_PARAMETER",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for a missing required parameter.
@param string $parameterName The parameter name.
@param string $installerName The installer name.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"a",
"missing",
"required",
"parameter",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installation/NotInstallableException.php#L75-L82
|
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.