id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
230,600
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.addView
public function addView($viewer_guid = 0) { if ($viewer_guid == 0) { $viewer_guid = elgg_get_logged_in_user_guid(); } if ($viewer_guid != $this->owner_guid && tp_is_person()) { create_annotation($this->getGUID(), "tp_view", "1", "integer", $viewer_guid, ACCESS_PUBLIC); } }
php
public function addView($viewer_guid = 0) { if ($viewer_guid == 0) { $viewer_guid = elgg_get_logged_in_user_guid(); } if ($viewer_guid != $this->owner_guid && tp_is_person()) { create_annotation($this->getGUID(), "tp_view", "1", "integer", $viewer_guid, ACCESS_PUBLIC); } }
[ "public", "function", "addView", "(", "$", "viewer_guid", "=", "0", ")", "{", "if", "(", "$", "viewer_guid", "==", "0", ")", "{", "$", "viewer_guid", "=", "elgg_get_logged_in_user_guid", "(", ")", ";", "}", "if", "(", "$", "viewer_guid", "!=", "$", "this", "->", "owner_guid", "&&", "tp_is_person", "(", ")", ")", "{", "create_annotation", "(", "$", "this", "->", "getGUID", "(", ")", ",", "\"tp_view\"", ",", "\"1\"", ",", "\"integer\"", ",", "$", "viewer_guid", ",", "ACCESS_PUBLIC", ")", ";", "}", "}" ]
Add a view to this image @param $viewer_guid @return void
[ "Add", "a", "view", "to", "this", "image" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L194-L202
230,601
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.setOriginalFilename
protected function setOriginalFilename($originalName) { $prefix = "image/" . $this->container_guid . "/"; $filestorename = elgg_strtolower(time() . $originalName); $this->setFilename($prefix . $filestorename); $this->originalfilename = $originalName; }
php
protected function setOriginalFilename($originalName) { $prefix = "image/" . $this->container_guid . "/"; $filestorename = elgg_strtolower(time() . $originalName); $this->setFilename($prefix . $filestorename); $this->originalfilename = $originalName; }
[ "protected", "function", "setOriginalFilename", "(", "$", "originalName", ")", "{", "$", "prefix", "=", "\"image/\"", ".", "$", "this", "->", "container_guid", ".", "\"/\"", ";", "$", "filestorename", "=", "elgg_strtolower", "(", "time", "(", ")", ".", "$", "originalName", ")", ";", "$", "this", "->", "setFilename", "(", "$", "prefix", ".", "$", "filestorename", ")", ";", "$", "this", "->", "originalfilename", "=", "$", "originalName", ";", "}" ]
Set the internal filenames
[ "Set", "the", "internal", "filenames" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L208-L213
230,602
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.saveImageFile
protected function saveImageFile($data) { $this->checkUploadErrors($data); $this->OrientationCorrection($data); // we need to make sure the directory for the album exists // @note for group albums, the photos are distributed among the users $dir = tp_get_img_dir($this->getContainerGUID()); if (!file_exists($dir)) { mkdir($dir, 0755, true); } // move the uploaded file into album directory $this->setOriginalFilename($data['name']); $filename = $this->getFilenameOnFilestore(); $result = move_uploaded_file($data['tmp_name'], $filename); if (!$result) { return false; } $owner = $this->getOwnerEntity(); $owner->image_repo_size = (int)$owner->image_repo_size + $this->getSize(); return true; }
php
protected function saveImageFile($data) { $this->checkUploadErrors($data); $this->OrientationCorrection($data); // we need to make sure the directory for the album exists // @note for group albums, the photos are distributed among the users $dir = tp_get_img_dir($this->getContainerGUID()); if (!file_exists($dir)) { mkdir($dir, 0755, true); } // move the uploaded file into album directory $this->setOriginalFilename($data['name']); $filename = $this->getFilenameOnFilestore(); $result = move_uploaded_file($data['tmp_name'], $filename); if (!$result) { return false; } $owner = $this->getOwnerEntity(); $owner->image_repo_size = (int)$owner->image_repo_size + $this->getSize(); return true; }
[ "protected", "function", "saveImageFile", "(", "$", "data", ")", "{", "$", "this", "->", "checkUploadErrors", "(", "$", "data", ")", ";", "$", "this", "->", "OrientationCorrection", "(", "$", "data", ")", ";", "// we need to make sure the directory for the album exists", "// @note for group albums, the photos are distributed among the users", "$", "dir", "=", "tp_get_img_dir", "(", "$", "this", "->", "getContainerGUID", "(", ")", ")", ";", "if", "(", "!", "file_exists", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0755", ",", "true", ")", ";", "}", "// move the uploaded file into album directory", "$", "this", "->", "setOriginalFilename", "(", "$", "data", "[", "'name'", "]", ")", ";", "$", "filename", "=", "$", "this", "->", "getFilenameOnFilestore", "(", ")", ";", "$", "result", "=", "move_uploaded_file", "(", "$", "data", "[", "'tmp_name'", "]", ",", "$", "filename", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "false", ";", "}", "$", "owner", "=", "$", "this", "->", "getOwnerEntity", "(", ")", ";", "$", "owner", "->", "image_repo_size", "=", "(", "int", ")", "$", "owner", "->", "image_repo_size", "+", "$", "this", "->", "getSize", "(", ")", ";", "return", "true", ";", "}" ]
Save the uploaded image @param array $data
[ "Save", "the", "uploaded", "image" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L404-L428
230,603
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.checkUploadErrors
protected function checkUploadErrors($data) { // check for upload errors if ($data['error']) { if ($data['error'] == 1) { trigger_error('Tidypics warning: image exceeded server php upload limit', E_USER_WARNING); throw new Exception(elgg_echo('tidypics:image_mem')); } else { throw new Exception(elgg_echo('tidypics:unk_error')); } } // must be an image if (!tp_upload_check_format($data['type'])) { throw new Exception(elgg_echo('tidypics:not_image')); } // make sure file does not exceed memory limit if (!tp_upload_check_max_size($data['size'])) { throw new Exception(elgg_echo('tidypics:image_mem')); } // make sure the in memory image size does not exceed memory available $imginfo = getimagesize($data['tmp_name']); $requiredMemory1 = ceil($imginfo[0] * $imginfo[1] * 5.35); $requiredMemory2 = ceil($imginfo[0] * $imginfo[1] * ($imginfo['bits'] / 8) * $imginfo['channels'] * 2.5); $requiredMemory = (int)max($requiredMemory1, $requiredMemory2); $image_lib = elgg_get_plugin_setting('image_lib', 'tidypics'); if (!tp_upload_memory_check($image_lib, $requiredMemory)) { trigger_error('Tidypics warning: image memory size too large for resizing so rejecting', E_USER_WARNING); throw new Exception(elgg_echo('tidypics:image_pixels')); } // make sure file fits quota if (!tp_upload_check_quota($data['size'], elgg_get_logged_in_user_guid())) { throw new Exception(elgg_echo('tidypics:cannot_upload_exceeds_quota')); } }
php
protected function checkUploadErrors($data) { // check for upload errors if ($data['error']) { if ($data['error'] == 1) { trigger_error('Tidypics warning: image exceeded server php upload limit', E_USER_WARNING); throw new Exception(elgg_echo('tidypics:image_mem')); } else { throw new Exception(elgg_echo('tidypics:unk_error')); } } // must be an image if (!tp_upload_check_format($data['type'])) { throw new Exception(elgg_echo('tidypics:not_image')); } // make sure file does not exceed memory limit if (!tp_upload_check_max_size($data['size'])) { throw new Exception(elgg_echo('tidypics:image_mem')); } // make sure the in memory image size does not exceed memory available $imginfo = getimagesize($data['tmp_name']); $requiredMemory1 = ceil($imginfo[0] * $imginfo[1] * 5.35); $requiredMemory2 = ceil($imginfo[0] * $imginfo[1] * ($imginfo['bits'] / 8) * $imginfo['channels'] * 2.5); $requiredMemory = (int)max($requiredMemory1, $requiredMemory2); $image_lib = elgg_get_plugin_setting('image_lib', 'tidypics'); if (!tp_upload_memory_check($image_lib, $requiredMemory)) { trigger_error('Tidypics warning: image memory size too large for resizing so rejecting', E_USER_WARNING); throw new Exception(elgg_echo('tidypics:image_pixels')); } // make sure file fits quota if (!tp_upload_check_quota($data['size'], elgg_get_logged_in_user_guid())) { throw new Exception(elgg_echo('tidypics:cannot_upload_exceeds_quota')); } }
[ "protected", "function", "checkUploadErrors", "(", "$", "data", ")", "{", "// check for upload errors", "if", "(", "$", "data", "[", "'error'", "]", ")", "{", "if", "(", "$", "data", "[", "'error'", "]", "==", "1", ")", "{", "trigger_error", "(", "'Tidypics warning: image exceeded server php upload limit'", ",", "E_USER_WARNING", ")", ";", "throw", "new", "Exception", "(", "elgg_echo", "(", "'tidypics:image_mem'", ")", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "elgg_echo", "(", "'tidypics:unk_error'", ")", ")", ";", "}", "}", "// must be an image", "if", "(", "!", "tp_upload_check_format", "(", "$", "data", "[", "'type'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "elgg_echo", "(", "'tidypics:not_image'", ")", ")", ";", "}", "// make sure file does not exceed memory limit", "if", "(", "!", "tp_upload_check_max_size", "(", "$", "data", "[", "'size'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "elgg_echo", "(", "'tidypics:image_mem'", ")", ")", ";", "}", "// make sure the in memory image size does not exceed memory available", "$", "imginfo", "=", "getimagesize", "(", "$", "data", "[", "'tmp_name'", "]", ")", ";", "$", "requiredMemory1", "=", "ceil", "(", "$", "imginfo", "[", "0", "]", "*", "$", "imginfo", "[", "1", "]", "*", "5.35", ")", ";", "$", "requiredMemory2", "=", "ceil", "(", "$", "imginfo", "[", "0", "]", "*", "$", "imginfo", "[", "1", "]", "*", "(", "$", "imginfo", "[", "'bits'", "]", "/", "8", ")", "*", "$", "imginfo", "[", "'channels'", "]", "*", "2.5", ")", ";", "$", "requiredMemory", "=", "(", "int", ")", "max", "(", "$", "requiredMemory1", ",", "$", "requiredMemory2", ")", ";", "$", "image_lib", "=", "elgg_get_plugin_setting", "(", "'image_lib'", ",", "'tidypics'", ")", ";", "if", "(", "!", "tp_upload_memory_check", "(", "$", "image_lib", ",", "$", "requiredMemory", ")", ")", "{", "trigger_error", "(", "'Tidypics warning: image memory size too large for resizing so rejecting'", ",", "E_USER_WARNING", ")", ";", "throw", "new", "Exception", "(", "elgg_echo", "(", "'tidypics:image_pixels'", ")", ")", ";", "}", "// make sure file fits quota", "if", "(", "!", "tp_upload_check_quota", "(", "$", "data", "[", "'size'", "]", ",", "elgg_get_logged_in_user_guid", "(", ")", ")", ")", "{", "throw", "new", "Exception", "(", "elgg_echo", "(", "'tidypics:cannot_upload_exceeds_quota'", ")", ")", ";", "}", "}" ]
Need to restore sanity to this function @param type $data
[ "Need", "to", "restore", "sanity", "to", "this", "function" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L434-L470
230,604
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.saveThumbnails
protected function saveThumbnails() { $imageLib = elgg_get_plugin_setting('image_lib', 'tidypics'); $prefix = "image/" . $this->container_guid . "/"; $filename = $this->getFilename(); $filename = substr($filename, strrpos($filename, '/') + 1); if ($imageLib == 'ImageMagick') { // ImageMagick command line if (tp_create_im_cmdline_thumbnails($this, $prefix, $filename) != true) { trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); } } else if ($imageLib == 'ImageMagickPHP') { // imagick php extension if (tp_create_imagick_thumbnails($this, $prefix, $filename) != true) { trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); } } else { if (tp_create_gd_thumbnails($this, $prefix, $filename) != true) { trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); } } }
php
protected function saveThumbnails() { $imageLib = elgg_get_plugin_setting('image_lib', 'tidypics'); $prefix = "image/" . $this->container_guid . "/"; $filename = $this->getFilename(); $filename = substr($filename, strrpos($filename, '/') + 1); if ($imageLib == 'ImageMagick') { // ImageMagick command line if (tp_create_im_cmdline_thumbnails($this, $prefix, $filename) != true) { trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); } } else if ($imageLib == 'ImageMagickPHP') { // imagick php extension if (tp_create_imagick_thumbnails($this, $prefix, $filename) != true) { trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); } } else { if (tp_create_gd_thumbnails($this, $prefix, $filename) != true) { trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); } } }
[ "protected", "function", "saveThumbnails", "(", ")", "{", "$", "imageLib", "=", "elgg_get_plugin_setting", "(", "'image_lib'", ",", "'tidypics'", ")", ";", "$", "prefix", "=", "\"image/\"", ".", "$", "this", "->", "container_guid", ".", "\"/\"", ";", "$", "filename", "=", "$", "this", "->", "getFilename", "(", ")", ";", "$", "filename", "=", "substr", "(", "$", "filename", ",", "strrpos", "(", "$", "filename", ",", "'/'", ")", "+", "1", ")", ";", "if", "(", "$", "imageLib", "==", "'ImageMagick'", ")", "{", "// ImageMagick command line", "if", "(", "tp_create_im_cmdline_thumbnails", "(", "$", "this", ",", "$", "prefix", ",", "$", "filename", ")", "!=", "true", ")", "{", "trigger_error", "(", "'Tidypics warning: failed to create thumbnails - ImageMagick command line'", ",", "E_USER_WARNING", ")", ";", "}", "}", "else", "if", "(", "$", "imageLib", "==", "'ImageMagickPHP'", ")", "{", "// imagick php extension", "if", "(", "tp_create_imagick_thumbnails", "(", "$", "this", ",", "$", "prefix", ",", "$", "filename", ")", "!=", "true", ")", "{", "trigger_error", "(", "'Tidypics warning: failed to create thumbnails - ImageMagick PHP'", ",", "E_USER_WARNING", ")", ";", "}", "}", "else", "{", "if", "(", "tp_create_gd_thumbnails", "(", "$", "this", ",", "$", "prefix", ",", "$", "filename", ")", "!=", "true", ")", "{", "trigger_error", "(", "'Tidypics warning: failed to create thumbnails - GD'", ",", "E_USER_WARNING", ")", ";", "}", "}", "}" ]
Save the image thumbnails
[ "Save", "the", "image", "thumbnails" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L475-L497
230,605
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.getThumbnail
public function getThumbnail($size) { switch ($size) { case 'thumb': $thumb = $this->thumbnail; break; case 'small': $thumb = $this->smallthumb; break; case 'large': $thumb = $this->largethumb; break; default: return ''; break; } if (!$thumb) { return ''; } $file = new ElggFile(); $file->owner_guid = $this->getOwnerGUID(); $file->setFilename($thumb); return $file->grabFile(); }
php
public function getThumbnail($size) { switch ($size) { case 'thumb': $thumb = $this->thumbnail; break; case 'small': $thumb = $this->smallthumb; break; case 'large': $thumb = $this->largethumb; break; default: return ''; break; } if (!$thumb) { return ''; } $file = new ElggFile(); $file->owner_guid = $this->getOwnerGUID(); $file->setFilename($thumb); return $file->grabFile(); }
[ "public", "function", "getThumbnail", "(", "$", "size", ")", "{", "switch", "(", "$", "size", ")", "{", "case", "'thumb'", ":", "$", "thumb", "=", "$", "this", "->", "thumbnail", ";", "break", ";", "case", "'small'", ":", "$", "thumb", "=", "$", "this", "->", "smallthumb", ";", "break", ";", "case", "'large'", ":", "$", "thumb", "=", "$", "this", "->", "largethumb", ";", "break", ";", "default", ":", "return", "''", ";", "break", ";", "}", "if", "(", "!", "$", "thumb", ")", "{", "return", "''", ";", "}", "$", "file", "=", "new", "ElggFile", "(", ")", ";", "$", "file", "->", "owner_guid", "=", "$", "this", "->", "getOwnerGUID", "(", ")", ";", "$", "file", "->", "setFilename", "(", "$", "thumb", ")", ";", "return", "$", "file", "->", "grabFile", "(", ")", ";", "}" ]
Get the image data of a thumbnail @param string $size @return string
[ "Get", "the", "image", "data", "of", "a", "thumbnail" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L505-L529
230,606
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.isPhotoTagged
public function isPhotoTagged() { $num_tags = elgg_get_annotations([ 'guid' => $this->getGUID(), 'type' => 'object', 'subtype' => TidypicsImage::SUBTYPE, 'annotation_name' => 'phototag', 'count' => true, ]); if ($num_tags > 0) { return true; } else { return false; } }
php
public function isPhotoTagged() { $num_tags = elgg_get_annotations([ 'guid' => $this->getGUID(), 'type' => 'object', 'subtype' => TidypicsImage::SUBTYPE, 'annotation_name' => 'phototag', 'count' => true, ]); if ($num_tags > 0) { return true; } else { return false; } }
[ "public", "function", "isPhotoTagged", "(", ")", "{", "$", "num_tags", "=", "elgg_get_annotations", "(", "[", "'guid'", "=>", "$", "this", "->", "getGUID", "(", ")", ",", "'type'", "=>", "'object'", ",", "'subtype'", "=>", "TidypicsImage", "::", "SUBTYPE", ",", "'annotation_name'", "=>", "'phototag'", ",", "'count'", "=>", "true", ",", "]", ")", ";", "if", "(", "$", "num_tags", ">", "0", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Has the photo been tagged with "in this photo" tags @return true/false
[ "Has", "the", "photo", "been", "tagged", "with", "in", "this", "photo", "tags" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L549-L562
230,607
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.getPhotoTags
public function getPhotoTags() { $tags = []; $annotations = elgg_get_annotations([ 'guid' => $this->getGUID(), 'annotation_name' => 'phototag', ]); foreach ($annotations as $annotation) { $tag = unserialize($annotation->value); $tag->annotation_id = $annotation->id; $tags[] = $tag; } return $tags; }
php
public function getPhotoTags() { $tags = []; $annotations = elgg_get_annotations([ 'guid' => $this->getGUID(), 'annotation_name' => 'phototag', ]); foreach ($annotations as $annotation) { $tag = unserialize($annotation->value); $tag->annotation_id = $annotation->id; $tags[] = $tag; } return $tags; }
[ "public", "function", "getPhotoTags", "(", ")", "{", "$", "tags", "=", "[", "]", ";", "$", "annotations", "=", "elgg_get_annotations", "(", "[", "'guid'", "=>", "$", "this", "->", "getGUID", "(", ")", ",", "'annotation_name'", "=>", "'phototag'", ",", "]", ")", ";", "foreach", "(", "$", "annotations", "as", "$", "annotation", ")", "{", "$", "tag", "=", "unserialize", "(", "$", "annotation", "->", "value", ")", ";", "$", "tag", "->", "annotation_id", "=", "$", "annotation", "->", "id", ";", "$", "tags", "[", "]", "=", "$", "tag", ";", "}", "return", "$", "tags", ";", "}" ]
Get an array of photo tag information @return array
[ "Get", "an", "array", "of", "photo", "tag", "information" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L569-L582
230,608
iionly/tidypics
classes/TidypicsImage.php
TidypicsImage.removeThumbnails
protected function removeThumbnails() { $thumbnail = $this->thumbnail; $smallthumb = $this->smallthumb; $largethumb = $this->largethumb; //delete standard thumbnail image if ($thumbnail) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($thumbnail); $delfile->delete(); } //delete small thumbnail image if ($smallthumb) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($smallthumb); $delfile->delete(); } //delete large thumbnail image if ($largethumb) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($largethumb); $delfile->delete(); } }
php
protected function removeThumbnails() { $thumbnail = $this->thumbnail; $smallthumb = $this->smallthumb; $largethumb = $this->largethumb; //delete standard thumbnail image if ($thumbnail) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($thumbnail); $delfile->delete(); } //delete small thumbnail image if ($smallthumb) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($smallthumb); $delfile->delete(); } //delete large thumbnail image if ($largethumb) { $delfile = new ElggFile(); $delfile->owner_guid = $this->getOwnerGUID(); $delfile->setFilename($largethumb); $delfile->delete(); } }
[ "protected", "function", "removeThumbnails", "(", ")", "{", "$", "thumbnail", "=", "$", "this", "->", "thumbnail", ";", "$", "smallthumb", "=", "$", "this", "->", "smallthumb", ";", "$", "largethumb", "=", "$", "this", "->", "largethumb", ";", "//delete standard thumbnail image", "if", "(", "$", "thumbnail", ")", "{", "$", "delfile", "=", "new", "ElggFile", "(", ")", ";", "$", "delfile", "->", "owner_guid", "=", "$", "this", "->", "getOwnerGUID", "(", ")", ";", "$", "delfile", "->", "setFilename", "(", "$", "thumbnail", ")", ";", "$", "delfile", "->", "delete", "(", ")", ";", "}", "//delete small thumbnail image", "if", "(", "$", "smallthumb", ")", "{", "$", "delfile", "=", "new", "ElggFile", "(", ")", ";", "$", "delfile", "->", "owner_guid", "=", "$", "this", "->", "getOwnerGUID", "(", ")", ";", "$", "delfile", "->", "setFilename", "(", "$", "smallthumb", ")", ";", "$", "delfile", "->", "delete", "(", ")", ";", "}", "//delete large thumbnail image", "if", "(", "$", "largethumb", ")", "{", "$", "delfile", "=", "new", "ElggFile", "(", ")", ";", "$", "delfile", "->", "owner_guid", "=", "$", "this", "->", "getOwnerGUID", "(", ")", ";", "$", "delfile", "->", "setFilename", "(", "$", "largethumb", ")", ";", "$", "delfile", "->", "delete", "(", ")", ";", "}", "}" ]
Remove thumbnails - usually in preparation for deletion The thumbnails are not actually ElggObjects so we create temporary objects to delete them.
[ "Remove", "thumbnails", "-", "usually", "in", "preparation", "for", "deletion" ]
6dc7d2728a7074a28f5440d191e4832b0d04367e
https://github.com/iionly/tidypics/blob/6dc7d2728a7074a28f5440d191e4832b0d04367e/classes/TidypicsImage.php#L590-L616
230,609
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_compile_include.php
Smarty_Internal_Compile_Include.compileInlineTemplate
public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler, $fullResourceName, $_caching, $hashResourceName, $t_hash, $c_id) { $compiler->smarty->allow_ambiguous_resources = true; /* @var Smarty_Internal_Template $tpl */ $tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty, $compiler->template, $compiler->template->cache_id, $c_id, $_caching); if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) { $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['uid'] = $tpl->source->uid; if (isset($compiler->template->_inheritance)) { $tpl->_inheritance = clone $compiler->template->_inheritance; } $tpl->compiled = new Smarty_Template_Compiled(); $tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash; $tpl->loadCompiler(); // save unique function name $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['func'] = $tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); // make sure whole chain gets compiled $tpl->mustCompile = true; $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['nocache_hash'] = $tpl->compiled->nocache_hash; // get compiled code $compiled_code = "<?php\n\n"; $compiled_code .= "/* Start inline template \"{$tpl->source->type}:{$tpl->source->name}\" =============================*/\n"; $compiled_code .= "function {$tpl->compiled->unifunc} (\$_smarty_tpl) {\n"; $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler); $compiled_code .= "<?php\n"; $compiled_code .= "}\n?>\n"; $compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode); $compiled_code .= "<?php\n\n"; $compiled_code .= "/* End inline template \"{$tpl->source->type}:{$tpl->source->name}\" =============================*/\n"; $compiled_code .= "?>"; unset($tpl->compiler); if ($tpl->compiled->has_nocache_code) { // replace nocache_hash $compiled_code = str_replace("{$tpl->compiled->nocache_hash}", $compiler->template->compiled->nocache_hash, $compiled_code); $compiler->template->compiled->has_nocache_code = true; } $compiler->parent_compiler->mergedSubTemplatesCode[$tpl->compiled->unifunc] = $compiled_code; return true; } else { return false; } }
php
public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler, $fullResourceName, $_caching, $hashResourceName, $t_hash, $c_id) { $compiler->smarty->allow_ambiguous_resources = true; /* @var Smarty_Internal_Template $tpl */ $tpl = new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty, $compiler->template, $compiler->template->cache_id, $c_id, $_caching); if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) { $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['uid'] = $tpl->source->uid; if (isset($compiler->template->_inheritance)) { $tpl->_inheritance = clone $compiler->template->_inheritance; } $tpl->compiled = new Smarty_Template_Compiled(); $tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash; $tpl->loadCompiler(); // save unique function name $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['func'] = $tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); // make sure whole chain gets compiled $tpl->mustCompile = true; $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['nocache_hash'] = $tpl->compiled->nocache_hash; // get compiled code $compiled_code = "<?php\n\n"; $compiled_code .= "/* Start inline template \"{$tpl->source->type}:{$tpl->source->name}\" =============================*/\n"; $compiled_code .= "function {$tpl->compiled->unifunc} (\$_smarty_tpl) {\n"; $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler); $compiled_code .= "<?php\n"; $compiled_code .= "}\n?>\n"; $compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode); $compiled_code .= "<?php\n\n"; $compiled_code .= "/* End inline template \"{$tpl->source->type}:{$tpl->source->name}\" =============================*/\n"; $compiled_code .= "?>"; unset($tpl->compiler); if ($tpl->compiled->has_nocache_code) { // replace nocache_hash $compiled_code = str_replace("{$tpl->compiled->nocache_hash}", $compiler->template->compiled->nocache_hash, $compiled_code); $compiler->template->compiled->has_nocache_code = true; } $compiler->parent_compiler->mergedSubTemplatesCode[$tpl->compiled->unifunc] = $compiled_code; return true; } else { return false; } }
[ "public", "function", "compileInlineTemplate", "(", "Smarty_Internal_SmartyTemplateCompiler", "$", "compiler", ",", "$", "fullResourceName", ",", "$", "_caching", ",", "$", "hashResourceName", ",", "$", "t_hash", ",", "$", "c_id", ")", "{", "$", "compiler", "->", "smarty", "->", "allow_ambiguous_resources", "=", "true", ";", "/* @var Smarty_Internal_Template $tpl */", "$", "tpl", "=", "new", "$", "compiler", "->", "smarty", "->", "template_class", "(", "trim", "(", "$", "fullResourceName", ",", "'\"\\''", ")", ",", "$", "compiler", "->", "smarty", ",", "$", "compiler", "->", "template", ",", "$", "compiler", "->", "template", "->", "cache_id", ",", "$", "c_id", ",", "$", "_caching", ")", ";", "if", "(", "!", "(", "$", "tpl", "->", "source", "->", "handler", "->", "uncompiled", ")", "&&", "$", "tpl", "->", "source", "->", "exists", ")", "{", "$", "compiler", "->", "parent_compiler", "->", "mergedSubTemplatesData", "[", "$", "hashResourceName", "]", "[", "$", "t_hash", "]", "[", "'uid'", "]", "=", "$", "tpl", "->", "source", "->", "uid", ";", "if", "(", "isset", "(", "$", "compiler", "->", "template", "->", "_inheritance", ")", ")", "{", "$", "tpl", "->", "_inheritance", "=", "clone", "$", "compiler", "->", "template", "->", "_inheritance", ";", "}", "$", "tpl", "->", "compiled", "=", "new", "Smarty_Template_Compiled", "(", ")", ";", "$", "tpl", "->", "compiled", "->", "nocache_hash", "=", "$", "compiler", "->", "parent_compiler", "->", "template", "->", "compiled", "->", "nocache_hash", ";", "$", "tpl", "->", "loadCompiler", "(", ")", ";", "// save unique function name", "$", "compiler", "->", "parent_compiler", "->", "mergedSubTemplatesData", "[", "$", "hashResourceName", "]", "[", "$", "t_hash", "]", "[", "'func'", "]", "=", "$", "tpl", "->", "compiled", "->", "unifunc", "=", "'content_'", ".", "str_replace", "(", "array", "(", "'.'", ",", "','", ")", ",", "'_'", ",", "uniqid", "(", "''", ",", "true", ")", ")", ";", "// make sure whole chain gets compiled", "$", "tpl", "->", "mustCompile", "=", "true", ";", "$", "compiler", "->", "parent_compiler", "->", "mergedSubTemplatesData", "[", "$", "hashResourceName", "]", "[", "$", "t_hash", "]", "[", "'nocache_hash'", "]", "=", "$", "tpl", "->", "compiled", "->", "nocache_hash", ";", "// get compiled code", "$", "compiled_code", "=", "\"<?php\\n\\n\"", ";", "$", "compiled_code", ".=", "\"/* Start inline template \\\"{$tpl->source->type}:{$tpl->source->name}\\\" =============================*/\\n\"", ";", "$", "compiled_code", ".=", "\"function {$tpl->compiled->unifunc} (\\$_smarty_tpl) {\\n\"", ";", "$", "compiled_code", ".=", "\"?>\\n\"", ".", "$", "tpl", "->", "compiler", "->", "compileTemplateSource", "(", "$", "tpl", ",", "null", ",", "$", "compiler", "->", "parent_compiler", ")", ";", "$", "compiled_code", ".=", "\"<?php\\n\"", ";", "$", "compiled_code", ".=", "\"}\\n?>\\n\"", ";", "$", "compiled_code", ".=", "$", "tpl", "->", "compiler", "->", "postFilter", "(", "$", "tpl", "->", "compiler", "->", "blockOrFunctionCode", ")", ";", "$", "compiled_code", ".=", "\"<?php\\n\\n\"", ";", "$", "compiled_code", ".=", "\"/* End inline template \\\"{$tpl->source->type}:{$tpl->source->name}\\\" =============================*/\\n\"", ";", "$", "compiled_code", ".=", "\"?>\"", ";", "unset", "(", "$", "tpl", "->", "compiler", ")", ";", "if", "(", "$", "tpl", "->", "compiled", "->", "has_nocache_code", ")", "{", "// replace nocache_hash", "$", "compiled_code", "=", "str_replace", "(", "\"{$tpl->compiled->nocache_hash}\"", ",", "$", "compiler", "->", "template", "->", "compiled", "->", "nocache_hash", ",", "$", "compiled_code", ")", ";", "$", "compiler", "->", "template", "->", "compiled", "->", "has_nocache_code", "=", "true", ";", "}", "$", "compiler", "->", "parent_compiler", "->", "mergedSubTemplatesCode", "[", "$", "tpl", "->", "compiled", "->", "unifunc", "]", "=", "$", "compiled_code", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Compile inline sub template @param \Smarty_Internal_SmartyTemplateCompiler $compiler @param $fullResourceName @param $_caching @param $hashResourceName @param $t_hash @param $c_id @return bool
[ "Compile", "inline", "sub", "template" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_compile_include.php#L318-L365
230,610
cygnite/framework
src/Cygnite/Container/Container.php
Container.setDefinitions
public function setDefinitions(array $definitions) : ContainerAwareInterface { $this->set('definition.config', $definitions); parent::setPropertyDefinition($definitions['property.definition']); return $this; }
php
public function setDefinitions(array $definitions) : ContainerAwareInterface { $this->set('definition.config', $definitions); parent::setPropertyDefinition($definitions['property.definition']); return $this; }
[ "public", "function", "setDefinitions", "(", "array", "$", "definitions", ")", ":", "ContainerAwareInterface", "{", "$", "this", "->", "set", "(", "'definition.config'", ",", "$", "definitions", ")", ";", "parent", "::", "setPropertyDefinition", "(", "$", "definitions", "[", "'property.definition'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Set definitions for property and interface injection. @param array $definitions @return ContainerAwareInterface
[ "Set", "definitions", "for", "property", "and", "interface", "injection", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L91-L97
230,611
cygnite/framework
src/Cygnite/Container/Container.php
Container.extend
public function extend(string $key, Closure $callable) { if (!isset($this->stack[$key])) { throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $key)); } if (!$callable instanceof Closure) { throw new InvalidArgumentException( sprintf('Identifier "%s" is not Closure Object.', $callable) ); } $binding = $this->offsetExists($key) ? $this->stack[$key] : null; $extended = function () use ($callable, $binding) { if (!is_object($binding)) { throw new ContainerException(sprintf('"%s" must be Closure object.', $binding)); } return $callable($binding($this), $this); }; return $this[$key] = $extended; }
php
public function extend(string $key, Closure $callable) { if (!isset($this->stack[$key])) { throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $key)); } if (!$callable instanceof Closure) { throw new InvalidArgumentException( sprintf('Identifier "%s" is not Closure Object.', $callable) ); } $binding = $this->offsetExists($key) ? $this->stack[$key] : null; $extended = function () use ($callable, $binding) { if (!is_object($binding)) { throw new ContainerException(sprintf('"%s" must be Closure object.', $binding)); } return $callable($binding($this), $this); }; return $this[$key] = $extended; }
[ "public", "function", "extend", "(", "string", "$", "key", ",", "Closure", "$", "callable", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stack", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Identifier \"%s\" is not defined.'", ",", "$", "key", ")", ")", ";", "}", "if", "(", "!", "$", "callable", "instanceof", "Closure", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Identifier \"%s\" is not Closure Object.'", ",", "$", "callable", ")", ")", ";", "}", "$", "binding", "=", "$", "this", "->", "offsetExists", "(", "$", "key", ")", "?", "$", "this", "->", "stack", "[", "$", "key", "]", ":", "null", ";", "$", "extended", "=", "function", "(", ")", "use", "(", "$", "callable", ",", "$", "binding", ")", "{", "if", "(", "!", "is_object", "(", "$", "binding", ")", ")", "{", "throw", "new", "ContainerException", "(", "sprintf", "(", "'\"%s\" must be Closure object.'", ",", "$", "binding", ")", ")", ";", "}", "return", "$", "callable", "(", "$", "binding", "(", "$", "this", ")", ",", "$", "this", ")", ";", "}", ";", "return", "$", "this", "[", "$", "key", "]", "=", "$", "extended", ";", "}" ]
Extends the existing object. @param string $key @param callable|Closure $callable $callable @return callable
[ "Extends", "the", "existing", "object", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L335-L358
230,612
cygnite/framework
src/Cygnite/Container/Container.php
Container.singleton
public function singleton(string $name, callable $callback = null) { static $instance = []; // if closure callback given we will create a singleton instance of class // and return it to user if ($callback instanceof Closure) { if (!isset($instance[$name])) { $instance[$name] = $callback($this); } return $this->stack[$name] = $instance[$name]; } /* | If callback is not instance of closure then we will simply | create a singleton instance and return it */ if (!isset($instance[$name])) { $instance[$name] = new $name(); } return $instance[$name]; }
php
public function singleton(string $name, callable $callback = null) { static $instance = []; // if closure callback given we will create a singleton instance of class // and return it to user if ($callback instanceof Closure) { if (!isset($instance[$name])) { $instance[$name] = $callback($this); } return $this->stack[$name] = $instance[$name]; } /* | If callback is not instance of closure then we will simply | create a singleton instance and return it */ if (!isset($instance[$name])) { $instance[$name] = new $name(); } return $instance[$name]; }
[ "public", "function", "singleton", "(", "string", "$", "name", ",", "callable", "$", "callback", "=", "null", ")", "{", "static", "$", "instance", "=", "[", "]", ";", "// if closure callback given we will create a singleton instance of class", "// and return it to user", "if", "(", "$", "callback", "instanceof", "Closure", ")", "{", "if", "(", "!", "isset", "(", "$", "instance", "[", "$", "name", "]", ")", ")", "{", "$", "instance", "[", "$", "name", "]", "=", "$", "callback", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "stack", "[", "$", "name", "]", "=", "$", "instance", "[", "$", "name", "]", ";", "}", "/*\n | If callback is not instance of closure then we will simply\n | create a singleton instance and return it\n */", "if", "(", "!", "isset", "(", "$", "instance", "[", "$", "name", "]", ")", ")", "{", "$", "instance", "[", "$", "name", "]", "=", "new", "$", "name", "(", ")", ";", "}", "return", "$", "instance", "[", "$", "name", "]", ";", "}" ]
Get singleton instance of your class. @param $name @param null $callback @return mixed
[ "Get", "singleton", "instance", "of", "your", "class", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L368-L391
230,613
cygnite/framework
src/Cygnite/Container/Container.php
Container.make
public function make(string $namespace, array $arguments = []) { $class = $this->getClassNameFromNamespace($namespace); /* * If instance of the class already created and stored into * stack then simply return from here */ if ($this->has($class)) { return $this->get($class); } $reflectionClass = $this->reflection->setClass($namespace)->getReflectionClass(); $this->throwExceptionIfNotInstantiable($namespace, $reflectionClass); $constructor = null; $constructorArgsCount = 0; list($constructor, $constructorArgsCount) = $this->getConstructorArgs($reflectionClass, $constructorArgsCount); // if class does not have explicitly defined constructor or constructor // does not have parameters get the new instance if (!isset($constructor) && is_null($constructor) || $constructorArgsCount < 1) { return $this[$class] = $reflectionClass->newInstance(); } $dependencies = $constructor->getParameters(); $constructorArgs = $this->createMethodArgument($dependencies, $arguments); return $this[$class] = $reflectionClass->newInstanceArgs($constructorArgs); }
php
public function make(string $namespace, array $arguments = []) { $class = $this->getClassNameFromNamespace($namespace); /* * If instance of the class already created and stored into * stack then simply return from here */ if ($this->has($class)) { return $this->get($class); } $reflectionClass = $this->reflection->setClass($namespace)->getReflectionClass(); $this->throwExceptionIfNotInstantiable($namespace, $reflectionClass); $constructor = null; $constructorArgsCount = 0; list($constructor, $constructorArgsCount) = $this->getConstructorArgs($reflectionClass, $constructorArgsCount); // if class does not have explicitly defined constructor or constructor // does not have parameters get the new instance if (!isset($constructor) && is_null($constructor) || $constructorArgsCount < 1) { return $this[$class] = $reflectionClass->newInstance(); } $dependencies = $constructor->getParameters(); $constructorArgs = $this->createMethodArgument($dependencies, $arguments); return $this[$class] = $reflectionClass->newInstanceArgs($constructorArgs); }
[ "public", "function", "make", "(", "string", "$", "namespace", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "$", "class", "=", "$", "this", "->", "getClassNameFromNamespace", "(", "$", "namespace", ")", ";", "/*\n * If instance of the class already created and stored into\n * stack then simply return from here\n */", "if", "(", "$", "this", "->", "has", "(", "$", "class", ")", ")", "{", "return", "$", "this", "->", "get", "(", "$", "class", ")", ";", "}", "$", "reflectionClass", "=", "$", "this", "->", "reflection", "->", "setClass", "(", "$", "namespace", ")", "->", "getReflectionClass", "(", ")", ";", "$", "this", "->", "throwExceptionIfNotInstantiable", "(", "$", "namespace", ",", "$", "reflectionClass", ")", ";", "$", "constructor", "=", "null", ";", "$", "constructorArgsCount", "=", "0", ";", "list", "(", "$", "constructor", ",", "$", "constructorArgsCount", ")", "=", "$", "this", "->", "getConstructorArgs", "(", "$", "reflectionClass", ",", "$", "constructorArgsCount", ")", ";", "// if class does not have explicitly defined constructor or constructor", "// does not have parameters get the new instance", "if", "(", "!", "isset", "(", "$", "constructor", ")", "&&", "is_null", "(", "$", "constructor", ")", "||", "$", "constructorArgsCount", "<", "1", ")", "{", "return", "$", "this", "[", "$", "class", "]", "=", "$", "reflectionClass", "->", "newInstance", "(", ")", ";", "}", "$", "dependencies", "=", "$", "constructor", "->", "getParameters", "(", ")", ";", "$", "constructorArgs", "=", "$", "this", "->", "createMethodArgument", "(", "$", "dependencies", ",", "$", "arguments", ")", ";", "return", "$", "this", "[", "$", "class", "]", "=", "$", "reflectionClass", "->", "newInstanceArgs", "(", "$", "constructorArgs", ")", ";", "}" ]
Resolve all dependencies of your class and return instance of your class. @param $class @throws \Cygnite\Container\Exceptions\ContainerException @return mixed
[ "Resolve", "all", "dependencies", "of", "your", "class", "and", "return", "instance", "of", "your", "class", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L415-L442
230,614
cygnite/framework
src/Cygnite/Container/Container.php
Container.createMethodArgument
protected function createMethodArgument(array $dependencies, array $arguments = []) : array { $args = []; foreach ($dependencies as $dependency) { if (!is_null($dependency->getClass())) { $args[] = $this->resolverClass($dependency, $arguments); } else { // Check if construct has default value then we will simply assign it into array // and continue for next argument if ($dependency->isDefaultValueAvailable()) { $args[] = $this->injector->checkIfConstructorHasDefaultArgs($dependency, $arguments); continue; } //Check if parameters are optional then we will set the default value $args[] = $this->injector->isOptionalArgs($dependency); } } return $args; }
php
protected function createMethodArgument(array $dependencies, array $arguments = []) : array { $args = []; foreach ($dependencies as $dependency) { if (!is_null($dependency->getClass())) { $args[] = $this->resolverClass($dependency, $arguments); } else { // Check if construct has default value then we will simply assign it into array // and continue for next argument if ($dependency->isDefaultValueAvailable()) { $args[] = $this->injector->checkIfConstructorHasDefaultArgs($dependency, $arguments); continue; } //Check if parameters are optional then we will set the default value $args[] = $this->injector->isOptionalArgs($dependency); } } return $args; }
[ "protected", "function", "createMethodArgument", "(", "array", "$", "dependencies", ",", "array", "$", "arguments", "=", "[", "]", ")", ":", "array", "{", "$", "args", "=", "[", "]", ";", "foreach", "(", "$", "dependencies", "as", "$", "dependency", ")", "{", "if", "(", "!", "is_null", "(", "$", "dependency", "->", "getClass", "(", ")", ")", ")", "{", "$", "args", "[", "]", "=", "$", "this", "->", "resolverClass", "(", "$", "dependency", ",", "$", "arguments", ")", ";", "}", "else", "{", "// Check if construct has default value then we will simply assign it into array", "// and continue for next argument", "if", "(", "$", "dependency", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "args", "[", "]", "=", "$", "this", "->", "injector", "->", "checkIfConstructorHasDefaultArgs", "(", "$", "dependency", ",", "$", "arguments", ")", ";", "continue", ";", "}", "//Check if parameters are optional then we will set the default value", "$", "args", "[", "]", "=", "$", "this", "->", "injector", "->", "isOptionalArgs", "(", "$", "dependency", ")", ";", "}", "}", "return", "$", "args", ";", "}" ]
This method is used to find out the arguments required for the constructor or any method and returns array of arguments. @param array $dependencies @param array $arguments @return array
[ "This", "method", "is", "used", "to", "find", "out", "the", "arguments", "required", "for", "the", "constructor", "or", "any", "method", "and", "returns", "array", "of", "arguments", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L452-L471
230,615
cygnite/framework
src/Cygnite/Container/Container.php
Container.resolveMethod
public function resolveMethod(string $namespace, string $method) : array { $class = $this->reflection->setClass($namespace)->getReflectionClass(); if (!method_exists($namespace, $method)) { throw new \RuntimeException("Method $method doesn't exists in $namespace class"); } $arguments = $class->getMethod($method)->getParameters(); $methodArgs = $this->createMethodArgument($arguments); return array_filter($methodArgs); }
php
public function resolveMethod(string $namespace, string $method) : array { $class = $this->reflection->setClass($namespace)->getReflectionClass(); if (!method_exists($namespace, $method)) { throw new \RuntimeException("Method $method doesn't exists in $namespace class"); } $arguments = $class->getMethod($method)->getParameters(); $methodArgs = $this->createMethodArgument($arguments); return array_filter($methodArgs); }
[ "public", "function", "resolveMethod", "(", "string", "$", "namespace", ",", "string", "$", "method", ")", ":", "array", "{", "$", "class", "=", "$", "this", "->", "reflection", "->", "setClass", "(", "$", "namespace", ")", "->", "getReflectionClass", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "namespace", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Method $method doesn't exists in $namespace class\"", ")", ";", "}", "$", "arguments", "=", "$", "class", "->", "getMethod", "(", "$", "method", ")", "->", "getParameters", "(", ")", ";", "$", "methodArgs", "=", "$", "this", "->", "createMethodArgument", "(", "$", "arguments", ")", ";", "return", "array_filter", "(", "$", "methodArgs", ")", ";", "}" ]
This method is used to resolve all dependencies of your method and returns method arguments. @param string $namespace @param string $method @return array
[ "This", "method", "is", "used", "to", "resolve", "all", "dependencies", "of", "your", "method", "and", "returns", "method", "arguments", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L481-L492
230,616
cygnite/framework
src/Cygnite/Container/Container.php
Container.getConstructorArgs
private function getConstructorArgs($reflectionClass, int $constructorArgsCount = 0) { if ($reflectionClass->hasMethod('__construct')) { $constructor = $reflectionClass->getConstructor(); $constructor->setAccessible(true); $constructorArgsCount = $constructor->getNumberOfParameters(); return [$constructor, $constructorArgsCount]; } }
php
private function getConstructorArgs($reflectionClass, int $constructorArgsCount = 0) { if ($reflectionClass->hasMethod('__construct')) { $constructor = $reflectionClass->getConstructor(); $constructor->setAccessible(true); $constructorArgsCount = $constructor->getNumberOfParameters(); return [$constructor, $constructorArgsCount]; } }
[ "private", "function", "getConstructorArgs", "(", "$", "reflectionClass", ",", "int", "$", "constructorArgsCount", "=", "0", ")", "{", "if", "(", "$", "reflectionClass", "->", "hasMethod", "(", "'__construct'", ")", ")", "{", "$", "constructor", "=", "$", "reflectionClass", "->", "getConstructor", "(", ")", ";", "$", "constructor", "->", "setAccessible", "(", "true", ")", ";", "$", "constructorArgsCount", "=", "$", "constructor", "->", "getNumberOfParameters", "(", ")", ";", "return", "[", "$", "constructor", ",", "$", "constructorArgsCount", "]", ";", "}", "}" ]
Get Class Constructor Arguments. @param $reflectionClass @param int $constructorArgsCount @return array
[ "Get", "Class", "Constructor", "Arguments", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L512-L521
230,617
cygnite/framework
src/Cygnite/Container/Container.php
Container.throwExceptionIfNotInstantiable
private function throwExceptionIfNotInstantiable($class, $reflectionClass) { /* * Check if reflection class is not instantiable then throw ContainerException */ if (!$reflectionClass->isInstantiable()) { $type = ($this->reflection->getReflectionClass()->isInterface() ? 'interface' : 'class'); throw new ContainerException("Cannot instantiate $type $class"); } }
php
private function throwExceptionIfNotInstantiable($class, $reflectionClass) { /* * Check if reflection class is not instantiable then throw ContainerException */ if (!$reflectionClass->isInstantiable()) { $type = ($this->reflection->getReflectionClass()->isInterface() ? 'interface' : 'class'); throw new ContainerException("Cannot instantiate $type $class"); } }
[ "private", "function", "throwExceptionIfNotInstantiable", "(", "$", "class", ",", "$", "reflectionClass", ")", "{", "/*\n * Check if reflection class is not instantiable then throw ContainerException\n */", "if", "(", "!", "$", "reflectionClass", "->", "isInstantiable", "(", ")", ")", "{", "$", "type", "=", "(", "$", "this", "->", "reflection", "->", "getReflectionClass", "(", ")", "->", "isInterface", "(", ")", "?", "'interface'", ":", "'class'", ")", ";", "throw", "new", "ContainerException", "(", "\"Cannot instantiate $type $class\"", ")", ";", "}", "}" ]
Throws exception if given input is not instantiable. @param $class @param $reflectionClass @throws Exceptions\ContainerException
[ "Throws", "exception", "if", "given", "input", "is", "not", "instantiable", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L530-L539
230,618
cygnite/framework
src/Cygnite/Container/Container.php
Container.resolverClass
private function resolverClass($dependency, $arguments) { list($resolveClass, $reflectionParam) = $this->injector->getReflectionParam($dependency); // Application and Container cannot be injected into controller currently // since Application constructor is protected if ($reflectionParam->IsInstantiable()) { return $this->makeInstance($resolveClass, $arguments); } return $this->injector->interfaceInjection($reflectionParam); }
php
private function resolverClass($dependency, $arguments) { list($resolveClass, $reflectionParam) = $this->injector->getReflectionParam($dependency); // Application and Container cannot be injected into controller currently // since Application constructor is protected if ($reflectionParam->IsInstantiable()) { return $this->makeInstance($resolveClass, $arguments); } return $this->injector->interfaceInjection($reflectionParam); }
[ "private", "function", "resolverClass", "(", "$", "dependency", ",", "$", "arguments", ")", "{", "list", "(", "$", "resolveClass", ",", "$", "reflectionParam", ")", "=", "$", "this", "->", "injector", "->", "getReflectionParam", "(", "$", "dependency", ")", ";", "// Application and Container cannot be injected into controller currently", "// since Application constructor is protected", "if", "(", "$", "reflectionParam", "->", "IsInstantiable", "(", ")", ")", "{", "return", "$", "this", "->", "makeInstance", "(", "$", "resolveClass", ",", "$", "arguments", ")", ";", "}", "return", "$", "this", "->", "injector", "->", "interfaceInjection", "(", "$", "reflectionParam", ")", ";", "}" ]
Resolves class and returns object if instantiable, otherwise checks for interface injection can be done. @param $dependency @param $arguments @return array|mixed
[ "Resolves", "class", "and", "returns", "object", "if", "instantiable", "otherwise", "checks", "for", "interface", "injection", "can", "be", "done", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Container.php#L549-L560
230,619
cygnite/framework
src/Cygnite/Logger/Log.php
Log.errorLog
public function errorLog($type = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM) { $this->pushHandler(new ErrorLogHandler($messageType, $this->getLevel($type))); }
php
public function errorLog($type = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM) { $this->pushHandler(new ErrorLogHandler($messageType, $this->getLevel($type))); }
[ "public", "function", "errorLog", "(", "$", "type", "=", "'debug'", ",", "$", "messageType", "=", "ErrorLogHandler", "::", "OPERATING_SYSTEM", ")", "{", "$", "this", "->", "pushHandler", "(", "new", "ErrorLogHandler", "(", "$", "messageType", ",", "$", "this", "->", "getLevel", "(", "$", "type", ")", ")", ")", ";", "}" ]
Register a Error Log Handler. @param string $type @param int $messageType
[ "Register", "a", "Error", "Log", "Handler", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Logger/Log.php#L203-L206
230,620
cygnite/framework
src/Cygnite/Logger/Log.php
Log.sysLog
public function sysLog($name = 'cygnite', $type = 'debug') { return $this->pushHandler(new SyslogHandler($name, LOG_USER, $type), false); }
php
public function sysLog($name = 'cygnite', $type = 'debug') { return $this->pushHandler(new SyslogHandler($name, LOG_USER, $type), false); }
[ "public", "function", "sysLog", "(", "$", "name", "=", "'cygnite'", ",", "$", "type", "=", "'debug'", ")", "{", "return", "$", "this", "->", "pushHandler", "(", "new", "SyslogHandler", "(", "$", "name", ",", "LOG_USER", ",", "$", "type", ")", ",", "false", ")", ";", "}" ]
Register a Syslog handler to Monolog Library. @param string $name @param string $type @return Log
[ "Register", "a", "Syslog", "handler", "to", "Monolog", "Library", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Logger/Log.php#L215-L218
230,621
cygnite/framework
src/Cygnite/Logger/Log.php
Log.pushHandler
protected function pushHandler($handler, $formatter = true) { if ($formatter == false) { return $this->monolog->pushHandler($handler); } $this->monolog->pushHandler($handler); $handler->setFormatter($this->getDefaultFormatter()); return $this; }
php
protected function pushHandler($handler, $formatter = true) { if ($formatter == false) { return $this->monolog->pushHandler($handler); } $this->monolog->pushHandler($handler); $handler->setFormatter($this->getDefaultFormatter()); return $this; }
[ "protected", "function", "pushHandler", "(", "$", "handler", ",", "$", "formatter", "=", "true", ")", "{", "if", "(", "$", "formatter", "==", "false", ")", "{", "return", "$", "this", "->", "monolog", "->", "pushHandler", "(", "$", "handler", ")", ";", "}", "$", "this", "->", "monolog", "->", "pushHandler", "(", "$", "handler", ")", ";", "$", "handler", "->", "setFormatter", "(", "$", "this", "->", "getDefaultFormatter", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Push Handler to Monolog. @param $handler @param bool $formatter @return $this
[ "Push", "Handler", "to", "Monolog", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Logger/Log.php#L227-L237
230,622
cygnite/framework
src/Cygnite/Logger/Log.php
Log.getLevel
protected function getLevel($type) { if (!isset($this->types[$type])) { throw new InvalidArgumentException('Invalid log type.'); } return $this->types[$type]; }
php
protected function getLevel($type) { if (!isset($this->types[$type])) { throw new InvalidArgumentException('Invalid log type.'); } return $this->types[$type]; }
[ "protected", "function", "getLevel", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "types", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid log type.'", ")", ";", "}", "return", "$", "this", "->", "types", "[", "$", "type", "]", ";", "}" ]
Get the Log Level. @param $type @return mixed
[ "Get", "the", "Log", "Level", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Logger/Log.php#L245-L252
230,623
franzliedke/lti
src/OAuth/Request.php
Request.fromPsrRequest
public static function fromPsrRequest(ServerRequestInterface $request) { $url = (string) $request->getUri(); $httpMethod = $request->getMethod(); // Let's find the parameters relevant to this request $parameters = (array) $request->getParsedBody() + $request->getQueryParams(); // We have a Authorization-header with OAuth data. Parse the header // and add those overriding any duplicates from GET or POST if (substr($request->getHeaderLine('Authorization'), 0, 6) == 'OAuth ') { $header_parameters = Util::splitHeader( $request->getHeaderLine('Authorization') ); $parameters = array_merge($parameters, $header_parameters); } return new Request($httpMethod, $url, $parameters); }
php
public static function fromPsrRequest(ServerRequestInterface $request) { $url = (string) $request->getUri(); $httpMethod = $request->getMethod(); // Let's find the parameters relevant to this request $parameters = (array) $request->getParsedBody() + $request->getQueryParams(); // We have a Authorization-header with OAuth data. Parse the header // and add those overriding any duplicates from GET or POST if (substr($request->getHeaderLine('Authorization'), 0, 6) == 'OAuth ') { $header_parameters = Util::splitHeader( $request->getHeaderLine('Authorization') ); $parameters = array_merge($parameters, $header_parameters); } return new Request($httpMethod, $url, $parameters); }
[ "public", "static", "function", "fromPsrRequest", "(", "ServerRequestInterface", "$", "request", ")", "{", "$", "url", "=", "(", "string", ")", "$", "request", "->", "getUri", "(", ")", ";", "$", "httpMethod", "=", "$", "request", "->", "getMethod", "(", ")", ";", "// Let's find the parameters relevant to this request", "$", "parameters", "=", "(", "array", ")", "$", "request", "->", "getParsedBody", "(", ")", "+", "$", "request", "->", "getQueryParams", "(", ")", ";", "// We have a Authorization-header with OAuth data. Parse the header", "// and add those overriding any duplicates from GET or POST", "if", "(", "substr", "(", "$", "request", "->", "getHeaderLine", "(", "'Authorization'", ")", ",", "0", ",", "6", ")", "==", "'OAuth '", ")", "{", "$", "header_parameters", "=", "Util", "::", "splitHeader", "(", "$", "request", "->", "getHeaderLine", "(", "'Authorization'", ")", ")", ";", "$", "parameters", "=", "array_merge", "(", "$", "parameters", ",", "$", "header_parameters", ")", ";", "}", "return", "new", "Request", "(", "$", "httpMethod", ",", "$", "url", ",", "$", "parameters", ")", ";", "}" ]
attempt to build up a request from a PSR-7 compatible request @param ServerRequestInterface $request @return Request
[ "attempt", "to", "build", "up", "a", "request", "from", "a", "PSR", "-", "7", "compatible", "request" ]
131cf331f2cb87fcc29049ac739c8751e9e5133b
https://github.com/franzliedke/lti/blob/131cf331f2cb87fcc29049ac739c8751e9e5133b/src/OAuth/Request.php#L88-L106
230,624
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_template_resource_base.php
Smarty_Template_Resource_Base.getRenderedTemplateCode
public function getRenderedTemplateCode(Smarty_Internal_Template $_template, $unifunc = null) { $unifunc = isset($unifunc) ? $unifunc : $this->unifunc; $level = ob_get_level(); try { if (empty($unifunc) || !is_callable($unifunc)) { throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'"); } if (isset($_template->smarty->security_policy)) { $_template->smarty->security_policy->startTemplate($_template); } // // render compiled or saved template code // if (!isset($_template->_cache['capture_stack'])) { $_template->_cache['capture_stack'] = array(); } $_saved_capture_level = count($_template->_cache['capture_stack']); $unifunc($_template); // any unclosed {capture} tags ? if ($_saved_capture_level != count($_template->_cache['capture_stack'])) { $_template->capture_error(); } if (isset($_template->smarty->security_policy)) { $_template->smarty->security_policy->exitTemplate(); } return null; } catch (Exception $e) { while (ob_get_level() > $level) { ob_end_clean(); } if (isset($_template->smarty->security_policy)) { $_template->smarty->security_policy->exitTemplate(); } throw $e; } }
php
public function getRenderedTemplateCode(Smarty_Internal_Template $_template, $unifunc = null) { $unifunc = isset($unifunc) ? $unifunc : $this->unifunc; $level = ob_get_level(); try { if (empty($unifunc) || !is_callable($unifunc)) { throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'"); } if (isset($_template->smarty->security_policy)) { $_template->smarty->security_policy->startTemplate($_template); } // // render compiled or saved template code // if (!isset($_template->_cache['capture_stack'])) { $_template->_cache['capture_stack'] = array(); } $_saved_capture_level = count($_template->_cache['capture_stack']); $unifunc($_template); // any unclosed {capture} tags ? if ($_saved_capture_level != count($_template->_cache['capture_stack'])) { $_template->capture_error(); } if (isset($_template->smarty->security_policy)) { $_template->smarty->security_policy->exitTemplate(); } return null; } catch (Exception $e) { while (ob_get_level() > $level) { ob_end_clean(); } if (isset($_template->smarty->security_policy)) { $_template->smarty->security_policy->exitTemplate(); } throw $e; } }
[ "public", "function", "getRenderedTemplateCode", "(", "Smarty_Internal_Template", "$", "_template", ",", "$", "unifunc", "=", "null", ")", "{", "$", "unifunc", "=", "isset", "(", "$", "unifunc", ")", "?", "$", "unifunc", ":", "$", "this", "->", "unifunc", ";", "$", "level", "=", "ob_get_level", "(", ")", ";", "try", "{", "if", "(", "empty", "(", "$", "unifunc", ")", "||", "!", "is_callable", "(", "$", "unifunc", ")", ")", "{", "throw", "new", "SmartyException", "(", "\"Invalid compiled template for '{$_template->template_resource}'\"", ")", ";", "}", "if", "(", "isset", "(", "$", "_template", "->", "smarty", "->", "security_policy", ")", ")", "{", "$", "_template", "->", "smarty", "->", "security_policy", "->", "startTemplate", "(", "$", "_template", ")", ";", "}", "//", "// render compiled or saved template code", "//", "if", "(", "!", "isset", "(", "$", "_template", "->", "_cache", "[", "'capture_stack'", "]", ")", ")", "{", "$", "_template", "->", "_cache", "[", "'capture_stack'", "]", "=", "array", "(", ")", ";", "}", "$", "_saved_capture_level", "=", "count", "(", "$", "_template", "->", "_cache", "[", "'capture_stack'", "]", ")", ";", "$", "unifunc", "(", "$", "_template", ")", ";", "// any unclosed {capture} tags ?", "if", "(", "$", "_saved_capture_level", "!=", "count", "(", "$", "_template", "->", "_cache", "[", "'capture_stack'", "]", ")", ")", "{", "$", "_template", "->", "capture_error", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "_template", "->", "smarty", "->", "security_policy", ")", ")", "{", "$", "_template", "->", "smarty", "->", "security_policy", "->", "exitTemplate", "(", ")", ";", "}", "return", "null", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "while", "(", "ob_get_level", "(", ")", ">", "$", "level", ")", "{", "ob_end_clean", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "_template", "->", "smarty", "->", "security_policy", ")", ")", "{", "$", "_template", "->", "smarty", "->", "security_policy", "->", "exitTemplate", "(", ")", ";", "}", "throw", "$", "e", ";", "}", "}" ]
get rendered template content by calling compiled or cached template code @param string $unifunc function with template code @return string @throws \Exception
[ "get", "rendered", "template", "content", "by", "calling", "compiled", "or", "cached", "template", "code" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_template_resource_base.php#L104-L141
230,625
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_template_resource_base.php
Smarty_Template_Resource_Base.getTimeStamp
public function getTimeStamp() { if ($this->exists && !isset($this->timestamp)) { $this->timestamp = @filemtime($this->filepath); } return $this->timestamp; }
php
public function getTimeStamp() { if ($this->exists && !isset($this->timestamp)) { $this->timestamp = @filemtime($this->filepath); } return $this->timestamp; }
[ "public", "function", "getTimeStamp", "(", ")", "{", "if", "(", "$", "this", "->", "exists", "&&", "!", "isset", "(", "$", "this", "->", "timestamp", ")", ")", "{", "$", "this", "->", "timestamp", "=", "@", "filemtime", "(", "$", "this", "->", "filepath", ")", ";", "}", "return", "$", "this", "->", "timestamp", ";", "}" ]
Get compiled time stamp @return int
[ "Get", "compiled", "time", "stamp" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_template_resource_base.php#L148-L154
230,626
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_method_mustcompile.php
Smarty_Internal_Method_MustCompile.mustCompile
public function mustCompile(Smarty_Internal_Template $_template) { if (!$_template->source->exists) { if (isset($_template->parent) && $_template->parent->_objType == 2) { $parent_resource = " in '$_template->parent->template_resource}'"; } else { $parent_resource = ''; } throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}"); } if ($_template->mustCompile === null) { $_template->mustCompile = (!$_template->source->handler->uncompiled && ($_template->smarty->force_compile || $_template->source->handler->recompiled || !$_template->compiled->exists || ($_template->smarty->compile_check && $_template->compiled->getTimeStamp() < $_template->source->getTimeStamp()))); } return $_template->mustCompile; }
php
public function mustCompile(Smarty_Internal_Template $_template) { if (!$_template->source->exists) { if (isset($_template->parent) && $_template->parent->_objType == 2) { $parent_resource = " in '$_template->parent->template_resource}'"; } else { $parent_resource = ''; } throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}"); } if ($_template->mustCompile === null) { $_template->mustCompile = (!$_template->source->handler->uncompiled && ($_template->smarty->force_compile || $_template->source->handler->recompiled || !$_template->compiled->exists || ($_template->smarty->compile_check && $_template->compiled->getTimeStamp() < $_template->source->getTimeStamp()))); } return $_template->mustCompile; }
[ "public", "function", "mustCompile", "(", "Smarty_Internal_Template", "$", "_template", ")", "{", "if", "(", "!", "$", "_template", "->", "source", "->", "exists", ")", "{", "if", "(", "isset", "(", "$", "_template", "->", "parent", ")", "&&", "$", "_template", "->", "parent", "->", "_objType", "==", "2", ")", "{", "$", "parent_resource", "=", "\" in '$_template->parent->template_resource}'\"", ";", "}", "else", "{", "$", "parent_resource", "=", "''", ";", "}", "throw", "new", "SmartyException", "(", "\"Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}\"", ")", ";", "}", "if", "(", "$", "_template", "->", "mustCompile", "===", "null", ")", "{", "$", "_template", "->", "mustCompile", "=", "(", "!", "$", "_template", "->", "source", "->", "handler", "->", "uncompiled", "&&", "(", "$", "_template", "->", "smarty", "->", "force_compile", "||", "$", "_template", "->", "source", "->", "handler", "->", "recompiled", "||", "!", "$", "_template", "->", "compiled", "->", "exists", "||", "(", "$", "_template", "->", "smarty", "->", "compile_check", "&&", "$", "_template", "->", "compiled", "->", "getTimeStamp", "(", ")", "<", "$", "_template", "->", "source", "->", "getTimeStamp", "(", ")", ")", ")", ")", ";", "}", "return", "$", "_template", "->", "mustCompile", ";", "}" ]
Returns if the current template must be compiled by the Smarty compiler It does compare the timestamps of template source and the compiled templates and checks the force compile configuration @param \Smarty_Internal_Template $_template @return bool @throws \SmartyException
[ "Returns", "if", "the", "current", "template", "must", "be", "compiled", "by", "the", "Smarty", "compiler", "It", "does", "compare", "the", "timestamps", "of", "template", "source", "and", "the", "compiled", "templates", "and", "checks", "the", "force", "compile", "configuration" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_mustcompile.php#L31-L48
230,627
thrace-project/datagrid-bundle
Doctrine/ORM/DataGridHandler.php
DataGridHandler.applyFilters
private function applyFilters (QueryBuilder $qb, array $filters) { if (!isset($filters['groupOp']) || !in_array($filters['groupOp'], array('AND', 'OR'))){ throw new \InvalidArgumentException('Operator does not match OR | AND'); } if (!isset($filters['rules']) || !is_array($filters['rules'])){ throw new \InvalidArgumentException('Rules are not set.'); } $groupOp = $filters['groupOp']; $andXWithWhere = $qb->expr()->andX(); $andXWithHaving = $qb->expr()->andX(); $orXWithWhere = $qb->expr()->orX(); $orXWithHaving = $qb->expr()->orX(); $supportedAggregateOperators = array('eq', 'ne', 'lt', 'le', 'gt', 'ge'); foreach ($filters['rules'] as $rule) { $rule = $this->getResolvedRule((array) $rule); $field = $this->getFieldQuery($rule['field'], $rule['op'], $rule['data'], $qb); $isAgrigated = $this->isAggregated($rule['field']); if ($groupOp === 'AND'){ if (false === $isAgrigated){ $andXWithWhere->add($field); } else if ($isAgrigated && in_array($rule['op'], $supportedAggregateOperators)){ $andXWithHaving->add($field); } } elseif ($groupOp === 'OR'){ if (false === $isAgrigated){ $orXWithWhere->add($field); } else if ($isAgrigated && in_array($rule['op'], $supportedAggregateOperators)){ $orXWithHaving->add($field); } } } (count($andXWithWhere->getParts()) > 0) ? $qb->andWhere($andXWithWhere) : null; (count($andXWithHaving->getParts()) > 0) ? $qb->andHaving($andXWithHaving) : null; // we use addWhere/addHaving because if we add a where/having clause beforehand then it will be ignored. (count($orXWithWhere->getParts()) > 0) ? $qb->andWhere($orXWithWhere) : null; (count($orXWithHaving->getParts()) > 0) ? $qb->andHaving($orXWithHaving) : null; }
php
private function applyFilters (QueryBuilder $qb, array $filters) { if (!isset($filters['groupOp']) || !in_array($filters['groupOp'], array('AND', 'OR'))){ throw new \InvalidArgumentException('Operator does not match OR | AND'); } if (!isset($filters['rules']) || !is_array($filters['rules'])){ throw new \InvalidArgumentException('Rules are not set.'); } $groupOp = $filters['groupOp']; $andXWithWhere = $qb->expr()->andX(); $andXWithHaving = $qb->expr()->andX(); $orXWithWhere = $qb->expr()->orX(); $orXWithHaving = $qb->expr()->orX(); $supportedAggregateOperators = array('eq', 'ne', 'lt', 'le', 'gt', 'ge'); foreach ($filters['rules'] as $rule) { $rule = $this->getResolvedRule((array) $rule); $field = $this->getFieldQuery($rule['field'], $rule['op'], $rule['data'], $qb); $isAgrigated = $this->isAggregated($rule['field']); if ($groupOp === 'AND'){ if (false === $isAgrigated){ $andXWithWhere->add($field); } else if ($isAgrigated && in_array($rule['op'], $supportedAggregateOperators)){ $andXWithHaving->add($field); } } elseif ($groupOp === 'OR'){ if (false === $isAgrigated){ $orXWithWhere->add($field); } else if ($isAgrigated && in_array($rule['op'], $supportedAggregateOperators)){ $orXWithHaving->add($field); } } } (count($andXWithWhere->getParts()) > 0) ? $qb->andWhere($andXWithWhere) : null; (count($andXWithHaving->getParts()) > 0) ? $qb->andHaving($andXWithHaving) : null; // we use addWhere/addHaving because if we add a where/having clause beforehand then it will be ignored. (count($orXWithWhere->getParts()) > 0) ? $qb->andWhere($orXWithWhere) : null; (count($orXWithHaving->getParts()) > 0) ? $qb->andHaving($orXWithHaving) : null; }
[ "private", "function", "applyFilters", "(", "QueryBuilder", "$", "qb", ",", "array", "$", "filters", ")", "{", "if", "(", "!", "isset", "(", "$", "filters", "[", "'groupOp'", "]", ")", "||", "!", "in_array", "(", "$", "filters", "[", "'groupOp'", "]", ",", "array", "(", "'AND'", ",", "'OR'", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Operator does not match OR | AND'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "filters", "[", "'rules'", "]", ")", "||", "!", "is_array", "(", "$", "filters", "[", "'rules'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Rules are not set.'", ")", ";", "}", "$", "groupOp", "=", "$", "filters", "[", "'groupOp'", "]", ";", "$", "andXWithWhere", "=", "$", "qb", "->", "expr", "(", ")", "->", "andX", "(", ")", ";", "$", "andXWithHaving", "=", "$", "qb", "->", "expr", "(", ")", "->", "andX", "(", ")", ";", "$", "orXWithWhere", "=", "$", "qb", "->", "expr", "(", ")", "->", "orX", "(", ")", ";", "$", "orXWithHaving", "=", "$", "qb", "->", "expr", "(", ")", "->", "orX", "(", ")", ";", "$", "supportedAggregateOperators", "=", "array", "(", "'eq'", ",", "'ne'", ",", "'lt'", ",", "'le'", ",", "'gt'", ",", "'ge'", ")", ";", "foreach", "(", "$", "filters", "[", "'rules'", "]", "as", "$", "rule", ")", "{", "$", "rule", "=", "$", "this", "->", "getResolvedRule", "(", "(", "array", ")", "$", "rule", ")", ";", "$", "field", "=", "$", "this", "->", "getFieldQuery", "(", "$", "rule", "[", "'field'", "]", ",", "$", "rule", "[", "'op'", "]", ",", "$", "rule", "[", "'data'", "]", ",", "$", "qb", ")", ";", "$", "isAgrigated", "=", "$", "this", "->", "isAggregated", "(", "$", "rule", "[", "'field'", "]", ")", ";", "if", "(", "$", "groupOp", "===", "'AND'", ")", "{", "if", "(", "false", "===", "$", "isAgrigated", ")", "{", "$", "andXWithWhere", "->", "add", "(", "$", "field", ")", ";", "}", "else", "if", "(", "$", "isAgrigated", "&&", "in_array", "(", "$", "rule", "[", "'op'", "]", ",", "$", "supportedAggregateOperators", ")", ")", "{", "$", "andXWithHaving", "->", "add", "(", "$", "field", ")", ";", "}", "}", "elseif", "(", "$", "groupOp", "===", "'OR'", ")", "{", "if", "(", "false", "===", "$", "isAgrigated", ")", "{", "$", "orXWithWhere", "->", "add", "(", "$", "field", ")", ";", "}", "else", "if", "(", "$", "isAgrigated", "&&", "in_array", "(", "$", "rule", "[", "'op'", "]", ",", "$", "supportedAggregateOperators", ")", ")", "{", "$", "orXWithHaving", "->", "add", "(", "$", "field", ")", ";", "}", "}", "}", "(", "count", "(", "$", "andXWithWhere", "->", "getParts", "(", ")", ")", ">", "0", ")", "?", "$", "qb", "->", "andWhere", "(", "$", "andXWithWhere", ")", ":", "null", ";", "(", "count", "(", "$", "andXWithHaving", "->", "getParts", "(", ")", ")", ">", "0", ")", "?", "$", "qb", "->", "andHaving", "(", "$", "andXWithHaving", ")", ":", "null", ";", "// we use addWhere/addHaving because if we add a where/having clause beforehand then it will be ignored.\r", "(", "count", "(", "$", "orXWithWhere", "->", "getParts", "(", ")", ")", ">", "0", ")", "?", "$", "qb", "->", "andWhere", "(", "$", "orXWithWhere", ")", ":", "null", ";", "(", "count", "(", "$", "orXWithHaving", "->", "getParts", "(", ")", ")", ">", "0", ")", "?", "$", "qb", "->", "andHaving", "(", "$", "orXWithHaving", ")", ":", "null", ";", "}" ]
Applying the filters on QueryBuilder @param QueryBuilder $qb @param object $filters @return void @throws \RuntimeException
[ "Applying", "the", "filters", "on", "QueryBuilder" ]
07b39d6494336870933756276d6af1ef7039d700
https://github.com/thrace-project/datagrid-bundle/blob/07b39d6494336870933756276d6af1ef7039d700/Doctrine/ORM/DataGridHandler.php#L97-L147
230,628
thrace-project/datagrid-bundle
Doctrine/ORM/DataGridHandler.php
DataGridHandler.isAggregated
private function isAggregated($field) { $cols = $this->getDataGrid()->getColModel(); foreach ($cols as $col){ if ($col['index'] === $field && isset($col['aggregated']) && $col['aggregated'] === true){ return true; } } return false; }
php
private function isAggregated($field) { $cols = $this->getDataGrid()->getColModel(); foreach ($cols as $col){ if ($col['index'] === $field && isset($col['aggregated']) && $col['aggregated'] === true){ return true; } } return false; }
[ "private", "function", "isAggregated", "(", "$", "field", ")", "{", "$", "cols", "=", "$", "this", "->", "getDataGrid", "(", ")", "->", "getColModel", "(", ")", ";", "foreach", "(", "$", "cols", "as", "$", "col", ")", "{", "if", "(", "$", "col", "[", "'index'", "]", "===", "$", "field", "&&", "isset", "(", "$", "col", "[", "'aggregated'", "]", ")", "&&", "$", "col", "[", "'aggregated'", "]", "===", "true", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if field is aggregated value @param string $field @return boolean
[ "Checks", "if", "field", "is", "aggregated", "value" ]
07b39d6494336870933756276d6af1ef7039d700
https://github.com/thrace-project/datagrid-bundle/blob/07b39d6494336870933756276d6af1ef7039d700/Doctrine/ORM/DataGridHandler.php#L210-L221
230,629
cygnite/framework
src/Cygnite/Cache/Storage/Apc.php
Apc.store
public function store($key, $value, $minute = null) { return $this->apc->store($key, $value, $minute = null); }
php
public function store($key, $value, $minute = null) { return $this->apc->store($key, $value, $minute = null); }
[ "public", "function", "store", "(", "$", "key", ",", "$", "value", ",", "$", "minute", "=", "null", ")", "{", "return", "$", "this", "->", "apc", "->", "store", "(", "$", "key", ",", "$", "value", ",", "$", "minute", "=", "null", ")", ";", "}" ]
Store item into apc memory. @param $key @param $value @param null $minute @return mixed
[ "Store", "item", "into", "apc", "memory", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Storage/Apc.php#L63-L66
230,630
cygnite/framework
src/Cygnite/Console/Command/InitCommand.php
InitCommand.process
public function process() { $this->argumentName = $this->argument('name'); $this->appDir = CYGNITE_BASE.DS.APPPATH; $migrateTemplateDir = dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Database'.DS; $migrateInstance = null; $migrateInstance = Migrator::instance($this); $this->table()->makeMigration('migrations'); // We will generate migration class only if class name provided in command if (!is_null($this->argumentName)) { $migrateInstance->setTemplateDir($migrateTemplateDir); $migrateInstance->replaceTemplateByInput(); $file = $migrateInstance->generate(new \DateTime('now', new \DateTimeZone(SET_TIME_ZONE))); if ($file) { $file = APP_NS.DS.'Resources'.DS.'Database'.DS.'Migrations'.DS.$file; $this->info('Your migration class generated in '.$file); } $this->info('Cool!! You are ready to use migration!'); } }
php
public function process() { $this->argumentName = $this->argument('name'); $this->appDir = CYGNITE_BASE.DS.APPPATH; $migrateTemplateDir = dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Database'.DS; $migrateInstance = null; $migrateInstance = Migrator::instance($this); $this->table()->makeMigration('migrations'); // We will generate migration class only if class name provided in command if (!is_null($this->argumentName)) { $migrateInstance->setTemplateDir($migrateTemplateDir); $migrateInstance->replaceTemplateByInput(); $file = $migrateInstance->generate(new \DateTime('now', new \DateTimeZone(SET_TIME_ZONE))); if ($file) { $file = APP_NS.DS.'Resources'.DS.'Database'.DS.'Migrations'.DS.$file; $this->info('Your migration class generated in '.$file); } $this->info('Cool!! You are ready to use migration!'); } }
[ "public", "function", "process", "(", ")", "{", "$", "this", "->", "argumentName", "=", "$", "this", "->", "argument", "(", "'name'", ")", ";", "$", "this", "->", "appDir", "=", "CYGNITE_BASE", ".", "DS", ".", "APPPATH", ";", "$", "migrateTemplateDir", "=", "dirname", "(", "dirname", "(", "__FILE__", ")", ")", ".", "DS", ".", "'src'", ".", "DS", ".", "'Apps'", ".", "DS", ".", "'Database'", ".", "DS", ";", "$", "migrateInstance", "=", "null", ";", "$", "migrateInstance", "=", "Migrator", "::", "instance", "(", "$", "this", ")", ";", "$", "this", "->", "table", "(", ")", "->", "makeMigration", "(", "'migrations'", ")", ";", "// We will generate migration class only if class name provided in command", "if", "(", "!", "is_null", "(", "$", "this", "->", "argumentName", ")", ")", "{", "$", "migrateInstance", "->", "setTemplateDir", "(", "$", "migrateTemplateDir", ")", ";", "$", "migrateInstance", "->", "replaceTemplateByInput", "(", ")", ";", "$", "file", "=", "$", "migrateInstance", "->", "generate", "(", "new", "\\", "DateTime", "(", "'now'", ",", "new", "\\", "DateTimeZone", "(", "SET_TIME_ZONE", ")", ")", ")", ";", "if", "(", "$", "file", ")", "{", "$", "file", "=", "APP_NS", ".", "DS", ".", "'Resources'", ".", "DS", ".", "'Database'", ".", "DS", ".", "'Migrations'", ".", "DS", ".", "$", "file", ";", "$", "this", "->", "info", "(", "'Your migration class generated in '", ".", "$", "file", ")", ";", "}", "$", "this", "->", "info", "(", "'Cool!! You are ready to use migration!'", ")", ";", "}", "}" ]
Execute Command To Initialize Migration Class. @return int|null|void
[ "Execute", "Command", "To", "Initialize", "Migration", "Class", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Command/InitCommand.php#L97-L121
230,631
cygnite/framework
src/Cygnite/Helpers/Profiler.php
Profiler.start
public static function start($startToken = 'cygnite_start') { if (!defined('MEMORY_START_POINT')): define('MEMORY_START_POINT', self::getMemorySpace()); self::$blocks[$startToken] = self::getTime(); endif; }
php
public static function start($startToken = 'cygnite_start') { if (!defined('MEMORY_START_POINT')): define('MEMORY_START_POINT', self::getMemorySpace()); self::$blocks[$startToken] = self::getTime(); endif; }
[ "public", "static", "function", "start", "(", "$", "startToken", "=", "'cygnite_start'", ")", "{", "if", "(", "!", "defined", "(", "'MEMORY_START_POINT'", ")", ")", ":", "define", "(", "'MEMORY_START_POINT'", ",", "self", "::", "getMemorySpace", "(", ")", ")", ";", "self", "::", "$", "blocks", "[", "$", "startToken", "]", "=", "self", "::", "getTime", "(", ")", ";", "endif", ";", "}" ]
Profiler starting point. @false string
[ "Profiler", "starting", "point", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Helpers/Profiler.php#L20-L26
230,632
cygnite/framework
src/Cygnite/Helpers/Profiler.php
Profiler.end
public static function end($endToken = 'cygnite_start') { $html = ''; $html .= "<div id='benchmark'><div class='benchmark'>Total elapsed time : ".round(self::getTime() - self::$blocks[$endToken], 3).' s'; //$html .= self::getMemoryPeakUsage(); $html .= ' &nbsp;&nbsp; &nbsp;Total memory :'.self::getMemorySpaceUsage().'</div></div>'; echo $html; }
php
public static function end($endToken = 'cygnite_start') { $html = ''; $html .= "<div id='benchmark'><div class='benchmark'>Total elapsed time : ".round(self::getTime() - self::$blocks[$endToken], 3).' s'; //$html .= self::getMemoryPeakUsage(); $html .= ' &nbsp;&nbsp; &nbsp;Total memory :'.self::getMemorySpaceUsage().'</div></div>'; echo $html; }
[ "public", "static", "function", "end", "(", "$", "endToken", "=", "'cygnite_start'", ")", "{", "$", "html", "=", "''", ";", "$", "html", ".=", "\"<div id='benchmark'><div class='benchmark'>Total elapsed time : \"", ".", "round", "(", "self", "::", "getTime", "(", ")", "-", "self", "::", "$", "blocks", "[", "$", "endToken", "]", ",", "3", ")", ".", "' s'", ";", "//$html .= self::getMemoryPeakUsage();", "$", "html", ".=", "' &nbsp;&nbsp; &nbsp;Total memory :'", ".", "self", "::", "getMemorySpaceUsage", "(", ")", ".", "'</div></div>'", ";", "echo", "$", "html", ";", "}" ]
Profiler end point. @false string
[ "Profiler", "end", "point", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Helpers/Profiler.php#L43-L50
230,633
cygnite/framework
src/Cygnite/Cache/Storage/File.php
File.store
public function store($key, $value, $expiration = 0) { // $this->getTimeout(); Do delete based on the session time out $data = [ 'time' => time(), 'expire' => $expiration, 'data' => $value, ]; if ($this->where == true) { $this->setCache($key) ->setPath(CYGNITE_BASE.DS.toPath('public.storage.cache').DS); } if (is_array($this->getCache())) { $array = $this->getCache(); $array[$key] = $data; } else { $array = [$key => $data]; } $cacheData = json_encode($array); if ($this->getDirectory() == true) { @file_put_contents($this->getDirectory(), $cacheData); } return $this; }
php
public function store($key, $value, $expiration = 0) { // $this->getTimeout(); Do delete based on the session time out $data = [ 'time' => time(), 'expire' => $expiration, 'data' => $value, ]; if ($this->where == true) { $this->setCache($key) ->setPath(CYGNITE_BASE.DS.toPath('public.storage.cache').DS); } if (is_array($this->getCache())) { $array = $this->getCache(); $array[$key] = $data; } else { $array = [$key => $data]; } $cacheData = json_encode($array); if ($this->getDirectory() == true) { @file_put_contents($this->getDirectory(), $cacheData); } return $this; }
[ "public", "function", "store", "(", "$", "key", ",", "$", "value", ",", "$", "expiration", "=", "0", ")", "{", "// $this->getTimeout(); Do delete based on the session time out", "$", "data", "=", "[", "'time'", "=>", "time", "(", ")", ",", "'expire'", "=>", "$", "expiration", ",", "'data'", "=>", "$", "value", ",", "]", ";", "if", "(", "$", "this", "->", "where", "==", "true", ")", "{", "$", "this", "->", "setCache", "(", "$", "key", ")", "->", "setPath", "(", "CYGNITE_BASE", ".", "DS", ".", "toPath", "(", "'public.storage.cache'", ")", ".", "DS", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "getCache", "(", ")", ")", ")", "{", "$", "array", "=", "$", "this", "->", "getCache", "(", ")", ";", "$", "array", "[", "$", "key", "]", "=", "$", "data", ";", "}", "else", "{", "$", "array", "=", "[", "$", "key", "=>", "$", "data", "]", ";", "}", "$", "cacheData", "=", "json_encode", "(", "$", "array", ")", ";", "if", "(", "$", "this", "->", "getDirectory", "(", ")", "==", "true", ")", "{", "@", "file_put_contents", "(", "$", "this", "->", "getDirectory", "(", ")", ",", "$", "cacheData", ")", ";", "}", "return", "$", "this", ";", "}" ]
Save data into cache. @false string @false mixed @false integer [optional] @param $key @param $value @param int $expiration @return object
[ "Save", "data", "into", "cache", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Storage/File.php#L242-L270
230,634
cygnite/framework
src/Cygnite/Cache/Storage/File.php
File.has
public function has($key) { if ($this->where == true) { $this->setCache($key)->setPath(CYGNITE_BASE.DS.toPath('public.storage.cache').DS); } $cached = $this->getCache(); return !empty($cached[$key]) ? true : false; }
php
public function has($key) { if ($this->where == true) { $this->setCache($key)->setPath(CYGNITE_BASE.DS.toPath('public.storage.cache').DS); } $cached = $this->getCache(); return !empty($cached[$key]) ? true : false; }
[ "public", "function", "has", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "where", "==", "true", ")", "{", "$", "this", "->", "setCache", "(", "$", "key", ")", "->", "setPath", "(", "CYGNITE_BASE", ".", "DS", ".", "toPath", "(", "'public.storage.cache'", ")", ".", "DS", ")", ";", "}", "$", "cached", "=", "$", "this", "->", "getCache", "(", ")", ";", "return", "!", "empty", "(", "$", "cached", "[", "$", "key", "]", ")", "?", "true", ":", "false", ";", "}" ]
Checking cache existence. @param $key @param $key @return bool
[ "Checking", "cache", "existence", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Storage/File.php#L280-L289
230,635
cygnite/framework
src/Cygnite/Cache/Storage/File.php
File.get
public function get($key, $timestamp = false) { if ($this->where == true) { $this->setCache($key)->setPath(CYGNITE_BASE.DS.toPath('public.storage.cache').DS); } $cached = []; $cached = $this->getCache(); if ($timestamp === false) { return $cached[$key]['data']; } else { return $cached[$key]['time']; } }
php
public function get($key, $timestamp = false) { if ($this->where == true) { $this->setCache($key)->setPath(CYGNITE_BASE.DS.toPath('public.storage.cache').DS); } $cached = []; $cached = $this->getCache(); if ($timestamp === false) { return $cached[$key]['data']; } else { return $cached[$key]['time']; } }
[ "public", "function", "get", "(", "$", "key", ",", "$", "timestamp", "=", "false", ")", "{", "if", "(", "$", "this", "->", "where", "==", "true", ")", "{", "$", "this", "->", "setCache", "(", "$", "key", ")", "->", "setPath", "(", "CYGNITE_BASE", ".", "DS", ".", "toPath", "(", "'public.storage.cache'", ")", ".", "DS", ")", ";", "}", "$", "cached", "=", "[", "]", ";", "$", "cached", "=", "$", "this", "->", "getCache", "(", ")", ";", "if", "(", "$", "timestamp", "===", "false", ")", "{", "return", "$", "cached", "[", "$", "key", "]", "[", "'data'", "]", ";", "}", "else", "{", "return", "$", "cached", "[", "$", "key", "]", "[", "'time'", "]", ";", "}", "}" ]
Retrieve cache value from file by key. @false string @false boolean [optional] @param $key @param bool $timestamp @return string
[ "Retrieve", "cache", "value", "from", "file", "by", "key", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Storage/File.php#L302-L316
230,636
cygnite/framework
src/Cygnite/Cache/Storage/File.php
File.destroyExpiredCache
public function destroyExpiredCache() { $cacheData = $this->getCache(); if (true === is_array($cacheData)) { $counter = 0; foreach ($cacheData as $key => $entry) { if (true === $this->isExpired($entry['time'], $entry['expire'])) { unset($cacheData[$key]); $counter++; } } if ($counter > 0) { $cacheData = json_encode($cacheData); @file_put_contents($this->getDirectory(), $cacheData); } return $counter; } }
php
public function destroyExpiredCache() { $cacheData = $this->getCache(); if (true === is_array($cacheData)) { $counter = 0; foreach ($cacheData as $key => $entry) { if (true === $this->isExpired($entry['time'], $entry['expire'])) { unset($cacheData[$key]); $counter++; } } if ($counter > 0) { $cacheData = json_encode($cacheData); @file_put_contents($this->getDirectory(), $cacheData); } return $counter; } }
[ "public", "function", "destroyExpiredCache", "(", ")", "{", "$", "cacheData", "=", "$", "this", "->", "getCache", "(", ")", ";", "if", "(", "true", "===", "is_array", "(", "$", "cacheData", ")", ")", "{", "$", "counter", "=", "0", ";", "foreach", "(", "$", "cacheData", "as", "$", "key", "=>", "$", "entry", ")", "{", "if", "(", "true", "===", "$", "this", "->", "isExpired", "(", "$", "entry", "[", "'time'", "]", ",", "$", "entry", "[", "'expire'", "]", ")", ")", "{", "unset", "(", "$", "cacheData", "[", "$", "key", "]", ")", ";", "$", "counter", "++", ";", "}", "}", "if", "(", "$", "counter", ">", "0", ")", "{", "$", "cacheData", "=", "json_encode", "(", "$", "cacheData", ")", ";", "@", "file_put_contents", "(", "$", "this", "->", "getDirectory", "(", ")", ",", "$", "cacheData", ")", ";", "}", "return", "$", "counter", ";", "}", "}" ]
We will destroy expired cache from the directory. @return int
[ "We", "will", "destroy", "expired", "cache", "from", "the", "directory", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Storage/File.php#L352-L372
230,637
cygnite/framework
src/Cygnite/Cache/Storage/File.php
File.destroyAll
public function destroyAll() { $cacheDir = $this->getDirectory(); if (file_exists($cacheDir)) { $cacheFile = fopen($cacheDir, 'w'); fclose($cacheFile); } return $this; }
php
public function destroyAll() { $cacheDir = $this->getDirectory(); if (file_exists($cacheDir)) { $cacheFile = fopen($cacheDir, 'w'); fclose($cacheFile); } return $this; }
[ "public", "function", "destroyAll", "(", ")", "{", "$", "cacheDir", "=", "$", "this", "->", "getDirectory", "(", ")", ";", "if", "(", "file_exists", "(", "$", "cacheDir", ")", ")", "{", "$", "cacheFile", "=", "fopen", "(", "$", "cacheDir", ",", "'w'", ")", ";", "fclose", "(", "$", "cacheFile", ")", ";", "}", "return", "$", "this", ";", "}" ]
Erase all cached entries. @return object
[ "Erase", "all", "cached", "entries", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Storage/File.php#L400-L410
230,638
cygnite/framework
src/Cygnite/Database/Table/Table.php
Table.getColumns
public function getColumns() { $query = Schema::make(trim($this->tableName), function ($table) { $table->on($this->database); $this->setSchemaInstance($table); return $table->setTableSchema()->getSchemaPreparedQuery(); }); return $this->query($query)->getAll(); }
php
public function getColumns() { $query = Schema::make(trim($this->tableName), function ($table) { $table->on($this->database); $this->setSchemaInstance($table); return $table->setTableSchema()->getSchemaPreparedQuery(); }); return $this->query($query)->getAll(); }
[ "public", "function", "getColumns", "(", ")", "{", "$", "query", "=", "Schema", "::", "make", "(", "trim", "(", "$", "this", "->", "tableName", ")", ",", "function", "(", "$", "table", ")", "{", "$", "table", "->", "on", "(", "$", "this", "->", "database", ")", ";", "$", "this", "->", "setSchemaInstance", "(", "$", "table", ")", ";", "return", "$", "table", "->", "setTableSchema", "(", ")", "->", "getSchemaPreparedQuery", "(", ")", ";", "}", ")", ";", "return", "$", "this", "->", "query", "(", "$", "query", ")", "->", "getAll", "(", ")", ";", "}" ]
Return Column array. @return array
[ "Return", "Column", "array", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Database/Table/Table.php#L61-L71
230,639
cygnite/framework
src/Cygnite/Common/File/Thumbnail/Image.php
Image.setProperties
public function setProperties(array $properties = []) { foreach ($properties as $property => $value) { $method = 'set'.ucfirst($property); if (!method_exists($this, $method)) { throw new \RuntimeException("Undefined method $method."); } if (!in_array($property, $this->validProperties)) { throw new \Exception('You are trying to set invalid properties. Please check valid properties.'); } $this->{$method}($value); } }
php
public function setProperties(array $properties = []) { foreach ($properties as $property => $value) { $method = 'set'.ucfirst($property); if (!method_exists($this, $method)) { throw new \RuntimeException("Undefined method $method."); } if (!in_array($property, $this->validProperties)) { throw new \Exception('You are trying to set invalid properties. Please check valid properties.'); } $this->{$method}($value); } }
[ "public", "function", "setProperties", "(", "array", "$", "properties", "=", "[", "]", ")", "{", "foreach", "(", "$", "properties", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "method", "=", "'set'", ".", "ucfirst", "(", "$", "property", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Undefined method $method.\"", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "property", ",", "$", "this", "->", "validProperties", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'You are trying to set invalid properties. Please check valid properties.'", ")", ";", "}", "$", "this", "->", "{", "$", "method", "}", "(", "$", "value", ")", ";", "}", "}" ]
Set all the properties from given array values. @param array $properties @throws \RuntimeException @throws \Exception
[ "Set", "all", "the", "properties", "from", "given", "array", "values", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/File/Thumbnail/Image.php#L69-L83
230,640
cygnite/framework
src/Cygnite/Common/File/Thumbnail/Image.php
Image.setRootDir
public function setRootDir($rootPath = false) { if (!$rootPath) { $this->rootDir = getcwd().DS; } $this->rootDir = $rootPath.DS; return $this; }
php
public function setRootDir($rootPath = false) { if (!$rootPath) { $this->rootDir = getcwd().DS; } $this->rootDir = $rootPath.DS; return $this; }
[ "public", "function", "setRootDir", "(", "$", "rootPath", "=", "false", ")", "{", "if", "(", "!", "$", "rootPath", ")", "{", "$", "this", "->", "rootDir", "=", "getcwd", "(", ")", ".", "DS", ";", "}", "$", "this", "->", "rootDir", "=", "$", "rootPath", ".", "DS", ";", "return", "$", "this", ";", "}" ]
Set the root directory of image. @param bool $rootPath @return $this
[ "Set", "the", "root", "directory", "of", "image", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/File/Thumbnail/Image.php#L189-L198
230,641
cygnite/framework
src/Cygnite/Common/File/Thumbnail/Image.php
Image.resize
public function resize() { $src = $this->rootDir.DS.str_replace(['/', '\\'], DS, $this->imagePath); /* read the source image */ if (!file_exists($src)) { throw new \Exception("File not found in given path $src."); } $info = getimagesize($src); // get the image size $path = pathinfo($src); $extension = strtolower($path['extension']); if (!in_array($extension, $this->imageTypes)) { throw new \Exception('File type not supported!'); } $thumbName = is_null($this->thumbName) ? $path['basename'] : $this->thumbName.'.'.$path['extension']; $sourceImage = $this->imageCreateFrom(($extension == 'gif') ? 'jpeg' : $extension, $src); $thumbImg = $this->changeDimensions($sourceImage, $this->fixedWidth, $this->fixedHeight); $this->image($extension, $thumbImg, $thumbName); return true; }
php
public function resize() { $src = $this->rootDir.DS.str_replace(['/', '\\'], DS, $this->imagePath); /* read the source image */ if (!file_exists($src)) { throw new \Exception("File not found in given path $src."); } $info = getimagesize($src); // get the image size $path = pathinfo($src); $extension = strtolower($path['extension']); if (!in_array($extension, $this->imageTypes)) { throw new \Exception('File type not supported!'); } $thumbName = is_null($this->thumbName) ? $path['basename'] : $this->thumbName.'.'.$path['extension']; $sourceImage = $this->imageCreateFrom(($extension == 'gif') ? 'jpeg' : $extension, $src); $thumbImg = $this->changeDimensions($sourceImage, $this->fixedWidth, $this->fixedHeight); $this->image($extension, $thumbImg, $thumbName); return true; }
[ "public", "function", "resize", "(", ")", "{", "$", "src", "=", "$", "this", "->", "rootDir", ".", "DS", ".", "str_replace", "(", "[", "'/'", ",", "'\\\\'", "]", ",", "DS", ",", "$", "this", "->", "imagePath", ")", ";", "/* read the source image */", "if", "(", "!", "file_exists", "(", "$", "src", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"File not found in given path $src.\"", ")", ";", "}", "$", "info", "=", "getimagesize", "(", "$", "src", ")", ";", "// get the image size", "$", "path", "=", "pathinfo", "(", "$", "src", ")", ";", "$", "extension", "=", "strtolower", "(", "$", "path", "[", "'extension'", "]", ")", ";", "if", "(", "!", "in_array", "(", "$", "extension", ",", "$", "this", "->", "imageTypes", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'File type not supported!'", ")", ";", "}", "$", "thumbName", "=", "is_null", "(", "$", "this", "->", "thumbName", ")", "?", "$", "path", "[", "'basename'", "]", ":", "$", "this", "->", "thumbName", ".", "'.'", ".", "$", "path", "[", "'extension'", "]", ";", "$", "sourceImage", "=", "$", "this", "->", "imageCreateFrom", "(", "(", "$", "extension", "==", "'gif'", ")", "?", "'jpeg'", ":", "$", "extension", ",", "$", "src", ")", ";", "$", "thumbImg", "=", "$", "this", "->", "changeDimensions", "(", "$", "sourceImage", ",", "$", "this", "->", "fixedWidth", ",", "$", "this", "->", "fixedHeight", ")", ";", "$", "this", "->", "image", "(", "$", "extension", ",", "$", "thumbImg", ",", "$", "thumbName", ")", ";", "return", "true", ";", "}" ]
Resize image as given configurations. @throws \Exception @return bool
[ "Resize", "image", "as", "given", "configurations", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/File/Thumbnail/Image.php#L207-L232
230,642
cygnite/framework
src/Cygnite/Common/File/Thumbnail/Image.php
Image.changeDimensions
public function changeDimensions($sourceImage, $desiredWidth, $desiredHeight) { $temp = ''; // find the height and width of the image if (imagesx($sourceImage) >= imagesy($sourceImage) && imagesx($sourceImage) >= $this->fixedWidth ) { $temp = imagesx($sourceImage) / $this->fixedWidth; $desiredWidth = imagesx($sourceImage) / $temp; $desiredHeight = imagesy($sourceImage) / $temp; } elseif (imagesx($sourceImage) <= imagesy($sourceImage) && imagesy($sourceImage) >= $this->fixedHeight ) { $temp = imagesy($sourceImage) / $this->fixedHeight; $desiredWidth = imagesx($sourceImage) / $temp; $desiredHeight = imagesy($sourceImage) / $temp; } else { $desiredWidth = imagesx($sourceImage); $desiredHeight = imagesy($sourceImage); } // create a new image $thumbImg = imagecreatetruecolor($desiredWidth, $desiredHeight); $imgAllocate = imagecolorallocate($thumbImg, 255, 255, 255); imagefill($thumbImg, 0, 0, $imgAllocate); //copy source image to resize imagecopyresampled( $thumbImg, $sourceImage, 0, 0, 0, 0, $desiredWidth, $desiredHeight, imagesx($sourceImage), imagesy($sourceImage) ); return $thumbImg; }
php
public function changeDimensions($sourceImage, $desiredWidth, $desiredHeight) { $temp = ''; // find the height and width of the image if (imagesx($sourceImage) >= imagesy($sourceImage) && imagesx($sourceImage) >= $this->fixedWidth ) { $temp = imagesx($sourceImage) / $this->fixedWidth; $desiredWidth = imagesx($sourceImage) / $temp; $desiredHeight = imagesy($sourceImage) / $temp; } elseif (imagesx($sourceImage) <= imagesy($sourceImage) && imagesy($sourceImage) >= $this->fixedHeight ) { $temp = imagesy($sourceImage) / $this->fixedHeight; $desiredWidth = imagesx($sourceImage) / $temp; $desiredHeight = imagesy($sourceImage) / $temp; } else { $desiredWidth = imagesx($sourceImage); $desiredHeight = imagesy($sourceImage); } // create a new image $thumbImg = imagecreatetruecolor($desiredWidth, $desiredHeight); $imgAllocate = imagecolorallocate($thumbImg, 255, 255, 255); imagefill($thumbImg, 0, 0, $imgAllocate); //copy source image to resize imagecopyresampled( $thumbImg, $sourceImage, 0, 0, 0, 0, $desiredWidth, $desiredHeight, imagesx($sourceImage), imagesy($sourceImage) ); return $thumbImg; }
[ "public", "function", "changeDimensions", "(", "$", "sourceImage", ",", "$", "desiredWidth", ",", "$", "desiredHeight", ")", "{", "$", "temp", "=", "''", ";", "// find the height and width of the image", "if", "(", "imagesx", "(", "$", "sourceImage", ")", ">=", "imagesy", "(", "$", "sourceImage", ")", "&&", "imagesx", "(", "$", "sourceImage", ")", ">=", "$", "this", "->", "fixedWidth", ")", "{", "$", "temp", "=", "imagesx", "(", "$", "sourceImage", ")", "/", "$", "this", "->", "fixedWidth", ";", "$", "desiredWidth", "=", "imagesx", "(", "$", "sourceImage", ")", "/", "$", "temp", ";", "$", "desiredHeight", "=", "imagesy", "(", "$", "sourceImage", ")", "/", "$", "temp", ";", "}", "elseif", "(", "imagesx", "(", "$", "sourceImage", ")", "<=", "imagesy", "(", "$", "sourceImage", ")", "&&", "imagesy", "(", "$", "sourceImage", ")", ">=", "$", "this", "->", "fixedHeight", ")", "{", "$", "temp", "=", "imagesy", "(", "$", "sourceImage", ")", "/", "$", "this", "->", "fixedHeight", ";", "$", "desiredWidth", "=", "imagesx", "(", "$", "sourceImage", ")", "/", "$", "temp", ";", "$", "desiredHeight", "=", "imagesy", "(", "$", "sourceImage", ")", "/", "$", "temp", ";", "}", "else", "{", "$", "desiredWidth", "=", "imagesx", "(", "$", "sourceImage", ")", ";", "$", "desiredHeight", "=", "imagesy", "(", "$", "sourceImage", ")", ";", "}", "// create a new image", "$", "thumbImg", "=", "imagecreatetruecolor", "(", "$", "desiredWidth", ",", "$", "desiredHeight", ")", ";", "$", "imgAllocate", "=", "imagecolorallocate", "(", "$", "thumbImg", ",", "255", ",", "255", ",", "255", ")", ";", "imagefill", "(", "$", "thumbImg", ",", "0", ",", "0", ",", "$", "imgAllocate", ")", ";", "//copy source image to resize", "imagecopyresampled", "(", "$", "thumbImg", ",", "$", "sourceImage", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "desiredWidth", ",", "$", "desiredHeight", ",", "imagesx", "(", "$", "sourceImage", ")", ",", "imagesy", "(", "$", "sourceImage", ")", ")", ";", "return", "$", "thumbImg", ";", "}" ]
Change dimension of the image. @param $sourceImage @param $desiredWidth @param $desiredHeight @return thumbImage
[ "Change", "dimension", "of", "the", "image", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/File/Thumbnail/Image.php#L280-L321
230,643
cygnite/framework
src/Cygnite/Mvc/View/View.php
View.createAssetCollection
public function createAssetCollection($class) : Asset { $a = AssetCollection::make($this->getContainer(), function ($collection) use ($class) { (new $class($collection->asset()))->register(); return $collection->asset(); }); return $a; }
php
public function createAssetCollection($class) : Asset { $a = AssetCollection::make($this->getContainer(), function ($collection) use ($class) { (new $class($collection->asset()))->register(); return $collection->asset(); }); return $a; }
[ "public", "function", "createAssetCollection", "(", "$", "class", ")", ":", "Asset", "{", "$", "a", "=", "AssetCollection", "::", "make", "(", "$", "this", "->", "getContainer", "(", ")", ",", "function", "(", "$", "collection", ")", "use", "(", "$", "class", ")", "{", "(", "new", "$", "class", "(", "$", "collection", "->", "asset", "(", ")", ")", ")", "->", "register", "(", ")", ";", "return", "$", "collection", "->", "asset", "(", ")", ";", "}", ")", ";", "return", "$", "a", ";", "}" ]
Create Asset collection. @param $class @return mixed
[ "Create", "Asset", "collection", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Mvc/View/View.php#L467-L476
230,644
cygnite/framework
src/Cygnite/Mvc/View/View.php
View.bind
public function bind(string $view, $mapper) { if ($mapper instanceof \Closure) { return $this->set($view, $mapper($this, $view)); } return $this->set($view, $mapper); }
php
public function bind(string $view, $mapper) { if ($mapper instanceof \Closure) { return $this->set($view, $mapper($this, $view)); } return $this->set($view, $mapper); }
[ "public", "function", "bind", "(", "string", "$", "view", ",", "$", "mapper", ")", "{", "if", "(", "$", "mapper", "instanceof", "\\", "Closure", ")", "{", "return", "$", "this", "->", "set", "(", "$", "view", ",", "$", "mapper", "(", "$", "this", ",", "$", "view", ")", ")", ";", "}", "return", "$", "this", "->", "set", "(", "$", "view", ",", "$", "mapper", ")", ";", "}" ]
Bind the event to the view. All the binded events will get triggered before rendering and after rendering view page. @param string $view @param $mapper @return View|mixed
[ "Bind", "the", "event", "to", "the", "view", ".", "All", "the", "binded", "events", "will", "get", "triggered", "before", "rendering", "and", "after", "rendering", "view", "page", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Mvc/View/View.php#L523-L530
230,645
tapestry-cloud/tapestry
src/Entities/Pagination.php
Pagination.getNext
public function getNext() { return is_null($this->next) ? null : new ViewFile($this->project, $this->next); }
php
public function getNext() { return is_null($this->next) ? null : new ViewFile($this->project, $this->next); }
[ "public", "function", "getNext", "(", ")", "{", "return", "is_null", "(", "$", "this", "->", "next", ")", "?", "null", ":", "new", "ViewFile", "(", "$", "this", "->", "project", ",", "$", "this", "->", "next", ")", ";", "}" ]
Get the next page, or null if we are the last page. @return null|ViewFile
[ "Get", "the", "next", "page", "or", "null", "if", "we", "are", "the", "last", "page", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Entities/Pagination.php#L106-L109
230,646
tapestry-cloud/tapestry
src/Entities/Pagination.php
Pagination.getPrevious
public function getPrevious() { return is_null($this->previous) ? null : new ViewFile($this->project, $this->previous); }
php
public function getPrevious() { return is_null($this->previous) ? null : new ViewFile($this->project, $this->previous); }
[ "public", "function", "getPrevious", "(", ")", "{", "return", "is_null", "(", "$", "this", "->", "previous", ")", "?", "null", ":", "new", "ViewFile", "(", "$", "this", "->", "project", ",", "$", "this", "->", "previous", ")", ";", "}" ]
Get the previous page, or null if we are the first page. @return null|ViewFile
[ "Get", "the", "previous", "page", "or", "null", "if", "we", "are", "the", "first", "page", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Entities/Pagination.php#L116-L119
230,647
michaeljennings/feed
src/Feed.php
Feed.push
public function push($notification, $notifiable) { if ( ! is_array($notifiable) && ! $notifiable instanceof Traversable) { $notifiable = [$notifiable]; } foreach ($notifiable as $toBeNotified) { if ( ! $toBeNotified instanceof Notifiable && !$toBeNotified instanceof NotifiableGroup) { throw new NotNotifiableException("The notifiable members must implement the notifiable interface."); } } $notification = is_string($notification) ? ['body' => $notification] : $notification; foreach ($notifiable as $toBeNotified) { $this->pushNotification($notification, $toBeNotified); } }
php
public function push($notification, $notifiable) { if ( ! is_array($notifiable) && ! $notifiable instanceof Traversable) { $notifiable = [$notifiable]; } foreach ($notifiable as $toBeNotified) { if ( ! $toBeNotified instanceof Notifiable && !$toBeNotified instanceof NotifiableGroup) { throw new NotNotifiableException("The notifiable members must implement the notifiable interface."); } } $notification = is_string($notification) ? ['body' => $notification] : $notification; foreach ($notifiable as $toBeNotified) { $this->pushNotification($notification, $toBeNotified); } }
[ "public", "function", "push", "(", "$", "notification", ",", "$", "notifiable", ")", "{", "if", "(", "!", "is_array", "(", "$", "notifiable", ")", "&&", "!", "$", "notifiable", "instanceof", "Traversable", ")", "{", "$", "notifiable", "=", "[", "$", "notifiable", "]", ";", "}", "foreach", "(", "$", "notifiable", "as", "$", "toBeNotified", ")", "{", "if", "(", "!", "$", "toBeNotified", "instanceof", "Notifiable", "&&", "!", "$", "toBeNotified", "instanceof", "NotifiableGroup", ")", "{", "throw", "new", "NotNotifiableException", "(", "\"The notifiable members must implement the notifiable interface.\"", ")", ";", "}", "}", "$", "notification", "=", "is_string", "(", "$", "notification", ")", "?", "[", "'body'", "=>", "$", "notification", "]", ":", "$", "notification", ";", "foreach", "(", "$", "notifiable", "as", "$", "toBeNotified", ")", "{", "$", "this", "->", "pushNotification", "(", "$", "notification", ",", "$", "toBeNotified", ")", ";", "}", "}" ]
Push the provided notification to the notifiable members. @param string|array $notification @param Notifiable[]|Notifiable $notifiable @throws NotNotifiableException
[ "Push", "the", "provided", "notification", "to", "the", "notifiable", "members", "." ]
687cae75dae7ce6cbf81678ffe1615faf6cbe0d6
https://github.com/michaeljennings/feed/blob/687cae75dae7ce6cbf81678ffe1615faf6cbe0d6/src/Feed.php#L39-L56
230,648
michaeljennings/feed
src/Feed.php
Feed.pushNotification
protected function pushNotification($notification, $notifiable) { if ($notifiable instanceof NotifiableGroup) { foreach ($notifiable->getGroup() as $toBeNotified) { $this->push($notification, $toBeNotified); } } else { // @todo Change this fucking shite $notification = $notifiable->notifications()->create($notification); event(new NotificationAdded($notification, $notifiable)); } }
php
protected function pushNotification($notification, $notifiable) { if ($notifiable instanceof NotifiableGroup) { foreach ($notifiable->getGroup() as $toBeNotified) { $this->push($notification, $toBeNotified); } } else { // @todo Change this fucking shite $notification = $notifiable->notifications()->create($notification); event(new NotificationAdded($notification, $notifiable)); } }
[ "protected", "function", "pushNotification", "(", "$", "notification", ",", "$", "notifiable", ")", "{", "if", "(", "$", "notifiable", "instanceof", "NotifiableGroup", ")", "{", "foreach", "(", "$", "notifiable", "->", "getGroup", "(", ")", "as", "$", "toBeNotified", ")", "{", "$", "this", "->", "push", "(", "$", "notification", ",", "$", "toBeNotified", ")", ";", "}", "}", "else", "{", "// @todo Change this fucking shite", "$", "notification", "=", "$", "notifiable", "->", "notifications", "(", ")", "->", "create", "(", "$", "notification", ")", ";", "event", "(", "new", "NotificationAdded", "(", "$", "notification", ",", "$", "notifiable", ")", ")", ";", "}", "}" ]
Push a notification to a member. @param string|array $notification @param Notifiable $notifiable
[ "Push", "a", "notification", "to", "a", "member", "." ]
687cae75dae7ce6cbf81678ffe1615faf6cbe0d6
https://github.com/michaeljennings/feed/blob/687cae75dae7ce6cbf81678ffe1615faf6cbe0d6/src/Feed.php#L64-L76
230,649
michaeljennings/feed
src/Feed.php
Feed.pull
public function pull($notifiable) { if ( ! is_array($notifiable)) { $notifiable = func_get_args(); } $notifiable = $this->getUsersToPullFor($notifiable); $types = array_map(function ($notifiable) { return get_class($notifiable); }, $notifiable); $ids = array_map(function ($notifiable) { return $notifiable->getKey(); }, $notifiable); return $this->store->getNotifications($types, $ids); }
php
public function pull($notifiable) { if ( ! is_array($notifiable)) { $notifiable = func_get_args(); } $notifiable = $this->getUsersToPullFor($notifiable); $types = array_map(function ($notifiable) { return get_class($notifiable); }, $notifiable); $ids = array_map(function ($notifiable) { return $notifiable->getKey(); }, $notifiable); return $this->store->getNotifications($types, $ids); }
[ "public", "function", "pull", "(", "$", "notifiable", ")", "{", "if", "(", "!", "is_array", "(", "$", "notifiable", ")", ")", "{", "$", "notifiable", "=", "func_get_args", "(", ")", ";", "}", "$", "notifiable", "=", "$", "this", "->", "getUsersToPullFor", "(", "$", "notifiable", ")", ";", "$", "types", "=", "array_map", "(", "function", "(", "$", "notifiable", ")", "{", "return", "get_class", "(", "$", "notifiable", ")", ";", "}", ",", "$", "notifiable", ")", ";", "$", "ids", "=", "array_map", "(", "function", "(", "$", "notifiable", ")", "{", "return", "$", "notifiable", "->", "getKey", "(", ")", ";", "}", ",", "$", "notifiable", ")", ";", "return", "$", "this", "->", "store", "->", "getNotifications", "(", "$", "types", ",", "$", "ids", ")", ";", "}" ]
Get all of the unread notifications for the provided notifiable members. @param array|Notifiable $notifiable @return mixed @throws NotNotifiableException
[ "Get", "all", "of", "the", "unread", "notifications", "for", "the", "provided", "notifiable", "members", "." ]
687cae75dae7ce6cbf81678ffe1615faf6cbe0d6
https://github.com/michaeljennings/feed/blob/687cae75dae7ce6cbf81678ffe1615faf6cbe0d6/src/Feed.php#L85-L102
230,650
michaeljennings/feed
src/Feed.php
Feed.getUsersToPullFor
protected function getUsersToPullFor($notifiable) { foreach ($notifiable as $key => $toBeNotified) { if ( ! $toBeNotified instanceof Notifiable && ! $toBeNotified instanceof NotifiableGroup) { throw new NotNotifiableException("The members passed to the pull must implement the notifiable interface"); } if ($toBeNotified instanceof NotifiableGroup) { $group = $toBeNotified->getGroup(); if ($group instanceof Collection) { $group = $group->all(); } $notifiable = array_merge($notifiable, $group); unset($notifiable[$key]); } } return $notifiable; }
php
protected function getUsersToPullFor($notifiable) { foreach ($notifiable as $key => $toBeNotified) { if ( ! $toBeNotified instanceof Notifiable && ! $toBeNotified instanceof NotifiableGroup) { throw new NotNotifiableException("The members passed to the pull must implement the notifiable interface"); } if ($toBeNotified instanceof NotifiableGroup) { $group = $toBeNotified->getGroup(); if ($group instanceof Collection) { $group = $group->all(); } $notifiable = array_merge($notifiable, $group); unset($notifiable[$key]); } } return $notifiable; }
[ "protected", "function", "getUsersToPullFor", "(", "$", "notifiable", ")", "{", "foreach", "(", "$", "notifiable", "as", "$", "key", "=>", "$", "toBeNotified", ")", "{", "if", "(", "!", "$", "toBeNotified", "instanceof", "Notifiable", "&&", "!", "$", "toBeNotified", "instanceof", "NotifiableGroup", ")", "{", "throw", "new", "NotNotifiableException", "(", "\"The members passed to the pull must implement the notifiable interface\"", ")", ";", "}", "if", "(", "$", "toBeNotified", "instanceof", "NotifiableGroup", ")", "{", "$", "group", "=", "$", "toBeNotified", "->", "getGroup", "(", ")", ";", "if", "(", "$", "group", "instanceof", "Collection", ")", "{", "$", "group", "=", "$", "group", "->", "all", "(", ")", ";", "}", "$", "notifiable", "=", "array_merge", "(", "$", "notifiable", ",", "$", "group", ")", ";", "unset", "(", "$", "notifiable", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "notifiable", ";", "}" ]
Get the users to pull notifications for from the notifiable members. @param array $notifiable @return array @throws NotNotifiableException
[ "Get", "the", "users", "to", "pull", "notifications", "for", "from", "the", "notifiable", "members", "." ]
687cae75dae7ce6cbf81678ffe1615faf6cbe0d6
https://github.com/michaeljennings/feed/blob/687cae75dae7ce6cbf81678ffe1615faf6cbe0d6/src/Feed.php#L136-L157
230,651
cygnite/framework
src/Cygnite/Router/Controller/RouteController.php
RouteController.triggerActionEvent
private function triggerActionEvent($instance, $action, $type = 'before') { if (method_exists($instance, $type . ucfirst($action))) { call_user_func([$instance, $type . ucfirst($action)]); } }
php
private function triggerActionEvent($instance, $action, $type = 'before') { if (method_exists($instance, $type . ucfirst($action))) { call_user_func([$instance, $type . ucfirst($action)]); } }
[ "private", "function", "triggerActionEvent", "(", "$", "instance", ",", "$", "action", ",", "$", "type", "=", "'before'", ")", "{", "if", "(", "method_exists", "(", "$", "instance", ",", "$", "type", ".", "ucfirst", "(", "$", "action", ")", ")", ")", "{", "call_user_func", "(", "[", "$", "instance", ",", "$", "type", ".", "ucfirst", "(", "$", "action", ")", "]", ")", ";", "}", "}" ]
Trigger controller action events. @param $instance @param $action @param string $type
[ "Trigger", "controller", "action", "events", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Router/Controller/RouteController.php#L311-L316
230,652
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.make
public static function make($content = '', $statusCode = ResponseHeader::HTTP_OK, $headers = []) { // We will check if statusCode given as Closure object if ($statusCode instanceof \Closure) { return $statusCode(new static($content, ResponseHeader::HTTP_OK, $headers)); } return new static($content, $statusCode, $headers); }
php
public static function make($content = '', $statusCode = ResponseHeader::HTTP_OK, $headers = []) { // We will check if statusCode given as Closure object if ($statusCode instanceof \Closure) { return $statusCode(new static($content, ResponseHeader::HTTP_OK, $headers)); } return new static($content, $statusCode, $headers); }
[ "public", "static", "function", "make", "(", "$", "content", "=", "''", ",", "$", "statusCode", "=", "ResponseHeader", "::", "HTTP_OK", ",", "$", "headers", "=", "[", "]", ")", "{", "// We will check if statusCode given as Closure object", "if", "(", "$", "statusCode", "instanceof", "\\", "Closure", ")", "{", "return", "$", "statusCode", "(", "new", "static", "(", "$", "content", ",", "ResponseHeader", "::", "HTTP_OK", ",", "$", "headers", ")", ")", ";", "}", "return", "new", "static", "(", "$", "content", ",", "$", "statusCode", ",", "$", "headers", ")", ";", "}" ]
Returns Response object. <code> Response::make($content, ResponseHeader::HTTP_OK)->send(); Response::make($content, function ($response) { return $response->setHeader($key, $value)->send(); }); </code> @param string $content @param callable|int $statusCode @param array $headers @return static
[ "Returns", "Response", "object", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L79-L87
230,653
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.json
public static function json($content = null, array $headers = [], $prettyPrint = false) { return new JsonResponse($content, $headers, $prettyPrint); }
php
public static function json($content = null, array $headers = [], $prettyPrint = false) { return new JsonResponse($content, $headers, $prettyPrint); }
[ "public", "static", "function", "json", "(", "$", "content", "=", "null", ",", "array", "$", "headers", "=", "[", "]", ",", "$", "prettyPrint", "=", "false", ")", "{", "return", "new", "JsonResponse", "(", "$", "content", ",", "$", "headers", ",", "$", "prettyPrint", ")", ";", "}" ]
Create Json response. @param type $content @param array $headers @param type $prettyPrint @return \Cygnite\Http\Responses\JsonResponse
[ "Create", "Json", "response", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L98-L101
230,654
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.streamed
public static function streamed(callable $callback = null, $status = ResponseHeader::HTTP_OK, $headers = []) { return new StreamedResponse($callback, $status, $headers); }
php
public static function streamed(callable $callback = null, $status = ResponseHeader::HTTP_OK, $headers = []) { return new StreamedResponse($callback, $status, $headers); }
[ "public", "static", "function", "streamed", "(", "callable", "$", "callback", "=", "null", ",", "$", "status", "=", "ResponseHeader", "::", "HTTP_OK", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "new", "StreamedResponse", "(", "$", "callback", ",", "$", "status", ",", "$", "headers", ")", ";", "}" ]
Create a Streamed Response. @param \Cygnite\Http\Responses\callable $callback @param type $status @param type $headers @return \Cygnite\Http\Responses\StreamedResponse
[ "Create", "a", "Streamed", "Response", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L112-L115
230,655
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.setContent
public function setContent($content = null) { if (null !== $content && !is_string($content)) { throw new ResponseException('Response content must be a string.'); } $this->content = (string) $content; return $this; }
php
public function setContent($content = null) { if (null !== $content && !is_string($content)) { throw new ResponseException('Response content must be a string.'); } $this->content = (string) $content; return $this; }
[ "public", "function", "setContent", "(", "$", "content", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "content", "&&", "!", "is_string", "(", "$", "content", ")", ")", "{", "throw", "new", "ResponseException", "(", "'Response content must be a string.'", ")", ";", "}", "$", "this", "->", "content", "=", "(", "string", ")", "$", "content", ";", "return", "$", "this", ";", "}" ]
Set content for the http response object. @param $content @throws \Cygnite\Exception\Http\ResponseException @return $this
[ "Set", "content", "for", "the", "http", "response", "object", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L126-L135
230,656
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.statusMessage
public function statusMessage($message = '') { $statusCode = $this->getStatusCode(); if (!isset(ResponseHeader::$httpStatus[$statusCode])) { throw new ResponseException(sprintf('Invalid status code provided %s', $statusCode)); } if (!empty($message)) { $this->statusMessage = $message; return $this; } $this->statusMessage = ResponseHeader::$httpStatus[$statusCode]; return $this; }
php
public function statusMessage($message = '') { $statusCode = $this->getStatusCode(); if (!isset(ResponseHeader::$httpStatus[$statusCode])) { throw new ResponseException(sprintf('Invalid status code provided %s', $statusCode)); } if (!empty($message)) { $this->statusMessage = $message; return $this; } $this->statusMessage = ResponseHeader::$httpStatus[$statusCode]; return $this; }
[ "public", "function", "statusMessage", "(", "$", "message", "=", "''", ")", "{", "$", "statusCode", "=", "$", "this", "->", "getStatusCode", "(", ")", ";", "if", "(", "!", "isset", "(", "ResponseHeader", "::", "$", "httpStatus", "[", "$", "statusCode", "]", ")", ")", "{", "throw", "new", "ResponseException", "(", "sprintf", "(", "'Invalid status code provided %s'", ",", "$", "statusCode", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "message", ")", ")", "{", "$", "this", "->", "statusMessage", "=", "$", "message", ";", "return", "$", "this", ";", "}", "$", "this", "->", "statusMessage", "=", "ResponseHeader", "::", "$", "httpStatus", "[", "$", "statusCode", "]", ";", "return", "$", "this", ";", "}" ]
Set Status Message. @param string $message @throws \Cygnite\Exception\Http\ResponseException @return $this
[ "Set", "Status", "Message", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L180-L197
230,657
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.setHeader
public function setHeader($name, $value, $replace = false) { // Add multiple headers for the reponse as array if (is_array($name)) { foreach ($name as $headerKey => $headerValue) { $this->headers->set($headerKey, $headerValue, $replace); } return $this; } $this->headers->set($name, $value, $replace); return $this; }
php
public function setHeader($name, $value, $replace = false) { // Add multiple headers for the reponse as array if (is_array($name)) { foreach ($name as $headerKey => $headerValue) { $this->headers->set($headerKey, $headerValue, $replace); } return $this; } $this->headers->set($name, $value, $replace); return $this; }
[ "public", "function", "setHeader", "(", "$", "name", ",", "$", "value", ",", "$", "replace", "=", "false", ")", "{", "// Add multiple headers for the reponse as array", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "name", "as", "$", "headerKey", "=>", "$", "headerValue", ")", "{", "$", "this", "->", "headers", "->", "set", "(", "$", "headerKey", ",", "$", "headerValue", ",", "$", "replace", ")", ";", "}", "return", "$", "this", ";", "}", "$", "this", "->", "headers", "->", "set", "(", "$", "name", ",", "$", "value", ",", "$", "replace", ")", ";", "return", "$", "this", ";", "}" ]
Set HTTP headers here. @param $name @param $value @param $replace @return $this
[ "Set", "HTTP", "headers", "here", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L213-L227
230,658
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.setAsNotModified
public function setAsNotModified() { $this->setStatusCode(304)->setContent(null); $headersToRemove = [ 'Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified', ]; foreach ($headersToRemove as $header) { //remove header key $this->headers->remove($header); } return $this; }
php
public function setAsNotModified() { $this->setStatusCode(304)->setContent(null); $headersToRemove = [ 'Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-MD5', 'Content-Type', 'Last-Modified', ]; foreach ($headersToRemove as $header) { //remove header key $this->headers->remove($header); } return $this; }
[ "public", "function", "setAsNotModified", "(", ")", "{", "$", "this", "->", "setStatusCode", "(", "304", ")", "->", "setContent", "(", "null", ")", ";", "$", "headersToRemove", "=", "[", "'Allow'", ",", "'Content-Encoding'", ",", "'Content-Language'", ",", "'Content-Length'", ",", "'Content-MD5'", ",", "'Content-Type'", ",", "'Last-Modified'", ",", "]", ";", "foreach", "(", "$", "headersToRemove", "as", "$", "header", ")", "{", "//remove header key", "$", "this", "->", "headers", "->", "remove", "(", "$", "header", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove status, response body and all headers for 304 response. @return $this
[ "Remove", "status", "response", "body", "and", "all", "headers", "for", "304", "response", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L323-L343
230,659
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.sendHeaders
public function sendHeaders() { // Throw exception if header already sent if ($this->headersSent()) { throw new ResponseException('Cannot send headers, headers already sent.'); } /* | If headers not set already we will set header here */ if (!$this->headers->has('Content-Type')) { $this->setHeader('Content-Type', $this->getContentType().'; charset='.$this->getCharset()); } // Check if script is running in FCGI server if ($this->server('FCGI_SERVER_VERSION')) { //We will set Header for Fast-CGI server $this->setFastCgiHeader(); } else { $this->setHeaderForServer(); } foreach ($this->headers->all() as $name => $values) { foreach ($values as $value) { // Create the header and send it is_string($name) && $value = "{$name}: {$value}"; header($value, true); } } return $this; }
php
public function sendHeaders() { // Throw exception if header already sent if ($this->headersSent()) { throw new ResponseException('Cannot send headers, headers already sent.'); } /* | If headers not set already we will set header here */ if (!$this->headers->has('Content-Type')) { $this->setHeader('Content-Type', $this->getContentType().'; charset='.$this->getCharset()); } // Check if script is running in FCGI server if ($this->server('FCGI_SERVER_VERSION')) { //We will set Header for Fast-CGI server $this->setFastCgiHeader(); } else { $this->setHeaderForServer(); } foreach ($this->headers->all() as $name => $values) { foreach ($values as $value) { // Create the header and send it is_string($name) && $value = "{$name}: {$value}"; header($value, true); } } return $this; }
[ "public", "function", "sendHeaders", "(", ")", "{", "// Throw exception if header already sent", "if", "(", "$", "this", "->", "headersSent", "(", ")", ")", "{", "throw", "new", "ResponseException", "(", "'Cannot send headers, headers already sent.'", ")", ";", "}", "/*\n | If headers not set already we will set header here\n */", "if", "(", "!", "$", "this", "->", "headers", "->", "has", "(", "'Content-Type'", ")", ")", "{", "$", "this", "->", "setHeader", "(", "'Content-Type'", ",", "$", "this", "->", "getContentType", "(", ")", ".", "'; charset='", ".", "$", "this", "->", "getCharset", "(", ")", ")", ";", "}", "// Check if script is running in FCGI server", "if", "(", "$", "this", "->", "server", "(", "'FCGI_SERVER_VERSION'", ")", ")", "{", "//We will set Header for Fast-CGI server", "$", "this", "->", "setFastCgiHeader", "(", ")", ";", "}", "else", "{", "$", "this", "->", "setHeaderForServer", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "headers", "->", "all", "(", ")", "as", "$", "name", "=>", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "// Create the header and send it", "is_string", "(", "$", "name", ")", "&&", "$", "value", "=", "\"{$name}: {$value}\"", ";", "header", "(", "$", "value", ",", "true", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Send HTTP response headers. @throws \Cygnite\Exception\Http\ResponseException @return $this
[ "Send", "HTTP", "response", "headers", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L370-L401
230,660
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.setFastCgiHeader
protected function setFastCgiHeader() { $message = 'Unknown Status'; if (isset(ResponseHeader::$httpStatus[$this->getStatusCode()])) { $message = ResponseHeader::$httpStatus[$this->getStatusCode()]; } header('Status: '.$this->getStatusCode().' '.$message); }
php
protected function setFastCgiHeader() { $message = 'Unknown Status'; if (isset(ResponseHeader::$httpStatus[$this->getStatusCode()])) { $message = ResponseHeader::$httpStatus[$this->getStatusCode()]; } header('Status: '.$this->getStatusCode().' '.$message); }
[ "protected", "function", "setFastCgiHeader", "(", ")", "{", "$", "message", "=", "'Unknown Status'", ";", "if", "(", "isset", "(", "ResponseHeader", "::", "$", "httpStatus", "[", "$", "this", "->", "getStatusCode", "(", ")", "]", ")", ")", "{", "$", "message", "=", "ResponseHeader", "::", "$", "httpStatus", "[", "$", "this", "->", "getStatusCode", "(", ")", "]", ";", "}", "header", "(", "'Status: '", ".", "$", "this", "->", "getStatusCode", "(", ")", ".", "' '", ".", "$", "message", ")", ";", "}" ]
We will set header for server script.
[ "We", "will", "set", "header", "for", "server", "script", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L406-L415
230,661
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.setHeaderForServer
protected function setHeaderForServer() { header($this->protocol().' '.$this->getStatusCode().' '.ResponseHeader::$httpStatus[$this->getStatusCode()]); }
php
protected function setHeaderForServer() { header($this->protocol().' '.$this->getStatusCode().' '.ResponseHeader::$httpStatus[$this->getStatusCode()]); }
[ "protected", "function", "setHeaderForServer", "(", ")", "{", "header", "(", "$", "this", "->", "protocol", "(", ")", ".", "' '", ".", "$", "this", "->", "getStatusCode", "(", ")", ".", "' '", ".", "ResponseHeader", "::", "$", "httpStatus", "[", "$", "this", "->", "getStatusCode", "(", ")", "]", ")", ";", "}" ]
Set header for FCGI based servers.
[ "Set", "header", "for", "FCGI", "based", "servers", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L420-L423
230,662
cygnite/framework
src/Cygnite/Http/Responses/Response.php
Response.send
public function send() { $this->sendHeaders()->sendContent(); // close the request if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif (strtolower(PHP_SAPI) != 'cli') { if (ob_get_length()) { ob_end_flush(); } } return $this; }
php
public function send() { $this->sendHeaders()->sendContent(); // close the request if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif (strtolower(PHP_SAPI) != 'cli') { if (ob_get_length()) { ob_end_flush(); } } return $this; }
[ "public", "function", "send", "(", ")", "{", "$", "this", "->", "sendHeaders", "(", ")", "->", "sendContent", "(", ")", ";", "// close the request", "if", "(", "function_exists", "(", "'fastcgi_finish_request'", ")", ")", "{", "fastcgi_finish_request", "(", ")", ";", "}", "elseif", "(", "strtolower", "(", "PHP_SAPI", ")", "!=", "'cli'", ")", "{", "if", "(", "ob_get_length", "(", ")", ")", "{", "ob_end_flush", "(", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Send header and content to the browser. @return $this
[ "Send", "header", "and", "content", "to", "the", "browser", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Http/Responses/Response.php#L452-L466
230,663
cygnite/framework
src/Cygnite/EventHandler/EventRegistrarTrait.php
EventRegistrarTrait.registerEvents
public function registerEvents($events) { if (empty($events)) { throw new \RuntimeException(sprintf('Empty argument passed %s', __FUNCTION__)); } foreach ($events as $event => $namespace) { $parts = explode('@', $namespace); // attach all before and after event to handler $this->register("$event.before", $parts[0].'@before'.ucfirst(Inflector::pathAction(end($parts)))) ->register("$event", $parts[0].'@'.Inflector::pathAction(end($parts))) ->register("$event.after", $parts[0].'@after'.ucfirst(Inflector::pathAction(end($parts)))); } }
php
public function registerEvents($events) { if (empty($events)) { throw new \RuntimeException(sprintf('Empty argument passed %s', __FUNCTION__)); } foreach ($events as $event => $namespace) { $parts = explode('@', $namespace); // attach all before and after event to handler $this->register("$event.before", $parts[0].'@before'.ucfirst(Inflector::pathAction(end($parts)))) ->register("$event", $parts[0].'@'.Inflector::pathAction(end($parts))) ->register("$event.after", $parts[0].'@after'.ucfirst(Inflector::pathAction(end($parts)))); } }
[ "public", "function", "registerEvents", "(", "$", "events", ")", "{", "if", "(", "empty", "(", "$", "events", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Empty argument passed %s'", ",", "__FUNCTION__", ")", ")", ";", "}", "foreach", "(", "$", "events", "as", "$", "event", "=>", "$", "namespace", ")", "{", "$", "parts", "=", "explode", "(", "'@'", ",", "$", "namespace", ")", ";", "// attach all before and after event to handler", "$", "this", "->", "register", "(", "\"$event.before\"", ",", "$", "parts", "[", "0", "]", ".", "'@before'", ".", "ucfirst", "(", "Inflector", "::", "pathAction", "(", "end", "(", "$", "parts", ")", ")", ")", ")", "->", "register", "(", "\"$event\"", ",", "$", "parts", "[", "0", "]", ".", "'@'", ".", "Inflector", "::", "pathAction", "(", "end", "(", "$", "parts", ")", ")", ")", "->", "register", "(", "\"$event.after\"", ",", "$", "parts", "[", "0", "]", ".", "'@after'", ".", "ucfirst", "(", "Inflector", "::", "pathAction", "(", "end", "(", "$", "parts", ")", ")", ")", ")", ";", "}", "}" ]
We will register user defined events, it will trigger event when matches. @param $events @throws \RuntimeException
[ "We", "will", "register", "user", "defined", "events", "it", "will", "trigger", "event", "when", "matches", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/EventHandler/EventRegistrarTrait.php#L38-L51
230,664
cygnite/framework
src/Cygnite/EventHandler/EventRegistrarTrait.php
EventRegistrarTrait.fire
public function fire($event) { $this->dispatch("$event.before"); $this->dispatch($event); $this->dispatch("$event.after"); return $this; }
php
public function fire($event) { $this->dispatch("$event.before"); $this->dispatch($event); $this->dispatch("$event.after"); return $this; }
[ "public", "function", "fire", "(", "$", "event", ")", "{", "$", "this", "->", "dispatch", "(", "\"$event.before\"", ")", ";", "$", "this", "->", "dispatch", "(", "$", "event", ")", ";", "$", "this", "->", "dispatch", "(", "\"$event.after\"", ")", ";", "return", "$", "this", ";", "}" ]
Fire all events registered with EventHandler. @param $event @return $this
[ "Fire", "all", "events", "registered", "with", "EventHandler", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/EventHandler/EventRegistrarTrait.php#L59-L66
230,665
cygnite/framework
src/Cygnite/Common/File/FileExtensionFilter.php
FileExtensionFilter.accept
public function accept() { $file = $this->getInnerIterator()->current(); // If we somehow have something other than an SplFileInfo object, just // return false if (!$file instanceof \SplFileInfo) { return false; } // If we have a directory, it's not a file, so return false if (!$file->isFile()) { return false; } // If not a PHP file, skip if ($file->getBasename('.php') == $file->getBasename()) { return false; } return in_array($this->getExtension(), $this->ext); }
php
public function accept() { $file = $this->getInnerIterator()->current(); // If we somehow have something other than an SplFileInfo object, just // return false if (!$file instanceof \SplFileInfo) { return false; } // If we have a directory, it's not a file, so return false if (!$file->isFile()) { return false; } // If not a PHP file, skip if ($file->getBasename('.php') == $file->getBasename()) { return false; } return in_array($this->getExtension(), $this->ext); }
[ "public", "function", "accept", "(", ")", "{", "$", "file", "=", "$", "this", "->", "getInnerIterator", "(", ")", "->", "current", "(", ")", ";", "// If we somehow have something other than an SplFileInfo object, just", "// return false", "if", "(", "!", "$", "file", "instanceof", "\\", "SplFileInfo", ")", "{", "return", "false", ";", "}", "// If we have a directory, it's not a file, so return false", "if", "(", "!", "$", "file", "->", "isFile", "(", ")", ")", "{", "return", "false", ";", "}", "// If not a PHP file, skip", "if", "(", "$", "file", "->", "getBasename", "(", "'.php'", ")", "==", "$", "file", "->", "getBasename", "(", ")", ")", "{", "return", "false", ";", "}", "return", "in_array", "(", "$", "this", "->", "getExtension", "(", ")", ",", "$", "this", "->", "ext", ")", ";", "}" ]
an abstract method which must be implemented in subclass
[ "an", "abstract", "method", "which", "must", "be", "implemented", "in", "subclass" ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/File/FileExtensionFilter.php#L37-L58
230,666
cygnite/framework
src/Cygnite/Foundation/Bootstrappers/AliasLoaderBootstraper.php
AliasLoaderBootstraper.run
public function run() { $config = Config::get('global.config', 'aliases'); $alias = new Manager($config['classes']); $alias->register(); $this->container->set('alias', $alias); }
php
public function run() { $config = Config::get('global.config', 'aliases'); $alias = new Manager($config['classes']); $alias->register(); $this->container->set('alias', $alias); }
[ "public", "function", "run", "(", ")", "{", "$", "config", "=", "Config", "::", "get", "(", "'global.config'", ",", "'aliases'", ")", ";", "$", "alias", "=", "new", "Manager", "(", "$", "config", "[", "'classes'", "]", ")", ";", "$", "alias", "->", "register", "(", ")", ";", "$", "this", "->", "container", "->", "set", "(", "'alias'", ",", "$", "alias", ")", ";", "}" ]
Register Log instance into Container.
[ "Register", "Log", "instance", "into", "Container", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Foundation/Bootstrappers/AliasLoaderBootstraper.php#L40-L46
230,667
cygnite/framework
src/Cygnite/Common/Pagination.php
Pagination.setPerPage
public function setPerPage($number = null) { if (is_null($number)) { if (property_exists($this->model, 'perPage')) { $this->perPage = $this->model->perPage; return $this; } } $this->perPage = $number; return $this; }
php
public function setPerPage($number = null) { if (is_null($number)) { if (property_exists($this->model, 'perPage')) { $this->perPage = $this->model->perPage; return $this; } } $this->perPage = $number; return $this; }
[ "public", "function", "setPerPage", "(", "$", "number", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "number", ")", ")", "{", "if", "(", "property_exists", "(", "$", "this", "->", "model", ",", "'perPage'", ")", ")", "{", "$", "this", "->", "perPage", "=", "$", "this", "->", "model", "->", "perPage", ";", "return", "$", "this", ";", "}", "}", "$", "this", "->", "perPage", "=", "$", "number", ";", "return", "$", "this", ";", "}" ]
Set per page record. @param null $number @return $this
[ "Set", "per", "page", "record", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Pagination.php#L105-L118
230,668
cygnite/framework
src/Cygnite/Common/Pagination.php
Pagination.calculate
public function calculate() { $this->calculatePageLimitAndOffset(); $pageNumber = $this->getPageNumber(); $offset = $this->getPaginationOffset(); /* Setup page vars for display. */ if ($pageNumber == 0) { $pageNumber = 1; //if no page var is given, default to 1. } $this->previous = $pageNumber - 1; $this->next = $pageNumber + 1; //last page is = total pages / items per page, rounded up. $this->lastPage = ceil($this->getTotalNumberOfPages() / $this->perPage); $this->lastPageMinusOne = $this->lastPage - 1; //last page minus 1 $this->create(); }
php
public function calculate() { $this->calculatePageLimitAndOffset(); $pageNumber = $this->getPageNumber(); $offset = $this->getPaginationOffset(); /* Setup page vars for display. */ if ($pageNumber == 0) { $pageNumber = 1; //if no page var is given, default to 1. } $this->previous = $pageNumber - 1; $this->next = $pageNumber + 1; //last page is = total pages / items per page, rounded up. $this->lastPage = ceil($this->getTotalNumberOfPages() / $this->perPage); $this->lastPageMinusOne = $this->lastPage - 1; //last page minus 1 $this->create(); }
[ "public", "function", "calculate", "(", ")", "{", "$", "this", "->", "calculatePageLimitAndOffset", "(", ")", ";", "$", "pageNumber", "=", "$", "this", "->", "getPageNumber", "(", ")", ";", "$", "offset", "=", "$", "this", "->", "getPaginationOffset", "(", ")", ";", "/* Setup page vars for display. */", "if", "(", "$", "pageNumber", "==", "0", ")", "{", "$", "pageNumber", "=", "1", ";", "//if no page var is given, default to 1.", "}", "$", "this", "->", "previous", "=", "$", "pageNumber", "-", "1", ";", "$", "this", "->", "next", "=", "$", "pageNumber", "+", "1", ";", "//last page is = total pages / items per page, rounded up.", "$", "this", "->", "lastPage", "=", "ceil", "(", "$", "this", "->", "getTotalNumberOfPages", "(", ")", "/", "$", "this", "->", "perPage", ")", ";", "$", "this", "->", "lastPageMinusOne", "=", "$", "this", "->", "lastPage", "-", "1", ";", "//last page minus 1", "$", "this", "->", "create", "(", ")", ";", "}" ]
Calculate the pagination links.
[ "Calculate", "the", "pagination", "links", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Pagination.php#L176-L194
230,669
cygnite/framework
src/Cygnite/Common/Pagination.php
Pagination.calculatePageLimitAndOffset
private function calculatePageLimitAndOffset() { $pageUri = ''; $pageUri = Url::segment(3); $pageNumber = ($pageUri !== '') ? $pageUri : 0; if ($pageNumber) { //calculate starting point of pagination $start = ($this->getPageNumber() - 1) * $this->perPage; } else { $start = 0; //set start to 0 by default. } $this->setPageNumber($pageNumber); $this->setPaginationOffset($start); }
php
private function calculatePageLimitAndOffset() { $pageUri = ''; $pageUri = Url::segment(3); $pageNumber = ($pageUri !== '') ? $pageUri : 0; if ($pageNumber) { //calculate starting point of pagination $start = ($this->getPageNumber() - 1) * $this->perPage; } else { $start = 0; //set start to 0 by default. } $this->setPageNumber($pageNumber); $this->setPaginationOffset($start); }
[ "private", "function", "calculatePageLimitAndOffset", "(", ")", "{", "$", "pageUri", "=", "''", ";", "$", "pageUri", "=", "Url", "::", "segment", "(", "3", ")", ";", "$", "pageNumber", "=", "(", "$", "pageUri", "!==", "''", ")", "?", "$", "pageUri", ":", "0", ";", "if", "(", "$", "pageNumber", ")", "{", "//calculate starting point of pagination", "$", "start", "=", "(", "$", "this", "->", "getPageNumber", "(", ")", "-", "1", ")", "*", "$", "this", "->", "perPage", ";", "}", "else", "{", "$", "start", "=", "0", ";", "//set start to 0 by default.", "}", "$", "this", "->", "setPageNumber", "(", "$", "pageNumber", ")", ";", "$", "this", "->", "setPaginationOffset", "(", "$", "start", ")", ";", "}" ]
Calculate page limit and offset.
[ "Calculate", "page", "limit", "and", "offset", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Pagination.php#L199-L214
230,670
cygnite/framework
src/Cygnite/Common/Pagination.php
Pagination.setCurrentPageUrl
private function setCurrentPageUrl() { $controller = Url::segment(1); $method = ''; $method = (Url::segment(2) == '') ? 'index' : Url::segment(2); $this->currentPageUrl = Url::getBase().$controller.'/'.$method; }
php
private function setCurrentPageUrl() { $controller = Url::segment(1); $method = ''; $method = (Url::segment(2) == '') ? 'index' : Url::segment(2); $this->currentPageUrl = Url::getBase().$controller.'/'.$method; }
[ "private", "function", "setCurrentPageUrl", "(", ")", "{", "$", "controller", "=", "Url", "::", "segment", "(", "1", ")", ";", "$", "method", "=", "''", ";", "$", "method", "=", "(", "Url", "::", "segment", "(", "2", ")", "==", "''", ")", "?", "'index'", ":", "Url", "::", "segment", "(", "2", ")", ";", "$", "this", "->", "currentPageUrl", "=", "Url", "::", "getBase", "(", ")", ".", "$", "controller", ".", "'/'", ".", "$", "method", ";", "}" ]
Set current page url.
[ "Set", "current", "page", "url", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Pagination.php#L219-L226
230,671
cygnite/framework
src/Cygnite/Common/Pagination.php
Pagination.create
public function create() { $content = ''; $pageNumber = $this->getPageNumber(); if ($pageNumber === 0) { $pageNumber = 1; } if ($this->lastPage > 1) { $content .= "<div class='pagination'>"; $content .= $this->renderPreviousLink($pageNumber); //not enough pages to bother breaking it up if ($this->lastPage < 7 + ($this->adjacent * 2)) { for ($counter = 1; $counter <= $this->lastPage; $counter++) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } } elseif ($this->lastPage > 5 + ($this->adjacent * 2)) { //close to beginning; only hide later pages if ($pageNumber < 1 + ($this->adjacent * 2)) { for ($counter = 1; $counter < 4 + ($this->adjacent * 2); $counter++) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } $content .= '...'; $content .= $this->createSecondLink(); } elseif ( $this->lastPage - ($this->adjacent * 2) > $pageNumber && $pageNumber > ($this->adjacent * 2) ) { $content .= $this->createPrimaryLink(); $content .= '...'; for ( $counter = $pageNumber - $this->adjacent; $counter <= $pageNumber + $this->adjacent; $counter++ ) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } $content .= '...'; $content .= $this->createPrimaryLink(); $content .= $this->createSecondLink(); } else { //close to end; only hide early pages $content .= $this->createPrimaryLink(); $content .= '...'; for ( $counter = $this->lastPage - (2 + ($this->adjacent * 2)); $counter <= $this->lastPage; $counter++ ) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } } } $content .= $this->renderNextLink($counter, $pageNumber); } $this->paginationLinks = $content; }
php
public function create() { $content = ''; $pageNumber = $this->getPageNumber(); if ($pageNumber === 0) { $pageNumber = 1; } if ($this->lastPage > 1) { $content .= "<div class='pagination'>"; $content .= $this->renderPreviousLink($pageNumber); //not enough pages to bother breaking it up if ($this->lastPage < 7 + ($this->adjacent * 2)) { for ($counter = 1; $counter <= $this->lastPage; $counter++) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } } elseif ($this->lastPage > 5 + ($this->adjacent * 2)) { //close to beginning; only hide later pages if ($pageNumber < 1 + ($this->adjacent * 2)) { for ($counter = 1; $counter < 4 + ($this->adjacent * 2); $counter++) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } $content .= '...'; $content .= $this->createSecondLink(); } elseif ( $this->lastPage - ($this->adjacent * 2) > $pageNumber && $pageNumber > ($this->adjacent * 2) ) { $content .= $this->createPrimaryLink(); $content .= '...'; for ( $counter = $pageNumber - $this->adjacent; $counter <= $pageNumber + $this->adjacent; $counter++ ) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } $content .= '...'; $content .= $this->createPrimaryLink(); $content .= $this->createSecondLink(); } else { //close to end; only hide early pages $content .= $this->createPrimaryLink(); $content .= '...'; for ( $counter = $this->lastPage - (2 + ($this->adjacent * 2)); $counter <= $this->lastPage; $counter++ ) { $content .= $this->createCurrentActiveLink($pageNumber, $counter); } } } $content .= $this->renderNextLink($counter, $pageNumber); } $this->paginationLinks = $content; }
[ "public", "function", "create", "(", ")", "{", "$", "content", "=", "''", ";", "$", "pageNumber", "=", "$", "this", "->", "getPageNumber", "(", ")", ";", "if", "(", "$", "pageNumber", "===", "0", ")", "{", "$", "pageNumber", "=", "1", ";", "}", "if", "(", "$", "this", "->", "lastPage", ">", "1", ")", "{", "$", "content", ".=", "\"<div class='pagination'>\"", ";", "$", "content", ".=", "$", "this", "->", "renderPreviousLink", "(", "$", "pageNumber", ")", ";", "//not enough pages to bother breaking it up", "if", "(", "$", "this", "->", "lastPage", "<", "7", "+", "(", "$", "this", "->", "adjacent", "*", "2", ")", ")", "{", "for", "(", "$", "counter", "=", "1", ";", "$", "counter", "<=", "$", "this", "->", "lastPage", ";", "$", "counter", "++", ")", "{", "$", "content", ".=", "$", "this", "->", "createCurrentActiveLink", "(", "$", "pageNumber", ",", "$", "counter", ")", ";", "}", "}", "elseif", "(", "$", "this", "->", "lastPage", ">", "5", "+", "(", "$", "this", "->", "adjacent", "*", "2", ")", ")", "{", "//close to beginning; only hide later pages", "if", "(", "$", "pageNumber", "<", "1", "+", "(", "$", "this", "->", "adjacent", "*", "2", ")", ")", "{", "for", "(", "$", "counter", "=", "1", ";", "$", "counter", "<", "4", "+", "(", "$", "this", "->", "adjacent", "*", "2", ")", ";", "$", "counter", "++", ")", "{", "$", "content", ".=", "$", "this", "->", "createCurrentActiveLink", "(", "$", "pageNumber", ",", "$", "counter", ")", ";", "}", "$", "content", ".=", "'...'", ";", "$", "content", ".=", "$", "this", "->", "createSecondLink", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "lastPage", "-", "(", "$", "this", "->", "adjacent", "*", "2", ")", ">", "$", "pageNumber", "&&", "$", "pageNumber", ">", "(", "$", "this", "->", "adjacent", "*", "2", ")", ")", "{", "$", "content", ".=", "$", "this", "->", "createPrimaryLink", "(", ")", ";", "$", "content", ".=", "'...'", ";", "for", "(", "$", "counter", "=", "$", "pageNumber", "-", "$", "this", "->", "adjacent", ";", "$", "counter", "<=", "$", "pageNumber", "+", "$", "this", "->", "adjacent", ";", "$", "counter", "++", ")", "{", "$", "content", ".=", "$", "this", "->", "createCurrentActiveLink", "(", "$", "pageNumber", ",", "$", "counter", ")", ";", "}", "$", "content", ".=", "'...'", ";", "$", "content", ".=", "$", "this", "->", "createPrimaryLink", "(", ")", ";", "$", "content", ".=", "$", "this", "->", "createSecondLink", "(", ")", ";", "}", "else", "{", "//close to end; only hide early pages", "$", "content", ".=", "$", "this", "->", "createPrimaryLink", "(", ")", ";", "$", "content", ".=", "'...'", ";", "for", "(", "$", "counter", "=", "$", "this", "->", "lastPage", "-", "(", "2", "+", "(", "$", "this", "->", "adjacent", "*", "2", ")", ")", ";", "$", "counter", "<=", "$", "this", "->", "lastPage", ";", "$", "counter", "++", ")", "{", "$", "content", ".=", "$", "this", "->", "createCurrentActiveLink", "(", "$", "pageNumber", ",", "$", "counter", ")", ";", "}", "}", "}", "$", "content", ".=", "$", "this", "->", "renderNextLink", "(", "$", "counter", ",", "$", "pageNumber", ")", ";", "}", "$", "this", "->", "paginationLinks", "=", "$", "content", ";", "}" ]
Create pagination links.
[ "Create", "pagination", "links", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Pagination.php#L284-L349
230,672
cygnite/framework
src/Cygnite/Common/Pagination.php
Pagination.createSecondLink
private function createSecondLink() { $content = ''; $content .= "<a href='".$this->currentPageUrl.'/'.$this->lastPageMinusOne."'>$this->lastPageMinusOne</a>"; $content .= "<a href='".$this->currentPageUrl.'/'.$this->lastPage."'>$this->lastPage</a>"; return $content; }
php
private function createSecondLink() { $content = ''; $content .= "<a href='".$this->currentPageUrl.'/'.$this->lastPageMinusOne."'>$this->lastPageMinusOne</a>"; $content .= "<a href='".$this->currentPageUrl.'/'.$this->lastPage."'>$this->lastPage</a>"; return $content; }
[ "private", "function", "createSecondLink", "(", ")", "{", "$", "content", "=", "''", ";", "$", "content", ".=", "\"<a href='\"", ".", "$", "this", "->", "currentPageUrl", ".", "'/'", ".", "$", "this", "->", "lastPageMinusOne", ".", "\"'>$this->lastPageMinusOne</a>\"", ";", "$", "content", ".=", "\"<a href='\"", ".", "$", "this", "->", "currentPageUrl", ".", "'/'", ".", "$", "this", "->", "lastPage", ".", "\"'>$this->lastPage</a>\"", ";", "return", "$", "content", ";", "}" ]
Create Second link. @return string
[ "Create", "Second", "link", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/Pagination.php#L383-L392
230,673
cygnite/framework
src/Cygnite/Container/Dependency/Builder.php
Builder.setPropertyInjection
public function setPropertyInjection($propertyInjections) { if (!is_array($propertyInjections)) { throw new DependencyException(__METHOD__.' only accept parameter as array.'); } $namespace = $this->getAppNamespace(); foreach ($propertyInjections as $controller => $properties) { foreach ($properties as $key => $value) { /* | We will add key value pair into the definition array only if | it is not already exists */ if (!isset($this->cache[$namespace.$controller][$key])) { $this->definitions['\\'.$namespace.$controller][$key] = $value; } } } return $this; }
php
public function setPropertyInjection($propertyInjections) { if (!is_array($propertyInjections)) { throw new DependencyException(__METHOD__.' only accept parameter as array.'); } $namespace = $this->getAppNamespace(); foreach ($propertyInjections as $controller => $properties) { foreach ($properties as $key => $value) { /* | We will add key value pair into the definition array only if | it is not already exists */ if (!isset($this->cache[$namespace.$controller][$key])) { $this->definitions['\\'.$namespace.$controller][$key] = $value; } } } return $this; }
[ "public", "function", "setPropertyInjection", "(", "$", "propertyInjections", ")", "{", "if", "(", "!", "is_array", "(", "$", "propertyInjections", ")", ")", "{", "throw", "new", "DependencyException", "(", "__METHOD__", ".", "' only accept parameter as array.'", ")", ";", "}", "$", "namespace", "=", "$", "this", "->", "getAppNamespace", "(", ")", ";", "foreach", "(", "$", "propertyInjections", "as", "$", "controller", "=>", "$", "properties", ")", "{", "foreach", "(", "$", "properties", "as", "$", "key", "=>", "$", "value", ")", "{", "/*\n | We will add key value pair into the definition array only if\n | it is not already exists\n */", "if", "(", "!", "isset", "(", "$", "this", "->", "cache", "[", "$", "namespace", ".", "$", "controller", "]", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "definitions", "[", "'\\\\'", ".", "$", "namespace", ".", "$", "controller", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Set all definitions into array. @param $propertyInjections @throws \Cygnite\Container\Exceptions\DependencyException @return $this
[ "Set", "all", "definitions", "into", "array", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Dependency/Builder.php#L64-L85
230,674
cygnite/framework
src/Cygnite/Container/Dependency/Builder.php
Builder.setService
public function setService($services) { if (!is_array($services)) { throw new \Exception(__METHOD__.' accept parameter as array.'); } foreach ($services as $key => $alias) { $this[$key] = $alias; } return $this; }
php
public function setService($services) { if (!is_array($services)) { throw new \Exception(__METHOD__.' accept parameter as array.'); } foreach ($services as $key => $alias) { $this[$key] = $alias; } return $this; }
[ "public", "function", "setService", "(", "$", "services", ")", "{", "if", "(", "!", "is_array", "(", "$", "services", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "__METHOD__", ".", "' accept parameter as array.'", ")", ";", "}", "foreach", "(", "$", "services", "as", "$", "key", "=>", "$", "alias", ")", "{", "$", "this", "[", "$", "key", "]", "=", "$", "alias", ";", "}", "return", "$", "this", ";", "}" ]
Set the service into container. @param $services @throws \Exception @return $this
[ "Set", "the", "service", "into", "container", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Dependency/Builder.php#L94-L105
230,675
cygnite/framework
src/Cygnite/Container/Dependency/Builder.php
Builder.getDefinitions
public function getDefinitions($key = null) { if (!is_null($key)) { return isset($this->definitions[$key]) ? $this->definitions[$key] : null; } return !empty($this->definitions) ? $this->definitions : []; }
php
public function getDefinitions($key = null) { if (!is_null($key)) { return isset($this->definitions[$key]) ? $this->definitions[$key] : null; } return !empty($this->definitions) ? $this->definitions : []; }
[ "public", "function", "getDefinitions", "(", "$", "key", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "key", ")", ")", "{", "return", "isset", "(", "$", "this", "->", "definitions", "[", "$", "key", "]", ")", "?", "$", "this", "->", "definitions", "[", "$", "key", "]", ":", "null", ";", "}", "return", "!", "empty", "(", "$", "this", "->", "definitions", ")", "?", "$", "this", "->", "definitions", ":", "[", "]", ";", "}" ]
Returns definitions by given key. @param null $key @return array|null
[ "Returns", "definitions", "by", "given", "key", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Dependency/Builder.php#L113-L120
230,676
cygnite/framework
src/Cygnite/Container/Dependency/Builder.php
Builder.propertyInjection
public function propertyInjection($classInstance, $controller) { $dependencies = $this->getPropertyDefinitionConfig($controller); $controller = "\\\\"; if (array_key_exists($controller, $this->definitions)) { list($reflection, $reflectionClass) = $this->setReflectionClassAttributes($controller); foreach ($dependencies as $classProperty => $class) { $reflectionArray = [$reflectionClass, $classProperty]; list($object, $controllerProp) = $this->checkPropertyAndMakeObject($controller, $class, $reflectionArray); /* | We will check is set{PropertyName}() method exists in class. | If exists we will call the method to set object into it */ if (method_exists($classInstance, 'set'.$controllerProp)) { $classInstance->{'set'.$controllerProp}($object); } else { $prop = $reflectionClass->getProperty($classProperty); /* | Check if property defined as static. | we will throw exception is property defined as static */ if ($prop->isStatic()) { throw new DependencyException( sprintf("Static Property '%s' is not injectable in $controller controller", $classProperty) ); } $this->setPropertyValue($reflection, $classInstance, $classProperty, $object); } } return true; } return false; }
php
public function propertyInjection($classInstance, $controller) { $dependencies = $this->getPropertyDefinitionConfig($controller); $controller = "\\\\"; if (array_key_exists($controller, $this->definitions)) { list($reflection, $reflectionClass) = $this->setReflectionClassAttributes($controller); foreach ($dependencies as $classProperty => $class) { $reflectionArray = [$reflectionClass, $classProperty]; list($object, $controllerProp) = $this->checkPropertyAndMakeObject($controller, $class, $reflectionArray); /* | We will check is set{PropertyName}() method exists in class. | If exists we will call the method to set object into it */ if (method_exists($classInstance, 'set'.$controllerProp)) { $classInstance->{'set'.$controllerProp}($object); } else { $prop = $reflectionClass->getProperty($classProperty); /* | Check if property defined as static. | we will throw exception is property defined as static */ if ($prop->isStatic()) { throw new DependencyException( sprintf("Static Property '%s' is not injectable in $controller controller", $classProperty) ); } $this->setPropertyValue($reflection, $classInstance, $classProperty, $object); } } return true; } return false; }
[ "public", "function", "propertyInjection", "(", "$", "classInstance", ",", "$", "controller", ")", "{", "$", "dependencies", "=", "$", "this", "->", "getPropertyDefinitionConfig", "(", "$", "controller", ")", ";", "$", "controller", "=", "\"\\\\\\\\\"", ";", "if", "(", "array_key_exists", "(", "$", "controller", ",", "$", "this", "->", "definitions", ")", ")", "{", "list", "(", "$", "reflection", ",", "$", "reflectionClass", ")", "=", "$", "this", "->", "setReflectionClassAttributes", "(", "$", "controller", ")", ";", "foreach", "(", "$", "dependencies", "as", "$", "classProperty", "=>", "$", "class", ")", "{", "$", "reflectionArray", "=", "[", "$", "reflectionClass", ",", "$", "classProperty", "]", ";", "list", "(", "$", "object", ",", "$", "controllerProp", ")", "=", "$", "this", "->", "checkPropertyAndMakeObject", "(", "$", "controller", ",", "$", "class", ",", "$", "reflectionArray", ")", ";", "/*\n | We will check is set{PropertyName}() method exists in class.\n | If exists we will call the method to set object into it\n */", "if", "(", "method_exists", "(", "$", "classInstance", ",", "'set'", ".", "$", "controllerProp", ")", ")", "{", "$", "classInstance", "->", "{", "'set'", ".", "$", "controllerProp", "}", "(", "$", "object", ")", ";", "}", "else", "{", "$", "prop", "=", "$", "reflectionClass", "->", "getProperty", "(", "$", "classProperty", ")", ";", "/*\n | Check if property defined as static.\n | we will throw exception is property defined as static\n */", "if", "(", "$", "prop", "->", "isStatic", "(", ")", ")", "{", "throw", "new", "DependencyException", "(", "sprintf", "(", "\"Static Property '%s' is not injectable in $controller controller\"", ",", "$", "classProperty", ")", ")", ";", "}", "$", "this", "->", "setPropertyValue", "(", "$", "reflection", ",", "$", "classInstance", ",", "$", "classProperty", ",", "$", "object", ")", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Inject all your properties into controller at run time. @param $classInstance @param $controller @throws \Exception @return bool
[ "Inject", "all", "your", "properties", "into", "controller", "at", "run", "time", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Container/Dependency/Builder.php#L164-L202
230,677
inetprocess/libsugarcrm
src/SugarQueryIterator.php
SugarQueryIterator.fetchNextRecords
protected function fetchNextRecords() { if (!$this->use_fixed_offset) { $this->query->offset($this->query_offset); } if ($this->clean_memory_on_fetch) { // Attempt to clean php memory $this->results_cache = null; BeanFactoryCache::clearCache(); gc_collect_cycles(); } $this->results_cache = $this->query->execute(); $this->cache_current_index = 0; }
php
protected function fetchNextRecords() { if (!$this->use_fixed_offset) { $this->query->offset($this->query_offset); } if ($this->clean_memory_on_fetch) { // Attempt to clean php memory $this->results_cache = null; BeanFactoryCache::clearCache(); gc_collect_cycles(); } $this->results_cache = $this->query->execute(); $this->cache_current_index = 0; }
[ "protected", "function", "fetchNextRecords", "(", ")", "{", "if", "(", "!", "$", "this", "->", "use_fixed_offset", ")", "{", "$", "this", "->", "query", "->", "offset", "(", "$", "this", "->", "query_offset", ")", ";", "}", "if", "(", "$", "this", "->", "clean_memory_on_fetch", ")", "{", "// Attempt to clean php memory", "$", "this", "->", "results_cache", "=", "null", ";", "BeanFactoryCache", "::", "clearCache", "(", ")", ";", "gc_collect_cycles", "(", ")", ";", "}", "$", "this", "->", "results_cache", "=", "$", "this", "->", "query", "->", "execute", "(", ")", ";", "$", "this", "->", "cache_current_index", "=", "0", ";", "}" ]
Fetch the next page of ids from the database
[ "Fetch", "the", "next", "page", "of", "ids", "from", "the", "database" ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/SugarQueryIterator.php#L149-L162
230,678
kaliop-uk/ezworkflowenginebundle
Core/EventListener/TracingStepExecutedListener.php
TracingStepExecutedListener.echoMessage
protected function echoMessage($out) { if ($this->output) { if ($this->output->getVerbosity() >= $this->minVerbosityLevel) { $this->output->writeln($out); } } if ($this->logger) { $this->logger->debug($out); } }
php
protected function echoMessage($out) { if ($this->output) { if ($this->output->getVerbosity() >= $this->minVerbosityLevel) { $this->output->writeln($out); } } if ($this->logger) { $this->logger->debug($out); } }
[ "protected", "function", "echoMessage", "(", "$", "out", ")", "{", "if", "(", "$", "this", "->", "output", ")", "{", "if", "(", "$", "this", "->", "output", "->", "getVerbosity", "(", ")", ">=", "$", "this", "->", "minVerbosityLevel", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "$", "out", ")", ";", "}", "}", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "$", "out", ")", ";", "}", "}" ]
Unlike the parent class, we default to always writing to the log file and to the output only if available @param string $out
[ "Unlike", "the", "parent", "class", "we", "default", "to", "always", "writing", "to", "the", "log", "file", "and", "to", "the", "output", "only", "if", "available" ]
1540eff00b64b6db692ec865c9d25b0179b4b638
https://github.com/kaliop-uk/ezworkflowenginebundle/blob/1540eff00b64b6db692ec865c9d25b0179b4b638/Core/EventListener/TracingStepExecutedListener.php#L23-L34
230,679
schnittstabil/psr7-csrf-middleware
src/Middleware.php
Middleware.add
public function add(callable $newTopMiddleware) { if ($this->isGuarded) { if ($newTopMiddleware instanceof GuardInterface) { throw new \RuntimeException('Invalid state: already guarded'); } } else { if (!($newTopMiddleware instanceof GuardInterface)) { throw new \RuntimeException('Invalid state: not guarded'); } } $clone = clone $this; $clone->isGuarded = true; return $clone->push($newTopMiddleware); }
php
public function add(callable $newTopMiddleware) { if ($this->isGuarded) { if ($newTopMiddleware instanceof GuardInterface) { throw new \RuntimeException('Invalid state: already guarded'); } } else { if (!($newTopMiddleware instanceof GuardInterface)) { throw new \RuntimeException('Invalid state: not guarded'); } } $clone = clone $this; $clone->isGuarded = true; return $clone->push($newTopMiddleware); }
[ "public", "function", "add", "(", "callable", "$", "newTopMiddleware", ")", "{", "if", "(", "$", "this", "->", "isGuarded", ")", "{", "if", "(", "$", "newTopMiddleware", "instanceof", "GuardInterface", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Invalid state: already guarded'", ")", ";", "}", "}", "else", "{", "if", "(", "!", "(", "$", "newTopMiddleware", "instanceof", "GuardInterface", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Invalid state: not guarded'", ")", ";", "}", "}", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "isGuarded", "=", "true", ";", "return", "$", "clone", "->", "push", "(", "$", "newTopMiddleware", ")", ";", "}" ]
Push a middleware onto the top of a new Stack instance. @param callable $newTopMiddleware the middleware to be pushed onto the top @return static the new instance @SuppressWarnings(PHPMD.ElseExpression)
[ "Push", "a", "middleware", "onto", "the", "top", "of", "a", "new", "Stack", "instance", "." ]
bbd00834ceb891ebf6419e6fab506b641e04b2bb
https://github.com/schnittstabil/psr7-csrf-middleware/blob/bbd00834ceb891ebf6419e6fab506b641e04b2bb/src/Middleware.php#L57-L73
230,680
schnittstabil/psr7-csrf-middleware
src/Middleware.php
Middleware.withRespondWithCookieToken
public function withRespondWithCookieToken($cookieName = 'XSRF-TOKEN', callable $modify = null) { return $this->add(new RespondWithCookieToken([$this->tokenService, 'generate'], $cookieName, $modify)); }
php
public function withRespondWithCookieToken($cookieName = 'XSRF-TOKEN', callable $modify = null) { return $this->add(new RespondWithCookieToken([$this->tokenService, 'generate'], $cookieName, $modify)); }
[ "public", "function", "withRespondWithCookieToken", "(", "$", "cookieName", "=", "'XSRF-TOKEN'", ",", "callable", "$", "modify", "=", "null", ")", "{", "return", "$", "this", "->", "add", "(", "new", "RespondWithCookieToken", "(", "[", "$", "this", "->", "tokenService", ",", "'generate'", "]", ",", "$", "cookieName", ",", "$", "modify", ")", ")", ";", "}" ]
Add new RespondWithCookieToken middleware. @param string $cookieName Cookie name @param callable $modify Allows to modify the cookie; same signature as `$this->modifyCookie` @return static
[ "Add", "new", "RespondWithCookieToken", "middleware", "." ]
bbd00834ceb891ebf6419e6fab506b641e04b2bb
https://github.com/schnittstabil/psr7-csrf-middleware/blob/bbd00834ceb891ebf6419e6fab506b641e04b2bb/src/Middleware.php#L133-L136
230,681
cygnite/framework
src/Cygnite/Cache/Factory/Cache.php
Cache.make
public static function make($cache, \Closure $callback) { // Return Closure callback if (array_key_exists($cache, static::$drivers)) { return static::getCacheDriver($callback, $cache); } throw new \RuntimeException('Cache driver not found!'); }
php
public static function make($cache, \Closure $callback) { // Return Closure callback if (array_key_exists($cache, static::$drivers)) { return static::getCacheDriver($callback, $cache); } throw new \RuntimeException('Cache driver not found!'); }
[ "public", "static", "function", "make", "(", "$", "cache", ",", "\\", "Closure", "$", "callback", ")", "{", "// Return Closure callback", "if", "(", "array_key_exists", "(", "$", "cache", ",", "static", "::", "$", "drivers", ")", ")", "{", "return", "static", "::", "getCacheDriver", "(", "$", "callback", ",", "$", "cache", ")", ";", "}", "throw", "new", "\\", "RuntimeException", "(", "'Cache driver not found!'", ")", ";", "}" ]
Factory Method to return appropriate driver instance. @param $cache @param callable $callback @throws \RuntimeException @return mixed
[ "Factory", "Method", "to", "return", "appropriate", "driver", "instance", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Cache/Factory/Cache.php#L41-L49
230,682
cygnite/framework
src/Cygnite/Common/UrlManager/Manager.php
Manager.getSegment
public function getSegment($segment = 1) { $segment = (!is_null($segment)) ? $segment : 1; $uri = $this->router->getCurrentUri(); $urlArray = array_filter(explode('/', $uri)); $indexCount = array_search(Router::$indexPage, $urlArray); if ($indexCount == true) { $num = $indexCount + $segment; return isset($urlArray[$num]) ? $urlArray[$num] : null; } return isset($urlArray[$segment]) ? $urlArray[$segment] : null; }
php
public function getSegment($segment = 1) { $segment = (!is_null($segment)) ? $segment : 1; $uri = $this->router->getCurrentUri(); $urlArray = array_filter(explode('/', $uri)); $indexCount = array_search(Router::$indexPage, $urlArray); if ($indexCount == true) { $num = $indexCount + $segment; return isset($urlArray[$num]) ? $urlArray[$num] : null; } return isset($urlArray[$segment]) ? $urlArray[$segment] : null; }
[ "public", "function", "getSegment", "(", "$", "segment", "=", "1", ")", "{", "$", "segment", "=", "(", "!", "is_null", "(", "$", "segment", ")", ")", "?", "$", "segment", ":", "1", ";", "$", "uri", "=", "$", "this", "->", "router", "->", "getCurrentUri", "(", ")", ";", "$", "urlArray", "=", "array_filter", "(", "explode", "(", "'/'", ",", "$", "uri", ")", ")", ";", "$", "indexCount", "=", "array_search", "(", "Router", "::", "$", "indexPage", ",", "$", "urlArray", ")", ";", "if", "(", "$", "indexCount", "==", "true", ")", "{", "$", "num", "=", "$", "indexCount", "+", "$", "segment", ";", "return", "isset", "(", "$", "urlArray", "[", "$", "num", "]", ")", "?", "$", "urlArray", "[", "$", "num", "]", ":", "null", ";", "}", "return", "isset", "(", "$", "urlArray", "[", "$", "segment", "]", ")", "?", "$", "urlArray", "[", "$", "segment", "]", ":", "null", ";", "}" ]
This Function is to get Uri Segment of the url. @false int @param array|int $segment @return string
[ "This", "Function", "is", "to", "get", "Uri", "Segment", "of", "the", "url", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/UrlManager/Manager.php#L50-L64
230,683
cygnite/framework
src/Cygnite/Common/UrlManager/Manager.php
Manager.redirectTo
public function redirectTo($uri, $type = 'location', $httpResponseCode = 302) { $uri = str_replace(['.', '/'], '/', $uri); if (!preg_match('#^https?://#i', $uri)) { $uri = $this->sitePath($uri); } switch ($type) { case 'refresh': header('Refresh:0;url='.$uri); break; case 'location': header('Location: '.$uri, true, $httpResponseCode); break; } exit; }
php
public function redirectTo($uri, $type = 'location', $httpResponseCode = 302) { $uri = str_replace(['.', '/'], '/', $uri); if (!preg_match('#^https?://#i', $uri)) { $uri = $this->sitePath($uri); } switch ($type) { case 'refresh': header('Refresh:0;url='.$uri); break; case 'location': header('Location: '.$uri, true, $httpResponseCode); break; } exit; }
[ "public", "function", "redirectTo", "(", "$", "uri", ",", "$", "type", "=", "'location'", ",", "$", "httpResponseCode", "=", "302", ")", "{", "$", "uri", "=", "str_replace", "(", "[", "'.'", ",", "'/'", "]", ",", "'/'", ",", "$", "uri", ")", ";", "if", "(", "!", "preg_match", "(", "'#^https?://#i'", ",", "$", "uri", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "sitePath", "(", "$", "uri", ")", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "'refresh'", ":", "header", "(", "'Refresh:0;url='", ".", "$", "uri", ")", ";", "break", ";", "case", "'location'", ":", "header", "(", "'Location: '", ".", "$", "uri", ",", "true", ",", "$", "httpResponseCode", ")", ";", "break", ";", "}", "exit", ";", "}" ]
Header Redirect. @param string $uri @param string $type @param int $httpResponseCode
[ "Header", "Redirect", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/UrlManager/Manager.php#L73-L90
230,684
cygnite/framework
src/Cygnite/Common/UrlManager/Manager.php
Manager.sitePath
public function sitePath($uri) { $expression = array_filter(explode('/', $this->request->server['REQUEST_URI'])); $index = (false !== array_search(Router::$indexPage, $expression)) ? Router::$indexPage.'/' : ''; return $this->getBase().$index.$uri; }
php
public function sitePath($uri) { $expression = array_filter(explode('/', $this->request->server['REQUEST_URI'])); $index = (false !== array_search(Router::$indexPage, $expression)) ? Router::$indexPage.'/' : ''; return $this->getBase().$index.$uri; }
[ "public", "function", "sitePath", "(", "$", "uri", ")", "{", "$", "expression", "=", "array_filter", "(", "explode", "(", "'/'", ",", "$", "this", "->", "request", "->", "server", "[", "'REQUEST_URI'", "]", ")", ")", ";", "$", "index", "=", "(", "false", "!==", "array_search", "(", "Router", "::", "$", "indexPage", ",", "$", "expression", ")", ")", "?", "Router", "::", "$", "indexPage", ".", "'/'", ":", "''", ";", "return", "$", "this", "->", "getBase", "(", ")", ".", "$", "index", ".", "$", "uri", ";", "}" ]
This Function is to get the url sitePath with index.php. @param $uri @return string
[ "This", "Function", "is", "to", "get", "the", "url", "sitePath", "with", "index", ".", "php", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Common/UrlManager/Manager.php#L98-L104
230,685
inetprocess/libsugarcrm
src/Database/Relationship.php
Relationship.loadFromDb
public function loadFromDb() { $this->getLogger()->debug('Reading relationships from DB.'); $query = $this->getQueryFactory()->createSelectAllQuery($this->tableName); $res = $query->execute(); $rels = array(); foreach ($res->fetchAll(\PDO::FETCH_ASSOC) as $row) { $rels[$row['relationship_name']] = $row; } ksort($rels); return $rels; }
php
public function loadFromDb() { $this->getLogger()->debug('Reading relationships from DB.'); $query = $this->getQueryFactory()->createSelectAllQuery($this->tableName); $res = $query->execute(); $rels = array(); foreach ($res->fetchAll(\PDO::FETCH_ASSOC) as $row) { $rels[$row['relationship_name']] = $row; } ksort($rels); return $rels; }
[ "public", "function", "loadFromDb", "(", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Reading relationships from DB.'", ")", ";", "$", "query", "=", "$", "this", "->", "getQueryFactory", "(", ")", "->", "createSelectAllQuery", "(", "$", "this", "->", "tableName", ")", ";", "$", "res", "=", "$", "query", "->", "execute", "(", ")", ";", "$", "rels", "=", "array", "(", ")", ";", "foreach", "(", "$", "res", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", "as", "$", "row", ")", "{", "$", "rels", "[", "$", "row", "[", "'relationship_name'", "]", "]", "=", "$", "row", ";", "}", "ksort", "(", "$", "rels", ")", ";", "return", "$", "rels", ";", "}" ]
Fetch relationships array from the sugar database.
[ "Fetch", "relationships", "array", "from", "the", "sugar", "database", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/Database/Relationship.php#L32-L44
230,686
inetprocess/libsugarcrm
src/Database/Relationship.php
Relationship.loadFromFile
public function loadFromFile() { $this->getLogger()->debug('Reading relationships from ' . $this->defFile); $relsFromFile = Yaml::parse($this->defFile); if (!is_array($relsFromFile)) { $relsFromFile = array(); $this->getLogger()->warning('No definition found in relationships file.'); } $rels = array(); foreach ($relsFromFile as $relsData) { $rels[$relsData['relationship_name']] = $relsData; } ksort($rels); return $rels; }
php
public function loadFromFile() { $this->getLogger()->debug('Reading relationships from ' . $this->defFile); $relsFromFile = Yaml::parse($this->defFile); if (!is_array($relsFromFile)) { $relsFromFile = array(); $this->getLogger()->warning('No definition found in relationships file.'); } $rels = array(); foreach ($relsFromFile as $relsData) { $rels[$relsData['relationship_name']] = $relsData; } ksort($rels); return $rels; }
[ "public", "function", "loadFromFile", "(", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Reading relationships from '", ".", "$", "this", "->", "defFile", ")", ";", "$", "relsFromFile", "=", "Yaml", "::", "parse", "(", "$", "this", "->", "defFile", ")", ";", "if", "(", "!", "is_array", "(", "$", "relsFromFile", ")", ")", "{", "$", "relsFromFile", "=", "array", "(", ")", ";", "$", "this", "->", "getLogger", "(", ")", "->", "warning", "(", "'No definition found in relationships file.'", ")", ";", "}", "$", "rels", "=", "array", "(", ")", ";", "foreach", "(", "$", "relsFromFile", "as", "$", "relsData", ")", "{", "$", "rels", "[", "$", "relsData", "[", "'relationship_name'", "]", "]", "=", "$", "relsData", ";", "}", "ksort", "(", "$", "rels", ")", ";", "return", "$", "rels", ";", "}" ]
Fetch relationships array from the definition file
[ "Fetch", "relationships", "array", "from", "the", "definition", "file" ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/Database/Relationship.php#L49-L64
230,687
inetprocess/libsugarcrm
src/Database/Relationship.php
Relationship.diff
public function diff($base, $new, $mode = self::DIFF_ALL, array $field_ids = array()) { $res = parent::diff($base, $new, $mode, $field_ids); // For update, be careful to ignore the ID if it's the only difference foreach ($res[self::UPDATE] as $key => $data) { $fields = $data[self::MODIFIED]; if (count($fields) === 1 && array_key_exists('id', $fields)) { unset($res[self::UPDATE][$key]); } } return $res; }
php
public function diff($base, $new, $mode = self::DIFF_ALL, array $field_ids = array()) { $res = parent::diff($base, $new, $mode, $field_ids); // For update, be careful to ignore the ID if it's the only difference foreach ($res[self::UPDATE] as $key => $data) { $fields = $data[self::MODIFIED]; if (count($fields) === 1 && array_key_exists('id', $fields)) { unset($res[self::UPDATE][$key]); } } return $res; }
[ "public", "function", "diff", "(", "$", "base", ",", "$", "new", ",", "$", "mode", "=", "self", "::", "DIFF_ALL", ",", "array", "$", "field_ids", "=", "array", "(", ")", ")", "{", "$", "res", "=", "parent", "::", "diff", "(", "$", "base", ",", "$", "new", ",", "$", "mode", ",", "$", "field_ids", ")", ";", "// For update, be careful to ignore the ID if it's the only difference", "foreach", "(", "$", "res", "[", "self", "::", "UPDATE", "]", "as", "$", "key", "=>", "$", "data", ")", "{", "$", "fields", "=", "$", "data", "[", "self", "::", "MODIFIED", "]", ";", "if", "(", "count", "(", "$", "fields", ")", "===", "1", "&&", "array_key_exists", "(", "'id'", ",", "$", "fields", ")", ")", "{", "unset", "(", "$", "res", "[", "self", "::", "UPDATE", "]", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "res", ";", "}" ]
Compute the difference between two metadata arrays. That method is overriden because else the id is taken into account @param $base Base or old array. @param $new New array with new definitions. @param $add If true find new fields. Default: true @param $del If true find fields to delete. Default: true @param $update if true find modified fields; Default: true @param $field_ids Array for field name to filter the results. @return array Return a 3-row array for add, del and update fields.
[ "Compute", "the", "difference", "between", "two", "metadata", "arrays", ".", "That", "method", "is", "overriden", "because", "else", "the", "id", "is", "taken", "into", "account" ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/Database/Relationship.php#L77-L90
230,688
teamreflex/TidalPHP
src/Tidal/Tidal.php
Tidal.connect
public function connect($email, $password) { $deferred = new Deferred(); $this->http->submit(Endpoints::LOGIN, [ 'username' => $email, 'password' => $password, ])->then(function (Response $response) use ($deferred) { $json = json_decode($response->getBody(), true); $this->userInfo = $json; $this->http = new Http($this->http, $json); $deferred->resolve($this); }, function ($e) use ($deferred) { $deferred->reject($e); }); return $deferred->promise(); }
php
public function connect($email, $password) { $deferred = new Deferred(); $this->http->submit(Endpoints::LOGIN, [ 'username' => $email, 'password' => $password, ])->then(function (Response $response) use ($deferred) { $json = json_decode($response->getBody(), true); $this->userInfo = $json; $this->http = new Http($this->http, $json); $deferred->resolve($this); }, function ($e) use ($deferred) { $deferred->reject($e); }); return $deferred->promise(); }
[ "public", "function", "connect", "(", "$", "email", ",", "$", "password", ")", "{", "$", "deferred", "=", "new", "Deferred", "(", ")", ";", "$", "this", "->", "http", "->", "submit", "(", "Endpoints", "::", "LOGIN", ",", "[", "'username'", "=>", "$", "email", ",", "'password'", "=>", "$", "password", ",", "]", ")", "->", "then", "(", "function", "(", "Response", "$", "response", ")", "use", "(", "$", "deferred", ")", "{", "$", "json", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "$", "this", "->", "userInfo", "=", "$", "json", ";", "$", "this", "->", "http", "=", "new", "Http", "(", "$", "this", "->", "http", ",", "$", "json", ")", ";", "$", "deferred", "->", "resolve", "(", "$", "this", ")", ";", "}", ",", "function", "(", "$", "e", ")", "use", "(", "$", "deferred", ")", "{", "$", "deferred", "->", "reject", "(", "$", "e", ")", ";", "}", ")", ";", "return", "$", "deferred", "->", "promise", "(", ")", ";", "}" ]
Authenticates with the TIDAL servers. @param string $email The Email to login with. @param string $password The password to login with. @return \React\Promise\Promise
[ "Authenticates", "with", "the", "TIDAL", "servers", "." ]
5d4948c75ae483d4baf318d94ba338801ec50cfc
https://github.com/teamreflex/TidalPHP/blob/5d4948c75ae483d4baf318d94ba338801ec50cfc/src/Tidal/Tidal.php#L77-L96
230,689
teamreflex/TidalPHP
src/Tidal/Tidal.php
Tidal.getUserInformation
public function getUserInformation() { $deferred = new Deferred(); $this->http->get(Options::replace(Endpoints::USER_INFO, ['id' => $this->userInfo['userId']]))->then(function ($json) use ($deferred) { $deferred->resolve($json); }, function ($e) use ($deferred) { $deferred->reject($e); }); return $deferred->promise(); }
php
public function getUserInformation() { $deferred = new Deferred(); $this->http->get(Options::replace(Endpoints::USER_INFO, ['id' => $this->userInfo['userId']]))->then(function ($json) use ($deferred) { $deferred->resolve($json); }, function ($e) use ($deferred) { $deferred->reject($e); }); return $deferred->promise(); }
[ "public", "function", "getUserInformation", "(", ")", "{", "$", "deferred", "=", "new", "Deferred", "(", ")", ";", "$", "this", "->", "http", "->", "get", "(", "Options", "::", "replace", "(", "Endpoints", "::", "USER_INFO", ",", "[", "'id'", "=>", "$", "this", "->", "userInfo", "[", "'userId'", "]", "]", ")", ")", "->", "then", "(", "function", "(", "$", "json", ")", "use", "(", "$", "deferred", ")", "{", "$", "deferred", "->", "resolve", "(", "$", "json", ")", ";", "}", ",", "function", "(", "$", "e", ")", "use", "(", "$", "deferred", ")", "{", "$", "deferred", "->", "reject", "(", "$", "e", ")", ";", "}", ")", ";", "return", "$", "deferred", "->", "promise", "(", ")", ";", "}" ]
Gets the current user information. @return \React\Promise\Promise
[ "Gets", "the", "current", "user", "information", "." ]
5d4948c75ae483d4baf318d94ba338801ec50cfc
https://github.com/teamreflex/TidalPHP/blob/5d4948c75ae483d4baf318d94ba338801ec50cfc/src/Tidal/Tidal.php#L103-L114
230,690
teamreflex/TidalPHP
src/Tidal/Tidal.php
Tidal.search
public function search(array $options) { $options = Options::buildOptions(Options::$defaultOptions, $options, $this); $deferred = new Deferred(); $this->http->get(Endpoints::SEARCH.$options)->then(function ($response) use ($deferred) { $collection = new Collection(); foreach ($response as $key => $values) { if ($key == 'artists') { $artists = new Collection(); foreach ($values['items'] as $value) { $artists->push(new Artist($this->http, $this, $value)); } $collection['artists'] = $artists; } elseif ($key == 'albums') { $albums = new Collection(); foreach ($values['items'] as $value) { $albums->push(new Album($this->http, $this, $value)); } $collection['albums'] = $albums; } elseif ($key == 'playlists') { $playlists = new Collection(); foreach ($values['items'] as $value) { $playlists->push(new Playlist($this->http, $this, $value)); } $collection['playlists'] = $playlists; } elseif ($key == 'tracks') { $tracks = new Collection(); foreach ($values['items'] as $value) { $tracks->push(new Track($this->http, $this, $value)); } $collection['tracks'] = $tracks; } elseif ($key == 'videos') { $videos = new Collection(); foreach ($values['items'] as $value) { $videos->push(new Video($this->http, $this, $value)); } $collection['videos'] = $videos; } } $deferred->resolve($collection); }, function ($e) use ($deferred) { $deferred->reject($e); }); return $deferred->promise(); }
php
public function search(array $options) { $options = Options::buildOptions(Options::$defaultOptions, $options, $this); $deferred = new Deferred(); $this->http->get(Endpoints::SEARCH.$options)->then(function ($response) use ($deferred) { $collection = new Collection(); foreach ($response as $key => $values) { if ($key == 'artists') { $artists = new Collection(); foreach ($values['items'] as $value) { $artists->push(new Artist($this->http, $this, $value)); } $collection['artists'] = $artists; } elseif ($key == 'albums') { $albums = new Collection(); foreach ($values['items'] as $value) { $albums->push(new Album($this->http, $this, $value)); } $collection['albums'] = $albums; } elseif ($key == 'playlists') { $playlists = new Collection(); foreach ($values['items'] as $value) { $playlists->push(new Playlist($this->http, $this, $value)); } $collection['playlists'] = $playlists; } elseif ($key == 'tracks') { $tracks = new Collection(); foreach ($values['items'] as $value) { $tracks->push(new Track($this->http, $this, $value)); } $collection['tracks'] = $tracks; } elseif ($key == 'videos') { $videos = new Collection(); foreach ($values['items'] as $value) { $videos->push(new Video($this->http, $this, $value)); } $collection['videos'] = $videos; } } $deferred->resolve($collection); }, function ($e) use ($deferred) { $deferred->reject($e); }); return $deferred->promise(); }
[ "public", "function", "search", "(", "array", "$", "options", ")", "{", "$", "options", "=", "Options", "::", "buildOptions", "(", "Options", "::", "$", "defaultOptions", ",", "$", "options", ",", "$", "this", ")", ";", "$", "deferred", "=", "new", "Deferred", "(", ")", ";", "$", "this", "->", "http", "->", "get", "(", "Endpoints", "::", "SEARCH", ".", "$", "options", ")", "->", "then", "(", "function", "(", "$", "response", ")", "use", "(", "$", "deferred", ")", "{", "$", "collection", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "response", "as", "$", "key", "=>", "$", "values", ")", "{", "if", "(", "$", "key", "==", "'artists'", ")", "{", "$", "artists", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "values", "[", "'items'", "]", "as", "$", "value", ")", "{", "$", "artists", "->", "push", "(", "new", "Artist", "(", "$", "this", "->", "http", ",", "$", "this", ",", "$", "value", ")", ")", ";", "}", "$", "collection", "[", "'artists'", "]", "=", "$", "artists", ";", "}", "elseif", "(", "$", "key", "==", "'albums'", ")", "{", "$", "albums", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "values", "[", "'items'", "]", "as", "$", "value", ")", "{", "$", "albums", "->", "push", "(", "new", "Album", "(", "$", "this", "->", "http", ",", "$", "this", ",", "$", "value", ")", ")", ";", "}", "$", "collection", "[", "'albums'", "]", "=", "$", "albums", ";", "}", "elseif", "(", "$", "key", "==", "'playlists'", ")", "{", "$", "playlists", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "values", "[", "'items'", "]", "as", "$", "value", ")", "{", "$", "playlists", "->", "push", "(", "new", "Playlist", "(", "$", "this", "->", "http", ",", "$", "this", ",", "$", "value", ")", ")", ";", "}", "$", "collection", "[", "'playlists'", "]", "=", "$", "playlists", ";", "}", "elseif", "(", "$", "key", "==", "'tracks'", ")", "{", "$", "tracks", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "values", "[", "'items'", "]", "as", "$", "value", ")", "{", "$", "tracks", "->", "push", "(", "new", "Track", "(", "$", "this", "->", "http", ",", "$", "this", ",", "$", "value", ")", ")", ";", "}", "$", "collection", "[", "'tracks'", "]", "=", "$", "tracks", ";", "}", "elseif", "(", "$", "key", "==", "'videos'", ")", "{", "$", "videos", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "values", "[", "'items'", "]", "as", "$", "value", ")", "{", "$", "videos", "->", "push", "(", "new", "Video", "(", "$", "this", "->", "http", ",", "$", "this", ",", "$", "value", ")", ")", ";", "}", "$", "collection", "[", "'videos'", "]", "=", "$", "videos", ";", "}", "}", "$", "deferred", "->", "resolve", "(", "$", "collection", ")", ";", "}", ",", "function", "(", "$", "e", ")", "use", "(", "$", "deferred", ")", "{", "$", "deferred", "->", "reject", "(", "$", "e", ")", ";", "}", ")", ";", "return", "$", "deferred", "->", "promise", "(", ")", ";", "}" ]
Runs a search query on the Discord servers. @param array $options An array of search options. @return \React\Promise\Promise
[ "Runs", "a", "search", "query", "on", "the", "Discord", "servers", "." ]
5d4948c75ae483d4baf318d94ba338801ec50cfc
https://github.com/teamreflex/TidalPHP/blob/5d4948c75ae483d4baf318d94ba338801ec50cfc/src/Tidal/Tidal.php#L123-L182
230,691
cygnite/framework
src/Cygnite/Console/Command/GeneratorCommand.php
GeneratorCommand.generateController
private function generateController() { // Generate Controller class $controllerInstance = Controller::instance($this->columns, $this->viewType, $this); $controllerTemplateDir = dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Controllers'.DS; $controllerInstance->setControllerTemplatePath($controllerTemplateDir); $controllerInstance->setApplicationDirectory($this->applicationDir); $controllerInstance->setControllerName($this->controller); $controllerInstance->setModelName($this->model); $controllerInstance->updateTemplate(); $controllerInstance->generateControllerTemplate(); $controllerInstance->generate(); $this->info("Controller $this->controller Generated Successfully!"); }
php
private function generateController() { // Generate Controller class $controllerInstance = Controller::instance($this->columns, $this->viewType, $this); $controllerTemplateDir = dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Controllers'.DS; $controllerInstance->setControllerTemplatePath($controllerTemplateDir); $controllerInstance->setApplicationDirectory($this->applicationDir); $controllerInstance->setControllerName($this->controller); $controllerInstance->setModelName($this->model); $controllerInstance->updateTemplate(); $controllerInstance->generateControllerTemplate(); $controllerInstance->generate(); $this->info("Controller $this->controller Generated Successfully!"); }
[ "private", "function", "generateController", "(", ")", "{", "// Generate Controller class", "$", "controllerInstance", "=", "Controller", "::", "instance", "(", "$", "this", "->", "columns", ",", "$", "this", "->", "viewType", ",", "$", "this", ")", ";", "$", "controllerTemplateDir", "=", "dirname", "(", "dirname", "(", "__FILE__", ")", ")", ".", "DS", ".", "'src'", ".", "DS", ".", "'Apps'", ".", "DS", ".", "'Controllers'", ".", "DS", ";", "$", "controllerInstance", "->", "setControllerTemplatePath", "(", "$", "controllerTemplateDir", ")", ";", "$", "controllerInstance", "->", "setApplicationDirectory", "(", "$", "this", "->", "applicationDir", ")", ";", "$", "controllerInstance", "->", "setControllerName", "(", "$", "this", "->", "controller", ")", ";", "$", "controllerInstance", "->", "setModelName", "(", "$", "this", "->", "model", ")", ";", "$", "controllerInstance", "->", "updateTemplate", "(", ")", ";", "$", "controllerInstance", "->", "generateControllerTemplate", "(", ")", ";", "$", "controllerInstance", "->", "generate", "(", ")", ";", "$", "this", "->", "info", "(", "\"Controller $this->controller Generated Successfully!\"", ")", ";", "}" ]
We will generate Controller.
[ "We", "will", "generate", "Controller", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Command/GeneratorCommand.php#L197-L216
230,692
cygnite/framework
src/Cygnite/Console/Command/GeneratorCommand.php
GeneratorCommand.generateViews
private function generateViews() { $viewInstance = View::instance($this); $viewInstance->setLayoutType($this->viewType); $viewTemplateDir = dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Views'.DS; $viewInstance->setTableColumns($this->columns); $viewInstance->setViewTemplatePath($viewTemplateDir); // generate twig template layout if type has set via user if ($this->viewType == 'php') { // Type not set then we will generate php layout $viewInstance->generateLayout('layouts'); } else { $viewInstance->generateLayout('layouts.main'); } $viewInstance->generateViews(); $this->info( 'Views Generated In '.str_replace('Controller', '', $this->controller).' Directory..' ); }
php
private function generateViews() { $viewInstance = View::instance($this); $viewInstance->setLayoutType($this->viewType); $viewTemplateDir = dirname(dirname(__FILE__)).DS.'src'.DS.'Apps'.DS.'Views'.DS; $viewInstance->setTableColumns($this->columns); $viewInstance->setViewTemplatePath($viewTemplateDir); // generate twig template layout if type has set via user if ($this->viewType == 'php') { // Type not set then we will generate php layout $viewInstance->generateLayout('layouts'); } else { $viewInstance->generateLayout('layouts.main'); } $viewInstance->generateViews(); $this->info( 'Views Generated In '.str_replace('Controller', '', $this->controller).' Directory..' ); }
[ "private", "function", "generateViews", "(", ")", "{", "$", "viewInstance", "=", "View", "::", "instance", "(", "$", "this", ")", ";", "$", "viewInstance", "->", "setLayoutType", "(", "$", "this", "->", "viewType", ")", ";", "$", "viewTemplateDir", "=", "dirname", "(", "dirname", "(", "__FILE__", ")", ")", ".", "DS", ".", "'src'", ".", "DS", ".", "'Apps'", ".", "DS", ".", "'Views'", ".", "DS", ";", "$", "viewInstance", "->", "setTableColumns", "(", "$", "this", "->", "columns", ")", ";", "$", "viewInstance", "->", "setViewTemplatePath", "(", "$", "viewTemplateDir", ")", ";", "// generate twig template layout if type has set via user", "if", "(", "$", "this", "->", "viewType", "==", "'php'", ")", "{", "// Type not set then we will generate php layout", "$", "viewInstance", "->", "generateLayout", "(", "'layouts'", ")", ";", "}", "else", "{", "$", "viewInstance", "->", "generateLayout", "(", "'layouts.main'", ")", ";", "}", "$", "viewInstance", "->", "generateViews", "(", ")", ";", "$", "this", "->", "info", "(", "'Views Generated In '", ".", "str_replace", "(", "'Controller'", ",", "''", ",", "$", "this", "->", "controller", ")", ".", "' Directory..'", ")", ";", "}" ]
We will generate the view pages into views directory.
[ "We", "will", "generate", "the", "view", "pages", "into", "views", "directory", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Command/GeneratorCommand.php#L236-L257
230,693
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_method_clearallcache.php
Smarty_Internal_Method_ClearAllCache.clearAllCache
public function clearAllCache(Smarty $smarty, $exp_time = null, $type = null) { // load cache resource and call clearAll $_cache_resource = Smarty_CacheResource::load($smarty, $type); $_cache_resource->invalidLoadedCache($smarty); return $_cache_resource->clearAll($smarty, $exp_time); }
php
public function clearAllCache(Smarty $smarty, $exp_time = null, $type = null) { // load cache resource and call clearAll $_cache_resource = Smarty_CacheResource::load($smarty, $type); $_cache_resource->invalidLoadedCache($smarty); return $_cache_resource->clearAll($smarty, $exp_time); }
[ "public", "function", "clearAllCache", "(", "Smarty", "$", "smarty", ",", "$", "exp_time", "=", "null", ",", "$", "type", "=", "null", ")", "{", "// load cache resource and call clearAll", "$", "_cache_resource", "=", "Smarty_CacheResource", "::", "load", "(", "$", "smarty", ",", "$", "type", ")", ";", "$", "_cache_resource", "->", "invalidLoadedCache", "(", "$", "smarty", ")", ";", "return", "$", "_cache_resource", "->", "clearAll", "(", "$", "smarty", ",", "$", "exp_time", ")", ";", "}" ]
Empty cache folder @api Smarty::clearAllCache() @link http://www.smarty.net/docs/en/api.clear.all.cache.tpl @param \Smarty $smarty @param integer $exp_time expiration time @param string $type resource type @return integer number of cache files deleted
[ "Empty", "cache", "folder" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_method_clearallcache.php#L33-L39
230,694
inetprocess/libsugarcrm
src/Util/Filesystem.php
Filesystem.isEmpty
public function isEmpty($files) { if (!$files instanceof \Traversable) { $files = new \ArrayObject(is_array($files) ? $files : array($files)); } foreach ($files as $file) { if (!$this->exists($file)) { throw new FileNotFoundException(null, 0, null, $file); } if (is_file($file)) { $file_info = new \SplFileInfo($file); if ($file_info->getSize() !== 0) { return false; } } elseif (is_dir($file)) { $finder = new Finder(); $finder->in($file); $it = $finder->getIterator(); $it->rewind(); if ($it->valid()) { return false; } } else { throw new IOException( sprintf('File "%s" is not a directory or a regular file.', $file), 0, null, $file ); } } return true; }
php
public function isEmpty($files) { if (!$files instanceof \Traversable) { $files = new \ArrayObject(is_array($files) ? $files : array($files)); } foreach ($files as $file) { if (!$this->exists($file)) { throw new FileNotFoundException(null, 0, null, $file); } if (is_file($file)) { $file_info = new \SplFileInfo($file); if ($file_info->getSize() !== 0) { return false; } } elseif (is_dir($file)) { $finder = new Finder(); $finder->in($file); $it = $finder->getIterator(); $it->rewind(); if ($it->valid()) { return false; } } else { throw new IOException( sprintf('File "%s" is not a directory or a regular file.', $file), 0, null, $file ); } } return true; }
[ "public", "function", "isEmpty", "(", "$", "files", ")", "{", "if", "(", "!", "$", "files", "instanceof", "\\", "Traversable", ")", "{", "$", "files", "=", "new", "\\", "ArrayObject", "(", "is_array", "(", "$", "files", ")", "?", "$", "files", ":", "array", "(", "$", "files", ")", ")", ";", "}", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "file", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "null", ",", "0", ",", "null", ",", "$", "file", ")", ";", "}", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "$", "file_info", "=", "new", "\\", "SplFileInfo", "(", "$", "file", ")", ";", "if", "(", "$", "file_info", "->", "getSize", "(", ")", "!==", "0", ")", "{", "return", "false", ";", "}", "}", "elseif", "(", "is_dir", "(", "$", "file", ")", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "in", "(", "$", "file", ")", ";", "$", "it", "=", "$", "finder", "->", "getIterator", "(", ")", ";", "$", "it", "->", "rewind", "(", ")", ";", "if", "(", "$", "it", "->", "valid", "(", ")", ")", "{", "return", "false", ";", "}", "}", "else", "{", "throw", "new", "IOException", "(", "sprintf", "(", "'File \"%s\" is not a directory or a regular file.'", ",", "$", "file", ")", ",", "0", ",", "null", ",", "$", "file", ")", ";", "}", "}", "return", "true", ";", "}" ]
Test is files or directories passed as arguments are empty. Only valid for regular files and directories. @param mixed $files String or array of strings of path to files and directories. @return boolean True if all arguments are empty. (Size 0 for files and no children for directories).
[ "Test", "is", "files", "or", "directories", "passed", "as", "arguments", "are", "empty", ".", "Only", "valid", "for", "regular", "files", "and", "directories", "." ]
493bb105c29996dc583181431fcb0987fd1fed70
https://github.com/inetprocess/libsugarcrm/blob/493bb105c29996dc583181431fcb0987fd1fed70/src/Util/Filesystem.php#L35-L68
230,695
cygnite/framework
src/Cygnite/FormBuilder/Html/Elements.php
Elements.input
protected function input($key, $val) { $extra = [ 'type' => strtolower(__FUNCTION__), ]; return $this->composeElement($key, $val, $extra, true); }
php
protected function input($key, $val) { $extra = [ 'type' => strtolower(__FUNCTION__), ]; return $this->composeElement($key, $val, $extra, true); }
[ "protected", "function", "input", "(", "$", "key", ",", "$", "val", ")", "{", "$", "extra", "=", "[", "'type'", "=>", "strtolower", "(", "__FUNCTION__", ")", ",", "]", ";", "return", "$", "this", "->", "composeElement", "(", "$", "key", ",", "$", "val", ",", "$", "extra", ",", "true", ")", ";", "}" ]
Create html input element. @param $key @param $val @return $this
[ "Create", "html", "input", "element", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/FormBuilder/Html/Elements.php#L38-L45
230,696
cygnite/framework
src/Cygnite/FormBuilder/Html/Elements.php
Elements.label
protected function label($key, $val) { $extra = [ 'type' => strtolower(__FUNCTION__), ]; return $this->composeElement($key, $val, $extra); }
php
protected function label($key, $val) { $extra = [ 'type' => strtolower(__FUNCTION__), ]; return $this->composeElement($key, $val, $extra); }
[ "protected", "function", "label", "(", "$", "key", ",", "$", "val", ")", "{", "$", "extra", "=", "[", "'type'", "=>", "strtolower", "(", "__FUNCTION__", ")", ",", "]", ";", "return", "$", "this", "->", "composeElement", "(", "$", "key", ",", "$", "val", ",", "$", "extra", ")", ";", "}" ]
Create a label element form form. @param $key @param $val @return $this
[ "Create", "a", "label", "element", "form", "form", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/FormBuilder/Html/Elements.php#L133-L140
230,697
cygnite/framework
src/Cygnite/FormBuilder/Html/Elements.php
Elements.textarea
protected function textarea($key, $val) { $value = null; $value = isset($val['value']) ? $val['value'] : '' ; unset($val['value']); $extra = ['type' => 'textarea', 'value' => $value]; return $this->composeElement($key, $val, $extra); }
php
protected function textarea($key, $val) { $value = null; $value = isset($val['value']) ? $val['value'] : '' ; unset($val['value']); $extra = ['type' => 'textarea', 'value' => $value]; return $this->composeElement($key, $val, $extra); }
[ "protected", "function", "textarea", "(", "$", "key", ",", "$", "val", ")", "{", "$", "value", "=", "null", ";", "$", "value", "=", "isset", "(", "$", "val", "[", "'value'", "]", ")", "?", "$", "val", "[", "'value'", "]", ":", "''", ";", "unset", "(", "$", "val", "[", "'value'", "]", ")", ";", "$", "extra", "=", "[", "'type'", "=>", "'textarea'", ",", "'value'", "=>", "$", "value", "]", ";", "return", "$", "this", "->", "composeElement", "(", "$", "key", ",", "$", "val", ",", "$", "extra", ")", ";", "}" ]
Create textarea element. @param $key @param $val @return $this
[ "Create", "textarea", "element", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/FormBuilder/Html/Elements.php#L196-L205
230,698
cygnite/framework
src/Cygnite/FormBuilder/Html/Elements.php
Elements.select
protected function select($key, $params) { $select = $selectValue = ''; $options = $params['options']; unset($params['options']); $selected = null; if (isset($params['selected'])) { $selected = $params['selected']; unset($params['selected']); } list($elClass, $params) = $this->highlightErrorElement($key, $params); $select .= '<select'." name='".$key."' ".$this->attributes($params).' '.$elClass.'>'.PHP_EOL; /* | Build select box options and return as string | */ $select .= $this->getSelectOptions($options, $selected); $select .= '</select>'.PHP_EOL; $this->elements[static::$formHolder[static::$formName]][$key] = $select; return $this; }
php
protected function select($key, $params) { $select = $selectValue = ''; $options = $params['options']; unset($params['options']); $selected = null; if (isset($params['selected'])) { $selected = $params['selected']; unset($params['selected']); } list($elClass, $params) = $this->highlightErrorElement($key, $params); $select .= '<select'." name='".$key."' ".$this->attributes($params).' '.$elClass.'>'.PHP_EOL; /* | Build select box options and return as string | */ $select .= $this->getSelectOptions($options, $selected); $select .= '</select>'.PHP_EOL; $this->elements[static::$formHolder[static::$formName]][$key] = $select; return $this; }
[ "protected", "function", "select", "(", "$", "key", ",", "$", "params", ")", "{", "$", "select", "=", "$", "selectValue", "=", "''", ";", "$", "options", "=", "$", "params", "[", "'options'", "]", ";", "unset", "(", "$", "params", "[", "'options'", "]", ")", ";", "$", "selected", "=", "null", ";", "if", "(", "isset", "(", "$", "params", "[", "'selected'", "]", ")", ")", "{", "$", "selected", "=", "$", "params", "[", "'selected'", "]", ";", "unset", "(", "$", "params", "[", "'selected'", "]", ")", ";", "}", "list", "(", "$", "elClass", ",", "$", "params", ")", "=", "$", "this", "->", "highlightErrorElement", "(", "$", "key", ",", "$", "params", ")", ";", "$", "select", ".=", "'<select'", ".", "\" name='\"", ".", "$", "key", ".", "\"' \"", ".", "$", "this", "->", "attributes", "(", "$", "params", ")", ".", "' '", ".", "$", "elClass", ".", "'>'", ".", "PHP_EOL", ";", "/*\n | Build select box options and return as string\n |\n */", "$", "select", ".=", "$", "this", "->", "getSelectOptions", "(", "$", "options", ",", "$", "selected", ")", ";", "$", "select", ".=", "'</select>'", ".", "PHP_EOL", ";", "$", "this", "->", "elements", "[", "static", "::", "$", "formHolder", "[", "static", "::", "$", "formName", "]", "]", "[", "$", "key", "]", "=", "$", "select", ";", "return", "$", "this", ";", "}" ]
Create a select box. @param $key @param $params @return $this
[ "Create", "a", "select", "box", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/FormBuilder/Html/Elements.php#L215-L241
230,699
cygnite/framework
src/Cygnite/FormBuilder/Html/Elements.php
Elements.getSelectOptions
private function getSelectOptions($options, $selected) { $select = ''; foreach ($options as $key => $value) { $isSelected = ($selected == $key) ? 'selected="selected"' : ''; $select .= "<option $isSelected value='".$key."'>".$value.'</option>'.PHP_EOL; } return $select; }
php
private function getSelectOptions($options, $selected) { $select = ''; foreach ($options as $key => $value) { $isSelected = ($selected == $key) ? 'selected="selected"' : ''; $select .= "<option $isSelected value='".$key."'>".$value.'</option>'.PHP_EOL; } return $select; }
[ "private", "function", "getSelectOptions", "(", "$", "options", ",", "$", "selected", ")", "{", "$", "select", "=", "''", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "isSelected", "=", "(", "$", "selected", "==", "$", "key", ")", "?", "'selected=\"selected\"'", ":", "''", ";", "$", "select", ".=", "\"<option $isSelected value='\"", ".", "$", "key", ".", "\"'>\"", ".", "$", "value", ".", "'</option>'", ".", "PHP_EOL", ";", "}", "return", "$", "select", ";", "}" ]
Returns select box option elements. @param $options @param $selected @return string
[ "Returns", "select", "box", "option", "elements", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/FormBuilder/Html/Elements.php#L250-L260