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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37,700 | loduis/teamwork.com-project-management | src/File.php | File.upload | public function upload($files)
{
$files = (array) $files;
$pending_file_attachments = [];
foreach ($files as $filename) {
if (!is_file($filename)) {
throw new Exception("Not file exist $filename");
}
}
foreach ($files as $filename) {
$params = ['file'=> self::getFileParam($filename)];
$pending_file_attachments[] = $this->rest->upload(
'pendingfiles',
$params
);
}
return join(',', $pending_file_attachments);
} | php | public function upload($files)
{
$files = (array) $files;
$pending_file_attachments = [];
foreach ($files as $filename) {
if (!is_file($filename)) {
throw new Exception("Not file exist $filename");
}
}
foreach ($files as $filename) {
$params = ['file'=> self::getFileParam($filename)];
$pending_file_attachments[] = $this->rest->upload(
'pendingfiles',
$params
);
}
return join(',', $pending_file_attachments);
} | [
"public",
"function",
"upload",
"(",
"$",
"files",
")",
"{",
"$",
"files",
"=",
"(",
"array",
")",
"$",
"files",
";",
"$",
"pending_file_attachments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Not file exist $filename\"",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"files",
"as",
"$",
"filename",
")",
"{",
"$",
"params",
"=",
"[",
"'file'",
"=>",
"self",
"::",
"getFileParam",
"(",
"$",
"filename",
")",
"]",
";",
"$",
"pending_file_attachments",
"[",
"]",
"=",
"$",
"this",
"->",
"rest",
"->",
"upload",
"(",
"'pendingfiles'",
",",
"$",
"params",
")",
";",
"}",
"return",
"join",
"(",
"','",
",",
"$",
"pending_file_attachments",
")",
";",
"}"
] | Step 1. Upload the file
POST /pendingfiles
Send your file to POST /pendingfiles.xml using the FORM field "file".
You will still need to authenticate yourself by passing your API token.
If the upload is successful, you will get back something like:
tf_1706111559e0a49
@param mixed $files
@return string
@throws \TeamWorkPm\Exception | [
"Step",
"1",
".",
"Upload",
"the",
"file"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/File.php#L74-L92 |
37,701 | loduis/teamwork.com-project-management | src/File.php | File.save | public function save(array $data)
{
$project_id = empty($data['project_id']) ? 0: (int) $data['project_id'];
if ($project_id <= 0) {
throw new Exception('Required field project_id');
}
if (empty($data['pending_file_ref']) && empty($data['filename'])) {
throw new Exception('Required field pending_file_ref or filename');
}
if (empty($data['pending_file_ref'])) {
$data['pending_file_ref'] = $this->upload($data['filename']);
}
unset($data['filename']);
return $this->rest->post("projects/$project_id/files", $data);
} | php | public function save(array $data)
{
$project_id = empty($data['project_id']) ? 0: (int) $data['project_id'];
if ($project_id <= 0) {
throw new Exception('Required field project_id');
}
if (empty($data['pending_file_ref']) && empty($data['filename'])) {
throw new Exception('Required field pending_file_ref or filename');
}
if (empty($data['pending_file_ref'])) {
$data['pending_file_ref'] = $this->upload($data['filename']);
}
unset($data['filename']);
return $this->rest->post("projects/$project_id/files", $data);
} | [
"public",
"function",
"save",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"project_id",
"=",
"empty",
"(",
"$",
"data",
"[",
"'project_id'",
"]",
")",
"?",
"0",
":",
"(",
"int",
")",
"$",
"data",
"[",
"'project_id'",
"]",
";",
"if",
"(",
"$",
"project_id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field project_id'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'pending_file_ref'",
"]",
")",
"&&",
"empty",
"(",
"$",
"data",
"[",
"'filename'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field pending_file_ref or filename'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'pending_file_ref'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'pending_file_ref'",
"]",
"=",
"$",
"this",
"->",
"upload",
"(",
"$",
"data",
"[",
"'filename'",
"]",
")",
";",
"}",
"unset",
"(",
"$",
"data",
"[",
"'filename'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"\"projects/$project_id/files\"",
",",
"$",
"data",
")",
";",
"}"
] | Add a File to a Project
POST /projects/#{file_id}/files
@param array $data
@return int File id
@throws \TeamWorkPm\Exception | [
"Add",
"a",
"File",
"to",
"a",
"Project"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/File.php#L113-L127 |
37,702 | loduis/teamwork.com-project-management | src/Portfolio/Card.php | Card.insert | public function insert(array $data)
{
$columnId = empty($data['columnId']) ? 0 : (int) $data['columnId'];
if ($columnId <= 0) {
throw new Exception('Required field columnId');
}
unset($data['columnId']);
if (empty($data['projectId'])) {
throw new Exception('Required field projectId');
}
return $this->rest->post("portfolio/columns/$columnId/cards", $data);
} | php | public function insert(array $data)
{
$columnId = empty($data['columnId']) ? 0 : (int) $data['columnId'];
if ($columnId <= 0) {
throw new Exception('Required field columnId');
}
unset($data['columnId']);
if (empty($data['projectId'])) {
throw new Exception('Required field projectId');
}
return $this->rest->post("portfolio/columns/$columnId/cards", $data);
} | [
"public",
"function",
"insert",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"columnId",
"=",
"empty",
"(",
"$",
"data",
"[",
"'columnId'",
"]",
")",
"?",
"0",
":",
"(",
"int",
")",
"$",
"data",
"[",
"'columnId'",
"]",
";",
"if",
"(",
"$",
"columnId",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field columnId'",
")",
";",
"}",
"unset",
"(",
"$",
"data",
"[",
"'columnId'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'projectId'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field projectId'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"\"portfolio/columns/$columnId/cards\"",
",",
"$",
"data",
")",
";",
"}"
] | Adds a project to the given board
@param array $data
@return int | [
"Adds",
"a",
"project",
"to",
"the",
"given",
"board"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Portfolio/Card.php#L74-L87 |
37,703 | loduis/teamwork.com-project-management | src/Portfolio/Card.php | Card.update | public function update(array $data)
{
$cardId = empty($data['id']) ? 0: (int) $data['id'];
if ($cardId <= 0) {
throw new Exception('Required field id');
}
$data['cardId'] = $data['id'];
unset($data['id']);
if (empty($data['columnId'])) {
throw new Exception('Required field columnId');
}
if (empty($data['oldColumnId'])) {
throw new Exception('Required field oldColumnId');
}
return $this->rest->put("$this->action/$cardId/move", $data);
} | php | public function update(array $data)
{
$cardId = empty($data['id']) ? 0: (int) $data['id'];
if ($cardId <= 0) {
throw new Exception('Required field id');
}
$data['cardId'] = $data['id'];
unset($data['id']);
if (empty($data['columnId'])) {
throw new Exception('Required field columnId');
}
if (empty($data['oldColumnId'])) {
throw new Exception('Required field oldColumnId');
}
return $this->rest->put("$this->action/$cardId/move", $data);
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"cardId",
"=",
"empty",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
"?",
"0",
":",
"(",
"int",
")",
"$",
"data",
"[",
"'id'",
"]",
";",
"if",
"(",
"$",
"cardId",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field id'",
")",
";",
"}",
"$",
"data",
"[",
"'cardId'",
"]",
"=",
"$",
"data",
"[",
"'id'",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'columnId'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field columnId'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'oldColumnId'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field oldColumnId'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"put",
"(",
"\"$this->action/$cardId/move\"",
",",
"$",
"data",
")",
";",
"}"
] | Moves the given card from one board to another
@param array $data
@return bool
@throws \TeamWorkPm\Exception | [
"Moves",
"the",
"given",
"card",
"from",
"one",
"board",
"to",
"another"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Portfolio/Card.php#L97-L115 |
37,704 | loduis/teamwork.com-project-management | src/Notebook.php | Notebook.getAll | public function getAll($includeContent = false)
{
$includeContent = (bool) $includeContent;
return $this->rest->get("$this->action", [
'includeContent'=>$includeContent ? 'true' : 'false'
]);
} | php | public function getAll($includeContent = false)
{
$includeContent = (bool) $includeContent;
return $this->rest->get("$this->action", [
'includeContent'=>$includeContent ? 'true' : 'false'
]);
} | [
"public",
"function",
"getAll",
"(",
"$",
"includeContent",
"=",
"false",
")",
"{",
"$",
"includeContent",
"=",
"(",
"bool",
")",
"$",
"includeContent",
";",
"return",
"$",
"this",
"->",
"rest",
"->",
"get",
"(",
"\"$this->action\"",
",",
"[",
"'includeContent'",
"=>",
"$",
"includeContent",
"?",
"'true'",
":",
"'false'",
"]",
")",
";",
"}"
] | List All Notebooks
GET /notebooks.xml?includeContent=[true|false]
Lists all notebooks on projects that the authenticated user is associated with.
By default, the actual notebook HTML content is not returned.
You can pass includeContent=true to return the notebook HTML content with the notebook data
@param bool $includeContent
@return \TeamWorkPm\Response\Model
@throws \TeamWorkPm\Exception | [
"List",
"All",
"Notebooks"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L68-L74 |
37,705 | loduis/teamwork.com-project-management | src/Notebook.php | Notebook.getByProject | public function getByProject($projectId, $includeContent = false)
{
$projectId = (int) $projectId;
if ($projectId <= 0) {
throw new Exception('Invalid param project_id');
}
$includeContent = (bool) $includeContent;
return $this->rest->get("projects/$projectId/$this->action", [
'includeContent'=>$includeContent ? 'true' : 'false'
]);
} | php | public function getByProject($projectId, $includeContent = false)
{
$projectId = (int) $projectId;
if ($projectId <= 0) {
throw new Exception('Invalid param project_id');
}
$includeContent = (bool) $includeContent;
return $this->rest->get("projects/$projectId/$this->action", [
'includeContent'=>$includeContent ? 'true' : 'false'
]);
} | [
"public",
"function",
"getByProject",
"(",
"$",
"projectId",
",",
"$",
"includeContent",
"=",
"false",
")",
"{",
"$",
"projectId",
"=",
"(",
"int",
")",
"$",
"projectId",
";",
"if",
"(",
"$",
"projectId",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param project_id'",
")",
";",
"}",
"$",
"includeContent",
"=",
"(",
"bool",
")",
"$",
"includeContent",
";",
"return",
"$",
"this",
"->",
"rest",
"->",
"get",
"(",
"\"projects/$projectId/$this->action\"",
",",
"[",
"'includeContent'",
"=>",
"$",
"includeContent",
"?",
"'true'",
":",
"'false'",
"]",
")",
";",
"}"
] | List Notebooks on a Project
GET /projects/#{project_id}/notebooks.xml
This lets you query the list of notebooks for a project.
By default, the actual notebook HTML content is not returned.
You can pass includeContent=true to return the notebook HTML content with the notebook data
@param int $projectId
@param bool $includeContent
@return \TeamWorkPm\Response\Model
@throws \TeamWorkPm\Exception | [
"List",
"Notebooks",
"on",
"a",
"Project"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L92-L102 |
37,706 | loduis/teamwork.com-project-management | src/Notebook.php | Notebook.lock | public function lock($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/lock");
} | php | public function lock($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/lock");
} | [
"public",
"function",
"lock",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"put",
"(",
"\"$this->action/$id/lock\"",
")",
";",
"}"
] | Lock a Single Notebook For Editing
PUT /notebooks/#{id}/lock
Locks the notebook and all versions for editing.
@param int $id
@return bool
@throws \TeamWorkPm\Exception | [
"Lock",
"a",
"Single",
"Notebook",
"For",
"Editing"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L116-L123 |
37,707 | loduis/teamwork.com-project-management | src/Notebook.php | Notebook.unlock | public function unlock($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/unlock");
} | php | public function unlock($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/unlock");
} | [
"public",
"function",
"unlock",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"put",
"(",
"\"$this->action/$id/unlock\"",
")",
";",
"}"
] | Unlock a Single Notebook
PUT /notebooks/#{id}/unlock
Unlocks a locked notebook so it can be edited again.
@param int $id
@return bool
@throws \TeamWorkPm\Exception | [
"Unlock",
"a",
"Single",
"Notebook"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L137-L144 |
37,708 | loduis/teamwork.com-project-management | src/Response/XML.php | XML.parse | public function parse($data, array $headers)
{
libxml_use_internal_errors(true);
$this->string = $data;
$source = simplexml_load_string($data);
$errors = $this->getXmlErrors($source);
if ($source) {
if ($headers['Status'] === 201 || $headers['Status'] === 200) {
switch ($headers['Method']) {
case 'UPLOAD':
if (!empty($source->ref)) {
return (string) $source->ref;
}
break;
case 'POST':
if (!empty($headers['id'])) {
return $headers['id'];
} else {
$property = 0;
$value = (int) $source->$property;
// this case the fileid
if ($value > 0) {
return $value;
}
}
break;
case 'PUT':
case 'DELETE':
return true;
default:
if (!empty($source->files->file)) {
$source = $source->files->file;
$isArray = true;
} elseif (!empty($source->notebooks->notebook)) {
$source = $source->notebooks->notebook;
$isArray = true;
} elseif (!empty($source->project->links)) {
$source = $source->project->links;
$isArray = true;
} else {
$attrs = $source->attributes();
$isArray = !empty($attrs->type) &&
(string) $attrs->type === 'array';
}
$this->headers = $headers;
$_this = self::toStdClass($source, $isArray);
foreach ($_this as $key=>$value) {
$this->$key = $value;
}
return $this;
}
} else {
if (!empty($source->error)) {
foreach ($source as $error) {
$errors .= $error ."\n";
}
} else {
$property = 0;
$errors .= $source->$property;
}
}
}
throw new Exception([
'Message'=> $errors,
'Response'=> $data,
'Headers'=> $headers
]);
} | php | public function parse($data, array $headers)
{
libxml_use_internal_errors(true);
$this->string = $data;
$source = simplexml_load_string($data);
$errors = $this->getXmlErrors($source);
if ($source) {
if ($headers['Status'] === 201 || $headers['Status'] === 200) {
switch ($headers['Method']) {
case 'UPLOAD':
if (!empty($source->ref)) {
return (string) $source->ref;
}
break;
case 'POST':
if (!empty($headers['id'])) {
return $headers['id'];
} else {
$property = 0;
$value = (int) $source->$property;
// this case the fileid
if ($value > 0) {
return $value;
}
}
break;
case 'PUT':
case 'DELETE':
return true;
default:
if (!empty($source->files->file)) {
$source = $source->files->file;
$isArray = true;
} elseif (!empty($source->notebooks->notebook)) {
$source = $source->notebooks->notebook;
$isArray = true;
} elseif (!empty($source->project->links)) {
$source = $source->project->links;
$isArray = true;
} else {
$attrs = $source->attributes();
$isArray = !empty($attrs->type) &&
(string) $attrs->type === 'array';
}
$this->headers = $headers;
$_this = self::toStdClass($source, $isArray);
foreach ($_this as $key=>$value) {
$this->$key = $value;
}
return $this;
}
} else {
if (!empty($source->error)) {
foreach ($source as $error) {
$errors .= $error ."\n";
}
} else {
$property = 0;
$errors .= $source->$property;
}
}
}
throw new Exception([
'Message'=> $errors,
'Response'=> $data,
'Headers'=> $headers
]);
} | [
"public",
"function",
"parse",
"(",
"$",
"data",
",",
"array",
"$",
"headers",
")",
"{",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"this",
"->",
"string",
"=",
"$",
"data",
";",
"$",
"source",
"=",
"simplexml_load_string",
"(",
"$",
"data",
")",
";",
"$",
"errors",
"=",
"$",
"this",
"->",
"getXmlErrors",
"(",
"$",
"source",
")",
";",
"if",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"headers",
"[",
"'Status'",
"]",
"===",
"201",
"||",
"$",
"headers",
"[",
"'Status'",
"]",
"===",
"200",
")",
"{",
"switch",
"(",
"$",
"headers",
"[",
"'Method'",
"]",
")",
"{",
"case",
"'UPLOAD'",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"source",
"->",
"ref",
")",
")",
"{",
"return",
"(",
"string",
")",
"$",
"source",
"->",
"ref",
";",
"}",
"break",
";",
"case",
"'POST'",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"headers",
"[",
"'id'",
"]",
")",
")",
"{",
"return",
"$",
"headers",
"[",
"'id'",
"]",
";",
"}",
"else",
"{",
"$",
"property",
"=",
"0",
";",
"$",
"value",
"=",
"(",
"int",
")",
"$",
"source",
"->",
"$",
"property",
";",
"// this case the fileid",
"if",
"(",
"$",
"value",
">",
"0",
")",
"{",
"return",
"$",
"value",
";",
"}",
"}",
"break",
";",
"case",
"'PUT'",
":",
"case",
"'DELETE'",
":",
"return",
"true",
";",
"default",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"source",
"->",
"files",
"->",
"file",
")",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"->",
"files",
"->",
"file",
";",
"$",
"isArray",
"=",
"true",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"source",
"->",
"notebooks",
"->",
"notebook",
")",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"->",
"notebooks",
"->",
"notebook",
";",
"$",
"isArray",
"=",
"true",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"source",
"->",
"project",
"->",
"links",
")",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"->",
"project",
"->",
"links",
";",
"$",
"isArray",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"attrs",
"=",
"$",
"source",
"->",
"attributes",
"(",
")",
";",
"$",
"isArray",
"=",
"!",
"empty",
"(",
"$",
"attrs",
"->",
"type",
")",
"&&",
"(",
"string",
")",
"$",
"attrs",
"->",
"type",
"===",
"'array'",
";",
"}",
"$",
"this",
"->",
"headers",
"=",
"$",
"headers",
";",
"$",
"_this",
"=",
"self",
"::",
"toStdClass",
"(",
"$",
"source",
",",
"$",
"isArray",
")",
";",
"foreach",
"(",
"$",
"_this",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"source",
"->",
"error",
")",
")",
"{",
"foreach",
"(",
"$",
"source",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
".=",
"$",
"error",
".",
"\"\\n\"",
";",
"}",
"}",
"else",
"{",
"$",
"property",
"=",
"0",
";",
"$",
"errors",
".=",
"$",
"source",
"->",
"$",
"property",
";",
"}",
"}",
"}",
"throw",
"new",
"Exception",
"(",
"[",
"'Message'",
"=>",
"$",
"errors",
",",
"'Response'",
"=>",
"$",
"data",
",",
"'Headers'",
"=>",
"$",
"headers",
"]",
")",
";",
"}"
] | Parsea un string type xml
@param string $data
@param type $headers
@return mixed [bool, int, TeamWorkPm\Response\XML]
@throws \TeamWorkPm\Exception | [
"Parsea",
"un",
"string",
"type",
"xml"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Response/XML.php#L21-L90 |
37,709 | loduis/teamwork.com-project-management | src/Response/XML.php | XML.getContent | protected function getContent()
{
$dom = new DOMDocument('1.0');
$dom->loadXML($this->string);
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
return $dom->saveXML();
} | php | protected function getContent()
{
$dom = new DOMDocument('1.0');
$dom->loadXML($this->string);
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
return $dom->saveXML();
} | [
"protected",
"function",
"getContent",
"(",
")",
"{",
"$",
"dom",
"=",
"new",
"DOMDocument",
"(",
"'1.0'",
")",
";",
"$",
"dom",
"->",
"loadXML",
"(",
"$",
"this",
"->",
"string",
")",
";",
"$",
"dom",
"->",
"preserveWhiteSpace",
"=",
"false",
";",
"$",
"dom",
"->",
"formatOutput",
"=",
"true",
";",
"return",
"$",
"dom",
"->",
"saveXML",
"(",
")",
";",
"}"
] | Devuelve un xml formateado
@return string | [
"Devuelve",
"un",
"xml",
"formateado"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Response/XML.php#L97-L105 |
37,710 | loduis/teamwork.com-project-management | src/Response/XML.php | XML.toStdClass | private static function toStdClass(
SimpleXMLElement $source,
$isArray = false
) {
$destination = $isArray ? [] : new stdClass();
foreach ($source as $key=>$value) {
$key = Str::camel($key);
$attrs = $value->attributes();
if (!empty($attrs->type)) {
$type = (string) $attrs->type;
switch ($type) {
case 'integer':
$destination->$key = (int) $value;
break;
case 'boolean':
$value = (string) $value;
$destination->$key = (bool) $value === 'true';
break;
case 'array':
if (is_array($destination)) {
$destination[$key] = self::toStdClass($value, true);
} else {
$destination->$key = self::toStdClass($value, true);
}
break;
default:
$destination->$key = (string) $value;
break;
}
} else {
$children = $value->children();
if (!empty($children)) {
if ($isArray) {
$i = count($destination);
$destination[$i] = self::toStdClass($value);
} else {
$destination->$key = self::toStdClass($value);
}
} else {
$destination->$key = (string) $value;
}
}
}
return $destination;
} | php | private static function toStdClass(
SimpleXMLElement $source,
$isArray = false
) {
$destination = $isArray ? [] : new stdClass();
foreach ($source as $key=>$value) {
$key = Str::camel($key);
$attrs = $value->attributes();
if (!empty($attrs->type)) {
$type = (string) $attrs->type;
switch ($type) {
case 'integer':
$destination->$key = (int) $value;
break;
case 'boolean':
$value = (string) $value;
$destination->$key = (bool) $value === 'true';
break;
case 'array':
if (is_array($destination)) {
$destination[$key] = self::toStdClass($value, true);
} else {
$destination->$key = self::toStdClass($value, true);
}
break;
default:
$destination->$key = (string) $value;
break;
}
} else {
$children = $value->children();
if (!empty($children)) {
if ($isArray) {
$i = count($destination);
$destination[$i] = self::toStdClass($value);
} else {
$destination->$key = self::toStdClass($value);
}
} else {
$destination->$key = (string) $value;
}
}
}
return $destination;
} | [
"private",
"static",
"function",
"toStdClass",
"(",
"SimpleXMLElement",
"$",
"source",
",",
"$",
"isArray",
"=",
"false",
")",
"{",
"$",
"destination",
"=",
"$",
"isArray",
"?",
"[",
"]",
":",
"new",
"stdClass",
"(",
")",
";",
"foreach",
"(",
"$",
"source",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"Str",
"::",
"camel",
"(",
"$",
"key",
")",
";",
"$",
"attrs",
"=",
"$",
"value",
"->",
"attributes",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attrs",
"->",
"type",
")",
")",
"{",
"$",
"type",
"=",
"(",
"string",
")",
"$",
"attrs",
"->",
"type",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'integer'",
":",
"$",
"destination",
"->",
"$",
"key",
"=",
"(",
"int",
")",
"$",
"value",
";",
"break",
";",
"case",
"'boolean'",
":",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"$",
"destination",
"->",
"$",
"key",
"=",
"(",
"bool",
")",
"$",
"value",
"===",
"'true'",
";",
"break",
";",
"case",
"'array'",
":",
"if",
"(",
"is_array",
"(",
"$",
"destination",
")",
")",
"{",
"$",
"destination",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"toStdClass",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"destination",
"->",
"$",
"key",
"=",
"self",
"::",
"toStdClass",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"break",
";",
"default",
":",
"$",
"destination",
"->",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"value",
";",
"break",
";",
"}",
"}",
"else",
"{",
"$",
"children",
"=",
"$",
"value",
"->",
"children",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"children",
")",
")",
"{",
"if",
"(",
"$",
"isArray",
")",
"{",
"$",
"i",
"=",
"count",
"(",
"$",
"destination",
")",
";",
"$",
"destination",
"[",
"$",
"i",
"]",
"=",
"self",
"::",
"toStdClass",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"destination",
"->",
"$",
"key",
"=",
"self",
"::",
"toStdClass",
"(",
"$",
"value",
")",
";",
"}",
"}",
"else",
"{",
"$",
"destination",
"->",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"destination",
";",
"}"
] | Convierte un objecto SimpleXMLElement a stdClass
@param SimpleXMLElement $source
@param bool $isArray
@return stdClass | [
"Convierte",
"un",
"objecto",
"SimpleXMLElement",
"a",
"stdClass"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Response/XML.php#L114-L159 |
37,711 | loduis/teamwork.com-project-management | src/Milestone.php | Milestone.getByProject | public function getByProject($project_id, $filter = 'all')
{
$project_id = (int) $project_id;
if ($project_id <= 0) {
throw new Exception('Invalid param project_id');
}
return $this->rest->get(
"projects/$project_id/$this->action",
$this->getParams($filter)
);
} | php | public function getByProject($project_id, $filter = 'all')
{
$project_id = (int) $project_id;
if ($project_id <= 0) {
throw new Exception('Invalid param project_id');
}
return $this->rest->get(
"projects/$project_id/$this->action",
$this->getParams($filter)
);
} | [
"public",
"function",
"getByProject",
"(",
"$",
"project_id",
",",
"$",
"filter",
"=",
"'all'",
")",
"{",
"$",
"project_id",
"=",
"(",
"int",
")",
"$",
"project_id",
";",
"if",
"(",
"$",
"project_id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param project_id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"get",
"(",
"\"projects/$project_id/$this->action\"",
",",
"$",
"this",
"->",
"getParams",
"(",
"$",
"filter",
")",
")",
";",
"}"
] | Get all milestone
@param $project_id
@param string $filter
@return \TeamWorkPm\Response\Model
@throws \TeamWorkPm\Exception | [
"Get",
"all",
"milestone"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Milestone.php#L116-L126 |
37,712 | loduis/teamwork.com-project-management | src/Project.php | Project.star | public function star($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/star");
} | php | public function star($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/star");
} | [
"public",
"function",
"star",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"put",
"(",
"\"$this->action/$id/star\"",
")",
";",
"}"
] | Adds a project to your list of favourite projects.
@param int $id
@return bool
@throws \TeamWorkPm\Exception | [
"Adds",
"a",
"project",
"to",
"your",
"list",
"of",
"favourite",
"projects",
"."
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L125-L132 |
37,713 | loduis/teamwork.com-project-management | src/Project.php | Project.unStar | public function unStar($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new \TeamWorkPm\Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/unstar");
} | php | public function unStar($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new \TeamWorkPm\Exception('Invalid param id');
}
return $this->rest->put("$this->action/$id/unstar");
} | [
"public",
"function",
"unStar",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"\\",
"TeamWorkPm",
"\\",
"Exception",
"(",
"'Invalid param id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"put",
"(",
"\"$this->action/$id/unstar\"",
")",
";",
"}"
] | Removes a project from your list of favourite projects.
@param int $id
@return bool
@throws \TeamWorkPm\Exception | [
"Removes",
"a",
"project",
"from",
"your",
"list",
"of",
"favourite",
"projects",
"."
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L142-L149 |
37,714 | loduis/teamwork.com-project-management | src/Project.php | Project.activate | public function activate($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
$data = [];
$data['id'] = $id;
$data['status'] = 'active';
return $this->update($data);
} | php | public function activate($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
$data = [];
$data['id'] = $id;
$data['status'] = 'active';
return $this->update($data);
} | [
"public",
"function",
"activate",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param id'",
")",
";",
"}",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"$",
"data",
"[",
"'status'",
"]",
"=",
"'active'",
";",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"data",
")",
";",
"}"
] | Shortcut for active project
@param int $id
@return bool
@throws \TeamWorkPm\Exception | [
"Shortcut",
"for",
"active",
"project"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L159-L169 |
37,715 | loduis/teamwork.com-project-management | src/Project.php | Project.archive | public function archive($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
$data = [];
$data['id'] = $id;
$data['status'] = 'archived';
return $this->update($data);
} | php | public function archive($id)
{
$id = (int) $id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
$data = [];
$data['id'] = $id;
$data['status'] = 'archived';
return $this->update($data);
} | [
"public",
"function",
"archive",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param id'",
")",
";",
"}",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"$",
"data",
"[",
"'status'",
"]",
"=",
"'archived'",
";",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"data",
")",
";",
"}"
] | Shortcut for archive project
@param int $id
@return bool
@throws \TeamWorkPm\Exception | [
"Shortcut",
"for",
"archive",
"project"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L179-L189 |
37,716 | loduis/teamwork.com-project-management | src/Tag.php | Tag.get | public function get($id, $params = null)
{
$id = (int)$id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->get("$this->action/$id", $params);
} | php | public function get($id, $params = null)
{
$id = (int)$id;
if ($id <= 0) {
throw new Exception('Invalid param id');
}
return $this->rest->get("$this->action/$id", $params);
} | [
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"get",
"(",
"\"$this->action/$id\"",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve a single tag
@param int $id
@param null $params
@return \TeamWorkPm\Response\Model
@throws \TeamWorkPm\Exception | [
"Retrieve",
"a",
"single",
"tag"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Tag.php#L25-L32 |
37,717 | loduis/teamwork.com-project-management | src/Task_List.php | Task_List.getByProject | public function getByProject($id, $params = null)
{
$project_id = (int) $id;
if ($project_id <= 0) {
throw new Exception('Invalid param project_id');
}
if ($params && is_string($params)) {
$status = ['active','completed'];
$filter = ['upcoming','late','today','tomorrow'];
if (in_array($params, $status)) {
$params = ['status'=> $params];
} elseif (in_array($params, $filter)) {
$params = ['filter'=> $params];
} else {
$params = null;
}
}
return $this->rest->get("projects/$project_id/$this->action", $params);
} | php | public function getByProject($id, $params = null)
{
$project_id = (int) $id;
if ($project_id <= 0) {
throw new Exception('Invalid param project_id');
}
if ($params && is_string($params)) {
$status = ['active','completed'];
$filter = ['upcoming','late','today','tomorrow'];
if (in_array($params, $status)) {
$params = ['status'=> $params];
} elseif (in_array($params, $filter)) {
$params = ['filter'=> $params];
} else {
$params = null;
}
}
return $this->rest->get("projects/$project_id/$this->action", $params);
} | [
"public",
"function",
"getByProject",
"(",
"$",
"id",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"project_id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"project_id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param project_id'",
")",
";",
"}",
"if",
"(",
"$",
"params",
"&&",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"$",
"status",
"=",
"[",
"'active'",
",",
"'completed'",
"]",
";",
"$",
"filter",
"=",
"[",
"'upcoming'",
",",
"'late'",
",",
"'today'",
",",
"'tomorrow'",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"params",
",",
"$",
"status",
")",
")",
"{",
"$",
"params",
"=",
"[",
"'status'",
"=>",
"$",
"params",
"]",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"params",
",",
"$",
"filter",
")",
")",
"{",
"$",
"params",
"=",
"[",
"'filter'",
"=>",
"$",
"params",
"]",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"get",
"(",
"\"projects/$project_id/$this->action\"",
",",
"$",
"params",
")",
";",
"}"
] | Get all task lists for a project
GET /projects/#{project_id}/todo_lists.xml
GET /projects/#{project_id}/todo_lists.xml?showTasks=no
GET /projects/#{project_id}/todo_lists.xml?responsible-party-id=#{id}
GET /projects/#{project_id}/todo_lists.xml?getOverdueCount=yes
GET /projects/#{project_id}/todo_lists.xml?responsible-party-id=#{id}&getOverdueCount=yes
GET /projects/#{project_id}/todo_lists.xml?status=completed&getCompletedCount=yes
Retrieves all project task lists
Options:
You can pass 'showMilestones=yes' if you would like to get information on Milestones associated with each task list
You can pass 'showTasks=no' if you do not want to have the tasks returned (showTasks defaults to "yes").
If 'responsible-party-id' is passed lists returned will be filtered to those with tasks for the user.
Passing "getOverdueCount" will return the number of overdue tasks ("overdue-count") for each task list.
Passing "getCompletedCount" will return the number of completed tasks ("completed-count") for each task list.
Status: You can use the Status option to restrict the lists return - valid values are 'all', 'active', and 'completed'. The default is "ACTIVE"
Filter: You can use the Filter option to return specific tasks - valid values are 'all','upcoming','late','today','tomorrow'. The default is "ALL"
If you pass FILTER as upcoming, late, today or tomorrow, you can also pass includeOverdue to also include overdue tasks
@param [int] $id
@param [string | array] $params
@return object
@throws \TeamWorkPm\Exception | [
"Get",
"all",
"task",
"lists",
"for",
"a",
"project"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Task_List.php#L96-L114 |
37,718 | loduis/teamwork.com-project-management | src/Rest.php | Rest.execute | private function execute($method, $action, $request = null)
{
$url = "{$this->url}$action." . self::$FORMAT;
$headers = ['Authorization: BASIC '. base64_encode(
$this->key . ':xxx'
)];
$request = $this->request
->setAction($action)
->getParameters($method, $request);
$ch = static::initCurl($method, $url, $request, $headers);
$i = 0;
while ($i < 5) {
$data = curl_exec($ch);
$status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = $this->parseHeaders(substr($data, 0, $header_size));
if ($status === 400 &&
(int) $headers['X-RateLimit-Remaining'] === 0) {
$i ++;
sleep(10);
} else {
break;
}
}
// echo $data, PHP_EOL, PHP_EOL;
$body = substr($data, $header_size);
$errorInfo = curl_error($ch);
$error = curl_errno($ch);
curl_close($ch);
if ($error) {
throw new Exception($errorInfo);
}
$headers['Status'] = $status;
$headers['Method'] = $method;
$headers['X-Url'] = $url;
$headers['X-Request'] = $request;
$headers['X-Action'] = $action;
// for chrome use
$headers['X-Authorization'] = 'BASIC '. base64_encode($this->key . ':xxx');
$response = '\\TeamWorkPm\\Response\\' . strtoupper(self::$FORMAT);
$response = new $response;
return $response->parse($body, $headers);
} | php | private function execute($method, $action, $request = null)
{
$url = "{$this->url}$action." . self::$FORMAT;
$headers = ['Authorization: BASIC '. base64_encode(
$this->key . ':xxx'
)];
$request = $this->request
->setAction($action)
->getParameters($method, $request);
$ch = static::initCurl($method, $url, $request, $headers);
$i = 0;
while ($i < 5) {
$data = curl_exec($ch);
$status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = $this->parseHeaders(substr($data, 0, $header_size));
if ($status === 400 &&
(int) $headers['X-RateLimit-Remaining'] === 0) {
$i ++;
sleep(10);
} else {
break;
}
}
// echo $data, PHP_EOL, PHP_EOL;
$body = substr($data, $header_size);
$errorInfo = curl_error($ch);
$error = curl_errno($ch);
curl_close($ch);
if ($error) {
throw new Exception($errorInfo);
}
$headers['Status'] = $status;
$headers['Method'] = $method;
$headers['X-Url'] = $url;
$headers['X-Request'] = $request;
$headers['X-Action'] = $action;
// for chrome use
$headers['X-Authorization'] = 'BASIC '. base64_encode($this->key . ':xxx');
$response = '\\TeamWorkPm\\Response\\' . strtoupper(self::$FORMAT);
$response = new $response;
return $response->parse($body, $headers);
} | [
"private",
"function",
"execute",
"(",
"$",
"method",
",",
"$",
"action",
",",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"\"{$this->url}$action.\"",
".",
"self",
"::",
"$",
"FORMAT",
";",
"$",
"headers",
"=",
"[",
"'Authorization: BASIC '",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"key",
".",
"':xxx'",
")",
"]",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"request",
"->",
"setAction",
"(",
"$",
"action",
")",
"->",
"getParameters",
"(",
"$",
"method",
",",
"$",
"request",
")",
";",
"$",
"ch",
"=",
"static",
"::",
"initCurl",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"request",
",",
"$",
"headers",
")",
";",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"i",
"<",
"5",
")",
"{",
"$",
"data",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"status",
"=",
"(",
"int",
")",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"$",
"header_size",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HEADER_SIZE",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"parseHeaders",
"(",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"$",
"header_size",
")",
")",
";",
"if",
"(",
"$",
"status",
"===",
"400",
"&&",
"(",
"int",
")",
"$",
"headers",
"[",
"'X-RateLimit-Remaining'",
"]",
"===",
"0",
")",
"{",
"$",
"i",
"++",
";",
"sleep",
"(",
"10",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"// echo $data, PHP_EOL, PHP_EOL;",
"$",
"body",
"=",
"substr",
"(",
"$",
"data",
",",
"$",
"header_size",
")",
";",
"$",
"errorInfo",
"=",
"curl_error",
"(",
"$",
"ch",
")",
";",
"$",
"error",
"=",
"curl_errno",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"errorInfo",
")",
";",
"}",
"$",
"headers",
"[",
"'Status'",
"]",
"=",
"$",
"status",
";",
"$",
"headers",
"[",
"'Method'",
"]",
"=",
"$",
"method",
";",
"$",
"headers",
"[",
"'X-Url'",
"]",
"=",
"$",
"url",
";",
"$",
"headers",
"[",
"'X-Request'",
"]",
"=",
"$",
"request",
";",
"$",
"headers",
"[",
"'X-Action'",
"]",
"=",
"$",
"action",
";",
"// for chrome use",
"$",
"headers",
"[",
"'X-Authorization'",
"]",
"=",
"'BASIC '",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"key",
".",
"':xxx'",
")",
";",
"$",
"response",
"=",
"'\\\\TeamWorkPm\\\\Response\\\\'",
".",
"strtoupper",
"(",
"self",
"::",
"$",
"FORMAT",
")",
";",
"$",
"response",
"=",
"new",
"$",
"response",
";",
"return",
"$",
"response",
"->",
"parse",
"(",
"$",
"body",
",",
"$",
"headers",
")",
";",
"}"
] | Call to api
@param string $method
@param string $action
@param mixed $request
@return mixed
@throws \TeamWorkPm\Exception | [
"Call",
"to",
"api"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Rest.php#L56-L100 |
37,719 | loduis/teamwork.com-project-management | src/Task.php | Task.getByTaskList | public function getByTaskList($task_list_id, $filter = 'all')
{
$task_list_id = (int) $task_list_id;
if ($task_list_id <= 0) {
throw new Exception('Invalid param task_list_id');
}
$params = [
'filter'=> $filter
];
$filter = strtolower($filter);
$validate = ['all', 'pending', 'upcoming','late','today','finished'];
if (in_array($filter, $validate)) {
$params['filter'] = 'all';
}
return $this->rest->get("todo_lists/$task_list_id/$this->action", $params);
} | php | public function getByTaskList($task_list_id, $filter = 'all')
{
$task_list_id = (int) $task_list_id;
if ($task_list_id <= 0) {
throw new Exception('Invalid param task_list_id');
}
$params = [
'filter'=> $filter
];
$filter = strtolower($filter);
$validate = ['all', 'pending', 'upcoming','late','today','finished'];
if (in_array($filter, $validate)) {
$params['filter'] = 'all';
}
return $this->rest->get("todo_lists/$task_list_id/$this->action", $params);
} | [
"public",
"function",
"getByTaskList",
"(",
"$",
"task_list_id",
",",
"$",
"filter",
"=",
"'all'",
")",
"{",
"$",
"task_list_id",
"=",
"(",
"int",
")",
"$",
"task_list_id",
";",
"if",
"(",
"$",
"task_list_id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param task_list_id'",
")",
";",
"}",
"$",
"params",
"=",
"[",
"'filter'",
"=>",
"$",
"filter",
"]",
";",
"$",
"filter",
"=",
"strtolower",
"(",
"$",
"filter",
")",
";",
"$",
"validate",
"=",
"[",
"'all'",
",",
"'pending'",
",",
"'upcoming'",
",",
"'late'",
",",
"'today'",
",",
"'finished'",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"filter",
",",
"$",
"validate",
")",
")",
"{",
"$",
"params",
"[",
"'filter'",
"]",
"=",
"'all'",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"get",
"(",
"\"todo_lists/$task_list_id/$this->action\"",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve all tasks on a task list
GET /todo_lists/#{todo_list_id}/tasks.json
This is almost the same as the “Get list” action, except it does only returns the items.
This is almost the same as the “Get list” action, except it does only returns the items.
If you want to return details about who created each todo item, you must
pass the flag "getCreator=yes". This will then return "creator-id",
"creator-firstname", "creator-lastname" and "creator-avatar-url" for each task.
A flag "canEdit" is returned with each task.
@param int $task_list_id
@param string $filter
@return \TeamWorkPm\Response\Model
@throws \TeamWorkPm\Exception | [
"Retrieve",
"all",
"tasks",
"on",
"a",
"task",
"list"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Task.php#L103-L118 |
37,720 | loduis/teamwork.com-project-management | src/Task.php | Task.reorder | public function reorder($task_list_id, array $ids)
{
$task_list_id = (int) $task_list_id;
if ($task_list_id <= 0) {
throw new Exception('Invalid param task_list_id');
}
return $this->rest->post("todo_lists/$task_list_id/" .
"$this->action/reorder", $ids);
} | php | public function reorder($task_list_id, array $ids)
{
$task_list_id = (int) $task_list_id;
if ($task_list_id <= 0) {
throw new Exception('Invalid param task_list_id');
}
return $this->rest->post("todo_lists/$task_list_id/" .
"$this->action/reorder", $ids);
} | [
"public",
"function",
"reorder",
"(",
"$",
"task_list_id",
",",
"array",
"$",
"ids",
")",
"{",
"$",
"task_list_id",
"=",
"(",
"int",
")",
"$",
"task_list_id",
";",
"if",
"(",
"$",
"task_list_id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param task_list_id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"\"todo_lists/$task_list_id/\"",
".",
"\"$this->action/reorder\"",
",",
"$",
"ids",
")",
";",
"}"
] | Reorder the todo items
POST /todo_lists/#{todo_list_id}/todo_items/reorder.xml
Re-orders items on the submitted list. Completed items cannot be reordered,
and any items not specified will be sorted after the items explicitly given
Items can be re-parented by putting them from one list into the ordering of items for a different list/
@param int $task_list_id
@param array $ids
@return bool
@throws \TeamWorkPm\Exception | [
"Reorder",
"the",
"todo",
"items"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Task.php#L208-L216 |
37,721 | loduis/teamwork.com-project-management | src/Time.php | Time.insert | public function insert(array $data)
{
$id = 0;
if (!empty($data['task_id'])) {
$id = (int) $data['task_id'];
$resource = 'todo_items';
} elseif (!empty($data['project_id'])) {
$id = (int) $data['project_id'];
$resource = 'projects';
}
if ($id <= 0) {
throw new Exception('Required field project_id or task_id');
}
return $this->rest->post("$resource/$id/$this->action", $data);
} | php | public function insert(array $data)
{
$id = 0;
if (!empty($data['task_id'])) {
$id = (int) $data['task_id'];
$resource = 'todo_items';
} elseif (!empty($data['project_id'])) {
$id = (int) $data['project_id'];
$resource = 'projects';
}
if ($id <= 0) {
throw new Exception('Required field project_id or task_id');
}
return $this->rest->post("$resource/$id/$this->action", $data);
} | [
"public",
"function",
"insert",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"id",
"=",
"0",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'task_id'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"data",
"[",
"'task_id'",
"]",
";",
"$",
"resource",
"=",
"'todo_items'",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'project_id'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"data",
"[",
"'project_id'",
"]",
";",
"$",
"resource",
"=",
"'projects'",
";",
"}",
"if",
"(",
"$",
"id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Required field project_id or task_id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"post",
"(",
"\"$resource/$id/$this->action\"",
",",
"$",
"data",
")",
";",
"}"
] | Inserta un time entry ya sea para
un projecto o para un todo item
@param array $data
@return int
@throws \TeamWorkPm\Exception | [
"Inserta",
"un",
"time",
"entry",
"ya",
"sea",
"para",
"un",
"projecto",
"o",
"para",
"un",
"todo",
"item"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Time.php#L43-L57 |
37,722 | loduis/teamwork.com-project-management | src/Time.php | Time.getByTask | public function getByTask($task_id, array $params = [])
{
$task_id = (int) $task_id;
if ($task_id <= 0) {
throw new Exception('Invalid param task_id');
}
return $this->rest->get("todo_items/$task_id/$this->action", $params);
} | php | public function getByTask($task_id, array $params = [])
{
$task_id = (int) $task_id;
if ($task_id <= 0) {
throw new Exception('Invalid param task_id');
}
return $this->rest->get("todo_items/$task_id/$this->action", $params);
} | [
"public",
"function",
"getByTask",
"(",
"$",
"task_id",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"task_id",
"=",
"(",
"int",
")",
"$",
"task_id",
";",
"if",
"(",
"$",
"task_id",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid param task_id'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rest",
"->",
"get",
"(",
"\"todo_items/$task_id/$this->action\"",
",",
"$",
"params",
")",
";",
"}"
] | Retrieve all To-do Item Times
GET /todo_items/#{todo_item_id}/time_entries
Retrieves all of the time entries from a submitted todo item.
@param $task_id
@param array $params
@return \TeamWorkPm\Response\Model
@throws \TeamWorkPm\Exception | [
"Retrieve",
"all",
"To",
"-",
"do",
"Item",
"Times"
] | 29b2006dd450992cc7cc130d823b3a472dbad179 | https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Time.php#L117-L124 |
37,723 | chriskonnertz/bbcode | src/ChrisKonnertz/BBCode/BBCode.php | BBCode.renderPlain | public function renderPlain($text = null)
{
if ($this->text !== null and $text === null) {
$text = $this->text;
}
return preg_replace("/\[(.*?)\]/is", '', $text);
} | php | public function renderPlain($text = null)
{
if ($this->text !== null and $text === null) {
$text = $this->text;
}
return preg_replace("/\[(.*?)\]/is", '', $text);
} | [
"public",
"function",
"renderPlain",
"(",
"$",
"text",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"text",
"!==",
"null",
"and",
"$",
"text",
"===",
"null",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"text",
";",
"}",
"return",
"preg_replace",
"(",
"\"/\\[(.*?)\\]/is\"",
",",
"''",
",",
"$",
"text",
")",
";",
"}"
] | Renders only the text without any BBCode tags.
@param string $text Optional: Render the passed BBCode string instead of the internally stored one
@return string | [
"Renders",
"only",
"the",
"text",
"without",
"any",
"BBCode",
"tags",
"."
] | d3acd447ee11265d4ef38b9058cef32adcafa245 | https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L110-L117 |
37,724 | chriskonnertz/bbcode | src/ChrisKonnertz/BBCode/BBCode.php | BBCode.popTag | protected function popTag(array &$tags, $tag)
{
if (! isset($tags[$tag->name])) {
return null;
}
$size = sizeof($tags[$tag->name]);
if ($size === 0) {
return null;
} else {
return array_pop($tags[$tag->name]);
}
} | php | protected function popTag(array &$tags, $tag)
{
if (! isset($tags[$tag->name])) {
return null;
}
$size = sizeof($tags[$tag->name]);
if ($size === 0) {
return null;
} else {
return array_pop($tags[$tag->name]);
}
} | [
"protected",
"function",
"popTag",
"(",
"array",
"&",
"$",
"tags",
",",
"$",
"tag",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"tags",
"[",
"$",
"tag",
"->",
"name",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"size",
"=",
"sizeof",
"(",
"$",
"tags",
"[",
"$",
"tag",
"->",
"name",
"]",
")",
";",
"if",
"(",
"$",
"size",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"array_pop",
"(",
"$",
"tags",
"[",
"$",
"tag",
"->",
"name",
"]",
")",
";",
"}",
"}"
] | Returns the last tag of a given type and removes it from the array.
@param Tag[] $tags Array of tags
@param Tag $tag Return the last tag of the type of this tag
@return Tag|null | [
"Returns",
"the",
"last",
"tag",
"of",
"a",
"given",
"type",
"and",
"removes",
"it",
"from",
"the",
"array",
"."
] | d3acd447ee11265d4ef38b9058cef32adcafa245 | https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L534-L547 |
37,725 | chriskonnertz/bbcode | src/ChrisKonnertz/BBCode/BBCode.php | BBCode.permitTag | public function permitTag($name)
{
$key = array_search($name, $this->ignoredTags);
if ($key !== false) {
unset($this->ignoredTags[$key]);
}
} | php | public function permitTag($name)
{
$key = array_search($name, $this->ignoredTags);
if ($key !== false) {
unset($this->ignoredTags[$key]);
}
} | [
"public",
"function",
"permitTag",
"(",
"$",
"name",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"ignoredTags",
")",
";",
"if",
"(",
"$",
"key",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"ignoredTags",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] | Remove a tag from the array of ignored tags
@param string $name The name of the tag
@return void | [
"Remove",
"a",
"tag",
"from",
"the",
"array",
"of",
"ignored",
"tags"
] | d3acd447ee11265d4ef38b9058cef32adcafa245 | https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L601-L608 |
37,726 | chriskonnertz/bbcode | src/ChrisKonnertz/BBCode/BBCode.php | BBCode.getDefaultTagNames | public function getDefaultTagNames()
{
return [
self::TAG_NAME_B,
self::TAG_NAME_I,
self::TAG_NAME_S,
self::TAG_NAME_U,
self::TAG_NAME_CODE,
self::TAG_NAME_EMAIL,
self::TAG_NAME_URL,
self::TAG_NAME_IMG,
self::TAG_NAME_LIST,
self::TAG_NAME_LI_STAR,
self::TAG_NAME_LI,
self::TAG_NAME_QUOTE,
self::TAG_NAME_YOUTUBE,
self::TAG_NAME_FONT,
self::TAG_NAME_SIZE,
self::TAG_NAME_COLOR,
self::TAG_NAME_LEFT,
self::TAG_NAME_CENTER,
self::TAG_NAME_RIGHT,
self::TAG_NAME_SPOILER,
];
} | php | public function getDefaultTagNames()
{
return [
self::TAG_NAME_B,
self::TAG_NAME_I,
self::TAG_NAME_S,
self::TAG_NAME_U,
self::TAG_NAME_CODE,
self::TAG_NAME_EMAIL,
self::TAG_NAME_URL,
self::TAG_NAME_IMG,
self::TAG_NAME_LIST,
self::TAG_NAME_LI_STAR,
self::TAG_NAME_LI,
self::TAG_NAME_QUOTE,
self::TAG_NAME_YOUTUBE,
self::TAG_NAME_FONT,
self::TAG_NAME_SIZE,
self::TAG_NAME_COLOR,
self::TAG_NAME_LEFT,
self::TAG_NAME_CENTER,
self::TAG_NAME_RIGHT,
self::TAG_NAME_SPOILER,
];
} | [
"public",
"function",
"getDefaultTagNames",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"TAG_NAME_B",
",",
"self",
"::",
"TAG_NAME_I",
",",
"self",
"::",
"TAG_NAME_S",
",",
"self",
"::",
"TAG_NAME_U",
",",
"self",
"::",
"TAG_NAME_CODE",
",",
"self",
"::",
"TAG_NAME_EMAIL",
",",
"self",
"::",
"TAG_NAME_URL",
",",
"self",
"::",
"TAG_NAME_IMG",
",",
"self",
"::",
"TAG_NAME_LIST",
",",
"self",
"::",
"TAG_NAME_LI_STAR",
",",
"self",
"::",
"TAG_NAME_LI",
",",
"self",
"::",
"TAG_NAME_QUOTE",
",",
"self",
"::",
"TAG_NAME_YOUTUBE",
",",
"self",
"::",
"TAG_NAME_FONT",
",",
"self",
"::",
"TAG_NAME_SIZE",
",",
"self",
"::",
"TAG_NAME_COLOR",
",",
"self",
"::",
"TAG_NAME_LEFT",
",",
"self",
"::",
"TAG_NAME_CENTER",
",",
"self",
"::",
"TAG_NAME_RIGHT",
",",
"self",
"::",
"TAG_NAME_SPOILER",
",",
"]",
";",
"}"
] | Returns an array with the names of all default tags
@return string[] | [
"Returns",
"an",
"array",
"with",
"the",
"names",
"of",
"all",
"default",
"tags"
] | d3acd447ee11265d4ef38b9058cef32adcafa245 | https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L667-L691 |
37,727 | softon/sweetalert | src/SweetAlert.php | SweetAlert.message | public function message($title='', $text='', $type='', $options=[])
{
$this->params['title'] = $title;
$this->params['text'] = $text;
$this->params['type'] = $type;
if (isset($options)) {
$this->params = array_merge($this->params, $options);
}
session()->flash('sweetalert.json', json_encode($this->params));
return $this;
} | php | public function message($title='', $text='', $type='', $options=[])
{
$this->params['title'] = $title;
$this->params['text'] = $text;
$this->params['type'] = $type;
if (isset($options)) {
$this->params = array_merge($this->params, $options);
}
session()->flash('sweetalert.json', json_encode($this->params));
return $this;
} | [
"public",
"function",
"message",
"(",
"$",
"title",
"=",
"''",
",",
"$",
"text",
"=",
"''",
",",
"$",
"type",
"=",
"''",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"$",
"this",
"->",
"params",
"[",
"'text'",
"]",
"=",
"$",
"text",
";",
"$",
"this",
"->",
"params",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
")",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"params",
",",
"$",
"options",
")",
";",
"}",
"session",
"(",
")",
"->",
"flash",
"(",
"'sweetalert.json'",
",",
"json_encode",
"(",
"$",
"this",
"->",
"params",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Send Message to SweetAlert2. With full configuration possible.
@param title string
@param text string
@param type string
@param options array
@return object | [
"Send",
"Message",
"to",
"SweetAlert2",
".",
"With",
"full",
"configuration",
"possible",
"."
] | 97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7 | https://github.com/softon/sweetalert/blob/97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7/src/SweetAlert.php#L20-L33 |
37,728 | softon/sweetalert | src/SweetAlert.php | SweetAlert.autoclose | public function autoclose($time=2000)
{
unset($this->params['timer']);
if ($time !== false) {
$this->params['timer'] = (int)$time;
}
return $this;
} | php | public function autoclose($time=2000)
{
unset($this->params['timer']);
if ($time !== false) {
$this->params['timer'] = (int)$time;
}
return $this;
} | [
"public",
"function",
"autoclose",
"(",
"$",
"time",
"=",
"2000",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"params",
"[",
"'timer'",
"]",
")",
";",
"if",
"(",
"$",
"time",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"'timer'",
"]",
"=",
"(",
"int",
")",
"$",
"time",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | AutoClose the Modal after specified milliseconds
@param integer
@return [type] | [
"AutoClose",
"the",
"Modal",
"after",
"specified",
"milliseconds"
] | 97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7 | https://github.com/softon/sweetalert/blob/97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7/src/SweetAlert.php#L111-L120 |
37,729 | softon/sweetalert | src/SweetAlert.php | SweetAlert.button | public function button($text='OK', $color='#3085d6', $style=true, $class=null)
{
$this->params['confirmButtonText'] = $text;
$this->params['confirmButtonColor'] = $color;
$this->params['buttonsStyling'] = (bool)$style;
if (!is_null($class)) {
$this->params['confirmButtonClass'] = $class;
}
return $this;
} | php | public function button($text='OK', $color='#3085d6', $style=true, $class=null)
{
$this->params['confirmButtonText'] = $text;
$this->params['confirmButtonColor'] = $color;
$this->params['buttonsStyling'] = (bool)$style;
if (!is_null($class)) {
$this->params['confirmButtonClass'] = $class;
}
return $this;
} | [
"public",
"function",
"button",
"(",
"$",
"text",
"=",
"'OK'",
",",
"$",
"color",
"=",
"'#3085d6'",
",",
"$",
"style",
"=",
"true",
",",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"'confirmButtonText'",
"]",
"=",
"$",
"text",
";",
"$",
"this",
"->",
"params",
"[",
"'confirmButtonColor'",
"]",
"=",
"$",
"color",
";",
"$",
"this",
"->",
"params",
"[",
"'buttonsStyling'",
"]",
"=",
"(",
"bool",
")",
"$",
"style",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"'confirmButtonClass'",
"]",
"=",
"$",
"class",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Change Button Properties in the Modal. Like Text , Colour and Style
@param string
@param string
@param boolean
@param [type]
@return [type] | [
"Change",
"Button",
"Properties",
"in",
"the",
"Modal",
".",
"Like",
"Text",
"Colour",
"and",
"Style"
] | 97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7 | https://github.com/softon/sweetalert/blob/97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7/src/SweetAlert.php#L141-L151 |
37,730 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php | EmbedHelper.url | public function url($route, $params)
{
// use array filter to remove keys with null values
$params += array_filter($this->getEmbedParams());
return $this->router->generate($route, $params);
} | php | public function url($route, $params)
{
// use array filter to remove keys with null values
$params += array_filter($this->getEmbedParams());
return $this->router->generate($route, $params);
} | [
"public",
"function",
"url",
"(",
"$",
"route",
",",
"$",
"params",
")",
"{",
"// use array filter to remove keys with null values",
"$",
"params",
"+=",
"array_filter",
"(",
"$",
"this",
"->",
"getEmbedParams",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"$",
"route",
",",
"$",
"params",
")",
";",
"}"
] | Generate an embedded url, adding the embedded parameters to the url
@param string $route
@param array $params
@return string | [
"Generate",
"an",
"embedded",
"url",
"adding",
"the",
"embedded",
"parameters",
"to",
"the",
"url"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L86-L92 |
37,731 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php | EmbedHelper.getParamFromRequest | protected function getParamFromRequest($name)
{
if (null !== $value = $this->requestStack->getCurrentRequest()->get($name)) {
return $value;
}
if ((null !== $request = $this->requestStack->getParentRequest()) && null !== $value = $request->get($name)) {
return $value;
}
if ((null !== $request = $this->requestStack->getMasterRequest()) && null !== $value = $request->get($name)) {
return $value;
}
return null;
} | php | protected function getParamFromRequest($name)
{
if (null !== $value = $this->requestStack->getCurrentRequest()->get($name)) {
return $value;
}
if ((null !== $request = $this->requestStack->getParentRequest()) && null !== $value = $request->get($name)) {
return $value;
}
if ((null !== $request = $this->requestStack->getMasterRequest()) && null !== $value = $request->get($name)) {
return $value;
}
return null;
} | [
"protected",
"function",
"getParamFromRequest",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"value",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
"->",
"get",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"(",
"null",
"!==",
"$",
"request",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getParentRequest",
"(",
")",
")",
"&&",
"null",
"!==",
"$",
"value",
"=",
"$",
"request",
"->",
"get",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"(",
"null",
"!==",
"$",
"request",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getMasterRequest",
"(",
")",
")",
"&&",
"null",
"!==",
"$",
"value",
"=",
"$",
"request",
"->",
"get",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"null",
";",
"}"
] | search for a param value in the request stack, start in current
and bubble up till master request when not found.
@param string $name
@return mixed|null | [
"search",
"for",
"a",
"param",
"value",
"in",
"the",
"request",
"stack",
"start",
"in",
"current",
"and",
"bubble",
"up",
"till",
"master",
"request",
"when",
"not",
"found",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L117-L132 |
37,732 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php | EmbedHelper.getFormId | public function getFormId(FormInterface $form)
{
if (is_object($form->getData())) {
$ret = preg_replace('/\W/', '_', get_class($form->getData()));
} else {
if ($form->getName()) {
return (string)$form->getName();
} else {
return preg_replace('/\W/', '_', get_class($form));
}
}
return $ret;
} | php | public function getFormId(FormInterface $form)
{
if (is_object($form->getData())) {
$ret = preg_replace('/\W/', '_', get_class($form->getData()));
} else {
if ($form->getName()) {
return (string)$form->getName();
} else {
return preg_replace('/\W/', '_', get_class($form));
}
}
return $ret;
} | [
"public",
"function",
"getFormId",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
")",
")",
"{",
"$",
"ret",
"=",
"preg_replace",
"(",
"'/\\W/'",
",",
"'_'",
",",
"get_class",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"form",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"(",
"string",
")",
"$",
"form",
"->",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"return",
"preg_replace",
"(",
"'/\\W/'",
",",
"'_'",
",",
"get_class",
"(",
"$",
"form",
")",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Returns the ID the form's state is stored by in the session
@param \Symfony\Component\Form\FormInterface $form
@return mixed | [
"Returns",
"the",
"ID",
"the",
"form",
"s",
"state",
"is",
"stored",
"by",
"in",
"the",
"session"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L329-L341 |
37,733 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php | EmbedHelper.setFlashMessage | public function setFlashMessage(Form $form, $message, SessionInterface $session = null)
{
if (null === $session) {
trigger_error(
"Please do not rely on the container's instance of the session, but fetch it from the Request",
E_USER_DEPRECATED
);
$session = $this->session;
}
$session->getFlashBag()->set($this->getFormId($form), $message);
} | php | public function setFlashMessage(Form $form, $message, SessionInterface $session = null)
{
if (null === $session) {
trigger_error(
"Please do not rely on the container's instance of the session, but fetch it from the Request",
E_USER_DEPRECATED
);
$session = $this->session;
}
$session->getFlashBag()->set($this->getFormId($form), $message);
} | [
"public",
"function",
"setFlashMessage",
"(",
"Form",
"$",
"form",
",",
"$",
"message",
",",
"SessionInterface",
"$",
"session",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"session",
")",
"{",
"trigger_error",
"(",
"\"Please do not rely on the container's instance of the session, but fetch it from the Request\"",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
"session",
"=",
"$",
"this",
"->",
"session",
";",
"}",
"$",
"session",
"->",
"getFlashBag",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"getFormId",
"(",
"$",
"form",
")",
",",
"$",
"message",
")",
";",
"}"
] | A generic way to set flash messages.
When using this make sure you set the following parameter in your parameters.yml to avoid stacking of messages
when they are not shown or rendered in templates
session.flashbag.class: Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag
Messages will be pushed to a viewVars called 'messages' see $this->handleForm
@param Form $form
@param string $message | [
"A",
"generic",
"way",
"to",
"set",
"flash",
"messages",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L377-L387 |
37,734 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Validator/ParentValidator.php | ParentValidator.validate | public static function validate($object, ExecutionContextInterface $context)
{
if (!method_exists($object, 'getParent')) {
return;
}
$tempObject = $object->getParent();
while ($tempObject !== null) {
if ($tempObject === $object) {
$context->buildViolation(
'Circular reference error. '
. 'An object can not reference with a parent to itself nor to an ancestor of itself'
)
->atPath('parent')
->addViolation();
break;
}
$tempObject = $tempObject->getParent();
}
} | php | public static function validate($object, ExecutionContextInterface $context)
{
if (!method_exists($object, 'getParent')) {
return;
}
$tempObject = $object->getParent();
while ($tempObject !== null) {
if ($tempObject === $object) {
$context->buildViolation(
'Circular reference error. '
. 'An object can not reference with a parent to itself nor to an ancestor of itself'
)
->atPath('parent')
->addViolation();
break;
}
$tempObject = $tempObject->getParent();
}
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"object",
",",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"object",
",",
"'getParent'",
")",
")",
"{",
"return",
";",
"}",
"$",
"tempObject",
"=",
"$",
"object",
"->",
"getParent",
"(",
")",
";",
"while",
"(",
"$",
"tempObject",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"tempObject",
"===",
"$",
"object",
")",
"{",
"$",
"context",
"->",
"buildViolation",
"(",
"'Circular reference error. '",
".",
"'An object can not reference with a parent to itself nor to an ancestor of itself'",
")",
"->",
"atPath",
"(",
"'parent'",
")",
"->",
"addViolation",
"(",
")",
";",
"break",
";",
"}",
"$",
"tempObject",
"=",
"$",
"tempObject",
"->",
"getParent",
"(",
")",
";",
"}",
"}"
] | Validates parents of a MenuItem
@param object $object
@param ExecutionContextInterface $context | [
"Validates",
"parents",
"of",
"a",
"MenuItem"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Validator/ParentValidator.php#L23-L45 |
37,735 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Validator/Constraints/ContainsValidUrlsValidator.php | ContainsValidUrlsValidator.validate | public function validate($value, Constraint $constraint)
{
// collect urls
$matches = [];
// matches all urls withing a href's
preg_match_all('#<a\s+(?:[^>]*?\s+)?href="((https*:)*//[^"]*)">.*</a>#U', $value, $matches);
if (count($matches) === 0 || !isset($matches[1])) {
return;
}
$externalUrls = $matches[1];
// validate urls
foreach ($externalUrls as $externalUrl) {
if ($this->urlValidator->validate($externalUrl) === false) {
$this->context
->addViolation($constraint->message, ['%string%' => $externalUrl]);
}
}
} | php | public function validate($value, Constraint $constraint)
{
// collect urls
$matches = [];
// matches all urls withing a href's
preg_match_all('#<a\s+(?:[^>]*?\s+)?href="((https*:)*//[^"]*)">.*</a>#U', $value, $matches);
if (count($matches) === 0 || !isset($matches[1])) {
return;
}
$externalUrls = $matches[1];
// validate urls
foreach ($externalUrls as $externalUrl) {
if ($this->urlValidator->validate($externalUrl) === false) {
$this->context
->addViolation($constraint->message, ['%string%' => $externalUrl]);
}
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"// collect urls",
"$",
"matches",
"=",
"[",
"]",
";",
"// matches all urls withing a href's",
"preg_match_all",
"(",
"'#<a\\s+(?:[^>]*?\\s+)?href=\"((https*:)*//[^\"]*)\">.*</a>#U'",
",",
"$",
"value",
",",
"$",
"matches",
")",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
"===",
"0",
"||",
"!",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"externalUrls",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"// validate urls",
"foreach",
"(",
"$",
"externalUrls",
"as",
"$",
"externalUrl",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"urlValidator",
"->",
"validate",
"(",
"$",
"externalUrl",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"addViolation",
"(",
"$",
"constraint",
"->",
"message",
",",
"[",
"'%string%'",
"=>",
"$",
"externalUrl",
"]",
")",
";",
"}",
"}",
"}"
] | Checks if the passed value is valid.
Validates only urls within a href's
@param mixed $value The value that should be validated
@param Constraint $constraint The constraint for the validation | [
"Checks",
"if",
"the",
"passed",
"value",
"is",
"valid",
".",
"Validates",
"only",
"urls",
"within",
"a",
"href",
"s"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Validator/Constraints/ContainsValidUrlsValidator.php#L35-L56 |
37,736 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Doctrine/NestedTreeValidationSubscriber.php | NestedTreeValidationSubscriber.postFlush | public function postFlush(PostFlushEventArgs $e)
{
$repo = $e->getEntityManager()->getRepository($this->entityName);
if (true !== ($issues = $repo->verify())) {
throw new \UnexpectedValueException(
sprintf(
"The repository '%s' did not validate. Run the '%s' console command to find out what's going on",
$this->entityName,
RepairNestedTreeCommand::COMMAND_NAME
)
);
}
} | php | public function postFlush(PostFlushEventArgs $e)
{
$repo = $e->getEntityManager()->getRepository($this->entityName);
if (true !== ($issues = $repo->verify())) {
throw new \UnexpectedValueException(
sprintf(
"The repository '%s' did not validate. Run the '%s' console command to find out what's going on",
$this->entityName,
RepairNestedTreeCommand::COMMAND_NAME
)
);
}
} | [
"public",
"function",
"postFlush",
"(",
"PostFlushEventArgs",
"$",
"e",
")",
"{",
"$",
"repo",
"=",
"$",
"e",
"->",
"getEntityManager",
"(",
")",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"entityName",
")",
";",
"if",
"(",
"true",
"!==",
"(",
"$",
"issues",
"=",
"$",
"repo",
"->",
"verify",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"\"The repository '%s' did not validate. Run the '%s' console command to find out what's going on\"",
",",
"$",
"this",
"->",
"entityName",
",",
"RepairNestedTreeCommand",
"::",
"COMMAND_NAME",
")",
")",
";",
"}",
"}"
] | Throw an exception if the validation fails after any save
@param PostFlushEventArgs $e
@return void
@throws \UnexpectedValueException | [
"Throw",
"an",
"exception",
"if",
"the",
"validation",
"fails",
"after",
"any",
"save"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Doctrine/NestedTreeValidationSubscriber.php#L63-L75 |
37,737 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php | TranslationController.translateAction | public function translateAction(Request $request, $locale, $domain = null)
{
$queryIds = $request->query->get('id');
if ($domain) {
if ($queryIds) {
if (!is_array($queryIds)) {
$queryIds = [$queryIds];
}
$translations = $this->getTranslationsForDomainAndIds($locale, $domain, $queryIds);
} else {
$translations = $this->getTranslationsForDomain($locale, $domain);
}
} else {
$translations = $this->getTranslationsForLocale($locale);
}
return new JsonResponse(
$translations
);
} | php | public function translateAction(Request $request, $locale, $domain = null)
{
$queryIds = $request->query->get('id');
if ($domain) {
if ($queryIds) {
if (!is_array($queryIds)) {
$queryIds = [$queryIds];
}
$translations = $this->getTranslationsForDomainAndIds($locale, $domain, $queryIds);
} else {
$translations = $this->getTranslationsForDomain($locale, $domain);
}
} else {
$translations = $this->getTranslationsForLocale($locale);
}
return new JsonResponse(
$translations
);
} | [
"public",
"function",
"translateAction",
"(",
"Request",
"$",
"request",
",",
"$",
"locale",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"$",
"queryIds",
"=",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'id'",
")",
";",
"if",
"(",
"$",
"domain",
")",
"{",
"if",
"(",
"$",
"queryIds",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"queryIds",
")",
")",
"{",
"$",
"queryIds",
"=",
"[",
"$",
"queryIds",
"]",
";",
"}",
"$",
"translations",
"=",
"$",
"this",
"->",
"getTranslationsForDomainAndIds",
"(",
"$",
"locale",
",",
"$",
"domain",
",",
"$",
"queryIds",
")",
";",
"}",
"else",
"{",
"$",
"translations",
"=",
"$",
"this",
"->",
"getTranslationsForDomain",
"(",
"$",
"locale",
",",
"$",
"domain",
")",
";",
"}",
"}",
"else",
"{",
"$",
"translations",
"=",
"$",
"this",
"->",
"getTranslationsForLocale",
"(",
"$",
"locale",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"translations",
")",
";",
"}"
] | Wrapper for the translator-service
The id's and domain are optional. When withheld the controller will return all the translations for the locale and (optional) the domain
If id's are passed, they should be passed in the query-parameters, ie:
One id:
/translate/nl/messages?id=eticket.can_not_be_rendered_no_barcode
Multiple id's:
/translate/nl/messages?id[]=eticket.can_not_be_rendered_no_barcode&id[]=eticket.col1&id[]=eticket.copy_warning&id[]=form_label.form.email
@param Request $request
@param string $locale
@param string $domain
@return JsonResponse
@Route("/translate/{locale}/{domain}")
@Route("/translate/{locale}") | [
"Wrapper",
"for",
"the",
"translator",
"-",
"service"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php#L41-L62 |
37,738 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php | TranslationController.getTranslationsForDomain | private function getTranslationsForDomain($locale, $domain)
{
$allMessages = $this->getTranslationsForLocale($locale);
if (!array_key_exists($domain, $allMessages)) {
throw new \Exception('Domain ' . $domain . ' not found in the translations for locale ' . $locale);
}
return $allMessages[$domain];
} | php | private function getTranslationsForDomain($locale, $domain)
{
$allMessages = $this->getTranslationsForLocale($locale);
if (!array_key_exists($domain, $allMessages)) {
throw new \Exception('Domain ' . $domain . ' not found in the translations for locale ' . $locale);
}
return $allMessages[$domain];
} | [
"private",
"function",
"getTranslationsForDomain",
"(",
"$",
"locale",
",",
"$",
"domain",
")",
"{",
"$",
"allMessages",
"=",
"$",
"this",
"->",
"getTranslationsForLocale",
"(",
"$",
"locale",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"domain",
",",
"$",
"allMessages",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Domain '",
".",
"$",
"domain",
".",
"' not found in the translations for locale '",
".",
"$",
"locale",
")",
";",
"}",
"return",
"$",
"allMessages",
"[",
"$",
"domain",
"]",
";",
"}"
] | Retrieve all translations for the provided locale and domain
@param string $locale
@param string $domain
@return array
@throws \Exception | [
"Retrieve",
"all",
"translations",
"for",
"the",
"provided",
"locale",
"and",
"domain"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php#L93-L102 |
37,739 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.validatePublicConflictingStrategy | public static function validatePublicConflictingStrategy($conflictingPublicUrlStrategy)
{
if (!in_array($conflictingPublicUrlStrategy, [self::STRATEGY_KEEP, self::STRATEGY_OVERWRITE, self::STRATEGY_SUFFIX])) {
throw new \InvalidArgumentException("Invalid \$conflictingPublicUrlStrategy '$conflictingPublicUrlStrategy'");
}
} | php | public static function validatePublicConflictingStrategy($conflictingPublicUrlStrategy)
{
if (!in_array($conflictingPublicUrlStrategy, [self::STRATEGY_KEEP, self::STRATEGY_OVERWRITE, self::STRATEGY_SUFFIX])) {
throw new \InvalidArgumentException("Invalid \$conflictingPublicUrlStrategy '$conflictingPublicUrlStrategy'");
}
} | [
"public",
"static",
"function",
"validatePublicConflictingStrategy",
"(",
"$",
"conflictingPublicUrlStrategy",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"conflictingPublicUrlStrategy",
",",
"[",
"self",
"::",
"STRATEGY_KEEP",
",",
"self",
"::",
"STRATEGY_OVERWRITE",
",",
"self",
"::",
"STRATEGY_SUFFIX",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid \\$conflictingPublicUrlStrategy '$conflictingPublicUrlStrategy'\"",
")",
";",
"}",
"}"
] | Assert if the strategy is ok when the public url already exists.
@param string $conflictingPublicUrlStrategy
@return void | [
"Assert",
"if",
"the",
"strategy",
"is",
"ok",
"when",
"the",
"public",
"url",
"already",
"exists",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L91-L96 |
37,740 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.validateInternalConflictingStrategy | public static function validateInternalConflictingStrategy($conflictingInternalUrlStrategy)
{
if (!in_array($conflictingInternalUrlStrategy, [self::STRATEGY_IGNORE, self::STRATEGY_MOVE_PREVIOUS_TO_NEW, self::STRATEGY_MOVE_NEW_TO_PREVIOUS])) {
throw new \InvalidArgumentException("Invalid \$conflictingInternalUrlStrategy '$conflictingInternalUrlStrategy'");
}
} | php | public static function validateInternalConflictingStrategy($conflictingInternalUrlStrategy)
{
if (!in_array($conflictingInternalUrlStrategy, [self::STRATEGY_IGNORE, self::STRATEGY_MOVE_PREVIOUS_TO_NEW, self::STRATEGY_MOVE_NEW_TO_PREVIOUS])) {
throw new \InvalidArgumentException("Invalid \$conflictingInternalUrlStrategy '$conflictingInternalUrlStrategy'");
}
} | [
"public",
"static",
"function",
"validateInternalConflictingStrategy",
"(",
"$",
"conflictingInternalUrlStrategy",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"conflictingInternalUrlStrategy",
",",
"[",
"self",
"::",
"STRATEGY_IGNORE",
",",
"self",
"::",
"STRATEGY_MOVE_PREVIOUS_TO_NEW",
",",
"self",
"::",
"STRATEGY_MOVE_NEW_TO_PREVIOUS",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid \\$conflictingInternalUrlStrategy '$conflictingInternalUrlStrategy'\"",
")",
";",
"}",
"}"
] | Assert if the strategy is ok when the internal url already has a public url.
@param string $conflictingInternalUrlStrategy
@return void | [
"Assert",
"if",
"the",
"strategy",
"is",
"ok",
"when",
"the",
"internal",
"url",
"already",
"has",
"a",
"public",
"url",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L104-L109 |
37,741 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.hasInternalAlias | public function hasInternalAlias($publicUrl, $asObject = false, $mode = null)
{
$ret = null;
if (isset($this->batch[$publicUrl])) {
$alias = $this->batch[$publicUrl];
} else {
$alias = $this->repository->findOneByPublicUrl($publicUrl, $mode);
}
if ($alias) {
$ret = ($asObject ? $alias : $alias->getInternalUrl());
}
return $ret;
} | php | public function hasInternalAlias($publicUrl, $asObject = false, $mode = null)
{
$ret = null;
if (isset($this->batch[$publicUrl])) {
$alias = $this->batch[$publicUrl];
} else {
$alias = $this->repository->findOneByPublicUrl($publicUrl, $mode);
}
if ($alias) {
$ret = ($asObject ? $alias : $alias->getInternalUrl());
}
return $ret;
} | [
"public",
"function",
"hasInternalAlias",
"(",
"$",
"publicUrl",
",",
"$",
"asObject",
"=",
"false",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"$",
"ret",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"batch",
"[",
"$",
"publicUrl",
"]",
")",
")",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"batch",
"[",
"$",
"publicUrl",
"]",
";",
"}",
"else",
"{",
"$",
"alias",
"=",
"$",
"this",
"->",
"repository",
"->",
"findOneByPublicUrl",
"(",
"$",
"publicUrl",
",",
"$",
"mode",
")",
";",
"}",
"if",
"(",
"$",
"alias",
")",
"{",
"$",
"ret",
"=",
"(",
"$",
"asObject",
"?",
"$",
"alias",
":",
"$",
"alias",
"->",
"getInternalUrl",
"(",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Checks if the passed public url is currently mapped to an internal url
@param string $publicUrl
@param bool $asObject
@param null|integer $mode
@return null|string|UrlAlias | [
"Checks",
"if",
"the",
"passed",
"public",
"url",
"is",
"currently",
"mapped",
"to",
"an",
"internal",
"url"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L119-L132 |
37,742 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.hasPublicAlias | public function hasPublicAlias($internalUrl, $asObject = false, $mode = UrlAlias::REWRITE)
{
$ret = null;
if ($alias = $this->repository->findOneByInternalUrl($internalUrl, $mode)) {
$ret = ($asObject ? $alias : $alias->getPublicUrl());
}
return $ret;
} | php | public function hasPublicAlias($internalUrl, $asObject = false, $mode = UrlAlias::REWRITE)
{
$ret = null;
if ($alias = $this->repository->findOneByInternalUrl($internalUrl, $mode)) {
$ret = ($asObject ? $alias : $alias->getPublicUrl());
}
return $ret;
} | [
"public",
"function",
"hasPublicAlias",
"(",
"$",
"internalUrl",
",",
"$",
"asObject",
"=",
"false",
",",
"$",
"mode",
"=",
"UrlAlias",
"::",
"REWRITE",
")",
"{",
"$",
"ret",
"=",
"null",
";",
"if",
"(",
"$",
"alias",
"=",
"$",
"this",
"->",
"repository",
"->",
"findOneByInternalUrl",
"(",
"$",
"internalUrl",
",",
"$",
"mode",
")",
")",
"{",
"$",
"ret",
"=",
"(",
"$",
"asObject",
"?",
"$",
"alias",
":",
"$",
"alias",
"->",
"getPublicUrl",
"(",
")",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Check if the passed internal URL has a public url alias.
@param string $internalUrl
@param bool $asObject
@param integer $mode
@return null|string|UrlAlias | [
"Check",
"if",
"the",
"passed",
"internal",
"URL",
"has",
"a",
"public",
"url",
"alias",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L143-L152 |
37,743 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.findAlias | public function findAlias($publicUrl, $internalUrl)
{
$ret = null;
$params = ['public_url' => $publicUrl, 'internal_url' => $internalUrl];
if ($alias = $this->getRepository()->findOneBy($params)) {
$ret = $alias;
}
return $ret;
} | php | public function findAlias($publicUrl, $internalUrl)
{
$ret = null;
$params = ['public_url' => $publicUrl, 'internal_url' => $internalUrl];
if ($alias = $this->getRepository()->findOneBy($params)) {
$ret = $alias;
}
return $ret;
} | [
"public",
"function",
"findAlias",
"(",
"$",
"publicUrl",
",",
"$",
"internalUrl",
")",
"{",
"$",
"ret",
"=",
"null",
";",
"$",
"params",
"=",
"[",
"'public_url'",
"=>",
"$",
"publicUrl",
",",
"'internal_url'",
"=>",
"$",
"internalUrl",
"]",
";",
"if",
"(",
"$",
"alias",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"findOneBy",
"(",
"$",
"params",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"alias",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Find an alias matching both public and internal url
@param string $publicUrl
@param string $internalUrl
@return null|UrlAlias | [
"Find",
"an",
"alias",
"matching",
"both",
"public",
"and",
"internal",
"url"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L161-L171 |
37,744 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.save | protected function save(UrlAlias $alias)
{
$this->manager->persist($alias);
if ($this->isBatch) {
$this->batch[$alias->getPublicUrl()] = $alias;
} else {
$this->manager->flush($alias);
}
} | php | protected function save(UrlAlias $alias)
{
$this->manager->persist($alias);
if ($this->isBatch) {
$this->batch[$alias->getPublicUrl()] = $alias;
} else {
$this->manager->flush($alias);
}
} | [
"protected",
"function",
"save",
"(",
"UrlAlias",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"manager",
"->",
"persist",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isBatch",
")",
"{",
"$",
"this",
"->",
"batch",
"[",
"$",
"alias",
"->",
"getPublicUrl",
"(",
")",
"]",
"=",
"$",
"alias",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"manager",
"->",
"flush",
"(",
"$",
"alias",
")",
";",
"}",
"}"
] | Persist the URL alias.
@param \Zicht\Bundle\UrlBundle\Entity\UrlAlias $alias
@return void | [
"Persist",
"the",
"URL",
"alias",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L384-L393 |
37,745 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.mapContent | public function mapContent($contentType, $mode, $content, $hosts)
{
$rewriter = new Rewriter($this);
$rewriter->setLocalDomains($hosts);
foreach ($this->contentMappers as $mapper) {
if ($mapper->supports($contentType)) {
return $mapper->processAliasing($content, $mode, $rewriter);
}
}
return $content;
} | php | public function mapContent($contentType, $mode, $content, $hosts)
{
$rewriter = new Rewriter($this);
$rewriter->setLocalDomains($hosts);
foreach ($this->contentMappers as $mapper) {
if ($mapper->supports($contentType)) {
return $mapper->processAliasing($content, $mode, $rewriter);
}
}
return $content;
} | [
"public",
"function",
"mapContent",
"(",
"$",
"contentType",
",",
"$",
"mode",
",",
"$",
"content",
",",
"$",
"hosts",
")",
"{",
"$",
"rewriter",
"=",
"new",
"Rewriter",
"(",
"$",
"this",
")",
";",
"$",
"rewriter",
"->",
"setLocalDomains",
"(",
"$",
"hosts",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"contentMappers",
"as",
"$",
"mapper",
")",
"{",
"if",
"(",
"$",
"mapper",
"->",
"supports",
"(",
"$",
"contentType",
")",
")",
"{",
"return",
"$",
"mapper",
"->",
"processAliasing",
"(",
"$",
"content",
",",
"$",
"mode",
",",
"$",
"rewriter",
")",
";",
"}",
"}",
"return",
"$",
"content",
";",
"}"
] | Transform internal URLS to public URLS using our defined mappers
@param string $contentType
@param string $mode
@param string $content
@param string[] $hosts
@return string | [
"Transform",
"internal",
"URLS",
"to",
"public",
"URLS",
"using",
"our",
"defined",
"mappers"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L485-L497 |
37,746 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Rewriter.php | Rewriter.extractPath | public function extractPath($url)
{
$parts = $this->parseUrl($url);
if (!isset($parts['path'])) {
return null;
}
// ignore non-http schemes
if (isset($parts['scheme']) && !in_array($parts['scheme'], ['http', 'https'])) {
return null;
}
return $parts['path'];
} | php | public function extractPath($url)
{
$parts = $this->parseUrl($url);
if (!isset($parts['path'])) {
return null;
}
// ignore non-http schemes
if (isset($parts['scheme']) && !in_array($parts['scheme'], ['http', 'https'])) {
return null;
}
return $parts['path'];
} | [
"public",
"function",
"extractPath",
"(",
"$",
"url",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"parseUrl",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parts",
"[",
"'path'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"// ignore non-http schemes",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
")",
"&&",
"!",
"in_array",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
",",
"[",
"'http'",
",",
"'https'",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"parts",
"[",
"'path'",
"]",
";",
"}"
] | Extract the path of the URL which is considered for aliasing.
@param string $url
@return string|null | [
"Extract",
"the",
"path",
"of",
"the",
"URL",
"which",
"is",
"considered",
"for",
"aliasing",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Rewriter.php#L130-L143 |
37,747 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.transMultiple | public function transMultiple($messages, $parameters = [], $domain = null, $locale = null)
{
foreach ($messages as $message) {
yield $this->translator->trans($message, $parameters, $domain, $locale);
}
} | php | public function transMultiple($messages, $parameters = [], $domain = null, $locale = null)
{
foreach ($messages as $message) {
yield $this->translator->trans($message, $parameters, $domain, $locale);
}
} | [
"public",
"function",
"transMultiple",
"(",
"$",
"messages",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"yield",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"$",
"message",
",",
"$",
"parameters",
",",
"$",
"domain",
",",
"$",
"locale",
")",
";",
"}",
"}"
] | Translate multiple strings
@param array $messages
@param array $parameters
@param null $domain
@param null $locale
@return \Generator | [
"Translate",
"multiple",
"strings"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L177-L182 |
37,748 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.formHasErrors | public function formHasErrors(FormView $form)
{
if ($form->vars['errors']->count()) {
return true;
}
foreach ($form->children as $child) {
if ($this->formHasErrors($child)) {
return true;
}
}
return false;
} | php | public function formHasErrors(FormView $form)
{
if ($form->vars['errors']->count()) {
return true;
}
foreach ($form->children as $child) {
if ($this->formHasErrors($child)) {
return true;
}
}
return false;
} | [
"public",
"function",
"formHasErrors",
"(",
"FormView",
"$",
"form",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"vars",
"[",
"'errors'",
"]",
"->",
"count",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"form",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formHasErrors",
"(",
"$",
"child",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true when the form, or any of its children, has one or more errors.
@param FormView $form
@return bool | [
"Returns",
"true",
"when",
"the",
"form",
"or",
"any",
"of",
"its",
"children",
"has",
"one",
"or",
"more",
"errors",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L202-L215 |
37,749 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.jsonDecode | public function jsonDecode($string, $assoc = false)
{
if (is_string($string)) {
return json_decode($string, $assoc);
}
return null;
} | php | public function jsonDecode($string, $assoc = false)
{
if (is_string($string)) {
return json_decode($string, $assoc);
}
return null;
} | [
"public",
"function",
"jsonDecode",
"(",
"$",
"string",
",",
"$",
"assoc",
"=",
"false",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"return",
"json_decode",
"(",
"$",
"string",
",",
"$",
"assoc",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Call the php json_decode
@param string $string
@param bool $assoc
@return mixed|null | [
"Call",
"the",
"php",
"json_decode"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L224-L230 |
37,750 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.where | public function where($items, array $keyValuePairs, $comparator = 'eq', $booleanOperator = 'and')
{
if (is_array($items)) {
$items = new ArrayCollection($items);
}
if ($items instanceof PersistentCollection && !$items->isInitialized()) {
$items->initialize();
}
$whereMethod = $booleanOperator . 'Where';
$eb = new ExpressionBuilder();
$criteria = new Criteria();
foreach ($keyValuePairs as $key => $value) {
if (is_array($value)) {
if ($comparator === 'eq') {
$criteria->$whereMethod($eb->in($key, $value));
continue;
} elseif ($comparator === 'neq') {
$criteria->$whereMethod($eb->notIn($key, $value));
continue;
}
}
$criteria->$whereMethod($eb->$comparator($key, $value));
}
return $items->matching($criteria);
} | php | public function where($items, array $keyValuePairs, $comparator = 'eq', $booleanOperator = 'and')
{
if (is_array($items)) {
$items = new ArrayCollection($items);
}
if ($items instanceof PersistentCollection && !$items->isInitialized()) {
$items->initialize();
}
$whereMethod = $booleanOperator . 'Where';
$eb = new ExpressionBuilder();
$criteria = new Criteria();
foreach ($keyValuePairs as $key => $value) {
if (is_array($value)) {
if ($comparator === 'eq') {
$criteria->$whereMethod($eb->in($key, $value));
continue;
} elseif ($comparator === 'neq') {
$criteria->$whereMethod($eb->notIn($key, $value));
continue;
}
}
$criteria->$whereMethod($eb->$comparator($key, $value));
}
return $items->matching($criteria);
} | [
"public",
"function",
"where",
"(",
"$",
"items",
",",
"array",
"$",
"keyValuePairs",
",",
"$",
"comparator",
"=",
"'eq'",
",",
"$",
"booleanOperator",
"=",
"'and'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"items",
")",
")",
"{",
"$",
"items",
"=",
"new",
"ArrayCollection",
"(",
"$",
"items",
")",
";",
"}",
"if",
"(",
"$",
"items",
"instanceof",
"PersistentCollection",
"&&",
"!",
"$",
"items",
"->",
"isInitialized",
"(",
")",
")",
"{",
"$",
"items",
"->",
"initialize",
"(",
")",
";",
"}",
"$",
"whereMethod",
"=",
"$",
"booleanOperator",
".",
"'Where'",
";",
"$",
"eb",
"=",
"new",
"ExpressionBuilder",
"(",
")",
";",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
")",
";",
"foreach",
"(",
"$",
"keyValuePairs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"comparator",
"===",
"'eq'",
")",
"{",
"$",
"criteria",
"->",
"$",
"whereMethod",
"(",
"$",
"eb",
"->",
"in",
"(",
"$",
"key",
",",
"$",
"value",
")",
")",
";",
"continue",
";",
"}",
"elseif",
"(",
"$",
"comparator",
"===",
"'neq'",
")",
"{",
"$",
"criteria",
"->",
"$",
"whereMethod",
"(",
"$",
"eb",
"->",
"notIn",
"(",
"$",
"key",
",",
"$",
"value",
")",
")",
";",
"continue",
";",
"}",
"}",
"$",
"criteria",
"->",
"$",
"whereMethod",
"(",
"$",
"eb",
"->",
"$",
"comparator",
"(",
"$",
"key",
",",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"items",
"->",
"matching",
"(",
"$",
"criteria",
")",
";",
"}"
] | Filter a collection based on properties of the collection's items
@param array|Collection $items
@param array $keyValuePairs
@param string $comparator
@param string $booleanOperator
@return \Doctrine\Common\Collections\Collection | [
"Filter",
"a",
"collection",
"based",
"on",
"properties",
"of",
"the",
"collection",
"s",
"items"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L256-L283 |
37,751 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.whereSplit | public function whereSplit($items, $keyValuePairs)
{
return array(
$this->notWhere($items, $keyValuePairs),
$this->where($items, $keyValuePairs)
);
} | php | public function whereSplit($items, $keyValuePairs)
{
return array(
$this->notWhere($items, $keyValuePairs),
$this->where($items, $keyValuePairs)
);
} | [
"public",
"function",
"whereSplit",
"(",
"$",
"items",
",",
"$",
"keyValuePairs",
")",
"{",
"return",
"array",
"(",
"$",
"this",
"->",
"notWhere",
"(",
"$",
"items",
",",
"$",
"keyValuePairs",
")",
",",
"$",
"this",
"->",
"where",
"(",
"$",
"items",
",",
"$",
"keyValuePairs",
")",
")",
";",
"}"
] | Splits a list in two collections, one matching the criteria, and the rest
@param array|Collection $items
@param array $keyValuePairs
@return array | [
"Splits",
"a",
"list",
"in",
"two",
"collections",
"one",
"matching",
"the",
"criteria",
"and",
"the",
"rest"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L304-L310 |
37,752 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.urlToFormParameters | public function urlToFormParameters($url)
{
$query = parse_url($url, PHP_URL_QUERY);
$vars = array();
parse_str($query, $vars);
return $this->valuesToFormParameters($vars, null);
} | php | public function urlToFormParameters($url)
{
$query = parse_url($url, PHP_URL_QUERY);
$vars = array();
parse_str($query, $vars);
return $this->valuesToFormParameters($vars, null);
} | [
"public",
"function",
"urlToFormParameters",
"(",
"$",
"url",
")",
"{",
"$",
"query",
"=",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_QUERY",
")",
";",
"$",
"vars",
"=",
"array",
"(",
")",
";",
"parse_str",
"(",
"$",
"query",
",",
"$",
"vars",
")",
";",
"return",
"$",
"this",
"->",
"valuesToFormParameters",
"(",
"$",
"vars",
",",
"null",
")",
";",
"}"
] | Url to form parameters
@param string $url
@return array | [
"Url",
"to",
"form",
"parameters"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L338-L344 |
37,753 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.valuesToFormParameters | private function valuesToFormParameters($values, $parent)
{
$ret = array();
foreach ($values as $key => $value) {
if (null !== $parent) {
$keyName = sprintf('%s[%s]', $parent, $key);
} else {
$keyName = $key;
}
if (is_scalar($value)) {
$ret[$keyName] = $value;
} else {
$ret = array_merge($ret, $this->valuesToFormParameters($value, $keyName));
}
}
return $ret;
} | php | private function valuesToFormParameters($values, $parent)
{
$ret = array();
foreach ($values as $key => $value) {
if (null !== $parent) {
$keyName = sprintf('%s[%s]', $parent, $key);
} else {
$keyName = $key;
}
if (is_scalar($value)) {
$ret[$keyName] = $value;
} else {
$ret = array_merge($ret, $this->valuesToFormParameters($value, $keyName));
}
}
return $ret;
} | [
"private",
"function",
"valuesToFormParameters",
"(",
"$",
"values",
",",
"$",
"parent",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"parent",
")",
"{",
"$",
"keyName",
"=",
"sprintf",
"(",
"'%s[%s]'",
",",
"$",
"parent",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"keyName",
"=",
"$",
"key",
";",
"}",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"$",
"ret",
"[",
"$",
"keyName",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"array_merge",
"(",
"$",
"ret",
",",
"$",
"this",
"->",
"valuesToFormParameters",
"(",
"$",
"value",
",",
"$",
"keyName",
")",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Prepares a nested array for use in form fields.
@param mixed[] $values
@param string $parent
@return array | [
"Prepares",
"a",
"nested",
"array",
"for",
"use",
"in",
"form",
"fields",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L353-L369 |
37,754 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.embeddedImage | public function embeddedImage($filename)
{
if (is_file($filename) && preg_match('/[.](?P<extension>[a-zA-Z0-9]+)$/', $filename, $matches)) {
return sprintf('data:image/%s;base64,%s', $matches['extension'], base64_encode(file_get_contents($filename)));
}
return null;
} | php | public function embeddedImage($filename)
{
if (is_file($filename) && preg_match('/[.](?P<extension>[a-zA-Z0-9]+)$/', $filename, $matches)) {
return sprintf('data:image/%s;base64,%s', $matches['extension'], base64_encode(file_get_contents($filename)));
}
return null;
} | [
"public",
"function",
"embeddedImage",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"filename",
")",
"&&",
"preg_match",
"(",
"'/[.](?P<extension>[a-zA-Z0-9]+)$/'",
",",
"$",
"filename",
",",
"$",
"matches",
")",
")",
"{",
"return",
"sprintf",
"(",
"'data:image/%s;base64,%s'",
",",
"$",
"matches",
"[",
"'extension'",
"]",
",",
"base64_encode",
"(",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Given an existing file, returns an embedded data stream, or null when the file does not exist
For example
{{ embedded_image('foo.jpg') }}
--> "data:image/jpg;base64,BLABLABLA"
@param string $filename
@return null|string | [
"Given",
"an",
"existing",
"file",
"returns",
"an",
"embedded",
"data",
"stream",
"or",
"null",
"when",
"the",
"file",
"does",
"not",
"exist"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L396-L403 |
37,755 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.isGranted | public function isGranted($role, $object = null, $field = null)
{
if (null !== $field) {
$object = new FieldVote($object, $field);
}
return $this->authChecker->isGranted($role, $object);
} | php | public function isGranted($role, $object = null, $field = null)
{
if (null !== $field) {
$object = new FieldVote($object, $field);
}
return $this->authChecker->isGranted($role, $object);
} | [
"public",
"function",
"isGranted",
"(",
"$",
"role",
",",
"$",
"object",
"=",
"null",
",",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"field",
")",
"{",
"$",
"object",
"=",
"new",
"FieldVote",
"(",
"$",
"object",
",",
"$",
"field",
")",
";",
"}",
"return",
"$",
"this",
"->",
"authChecker",
"->",
"isGranted",
"(",
"$",
"role",
",",
"$",
"object",
")",
";",
"}"
] | The template may assume that the role will be denied when there is no security context, therefore we override
the default behaviour here.
@param string $role
@param mixed $object
@param mixed $field
@return bool | [
"The",
"template",
"may",
"assume",
"that",
"the",
"role",
"will",
"be",
"denied",
"when",
"there",
"is",
"no",
"security",
"context",
"therefore",
"we",
"override",
"the",
"default",
"behaviour",
"here",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L414-L420 |
37,756 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.gaTrackEvent | public function gaTrackEvent($values = null)
{
$values = func_get_args();
array_unshift($values, '_trackEvent');
return sprintf(
' onclick="_gaq.push(%s);"',
htmlspecialchars(json_encode(array_values($values)))
);
} | php | public function gaTrackEvent($values = null)
{
$values = func_get_args();
array_unshift($values, '_trackEvent');
return sprintf(
' onclick="_gaq.push(%s);"',
htmlspecialchars(json_encode(array_values($values)))
);
} | [
"public",
"function",
"gaTrackEvent",
"(",
"$",
"values",
"=",
"null",
")",
"{",
"$",
"values",
"=",
"func_get_args",
"(",
")",
";",
"array_unshift",
"(",
"$",
"values",
",",
"'_trackEvent'",
")",
";",
"return",
"sprintf",
"(",
"' onclick=\"_gaq.push(%s);\"'",
",",
"htmlspecialchars",
"(",
"json_encode",
"(",
"array_values",
"(",
"$",
"values",
")",
")",
")",
")",
";",
"}"
] | Formats some values as an 'onclick' attribute for Google Analytics
@param null $values
@return string | [
"Formats",
"some",
"values",
"as",
"an",
"onclick",
"attribute",
"for",
"Google",
"Analytics"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L447-L456 |
37,757 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.sortByType | public function sortByType($collection, $types)
{
if ($collection instanceof \Traversable) {
$collection = iterator_to_array($collection);
}
// store a map of the original sorting, so the usort can use this to keep the original sorting if the types are
// equal
$idToIndexMap = array();
foreach ($collection as $index => $item) {
$idToIndexMap[$item->getId()] = $index;
}
$numTypes = count($types);
usort(
$collection,
function ($left, $right) use ($types, $idToIndexMap, $numTypes) {
$localClassNameLeft = Str::classname(get_class($left));
$localClassNameRight = Str::classname(get_class($right));
// if same type, use original sorting
if ($localClassNameRight === $localClassNameLeft) {
$indexLeft = $idToIndexMap[$left->getId()];
$indexRight = $idToIndexMap[$right->getId()];
} else {
$indexLeft = array_search($localClassNameLeft, $types);
$indexRight = array_search($localClassNameRight, $types);
// assume that types that aren't defined, should come last.
if (false === $indexLeft) {
$indexLeft = $numTypes + 1;
}
if (false === $indexRight) {
$indexRight = $numTypes + 1;
}
}
if ($indexLeft < $indexRight) {
return -1;
}
if ($indexLeft > $indexRight) {
return 1;
}
return 0;
}
);
return $collection;
} | php | public function sortByType($collection, $types)
{
if ($collection instanceof \Traversable) {
$collection = iterator_to_array($collection);
}
// store a map of the original sorting, so the usort can use this to keep the original sorting if the types are
// equal
$idToIndexMap = array();
foreach ($collection as $index => $item) {
$idToIndexMap[$item->getId()] = $index;
}
$numTypes = count($types);
usort(
$collection,
function ($left, $right) use ($types, $idToIndexMap, $numTypes) {
$localClassNameLeft = Str::classname(get_class($left));
$localClassNameRight = Str::classname(get_class($right));
// if same type, use original sorting
if ($localClassNameRight === $localClassNameLeft) {
$indexLeft = $idToIndexMap[$left->getId()];
$indexRight = $idToIndexMap[$right->getId()];
} else {
$indexLeft = array_search($localClassNameLeft, $types);
$indexRight = array_search($localClassNameRight, $types);
// assume that types that aren't defined, should come last.
if (false === $indexLeft) {
$indexLeft = $numTypes + 1;
}
if (false === $indexRight) {
$indexRight = $numTypes + 1;
}
}
if ($indexLeft < $indexRight) {
return -1;
}
if ($indexLeft > $indexRight) {
return 1;
}
return 0;
}
);
return $collection;
} | [
"public",
"function",
"sortByType",
"(",
"$",
"collection",
",",
"$",
"types",
")",
"{",
"if",
"(",
"$",
"collection",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"collection",
"=",
"iterator_to_array",
"(",
"$",
"collection",
")",
";",
"}",
"// store a map of the original sorting, so the usort can use this to keep the original sorting if the types are",
"// equal",
"$",
"idToIndexMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"index",
"=>",
"$",
"item",
")",
"{",
"$",
"idToIndexMap",
"[",
"$",
"item",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"index",
";",
"}",
"$",
"numTypes",
"=",
"count",
"(",
"$",
"types",
")",
";",
"usort",
"(",
"$",
"collection",
",",
"function",
"(",
"$",
"left",
",",
"$",
"right",
")",
"use",
"(",
"$",
"types",
",",
"$",
"idToIndexMap",
",",
"$",
"numTypes",
")",
"{",
"$",
"localClassNameLeft",
"=",
"Str",
"::",
"classname",
"(",
"get_class",
"(",
"$",
"left",
")",
")",
";",
"$",
"localClassNameRight",
"=",
"Str",
"::",
"classname",
"(",
"get_class",
"(",
"$",
"right",
")",
")",
";",
"// if same type, use original sorting",
"if",
"(",
"$",
"localClassNameRight",
"===",
"$",
"localClassNameLeft",
")",
"{",
"$",
"indexLeft",
"=",
"$",
"idToIndexMap",
"[",
"$",
"left",
"->",
"getId",
"(",
")",
"]",
";",
"$",
"indexRight",
"=",
"$",
"idToIndexMap",
"[",
"$",
"right",
"->",
"getId",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"indexLeft",
"=",
"array_search",
"(",
"$",
"localClassNameLeft",
",",
"$",
"types",
")",
";",
"$",
"indexRight",
"=",
"array_search",
"(",
"$",
"localClassNameRight",
",",
"$",
"types",
")",
";",
"// assume that types that aren't defined, should come last.",
"if",
"(",
"false",
"===",
"$",
"indexLeft",
")",
"{",
"$",
"indexLeft",
"=",
"$",
"numTypes",
"+",
"1",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"indexRight",
")",
"{",
"$",
"indexRight",
"=",
"$",
"numTypes",
"+",
"1",
";",
"}",
"}",
"if",
"(",
"$",
"indexLeft",
"<",
"$",
"indexRight",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"$",
"indexLeft",
">",
"$",
"indexRight",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0",
";",
"}",
")",
";",
"return",
"$",
"collection",
";",
"}"
] | Sort by type
@param array|object $collection
@param array $types
@return array | [
"Sort",
"by",
"type"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L465-L514 |
37,758 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.strDash | public function strDash($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::dash($str);
} | php | public function strDash($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::dash($str);
} | [
"public",
"function",
"strDash",
"(",
"$",
"str",
",",
"$",
"camelFirst",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"camelFirst",
")",
"{",
"$",
"str",
"=",
"StrUtil",
"::",
"camel",
"(",
"$",
"str",
")",
";",
"}",
"return",
"StrUtil",
"::",
"dash",
"(",
"$",
"str",
")",
";",
"}"
] | Dash to CamelCase
@param string $str
@param bool $camelFirst
@return string | [
"Dash",
"to",
"CamelCase"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L523-L529 |
37,759 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.strUscore | public function strUscore($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::uscore($str);
} | php | public function strUscore($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::uscore($str);
} | [
"public",
"function",
"strUscore",
"(",
"$",
"str",
",",
"$",
"camelFirst",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"camelFirst",
")",
"{",
"$",
"str",
"=",
"StrUtil",
"::",
"camel",
"(",
"$",
"str",
")",
";",
"}",
"return",
"StrUtil",
"::",
"uscore",
"(",
"$",
"str",
")",
";",
"}"
] | CamelCased to under_score
@param string $str
@param bool $camelFirst
@return string | [
"CamelCased",
"to",
"under_score"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L538-L544 |
37,760 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.truncate | public function truncate($str, $length, $ellipsis = '...')
{
$result = '';
foreach (preg_split('/\b/U', $str) as $part) {
if (strlen($result . $part) > $length) {
$result = rtrim($result) . $ellipsis;
break;
} else {
$result .= $part;
}
}
return $result;
} | php | public function truncate($str, $length, $ellipsis = '...')
{
$result = '';
foreach (preg_split('/\b/U', $str) as $part) {
if (strlen($result . $part) > $length) {
$result = rtrim($result) . $ellipsis;
break;
} else {
$result .= $part;
}
}
return $result;
} | [
"public",
"function",
"truncate",
"(",
"$",
"str",
",",
"$",
"length",
",",
"$",
"ellipsis",
"=",
"'...'",
")",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"preg_split",
"(",
"'/\\b/U'",
",",
"$",
"str",
")",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"result",
".",
"$",
"part",
")",
">",
"$",
"length",
")",
"{",
"$",
"result",
"=",
"rtrim",
"(",
"$",
"result",
")",
".",
"$",
"ellipsis",
";",
"break",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"$",
"part",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Truncate text at a maximum length, splitting by words, and add an ellipsis "...".
@param string $str
@param int $length
@param string $ellipsis
@return string | [
"Truncate",
"text",
"at",
"a",
"maximum",
"length",
"splitting",
"by",
"words",
"and",
"add",
"an",
"ellipsis",
"...",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L650-L663 |
37,761 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.truncateHtml | public function truncateHtml($html, $length, $ellipsis = '...')
{
return $this->truncate(html_entity_decode(strip_tags($html), null, 'UTF-8'), $length, $ellipsis);
} | php | public function truncateHtml($html, $length, $ellipsis = '...')
{
return $this->truncate(html_entity_decode(strip_tags($html), null, 'UTF-8'), $length, $ellipsis);
} | [
"public",
"function",
"truncateHtml",
"(",
"$",
"html",
",",
"$",
"length",
",",
"$",
"ellipsis",
"=",
"'...'",
")",
"{",
"return",
"$",
"this",
"->",
"truncate",
"(",
"html_entity_decode",
"(",
"strip_tags",
"(",
"$",
"html",
")",
",",
"null",
",",
"'UTF-8'",
")",
",",
"$",
"length",
",",
"$",
"ellipsis",
")",
";",
"}"
] | Truncates html as text
@param string $html
@param int $length
@param string $ellipsis
@return string | [
"Truncates",
"html",
"as",
"text"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L673-L676 |
37,762 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.dump | public function dump($var, $mode = null)
{
if (null === $mode && class_exists('Zicht\Util\Debug')) {
return htmlspecialchars(Debug::dump($var));
} else {
switch ($mode) {
case 'export':
VarDumper::dump($var);
break;
default:
var_dump($var);
break;
}
}
return null;
} | php | public function dump($var, $mode = null)
{
if (null === $mode && class_exists('Zicht\Util\Debug')) {
return htmlspecialchars(Debug::dump($var));
} else {
switch ($mode) {
case 'export':
VarDumper::dump($var);
break;
default:
var_dump($var);
break;
}
}
return null;
} | [
"public",
"function",
"dump",
"(",
"$",
"var",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"mode",
"&&",
"class_exists",
"(",
"'Zicht\\Util\\Debug'",
")",
")",
"{",
"return",
"htmlspecialchars",
"(",
"Debug",
"::",
"dump",
"(",
"$",
"var",
")",
")",
";",
"}",
"else",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"'export'",
":",
"VarDumper",
"::",
"dump",
"(",
"$",
"var",
")",
";",
"break",
";",
"default",
":",
"var_dump",
"(",
"$",
"var",
")",
";",
"break",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Dumps given variable in styled format
@param mixed $var
@param string $mode
@return mixed | [
"Dumps",
"given",
"variable",
"in",
"styled",
"format"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L773-L788 |
37,763 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Entity/Repository/StaticReferenceRepository.php | StaticReferenceRepository.getAll | public function getAll($locale)
{
$qb = $this->createQueryBuilder('r');
$qb->addSelect('t');
$qb->innerJoin('r.translations', 't');
$qb->andWhere('t.locale=:locale');
$qb->setParameter(':locale', $locale);
return $qb->getQuery()->execute();
} | php | public function getAll($locale)
{
$qb = $this->createQueryBuilder('r');
$qb->addSelect('t');
$qb->innerJoin('r.translations', 't');
$qb->andWhere('t.locale=:locale');
$qb->setParameter(':locale', $locale);
return $qb->getQuery()->execute();
} | [
"public",
"function",
"getAll",
"(",
"$",
"locale",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'r'",
")",
";",
"$",
"qb",
"->",
"addSelect",
"(",
"'t'",
")",
";",
"$",
"qb",
"->",
"innerJoin",
"(",
"'r.translations'",
",",
"'t'",
")",
";",
"$",
"qb",
"->",
"andWhere",
"(",
"'t.locale=:locale'",
")",
";",
"$",
"qb",
"->",
"setParameter",
"(",
"':locale'",
",",
"$",
"locale",
")",
";",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Returns the references for the specified locale
@param string $locale
@return mixed | [
"Returns",
"the",
"references",
"for",
"the",
"specified",
"locale"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Entity/Repository/StaticReferenceRepository.php#L20-L30 |
37,764 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php | AbstractAliasingTransformer.transform | public function transform($data)
{
if (self::MODE_TO_PUBLIC === (self::MODE_TO_PUBLIC & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC);
} else {
return $data;
}
} | php | public function transform($data)
{
if (self::MODE_TO_PUBLIC === (self::MODE_TO_PUBLIC & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC);
} else {
return $data;
}
} | [
"public",
"function",
"transform",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"self",
"::",
"MODE_TO_PUBLIC",
"===",
"(",
"self",
"::",
"MODE_TO_PUBLIC",
"&",
"$",
"this",
"->",
"mode",
")",
")",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"data",
",",
"UrlMapperInterface",
"::",
"MODE_INTERNAL_TO_PUBLIC",
")",
";",
"}",
"else",
"{",
"return",
"$",
"data",
";",
"}",
"}"
] | Transforms a string containing internal urls to string to public urls.
@param string $data
@return null|string | [
"Transforms",
"a",
"string",
"containing",
"internal",
"urls",
"to",
"string",
"to",
"public",
"urls",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php#L45-L52 |
37,765 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php | AbstractAliasingTransformer.reverseTransform | public function reverseTransform($data)
{
if (self::MODE_TO_INTERNAL === (self::MODE_TO_INTERNAL & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_PUBLIC_TO_INTERNAL);
} else {
return $data;
}
} | php | public function reverseTransform($data)
{
if (self::MODE_TO_INTERNAL === (self::MODE_TO_INTERNAL & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_PUBLIC_TO_INTERNAL);
} else {
return $data;
}
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"self",
"::",
"MODE_TO_INTERNAL",
"===",
"(",
"self",
"::",
"MODE_TO_INTERNAL",
"&",
"$",
"this",
"->",
"mode",
")",
")",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"data",
",",
"UrlMapperInterface",
"::",
"MODE_PUBLIC_TO_INTERNAL",
")",
";",
"}",
"else",
"{",
"return",
"$",
"data",
";",
"}",
"}"
] | Tranforms a string containing public urls to string with internal urls.
@param string $data
@return null|string | [
"Tranforms",
"a",
"string",
"containing",
"public",
"urls",
"to",
"string",
"with",
"internal",
"urls",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php#L60-L67 |
37,766 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php | AbstractAliasingTransformer.map | final public function map($data, $mode)
{
if (null === $data) {
return $data;
}
return $this->doMap($data, $mode);
} | php | final public function map($data, $mode)
{
if (null === $data) {
return $data;
}
return $this->doMap($data, $mode);
} | [
"final",
"public",
"function",
"map",
"(",
"$",
"data",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"data",
")",
"{",
"return",
"$",
"data",
";",
"}",
"return",
"$",
"this",
"->",
"doMap",
"(",
"$",
"data",
",",
"$",
"mode",
")",
";",
"}"
] | Wraps the doMap to defend for the 'null'-value case
@param string $data
@param string $mode
@return string | [
"Wraps",
"the",
"doMap",
"to",
"defend",
"for",
"the",
"null",
"-",
"value",
"case"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php#L76-L83 |
37,767 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Admin/AliasOverviewType.php | AliasOverviewType.getUrlAliases | protected function getUrlAliases($object)
{
try {
$internalUrl = $this->provider->url($object);
} catch (UnsupportedException $exception) {
return [];
}
return $this
->doctrine
->getRepository('ZichtUrlBundle:UrlAlias')
->findAllByInternalUrl($internalUrl);
} | php | protected function getUrlAliases($object)
{
try {
$internalUrl = $this->provider->url($object);
} catch (UnsupportedException $exception) {
return [];
}
return $this
->doctrine
->getRepository('ZichtUrlBundle:UrlAlias')
->findAllByInternalUrl($internalUrl);
} | [
"protected",
"function",
"getUrlAliases",
"(",
"$",
"object",
")",
"{",
"try",
"{",
"$",
"internalUrl",
"=",
"$",
"this",
"->",
"provider",
"->",
"url",
"(",
"$",
"object",
")",
";",
"}",
"catch",
"(",
"UnsupportedException",
"$",
"exception",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"doctrine",
"->",
"getRepository",
"(",
"'ZichtUrlBundle:UrlAlias'",
")",
"->",
"findAllByInternalUrl",
"(",
"$",
"internalUrl",
")",
";",
"}"
] | Returns all UrlAlias entities associated to an object
@param mixed $object
@return mixed | [
"Returns",
"all",
"UrlAlias",
"entities",
"associated",
"to",
"an",
"object"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Admin/AliasOverviewType.php#L88-L100 |
37,768 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/TextTransformer.php | TextTransformer.doMap | protected function doMap($text, $mode)
{
$map = $this->aliasing->getAliasingMap([$text], $mode);
if (count($map) === 1) {
return current($map);
}
return $text;
} | php | protected function doMap($text, $mode)
{
$map = $this->aliasing->getAliasingMap([$text], $mode);
if (count($map) === 1) {
return current($map);
}
return $text;
} | [
"protected",
"function",
"doMap",
"(",
"$",
"text",
",",
"$",
"mode",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"aliasing",
"->",
"getAliasingMap",
"(",
"[",
"$",
"text",
"]",
",",
"$",
"mode",
")",
";",
"if",
"(",
"count",
"(",
"$",
"map",
")",
"===",
"1",
")",
"{",
"return",
"current",
"(",
"$",
"map",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | Delegates the text mapping to the aliasing service.
@param string $text
@param string $mode
@return mixed|null | [
"Delegates",
"the",
"text",
"mapping",
"to",
"the",
"aliasing",
"service",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/TextTransformer.php#L19-L28 |
37,769 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php | DbStaticProvider.addAll | public function addAll()
{
// Make sure refs are not null any more, else it keeps checking on every static ref
$this->refs = [];
/** @var StaticReference $repos */
$references = $this->em->getRepository('ZichtUrlBundle:StaticReference')->getAll($this->getLocale());
foreach ($references as $static_reference) {
foreach ($static_reference->getTranslations() as $translation) {
$this->refs[$static_reference->getMachineName()][$translation->getLocale()] = $translation->getUrl();
}
}
} | php | public function addAll()
{
// Make sure refs are not null any more, else it keeps checking on every static ref
$this->refs = [];
/** @var StaticReference $repos */
$references = $this->em->getRepository('ZichtUrlBundle:StaticReference')->getAll($this->getLocale());
foreach ($references as $static_reference) {
foreach ($static_reference->getTranslations() as $translation) {
$this->refs[$static_reference->getMachineName()][$translation->getLocale()] = $translation->getUrl();
}
}
} | [
"public",
"function",
"addAll",
"(",
")",
"{",
"// Make sure refs are not null any more, else it keeps checking on every static ref",
"$",
"this",
"->",
"refs",
"=",
"[",
"]",
";",
"/** @var StaticReference $repos */",
"$",
"references",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"'ZichtUrlBundle:StaticReference'",
")",
"->",
"getAll",
"(",
"$",
"this",
"->",
"getLocale",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"references",
"as",
"$",
"static_reference",
")",
"{",
"foreach",
"(",
"$",
"static_reference",
"->",
"getTranslations",
"(",
")",
"as",
"$",
"translation",
")",
"{",
"$",
"this",
"->",
"refs",
"[",
"$",
"static_reference",
"->",
"getMachineName",
"(",
")",
"]",
"[",
"$",
"translation",
"->",
"getLocale",
"(",
")",
"]",
"=",
"$",
"translation",
"->",
"getUrl",
"(",
")",
";",
"}",
"}",
"}"
] | Add the array as references
@return void | [
"Add",
"the",
"array",
"as",
"references"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php#L59-L72 |
37,770 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php | DbStaticProvider.getLocale | public function getLocale()
{
if (null !== ($request = $this->getMasterRequest())) {
$locale = $request->get('_locale');
}
if (!isset($locale)) {
$locale = $this->fallback_locale;
}
return $locale;
} | php | public function getLocale()
{
if (null !== ($request = $this->getMasterRequest())) {
$locale = $request->get('_locale');
}
if (!isset($locale)) {
$locale = $this->fallback_locale;
}
return $locale;
} | [
"public",
"function",
"getLocale",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"request",
"=",
"$",
"this",
"->",
"getMasterRequest",
"(",
")",
")",
")",
"{",
"$",
"locale",
"=",
"$",
"request",
"->",
"get",
"(",
"'_locale'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"locale",
")",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"fallback_locale",
";",
"}",
"return",
"$",
"locale",
";",
"}"
] | Returns the locale parameter for the current request, if any.
@return mixed | [
"Returns",
"the",
"locale",
"parameter",
"for",
"the",
"current",
"request",
"if",
"any",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php#L106-L117 |
37,771 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php | UriParser.parsePost | public function parsePost(array $post)
{
$ret = [];
foreach ($post as $key => $value) {
if ($key) {
$external = $this->translateKeyOutput($key);
$ret[$key] = [];
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = $value;
}
}
}
return $ret;
} | php | public function parsePost(array $post)
{
$ret = [];
foreach ($post as $key => $value) {
if ($key) {
$external = $this->translateKeyOutput($key);
$ret[$key] = [];
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = $value;
}
}
}
return $ret;
} | [
"public",
"function",
"parsePost",
"(",
"array",
"$",
"post",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"post",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"external",
"=",
"$",
"this",
"->",
"translateKeyOutput",
"(",
"$",
"key",
")",
";",
"$",
"ret",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
">",
"0",
")",
"{",
"if",
"(",
"$",
"internal",
"=",
"$",
"this",
"->",
"translateValueInput",
"(",
"$",
"external",
",",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"internal",
";",
"}",
"$",
"ret",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | POST keys are not translated, but do translate the values
@param array $post
@return array | [
"POST",
"keys",
"are",
"not",
"translated",
"but",
"do",
"translate",
"the",
"values"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php#L50-L67 |
37,772 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php | UriParser.parseUri | public function parseUri($uri)
{
$ret = [];
foreach (explode($this->seperators['param'], $uri) as $params) {
if ($params) {
@list($key, $values) = explode($this->seperators['key_value'], $params, 2);
$external = $key;
if ($internal = $this->translateKeyInput($key)) {
$key = $internal;
}
$ret[$key] = [];
foreach (explode($this->seperators['value'], $values) as $value) {
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = urldecode($value);
}
}
}
}
return $ret;
} | php | public function parseUri($uri)
{
$ret = [];
foreach (explode($this->seperators['param'], $uri) as $params) {
if ($params) {
@list($key, $values) = explode($this->seperators['key_value'], $params, 2);
$external = $key;
if ($internal = $this->translateKeyInput($key)) {
$key = $internal;
}
$ret[$key] = [];
foreach (explode($this->seperators['value'], $values) as $value) {
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = urldecode($value);
}
}
}
}
return $ret;
} | [
"public",
"function",
"parseUri",
"(",
"$",
"uri",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"$",
"this",
"->",
"seperators",
"[",
"'param'",
"]",
",",
"$",
"uri",
")",
"as",
"$",
"params",
")",
"{",
"if",
"(",
"$",
"params",
")",
"{",
"@",
"list",
"(",
"$",
"key",
",",
"$",
"values",
")",
"=",
"explode",
"(",
"$",
"this",
"->",
"seperators",
"[",
"'key_value'",
"]",
",",
"$",
"params",
",",
"2",
")",
";",
"$",
"external",
"=",
"$",
"key",
";",
"if",
"(",
"$",
"internal",
"=",
"$",
"this",
"->",
"translateKeyInput",
"(",
"$",
"key",
")",
")",
"{",
"$",
"key",
"=",
"$",
"internal",
";",
"}",
"$",
"ret",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"$",
"this",
"->",
"seperators",
"[",
"'value'",
"]",
",",
"$",
"values",
")",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
">",
"0",
")",
"{",
"if",
"(",
"$",
"internal",
"=",
"$",
"this",
"->",
"translateValueInput",
"(",
"$",
"external",
",",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"internal",
";",
"}",
"$",
"ret",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"urldecode",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Parse the uri
@param string $uri
@return array | [
"Parse",
"the",
"uri"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php#L75-L98 |
37,773 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/DelegatingProvider.php | DelegatingProvider.addProvider | public function addProvider(Provider $provider, $priority = 0)
{
$this->providers[$priority][] = $provider;
ksort($this->providers);
} | php | public function addProvider(Provider $provider, $priority = 0)
{
$this->providers[$priority][] = $provider;
ksort($this->providers);
} | [
"public",
"function",
"addProvider",
"(",
"Provider",
"$",
"provider",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"providers",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"$",
"provider",
";",
"ksort",
"(",
"$",
"this",
"->",
"providers",
")",
";",
"}"
] | Add a provider with the specified priority. Higher priority means exactly that ;)
@param Provider $provider
@param int $priority
@return void | [
"Add",
"a",
"provider",
"with",
"the",
"specified",
"priority",
".",
"Higher",
"priority",
"means",
"exactly",
"that",
";",
")"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/DelegatingProvider.php#L36-L40 |
37,774 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php | UrlValidator.validate | public function validate($url)
{
if (null !== ($headers = $this->getHeader($url))) {
$statusCode = $this->getStatusCode($headers);
// see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
return ($statusCode >= 200 && $statusCode < 300);
}
return false;
} | php | public function validate($url)
{
if (null !== ($headers = $this->getHeader($url))) {
$statusCode = $this->getStatusCode($headers);
// see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
return ($statusCode >= 200 && $statusCode < 300);
}
return false;
} | [
"public",
"function",
"validate",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"headers",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"$",
"url",
")",
")",
")",
"{",
"$",
"statusCode",
"=",
"$",
"this",
"->",
"getStatusCode",
"(",
"$",
"headers",
")",
";",
"// see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"return",
"(",
"$",
"statusCode",
">=",
"200",
"&&",
"$",
"statusCode",
"<",
"300",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true when url does not return error codes or not found.
@param string $url
@return boolean | [
"Returns",
"true",
"when",
"url",
"does",
"not",
"return",
"error",
"codes",
"or",
"not",
"found",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php#L16-L24 |
37,775 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php | UrlValidator.getStatusCode | protected function getStatusCode(array $headers)
{
$status = 0;
foreach ($headers as $header) {
if (preg_match('#^HTTP/(?:[^\s]+)\s(?P<code>\d+)\s#', $header, $match)) {
$status = (int)$match['code'];
}
}
return $status;
} | php | protected function getStatusCode(array $headers)
{
$status = 0;
foreach ($headers as $header) {
if (preg_match('#^HTTP/(?:[^\s]+)\s(?P<code>\d+)\s#', $header, $match)) {
$status = (int)$match['code'];
}
}
return $status;
} | [
"protected",
"function",
"getStatusCode",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"status",
"=",
"0",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#^HTTP/(?:[^\\s]+)\\s(?P<code>\\d+)\\s#'",
",",
"$",
"header",
",",
"$",
"match",
")",
")",
"{",
"$",
"status",
"=",
"(",
"int",
")",
"$",
"match",
"[",
"'code'",
"]",
";",
"}",
"}",
"return",
"$",
"status",
";",
"}"
] | Parse the headers array and search for the status pattern
@param array $headers
@return int | [
"Parse",
"the",
"headers",
"array",
"and",
"search",
"for",
"the",
"status",
"pattern"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php#L47-L56 |
37,776 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php | Aliaser.createAlias | public function createAlias($record, $action = ['VIEW'])
{
$internalUrl = $this->provider->url($record);
if (in_array($internalUrl, $this->recursionProtection)) {
return false;
}
$this->recursionProtection[] = $internalUrl;
if ($this->shouldGenerateAlias($record, $action)) {
// Don't save an alias if the generated public alias is null
if (null !== ($generatedAlias = $this->aliasingStrategy->generatePublicAlias($record))) {
return $this->aliasing->addAlias(
$generatedAlias,
$internalUrl,
UrlAlias::REWRITE,
$this->conflictingPublicUrlStrategy,
$this->conflictingInternalUrlStrategy
);
}
}
return false;
} | php | public function createAlias($record, $action = ['VIEW'])
{
$internalUrl = $this->provider->url($record);
if (in_array($internalUrl, $this->recursionProtection)) {
return false;
}
$this->recursionProtection[] = $internalUrl;
if ($this->shouldGenerateAlias($record, $action)) {
// Don't save an alias if the generated public alias is null
if (null !== ($generatedAlias = $this->aliasingStrategy->generatePublicAlias($record))) {
return $this->aliasing->addAlias(
$generatedAlias,
$internalUrl,
UrlAlias::REWRITE,
$this->conflictingPublicUrlStrategy,
$this->conflictingInternalUrlStrategy
);
}
}
return false;
} | [
"public",
"function",
"createAlias",
"(",
"$",
"record",
",",
"$",
"action",
"=",
"[",
"'VIEW'",
"]",
")",
"{",
"$",
"internalUrl",
"=",
"$",
"this",
"->",
"provider",
"->",
"url",
"(",
"$",
"record",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"internalUrl",
",",
"$",
"this",
"->",
"recursionProtection",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"recursionProtection",
"[",
"]",
"=",
"$",
"internalUrl",
";",
"if",
"(",
"$",
"this",
"->",
"shouldGenerateAlias",
"(",
"$",
"record",
",",
"$",
"action",
")",
")",
"{",
"// Don't save an alias if the generated public alias is null",
"if",
"(",
"null",
"!==",
"(",
"$",
"generatedAlias",
"=",
"$",
"this",
"->",
"aliasingStrategy",
"->",
"generatePublicAlias",
"(",
"$",
"record",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"aliasing",
"->",
"addAlias",
"(",
"$",
"generatedAlias",
",",
"$",
"internalUrl",
",",
"UrlAlias",
"::",
"REWRITE",
",",
"$",
"this",
"->",
"conflictingPublicUrlStrategy",
",",
"$",
"this",
"->",
"conflictingInternalUrlStrategy",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Create an alias for the provided object.
@param mixed $record
@param array $action
@return bool Whether or not an alias was created. | [
"Create",
"an",
"alias",
"for",
"the",
"provided",
"object",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php#L97-L121 |
37,777 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php | Aliaser.shouldGenerateAlias | public function shouldGenerateAlias($record, array $action = ['VIEW'])
{
// without security, everything is considered public
if (null === $this->decisionManager) {
return true;
}
return $this->decisionManager->decide(new AnonymousToken('main', 'anonymous'), $action, $record);
} | php | public function shouldGenerateAlias($record, array $action = ['VIEW'])
{
// without security, everything is considered public
if (null === $this->decisionManager) {
return true;
}
return $this->decisionManager->decide(new AnonymousToken('main', 'anonymous'), $action, $record);
} | [
"public",
"function",
"shouldGenerateAlias",
"(",
"$",
"record",
",",
"array",
"$",
"action",
"=",
"[",
"'VIEW'",
"]",
")",
"{",
"// without security, everything is considered public",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"decisionManager",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"decisionManager",
"->",
"decide",
"(",
"new",
"AnonymousToken",
"(",
"'main'",
",",
"'anonymous'",
")",
",",
"$",
"action",
",",
"$",
"record",
")",
";",
"}"
] | Determines whether an alias should be generated for the given record.
@param mixed $record
@param array $action
@return bool | [
"Determines",
"whether",
"an",
"alias",
"should",
"be",
"generated",
"for",
"the",
"given",
"record",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php#L131-L139 |
37,778 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php | Aliaser.removeScheduledAliases | public function removeScheduledAliases()
{
foreach ($this->scheduledRemoveAlias as $alias) {
$this->aliasing->removeAlias($alias);
}
$this->scheduledRemoveAlias = [];
} | php | public function removeScheduledAliases()
{
foreach ($this->scheduledRemoveAlias as $alias) {
$this->aliasing->removeAlias($alias);
}
$this->scheduledRemoveAlias = [];
} | [
"public",
"function",
"removeScheduledAliases",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"scheduledRemoveAlias",
"as",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"aliasing",
"->",
"removeAlias",
"(",
"$",
"alias",
")",
";",
"}",
"$",
"this",
"->",
"scheduledRemoveAlias",
"=",
"[",
"]",
";",
"}"
] | Remove scheduled aliases
Example:
$aliaser->removeAlias($page, true);
# alias for $page is scheduled for removal, i.e. not yet actually removed
$aliaser->removeScheduledAliases()
# now the alias for $page is removed
@return void | [
"Remove",
"scheduled",
"aliases"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php#L171-L178 |
37,779 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/DefaultAliasingStrategy.php | DefaultAliasingStrategy.generatePublicAlias | public function generatePublicAlias($subject, $currentAlias = '')
{
if (is_object($subject)) {
if ($subject instanceof Aliasable) {
$subject = (string)$subject->getAliasTitle();
} elseif (method_exists($subject, 'getTitle')) {
$subject = (string)$subject->getTitle();
} else {
$subject = (string)$subject;
}
}
if (!is_string($subject)) {
throw new \InvalidArgumentException('Expected a string or object as subject, got ' . gettype($subject));
}
if ($alias = $this->toAlias($subject)) {
return $this->basePath . $alias;
}
return null;
} | php | public function generatePublicAlias($subject, $currentAlias = '')
{
if (is_object($subject)) {
if ($subject instanceof Aliasable) {
$subject = (string)$subject->getAliasTitle();
} elseif (method_exists($subject, 'getTitle')) {
$subject = (string)$subject->getTitle();
} else {
$subject = (string)$subject;
}
}
if (!is_string($subject)) {
throw new \InvalidArgumentException('Expected a string or object as subject, got ' . gettype($subject));
}
if ($alias = $this->toAlias($subject)) {
return $this->basePath . $alias;
}
return null;
} | [
"public",
"function",
"generatePublicAlias",
"(",
"$",
"subject",
",",
"$",
"currentAlias",
"=",
"''",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"subject",
")",
")",
"{",
"if",
"(",
"$",
"subject",
"instanceof",
"Aliasable",
")",
"{",
"$",
"subject",
"=",
"(",
"string",
")",
"$",
"subject",
"->",
"getAliasTitle",
"(",
")",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"subject",
",",
"'getTitle'",
")",
")",
"{",
"$",
"subject",
"=",
"(",
"string",
")",
"$",
"subject",
"->",
"getTitle",
"(",
")",
";",
"}",
"else",
"{",
"$",
"subject",
"=",
"(",
"string",
")",
"$",
"subject",
";",
"}",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"subject",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Expected a string or object as subject, got '",
".",
"gettype",
"(",
"$",
"subject",
")",
")",
";",
"}",
"if",
"(",
"$",
"alias",
"=",
"$",
"this",
"->",
"toAlias",
"(",
"$",
"subject",
")",
")",
"{",
"return",
"$",
"this",
"->",
"basePath",
".",
"$",
"alias",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the calculated public alias for the specified object.
@param string $subject
@param string $currentAlias
@return null|string
@throws \InvalidArgumentException | [
"Returns",
"the",
"calculated",
"public",
"alias",
"for",
"the",
"specified",
"object",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/DefaultAliasingStrategy.php#L33-L52 |
37,780 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/Params.php | Params.with | public function with($key, $value, $multiple = true)
{
$ret = clone $this;
$ret = self::doWith($ret, $key, $value, $multiple);
return $ret;
} | php | public function with($key, $value, $multiple = true)
{
$ret = clone $this;
$ret = self::doWith($ret, $key, $value, $multiple);
return $ret;
} | [
"public",
"function",
"with",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"multiple",
"=",
"true",
")",
"{",
"$",
"ret",
"=",
"clone",
"$",
"this",
";",
"$",
"ret",
"=",
"self",
"::",
"doWith",
"(",
"$",
"ret",
",",
"$",
"key",
",",
"$",
"value",
",",
"$",
"multiple",
")",
";",
"return",
"$",
"ret",
";",
"}"
] | Duplicates the current instance with one value changed.
- If the value already exists, the value is removed;
- If the value does not exist, it is added;
- If the value exists, and 'multiple' is false, it is replaced.
- If the value does not exists, and 'multiple' is false, it is added.
The $multiple parameter is typically useful for paging or other parameters.
@param string $key
@param string $value
@param bool $multiple
@return Params | [
"Duplicates",
"the",
"current",
"instance",
"with",
"one",
"value",
"changed",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/Params.php#L89-L95 |
37,781 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/Params.php | Params.getOne | public function getOne($key, $default = null)
{
$ret = $default;
$all = $this->get($key);
if (count($all) > 0) {
$ret = array_shift($all);
}
return $ret;
} | php | public function getOne($key, $default = null)
{
$ret = $default;
$all = $this->get($key);
if (count($all) > 0) {
$ret = array_shift($all);
}
return $ret;
} | [
"public",
"function",
"getOne",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"ret",
"=",
"$",
"default",
";",
"$",
"all",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"count",
"(",
"$",
"all",
")",
">",
"0",
")",
"{",
"$",
"ret",
"=",
"array_shift",
"(",
"$",
"all",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Returns a single value, and defaults to the given default parameter if not available.
@param string $key
@param mixed $default
@return mixed | [
"Returns",
"a",
"single",
"value",
"and",
"defaults",
"to",
"the",
"given",
"default",
"parameter",
"if",
"not",
"available",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/Params.php#L139-L148 |
37,782 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/Params.php | Params.without | public function without($keys)
{
if (is_scalar($keys)) {
$keys = [$keys];
}
$ret = clone $this;
foreach ($keys as $key) {
$ret->removeKey($key);
}
return $ret;
} | php | public function without($keys)
{
if (is_scalar($keys)) {
$keys = [$keys];
}
$ret = clone $this;
foreach ($keys as $key) {
$ret->removeKey($key);
}
return $ret;
} | [
"public",
"function",
"without",
"(",
"$",
"keys",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"keys",
"=",
"[",
"$",
"keys",
"]",
";",
"}",
"$",
"ret",
"=",
"clone",
"$",
"this",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"ret",
"->",
"removeKey",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Duplicates the current instance with one or more sets of values removed
@param mixed $keys
@return Params | [
"Duplicates",
"the",
"current",
"instance",
"with",
"one",
"or",
"more",
"sets",
"of",
"values",
"removed"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/Params.php#L157-L168 |
37,783 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.resolve | private function resolve($entity)
{
foreach ($this->namespaces as $namespace) {
$className = $namespace . '\\' . ucfirst($entity);
if (class_exists($className)) {
return $className;
}
}
return null;
} | php | private function resolve($entity)
{
foreach ($this->namespaces as $namespace) {
$className = $namespace . '\\' . ucfirst($entity);
if (class_exists($className)) {
return $className;
}
}
return null;
} | [
"private",
"function",
"resolve",
"(",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"$",
"className",
"=",
"$",
"namespace",
".",
"'\\\\'",
".",
"ucfirst",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"return",
"$",
"className",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Resolve the entity name to any of the configured namespaces.
Returns null if not found.
@param string $entity
@return null|string | [
"Resolve",
"the",
"entity",
"name",
"to",
"any",
"of",
"the",
"configured",
"namespaces",
".",
"Returns",
"null",
"if",
"not",
"found",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L99-L108 |
37,784 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.current | protected function current()
{
if (count($this->stack)) {
return $this->stack[count($this->stack) -1];
}
return null;
} | php | protected function current()
{
if (count($this->stack)) {
return $this->stack[count($this->stack) -1];
}
return null;
} | [
"protected",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"return",
"$",
"this",
"->",
"stack",
"[",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
"-",
"1",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the top of the stack.
@return mixed | [
"Returns",
"the",
"top",
"of",
"the",
"stack",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L116-L122 |
37,785 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.end | public function end($setter = null)
{
if (!count($this->stack)) {
throw new \UnexpectedValueException("Stack is empty. Did you call end() too many times?");
}
$current = array_pop($this->stack);
if ($parent = $this->current()) {
$parentClassName = get_class($parent);
$entityLocalName = Str::classname(get_class($current));
if ($current instanceof $parentClassName) {
if (method_exists($parent, 'addChildren')) {
call_user_func(array($parent, 'addChildren'), $current);
}
}
if (is_null($setter)) {
foreach (array('set', 'add') as $methodPrefix) {
$methodName = $methodPrefix . $entityLocalName;
if (method_exists($parent, $methodName)) {
$setter = $methodName;
break;
}
}
}
if (!is_null($setter)) {
call_user_func(array($parent, $setter), $current);
}
$parentClassNames = array_merge(class_parents($parentClassName), array($parentClassName));
foreach (array_reverse($parentClassNames) as $lParentClassName) {
$lParentClass = Str::classname($lParentClassName);
$parentSetter = 'set' . $lParentClass;
if ($lParentClassName == get_class($current)) {
$parentSetter = 'setParent';
}
if (method_exists($current, $parentSetter)) {
call_user_func(
array($current, $parentSetter),
$parent
);
break;
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $parent);
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $current);
}
return $this;
} | php | public function end($setter = null)
{
if (!count($this->stack)) {
throw new \UnexpectedValueException("Stack is empty. Did you call end() too many times?");
}
$current = array_pop($this->stack);
if ($parent = $this->current()) {
$parentClassName = get_class($parent);
$entityLocalName = Str::classname(get_class($current));
if ($current instanceof $parentClassName) {
if (method_exists($parent, 'addChildren')) {
call_user_func(array($parent, 'addChildren'), $current);
}
}
if (is_null($setter)) {
foreach (array('set', 'add') as $methodPrefix) {
$methodName = $methodPrefix . $entityLocalName;
if (method_exists($parent, $methodName)) {
$setter = $methodName;
break;
}
}
}
if (!is_null($setter)) {
call_user_func(array($parent, $setter), $current);
}
$parentClassNames = array_merge(class_parents($parentClassName), array($parentClassName));
foreach (array_reverse($parentClassNames) as $lParentClassName) {
$lParentClass = Str::classname($lParentClassName);
$parentSetter = 'set' . $lParentClass;
if ($lParentClassName == get_class($current)) {
$parentSetter = 'setParent';
}
if (method_exists($current, $parentSetter)) {
call_user_func(
array($current, $parentSetter),
$parent
);
break;
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $parent);
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $current);
}
return $this;
} | [
"public",
"function",
"end",
"(",
"$",
"setter",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Stack is empty. Did you call end() too many times?\"",
")",
";",
"}",
"$",
"current",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"stack",
")",
";",
"if",
"(",
"$",
"parent",
"=",
"$",
"this",
"->",
"current",
"(",
")",
")",
"{",
"$",
"parentClassName",
"=",
"get_class",
"(",
"$",
"parent",
")",
";",
"$",
"entityLocalName",
"=",
"Str",
"::",
"classname",
"(",
"get_class",
"(",
"$",
"current",
")",
")",
";",
"if",
"(",
"$",
"current",
"instanceof",
"$",
"parentClassName",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"parent",
",",
"'addChildren'",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"parent",
",",
"'addChildren'",
")",
",",
"$",
"current",
")",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"setter",
")",
")",
"{",
"foreach",
"(",
"array",
"(",
"'set'",
",",
"'add'",
")",
"as",
"$",
"methodPrefix",
")",
"{",
"$",
"methodName",
"=",
"$",
"methodPrefix",
".",
"$",
"entityLocalName",
";",
"if",
"(",
"method_exists",
"(",
"$",
"parent",
",",
"$",
"methodName",
")",
")",
"{",
"$",
"setter",
"=",
"$",
"methodName",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"setter",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"parent",
",",
"$",
"setter",
")",
",",
"$",
"current",
")",
";",
"}",
"$",
"parentClassNames",
"=",
"array_merge",
"(",
"class_parents",
"(",
"$",
"parentClassName",
")",
",",
"array",
"(",
"$",
"parentClassName",
")",
")",
";",
"foreach",
"(",
"array_reverse",
"(",
"$",
"parentClassNames",
")",
"as",
"$",
"lParentClassName",
")",
"{",
"$",
"lParentClass",
"=",
"Str",
"::",
"classname",
"(",
"$",
"lParentClassName",
")",
";",
"$",
"parentSetter",
"=",
"'set'",
".",
"$",
"lParentClass",
";",
"if",
"(",
"$",
"lParentClassName",
"==",
"get_class",
"(",
"$",
"current",
")",
")",
"{",
"$",
"parentSetter",
"=",
"'setParent'",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"current",
",",
"$",
"parentSetter",
")",
")",
"{",
"call_user_func",
"(",
"array",
"(",
"$",
"current",
",",
"$",
"parentSetter",
")",
",",
"$",
"parent",
")",
";",
"break",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"alwaysDo",
"as",
"$",
"callable",
")",
"{",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"parent",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"alwaysDo",
"as",
"$",
"callable",
")",
"{",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"current",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Returns one level up in the tree.
@param null $setter
@return Builder | [
"Returns",
"one",
"level",
"up",
"in",
"the",
"tree",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L142-L195 |
37,786 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.peek | public function peek()
{
$c = count($this->stack);
if ($c == 0) {
throw new \UnexpectedValueException("The stack is empty. You should probably peek() before the last end() call.");
}
$ret = $this->stack[$c -1];
return $ret;
} | php | public function peek()
{
$c = count($this->stack);
if ($c == 0) {
throw new \UnexpectedValueException("The stack is empty. You should probably peek() before the last end() call.");
}
$ret = $this->stack[$c -1];
return $ret;
} | [
"public",
"function",
"peek",
"(",
")",
"{",
"$",
"c",
"=",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
";",
"if",
"(",
"$",
"c",
"==",
"0",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"The stack is empty. You should probably peek() before the last end() call.\"",
")",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"stack",
"[",
"$",
"c",
"-",
"1",
"]",
";",
"return",
"$",
"ret",
";",
"}"
] | Returns the object that is currently the subject of building
@return mixed
@throws \UnexpectedValueException | [
"Returns",
"the",
"object",
"that",
"is",
"currently",
"the",
"subject",
"of",
"building"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L204-L212 |
37,787 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php | CreateAliasSubscriber.addRecord | protected function addRecord($entity, array $action = [])
{
if ($entity instanceof $this->className) {
if (false !== ($index = array_search($entity, array_column($this->records, 0), true))) {
if (!in_array($this->records[$index], $action)) {
$this->records[$index][] = $action;
}
} else {
$this->records[] = [$entity, $action];
}
}
} | php | protected function addRecord($entity, array $action = [])
{
if ($entity instanceof $this->className) {
if (false !== ($index = array_search($entity, array_column($this->records, 0), true))) {
if (!in_array($this->records[$index], $action)) {
$this->records[$index][] = $action;
}
} else {
$this->records[] = [$entity, $action];
}
}
} | [
"protected",
"function",
"addRecord",
"(",
"$",
"entity",
",",
"array",
"$",
"action",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"entity",
"instanceof",
"$",
"this",
"->",
"className",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"index",
"=",
"array_search",
"(",
"$",
"entity",
",",
"array_column",
"(",
"$",
"this",
"->",
"records",
",",
"0",
")",
",",
"true",
")",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"records",
"[",
"$",
"index",
"]",
",",
"$",
"action",
")",
")",
"{",
"$",
"this",
"->",
"records",
"[",
"$",
"index",
"]",
"[",
"]",
"=",
"$",
"action",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"records",
"[",
"]",
"=",
"[",
"$",
"entity",
",",
"$",
"action",
"]",
";",
"}",
"}",
"}"
] | Add a entity to record list for postFlush processing.
@param object $entity
@param array $action | [
"Add",
"a",
"entity",
"to",
"record",
"list",
"for",
"postFlush",
"processing",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php#L48-L59 |
37,788 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php | CreateAliasSubscriber.postFlush | public function postFlush()
{
if (!$this->enabled || $this->isHandling) {
return;
}
$this->isHandling = true;
$aliaser = $this->container->get($this->aliaserServiceId);
while (list($record, $action) = array_shift($this->records)) {
$aliaser->createAlias($record, $action);
}
$this->isHandling = false;
} | php | public function postFlush()
{
if (!$this->enabled || $this->isHandling) {
return;
}
$this->isHandling = true;
$aliaser = $this->container->get($this->aliaserServiceId);
while (list($record, $action) = array_shift($this->records)) {
$aliaser->createAlias($record, $action);
}
$this->isHandling = false;
} | [
"public",
"function",
"postFlush",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
"||",
"$",
"this",
"->",
"isHandling",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"isHandling",
"=",
"true",
";",
"$",
"aliaser",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"aliaserServiceId",
")",
";",
"while",
"(",
"list",
"(",
"$",
"record",
",",
"$",
"action",
")",
"=",
"array_shift",
"(",
"$",
"this",
"->",
"records",
")",
")",
"{",
"$",
"aliaser",
"->",
"createAlias",
"(",
"$",
"record",
",",
"$",
"action",
")",
";",
"}",
"$",
"this",
"->",
"isHandling",
"=",
"false",
";",
"}"
] | Create the aliases
@return void | [
"Create",
"the",
"aliases"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php#L90-L105 |
37,789 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Pager/Pager.php | Pager.itemAt | private function itemAt($i)
{
return array(
'index' => $i,
'title' => $i + 1,
'is_previous' => $i == ($this->currentPage - 1),
'is_current' => $i == $this->currentPage,
'is_next' => $i == ($this->currentPage + 1)
);
} | php | private function itemAt($i)
{
return array(
'index' => $i,
'title' => $i + 1,
'is_previous' => $i == ($this->currentPage - 1),
'is_current' => $i == $this->currentPage,
'is_next' => $i == ($this->currentPage + 1)
);
} | [
"private",
"function",
"itemAt",
"(",
"$",
"i",
")",
"{",
"return",
"array",
"(",
"'index'",
"=>",
"$",
"i",
",",
"'title'",
"=>",
"$",
"i",
"+",
"1",
",",
"'is_previous'",
"=>",
"$",
"i",
"==",
"(",
"$",
"this",
"->",
"currentPage",
"-",
"1",
")",
",",
"'is_current'",
"=>",
"$",
"i",
"==",
"$",
"this",
"->",
"currentPage",
",",
"'is_next'",
"=>",
"$",
"i",
"==",
"(",
"$",
"this",
"->",
"currentPage",
"+",
"1",
")",
")",
";",
"}"
] | Meta data helper function, returns the following meta data for each of the requested pages.
- title: The displayable title for the current page (e.g. "1" for page 0)
- is_previous: Whether the page is the previous page
- is_current
- is_next: Whether the page is the next page
@param int $i
@return array | [
"Meta",
"data",
"helper",
"function",
"returns",
"the",
"following",
"meta",
"data",
"for",
"each",
"of",
"the",
"requested",
"pages",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Pager/Pager.php#L239-L248 |
37,790 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php | AbstractCronCommand.exceptionHandler | public function exceptionHandler(Exception $exception)
{
$this->logger->addError($exception->getMessage(), array($exception->getFile(), $exception->getLine()));
exit(-1);
} | php | public function exceptionHandler(Exception $exception)
{
$this->logger->addError($exception->getMessage(), array($exception->getFile(), $exception->getLine()));
exit(-1);
} | [
"public",
"function",
"exceptionHandler",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addError",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"array",
"(",
"$",
"exception",
"->",
"getFile",
"(",
")",
",",
"$",
"exception",
"->",
"getLine",
"(",
")",
")",
")",
";",
"exit",
"(",
"-",
"1",
")",
";",
"}"
] | Exception handler; will log the exception and exit the script.
@param \Exception $exception
@return void | [
"Exception",
"handler",
";",
"will",
"log",
"the",
"exception",
"and",
"exit",
"the",
"script",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php#L86-L90 |
37,791 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php | AbstractCronCommand.errorHandler | public function errorHandler($errno, $errstr, $file, $line)
{
switch ($errno) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
$this->logger->addError($errstr, array($file, $line));
exit();
break;
case E_WARNING:
case E_USER_WARNING:
$this->logger->addWarning($errstr, array($file, $line));
break;
default:
$this->logger->addInfo($errstr, array($file, $line));
break;
}
} | php | public function errorHandler($errno, $errstr, $file, $line)
{
switch ($errno) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
$this->logger->addError($errstr, array($file, $line));
exit();
break;
case E_WARNING:
case E_USER_WARNING:
$this->logger->addWarning($errstr, array($file, $line));
break;
default:
$this->logger->addInfo($errstr, array($file, $line));
break;
}
} | [
"public",
"function",
"errorHandler",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"switch",
"(",
"$",
"errno",
")",
"{",
"case",
"E_USER_ERROR",
":",
"case",
"E_ERROR",
":",
"case",
"E_RECOVERABLE_ERROR",
":",
"$",
"this",
"->",
"logger",
"->",
"addError",
"(",
"$",
"errstr",
",",
"array",
"(",
"$",
"file",
",",
"$",
"line",
")",
")",
";",
"exit",
"(",
")",
";",
"break",
";",
"case",
"E_WARNING",
":",
"case",
"E_USER_WARNING",
":",
"$",
"this",
"->",
"logger",
"->",
"addWarning",
"(",
"$",
"errstr",
",",
"array",
"(",
"$",
"file",
",",
"$",
"line",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"logger",
"->",
"addInfo",
"(",
"$",
"errstr",
",",
"array",
"(",
"$",
"file",
",",
"$",
"line",
")",
")",
";",
"break",
";",
"}",
"}"
] | Error handler; will log the error and exit the script.
@param int $errno
@param string $errstr
@param string $file
@param int $line
@return void | [
"Error",
"handler",
";",
"will",
"log",
"the",
"error",
"and",
"exit",
"the",
"script",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php#L102-L119 |
37,792 | zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php | AbstractCronCommand.getMutexFile | protected function getMutexFile()
{
$file = false;
if (true === $this->mutex) {
$file = $this->getContainer()->getParameter('kernel.cache_dir')
. '/'
. Str::dash(lcfirst(Str::classname(get_class($this))))
. '.lock';
} elseif ($this->mutex) {
$file = $this->mutex;
}
return $file;
} | php | protected function getMutexFile()
{
$file = false;
if (true === $this->mutex) {
$file = $this->getContainer()->getParameter('kernel.cache_dir')
. '/'
. Str::dash(lcfirst(Str::classname(get_class($this))))
. '.lock';
} elseif ($this->mutex) {
$file = $this->mutex;
}
return $file;
} | [
"protected",
"function",
"getMutexFile",
"(",
")",
"{",
"$",
"file",
"=",
"false",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"mutex",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'kernel.cache_dir'",
")",
".",
"'/'",
".",
"Str",
"::",
"dash",
"(",
"lcfirst",
"(",
"Str",
"::",
"classname",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
")",
")",
".",
"'.lock'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"mutex",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"mutex",
";",
"}",
"return",
"$",
"file",
";",
"}"
] | Returns a path to the file which can be used as a mutex.
@return bool|string | [
"Returns",
"a",
"path",
"to",
"the",
"file",
"which",
"can",
"be",
"used",
"as",
"a",
"mutex",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php#L199-L212 |
37,793 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.onKernelResponse | public function onKernelResponse(Event\FilterResponseEvent $e)
{
if ($e->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$response = $e->getResponse();
// only do anything if the response has a Location header
if (false !== ($location = $response->headers->get('location', false))) {
$absolutePrefix = $e->getRequest()->getSchemeAndHttpHost();
if (parse_url($location, PHP_URL_SCHEME)) {
if (substr($location, 0, strlen($absolutePrefix)) === $absolutePrefix) {
$relative = substr($location, strlen($absolutePrefix));
} else {
$relative = null;
}
} else {
$relative = $location;
}
// Possible suffix for the rewrite URL
$suffix = '';
/**
* Catches the following situation:
*
* Some redirect URLs might contain extra URL parameters in the form of:
*
* /nl/page/666/terms=FOO/tag=BAR
*
* (E.g. some SOLR implementations use this URL scheme)
*
* The relative URL above is then incorrect and the public alias can not be found.
*
* Remove /terms=FOO/tag=BAR from the relative path and attach to clean URL if found.
*
*/
if (preg_match('/^(\/[a-z]{2,2}\/page\/\d+)(.*)$/', $relative, $matches)) {
list(, $relative, $suffix) = $matches;
} elseif (preg_match('/^(\/page\/\d+)(.*)$/', $relative, $matches)) {
/* For old sites that don't have the locale in the URI */
list(, $relative, $suffix) = $matches;
}
if (null !== $relative && null !== ($url = $this->aliasing->hasPublicAlias($relative))) {
$rewrite = $absolutePrefix . $url . $suffix;
$response->headers->set('location', $rewrite);
}
}
$this->rewriteResponse($e->getRequest(), $response);
}
} | php | public function onKernelResponse(Event\FilterResponseEvent $e)
{
if ($e->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$response = $e->getResponse();
// only do anything if the response has a Location header
if (false !== ($location = $response->headers->get('location', false))) {
$absolutePrefix = $e->getRequest()->getSchemeAndHttpHost();
if (parse_url($location, PHP_URL_SCHEME)) {
if (substr($location, 0, strlen($absolutePrefix)) === $absolutePrefix) {
$relative = substr($location, strlen($absolutePrefix));
} else {
$relative = null;
}
} else {
$relative = $location;
}
// Possible suffix for the rewrite URL
$suffix = '';
/**
* Catches the following situation:
*
* Some redirect URLs might contain extra URL parameters in the form of:
*
* /nl/page/666/terms=FOO/tag=BAR
*
* (E.g. some SOLR implementations use this URL scheme)
*
* The relative URL above is then incorrect and the public alias can not be found.
*
* Remove /terms=FOO/tag=BAR from the relative path and attach to clean URL if found.
*
*/
if (preg_match('/^(\/[a-z]{2,2}\/page\/\d+)(.*)$/', $relative, $matches)) {
list(, $relative, $suffix) = $matches;
} elseif (preg_match('/^(\/page\/\d+)(.*)$/', $relative, $matches)) {
/* For old sites that don't have the locale in the URI */
list(, $relative, $suffix) = $matches;
}
if (null !== $relative && null !== ($url = $this->aliasing->hasPublicAlias($relative))) {
$rewrite = $absolutePrefix . $url . $suffix;
$response->headers->set('location', $rewrite);
}
}
$this->rewriteResponse($e->getRequest(), $response);
}
} | [
"public",
"function",
"onKernelResponse",
"(",
"Event",
"\\",
"FilterResponseEvent",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getRequestType",
"(",
")",
"===",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
")",
"{",
"$",
"response",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
";",
"// only do anything if the response has a Location header",
"if",
"(",
"false",
"!==",
"(",
"$",
"location",
"=",
"$",
"response",
"->",
"headers",
"->",
"get",
"(",
"'location'",
",",
"false",
")",
")",
")",
"{",
"$",
"absolutePrefix",
"=",
"$",
"e",
"->",
"getRequest",
"(",
")",
"->",
"getSchemeAndHttpHost",
"(",
")",
";",
"if",
"(",
"parse_url",
"(",
"$",
"location",
",",
"PHP_URL_SCHEME",
")",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"location",
",",
"0",
",",
"strlen",
"(",
"$",
"absolutePrefix",
")",
")",
"===",
"$",
"absolutePrefix",
")",
"{",
"$",
"relative",
"=",
"substr",
"(",
"$",
"location",
",",
"strlen",
"(",
"$",
"absolutePrefix",
")",
")",
";",
"}",
"else",
"{",
"$",
"relative",
"=",
"null",
";",
"}",
"}",
"else",
"{",
"$",
"relative",
"=",
"$",
"location",
";",
"}",
"// Possible suffix for the rewrite URL",
"$",
"suffix",
"=",
"''",
";",
"/**\n * Catches the following situation:\n *\n * Some redirect URLs might contain extra URL parameters in the form of:\n *\n * /nl/page/666/terms=FOO/tag=BAR\n *\n * (E.g. some SOLR implementations use this URL scheme)\n *\n * The relative URL above is then incorrect and the public alias can not be found.\n *\n * Remove /terms=FOO/tag=BAR from the relative path and attach to clean URL if found.\n *\n */",
"if",
"(",
"preg_match",
"(",
"'/^(\\/[a-z]{2,2}\\/page\\/\\d+)(.*)$/'",
",",
"$",
"relative",
",",
"$",
"matches",
")",
")",
"{",
"list",
"(",
",",
"$",
"relative",
",",
"$",
"suffix",
")",
"=",
"$",
"matches",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^(\\/page\\/\\d+)(.*)$/'",
",",
"$",
"relative",
",",
"$",
"matches",
")",
")",
"{",
"/* For old sites that don't have the locale in the URI */",
"list",
"(",
",",
"$",
"relative",
",",
"$",
"suffix",
")",
"=",
"$",
"matches",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"relative",
"&&",
"null",
"!==",
"(",
"$",
"url",
"=",
"$",
"this",
"->",
"aliasing",
"->",
"hasPublicAlias",
"(",
"$",
"relative",
")",
")",
")",
"{",
"$",
"rewrite",
"=",
"$",
"absolutePrefix",
".",
"$",
"url",
".",
"$",
"suffix",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'location'",
",",
"$",
"rewrite",
")",
";",
"}",
"}",
"$",
"this",
"->",
"rewriteResponse",
"(",
"$",
"e",
"->",
"getRequest",
"(",
")",
",",
"$",
"response",
")",
";",
"}",
"}"
] | Listens to redirect responses, to replace any internal url with a public one.
@param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $e
@return void | [
"Listens",
"to",
"redirect",
"responses",
"to",
"replace",
"any",
"internal",
"url",
"with",
"a",
"public",
"one",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L46-L97 |
37,794 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.isExcluded | protected function isExcluded($url)
{
$ret = false;
foreach ($this->excludePatterns as $pattern) {
if (preg_match($pattern, $url)) {
$ret = true;
break;
}
}
return $ret;
} | php | protected function isExcluded($url)
{
$ret = false;
foreach ($this->excludePatterns as $pattern) {
if (preg_match($pattern, $url)) {
$ret = true;
break;
}
}
return $ret;
} | [
"protected",
"function",
"isExcluded",
"(",
"$",
"url",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"excludePatterns",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"url",
")",
")",
"{",
"$",
"ret",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Returns true if the URL matches any of the exclude patterns
@param string $url
@return bool | [
"Returns",
"true",
"if",
"the",
"URL",
"matches",
"any",
"of",
"the",
"exclude",
"patterns"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L127-L137 |
37,795 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.onKernelRequest | public function onKernelRequest(Event\GetResponseEvent $event)
{
if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$request = $event->getRequest();
$publicUrl = rawurldecode($request->getRequestUri());
if ($this->isExcluded($publicUrl)) {
// don't process urls which are marked as excluded.
return;
}
if ($this->isParamsEnabled) {
if (false !== ($queryMark = strpos($publicUrl, '?'))) {
$originalUrl = $publicUrl;
$publicUrl = substr($originalUrl, 0, $queryMark);
$queryString = substr($originalUrl, $queryMark);
} else {
$queryString = null;
}
$parts = explode('/', $publicUrl);
$params = [];
while (false !== strpos(end($parts), '=')) {
array_push($params, array_pop($parts));
}
if ($params) {
$publicUrl = join('/', $parts);
$parser = new UriParser();
$request->query->add($parser->parseUri(join('/', array_reverse($params))));
if (!$this->aliasing->hasInternalAlias($publicUrl, false)) {
$this->rewriteRequest($event, $publicUrl . $queryString);
return;
}
}
}
/** @var UrlAlias $url */
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true)) {
switch ($url->getMode()) {
case UrlAlias::REWRITE:
$this->rewriteRequest($event, $url->getInternalUrl());
break;
case UrlAlias::MOVE:
case UrlAlias::ALIAS:
$event->setResponse(new RedirectResponse($url->getInternalUrl(), $url->getMode()));
break;
default:
throw new \UnexpectedValueException(
sprintf(
'Invalid mode %s for UrlAlias %s.',
$url->getMode(),
json_encode($url)
)
);
}
} elseif (strpos($publicUrl, '?') !== false) {
// allow aliases to receive the query string.
$publicUrl = substr($publicUrl, 0, strpos($publicUrl, '?'));
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true, UrlAlias::REWRITE)) {
$this->rewriteRequest($event, $url->getInternalUrl());
return;
}
}
}
} | php | public function onKernelRequest(Event\GetResponseEvent $event)
{
if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$request = $event->getRequest();
$publicUrl = rawurldecode($request->getRequestUri());
if ($this->isExcluded($publicUrl)) {
// don't process urls which are marked as excluded.
return;
}
if ($this->isParamsEnabled) {
if (false !== ($queryMark = strpos($publicUrl, '?'))) {
$originalUrl = $publicUrl;
$publicUrl = substr($originalUrl, 0, $queryMark);
$queryString = substr($originalUrl, $queryMark);
} else {
$queryString = null;
}
$parts = explode('/', $publicUrl);
$params = [];
while (false !== strpos(end($parts), '=')) {
array_push($params, array_pop($parts));
}
if ($params) {
$publicUrl = join('/', $parts);
$parser = new UriParser();
$request->query->add($parser->parseUri(join('/', array_reverse($params))));
if (!$this->aliasing->hasInternalAlias($publicUrl, false)) {
$this->rewriteRequest($event, $publicUrl . $queryString);
return;
}
}
}
/** @var UrlAlias $url */
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true)) {
switch ($url->getMode()) {
case UrlAlias::REWRITE:
$this->rewriteRequest($event, $url->getInternalUrl());
break;
case UrlAlias::MOVE:
case UrlAlias::ALIAS:
$event->setResponse(new RedirectResponse($url->getInternalUrl(), $url->getMode()));
break;
default:
throw new \UnexpectedValueException(
sprintf(
'Invalid mode %s for UrlAlias %s.',
$url->getMode(),
json_encode($url)
)
);
}
} elseif (strpos($publicUrl, '?') !== false) {
// allow aliases to receive the query string.
$publicUrl = substr($publicUrl, 0, strpos($publicUrl, '?'));
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true, UrlAlias::REWRITE)) {
$this->rewriteRequest($event, $url->getInternalUrl());
return;
}
}
}
} | [
"public",
"function",
"onKernelRequest",
"(",
"Event",
"\\",
"GetResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getRequestType",
"(",
")",
"===",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"publicUrl",
"=",
"rawurldecode",
"(",
"$",
"request",
"->",
"getRequestUri",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isExcluded",
"(",
"$",
"publicUrl",
")",
")",
"{",
"// don't process urls which are marked as excluded.",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isParamsEnabled",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"queryMark",
"=",
"strpos",
"(",
"$",
"publicUrl",
",",
"'?'",
")",
")",
")",
"{",
"$",
"originalUrl",
"=",
"$",
"publicUrl",
";",
"$",
"publicUrl",
"=",
"substr",
"(",
"$",
"originalUrl",
",",
"0",
",",
"$",
"queryMark",
")",
";",
"$",
"queryString",
"=",
"substr",
"(",
"$",
"originalUrl",
",",
"$",
"queryMark",
")",
";",
"}",
"else",
"{",
"$",
"queryString",
"=",
"null",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"publicUrl",
")",
";",
"$",
"params",
"=",
"[",
"]",
";",
"while",
"(",
"false",
"!==",
"strpos",
"(",
"end",
"(",
"$",
"parts",
")",
",",
"'='",
")",
")",
"{",
"array_push",
"(",
"$",
"params",
",",
"array_pop",
"(",
"$",
"parts",
")",
")",
";",
"}",
"if",
"(",
"$",
"params",
")",
"{",
"$",
"publicUrl",
"=",
"join",
"(",
"'/'",
",",
"$",
"parts",
")",
";",
"$",
"parser",
"=",
"new",
"UriParser",
"(",
")",
";",
"$",
"request",
"->",
"query",
"->",
"add",
"(",
"$",
"parser",
"->",
"parseUri",
"(",
"join",
"(",
"'/'",
",",
"array_reverse",
"(",
"$",
"params",
")",
")",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"aliasing",
"->",
"hasInternalAlias",
"(",
"$",
"publicUrl",
",",
"false",
")",
")",
"{",
"$",
"this",
"->",
"rewriteRequest",
"(",
"$",
"event",
",",
"$",
"publicUrl",
".",
"$",
"queryString",
")",
";",
"return",
";",
"}",
"}",
"}",
"/** @var UrlAlias $url */",
"if",
"(",
"$",
"url",
"=",
"$",
"this",
"->",
"aliasing",
"->",
"hasInternalAlias",
"(",
"$",
"publicUrl",
",",
"true",
")",
")",
"{",
"switch",
"(",
"$",
"url",
"->",
"getMode",
"(",
")",
")",
"{",
"case",
"UrlAlias",
"::",
"REWRITE",
":",
"$",
"this",
"->",
"rewriteRequest",
"(",
"$",
"event",
",",
"$",
"url",
"->",
"getInternalUrl",
"(",
")",
")",
";",
"break",
";",
"case",
"UrlAlias",
"::",
"MOVE",
":",
"case",
"UrlAlias",
"::",
"ALIAS",
":",
"$",
"event",
"->",
"setResponse",
"(",
"new",
"RedirectResponse",
"(",
"$",
"url",
"->",
"getInternalUrl",
"(",
")",
",",
"$",
"url",
"->",
"getMode",
"(",
")",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'Invalid mode %s for UrlAlias %s.'",
",",
"$",
"url",
"->",
"getMode",
"(",
")",
",",
"json_encode",
"(",
"$",
"url",
")",
")",
")",
";",
"}",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"publicUrl",
",",
"'?'",
")",
"!==",
"false",
")",
"{",
"// allow aliases to receive the query string.",
"$",
"publicUrl",
"=",
"substr",
"(",
"$",
"publicUrl",
",",
"0",
",",
"strpos",
"(",
"$",
"publicUrl",
",",
"'?'",
")",
")",
";",
"if",
"(",
"$",
"url",
"=",
"$",
"this",
"->",
"aliasing",
"->",
"hasInternalAlias",
"(",
"$",
"publicUrl",
",",
"true",
",",
"UrlAlias",
"::",
"REWRITE",
")",
")",
"{",
"$",
"this",
"->",
"rewriteRequest",
"(",
"$",
"event",
",",
"$",
"url",
"->",
"getInternalUrl",
"(",
")",
")",
";",
"return",
";",
"}",
"}",
"}",
"}"
] | Listens to master requests and translates the URL to an internal url, if there is an alias available
@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
@return void
@throws \UnexpectedValueException | [
"Listens",
"to",
"master",
"requests",
"and",
"translates",
"the",
"URL",
"to",
"an",
"internal",
"url",
"if",
"there",
"is",
"an",
"alias",
"available"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L147-L216 |
37,796 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.rewriteRequest | public function rewriteRequest($event, $url)
{
// override the request's REQUEST_URI
$event->getRequest()->initialize(
$event->getRequest()->query->all(),
$event->getRequest()->request->all(),
$event->getRequest()->attributes->all(),
$event->getRequest()->cookies->all(),
$event->getRequest()->files->all(),
[
'ORIGINAL_REQUEST_URI' => $event->getRequest()->server->get('REQUEST_URI'),
'REQUEST_URI' => $url
] + $event->getRequest()->server->all(),
$event->getRequest()->getContent()
);
// route the request
$subEvent = new Event\GetResponseEvent(
$event->getKernel(),
$event->getRequest(),
$event->getRequestType()
);
$this->router->onKernelRequest($subEvent);
} | php | public function rewriteRequest($event, $url)
{
// override the request's REQUEST_URI
$event->getRequest()->initialize(
$event->getRequest()->query->all(),
$event->getRequest()->request->all(),
$event->getRequest()->attributes->all(),
$event->getRequest()->cookies->all(),
$event->getRequest()->files->all(),
[
'ORIGINAL_REQUEST_URI' => $event->getRequest()->server->get('REQUEST_URI'),
'REQUEST_URI' => $url
] + $event->getRequest()->server->all(),
$event->getRequest()->getContent()
);
// route the request
$subEvent = new Event\GetResponseEvent(
$event->getKernel(),
$event->getRequest(),
$event->getRequestType()
);
$this->router->onKernelRequest($subEvent);
} | [
"public",
"function",
"rewriteRequest",
"(",
"$",
"event",
",",
"$",
"url",
")",
"{",
"// override the request's REQUEST_URI",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"initialize",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"query",
"->",
"all",
"(",
")",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"request",
"->",
"all",
"(",
")",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"attributes",
"->",
"all",
"(",
")",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"cookies",
"->",
"all",
"(",
")",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"files",
"->",
"all",
"(",
")",
",",
"[",
"'ORIGINAL_REQUEST_URI'",
"=>",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"server",
"->",
"get",
"(",
"'REQUEST_URI'",
")",
",",
"'REQUEST_URI'",
"=>",
"$",
"url",
"]",
"+",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"server",
"->",
"all",
"(",
")",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"getContent",
"(",
")",
")",
";",
"// route the request",
"$",
"subEvent",
"=",
"new",
"Event",
"\\",
"GetResponseEvent",
"(",
"$",
"event",
"->",
"getKernel",
"(",
")",
",",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"event",
"->",
"getRequestType",
"(",
")",
")",
";",
"$",
"this",
"->",
"router",
"->",
"onKernelRequest",
"(",
"$",
"subEvent",
")",
";",
"}"
] | Route the request to the specified URL.
@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
@param string $url
@return void | [
"Route",
"the",
"request",
"to",
"the",
"specified",
"URL",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L226-L249 |
37,797 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.rewriteResponse | protected function rewriteResponse(Request $request, Response $response)
{
// for debugging purposes. Might need to be configurable.
if ($request->query->get('__disable_aliasing')) {
return;
}
if (preg_match('!^/admin/!', $request->getRequestUri())) {
// don't bother here.
return;
}
if ($response->getContent()) {
$contentType = current(explode(';', $response->headers->get('content-type', 'text/html')));
$response->setContent(
$this->aliasing->mapContent(
$contentType,
UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC,
$response->getContent(),
[$request->getHttpHost()]
)
);
}
} | php | protected function rewriteResponse(Request $request, Response $response)
{
// for debugging purposes. Might need to be configurable.
if ($request->query->get('__disable_aliasing')) {
return;
}
if (preg_match('!^/admin/!', $request->getRequestUri())) {
// don't bother here.
return;
}
if ($response->getContent()) {
$contentType = current(explode(';', $response->headers->get('content-type', 'text/html')));
$response->setContent(
$this->aliasing->mapContent(
$contentType,
UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC,
$response->getContent(),
[$request->getHttpHost()]
)
);
}
} | [
"protected",
"function",
"rewriteResponse",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"// for debugging purposes. Might need to be configurable.",
"if",
"(",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'__disable_aliasing'",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'!^/admin/!'",
",",
"$",
"request",
"->",
"getRequestUri",
"(",
")",
")",
")",
"{",
"// don't bother here.",
"return",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
"{",
"$",
"contentType",
"=",
"current",
"(",
"explode",
"(",
"';'",
",",
"$",
"response",
"->",
"headers",
"->",
"get",
"(",
"'content-type'",
",",
"'text/html'",
")",
")",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"this",
"->",
"aliasing",
"->",
"mapContent",
"(",
"$",
"contentType",
",",
"UrlMapperInterface",
"::",
"MODE_INTERNAL_TO_PUBLIC",
",",
"$",
"response",
"->",
"getContent",
"(",
")",
",",
"[",
"$",
"request",
"->",
"getHttpHost",
"(",
")",
"]",
")",
")",
";",
"}",
"}"
] | Rewrite URL's from internal naming to public aliases in the response.
@param Request $request
@param Response $response
@return void | [
"Rewrite",
"URL",
"s",
"from",
"internal",
"naming",
"to",
"public",
"aliases",
"in",
"the",
"response",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L259-L281 |
37,798 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Controller/SitemapController.php | SitemapController.sitemapAction | public function sitemapAction(Request $request)
{
$urls = $this->get('zicht_url.sitemap_provider')->all($this->get('security.authorization_checker'));
return new Response(
$this->renderView('ZichtUrlBundle:Sitemap:sitemap.xml.twig', ['urls' => $urls]),
200,
[
'content-type' => 'text/xml'
]
);
} | php | public function sitemapAction(Request $request)
{
$urls = $this->get('zicht_url.sitemap_provider')->all($this->get('security.authorization_checker'));
return new Response(
$this->renderView('ZichtUrlBundle:Sitemap:sitemap.xml.twig', ['urls' => $urls]),
200,
[
'content-type' => 'text/xml'
]
);
} | [
"public",
"function",
"sitemapAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"urls",
"=",
"$",
"this",
"->",
"get",
"(",
"'zicht_url.sitemap_provider'",
")",
"->",
"all",
"(",
"$",
"this",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
")",
";",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"renderView",
"(",
"'ZichtUrlBundle:Sitemap:sitemap.xml.twig'",
",",
"[",
"'urls'",
"=>",
"$",
"urls",
"]",
")",
",",
"200",
",",
"[",
"'content-type'",
"=>",
"'text/xml'",
"]",
")",
";",
"}"
] | Render basic sitemap from all database urls
@param Request $request
@return Response
@Route("/sitemap.{_format}", defaults={"_format": "xml"}) | [
"Render",
"basic",
"sitemap",
"from",
"all",
"database",
"urls"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Controller/SitemapController.php#L23-L34 |
37,799 | zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Logging/Listener.php | Listener.onKernelException | public function onKernelException(GetResponseForExceptionEvent $event)
{
$this->log = $this->logging->createLog($event->getRequest(), $event->getException()->getMessage());
} | php | public function onKernelException(GetResponseForExceptionEvent $event)
{
$this->log = $this->logging->createLog($event->getRequest(), $event->getException()->getMessage());
} | [
"public",
"function",
"onKernelException",
"(",
"GetResponseForExceptionEvent",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"log",
"=",
"$",
"this",
"->",
"logging",
"->",
"createLog",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"event",
"->",
"getException",
"(",
")",
"->",
"getMessage",
"(",
")",
")",
";",
"}"
] | Create log entry if a kernelexception occurs.
@param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
@return void | [
"Create",
"log",
"entry",
"if",
"a",
"kernelexception",
"occurs",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Logging/Listener.php#L38-L41 |
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.