repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.create
public function create(array $input, $openTransaction = true, $databaseConnectionName = null, $organizationId = null, $loggedUserId = null) { unset($input['_token'] , $input['parent_label']); if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId(); } if(empty($loggedUserId)) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); } //Sacamos lo que nos importa de los arreglos $icon = $this->Config->get('file-general.folder.icon'); $color = $this->Config->get('file-general.folder.color'); //Agregando la informacion que nos importa $input = eloquent_array_filter_for_insert($input); $input = array_add($input, 'organization_id', $organizationId); $input = array_add($input, 'type', 'C'); $input = array_add($input, 'icon', $icon); $input = array_add($input, 'icon_html', '<i class="'. $icon .'" aria-hidden="true" style="font-size: 2em;color:'. $color .';"></i>'); if(!isset($input['parent_file_id'])) { $input['parent_file_id'] = null; } //Retorna los parent $result = $this->File->byParentByFolderNameAndByOrganization($input['parent_file_id'], $input['name'], $organizationId, $databaseConnectionName); //Cuenta el resultado y lo compara if($result->count() == 0) { //Se asegura que no exista una carpeta en la misma raiz $this->DB->transaction(function() use ($input, $loggedUserId, $organizationId, $databaseConnectionName, &$File, &$folders) { $File = $this->File->create($input, $databaseConnectionName); $Journal = $this->Journal->create(array('journalized_id' => $File->id, 'journalized_type' => $this->File->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-file::file-management.addedJournal', array('name' => $File->name . ' ' , $File->key)), $Journal)); $folders = $this->getFolders($databaseConnectionName, $organizationId); }); return json_encode(array('success' => $this->Lang->get('form.defaultSuccessSaveMessage'), 'id' => $File->id, 'folders' => $folders)); } else { //Error, no dos carpetas no pueden tener el mismo nombre en la misa raiz return json_encode(array('info' => $this->Lang->get('decima-file::file-management.folderAlreadyExistValidation'))); } }
php
public function create(array $input, $openTransaction = true, $databaseConnectionName = null, $organizationId = null, $loggedUserId = null) { unset($input['_token'] , $input['parent_label']); if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId(); } if(empty($loggedUserId)) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); } //Sacamos lo que nos importa de los arreglos $icon = $this->Config->get('file-general.folder.icon'); $color = $this->Config->get('file-general.folder.color'); //Agregando la informacion que nos importa $input = eloquent_array_filter_for_insert($input); $input = array_add($input, 'organization_id', $organizationId); $input = array_add($input, 'type', 'C'); $input = array_add($input, 'icon', $icon); $input = array_add($input, 'icon_html', '<i class="'. $icon .'" aria-hidden="true" style="font-size: 2em;color:'. $color .';"></i>'); if(!isset($input['parent_file_id'])) { $input['parent_file_id'] = null; } //Retorna los parent $result = $this->File->byParentByFolderNameAndByOrganization($input['parent_file_id'], $input['name'], $organizationId, $databaseConnectionName); //Cuenta el resultado y lo compara if($result->count() == 0) { //Se asegura que no exista una carpeta en la misma raiz $this->DB->transaction(function() use ($input, $loggedUserId, $organizationId, $databaseConnectionName, &$File, &$folders) { $File = $this->File->create($input, $databaseConnectionName); $Journal = $this->Journal->create(array('journalized_id' => $File->id, 'journalized_type' => $this->File->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-file::file-management.addedJournal', array('name' => $File->name . ' ' , $File->key)), $Journal)); $folders = $this->getFolders($databaseConnectionName, $organizationId); }); return json_encode(array('success' => $this->Lang->get('form.defaultSuccessSaveMessage'), 'id' => $File->id, 'folders' => $folders)); } else { //Error, no dos carpetas no pueden tener el mismo nombre en la misa raiz return json_encode(array('info' => $this->Lang->get('decima-file::file-management.folderAlreadyExistValidation'))); } }
[ "public", "function", "create", "(", "array", "$", "input", ",", "$", "openTransaction", "=", "true", ",", "$", "databaseConnectionName", "=", "null", ",", "$", "organizationId", "=", "null", ",", "$", "loggedUserId", "=", "null", ")", "{", "unset", "(", "$", "input", "[", "'_token'", "]", ",", "$", "input", "[", "'parent_label'", "]", ")", ";", "if", "(", "empty", "(", "$", "organizationId", ")", ")", "{", "$", "organizationId", "=", "$", "this", "->", "AuthenticationManager", "->", "getCurrentUserOrganizationId", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "loggedUserId", ")", ")", "{", "$", "loggedUserId", "=", "$", "this", "->", "AuthenticationManager", "->", "getLoggedUserId", "(", ")", ";", "}", "//Sacamos lo que nos importa de los arreglos", "$", "icon", "=", "$", "this", "->", "Config", "->", "get", "(", "'file-general.folder.icon'", ")", ";", "$", "color", "=", "$", "this", "->", "Config", "->", "get", "(", "'file-general.folder.color'", ")", ";", "//Agregando la informacion que nos importa", "$", "input", "=", "eloquent_array_filter_for_insert", "(", "$", "input", ")", ";", "$", "input", "=", "array_add", "(", "$", "input", ",", "'organization_id'", ",", "$", "organizationId", ")", ";", "$", "input", "=", "array_add", "(", "$", "input", ",", "'type'", ",", "'C'", ")", ";", "$", "input", "=", "array_add", "(", "$", "input", ",", "'icon'", ",", "$", "icon", ")", ";", "$", "input", "=", "array_add", "(", "$", "input", ",", "'icon_html'", ",", "'<i class=\"'", ".", "$", "icon", ".", "'\" aria-hidden=\"true\" style=\"font-size: 2em;color:'", ".", "$", "color", ".", "';\"></i>'", ")", ";", "if", "(", "!", "isset", "(", "$", "input", "[", "'parent_file_id'", "]", ")", ")", "{", "$", "input", "[", "'parent_file_id'", "]", "=", "null", ";", "}", "//Retorna los parent", "$", "result", "=", "$", "this", "->", "File", "->", "byParentByFolderNameAndByOrganization", "(", "$", "input", "[", "'parent_file_id'", "]", ",", "$", "input", "[", "'name'", "]", ",", "$", "organizationId", ",", "$", "databaseConnectionName", ")", ";", "//Cuenta el resultado y lo compara", "if", "(", "$", "result", "->", "count", "(", ")", "==", "0", ")", "{", "//Se asegura que no exista una carpeta en la misma raiz", "$", "this", "->", "DB", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "input", ",", "$", "loggedUserId", ",", "$", "organizationId", ",", "$", "databaseConnectionName", ",", "&", "$", "File", ",", "&", "$", "folders", ")", "{", "$", "File", "=", "$", "this", "->", "File", "->", "create", "(", "$", "input", ",", "$", "databaseConnectionName", ")", ";", "$", "Journal", "=", "$", "this", "->", "Journal", "->", "create", "(", "array", "(", "'journalized_id'", "=>", "$", "File", "->", "id", ",", "'journalized_type'", "=>", "$", "this", "->", "File", "->", "getTable", "(", ")", ",", "'user_id'", "=>", "$", "loggedUserId", ",", "'organization_id'", "=>", "$", "organizationId", ")", ")", ";", "$", "this", "->", "Journal", "->", "attachDetail", "(", "$", "Journal", "->", "id", ",", "array", "(", "'note'", "=>", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.addedJournal'", ",", "array", "(", "'name'", "=>", "$", "File", "->", "name", ".", "' '", ",", "$", "File", "->", "key", ")", ")", ",", "$", "Journal", ")", ")", ";", "$", "folders", "=", "$", "this", "->", "getFolders", "(", "$", "databaseConnectionName", ",", "$", "organizationId", ")", ";", "}", ")", ";", "return", "json_encode", "(", "array", "(", "'success'", "=>", "$", "this", "->", "Lang", "->", "get", "(", "'form.defaultSuccessSaveMessage'", ")", ",", "'id'", "=>", "$", "File", "->", "id", ",", "'folders'", "=>", "$", "folders", ")", ")", ";", "}", "else", "{", "//Error, no dos carpetas no pueden tener el mismo nombre en la misa raiz", "return", "json_encode", "(", "array", "(", "'info'", "=>", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.folderAlreadyExistValidation'", ")", ")", ")", ";", "}", "}" ]
Create a new ... @param array $input An array as follows: array('field0'=>$field0, 'field1'=>$field1 ); @return JSON encoded string A string as follows: In case of success: {"success" : form.defaultSuccessSaveMessage}
[ "Create", "a", "new", "..." ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L808-L862
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.delete
public function delete(array $input, $openTransaction = true, $databaseConnectionName = null, $organizationId = null, $loggedUserId = null) { unset($input['_token']); if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId(); } if(empty($loggedUserId)) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); } $this->DB->transaction(function() use ($input, &$count , &$folders, $databaseConnectionName, $organizationId, $loggedUserId) { $File = $this->File->byId($input['id'], $databaseConnectionName); if($File->type == 'A') { $this->Storage->delete('organizations/'. $organizationId . '/' . $File['name']); $this->File->delete(array($input['id']), $databaseConnectionName); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->File->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-file::file-management.deletedFile', array('name' => $File->name))), $Journal); } else { $hijo = $this->File->byParentId($input['id'], $organizationId, $databaseConnectionName); $count = $hijo->count(); if($count == 0) { $this->File->delete(array($input['id']), $databaseConnectionName); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->File->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-file::file-management.deletedJournal', array('name' => $File->name))), $Journal); } } $folders = $this->getFolders($databaseConnectionName, $organizationId); }); if($count == 0) { return json_encode(array('success' => $this->Lang->get('form.defaultSuccessDeleteMessage'), 'folders' => $folders)); } else { return json_encode(array('success' => $this->Lang->get('decima-file::file-management.val'))); } }
php
public function delete(array $input, $openTransaction = true, $databaseConnectionName = null, $organizationId = null, $loggedUserId = null) { unset($input['_token']); if(empty($organizationId)) { $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId(); } if(empty($loggedUserId)) { $loggedUserId = $this->AuthenticationManager->getLoggedUserId(); } $this->DB->transaction(function() use ($input, &$count , &$folders, $databaseConnectionName, $organizationId, $loggedUserId) { $File = $this->File->byId($input['id'], $databaseConnectionName); if($File->type == 'A') { $this->Storage->delete('organizations/'. $organizationId . '/' . $File['name']); $this->File->delete(array($input['id']), $databaseConnectionName); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->File->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-file::file-management.deletedFile', array('name' => $File->name))), $Journal); } else { $hijo = $this->File->byParentId($input['id'], $organizationId, $databaseConnectionName); $count = $hijo->count(); if($count == 0) { $this->File->delete(array($input['id']), $databaseConnectionName); $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->File->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId)); $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-file::file-management.deletedJournal', array('name' => $File->name))), $Journal); } } $folders = $this->getFolders($databaseConnectionName, $organizationId); }); if($count == 0) { return json_encode(array('success' => $this->Lang->get('form.defaultSuccessDeleteMessage'), 'folders' => $folders)); } else { return json_encode(array('success' => $this->Lang->get('decima-file::file-management.val'))); } }
[ "public", "function", "delete", "(", "array", "$", "input", ",", "$", "openTransaction", "=", "true", ",", "$", "databaseConnectionName", "=", "null", ",", "$", "organizationId", "=", "null", ",", "$", "loggedUserId", "=", "null", ")", "{", "unset", "(", "$", "input", "[", "'_token'", "]", ")", ";", "if", "(", "empty", "(", "$", "organizationId", ")", ")", "{", "$", "organizationId", "=", "$", "this", "->", "AuthenticationManager", "->", "getCurrentUserOrganizationId", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "loggedUserId", ")", ")", "{", "$", "loggedUserId", "=", "$", "this", "->", "AuthenticationManager", "->", "getLoggedUserId", "(", ")", ";", "}", "$", "this", "->", "DB", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "input", ",", "&", "$", "count", ",", "&", "$", "folders", ",", "$", "databaseConnectionName", ",", "$", "organizationId", ",", "$", "loggedUserId", ")", "{", "$", "File", "=", "$", "this", "->", "File", "->", "byId", "(", "$", "input", "[", "'id'", "]", ",", "$", "databaseConnectionName", ")", ";", "if", "(", "$", "File", "->", "type", "==", "'A'", ")", "{", "$", "this", "->", "Storage", "->", "delete", "(", "'organizations/'", ".", "$", "organizationId", ".", "'/'", ".", "$", "File", "[", "'name'", "]", ")", ";", "$", "this", "->", "File", "->", "delete", "(", "array", "(", "$", "input", "[", "'id'", "]", ")", ",", "$", "databaseConnectionName", ")", ";", "$", "Journal", "=", "$", "this", "->", "Journal", "->", "create", "(", "array", "(", "'journalized_id'", "=>", "$", "input", "[", "'id'", "]", ",", "'journalized_type'", "=>", "$", "this", "->", "File", "->", "getTable", "(", ")", ",", "'user_id'", "=>", "$", "loggedUserId", ",", "'organization_id'", "=>", "$", "organizationId", ")", ")", ";", "$", "this", "->", "Journal", "->", "attachDetail", "(", "$", "Journal", "->", "id", ",", "array", "(", "'note'", "=>", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.deletedFile'", ",", "array", "(", "'name'", "=>", "$", "File", "->", "name", ")", ")", ")", ",", "$", "Journal", ")", ";", "}", "else", "{", "$", "hijo", "=", "$", "this", "->", "File", "->", "byParentId", "(", "$", "input", "[", "'id'", "]", ",", "$", "organizationId", ",", "$", "databaseConnectionName", ")", ";", "$", "count", "=", "$", "hijo", "->", "count", "(", ")", ";", "if", "(", "$", "count", "==", "0", ")", "{", "$", "this", "->", "File", "->", "delete", "(", "array", "(", "$", "input", "[", "'id'", "]", ")", ",", "$", "databaseConnectionName", ")", ";", "$", "Journal", "=", "$", "this", "->", "Journal", "->", "create", "(", "array", "(", "'journalized_id'", "=>", "$", "input", "[", "'id'", "]", ",", "'journalized_type'", "=>", "$", "this", "->", "File", "->", "getTable", "(", ")", ",", "'user_id'", "=>", "$", "loggedUserId", ",", "'organization_id'", "=>", "$", "organizationId", ")", ")", ";", "$", "this", "->", "Journal", "->", "attachDetail", "(", "$", "Journal", "->", "id", ",", "array", "(", "'note'", "=>", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.deletedJournal'", ",", "array", "(", "'name'", "=>", "$", "File", "->", "name", ")", ")", ")", ",", "$", "Journal", ")", ";", "}", "}", "$", "folders", "=", "$", "this", "->", "getFolders", "(", "$", "databaseConnectionName", ",", "$", "organizationId", ")", ";", "}", ")", ";", "if", "(", "$", "count", "==", "0", ")", "{", "return", "json_encode", "(", "array", "(", "'success'", "=>", "$", "this", "->", "Lang", "->", "get", "(", "'form.defaultSuccessDeleteMessage'", ")", ",", "'folders'", "=>", "$", "folders", ")", ")", ";", "}", "else", "{", "return", "json_encode", "(", "array", "(", "'success'", "=>", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.val'", ")", ")", ")", ";", "}", "}" ]
Delete existing ... (soft delete) @param array $input An array as follows: array($id0, $id1,…); @return JSON encoded string A string as follows: In case of success: {"success" : form.defaultSuccessDeleteMessage}
[ "Delete", "existing", "...", "(", "soft", "delete", ")" ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L928-L977
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.serveFile
public function serveFile($type, $route, $filename) { if($type == 'image') { return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'image'); } else if($type == 'pdf') { return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'application/pdf'); } else { return $this->Response->make($this->Storage->read($route)) ->header('Pragma', 'public') ->header('Expires', '0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Content-Type', 'application/force-download') ->header('Content-Type', 'application/octet-stream') ->header('Content-Type', 'application/download') ->header('Content-Disposition', 'attachment; filename=' . $filename) ->header('Content-Transfer-Encoding', 'binary'); } // if($this->Config->get('filesystems.default') == 'gcs') // { // if($type == 'image') // { // return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'image'); // } // else if($type == 'pdf') // { // return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'application/pdf'); // } // else // { // return $this->Response->make($this->Storage->read($route)) // ->header('Pragma', 'public') // ->header('Expires', '0') // ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') // ->header('Content-Type', 'application/force-download') // ->header('Content-Type', 'application/octet-stream') // ->header('Content-Type', 'application/download') // ->header('Content-Disposition', 'attachment; filename=' . $filename) // ->header('Content-Transfer-Encoding', 'binary'); // } // } // // if($type == 'image' || $type == 'pdf') // { // return $this->Response->file($route); // } // // return $this->Response->download($route); }
php
public function serveFile($type, $route, $filename) { if($type == 'image') { return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'image'); } else if($type == 'pdf') { return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'application/pdf'); } else { return $this->Response->make($this->Storage->read($route)) ->header('Pragma', 'public') ->header('Expires', '0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Content-Type', 'application/force-download') ->header('Content-Type', 'application/octet-stream') ->header('Content-Type', 'application/download') ->header('Content-Disposition', 'attachment; filename=' . $filename) ->header('Content-Transfer-Encoding', 'binary'); } // if($this->Config->get('filesystems.default') == 'gcs') // { // if($type == 'image') // { // return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'image'); // } // else if($type == 'pdf') // { // return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'application/pdf'); // } // else // { // return $this->Response->make($this->Storage->read($route)) // ->header('Pragma', 'public') // ->header('Expires', '0') // ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') // ->header('Content-Type', 'application/force-download') // ->header('Content-Type', 'application/octet-stream') // ->header('Content-Type', 'application/download') // ->header('Content-Disposition', 'attachment; filename=' . $filename) // ->header('Content-Transfer-Encoding', 'binary'); // } // } // // if($type == 'image' || $type == 'pdf') // { // return $this->Response->file($route); // } // // return $this->Response->download($route); }
[ "public", "function", "serveFile", "(", "$", "type", ",", "$", "route", ",", "$", "filename", ")", "{", "if", "(", "$", "type", "==", "'image'", ")", "{", "return", "$", "this", "->", "Response", "->", "make", "(", "$", "this", "->", "Storage", "->", "read", "(", "$", "route", ")", ")", "->", "header", "(", "'Content-Type'", ",", "'image'", ")", ";", "}", "else", "if", "(", "$", "type", "==", "'pdf'", ")", "{", "return", "$", "this", "->", "Response", "->", "make", "(", "$", "this", "->", "Storage", "->", "read", "(", "$", "route", ")", ")", "->", "header", "(", "'Content-Type'", ",", "'application/pdf'", ")", ";", "}", "else", "{", "return", "$", "this", "->", "Response", "->", "make", "(", "$", "this", "->", "Storage", "->", "read", "(", "$", "route", ")", ")", "->", "header", "(", "'Pragma'", ",", "'public'", ")", "->", "header", "(", "'Expires'", ",", "'0'", ")", "->", "header", "(", "'Cache-Control'", ",", "'must-revalidate, post-check=0, pre-check=0'", ")", "->", "header", "(", "'Content-Type'", ",", "'application/force-download'", ")", "->", "header", "(", "'Content-Type'", ",", "'application/octet-stream'", ")", "->", "header", "(", "'Content-Type'", ",", "'application/download'", ")", "->", "header", "(", "'Content-Disposition'", ",", "'attachment; filename='", ".", "$", "filename", ")", "->", "header", "(", "'Content-Transfer-Encoding'", ",", "'binary'", ")", ";", "}", "// if($this->Config->get('filesystems.default') == 'gcs')", "// {", "// if($type == 'image')", "// {", "// return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'image');", "// }", "// else if($type == 'pdf')", "// {", "// return $this->Response->make($this->Storage->read($route))->header('Content-Type', 'application/pdf');", "// }", "// else", "// {", "// return $this->Response->make($this->Storage->read($route))", "// ->header('Pragma', 'public')", "// ->header('Expires', '0')", "// ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')", "// ->header('Content-Type', 'application/force-download')", "// ->header('Content-Type', 'application/octet-stream')", "// ->header('Content-Type', 'application/download')", "// ->header('Content-Disposition', 'attachment; filename=' . $filename)", "// ->header('Content-Transfer-Encoding', 'binary');", "// }", "// }", "//", "// if($type == 'image' || $type == 'pdf')", "// {", "// return $this->Response->file($route);", "// }", "//", "// return $this->Response->download($route);", "}" ]
Serve public file @param string $key @return Response
[ "Serve", "public", "file" ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L1003-L1056
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.servePublicFile
public function servePublicFile($key) { $SecurityFile = $this->SecurityFile->byKey($key)->first(); if(!is_null($SecurityFile)) { $File = $this->File->byKeyAndPublicWithConnectionName($key, true, $SecurityFile->organization->database_connection_name)->first(); } else { $File = $this->File->byKeyAndPublic($key, true)->first(); } if(!is_null($File)) { return $this->serveFile($File->system_type, $File->system_route, $File->name); } return $this->Redirector->to($this->AppManager->getErrorPageUrl())->withError($this->Lang->get('decima-file::file-management.fileNotFound')); }
php
public function servePublicFile($key) { $SecurityFile = $this->SecurityFile->byKey($key)->first(); if(!is_null($SecurityFile)) { $File = $this->File->byKeyAndPublicWithConnectionName($key, true, $SecurityFile->organization->database_connection_name)->first(); } else { $File = $this->File->byKeyAndPublic($key, true)->first(); } if(!is_null($File)) { return $this->serveFile($File->system_type, $File->system_route, $File->name); } return $this->Redirector->to($this->AppManager->getErrorPageUrl())->withError($this->Lang->get('decima-file::file-management.fileNotFound')); }
[ "public", "function", "servePublicFile", "(", "$", "key", ")", "{", "$", "SecurityFile", "=", "$", "this", "->", "SecurityFile", "->", "byKey", "(", "$", "key", ")", "->", "first", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "SecurityFile", ")", ")", "{", "$", "File", "=", "$", "this", "->", "File", "->", "byKeyAndPublicWithConnectionName", "(", "$", "key", ",", "true", ",", "$", "SecurityFile", "->", "organization", "->", "database_connection_name", ")", "->", "first", "(", ")", ";", "}", "else", "{", "$", "File", "=", "$", "this", "->", "File", "->", "byKeyAndPublic", "(", "$", "key", ",", "true", ")", "->", "first", "(", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "File", ")", ")", "{", "return", "$", "this", "->", "serveFile", "(", "$", "File", "->", "system_type", ",", "$", "File", "->", "system_route", ",", "$", "File", "->", "name", ")", ";", "}", "return", "$", "this", "->", "Redirector", "->", "to", "(", "$", "this", "->", "AppManager", "->", "getErrorPageUrl", "(", ")", ")", "->", "withError", "(", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.fileNotFound'", ")", ")", ";", "}" ]
Serve public file @param string $key @return Response
[ "Serve", "public", "file" ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L1065-L1084
mgallegos/decima-file
src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php
FileManager.servePrivateFile
public function servePrivateFile($key) { $File = $this->File->byKeyAndPublic($key , false)->first(); if(!is_null($File)) { return $this->serveFile($File->system_type, $File->system_route, $File->name); } return $this->Redirector->to($this->AppManager->getErrorPageUrl())->withError($this->Lang->get('decima-file::file-management.fileNotFound')); }
php
public function servePrivateFile($key) { $File = $this->File->byKeyAndPublic($key , false)->first(); if(!is_null($File)) { return $this->serveFile($File->system_type, $File->system_route, $File->name); } return $this->Redirector->to($this->AppManager->getErrorPageUrl())->withError($this->Lang->get('decima-file::file-management.fileNotFound')); }
[ "public", "function", "servePrivateFile", "(", "$", "key", ")", "{", "$", "File", "=", "$", "this", "->", "File", "->", "byKeyAndPublic", "(", "$", "key", ",", "false", ")", "->", "first", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "File", ")", ")", "{", "return", "$", "this", "->", "serveFile", "(", "$", "File", "->", "system_type", ",", "$", "File", "->", "system_route", ",", "$", "File", "->", "name", ")", ";", "}", "return", "$", "this", "->", "Redirector", "->", "to", "(", "$", "this", "->", "AppManager", "->", "getErrorPageUrl", "(", ")", ")", "->", "withError", "(", "$", "this", "->", "Lang", "->", "get", "(", "'decima-file::file-management.fileNotFound'", ")", ")", ";", "}" ]
Serve private file @param string $key @return Response
[ "Serve", "private", "file" ]
train
https://github.com/mgallegos/decima-file/blob/94c26ab40f5c4dd12e913e73376c24db27588f0b/src/Mgallegos/DecimaFile/File/Services/FileManagement/FileManager.php#L1093-L1103
yuncms/framework
src/filesystem/FilesystemAdapter.php
FilesystemAdapter.putFile
public function putFile($path, $file, $options = []) { return $this->putFileAs($path, $file, $file->getRename(), $options); }
php
public function putFile($path, $file, $options = []) { return $this->putFileAs($path, $file, $file->getRename(), $options); }
[ "public", "function", "putFile", "(", "$", "path", ",", "$", "file", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "putFileAs", "(", "$", "path", ",", "$", "file", ",", "$", "file", "->", "getRename", "(", ")", ",", "$", "options", ")", ";", "}" ]
Store the uploaded file on the disk. @param string $path @param \yuncms\web\UploadedFile $file @param array $options @return string|false
[ "Store", "the", "uploaded", "file", "on", "the", "disk", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemAdapter.php#L112-L115
yuncms/framework
src/filesystem/FilesystemAdapter.php
FilesystemAdapter.getVisibility
public function getVisibility($path) { if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) { return Filesystem::VISIBILITY_PUBLIC; } return Filesystem::VISIBILITY_PRIVATE; }
php
public function getVisibility($path) { if ($this->driver->getVisibility($path) == AdapterInterface::VISIBILITY_PUBLIC) { return Filesystem::VISIBILITY_PUBLIC; } return Filesystem::VISIBILITY_PRIVATE; }
[ "public", "function", "getVisibility", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "driver", "->", "getVisibility", "(", "$", "path", ")", "==", "AdapterInterface", "::", "VISIBILITY_PUBLIC", ")", "{", "return", "Filesystem", "::", "VISIBILITY_PUBLIC", ";", "}", "return", "Filesystem", "::", "VISIBILITY_PRIVATE", ";", "}" ]
获取文件的可见性属性 @param string $path @return string @throws FileNotFoundException
[ "获取文件的可见性属性" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemAdapter.php#L151-L157
yuncms/framework
src/filesystem/FilesystemAdapter.php
FilesystemAdapter.url
public function url($path) { $adapter = $this->driver->getAdapter(); if ($adapter instanceof CachedAdapter) { $adapter = $adapter->getAdapter(); } if (method_exists($adapter, 'getUrl')) { return $adapter->getUrl($path); } elseif ($adapter instanceof OssAdapter) { return $this->getOssUrl($adapter, $path); } elseif ($adapter instanceof AwsS3Adapter) { return $this->getAwsUrl($adapter, $path); } elseif ($adapter instanceof LocalAdapter) { return $this->getLocalUrl($path); } else { throw new RuntimeException('This driver does not support retrieving URLs.'); } }
php
public function url($path) { $adapter = $this->driver->getAdapter(); if ($adapter instanceof CachedAdapter) { $adapter = $adapter->getAdapter(); } if (method_exists($adapter, 'getUrl')) { return $adapter->getUrl($path); } elseif ($adapter instanceof OssAdapter) { return $this->getOssUrl($adapter, $path); } elseif ($adapter instanceof AwsS3Adapter) { return $this->getAwsUrl($adapter, $path); } elseif ($adapter instanceof LocalAdapter) { return $this->getLocalUrl($path); } else { throw new RuntimeException('This driver does not support retrieving URLs.'); } }
[ "public", "function", "url", "(", "$", "path", ")", "{", "$", "adapter", "=", "$", "this", "->", "driver", "->", "getAdapter", "(", ")", ";", "if", "(", "$", "adapter", "instanceof", "CachedAdapter", ")", "{", "$", "adapter", "=", "$", "adapter", "->", "getAdapter", "(", ")", ";", "}", "if", "(", "method_exists", "(", "$", "adapter", ",", "'getUrl'", ")", ")", "{", "return", "$", "adapter", "->", "getUrl", "(", "$", "path", ")", ";", "}", "elseif", "(", "$", "adapter", "instanceof", "OssAdapter", ")", "{", "return", "$", "this", "->", "getOssUrl", "(", "$", "adapter", ",", "$", "path", ")", ";", "}", "elseif", "(", "$", "adapter", "instanceof", "AwsS3Adapter", ")", "{", "return", "$", "this", "->", "getAwsUrl", "(", "$", "adapter", ",", "$", "path", ")", ";", "}", "elseif", "(", "$", "adapter", "instanceof", "LocalAdapter", ")", "{", "return", "$", "this", "->", "getLocalUrl", "(", "$", "path", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'This driver does not support retrieving URLs.'", ")", ";", "}", "}" ]
获取文件访问Url @param string $path @return string @throws \OSS\Core\OssException
[ "获取文件访问Url" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemAdapter.php#L301-L320
yuncms/framework
src/filesystem/FilesystemAdapter.php
FilesystemAdapter.getLocalUrl
protected function getLocalUrl($path) { $config = $this->driver->getConfig(); // If an explicit base URL has been set on the disk configuration then we will use // it as the base URL instead of the default path. This allows the developer to // have full control over the base path for this filesystem's generated URLs. if ($config->has('url')) { return $this->concatPathToUrl(Yii::getAlias($config->get('url')), $path); } $path = '/storage/' . $path; // If the path contains "storage/public", it probably means the developer is using // the default disk to generate the path instead of the "public" disk like they // are really supposed to use. We will remove the public from this path here. if (StringHelper::contains($path, '/storage/public/')) { return StringHelper::replaceFirst('/public/', '/', $path); } return $path; }
php
protected function getLocalUrl($path) { $config = $this->driver->getConfig(); // If an explicit base URL has been set on the disk configuration then we will use // it as the base URL instead of the default path. This allows the developer to // have full control over the base path for this filesystem's generated URLs. if ($config->has('url')) { return $this->concatPathToUrl(Yii::getAlias($config->get('url')), $path); } $path = '/storage/' . $path; // If the path contains "storage/public", it probably means the developer is using // the default disk to generate the path instead of the "public" disk like they // are really supposed to use. We will remove the public from this path here. if (StringHelper::contains($path, '/storage/public/')) { return StringHelper::replaceFirst('/public/', '/', $path); } return $path; }
[ "protected", "function", "getLocalUrl", "(", "$", "path", ")", "{", "$", "config", "=", "$", "this", "->", "driver", "->", "getConfig", "(", ")", ";", "// If an explicit base URL has been set on the disk configuration then we will use", "// it as the base URL instead of the default path. This allows the developer to", "// have full control over the base path for this filesystem's generated URLs.", "if", "(", "$", "config", "->", "has", "(", "'url'", ")", ")", "{", "return", "$", "this", "->", "concatPathToUrl", "(", "Yii", "::", "getAlias", "(", "$", "config", "->", "get", "(", "'url'", ")", ")", ",", "$", "path", ")", ";", "}", "$", "path", "=", "'/storage/'", ".", "$", "path", ";", "// If the path contains \"storage/public\", it probably means the developer is using", "// the default disk to generate the path instead of the \"public\" disk like they", "// are really supposed to use. We will remove the public from this path here.", "if", "(", "StringHelper", "::", "contains", "(", "$", "path", ",", "'/storage/public/'", ")", ")", "{", "return", "StringHelper", "::", "replaceFirst", "(", "'/public/'", ",", "'/'", ",", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
Get the URL for the file at the given path. @param string $path @return string
[ "Get", "the", "URL", "for", "the", "file", "at", "the", "given", "path", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemAdapter.php#L328-L349
yuncms/framework
src/filesystem/FilesystemAdapter.php
FilesystemAdapter.temporaryUrl
public function temporaryUrl($path, $expiration, array $options = []) { $adapter = $this->driver->getAdapter(); if ($adapter instanceof CachedAdapter) { $adapter = $adapter->getAdapter(); } if (method_exists($adapter, 'getTemporaryUrl')) { return $adapter->getTemporaryUrl($path, $expiration, $options); } elseif ($adapter instanceof AwsS3Adapter) { return $this->getAwsTemporaryUrl($adapter, $path, $expiration, $options); } else { throw new RuntimeException('This driver does not support creating temporary URLs.'); } }
php
public function temporaryUrl($path, $expiration, array $options = []) { $adapter = $this->driver->getAdapter(); if ($adapter instanceof CachedAdapter) { $adapter = $adapter->getAdapter(); } if (method_exists($adapter, 'getTemporaryUrl')) { return $adapter->getTemporaryUrl($path, $expiration, $options); } elseif ($adapter instanceof AwsS3Adapter) { return $this->getAwsTemporaryUrl($adapter, $path, $expiration, $options); } else { throw new RuntimeException('This driver does not support creating temporary URLs.'); } }
[ "public", "function", "temporaryUrl", "(", "$", "path", ",", "$", "expiration", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "adapter", "=", "$", "this", "->", "driver", "->", "getAdapter", "(", ")", ";", "if", "(", "$", "adapter", "instanceof", "CachedAdapter", ")", "{", "$", "adapter", "=", "$", "adapter", "->", "getAdapter", "(", ")", ";", "}", "if", "(", "method_exists", "(", "$", "adapter", ",", "'getTemporaryUrl'", ")", ")", "{", "return", "$", "adapter", "->", "getTemporaryUrl", "(", "$", "path", ",", "$", "expiration", ",", "$", "options", ")", ";", "}", "elseif", "(", "$", "adapter", "instanceof", "AwsS3Adapter", ")", "{", "return", "$", "this", "->", "getAwsTemporaryUrl", "(", "$", "adapter", ",", "$", "path", ",", "$", "expiration", ",", "$", "options", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'This driver does not support creating temporary URLs.'", ")", ";", "}", "}" ]
获取文件的临时访问Url @param string $path @param \DateTimeInterface $expiration @param array $options @return string
[ "获取文件的临时访问Url" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemAdapter.php#L397-L412
yuncms/framework
src/filesystem/FilesystemAdapter.php
FilesystemAdapter.parseVisibility
protected function parseVisibility($visibility) { if (is_null($visibility)) { return; } switch ($visibility) { case Filesystem::VISIBILITY_PUBLIC: return AdapterInterface::VISIBILITY_PUBLIC; case Filesystem::VISIBILITY_PRIVATE: return AdapterInterface::VISIBILITY_PRIVATE; } throw new InvalidArgumentException('Unknown visibility: ' . $visibility); }
php
protected function parseVisibility($visibility) { if (is_null($visibility)) { return; } switch ($visibility) { case Filesystem::VISIBILITY_PUBLIC: return AdapterInterface::VISIBILITY_PUBLIC; case Filesystem::VISIBILITY_PRIVATE: return AdapterInterface::VISIBILITY_PRIVATE; } throw new InvalidArgumentException('Unknown visibility: ' . $visibility); }
[ "protected", "function", "parseVisibility", "(", "$", "visibility", ")", "{", "if", "(", "is_null", "(", "$", "visibility", ")", ")", "{", "return", ";", "}", "switch", "(", "$", "visibility", ")", "{", "case", "Filesystem", "::", "VISIBILITY_PUBLIC", ":", "return", "AdapterInterface", "::", "VISIBILITY_PUBLIC", ";", "case", "Filesystem", "::", "VISIBILITY_PRIVATE", ":", "return", "AdapterInterface", "::", "VISIBILITY_PRIVATE", ";", "}", "throw", "new", "InvalidArgumentException", "(", "'Unknown visibility: '", ".", "$", "visibility", ")", ";", "}" ]
解析可见性值 @param string|null $visibility @return string @throws InvalidArgumentException
[ "解析可见性值" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemAdapter.php#L502-L515
ruvents/ruwork-upload-bundle
Form/Type/DoctrineUploadType.php
DoctrineUploadType.configureOptions
public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ 'finder' => function (Options $options): callable { $class = $options['class']; return function (string $path) use ($class) { $repository = $this ->getManager($class) ->getRepository($class); if ($repository instanceof UploadFinderInterface) { return $repository->findOneByPath($path); } $pathProperty = $this->metadataFactory ->getMetadata($class) ->getPathProperty(); return $repository->findOneBy([$pathProperty => $path]); }; }, 'saver' => function (Options $options): callable { $class = $options['class']; return function ($upload) use ($class): void { $manager = $this->getManager($class); $manager->clear(); $manager->persist($upload); $manager->flush(); }; }, ]); }
php
public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ 'finder' => function (Options $options): callable { $class = $options['class']; return function (string $path) use ($class) { $repository = $this ->getManager($class) ->getRepository($class); if ($repository instanceof UploadFinderInterface) { return $repository->findOneByPath($path); } $pathProperty = $this->metadataFactory ->getMetadata($class) ->getPathProperty(); return $repository->findOneBy([$pathProperty => $path]); }; }, 'saver' => function (Options $options): callable { $class = $options['class']; return function ($upload) use ($class): void { $manager = $this->getManager($class); $manager->clear(); $manager->persist($upload); $manager->flush(); }; }, ]); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", ":", "void", "{", "$", "resolver", "->", "setDefaults", "(", "[", "'finder'", "=>", "function", "(", "Options", "$", "options", ")", ":", "callable", "{", "$", "class", "=", "$", "options", "[", "'class'", "]", ";", "return", "function", "(", "string", "$", "path", ")", "use", "(", "$", "class", ")", "{", "$", "repository", "=", "$", "this", "->", "getManager", "(", "$", "class", ")", "->", "getRepository", "(", "$", "class", ")", ";", "if", "(", "$", "repository", "instanceof", "UploadFinderInterface", ")", "{", "return", "$", "repository", "->", "findOneByPath", "(", "$", "path", ")", ";", "}", "$", "pathProperty", "=", "$", "this", "->", "metadataFactory", "->", "getMetadata", "(", "$", "class", ")", "->", "getPathProperty", "(", ")", ";", "return", "$", "repository", "->", "findOneBy", "(", "[", "$", "pathProperty", "=>", "$", "path", "]", ")", ";", "}", ";", "}", ",", "'saver'", "=>", "function", "(", "Options", "$", "options", ")", ":", "callable", "{", "$", "class", "=", "$", "options", "[", "'class'", "]", ";", "return", "function", "(", "$", "upload", ")", "use", "(", "$", "class", ")", ":", "void", "{", "$", "manager", "=", "$", "this", "->", "getManager", "(", "$", "class", ")", ";", "$", "manager", "->", "clear", "(", ")", ";", "$", "manager", "->", "persist", "(", "$", "upload", ")", ";", "$", "manager", "->", "flush", "(", ")", ";", "}", ";", "}", ",", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Form/Type/DoctrineUploadType.php#L29-L63
fond-of/spryker-brand
src/FondOfSpryker/Zed/Brand/Communication/Console/BrandConsole.php
BrandConsole.execute
protected function execute(InputInterface $input, OutputInterface $output) { // single $single = 2; if ($single === 1) { $brandTransfer = new BrandTransfer(); $brandTransfer->setName('pinqponq'); $brandTransfer = $this->getFacade()->getBrand($brandTransfer); $this->printBrand($brandTransfer, $output); } else { // collection $filter = new FilterTransfer(); $brandCollectionTransfer = new BrandCollectionTransfer(); $brandCollectionTransfer->setFilter($filter); $brandTransfer = $this->getFacade()->getBrandCollection($brandCollectionTransfer); foreach ($brandTransfer->getBrands() as $brandTransfer) { $this->printBrand($brandTransfer, $output); } } return static::CODE_SUCCESS; }
php
protected function execute(InputInterface $input, OutputInterface $output) { // single $single = 2; if ($single === 1) { $brandTransfer = new BrandTransfer(); $brandTransfer->setName('pinqponq'); $brandTransfer = $this->getFacade()->getBrand($brandTransfer); $this->printBrand($brandTransfer, $output); } else { // collection $filter = new FilterTransfer(); $brandCollectionTransfer = new BrandCollectionTransfer(); $brandCollectionTransfer->setFilter($filter); $brandTransfer = $this->getFacade()->getBrandCollection($brandCollectionTransfer); foreach ($brandTransfer->getBrands() as $brandTransfer) { $this->printBrand($brandTransfer, $output); } } return static::CODE_SUCCESS; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// single", "$", "single", "=", "2", ";", "if", "(", "$", "single", "===", "1", ")", "{", "$", "brandTransfer", "=", "new", "BrandTransfer", "(", ")", ";", "$", "brandTransfer", "->", "setName", "(", "'pinqponq'", ")", ";", "$", "brandTransfer", "=", "$", "this", "->", "getFacade", "(", ")", "->", "getBrand", "(", "$", "brandTransfer", ")", ";", "$", "this", "->", "printBrand", "(", "$", "brandTransfer", ",", "$", "output", ")", ";", "}", "else", "{", "// collection", "$", "filter", "=", "new", "FilterTransfer", "(", ")", ";", "$", "brandCollectionTransfer", "=", "new", "BrandCollectionTransfer", "(", ")", ";", "$", "brandCollectionTransfer", "->", "setFilter", "(", "$", "filter", ")", ";", "$", "brandTransfer", "=", "$", "this", "->", "getFacade", "(", ")", "->", "getBrandCollection", "(", "$", "brandCollectionTransfer", ")", ";", "foreach", "(", "$", "brandTransfer", "->", "getBrands", "(", ")", "as", "$", "brandTransfer", ")", "{", "$", "this", "->", "printBrand", "(", "$", "brandTransfer", ",", "$", "output", ")", ";", "}", "}", "return", "static", "::", "CODE_SUCCESS", ";", "}" ]
@param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return int
[ "@param", "\\", "Symfony", "\\", "Component", "\\", "Console", "\\", "Input", "\\", "InputInterface", "$input", "@param", "\\", "Symfony", "\\", "Component", "\\", "Console", "\\", "Output", "\\", "OutputInterface", "$output" ]
train
https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Communication/Console/BrandConsole.php#L39-L63
fond-of/spryker-brand
src/FondOfSpryker/Zed/Brand/Communication/Console/BrandConsole.php
BrandConsole.printBrand
protected function printBrand(BrandTransfer $brandTransfer, OutputInterface $output): void { $output->writeln($brandTransfer->getName() . ' ' . $brandTransfer->getB2cUrlShop()); $output->writeln('--------'); }
php
protected function printBrand(BrandTransfer $brandTransfer, OutputInterface $output): void { $output->writeln($brandTransfer->getName() . ' ' . $brandTransfer->getB2cUrlShop()); $output->writeln('--------'); }
[ "protected", "function", "printBrand", "(", "BrandTransfer", "$", "brandTransfer", ",", "OutputInterface", "$", "output", ")", ":", "void", "{", "$", "output", "->", "writeln", "(", "$", "brandTransfer", "->", "getName", "(", ")", ".", "' '", ".", "$", "brandTransfer", "->", "getB2cUrlShop", "(", ")", ")", ";", "$", "output", "->", "writeln", "(", "'--------'", ")", ";", "}" ]
@param \Generated\Shared\Transfer\BrandTransfer $brandTransfer @param \Symfony\Component\Console\Output\OutputInterface $output @return void
[ "@param", "\\", "Generated", "\\", "Shared", "\\", "Transfer", "\\", "BrandTransfer", "$brandTransfer", "@param", "\\", "Symfony", "\\", "Component", "\\", "Console", "\\", "Output", "\\", "OutputInterface", "$output" ]
train
https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Communication/Console/BrandConsole.php#L71-L75
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.buildStatement
public function buildStatement(Query $query) { $type = $query->getType(); $method = 'build' . ucfirst($type); $dialect = $this->getDialect(); if (!method_exists($dialect, $method)) { throw new UnsupportedQueryStatementException(sprintf('Query statement %s does not exist or has not been implemented', $type)); } return $this->getConnection()->prepare(call_user_func([$dialect, $method], $query)); }
php
public function buildStatement(Query $query) { $type = $query->getType(); $method = 'build' . ucfirst($type); $dialect = $this->getDialect(); if (!method_exists($dialect, $method)) { throw new UnsupportedQueryStatementException(sprintf('Query statement %s does not exist or has not been implemented', $type)); } return $this->getConnection()->prepare(call_user_func([$dialect, $method], $query)); }
[ "public", "function", "buildStatement", "(", "Query", "$", "query", ")", "{", "$", "type", "=", "$", "query", "->", "getType", "(", ")", ";", "$", "method", "=", "'build'", ".", "ucfirst", "(", "$", "type", ")", ";", "$", "dialect", "=", "$", "this", "->", "getDialect", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "dialect", ",", "$", "method", ")", ")", "{", "throw", "new", "UnsupportedQueryStatementException", "(", "sprintf", "(", "'Query statement %s does not exist or has not been implemented'", ",", "$", "type", ")", ")", ";", "}", "return", "$", "this", "->", "getConnection", "(", ")", "->", "prepare", "(", "call_user_func", "(", "[", "$", "dialect", ",", "$", "method", "]", ",", "$", "query", ")", ")", ";", "}" ]
{@inheritdoc} @throws \Titon\Db\Exception\UnsupportedQueryStatementException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L54-L64
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.connect
public function connect() { if ($this->isConnected()) { return true; } // @codeCoverageIgnoreStart if (!$this->isEnabled()) { throw new MissingDriverException(sprintf('%s driver extension is not enabled', $this->getDriver())); } // @codeCoverageIgnoreEnd $this->_connections[$this->getContext()] = new PDO($this->getDsn(), $this->getUser(), $this->getPassword(), $this->getConfig('flags') + [ PDO::ATTR_PERSISTENT => $this->isPersistent(), PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); return true; }
php
public function connect() { if ($this->isConnected()) { return true; } // @codeCoverageIgnoreStart if (!$this->isEnabled()) { throw new MissingDriverException(sprintf('%s driver extension is not enabled', $this->getDriver())); } // @codeCoverageIgnoreEnd $this->_connections[$this->getContext()] = new PDO($this->getDsn(), $this->getUser(), $this->getPassword(), $this->getConfig('flags') + [ PDO::ATTR_PERSISTENT => $this->isPersistent(), PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); return true; }
[ "public", "function", "connect", "(", ")", "{", "if", "(", "$", "this", "->", "isConnected", "(", ")", ")", "{", "return", "true", ";", "}", "// @codeCoverageIgnoreStart", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "throw", "new", "MissingDriverException", "(", "sprintf", "(", "'%s driver extension is not enabled'", ",", "$", "this", "->", "getDriver", "(", ")", ")", ")", ";", "}", "// @codeCoverageIgnoreEnd", "$", "this", "->", "_connections", "[", "$", "this", "->", "getContext", "(", ")", "]", "=", "new", "PDO", "(", "$", "this", "->", "getDsn", "(", ")", ",", "$", "this", "->", "getUser", "(", ")", ",", "$", "this", "->", "getPassword", "(", ")", ",", "$", "this", "->", "getConfig", "(", "'flags'", ")", "+", "[", "PDO", "::", "ATTR_PERSISTENT", "=>", "$", "this", "->", "isPersistent", "(", ")", ",", "PDO", "::", "ATTR_ERRMODE", "=>", "PDO", "::", "ERRMODE_EXCEPTION", "]", ")", ";", "return", "true", ";", "}" ]
Connect to the database using PDO. @return bool @throws \Titon\Db\Exception\MissingDriverException
[ "Connect", "to", "the", "database", "using", "PDO", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L72-L89
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.commitTransaction
public function commitTransaction() { if ($this->_transactions === 1) { $this->logQuery(new SqlResultSet('COMMIT')); $status = $this->getConnection()->commit(); } else { $status = true; } $this->_transactions--; return $status; }
php
public function commitTransaction() { if ($this->_transactions === 1) { $this->logQuery(new SqlResultSet('COMMIT')); $status = $this->getConnection()->commit(); } else { $status = true; } $this->_transactions--; return $status; }
[ "public", "function", "commitTransaction", "(", ")", "{", "if", "(", "$", "this", "->", "_transactions", "===", "1", ")", "{", "$", "this", "->", "logQuery", "(", "new", "SqlResultSet", "(", "'COMMIT'", ")", ")", ";", "$", "status", "=", "$", "this", "->", "getConnection", "(", ")", "->", "commit", "(", ")", ";", "}", "else", "{", "$", "status", "=", "true", ";", "}", "$", "this", "->", "_transactions", "--", ";", "return", "$", "status", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L94-L106
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.describeTable
public function describeTable($table) { return $this->cacheQuery([__METHOD__, $table], function(AbstractPdoDriver $driver) use ($table) { $columns = $driver->executeQuery('SELECT * FROM information_schema.columns WHERE table_schema = ? AND table_name = ?;', [$driver->getDatabase(), $table])->find(); $schema = []; if (!$columns) { return $schema; } foreach ($columns as $column) { $field = $column['COLUMN_NAME']; $type = strtolower($column['COLUMN_TYPE']); $length = ''; // Determine type and length if (preg_match('/([a-z]+)(?:\(([0-9,]+)\))?/is', $type, $matches)) { $type = $matches[1]; if (isset($matches[2])) { $length = $matches[2]; } } // Inherit type defaults $data = $driver->getType($type)->getDefaultOptions(); // Overwrite with custom $data = [ 'field' => $field, 'type' => $type, 'length' => $length, 'null' => ($column['IS_NULLABLE'] === 'YES'), ] + $data; foreach ([ 'default' => 'COLUMN_DEFAULT', 'charset' => 'CHARACTER_SET_NAME', 'collate' => 'COLLATION_NAME', 'comment' => 'COLUMN_COMMENT' ] as $key => $search) { if (!empty($column[$search])) { $data[$key] = $column[$search]; } } switch (strtoupper($column['COLUMN_KEY'])) { case 'PRI': $data['primary'] = true; break; case 'UNI': $data['unique'] = true; break; case 'MUL': $data['index'] = true; break; } if ($column['EXTRA'] === 'auto_increment') { $data['ai'] = true; } $schema[$field] = $data; } return $schema; }, '+1 year'); }
php
public function describeTable($table) { return $this->cacheQuery([__METHOD__, $table], function(AbstractPdoDriver $driver) use ($table) { $columns = $driver->executeQuery('SELECT * FROM information_schema.columns WHERE table_schema = ? AND table_name = ?;', [$driver->getDatabase(), $table])->find(); $schema = []; if (!$columns) { return $schema; } foreach ($columns as $column) { $field = $column['COLUMN_NAME']; $type = strtolower($column['COLUMN_TYPE']); $length = ''; // Determine type and length if (preg_match('/([a-z]+)(?:\(([0-9,]+)\))?/is', $type, $matches)) { $type = $matches[1]; if (isset($matches[2])) { $length = $matches[2]; } } // Inherit type defaults $data = $driver->getType($type)->getDefaultOptions(); // Overwrite with custom $data = [ 'field' => $field, 'type' => $type, 'length' => $length, 'null' => ($column['IS_NULLABLE'] === 'YES'), ] + $data; foreach ([ 'default' => 'COLUMN_DEFAULT', 'charset' => 'CHARACTER_SET_NAME', 'collate' => 'COLLATION_NAME', 'comment' => 'COLUMN_COMMENT' ] as $key => $search) { if (!empty($column[$search])) { $data[$key] = $column[$search]; } } switch (strtoupper($column['COLUMN_KEY'])) { case 'PRI': $data['primary'] = true; break; case 'UNI': $data['unique'] = true; break; case 'MUL': $data['index'] = true; break; } if ($column['EXTRA'] === 'auto_increment') { $data['ai'] = true; } $schema[$field] = $data; } return $schema; }, '+1 year'); }
[ "public", "function", "describeTable", "(", "$", "table", ")", "{", "return", "$", "this", "->", "cacheQuery", "(", "[", "__METHOD__", ",", "$", "table", "]", ",", "function", "(", "AbstractPdoDriver", "$", "driver", ")", "use", "(", "$", "table", ")", "{", "$", "columns", "=", "$", "driver", "->", "executeQuery", "(", "'SELECT * FROM information_schema.columns WHERE table_schema = ? AND table_name = ?;'", ",", "[", "$", "driver", "->", "getDatabase", "(", ")", ",", "$", "table", "]", ")", "->", "find", "(", ")", ";", "$", "schema", "=", "[", "]", ";", "if", "(", "!", "$", "columns", ")", "{", "return", "$", "schema", ";", "}", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "field", "=", "$", "column", "[", "'COLUMN_NAME'", "]", ";", "$", "type", "=", "strtolower", "(", "$", "column", "[", "'COLUMN_TYPE'", "]", ")", ";", "$", "length", "=", "''", ";", "// Determine type and length", "if", "(", "preg_match", "(", "'/([a-z]+)(?:\\(([0-9,]+)\\))?/is'", ",", "$", "type", ",", "$", "matches", ")", ")", "{", "$", "type", "=", "$", "matches", "[", "1", "]", ";", "if", "(", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "$", "length", "=", "$", "matches", "[", "2", "]", ";", "}", "}", "// Inherit type defaults", "$", "data", "=", "$", "driver", "->", "getType", "(", "$", "type", ")", "->", "getDefaultOptions", "(", ")", ";", "// Overwrite with custom", "$", "data", "=", "[", "'field'", "=>", "$", "field", ",", "'type'", "=>", "$", "type", ",", "'length'", "=>", "$", "length", ",", "'null'", "=>", "(", "$", "column", "[", "'IS_NULLABLE'", "]", "===", "'YES'", ")", ",", "]", "+", "$", "data", ";", "foreach", "(", "[", "'default'", "=>", "'COLUMN_DEFAULT'", ",", "'charset'", "=>", "'CHARACTER_SET_NAME'", ",", "'collate'", "=>", "'COLLATION_NAME'", ",", "'comment'", "=>", "'COLUMN_COMMENT'", "]", "as", "$", "key", "=>", "$", "search", ")", "{", "if", "(", "!", "empty", "(", "$", "column", "[", "$", "search", "]", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "column", "[", "$", "search", "]", ";", "}", "}", "switch", "(", "strtoupper", "(", "$", "column", "[", "'COLUMN_KEY'", "]", ")", ")", "{", "case", "'PRI'", ":", "$", "data", "[", "'primary'", "]", "=", "true", ";", "break", ";", "case", "'UNI'", ":", "$", "data", "[", "'unique'", "]", "=", "true", ";", "break", ";", "case", "'MUL'", ":", "$", "data", "[", "'index'", "]", "=", "true", ";", "break", ";", "}", "if", "(", "$", "column", "[", "'EXTRA'", "]", "===", "'auto_increment'", ")", "{", "$", "data", "[", "'ai'", "]", "=", "true", ";", "}", "$", "schema", "[", "$", "field", "]", "=", "$", "data", ";", "}", "return", "$", "schema", ";", "}", ",", "'+1 year'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L111-L171
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.escape
public function escape($value) { if ($value === null) { return 'NULL'; } return $this->getConnection()->quote($value, $this->resolveType($value)); }
php
public function escape($value) { if ($value === null) { return 'NULL'; } return $this->getConnection()->quote($value, $this->resolveType($value)); }
[ "public", "function", "escape", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "return", "'NULL'", ";", "}", "return", "$", "this", "->", "getConnection", "(", ")", "->", "quote", "(", "$", "value", ",", "$", "this", "->", "resolveType", "(", "$", "value", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L176-L182
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.executeQuery
public function executeQuery($query, array $params = []) { $this->connect(); $cacheKey = null; $cacheLength = null; // Determine cache key and lengths if ($query instanceof Query) { $cacheKey = $query->getCacheKey(); $cacheLength = $query->getCacheLength(); } else if (!is_string($query)) { throw new InvalidQueryException('Query must be a raw SQL string or a Titon\Db\Query instance'); } // Execute and return result return $this->_result = $this->cacheQuery($cacheKey, function(AbstractPdoDriver $driver) use ($query, $params) { $isQuery = ($query instanceof Query); // Prepare statement and bind parameters if ($isQuery) { $statement = $driver->buildStatement($query); $binds = $driver->resolveParams($query); } else { $statement = $driver->getConnection()->prepare($query); $binds = []; foreach ($params as $value) { $binds[] = [$value, $driver->resolveType($value)]; } } foreach ($binds as $i => $value) { $statement->bindValue($i + 1, $value[0], $value[1]); } $statement->params = $binds; // Gather and log result if ($isQuery) { $result = new PdoResultSet($statement, $query); } else { $result = new PdoResultSet($statement); } $driver->logQuery($result); return $result; }, $cacheLength); }
php
public function executeQuery($query, array $params = []) { $this->connect(); $cacheKey = null; $cacheLength = null; // Determine cache key and lengths if ($query instanceof Query) { $cacheKey = $query->getCacheKey(); $cacheLength = $query->getCacheLength(); } else if (!is_string($query)) { throw new InvalidQueryException('Query must be a raw SQL string or a Titon\Db\Query instance'); } // Execute and return result return $this->_result = $this->cacheQuery($cacheKey, function(AbstractPdoDriver $driver) use ($query, $params) { $isQuery = ($query instanceof Query); // Prepare statement and bind parameters if ($isQuery) { $statement = $driver->buildStatement($query); $binds = $driver->resolveParams($query); } else { $statement = $driver->getConnection()->prepare($query); $binds = []; foreach ($params as $value) { $binds[] = [$value, $driver->resolveType($value)]; } } foreach ($binds as $i => $value) { $statement->bindValue($i + 1, $value[0], $value[1]); } $statement->params = $binds; // Gather and log result if ($isQuery) { $result = new PdoResultSet($statement, $query); } else { $result = new PdoResultSet($statement); } $driver->logQuery($result); return $result; }, $cacheLength); }
[ "public", "function", "executeQuery", "(", "$", "query", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "$", "cacheKey", "=", "null", ";", "$", "cacheLength", "=", "null", ";", "// Determine cache key and lengths", "if", "(", "$", "query", "instanceof", "Query", ")", "{", "$", "cacheKey", "=", "$", "query", "->", "getCacheKey", "(", ")", ";", "$", "cacheLength", "=", "$", "query", "->", "getCacheLength", "(", ")", ";", "}", "else", "if", "(", "!", "is_string", "(", "$", "query", ")", ")", "{", "throw", "new", "InvalidQueryException", "(", "'Query must be a raw SQL string or a Titon\\Db\\Query instance'", ")", ";", "}", "// Execute and return result", "return", "$", "this", "->", "_result", "=", "$", "this", "->", "cacheQuery", "(", "$", "cacheKey", ",", "function", "(", "AbstractPdoDriver", "$", "driver", ")", "use", "(", "$", "query", ",", "$", "params", ")", "{", "$", "isQuery", "=", "(", "$", "query", "instanceof", "Query", ")", ";", "// Prepare statement and bind parameters", "if", "(", "$", "isQuery", ")", "{", "$", "statement", "=", "$", "driver", "->", "buildStatement", "(", "$", "query", ")", ";", "$", "binds", "=", "$", "driver", "->", "resolveParams", "(", "$", "query", ")", ";", "}", "else", "{", "$", "statement", "=", "$", "driver", "->", "getConnection", "(", ")", "->", "prepare", "(", "$", "query", ")", ";", "$", "binds", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "value", ")", "{", "$", "binds", "[", "]", "=", "[", "$", "value", ",", "$", "driver", "->", "resolveType", "(", "$", "value", ")", "]", ";", "}", "}", "foreach", "(", "$", "binds", "as", "$", "i", "=>", "$", "value", ")", "{", "$", "statement", "->", "bindValue", "(", "$", "i", "+", "1", ",", "$", "value", "[", "0", "]", ",", "$", "value", "[", "1", "]", ")", ";", "}", "$", "statement", "->", "params", "=", "$", "binds", ";", "// Gather and log result", "if", "(", "$", "isQuery", ")", "{", "$", "result", "=", "new", "PdoResultSet", "(", "$", "statement", ",", "$", "query", ")", ";", "}", "else", "{", "$", "result", "=", "new", "PdoResultSet", "(", "$", "statement", ")", ";", "}", "$", "driver", "->", "logQuery", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}", ",", "$", "cacheLength", ")", ";", "}" ]
{@inheritdoc} @throws \Titon\Db\Exception\InvalidQueryException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L189-L239
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.resolveBind
public function resolveBind($field, $value, array $schema = []) { $type = null; // Exit early for functions since we don't have a valid field if ($field instanceof Func) { return [$value, $this->resolveType($value)]; } // Use the raw value for binding if ($value instanceof RawExpr) { $value = $value->getValue(); } // Type cast if ($value === null) { $type = PDO::PARAM_NULL; } else if (isset($schema[$field]['type'])) { $dataType = $this->getType($schema[$field]['type']); $value = $dataType->to($value); $type = $dataType->getBindingType(); } // Fallback and resolve if (!$type) { $type = $this->resolveType($value); } return [$value, $type]; }
php
public function resolveBind($field, $value, array $schema = []) { $type = null; // Exit early for functions since we don't have a valid field if ($field instanceof Func) { return [$value, $this->resolveType($value)]; } // Use the raw value for binding if ($value instanceof RawExpr) { $value = $value->getValue(); } // Type cast if ($value === null) { $type = PDO::PARAM_NULL; } else if (isset($schema[$field]['type'])) { $dataType = $this->getType($schema[$field]['type']); $value = $dataType->to($value); $type = $dataType->getBindingType(); } // Fallback and resolve if (!$type) { $type = $this->resolveType($value); } return [$value, $type]; }
[ "public", "function", "resolveBind", "(", "$", "field", ",", "$", "value", ",", "array", "$", "schema", "=", "[", "]", ")", "{", "$", "type", "=", "null", ";", "// Exit early for functions since we don't have a valid field", "if", "(", "$", "field", "instanceof", "Func", ")", "{", "return", "[", "$", "value", ",", "$", "this", "->", "resolveType", "(", "$", "value", ")", "]", ";", "}", "// Use the raw value for binding", "if", "(", "$", "value", "instanceof", "RawExpr", ")", "{", "$", "value", "=", "$", "value", "->", "getValue", "(", ")", ";", "}", "// Type cast", "if", "(", "$", "value", "===", "null", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_NULL", ";", "}", "else", "if", "(", "isset", "(", "$", "schema", "[", "$", "field", "]", "[", "'type'", "]", ")", ")", "{", "$", "dataType", "=", "$", "this", "->", "getType", "(", "$", "schema", "[", "$", "field", "]", "[", "'type'", "]", ")", ";", "$", "value", "=", "$", "dataType", "->", "to", "(", "$", "value", ")", ";", "$", "type", "=", "$", "dataType", "->", "getBindingType", "(", ")", ";", "}", "// Fallback and resolve", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "resolveType", "(", "$", "value", ")", ";", "}", "return", "[", "$", "value", ",", "$", "type", "]", ";", "}" ]
Resolve the bind value and the PDO binding type. @param string $field @param mixed $value @param array $schema @return array
[ "Resolve", "the", "bind", "value", "and", "the", "PDO", "binding", "type", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L334-L363
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.resolveParams
public function resolveParams(Query $query) { $params = []; $schema = $query->getRepository()->getSchema()->getColumns(); foreach ($query->getGroupedBindings() as $groupedBinds) { foreach ($groupedBinds as $binds) { $params[] = $this->resolveBind($binds['field'], $binds['value'], $schema); } } foreach ($query->getCompounds() as $compound) { $params = array_merge($params, $this->resolveParams($compound)); } return $params; }
php
public function resolveParams(Query $query) { $params = []; $schema = $query->getRepository()->getSchema()->getColumns(); foreach ($query->getGroupedBindings() as $groupedBinds) { foreach ($groupedBinds as $binds) { $params[] = $this->resolveBind($binds['field'], $binds['value'], $schema); } } foreach ($query->getCompounds() as $compound) { $params = array_merge($params, $this->resolveParams($compound)); } return $params; }
[ "public", "function", "resolveParams", "(", "Query", "$", "query", ")", "{", "$", "params", "=", "[", "]", ";", "$", "schema", "=", "$", "query", "->", "getRepository", "(", ")", "->", "getSchema", "(", ")", "->", "getColumns", "(", ")", ";", "foreach", "(", "$", "query", "->", "getGroupedBindings", "(", ")", "as", "$", "groupedBinds", ")", "{", "foreach", "(", "$", "groupedBinds", "as", "$", "binds", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "resolveBind", "(", "$", "binds", "[", "'field'", "]", ",", "$", "binds", "[", "'value'", "]", ",", "$", "schema", ")", ";", "}", "}", "foreach", "(", "$", "query", "->", "getCompounds", "(", ")", "as", "$", "compound", ")", "{", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "this", "->", "resolveParams", "(", "$", "compound", ")", ")", ";", "}", "return", "$", "params", ";", "}" ]
Resolve the list of values that will be required for PDO statement binding. @param \Titon\Db\Query $query @return array
[ "Resolve", "the", "list", "of", "values", "that", "will", "be", "required", "for", "PDO", "statement", "binding", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L371-L386
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.resolveType
public function resolveType($value) { if ($value === null) { $type = PDO::PARAM_NULL; } else if (is_resource($value)) { $type = PDO::PARAM_LOB; } else if (is_numeric($value)) { if (is_float($value) || is_double($value)) { $type = PDO::PARAM_STR; // Uses string type } else { $type = PDO::PARAM_INT; } } else if (is_bool($value)) { $type = PDO::PARAM_BOOL; } else { $type = PDO::PARAM_STR; } return $type; }
php
public function resolveType($value) { if ($value === null) { $type = PDO::PARAM_NULL; } else if (is_resource($value)) { $type = PDO::PARAM_LOB; } else if (is_numeric($value)) { if (is_float($value) || is_double($value)) { $type = PDO::PARAM_STR; // Uses string type } else { $type = PDO::PARAM_INT; } } else if (is_bool($value)) { $type = PDO::PARAM_BOOL; } else { $type = PDO::PARAM_STR; } return $type; }
[ "public", "function", "resolveType", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_NULL", ";", "}", "else", "if", "(", "is_resource", "(", "$", "value", ")", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_LOB", ";", "}", "else", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "if", "(", "is_float", "(", "$", "value", ")", "||", "is_double", "(", "$", "value", ")", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_STR", ";", "// Uses string type", "}", "else", "{", "$", "type", "=", "PDO", "::", "PARAM_INT", ";", "}", "}", "else", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "type", "=", "PDO", "::", "PARAM_BOOL", ";", "}", "else", "{", "$", "type", "=", "PDO", "::", "PARAM_STR", ";", "}", "return", "$", "type", ";", "}" ]
Resolve the value type for PDO parameter binding and quoting. @param mixed $value @return int
[ "Resolve", "the", "value", "type", "for", "PDO", "parameter", "binding", "and", "quoting", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L394-L417
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.rollbackTransaction
public function rollbackTransaction() { if ($this->_transactions === 1) { $this->logQuery(new SqlResultSet('ROLLBACK')); $status = $this->getConnection()->rollBack(); $this->_transactions = 0; } else { $status = true; $this->_transactions--; } return $status; }
php
public function rollbackTransaction() { if ($this->_transactions === 1) { $this->logQuery(new SqlResultSet('ROLLBACK')); $status = $this->getConnection()->rollBack(); $this->_transactions = 0; } else { $status = true; $this->_transactions--; } return $status; }
[ "public", "function", "rollbackTransaction", "(", ")", "{", "if", "(", "$", "this", "->", "_transactions", "===", "1", ")", "{", "$", "this", "->", "logQuery", "(", "new", "SqlResultSet", "(", "'ROLLBACK'", ")", ")", ";", "$", "status", "=", "$", "this", "->", "getConnection", "(", ")", "->", "rollBack", "(", ")", ";", "$", "this", "->", "_transactions", "=", "0", ";", "}", "else", "{", "$", "status", "=", "true", ";", "$", "this", "->", "_transactions", "--", ";", "}", "return", "$", "status", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L422-L437
titon/db
src/Titon/Db/Driver/AbstractPdoDriver.php
AbstractPdoDriver.startTransaction
public function startTransaction() { if (!$this->_transactions) { $this->logQuery(new SqlResultSet('BEGIN')); $status = $this->getConnection()->beginTransaction(); } else { $status = true; } $this->_transactions++; return $status; }
php
public function startTransaction() { if (!$this->_transactions) { $this->logQuery(new SqlResultSet('BEGIN')); $status = $this->getConnection()->beginTransaction(); } else { $status = true; } $this->_transactions++; return $status; }
[ "public", "function", "startTransaction", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_transactions", ")", "{", "$", "this", "->", "logQuery", "(", "new", "SqlResultSet", "(", "'BEGIN'", ")", ")", ";", "$", "status", "=", "$", "this", "->", "getConnection", "(", ")", "->", "beginTransaction", "(", ")", ";", "}", "else", "{", "$", "status", "=", "true", ";", "}", "$", "this", "->", "_transactions", "++", ";", "return", "$", "status", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/AbstractPdoDriver.php#L442-L454
drsdre/yii2-xmlsoccer
migrations/m180312_095716_init.php
m180312_095716_init.safeUp
public function safeUp() { $this->createTable('{{%goal}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'team_id' => $this->integer(10)->unsigned()->notNull(), 'player_id' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'match_id' => $this->integer(10)->unsigned()->notNull(), 'minute' => $this->tinyInteger(3)->unsigned()->notNull(), 'owngoal' => $this->boolean()->notNull()->defaultValue(false), 'penalty' => $this->boolean()->notNull()->defaultValue(false) ]); $this->createTable('{{%group}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'season' => $this->char(4)->notNull(), 'league_id' => $this->integer(10)->unsigned()->notNull(), 'is_knockout_stage' => $this->boolean()->notNull()->defaultValue(false) ]); $this->createTable('{{%league}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'country' => $this->string(255)->notNull()->defaultValue('International'), 'historical_data' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('0=No,1=Yes,2=Partial'), 'fixtures' => $this->boolean()->notNull()->defaultValue(false), 'livescore' => $this->boolean()->notNull()->defaultValue(false), 'number_of_matches' => $this->integer(10)->unsigned()->notNull(), 'latest_match' => $this->integer(10)->unsigned()->notNull(), 'is_cup' => $this->boolean()->notNull()->defaultValue(false) ]); $this->createTable('{{%match}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'date' => $this->integer(10)->unsigned()->notNull(), 'league_id' => $this->integer(10)->unsigned()->notNull(), 'round' => $this->tinyInteger(3)->unsigned()->null()->defaultValue(null), 'home_team_id' => $this->integer(10)->unsigned()->notNull(), 'away_team_id' => $this->integer(10)->unsigned()->notNull(), 'group_id' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'location' => $this->string(255)->null()->defaultValue(null) ]); $this->createTable('{{%player}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'height' => $this->decimal(10, 2)->null()->defaultValue(null), 'weight' => $this->decimal(10, 2)->null()->defaultValue(null), 'nationality' => $this->string(255)->null()->defaultValue(null), 'position' => $this->string(255)->null()->defaultValue(null), 'team_id' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'player_number' => $this->tinyInteger(3)->unsigned()->notNull(), 'loan_to' => $this->integer(10) ->unsigned() ->null() ->defaultValue(null) ->comment('loaned to team with id'), 'date_of_birth' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'date_of_signing' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'signing' => $this->string(50) ->null() ->defaultValue(null) ->comment('amount of signing (including currency)') ]); $this->createTable('{{%team}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'country' => $this->string(255)->notNull(), 'stadium' => $this->string(255)->null()->defaultValue(null), 'home_page_url' => $this->string(255)->null()->defaultValue(null), 'wiki_link' => $this->string(255)->null()->defaultValue(null), 'coach' => $this->string(255)->null()->defaultValue(null) ]); $this->addForeignKey( '{{%goal_ibfk_1}}', '{{%goal}}', 'match_id', '{{%match}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%goal_ibfk_2}}', '{{%goal}}', 'team_id', '{{%team}}', 'id', 'SET NULL', 'CASCADE' ); $this->addForeignKey( '{{%goal_ibfk_3}}', '{{%goal}}', 'player_id', '{{%player}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%group_ibfk_1}}', '{{%group}}', 'league_id', '{{%league}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_1}}', '{{%match}}', 'away_team_id', '{{%team}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_2}}', '{{%match}}', 'home_team_id', '{{%team}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_3}}', '{{%match}}', 'group_id', '{{%group}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_4}}', '{{%match}}', 'league_id', '{{%league}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%player_ibfk_1}}', '{{%player}}', 'loan_to', '{{%team}}', 'id', 'SET NULL', 'CASCADE' ); $this->addForeignKey( '{{%player_ibfk_2}}', '{{%player}}', 'team_id', '{{%team}}', 'id', 'CASCADE', 'CASCADE' ); }
php
public function safeUp() { $this->createTable('{{%goal}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'team_id' => $this->integer(10)->unsigned()->notNull(), 'player_id' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'match_id' => $this->integer(10)->unsigned()->notNull(), 'minute' => $this->tinyInteger(3)->unsigned()->notNull(), 'owngoal' => $this->boolean()->notNull()->defaultValue(false), 'penalty' => $this->boolean()->notNull()->defaultValue(false) ]); $this->createTable('{{%group}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'season' => $this->char(4)->notNull(), 'league_id' => $this->integer(10)->unsigned()->notNull(), 'is_knockout_stage' => $this->boolean()->notNull()->defaultValue(false) ]); $this->createTable('{{%league}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'country' => $this->string(255)->notNull()->defaultValue('International'), 'historical_data' => $this->tinyInteger(1)->notNull()->defaultValue(0)->comment('0=No,1=Yes,2=Partial'), 'fixtures' => $this->boolean()->notNull()->defaultValue(false), 'livescore' => $this->boolean()->notNull()->defaultValue(false), 'number_of_matches' => $this->integer(10)->unsigned()->notNull(), 'latest_match' => $this->integer(10)->unsigned()->notNull(), 'is_cup' => $this->boolean()->notNull()->defaultValue(false) ]); $this->createTable('{{%match}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'date' => $this->integer(10)->unsigned()->notNull(), 'league_id' => $this->integer(10)->unsigned()->notNull(), 'round' => $this->tinyInteger(3)->unsigned()->null()->defaultValue(null), 'home_team_id' => $this->integer(10)->unsigned()->notNull(), 'away_team_id' => $this->integer(10)->unsigned()->notNull(), 'group_id' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'location' => $this->string(255)->null()->defaultValue(null) ]); $this->createTable('{{%player}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'height' => $this->decimal(10, 2)->null()->defaultValue(null), 'weight' => $this->decimal(10, 2)->null()->defaultValue(null), 'nationality' => $this->string(255)->null()->defaultValue(null), 'position' => $this->string(255)->null()->defaultValue(null), 'team_id' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'player_number' => $this->tinyInteger(3)->unsigned()->notNull(), 'loan_to' => $this->integer(10) ->unsigned() ->null() ->defaultValue(null) ->comment('loaned to team with id'), 'date_of_birth' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'date_of_signing' => $this->integer(10)->unsigned()->null()->defaultValue(null), 'signing' => $this->string(50) ->null() ->defaultValue(null) ->comment('amount of signing (including currency)') ]); $this->createTable('{{%team}}', [ 'id' => $this->primaryKey(10)->unsigned(), 'interface_id' => $this->integer(10)->unsigned()->null()->defaultValue(null)->comment('XMLSOCCER id'), 'name' => $this->string(255)->notNull(), 'country' => $this->string(255)->notNull(), 'stadium' => $this->string(255)->null()->defaultValue(null), 'home_page_url' => $this->string(255)->null()->defaultValue(null), 'wiki_link' => $this->string(255)->null()->defaultValue(null), 'coach' => $this->string(255)->null()->defaultValue(null) ]); $this->addForeignKey( '{{%goal_ibfk_1}}', '{{%goal}}', 'match_id', '{{%match}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%goal_ibfk_2}}', '{{%goal}}', 'team_id', '{{%team}}', 'id', 'SET NULL', 'CASCADE' ); $this->addForeignKey( '{{%goal_ibfk_3}}', '{{%goal}}', 'player_id', '{{%player}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%group_ibfk_1}}', '{{%group}}', 'league_id', '{{%league}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_1}}', '{{%match}}', 'away_team_id', '{{%team}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_2}}', '{{%match}}', 'home_team_id', '{{%team}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_3}}', '{{%match}}', 'group_id', '{{%group}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%match_ibfk_4}}', '{{%match}}', 'league_id', '{{%league}}', 'id', 'CASCADE', 'CASCADE' ); $this->addForeignKey( '{{%player_ibfk_1}}', '{{%player}}', 'loan_to', '{{%team}}', 'id', 'SET NULL', 'CASCADE' ); $this->addForeignKey( '{{%player_ibfk_2}}', '{{%player}}', 'team_id', '{{%team}}', 'id', 'CASCADE', 'CASCADE' ); }
[ "public", "function", "safeUp", "(", ")", "{", "$", "this", "->", "createTable", "(", "'{{%goal}}'", ",", "[", "'id'", "=>", "$", "this", "->", "primaryKey", "(", "10", ")", "->", "unsigned", "(", ")", ",", "'team_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'player_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'match_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'minute'", "=>", "$", "this", "->", "tinyInteger", "(", "3", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'owngoal'", "=>", "$", "this", "->", "boolean", "(", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "false", ")", ",", "'penalty'", "=>", "$", "this", "->", "boolean", "(", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "false", ")", "]", ")", ";", "$", "this", "->", "createTable", "(", "'{{%group}}'", ",", "[", "'id'", "=>", "$", "this", "->", "primaryKey", "(", "10", ")", "->", "unsigned", "(", ")", ",", "'interface_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "->", "comment", "(", "'XMLSOCCER id'", ")", ",", "'name'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "notNull", "(", ")", ",", "'season'", "=>", "$", "this", "->", "char", "(", "4", ")", "->", "notNull", "(", ")", ",", "'league_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'is_knockout_stage'", "=>", "$", "this", "->", "boolean", "(", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "false", ")", "]", ")", ";", "$", "this", "->", "createTable", "(", "'{{%league}}'", ",", "[", "'id'", "=>", "$", "this", "->", "primaryKey", "(", "10", ")", "->", "unsigned", "(", ")", ",", "'interface_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "->", "comment", "(", "'XMLSOCCER id'", ")", ",", "'name'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "notNull", "(", ")", ",", "'country'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "'International'", ")", ",", "'historical_data'", "=>", "$", "this", "->", "tinyInteger", "(", "1", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "0", ")", "->", "comment", "(", "'0=No,1=Yes,2=Partial'", ")", ",", "'fixtures'", "=>", "$", "this", "->", "boolean", "(", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "false", ")", ",", "'livescore'", "=>", "$", "this", "->", "boolean", "(", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "false", ")", ",", "'number_of_matches'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'latest_match'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'is_cup'", "=>", "$", "this", "->", "boolean", "(", ")", "->", "notNull", "(", ")", "->", "defaultValue", "(", "false", ")", "]", ")", ";", "$", "this", "->", "createTable", "(", "'{{%match}}'", ",", "[", "'id'", "=>", "$", "this", "->", "primaryKey", "(", "10", ")", "->", "unsigned", "(", ")", ",", "'interface_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "->", "comment", "(", "'XMLSOCCER id'", ")", ",", "'date'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'league_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'round'", "=>", "$", "this", "->", "tinyInteger", "(", "3", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'home_team_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'away_team_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'group_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'location'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "]", ")", ";", "$", "this", "->", "createTable", "(", "'{{%player}}'", ",", "[", "'id'", "=>", "$", "this", "->", "primaryKey", "(", "10", ")", "->", "unsigned", "(", ")", ",", "'interface_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "->", "comment", "(", "'XMLSOCCER id'", ")", ",", "'name'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "notNull", "(", ")", ",", "'height'", "=>", "$", "this", "->", "decimal", "(", "10", ",", "2", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'weight'", "=>", "$", "this", "->", "decimal", "(", "10", ",", "2", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'nationality'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'position'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'team_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'player_number'", "=>", "$", "this", "->", "tinyInteger", "(", "3", ")", "->", "unsigned", "(", ")", "->", "notNull", "(", ")", ",", "'loan_to'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "->", "comment", "(", "'loaned to team with id'", ")", ",", "'date_of_birth'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'date_of_signing'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'signing'", "=>", "$", "this", "->", "string", "(", "50", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "->", "comment", "(", "'amount of signing (including currency)'", ")", "]", ")", ";", "$", "this", "->", "createTable", "(", "'{{%team}}'", ",", "[", "'id'", "=>", "$", "this", "->", "primaryKey", "(", "10", ")", "->", "unsigned", "(", ")", ",", "'interface_id'", "=>", "$", "this", "->", "integer", "(", "10", ")", "->", "unsigned", "(", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "->", "comment", "(", "'XMLSOCCER id'", ")", ",", "'name'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "notNull", "(", ")", ",", "'country'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "notNull", "(", ")", ",", "'stadium'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'home_page_url'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'wiki_link'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", ",", "'coach'", "=>", "$", "this", "->", "string", "(", "255", ")", "->", "null", "(", ")", "->", "defaultValue", "(", "null", ")", "]", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%goal_ibfk_1}}'", ",", "'{{%goal}}'", ",", "'match_id'", ",", "'{{%match}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%goal_ibfk_2}}'", ",", "'{{%goal}}'", ",", "'team_id'", ",", "'{{%team}}'", ",", "'id'", ",", "'SET NULL'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%goal_ibfk_3}}'", ",", "'{{%goal}}'", ",", "'player_id'", ",", "'{{%player}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%group_ibfk_1}}'", ",", "'{{%group}}'", ",", "'league_id'", ",", "'{{%league}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%match_ibfk_1}}'", ",", "'{{%match}}'", ",", "'away_team_id'", ",", "'{{%team}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%match_ibfk_2}}'", ",", "'{{%match}}'", ",", "'home_team_id'", ",", "'{{%team}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%match_ibfk_3}}'", ",", "'{{%match}}'", ",", "'group_id'", ",", "'{{%group}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%match_ibfk_4}}'", ",", "'{{%match}}'", ",", "'league_id'", ",", "'{{%league}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%player_ibfk_1}}'", ",", "'{{%player}}'", ",", "'loan_to'", ",", "'{{%team}}'", ",", "'id'", ",", "'SET NULL'", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%player_ibfk_2}}'", ",", "'{{%player}}'", ",", "'team_id'", ",", "'{{%team}}'", ",", "'id'", ",", "'CASCADE'", ",", "'CASCADE'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/drsdre/yii2-xmlsoccer/blob/a746edee6269ed0791bac6c6165a946adc30d994/migrations/m180312_095716_init.php#L27-L192
drsdre/yii2-xmlsoccer
migrations/m180312_095716_init.php
m180312_095716_init.safeDown
public function safeDown() { $this->dropForeignKey('{{%player_ibfk_1}}', '{{%player}}'); $this->dropForeignKey('{{%player_ibfk_2}}', '{{%player}}'); $this->dropForeignKey('{{%match_ibfk_1}}', '{{%match}}'); $this->dropForeignKey('{{%match_ibfk_2}}', '{{%match}}'); $this->dropForeignKey('{{%match_ibfk_3}}', '{{%match}}'); $this->dropForeignKey('{{%match_ibfk_4}}', '{{%match}}'); $this->dropForeignKey('{{%group_ibfk_1}}', '{{%group}}'); $this->dropForeignKey('{{%goal_ibfk_1}}', '{{%goal}}'); $this->dropForeignKey('{{%goal_ibfk_2}}', '{{%goal}}'); $this->dropTable('{{%team}}'); $this->dropTable('{{%player}}'); $this->dropTable('{{%match}}'); $this->dropTable('{{%league}}'); $this->dropTable('{{%group}}'); $this->dropTable('{{%goal}}'); }
php
public function safeDown() { $this->dropForeignKey('{{%player_ibfk_1}}', '{{%player}}'); $this->dropForeignKey('{{%player_ibfk_2}}', '{{%player}}'); $this->dropForeignKey('{{%match_ibfk_1}}', '{{%match}}'); $this->dropForeignKey('{{%match_ibfk_2}}', '{{%match}}'); $this->dropForeignKey('{{%match_ibfk_3}}', '{{%match}}'); $this->dropForeignKey('{{%match_ibfk_4}}', '{{%match}}'); $this->dropForeignKey('{{%group_ibfk_1}}', '{{%group}}'); $this->dropForeignKey('{{%goal_ibfk_1}}', '{{%goal}}'); $this->dropForeignKey('{{%goal_ibfk_2}}', '{{%goal}}'); $this->dropTable('{{%team}}'); $this->dropTable('{{%player}}'); $this->dropTable('{{%match}}'); $this->dropTable('{{%league}}'); $this->dropTable('{{%group}}'); $this->dropTable('{{%goal}}'); }
[ "public", "function", "safeDown", "(", ")", "{", "$", "this", "->", "dropForeignKey", "(", "'{{%player_ibfk_1}}'", ",", "'{{%player}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%player_ibfk_2}}'", ",", "'{{%player}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%match_ibfk_1}}'", ",", "'{{%match}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%match_ibfk_2}}'", ",", "'{{%match}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%match_ibfk_3}}'", ",", "'{{%match}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%match_ibfk_4}}'", ",", "'{{%match}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%group_ibfk_1}}'", ",", "'{{%group}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%goal_ibfk_1}}'", ",", "'{{%goal}}'", ")", ";", "$", "this", "->", "dropForeignKey", "(", "'{{%goal_ibfk_2}}'", ",", "'{{%goal}}'", ")", ";", "$", "this", "->", "dropTable", "(", "'{{%team}}'", ")", ";", "$", "this", "->", "dropTable", "(", "'{{%player}}'", ")", ";", "$", "this", "->", "dropTable", "(", "'{{%match}}'", ")", ";", "$", "this", "->", "dropTable", "(", "'{{%league}}'", ")", ";", "$", "this", "->", "dropTable", "(", "'{{%group}}'", ")", ";", "$", "this", "->", "dropTable", "(", "'{{%goal}}'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/drsdre/yii2-xmlsoccer/blob/a746edee6269ed0791bac6c6165a946adc30d994/migrations/m180312_095716_init.php#L197-L215
kattsoftware/phassets
src/Phassets/FilesCollector.php
FilesCollector.parse
public function parse($dirPath, array $extensions, $deep = false, array $exclusions = array()) { $files = []; try { $iterator = new \DirectoryIterator($dirPath); foreach ($iterator as $entry) { if ($deep && $entry->isDir() && !$entry->isDot() ) { $files = array_merge($files, $this->parse($entry->getPathname(), $extensions, $deep)); } if ($entry->isFile() && in_array($entry->getExtension(), $extensions, true) && !in_array($entry->getFilename(), $exclusions) ) { $files[] = $entry->getPathname(); } } } catch (\UnexpectedValueException $e) { throw new PhassetsInternalException('UnexpectedValueException caught', 0, $e); } catch (\RuntimeException $e) { throw new PhassetsInternalException('RuntimeException caught', 0, $e); } return $files; }
php
public function parse($dirPath, array $extensions, $deep = false, array $exclusions = array()) { $files = []; try { $iterator = new \DirectoryIterator($dirPath); foreach ($iterator as $entry) { if ($deep && $entry->isDir() && !$entry->isDot() ) { $files = array_merge($files, $this->parse($entry->getPathname(), $extensions, $deep)); } if ($entry->isFile() && in_array($entry->getExtension(), $extensions, true) && !in_array($entry->getFilename(), $exclusions) ) { $files[] = $entry->getPathname(); } } } catch (\UnexpectedValueException $e) { throw new PhassetsInternalException('UnexpectedValueException caught', 0, $e); } catch (\RuntimeException $e) { throw new PhassetsInternalException('RuntimeException caught', 0, $e); } return $files; }
[ "public", "function", "parse", "(", "$", "dirPath", ",", "array", "$", "extensions", ",", "$", "deep", "=", "false", ",", "array", "$", "exclusions", "=", "array", "(", ")", ")", "{", "$", "files", "=", "[", "]", ";", "try", "{", "$", "iterator", "=", "new", "\\", "DirectoryIterator", "(", "$", "dirPath", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "entry", ")", "{", "if", "(", "$", "deep", "&&", "$", "entry", "->", "isDir", "(", ")", "&&", "!", "$", "entry", "->", "isDot", "(", ")", ")", "{", "$", "files", "=", "array_merge", "(", "$", "files", ",", "$", "this", "->", "parse", "(", "$", "entry", "->", "getPathname", "(", ")", ",", "$", "extensions", ",", "$", "deep", ")", ")", ";", "}", "if", "(", "$", "entry", "->", "isFile", "(", ")", "&&", "in_array", "(", "$", "entry", "->", "getExtension", "(", ")", ",", "$", "extensions", ",", "true", ")", "&&", "!", "in_array", "(", "$", "entry", "->", "getFilename", "(", ")", ",", "$", "exclusions", ")", ")", "{", "$", "files", "[", "]", "=", "$", "entry", "->", "getPathname", "(", ")", ";", "}", "}", "}", "catch", "(", "\\", "UnexpectedValueException", "$", "e", ")", "{", "throw", "new", "PhassetsInternalException", "(", "'UnexpectedValueException caught'", ",", "0", ",", "$", "e", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "e", ")", "{", "throw", "new", "PhassetsInternalException", "(", "'RuntimeException caught'", ",", "0", ",", "$", "e", ")", ";", "}", "return", "$", "files", ";", "}" ]
Parses a folder and returns the full paths of all files from there having the extensions in $extensions array. Setting $deep to true will make this collector to look in all sub-folders as well. @param string $dirPath Full path of a folder to be opened by a DirectoryIterator @param array $extensions List of extensions for checking the files found against @param bool $deep Whether to search in sub-folders or not @param array $exclusions Array of filenames to be removed from processing @return array List of the found files full paths @throws PhassetsInternalException If the DirectoryIterator may fail
[ "Parses", "a", "folder", "and", "returns", "the", "full", "paths", "of", "all", "files", "from", "there", "having", "the", "extensions", "in", "$extensions", "array", ".", "Setting", "$deep", "to", "true", "will", "make", "this", "collector", "to", "look", "in", "all", "sub", "-", "folders", "as", "well", "." ]
train
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/FilesCollector.php#L27-L56
yuncms/framework
src/user/migrations/m180223_102927Create_user_extra_table.php
m180223_102927Create_user_extra_table.safeUp
public function safeUp() { $tableOptions = null; if ($this->db->driverName === 'mysql') { // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; } /** * 创建用户附表 */ $this->createTable($this->tableName, [ 'user_id' => $this->userId()->notNull()->comment('User ID'), 'login_ip' => $this->ipAddress()->comment('Login Ip'), 'login_at' => $this->unixTimestamp()->comment('Login At'), 'login_num' => $this->counter()->comment('Login Num'), 'last_visit' => $this->counter()->comment('Last Visit'), 'views' => $this->counter()->comment('Views'), 'supports' => $this->counter()->comment('Supports'), 'followers' => $this->counter()->comment('Followers'), 'collections' => $this->counter()->comment('Collections'), ], $tableOptions); $this->addPrimaryKey('{{%user_extra_pk}}', $this->tableName, 'user_id'); $this->addForeignKey('{{%user_extra_fk_1}}', $this->tableName, 'user_id', '{{%user}}', 'id', 'CASCADE', 'RESTRICT'); }
php
public function safeUp() { $tableOptions = null; if ($this->db->driverName === 'mysql') { // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'; } /** * 创建用户附表 */ $this->createTable($this->tableName, [ 'user_id' => $this->userId()->notNull()->comment('User ID'), 'login_ip' => $this->ipAddress()->comment('Login Ip'), 'login_at' => $this->unixTimestamp()->comment('Login At'), 'login_num' => $this->counter()->comment('Login Num'), 'last_visit' => $this->counter()->comment('Last Visit'), 'views' => $this->counter()->comment('Views'), 'supports' => $this->counter()->comment('Supports'), 'followers' => $this->counter()->comment('Followers'), 'collections' => $this->counter()->comment('Collections'), ], $tableOptions); $this->addPrimaryKey('{{%user_extra_pk}}', $this->tableName, 'user_id'); $this->addForeignKey('{{%user_extra_fk_1}}', $this->tableName, 'user_id', '{{%user}}', 'id', 'CASCADE', 'RESTRICT'); }
[ "public", "function", "safeUp", "(", ")", "{", "$", "tableOptions", "=", "null", ";", "if", "(", "$", "this", "->", "db", "->", "driverName", "===", "'mysql'", ")", "{", "// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci", "$", "tableOptions", "=", "'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'", ";", "}", "/**\n * 创建用户附表\n */", "$", "this", "->", "createTable", "(", "$", "this", "->", "tableName", ",", "[", "'user_id'", "=>", "$", "this", "->", "userId", "(", ")", "->", "notNull", "(", ")", "->", "comment", "(", "'User ID'", ")", ",", "'login_ip'", "=>", "$", "this", "->", "ipAddress", "(", ")", "->", "comment", "(", "'Login Ip'", ")", ",", "'login_at'", "=>", "$", "this", "->", "unixTimestamp", "(", ")", "->", "comment", "(", "'Login At'", ")", ",", "'login_num'", "=>", "$", "this", "->", "counter", "(", ")", "->", "comment", "(", "'Login Num'", ")", ",", "'last_visit'", "=>", "$", "this", "->", "counter", "(", ")", "->", "comment", "(", "'Last Visit'", ")", ",", "'views'", "=>", "$", "this", "->", "counter", "(", ")", "->", "comment", "(", "'Views'", ")", ",", "'supports'", "=>", "$", "this", "->", "counter", "(", ")", "->", "comment", "(", "'Supports'", ")", ",", "'followers'", "=>", "$", "this", "->", "counter", "(", ")", "->", "comment", "(", "'Followers'", ")", ",", "'collections'", "=>", "$", "this", "->", "counter", "(", ")", "->", "comment", "(", "'Collections'", ")", ",", "]", ",", "$", "tableOptions", ")", ";", "$", "this", "->", "addPrimaryKey", "(", "'{{%user_extra_pk}}'", ",", "$", "this", "->", "tableName", ",", "'user_id'", ")", ";", "$", "this", "->", "addForeignKey", "(", "'{{%user_extra_fk_1}}'", ",", "$", "this", "->", "tableName", ",", "'user_id'", ",", "'{{%user}}'", ",", "'id'", ",", "'CASCADE'", ",", "'RESTRICT'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/migrations/m180223_102927Create_user_extra_table.php#L12-L36
OpenClassrooms/CacheBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('openclassrooms_cache'); $rootNode ->children() ->arrayNode('provider') ->performNoDeepMerging() ->beforeNormalization() ->ifString() ->then(function($v) { return array($v => array()); }) ->end() ->children() ->append($this->addArrayNode()) ->append($this->addRedisNode()) ->end() ->end() ->end() ->children() ->scalarNode('default_lifetime') ->defaultValue(0) ->end() ->end(); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('openclassrooms_cache'); $rootNode ->children() ->arrayNode('provider') ->performNoDeepMerging() ->beforeNormalization() ->ifString() ->then(function($v) { return array($v => array()); }) ->end() ->children() ->append($this->addArrayNode()) ->append($this->addRedisNode()) ->end() ->end() ->end() ->children() ->scalarNode('default_lifetime') ->defaultValue(0) ->end() ->end(); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'openclassrooms_cache'", ")", ";", "$", "rootNode", "->", "children", "(", ")", "->", "arrayNode", "(", "'provider'", ")", "->", "performNoDeepMerging", "(", ")", "->", "beforeNormalization", "(", ")", "->", "ifString", "(", ")", "->", "then", "(", "function", "(", "$", "v", ")", "{", "return", "array", "(", "$", "v", "=>", "array", "(", ")", ")", ";", "}", ")", "->", "end", "(", ")", "->", "children", "(", ")", "->", "append", "(", "$", "this", "->", "addArrayNode", "(", ")", ")", "->", "append", "(", "$", "this", "->", "addRedisNode", "(", ")", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'default_lifetime'", ")", "->", "defaultValue", "(", "0", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
Generates the configuration tree builder. @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
[ "Generates", "the", "configuration", "tree", "builder", "." ]
train
https://github.com/OpenClassrooms/CacheBundle/blob/a8b9226b4370bba12190b821b45d46eb848ca34b/DependencyInjection/Configuration.php#L18-L43
webforge-labs/psc-cms
lib/Psc/CMS/Controller/PageController.php
PageController.processEntityFormRequest
protected function processEntityFormRequest(Entity $entity, FormData $requestData, $revision) { $this->addOptionalProperty('contentStreams'); // erst formular bearbeiten parent::processEntityFormRequest($entity, $requestData, $revision); // wenn es neu ist, wollen wir die content streams erstellen if ($entity->isNew()) { $this->fillContentStreams($entity); } }
php
protected function processEntityFormRequest(Entity $entity, FormData $requestData, $revision) { $this->addOptionalProperty('contentStreams'); // erst formular bearbeiten parent::processEntityFormRequest($entity, $requestData, $revision); // wenn es neu ist, wollen wir die content streams erstellen if ($entity->isNew()) { $this->fillContentStreams($entity); } }
[ "protected", "function", "processEntityFormRequest", "(", "Entity", "$", "entity", ",", "FormData", "$", "requestData", ",", "$", "revision", ")", "{", "$", "this", "->", "addOptionalProperty", "(", "'contentStreams'", ")", ";", "// erst formular bearbeiten", "parent", "::", "processEntityFormRequest", "(", "$", "entity", ",", "$", "requestData", ",", "$", "revision", ")", ";", "// wenn es neu ist, wollen wir die content streams erstellen", "if", "(", "$", "entity", "->", "isNew", "(", ")", ")", "{", "$", "this", "->", "fillContentStreams", "(", "$", "entity", ")", ";", "}", "}" ]
Beim ersten Speichern eines neuen Entities fügen wir die Content-Streams (die wir vorhe rnicht anzeigen) hinzu
[ "Beim", "ersten", "Speichern", "eines", "neuen", "Entities", "fügen", "wir", "die", "Content", "-", "Streams", "(", "die", "wir", "vorhe", "rnicht", "anzeigen", ")", "hinzu" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/PageController.php#L94-L104
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController.parse
public static function parse( $cmd ) { // if we dont have an command if ( empty( $cmd ) ) { return false; } $params = array(); // are we in a string $in_string = false; $len = strlen( $cmd ); $crr_prm = ""; $command_str = $cmd; $cmd = array(); // loop trough for( $i=0;$len>$i;$i++ ) { $char = $command_str[$i]; switch( $char ) { case ' ': if ( !$in_string ) { $cmd[] = $crr_prm; $crr_prm = ''; } else { $crr_prm .= $char; } break; case '"': if( $i > 0 && $command_str[$c-1] != '\\' ) { $in_string = !$in_string; } break; default: $crr_prm .= $char; break; } } $cmd[] = $crr_prm; // get the controller $controller = array_shift( $cmd ); // get the action $action = null; // check we got an action in our controller if ( strpos( $controller, '::' ) !== false ) { $controller = explode( '::', $controller ); $action = $controller[1]; $controller = $controller[0]; } // skipper if we got an named param skip the next $skip = false; // get the params foreach( $cmd as $key => $value ) { if ( $skip ) { $skip = false; continue; } // named param? if ( substr( $value, 0, 1 ) == '-' ) { if ( array_key_exists( $key+1, $cmd ) ) { $next_value = $cmd[$key+1]; if ( substr( $next_value, 0, 1 ) == '-' ) { $params[substr( $value, 1 )] = true; } else { $params[substr( $value, 1 )] = $next_value; $skip = true; } } else { $params[substr( $value, 1 )] = true; } } else { $params[] = $value; } } return static::run( trim( $controller ), trim( $action ), $params ); }
php
public static function parse( $cmd ) { // if we dont have an command if ( empty( $cmd ) ) { return false; } $params = array(); // are we in a string $in_string = false; $len = strlen( $cmd ); $crr_prm = ""; $command_str = $cmd; $cmd = array(); // loop trough for( $i=0;$len>$i;$i++ ) { $char = $command_str[$i]; switch( $char ) { case ' ': if ( !$in_string ) { $cmd[] = $crr_prm; $crr_prm = ''; } else { $crr_prm .= $char; } break; case '"': if( $i > 0 && $command_str[$c-1] != '\\' ) { $in_string = !$in_string; } break; default: $crr_prm .= $char; break; } } $cmd[] = $crr_prm; // get the controller $controller = array_shift( $cmd ); // get the action $action = null; // check we got an action in our controller if ( strpos( $controller, '::' ) !== false ) { $controller = explode( '::', $controller ); $action = $controller[1]; $controller = $controller[0]; } // skipper if we got an named param skip the next $skip = false; // get the params foreach( $cmd as $key => $value ) { if ( $skip ) { $skip = false; continue; } // named param? if ( substr( $value, 0, 1 ) == '-' ) { if ( array_key_exists( $key+1, $cmd ) ) { $next_value = $cmd[$key+1]; if ( substr( $next_value, 0, 1 ) == '-' ) { $params[substr( $value, 1 )] = true; } else { $params[substr( $value, 1 )] = $next_value; $skip = true; } } else { $params[substr( $value, 1 )] = true; } } else { $params[] = $value; } } return static::run( trim( $controller ), trim( $action ), $params ); }
[ "public", "static", "function", "parse", "(", "$", "cmd", ")", "{", "// if we dont have an command", "if", "(", "empty", "(", "$", "cmd", ")", ")", "{", "return", "false", ";", "}", "$", "params", "=", "array", "(", ")", ";", "// are we in a string", "$", "in_string", "=", "false", ";", "$", "len", "=", "strlen", "(", "$", "cmd", ")", ";", "$", "crr_prm", "=", "\"\"", ";", "$", "command_str", "=", "$", "cmd", ";", "$", "cmd", "=", "array", "(", ")", ";", "// loop trough", "for", "(", "$", "i", "=", "0", ";", "$", "len", ">", "$", "i", ";", "$", "i", "++", ")", "{", "$", "char", "=", "$", "command_str", "[", "$", "i", "]", ";", "switch", "(", "$", "char", ")", "{", "case", "' '", ":", "if", "(", "!", "$", "in_string", ")", "{", "$", "cmd", "[", "]", "=", "$", "crr_prm", ";", "$", "crr_prm", "=", "''", ";", "}", "else", "{", "$", "crr_prm", ".=", "$", "char", ";", "}", "break", ";", "case", "'\"'", ":", "if", "(", "$", "i", ">", "0", "&&", "$", "command_str", "[", "$", "c", "-", "1", "]", "!=", "'\\\\'", ")", "{", "$", "in_string", "=", "!", "$", "in_string", ";", "}", "break", ";", "default", ":", "$", "crr_prm", ".=", "$", "char", ";", "break", ";", "}", "}", "$", "cmd", "[", "]", "=", "$", "crr_prm", ";", "// get the controller", "$", "controller", "=", "array_shift", "(", "$", "cmd", ")", ";", "// get the action", "$", "action", "=", "null", ";", "// check we got an action in our controller", "if", "(", "strpos", "(", "$", "controller", ",", "'::'", ")", "!==", "false", ")", "{", "$", "controller", "=", "explode", "(", "'::'", ",", "$", "controller", ")", ";", "$", "action", "=", "$", "controller", "[", "1", "]", ";", "$", "controller", "=", "$", "controller", "[", "0", "]", ";", "}", "// skipper if we got an named param skip the next", "$", "skip", "=", "false", ";", "// get the params", "foreach", "(", "$", "cmd", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "skip", ")", "{", "$", "skip", "=", "false", ";", "continue", ";", "}", "// named param?", "if", "(", "substr", "(", "$", "value", ",", "0", ",", "1", ")", "==", "'-'", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", "+", "1", ",", "$", "cmd", ")", ")", "{", "$", "next_value", "=", "$", "cmd", "[", "$", "key", "+", "1", "]", ";", "if", "(", "substr", "(", "$", "next_value", ",", "0", ",", "1", ")", "==", "'-'", ")", "{", "$", "params", "[", "substr", "(", "$", "value", ",", "1", ")", "]", "=", "true", ";", "}", "else", "{", "$", "params", "[", "substr", "(", "$", "value", ",", "1", ")", "]", "=", "$", "next_value", ";", "$", "skip", "=", "true", ";", "}", "}", "else", "{", "$", "params", "[", "substr", "(", "$", "value", ",", "1", ")", "]", "=", "true", ";", "}", "}", "else", "{", "$", "params", "[", "]", "=", "$", "value", ";", "}", "}", "return", "static", "::", "run", "(", "trim", "(", "$", "controller", ")", ",", "trim", "(", "$", "action", ")", ",", "$", "params", ")", ";", "}" ]
Parse an command and execute console style @param string $cmd
[ "Parse", "an", "command", "and", "execute", "console", "style" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L21-L112
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController.run
public static function run( $controller, $action = null, $params = array() ) { // always enable the file infos // this allows CCFile to print an info when a file gets created or deleted. CCFile::enable_infos(); // execute by default the help action if ( empty( $action ) ) { $action = 'default'; } $path = CCPath::get( $controller, CCDIR_CONSOLE, EXT ); // check if the file exists, if not try with core path if ( !file_exists( $path ) ) { if ( !CCPath::contains_namespace( $controller ) ) { $path = CCPath::get( CCCORE_NAMESPACE.'::'.$controller, CCDIR_CONSOLE, EXT ); } } // still nothing? if ( !file_exists( $path ) ) { CCCli::line( "Could not find controller {$controller}.", 'red' ); return false; } // all console classes should be on the CCConsole namespace // this way you can easly overwrite a console script $class = 'CCConsole\\'.$controller; // add the class to the autoloader \CCFinder::bind( $class, $path ); // create an instance $class = new $class( $action, $params ); // run wake function if ( method_exists( $class, 'wake' ) ) { call_user_func( array( $class, 'wake' ), $params ); } // run the execution call_user_func( array( $class, '_execute' ), $action, $params ); // run sleep if ( method_exists( $class, 'sleep' ) ) { call_user_func( array( $class, 'sleep' ), $params ); } }
php
public static function run( $controller, $action = null, $params = array() ) { // always enable the file infos // this allows CCFile to print an info when a file gets created or deleted. CCFile::enable_infos(); // execute by default the help action if ( empty( $action ) ) { $action = 'default'; } $path = CCPath::get( $controller, CCDIR_CONSOLE, EXT ); // check if the file exists, if not try with core path if ( !file_exists( $path ) ) { if ( !CCPath::contains_namespace( $controller ) ) { $path = CCPath::get( CCCORE_NAMESPACE.'::'.$controller, CCDIR_CONSOLE, EXT ); } } // still nothing? if ( !file_exists( $path ) ) { CCCli::line( "Could not find controller {$controller}.", 'red' ); return false; } // all console classes should be on the CCConsole namespace // this way you can easly overwrite a console script $class = 'CCConsole\\'.$controller; // add the class to the autoloader \CCFinder::bind( $class, $path ); // create an instance $class = new $class( $action, $params ); // run wake function if ( method_exists( $class, 'wake' ) ) { call_user_func( array( $class, 'wake' ), $params ); } // run the execution call_user_func( array( $class, '_execute' ), $action, $params ); // run sleep if ( method_exists( $class, 'sleep' ) ) { call_user_func( array( $class, 'sleep' ), $params ); } }
[ "public", "static", "function", "run", "(", "$", "controller", ",", "$", "action", "=", "null", ",", "$", "params", "=", "array", "(", ")", ")", "{", "// always enable the file infos", "// this allows CCFile to print an info when a file gets created or deleted.", "CCFile", "::", "enable_infos", "(", ")", ";", "// execute by default the help action", "if", "(", "empty", "(", "$", "action", ")", ")", "{", "$", "action", "=", "'default'", ";", "}", "$", "path", "=", "CCPath", "::", "get", "(", "$", "controller", ",", "CCDIR_CONSOLE", ",", "EXT", ")", ";", "// check if the file exists, if not try with core path", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "!", "CCPath", "::", "contains_namespace", "(", "$", "controller", ")", ")", "{", "$", "path", "=", "CCPath", "::", "get", "(", "CCCORE_NAMESPACE", ".", "'::'", ".", "$", "controller", ",", "CCDIR_CONSOLE", ",", "EXT", ")", ";", "}", "}", "// still nothing?", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "CCCli", "::", "line", "(", "\"Could not find controller {$controller}.\"", ",", "'red'", ")", ";", "return", "false", ";", "}", "// all console classes should be on the CCConsole namespace", "// this way you can easly overwrite a console script", "$", "class", "=", "'CCConsole\\\\'", ".", "$", "controller", ";", "// add the class to the autoloader ", "\\", "CCFinder", "::", "bind", "(", "$", "class", ",", "$", "path", ")", ";", "// create an instance", "$", "class", "=", "new", "$", "class", "(", "$", "action", ",", "$", "params", ")", ";", "// run wake function", "if", "(", "method_exists", "(", "$", "class", ",", "'wake'", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "class", ",", "'wake'", ")", ",", "$", "params", ")", ";", "}", "// run the execution", "call_user_func", "(", "array", "(", "$", "class", ",", "'_execute'", ")", ",", "$", "action", ",", "$", "params", ")", ";", "// run sleep", "if", "(", "method_exists", "(", "$", "class", ",", "'sleep'", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "class", ",", "'sleep'", ")", ",", "$", "params", ")", ";", "}", "}" ]
Run a console script @param string $controller @param string $action @param array $params
[ "Run", "a", "console", "script" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L121-L175
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController._execute
public function _execute( $action, $params = array() ) { if ( method_exists( $this, 'action_'.$action ) ) { call_user_func( array( $this, 'action_'.$action ), $params ); } else { CCCli::line( "There is no action {$action}.", 'red' ); } }
php
public function _execute( $action, $params = array() ) { if ( method_exists( $this, 'action_'.$action ) ) { call_user_func( array( $this, 'action_'.$action ), $params ); } else { CCCli::line( "There is no action {$action}.", 'red' ); } }
[ "public", "function", "_execute", "(", "$", "action", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "'action_'", ".", "$", "action", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "this", ",", "'action_'", ".", "$", "action", ")", ",", "$", "params", ")", ";", "}", "else", "{", "CCCli", "::", "line", "(", "\"There is no action {$action}.\"", ",", "'red'", ")", ";", "}", "}" ]
execute the controller @param string $action @param array $params @return void
[ "execute", "the", "controller" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L202-L212
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController.action_help
public function action_help( $params ) { if ( method_exists( $this, 'help' ) ) { CCCli::line( $this->help_formatter( $this->help() ) ); return; } CCCli::line( 'This console controller does not implement an help function or action.' , 'cyan' ); }
php
public function action_help( $params ) { if ( method_exists( $this, 'help' ) ) { CCCli::line( $this->help_formatter( $this->help() ) ); return; } CCCli::line( 'This console controller does not implement an help function or action.' , 'cyan' ); }
[ "public", "function", "action_help", "(", "$", "params", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "'help'", ")", ")", "{", "CCCli", "::", "line", "(", "$", "this", "->", "help_formatter", "(", "$", "this", "->", "help", "(", ")", ")", ")", ";", "return", ";", "}", "CCCli", "::", "line", "(", "'This console controller does not implement an help function or action.'", ",", "'cyan'", ")", ";", "}" ]
default help action @param array $params @return void
[ "default", "help", "action" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L230-L236
ClanCats/Core
src/classes/CCConsoleController.php
CCConsoleController.help_formatter
protected function help_formatter( $help = null ) { if ( is_null( $help ) ) { CCCli::line( 'Invalid data passed to help formatter.' , 'red' ); return; } $output = array(); // print the name if ( isset( $help['name'] ) ) { $output[] = '+-'.str_repeat( '-', strlen( $help['name'] ) ).'-+'; $output[] = '| '.CCCli::color( $help['name'], 'light_yellow' ).' |'; $output[] = '+-'.str_repeat( '-', strlen( $help['name'] ) ).'-+'; } // description if ( isset( $help['desc'] ) ) { $output[] = wordwrap( str_replace( "\n", "\n".' * ', $help['desc'] ), 60 ); } // list the actions if ( isset( $help['actions'] ) && !empty( $help['actions'] ) ) { // for every action in this console controller foreach( $help['actions'] as $action => $attributes ) { // print the action $output[] = ''; $output[] = '| '.CCStr::suffix( get_called_class(), '\\' ).'::'.CCCli::color( $action, 'cyan' ); $output[] = '|'; // for every attribute ( arguments, usage etc. ) foreach( $attributes as $attribute => $options ) { $output[] = '| '.CCCli::color( ucfirst( $attribute ), 'light_yellow' ); // if we just got a string if ( is_string( $options ) ) { $output[] = '| '.CCCli::color( $options, 'green' ); } // a key value array elseif ( is_array( $options ) ) { // print every option and its description foreach( $options as $option => $description ) { $buffer = CCCli::color( $option, 'green' ); $buffer .= str_repeat( ' ', 35 - strlen( $buffer ) ); $buffer .= $description; $buffer = '| '.$buffer; // is the line to long? if ( strlen( $buffer ) > 80 ) { $overflow = substr( $buffer, 80 ); $buffer = substr( $buffer, 0, 80 )."\n"; $overflow = wordwrap( $overflow, 45 ); $overflow = explode( "\n", $overflow ); foreach( $overflow as $key => $value ) { $overflow[$key] = '| '.str_repeat( ' ', 25 ).trim( $value ); } $buffer .= implode( "\n", $overflow ); } $output[] = $buffer; } } $output[] = '|'; } array_pop( $output ); } } return $output; }
php
protected function help_formatter( $help = null ) { if ( is_null( $help ) ) { CCCli::line( 'Invalid data passed to help formatter.' , 'red' ); return; } $output = array(); // print the name if ( isset( $help['name'] ) ) { $output[] = '+-'.str_repeat( '-', strlen( $help['name'] ) ).'-+'; $output[] = '| '.CCCli::color( $help['name'], 'light_yellow' ).' |'; $output[] = '+-'.str_repeat( '-', strlen( $help['name'] ) ).'-+'; } // description if ( isset( $help['desc'] ) ) { $output[] = wordwrap( str_replace( "\n", "\n".' * ', $help['desc'] ), 60 ); } // list the actions if ( isset( $help['actions'] ) && !empty( $help['actions'] ) ) { // for every action in this console controller foreach( $help['actions'] as $action => $attributes ) { // print the action $output[] = ''; $output[] = '| '.CCStr::suffix( get_called_class(), '\\' ).'::'.CCCli::color( $action, 'cyan' ); $output[] = '|'; // for every attribute ( arguments, usage etc. ) foreach( $attributes as $attribute => $options ) { $output[] = '| '.CCCli::color( ucfirst( $attribute ), 'light_yellow' ); // if we just got a string if ( is_string( $options ) ) { $output[] = '| '.CCCli::color( $options, 'green' ); } // a key value array elseif ( is_array( $options ) ) { // print every option and its description foreach( $options as $option => $description ) { $buffer = CCCli::color( $option, 'green' ); $buffer .= str_repeat( ' ', 35 - strlen( $buffer ) ); $buffer .= $description; $buffer = '| '.$buffer; // is the line to long? if ( strlen( $buffer ) > 80 ) { $overflow = substr( $buffer, 80 ); $buffer = substr( $buffer, 0, 80 )."\n"; $overflow = wordwrap( $overflow, 45 ); $overflow = explode( "\n", $overflow ); foreach( $overflow as $key => $value ) { $overflow[$key] = '| '.str_repeat( ' ', 25 ).trim( $value ); } $buffer .= implode( "\n", $overflow ); } $output[] = $buffer; } } $output[] = '|'; } array_pop( $output ); } } return $output; }
[ "protected", "function", "help_formatter", "(", "$", "help", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "help", ")", ")", "{", "CCCli", "::", "line", "(", "'Invalid data passed to help formatter.'", ",", "'red'", ")", ";", "return", ";", "}", "$", "output", "=", "array", "(", ")", ";", "// print the name", "if", "(", "isset", "(", "$", "help", "[", "'name'", "]", ")", ")", "{", "$", "output", "[", "]", "=", "'+-'", ".", "str_repeat", "(", "'-'", ",", "strlen", "(", "$", "help", "[", "'name'", "]", ")", ")", ".", "'-+'", ";", "$", "output", "[", "]", "=", "'| '", ".", "CCCli", "::", "color", "(", "$", "help", "[", "'name'", "]", ",", "'light_yellow'", ")", ".", "' |'", ";", "$", "output", "[", "]", "=", "'+-'", ".", "str_repeat", "(", "'-'", ",", "strlen", "(", "$", "help", "[", "'name'", "]", ")", ")", ".", "'-+'", ";", "}", "// description", "if", "(", "isset", "(", "$", "help", "[", "'desc'", "]", ")", ")", "{", "$", "output", "[", "]", "=", "wordwrap", "(", "str_replace", "(", "\"\\n\"", ",", "\"\\n\"", ".", "' * '", ",", "$", "help", "[", "'desc'", "]", ")", ",", "60", ")", ";", "}", "// list the actions ", "if", "(", "isset", "(", "$", "help", "[", "'actions'", "]", ")", "&&", "!", "empty", "(", "$", "help", "[", "'actions'", "]", ")", ")", "{", "// for every action in this console controller", "foreach", "(", "$", "help", "[", "'actions'", "]", "as", "$", "action", "=>", "$", "attributes", ")", "{", "// print the action", "$", "output", "[", "]", "=", "''", ";", "$", "output", "[", "]", "=", "'| '", ".", "CCStr", "::", "suffix", "(", "get_called_class", "(", ")", ",", "'\\\\'", ")", ".", "'::'", ".", "CCCli", "::", "color", "(", "$", "action", ",", "'cyan'", ")", ";", "$", "output", "[", "]", "=", "'|'", ";", "// for every attribute ( arguments, usage etc. )", "foreach", "(", "$", "attributes", "as", "$", "attribute", "=>", "$", "options", ")", "{", "$", "output", "[", "]", "=", "'| '", ".", "CCCli", "::", "color", "(", "ucfirst", "(", "$", "attribute", ")", ",", "'light_yellow'", ")", ";", "// if we just got a string", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "$", "output", "[", "]", "=", "'| '", ".", "CCCli", "::", "color", "(", "$", "options", ",", "'green'", ")", ";", "}", "// a key value array", "elseif", "(", "is_array", "(", "$", "options", ")", ")", "{", "// print every option and its description", "foreach", "(", "$", "options", "as", "$", "option", "=>", "$", "description", ")", "{", "$", "buffer", "=", "CCCli", "::", "color", "(", "$", "option", ",", "'green'", ")", ";", "$", "buffer", ".=", "str_repeat", "(", "' '", ",", "35", "-", "strlen", "(", "$", "buffer", ")", ")", ";", "$", "buffer", ".=", "$", "description", ";", "$", "buffer", "=", "'| '", ".", "$", "buffer", ";", "// is the line to long?", "if", "(", "strlen", "(", "$", "buffer", ")", ">", "80", ")", "{", "$", "overflow", "=", "substr", "(", "$", "buffer", ",", "80", ")", ";", "$", "buffer", "=", "substr", "(", "$", "buffer", ",", "0", ",", "80", ")", ".", "\"\\n\"", ";", "$", "overflow", "=", "wordwrap", "(", "$", "overflow", ",", "45", ")", ";", "$", "overflow", "=", "explode", "(", "\"\\n\"", ",", "$", "overflow", ")", ";", "foreach", "(", "$", "overflow", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "overflow", "[", "$", "key", "]", "=", "'| '", ".", "str_repeat", "(", "' '", ",", "25", ")", ".", "trim", "(", "$", "value", ")", ";", "}", "$", "buffer", ".=", "implode", "(", "\"\\n\"", ",", "$", "overflow", ")", ";", "}", "$", "output", "[", "]", "=", "$", "buffer", ";", "}", "}", "$", "output", "[", "]", "=", "'|'", ";", "}", "array_pop", "(", "$", "output", ")", ";", "}", "}", "return", "$", "output", ";", "}" ]
default help formatter @param array $params @return void
[ "default", "help", "formatter" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConsoleController.php#L244-L329
steeffeen/FancyManiaLinks
FML/ManiaCode/InstallScript.php
InstallScript.create
public static function create($name = null, $file = null, $url = null) { return new static($name, $file, $url); }
php
public static function create($name = null, $file = null, $url = null) { return new static($name, $file, $url); }
[ "public", "static", "function", "create", "(", "$", "name", "=", "null", ",", "$", "file", "=", "null", ",", "$", "url", "=", "null", ")", "{", "return", "new", "static", "(", "$", "name", ",", "$", "file", ",", "$", "url", ")", ";", "}" ]
Create a new InstallScript Element @api @param string $name (optional) Script name @param string $file (optional) Script file @param string $url (optional) Script url @return static
[ "Create", "a", "new", "InstallScript", "Element" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaCode/InstallScript.php#L39-L42
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._dataTooltip
protected function _dataTooltip(array $options, $tooltip) { if (Arr::key('title', $options)) { $options['data-tooltip'] = $options['title']; } if (is_string($tooltip)) { $options['data-tooltip'] = $tooltip; } return $options; }
php
protected function _dataTooltip(array $options, $tooltip) { if (Arr::key('title', $options)) { $options['data-tooltip'] = $options['title']; } if (is_string($tooltip)) { $options['data-tooltip'] = $tooltip; } return $options; }
[ "protected", "function", "_dataTooltip", "(", "array", "$", "options", ",", "$", "tooltip", ")", "{", "if", "(", "Arr", "::", "key", "(", "'title'", ",", "$", "options", ")", ")", "{", "$", "options", "[", "'data-tooltip'", "]", "=", "$", "options", "[", "'title'", "]", ";", "}", "if", "(", "is_string", "(", "$", "tooltip", ")", ")", "{", "$", "options", "[", "'data-tooltip'", "]", "=", "$", "tooltip", ";", "}", "return", "$", "options", ";", "}" ]
Setup tooltip data-tooltip attr. @param array $options @param string $tooltip @return array
[ "Setup", "tooltip", "data", "-", "tooltip", "attr", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L38-L49
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._prepareBtn
protected function _prepareBtn(Helper $helper, array $options, $button) { $options = $helper->addClass($options, 'waves-effect waves-light btn'); if (!empty($button)) { $options = $helper->addClass($options, Str::trim((string) $button)); } return $options; }
php
protected function _prepareBtn(Helper $helper, array $options, $button) { $options = $helper->addClass($options, 'waves-effect waves-light btn'); if (!empty($button)) { $options = $helper->addClass($options, Str::trim((string) $button)); } return $options; }
[ "protected", "function", "_prepareBtn", "(", "Helper", "$", "helper", ",", "array", "$", "options", ",", "$", "button", ")", "{", "$", "options", "=", "$", "helper", "->", "addClass", "(", "$", "options", ",", "'waves-effect waves-light btn'", ")", ";", "if", "(", "!", "empty", "(", "$", "button", ")", ")", "{", "$", "options", "=", "$", "helper", "->", "addClass", "(", "$", "options", ",", "Str", "::", "trim", "(", "(", "string", ")", "$", "button", ")", ")", ";", "}", "return", "$", "options", ";", "}" ]
Prepare form buttons. @param Helper $helper @param array $options @param string $button @return array
[ "Prepare", "form", "buttons", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L59-L67
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._prepareTooltip
protected function _prepareTooltip(Helper $helper, array $options, $tooltip) { $_options = [ 'data-position' => 'top' ]; if (Arr::key('tooltipPos', $options)) { $_options['data-position'] = (string) $options['tooltipPos']; unset($options['tooltipPos']); } $options = $this->_tooltipTitle($options, $tooltip); $options = $this->_dataTooltip($options, $tooltip); $options = $helper->addClass($options, 'hasTooltip'); return Hash::merge($_options, $options); }
php
protected function _prepareTooltip(Helper $helper, array $options, $tooltip) { $_options = [ 'data-position' => 'top' ]; if (Arr::key('tooltipPos', $options)) { $_options['data-position'] = (string) $options['tooltipPos']; unset($options['tooltipPos']); } $options = $this->_tooltipTitle($options, $tooltip); $options = $this->_dataTooltip($options, $tooltip); $options = $helper->addClass($options, 'hasTooltip'); return Hash::merge($_options, $options); }
[ "protected", "function", "_prepareTooltip", "(", "Helper", "$", "helper", ",", "array", "$", "options", ",", "$", "tooltip", ")", "{", "$", "_options", "=", "[", "'data-position'", "=>", "'top'", "]", ";", "if", "(", "Arr", "::", "key", "(", "'tooltipPos'", ",", "$", "options", ")", ")", "{", "$", "_options", "[", "'data-position'", "]", "=", "(", "string", ")", "$", "options", "[", "'tooltipPos'", "]", ";", "unset", "(", "$", "options", "[", "'tooltipPos'", "]", ")", ";", "}", "$", "options", "=", "$", "this", "->", "_tooltipTitle", "(", "$", "options", ",", "$", "tooltip", ")", ";", "$", "options", "=", "$", "this", "->", "_dataTooltip", "(", "$", "options", ",", "$", "tooltip", ")", ";", "$", "options", "=", "$", "helper", "->", "addClass", "(", "$", "options", ",", "'hasTooltip'", ")", ";", "return", "Hash", "::", "merge", "(", "$", "_options", ",", "$", "options", ")", ";", "}" ]
Prepare tooltip attrs. @param Helper $helper @param array $options @param string $tooltip @return array
[ "Prepare", "tooltip", "attrs", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L77-L93
CakeCMS/Core
src/View/Helper/Traits/MaterializeCssTrait.php
MaterializeCssTrait._tooltipTitle
protected function _tooltipTitle(array $options, $tooltip) { if ($tooltip === true && !Arr::key('title', $options)) { $options['title'] = strip_tags($options['label']); } if (is_string($tooltip)) { $options['title'] = $tooltip; } return $options; }
php
protected function _tooltipTitle(array $options, $tooltip) { if ($tooltip === true && !Arr::key('title', $options)) { $options['title'] = strip_tags($options['label']); } if (is_string($tooltip)) { $options['title'] = $tooltip; } return $options; }
[ "protected", "function", "_tooltipTitle", "(", "array", "$", "options", ",", "$", "tooltip", ")", "{", "if", "(", "$", "tooltip", "===", "true", "&&", "!", "Arr", "::", "key", "(", "'title'", ",", "$", "options", ")", ")", "{", "$", "options", "[", "'title'", "]", "=", "strip_tags", "(", "$", "options", "[", "'label'", "]", ")", ";", "}", "if", "(", "is_string", "(", "$", "tooltip", ")", ")", "{", "$", "options", "[", "'title'", "]", "=", "$", "tooltip", ";", "}", "return", "$", "options", ";", "}" ]
Setup tooltip title. @param array $options @param string $tooltip @return array
[ "Setup", "tooltip", "title", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/Helper/Traits/MaterializeCssTrait.php#L102-L113
aedart/laravel-helpers
src/Traits/Container/ContainerTrait.php
ContainerTrait.getContainer
public function getContainer(): ?Container { if (!$this->hasContainer()) { $this->setContainer($this->getDefaultContainer()); } return $this->container; }
php
public function getContainer(): ?Container { if (!$this->hasContainer()) { $this->setContainer($this->getDefaultContainer()); } return $this->container; }
[ "public", "function", "getContainer", "(", ")", ":", "?", "Container", "{", "if", "(", "!", "$", "this", "->", "hasContainer", "(", ")", ")", "{", "$", "this", "->", "setContainer", "(", "$", "this", "->", "getDefaultContainer", "(", ")", ")", ";", "}", "return", "$", "this", "->", "container", ";", "}" ]
Get container If no container has been set, this method will set and return a default container, if any such value is available @see getDefaultContainer() @return Container|null container or null if none container has been set
[ "Get", "container" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Container/ContainerTrait.php#L53-L59
ClanCats/Core
src/console/phpunit.php
phpunit.action_build
public function action_build( $params ) { $test_directories = array(); // check if there is an application tests direcotry if ( is_dir( APPPATH.CCDIR_TEST ) ) { $this->line( 'found tests in your application.' ); $test_directories['App'] = APPPATH.CCDIR_TEST; } // add the core tests if ( $params['-include-core'] ) { $test_directories['Core'] = COREPATH.'../'.CCDIR_TEST; } // check all bundles for tests foreach( \CCFinder::$bundles as $bundle => $path ) { if ( is_dir( $path.CCDIR_TEST ) ) { $this->info( 'found tests in the '.$bundle.' bundle.' ); $test_directories[$bundle] = $path.CCDIR_TEST; } } // we have to remove CCROOT from the paths to get the relative one foreach( $test_directories as $key => $dir ) { $test_directories[$key] = './'.str_replace( CCROOT, '', $dir ); } // finally generate an phpunit.xml file $xml = new \DOMDocument("1.0", 'UTF-8'); $root = $xml->createElement( "phpunit" ); $testsuites = $xml->createElement( "testsuites" ); foreach( $test_directories as $key => $dir ) { $testsuite = $xml->createElement( "testsuite" ); $testsuite->setAttribute( 'name', $key.' tests' ); $directory = $xml->createElement( "directory", $dir ); $directory->setAttribute( 'suffix', EXT ); $testsuite->appendChild( $directory ); $testsuites->appendChild( $testsuite ); } $root->appendChild( $testsuites ); $root = $xml->appendChild( $root ); $root->setAttribute( 'colors', 'true' ); $root->setAttribute( 'bootstrap', 'boot/phpunit.php' ); $xml->formatOutput = true; \CCFile::write( CCROOT.'phpunit.xml', $xml->saveXML() ); }
php
public function action_build( $params ) { $test_directories = array(); // check if there is an application tests direcotry if ( is_dir( APPPATH.CCDIR_TEST ) ) { $this->line( 'found tests in your application.' ); $test_directories['App'] = APPPATH.CCDIR_TEST; } // add the core tests if ( $params['-include-core'] ) { $test_directories['Core'] = COREPATH.'../'.CCDIR_TEST; } // check all bundles for tests foreach( \CCFinder::$bundles as $bundle => $path ) { if ( is_dir( $path.CCDIR_TEST ) ) { $this->info( 'found tests in the '.$bundle.' bundle.' ); $test_directories[$bundle] = $path.CCDIR_TEST; } } // we have to remove CCROOT from the paths to get the relative one foreach( $test_directories as $key => $dir ) { $test_directories[$key] = './'.str_replace( CCROOT, '', $dir ); } // finally generate an phpunit.xml file $xml = new \DOMDocument("1.0", 'UTF-8'); $root = $xml->createElement( "phpunit" ); $testsuites = $xml->createElement( "testsuites" ); foreach( $test_directories as $key => $dir ) { $testsuite = $xml->createElement( "testsuite" ); $testsuite->setAttribute( 'name', $key.' tests' ); $directory = $xml->createElement( "directory", $dir ); $directory->setAttribute( 'suffix', EXT ); $testsuite->appendChild( $directory ); $testsuites->appendChild( $testsuite ); } $root->appendChild( $testsuites ); $root = $xml->appendChild( $root ); $root->setAttribute( 'colors', 'true' ); $root->setAttribute( 'bootstrap', 'boot/phpunit.php' ); $xml->formatOutput = true; \CCFile::write( CCROOT.'phpunit.xml', $xml->saveXML() ); }
[ "public", "function", "action_build", "(", "$", "params", ")", "{", "$", "test_directories", "=", "array", "(", ")", ";", "// check if there is an application tests direcotry", "if", "(", "is_dir", "(", "APPPATH", ".", "CCDIR_TEST", ")", ")", "{", "$", "this", "->", "line", "(", "'found tests in your application.'", ")", ";", "$", "test_directories", "[", "'App'", "]", "=", "APPPATH", ".", "CCDIR_TEST", ";", "}", "// add the core tests", "if", "(", "$", "params", "[", "'-include-core'", "]", ")", "{", "$", "test_directories", "[", "'Core'", "]", "=", "COREPATH", ".", "'../'", ".", "CCDIR_TEST", ";", "}", "// check all bundles for tests", "foreach", "(", "\\", "CCFinder", "::", "$", "bundles", "as", "$", "bundle", "=>", "$", "path", ")", "{", "if", "(", "is_dir", "(", "$", "path", ".", "CCDIR_TEST", ")", ")", "{", "$", "this", "->", "info", "(", "'found tests in the '", ".", "$", "bundle", ".", "' bundle.'", ")", ";", "$", "test_directories", "[", "$", "bundle", "]", "=", "$", "path", ".", "CCDIR_TEST", ";", "}", "}", "// we have to remove CCROOT from the paths to get the relative one", "foreach", "(", "$", "test_directories", "as", "$", "key", "=>", "$", "dir", ")", "{", "$", "test_directories", "[", "$", "key", "]", "=", "'./'", ".", "str_replace", "(", "CCROOT", ",", "''", ",", "$", "dir", ")", ";", "}", "// finally generate an phpunit.xml file", "$", "xml", "=", "new", "\\", "DOMDocument", "(", "\"1.0\"", ",", "'UTF-8'", ")", ";", "$", "root", "=", "$", "xml", "->", "createElement", "(", "\"phpunit\"", ")", ";", "$", "testsuites", "=", "$", "xml", "->", "createElement", "(", "\"testsuites\"", ")", ";", "foreach", "(", "$", "test_directories", "as", "$", "key", "=>", "$", "dir", ")", "{", "$", "testsuite", "=", "$", "xml", "->", "createElement", "(", "\"testsuite\"", ")", ";", "$", "testsuite", "->", "setAttribute", "(", "'name'", ",", "$", "key", ".", "' tests'", ")", ";", "$", "directory", "=", "$", "xml", "->", "createElement", "(", "\"directory\"", ",", "$", "dir", ")", ";", "$", "directory", "->", "setAttribute", "(", "'suffix'", ",", "EXT", ")", ";", "$", "testsuite", "->", "appendChild", "(", "$", "directory", ")", ";", "$", "testsuites", "->", "appendChild", "(", "$", "testsuite", ")", ";", "}", "$", "root", "->", "appendChild", "(", "$", "testsuites", ")", ";", "$", "root", "=", "$", "xml", "->", "appendChild", "(", "$", "root", ")", ";", "$", "root", "->", "setAttribute", "(", "'colors'", ",", "'true'", ")", ";", "$", "root", "->", "setAttribute", "(", "'bootstrap'", ",", "'boot/phpunit.php'", ")", ";", "$", "xml", "->", "formatOutput", "=", "true", ";", "\\", "CCFile", "::", "write", "(", "CCROOT", ".", "'phpunit.xml'", ",", "$", "xml", "->", "saveXML", "(", ")", ")", ";", "}" ]
Builds the phpunit.xml file @param array $params
[ "Builds", "the", "phpunit", ".", "xml", "file" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/console/phpunit.php#L33-L96
webforge-labs/psc-cms
lib/Psc/DataInput.php
DataInput.getDataWithKeys
public function getDataWithKeys(Array $keys, $do = self::RETURN_NULL) { $data = $this->data; foreach ($keys as $key) { if (is_array($key)) { throw new InvalidArgumentException('$keys kann nur ein Array von Strings sein. '.Code::varInfo($keys)); } if (!is_array($data) || !array_key_exists($key,$data)) { if ($do === self::RETURN_NULL) { return NULL; } else { $e = new DataInputException('Konnte Schlüssel: "'.implode('.',$keys).'" nicht finden'); $e->keys = $keys; throw $e; } } $data = $data[$key]; } if (is_array($data)) return $this->cleanArray($data); else return $this->clean($data); }
php
public function getDataWithKeys(Array $keys, $do = self::RETURN_NULL) { $data = $this->data; foreach ($keys as $key) { if (is_array($key)) { throw new InvalidArgumentException('$keys kann nur ein Array von Strings sein. '.Code::varInfo($keys)); } if (!is_array($data) || !array_key_exists($key,$data)) { if ($do === self::RETURN_NULL) { return NULL; } else { $e = new DataInputException('Konnte Schlüssel: "'.implode('.',$keys).'" nicht finden'); $e->keys = $keys; throw $e; } } $data = $data[$key]; } if (is_array($data)) return $this->cleanArray($data); else return $this->clean($data); }
[ "public", "function", "getDataWithKeys", "(", "Array", "$", "keys", ",", "$", "do", "=", "self", "::", "RETURN_NULL", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$keys kann nur ein Array von Strings sein. '", ".", "Code", "::", "varInfo", "(", "$", "keys", ")", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "data", ")", "||", "!", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "if", "(", "$", "do", "===", "self", "::", "RETURN_NULL", ")", "{", "return", "NULL", ";", "}", "else", "{", "$", "e", "=", "new", "DataInputException", "(", "'Konnte Schlüssel: \"'.", "i", "mplode(", "'", ".',", "$", "k", "eys)", ".", "'", "\" nicht finden')", ";", "", "$", "e", "->", "keys", "=", "$", "keys", ";", "throw", "$", "e", ";", "}", "}", "$", "data", "=", "$", "data", "[", "$", "key", "]", ";", "}", "if", "(", "is_array", "(", "$", "data", ")", ")", "return", "$", "this", "->", "cleanArray", "(", "$", "data", ")", ";", "else", "return", "$", "this", "->", "clean", "(", "$", "data", ")", ";", "}" ]
Gibt einen Pfad zu einem Wert aus dem Array zurück Ableitenden Klassen können dann sowas machen: public function bla() { $keys = func_get_args(); return $this->getDataWithKeys($keys, self::THROW_EXCEPTION); } oder so kann keine Defaults sondern nur return NULL oder eine Exception schmeissen
[ "Gibt", "einen", "Pfad", "zu", "einem", "Wert", "aus", "dem", "Array", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DataInput.php#L64-L90
webforge-labs/psc-cms
lib/Psc/DataInput.php
DataInput.setDataWithKeys
public function setDataWithKeys(Array $keys, $value) { $data =& $this->data; if ($keys === array()) { if (!is_array($value)) { throw new DataInputException('Wenn $keys leer ist, darf value nur ein array sein!'); } return $data = $value; } $lastKey = array_pop($keys); foreach ($keys as $key) { if (!array_key_exists($key,$data)) { $data[$key] = array(); } $data =& $data[$key]; } $data[$lastKey] = $value; return $data; }
php
public function setDataWithKeys(Array $keys, $value) { $data =& $this->data; if ($keys === array()) { if (!is_array($value)) { throw new DataInputException('Wenn $keys leer ist, darf value nur ein array sein!'); } return $data = $value; } $lastKey = array_pop($keys); foreach ($keys as $key) { if (!array_key_exists($key,$data)) { $data[$key] = array(); } $data =& $data[$key]; } $data[$lastKey] = $value; return $data; }
[ "public", "function", "setDataWithKeys", "(", "Array", "$", "keys", ",", "$", "value", ")", "{", "$", "data", "=", "&", "$", "this", "->", "data", ";", "if", "(", "$", "keys", "===", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "throw", "new", "DataInputException", "(", "'Wenn $keys leer ist, darf value nur ein array sein!'", ")", ";", "}", "return", "$", "data", "=", "$", "value", ";", "}", "$", "lastKey", "=", "array_pop", "(", "$", "keys", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "array", "(", ")", ";", "}", "$", "data", "=", "&", "$", "data", "[", "$", "key", "]", ";", "}", "$", "data", "[", "$", "lastKey", "]", "=", "$", "value", ";", "return", "$", "data", ";", "}" ]
Setzt einen Wert mit einem Pfad Ableitenden Klassen können dann sowas machen: public function bla() { $keys = func_get_args(); $value = array_pop($keys); return $this->setDataWithKeys($keys, $value, self::THROW_EXCEPTION); } oder so ist $keys ein leerer array werden alle Daten des Objektes mit $value ersetzt. ist $value dann kein Array wird toArray() einen array mit $value als einziges Element zurückgeben - das ist sehr weird also besser ist immer $value einen array zu haben
[ "Setzt", "einen", "Wert", "mit", "einem", "Pfad" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DataInput.php#L109-L130
webforge-labs/psc-cms
lib/Psc/DataInput.php
DataInput.get
public function get($keys, $do = self::RETURN_NULL, $default = NULL) { if (is_string($keys)) $keys = explode('.',$keys); try { $data = $this->getDataWithKeys($keys, self::THROW_EXCEPTION); } catch (DataInputException $e) { /* Do */ if ($do === self::THROW_EXCEPTION) throw $e; if ($do === self::RETURN_NULL) return NULL; return $do; } /* Default */ if ($data === NULL) { if ($default == self::THROW_EXCEPTION) { $e = new EmptyDataInputException('Daten zu den Schlüssel(n): "'.implode('.',$keys).'" waren NULL'); $e->keys = $keys; throw $e; } return $default; } return $data; }
php
public function get($keys, $do = self::RETURN_NULL, $default = NULL) { if (is_string($keys)) $keys = explode('.',$keys); try { $data = $this->getDataWithKeys($keys, self::THROW_EXCEPTION); } catch (DataInputException $e) { /* Do */ if ($do === self::THROW_EXCEPTION) throw $e; if ($do === self::RETURN_NULL) return NULL; return $do; } /* Default */ if ($data === NULL) { if ($default == self::THROW_EXCEPTION) { $e = new EmptyDataInputException('Daten zu den Schlüssel(n): "'.implode('.',$keys).'" waren NULL'); $e->keys = $keys; throw $e; } return $default; } return $data; }
[ "public", "function", "get", "(", "$", "keys", ",", "$", "do", "=", "self", "::", "RETURN_NULL", ",", "$", "default", "=", "NULL", ")", "{", "if", "(", "is_string", "(", "$", "keys", ")", ")", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "keys", ")", ";", "try", "{", "$", "data", "=", "$", "this", "->", "getDataWithKeys", "(", "$", "keys", ",", "self", "::", "THROW_EXCEPTION", ")", ";", "}", "catch", "(", "DataInputException", "$", "e", ")", "{", "/* Do */", "if", "(", "$", "do", "===", "self", "::", "THROW_EXCEPTION", ")", "throw", "$", "e", ";", "if", "(", "$", "do", "===", "self", "::", "RETURN_NULL", ")", "return", "NULL", ";", "return", "$", "do", ";", "}", "/* Default */", "if", "(", "$", "data", "===", "NULL", ")", "{", "if", "(", "$", "default", "==", "self", "::", "THROW_EXCEPTION", ")", "{", "$", "e", "=", "new", "EmptyDataInputException", "(", "'Daten zu den Schlüssel(n): \"'.", "i", "mplode(", "'", ".',", "$", "k", "eys)", ".", "'", "\" waren NULL')", ";", "", "$", "e", "->", "keys", "=", "$", "keys", ";", "throw", "$", "e", ";", "}", "return", "$", "default", ";", "}", "return", "$", "data", ";", "}" ]
Gibt einen Wert aus den Daten zurück Der dritte Parameter ist anfangs etwas verwirred, er ist aber dafür da ein fine-grained control über diese Klase zu bekommen Der Standardfall den man aus einem Formular machen möchte ist z. B.: $ids = $formDataPOST->get(array('data','ids'), array()); was hier passiert ist, dass wenn $_POST['data']['ids'] nicht gesetzt ist. Also der array in $_POST['data'] keinen schlüssel ids hat, ein array() zurückgibt (also den 2ten Parameter) Was man aber eigentlich will ist, dass in $ids immer ein array ist. Also auch ein leerer array, wenn im Formular $_POST['data']['ids'] = NULL; z.b. übergeben wird. Dafür braucht man dann den dritten Parameter, der erst dann zurückgegeben wird, wenn $_POST['data']['ids'] === NULL ist Der Standardfall ist also $ids = $formDataPOST->get(array('data','ids'), array(), array()); zu benutzen. Deshalb ist im FORMDataInput der dritte Parameter unwirksam denn hier gilt $do = $default zu beachten ist auch, dass der Defaultwert auch genommen wird wenn der Wert trim() === '' ist (siehe clean) @param string|array $keys @param $do entweder die constanten self::RETURN_NULL oder self::THROW_EXCEPTION, sind dies es nicht wird $do als defaultwert behandelt, wenn der Wert von $keys nicht gesetzt ist @param $default der Wert der zurückgebeben wird, wenn die Keys zwar gefunden wurden, aber der wert der Keys === NULL ist
[ "Gibt", "einen", "Wert", "aus", "den", "Daten", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DataInput.php#L187-L216
webforge-labs/psc-cms
lib/Psc/DataInput.php
DataInput.set
public function set($keys, $value) { if (is_string($keys)) $keys = explode('.',$keys); if (is_integer($keys)) $keys = array($keys); return $this->setDataWithKeys($keys, $value); }
php
public function set($keys, $value) { if (is_string($keys)) $keys = explode('.',$keys); if (is_integer($keys)) $keys = array($keys); return $this->setDataWithKeys($keys, $value); }
[ "public", "function", "set", "(", "$", "keys", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "keys", ")", ")", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "keys", ")", ";", "if", "(", "is_integer", "(", "$", "keys", ")", ")", "$", "keys", "=", "array", "(", "$", "keys", ")", ";", "return", "$", "this", "->", "setDataWithKeys", "(", "$", "keys", ",", "$", "value", ")", ";", "}" ]
Setzt einen Wert in den Daten @param string|array $keys @param mixed $value
[ "Setzt", "einen", "Wert", "in", "den", "Daten" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DataInput.php#L224-L229
webforge-labs/psc-cms
lib/Psc/DataInput.php
DataInput.remove
public function remove(array $keys) { $data =& $this->data; if ($keys === array() || $keys == NULL) { return $this; } $lastKey = array_pop($keys); foreach ($keys as $key) { if (!array_key_exists($key,$data)) { return $this; } $data =& $data[$key]; } if (array_key_exists($lastKey, $data)) unset($data[$lastKey]); return $this; }
php
public function remove(array $keys) { $data =& $this->data; if ($keys === array() || $keys == NULL) { return $this; } $lastKey = array_pop($keys); foreach ($keys as $key) { if (!array_key_exists($key,$data)) { return $this; } $data =& $data[$key]; } if (array_key_exists($lastKey, $data)) unset($data[$lastKey]); return $this; }
[ "public", "function", "remove", "(", "array", "$", "keys", ")", "{", "$", "data", "=", "&", "$", "this", "->", "data", ";", "if", "(", "$", "keys", "===", "array", "(", ")", "||", "$", "keys", "==", "NULL", ")", "{", "return", "$", "this", ";", "}", "$", "lastKey", "=", "array_pop", "(", "$", "keys", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "return", "$", "this", ";", "}", "$", "data", "=", "&", "$", "data", "[", "$", "key", "]", ";", "}", "if", "(", "array_key_exists", "(", "$", "lastKey", ",", "$", "data", ")", ")", "unset", "(", "$", "data", "[", "$", "lastKey", "]", ")", ";", "return", "$", "this", ";", "}" ]
Entfernt Schlüssel aus den Daten alle Schlüssel darunter werden ebenfalls entfernt. Wird der Schlüssel nicht gefunden, passiert nichts
[ "Entfernt", "Schlüssel", "aus", "den", "Daten" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/DataInput.php#L237-L255
yuncms/framework
src/sms/Sms.php
Sms.send
public function send($to, $message, array $gateways = []): array { return $this->getMessenger()->send($to, $message, $gateways); }
php
public function send($to, $message, array $gateways = []): array { return $this->getMessenger()->send($to, $message, $gateways); }
[ "public", "function", "send", "(", "$", "to", ",", "$", "message", ",", "array", "$", "gateways", "=", "[", "]", ")", ":", "array", "{", "return", "$", "this", "->", "getMessenger", "(", ")", "->", "send", "(", "$", "to", ",", "$", "message", ",", "$", "gateways", ")", ";", "}" ]
Send a message. @param string|array $to @param array|string|MessageInterface $message @param array $gateways @return array @throws InvalidConfigException @throws exceptions\NoGatewayAvailableException
[ "Send", "a", "message", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L75-L78
yuncms/framework
src/sms/Sms.php
Sms.strategy
public function strategy($strategy = null) { if (is_null($strategy)) { $strategy = $this->defaultStrategy ?: OrderStrategy::class; } if (!class_exists($strategy)) { $strategy = __NAMESPACE__ . '\strategies\\' . ucfirst($strategy); } if (!class_exists($strategy)) { throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\""); } if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) { $this->strategies[$strategy] = new $strategy($this); } return $this->strategies[$strategy]; }
php
public function strategy($strategy = null) { if (is_null($strategy)) { $strategy = $this->defaultStrategy ?: OrderStrategy::class; } if (!class_exists($strategy)) { $strategy = __NAMESPACE__ . '\strategies\\' . ucfirst($strategy); } if (!class_exists($strategy)) { throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\""); } if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) { $this->strategies[$strategy] = new $strategy($this); } return $this->strategies[$strategy]; }
[ "public", "function", "strategy", "(", "$", "strategy", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "strategy", ")", ")", "{", "$", "strategy", "=", "$", "this", "->", "defaultStrategy", "?", ":", "OrderStrategy", "::", "class", ";", "}", "if", "(", "!", "class_exists", "(", "$", "strategy", ")", ")", "{", "$", "strategy", "=", "__NAMESPACE__", ".", "'\\strategies\\\\'", ".", "ucfirst", "(", "$", "strategy", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "strategy", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Unsupported strategy \\\"{$strategy}\\\"\"", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "strategies", "[", "$", "strategy", "]", ")", "||", "!", "(", "$", "this", "->", "strategies", "[", "$", "strategy", "]", "instanceof", "StrategyInterface", ")", ")", "{", "$", "this", "->", "strategies", "[", "$", "strategy", "]", "=", "new", "$", "strategy", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "strategies", "[", "$", "strategy", "]", ";", "}" ]
Get a strategy instance. @param string|null $strategy @return StrategyInterface @throws InvalidArgumentException
[ "Get", "a", "strategy", "instance", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L95-L114
yuncms/framework
src/sms/Sms.php
Sms.has
public function has($id, $checkInstance = false) { return $checkInstance ? isset($this->_gateways[$id]) : isset($this->_definitions[$id]); }
php
public function has($id, $checkInstance = false) { return $checkInstance ? isset($this->_gateways[$id]) : isset($this->_definitions[$id]); }
[ "public", "function", "has", "(", "$", "id", ",", "$", "checkInstance", "=", "false", ")", "{", "return", "$", "checkInstance", "?", "isset", "(", "$", "this", "->", "_gateways", "[", "$", "id", "]", ")", ":", "isset", "(", "$", "this", "->", "_definitions", "[", "$", "id", "]", ")", ";", "}" ]
Returns a value indicating whether the locator has the specified gateway definition or has instantiated the gateway. This method may return different results depending on the value of `$checkInstance`. - If `$checkInstance` is false (default), the method will return a value indicating whether the locator has the specified gateway definition. - If `$checkInstance` is true, the method will return a value indicating whether the locator has instantiated the specified gateway. @param string $id gateway ID (e.g. `local`). @param bool $checkInstance whether the method should check if the gateway is shared and instantiated. @return bool whether the locator has the specified gateway definition or has instantiated the gateway. @see set()
[ "Returns", "a", "value", "indicating", "whether", "the", "locator", "has", "the", "specified", "gateway", "definition", "or", "has", "instantiated", "the", "gateway", ".", "This", "method", "may", "return", "different", "results", "depending", "on", "the", "value", "of", "$checkInstance", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L162-L165
yuncms/framework
src/sms/Sms.php
Sms.get
public function get($id, $throwException = true) { if (isset($this->_gateways[$id])) { return $this->_gateways[$id]; } if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_gateways[$id] = $definition; } return $this->_gateways[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown gateway ID: $id"); } return null; }
php
public function get($id, $throwException = true) { if (isset($this->_gateways[$id])) { return $this->_gateways[$id]; } if (isset($this->_definitions[$id])) { $definition = $this->_definitions[$id]; if (is_object($definition) && !$definition instanceof Closure) { return $this->_gateways[$id] = $definition; } return $this->_gateways[$id] = Yii::createObject($definition); } elseif ($throwException) { throw new InvalidConfigException("Unknown gateway ID: $id"); } return null; }
[ "public", "function", "get", "(", "$", "id", ",", "$", "throwException", "=", "true", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_gateways", "[", "$", "id", "]", ")", ")", "{", "return", "$", "this", "->", "_gateways", "[", "$", "id", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_definitions", "[", "$", "id", "]", ")", ")", "{", "$", "definition", "=", "$", "this", "->", "_definitions", "[", "$", "id", "]", ";", "if", "(", "is_object", "(", "$", "definition", ")", "&&", "!", "$", "definition", "instanceof", "Closure", ")", "{", "return", "$", "this", "->", "_gateways", "[", "$", "id", "]", "=", "$", "definition", ";", "}", "return", "$", "this", "->", "_gateways", "[", "$", "id", "]", "=", "Yii", "::", "createObject", "(", "$", "definition", ")", ";", "}", "elseif", "(", "$", "throwException", ")", "{", "throw", "new", "InvalidConfigException", "(", "\"Unknown gateway ID: $id\"", ")", ";", "}", "return", "null", ";", "}" ]
Returns the gateway instance with the specified ID. @param string $id gateway ID (e.g. `db`). @param bool $throwException whether to throw an exception if `$id` is not registered with the locator before. @return object|null the gateway of the specified ID. If `$throwException` is false and `$id` is not registered before, null will be returned. @throws InvalidConfigException if `$id` refers to a nonexistent gateway ID @see has() @see set()
[ "Returns", "the", "gateway", "instance", "with", "the", "specified", "ID", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L178-L196
yuncms/framework
src/sms/Sms.php
Sms.set
public function set($id, $definition) { unset($this->_gateways[$id]); if ($definition === null) { unset($this->_definitions[$id]); return; } if (is_object($definition) || is_callable($definition, true)) { // an object, a class name, or a PHP callable $this->_definitions[$id] = $definition; } elseif (is_array($definition)) { // a configuration array if (isset($definition['class'])) { $this->_definitions[$id] = $definition; } else { throw new InvalidConfigException("The configuration for the \"$id\" gateway must contain a \"class\" element."); } } else { throw new InvalidConfigException("Unexpected configuration type for the \"$id\" gateway: " . gettype($definition)); } }
php
public function set($id, $definition) { unset($this->_gateways[$id]); if ($definition === null) { unset($this->_definitions[$id]); return; } if (is_object($definition) || is_callable($definition, true)) { // an object, a class name, or a PHP callable $this->_definitions[$id] = $definition; } elseif (is_array($definition)) { // a configuration array if (isset($definition['class'])) { $this->_definitions[$id] = $definition; } else { throw new InvalidConfigException("The configuration for the \"$id\" gateway must contain a \"class\" element."); } } else { throw new InvalidConfigException("Unexpected configuration type for the \"$id\" gateway: " . gettype($definition)); } }
[ "public", "function", "set", "(", "$", "id", ",", "$", "definition", ")", "{", "unset", "(", "$", "this", "->", "_gateways", "[", "$", "id", "]", ")", ";", "if", "(", "$", "definition", "===", "null", ")", "{", "unset", "(", "$", "this", "->", "_definitions", "[", "$", "id", "]", ")", ";", "return", ";", "}", "if", "(", "is_object", "(", "$", "definition", ")", "||", "is_callable", "(", "$", "definition", ",", "true", ")", ")", "{", "// an object, a class name, or a PHP callable", "$", "this", "->", "_definitions", "[", "$", "id", "]", "=", "$", "definition", ";", "}", "elseif", "(", "is_array", "(", "$", "definition", ")", ")", "{", "// a configuration array", "if", "(", "isset", "(", "$", "definition", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "_definitions", "[", "$", "id", "]", "=", "$", "definition", ";", "}", "else", "{", "throw", "new", "InvalidConfigException", "(", "\"The configuration for the \\\"$id\\\" gateway must contain a \\\"class\\\" element.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "InvalidConfigException", "(", "\"Unexpected configuration type for the \\\"$id\\\" gateway: \"", ".", "gettype", "(", "$", "definition", ")", ")", ";", "}", "}" ]
Registers a gateway definition with this locator. For example, ```php // a class name $locator->set('cache', 'yii\caching\FileCache'); // a configuration array $locator->set('db', [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;dbname=demo', 'username' => 'root', 'password' => '', 'charset' => 'utf8', ]); // an anonymous function $locator->set('cache', function ($params) { return new \yii\caching\FileCache; }); // an instance $locator->set('cache', new \yii\caching\FileCache); ``` If a filesystem definition with the same ID already exists, it will be overwritten. @param string $id filesystem ID (e.g. `db`). @param mixed $definition the filesystem definition to be registered with this locator. It can be one of the following: - a class name - a configuration array: the array contains name-value pairs that will be used to initialize the property values of the newly created object when [[get()]] is called. The `class` element is required and stands for the the class of the object to be created. - a PHP callable: either an anonymous function or an array representing a class method (e.g. `['Foo', 'bar']`). The callable will be called by [[get()]] to return an object associated with the specified filesystem ID. - an object: When [[get()]] is called, this object will be returned. @throws InvalidConfigException if the definition is an invalid configuration array
[ "Registers", "a", "gateway", "definition", "with", "this", "locator", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L241-L263
yuncms/framework
src/sms/Sms.php
Sms.setGateways
public function setGateways($gateways) { foreach ($gateways as $id => $gateway) { $this->set($id, $gateway); } }
php
public function setGateways($gateways) { foreach ($gateways as $id => $gateway) { $this->set($id, $gateway); } }
[ "public", "function", "setGateways", "(", "$", "gateways", ")", "{", "foreach", "(", "$", "gateways", "as", "$", "id", "=>", "$", "gateway", ")", "{", "$", "this", "->", "set", "(", "$", "id", ",", "$", "gateway", ")", ";", "}", "}" ]
Registers a set of gateway definitions in this locator. This is the bulk version of [[set()]]. The parameter should be an array whose keys are gateway IDs and values the corresponding gateway definitions. For more details on how to specify gateway IDs and definitions, please refer to [[set()]]. If a gateway definition with the same ID already exists, it will be overwritten. The following is an example for registering two gateway definitions: ```php [ 'local' => [ 'class' => 'yuncms\payment\gateways\LocalAdapter', 'path' => '@root/storage', ], ] ``` @param array $gateways gateway definitions or instances @throws InvalidConfigException
[ "Registers", "a", "set", "of", "gateway", "definitions", "in", "this", "locator", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/sms/Sms.php#L308-L313
nexusnetsoftgmbh/nexuscli
src/Nexus/Dumper/Business/DumperBusinessFactory.php
DumperBusinessFactory.createDumper
public function createDumper(DumperConfigDataProvider $configDataProvider): DumperInterface { $configDataProvider->setSshHost($this->getConfig()->getSshHost()); $configDataProvider->setSshUser($this->getConfig()->getSshUser()); $configDataProvider->setProject($this->getConfig()->getProject()); $configDataProvider->setImageName($this->getConfig()->getImageName()); $configDataProvider->setDumpDirectory($this->getConfig()->getDumpDirectory()); return new Dumper( $configDataProvider, $this->getDockerFacade() ); }
php
public function createDumper(DumperConfigDataProvider $configDataProvider): DumperInterface { $configDataProvider->setSshHost($this->getConfig()->getSshHost()); $configDataProvider->setSshUser($this->getConfig()->getSshUser()); $configDataProvider->setProject($this->getConfig()->getProject()); $configDataProvider->setImageName($this->getConfig()->getImageName()); $configDataProvider->setDumpDirectory($this->getConfig()->getDumpDirectory()); return new Dumper( $configDataProvider, $this->getDockerFacade() ); }
[ "public", "function", "createDumper", "(", "DumperConfigDataProvider", "$", "configDataProvider", ")", ":", "DumperInterface", "{", "$", "configDataProvider", "->", "setSshHost", "(", "$", "this", "->", "getConfig", "(", ")", "->", "getSshHost", "(", ")", ")", ";", "$", "configDataProvider", "->", "setSshUser", "(", "$", "this", "->", "getConfig", "(", ")", "->", "getSshUser", "(", ")", ")", ";", "$", "configDataProvider", "->", "setProject", "(", "$", "this", "->", "getConfig", "(", ")", "->", "getProject", "(", ")", ")", ";", "$", "configDataProvider", "->", "setImageName", "(", "$", "this", "->", "getConfig", "(", ")", "->", "getImageName", "(", ")", ")", ";", "$", "configDataProvider", "->", "setDumpDirectory", "(", "$", "this", "->", "getConfig", "(", ")", "->", "getDumpDirectory", "(", ")", ")", ";", "return", "new", "Dumper", "(", "$", "configDataProvider", ",", "$", "this", "->", "getDockerFacade", "(", ")", ")", ";", "}" ]
@param \DataProvider\DumperConfigDataProvider $configDataProvider @return \Nexus\Dumper\Business\Model\Dumper
[ "@param", "\\", "DataProvider", "\\", "DumperConfigDataProvider", "$configDataProvider" ]
train
https://github.com/nexusnetsoftgmbh/nexuscli/blob/8416b43d31ad56ea379ae2b0bf85d456e78ba67a/src/Nexus/Dumper/Business/DumperBusinessFactory.php#L24-L36
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Dumper.php
Dumper.getClasses
public function getClasses($name) { $classes = array(); $instanceDefinitions = $this->getInjectedDefinitions($name); foreach ($instanceDefinitions as $instanceDefinition) { if ($instanceDefinition->getClass()) { $classes[$instanceDefinition->getClass()] = true; continue; } $alias = $this->di->instanceManager()->getClassFromAlias($instanceDefinition->getName()); $classes[$alias] = true; } return array_keys($classes); }
php
public function getClasses($name) { $classes = array(); $instanceDefinitions = $this->getInjectedDefinitions($name); foreach ($instanceDefinitions as $instanceDefinition) { if ($instanceDefinition->getClass()) { $classes[$instanceDefinition->getClass()] = true; continue; } $alias = $this->di->instanceManager()->getClassFromAlias($instanceDefinition->getName()); $classes[$alias] = true; } return array_keys($classes); }
[ "public", "function", "getClasses", "(", "$", "name", ")", "{", "$", "classes", "=", "array", "(", ")", ";", "$", "instanceDefinitions", "=", "$", "this", "->", "getInjectedDefinitions", "(", "$", "name", ")", ";", "foreach", "(", "$", "instanceDefinitions", "as", "$", "instanceDefinition", ")", "{", "if", "(", "$", "instanceDefinition", "->", "getClass", "(", ")", ")", "{", "$", "classes", "[", "$", "instanceDefinition", "->", "getClass", "(", ")", "]", "=", "true", ";", "continue", ";", "}", "$", "alias", "=", "$", "this", "->", "di", "->", "instanceManager", "(", ")", "->", "getClassFromAlias", "(", "$", "instanceDefinition", "->", "getName", "(", ")", ")", ";", "$", "classes", "[", "$", "alias", "]", "=", "true", ";", "}", "return", "array_keys", "(", "$", "classes", ")", ";", "}" ]
Retrieves all classes that are involved in generating an instance for $name and its dependencies @param array|string $name @return string[]
[ "Retrieves", "all", "classes", "that", "are", "involved", "in", "generating", "an", "instance", "for", "$name", "and", "its", "dependencies" ]
train
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Dumper.php#L106-L122
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Dumper.php
Dumper.getInjectedDefinitions
public function getInjectedDefinitions($name) { $names = (array) $name; $visited = array(); foreach ($names as $name) { $this->doGetInjectedDefinitions($name, $visited); } return $visited; }
php
public function getInjectedDefinitions($name) { $names = (array) $name; $visited = array(); foreach ($names as $name) { $this->doGetInjectedDefinitions($name, $visited); } return $visited; }
[ "public", "function", "getInjectedDefinitions", "(", "$", "name", ")", "{", "$", "names", "=", "(", "array", ")", "$", "name", ";", "$", "visited", "=", "array", "(", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "$", "this", "->", "doGetInjectedDefinitions", "(", "$", "name", ",", "$", "visited", ")", ";", "}", "return", "$", "visited", ";", "}" ]
Retrieves all GeneratorInstances that represent instantiation of an instance for $name and its dependencies @param string|array $name name or names of the instances to get @return GeneratorInstance[] all definitions discovered recursively
[ "Retrieves", "all", "GeneratorInstances", "that", "represent", "instantiation", "of", "an", "instance", "for", "$name", "and", "its", "dependencies" ]
train
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Dumper.php#L131-L141
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Dumper.php
Dumper.doGetInjectedDefinitions
protected function doGetInjectedDefinitions($name, array &$visited) { if (isset($visited[$name])) { return; } try { $visited[$name] = $this->proxy->get($name); } catch (RuntimeException $e) { // usually abstract class or interface that cannot be resolved return; } catch (MissingPropertyException $e) { // usually missing parameters required for a particular instance return; } foreach ($visited[$name]->getParams() as $param) { if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } foreach ($visited[$name]->getMethods() as $method) { if (isset($method['params']) && is_array($method['params'])) { foreach ($method['params'] as $param) { /* @var $param GeneratorInstance */ if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } } } }
php
protected function doGetInjectedDefinitions($name, array &$visited) { if (isset($visited[$name])) { return; } try { $visited[$name] = $this->proxy->get($name); } catch (RuntimeException $e) { // usually abstract class or interface that cannot be resolved return; } catch (MissingPropertyException $e) { // usually missing parameters required for a particular instance return; } foreach ($visited[$name]->getParams() as $param) { if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } foreach ($visited[$name]->getMethods() as $method) { if (isset($method['params']) && is_array($method['params'])) { foreach ($method['params'] as $param) { /* @var $param GeneratorInstance */ if ($param instanceof GeneratorInstance) { /* @var $param GeneratorInstance */ $this->doGetInjectedDefinitions($param->getName(), $visited); } } } } }
[ "protected", "function", "doGetInjectedDefinitions", "(", "$", "name", ",", "array", "&", "$", "visited", ")", "{", "if", "(", "isset", "(", "$", "visited", "[", "$", "name", "]", ")", ")", "{", "return", ";", "}", "try", "{", "$", "visited", "[", "$", "name", "]", "=", "$", "this", "->", "proxy", "->", "get", "(", "$", "name", ")", ";", "}", "catch", "(", "RuntimeException", "$", "e", ")", "{", "// usually abstract class or interface that cannot be resolved", "return", ";", "}", "catch", "(", "MissingPropertyException", "$", "e", ")", "{", "// usually missing parameters required for a particular instance", "return", ";", "}", "foreach", "(", "$", "visited", "[", "$", "name", "]", "->", "getParams", "(", ")", "as", "$", "param", ")", "{", "if", "(", "$", "param", "instanceof", "GeneratorInstance", ")", "{", "/* @var $param GeneratorInstance */", "$", "this", "->", "doGetInjectedDefinitions", "(", "$", "param", "->", "getName", "(", ")", ",", "$", "visited", ")", ";", "}", "}", "foreach", "(", "$", "visited", "[", "$", "name", "]", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "if", "(", "isset", "(", "$", "method", "[", "'params'", "]", ")", "&&", "is_array", "(", "$", "method", "[", "'params'", "]", ")", ")", "{", "foreach", "(", "$", "method", "[", "'params'", "]", "as", "$", "param", ")", "{", "/* @var $param GeneratorInstance */", "if", "(", "$", "param", "instanceof", "GeneratorInstance", ")", "{", "/* @var $param GeneratorInstance */", "$", "this", "->", "doGetInjectedDefinitions", "(", "$", "param", "->", "getName", "(", ")", ",", "$", "visited", ")", ";", "}", "}", "}", "}", "}" ]
Recursively looks for discovered dependencies @param string $name of the instances to get @param array $visited the array where discovered instance definitions will be stored
[ "Recursively", "looks", "for", "discovered", "dependencies" ]
train
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Dumper.php#L149-L183
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.getFilter
public function getFilter() { $filter = []; $tag = $this->getRequest()->getVar("t"); if ($tag) { $filter["Tags.URLSegment"] = $tag; } $this->extend("updateFilter", $filter); return $filter; }
php
public function getFilter() { $filter = []; $tag = $this->getRequest()->getVar("t"); if ($tag) { $filter["Tags.URLSegment"] = $tag; } $this->extend("updateFilter", $filter); return $filter; }
[ "public", "function", "getFilter", "(", ")", "{", "$", "filter", "=", "[", "]", ";", "$", "tag", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getVar", "(", "\"t\"", ")", ";", "if", "(", "$", "tag", ")", "{", "$", "filter", "[", "\"Tags.URLSegment\"", "]", "=", "$", "tag", ";", "}", "$", "this", "->", "extend", "(", "\"updateFilter\"", ",", "$", "filter", ")", ";", "return", "$", "filter", ";", "}" ]
Find a filter from the URL that we can apply to the products list @return array
[ "Find", "a", "filter", "from", "the", "URL", "that", "we", "can", "apply", "to", "the", "products", "list" ]
train
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L31-L43
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.PaginatedProducts
public function PaginatedProducts($limit = 10) { $products = $this->SortedProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
php
public function PaginatedProducts($limit = 10) { $products = $this->SortedProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
[ "public", "function", "PaginatedProducts", "(", "$", "limit", "=", "10", ")", "{", "$", "products", "=", "$", "this", "->", "SortedProducts", "(", ")", ";", "$", "filter", "=", "$", "this", "->", "getFilter", "(", ")", ";", "if", "(", "count", "(", "$", "filter", ")", ")", "{", "$", "products", "=", "$", "products", "->", "filter", "(", "$", "filter", ")", ";", "}", "return", "PaginatedList", "::", "create", "(", "$", "products", ",", "$", "this", "->", "getRequest", "(", ")", ")", "->", "setPageLength", "(", "$", "limit", ")", ";", "}" ]
Get a paginated list of products contained in this category @return PaginatedList
[ "Get", "a", "paginated", "list", "of", "products", "contained", "in", "this", "category" ]
train
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L50-L63
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.PaginatedAllProducts
public function PaginatedAllProducts($limit = 10) { $products = $this->AllProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
php
public function PaginatedAllProducts($limit = 10) { $products = $this->AllProducts(); $filter = $this->getFilter(); if (count($filter)) { $products = $products->filter($filter); } return PaginatedList::create( $products, $this->getRequest() )->setPageLength($limit); }
[ "public", "function", "PaginatedAllProducts", "(", "$", "limit", "=", "10", ")", "{", "$", "products", "=", "$", "this", "->", "AllProducts", "(", ")", ";", "$", "filter", "=", "$", "this", "->", "getFilter", "(", ")", ";", "if", "(", "count", "(", "$", "filter", ")", ")", "{", "$", "products", "=", "$", "products", "->", "filter", "(", "$", "filter", ")", ";", "}", "return", "PaginatedList", "::", "create", "(", "$", "products", ",", "$", "this", "->", "getRequest", "(", ")", ")", "->", "setPageLength", "(", "$", "limit", ")", ";", "}" ]
Get a paginated list of all products at this level and below @return PaginatedList
[ "Get", "a", "paginated", "list", "of", "all", "products", "at", "this", "level", "and", "below" ]
train
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L71-L84
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.handleRequest
public function handleRequest(HTTPRequest $request) { /** @var SiteTree $child */ $child = null; $action = $request->param('Action'); // If nested URLs are enabled, and there is no action handler for the current request then attempt to pass // control to a child controller. This allows for the creation of chains of controllers which correspond to a // nested URL. if ($action && !$this->hasAction($action)) { // See ModelAdController->getNestedController() for similar logic if (class_exists('Translatable')) { Translatable::disable_locale_filter(); } // look for a child category with this URLSegment $child = CatalogueCategory::get()->filter([ 'ParentID' => $this->ID, 'URLSegment' => rawurlencode($action), 'Disabled' => 0 ])->first(); // Next check to see if the child os a product if (!$child) { $child = CatalogueProduct::get()->filter([ "Categories.ID" => $this->ID, "URLSegment" => rawurldecode($action), 'Disabled' => 0 ])->first(); } if (class_exists('Translatable')) { Translatable::enable_locale_filter(); } } // we found a page with this URLSegment. if ($child) { $request->shiftAllParams(); $request->shift(); $response = ModelAsController::controller_for_object($child)->handleRequest($request); } else { // If a specific locale is requested, and it doesn't match the page found by URLSegment, // look for a translation and redirect (see #5001). Only happens on the last child in // a potentially nested URL chain. if (class_exists('Translatable')) { $locale = $request->getVar('locale'); if ($locale && i18n::getData()->validate($locale) && $this->dataRecord && $this->dataRecord->Locale != $locale ) { $translation = $this->dataRecord->getTranslation($locale); if ($translation) { $response = new HTTPResponse(); $response->redirect($translation->Link(), 301); throw new HTTPResponse_Exception($response); } } } Director::set_current_page($this->data()); try { $response = parent::handleRequest($request); Director::set_current_page(null); } catch (HTTPResponse_Exception $e) { $this->popCurrent(); Director::set_current_page(null); throw $e; } } return $response; }
php
public function handleRequest(HTTPRequest $request) { /** @var SiteTree $child */ $child = null; $action = $request->param('Action'); // If nested URLs are enabled, and there is no action handler for the current request then attempt to pass // control to a child controller. This allows for the creation of chains of controllers which correspond to a // nested URL. if ($action && !$this->hasAction($action)) { // See ModelAdController->getNestedController() for similar logic if (class_exists('Translatable')) { Translatable::disable_locale_filter(); } // look for a child category with this URLSegment $child = CatalogueCategory::get()->filter([ 'ParentID' => $this->ID, 'URLSegment' => rawurlencode($action), 'Disabled' => 0 ])->first(); // Next check to see if the child os a product if (!$child) { $child = CatalogueProduct::get()->filter([ "Categories.ID" => $this->ID, "URLSegment" => rawurldecode($action), 'Disabled' => 0 ])->first(); } if (class_exists('Translatable')) { Translatable::enable_locale_filter(); } } // we found a page with this URLSegment. if ($child) { $request->shiftAllParams(); $request->shift(); $response = ModelAsController::controller_for_object($child)->handleRequest($request); } else { // If a specific locale is requested, and it doesn't match the page found by URLSegment, // look for a translation and redirect (see #5001). Only happens on the last child in // a potentially nested URL chain. if (class_exists('Translatable')) { $locale = $request->getVar('locale'); if ($locale && i18n::getData()->validate($locale) && $this->dataRecord && $this->dataRecord->Locale != $locale ) { $translation = $this->dataRecord->getTranslation($locale); if ($translation) { $response = new HTTPResponse(); $response->redirect($translation->Link(), 301); throw new HTTPResponse_Exception($response); } } } Director::set_current_page($this->data()); try { $response = parent::handleRequest($request); Director::set_current_page(null); } catch (HTTPResponse_Exception $e) { $this->popCurrent(); Director::set_current_page(null); throw $e; } } return $response; }
[ "public", "function", "handleRequest", "(", "HTTPRequest", "$", "request", ")", "{", "/** @var SiteTree $child */", "$", "child", "=", "null", ";", "$", "action", "=", "$", "request", "->", "param", "(", "'Action'", ")", ";", "// If nested URLs are enabled, and there is no action handler for the current request then attempt to pass", "// control to a child controller. This allows for the creation of chains of controllers which correspond to a", "// nested URL.", "if", "(", "$", "action", "&&", "!", "$", "this", "->", "hasAction", "(", "$", "action", ")", ")", "{", "// See ModelAdController->getNestedController() for similar logic", "if", "(", "class_exists", "(", "'Translatable'", ")", ")", "{", "Translatable", "::", "disable_locale_filter", "(", ")", ";", "}", "// look for a child category with this URLSegment", "$", "child", "=", "CatalogueCategory", "::", "get", "(", ")", "->", "filter", "(", "[", "'ParentID'", "=>", "$", "this", "->", "ID", ",", "'URLSegment'", "=>", "rawurlencode", "(", "$", "action", ")", ",", "'Disabled'", "=>", "0", "]", ")", "->", "first", "(", ")", ";", "// Next check to see if the child os a product", "if", "(", "!", "$", "child", ")", "{", "$", "child", "=", "CatalogueProduct", "::", "get", "(", ")", "->", "filter", "(", "[", "\"Categories.ID\"", "=>", "$", "this", "->", "ID", ",", "\"URLSegment\"", "=>", "rawurldecode", "(", "$", "action", ")", ",", "'Disabled'", "=>", "0", "]", ")", "->", "first", "(", ")", ";", "}", "if", "(", "class_exists", "(", "'Translatable'", ")", ")", "{", "Translatable", "::", "enable_locale_filter", "(", ")", ";", "}", "}", "// we found a page with this URLSegment.", "if", "(", "$", "child", ")", "{", "$", "request", "->", "shiftAllParams", "(", ")", ";", "$", "request", "->", "shift", "(", ")", ";", "$", "response", "=", "ModelAsController", "::", "controller_for_object", "(", "$", "child", ")", "->", "handleRequest", "(", "$", "request", ")", ";", "}", "else", "{", "// If a specific locale is requested, and it doesn't match the page found by URLSegment,", "// look for a translation and redirect (see #5001). Only happens on the last child in", "// a potentially nested URL chain.", "if", "(", "class_exists", "(", "'Translatable'", ")", ")", "{", "$", "locale", "=", "$", "request", "->", "getVar", "(", "'locale'", ")", ";", "if", "(", "$", "locale", "&&", "i18n", "::", "getData", "(", ")", "->", "validate", "(", "$", "locale", ")", "&&", "$", "this", "->", "dataRecord", "&&", "$", "this", "->", "dataRecord", "->", "Locale", "!=", "$", "locale", ")", "{", "$", "translation", "=", "$", "this", "->", "dataRecord", "->", "getTranslation", "(", "$", "locale", ")", ";", "if", "(", "$", "translation", ")", "{", "$", "response", "=", "new", "HTTPResponse", "(", ")", ";", "$", "response", "->", "redirect", "(", "$", "translation", "->", "Link", "(", ")", ",", "301", ")", ";", "throw", "new", "HTTPResponse_Exception", "(", "$", "response", ")", ";", "}", "}", "}", "Director", "::", "set_current_page", "(", "$", "this", "->", "data", "(", ")", ")", ";", "try", "{", "$", "response", "=", "parent", "::", "handleRequest", "(", "$", "request", ")", ";", "Director", "::", "set_current_page", "(", "null", ")", ";", "}", "catch", "(", "HTTPResponse_Exception", "$", "e", ")", "{", "$", "this", "->", "popCurrent", "(", ")", ";", "Director", "::", "set_current_page", "(", "null", ")", ";", "throw", "$", "e", ";", "}", "}", "return", "$", "response", ";", "}" ]
This acts the same as {@link Controller::handleRequest()}, but if an action cannot be found this will attempt to fall over to a child controller in order to provide functionality for nested URLs. @param HTTPRequest $request @return HTTPResponse @throws HTTPResponse_Exception
[ "This", "acts", "the", "same", "as", "{", "@link", "Controller", "::", "handleRequest", "()", "}", "but", "if", "an", "action", "cannot", "be", "found", "this", "will", "attempt", "to", "fall", "over", "to", "a", "child", "controller", "in", "order", "to", "provide", "functionality", "for", "nested", "URLs", "." ]
train
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L145-L222
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.getViewer
public function getViewer($action) { // Manually set templates should be dealt with by Controller::getViewer() if (isset($this->templates[$action]) && $this->templates[$action] || (isset($this->templates['index']) && $this->templates['index']) || $this->template ) { return parent::getViewer($action); } // Prepare action for template search if ($action == "index") { $action = ""; } else { $action = '_' . $action; } $templates = array_merge( // Find templates by dataRecord SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Now get templates for sitetree SSViewer::get_templates_by_class(Page::singleton(), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Next, we need to add templates for all controllers SSViewer::get_templates_by_class(static::class, $action, "SilverStripe\\Control\\Controller"), // Fail-over to the same for the "index" action SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"), SSViewer::get_templates_by_class(static::class, "", "SilverStripe\\Control\\Controller") ); return SSViewer::create($templates); }
php
public function getViewer($action) { // Manually set templates should be dealt with by Controller::getViewer() if (isset($this->templates[$action]) && $this->templates[$action] || (isset($this->templates['index']) && $this->templates['index']) || $this->template ) { return parent::getViewer($action); } // Prepare action for template search if ($action == "index") { $action = ""; } else { $action = '_' . $action; } $templates = array_merge( // Find templates by dataRecord SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Now get templates for sitetree SSViewer::get_templates_by_class(Page::singleton(), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Next, we need to add templates for all controllers SSViewer::get_templates_by_class(static::class, $action, "SilverStripe\\Control\\Controller"), // Fail-over to the same for the "index" action SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"), SSViewer::get_templates_by_class(static::class, "", "SilverStripe\\Control\\Controller") ); return SSViewer::create($templates); }
[ "public", "function", "getViewer", "(", "$", "action", ")", "{", "// Manually set templates should be dealt with by Controller::getViewer()", "if", "(", "isset", "(", "$", "this", "->", "templates", "[", "$", "action", "]", ")", "&&", "$", "this", "->", "templates", "[", "$", "action", "]", "||", "(", "isset", "(", "$", "this", "->", "templates", "[", "'index'", "]", ")", "&&", "$", "this", "->", "templates", "[", "'index'", "]", ")", "||", "$", "this", "->", "template", ")", "{", "return", "parent", "::", "getViewer", "(", "$", "action", ")", ";", "}", "// Prepare action for template search", "if", "(", "$", "action", "==", "\"index\"", ")", "{", "$", "action", "=", "\"\"", ";", "}", "else", "{", "$", "action", "=", "'_'", ".", "$", "action", ";", "}", "$", "templates", "=", "array_merge", "(", "// Find templates by dataRecord", "SSViewer", "::", "get_templates_by_class", "(", "get_class", "(", "$", "this", "->", "dataRecord", ")", ",", "$", "action", ",", "\"SilverStripe\\\\CMS\\\\Model\\\\SiteTree\"", ")", ",", "// Now get templates for sitetree", "SSViewer", "::", "get_templates_by_class", "(", "Page", "::", "singleton", "(", ")", ",", "$", "action", ",", "\"SilverStripe\\\\CMS\\\\Model\\\\SiteTree\"", ")", ",", "// Next, we need to add templates for all controllers", "SSViewer", "::", "get_templates_by_class", "(", "static", "::", "class", ",", "$", "action", ",", "\"SilverStripe\\\\Control\\\\Controller\"", ")", ",", "// Fail-over to the same for the \"index\" action", "SSViewer", "::", "get_templates_by_class", "(", "get_class", "(", "$", "this", "->", "dataRecord", ")", ",", "\"\"", ",", "\"SilverStripe\\\\CMS\\\\Model\\\\SiteTree\"", ")", ",", "SSViewer", "::", "get_templates_by_class", "(", "static", "::", "class", ",", "\"\"", ",", "\"SilverStripe\\\\Control\\\\Controller\"", ")", ")", ";", "return", "SSViewer", "::", "create", "(", "$", "templates", ")", ";", "}" ]
Overwrite default SSViewer call to get a custom template list @param $action string @return SSViewer
[ "Overwrite", "default", "SSViewer", "call", "to", "get", "a", "custom", "template", "list" ]
train
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L231-L261
silvercommerce/catalogue-frontend
src/control/CatalogueController.php
CatalogueController.CategoryMenu
public function CategoryMenu($level = 1) { if ($level == 1) { $result = CatalogueCategory::get()->filter(array( "ParentID" => 0 )); } else { $parent = $this->data(); $stack = array($parent); if ($parent) { while ($parent = $parent->Parent) { array_unshift($stack, $parent); } } if (isset($stack[$level-2])) { $result = $stack[$level-2]->Children(); } } $visible = array(); if (isset($result)) { foreach ($result as $item) { if ($item->canView()) { $visible[] = $item; } } } return new ArrayList($visible); }
php
public function CategoryMenu($level = 1) { if ($level == 1) { $result = CatalogueCategory::get()->filter(array( "ParentID" => 0 )); } else { $parent = $this->data(); $stack = array($parent); if ($parent) { while ($parent = $parent->Parent) { array_unshift($stack, $parent); } } if (isset($stack[$level-2])) { $result = $stack[$level-2]->Children(); } } $visible = array(); if (isset($result)) { foreach ($result as $item) { if ($item->canView()) { $visible[] = $item; } } } return new ArrayList($visible); }
[ "public", "function", "CategoryMenu", "(", "$", "level", "=", "1", ")", "{", "if", "(", "$", "level", "==", "1", ")", "{", "$", "result", "=", "CatalogueCategory", "::", "get", "(", ")", "->", "filter", "(", "array", "(", "\"ParentID\"", "=>", "0", ")", ")", ";", "}", "else", "{", "$", "parent", "=", "$", "this", "->", "data", "(", ")", ";", "$", "stack", "=", "array", "(", "$", "parent", ")", ";", "if", "(", "$", "parent", ")", "{", "while", "(", "$", "parent", "=", "$", "parent", "->", "Parent", ")", "{", "array_unshift", "(", "$", "stack", ",", "$", "parent", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "stack", "[", "$", "level", "-", "2", "]", ")", ")", "{", "$", "result", "=", "$", "stack", "[", "$", "level", "-", "2", "]", "->", "Children", "(", ")", ";", "}", "}", "$", "visible", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "result", ")", ")", "{", "foreach", "(", "$", "result", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "canView", "(", ")", ")", "{", "$", "visible", "[", "]", "=", "$", "item", ";", "}", "}", "}", "return", "new", "ArrayList", "(", "$", "visible", ")", ";", "}" ]
Returns a fixed navigation menu of the given level. @return SS_List
[ "Returns", "a", "fixed", "navigation", "menu", "of", "the", "given", "level", "." ]
train
https://github.com/silvercommerce/catalogue-frontend/blob/671f1e32bf6bc6eb193c6608ae904cd055540cc4/src/control/CatalogueController.php#L267-L299
nyeholt/silverstripe-external-content
code/forms/ExternalHtmlEditorField_Toolbar.php
ExternalHtmlEditorField_Toolbar.LinkForm
function LinkForm() { Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js"); Requirements::javascript(ExternalContentAdmin::$directory . "/javascript/external_tiny_mce_improvements.js"); $form = new Form( $this->controller, "{$this->name}/LinkForm", new FieldSet( new LiteralField('Heading', '<h2><img src="cms/images/closeicon.gif" alt="' . _t('HtmlEditorField.CLOSE', 'close').'" title="' . _t('HtmlEditorField.CLOSE', 'close') . '" />' . _t('HtmlEditorField.LINK', 'Link') . '</h2>'), new OptionsetField( 'LinkType', _t('HtmlEditorField.LINKTO', 'Link to'), array( 'internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('HtmlEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'), 'externalcontent' =>_t('HtmlEditorField.LINKEXTERNALCONTENT', 'External Content'), ) ), new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle'), new TextField('external', _t('HtmlEditorField.URL', 'URL'), 'http://'), new EmailField('email', _t('HtmlEditorField.EMAIL', 'Email address')), new TreeDropdownField('file', _t('HtmlEditorField.FILE', 'File'), 'File', 'Filename'), new ExternalTreeDropdownField('externalcontent', _t('ExternalHtmlEditorField.EXTERNAL_CONTENT', 'External Content'), 'ExternalContentSource', 'Link()'), new TextField('Anchor', _t('HtmlEditorField.ANCHORVALUE', 'Anchor')), new TextField('LinkText', _t('HtmlEditorField.LINKTEXT', 'Link text')), new TextField('Description', _t('HtmlEditorField.LINKDESCR', 'Link description')), new CheckboxField('TargetBlank', _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?')) ), new FieldSet( new FormAction('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link')), new FormAction('remove', _t('HtmlEditorField.BUTTONREMOVELINK', 'Remove link')) ) ); $form->loadDataFrom($this); return $form; }
php
function LinkForm() { Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js"); Requirements::javascript(ExternalContentAdmin::$directory . "/javascript/external_tiny_mce_improvements.js"); $form = new Form( $this->controller, "{$this->name}/LinkForm", new FieldSet( new LiteralField('Heading', '<h2><img src="cms/images/closeicon.gif" alt="' . _t('HtmlEditorField.CLOSE', 'close').'" title="' . _t('HtmlEditorField.CLOSE', 'close') . '" />' . _t('HtmlEditorField.LINK', 'Link') . '</h2>'), new OptionsetField( 'LinkType', _t('HtmlEditorField.LINKTO', 'Link to'), array( 'internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('HtmlEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'file' => _t('HtmlEditorField.LINKFILE', 'Download a file'), 'externalcontent' =>_t('HtmlEditorField.LINKEXTERNALCONTENT', 'External Content'), ) ), new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle'), new TextField('external', _t('HtmlEditorField.URL', 'URL'), 'http://'), new EmailField('email', _t('HtmlEditorField.EMAIL', 'Email address')), new TreeDropdownField('file', _t('HtmlEditorField.FILE', 'File'), 'File', 'Filename'), new ExternalTreeDropdownField('externalcontent', _t('ExternalHtmlEditorField.EXTERNAL_CONTENT', 'External Content'), 'ExternalContentSource', 'Link()'), new TextField('Anchor', _t('HtmlEditorField.ANCHORVALUE', 'Anchor')), new TextField('LinkText', _t('HtmlEditorField.LINKTEXT', 'Link text')), new TextField('Description', _t('HtmlEditorField.LINKDESCR', 'Link description')), new CheckboxField('TargetBlank', _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?')) ), new FieldSet( new FormAction('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link')), new FormAction('remove', _t('HtmlEditorField.BUTTONREMOVELINK', 'Remove link')) ) ); $form->loadDataFrom($this); return $form; }
[ "function", "LinkForm", "(", ")", "{", "Requirements", "::", "javascript", "(", "THIRDPARTY_DIR", ".", "\"/behaviour.js\"", ")", ";", "Requirements", "::", "javascript", "(", "ExternalContentAdmin", "::", "$", "directory", ".", "\"/javascript/external_tiny_mce_improvements.js\"", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", "->", "controller", ",", "\"{$this->name}/LinkForm\"", ",", "new", "FieldSet", "(", "new", "LiteralField", "(", "'Heading'", ",", "'<h2><img src=\"cms/images/closeicon.gif\" alt=\"'", ".", "_t", "(", "'HtmlEditorField.CLOSE'", ",", "'close'", ")", ".", "'\" title=\"'", ".", "_t", "(", "'HtmlEditorField.CLOSE'", ",", "'close'", ")", ".", "'\" />'", ".", "_t", "(", "'HtmlEditorField.LINK'", ",", "'Link'", ")", ".", "'</h2>'", ")", ",", "new", "OptionsetField", "(", "'LinkType'", ",", "_t", "(", "'HtmlEditorField.LINKTO'", ",", "'Link to'", ")", ",", "array", "(", "'internal'", "=>", "_t", "(", "'HtmlEditorField.LINKINTERNAL'", ",", "'Page on the site'", ")", ",", "'external'", "=>", "_t", "(", "'HtmlEditorField.LINKEXTERNAL'", ",", "'Another website'", ")", ",", "'anchor'", "=>", "_t", "(", "'HtmlEditorField.LINKANCHOR'", ",", "'Anchor on this page'", ")", ",", "'email'", "=>", "_t", "(", "'HtmlEditorField.LINKEMAIL'", ",", "'Email address'", ")", ",", "'file'", "=>", "_t", "(", "'HtmlEditorField.LINKFILE'", ",", "'Download a file'", ")", ",", "'externalcontent'", "=>", "_t", "(", "'HtmlEditorField.LINKEXTERNALCONTENT'", ",", "'External Content'", ")", ",", ")", ")", ",", "new", "TreeDropdownField", "(", "'internal'", ",", "_t", "(", "'HtmlEditorField.PAGE'", ",", "\"Page\"", ")", ",", "'SiteTree'", ",", "'ID'", ",", "'MenuTitle'", ")", ",", "new", "TextField", "(", "'external'", ",", "_t", "(", "'HtmlEditorField.URL'", ",", "'URL'", ")", ",", "'http://'", ")", ",", "new", "EmailField", "(", "'email'", ",", "_t", "(", "'HtmlEditorField.EMAIL'", ",", "'Email address'", ")", ")", ",", "new", "TreeDropdownField", "(", "'file'", ",", "_t", "(", "'HtmlEditorField.FILE'", ",", "'File'", ")", ",", "'File'", ",", "'Filename'", ")", ",", "new", "ExternalTreeDropdownField", "(", "'externalcontent'", ",", "_t", "(", "'ExternalHtmlEditorField.EXTERNAL_CONTENT'", ",", "'External Content'", ")", ",", "'ExternalContentSource'", ",", "'Link()'", ")", ",", "new", "TextField", "(", "'Anchor'", ",", "_t", "(", "'HtmlEditorField.ANCHORVALUE'", ",", "'Anchor'", ")", ")", ",", "new", "TextField", "(", "'LinkText'", ",", "_t", "(", "'HtmlEditorField.LINKTEXT'", ",", "'Link text'", ")", ")", ",", "new", "TextField", "(", "'Description'", ",", "_t", "(", "'HtmlEditorField.LINKDESCR'", ",", "'Link description'", ")", ")", ",", "new", "CheckboxField", "(", "'TargetBlank'", ",", "_t", "(", "'HtmlEditorField.LINKOPENNEWWIN'", ",", "'Open link in a new window?'", ")", ")", ")", ",", "new", "FieldSet", "(", "new", "FormAction", "(", "'insert'", ",", "_t", "(", "'HtmlEditorField.BUTTONINSERTLINK'", ",", "'Insert link'", ")", ")", ",", "new", "FormAction", "(", "'remove'", ",", "_t", "(", "'HtmlEditorField.BUTTONREMOVELINK'", ",", "'Remove link'", ")", ")", ")", ")", ";", "$", "form", "->", "loadDataFrom", "(", "$", "this", ")", ";", "return", "$", "form", ";", "}" ]
Return a {@link Form} instance allowing a user to add links in the TinyMCE content editor. @return Form
[ "Return", "a", "{", "@link", "Form", "}", "instance", "allowing", "a", "user", "to", "add", "links", "in", "the", "TinyMCE", "content", "editor", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/forms/ExternalHtmlEditorField_Toolbar.php#L26-L66
nyeholt/silverstripe-external-content
code/forms/ExternalHtmlEditorField_Toolbar.php
ExternalHtmlEditorField_Toolbar.ImageForm
function ImageForm() { Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js"); Requirements::javascript(EXTERNALCONTENT . "/javascript/external_tiny_mce_improvements.js"); Requirements::css('cms/css/TinyMCEImageEnhancement.css'); Requirements::javascript('cms/javascript/TinyMCEImageEnhancement.js'); Requirements::javascript(THIRDPARTY_DIR . '/SWFUpload/SWFUpload.js'); Requirements::javascript(CMS_DIR . '/javascript/Upload.js'); $form = new Form( $this->controller, "{$this->name}/ImageForm", new FieldSet( new LiteralField('Heading', '<h2><img src="cms/images/closeicon.gif" alt="' . _t('HtmlEditorField.CLOSE', 'close') . '" title="' . _t('HtmlEditorField.CLOSE', 'close') . '" />' . _t('HtmlEditorField.IMAGE', 'Image') . '</h2>'), new TreeDropdownField('FolderID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'), new LiteralField('AddFolderOrUpload', '<div style="clear:both;"></div><div id="AddFolderGroup" style="display: none"> <a style="" href="#" id="AddFolder" class="link">' . _t('HtmlEditorField.CREATEFOLDER','Create Folder') . '</a> <input style="display: none; margin-left: 2px; width: 94px;" id="NewFolderName" class="addFolder" type="text"> <a style="display: none;" href="#" id="FolderOk" class="link addFolder">' . _t('HtmlEditorField.OK','Ok') . '</a> <a style="display: none;" href="#" id="FolderCancel" class="link addFolder">' . _t('HtmlEditorField.FOLDERCANCEL','Cancel') . '</a> </div> <div id="PipeSeparator" style="display: none">|</div> <div id="UploadGroup" class="group" style="display: none; margin-top: 2px;"> <a href="#" id="UploadFiles" class="link">' . _t('HtmlEditorField.UPLOAD','Upload') . '</a> </div>' ), new TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')), new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'), new TextField('AltText', _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'), '', 80), new TextField('ImageTitle', _t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image')), new TextField('CaptionText', _t('HtmlEditorField.CAPTIONTEXT', 'Caption text')), new DropdownField( 'CSSClass', _t('HtmlEditorField.CSSCLASS', 'Alignment / style'), array( 'left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'), 'leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'), 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.'), 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.'), ) ), new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'), new TextField('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), 100), new TextField('Height', " x " . _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'), 100) ) ), new FieldSet( new FormAction('insertimage', _t('HtmlEditorField.BUTTONINSERTIMAGE', 'Insert image')) ) ); $form->disableSecurityToken(); $form->loadDataFrom($this); return $form; }
php
function ImageForm() { Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js"); Requirements::javascript(EXTERNALCONTENT . "/javascript/external_tiny_mce_improvements.js"); Requirements::css('cms/css/TinyMCEImageEnhancement.css'); Requirements::javascript('cms/javascript/TinyMCEImageEnhancement.js'); Requirements::javascript(THIRDPARTY_DIR . '/SWFUpload/SWFUpload.js'); Requirements::javascript(CMS_DIR . '/javascript/Upload.js'); $form = new Form( $this->controller, "{$this->name}/ImageForm", new FieldSet( new LiteralField('Heading', '<h2><img src="cms/images/closeicon.gif" alt="' . _t('HtmlEditorField.CLOSE', 'close') . '" title="' . _t('HtmlEditorField.CLOSE', 'close') . '" />' . _t('HtmlEditorField.IMAGE', 'Image') . '</h2>'), new TreeDropdownField('FolderID', _t('HtmlEditorField.FOLDER', 'Folder'), 'Folder'), new LiteralField('AddFolderOrUpload', '<div style="clear:both;"></div><div id="AddFolderGroup" style="display: none"> <a style="" href="#" id="AddFolder" class="link">' . _t('HtmlEditorField.CREATEFOLDER','Create Folder') . '</a> <input style="display: none; margin-left: 2px; width: 94px;" id="NewFolderName" class="addFolder" type="text"> <a style="display: none;" href="#" id="FolderOk" class="link addFolder">' . _t('HtmlEditorField.OK','Ok') . '</a> <a style="display: none;" href="#" id="FolderCancel" class="link addFolder">' . _t('HtmlEditorField.FOLDERCANCEL','Cancel') . '</a> </div> <div id="PipeSeparator" style="display: none">|</div> <div id="UploadGroup" class="group" style="display: none; margin-top: 2px;"> <a href="#" id="UploadFiles" class="link">' . _t('HtmlEditorField.UPLOAD','Upload') . '</a> </div>' ), new TextField('getimagesSearch', _t('HtmlEditorField.SEARCHFILENAME', 'Search by file name')), new ThumbnailStripField('FolderImages', 'FolderID', 'getimages'), new TextField('AltText', _t('HtmlEditorField.IMAGEALTTEXT', 'Alternative text (alt) - shown if image cannot be displayed'), '', 80), new TextField('ImageTitle', _t('HtmlEditorField.IMAGETITLE', 'Title text (tooltip) - for additional information about the image')), new TextField('CaptionText', _t('HtmlEditorField.CAPTIONTEXT', 'Caption text')), new DropdownField( 'CSSClass', _t('HtmlEditorField.CSSCLASS', 'Alignment / style'), array( 'left' => _t('HtmlEditorField.CSSCLASSLEFT', 'On the left, with text wrapping around.'), 'leftAlone' => _t('HtmlEditorField.CSSCLASSLEFTALONE', 'On the left, on its own.'), 'right' => _t('HtmlEditorField.CSSCLASSRIGHT', 'On the right, with text wrapping around.'), 'center' => _t('HtmlEditorField.CSSCLASSCENTER', 'Centered, on its own.'), ) ), new FieldGroup(_t('HtmlEditorField.IMAGEDIMENSIONS', 'Dimensions'), new TextField('Width', _t('HtmlEditorField.IMAGEWIDTHPX', 'Width'), 100), new TextField('Height', " x " . _t('HtmlEditorField.IMAGEHEIGHTPX', 'Height'), 100) ) ), new FieldSet( new FormAction('insertimage', _t('HtmlEditorField.BUTTONINSERTIMAGE', 'Insert image')) ) ); $form->disableSecurityToken(); $form->loadDataFrom($this); return $form; }
[ "function", "ImageForm", "(", ")", "{", "Requirements", "::", "javascript", "(", "THIRDPARTY_DIR", ".", "\"/behaviour.js\"", ")", ";", "Requirements", "::", "javascript", "(", "EXTERNALCONTENT", ".", "\"/javascript/external_tiny_mce_improvements.js\"", ")", ";", "Requirements", "::", "css", "(", "'cms/css/TinyMCEImageEnhancement.css'", ")", ";", "Requirements", "::", "javascript", "(", "'cms/javascript/TinyMCEImageEnhancement.js'", ")", ";", "Requirements", "::", "javascript", "(", "THIRDPARTY_DIR", ".", "'/SWFUpload/SWFUpload.js'", ")", ";", "Requirements", "::", "javascript", "(", "CMS_DIR", ".", "'/javascript/Upload.js'", ")", ";", "$", "form", "=", "new", "Form", "(", "$", "this", "->", "controller", ",", "\"{$this->name}/ImageForm\"", ",", "new", "FieldSet", "(", "new", "LiteralField", "(", "'Heading'", ",", "'<h2><img src=\"cms/images/closeicon.gif\" alt=\"'", ".", "_t", "(", "'HtmlEditorField.CLOSE'", ",", "'close'", ")", ".", "'\" title=\"'", ".", "_t", "(", "'HtmlEditorField.CLOSE'", ",", "'close'", ")", ".", "'\" />'", ".", "_t", "(", "'HtmlEditorField.IMAGE'", ",", "'Image'", ")", ".", "'</h2>'", ")", ",", "new", "TreeDropdownField", "(", "'FolderID'", ",", "_t", "(", "'HtmlEditorField.FOLDER'", ",", "'Folder'", ")", ",", "'Folder'", ")", ",", "new", "LiteralField", "(", "'AddFolderOrUpload'", ",", "'<div style=\"clear:both;\"></div><div id=\"AddFolderGroup\" style=\"display: none\">\n\t\t\t\t\t\t<a style=\"\" href=\"#\" id=\"AddFolder\" class=\"link\">'", ".", "_t", "(", "'HtmlEditorField.CREATEFOLDER'", ",", "'Create Folder'", ")", ".", "'</a>\n\t\t\t\t\t\t<input style=\"display: none; margin-left: 2px; width: 94px;\" id=\"NewFolderName\" class=\"addFolder\" type=\"text\">\n\t\t\t\t\t\t<a style=\"display: none;\" href=\"#\" id=\"FolderOk\" class=\"link addFolder\">'", ".", "_t", "(", "'HtmlEditorField.OK'", ",", "'Ok'", ")", ".", "'</a>\n\t\t\t\t\t\t<a style=\"display: none;\" href=\"#\" id=\"FolderCancel\" class=\"link addFolder\">'", ".", "_t", "(", "'HtmlEditorField.FOLDERCANCEL'", ",", "'Cancel'", ")", ".", "'</a>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div id=\"PipeSeparator\" style=\"display: none\">|</div>\n\t\t\t\t\t<div id=\"UploadGroup\" class=\"group\" style=\"display: none; margin-top: 2px;\">\n\t\t\t\t\t\t<a href=\"#\" id=\"UploadFiles\" class=\"link\">'", ".", "_t", "(", "'HtmlEditorField.UPLOAD'", ",", "'Upload'", ")", ".", "'</a>\n\t\t\t\t\t</div>'", ")", ",", "new", "TextField", "(", "'getimagesSearch'", ",", "_t", "(", "'HtmlEditorField.SEARCHFILENAME'", ",", "'Search by file name'", ")", ")", ",", "new", "ThumbnailStripField", "(", "'FolderImages'", ",", "'FolderID'", ",", "'getimages'", ")", ",", "new", "TextField", "(", "'AltText'", ",", "_t", "(", "'HtmlEditorField.IMAGEALTTEXT'", ",", "'Alternative text (alt) - shown if image cannot be displayed'", ")", ",", "''", ",", "80", ")", ",", "new", "TextField", "(", "'ImageTitle'", ",", "_t", "(", "'HtmlEditorField.IMAGETITLE'", ",", "'Title text (tooltip) - for additional information about the image'", ")", ")", ",", "new", "TextField", "(", "'CaptionText'", ",", "_t", "(", "'HtmlEditorField.CAPTIONTEXT'", ",", "'Caption text'", ")", ")", ",", "new", "DropdownField", "(", "'CSSClass'", ",", "_t", "(", "'HtmlEditorField.CSSCLASS'", ",", "'Alignment / style'", ")", ",", "array", "(", "'left'", "=>", "_t", "(", "'HtmlEditorField.CSSCLASSLEFT'", ",", "'On the left, with text wrapping around.'", ")", ",", "'leftAlone'", "=>", "_t", "(", "'HtmlEditorField.CSSCLASSLEFTALONE'", ",", "'On the left, on its own.'", ")", ",", "'right'", "=>", "_t", "(", "'HtmlEditorField.CSSCLASSRIGHT'", ",", "'On the right, with text wrapping around.'", ")", ",", "'center'", "=>", "_t", "(", "'HtmlEditorField.CSSCLASSCENTER'", ",", "'Centered, on its own.'", ")", ",", ")", ")", ",", "new", "FieldGroup", "(", "_t", "(", "'HtmlEditorField.IMAGEDIMENSIONS'", ",", "'Dimensions'", ")", ",", "new", "TextField", "(", "'Width'", ",", "_t", "(", "'HtmlEditorField.IMAGEWIDTHPX'", ",", "'Width'", ")", ",", "100", ")", ",", "new", "TextField", "(", "'Height'", ",", "\" x \"", ".", "_t", "(", "'HtmlEditorField.IMAGEHEIGHTPX'", ",", "'Height'", ")", ",", "100", ")", ")", ")", ",", "new", "FieldSet", "(", "new", "FormAction", "(", "'insertimage'", ",", "_t", "(", "'HtmlEditorField.BUTTONINSERTIMAGE'", ",", "'Insert image'", ")", ")", ")", ")", ";", "$", "form", "->", "disableSecurityToken", "(", ")", ";", "$", "form", "->", "loadDataFrom", "(", "$", "this", ")", ";", "return", "$", "form", ";", "}" ]
Return a {@link Form} instance allowing a user to add images to the TinyMCE content editor. @return Form
[ "Return", "a", "{", "@link", "Form", "}", "instance", "allowing", "a", "user", "to", "add", "images", "to", "the", "TinyMCE", "content", "editor", "." ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/forms/ExternalHtmlEditorField_Toolbar.php#L74-L129
zircote/AMQP
library/AMQP/Channel.php
Channel.doClose
protected function doClose() { $this->isOpen = false; unset($this->connection->channels[$this->channelId]); $this->channelId = $this->connection = null; }
php
protected function doClose() { $this->isOpen = false; unset($this->connection->channels[$this->channelId]); $this->channelId = $this->connection = null; }
[ "protected", "function", "doClose", "(", ")", "{", "$", "this", "->", "isOpen", "=", "false", ";", "unset", "(", "$", "this", "->", "connection", "->", "channels", "[", "$", "this", "->", "channelId", "]", ")", ";", "$", "this", "->", "channelId", "=", "$", "this", "->", "connection", "=", "null", ";", "}" ]
Tear down this object, after we've agreed to close with the server.
[ "Tear", "down", "this", "object", "after", "we", "ve", "agreed", "to", "close", "with", "the", "server", "." ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L108-L113
zircote/AMQP
library/AMQP/Channel.php
Channel.alert
protected function alert(\AMQP\Wire\Reader $args) { $replyCode = $args->readShort(); $replyText = $args->readShortstr(); $details = $args->readTable(); array_push($this->alerts, array($replyCode, $replyText, $details)); }
php
protected function alert(\AMQP\Wire\Reader $args) { $replyCode = $args->readShort(); $replyText = $args->readShortstr(); $details = $args->readTable(); array_push($this->alerts, array($replyCode, $replyText, $details)); }
[ "protected", "function", "alert", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "replyCode", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "replyText", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "details", "=", "$", "args", "->", "readTable", "(", ")", ";", "array_push", "(", "$", "this", "->", "alerts", ",", "array", "(", "$", "replyCode", ",", "$", "replyText", ",", "$", "details", ")", ")", ";", "}" ]
This method allows the server to send a non-fatal warning to the client. This is used for methods that are normally asynchronous and thus do not have confirmations, and for which the server may detect errors that need to be reported. Fatal errors are handled as channel or connection exceptions; non- fatal errors are sent through this method. @param \AMQP\Wire\Reader $args
[ "This", "method", "allows", "the", "server", "to", "send", "a", "non", "-", "fatal", "warning", "to", "the", "client", ".", "This", "is", "used", "for", "methods", "that", "are", "normally", "asynchronous", "and", "thus", "do", "not", "have", "confirmations", "and", "for", "which", "the", "server", "may", "detect", "errors", "that", "need", "to", "be", "reported", ".", "Fatal", "errors", "are", "handled", "as", "channel", "or", "connection", "exceptions", ";", "non", "-", "fatal", "errors", "are", "sent", "through", "this", "method", "." ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L125-L132
zircote/AMQP
library/AMQP/Channel.php
Channel.close
public function close($options = array()) { $default = array('reply_code' => 0, 'reply_text' => '', 'method_signature' => array(0,0)); $options = array_merge($default, $options); $args = $this->frameBuilder->channelClose($options); $this->sendMethodFrame(array(20, 40), $args); return $this->wait( array( "20,41" // Channel.close_ok ) ); }
php
public function close($options = array()) { $default = array('reply_code' => 0, 'reply_text' => '', 'method_signature' => array(0,0)); $options = array_merge($default, $options); $args = $this->frameBuilder->channelClose($options); $this->sendMethodFrame(array(20, 40), $args); return $this->wait( array( "20,41" // Channel.close_ok ) ); }
[ "public", "function", "close", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'reply_code'", "=>", "0", ",", "'reply_text'", "=>", "''", ",", "'method_signature'", "=>", "array", "(", "0", ",", "0", ")", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "channelClose", "(", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "20", ",", "40", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"20,41\"", "// Channel.close_ok", ")", ")", ";", "}" ]
@param array $options @return mixed|null close(array( 'reply_code' => 0, 'reply_text' => '', 'method_signature' => array(0,0)) )
[ "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L145-L157
zircote/AMQP
library/AMQP/Channel.php
Channel._close
protected function _close(\AMQP\Wire\Reader $args) { $replyCode = $args->readShort(); $replyText = $args->readShortstr(); $classId = $args->readShort(); $methodId = $args->readShort(); $this->sendMethodFrame(array(20, 41)); $this->doClose(); throw new ChannelException($replyCode, $replyText, array($classId, $methodId)); }
php
protected function _close(\AMQP\Wire\Reader $args) { $replyCode = $args->readShort(); $replyText = $args->readShortstr(); $classId = $args->readShort(); $methodId = $args->readShort(); $this->sendMethodFrame(array(20, 41)); $this->doClose(); throw new ChannelException($replyCode, $replyText, array($classId, $methodId)); }
[ "protected", "function", "_close", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "replyCode", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "replyText", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "classId", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "methodId", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "20", ",", "41", ")", ")", ";", "$", "this", "->", "doClose", "(", ")", ";", "throw", "new", "ChannelException", "(", "$", "replyCode", ",", "$", "replyText", ",", "array", "(", "$", "classId", ",", "$", "methodId", ")", ")", ";", "}" ]
@param \AMQP\Wire\Reader $args @throws \AMQP\Exception\ChannelException
[ "@param", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$args" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L164-L175
zircote/AMQP
library/AMQP/Channel.php
Channel.flow
public function flow($active) { $args = $this->frameBuilder->flow($active); $this->sendMethodFrame(array(20, 20), $args); return $this->wait( array( "20,21" //Channel.flowOk ) ); }
php
public function flow($active) { $args = $this->frameBuilder->flow($active); $this->sendMethodFrame(array(20, 20), $args); return $this->wait( array( "20,21" //Channel.flowOk ) ); }
[ "public", "function", "flow", "(", "$", "active", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "flow", "(", "$", "active", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "20", ",", "20", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"20,21\"", "//Channel.flowOk", ")", ")", ";", "}" ]
@param $active @return mixed|null
[ "@param", "$active" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L190-L199
zircote/AMQP
library/AMQP/Channel.php
Channel.xOpen
protected function xOpen($outOfBand = '') { if ($this->isOpen) { return null; } $args = $this->frameBuilder->xOpen($outOfBand); $this->sendMethodFrame(array(20, 10), $args); return $this->wait( array( "20,11" //Channel.openOk ) ); }
php
protected function xOpen($outOfBand = '') { if ($this->isOpen) { return null; } $args = $this->frameBuilder->xOpen($outOfBand); $this->sendMethodFrame(array(20, 10), $args); return $this->wait( array( "20,11" //Channel.openOk ) ); }
[ "protected", "function", "xOpen", "(", "$", "outOfBand", "=", "''", ")", "{", "if", "(", "$", "this", "->", "isOpen", ")", "{", "return", "null", ";", "}", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "xOpen", "(", "$", "outOfBand", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "20", ",", "10", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"20,11\"", "//Channel.openOk", ")", ")", ";", "}" ]
@param string $outOfBand @return mixed|null
[ "@param", "string", "$outOfBand" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L234-L247
zircote/AMQP
library/AMQP/Channel.php
Channel.accessRequest
public function accessRequest($realm, $options = array()) { $default = array('exclusive' => false, 'passive' => false, 'active' => false, 'write' => false, 'read' => false); $options = array_merge($default, $options); $args = $this->frameBuilder->accessRequest($realm, $options); $this->sendMethodFrame(array(30, 10), $args); return $this->wait( array( '30,11' //Channel.accessRequestOk ) ); }
php
public function accessRequest($realm, $options = array()) { $default = array('exclusive' => false, 'passive' => false, 'active' => false, 'write' => false, 'read' => false); $options = array_merge($default, $options); $args = $this->frameBuilder->accessRequest($realm, $options); $this->sendMethodFrame(array(30, 10), $args); return $this->wait( array( '30,11' //Channel.accessRequestOk ) ); }
[ "public", "function", "accessRequest", "(", "$", "realm", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'exclusive'", "=>", "false", ",", "'passive'", "=>", "false", ",", "'active'", "=>", "false", ",", "'write'", "=>", "false", ",", "'read'", "=>", "false", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "accessRequest", "(", "$", "realm", ",", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "30", ",", "10", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "'30,11'", "//Channel.accessRequestOk", ")", ")", ";", "}" ]
@param $realm @param array $options @return mixed|null accessRequest($realm, array( 'exclusive' => false, 'passive' => false, 'active' => false, 'write' => false, 'read' => false) )
[ "@param", "$realm", "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L274-L285
zircote/AMQP
library/AMQP/Channel.php
Channel.accessRequestOk
protected function accessRequestOk(\AMQP\Wire\Reader $args) { $this->defaultTicket = $args->readShort(); return $this->defaultTicket; }
php
protected function accessRequestOk(\AMQP\Wire\Reader $args) { $this->defaultTicket = $args->readShort(); return $this->defaultTicket; }
[ "protected", "function", "accessRequestOk", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "this", "->", "defaultTicket", "=", "$", "args", "->", "readShort", "(", ")", ";", "return", "$", "this", "->", "defaultTicket", ";", "}" ]
grant access to server resources @param \AMQP\Wire\Reader $args @return int
[ "grant", "access", "to", "server", "resources" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L294-L298
zircote/AMQP
library/AMQP/Channel.php
Channel.exchangeDeclare
public function exchangeDeclare($exchange, $type, $options = array()) { $defaultArgs = array('passive' => false, 'durable' => false, 'auto_delete' => true, 'internal' => false, 'no_wait' => false, 'arguments' => array(), 'ticket' => null); $options = array_merge($defaultArgs, $options); $options['arguments'] = $this->getArguments($options['arguments']); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->exchangeDeclare($exchange, $type, $options); $this->sendMethodFrame(array(40, 10), $args); if (!$options['no_wait']) { return $this->wait( array( "40,11" //Channel.exchangeDeclareOk ) ); } return null; }
php
public function exchangeDeclare($exchange, $type, $options = array()) { $defaultArgs = array('passive' => false, 'durable' => false, 'auto_delete' => true, 'internal' => false, 'no_wait' => false, 'arguments' => array(), 'ticket' => null); $options = array_merge($defaultArgs, $options); $options['arguments'] = $this->getArguments($options['arguments']); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->exchangeDeclare($exchange, $type, $options); $this->sendMethodFrame(array(40, 10), $args); if (!$options['no_wait']) { return $this->wait( array( "40,11" //Channel.exchangeDeclareOk ) ); } return null; }
[ "public", "function", "exchangeDeclare", "(", "$", "exchange", ",", "$", "type", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "defaultArgs", "=", "array", "(", "'passive'", "=>", "false", ",", "'durable'", "=>", "false", ",", "'auto_delete'", "=>", "true", ",", "'internal'", "=>", "false", ",", "'no_wait'", "=>", "false", ",", "'arguments'", "=>", "array", "(", ")", ",", "'ticket'", "=>", "null", ")", ";", "$", "options", "=", "array_merge", "(", "$", "defaultArgs", ",", "$", "options", ")", ";", "$", "options", "[", "'arguments'", "]", "=", "$", "this", "->", "getArguments", "(", "$", "options", "[", "'arguments'", "]", ")", ";", "$", "options", "[", "'ticket'", "]", "=", "$", "this", "->", "getTicket", "(", "$", "options", "[", "'ticket'", "]", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "exchangeDeclare", "(", "$", "exchange", ",", "$", "type", ",", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "40", ",", "10", ")", ",", "$", "args", ")", ";", "if", "(", "!", "$", "options", "[", "'no_wait'", "]", ")", "{", "return", "$", "this", "->", "wait", "(", "array", "(", "\"40,11\"", "//Channel.exchangeDeclareOk", ")", ")", ";", "}", "return", "null", ";", "}" ]
@param $exchange @param $type @param array $options @return mixed|null exchangeDeclare($exchange, $type, array( 'passive' => false, 'durable' => false, 'auto_delete' => true, 'internal' => false, 'no_wait' => false, 'arguments' => array(), 'ticket' => null) )
[ "@param", "$exchange", "@param", "$type", "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L318-L336
zircote/AMQP
library/AMQP/Channel.php
Channel.exchangeDelete
public function exchangeDelete($exchange, $options=array()) { $default = array('if_unused' => false, 'no_wait' => false, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->exchangeDelete($exchange, $options); $this->sendMethodFrame(array(40, 20), $args); if (!$options['no_wait']) { return $this->wait( array( "40,21" //Channel.exchangeDeleteOk ) ); } return null; }
php
public function exchangeDelete($exchange, $options=array()) { $default = array('if_unused' => false, 'no_wait' => false, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->exchangeDelete($exchange, $options); $this->sendMethodFrame(array(40, 20), $args); if (!$options['no_wait']) { return $this->wait( array( "40,21" //Channel.exchangeDeleteOk ) ); } return null; }
[ "public", "function", "exchangeDelete", "(", "$", "exchange", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'if_unused'", "=>", "false", ",", "'no_wait'", "=>", "false", ",", "'ticket'", "=>", "null", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "options", "[", "'ticket'", "]", "=", "$", "this", "->", "getTicket", "(", "$", "options", "[", "'ticket'", "]", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "exchangeDelete", "(", "$", "exchange", ",", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "40", ",", "20", ")", ",", "$", "args", ")", ";", "if", "(", "!", "$", "options", "[", "'no_wait'", "]", ")", "{", "return", "$", "this", "->", "wait", "(", "array", "(", "\"40,21\"", "//Channel.exchangeDeleteOk", ")", ")", ";", "}", "return", "null", ";", "}" ]
@param $exchange @param array $options @return mixed|null exchangeDelete($exchange, array( 'if_unused' => false, 'no_wait' => false, 'ticket' => null) );
[ "@param", "$exchange", "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L360-L376
zircote/AMQP
library/AMQP/Channel.php
Channel.queueBind
public function queueBind($queue, $exchange, $options=array()) { $default = array('routing_key' => '', 'no_wait' => false, 'arguments' => array(), 'ticket' => null); $options = array_merge($default, $options); $options['arguments'] = $this->getArguments($options['arguments']); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->queueBind($queue, $exchange, $options); $this->sendMethodFrame(array(50, 20), $args); if (!$options['no_wait']) { return $this->wait( array( "50,21" // Channel.queueBindOk ) ); } return null; }
php
public function queueBind($queue, $exchange, $options=array()) { $default = array('routing_key' => '', 'no_wait' => false, 'arguments' => array(), 'ticket' => null); $options = array_merge($default, $options); $options['arguments'] = $this->getArguments($options['arguments']); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->queueBind($queue, $exchange, $options); $this->sendMethodFrame(array(50, 20), $args); if (!$options['no_wait']) { return $this->wait( array( "50,21" // Channel.queueBindOk ) ); } return null; }
[ "public", "function", "queueBind", "(", "$", "queue", ",", "$", "exchange", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'routing_key'", "=>", "''", ",", "'no_wait'", "=>", "false", ",", "'arguments'", "=>", "array", "(", ")", ",", "'ticket'", "=>", "null", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "options", "[", "'arguments'", "]", "=", "$", "this", "->", "getArguments", "(", "$", "options", "[", "'arguments'", "]", ")", ";", "$", "options", "[", "'ticket'", "]", "=", "$", "this", "->", "getTicket", "(", "$", "options", "[", "'ticket'", "]", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "queueBind", "(", "$", "queue", ",", "$", "exchange", ",", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "50", ",", "20", ")", ",", "$", "args", ")", ";", "if", "(", "!", "$", "options", "[", "'no_wait'", "]", ")", "{", "return", "$", "this", "->", "wait", "(", "array", "(", "\"50,21\"", "// Channel.queueBindOk", ")", ")", ";", "}", "return", "null", ";", "}" ]
@param $queue @param $exchange @param array $options @return mixed|null queueBind($queue, $exchange, array( 'routing_key' => '', 'no_wait' => false, 'arguments' => array(), 'ticket' => null ) )
[ "@param", "$queue", "@param", "$exchange", "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L404-L423
zircote/AMQP
library/AMQP/Channel.php
Channel.queueDeclare
public function queueDeclare($options = array()) { $default = array('queue' => '', 'passive' => false, 'durable' => false, 'exclusive' => false, 'auto_delete' => true, 'no_wait' => false, 'arguments' => array(), 'ticket' => null); $options = array_merge($default, $options); $options['arguments'] = $this->getArguments($options['arguments']); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->queueDeclare($options); $this->sendMethodFrame(array(50, 10), $args); if (!$options['no_wait']) { return $this->wait( array( "50,11" // Channel.queueDeclareOk ) ); } return null; }
php
public function queueDeclare($options = array()) { $default = array('queue' => '', 'passive' => false, 'durable' => false, 'exclusive' => false, 'auto_delete' => true, 'no_wait' => false, 'arguments' => array(), 'ticket' => null); $options = array_merge($default, $options); $options['arguments'] = $this->getArguments($options['arguments']); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->queueDeclare($options); $this->sendMethodFrame(array(50, 10), $args); if (!$options['no_wait']) { return $this->wait( array( "50,11" // Channel.queueDeclareOk ) ); } return null; }
[ "public", "function", "queueDeclare", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'queue'", "=>", "''", ",", "'passive'", "=>", "false", ",", "'durable'", "=>", "false", ",", "'exclusive'", "=>", "false", ",", "'auto_delete'", "=>", "true", ",", "'no_wait'", "=>", "false", ",", "'arguments'", "=>", "array", "(", ")", ",", "'ticket'", "=>", "null", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "options", "[", "'arguments'", "]", "=", "$", "this", "->", "getArguments", "(", "$", "options", "[", "'arguments'", "]", ")", ";", "$", "options", "[", "'ticket'", "]", "=", "$", "this", "->", "getTicket", "(", "$", "options", "[", "'ticket'", "]", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "queueDeclare", "(", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "50", ",", "10", ")", ",", "$", "args", ")", ";", "if", "(", "!", "$", "options", "[", "'no_wait'", "]", ")", "{", "return", "$", "this", "->", "wait", "(", "array", "(", "\"50,11\"", "// Channel.queueDeclareOk", ")", ")", ";", "}", "return", "null", ";", "}" ]
@param array $options @return mixed|null queueDeclare(array( 'queue' => '', 'passive' => false, 'durable' => false, 'exclusive' => false, 'auto_delete' => true, 'no_wait' => false, 'arguments' => array(), 'ticket' => null ));
[ "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L487-L505
zircote/AMQP
library/AMQP/Channel.php
Channel.queueDeclareOk
protected function queueDeclareOk(\AMQP\Wire\Reader $args) { $queue = $args->readShortstr(); $messageCount = $args->readLong(); $consumerCount = $args->readLong(); return array($queue, $messageCount, $consumerCount); }
php
protected function queueDeclareOk(\AMQP\Wire\Reader $args) { $queue = $args->readShortstr(); $messageCount = $args->readLong(); $consumerCount = $args->readLong(); return array($queue, $messageCount, $consumerCount); }
[ "protected", "function", "queueDeclareOk", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "queue", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "messageCount", "=", "$", "args", "->", "readLong", "(", ")", ";", "$", "consumerCount", "=", "$", "args", "->", "readLong", "(", ")", ";", "return", "array", "(", "$", "queue", ",", "$", "messageCount", ",", "$", "consumerCount", ")", ";", "}" ]
confirms a queue definition @param \AMQP\Wire\Reader $args @return array
[ "confirms", "a", "queue", "definition" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L514-L521
zircote/AMQP
library/AMQP/Channel.php
Channel.queuePurge
public function queuePurge($options = array()) { $default = array('queue' => '', 'no_wait' => false, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->queuePurge($options); $this->sendMethodFrame(array(50, 30), $args); if (!$options['no_wait']) { return $this->wait( array( "50,31" //Channel.queuePurgeOk ) ); } return null; }
php
public function queuePurge($options = array()) { $default = array('queue' => '', 'no_wait' => false, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->queuePurge($options); $this->sendMethodFrame(array(50, 30), $args); if (!$options['no_wait']) { return $this->wait( array( "50,31" //Channel.queuePurgeOk ) ); } return null; }
[ "public", "function", "queuePurge", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'queue'", "=>", "''", ",", "'no_wait'", "=>", "false", ",", "'ticket'", "=>", "null", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "options", "[", "'ticket'", "]", "=", "$", "this", "->", "getTicket", "(", "$", "options", "[", "'ticket'", "]", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "queuePurge", "(", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "50", ",", "30", ")", ",", "$", "args", ")", ";", "if", "(", "!", "$", "options", "[", "'no_wait'", "]", ")", "{", "return", "$", "this", "->", "wait", "(", "array", "(", "\"50,31\"", "//Channel.queuePurgeOk", ")", ")", ";", "}", "return", "null", ";", "}" ]
@param array $options @return mixed|null queuePurge(array( 'queue' => '', 'no_wait' => false, 'ticket' => null) )
[ "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L579-L596
zircote/AMQP
library/AMQP/Channel.php
Channel.basicCancel
public function basicCancel($consumerTag, $nowait = false) { $args = $this->frameBuilder->basicCancel($consumerTag, $nowait); $this->sendMethodFrame(array(60, 30), $args); return $this->wait( array( "60,31" // Channel.basicCancelOk ) ); }
php
public function basicCancel($consumerTag, $nowait = false) { $args = $this->frameBuilder->basicCancel($consumerTag, $nowait); $this->sendMethodFrame(array(60, 30), $args); return $this->wait( array( "60,31" // Channel.basicCancelOk ) ); }
[ "public", "function", "basicCancel", "(", "$", "consumerTag", ",", "$", "nowait", "=", "false", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicCancel", "(", "$", "consumerTag", ",", "$", "nowait", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "30", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"60,31\"", "// Channel.basicCancelOk", ")", ")", ";", "}" ]
end a queue consumer @param $consumerTag @param bool $nowait @return mixed|null
[ "end", "a", "queue", "consumer" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L628-L637
zircote/AMQP
library/AMQP/Channel.php
Channel.basicConsume
public function basicConsume($options = array()) { $consumerTag = null; $default = array('queue' => '', 'consumer_tag' => '', 'no_local' => false, 'no_ack' => false, 'exclusive' => false, 'no_wait' => false, 'callback' => null, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->basicConsume($options); $this->sendMethodFrame(array(60, 20), $args); if (!$options['no_wait']) { $consumerTag = $this->wait( array( "60,21" //Channel.basicConsumeOk ) ); } $this->callbacks[$consumerTag] = $options['callback']; return $consumerTag; }
php
public function basicConsume($options = array()) { $consumerTag = null; $default = array('queue' => '', 'consumer_tag' => '', 'no_local' => false, 'no_ack' => false, 'exclusive' => false, 'no_wait' => false, 'callback' => null, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->basicConsume($options); $this->sendMethodFrame(array(60, 20), $args); if (!$options['no_wait']) { $consumerTag = $this->wait( array( "60,21" //Channel.basicConsumeOk ) ); } $this->callbacks[$consumerTag] = $options['callback']; return $consumerTag; }
[ "public", "function", "basicConsume", "(", "$", "options", "=", "array", "(", ")", ")", "{", "$", "consumerTag", "=", "null", ";", "$", "default", "=", "array", "(", "'queue'", "=>", "''", ",", "'consumer_tag'", "=>", "''", ",", "'no_local'", "=>", "false", ",", "'no_ack'", "=>", "false", ",", "'exclusive'", "=>", "false", ",", "'no_wait'", "=>", "false", ",", "'callback'", "=>", "null", ",", "'ticket'", "=>", "null", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "options", "[", "'ticket'", "]", "=", "$", "this", "->", "getTicket", "(", "$", "options", "[", "'ticket'", "]", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicConsume", "(", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "20", ")", ",", "$", "args", ")", ";", "if", "(", "!", "$", "options", "[", "'no_wait'", "]", ")", "{", "$", "consumerTag", "=", "$", "this", "->", "wait", "(", "array", "(", "\"60,21\"", "//Channel.basicConsumeOk", ")", ")", ";", "}", "$", "this", "->", "callbacks", "[", "$", "consumerTag", "]", "=", "$", "options", "[", "'callback'", "]", ";", "return", "$", "consumerTag", ";", "}" ]
@param array $options @return mixed|null basicConsume( array( 'queue' => '', 'consumer_tag' => '', 'no_local' => false, 'no_ack' => false, 'exclusive' => false, 'no_wait' => false, 'callback' => null, 'ticket' => null ) )
[ "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L666-L687
zircote/AMQP
library/AMQP/Channel.php
Channel.basicGetOk
protected function basicGetOk(\AMQP\Wire\Reader $args, \AMQP\Message $msg) { $deliveryTag = $args->readLonglong(); $redelivered = $args->readBit(); $exchange = $args->readShortstr(); $routingKey = $args->readShortstr(); $messageCount = $args->readLong(); $msg->delivery_info = array( "delivery_tag" => $deliveryTag, "redelivered" => $redelivered, "exchange" => $exchange, "routing_key" => $routingKey, "message_count" => $messageCount ); return $msg; }
php
protected function basicGetOk(\AMQP\Wire\Reader $args, \AMQP\Message $msg) { $deliveryTag = $args->readLonglong(); $redelivered = $args->readBit(); $exchange = $args->readShortstr(); $routingKey = $args->readShortstr(); $messageCount = $args->readLong(); $msg->delivery_info = array( "delivery_tag" => $deliveryTag, "redelivered" => $redelivered, "exchange" => $exchange, "routing_key" => $routingKey, "message_count" => $messageCount ); return $msg; }
[ "protected", "function", "basicGetOk", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ",", "\\", "AMQP", "\\", "Message", "$", "msg", ")", "{", "$", "deliveryTag", "=", "$", "args", "->", "readLonglong", "(", ")", ";", "$", "redelivered", "=", "$", "args", "->", "readBit", "(", ")", ";", "$", "exchange", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "routingKey", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "messageCount", "=", "$", "args", "->", "readLong", "(", ")", ";", "$", "msg", "->", "delivery_info", "=", "array", "(", "\"delivery_tag\"", "=>", "$", "deliveryTag", ",", "\"redelivered\"", "=>", "$", "redelivered", ",", "\"exchange\"", "=>", "$", "exchange", ",", "\"routing_key\"", "=>", "$", "routingKey", ",", "\"message_count\"", "=>", "$", "messageCount", ")", ";", "return", "$", "msg", ";", "}" ]
@param Wire\Reader $args @param Message $msg @return Message
[ "@param", "Wire", "\\", "Reader", "$args", "@param", "Message", "$msg" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L776-L792
zircote/AMQP
library/AMQP/Channel.php
Channel.basicPublish
public function basicPublish( \AMQP\Message $msg, $options = array()) { $default = array('exchange' => '', 'routing_key' => '', 'mandatory' => false, 'immediate' => false, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->basicPublish($options); $this->sendMethodFrame(array(60, 40), $args); $this->connection->sendContent( $this->channelId, 60, 0, strlen($msg->body), $msg->serializeProperties(), $msg->body ); }
php
public function basicPublish( \AMQP\Message $msg, $options = array()) { $default = array('exchange' => '', 'routing_key' => '', 'mandatory' => false, 'immediate' => false, 'ticket' => null); $options = array_merge($default, $options); $options['ticket'] = $this->getTicket($options['ticket']); $args = $this->frameBuilder->basicPublish($options); $this->sendMethodFrame(array(60, 40), $args); $this->connection->sendContent( $this->channelId, 60, 0, strlen($msg->body), $msg->serializeProperties(), $msg->body ); }
[ "public", "function", "basicPublish", "(", "\\", "AMQP", "\\", "Message", "$", "msg", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'exchange'", "=>", "''", ",", "'routing_key'", "=>", "''", ",", "'mandatory'", "=>", "false", ",", "'immediate'", "=>", "false", ",", "'ticket'", "=>", "null", ")", ";", "$", "options", "=", "array_merge", "(", "$", "default", ",", "$", "options", ")", ";", "$", "options", "[", "'ticket'", "]", "=", "$", "this", "->", "getTicket", "(", "$", "options", "[", "'ticket'", "]", ")", ";", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicPublish", "(", "$", "options", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "40", ")", ",", "$", "args", ")", ";", "$", "this", "->", "connection", "->", "sendContent", "(", "$", "this", "->", "channelId", ",", "60", ",", "0", ",", "strlen", "(", "$", "msg", "->", "body", ")", ",", "$", "msg", "->", "serializeProperties", "(", ")", ",", "$", "msg", "->", "body", ")", ";", "}" ]
@param Message $msg @param array $options basicPublish($msg, array( 'exchange' => '', 'routing_key' => '', 'mandatory' => false, 'immediate' => false, 'ticket' => null) )
[ "@param", "Message", "$msg", "@param", "array", "$options" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L807-L823
zircote/AMQP
library/AMQP/Channel.php
Channel.basicQos
public function basicQos($prefetchSize, $prefetchCount, $aGlobal) { $args = $this->frameBuilder->basicQos( $prefetchSize, $prefetchCount, $aGlobal ); $this->sendMethodFrame(array(60, 10), $args); return $this->wait( array( "60,11" //Channel.basicQosOk ) ); }
php
public function basicQos($prefetchSize, $prefetchCount, $aGlobal) { $args = $this->frameBuilder->basicQos( $prefetchSize, $prefetchCount, $aGlobal ); $this->sendMethodFrame(array(60, 10), $args); return $this->wait( array( "60,11" //Channel.basicQosOk ) ); }
[ "public", "function", "basicQos", "(", "$", "prefetchSize", ",", "$", "prefetchCount", ",", "$", "aGlobal", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicQos", "(", "$", "prefetchSize", ",", "$", "prefetchCount", ",", "$", "aGlobal", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "10", ")", ",", "$", "args", ")", ";", "return", "$", "this", "->", "wait", "(", "array", "(", "\"60,11\"", "//Channel.basicQosOk", ")", ")", ";", "}" ]
specify quality of service @param $prefetchSize @param $prefetchCount @param $aGlobal @return mixed|null
[ "specify", "quality", "of", "service" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L834-L845
zircote/AMQP
library/AMQP/Channel.php
Channel.basicRecover
public function basicRecover($reQueue = false) { $args = $this->frameBuilder->basicRecover($reQueue); $this->sendMethodFrame(array(60, 100), $args); }
php
public function basicRecover($reQueue = false) { $args = $this->frameBuilder->basicRecover($reQueue); $this->sendMethodFrame(array(60, 100), $args); }
[ "public", "function", "basicRecover", "(", "$", "reQueue", "=", "false", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicRecover", "(", "$", "reQueue", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "100", ")", ",", "$", "args", ")", ";", "}" ]
redeliver unacknowledged messages @param bool $reQueue
[ "redeliver", "unacknowledged", "messages" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L861-L865
zircote/AMQP
library/AMQP/Channel.php
Channel.basicReject
public function basicReject($deliveryTag, $reQueue) { $args = $this->frameBuilder->basicReject($deliveryTag, $reQueue); $this->sendMethodFrame(array(60, 90), $args); }
php
public function basicReject($deliveryTag, $reQueue) { $args = $this->frameBuilder->basicReject($deliveryTag, $reQueue); $this->sendMethodFrame(array(60, 90), $args); }
[ "public", "function", "basicReject", "(", "$", "deliveryTag", ",", "$", "reQueue", ")", "{", "$", "args", "=", "$", "this", "->", "frameBuilder", "->", "basicReject", "(", "$", "deliveryTag", ",", "$", "reQueue", ")", ";", "$", "this", "->", "sendMethodFrame", "(", "array", "(", "60", ",", "90", ")", ",", "$", "args", ")", ";", "}" ]
reject an incoming message @param $deliveryTag @param $reQueue
[ "reject", "an", "incoming", "message" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L873-L877
zircote/AMQP
library/AMQP/Channel.php
Channel.basicReturn
protected function basicReturn(\AMQP\Wire\Reader $args) { $reply_code = $args->readShort(); $reply_text = $args->readShortstr(); $exchange = $args->readShortstr(); $routing_key = $args->readShortstr(); $msg = $this->wait(); }
php
protected function basicReturn(\AMQP\Wire\Reader $args) { $reply_code = $args->readShort(); $reply_text = $args->readShortstr(); $exchange = $args->readShortstr(); $routing_key = $args->readShortstr(); $msg = $this->wait(); }
[ "protected", "function", "basicReturn", "(", "\\", "AMQP", "\\", "Wire", "\\", "Reader", "$", "args", ")", "{", "$", "reply_code", "=", "$", "args", "->", "readShort", "(", ")", ";", "$", "reply_text", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "exchange", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "routing_key", "=", "$", "args", "->", "readShortstr", "(", ")", ";", "$", "msg", "=", "$", "this", "->", "wait", "(", ")", ";", "}" ]
return a failed message @param \AMQP\Wire\Reader $args
[ "return", "a", "failed", "message" ]
train
https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Channel.php#L884-L891
shrink0r/workflux
src/Param/Output.php
Output.withCurrentState
public function withCurrentState(string $current_state): OutputInterface { $output = clone $this; $output->current_state = $current_state; return $output; }
php
public function withCurrentState(string $current_state): OutputInterface { $output = clone $this; $output->current_state = $current_state; return $output; }
[ "public", "function", "withCurrentState", "(", "string", "$", "current_state", ")", ":", "OutputInterface", "{", "$", "output", "=", "clone", "$", "this", ";", "$", "output", "->", "current_state", "=", "$", "current_state", ";", "return", "$", "output", ";", "}" ]
@param string $current_state @return OutputInterface
[ "@param", "string", "$current_state" ]
train
https://github.com/shrink0r/workflux/blob/008f45c64f52b1f795ab7f6ddbfc1a55580254d9/src/Param/Output.php#L41-L46
spiral-modules/scaffolder
source/Scaffolder/Commands/ControllerCommand.php
ControllerCommand.perform
public function perform() { /** @var ControllerDeclaration $declaration */ $declaration = $this->createDeclaration(); foreach ($this->option('action') as $action) { $declaration->addAction($action); } $this->writeDeclaration($declaration); }
php
public function perform() { /** @var ControllerDeclaration $declaration */ $declaration = $this->createDeclaration(); foreach ($this->option('action') as $action) { $declaration->addAction($action); } $this->writeDeclaration($declaration); }
[ "public", "function", "perform", "(", ")", "{", "/** @var ControllerDeclaration $declaration */", "$", "declaration", "=", "$", "this", "->", "createDeclaration", "(", ")", ";", "foreach", "(", "$", "this", "->", "option", "(", "'action'", ")", "as", "$", "action", ")", "{", "$", "declaration", "->", "addAction", "(", "$", "action", ")", ";", "}", "$", "this", "->", "writeDeclaration", "(", "$", "declaration", ")", ";", "}" ]
Create controller declaration.
[ "Create", "controller", "declaration", "." ]
train
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Commands/ControllerCommand.php#L35-L45
joseph-walker/vector
src/Lib/Lambda.php
Lambda.__flip
protected static function __flip($f) { return self::curry(function($a, $b) use ($f) { return $f($b, $a); }); }
php
protected static function __flip($f) { return self::curry(function($a, $b) use ($f) { return $f($b, $a); }); }
[ "protected", "static", "function", "__flip", "(", "$", "f", ")", "{", "return", "self", "::", "curry", "(", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "f", ")", "{", "return", "$", "f", "(", "$", "b", ",", "$", "a", ")", ";", "}", ")", ";", "}" ]
Flip Combinator Given a function that takes two arguments, return a new function that takes those two arguments with their order reversed. @example Math::subtract(2, 6); // 4 Lambda::flip(Math::subtract())(2, 6); // -4 @type (a -> b -> c) -> b -> a -> c @param \Closure $f Function to flip @return \Closure Flipped function
[ "Flip", "Combinator" ]
train
https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Lib/Lambda.php#L58-L63
barebone-php/barebone-core
lib/Router.php
Router.instance
public static function instance() { if (null === self::$_instance) { $routeCollector = new RouteCollector( new \FastRoute\RouteParser\Std, new \FastRoute\DataGenerator\GroupCountBased ); self::$_instance = $routeCollector; } return self::$_instance; }
php
public static function instance() { if (null === self::$_instance) { $routeCollector = new RouteCollector( new \FastRoute\RouteParser\Std, new \FastRoute\DataGenerator\GroupCountBased ); self::$_instance = $routeCollector; } return self::$_instance; }
[ "public", "static", "function", "instance", "(", ")", "{", "if", "(", "null", "===", "self", "::", "$", "_instance", ")", "{", "$", "routeCollector", "=", "new", "RouteCollector", "(", "new", "\\", "FastRoute", "\\", "RouteParser", "\\", "Std", ",", "new", "\\", "FastRoute", "\\", "DataGenerator", "\\", "GroupCountBased", ")", ";", "self", "::", "$", "_instance", "=", "$", "routeCollector", ";", "}", "return", "self", "::", "$", "_instance", ";", "}" ]
Instantiate Router or return $instance @return RouteCollector
[ "Instantiate", "Router", "or", "return", "$instance" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L50-L60
barebone-php/barebone-core
lib/Router.php
Router.dispatch
public static function dispatch() { $vars = []; $request = Request::createFromGlobals(); $dispatcher = new Dispatcher(static::instance()->getData()); $routeInfo = $dispatcher->dispatch( $request->getMethod(), $request->getUri()->getPath() ); $controller = "\\Barebone\\Controller"; $action = "index"; switch ($routeInfo[0]) { case Dispatcher::NOT_FOUND: $action = 'routerError'; $vars['error'] = static::ERR_NOT_FOUND; $vars['subject'] = $request->getUri()->getPath(); break; case Dispatcher::METHOD_NOT_ALLOWED: $action = 'routerError'; $vars['error'] = static::ERR_BAD_METHOD; $vars['subject'] = $routeInfo[1]; break; case Dispatcher::FOUND: $handler = $routeInfo[1]; $vars = $routeInfo[2]; if (!class_exists($handler[0])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_CONTROLLER; $vars['subject'] = $handler[0]; } elseif (!method_exists($handler[0], $handler[1])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_ACTION; $vars['subject'] = $handler[0] . '::' . $handler[1]; } else { $controller = $handler[0]; $action = $handler[1]; } break; } // Start with an empty response $response = new Response(); $request->setAction($action); // @var Controller $instance $instance = new $controller($request, $response); $instance->initController(); // Get Middleware stacks $before = $instance->getMiddlewareBefore(); $after = $instance->getMiddlewareAfter(); // Append the action call to the middleware stack $before[] = function (Request $request, Response $response, callable $next = null ) use ($instance, $action, $vars) { // assigned updated objects $instance->setRequest($request); $instance->setResponse($response); // get updated response from action $response = call_user_func_array([$instance, $action], $vars); // continue return $next($instance->getRequest(), $response); }; // Run the middleware stack and return the Response $middlewares = array_reverse(array_merge($before, $after)); $runner = \Sirius\Middleware\Runner::factory($middlewares); return $runner($request, $response); }
php
public static function dispatch() { $vars = []; $request = Request::createFromGlobals(); $dispatcher = new Dispatcher(static::instance()->getData()); $routeInfo = $dispatcher->dispatch( $request->getMethod(), $request->getUri()->getPath() ); $controller = "\\Barebone\\Controller"; $action = "index"; switch ($routeInfo[0]) { case Dispatcher::NOT_FOUND: $action = 'routerError'; $vars['error'] = static::ERR_NOT_FOUND; $vars['subject'] = $request->getUri()->getPath(); break; case Dispatcher::METHOD_NOT_ALLOWED: $action = 'routerError'; $vars['error'] = static::ERR_BAD_METHOD; $vars['subject'] = $routeInfo[1]; break; case Dispatcher::FOUND: $handler = $routeInfo[1]; $vars = $routeInfo[2]; if (!class_exists($handler[0])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_CONTROLLER; $vars['subject'] = $handler[0]; } elseif (!method_exists($handler[0], $handler[1])) { $action = 'routerError'; $vars['error'] = static::ERR_MISSING_ACTION; $vars['subject'] = $handler[0] . '::' . $handler[1]; } else { $controller = $handler[0]; $action = $handler[1]; } break; } // Start with an empty response $response = new Response(); $request->setAction($action); // @var Controller $instance $instance = new $controller($request, $response); $instance->initController(); // Get Middleware stacks $before = $instance->getMiddlewareBefore(); $after = $instance->getMiddlewareAfter(); // Append the action call to the middleware stack $before[] = function (Request $request, Response $response, callable $next = null ) use ($instance, $action, $vars) { // assigned updated objects $instance->setRequest($request); $instance->setResponse($response); // get updated response from action $response = call_user_func_array([$instance, $action], $vars); // continue return $next($instance->getRequest(), $response); }; // Run the middleware stack and return the Response $middlewares = array_reverse(array_merge($before, $after)); $runner = \Sirius\Middleware\Runner::factory($middlewares); return $runner($request, $response); }
[ "public", "static", "function", "dispatch", "(", ")", "{", "$", "vars", "=", "[", "]", ";", "$", "request", "=", "Request", "::", "createFromGlobals", "(", ")", ";", "$", "dispatcher", "=", "new", "Dispatcher", "(", "static", "::", "instance", "(", ")", "->", "getData", "(", ")", ")", ";", "$", "routeInfo", "=", "$", "dispatcher", "->", "dispatch", "(", "$", "request", "->", "getMethod", "(", ")", ",", "$", "request", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ")", ";", "$", "controller", "=", "\"\\\\Barebone\\\\Controller\"", ";", "$", "action", "=", "\"index\"", ";", "switch", "(", "$", "routeInfo", "[", "0", "]", ")", "{", "case", "Dispatcher", "::", "NOT_FOUND", ":", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_NOT_FOUND", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "request", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ";", "break", ";", "case", "Dispatcher", "::", "METHOD_NOT_ALLOWED", ":", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_BAD_METHOD", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "routeInfo", "[", "1", "]", ";", "break", ";", "case", "Dispatcher", "::", "FOUND", ":", "$", "handler", "=", "$", "routeInfo", "[", "1", "]", ";", "$", "vars", "=", "$", "routeInfo", "[", "2", "]", ";", "if", "(", "!", "class_exists", "(", "$", "handler", "[", "0", "]", ")", ")", "{", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_MISSING_CONTROLLER", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "handler", "[", "0", "]", ";", "}", "elseif", "(", "!", "method_exists", "(", "$", "handler", "[", "0", "]", ",", "$", "handler", "[", "1", "]", ")", ")", "{", "$", "action", "=", "'routerError'", ";", "$", "vars", "[", "'error'", "]", "=", "static", "::", "ERR_MISSING_ACTION", ";", "$", "vars", "[", "'subject'", "]", "=", "$", "handler", "[", "0", "]", ".", "'::'", ".", "$", "handler", "[", "1", "]", ";", "}", "else", "{", "$", "controller", "=", "$", "handler", "[", "0", "]", ";", "$", "action", "=", "$", "handler", "[", "1", "]", ";", "}", "break", ";", "}", "// Start with an empty response", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "request", "->", "setAction", "(", "$", "action", ")", ";", "// @var Controller $instance", "$", "instance", "=", "new", "$", "controller", "(", "$", "request", ",", "$", "response", ")", ";", "$", "instance", "->", "initController", "(", ")", ";", "// Get Middleware stacks", "$", "before", "=", "$", "instance", "->", "getMiddlewareBefore", "(", ")", ";", "$", "after", "=", "$", "instance", "->", "getMiddlewareAfter", "(", ")", ";", "// Append the action call to the middleware stack", "$", "before", "[", "]", "=", "function", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "callable", "$", "next", "=", "null", ")", "use", "(", "$", "instance", ",", "$", "action", ",", "$", "vars", ")", "{", "// assigned updated objects", "$", "instance", "->", "setRequest", "(", "$", "request", ")", ";", "$", "instance", "->", "setResponse", "(", "$", "response", ")", ";", "// get updated response from action", "$", "response", "=", "call_user_func_array", "(", "[", "$", "instance", ",", "$", "action", "]", ",", "$", "vars", ")", ";", "// continue", "return", "$", "next", "(", "$", "instance", "->", "getRequest", "(", ")", ",", "$", "response", ")", ";", "}", ";", "// Run the middleware stack and return the Response", "$", "middlewares", "=", "array_reverse", "(", "array_merge", "(", "$", "before", ",", "$", "after", ")", ")", ";", "$", "runner", "=", "\\", "Sirius", "\\", "Middleware", "\\", "Runner", "::", "factory", "(", "$", "middlewares", ")", ";", "return", "$", "runner", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Start router and parse incoming requests @return \Zend\Diactoros\Response
[ "Start", "router", "and", "parse", "incoming", "requests" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L67-L147
barebone-php/barebone-core
lib/Router.php
Router.callback
protected static function callback($callback) { if (is_string($callback)) { // default format is "ControllerClassName:action" if (strpos($callback, ':')) { // automatically prefix namespace on callbacks not starting with '\' if ($callback{0} !== '\\') { $callback = "\\App\\Controller\\{$callback}"; } $callback = explode(':', $callback); } else { // default to "index" method in "whatever is callback class" $callback = [$callback, 'index']; } } if (!is_array($callback)) { throw new \LogicException( "A route callback could not be understood." ."Couldn't resolve to [class,action] array." ); } return $callback; }
php
protected static function callback($callback) { if (is_string($callback)) { // default format is "ControllerClassName:action" if (strpos($callback, ':')) { // automatically prefix namespace on callbacks not starting with '\' if ($callback{0} !== '\\') { $callback = "\\App\\Controller\\{$callback}"; } $callback = explode(':', $callback); } else { // default to "index" method in "whatever is callback class" $callback = [$callback, 'index']; } } if (!is_array($callback)) { throw new \LogicException( "A route callback could not be understood." ."Couldn't resolve to [class,action] array." ); } return $callback; }
[ "protected", "static", "function", "callback", "(", "$", "callback", ")", "{", "if", "(", "is_string", "(", "$", "callback", ")", ")", "{", "// default format is \"ControllerClassName:action\"", "if", "(", "strpos", "(", "$", "callback", ",", "':'", ")", ")", "{", "// automatically prefix namespace on callbacks not starting with '\\'", "if", "(", "$", "callback", "{", "0", "}", "!==", "'\\\\'", ")", "{", "$", "callback", "=", "\"\\\\App\\\\Controller\\\\{$callback}\"", ";", "}", "$", "callback", "=", "explode", "(", "':'", ",", "$", "callback", ")", ";", "}", "else", "{", "// default to \"index\" method in \"whatever is callback class\"", "$", "callback", "=", "[", "$", "callback", ",", "'index'", "]", ";", "}", "}", "if", "(", "!", "is_array", "(", "$", "callback", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"A route callback could not be understood.\"", ".", "\"Couldn't resolve to [class,action] array.\"", ")", ";", "}", "return", "$", "callback", ";", "}" ]
We assume to receive a string with namespace prefix (starting with backslash). If the initial backslash is missing, we prefix \App\Controller namespace to allow for shorter controller callbacks. @param mixed $callback "MyController:method" or array(class,method) @throws \LogicException @return array
[ "We", "assume", "to", "receive", "a", "string", "with", "namespace", "prefix", "(", "starting", "with", "backslash", ")", "." ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L160-L182
barebone-php/barebone-core
lib/Router.php
Router.get
public static function get($path, $callback) { self::instance()->addRoute('GET', $path, self::callback($callback)); }
php
public static function get($path, $callback) { self::instance()->addRoute('GET', $path, self::callback($callback)); }
[ "public", "static", "function", "get", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'GET'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle GET HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "GET", "HTTP", "requests" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L192-L195
barebone-php/barebone-core
lib/Router.php
Router.post
public static function post($path, $callback) { self::instance()->addRoute('POST', $path, self::callback($callback)); }
php
public static function post($path, $callback) { self::instance()->addRoute('POST', $path, self::callback($callback)); }
[ "public", "static", "function", "post", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'POST'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle POST HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "POST", "HTTP", "requests" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L205-L208
barebone-php/barebone-core
lib/Router.php
Router.put
public static function put($path, $callback) { self::instance()->addRoute('PUT', $path, self::callback($callback)); }
php
public static function put($path, $callback) { self::instance()->addRoute('PUT', $path, self::callback($callback)); }
[ "public", "static", "function", "put", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'PUT'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle PUT HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "PUT", "HTTP", "requests" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L218-L221
barebone-php/barebone-core
lib/Router.php
Router.delete
public static function delete($path, $callback) { self::instance()->addRoute('DELETE', $path, self::callback($callback)); }
php
public static function delete($path, $callback) { self::instance()->addRoute('DELETE', $path, self::callback($callback)); }
[ "public", "static", "function", "delete", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'DELETE'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle DELETE HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "DELETE", "HTTP", "requests" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L231-L234
barebone-php/barebone-core
lib/Router.php
Router.patch
public static function patch($path, $callback) { self::instance()->addRoute('PATCH', $path, self::callback($callback)); }
php
public static function patch($path, $callback) { self::instance()->addRoute('PATCH', $path, self::callback($callback)); }
[ "public", "static", "function", "patch", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'PATCH'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle PATCH HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "PATCH", "HTTP", "requests" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L244-L247
barebone-php/barebone-core
lib/Router.php
Router.options
public static function options($path, $callback) { self::instance()->addRoute('OPTIONS', $path, self::callback($callback)); }
php
public static function options($path, $callback) { self::instance()->addRoute('OPTIONS', $path, self::callback($callback)); }
[ "public", "static", "function", "options", "(", "$", "path", ",", "$", "callback", ")", "{", "self", "::", "instance", "(", ")", "->", "addRoute", "(", "'OPTIONS'", ",", "$", "path", ",", "self", "::", "callback", "(", "$", "callback", ")", ")", ";", "}" ]
Handle OPTIONS HTTP requests @param string $path URL segments and placeholders @param mixed $callback "MyController:method" or array(class,method) @return void
[ "Handle", "OPTIONS", "HTTP", "requests" ]
train
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Router.php#L257-L260