repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
tttptd/laravel-responder
src/ResourceFactory.php
ResourceFactory.makeFromPaginator
protected function makeFromPaginator(Paginator $paginator):ResourceInterface { $resource = static::makeFromCollection($paginator->getCollection()); if ($resource instanceof CollectionResource) { $queryParams = array_diff_key(app('request')->all(), array_flip(['page'])); $paginator->appends($queryParams); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); } return $resource; }
php
protected function makeFromPaginator(Paginator $paginator):ResourceInterface { $resource = static::makeFromCollection($paginator->getCollection()); if ($resource instanceof CollectionResource) { $queryParams = array_diff_key(app('request')->all(), array_flip(['page'])); $paginator->appends($queryParams); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); } return $resource; }
[ "protected", "function", "makeFromPaginator", "(", "Paginator", "$", "paginator", ")", ":", "ResourceInterface", "{", "$", "resource", "=", "static", "::", "makeFromCollection", "(", "$", "paginator", "->", "getCollection", "(", ")", ")", ";", "if", "(", "$", "resource", "instanceof", "CollectionResource", ")", "{", "$", "queryParams", "=", "array_diff_key", "(", "app", "(", "'request'", ")", "->", "all", "(", ")", ",", "array_flip", "(", "[", "'page'", "]", ")", ")", ";", "$", "paginator", "->", "appends", "(", "$", "queryParams", ")", ";", "$", "resource", "->", "setPaginator", "(", "new", "IlluminatePaginatorAdapter", "(", "$", "paginator", ")", ")", ";", "}", "return", "$", "resource", ";", "}" ]
Make resource from an Eloquent paginator. @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator @return \League\Fractal\Resource\ResourceInterface
[ "Make", "resource", "from", "an", "Eloquent", "paginator", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResourceFactory.php#L130-L142
OKTOTV/OktolabMediaBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('oktolab_media'); $rootNode ->children() ->arrayNode('origin') ->addDefaultsIfNotSet() ->children() ->scalarNode('url')->defaultValue('http://www.oktolab.at')->end() ->scalarNode('position')->defaultValue('top-right')->end() ->integerNode('margin')->defaultValue(8)->end() ->scalarNode('logo')->end() ->end() ->end() ->scalarNode('stream_class')->isRequired()->end() // the class of your stream entity ->scalarNode('default_streamserver')->defaultValue('server_1')->end() // the default server to use ->arrayNode('streamservers') //->requiresAtLeastOneElement() ->prototype('array') ->children() ->scalarNode('player_url')->defaultValue('')->end() // public player url ->scalarNode('rtmp_url')->defaultValue('')->end() // "private" rtmp server url ->scalarNode('rtmp_control')->defaultValue('')->end() // app on the rtmp server to use ->end() ->end() ->end() ->scalarNode('player_type')->defaultValue('jwplayer')->end() ->scalarNode('player_url')->isRequired()->end() ->scalarNode('episode_class')->isRequired()->end() ->scalarNode('series_class')->isRequired()->end() ->scalarNode('media_class')->defaultValue('Oktolab\MediaBundle\Entity\Media')->end() ->scalarNode('asset_class')->isRequired()->end() ->booleanNode('keep_original')->defaultFalse()->end() ->scalarNode('encoding_filesystem')->defaultValue('cache')->end() ->scalarNode('posterframe_filesystem')->defaultValue('posterframe')->end() ->scalarNode('sprite_filesystem')->defaultValue('posterframe')->end() ->scalarNode('default_filesystem')->defaultValue('video')->end() ->scalarNode('serializing_schema')->end() ->scalarNode('worker_queue')->defaultValue('oktolab_media')->end() ->scalarNode('sprite_worker_queue')->defaultValue('oktolab_media_sprite')->end() ->scalarNode('finalize_worker_queue')->defaultValue('oktolab_media_finalize')->end() ->integerNode('sprite_height')->defaultValue(180)->end() ->integerNode('sprite_width')->defaultValue(320)->end() ->integerNode('sprite_interval')->defaultValue(5)->end() ->arrayNode('resolutions') ->requiresAtLeastOneElement() ->prototype('array') ->children() ->scalarNode('decoder')->defaultValue('ffprobe')->end() ->scalarNode('encoder')->defaultValue('ffmpeg')->end() ->scalarNode('mimetype')->defaultValue('video/quicktime')->end() ->scalarNode('name')->end() ->scalarNode('type')->defaultValue('video')->end() ->integerNode('sortNumber')->defaultValue(1)->end() ->integerNode('stereomode')->defaultValue(0)->end() // differentiates the resolutions to use 0 none, 1 monoscopic 2 topbottom 3 leftright ->scalarNode('video_codec')->defaultValue("h264")->end() ->scalarNode('video_framerate')->defaultValue("50/1")->end() ->scalarNode('video_width')->end() ->scalarNode('video_height')->end() ->integerNode('video_bitrate')->defaultValue(5000000)->end() // 5 mbit ->integerNode('crf_rate')->defaultValue(23)->end() ->scalarNode('preset')->defaultValue('veryslow')->end() ->scalarNode('audio_codec')->defaultValue("aac")->end() ->scalarNode('audio_sample_rate')->defaultValue("48000")->end() ->scalarNode('audio_bitrate')->defaultValue("256000")->end() ->scalarNode('pix_fmt')->defaultValue("yuv420p")->end() ->scalarNode('allow_lower_audio_bitrate')->defaultValue(0)->end() ->scalarNode('container')->defaultValue('mov')->end() ->booleanNode('public')->defaultTrue()->end() ->scalarNode('adapter')->defaultValue('video')->end() ->end() ->end() ->end() ->arrayNode('api_urls') ->prototype('array') ->prototype('scalar')->end() ->end() ->end(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for // more information on that topic. return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('oktolab_media'); $rootNode ->children() ->arrayNode('origin') ->addDefaultsIfNotSet() ->children() ->scalarNode('url')->defaultValue('http://www.oktolab.at')->end() ->scalarNode('position')->defaultValue('top-right')->end() ->integerNode('margin')->defaultValue(8)->end() ->scalarNode('logo')->end() ->end() ->end() ->scalarNode('stream_class')->isRequired()->end() // the class of your stream entity ->scalarNode('default_streamserver')->defaultValue('server_1')->end() // the default server to use ->arrayNode('streamservers') //->requiresAtLeastOneElement() ->prototype('array') ->children() ->scalarNode('player_url')->defaultValue('')->end() // public player url ->scalarNode('rtmp_url')->defaultValue('')->end() // "private" rtmp server url ->scalarNode('rtmp_control')->defaultValue('')->end() // app on the rtmp server to use ->end() ->end() ->end() ->scalarNode('player_type')->defaultValue('jwplayer')->end() ->scalarNode('player_url')->isRequired()->end() ->scalarNode('episode_class')->isRequired()->end() ->scalarNode('series_class')->isRequired()->end() ->scalarNode('media_class')->defaultValue('Oktolab\MediaBundle\Entity\Media')->end() ->scalarNode('asset_class')->isRequired()->end() ->booleanNode('keep_original')->defaultFalse()->end() ->scalarNode('encoding_filesystem')->defaultValue('cache')->end() ->scalarNode('posterframe_filesystem')->defaultValue('posterframe')->end() ->scalarNode('sprite_filesystem')->defaultValue('posterframe')->end() ->scalarNode('default_filesystem')->defaultValue('video')->end() ->scalarNode('serializing_schema')->end() ->scalarNode('worker_queue')->defaultValue('oktolab_media')->end() ->scalarNode('sprite_worker_queue')->defaultValue('oktolab_media_sprite')->end() ->scalarNode('finalize_worker_queue')->defaultValue('oktolab_media_finalize')->end() ->integerNode('sprite_height')->defaultValue(180)->end() ->integerNode('sprite_width')->defaultValue(320)->end() ->integerNode('sprite_interval')->defaultValue(5)->end() ->arrayNode('resolutions') ->requiresAtLeastOneElement() ->prototype('array') ->children() ->scalarNode('decoder')->defaultValue('ffprobe')->end() ->scalarNode('encoder')->defaultValue('ffmpeg')->end() ->scalarNode('mimetype')->defaultValue('video/quicktime')->end() ->scalarNode('name')->end() ->scalarNode('type')->defaultValue('video')->end() ->integerNode('sortNumber')->defaultValue(1)->end() ->integerNode('stereomode')->defaultValue(0)->end() // differentiates the resolutions to use 0 none, 1 monoscopic 2 topbottom 3 leftright ->scalarNode('video_codec')->defaultValue("h264")->end() ->scalarNode('video_framerate')->defaultValue("50/1")->end() ->scalarNode('video_width')->end() ->scalarNode('video_height')->end() ->integerNode('video_bitrate')->defaultValue(5000000)->end() // 5 mbit ->integerNode('crf_rate')->defaultValue(23)->end() ->scalarNode('preset')->defaultValue('veryslow')->end() ->scalarNode('audio_codec')->defaultValue("aac")->end() ->scalarNode('audio_sample_rate')->defaultValue("48000")->end() ->scalarNode('audio_bitrate')->defaultValue("256000")->end() ->scalarNode('pix_fmt')->defaultValue("yuv420p")->end() ->scalarNode('allow_lower_audio_bitrate')->defaultValue(0)->end() ->scalarNode('container')->defaultValue('mov')->end() ->booleanNode('public')->defaultTrue()->end() ->scalarNode('adapter')->defaultValue('video')->end() ->end() ->end() ->end() ->arrayNode('api_urls') ->prototype('array') ->prototype('scalar')->end() ->end() ->end(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for // more information on that topic. return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'oktolab_media'", ")", ";", "$", "rootNode", "->", "children", "(", ")", "->", "arrayNode", "(", "'origin'", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'url'", ")", "->", "defaultValue", "(", "'http://www.oktolab.at'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'position'", ")", "->", "defaultValue", "(", "'top-right'", ")", "->", "end", "(", ")", "->", "integerNode", "(", "'margin'", ")", "->", "defaultValue", "(", "8", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'logo'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'stream_class'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "// the class of your stream entity", "->", "scalarNode", "(", "'default_streamserver'", ")", "->", "defaultValue", "(", "'server_1'", ")", "->", "end", "(", ")", "// the default server to use", "->", "arrayNode", "(", "'streamservers'", ")", "//->requiresAtLeastOneElement()", "->", "prototype", "(", "'array'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'player_url'", ")", "->", "defaultValue", "(", "''", ")", "->", "end", "(", ")", "// public player url", "->", "scalarNode", "(", "'rtmp_url'", ")", "->", "defaultValue", "(", "''", ")", "->", "end", "(", ")", "// \"private\" rtmp server url", "->", "scalarNode", "(", "'rtmp_control'", ")", "->", "defaultValue", "(", "''", ")", "->", "end", "(", ")", "// app on the rtmp server to use", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'player_type'", ")", "->", "defaultValue", "(", "'jwplayer'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'player_url'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'episode_class'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'series_class'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'media_class'", ")", "->", "defaultValue", "(", "'Oktolab\\MediaBundle\\Entity\\Media'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'asset_class'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'keep_original'", ")", "->", "defaultFalse", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'encoding_filesystem'", ")", "->", "defaultValue", "(", "'cache'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'posterframe_filesystem'", ")", "->", "defaultValue", "(", "'posterframe'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'sprite_filesystem'", ")", "->", "defaultValue", "(", "'posterframe'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'default_filesystem'", ")", "->", "defaultValue", "(", "'video'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'serializing_schema'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'worker_queue'", ")", "->", "defaultValue", "(", "'oktolab_media'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'sprite_worker_queue'", ")", "->", "defaultValue", "(", "'oktolab_media_sprite'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'finalize_worker_queue'", ")", "->", "defaultValue", "(", "'oktolab_media_finalize'", ")", "->", "end", "(", ")", "->", "integerNode", "(", "'sprite_height'", ")", "->", "defaultValue", "(", "180", ")", "->", "end", "(", ")", "->", "integerNode", "(", "'sprite_width'", ")", "->", "defaultValue", "(", "320", ")", "->", "end", "(", ")", "->", "integerNode", "(", "'sprite_interval'", ")", "->", "defaultValue", "(", "5", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'resolutions'", ")", "->", "requiresAtLeastOneElement", "(", ")", "->", "prototype", "(", "'array'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'decoder'", ")", "->", "defaultValue", "(", "'ffprobe'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'encoder'", ")", "->", "defaultValue", "(", "'ffmpeg'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'mimetype'", ")", "->", "defaultValue", "(", "'video/quicktime'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'name'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'type'", ")", "->", "defaultValue", "(", "'video'", ")", "->", "end", "(", ")", "->", "integerNode", "(", "'sortNumber'", ")", "->", "defaultValue", "(", "1", ")", "->", "end", "(", ")", "->", "integerNode", "(", "'stereomode'", ")", "->", "defaultValue", "(", "0", ")", "->", "end", "(", ")", "// differentiates the resolutions to use 0 none, 1 monoscopic 2 topbottom 3 leftright", "->", "scalarNode", "(", "'video_codec'", ")", "->", "defaultValue", "(", "\"h264\"", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'video_framerate'", ")", "->", "defaultValue", "(", "\"50/1\"", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'video_width'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'video_height'", ")", "->", "end", "(", ")", "->", "integerNode", "(", "'video_bitrate'", ")", "->", "defaultValue", "(", "5000000", ")", "->", "end", "(", ")", "// 5 mbit", "->", "integerNode", "(", "'crf_rate'", ")", "->", "defaultValue", "(", "23", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'preset'", ")", "->", "defaultValue", "(", "'veryslow'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'audio_codec'", ")", "->", "defaultValue", "(", "\"aac\"", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'audio_sample_rate'", ")", "->", "defaultValue", "(", "\"48000\"", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'audio_bitrate'", ")", "->", "defaultValue", "(", "\"256000\"", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'pix_fmt'", ")", "->", "defaultValue", "(", "\"yuv420p\"", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'allow_lower_audio_bitrate'", ")", "->", "defaultValue", "(", "0", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'container'", ")", "->", "defaultValue", "(", "'mov'", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'public'", ")", "->", "defaultTrue", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'adapter'", ")", "->", "defaultValue", "(", "'video'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'api_urls'", ")", "->", "prototype", "(", "'array'", ")", "->", "prototype", "(", "'scalar'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "// Here you should define the parameters that are allowed to", "// configure your bundle. See the documentation linked above for", "// more information on that topic.", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/DependencyInjection/Configuration.php#L18-L102
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Adapter/FileTransfer.php
FileTransfer.download
public function download($ftkey, $size, $passthru = FALSE) { $this->init($ftkey); if($passthru) { return $this->passthru($size); } $buff = new Str(""); $size = intval($size); $pack = 4096; Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size); for($seek = 0;$seek < $size;) { $rest = $size-$seek; $pack = $rest < $pack ? $rest : $pack; $data = $this->getTransport()->read($rest < $pack ? $rest : $pack); $seek = $seek+$pack; $buff->append($data); Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size); } $this->getProfiler()->stop(); Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size); if(strlen($buff) != $size) { throw new Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)"); } return $buff; }
php
public function download($ftkey, $size, $passthru = FALSE) { $this->init($ftkey); if($passthru) { return $this->passthru($size); } $buff = new Str(""); $size = intval($size); $pack = 4096; Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size); for($seek = 0;$seek < $size;) { $rest = $size-$seek; $pack = $rest < $pack ? $rest : $pack; $data = $this->getTransport()->read($rest < $pack ? $rest : $pack); $seek = $seek+$pack; $buff->append($data); Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size); } $this->getProfiler()->stop(); Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size); if(strlen($buff) != $size) { throw new Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)"); } return $buff; }
[ "public", "function", "download", "(", "$", "ftkey", ",", "$", "size", ",", "$", "passthru", "=", "FALSE", ")", "{", "$", "this", "->", "init", "(", "$", "ftkey", ")", ";", "if", "(", "$", "passthru", ")", "{", "return", "$", "this", "->", "passthru", "(", "$", "size", ")", ";", "}", "$", "buff", "=", "new", "Str", "(", "\"\"", ")", ";", "$", "size", "=", "intval", "(", "$", "size", ")", ";", "$", "pack", "=", "4096", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadStarted\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "for", "(", "$", "seek", "=", "0", ";", "$", "seek", "<", "$", "size", ";", ")", "{", "$", "rest", "=", "$", "size", "-", "$", "seek", ";", "$", "pack", "=", "$", "rest", "<", "$", "pack", "?", "$", "rest", ":", "$", "pack", ";", "$", "data", "=", "$", "this", "->", "getTransport", "(", ")", "->", "read", "(", "$", "rest", "<", "$", "pack", "?", "$", "rest", ":", "$", "pack", ")", ";", "$", "seek", "=", "$", "seek", "+", "$", "pack", ";", "$", "buff", "->", "append", "(", "$", "data", ")", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadProgress\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "}", "$", "this", "->", "getProfiler", "(", ")", "->", "stop", "(", ")", ";", "Signal", "::", "getInstance", "(", ")", "->", "emit", "(", "\"filetransferDownloadFinished\"", ",", "$", "ftkey", ",", "count", "(", "$", "buff", ")", ",", "$", "size", ")", ";", "if", "(", "strlen", "(", "$", "buff", ")", "!=", "$", "size", ")", "{", "throw", "new", "Exception", "(", "\"incomplete file download (\"", ".", "count", "(", "$", "buff", ")", ".", "\" of \"", ".", "$", "size", ".", "\" bytes)\"", ")", ";", "}", "return", "$", "buff", ";", "}" ]
Returns the content of a downloaded file as a Str object. @param string $ftkey @param integer $size @param boolean $passthru @throws Exception @return Str
[ "Returns", "the", "content", "of", "a", "downloaded", "file", "as", "a", "Str", "object", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Adapter/FileTransfer.php#L142-L179
surebert/surebert-framework
src/sb/Cache/Memcache.php
Memcache.store
public function store($key, $data, $lifetime = 0, $compress = 0) { $key = $this->namespace . $key; $store = $this->memcache->set($key, $data, $compress, $lifetime); if ($store && $key != $this->namespace . $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return $store; }
php
public function store($key, $data, $lifetime = 0, $compress = 0) { $key = $this->namespace . $key; $store = $this->memcache->set($key, $data, $compress, $lifetime); if ($store && $key != $this->namespace . $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return $store; }
[ "public", "function", "store", "(", "$", "key", ",", "$", "data", ",", "$", "lifetime", "=", "0", ",", "$", "compress", "=", "0", ")", "{", "$", "key", "=", "$", "this", "->", "namespace", ".", "$", "key", ";", "$", "store", "=", "$", "this", "->", "memcache", "->", "set", "(", "$", "key", ",", "$", "data", ",", "$", "compress", ",", "$", "lifetime", ")", ";", "if", "(", "$", "store", "&&", "$", "key", "!=", "$", "this", "->", "namespace", ".", "$", "this", "->", "catalog_key", ")", "{", "$", "this", "->", "catalogKeyAdd", "(", "$", "key", ",", "$", "lifetime", ")", ";", "}", "return", "$", "store", ";", "}" ]
Store the cache data in memcache (non-PHPdoc) @see trunk/private/framework/sb/sb_Cache#store()
[ "Store", "the", "cache", "data", "in", "memcache", "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Memcache.php#L63-L74
surebert/surebert-framework
src/sb/Cache/Memcache.php
Memcache.delete
public function delete($key) { $deleted = false; $catalog = \array_keys($this->getKeys()); foreach ($catalog as $k) { if (substr($k, 0, strlen($key)) == $key) { $delete = $this->memcache->delete($this->namespace . $key); if ($delete) { $this->catalogKeyDelete($k); $deleted = true; } } } return $deleted; }
php
public function delete($key) { $deleted = false; $catalog = \array_keys($this->getKeys()); foreach ($catalog as $k) { if (substr($k, 0, strlen($key)) == $key) { $delete = $this->memcache->delete($this->namespace . $key); if ($delete) { $this->catalogKeyDelete($k); $deleted = true; } } } return $deleted; }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "$", "deleted", "=", "false", ";", "$", "catalog", "=", "\\", "array_keys", "(", "$", "this", "->", "getKeys", "(", ")", ")", ";", "foreach", "(", "$", "catalog", "as", "$", "k", ")", "{", "if", "(", "substr", "(", "$", "k", ",", "0", ",", "strlen", "(", "$", "key", ")", ")", "==", "$", "key", ")", "{", "$", "delete", "=", "$", "this", "->", "memcache", "->", "delete", "(", "$", "this", "->", "namespace", ".", "$", "key", ")", ";", "if", "(", "$", "delete", ")", "{", "$", "this", "->", "catalogKeyDelete", "(", "$", "k", ")", ";", "$", "deleted", "=", "true", ";", "}", "}", "}", "return", "$", "deleted", ";", "}" ]
Deletes cache data (non-PHPdoc) @see trunk/private/framework/sb/sb_Cache#delete()
[ "Deletes", "cache", "data", "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Memcache.php#L93-L112
ekuiter/feature-php
FeaturePhp/ProductLine/Settings.php
Settings.processDirectoryEntry
private function processDirectoryEntry($artifactDirectory, $entry) { $entity = fphp\Helper\Path::join($artifactDirectory, $entry); // directory containing artifact file if (is_dir($entity) && !fphp\Helper\Path::isDot($entry) && in_array($this->get("artifactFile"), scandir($entity))) { $feature = $this->get("model")->getFeature($entry, true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile( fphp\Helper\Path::join($entity, $this->get("artifactFile"))) )); } else if (is_dir($entity) && !fphp\Helper\Path::isDot($entry)) // recursively search subdirectory foreach (scandir($entity) as $entry) $this->processDirectoryEntry($entity, $entry); else if (is_file($entity)) // artifact file try { $feature = $this->get("model")->getFeature(pathinfo($entity)["filename"], true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile($entity) )); } catch (fphp\Model\ModelException $e) {} }
php
private function processDirectoryEntry($artifactDirectory, $entry) { $entity = fphp\Helper\Path::join($artifactDirectory, $entry); // directory containing artifact file if (is_dir($entity) && !fphp\Helper\Path::isDot($entry) && in_array($this->get("artifactFile"), scandir($entity))) { $feature = $this->get("model")->getFeature($entry, true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile( fphp\Helper\Path::join($entity, $this->get("artifactFile"))) )); } else if (is_dir($entity) && !fphp\Helper\Path::isDot($entry)) // recursively search subdirectory foreach (scandir($entity) as $entry) $this->processDirectoryEntry($entity, $entry); else if (is_file($entity)) // artifact file try { $feature = $this->get("model")->getFeature(pathinfo($entity)["filename"], true); if ($this->has($feature->getName(), $this->get("artifacts"))) throw new fphp\SettingsException("there are multiple settings for \"{$feature->getName()}\""); $this->set("artifacts", $feature->getName(), new fphp\Artifact\Artifact( $feature, fphp\Artifact\Settings::fromFile($entity) )); } catch (fphp\Model\ModelException $e) {} }
[ "private", "function", "processDirectoryEntry", "(", "$", "artifactDirectory", ",", "$", "entry", ")", "{", "$", "entity", "=", "fphp", "\\", "Helper", "\\", "Path", "::", "join", "(", "$", "artifactDirectory", ",", "$", "entry", ")", ";", "// directory containing artifact file", "if", "(", "is_dir", "(", "$", "entity", ")", "&&", "!", "fphp", "\\", "Helper", "\\", "Path", "::", "isDot", "(", "$", "entry", ")", "&&", "in_array", "(", "$", "this", "->", "get", "(", "\"artifactFile\"", ")", ",", "scandir", "(", "$", "entity", ")", ")", ")", "{", "$", "feature", "=", "$", "this", "->", "get", "(", "\"model\"", ")", "->", "getFeature", "(", "$", "entry", ",", "true", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "feature", "->", "getName", "(", ")", ",", "$", "this", "->", "get", "(", "\"artifacts\"", ")", ")", ")", "throw", "new", "fphp", "\\", "SettingsException", "(", "\"there are multiple settings for \\\"{$feature->getName()}\\\"\"", ")", ";", "$", "this", "->", "set", "(", "\"artifacts\"", ",", "$", "feature", "->", "getName", "(", ")", ",", "new", "fphp", "\\", "Artifact", "\\", "Artifact", "(", "$", "feature", ",", "fphp", "\\", "Artifact", "\\", "Settings", "::", "fromFile", "(", "fphp", "\\", "Helper", "\\", "Path", "::", "join", "(", "$", "entity", ",", "$", "this", "->", "get", "(", "\"artifactFile\"", ")", ")", ")", ")", ")", ";", "}", "else", "if", "(", "is_dir", "(", "$", "entity", ")", "&&", "!", "fphp", "\\", "Helper", "\\", "Path", "::", "isDot", "(", "$", "entry", ")", ")", "// recursively search subdirectory", "foreach", "(", "scandir", "(", "$", "entity", ")", "as", "$", "entry", ")", "$", "this", "->", "processDirectoryEntry", "(", "$", "entity", ",", "$", "entry", ")", ";", "else", "if", "(", "is_file", "(", "$", "entity", ")", ")", "// artifact file", "try", "{", "$", "feature", "=", "$", "this", "->", "get", "(", "\"model\"", ")", "->", "getFeature", "(", "pathinfo", "(", "$", "entity", ")", "[", "\"filename\"", "]", ",", "true", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "feature", "->", "getName", "(", ")", ",", "$", "this", "->", "get", "(", "\"artifacts\"", ")", ")", ")", "throw", "new", "fphp", "\\", "SettingsException", "(", "\"there are multiple settings for \\\"{$feature->getName()}\\\"\"", ")", ";", "$", "this", "->", "set", "(", "\"artifacts\"", ",", "$", "feature", "->", "getName", "(", ")", ",", "new", "fphp", "\\", "Artifact", "\\", "Artifact", "(", "$", "feature", ",", "fphp", "\\", "Artifact", "\\", "Settings", "::", "fromFile", "(", "$", "entity", ")", ")", ")", ";", "}", "catch", "(", "fphp", "\\", "Model", "\\", "ModelException", "$", "e", ")", "{", "}", "}" ]
recursively search the artifact directory, allowing the user to group features
[ "recursively", "search", "the", "artifact", "directory", "allowing", "the", "user", "to", "group", "features" ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/Settings.php#L99-L125
zhouyl/mellivora
Mellivora/Database/Eloquent/Concerns/HasEvents.php
HasEvents.observe
public static function observe($class) { $className = is_string($class) ? $class : get_class($class); // When registering a model observer, we will spin through the possible events // and determine if this observer has that method. If it does, we will hook // it into the model's event system, making it convenient to watch these. foreach (static::$observables as $event) { if (method_exists($class, $event)) { static::registerModelEvent($event, $className . '@' . $event); } } }
php
public static function observe($class) { $className = is_string($class) ? $class : get_class($class); // When registering a model observer, we will spin through the possible events // and determine if this observer has that method. If it does, we will hook // it into the model's event system, making it convenient to watch these. foreach (static::$observables as $event) { if (method_exists($class, $event)) { static::registerModelEvent($event, $className . '@' . $event); } } }
[ "public", "static", "function", "observe", "(", "$", "class", ")", "{", "$", "className", "=", "is_string", "(", "$", "class", ")", "?", "$", "class", ":", "get_class", "(", "$", "class", ")", ";", "// When registering a model observer, we will spin through the possible events", "// and determine if this observer has that method. If it does, we will hook", "// it into the model's event system, making it convenient to watch these.", "foreach", "(", "static", "::", "$", "observables", "as", "$", "event", ")", "{", "if", "(", "method_exists", "(", "$", "class", ",", "$", "event", ")", ")", "{", "static", "::", "registerModelEvent", "(", "$", "event", ",", "$", "className", ".", "'@'", ".", "$", "event", ")", ";", "}", "}", "}" ]
Register an observer with the Model. @param object|string $class @return void
[ "Register", "an", "observer", "with", "the", "Model", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Concerns/HasEvents.php#L37-L49
zhouyl/mellivora
Mellivora/Database/Eloquent/Concerns/HasEvents.php
HasEvents.fireModelEvent
protected function fireModelEvent($event, $halt = true) { if (!isset(static::$dispatcher)) { return true; } // First, we will get the proper method to call on the event dispatcher, and then we // will attempt to fire a custom, object based event for the given event. If that // returns a result we can return that result, or we'll call the string events. $method = $halt ? 'until' : 'fire'; $result = $this->fireCustomModelEvent($event, $method); return !is_null($result) ? $result : static::$dispatcher->{$method}( "eloquent.{$event}", $this ); }
php
protected function fireModelEvent($event, $halt = true) { if (!isset(static::$dispatcher)) { return true; } // First, we will get the proper method to call on the event dispatcher, and then we // will attempt to fire a custom, object based event for the given event. If that // returns a result we can return that result, or we'll call the string events. $method = $halt ? 'until' : 'fire'; $result = $this->fireCustomModelEvent($event, $method); return !is_null($result) ? $result : static::$dispatcher->{$method}( "eloquent.{$event}", $this ); }
[ "protected", "function", "fireModelEvent", "(", "$", "event", ",", "$", "halt", "=", "true", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "dispatcher", ")", ")", "{", "return", "true", ";", "}", "// First, we will get the proper method to call on the event dispatcher, and then we", "// will attempt to fire a custom, object based event for the given event. If that", "// returns a result we can return that result, or we'll call the string events.", "$", "method", "=", "$", "halt", "?", "'until'", ":", "'fire'", ";", "$", "result", "=", "$", "this", "->", "fireCustomModelEvent", "(", "$", "event", ",", "$", "method", ")", ";", "return", "!", "is_null", "(", "$", "result", ")", "?", "$", "result", ":", "static", "::", "$", "dispatcher", "->", "{", "$", "method", "}", "(", "\"eloquent.{$event}\"", ",", "$", "this", ")", ";", "}" ]
Fire the given event for the model. @param string $event @param bool $halt @return mixed
[ "Fire", "the", "given", "event", "for", "the", "model", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Concerns/HasEvents.php#L74-L91
nabab/bbn
src/bbn/mvc/controller.php
controller.say_local_path
public function say_local_path() { if ( ($pp = $this->get_prepath()) && (strpos($this->path, $pp) === 0) ){ return substr($this->path, \strlen($pp)); } return $this->path; }
php
public function say_local_path() { if ( ($pp = $this->get_prepath()) && (strpos($this->path, $pp) === 0) ){ return substr($this->path, \strlen($pp)); } return $this->path; }
[ "public", "function", "say_local_path", "(", ")", "{", "if", "(", "(", "$", "pp", "=", "$", "this", "->", "get_prepath", "(", ")", ")", "&&", "(", "strpos", "(", "$", "this", "->", "path", ",", "$", "pp", ")", "===", "0", ")", ")", "{", "return", "substr", "(", "$", "this", "->", "path", ",", "\\", "strlen", "(", "$", "pp", ")", ")", ";", "}", "return", "$", "this", "->", "path", ";", "}" ]
Returns the current controller's path. @return string
[ "Returns", "the", "current", "controller", "s", "path", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L228-L234
nabab/bbn
src/bbn/mvc/controller.php
controller.say_local_route
public function say_local_route() { if ( ($pp = $this->get_prepath()) && (strpos($this->request, $pp) === 0) ){ return substr($this->request, \strlen($pp)); } return $this->request; }
php
public function say_local_route() { if ( ($pp = $this->get_prepath()) && (strpos($this->request, $pp) === 0) ){ return substr($this->request, \strlen($pp)); } return $this->request; }
[ "public", "function", "say_local_route", "(", ")", "{", "if", "(", "(", "$", "pp", "=", "$", "this", "->", "get_prepath", "(", ")", ")", "&&", "(", "strpos", "(", "$", "this", "->", "request", ",", "$", "pp", ")", "===", "0", ")", ")", "{", "return", "substr", "(", "$", "this", "->", "request", ",", "\\", "strlen", "(", "$", "pp", ")", ")", ";", "}", "return", "$", "this", "->", "request", ";", "}" ]
Returns the current controller's path. @return string
[ "Returns", "the", "current", "controller", "s", "path", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L251-L257
nabab/bbn
src/bbn/mvc/controller.php
controller.say_dir
public function say_dir() { if ( $this->path ){ $p = dirname($this->path); if ( $p === '.' ){ return ''; } if ( ($prepath = $this->get_prepath()) && (strpos($p, $prepath) === 0) ){ return substr($p, \strlen($prepath)); } return $p; } return false; }
php
public function say_dir() { if ( $this->path ){ $p = dirname($this->path); if ( $p === '.' ){ return ''; } if ( ($prepath = $this->get_prepath()) && (strpos($p, $prepath) === 0) ){ return substr($p, \strlen($prepath)); } return $p; } return false; }
[ "public", "function", "say_dir", "(", ")", "{", "if", "(", "$", "this", "->", "path", ")", "{", "$", "p", "=", "dirname", "(", "$", "this", "->", "path", ")", ";", "if", "(", "$", "p", "===", "'.'", ")", "{", "return", "''", ";", "}", "if", "(", "(", "$", "prepath", "=", "$", "this", "->", "get_prepath", "(", ")", ")", "&&", "(", "strpos", "(", "$", "p", ",", "$", "prepath", ")", "===", "0", ")", ")", "{", "return", "substr", "(", "$", "p", ",", "\\", "strlen", "(", "$", "prepath", ")", ")", ";", "}", "return", "$", "p", ";", "}", "return", "false", ";", "}" ]
Returns the current controller's file's name. @return string
[ "Returns", "the", "current", "controller", "s", "file", "s", "name", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L264-L280
nabab/bbn
src/bbn/mvc/controller.php
controller.render
public function render($view, $model=''){ if ( empty($model) && $this->has_data() ){ $model = $this->data; } if ( \is_string($view) ){ return \is_array($model) ? bbn\tpl::render($view, $model) : $view; } die(bbn\x::hdump("Problem with the template", $view, $this->path, $this->mode)); }
php
public function render($view, $model=''){ if ( empty($model) && $this->has_data() ){ $model = $this->data; } if ( \is_string($view) ){ return \is_array($model) ? bbn\tpl::render($view, $model) : $view; } die(bbn\x::hdump("Problem with the template", $view, $this->path, $this->mode)); }
[ "public", "function", "render", "(", "$", "view", ",", "$", "model", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "model", ")", "&&", "$", "this", "->", "has_data", "(", ")", ")", "{", "$", "model", "=", "$", "this", "->", "data", ";", "}", "if", "(", "\\", "is_string", "(", "$", "view", ")", ")", "{", "return", "\\", "is_array", "(", "$", "model", ")", "?", "bbn", "\\", "tpl", "::", "render", "(", "$", "view", ",", "$", "model", ")", ":", "$", "view", ";", "}", "die", "(", "bbn", "\\", "x", "::", "hdump", "(", "\"Problem with the template\"", ",", "$", "view", ",", "$", "this", "->", "path", ",", "$", "this", "->", "mode", ")", ")", ";", "}" ]
This directly renders content with arbitrary values using the existing Mustache engine. @param string $view The view to be rendered @param array $model The data model to fill the view with @return void
[ "This", "directly", "renders", "content", "with", "arbitrary", "values", "using", "the", "existing", "Mustache", "engine", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L296-L304
nabab/bbn
src/bbn/mvc/controller.php
controller.reroute
public function reroute($path='', $post = false, $arguments = false) { if ( !\in_array($path, $this->reroutes) && ($this->path !== $path) ){ $this->reroutes[] = $path; $this->mvc->reroute($path, $post, $arguments); $this->is_rerouted = 1; } }
php
public function reroute($path='', $post = false, $arguments = false) { if ( !\in_array($path, $this->reroutes) && ($this->path !== $path) ){ $this->reroutes[] = $path; $this->mvc->reroute($path, $post, $arguments); $this->is_rerouted = 1; } }
[ "public", "function", "reroute", "(", "$", "path", "=", "''", ",", "$", "post", "=", "false", ",", "$", "arguments", "=", "false", ")", "{", "if", "(", "!", "\\", "in_array", "(", "$", "path", ",", "$", "this", "->", "reroutes", ")", "&&", "(", "$", "this", "->", "path", "!==", "$", "path", ")", ")", "{", "$", "this", "->", "reroutes", "[", "]", "=", "$", "path", ";", "$", "this", "->", "mvc", "->", "reroute", "(", "$", "path", ",", "$", "post", ",", "$", "arguments", ")", ";", "$", "this", "->", "is_rerouted", "=", "1", ";", "}", "}" ]
This will reroute a controller to another one seemlessly. Chainable @param string $path The request path <em>(e.g books/466565 or xml/books/48465)</em> @return void
[ "This", "will", "reroute", "a", "controller", "to", "another", "one", "seemlessly", ".", "Chainable" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L322-L329
nabab/bbn
src/bbn/mvc/controller.php
controller.incl
public function incl($file_name){ if ( $this->exists() ){ $d = dirname($this->file).'/'; if ( substr($file_name, -4) !== '.php' ){ $file_name .= '.php'; } if ( (strpos($file_name, '..') === false) && file_exists($d.$file_name) ){ $bbn_path = $d.$file_name; $ctrl =& $this; unset($d, $file_name); include($bbn_path); } } return $this; }
php
public function incl($file_name){ if ( $this->exists() ){ $d = dirname($this->file).'/'; if ( substr($file_name, -4) !== '.php' ){ $file_name .= '.php'; } if ( (strpos($file_name, '..') === false) && file_exists($d.$file_name) ){ $bbn_path = $d.$file_name; $ctrl =& $this; unset($d, $file_name); include($bbn_path); } } return $this; }
[ "public", "function", "incl", "(", "$", "file_name", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "d", "=", "dirname", "(", "$", "this", "->", "file", ")", ".", "'/'", ";", "if", "(", "substr", "(", "$", "file_name", ",", "-", "4", ")", "!==", "'.php'", ")", "{", "$", "file_name", ".=", "'.php'", ";", "}", "if", "(", "(", "strpos", "(", "$", "file_name", ",", "'..'", ")", "===", "false", ")", "&&", "file_exists", "(", "$", "d", ".", "$", "file_name", ")", ")", "{", "$", "bbn_path", "=", "$", "d", ".", "$", "file_name", ";", "$", "ctrl", "=", "&", "$", "this", ";", "unset", "(", "$", "d", ",", "$", "file_name", ")", ";", "include", "(", "$", "bbn_path", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
This will include a file from within the controller's path. Chainable @param string $file_name If .php is ommited it will be added @return $this
[ "This", "will", "include", "a", "file", "from", "within", "the", "controller", "s", "path", ".", "Chainable" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L337-L351
nabab/bbn
src/bbn/mvc/controller.php
controller.add_script
public function add_script($script){ if ( \is_object($this->obj) ){ if ( !isset($this->obj->script) ){ $this->obj->script = ''; } $this->obj->script .= $script; } return $this; }
php
public function add_script($script){ if ( \is_object($this->obj) ){ if ( !isset($this->obj->script) ){ $this->obj->script = ''; } $this->obj->script .= $script; } return $this; }
[ "public", "function", "add_script", "(", "$", "script", ")", "{", "if", "(", "\\", "is_object", "(", "$", "this", "->", "obj", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "obj", "->", "script", ")", ")", "{", "$", "this", "->", "obj", "->", "script", "=", "''", ";", "}", "$", "this", "->", "obj", "->", "script", ".=", "$", "script", ";", "}", "return", "$", "this", ";", "}" ]
This will add the given string to the script property, and create it if needed. Chainable @param string $script The javascript chain to add @return $this
[ "This", "will", "add", "the", "given", "string", "to", "the", "script", "property", "and", "create", "it", "if", "needed", ".", "Chainable" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L359-L367
nabab/bbn
src/bbn/mvc/controller.php
controller.control
private function control(){ if ( $this->file && !isset($this->is_controlled) ){ $ok = 1; if ( $this->plugin ){ $this->register_plugin_classes($this->plugin_path()); } ob_start(); foreach ( $this->checkers as $appui_checker_file ){ // If a checker file returns false, the controller is not processed // The checker file can define data and inc that can be used in the subsequent controller if ( bbn\mvc::include_controller($appui_checker_file, $this, true) === false ){ $ok = false; break; } } if ( ($log = ob_get_contents()) && \is_string($log) ){ $this->obj->content = $log; } ob_end_clean(); // If rerouted during the checkers if ( $this->is_rerouted ){ $this->is_rerouted = false; return $this->control(); } if ( !$ok ){ return false; } $output = bbn\mvc::include_controller($this->file, $this); // If rerouted during the controller if ( $this->is_rerouted ){ $this->is_rerouted = false; return $this->control(); } if ( \is_object($this->obj) && !isset($this->obj->content) && !empty($output) ){ $this->obj->content = $output; } $this->is_controlled = 1; } return $this->is_controlled ? true : false; }
php
private function control(){ if ( $this->file && !isset($this->is_controlled) ){ $ok = 1; if ( $this->plugin ){ $this->register_plugin_classes($this->plugin_path()); } ob_start(); foreach ( $this->checkers as $appui_checker_file ){ // If a checker file returns false, the controller is not processed // The checker file can define data and inc that can be used in the subsequent controller if ( bbn\mvc::include_controller($appui_checker_file, $this, true) === false ){ $ok = false; break; } } if ( ($log = ob_get_contents()) && \is_string($log) ){ $this->obj->content = $log; } ob_end_clean(); // If rerouted during the checkers if ( $this->is_rerouted ){ $this->is_rerouted = false; return $this->control(); } if ( !$ok ){ return false; } $output = bbn\mvc::include_controller($this->file, $this); // If rerouted during the controller if ( $this->is_rerouted ){ $this->is_rerouted = false; return $this->control(); } if ( \is_object($this->obj) && !isset($this->obj->content) && !empty($output) ){ $this->obj->content = $output; } $this->is_controlled = 1; } return $this->is_controlled ? true : false; }
[ "private", "function", "control", "(", ")", "{", "if", "(", "$", "this", "->", "file", "&&", "!", "isset", "(", "$", "this", "->", "is_controlled", ")", ")", "{", "$", "ok", "=", "1", ";", "if", "(", "$", "this", "->", "plugin", ")", "{", "$", "this", "->", "register_plugin_classes", "(", "$", "this", "->", "plugin_path", "(", ")", ")", ";", "}", "ob_start", "(", ")", ";", "foreach", "(", "$", "this", "->", "checkers", "as", "$", "appui_checker_file", ")", "{", "// If a checker file returns false, the controller is not processed", "// The checker file can define data and inc that can be used in the subsequent controller", "if", "(", "bbn", "\\", "mvc", "::", "include_controller", "(", "$", "appui_checker_file", ",", "$", "this", ",", "true", ")", "===", "false", ")", "{", "$", "ok", "=", "false", ";", "break", ";", "}", "}", "if", "(", "(", "$", "log", "=", "ob_get_contents", "(", ")", ")", "&&", "\\", "is_string", "(", "$", "log", ")", ")", "{", "$", "this", "->", "obj", "->", "content", "=", "$", "log", ";", "}", "ob_end_clean", "(", ")", ";", "// If rerouted during the checkers", "if", "(", "$", "this", "->", "is_rerouted", ")", "{", "$", "this", "->", "is_rerouted", "=", "false", ";", "return", "$", "this", "->", "control", "(", ")", ";", "}", "if", "(", "!", "$", "ok", ")", "{", "return", "false", ";", "}", "$", "output", "=", "bbn", "\\", "mvc", "::", "include_controller", "(", "$", "this", "->", "file", ",", "$", "this", ")", ";", "// If rerouted during the controller", "if", "(", "$", "this", "->", "is_rerouted", ")", "{", "$", "this", "->", "is_rerouted", "=", "false", ";", "return", "$", "this", "->", "control", "(", ")", ";", "}", "if", "(", "\\", "is_object", "(", "$", "this", "->", "obj", ")", "&&", "!", "isset", "(", "$", "this", "->", "obj", "->", "content", ")", "&&", "!", "empty", "(", "$", "output", ")", ")", "{", "$", "this", "->", "obj", "->", "content", "=", "$", "output", ";", "}", "$", "this", "->", "is_controlled", "=", "1", ";", "}", "return", "$", "this", "->", "is_controlled", "?", "true", ":", "false", ";", "}" ]
This will enclose the controller's inclusion It can be publicly launched through check() @return boolean
[ "This", "will", "enclose", "the", "controller", "s", "inclusion", "It", "can", "be", "publicly", "launched", "through", "check", "()" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L392-L431
nabab/bbn
src/bbn/mvc/controller.php
controller.get_js
public function get_js($path='', array $data=null, $encapsulated = true){ if ( \is_array($path) ){ $data = $path; $path = ''; } if ( $r = $this->get_view($path, 'js', $data) ){ return '<script>'. ( $encapsulated ? '(function($){' : '' ). ( empty($data) ? '' : 'var data = '.\bbn\x::js_object($data).';' ). $r. ( $encapsulated ? '})(jQuery);' : '' ). '</script>'; } return false; }
php
public function get_js($path='', array $data=null, $encapsulated = true){ if ( \is_array($path) ){ $data = $path; $path = ''; } if ( $r = $this->get_view($path, 'js', $data) ){ return '<script>'. ( $encapsulated ? '(function($){' : '' ). ( empty($data) ? '' : 'var data = '.\bbn\x::js_object($data).';' ). $r. ( $encapsulated ? '})(jQuery);' : '' ). '</script>'; } return false; }
[ "public", "function", "get_js", "(", "$", "path", "=", "''", ",", "array", "$", "data", "=", "null", ",", "$", "encapsulated", "=", "true", ")", "{", "if", "(", "\\", "is_array", "(", "$", "path", ")", ")", "{", "$", "data", "=", "$", "path", ";", "$", "path", "=", "''", ";", "}", "if", "(", "$", "r", "=", "$", "this", "->", "get_view", "(", "$", "path", ",", "'js'", ",", "$", "data", ")", ")", "{", "return", "'<script>'", ".", "(", "$", "encapsulated", "?", "'(function($){'", ":", "''", ")", ".", "(", "empty", "(", "$", "data", ")", "?", "''", ":", "'var data = '", ".", "\\", "bbn", "\\", "x", "::", "js_object", "(", "$", "data", ")", ".", "';'", ")", ".", "$", "r", ".", "(", "$", "encapsulated", "?", "'})(jQuery);'", ":", "''", ")", ".", "'</script>'", ";", "}", "return", "false", ";", "}" ]
This will get a javascript view encapsulated in an anonymous function for embedding in HTML. @param string $path @return string|false
[ "This", "will", "get", "a", "javascript", "view", "encapsulated", "in", "an", "anonymous", "function", "for", "embedding", "in", "HTML", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L460-L474
nabab/bbn
src/bbn/mvc/controller.php
controller.get_js_group
public function get_js_group($files='', array $data=null, $encapsulated = true){ if ( $js = $this->get_view_group($files, $data, 'js') ){ return '<script>'. ( $encapsulated ? '(function($){' : '' ). ( empty($data) ? '' : 'var data = '.\bbn\x::js_object($data).';' ). $js. ( $encapsulated ? '})(jQuery);' : '' ). '</script>'; } return false; }
php
public function get_js_group($files='', array $data=null, $encapsulated = true){ if ( $js = $this->get_view_group($files, $data, 'js') ){ return '<script>'. ( $encapsulated ? '(function($){' : '' ). ( empty($data) ? '' : 'var data = '.\bbn\x::js_object($data).';' ). $js. ( $encapsulated ? '})(jQuery);' : '' ). '</script>'; } return false; }
[ "public", "function", "get_js_group", "(", "$", "files", "=", "''", ",", "array", "$", "data", "=", "null", ",", "$", "encapsulated", "=", "true", ")", "{", "if", "(", "$", "js", "=", "$", "this", "->", "get_view_group", "(", "$", "files", ",", "$", "data", ",", "'js'", ")", ")", "{", "return", "'<script>'", ".", "(", "$", "encapsulated", "?", "'(function($){'", ":", "''", ")", ".", "(", "empty", "(", "$", "data", ")", "?", "''", ":", "'var data = '", ".", "\\", "bbn", "\\", "x", "::", "js_object", "(", "$", "data", ")", ".", "';'", ")", ".", "$", "js", ".", "(", "$", "encapsulated", "?", "'})(jQuery);'", ":", "''", ")", ".", "'</script>'", ";", "}", "return", "false", ";", "}" ]
This will get a javascript view encapsulated in an anonymous function for embedding in HTML. @param array|string $files @param array $data @param boolean $encapsulated @return string|false
[ "This", "will", "get", "a", "javascript", "view", "encapsulated", "in", "an", "anonymous", "function", "for", "embedding", "in", "HTML", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L484-L494
nabab/bbn
src/bbn/mvc/controller.php
controller.get_view_group
public function get_view_group($files='', array $data=null, $mode = 'html'){ if ( !\is_array($files) ){ if ( !($tmp = $this->mvc->fetch_dir($files, $mode)) ){ $this->error("Impossible to get files from directory $files"); return false; } $files = $tmp; } if ( \is_array($files) && \count($files) ){ $st = ''; foreach ( $files as $f ){ if ( $tmp = $this->get_view($f, $mode, $data) ){ $st .= $tmp; } } return $st; } $this->error('Impossible to get files from get_view_group files argument empty'); }
php
public function get_view_group($files='', array $data=null, $mode = 'html'){ if ( !\is_array($files) ){ if ( !($tmp = $this->mvc->fetch_dir($files, $mode)) ){ $this->error("Impossible to get files from directory $files"); return false; } $files = $tmp; } if ( \is_array($files) && \count($files) ){ $st = ''; foreach ( $files as $f ){ if ( $tmp = $this->get_view($f, $mode, $data) ){ $st .= $tmp; } } return $st; } $this->error('Impossible to get files from get_view_group files argument empty'); }
[ "public", "function", "get_view_group", "(", "$", "files", "=", "''", ",", "array", "$", "data", "=", "null", ",", "$", "mode", "=", "'html'", ")", "{", "if", "(", "!", "\\", "is_array", "(", "$", "files", ")", ")", "{", "if", "(", "!", "(", "$", "tmp", "=", "$", "this", "->", "mvc", "->", "fetch_dir", "(", "$", "files", ",", "$", "mode", ")", ")", ")", "{", "$", "this", "->", "error", "(", "\"Impossible to get files from directory $files\"", ")", ";", "return", "false", ";", "}", "$", "files", "=", "$", "tmp", ";", "}", "if", "(", "\\", "is_array", "(", "$", "files", ")", "&&", "\\", "count", "(", "$", "files", ")", ")", "{", "$", "st", "=", "''", ";", "foreach", "(", "$", "files", "as", "$", "f", ")", "{", "if", "(", "$", "tmp", "=", "$", "this", "->", "get_view", "(", "$", "f", ",", "$", "mode", ",", "$", "data", ")", ")", "{", "$", "st", ".=", "$", "tmp", ";", "}", "}", "return", "$", "st", ";", "}", "$", "this", "->", "error", "(", "'Impossible to get files from get_view_group files argument empty'", ")", ";", "}" ]
This will get a javascript view encapsulated in an anonymous function for embedding in HTML. @param array|string $files @param array $data @param string $mode @return string|false
[ "This", "will", "get", "a", "javascript", "view", "encapsulated", "in", "an", "anonymous", "function", "for", "embedding", "in", "HTML", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L504-L522
nabab/bbn
src/bbn/mvc/controller.php
controller.get_css
public function get_css($path=''){ if ( $r = $this->get_view($path, 'css') ){ return \CssMin::minify($r); } return false; }
php
public function get_css($path=''){ if ( $r = $this->get_view($path, 'css') ){ return \CssMin::minify($r); } return false; }
[ "public", "function", "get_css", "(", "$", "path", "=", "''", ")", "{", "if", "(", "$", "r", "=", "$", "this", "->", "get_view", "(", "$", "path", ",", "'css'", ")", ")", "{", "return", "\\", "CssMin", "::", "minify", "(", "$", "r", ")", ";", "}", "return", "false", ";", "}" ]
This will get a CSS view encapsulated in a scoped style tag. @param string $path @return string|false
[ "This", "will", "get", "a", "CSS", "view", "encapsulated", "in", "a", "scoped", "style", "tag", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L530-L535
nabab/bbn
src/bbn/mvc/controller.php
controller.get_less
public function get_less($path=''){ if ( $r = $this->get_view($path, 'css', false) ){ return \CssMin::minify($r); } }
php
public function get_less($path=''){ if ( $r = $this->get_view($path, 'css', false) ){ return \CssMin::minify($r); } }
[ "public", "function", "get_less", "(", "$", "path", "=", "''", ")", "{", "if", "(", "$", "r", "=", "$", "this", "->", "get_view", "(", "$", "path", ",", "'css'", ",", "false", ")", ")", "{", "return", "\\", "CssMin", "::", "minify", "(", "$", "r", ")", ";", "}", "}" ]
This will get and compile a LESS view encapsulated in a scoped style tag. @param string $path @return string|false
[ "This", "will", "get", "and", "compile", "a", "LESS", "view", "encapsulated", "in", "a", "scoped", "style", "tag", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L543-L547
nabab/bbn
src/bbn/mvc/controller.php
controller.add_css
public function add_css($path=''){ if ( $css = $this->get_css($path) ){ if ( !isset($this->obj->css) ){ $this->obj->css = ''; } $this->obj->css .= $css; } return $this; }
php
public function add_css($path=''){ if ( $css = $this->get_css($path) ){ if ( !isset($this->obj->css) ){ $this->obj->css = ''; } $this->obj->css .= $css; } return $this; }
[ "public", "function", "add_css", "(", "$", "path", "=", "''", ")", "{", "if", "(", "$", "css", "=", "$", "this", "->", "get_css", "(", "$", "path", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "obj", "->", "css", ")", ")", "{", "$", "this", "->", "obj", "->", "css", "=", "''", ";", "}", "$", "this", "->", "obj", "->", "css", ".=", "$", "css", ";", "}", "return", "$", "this", ";", "}" ]
This will get a CSS view encapsulated in a scoped style tag. @param string $path @return string|false
[ "This", "will", "get", "a", "CSS", "view", "encapsulated", "in", "a", "scoped", "style", "tag", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L555-L563
nabab/bbn
src/bbn/mvc/controller.php
controller.add_less
public function add_less($path=''){ if ( $css = $this->get_less($path) ){ if ( !isset($this->obj->css) ){ $this->obj->css = ''; } $this->obj->css .= $css; } return $this; }
php
public function add_less($path=''){ if ( $css = $this->get_less($path) ){ if ( !isset($this->obj->css) ){ $this->obj->css = ''; } $this->obj->css .= $css; } return $this; }
[ "public", "function", "add_less", "(", "$", "path", "=", "''", ")", "{", "if", "(", "$", "css", "=", "$", "this", "->", "get_less", "(", "$", "path", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "obj", "->", "css", ")", ")", "{", "$", "this", "->", "obj", "->", "css", "=", "''", ";", "}", "$", "this", "->", "obj", "->", "css", ".=", "$", "css", ";", "}", "return", "$", "this", ";", "}" ]
This will get and compile a LESS view encapsulated in a scoped style tag. @param string $path @return string|false
[ "This", "will", "get", "and", "compile", "a", "LESS", "view", "encapsulated", "in", "a", "scoped", "style", "tag", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L571-L579
nabab/bbn
src/bbn/mvc/controller.php
controller.add_js
public function add_js(){ $args = \func_get_args(); $has_path = false; foreach ( $args as $i => $a ){ if ( $new_data = $this->retrieve_var($a) ){ $this->js_data($new_data); } else if ( \is_string($a) ){ $has_path = 1; } else if ( \is_array($a) ){ $this->js_data($a); } } if ( !$has_path ){ array_unshift($args, $this->path); } $args[] = 'js'; if ( $r = $this->get_view(...$args) ){ $this->add_script($r); } return $this; }
php
public function add_js(){ $args = \func_get_args(); $has_path = false; foreach ( $args as $i => $a ){ if ( $new_data = $this->retrieve_var($a) ){ $this->js_data($new_data); } else if ( \is_string($a) ){ $has_path = 1; } else if ( \is_array($a) ){ $this->js_data($a); } } if ( !$has_path ){ array_unshift($args, $this->path); } $args[] = 'js'; if ( $r = $this->get_view(...$args) ){ $this->add_script($r); } return $this; }
[ "public", "function", "add_js", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "$", "has_path", "=", "false", ";", "foreach", "(", "$", "args", "as", "$", "i", "=>", "$", "a", ")", "{", "if", "(", "$", "new_data", "=", "$", "this", "->", "retrieve_var", "(", "$", "a", ")", ")", "{", "$", "this", "->", "js_data", "(", "$", "new_data", ")", ";", "}", "else", "if", "(", "\\", "is_string", "(", "$", "a", ")", ")", "{", "$", "has_path", "=", "1", ";", "}", "else", "if", "(", "\\", "is_array", "(", "$", "a", ")", ")", "{", "$", "this", "->", "js_data", "(", "$", "a", ")", ";", "}", "}", "if", "(", "!", "$", "has_path", ")", "{", "array_unshift", "(", "$", "args", ",", "$", "this", "->", "path", ")", ";", "}", "$", "args", "[", "]", "=", "'js'", ";", "if", "(", "$", "r", "=", "$", "this", "->", "get_view", "(", "...", "$", "args", ")", ")", "{", "$", "this", "->", "add_script", "(", "$", "r", ")", ";", "}", "return", "$", "this", ";", "}" ]
This will add a javascript view to $this->obj->script Chainable @param string $path @param string $mode @return string|false
[ "This", "will", "add", "a", "javascript", "view", "to", "$this", "-", ">", "obj", "-", ">", "script", "Chainable" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L589-L611
nabab/bbn
src/bbn/mvc/controller.php
controller.add_js_group
public function add_js_group($files = '', array $data = []){ if ( $js = $this->get_view_group($files, $data, 'js') ){ $this->js_data($data)->add_script($js); } return $this; }
php
public function add_js_group($files = '', array $data = []){ if ( $js = $this->get_view_group($files, $data, 'js') ){ $this->js_data($data)->add_script($js); } return $this; }
[ "public", "function", "add_js_group", "(", "$", "files", "=", "''", ",", "array", "$", "data", "=", "[", "]", ")", "{", "if", "(", "$", "js", "=", "$", "this", "->", "get_view_group", "(", "$", "files", ",", "$", "data", ",", "'js'", ")", ")", "{", "$", "this", "->", "js_data", "(", "$", "data", ")", "->", "add_script", "(", "$", "js", ")", ";", "}", "return", "$", "this", ";", "}" ]
This will add a javascript view to $this->obj->script Chainable @param string $path @param string $mode @return string|false
[ "This", "will", "add", "a", "javascript", "view", "to", "$this", "-", ">", "obj", "-", ">", "script", "Chainable" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L621-L626
nabab/bbn
src/bbn/mvc/controller.php
controller.get_view
public function get_view() { $args = $this->get_arguments(\func_get_args()); /*if ( !isset($args['mode']) ){ $v = $this->mvc->get_view($args['path'], 'html', $args['data']); if ( !$v ){ $v = $this->mvc->get_view($args['path'], 'php', $args['data']); } } else{ $v = $this->mvc->get_view($args['path'], $args['mode'], $args['data']); }*/ if ( empty($args['mode']) ){ $args['mode'] = 'html'; } $v = $this->mvc->get_view($args['path'], $args['mode'], $args['data']); /* if ( !$v && $args['die'] ){ die("Impossible to find the $args[mode] view $args[path] from $args[file]"); } */ return $v; }
php
public function get_view() { $args = $this->get_arguments(\func_get_args()); /*if ( !isset($args['mode']) ){ $v = $this->mvc->get_view($args['path'], 'html', $args['data']); if ( !$v ){ $v = $this->mvc->get_view($args['path'], 'php', $args['data']); } } else{ $v = $this->mvc->get_view($args['path'], $args['mode'], $args['data']); }*/ if ( empty($args['mode']) ){ $args['mode'] = 'html'; } $v = $this->mvc->get_view($args['path'], $args['mode'], $args['data']); /* if ( !$v && $args['die'] ){ die("Impossible to find the $args[mode] view $args[path] from $args[file]"); } */ return $v; }
[ "public", "function", "get_view", "(", ")", "{", "$", "args", "=", "$", "this", "->", "get_arguments", "(", "\\", "func_get_args", "(", ")", ")", ";", "/*if ( !isset($args['mode']) ){\n $v = $this->mvc->get_view($args['path'], 'html', $args['data']);\n if ( !$v ){\n $v = $this->mvc->get_view($args['path'], 'php', $args['data']);\n }\n\t\t}\n\t\telse{\n $v = $this->mvc->get_view($args['path'], $args['mode'], $args['data']);\n }*/", "if", "(", "empty", "(", "$", "args", "[", "'mode'", "]", ")", ")", "{", "$", "args", "[", "'mode'", "]", "=", "'html'", ";", "}", "$", "v", "=", "$", "this", "->", "mvc", "->", "get_view", "(", "$", "args", "[", "'path'", "]", ",", "$", "args", "[", "'mode'", "]", ",", "$", "args", "[", "'data'", "]", ")", ";", "/*\n if ( !$v && $args['die'] ){\n die(\"Impossible to find the $args[mode] view $args[path] from $args[file]\");\n }\n\t\t*/", "return", "$", "v", ";", "}" ]
This will get a view. @param string $path @param string $mode @return string|false
[ "This", "will", "get", "a", "view", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L723-L745
nabab/bbn
src/bbn/mvc/controller.php
controller.retrieve_var
private function retrieve_var($var){ if ( \is_string($var) && (strpos($var, '$') === 0) && isset($this->data[substr($var, 1)]) ){ return $this->data[substr($var, 1)]; } return false; }
php
private function retrieve_var($var){ if ( \is_string($var) && (strpos($var, '$') === 0) && isset($this->data[substr($var, 1)]) ){ return $this->data[substr($var, 1)]; } return false; }
[ "private", "function", "retrieve_var", "(", "$", "var", ")", "{", "if", "(", "\\", "is_string", "(", "$", "var", ")", "&&", "(", "strpos", "(", "$", "var", ",", "'$'", ")", "===", "0", ")", "&&", "isset", "(", "$", "this", "->", "data", "[", "substr", "(", "$", "var", ",", "1", ")", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "substr", "(", "$", "var", ",", "1", ")", "]", ";", "}", "return", "false", ";", "}" ]
/* public function get_php(){ $args = $this->get_arguments(\func_get_args()); $v = $this->mvc->get_view($args['path'], 'php', $args['data']); if ( !$v && $args['die'] ){ die("Impossible to find the PHP view $args[path]"); } return $v; } public function get_html(){ $args = $this->get_arguments(\func_get_args()); $v = $this->mvc->get_view($args['path'], 'html', $args['data']); if ( !$v && $args['die'] ){ die("Impossible to find the HTML view $args[path]"); } return $v; }
[ "/", "*", "public", "function", "get_php", "()", "{", "$args", "=", "$this", "-", ">", "get_arguments", "(", "\\", "func_get_args", "()", ")", ";", "$v", "=", "$this", "-", ">", "mvc", "-", ">", "get_view", "(", "$args", "[", "path", "]", "php", "$args", "[", "data", "]", ")", ";", "if", "(", "!$v", "&&", "$args", "[", "die", "]", ")", "{", "die", "(", "Impossible", "to", "find", "the", "PHP", "view", "$args", "[", "path", "]", ")", ";", "}", "return", "$v", ";", "}" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L781-L786
nabab/bbn
src/bbn/mvc/controller.php
controller.get_content
public function get_content($file_name){ if ( $this->check_path($file_name) && \defined('BBN_DATA_PATH') && is_file(BBN_DATA_PATH.$file_name) ){ return file_get_contents(BBN_DATA_PATH.$file_name); } return false; }
php
public function get_content($file_name){ if ( $this->check_path($file_name) && \defined('BBN_DATA_PATH') && is_file(BBN_DATA_PATH.$file_name) ){ return file_get_contents(BBN_DATA_PATH.$file_name); } return false; }
[ "public", "function", "get_content", "(", "$", "file_name", ")", "{", "if", "(", "$", "this", "->", "check_path", "(", "$", "file_name", ")", "&&", "\\", "defined", "(", "'BBN_DATA_PATH'", ")", "&&", "is_file", "(", "BBN_DATA_PATH", ".", "$", "file_name", ")", ")", "{", "return", "file_get_contents", "(", "BBN_DATA_PATH", ".", "$", "file_name", ")", ";", "}", "return", "false", ";", "}" ]
This will get a the content of a file located within the data path @param string $file_name @return string|false
[ "This", "will", "get", "a", "the", "content", "of", "a", "file", "located", "within", "the", "data", "path" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L840-L848
nabab/bbn
src/bbn/mvc/controller.php
controller.get_model
public function get_model(){ $args = \func_get_args(); $die = false; foreach ( $args as $a ){ if ( \is_string($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } else if ( \is_bool($a) ){ $die = $a; } } if ( empty($path) ){ $path = $this->path; if ( ($this->get_mode() === 'dom') && (!defined('BBN_DEFAULT_MODE') || (BBN_DEFAULT_MODE !== 'dom')) ){ $path .= '/index'; } } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } $m = $this->mvc->get_model($path, $data, $this); if ( \is_object($m) ){ $m = bbn\x::to_array($m); } if ( !\is_array($m) ){ if ( $die ){ die("$path is an invalid model"); } return []; } return $m; }
php
public function get_model(){ $args = \func_get_args(); $die = false; foreach ( $args as $a ){ if ( \is_string($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } else if ( \is_bool($a) ){ $die = $a; } } if ( empty($path) ){ $path = $this->path; if ( ($this->get_mode() === 'dom') && (!defined('BBN_DEFAULT_MODE') || (BBN_DEFAULT_MODE !== 'dom')) ){ $path .= '/index'; } } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } $m = $this->mvc->get_model($path, $data, $this); if ( \is_object($m) ){ $m = bbn\x::to_array($m); } if ( !\is_array($m) ){ if ( $die ){ die("$path is an invalid model"); } return []; } return $m; }
[ "public", "function", "get_model", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "$", "die", "=", "false", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "\\", "is_string", "(", "$", "a", ")", ")", "{", "$", "path", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_array", "(", "$", "a", ")", ")", "{", "$", "data", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_bool", "(", "$", "a", ")", ")", "{", "$", "die", "=", "$", "a", ";", "}", "}", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "path", ";", "if", "(", "(", "$", "this", "->", "get_mode", "(", ")", "===", "'dom'", ")", "&&", "(", "!", "defined", "(", "'BBN_DEFAULT_MODE'", ")", "||", "(", "BBN_DEFAULT_MODE", "!==", "'dom'", ")", ")", ")", "{", "$", "path", ".=", "'/index'", ";", "}", "}", "else", "if", "(", "strpos", "(", "$", "path", ",", "'./'", ")", "===", "0", ")", "{", "$", "path", "=", "$", "this", "->", "say_dir", "(", ")", ".", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "}", "$", "m", "=", "$", "this", "->", "mvc", "->", "get_model", "(", "$", "path", ",", "$", "data", ",", "$", "this", ")", ";", "if", "(", "\\", "is_object", "(", "$", "m", ")", ")", "{", "$", "m", "=", "bbn", "\\", "x", "::", "to_array", "(", "$", "m", ")", ";", "}", "if", "(", "!", "\\", "is_array", "(", "$", "m", ")", ")", "{", "if", "(", "$", "die", ")", "{", "die", "(", "\"$path is an invalid model\"", ")", ";", "}", "return", "[", "]", ";", "}", "return", "$", "m", ";", "}" ]
This will get the model. There is no order for the arguments. @params string path to the model @params array data to send to the model @return array|false A data model
[ "This", "will", "get", "the", "model", ".", "There", "is", "no", "order", "for", "the", "arguments", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L893-L930
nabab/bbn
src/bbn/mvc/controller.php
controller.delete_cached_model
public function delete_cached_model(){ $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) && \strlen($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } } if ( !isset($path) ){ $path = $this->path; } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } return $this->mvc->delete_cached_model($path, $data, $this); }
php
public function delete_cached_model(){ $args = \func_get_args(); foreach ( $args as $a ){ if ( \is_string($a) && \strlen($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } } if ( !isset($path) ){ $path = $this->path; } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } return $this->mvc->delete_cached_model($path, $data, $this); }
[ "public", "function", "delete_cached_model", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "\\", "is_string", "(", "$", "a", ")", "&&", "\\", "strlen", "(", "$", "a", ")", ")", "{", "$", "path", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_array", "(", "$", "a", ")", ")", "{", "$", "data", "=", "$", "a", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "path", ";", "}", "else", "if", "(", "strpos", "(", "$", "path", ",", "'./'", ")", "===", "0", ")", "{", "$", "path", "=", "$", "this", "->", "say_dir", "(", ")", ".", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "}", "return", "$", "this", "->", "mvc", "->", "delete_cached_model", "(", "$", "path", ",", "$", "data", ",", "$", "this", ")", ";", "}" ]
This will delete the cached model. There is no order for the arguments. @params string path to the model @params array data to send to the model
[ "This", "will", "delete", "the", "cached", "model", ".", "There", "is", "no", "order", "for", "the", "arguments", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L984-L1005
nabab/bbn
src/bbn/mvc/controller.php
controller.set_cached_model
public function set_cached_model(){ $args = \func_get_args(); $die = 1; foreach ( $args as $a ){ if ( \is_string($a) && \strlen($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } else if ( \is_int($a) ){ $ttl = $a; } else if ( \is_bool($a) ){ $die = $a; } } if ( !isset($path) ){ $path = $this->path; } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } if ( !isset($ttl) ){ $ttl = 10; } $this->mvc->set_cached_model($path, $data, $this, $ttl); return $this; }
php
public function set_cached_model(){ $args = \func_get_args(); $die = 1; foreach ( $args as $a ){ if ( \is_string($a) && \strlen($a) ){ $path = $a; } else if ( \is_array($a) ){ $data = $a; } else if ( \is_int($a) ){ $ttl = $a; } else if ( \is_bool($a) ){ $die = $a; } } if ( !isset($path) ){ $path = $this->path; } else if ( strpos($path, './') === 0 ){ $path = $this->say_dir().substr($path, 1); } if ( !isset($data) ){ $data = $this->data; } if ( !isset($ttl) ){ $ttl = 10; } $this->mvc->set_cached_model($path, $data, $this, $ttl); return $this; }
[ "public", "function", "set_cached_model", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "$", "die", "=", "1", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "\\", "is_string", "(", "$", "a", ")", "&&", "\\", "strlen", "(", "$", "a", ")", ")", "{", "$", "path", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_array", "(", "$", "a", ")", ")", "{", "$", "data", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_int", "(", "$", "a", ")", ")", "{", "$", "ttl", "=", "$", "a", ";", "}", "else", "if", "(", "\\", "is_bool", "(", "$", "a", ")", ")", "{", "$", "die", "=", "$", "a", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "path", ";", "}", "else", "if", "(", "strpos", "(", "$", "path", ",", "'./'", ")", "===", "0", ")", "{", "$", "path", "=", "$", "this", "->", "say_dir", "(", ")", ".", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "}", "if", "(", "!", "isset", "(", "$", "ttl", ")", ")", "{", "$", "ttl", "=", "10", ";", "}", "$", "this", "->", "mvc", "->", "set_cached_model", "(", "$", "path", ",", "$", "data", ",", "$", "this", ",", "$", "ttl", ")", ";", "return", "$", "this", ";", "}" ]
This will get the model. There is no order for the arguments. @params string path to the model @params array data to send to the model @return $this
[ "This", "will", "get", "the", "model", ".", "There", "is", "no", "order", "for", "the", "arguments", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L1014-L1045
nabab/bbn
src/bbn/mvc/controller.php
controller.has_data
public function has_data($data=null) { if ( \is_null($data) ){ $data = $this->data; } return ( \is_array($data) && (\count($data) > 0) ) ? 1 : false; }
php
public function has_data($data=null) { if ( \is_null($data) ){ $data = $this->data; } return ( \is_array($data) && (\count($data) > 0) ) ? 1 : false; }
[ "public", "function", "has_data", "(", "$", "data", "=", "null", ")", "{", "if", "(", "\\", "is_null", "(", "$", "data", ")", ")", "{", "$", "data", "=", "$", "this", "->", "data", ";", "}", "return", "(", "\\", "is_array", "(", "$", "data", ")", "&&", "(", "\\", "count", "(", "$", "data", ")", ">", "0", ")", ")", "?", "1", ":", "false", ";", "}" ]
Checks if data exists @return bool
[ "Checks", "if", "data", "exists" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L1086-L1092
nabab/bbn
src/bbn/mvc/controller.php
controller.add
public function add($path, $data=[], $internal = false) { if ( substr($path, 0, 2) === './' ){ $path = $this->say_dir().substr($path, 1); } if ( $route = $this->mvc->get_route($path, $internal ? 'private' : 'public') ){ $o = new controller($this->mvc, $route, $data); $o->process(); return $o; } return false; }
php
public function add($path, $data=[], $internal = false) { if ( substr($path, 0, 2) === './' ){ $path = $this->say_dir().substr($path, 1); } if ( $route = $this->mvc->get_route($path, $internal ? 'private' : 'public') ){ $o = new controller($this->mvc, $route, $data); $o->process(); return $o; } return false; }
[ "public", "function", "add", "(", "$", "path", ",", "$", "data", "=", "[", "]", ",", "$", "internal", "=", "false", ")", "{", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "2", ")", "===", "'./'", ")", "{", "$", "path", "=", "$", "this", "->", "say_dir", "(", ")", ".", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "if", "(", "$", "route", "=", "$", "this", "->", "mvc", "->", "get_route", "(", "$", "path", ",", "$", "internal", "?", "'private'", ":", "'public'", ")", ")", "{", "$", "o", "=", "new", "controller", "(", "$", "this", "->", "mvc", ",", "$", "route", ",", "$", "data", ")", ";", "$", "o", "->", "process", "(", ")", ";", "return", "$", "o", ";", "}", "return", "false", ";", "}" ]
Merges the existing data if there is with this one. Chainable. @return void
[ "Merges", "the", "existing", "data", "if", "there", "is", "with", "this", "one", ".", "Chainable", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L1179-L1190
nabab/bbn
src/bbn/mvc/controller.php
controller.add_to_obj
public function add_to_obj(string $path, $data=[], $internal = false) { if ( substr($path, 0, 2) === './' ){ $path = $this->say_dir().substr($path, 1); } if ( $route = $this->mvc->get_route($path, $internal ? 'private' : 'public') ){ $o = new controller($this->mvc, $route, $data); $o->process(); $this->obj = \bbn\x::merge_objects($this->obj, $o->obj); return $this; } return false; }
php
public function add_to_obj(string $path, $data=[], $internal = false) { if ( substr($path, 0, 2) === './' ){ $path = $this->say_dir().substr($path, 1); } if ( $route = $this->mvc->get_route($path, $internal ? 'private' : 'public') ){ $o = new controller($this->mvc, $route, $data); $o->process(); $this->obj = \bbn\x::merge_objects($this->obj, $o->obj); return $this; } return false; }
[ "public", "function", "add_to_obj", "(", "string", "$", "path", ",", "$", "data", "=", "[", "]", ",", "$", "internal", "=", "false", ")", "{", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "2", ")", "===", "'./'", ")", "{", "$", "path", "=", "$", "this", "->", "say_dir", "(", ")", ".", "substr", "(", "$", "path", ",", "1", ")", ";", "}", "if", "(", "$", "route", "=", "$", "this", "->", "mvc", "->", "get_route", "(", "$", "path", ",", "$", "internal", "?", "'private'", ":", "'public'", ")", ")", "{", "$", "o", "=", "new", "controller", "(", "$", "this", "->", "mvc", ",", "$", "route", ",", "$", "data", ")", ";", "$", "o", "->", "process", "(", ")", ";", "$", "this", "->", "obj", "=", "\\", "bbn", "\\", "x", "::", "merge_objects", "(", "$", "this", "->", "obj", ",", "$", "o", "->", "obj", ")", ";", "return", "$", "this", ";", "}", "return", "false", ";", "}" ]
Merges the existing data if there is with this one. Chainable. @return void
[ "Merges", "the", "existing", "data", "if", "there", "is", "with", "this", "one", ".", "Chainable", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/controller.php#L1197-L1209
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Module/UrlDomain.php
UrlDomain.urlGetDomainRouteAndDefaultDomainParams
protected function urlGetDomainRouteAndDefaultDomainParams (array & $params, $moduleParamDefined, $currentDomainRouteMatched) { $targetModule = NULL; $targetDomainRoute = NULL; $domainParamsDefault = []; if ($moduleParamDefined) { $moduleParamName = static::URL_PARAM_MODULE; $targetModule = $params[$moduleParamName]; if (!isset($this->domainRoutes[$targetModule])) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \InvalidArgumentException( "[".$selfClass."] No domain route defined for module: `$targetModule`." ); } else { $targetDomainRoute = $this->domainRoutes[$targetModule]; $routeReverseParamsKeys = $targetDomainRoute->GetReverseParams(); $routeReverseParamsDefaults = array_fill_keys($routeReverseParamsKeys, NULL); $targetDomainRouteDefaults = array_intersect_key($targetDomainRoute->GetDefaults(), $routeReverseParamsDefaults); $domainParamsDefault = array_merge($routeReverseParamsDefaults, $targetDomainRouteDefaults); $domainParamsDefault[$moduleParamName] = $targetModule; } } else if ($currentDomainRouteMatched) { $targetModule = $this->currentModule; $targetDomainRoute = $this->currentDomainRoute; $domainParamsDefault = $this->requestedDomainParams; } return [$targetModule, $targetDomainRoute, $domainParamsDefault]; }
php
protected function urlGetDomainRouteAndDefaultDomainParams (array & $params, $moduleParamDefined, $currentDomainRouteMatched) { $targetModule = NULL; $targetDomainRoute = NULL; $domainParamsDefault = []; if ($moduleParamDefined) { $moduleParamName = static::URL_PARAM_MODULE; $targetModule = $params[$moduleParamName]; if (!isset($this->domainRoutes[$targetModule])) { $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; throw new \InvalidArgumentException( "[".$selfClass."] No domain route defined for module: `$targetModule`." ); } else { $targetDomainRoute = $this->domainRoutes[$targetModule]; $routeReverseParamsKeys = $targetDomainRoute->GetReverseParams(); $routeReverseParamsDefaults = array_fill_keys($routeReverseParamsKeys, NULL); $targetDomainRouteDefaults = array_intersect_key($targetDomainRoute->GetDefaults(), $routeReverseParamsDefaults); $domainParamsDefault = array_merge($routeReverseParamsDefaults, $targetDomainRouteDefaults); $domainParamsDefault[$moduleParamName] = $targetModule; } } else if ($currentDomainRouteMatched) { $targetModule = $this->currentModule; $targetDomainRoute = $this->currentDomainRoute; $domainParamsDefault = $this->requestedDomainParams; } return [$targetModule, $targetDomainRoute, $domainParamsDefault]; }
[ "protected", "function", "urlGetDomainRouteAndDefaultDomainParams", "(", "array", "&", "$", "params", ",", "$", "moduleParamDefined", ",", "$", "currentDomainRouteMatched", ")", "{", "$", "targetModule", "=", "NULL", ";", "$", "targetDomainRoute", "=", "NULL", ";", "$", "domainParamsDefault", "=", "[", "]", ";", "if", "(", "$", "moduleParamDefined", ")", "{", "$", "moduleParamName", "=", "static", "::", "URL_PARAM_MODULE", ";", "$", "targetModule", "=", "$", "params", "[", "$", "moduleParamName", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "domainRoutes", "[", "$", "targetModule", "]", ")", ")", "{", "$", "selfClass", "=", "version_compare", "(", "PHP_VERSION", ",", "'5.5'", ",", "'>'", ")", "?", "self", "::", "class", ":", "__CLASS__", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "\"[\"", ".", "$", "selfClass", ".", "\"] No domain route defined for module: `$targetModule`.\"", ")", ";", "}", "else", "{", "$", "targetDomainRoute", "=", "$", "this", "->", "domainRoutes", "[", "$", "targetModule", "]", ";", "$", "routeReverseParamsKeys", "=", "$", "targetDomainRoute", "->", "GetReverseParams", "(", ")", ";", "$", "routeReverseParamsDefaults", "=", "array_fill_keys", "(", "$", "routeReverseParamsKeys", ",", "NULL", ")", ";", "$", "targetDomainRouteDefaults", "=", "array_intersect_key", "(", "$", "targetDomainRoute", "->", "GetDefaults", "(", ")", ",", "$", "routeReverseParamsDefaults", ")", ";", "$", "domainParamsDefault", "=", "array_merge", "(", "$", "routeReverseParamsDefaults", ",", "$", "targetDomainRouteDefaults", ")", ";", "$", "domainParamsDefault", "[", "$", "moduleParamName", "]", "=", "$", "targetModule", ";", "}", "}", "else", "if", "(", "$", "currentDomainRouteMatched", ")", "{", "$", "targetModule", "=", "$", "this", "->", "currentModule", ";", "$", "targetDomainRoute", "=", "$", "this", "->", "currentDomainRoute", ";", "$", "domainParamsDefault", "=", "$", "this", "->", "requestedDomainParams", ";", "}", "return", "[", "$", "targetModule", ",", "$", "targetDomainRoute", ",", "$", "domainParamsDefault", "]", ";", "}" ]
Get target module, target module domain route (for possibly defined) target `module` record in `Url()` method `$params` array) and get module domain route default params with default values, necessary to complete domain part. Those default params could be requested domain params or module domain route default reverse params. @param array $params `Url()` method `$params` array, it could still contain a `module` record. @param bool $moduleParamDefined `TRUE` if there was defined any `module` in `Url()` method `$params` array. @param bool $currentDomainRouteMatched `TRUE` if there is matched any current domain route. @throws \InvalidArgumentException No domain route defined for given module. @return array `[string|NULL $targetModule, \MvcCore\Ext\Routers\Modules\Route|NULL $targetDomainRoute, array $domainParamsDefault]`
[ "Get", "target", "module", "target", "module", "domain", "route", "(", "for", "possibly", "defined", ")", "target", "module", "record", "in", "Url", "()", "method", "$params", "array", ")", "and", "get", "module", "domain", "route", "default", "params", "with", "default", "values", "necessary", "to", "complete", "domain", "part", ".", "Those", "default", "params", "could", "be", "requested", "domain", "params", "or", "module", "domain", "route", "default", "reverse", "params", "." ]
train
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/UrlDomain.php#L30-L56
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Module/UrlDomain.php
UrlDomain.urlGetDomainUrlAndClasifyParamsAndDomainParams
protected function urlGetDomainUrlAndClasifyParamsAndDomainParams (array & $params, array & $domainParamsDefault, & $targetDomainRoute) { // remove domain module params and complete URL address base part by module domain $domainParams = array_intersect_key($params, $domainParamsDefault); $params = array_diff_key($params, $domainParamsDefault); $defaultDomainParams = array_merge([], $this->GetDefaultParams() ?: []); list($domainUrlBaseSection,) = $targetDomainRoute->Url( $this->request, $domainParams, $defaultDomainParams, '', TRUE ); return $domainUrlBaseSection; }
php
protected function urlGetDomainUrlAndClasifyParamsAndDomainParams (array & $params, array & $domainParamsDefault, & $targetDomainRoute) { // remove domain module params and complete URL address base part by module domain $domainParams = array_intersect_key($params, $domainParamsDefault); $params = array_diff_key($params, $domainParamsDefault); $defaultDomainParams = array_merge([], $this->GetDefaultParams() ?: []); list($domainUrlBaseSection,) = $targetDomainRoute->Url( $this->request, $domainParams, $defaultDomainParams, '', TRUE ); return $domainUrlBaseSection; }
[ "protected", "function", "urlGetDomainUrlAndClasifyParamsAndDomainParams", "(", "array", "&", "$", "params", ",", "array", "&", "$", "domainParamsDefault", ",", "&", "$", "targetDomainRoute", ")", "{", "// remove domain module params and complete URL address base part by module domain", "$", "domainParams", "=", "array_intersect_key", "(", "$", "params", ",", "$", "domainParamsDefault", ")", ";", "$", "params", "=", "array_diff_key", "(", "$", "params", ",", "$", "domainParamsDefault", ")", ";", "$", "defaultDomainParams", "=", "array_merge", "(", "[", "]", ",", "$", "this", "->", "GetDefaultParams", "(", ")", "?", ":", "[", "]", ")", ";", "list", "(", "$", "domainUrlBaseSection", ",", ")", "=", "$", "targetDomainRoute", "->", "Url", "(", "$", "this", "->", "request", ",", "$", "domainParams", ",", "$", "defaultDomainParams", ",", "''", ",", "TRUE", ")", ";", "return", "$", "domainUrlBaseSection", ";", "}" ]
Complete domain URL part by given module domain route and classify params necessary to complete URL by module route reverse string and unset those params from params array reference. Params array will be changed. Return URL base part by module domain route. @param array $params @param array $domainParamsDefault @param \MvcCore\Ext\Routers\Modules\Route|\MvcCore\Ext\Routers\Modules\IRoute $targetDomainRoute @return string
[ "Complete", "domain", "URL", "part", "by", "given", "module", "domain", "route", "and", "classify", "params", "necessary", "to", "complete", "URL", "by", "module", "route", "reverse", "string", "and", "unset", "those", "params", "from", "params", "array", "reference", ".", "Params", "array", "will", "be", "changed", ".", "Return", "URL", "base", "part", "by", "module", "domain", "route", "." ]
train
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/UrlDomain.php#L68-L77
zhouyl/mellivora
Mellivora/Database/Console/Migrations/ResetCommand.php
ResetCommand.fire
public function fire() { if (!$this->confirmToProceed()) { return; } $migrator = $this->container['migrator']; $migrator->setConnection($this->option('database')); // First, we'll make sure that the migration table actually exists before we // start trying to rollback and re-run all of the migrations. If it's not // present we'll just bail out with an info message for the developers. if (!$migrator->repositoryExists()) { return $this->comment('Migration table not found.'); } $migrator->reset( $this->getMigrationPaths(), $this->option('pretend') ); // Once the migrator has run we will grab the note output and send it out to // the console screen, since the migrator itself functions without having // any instances of the OutputInterface contract passed into the class. foreach ($migrator->getNotes() as $note) { $this->output->writeln($note); } }
php
public function fire() { if (!$this->confirmToProceed()) { return; } $migrator = $this->container['migrator']; $migrator->setConnection($this->option('database')); // First, we'll make sure that the migration table actually exists before we // start trying to rollback and re-run all of the migrations. If it's not // present we'll just bail out with an info message for the developers. if (!$migrator->repositoryExists()) { return $this->comment('Migration table not found.'); } $migrator->reset( $this->getMigrationPaths(), $this->option('pretend') ); // Once the migrator has run we will grab the note output and send it out to // the console screen, since the migrator itself functions without having // any instances of the OutputInterface contract passed into the class. foreach ($migrator->getNotes() as $note) { $this->output->writeln($note); } }
[ "public", "function", "fire", "(", ")", "{", "if", "(", "!", "$", "this", "->", "confirmToProceed", "(", ")", ")", "{", "return", ";", "}", "$", "migrator", "=", "$", "this", "->", "container", "[", "'migrator'", "]", ";", "$", "migrator", "->", "setConnection", "(", "$", "this", "->", "option", "(", "'database'", ")", ")", ";", "// First, we'll make sure that the migration table actually exists before we", "// start trying to rollback and re-run all of the migrations. If it's not", "// present we'll just bail out with an info message for the developers.", "if", "(", "!", "$", "migrator", "->", "repositoryExists", "(", ")", ")", "{", "return", "$", "this", "->", "comment", "(", "'Migration table not found.'", ")", ";", "}", "$", "migrator", "->", "reset", "(", "$", "this", "->", "getMigrationPaths", "(", ")", ",", "$", "this", "->", "option", "(", "'pretend'", ")", ")", ";", "// Once the migrator has run we will grab the note output and send it out to", "// the console screen, since the migrator itself functions without having", "// any instances of the OutputInterface contract passed into the class.", "foreach", "(", "$", "migrator", "->", "getNotes", "(", ")", "as", "$", "note", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "$", "note", ")", ";", "}", "}" ]
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Console/Migrations/ResetCommand.php#L31-L59
php-lug/lug
src/Component/Grid/Column/Type/BooleanType.php
BooleanType.render
public function render($data, array $options) { $boolean = $this->getValue($data, $options); if ($boolean === null) { return; } if (!is_bool($boolean)) { throw new InvalidTypeException(sprintf( 'The "%s" %s column type expects a boolean value, got "%s".', $options['column']->getName(), $this->getName(), is_object($boolean) ? get_class($boolean) : gettype($boolean) )); } return $this->renderTemplate($boolean, $options); }
php
public function render($data, array $options) { $boolean = $this->getValue($data, $options); if ($boolean === null) { return; } if (!is_bool($boolean)) { throw new InvalidTypeException(sprintf( 'The "%s" %s column type expects a boolean value, got "%s".', $options['column']->getName(), $this->getName(), is_object($boolean) ? get_class($boolean) : gettype($boolean) )); } return $this->renderTemplate($boolean, $options); }
[ "public", "function", "render", "(", "$", "data", ",", "array", "$", "options", ")", "{", "$", "boolean", "=", "$", "this", "->", "getValue", "(", "$", "data", ",", "$", "options", ")", ";", "if", "(", "$", "boolean", "===", "null", ")", "{", "return", ";", "}", "if", "(", "!", "is_bool", "(", "$", "boolean", ")", ")", "{", "throw", "new", "InvalidTypeException", "(", "sprintf", "(", "'The \"%s\" %s column type expects a boolean value, got \"%s\".'", ",", "$", "options", "[", "'column'", "]", "->", "getName", "(", ")", ",", "$", "this", "->", "getName", "(", ")", ",", "is_object", "(", "$", "boolean", ")", "?", "get_class", "(", "$", "boolean", ")", ":", "gettype", "(", "$", "boolean", ")", ")", ")", ";", "}", "return", "$", "this", "->", "renderTemplate", "(", "$", "boolean", ",", "$", "options", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Column/Type/BooleanType.php#L43-L61
php-lug/lug
src/Component/Grid/Column/Type/BooleanType.php
BooleanType.configureOptions
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver->setDefault('template', $this->template); }
php
public function configureOptions(OptionsResolver $resolver) { parent::configureOptions($resolver); $resolver->setDefault('template', $this->template); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "parent", "::", "configureOptions", "(", "$", "resolver", ")", ";", "$", "resolver", "->", "setDefault", "(", "'template'", ",", "$", "this", "->", "template", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Column/Type/BooleanType.php#L66-L71
zhouyl/mellivora
Mellivora/Database/Migrations/MigrationCreator.php
MigrationCreator.getStub
protected function getStub($table, $create) { if (is_null($table)) { return file_get_contents($this->stubPath() . '/blank.stub'); } // We also have stubs for creating new tables and modifying existing tables // to save the developer some typing when they are creating a new tables // or modifying existing tables. We'll grab the appropriate stub here. $stub = $create ? 'create.stub' : 'update.stub'; return file_get_contents($this->stubPath() . "/{$stub}"); }
php
protected function getStub($table, $create) { if (is_null($table)) { return file_get_contents($this->stubPath() . '/blank.stub'); } // We also have stubs for creating new tables and modifying existing tables // to save the developer some typing when they are creating a new tables // or modifying existing tables. We'll grab the appropriate stub here. $stub = $create ? 'create.stub' : 'update.stub'; return file_get_contents($this->stubPath() . "/{$stub}"); }
[ "protected", "function", "getStub", "(", "$", "table", ",", "$", "create", ")", "{", "if", "(", "is_null", "(", "$", "table", ")", ")", "{", "return", "file_get_contents", "(", "$", "this", "->", "stubPath", "(", ")", ".", "'/blank.stub'", ")", ";", "}", "// We also have stubs for creating new tables and modifying existing tables", "// to save the developer some typing when they are creating a new tables", "// or modifying existing tables. We'll grab the appropriate stub here.", "$", "stub", "=", "$", "create", "?", "'create.stub'", ":", "'update.stub'", ";", "return", "file_get_contents", "(", "$", "this", "->", "stubPath", "(", ")", ".", "\"/{$stub}\"", ")", ";", "}" ]
Get the migration stub file. @param string $table @param bool $create @return string
[ "Get", "the", "migration", "stub", "file", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Migrations/MigrationCreator.php#L76-L89
honzapospi/rest-server
src/RouteList.php
RouteList.get
public function get(string $path, string $className) { $this->add(new Route($path, Route::GET, $className)); }
php
public function get(string $path, string $className) { $this->add(new Route($path, Route::GET, $className)); }
[ "public", "function", "get", "(", "string", "$", "path", ",", "string", "$", "className", ")", "{", "$", "this", "->", "add", "(", "new", "Route", "(", "$", "path", ",", "Route", "::", "GET", ",", "$", "className", ")", ")", ";", "}" ]
*********************************************** SHORTERS ******************************************************
[ "***********************************************", "SHORTERS", "******************************************************" ]
train
https://github.com/honzapospi/rest-server/blob/8c56d62ef64c90dd1c594be4a229606fe5e8caec/src/RouteList.php#L48-L50
LeaseCloud/leasecloud-php-sdk
src/ApiRequestor.php
ApiRequestor.request
public function request($method, $url, $params = null, $headers = []) { $headers = array_merge(self::defaultHeaders(), $headers); $absUrl = $this->apiBase . $url; return $this->httpClient()->request($method, $absUrl, $params, $headers); }
php
public function request($method, $url, $params = null, $headers = []) { $headers = array_merge(self::defaultHeaders(), $headers); $absUrl = $this->apiBase . $url; return $this->httpClient()->request($method, $absUrl, $params, $headers); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "url", ",", "$", "params", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "$", "headers", "=", "array_merge", "(", "self", "::", "defaultHeaders", "(", ")", ",", "$", "headers", ")", ";", "$", "absUrl", "=", "$", "this", "->", "apiBase", ".", "$", "url", ";", "return", "$", "this", "->", "httpClient", "(", ")", "->", "request", "(", "$", "method", ",", "$", "absUrl", ",", "$", "params", ",", "$", "headers", ")", ";", "}" ]
Make an API request @param string $method @param string $url @param array|null $params @param array|null $headers @return array An array whose first element is an API response and second element is the API key used to make the request.
[ "Make", "an", "API", "request" ]
train
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/ApiRequestor.php#L61-L66
LeaseCloud/leasecloud-php-sdk
src/ApiRequestor.php
ApiRequestor.httpClient
private function httpClient() { if (!self::$httpClient) { self::$httpClient = HttpClient\CurlClient::instance(); } return self::$httpClient; }
php
private function httpClient() { if (!self::$httpClient) { self::$httpClient = HttpClient\CurlClient::instance(); } return self::$httpClient; }
[ "private", "function", "httpClient", "(", ")", "{", "if", "(", "!", "self", "::", "$", "httpClient", ")", "{", "self", "::", "$", "httpClient", "=", "HttpClient", "\\", "CurlClient", "::", "instance", "(", ")", ";", "}", "return", "self", "::", "$", "httpClient", ";", "}" ]
If needed create, and return a http client @return HttpClient\CurlClient
[ "If", "needed", "create", "and", "return", "a", "http", "client" ]
train
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/ApiRequestor.php#L84-L90
engineor/flysystem-runabove
src/Runabove.php
Runabove.getCredentials
public function getCredentials() { $secret = $this->getSecret(); if (!isset($secret['username']) || !isset($secret['password'])) { throw new CredentialError('Unrecognized credential secret'); } return parent::getCredentials(); }
php
public function getCredentials() { $secret = $this->getSecret(); if (!isset($secret['username']) || !isset($secret['password'])) { throw new CredentialError('Unrecognized credential secret'); } return parent::getCredentials(); }
[ "public", "function", "getCredentials", "(", ")", "{", "$", "secret", "=", "$", "this", "->", "getSecret", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "secret", "[", "'username'", "]", ")", "||", "!", "isset", "(", "$", "secret", "[", "'password'", "]", ")", ")", "{", "throw", "new", "CredentialError", "(", "'Unrecognized credential secret'", ")", ";", "}", "return", "parent", "::", "getCredentials", "(", ")", ";", "}" ]
Check whether required secret keys are set and return Runabove API credentials {@inheritDoc}
[ "Check", "whether", "required", "secret", "keys", "are", "set", "and", "return", "Runabove", "API", "credentials", "{" ]
train
https://github.com/engineor/flysystem-runabove/blob/d8c22dbf25c3bf2b62187f9da07efb48888d44de/src/Runabove.php#L50-L59
ezsystems/ezcomments-ls-extension
classes/ezcomaddcommenttool.php
ezcomAddCommentTool.isVariableRequired
public function isVariableRequired( $field ) { switch ( $field ) { case 'email': $user = eZUser::currentUser(); if( !$user->isAnonymous() ) { return false; } return true; case 'recaptcha': // if the user bypasses captcha, don't validate field $bypassCaptcha = ezcomPermission::hasAccessToSecurity( 'AntiSpam' , 'bypass_captcha' ); if( $bypassCaptcha['result'] ) { return false; } return true; default: return parent::isVariableRequired( $field ); } }
php
public function isVariableRequired( $field ) { switch ( $field ) { case 'email': $user = eZUser::currentUser(); if( !$user->isAnonymous() ) { return false; } return true; case 'recaptcha': // if the user bypasses captcha, don't validate field $bypassCaptcha = ezcomPermission::hasAccessToSecurity( 'AntiSpam' , 'bypass_captcha' ); if( $bypassCaptcha['result'] ) { return false; } return true; default: return parent::isVariableRequired( $field ); } }
[ "public", "function", "isVariableRequired", "(", "$", "field", ")", "{", "switch", "(", "$", "field", ")", "{", "case", "'email'", ":", "$", "user", "=", "eZUser", "::", "currentUser", "(", ")", ";", "if", "(", "!", "$", "user", "->", "isAnonymous", "(", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "case", "'recaptcha'", ":", "// if the user bypasses captcha, don't validate field", "$", "bypassCaptcha", "=", "ezcomPermission", "::", "hasAccessToSecurity", "(", "'AntiSpam'", ",", "'bypass_captcha'", ")", ";", "if", "(", "$", "bypassCaptcha", "[", "'result'", "]", ")", "{", "return", "false", ";", "}", "return", "true", ";", "default", ":", "return", "parent", "::", "isVariableRequired", "(", "$", "field", ")", ";", "}", "}" ]
isVariableRequire in adding comment. When adding comment, for logined user the email is not required @see extension/ezcomments/classes/ezcomFormTool#isVariableRequired($field)
[ "isVariableRequire", "in", "adding", "comment", ".", "When", "adding", "comment", "for", "logined", "user", "the", "email", "is", "not", "required" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomaddcommenttool.php#L24-L46
ezsystems/ezcomments-ls-extension
classes/ezcomaddcommenttool.php
ezcomAddCommentTool.validateField
protected function validateField( $field, $value ) { switch ( $field ) { case 'website': return ezcomUtility::validateURLString( $value ); case 'email': // just validate anonymous's input email $user = eZUser::currentUser(); if( $user->isAnonymous() ) { $result = eZMail::validate( $value ); if ( !$result ) { return ezpI18n::tr( 'ezcomments/comment/add', 'Not a valid email address.' ); } } return true; case 'recaptcha': require_once 'recaptchalib.php'; $ini = eZINI::instance( 'ezcomments.ini' ); $privateKey = $ini->variable( 'RecaptchaSetting' , 'PrivateKey' ); $http = eZHTTPTool::instance(); if( $http->hasPostVariable( 'recaptcha_challenge_field' ) && $http->hasPostVariable( 'recaptcha_response_field' ) ) { $ip = $_SERVER["REMOTE_ADDR"]; $challengeField = $http->postVariable( 'recaptcha_challenge_field' ); $responseField = $http->postVariable( 'recaptcha_response_field' ); $capchaResponse = recaptcha_check_answer( $privateKey, $ip, $challengeField, $responseField ); if( !$capchaResponse->is_valid ) { return ezpI18n::tr( 'ezcomments/comment/add', 'The words you input are incorrect.' ); } } else { return ezpI18n::tr( 'ezcomments/comment/add', 'Captcha parameter error.' ); } return true; default: return true; } }
php
protected function validateField( $field, $value ) { switch ( $field ) { case 'website': return ezcomUtility::validateURLString( $value ); case 'email': // just validate anonymous's input email $user = eZUser::currentUser(); if( $user->isAnonymous() ) { $result = eZMail::validate( $value ); if ( !$result ) { return ezpI18n::tr( 'ezcomments/comment/add', 'Not a valid email address.' ); } } return true; case 'recaptcha': require_once 'recaptchalib.php'; $ini = eZINI::instance( 'ezcomments.ini' ); $privateKey = $ini->variable( 'RecaptchaSetting' , 'PrivateKey' ); $http = eZHTTPTool::instance(); if( $http->hasPostVariable( 'recaptcha_challenge_field' ) && $http->hasPostVariable( 'recaptcha_response_field' ) ) { $ip = $_SERVER["REMOTE_ADDR"]; $challengeField = $http->postVariable( 'recaptcha_challenge_field' ); $responseField = $http->postVariable( 'recaptcha_response_field' ); $capchaResponse = recaptcha_check_answer( $privateKey, $ip, $challengeField, $responseField ); if( !$capchaResponse->is_valid ) { return ezpI18n::tr( 'ezcomments/comment/add', 'The words you input are incorrect.' ); } } else { return ezpI18n::tr( 'ezcomments/comment/add', 'Captcha parameter error.' ); } return true; default: return true; } }
[ "protected", "function", "validateField", "(", "$", "field", ",", "$", "value", ")", "{", "switch", "(", "$", "field", ")", "{", "case", "'website'", ":", "return", "ezcomUtility", "::", "validateURLString", "(", "$", "value", ")", ";", "case", "'email'", ":", "// just validate anonymous's input email", "$", "user", "=", "eZUser", "::", "currentUser", "(", ")", ";", "if", "(", "$", "user", "->", "isAnonymous", "(", ")", ")", "{", "$", "result", "=", "eZMail", "::", "validate", "(", "$", "value", ")", ";", "if", "(", "!", "$", "result", ")", "{", "return", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'Not a valid email address.'", ")", ";", "}", "}", "return", "true", ";", "case", "'recaptcha'", ":", "require_once", "'recaptchalib.php'", ";", "$", "ini", "=", "eZINI", "::", "instance", "(", "'ezcomments.ini'", ")", ";", "$", "privateKey", "=", "$", "ini", "->", "variable", "(", "'RecaptchaSetting'", ",", "'PrivateKey'", ")", ";", "$", "http", "=", "eZHTTPTool", "::", "instance", "(", ")", ";", "if", "(", "$", "http", "->", "hasPostVariable", "(", "'recaptcha_challenge_field'", ")", "&&", "$", "http", "->", "hasPostVariable", "(", "'recaptcha_response_field'", ")", ")", "{", "$", "ip", "=", "$", "_SERVER", "[", "\"REMOTE_ADDR\"", "]", ";", "$", "challengeField", "=", "$", "http", "->", "postVariable", "(", "'recaptcha_challenge_field'", ")", ";", "$", "responseField", "=", "$", "http", "->", "postVariable", "(", "'recaptcha_response_field'", ")", ";", "$", "capchaResponse", "=", "recaptcha_check_answer", "(", "$", "privateKey", ",", "$", "ip", ",", "$", "challengeField", ",", "$", "responseField", ")", ";", "if", "(", "!", "$", "capchaResponse", "->", "is_valid", ")", "{", "return", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'The words you input are incorrect.'", ")", ";", "}", "}", "else", "{", "return", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'Captcha parameter error.'", ")", ";", "}", "return", "true", ";", "default", ":", "return", "true", ";", "}", "}" ]
Implement the validatation in adding comment @see extension/ezcomments/classes/ezcomFormTool#validateField($field)
[ "Implement", "the", "validatation", "in", "adding", "comment" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomaddcommenttool.php#L52-L95
ezsystems/ezcomments-ls-extension
classes/ezcomaddcommenttool.php
ezcomAddCommentTool.setFieldValue
protected function setFieldValue( $field, $fieldPostName ) { $user = eZUser::currentUser(); switch ( $field ) { case 'email': if( !$user->isAnonymous() ) { $this->fieldValues[$field] = $user->attribute( 'email' ); } else { parent::setFieldValue( $field, $fieldPostName ); } break; case 'notificationField': $http = eZHTTPTool::instance(); $notification = false; if( $http->hasPostVariable( $fieldPostName ) && $http->postVariable( $fieldPostName ) == '1') { $notification = true; } $this->fieldValues[$field] = $notification; break; default: parent::setFieldValue( $field, $fieldPostName ); break; } }
php
protected function setFieldValue( $field, $fieldPostName ) { $user = eZUser::currentUser(); switch ( $field ) { case 'email': if( !$user->isAnonymous() ) { $this->fieldValues[$field] = $user->attribute( 'email' ); } else { parent::setFieldValue( $field, $fieldPostName ); } break; case 'notificationField': $http = eZHTTPTool::instance(); $notification = false; if( $http->hasPostVariable( $fieldPostName ) && $http->postVariable( $fieldPostName ) == '1') { $notification = true; } $this->fieldValues[$field] = $notification; break; default: parent::setFieldValue( $field, $fieldPostName ); break; } }
[ "protected", "function", "setFieldValue", "(", "$", "field", ",", "$", "fieldPostName", ")", "{", "$", "user", "=", "eZUser", "::", "currentUser", "(", ")", ";", "switch", "(", "$", "field", ")", "{", "case", "'email'", ":", "if", "(", "!", "$", "user", "->", "isAnonymous", "(", ")", ")", "{", "$", "this", "->", "fieldValues", "[", "$", "field", "]", "=", "$", "user", "->", "attribute", "(", "'email'", ")", ";", "}", "else", "{", "parent", "::", "setFieldValue", "(", "$", "field", ",", "$", "fieldPostName", ")", ";", "}", "break", ";", "case", "'notificationField'", ":", "$", "http", "=", "eZHTTPTool", "::", "instance", "(", ")", ";", "$", "notification", "=", "false", ";", "if", "(", "$", "http", "->", "hasPostVariable", "(", "$", "fieldPostName", ")", "&&", "$", "http", "->", "postVariable", "(", "$", "fieldPostName", ")", "==", "'1'", ")", "{", "$", "notification", "=", "true", ";", "}", "$", "this", "->", "fieldValues", "[", "$", "field", "]", "=", "$", "notification", ";", "break", ";", "default", ":", "parent", "::", "setFieldValue", "(", "$", "field", ",", "$", "fieldPostName", ")", ";", "break", ";", "}", "}" ]
Implement the setFieldValue in adding comment @see extension/ezcomments/classes/ezcomFormTool#setFieldValue($fieldPostName)
[ "Implement", "the", "setFieldValue", "in", "adding", "comment" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomaddcommenttool.php#L101-L129
digipolisgent/robo-digipolis-package-drupal8
src/Utility/ThemeFinder.php
ThemeFinder.getThemePaths
protected function getThemePaths($themes) { $dirsFromConfig = array_filter( [ $this->getConfig()->get('digipolis.root.project', false), $this->getConfig()->get('digipolis.root.web', false), ] ); $dirs = empty($this->dirs) ? $dirsFromConfig : $this->dirs; if (empty($dirs)) { $dirs = [getcwd()]; } $finder = clone $this->finder; $finder->in($dirs)->files(); foreach ($themes as $themeName) { // Matches 'themes/(custom/){randomfoldername}/{themename}.info.yml'. $finder->path('/themes\/(custom\/)?[^\/]*\/' . preg_quote($themeName, '/') . '\.info\.yml/'); } $processed = []; $paths = []; foreach ($finder as $infoFile) { $path = dirname($infoFile->getRealPath()); // The web dir can be a subdir of the project root (in most cases // really). Make sure we don't compile the same theme twice. if (isset($processed[$path])) { continue; } $processed[$path] = true; $theme = $infoFile->getBasename('.info.yml'); $paths[$theme] = $path; } return $paths; }
php
protected function getThemePaths($themes) { $dirsFromConfig = array_filter( [ $this->getConfig()->get('digipolis.root.project', false), $this->getConfig()->get('digipolis.root.web', false), ] ); $dirs = empty($this->dirs) ? $dirsFromConfig : $this->dirs; if (empty($dirs)) { $dirs = [getcwd()]; } $finder = clone $this->finder; $finder->in($dirs)->files(); foreach ($themes as $themeName) { // Matches 'themes/(custom/){randomfoldername}/{themename}.info.yml'. $finder->path('/themes\/(custom\/)?[^\/]*\/' . preg_quote($themeName, '/') . '\.info\.yml/'); } $processed = []; $paths = []; foreach ($finder as $infoFile) { $path = dirname($infoFile->getRealPath()); // The web dir can be a subdir of the project root (in most cases // really). Make sure we don't compile the same theme twice. if (isset($processed[$path])) { continue; } $processed[$path] = true; $theme = $infoFile->getBasename('.info.yml'); $paths[$theme] = $path; } return $paths; }
[ "protected", "function", "getThemePaths", "(", "$", "themes", ")", "{", "$", "dirsFromConfig", "=", "array_filter", "(", "[", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'digipolis.root.project'", ",", "false", ")", ",", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'digipolis.root.web'", ",", "false", ")", ",", "]", ")", ";", "$", "dirs", "=", "empty", "(", "$", "this", "->", "dirs", ")", "?", "$", "dirsFromConfig", ":", "$", "this", "->", "dirs", ";", "if", "(", "empty", "(", "$", "dirs", ")", ")", "{", "$", "dirs", "=", "[", "getcwd", "(", ")", "]", ";", "}", "$", "finder", "=", "clone", "$", "this", "->", "finder", ";", "$", "finder", "->", "in", "(", "$", "dirs", ")", "->", "files", "(", ")", ";", "foreach", "(", "$", "themes", "as", "$", "themeName", ")", "{", "// Matches 'themes/(custom/){randomfoldername}/{themename}.info.yml'.", "$", "finder", "->", "path", "(", "'/themes\\/(custom\\/)?[^\\/]*\\/'", ".", "preg_quote", "(", "$", "themeName", ",", "'/'", ")", ".", "'\\.info\\.yml/'", ")", ";", "}", "$", "processed", "=", "[", "]", ";", "$", "paths", "=", "[", "]", ";", "foreach", "(", "$", "finder", "as", "$", "infoFile", ")", "{", "$", "path", "=", "dirname", "(", "$", "infoFile", "->", "getRealPath", "(", ")", ")", ";", "// The web dir can be a subdir of the project root (in most cases", "// really). Make sure we don't compile the same theme twice.", "if", "(", "isset", "(", "$", "processed", "[", "$", "path", "]", ")", ")", "{", "continue", ";", "}", "$", "processed", "[", "$", "path", "]", "=", "true", ";", "$", "theme", "=", "$", "infoFile", "->", "getBasename", "(", "'.info.yml'", ")", ";", "$", "paths", "[", "$", "theme", "]", "=", "$", "path", ";", "}", "return", "$", "paths", ";", "}" ]
Get the theme paths. @param array $themes An array of theme names. @return array The theme paths keyed by theme name.
[ "Get", "the", "theme", "paths", "." ]
train
https://github.com/digipolisgent/robo-digipolis-package-drupal8/blob/dc03ae0f68d56a027291e9574ff7aa433c27690a/src/Utility/ThemeFinder.php#L17-L52
sgmendez/json
src/Json.php
Json.encode
public function encode($data, $options = 0, $depth = 512) { $dataValid = $this->validateType('not_resource', $data); $optionsValid = $this->validateType('int', $options, '$options'); $depthValid = $this->validateType('int', $depth, '$depth'); $jsonData = $this->encodeCheckVersion($dataValid, $optionsValid, $depthValid); $this->checkJsonError(); return $jsonData; }
php
public function encode($data, $options = 0, $depth = 512) { $dataValid = $this->validateType('not_resource', $data); $optionsValid = $this->validateType('int', $options, '$options'); $depthValid = $this->validateType('int', $depth, '$depth'); $jsonData = $this->encodeCheckVersion($dataValid, $optionsValid, $depthValid); $this->checkJsonError(); return $jsonData; }
[ "public", "function", "encode", "(", "$", "data", ",", "$", "options", "=", "0", ",", "$", "depth", "=", "512", ")", "{", "$", "dataValid", "=", "$", "this", "->", "validateType", "(", "'not_resource'", ",", "$", "data", ")", ";", "$", "optionsValid", "=", "$", "this", "->", "validateType", "(", "'int'", ",", "$", "options", ",", "'$options'", ")", ";", "$", "depthValid", "=", "$", "this", "->", "validateType", "(", "'int'", ",", "$", "depth", ",", "'$depth'", ")", ";", "$", "jsonData", "=", "$", "this", "->", "encodeCheckVersion", "(", "$", "dataValid", ",", "$", "optionsValid", ",", "$", "depthValid", ")", ";", "$", "this", "->", "checkJsonError", "(", ")", ";", "return", "$", "jsonData", ";", "}" ]
Returns the JSON representation of a value @param mixed $data Valid all type except a resource @param integer $options Acepted values: JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT, JSON_UNESCAPED_UNICODE @param integer $depth Set the maximum depth, must be greater than 0 @return mixed JSON encoded string on success or FALSE on failue
[ "Returns", "the", "JSON", "representation", "of", "a", "value" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L41-L51
sgmendez/json
src/Json.php
Json.decodeFile
public function decodeFile($file, $assoc = true, $depth = 512, $options = 0) { set_error_handler( create_function( '$severity, $message, $file, $line', 'throw new ErrorException($message, $severity, $severity, $file, $line);' ) ); try { $jsonData = file_get_contents($file); } catch (Exception $e) { throw new RuntimeException(sprintf($e->getMessage())); } restore_error_handler(); if(false === $jsonData) { throw new RuntimeException(sprintf('Unable to get file %s', $file)); } return $this->decode($jsonData, $assoc, $depth, $options); }
php
public function decodeFile($file, $assoc = true, $depth = 512, $options = 0) { set_error_handler( create_function( '$severity, $message, $file, $line', 'throw new ErrorException($message, $severity, $severity, $file, $line);' ) ); try { $jsonData = file_get_contents($file); } catch (Exception $e) { throw new RuntimeException(sprintf($e->getMessage())); } restore_error_handler(); if(false === $jsonData) { throw new RuntimeException(sprintf('Unable to get file %s', $file)); } return $this->decode($jsonData, $assoc, $depth, $options); }
[ "public", "function", "decodeFile", "(", "$", "file", ",", "$", "assoc", "=", "true", ",", "$", "depth", "=", "512", ",", "$", "options", "=", "0", ")", "{", "set_error_handler", "(", "create_function", "(", "'$severity, $message, $file, $line'", ",", "'throw new ErrorException($message, $severity, $severity, $file, $line);'", ")", ")", ";", "try", "{", "$", "jsonData", "=", "file_get_contents", "(", "$", "file", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "restore_error_handler", "(", ")", ";", "if", "(", "false", "===", "$", "jsonData", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Unable to get file %s'", ",", "$", "file", ")", ")", ";", "}", "return", "$", "this", "->", "decode", "(", "$", "jsonData", ",", "$", "assoc", ",", "$", "depth", ",", "$", "options", ")", ";", "}" ]
Decode JSON data encoded in file @param string $file @param boolean $assoc @param integer $depth @param integer $options @return mixed @throws RuntimeException
[ "Decode", "JSON", "data", "encoded", "in", "file" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L86-L111
sgmendez/json
src/Json.php
Json.checkJsonError
protected function checkJsonError() { if(!function_exists('json_last_error')) { throw new BadFunctionCallException('json_last_error() function not exits'); } $jsonError = json_last_error(); if($jsonError !== JSON_ERROR_NONE) { $this->jsonErrorException($jsonError); } return true; }
php
protected function checkJsonError() { if(!function_exists('json_last_error')) { throw new BadFunctionCallException('json_last_error() function not exits'); } $jsonError = json_last_error(); if($jsonError !== JSON_ERROR_NONE) { $this->jsonErrorException($jsonError); } return true; }
[ "protected", "function", "checkJsonError", "(", ")", "{", "if", "(", "!", "function_exists", "(", "'json_last_error'", ")", ")", "{", "throw", "new", "BadFunctionCallException", "(", "'json_last_error() function not exits'", ")", ";", "}", "$", "jsonError", "=", "json_last_error", "(", ")", ";", "if", "(", "$", "jsonError", "!==", "JSON_ERROR_NONE", ")", "{", "$", "this", "->", "jsonErrorException", "(", "$", "jsonError", ")", ";", "}", "return", "true", ";", "}" ]
Check exists error for last execution json funtion @return boolean @throws BadFunctionCallException
[ "Check", "exists", "error", "for", "last", "execution", "json", "funtion" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L157-L171
sgmendez/json
src/Json.php
Json.jsonErrorException
protected function jsonErrorException($code) { $this->defineCodesErrorJson(); switch($code) { case JSON_ERROR_DEPTH: throw new LengthException('The maximum stack depth has been exceeded'); break; case JSON_ERROR_STATE_MISMATCH: throw new UnexpectedValueException('Invalid or malformed JSON'); break; case JSON_ERROR_CTRL_CHAR: throw new UnexpectedValueException('Control character error, possibly incorrectly encoded'); break; case JSON_ERROR_SYNTAX: throw new RuntimeException('Syntax error'); break; case JSON_ERROR_UTF8: throw new RuntimeException('Malformed UTF-8 characters, possibly incorrectly encoded'); break; case JSON_ERROR_RECURSION: throw new RuntimeException('One or more recursive references in the value to be encoded'); break; case JSON_ERROR_INF_OR_NAN: throw new RuntimeException('One or more NAN or INF values in the value to be encoded'); break; case JSON_ERROR_UNSUPPORTED_TYPE: throw new UnexpectedValueException('A value of a type that cannot be encoded was given'); break; default : $msg = (function_exists('json_last_error_msg')) ? json_last_error_msg() : 'Code ERROR not valid for JSON'; throw new UnexpectedValueException($msg); } }
php
protected function jsonErrorException($code) { $this->defineCodesErrorJson(); switch($code) { case JSON_ERROR_DEPTH: throw new LengthException('The maximum stack depth has been exceeded'); break; case JSON_ERROR_STATE_MISMATCH: throw new UnexpectedValueException('Invalid or malformed JSON'); break; case JSON_ERROR_CTRL_CHAR: throw new UnexpectedValueException('Control character error, possibly incorrectly encoded'); break; case JSON_ERROR_SYNTAX: throw new RuntimeException('Syntax error'); break; case JSON_ERROR_UTF8: throw new RuntimeException('Malformed UTF-8 characters, possibly incorrectly encoded'); break; case JSON_ERROR_RECURSION: throw new RuntimeException('One or more recursive references in the value to be encoded'); break; case JSON_ERROR_INF_OR_NAN: throw new RuntimeException('One or more NAN or INF values in the value to be encoded'); break; case JSON_ERROR_UNSUPPORTED_TYPE: throw new UnexpectedValueException('A value of a type that cannot be encoded was given'); break; default : $msg = (function_exists('json_last_error_msg')) ? json_last_error_msg() : 'Code ERROR not valid for JSON'; throw new UnexpectedValueException($msg); } }
[ "protected", "function", "jsonErrorException", "(", "$", "code", ")", "{", "$", "this", "->", "defineCodesErrorJson", "(", ")", ";", "switch", "(", "$", "code", ")", "{", "case", "JSON_ERROR_DEPTH", ":", "throw", "new", "LengthException", "(", "'The maximum stack depth has been exceeded'", ")", ";", "break", ";", "case", "JSON_ERROR_STATE_MISMATCH", ":", "throw", "new", "UnexpectedValueException", "(", "'Invalid or malformed JSON'", ")", ";", "break", ";", "case", "JSON_ERROR_CTRL_CHAR", ":", "throw", "new", "UnexpectedValueException", "(", "'Control character error, possibly incorrectly encoded'", ")", ";", "break", ";", "case", "JSON_ERROR_SYNTAX", ":", "throw", "new", "RuntimeException", "(", "'Syntax error'", ")", ";", "break", ";", "case", "JSON_ERROR_UTF8", ":", "throw", "new", "RuntimeException", "(", "'Malformed UTF-8 characters, possibly incorrectly encoded'", ")", ";", "break", ";", "case", "JSON_ERROR_RECURSION", ":", "throw", "new", "RuntimeException", "(", "'One or more recursive references in the value to be encoded'", ")", ";", "break", ";", "case", "JSON_ERROR_INF_OR_NAN", ":", "throw", "new", "RuntimeException", "(", "'One or more NAN or INF values in the value to be encoded'", ")", ";", "break", ";", "case", "JSON_ERROR_UNSUPPORTED_TYPE", ":", "throw", "new", "UnexpectedValueException", "(", "'A value of a type that cannot be encoded was given'", ")", ";", "break", ";", "default", ":", "$", "msg", "=", "(", "function_exists", "(", "'json_last_error_msg'", ")", ")", "?", "json_last_error_msg", "(", ")", ":", "'Code ERROR not valid for JSON'", ";", "throw", "new", "UnexpectedValueException", "(", "$", "msg", ")", ";", "}", "}" ]
Generate exception when $code is a json defined error @param integer $code @throws LengthException @throws UnexpectedValueException @throws RuntimeException
[ "Generate", "exception", "when", "$code", "is", "a", "json", "defined", "error" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L181-L215
sgmendez/json
src/Json.php
Json.validateType
private function validateType($type, $value, $name = '') { $valueType = gettype($value); $codeException = $this->checkType($type, $value); if(1 === $codeException) { throw new InvalidArgumentException(sprintf('%s argument only accepts %s. Input type was: %s', $name, $type, $valueType)); } if(2 === $codeException) { throw new RuntimeException('The argument is a resource, not is a valid type'); } if(3 === $codeException) { throw new RuntimeException(sprintf('Value not defined in validation for %s', $type)); } return $value; }
php
private function validateType($type, $value, $name = '') { $valueType = gettype($value); $codeException = $this->checkType($type, $value); if(1 === $codeException) { throw new InvalidArgumentException(sprintf('%s argument only accepts %s. Input type was: %s', $name, $type, $valueType)); } if(2 === $codeException) { throw new RuntimeException('The argument is a resource, not is a valid type'); } if(3 === $codeException) { throw new RuntimeException(sprintf('Value not defined in validation for %s', $type)); } return $value; }
[ "private", "function", "validateType", "(", "$", "type", ",", "$", "value", ",", "$", "name", "=", "''", ")", "{", "$", "valueType", "=", "gettype", "(", "$", "value", ")", ";", "$", "codeException", "=", "$", "this", "->", "checkType", "(", "$", "type", ",", "$", "value", ")", ";", "if", "(", "1", "===", "$", "codeException", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'%s argument only accepts %s. Input type was: %s'", ",", "$", "name", ",", "$", "type", ",", "$", "valueType", ")", ")", ";", "}", "if", "(", "2", "===", "$", "codeException", ")", "{", "throw", "new", "RuntimeException", "(", "'The argument is a resource, not is a valid type'", ")", ";", "}", "if", "(", "3", "===", "$", "codeException", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Value not defined in validation for %s'", ",", "$", "type", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Validate type of $value @param string $type Type of de value expect @param mixec $value @param string $name Name of the variable $value @return mixed @throws InvalidArgumentException @throws RuntimeException
[ "Validate", "type", "of", "$value" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L248-L270
sgmendez/json
src/Json.php
Json.checkType
private function checkType($type, $value) { switch($type) { case 'bool': case 'boolean': $codeException = (!is_bool($value)) ? 1 : 0; break; case 'int': case 'integer': $codeException = (!is_int($value)) ? 1 : 0; break; case 'string': $codeException = (!is_string($value)) ? 1 : 0; break; case 'not_resource': $codeException = (is_resource($value)) ? 2 : 0; break; default : $codeException = 3; break; } return $codeException; }
php
private function checkType($type, $value) { switch($type) { case 'bool': case 'boolean': $codeException = (!is_bool($value)) ? 1 : 0; break; case 'int': case 'integer': $codeException = (!is_int($value)) ? 1 : 0; break; case 'string': $codeException = (!is_string($value)) ? 1 : 0; break; case 'not_resource': $codeException = (is_resource($value)) ? 2 : 0; break; default : $codeException = 3; break; } return $codeException; }
[ "private", "function", "checkType", "(", "$", "type", ",", "$", "value", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'bool'", ":", "case", "'boolean'", ":", "$", "codeException", "=", "(", "!", "is_bool", "(", "$", "value", ")", ")", "?", "1", ":", "0", ";", "break", ";", "case", "'int'", ":", "case", "'integer'", ":", "$", "codeException", "=", "(", "!", "is_int", "(", "$", "value", ")", ")", "?", "1", ":", "0", ";", "break", ";", "case", "'string'", ":", "$", "codeException", "=", "(", "!", "is_string", "(", "$", "value", ")", ")", "?", "1", ":", "0", ";", "break", ";", "case", "'not_resource'", ":", "$", "codeException", "=", "(", "is_resource", "(", "$", "value", ")", ")", "?", "2", ":", "0", ";", "break", ";", "default", ":", "$", "codeException", "=", "3", ";", "break", ";", "}", "return", "$", "codeException", ";", "}" ]
Check type of $value @param string $type Type expect for $value @param mixed $value Value of the variable to check @return int Code for exception
[ "Check", "type", "of", "$value" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L279-L303
sgmendez/json
src/Json.php
Json.decodeCheckVersion
private function decodeCheckVersion($dataValid, $assocValid, $depthValid, $optionsValid) { //In 5.4 add options param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_decode($dataValid, $assocValid, $depthValid, $optionsValid); } return json_decode($dataValid, $assocValid, $depthValid); }
php
private function decodeCheckVersion($dataValid, $assocValid, $depthValid, $optionsValid) { //In 5.4 add options param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_decode($dataValid, $assocValid, $depthValid, $optionsValid); } return json_decode($dataValid, $assocValid, $depthValid); }
[ "private", "function", "decodeCheckVersion", "(", "$", "dataValid", ",", "$", "assocValid", ",", "$", "depthValid", ",", "$", "optionsValid", ")", "{", "//In 5.4 add options param", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4.0'", ")", ">=", "0", ")", "{", "return", "json_decode", "(", "$", "dataValid", ",", "$", "assocValid", ",", "$", "depthValid", ",", "$", "optionsValid", ")", ";", "}", "return", "json_decode", "(", "$", "dataValid", ",", "$", "assocValid", ",", "$", "depthValid", ")", ";", "}" ]
Options param add 5.4 @param $dataValid @param $assocValid @param $depthValid @param $optionsValid @return mixed
[ "Options", "param", "add", "5", ".", "4" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L314-L323
sgmendez/json
src/Json.php
Json.encodeCheckVersion
private function encodeCheckVersion($dataValid, $optionsValid, $depthValid) { //In 5.4 add depth param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_encode($dataValid, $optionsValid, $depthValid); } return json_encode($dataValid, $optionsValid); }
php
private function encodeCheckVersion($dataValid, $optionsValid, $depthValid) { //In 5.4 add depth param if(version_compare(PHP_VERSION, '5.4.0') >= 0) { return json_encode($dataValid, $optionsValid, $depthValid); } return json_encode($dataValid, $optionsValid); }
[ "private", "function", "encodeCheckVersion", "(", "$", "dataValid", ",", "$", "optionsValid", ",", "$", "depthValid", ")", "{", "//In 5.4 add depth param", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'5.4.0'", ")", ">=", "0", ")", "{", "return", "json_encode", "(", "$", "dataValid", ",", "$", "optionsValid", ",", "$", "depthValid", ")", ";", "}", "return", "json_encode", "(", "$", "dataValid", ",", "$", "optionsValid", ")", ";", "}" ]
Depth param add 5.4 @param $dataValid @param $optionsValid @param $depthValid @return string
[ "Depth", "param", "add", "5", ".", "4" ]
train
https://github.com/sgmendez/json/blob/5b63f3328fe4235cdbf3cebe0aadab6fefcc6aba/src/Json.php#L333-L342
inhere/php-librarys
src/Traits/EventTrait.php
EventTrait.off
public function off($event) { if ($this->hasEvent($event)) { $handler = $this->eventHandlers[$event]; unset($this->events[$event], $this->eventHandlers[$event]); return $handler; } return null; }
php
public function off($event) { if ($this->hasEvent($event)) { $handler = $this->eventHandlers[$event]; unset($this->events[$event], $this->eventHandlers[$event]); return $handler; } return null; }
[ "public", "function", "off", "(", "$", "event", ")", "{", "if", "(", "$", "this", "->", "hasEvent", "(", "$", "event", ")", ")", "{", "$", "handler", "=", "$", "this", "->", "eventHandlers", "[", "$", "event", "]", ";", "unset", "(", "$", "this", "->", "events", "[", "$", "event", "]", ",", "$", "this", "->", "eventHandlers", "[", "$", "event", "]", ")", ";", "return", "$", "handler", ";", "}", "return", "null", ";", "}" ]
remove event and it's handlers @param string $event @return mixed
[ "remove", "event", "and", "it", "s", "handlers" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/EventTrait.php#L97-L108
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.boot
public function boot() { if (!$this->app->routesAreCached()) { require __DIR__.'/routes.php'; } $this->app->make('designpond\newsletter\Http\Controllers\Frontend\NewsletterController'); $this->app->make('designpond\newsletter\Http\Controllers\Frontend\InscriptionController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\NewsletterController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\CampagneController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ContentController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\SendController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\SubscriberController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ImportController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ListController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\EmailController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ClipboardController'); $this->publishes([ __DIR__.'/database/migrations/' => database_path('migrations') ], 'migrations'); $this->publishes([ __DIR__ . '/database/seeds' => base_path('database/seeds') ], 'seeds'); $this->publishes([ __DIR__.'/config/newsletter.php' => config_path('newsletter.php'), ], 'config'); $this->publishes([ __DIR__.'/assets' => public_path('newsletter'), ], 'assets'); $this->loadViewsFrom(__DIR__.'/views', 'newsletter'); $this->publishes([ __DIR__.'/views' => resource_path('views/vendor/newsletter'), ], 'views'); $this->publishes([ __DIR__.'/views/Backend/layouts' => resource_path('views/vendor/newsletter/Backend/layouts'), ], 'layouts'); $this->app['validator']->extend('emailconfirmed', function ($attribute, $value, $parameters) { $email = \DB::table('newsletter_users')->where('email','=',$value)->first(); if($email) { return (!$email->activated_at ? false : true); } return false; }); $this->app['validator']->extend('mustBeEmpty', function ($attr, $value, $parameters) { if(!empty($attr)) return false; return true; }); }
php
public function boot() { if (!$this->app->routesAreCached()) { require __DIR__.'/routes.php'; } $this->app->make('designpond\newsletter\Http\Controllers\Frontend\NewsletterController'); $this->app->make('designpond\newsletter\Http\Controllers\Frontend\InscriptionController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\NewsletterController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\CampagneController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ContentController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\SendController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\SubscriberController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ImportController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ListController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\EmailController'); $this->app->make('designpond\newsletter\Http\Controllers\Backend\ClipboardController'); $this->publishes([ __DIR__.'/database/migrations/' => database_path('migrations') ], 'migrations'); $this->publishes([ __DIR__ . '/database/seeds' => base_path('database/seeds') ], 'seeds'); $this->publishes([ __DIR__.'/config/newsletter.php' => config_path('newsletter.php'), ], 'config'); $this->publishes([ __DIR__.'/assets' => public_path('newsletter'), ], 'assets'); $this->loadViewsFrom(__DIR__.'/views', 'newsletter'); $this->publishes([ __DIR__.'/views' => resource_path('views/vendor/newsletter'), ], 'views'); $this->publishes([ __DIR__.'/views/Backend/layouts' => resource_path('views/vendor/newsletter/Backend/layouts'), ], 'layouts'); $this->app['validator']->extend('emailconfirmed', function ($attribute, $value, $parameters) { $email = \DB::table('newsletter_users')->where('email','=',$value)->first(); if($email) { return (!$email->activated_at ? false : true); } return false; }); $this->app['validator']->extend('mustBeEmpty', function ($attr, $value, $parameters) { if(!empty($attr)) return false; return true; }); }
[ "public", "function", "boot", "(", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "routesAreCached", "(", ")", ")", "{", "require", "__DIR__", ".", "'/routes.php'", ";", "}", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Frontend\\NewsletterController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Frontend\\InscriptionController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\NewsletterController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\CampagneController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\ContentController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\SendController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\SubscriberController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\ImportController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\ListController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\EmailController'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'designpond\\newsletter\\Http\\Controllers\\Backend\\ClipboardController'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/database/migrations/'", "=>", "database_path", "(", "'migrations'", ")", "]", ",", "'migrations'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/database/seeds'", "=>", "base_path", "(", "'database/seeds'", ")", "]", ",", "'seeds'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/config/newsletter.php'", "=>", "config_path", "(", "'newsletter.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/assets'", "=>", "public_path", "(", "'newsletter'", ")", ",", "]", ",", "'assets'", ")", ";", "$", "this", "->", "loadViewsFrom", "(", "__DIR__", ".", "'/views'", ",", "'newsletter'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/views'", "=>", "resource_path", "(", "'views/vendor/newsletter'", ")", ",", "]", ",", "'views'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/views/Backend/layouts'", "=>", "resource_path", "(", "'views/vendor/newsletter/Backend/layouts'", ")", ",", "]", ",", "'layouts'", ")", ";", "$", "this", "->", "app", "[", "'validator'", "]", "->", "extend", "(", "'emailconfirmed'", ",", "function", "(", "$", "attribute", ",", "$", "value", ",", "$", "parameters", ")", "{", "$", "email", "=", "\\", "DB", "::", "table", "(", "'newsletter_users'", ")", "->", "where", "(", "'email'", ",", "'='", ",", "$", "value", ")", "->", "first", "(", ")", ";", "if", "(", "$", "email", ")", "{", "return", "(", "!", "$", "email", "->", "activated_at", "?", "false", ":", "true", ")", ";", "}", "return", "false", ";", "}", ")", ";", "$", "this", "->", "app", "[", "'validator'", "]", "->", "extend", "(", "'mustBeEmpty'", ",", "function", "(", "$", "attr", ",", "$", "value", ",", "$", "parameters", ")", "{", "if", "(", "!", "empty", "(", "$", "attr", ")", ")", "return", "false", ";", "return", "true", ";", "}", ")", ";", "}" ]
Perform post-registration booting of services. @return void
[ "Perform", "post", "-", "registration", "booting", "of", "services", "." ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L14-L77
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.register
public function register() { $this->mergeConfigFrom( __DIR__.'/config/newsletter.php', 'newsletter' ); // Custom Facade for CampagneWorker $this->app['newsworker'] = $this->app->share(function () { return $this->app->make('\designpond\newsletter\Newsletter\Worker\CampagneInterface'); }); $this->registerMailjetService(); $this->registerMailjetNewService(); $this->registerNewsletterService(); $this->registerContentService(); $this->registerTypesService(); $this->registerCampagneService(); $this->registerCampagneWorkerService(); $this->registerInscriptionService(); $this->registerSubscribeService(); $this->registerImportService(); $this->registerUploadService(); $this->registerListService(); $this->registerEmailService(); $this->registerClipboardService(); $this->registerSubscribeWorkerService(); }
php
public function register() { $this->mergeConfigFrom( __DIR__.'/config/newsletter.php', 'newsletter' ); // Custom Facade for CampagneWorker $this->app['newsworker'] = $this->app->share(function () { return $this->app->make('\designpond\newsletter\Newsletter\Worker\CampagneInterface'); }); $this->registerMailjetService(); $this->registerMailjetNewService(); $this->registerNewsletterService(); $this->registerContentService(); $this->registerTypesService(); $this->registerCampagneService(); $this->registerCampagneWorkerService(); $this->registerInscriptionService(); $this->registerSubscribeService(); $this->registerImportService(); $this->registerUploadService(); $this->registerListService(); $this->registerEmailService(); $this->registerClipboardService(); $this->registerSubscribeWorkerService(); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/config/newsletter.php'", ",", "'newsletter'", ")", ";", "// Custom Facade for CampagneWorker", "$", "this", "->", "app", "[", "'newsworker'", "]", "=", "$", "this", "->", "app", "->", "share", "(", "function", "(", ")", "{", "return", "$", "this", "->", "app", "->", "make", "(", "'\\designpond\\newsletter\\Newsletter\\Worker\\CampagneInterface'", ")", ";", "}", ")", ";", "$", "this", "->", "registerMailjetService", "(", ")", ";", "$", "this", "->", "registerMailjetNewService", "(", ")", ";", "$", "this", "->", "registerNewsletterService", "(", ")", ";", "$", "this", "->", "registerContentService", "(", ")", ";", "$", "this", "->", "registerTypesService", "(", ")", ";", "$", "this", "->", "registerCampagneService", "(", ")", ";", "$", "this", "->", "registerCampagneWorkerService", "(", ")", ";", "$", "this", "->", "registerInscriptionService", "(", ")", ";", "$", "this", "->", "registerSubscribeService", "(", ")", ";", "$", "this", "->", "registerImportService", "(", ")", ";", "$", "this", "->", "registerUploadService", "(", ")", ";", "$", "this", "->", "registerListService", "(", ")", ";", "$", "this", "->", "registerEmailService", "(", ")", ";", "$", "this", "->", "registerClipboardService", "(", ")", ";", "$", "this", "->", "registerSubscribeWorkerService", "(", ")", ";", "}" ]
Register any package services. @return void
[ "Register", "any", "package", "services", "." ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L84-L111
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerMailjetService
protected function registerMailjetService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\MailjetInterface', function() { return new \designpond\newsletter\Newsletter\Worker\MailjetWorker( new \designpond\newsletter\Newsletter\Service\Mailjet( config('newsletter.mailjet.api'),config('newsletter.mailjet.secret') ) ); }); }
php
protected function registerMailjetService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\MailjetInterface', function() { return new \designpond\newsletter\Newsletter\Worker\MailjetWorker( new \designpond\newsletter\Newsletter\Service\Mailjet( config('newsletter.mailjet.api'),config('newsletter.mailjet.secret') ) ); }); }
[ "protected", "function", "registerMailjetService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Worker\\MailjetInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "MailjetWorker", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Service", "\\", "Mailjet", "(", "config", "(", "'newsletter.mailjet.api'", ")", ",", "config", "(", "'newsletter.mailjet.secret'", ")", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter Content service
[ "Newsletter", "Content", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L116-L126
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerMailjetNewService
protected function registerMailjetNewService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface', function() { return new \designpond\newsletter\Newsletter\Worker\MailjetService( new \Mailjet\Client(config('newsletter.mailjet.api'),config('newsletter.mailjet.secret')), new \Mailjet\Resources() ); }); }
php
protected function registerMailjetNewService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface', function() { return new \designpond\newsletter\Newsletter\Worker\MailjetService( new \Mailjet\Client(config('newsletter.mailjet.api'),config('newsletter.mailjet.secret')), new \Mailjet\Resources() ); }); }
[ "protected", "function", "registerMailjetNewService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Worker\\MailjetServiceInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "MailjetService", "(", "new", "\\", "Mailjet", "\\", "Client", "(", "config", "(", "'newsletter.mailjet.api'", ")", ",", "config", "(", "'newsletter.mailjet.secret'", ")", ")", ",", "new", "\\", "Mailjet", "\\", "Resources", "(", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter Content service
[ "Newsletter", "Content", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L131-L140
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerNewsletterService
protected function registerNewsletterService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter ); }); }
php
protected function registerNewsletterService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter ); }); }
[ "protected", "function", "registerNewsletterService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter", ")", ";", "}", ")", ";", "}" ]
Newsletter Content service
[ "Newsletter", "Content", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L145-L151
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerContentService
protected function registerContentService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterContentInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterContentEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_contents ); }); }
php
protected function registerContentService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterContentInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterContentEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_contents ); }); }
[ "protected", "function", "registerContentService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterContentInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterContentEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_contents", ")", ";", "}", ")", ";", "}" ]
Newsletter service
[ "Newsletter", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L156-L162
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerTypesService
protected function registerTypesService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterTypesInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterTypesEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_types ); }); }
php
protected function registerTypesService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterTypesInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterTypesEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_types ); }); }
[ "protected", "function", "registerTypesService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterTypesInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterTypesEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_types", ")", ";", "}", ")", ";", "}" ]
Newsletter Types service
[ "Newsletter", "Types", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L167-L173
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerCampagneService
protected function registerCampagneService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterCampagneEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_campagnes ); }); }
php
protected function registerCampagneService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterCampagneEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_campagnes ); }); }
[ "protected", "function", "registerCampagneService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterCampagneInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterCampagneEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_campagnes", ")", ";", "}", ")", ";", "}" ]
Newsletter Types service
[ "Newsletter", "Types", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L179-L185
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerCampagneWorkerService
protected function registerCampagneWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\CampagneInterface', function() { return new \designpond\newsletter\Newsletter\Worker\CampagneWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterContentInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface') ); }); }
php
protected function registerCampagneWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\CampagneInterface', function() { return new \designpond\newsletter\Newsletter\Worker\CampagneWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterContentInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface') ); }); }
[ "protected", "function", "registerCampagneWorkerService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Worker\\CampagneInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "CampagneWorker", "(", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterContentInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterCampagneInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterUserInterface'", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter Campagne worker
[ "Newsletter", "Campagne", "worker" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L190-L201
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerInscriptionService
protected function registerInscriptionService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterUserEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_users ); }); }
php
protected function registerInscriptionService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterUserEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_users ); }); }
[ "protected", "function", "registerInscriptionService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterUserInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterUserEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_users", ")", ";", "}", ")", ";", "}" ]
Newsletter user abo service
[ "Newsletter", "user", "abo", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L207-L213
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerSubscribeService
protected function registerSubscribeService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterSubscriptionInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterSubscriptionEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_subscriptions ); }); }
php
protected function registerSubscribeService(){ $this->app->bind('designpond\newsletter\Newsletter\Repo\NewsletterSubscriptionInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterSubscriptionEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_subscriptions ); }); }
[ "protected", "function", "registerSubscribeService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterSubscriptionInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterSubscriptionEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_subscriptions", ")", ";", "}", ")", ";", "}" ]
Newsletter user abo service
[ "Newsletter", "user", "abo", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L218-L226
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerImportService
protected function registerImportService(){ $this->app->singleton('designpond\newsletter\Newsletter\Worker\ImportWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\ImportWorker( \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('Maatwebsite\Excel\Excel'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Worker\CampagneInterface'), \App::make('designpond\newsletter\Newsletter\Service\UploadInterface') ); }); }
php
protected function registerImportService(){ $this->app->singleton('designpond\newsletter\Newsletter\Worker\ImportWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\ImportWorker( \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('Maatwebsite\Excel\Excel'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterCampagneInterface'), \App::make('designpond\newsletter\Newsletter\Worker\CampagneInterface'), \App::make('designpond\newsletter\Newsletter\Service\UploadInterface') ); }); }
[ "protected", "function", "registerImportService", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'designpond\\newsletter\\Newsletter\\Worker\\ImportWorkerInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "ImportWorker", "(", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Worker\\MailjetServiceInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterUserInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterInterface'", ")", ",", "\\", "App", "::", "make", "(", "'Maatwebsite\\Excel\\Excel'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterCampagneInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Worker\\CampagneInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Service\\UploadInterface'", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter Import worker
[ "Newsletter", "Import", "worker" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L231-L245
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerListService
protected function registerListService(){ $this->app->singleton('designpond\newsletter\Newsletter\Repo\NewsletterListInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterListEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_lists() ); }); }
php
protected function registerListService(){ $this->app->singleton('designpond\newsletter\Newsletter\Repo\NewsletterListInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterListEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_lists() ); }); }
[ "protected", "function", "registerListService", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterListInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterListEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_lists", "(", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter list
[ "Newsletter", "list" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L261-L267
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerEmailService
protected function registerEmailService(){ $this->app->singleton('designpond\newsletter\Newsletter\Repo\NewsletterEmailInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterEmailEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_emails() ); }); }
php
protected function registerEmailService(){ $this->app->singleton('designpond\newsletter\Newsletter\Repo\NewsletterEmailInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterEmailEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_emails() ); }); }
[ "protected", "function", "registerEmailService", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterEmailInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterEmailEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_emails", "(", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter Email
[ "Newsletter", "Email" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L272-L278
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerClipboardService
protected function registerClipboardService(){ $this->app->singleton('designpond\newsletter\Newsletter\Repo\NewsletterClipboardInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterClipboardEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_clipboards() ); }); }
php
protected function registerClipboardService(){ $this->app->singleton('designpond\newsletter\Newsletter\Repo\NewsletterClipboardInterface', function() { return new \designpond\newsletter\Newsletter\Repo\NewsletterClipboardEloquent( new \designpond\newsletter\Newsletter\Entities\Newsletter_clipboards() ); }); }
[ "protected", "function", "registerClipboardService", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterClipboardInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Repo", "\\", "NewsletterClipboardEloquent", "(", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Entities", "\\", "Newsletter_clipboards", "(", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter clipboard
[ "Newsletter", "clipboard" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L283-L289
DesignPond/newsletter
src/newsletterServiceProvider.php
newsletterServiceProvider.registerSubscribeWorkerService
protected function registerSubscribeWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\SubscriptionWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\SubscriptionWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface') ); }); }
php
protected function registerSubscribeWorkerService(){ $this->app->bind('designpond\newsletter\Newsletter\Worker\SubscriptionWorkerInterface', function() { return new \designpond\newsletter\Newsletter\Worker\SubscriptionWorker( \App::make('designpond\newsletter\Newsletter\Repo\NewsletterInterface'), \App::make('designpond\newsletter\Newsletter\Repo\NewsletterUserInterface'), \App::make('designpond\newsletter\Newsletter\Worker\MailjetServiceInterface') ); }); }
[ "protected", "function", "registerSubscribeWorkerService", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'designpond\\newsletter\\Newsletter\\Worker\\SubscriptionWorkerInterface'", ",", "function", "(", ")", "{", "return", "new", "\\", "designpond", "\\", "newsletter", "\\", "Newsletter", "\\", "Worker", "\\", "SubscriptionWorker", "(", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Repo\\NewsletterUserInterface'", ")", ",", "\\", "App", "::", "make", "(", "'designpond\\newsletter\\Newsletter\\Worker\\MailjetServiceInterface'", ")", ")", ";", "}", ")", ";", "}" ]
Newsletter subscriber service
[ "Newsletter", "subscriber", "service" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/newsletterServiceProvider.php#L294-L304
php-lug/lug
src/Bundle/GridBundle/Batch/Batcher.php
Batcher.batch
public function batch(GridInterface $grid, FormInterface $form) { if ($form->isValid()) { $this->batcher->batch( $grid, $form->get('type')->getData(), $form->get('value')->getData() ); } }
php
public function batch(GridInterface $grid, FormInterface $form) { if ($form->isValid()) { $this->batcher->batch( $grid, $form->get('type')->getData(), $form->get('value')->getData() ); } }
[ "public", "function", "batch", "(", "GridInterface", "$", "grid", ",", "FormInterface", "$", "form", ")", "{", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "this", "->", "batcher", "->", "batch", "(", "$", "grid", ",", "$", "form", "->", "get", "(", "'type'", ")", "->", "getData", "(", ")", ",", "$", "form", "->", "get", "(", "'value'", ")", "->", "getData", "(", ")", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Batch/Batcher.php#L39-L48
oroinc/OroLayoutComponent
Templating/Helper/LayoutHelper.php
LayoutHelper.parentBlockWidget
public function parentBlockWidget(BlockView $view, array $variables = []) { return $this->renderer->searchAndRenderBlock($view, 'widget', $variables, true); }
php
public function parentBlockWidget(BlockView $view, array $variables = []) { return $this->renderer->searchAndRenderBlock($view, 'widget', $variables, true); }
[ "public", "function", "parentBlockWidget", "(", "BlockView", "$", "view", ",", "array", "$", "variables", "=", "[", "]", ")", "{", "return", "$", "this", "->", "renderer", "->", "searchAndRenderBlock", "(", "$", "view", ",", "'widget'", ",", "$", "variables", ",", "true", ")", ";", "}" ]
Renders the parent block widget defined in other resources on all levels of block prefix hierarchy @param BlockView $view @param array $variables @return string
[ "Renders", "the", "parent", "block", "widget", "defined", "in", "other", "resources", "on", "all", "levels", "of", "block", "prefix", "hierarchy" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Templating/Helper/LayoutHelper.php#L98-L101
simbiosis-group/yii2-helper
widgets/ModalButton.php
ModalButton.run
public function run() { $options = array_merge([ 'value' => $this->url, 'data-modal-id' => $this->modalId, ], $this->options); ModalButtonAsset::register(Yii::$app->controller->getView()); Html::addCssClass($options, ['class' => 'show-modal-button']); if ('button' == $this->type) { return Html::button($this->label, $options); } if ('link' == $this->type) { return Html::a($this->label, false, $options); } }
php
public function run() { $options = array_merge([ 'value' => $this->url, 'data-modal-id' => $this->modalId, ], $this->options); ModalButtonAsset::register(Yii::$app->controller->getView()); Html::addCssClass($options, ['class' => 'show-modal-button']); if ('button' == $this->type) { return Html::button($this->label, $options); } if ('link' == $this->type) { return Html::a($this->label, false, $options); } }
[ "public", "function", "run", "(", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'value'", "=>", "$", "this", "->", "url", ",", "'data-modal-id'", "=>", "$", "this", "->", "modalId", ",", "]", ",", "$", "this", "->", "options", ")", ";", "ModalButtonAsset", "::", "register", "(", "Yii", "::", "$", "app", "->", "controller", "->", "getView", "(", ")", ")", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "[", "'class'", "=>", "'show-modal-button'", "]", ")", ";", "if", "(", "'button'", "==", "$", "this", "->", "type", ")", "{", "return", "Html", "::", "button", "(", "$", "this", "->", "label", ",", "$", "options", ")", ";", "}", "if", "(", "'link'", "==", "$", "this", "->", "type", ")", "{", "return", "Html", "::", "a", "(", "$", "this", "->", "label", ",", "false", ",", "$", "options", ")", ";", "}", "}" ]
Renders the widget.
[ "Renders", "the", "widget", "." ]
train
https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/widgets/ModalButton.php#L51-L68
dstuecken/notify
src/Handler/NotifySendHandler.php
NotifySendHandler.handle
public function handle(NotificationInterface $notification, $level) { if ($notification instanceof TitleAwareInterface) { $command = $this->shellCommand . ' ' . escapeshellarg($notification->message()) . ' ' . escapeshellarg($notification->title()); } else { $command = $this->shellCommand . ' ' . escapeshellarg($notification->message()); } if ($notification instanceof AttributeAwareInterface) { $expiry = (int) $notification->attribute('expiry'); if ($expiry) { $command .= "-t " . $expiry . " "; } $icon = $notification->attribute('icon'); if ($expiry) { $command .= "-i " . $icon . " "; } } $command .= "-u " . $this->levelMapping[$level] . " "; exec($command . ' > /dev/null', $output, $code); return $code === 0; }
php
public function handle(NotificationInterface $notification, $level) { if ($notification instanceof TitleAwareInterface) { $command = $this->shellCommand . ' ' . escapeshellarg($notification->message()) . ' ' . escapeshellarg($notification->title()); } else { $command = $this->shellCommand . ' ' . escapeshellarg($notification->message()); } if ($notification instanceof AttributeAwareInterface) { $expiry = (int) $notification->attribute('expiry'); if ($expiry) { $command .= "-t " . $expiry . " "; } $icon = $notification->attribute('icon'); if ($expiry) { $command .= "-i " . $icon . " "; } } $command .= "-u " . $this->levelMapping[$level] . " "; exec($command . ' > /dev/null', $output, $code); return $code === 0; }
[ "public", "function", "handle", "(", "NotificationInterface", "$", "notification", ",", "$", "level", ")", "{", "if", "(", "$", "notification", "instanceof", "TitleAwareInterface", ")", "{", "$", "command", "=", "$", "this", "->", "shellCommand", ".", "' '", ".", "escapeshellarg", "(", "$", "notification", "->", "message", "(", ")", ")", ".", "' '", ".", "escapeshellarg", "(", "$", "notification", "->", "title", "(", ")", ")", ";", "}", "else", "{", "$", "command", "=", "$", "this", "->", "shellCommand", ".", "' '", ".", "escapeshellarg", "(", "$", "notification", "->", "message", "(", ")", ")", ";", "}", "if", "(", "$", "notification", "instanceof", "AttributeAwareInterface", ")", "{", "$", "expiry", "=", "(", "int", ")", "$", "notification", "->", "attribute", "(", "'expiry'", ")", ";", "if", "(", "$", "expiry", ")", "{", "$", "command", ".=", "\"-t \"", ".", "$", "expiry", ".", "\" \"", ";", "}", "$", "icon", "=", "$", "notification", "->", "attribute", "(", "'icon'", ")", ";", "if", "(", "$", "expiry", ")", "{", "$", "command", ".=", "\"-i \"", ".", "$", "icon", ".", "\" \"", ";", "}", "}", "$", "command", ".=", "\"-u \"", ".", "$", "this", "->", "levelMapping", "[", "$", "level", "]", ".", "\" \"", ";", "exec", "(", "$", "command", ".", "' > /dev/null'", ",", "$", "output", ",", "$", "code", ")", ";", "return", "$", "code", "===", "0", ";", "}" ]
Handle a notification @return bool
[ "Handle", "a", "notification" ]
train
https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/Handler/NotifySendHandler.php#L48-L81
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.formatLog
public function formatLog(array $logMessage) { extract($logMessage); $level = strtoupper($level); $message = $this->applyContext($message, $context); $timestamp = date($this->dateTimeFormat, $timestamp); $exception = $this->getExceptionTrace($context); $log = str_replace(self::FORMAT_TIMESTAMP, $timestamp, $this->logFormat); $log = str_replace(self::FORMAT_LEVEL, $level, $log); $log = str_replace(self::FORMAT_MESSAGE, $message, $log); $log = str_replace(self::FORMAT_EXCEPTION, $exception, $log); return $log; }
php
public function formatLog(array $logMessage) { extract($logMessage); $level = strtoupper($level); $message = $this->applyContext($message, $context); $timestamp = date($this->dateTimeFormat, $timestamp); $exception = $this->getExceptionTrace($context); $log = str_replace(self::FORMAT_TIMESTAMP, $timestamp, $this->logFormat); $log = str_replace(self::FORMAT_LEVEL, $level, $log); $log = str_replace(self::FORMAT_MESSAGE, $message, $log); $log = str_replace(self::FORMAT_EXCEPTION, $exception, $log); return $log; }
[ "public", "function", "formatLog", "(", "array", "$", "logMessage", ")", "{", "extract", "(", "$", "logMessage", ")", ";", "$", "level", "=", "strtoupper", "(", "$", "level", ")", ";", "$", "message", "=", "$", "this", "->", "applyContext", "(", "$", "message", ",", "$", "context", ")", ";", "$", "timestamp", "=", "date", "(", "$", "this", "->", "dateTimeFormat", ",", "$", "timestamp", ")", ";", "$", "exception", "=", "$", "this", "->", "getExceptionTrace", "(", "$", "context", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_TIMESTAMP", ",", "$", "timestamp", ",", "$", "this", "->", "logFormat", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_LEVEL", ",", "$", "level", ",", "$", "log", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_MESSAGE", ",", "$", "message", ",", "$", "log", ")", ";", "$", "log", "=", "str_replace", "(", "self", "::", "FORMAT_EXCEPTION", ",", "$", "exception", ",", "$", "log", ")", ";", "return", "$", "log", ";", "}" ]
Format log message @param array $logMessage An array with key `timestamp`, 'level', 'message', and 'context' @return string
[ "Format", "log", "message" ]
train
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L64-L78
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.applyContext
protected function applyContext($message, array $context = array()) { foreach ($context as $key => $value) { $key = trim($key, "{}"); if ($key != 'exception') { $message = $this->replaceContext($message, $key, $value); } } return $message; }
php
protected function applyContext($message, array $context = array()) { foreach ($context as $key => $value) { $key = trim($key, "{}"); if ($key != 'exception') { $message = $this->replaceContext($message, $key, $value); } } return $message; }
[ "protected", "function", "applyContext", "(", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "context", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "trim", "(", "$", "key", ",", "\"{}\"", ")", ";", "if", "(", "$", "key", "!=", "'exception'", ")", "{", "$", "message", "=", "$", "this", "->", "replaceContext", "(", "$", "message", ",", "$", "key", ",", "$", "value", ")", ";", "}", "}", "return", "$", "message", ";", "}" ]
Apply context into log message. @param string $message @param array $context [optional] @return string
[ "Apply", "context", "into", "log", "message", "." ]
train
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L88-L98
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.replaceContext
protected function replaceContext($message, string $key, $context) { $strContext = ''; if (is_object($context)) { if (method_exists($context, '__toString')) { $strContext = call_user_func([$context, '__toString']); } else { $strContext = var_export($context, true); } } else { $strContext = $context; } return str_replace('{'.$key.'}', $strContext, $message); }
php
protected function replaceContext($message, string $key, $context) { $strContext = ''; if (is_object($context)) { if (method_exists($context, '__toString')) { $strContext = call_user_func([$context, '__toString']); } else { $strContext = var_export($context, true); } } else { $strContext = $context; } return str_replace('{'.$key.'}', $strContext, $message); }
[ "protected", "function", "replaceContext", "(", "$", "message", ",", "string", "$", "key", ",", "$", "context", ")", "{", "$", "strContext", "=", "''", ";", "if", "(", "is_object", "(", "$", "context", ")", ")", "{", "if", "(", "method_exists", "(", "$", "context", ",", "'__toString'", ")", ")", "{", "$", "strContext", "=", "call_user_func", "(", "[", "$", "context", ",", "'__toString'", "]", ")", ";", "}", "else", "{", "$", "strContext", "=", "var_export", "(", "$", "context", ",", "true", ")", ";", "}", "}", "else", "{", "$", "strContext", "=", "$", "context", ";", "}", "return", "str_replace", "(", "'{'", ".", "$", "key", ".", "'}'", ",", "$", "strContext", ",", "$", "message", ")", ";", "}" ]
Replace context pattern in the message with related context. @param string $message Log message @param string $key Context pattern to be replaced @param mixed $context Related context to replace $key @return string $message with pattern '{$key}' replaced by $context
[ "Replace", "context", "pattern", "in", "the", "message", "with", "related", "context", "." ]
train
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L109-L123
kenphp/ken
src/Log/LogFormatter.php
LogFormatter.getExceptionTrace
protected function getExceptionTrace(array $context) { if (array_key_exists('exception', $context)) { if ($context['exception'] instanceof \Exception) { $strException = $context['exception']->getTraceAsString(); return $strException; } } return ''; }
php
protected function getExceptionTrace(array $context) { if (array_key_exists('exception', $context)) { if ($context['exception'] instanceof \Exception) { $strException = $context['exception']->getTraceAsString(); return $strException; } } return ''; }
[ "protected", "function", "getExceptionTrace", "(", "array", "$", "context", ")", "{", "if", "(", "array_key_exists", "(", "'exception'", ",", "$", "context", ")", ")", "{", "if", "(", "$", "context", "[", "'exception'", "]", "instanceof", "\\", "Exception", ")", "{", "$", "strException", "=", "$", "context", "[", "'exception'", "]", "->", "getTraceAsString", "(", ")", ";", "return", "$", "strException", ";", "}", "}", "return", "''", ";", "}" ]
Get Exception trace if found in the context. @param array $context
[ "Get", "Exception", "trace", "if", "found", "in", "the", "context", "." ]
train
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Log/LogFormatter.php#L130-L141
InfiniteSoftware/ISEcommpayPayum
Action/ConvertPaymentAction.php
ConvertPaymentAction.execute
public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var PaymentInterface $payment */ $payment = $request->getSource(); /** @var OrderInterface $order */ $params = [ 'payment_id' => $payment->getNumber(), 'payment_amount' => $payment->getTotalAmount(), 'payment_currency' => $payment->getCurrencyCode(), 'project_id' => $this->api['projectId'], 'customer_id' => $payment->getClientId(), ]; $request->setResult($params); }
php
public function execute($request) { RequestNotSupportedException::assertSupports($this, $request); /** @var PaymentInterface $payment */ $payment = $request->getSource(); /** @var OrderInterface $order */ $params = [ 'payment_id' => $payment->getNumber(), 'payment_amount' => $payment->getTotalAmount(), 'payment_currency' => $payment->getCurrencyCode(), 'project_id' => $this->api['projectId'], 'customer_id' => $payment->getClientId(), ]; $request->setResult($params); }
[ "public", "function", "execute", "(", "$", "request", ")", "{", "RequestNotSupportedException", "::", "assertSupports", "(", "$", "this", ",", "$", "request", ")", ";", "/** @var PaymentInterface $payment */", "$", "payment", "=", "$", "request", "->", "getSource", "(", ")", ";", "/** @var OrderInterface $order */", "$", "params", "=", "[", "'payment_id'", "=>", "$", "payment", "->", "getNumber", "(", ")", ",", "'payment_amount'", "=>", "$", "payment", "->", "getTotalAmount", "(", ")", ",", "'payment_currency'", "=>", "$", "payment", "->", "getCurrencyCode", "(", ")", ",", "'project_id'", "=>", "$", "this", "->", "api", "[", "'projectId'", "]", ",", "'customer_id'", "=>", "$", "payment", "->", "getClientId", "(", ")", ",", "]", ";", "$", "request", "->", "setResult", "(", "$", "params", ")", ";", "}" ]
{@inheritDoc} @param Convert $request
[ "{", "@inheritDoc", "}" ]
train
https://github.com/InfiniteSoftware/ISEcommpayPayum/blob/44a073e3d885d9007aa54d6ff13aea93a9e52e7c/Action/ConvertPaymentAction.php#L34-L50
scherersoftware/cake-monitor
src/Lib/MonitorHandler.php
MonitorHandler._validateConfig
protected function _validateConfig() { foreach ($this->_config as $key => $value) { if (!isset($value)) { throw new \Exception('Incomplete configuration: ' . $key, 1); } } }
php
protected function _validateConfig() { foreach ($this->_config as $key => $value) { if (!isset($value)) { throw new \Exception('Incomplete configuration: ' . $key, 1); } } }
[ "protected", "function", "_validateConfig", "(", ")", "{", "foreach", "(", "$", "this", "->", "_config", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Incomplete configuration: '", ".", "$", "key", ",", "1", ")", ";", "}", "}", "}" ]
Validates Config @throws \Exception if configuration is incomplete @return void
[ "Validates", "Config" ]
train
https://github.com/scherersoftware/cake-monitor/blob/dbe07a1aac41b3db15e631d9e59cf26214bf6938/src/Lib/MonitorHandler.php#L61-L68
scherersoftware/cake-monitor
src/Lib/MonitorHandler.php
MonitorHandler.handleChecks
public function handleChecks() { $errors = []; foreach ($this->_config['checks'] as $name => $check) { if (empty($check)) { continue; } $result = $check['callback'](); if ($result !== true) { $errors[] = $name . ': <br>' . $check['error'] . ' - ' . $result; } } if (!empty($errors)) { $this->response->statusCode(500); echo date('Y-m-d H:i:s') . ': ' . $this->_config['projectName'] . ' - ' . $this->_config['serverDescription'] . ' - Status Code: ' . $this->response->statusCode() . '<br><br> '; foreach ($errors as $error) { echo $error . '<br><br>'; } die; } $this->_config['onSuccess'](); die; }
php
public function handleChecks() { $errors = []; foreach ($this->_config['checks'] as $name => $check) { if (empty($check)) { continue; } $result = $check['callback'](); if ($result !== true) { $errors[] = $name . ': <br>' . $check['error'] . ' - ' . $result; } } if (!empty($errors)) { $this->response->statusCode(500); echo date('Y-m-d H:i:s') . ': ' . $this->_config['projectName'] . ' - ' . $this->_config['serverDescription'] . ' - Status Code: ' . $this->response->statusCode() . '<br><br> '; foreach ($errors as $error) { echo $error . '<br><br>'; } die; } $this->_config['onSuccess'](); die; }
[ "public", "function", "handleChecks", "(", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_config", "[", "'checks'", "]", "as", "$", "name", "=>", "$", "check", ")", "{", "if", "(", "empty", "(", "$", "check", ")", ")", "{", "continue", ";", "}", "$", "result", "=", "$", "check", "[", "'callback'", "]", "(", ")", ";", "if", "(", "$", "result", "!==", "true", ")", "{", "$", "errors", "[", "]", "=", "$", "name", ".", "': <br>'", ".", "$", "check", "[", "'error'", "]", ".", "' - '", ".", "$", "result", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "errors", ")", ")", "{", "$", "this", "->", "response", "->", "statusCode", "(", "500", ")", ";", "echo", "date", "(", "'Y-m-d H:i:s'", ")", ".", "': '", ".", "$", "this", "->", "_config", "[", "'projectName'", "]", ".", "' - '", ".", "$", "this", "->", "_config", "[", "'serverDescription'", "]", ".", "' - Status Code: '", ".", "$", "this", "->", "response", "->", "statusCode", "(", ")", ".", "'<br><br> '", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "echo", "$", "error", ".", "'<br><br>'", ";", "}", "die", ";", "}", "$", "this", "->", "_config", "[", "'onSuccess'", "]", "(", ")", ";", "die", ";", "}" ]
Handle all defined checks @return void
[ "Handle", "all", "defined", "checks" ]
train
https://github.com/scherersoftware/cake-monitor/blob/dbe07a1aac41b3db15e631d9e59cf26214bf6938/src/Lib/MonitorHandler.php#L88-L112
PayBreak/foundation
src/AbstractEntity.php
AbstractEntity.make
public static function make(array $components) { $entity = new static(); foreach ($components as $k => $v) { if ($entity->isPropertyAllowed($k)) { $entity->{'set' . NameHelper::snakeToCamel($k)}($v); } } return $entity; }
php
public static function make(array $components) { $entity = new static(); foreach ($components as $k => $v) { if ($entity->isPropertyAllowed($k)) { $entity->{'set' . NameHelper::snakeToCamel($k)}($v); } } return $entity; }
[ "public", "static", "function", "make", "(", "array", "$", "components", ")", "{", "$", "entity", "=", "new", "static", "(", ")", ";", "foreach", "(", "$", "components", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "entity", "->", "isPropertyAllowed", "(", "$", "k", ")", ")", "{", "$", "entity", "->", "{", "'set'", ".", "NameHelper", "::", "snakeToCamel", "(", "$", "k", ")", "}", "(", "$", "v", ")", ";", "}", "}", "return", "$", "entity", ";", "}" ]
Make Entity @author WN @param array $components @return static
[ "Make", "Entity" ]
train
https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/AbstractEntity.php#L51-L62
ShaoZeMing/laravel-merchant
src/Controllers/PermissionController.php
PermissionController.create
public function create() { return Merchant::content(function (Content $content) { $content->header(trans('merchant.permissions')); $content->description(trans('merchant.create')); $content->body($this->form()); }); }
php
public function create() { return Merchant::content(function (Content $content) { $content->header(trans('merchant.permissions')); $content->description(trans('merchant.create')); $content->body($this->form()); }); }
[ "public", "function", "create", "(", ")", "{", "return", "Merchant", "::", "content", "(", "function", "(", "Content", "$", "content", ")", "{", "$", "content", "->", "header", "(", "trans", "(", "'merchant.permissions'", ")", ")", ";", "$", "content", "->", "description", "(", "trans", "(", "'merchant.create'", ")", ")", ";", "$", "content", "->", "body", "(", "$", "this", "->", "form", "(", ")", ")", ";", "}", ")", ";", "}" ]
Create interface. @return Content
[ "Create", "interface", "." ]
train
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Controllers/PermissionController.php#L52-L59
windwork/wf-db
lib/Finder.php
Finder.fetchAll
public function fetchAll($offset = 0, $rows = 0) { $opts = $this->options; if ($offset || $rows) { $offset = (int)$offset; $rows = (int)$rows; if ($rows) { $opts['limit'] = "{$offset},{$rows}"; } else { $opts['limit'] = "{$offset}"; } } $sql = QueryBuilder::optionsToSql($opts); $all = $this->getDb()->getAll($sql); return $all; }
php
public function fetchAll($offset = 0, $rows = 0) { $opts = $this->options; if ($offset || $rows) { $offset = (int)$offset; $rows = (int)$rows; if ($rows) { $opts['limit'] = "{$offset},{$rows}"; } else { $opts['limit'] = "{$offset}"; } } $sql = QueryBuilder::optionsToSql($opts); $all = $this->getDb()->getAll($sql); return $all; }
[ "public", "function", "fetchAll", "(", "$", "offset", "=", "0", ",", "$", "rows", "=", "0", ")", "{", "$", "opts", "=", "$", "this", "->", "options", ";", "if", "(", "$", "offset", "||", "$", "rows", ")", "{", "$", "offset", "=", "(", "int", ")", "$", "offset", ";", "$", "rows", "=", "(", "int", ")", "$", "rows", ";", "if", "(", "$", "rows", ")", "{", "$", "opts", "[", "'limit'", "]", "=", "\"{$offset},{$rows}\"", ";", "}", "else", "{", "$", "opts", "[", "'limit'", "]", "=", "\"{$offset}\"", ";", "}", "}", "$", "sql", "=", "QueryBuilder", "::", "optionsToSql", "(", "$", "opts", ")", ";", "$", "all", "=", "$", "this", "->", "getDb", "(", ")", "->", "getAll", "(", "$", "sql", ")", ";", "return", "$", "all", ";", "}" ]
获取符合条件的所有记录 @param int $offset = 0 开始查询记录下标,最小为0 @param int $rows = 0 返回记录数,为0则忽略offset和rows都使用默认值 @return array
[ "获取符合条件的所有记录" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L74-L91
windwork/wf-db
lib/Finder.php
Finder.fetchRow
public function fetchRow() { $opts = $this->options; $opts['limit'] = 1; $sql = QueryBuilder::optionsToSql($opts); $row = $this->getDb()->getRow($sql); return $row; }
php
public function fetchRow() { $opts = $this->options; $opts['limit'] = 1; $sql = QueryBuilder::optionsToSql($opts); $row = $this->getDb()->getRow($sql); return $row; }
[ "public", "function", "fetchRow", "(", ")", "{", "$", "opts", "=", "$", "this", "->", "options", ";", "$", "opts", "[", "'limit'", "]", "=", "1", ";", "$", "sql", "=", "QueryBuilder", "::", "optionsToSql", "(", "$", "opts", ")", ";", "$", "row", "=", "$", "this", "->", "getDb", "(", ")", "->", "getRow", "(", "$", "sql", ")", ";", "return", "$", "row", ";", "}" ]
获取一行记录,返回关联数组格式 @return array
[ "获取一行记录,返回关联数组格式" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L98-L107
windwork/wf-db
lib/Finder.php
Finder.fetchColumn
public function fetchColumn($field = '') { $opts = $this->options; if ($field) { $opts['field'] = $field; } $sql = QueryBuilder::optionsToSql($opts); $colValue = $this->getDb()->getColumn($sql); return $colValue; }
php
public function fetchColumn($field = '') { $opts = $this->options; if ($field) { $opts['field'] = $field; } $sql = QueryBuilder::optionsToSql($opts); $colValue = $this->getDb()->getColumn($sql); return $colValue; }
[ "public", "function", "fetchColumn", "(", "$", "field", "=", "''", ")", "{", "$", "opts", "=", "$", "this", "->", "options", ";", "if", "(", "$", "field", ")", "{", "$", "opts", "[", "'field'", "]", "=", "$", "field", ";", "}", "$", "sql", "=", "QueryBuilder", "::", "optionsToSql", "(", "$", "opts", ")", ";", "$", "colValue", "=", "$", "this", "->", "getDb", "(", ")", "->", "getColumn", "(", "$", "sql", ")", ";", "return", "$", "colValue", ";", "}" ]
获取字段值 @param string $field = '' @return string
[ "获取字段值" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L114-L126
windwork/wf-db
lib/Finder.php
Finder.fetchCount
public function fetchCount($field = '') { $opts = $this->options; if ($field) { $opts['field'] = $field; } else { $opts['field'] = '*'; } $sql = \wf\db\QueryBuilder::optionsToCountSql($opts); $num = $this->getDb()->getColumn($sql); return $num; }
php
public function fetchCount($field = '') { $opts = $this->options; if ($field) { $opts['field'] = $field; } else { $opts['field'] = '*'; } $sql = \wf\db\QueryBuilder::optionsToCountSql($opts); $num = $this->getDb()->getColumn($sql); return $num; }
[ "public", "function", "fetchCount", "(", "$", "field", "=", "''", ")", "{", "$", "opts", "=", "$", "this", "->", "options", ";", "if", "(", "$", "field", ")", "{", "$", "opts", "[", "'field'", "]", "=", "$", "field", ";", "}", "else", "{", "$", "opts", "[", "'field'", "]", "=", "'*'", ";", "}", "$", "sql", "=", "\\", "wf", "\\", "db", "\\", "QueryBuilder", "::", "optionsToCountSql", "(", "$", "opts", ")", ";", "$", "num", "=", "$", "this", "->", "getDb", "(", ")", "->", "getColumn", "(", "$", "sql", ")", ";", "return", "$", "num", ";", "}" ]
获取记录数 @param string $field = '' @return int
[ "获取记录数" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L133-L148
windwork/wf-db
lib/Finder.php
Finder.join
public function join($table, $onFieldA, $onFieldB, $joinType = 'LEFT') { $joinType = strtoupper(trim($joinType)); if (!in_array($joinType, ['LEFT', 'RIGHT', 'INNER', 'CROSS'])) { throw new \Exception('$joinType 不正确,只允许是LEFT|RIGHT|INNER|CROSS'); } $this->options['join'][] = [$table, $onFieldA, $onFieldB, $joinType]; return $this; }
php
public function join($table, $onFieldA, $onFieldB, $joinType = 'LEFT') { $joinType = strtoupper(trim($joinType)); if (!in_array($joinType, ['LEFT', 'RIGHT', 'INNER', 'CROSS'])) { throw new \Exception('$joinType 不正确,只允许是LEFT|RIGHT|INNER|CROSS'); } $this->options['join'][] = [$table, $onFieldA, $onFieldB, $joinType]; return $this; }
[ "public", "function", "join", "(", "$", "table", ",", "$", "onFieldA", ",", "$", "onFieldB", ",", "$", "joinType", "=", "'LEFT'", ")", "{", "$", "joinType", "=", "strtoupper", "(", "trim", "(", "$", "joinType", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "joinType", ",", "[", "'LEFT'", ",", "'RIGHT'", ",", "'INNER'", ",", "'CROSS'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'$joinType 不正确,只允许是LEFT|RIGHT|INNER|CROSS');", "", "", "}", "$", "this", "->", "options", "[", "'join'", "]", "[", "]", "=", "[", "$", "table", ",", "$", "onFieldA", ",", "$", "onFieldB", ",", "$", "joinType", "]", ";", "return", "$", "this", ";", "}" ]
连接表, 如:RIGHT JOIN myTable tb ON tb.a = xx.filed1 则参数为->join('myTable tb', 'tb.a', 'xx.filed1', 'RIGHT') @param string $table 连接的表 @param string $onFieldA ON 等号前面的字段名 @param string $onFieldB ON 等号后面的字段名 @param string $joinType = 'LEFT' join类型,LEFT|RIGHT|INNER|CROSS @return \wf\db\Finder
[ "连接表,", "如:RIGHT", "JOIN", "myTable", "tb", "ON", "tb", ".", "a", "=", "xx", ".", "filed1", "则参数为", "-", ">", "join", "(", "myTable", "tb", "tb", ".", "a", "xx", ".", "filed1", "RIGHT", ")" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L215-L224
windwork/wf-db
lib/Finder.php
Finder.where
public function where($field, $value, $operator = '=', $type = 'string') { $this->options['where'][] = [$field, $value, $operator, $type]; return $this; }
php
public function where($field, $value, $operator = '=', $type = 'string') { $this->options['where'][] = [$field, $value, $operator, $type]; return $this; }
[ "public", "function", "where", "(", "$", "field", ",", "$", "value", ",", "$", "operator", "=", "'='", ",", "$", "type", "=", "'string'", ")", "{", "$", "this", "->", "options", "[", "'where'", "]", "[", "]", "=", "[", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", "]", ";", "return", "$", "this", ";", "}" ]
WHERE查询条件 如需要复杂SQL查询,请使用 wfDb()->getAll($sql, $args)/wfDb()->getRow($sql, $args)/wfDb()->getColumn($sql, $args) @param string $field 字段名 @param mixed $value 字段值 @param string $operator = '=' 运算符,可选=,+,-,|,&,^,like,in,notin,>,<,<>,>=,<=,!=等 @param string $type = 'string' 字段值的类型,默认是string,string:字符串,field:字段,int:整形,float:浮点型,sql:sql语句 @return \wf\db\Finder
[ "WHERE查询条件" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L272-L277
windwork/wf-db
lib/Finder.php
Finder.andWhere
public function andWhere($field, $value, $operator = '=', $type = 'string') { $this->where($field, $value, $operator, $type); return $this; }
php
public function andWhere($field, $value, $operator = '=', $type = 'string') { $this->where($field, $value, $operator, $type); return $this; }
[ "public", "function", "andWhere", "(", "$", "field", ",", "$", "value", ",", "$", "operator", "=", "'='", ",", "$", "type", "=", "'string'", ")", "{", "$", "this", "->", "where", "(", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", ")", ";", "return", "$", "this", ";", "}" ]
WHERE查询条件(AND) 如需要复杂SQL查询,请使用 wfDb()->getAll($sql, $args)/wfDb()->getRow($sql, $args)/wfDb()->getColumn($sql, $args) @param string $field 字段名 @param mixed $value 字段值 @param string $operator = '=' 运算符,可选=,+,-,|,&,^,like,in,notin,>,<,<>,>=,<=,!=等 @param string $type = 'string' 字段值的类型,默认是string,string:字符串,field:字段,int:整形,float:浮点型,sql:sql语句 @return \wf\db\Finder
[ "WHERE查询条件(AND)" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L291-L296
windwork/wf-db
lib/Finder.php
Finder.orWhere
public function orWhere($field, $value, $operator = '=', $type = 'string') { if (!empty($this->options['where'])) { $this->options['where'] = [ 'OR', $this->options['where'], [$field, $value, $operator, $type], ]; } else { $this->where($field, $value, $operator, $type); } return $this; }
php
public function orWhere($field, $value, $operator = '=', $type = 'string') { if (!empty($this->options['where'])) { $this->options['where'] = [ 'OR', $this->options['where'], [$field, $value, $operator, $type], ]; } else { $this->where($field, $value, $operator, $type); } return $this; }
[ "public", "function", "orWhere", "(", "$", "field", ",", "$", "value", ",", "$", "operator", "=", "'='", ",", "$", "type", "=", "'string'", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "'where'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'where'", "]", "=", "[", "'OR'", ",", "$", "this", "->", "options", "[", "'where'", "]", ",", "[", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", "]", ",", "]", ";", "}", "else", "{", "$", "this", "->", "where", "(", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", ")", ";", "}", "return", "$", "this", ";", "}" ]
WHERE查询条件(OR) 如需要复杂SQL查询,请使用 wfDb()->getAll($sql, $args)/wfDb()->getRow($sql, $args)/wfDb()->getColumn($sql, $args) @param string $field 字段名 @param mixed $value 字段值 @param string $operator = '=' 运算符,可选=,+,-,|,&,^,like,in,notin,>,<,<>,>=,<=,!=等 @param string $type = 'string' 字段值的类型,默认是string,string:字符串,field:字段,int:整形,float:浮点型,sql:sql语句 @return \wf\db\Finder
[ "WHERE查询条件(OR)" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L310-L323
windwork/wf-db
lib/Finder.php
Finder.having
public function having($field, $value, $operator = '=', $type = 'string') { $this->options['having'][] = [$field, $value, $operator, $type]; return $this; }
php
public function having($field, $value, $operator = '=', $type = 'string') { $this->options['having'][] = [$field, $value, $operator, $type]; return $this; }
[ "public", "function", "having", "(", "$", "field", ",", "$", "value", ",", "$", "operator", "=", "'='", ",", "$", "type", "=", "'string'", ")", "{", "$", "this", "->", "options", "[", "'having'", "]", "[", "]", "=", "[", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", "]", ";", "return", "$", "this", ";", "}" ]
HAVING条件,格式同where 如需要复杂SQL查询,请使用 wfDb()->getAll($sql, $args)/wfDb()->getRow($sql, $args)/wfDb()->getColumn($sql, $args) @param string $field 字段名 @param mixed $value 字段值 @param string $operator = '=' 操作符,可选=,+,-,|,&,^,like,in,notin,>,<,<>,>=,<=,!=等 @param string $type = 'string' 字段值的类型,默认是string,string:字符串,field:字段,int:整形,float:浮点型,sql:sql语句 @return \wf\db\Finder
[ "HAVING条件,格式同where" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L402-L407
windwork/wf-db
lib/Finder.php
Finder.andHaving
public function andHaving($field, $value, $operator = '=', $type = 'string') { $this->having($field, $value, $operator, $type); return $this; }
php
public function andHaving($field, $value, $operator = '=', $type = 'string') { $this->having($field, $value, $operator, $type); return $this; }
[ "public", "function", "andHaving", "(", "$", "field", ",", "$", "value", ",", "$", "operator", "=", "'='", ",", "$", "type", "=", "'string'", ")", "{", "$", "this", "->", "having", "(", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", ")", ";", "return", "$", "this", ";", "}" ]
HAVING查询条件(AND) 如需要复杂SQL查询,请使用 wfDb()->getAll($sql, $args)/wfDb()->getRow($sql, $args)/wfDb()->getColumn($sql, $args) @param string $field 字段名 @param mixed $value 字段值 @param string $operator = '=' 运算符,可选=,+,-,|,&,^,like,in,notin,>,<,<>,>=,<=,!=等 @param string $type = 'string' 字段值的类型,默认是string,string:字符串,field:字段,int:整形,float:浮点型,sql:sql语句 @return \wf\db\Finder
[ "HAVING查询条件(AND)" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L421-L426
windwork/wf-db
lib/Finder.php
Finder.orHaving
public function orHaving($field, $value, $operator = '=', $type = 'string') { if (!empty($this->options['having'])) { $this->options['having'] = [ 'OR', $this->options['having'], [$field, $value, $operator, $type], ]; } else { $this->having($field, $value, $operator, $type); } return $this; }
php
public function orHaving($field, $value, $operator = '=', $type = 'string') { if (!empty($this->options['having'])) { $this->options['having'] = [ 'OR', $this->options['having'], [$field, $value, $operator, $type], ]; } else { $this->having($field, $value, $operator, $type); } return $this; }
[ "public", "function", "orHaving", "(", "$", "field", ",", "$", "value", ",", "$", "operator", "=", "'='", ",", "$", "type", "=", "'string'", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "'having'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'having'", "]", "=", "[", "'OR'", ",", "$", "this", "->", "options", "[", "'having'", "]", ",", "[", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", "]", ",", "]", ";", "}", "else", "{", "$", "this", "->", "having", "(", "$", "field", ",", "$", "value", ",", "$", "operator", ",", "$", "type", ")", ";", "}", "return", "$", "this", ";", "}" ]
HAVING查询条件(OR) 如需要复杂SQL查询,请使用 wfDb()->getAll($sql, $args)/wfDb()->getRow($sql, $args)/wfDb()->getColumn($sql, $args) @param string $field 字段名 @param mixed $value 字段值 @param string $operator = '=' 运算符,可选=,+,-,|,&,^,like,in,notin,>,<,<>,>=,<=,!=等 @param string $type = 'string' 字段值的类型,默认是string,string:字符串,field:字段,int:整形,float:浮点型,sql:sql语句 @return \wf\db\Finder
[ "HAVING查询条件(OR)" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L439-L452
windwork/wf-db
lib/Finder.php
Finder.limit
public function limit($offset, $rows = 0) { $offset = (int)($offset > 0 ? $offset : 0); $rows = (int)($rows > 0 ? $rows : 0); $this->options['limit'] = "{$offset}, {$rows}"; return $this; }
php
public function limit($offset, $rows = 0) { $offset = (int)($offset > 0 ? $offset : 0); $rows = (int)($rows > 0 ? $rows : 0); $this->options['limit'] = "{$offset}, {$rows}"; return $this; }
[ "public", "function", "limit", "(", "$", "offset", ",", "$", "rows", "=", "0", ")", "{", "$", "offset", "=", "(", "int", ")", "(", "$", "offset", ">", "0", "?", "$", "offset", ":", "0", ")", ";", "$", "rows", "=", "(", "int", ")", "(", "$", "rows", ">", "0", "?", "$", "rows", ":", "0", ")", ";", "$", "this", "->", "options", "[", "'limit'", "]", "=", "\"{$offset}, {$rows}\"", ";", "return", "$", "this", ";", "}" ]
SQL分页查询 @param number $offset @param number $rows @return \wf\db\Finder
[ "SQL分页查询" ]
train
https://github.com/windwork/wf-db/blob/b9ee5740a42d572ce728907ea24ba22c158863f5/lib/Finder.php#L461-L469
j-d/draggy
src/Draggy/Autocode/Templates/PHP/Symfony2/Doctrine2/Entity4.php
Entity4.getCascadeOwnerPart
public function getCascadeOwnerPart(PHPAttribute $attribute) { $cascadeAttributes = []; if (in_array($attribute->getCascadePersist(), ['both', 'owner'])) { $cascadeAttributes[] = '"persist"'; } if (in_array($attribute->getCascadeRemove(), ['both', 'owner'])) { $cascadeAttributes[] = '"remove"'; } if (count($cascadeAttributes) > 0) { return ', cascade={' . implode(', ', $cascadeAttributes) . '}'; } else { return ''; } }
php
public function getCascadeOwnerPart(PHPAttribute $attribute) { $cascadeAttributes = []; if (in_array($attribute->getCascadePersist(), ['both', 'owner'])) { $cascadeAttributes[] = '"persist"'; } if (in_array($attribute->getCascadeRemove(), ['both', 'owner'])) { $cascadeAttributes[] = '"remove"'; } if (count($cascadeAttributes) > 0) { return ', cascade={' . implode(', ', $cascadeAttributes) . '}'; } else { return ''; } }
[ "public", "function", "getCascadeOwnerPart", "(", "PHPAttribute", "$", "attribute", ")", "{", "$", "cascadeAttributes", "=", "[", "]", ";", "if", "(", "in_array", "(", "$", "attribute", "->", "getCascadePersist", "(", ")", ",", "[", "'both'", ",", "'owner'", "]", ")", ")", "{", "$", "cascadeAttributes", "[", "]", "=", "'\"persist\"'", ";", "}", "if", "(", "in_array", "(", "$", "attribute", "->", "getCascadeRemove", "(", ")", ",", "[", "'both'", ",", "'owner'", "]", ")", ")", "{", "$", "cascadeAttributes", "[", "]", "=", "'\"remove\"'", ";", "}", "if", "(", "count", "(", "$", "cascadeAttributes", ")", ">", "0", ")", "{", "return", "', cascade={'", ".", "implode", "(", "', '", ",", "$", "cascadeAttributes", ")", ".", "'}'", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
<user-additions part="otherMethods">
[ "<user", "-", "additions", "part", "=", "otherMethods", ">" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Symfony2/Doctrine2/Entity4.php#L43-L60
j-d/draggy
src/Draggy/Autocode/Templates/PHP/Symfony2/Doctrine2/Entity4.php
Entity4.getSetterCodeDocumentationParameterLines
public function getSetterCodeDocumentationParameterLines(PHPAttribute $attribute) { $lines = parent::getSetterCodeDocumentationParameterLines($attribute); if (null !== $attribute->getForeign()) { $lines[] = '@param bool $_reverseCall'; } return $lines; }
php
public function getSetterCodeDocumentationParameterLines(PHPAttribute $attribute) { $lines = parent::getSetterCodeDocumentationParameterLines($attribute); if (null !== $attribute->getForeign()) { $lines[] = '@param bool $_reverseCall'; } return $lines; }
[ "public", "function", "getSetterCodeDocumentationParameterLines", "(", "PHPAttribute", "$", "attribute", ")", "{", "$", "lines", "=", "parent", "::", "getSetterCodeDocumentationParameterLines", "(", "$", "attribute", ")", ";", "if", "(", "null", "!==", "$", "attribute", "->", "getForeign", "(", ")", ")", "{", "$", "lines", "[", "]", "=", "'@param bool $_reverseCall'", ";", "}", "return", "$", "lines", ";", "}" ]
<editor-fold desc="Setters">
[ "<editor", "-", "fold", "desc", "=", "Setters", ">" ]
train
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Templates/PHP/Symfony2/Doctrine2/Entity4.php#L217-L226