idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
19,100
protected function configure ( $ name ) { $ path = $ this -> app -> basePath ( "config/{$name}.php" ) ; if ( ! is_readable ( $ path ) ) { $ path = dirname ( __DIR__ ) . "/config/{$name}.php" ; } $ this -> app -> make ( 'config' ) -> set ( $ name , require $ path ) ; }
Configure provider .
19,101
public function handle ( UploadImage $ command ) { $ this -> assertCan ( $ command -> actor , 'flagrow.image.upload' ) ; $ tmpFile = tempnam ( $ this -> app -> storagePath ( ) . '/tmp' , 'image' ) ; $ command -> file -> moveTo ( $ tmpFile ) ; $ file = new UploadedFile ( $ tmpFile , $ command -> file -> getClientFilenam...
Handles the command execution .
19,102
public function subscribe ( Dispatcher $ events ) { $ events -> listen ( ConfigureApiRoutes :: class , [ $ this , 'configureApiRoutes' ] ) ; $ events -> listen ( PrepareApiAttributes :: class , [ $ this , 'prepareApiAttributes' ] ) ; }
Subscribes to the Flarum api routes configuration event .
19,103
public function start ( $ ip , $ port , $ path , $ logsPath , $ debug , $ expectationsPath ) { $ phiremockPath = is_file ( $ path ) ? $ path : $ path . DIRECTORY_SEPARATOR . 'phiremock' ; $ expectationsPath = is_dir ( $ expectationsPath ) ? $ expectationsPath : '' ; $ logFile = $ logsPath . DIRECTORY_SEPARATOR . self :...
Starts Phiremock .
19,104
protected function data ( ServerRequestInterface $ request , Document $ document ) { $ postId = array_get ( $ request -> getQueryParams ( ) , 'post' ) ; $ actor = $ request -> getAttribute ( 'actor' ) ; $ file = array_get ( $ request -> getUploadedFiles ( ) , 'image' ) ; return $ this -> bus -> dispatch ( new UploadIma...
Get the data to be serialized and assigned to the response document .
19,105
protected function registerJWTAuthDependency ( ) { $ this -> registerRequest ( ) ; $ this -> registerRoutingAlias ( ) ; $ this -> registerSessionServiceProvider ( ) ; $ this -> registerCookieComponent ( ) ; $ this -> registerCacheServiceProvider ( ) ; $ this -> registerAuthManagerAlias ( ) ; }
Here we do some internal function to fulfill JWTAuth dependency .
19,106
protected function loadComponent ( $ bindings , $ name ) { $ aliases = array_values ( $ bindings ) ; $ abstracts = array_keys ( $ bindings ) ; foreach ( $ abstracts as $ index => $ abstract ) { $ this -> app -> singleton ( $ abstract , $ this -> { "load{$name}Component" } ( ) ) ; $ this -> app -> alias ( $ abstract , $...
Load component by given bindings an name resolver .
19,107
public function queueSummary ( $ name ) { $ qid = $ this -> getQueueId ( $ name ) ; $ db = $ this -> getDb ( ) ; $ list = array ( ) ; $ sql = 'SELECT * FROM ' . $ this -> messageTable . ' WHERE queue_id = :queue_id' ; $ sth = $ db -> prepare ( $ sql ) ; $ sth -> execute ( array ( 'queue_id' => $ qid ) ) ; foreach ( $ s...
Return Queue summary
19,108
public function summary ( ) { $ list = array ( ) ; foreach ( $ this -> getQueues ( ) as $ queue ) { $ list = array_merge ( $ list , $ this -> queueSummary ( $ queue -> getName ( ) ) ) ; } return $ list ; }
Return all Queues summary
19,109
private function receiveQueueMessages ( Queue $ queue , $ max , $ timeout ) { $ messages = array ( ) ; $ microtime = microtime ( true ) ; $ db = $ this -> getDb ( ) ; $ qid = $ this -> getQueueId ( $ queue -> getName ( ) ) ; try { if ( $ max > 0 ) { $ db -> beginTransaction ( ) ; $ sql = "SELECT * ...
Select unselected messages from queue
19,110
public function executeQueue ( Queue $ queue , $ max , $ timeout = 30 ) { foreach ( $ this -> receiveQueueMessages ( $ queue , $ max , $ timeout ) as $ message ) { try { $ message -> execute ( ) ; $ this -> deleteMessage ( $ message ) ; } catch ( \ Exception $ e ) { $ this -> log ( $ message , $ e ) ; } } }
Execute messages in queue
19,111
public function executeAll ( $ max = 50 ) { $ sth = $ this -> getDb ( ) -> prepare ( 'SELECT * FROM ' . $ this -> queueTable . ' WHERE 1' ) ; $ sth -> execute ( ) ; foreach ( $ sth -> fetchAll ( ) as $ queue ) { $ q = new Queue ( $ queue [ 'queue_name' ] , $ queue [ 'timeout' ] ) ; $ q -> setManager ( $ this ) ; $ q ->...
Execute all queues
19,112
public function addMessageToQueue ( Message $ message , $ name ) { $ q = $ this -> getQueue ( $ name ) ; $ qid = $ this -> getQueueId ( $ q -> getName ( ) ) ; $ body = base64_encode ( serialize ( $ message ) ) ; $ md5 = md5 ( $ body ) ; $ sql = 'INSERT INTO ' . $ this -> messageTable . ' (queue_id, body, cre...
Add new message to queue
19,113
public function getQueue ( $ name , $ timeout = null ) { if ( ! is_string ( $ name ) ) { throw new Exception ( '$name is not a string' ) ; } if ( ( null !== $ timeout ) && ! is_integer ( $ timeout ) ) { throw new Exception ( '$timeout must be an integer' ) ; } if ( ! $ this -> getQueueId ( $ name ) ) { $ this -> create...
Return new queue instance
19,114
public function getQueueId ( $ name ) { $ sql = 'SELECT queue_id FROM ' . $ this -> queueTable . ' WHERE queue_name = ? LIMIT 1' ; $ stmt = $ this -> getDb ( ) -> prepare ( $ sql ) ; $ stmt -> execute ( array ( $ name ) ) ; return $ stmt -> fetchColumn ( ) ; }
Returns queue id or bool false
19,115
private function create ( $ name , $ timeout = null ) { if ( null === $ timeout ) { $ timeout = 10000 ; } $ sql = 'INSERT INTO ' . $ this -> queueTable . ' (queue_name, timeout) VALUES (:queue_name, :timeout) ' ; $ stmt = $ this -> getDb ( ) -> prepare ( $ sql ) ; $ stmt -> b...
Creates new Queue
19,116
public function deleteMessageById ( $ id ) { $ sql = 'DELETE FROM ' . $ this -> messageTable . ' WHERE message_id = ?' ; $ stmt = $ this -> getDb ( ) -> prepare ( $ sql ) ; $ stmt -> execute ( array ( $ id ) ) ; return true ; }
Remove message from queue by id
19,117
public function log ( Message $ message , \ Exception $ e ) { $ sql = "UPDATE " . $ this -> messageTable . " SET log = :log WHERE message_id = :id " ; $ stmt = $ this -> getDb ( ) -> prepare ( $ sql ) ; $ stmt -> bindValue ( ':log' , $ e -> getMessage ( ) , \ PDO :: PARAM_STR ) ; $ ...
Saves error message to message on execution failure
19,118
public function getTotalMessages ( ) { $ sql = 'SELECT COUNT(message_id) FROM ' . $ this -> messageTable . ' WHERE 1' ; $ stmt = $ this -> getDb ( ) -> prepare ( $ sql ) ; $ stmt -> execute ( ) ; return $ stmt -> fetchColumn ( ) ; }
Get total messages in all queues
19,119
public function addUploadMethods ( PrepareUnserializedSettings $ event ) { $ methods = [ 'local' , 'imgur' ] ; if ( class_exists ( Cloudinary :: class ) ) { $ methods [ ] = 'cloudinary' ; } $ event -> settings [ 'flagrow.image-upload.availableUploadMethods' ] = [ ] ; foreach ( $ methods as $ method ) { $ event -> setti...
Check for installed packages and provide the upload methods option in the admin page -
19,120
public function getPaylikeMultiplier ( $ currency_iso_code ) { $ currency = $ this -> getCurrency ( $ currency_iso_code ) ; if ( isset ( $ currency [ 'exponent' ] ) ) { return pow ( 10 , $ currency [ 'exponent' ] ) ; } else { return pow ( 10 , 2 ) ; } }
Return the number that should be used to compute cents from the total amount
19,121
public function build ( array $ renderers , array $ fields ) { $ this -> renderers = $ renderers ; $ this -> fields = $ fields ; $ this -> prepare ( ) ; return $ this ; }
Build the renderer
19,122
private function updateOffset ( ) { if ( $ this -> after ( ) ) { $ this -> params [ 'after' ] = $ this -> collection [ $ this -> total_count - 1 ] [ 'id' ] ; } else { $ this -> params [ 'before' ] = $ this -> collection [ $ this -> total_count - 1 ] [ 'id' ] ; } return $ this ; }
If after is set then we increment it otherwise we increment before
19,123
private function isTheIdentifierILookingFor ( Query \ Lexer $ lexer ) { if ( $ lexer -> token [ 'type' ] === Query \ Lexer :: T_IDENTIFIER && $ lexer -> isNextToken ( Query \ Lexer :: T_IDENTIFIER ) ) { return true ; } if ( $ lexer -> token [ 'type' ] === Query \ Lexer :: T_IDENTIFIER && $ lexer -> isNextToken ( Query ...
Check if it s the lexer part is the identifier I looking for
19,124
private function isStringDQLQuery ( $ value ) { $ keysWord = array ( "SELECT " , " FROM " , " WHERE " ) ; foreach ( $ keysWord as $ keyWord ) { if ( stripos ( $ value , $ keyWord ) !== false ) { return true ; } } return false ; }
Check if a sring is a DQL query
19,125
protected function prepareModels ( ) { if ( ! $ this -> query instanceof QueryInterface ) { throw new InvalidConfigException ( 'The "query" property must be an instance of a class that implements the ' . 'chsergey\rest\QueryInterface or its subclasses.' ) ; } $ query = clone $ this -> query ; $ this -> setPagination ( ...
Prepares the data models that will be made available in the current page .
19,126
protected function prepareKeys ( $ models ) { $ keys = [ ] ; foreach ( $ models as $ model ) { $ keys [ ] = $ model -> getPrimaryKey ( ) ; } return $ keys ; }
Prepares the keys associated with the currently available data models .
19,127
public function setGlobalSearch ( $ globalSearch ) { $ this -> globalSearch = $ globalSearch ; $ this -> queryBuilder -> setSearch ( $ globalSearch || $ this -> search ) ; return $ this ; }
set global search
19,128
public function one ( $ id ) { if ( $ this -> _where ) { throw new InvalidCallException ( __METHOD__ . '() can not be called with "where" clause' ) ; } $ model = $ this -> _populate ( $ this -> _request ( 'get' , $ this -> _getUrl ( 'element' , $ id ) , [ 'query' => $ this -> _buildQueryParams ( ) ] ) , false ) ; retur...
GET resource element request
19,129
private function _throwServerError ( \ Exception $ e ) { $ uri = ( string ) $ this -> httpClient -> getConfig ( 'base_uri' ) ; throw new ServerErrorHttpException ( get_class ( $ e ) . ': url=' . $ uri . ' ' . $ e -> getMessage ( ) , 500 ) ; }
Throw 500 error exception
19,130
protected function _populate ( ResponseInterface $ response , $ asCollection = true ) { $ models = [ ] ; $ statusCode = $ response -> getStatusCode ( ) ; $ data = $ this -> _unserializeResponseBody ( $ response ) ; if ( $ statusCode >= 400 ) { throw new HttpException ( $ statusCode , is_string ( $ data ) ? $ data : $ d...
Unserialize and create models
19,131
protected function _createModels ( array $ elements ) { $ modelClass = $ this -> modelClass ; $ models = [ ] ; foreach ( $ elements as $ element ) { $ model = $ modelClass :: instantiate ( ) -> setAttributes ( $ this -> _getProps ( $ element ) ) ; $ models [ ] = $ model -> setId ( $ model -> getAttribute ( $ modelClass...
Create models from array of elements
19,132
protected function _unserializeResponseBody ( ResponseInterface $ response ) { $ body = ( string ) $ response -> getBody ( ) ; $ contentType = $ response -> getHeaderLine ( 'Content-type' ) ; try { if ( false !== stripos ( $ contentType , $ this -> dataType ) && isset ( $ this -> unserializers [ $ this -> dataType ] ) ...
Try to unserialize response body data
19,133
private function _setPagination ( array $ pagination ) { foreach ( $ this -> _paginationEnvelopeKeys as $ key => $ name ) { $ this -> _pagination [ $ key ] = isset ( $ pagination [ $ name ] ) ? $ pagination [ $ name ] : null ; } return $ this ; }
Pagination data setter If pagination data isset in GET request result
19,134
private function _buildQueryParams ( ) { $ query = [ ] ; $ this -> _where = is_array ( $ this -> _where ) ? $ this -> _where : [ ] ; foreach ( $ this -> _where as $ key => $ val ) { $ query [ $ key ] = is_numeric ( $ val ) ? ( int ) $ val : $ val ; } if ( count ( $ this -> _select ) ) { $ query [ $ this -> selectFields...
Build query params
19,135
private function _getUrl ( $ type = 'base' , $ id = 'null' ) { $ modelClass = $ this -> modelClass ; $ collection = $ modelClass :: getResourceName ( ) ; switch ( $ type ) { case 'api' : return $ this -> _trailingSlash ( $ modelClass :: getApiUrl ( ) ) ; break ; case 'collection' : return $ this -> _trailingSlash ( $ c...
Get url to collection or element of resource with check base url trailing slash
19,136
protected function getDataVersionHash ( ) { $ filter = $ this -> getPropertyFilter ( ) ; $ properties = $ filter -> getProperties ( ) ; sort ( $ properties ) ; return sha1 ( static :: class . '|' . static :: VERSION . '|' . get_class ( $ filter ) . '|' . implode ( ',' , $ properties ) ) ; }
Generates a hash from relevant information that influence the validity of
19,137
public function createClient ( $ sandBox = false ) { $ client = new \ SoapClient ( $ this -> wsdl , array ( 'soap_version' => SOAP_1_1 , 'classmap' => $ this -> classmap ) ) ; $ login = $ sandBox ? self :: TEST_LOGIN : $ this -> login ; $ password = $ sandBox ? self :: TEST_PASSWORD : $ this -> password ; $ client -> _...
Return a new instance of SoapClient
19,138
public function getSecurityHeader ( $ login , $ password ) { $ authHeader = sprintf ( $ this -> getSecurityHeaderTemplate ( ) , htmlspecialchars ( $ login ) , htmlspecialchars ( $ password ) ) ; return new \ SoapHeader ( 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' , 'Security' , ...
Return an instance of SoapHeader for WS Security
19,139
public function index ( ) { $ tablesToList = [ ] ; $ data = [ ] ; if ( Configure :: check ( 'Sitemap.tables' ) ) { $ tablesToList = Configure :: read ( 'Sitemap.tables' ) ; } foreach ( $ tablesToList as $ table ) { $ tableInstance = $ this -> loadModel ( $ table ) ; $ data [ $ table ] = $ tableInstance -> find ( 'forSi...
Index page for the sitemap .
19,140
public function take ( $ key ) { self :: requireSession ( ) ; if ( false === \ array_key_exists ( $ key , $ _SESSION ) ) { throw new SessionException ( \ sprintf ( 'key "%s" not found in session' , $ key ) ) ; } $ value = $ _SESSION [ $ key ] ; unset ( $ _SESSION [ $ key ] ) ; return $ value ; }
Get value delete key .
19,141
public function returnUrlForEntity ( Entity $ entity ) { return Router :: url ( [ 'plugin' => null , 'prefix' => null , 'controller' => $ this -> _table -> alias ( ) , 'action' => 'view' , $ entity -> { $ this -> _table -> primaryKey ( ) } , ] , true ) ; }
Return the URL for the primary view action for an Entity .
19,142
public function findSitemapRecords ( Query $ query , array $ options ) { $ query = $ query -> where ( $ this -> _config [ 'conditions' ] ) -> cache ( "sitemap_{$query->repository()->alias()}" , $ this -> _config [ 'cacheConfigKey' ] ) -> order ( $ this -> _config [ 'order' ] ) -> formatResults ( function ( $ results ) ...
Find the Sitemap Records for a Table .
19,143
public function mapEntity ( Entity $ entity ) { $ entity [ '_loc' ] = $ this -> _table -> getUrl ( $ entity ) ; $ entity [ '_lastmod' ] = $ entity -> { $ this -> _config [ 'lastmod' ] } ; $ entity [ '_changefreq' ] = $ this -> _config [ 'changefreq' ] ; $ entity [ '_priority' ] = $ this -> _config [ 'priority' ] ; retu...
Modify an entity with new _ fields for the Sitemap display .
19,144
protected function resolveValue ( string $ setterMethodName , $ value ) { $ reflection = new ReflectionClass ( $ this ) ; $ method = $ reflection -> getMethod ( $ setterMethodName ) ; $ parameter = $ method -> getParameters ( ) [ 0 ] ; return $ this -> resolveParameter ( $ parameter , $ value ) ; }
Resolve and return the given value for the given setter method
19,145
protected function resolveParameter ( ReflectionParameter $ parameter , $ value ) { $ paramClass = $ parameter -> getClass ( ) ; if ( ! isset ( $ paramClass ) ) { return $ value ; } $ className = $ paramClass -> getName ( ) ; if ( $ value instanceof $ className ) { return $ value ; } $ container = $ this -> container (...
Resolve the given parameter ; pass the given value to it
19,146
protected function resolveInstancePopulation ( $ instance , ReflectionParameter $ parameter , $ value ) { if ( $ instance instanceof Populatable && is_array ( $ value ) ) { $ instance -> populate ( $ value ) ; return $ instance ; } $ message = sprintf ( 'Unable to resolve dependency for property "%s" of the type "%s"; ...
Attempts to populate instance if possible
19,147
public function addCookie ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { $ this -> cookies = $ name + $ this -> cookies ; } else { $ this -> cookies [ $ name ] = $ value ; } }
Adds a cookie for a cURL transfer
19,148
public function clearCookieFile ( ) { if ( ! is_writable ( $ this -> cookieFile ) ) { throw new CurlWrapperException ( 'Cookie file "' . ( $ this -> cookieFile ) . '" is not writable or does\'n exists!' ) ; } file_put_contents ( $ this -> cookieFile , '' , LOCK_EX ) ; }
Clears the cookies file
19,149
public function getTransferInfo ( $ key = null ) { if ( empty ( $ this -> transferInfo ) ) { throw new CurlWrapperException ( 'There is no transfer info. Did you do the request?' ) ; } if ( $ key === null ) { return $ this -> transferInfo ; } if ( isset ( $ this -> transferInfo [ $ key ] ) ) { return $ this -> transfer...
Gets the information about the last transfer
19,150
public function resetAll ( ) { $ this -> clearHeaders ( ) ; $ this -> clearOptions ( ) ; $ this -> clearRequestParams ( ) ; $ this -> clearCookies ( ) ; $ this -> clearCookieFile ( ) ; $ this -> reset ( ) ; }
Reinitiates the cURL handle and resets all data Including headers options request parameters cookies and cookies file
19,151
public function setDefaultOptions ( ) { $ this -> options = array ( CURLOPT_RETURNTRANSFER => true , CURLOPT_HEADER => false , CURLOPT_ENCODING => 'gzip,deflate' , CURLOPT_AUTOREFERER => true , CURLOPT_CONNECTTIMEOUT => 15 , CURLOPT_TIMEOUT => 30 , ) ; }
Sets the default options
19,152
protected function initOptions ( ) { if ( ! empty ( $ this -> requestParams ) ) { if ( isset ( $ this -> options [ CURLOPT_HTTPGET ] ) ) { $ this -> prepareGetParams ( ) ; } else { $ this -> addOption ( CURLOPT_POSTFIELDS , http_build_query ( $ this -> requestParams ) ) ; } } if ( ! empty ( $ this -> headers ) ) { $ th...
Sets the final options and prepares request params headers and cookies
19,153
protected function prepareCookies ( ) { $ cookiesString = '' ; foreach ( $ this -> cookies as $ cookie => $ value ) { $ cookiesString .= $ cookie . '=' . $ value . '; ' ; } return $ cookiesString ; }
Converts the cookies array to the correct string format
19,154
protected function prepareGetParams ( ) { $ parsedUrl = parse_url ( $ this -> options [ CURLOPT_URL ] ) ; $ query = http_build_query ( $ this -> requestParams ) ; if ( isset ( $ parsedUrl [ 'query' ] ) ) { $ parsedUrl [ 'query' ] .= '&' . $ query ; } else { $ parsedUrl [ 'query' ] = $ query ; } $ this -> setUrl ( $ thi...
Converts request parameters to the query string and adds it to the request url
19,155
protected function prepareHeaders ( ) { $ headers = array ( ) ; foreach ( $ this -> headers as $ header => $ value ) { $ headers [ ] = $ header . ': ' . $ value ; } return $ headers ; }
Converts the headers array to the cURL s option format array
19,156
protected function setRequestMethod ( $ method ) { $ this -> removeOption ( CURLOPT_NOBODY ) ; $ this -> removeOption ( CURLOPT_HTTPGET ) ; $ this -> removeOption ( CURLOPT_POST ) ; $ this -> removeOption ( CURLOPT_CUSTOMREQUEST ) ; switch ( strtoupper ( $ method ) ) { case 'HEAD' : $ this -> addOption ( CURLOPT_NOBODY...
Sets the HTTP request method
19,157
public function send ( Provider $ provider , $ userId , $ requestScope , Request $ request ) { $ accessToken = $ this -> getAccessToken ( $ provider , $ userId , $ requestScope ) ; if ( false === $ accessToken ) { return false ; } if ( $ accessToken -> isExpired ( $ this -> dateTime ) ) { if ( null === $ accessToken ->...
Perform a HTTP request .
19,158
public function getAuthorizeUri ( Provider $ provider , $ userId , $ scope , $ redirectUri ) { $ queryParameters = [ 'client_id' => $ provider -> getClientId ( ) , 'redirect_uri' => $ redirectUri , 'scope' => $ scope , 'state' => $ this -> random -> getHex ( 16 ) , 'response_type' => 'code' , ] ; $ authorizeUri = \ spr...
Obtain an authorization request URL to start the authorization process at the OAuth provider .
19,159
private function getAccessToken ( Provider $ provider , $ userId , $ scope ) { $ accessTokenList = $ this -> tokenStorage -> getAccessTokenList ( $ userId ) ; foreach ( $ accessTokenList as $ accessToken ) { if ( $ provider -> getProviderId ( ) !== $ accessToken -> getProviderId ( ) ) { continue ; } if ( $ scope !== $ ...
Find an AccessToken in the list that matches this scope bound to providerId and userId .
19,160
public static function getContainer ( ) : ? ContainerInterface { if ( is_null ( self :: $ container ) ) { self :: setContainer ( self :: getDefaultContainer ( ) ) ; } return self :: $ container ; }
Get the IoC service container
19,161
public function getLastEvent ( ) { if ( null === $ this -> { self :: $ sequence [ 0 ] } ) { return self :: $ sequence [ 0 ] ; } foreach ( self :: $ sequence as $ i => $ event ) { if ( null === $ this -> $ event ) { return self :: $ sequence [ $ i - 1 ] ; } } return self :: $ sequence [ count ( self :: $ sequence ) - 1 ...
Return the last not null event
19,162
public static function render_list_table_page ( $ page_title , $ list_table ) { $ list_table_class = get_class ( $ list_table ) ; $ pagenum = $ list_table -> get_pagenum ( ) ; $ action = $ list_table -> current_action ( ) ; if ( $ action ) { check_admin_referer ( 'bulk-posts' ) ; $ sendback = remove_query_arg ( array (...
Setup the list table and render the list table page or call the given action .
19,163
public function getApiClient ( ) { $ stack = HandlerStack :: create ( ) ; $ middleware = new Oauth1 ( [ 'consumer_key' => $ this -> configuration -> getConsumerKey ( ) , 'consumer_secret' => $ this -> configuration -> getConsumerSecret ( ) , 'token' => $ this -> configuration -> getToken ( ) , 'token_secret' => $ this ...
Get new api client .
19,164
public function send ( $ text , $ phones ) { if ( ! is_array ( $ phones ) ) { $ phones = [ $ phones ] ; } foreach ( $ phones as $ phone ) { if ( ! $ phone ) { continue ; } $ message = $ this -> sendMessage ( $ text , $ phone ) ; $ this -> saveToDb ( $ text , $ phone , $ message ) ; } return $ this -> lastSendMessagesId...
Send sms and return array of message s ids in database
19,165
public function saveToDb ( $ text , $ phone , $ message ) { if ( ! $ this -> saveToDb ) { return false ; } $ model = new TurboSmsSent ( ) ; $ model -> text = $ text ; $ model -> phone = $ phone ; $ model -> message = $ message . ( $ this -> debug ? $ this -> debugSuffixMessage : '' ) ; if ( $ this -> lastSendMessageId ...
Save sms to db
19,166
public function getMessageStatus ( $ messageId ) { if ( $ this -> debug || ! $ messageId ) { return '' ; } $ result = $ this -> getClient ( ) -> GetMessageStatus ( [ 'MessageId' => $ messageId ] ) ; return $ result -> GetMessageStatusResult ; }
Get message status
19,167
private function tryAcquire ( $ operation , $ lock_type ) { $ log_data = [ "lock_file" => $ this -> lock_file , "lock_type" => $ lock_type ] ; if ( ! $ this -> flock ( $ operation ) ) { $ this -> logger -> debug ( "could not acquire {lock_type} lock on {lock_file}" , $ log_data ) ; throw new RuntimeException ( "Could n...
try to acquire lock on file throw in case of faillure
19,168
public function flatten_props ( $ props ) { foreach ( $ props as $ property => $ value ) { if ( is_object ( $ value ) && get_class ( $ value ) == 'DateTime' ) { $ props [ $ property ] = $ value -> format ( 'Y-m-d H:i:s' ) ; } elseif ( is_array ( $ value ) ) { $ props [ $ property ] = serialize ( $ value ) ; } elseif ( ...
Convert complex objects to strings to insert into the database .
19,169
public function save ( ) { global $ wpdb ; $ props = $ this -> properties ( ) ; $ props = $ this -> flatten_props ( $ props ) ; if ( is_null ( $ props [ static :: get_primary_key ( ) ] ) ) { $ wpdb -> insert ( $ this -> get_table ( ) , $ props ) ; $ this -> { static :: get_primary_key ( ) } = $ wpdb -> insert_id ; } el...
Save this model to the database . Will create a new record if the ID property isn t set or update an existing record if the ID property is set .
19,170
public static function find_one_by ( $ property , $ value ) { global $ wpdb ; $ value = esc_sql ( $ value ) ; $ table = static :: get_table ( ) ; $ obj = $ wpdb -> get_row ( "SELECT * FROM `{$table}` WHERE `{$property}` = '{$value}'" , ARRAY_A ) ; return ( $ obj ? static :: create ( $ obj ) : false ) ; }
Find a specific model by a given property value .
19,171
public static function query ( ) { $ query = new Query ( get_called_class ( ) ) ; $ query -> set_searchable_fields ( static :: get_searchable_fields ( ) ) ; $ query -> set_primary_key ( static :: get_primary_key ( ) ) ; return $ query ; }
Start a query to find models matching specific criteria .
19,172
public static function all ( ) { global $ wpdb ; $ table = static :: get_table ( ) ; $ results = $ wpdb -> get_results ( "SELECT * FROM `{$table}`" ) ; foreach ( $ results as $ index => $ result ) { $ results [ $ index ] = static :: create ( ( array ) $ result ) ; } return $ results ; }
Return EVERY instance of this model from the database with NO filtering .
19,173
public function ChapterTitle ( $ num , $ title ) { $ this -> SetFont ( 'helvetica' , '' , 14 ) ; $ this -> SetFillColor ( 200 , 220 , 255 ) ; $ this -> Cell ( 180 , 6 , 'Chapter ' . $ num . ' : ' . $ title , 0 , 1 , '' , 1 ) ; $ this -> Ln ( 4 ) ; }
Set chapter title
19,174
public function ChapterBody ( $ file , $ mode = false ) { $ this -> selectColumn ( ) ; $ content = file_get_contents ( $ file , false ) ; $ this -> SetFont ( 'times' , '' , 9 ) ; $ this -> SetTextColor ( 50 , 50 , 50 ) ; if ( $ mode ) { $ this -> writeHTML ( $ content , true , false , true , false , 'J' ) ; } else { $ ...
Print chapter body
19,175
public function update_metadata ( $ meta_key , $ meta_value ) { $ this -> meta [ $ meta_key ] = $ meta_value ; update_user_meta ( $ this -> ID , $ meta_key , $ meta_value ) ; }
Update the user s meta data .
19,176
public static function decodeFilterASCIIHexDecode ( $ data ) { $ decoded = '' ; $ data = preg_replace ( '/[\s]/' , '' , $ data ) ; $ eod = strpos ( $ data , '>' ) ; if ( $ eod !== false ) { $ data = substr ( $ data , 0 , $ eod ) ; $ eod = true ; } $ data_length = strlen ( $ data ) ; if ( ( $ data_length % 2 ) != 0 ) { ...
ASCIIHexDecode Decodes data encoded in an ASCII hexadecimal representation reproducing the original binary data .
19,177
protected function set_pagination_args ( array $ args ) { $ args = wp_parse_args ( $ args , array ( 'total_items' => 0 , 'total_pages' => 0 , 'per_page' => 0 ) ) ; if ( ! $ args [ 'total_pages' ] && $ args [ 'per_page' ] > 0 ) { $ args [ 'total_pages' ] = ceil ( $ args [ 'total_items' ] / $ args [ 'per_page' ] ) ; } if...
An internal method that sets all the necessary pagination arguments .
19,178
public function get_pagination_arg ( $ key ) { if ( 'page' == $ key ) { return $ this -> get_pagenum ( ) ; } if ( isset ( $ this -> pagination_args [ $ key ] ) ) { return $ this -> pagination_args [ $ key ] ; } }
Access the pagination args .
19,179
public function get_search_query ( $ escaped = true ) { $ s = isset ( $ _REQUEST [ 's' ] ) ? $ _REQUEST [ 's' ] : '' ; $ query = apply_filters ( 'get_search_query' , $ s ) ; if ( $ escaped ) { $ query = esc_attr ( $ query ) ; } return $ query ; }
Cause the real one doesn t work .
19,180
public function search_box ( $ text , $ input_id ) { if ( empty ( $ _REQUEST [ 's' ] ) && ! $ this -> has_items ( ) ) { return ; } $ input_id = $ input_id . '-search-input' ; if ( ! empty ( $ _REQUEST [ 'orderby' ] ) ) { echo '<input type="hidden" name="orderby" value="' . esc_attr ( $ _REQUEST [ 'orderby' ] ) . '">' ;...
Display the search box .
19,181
public function views ( ) { $ views = $ this -> get_views ( ) ; $ views = apply_filters ( 'views_' . $ this -> screen -> id , $ views ) ; if ( empty ( $ views ) ) { return ; } echo "<ul class='subsubsub'>\n" ; foreach ( $ views as $ class => $ view ) { $ views [ $ class ] = "\t<li class='$class'>$view" ; } echo implode...
Display the list of views available on this table .
19,182
public function bulk_actions ( ) { if ( is_null ( $ this -> actions ) ) { $ this -> actions = $ this -> get_bulk_actions ( ) ; $ this -> actions = apply_filters ( 'bulk_actions-' . $ this -> screen -> id , $ this -> actions ) ; $ two = '' ; } else { $ two = '2' ; } if ( empty ( $ this -> actions ) ) { return ; } echo "...
Display the bulk actions dropdown .
19,183
public function current_action ( ) { if ( isset ( $ _REQUEST [ 'action' ] ) && - 1 != $ _REQUEST [ 'action' ] ) { return $ _REQUEST [ 'action' ] ; } if ( isset ( $ _REQUEST [ 'action2' ] ) && - 1 != $ _REQUEST [ 'action2' ] ) { return $ _REQUEST [ 'action2' ] ; } return false ; }
Get the current action selected from the bulk actions dropdown .
19,184
protected function row_actions ( $ actions , $ always_visible = false ) { $ action_count = count ( $ actions ) ; $ i = 0 ; if ( ! $ action_count ) { return '' ; } $ out = '<div class="' . ( $ always_visible ? 'row-actions-visible' : 'row-actions' ) . '">' ; foreach ( $ actions as $ action => $ link ) { $ i ++ ; ( $ i =...
Generate row actions div
19,185
protected function view_switcher ( $ current_mode ) { $ modes = array ( 'list' => __ ( 'List View' ) , 'excerpt' => __ ( 'Excerpt View' ) ) ; ?> <input type="hidden" name="mode" value=" <?php echo esc_attr ( $ current_mode ) ; ?> " /> <div class="view-switch"> <?php foreach ( $ modes as $ mode => $ title ) { $ c...
Display a view switcher
19,186
protected function comments_bubble ( $ post_id , $ pending_comments ) { $ pending_phrase = sprintf ( __ ( '%s pending' ) , number_format ( $ pending_comments ) ) ; if ( $ pending_comments ) { echo '<strong>' ; } echo "<a href='" . esc_url ( add_query_arg ( 'p' , $ post_id , admin_url ( 'edit-comments.php' ) ) ) . "' ti...
Display a comment count bubble
19,187
public function get_pagenum ( ) { $ pagenum = isset ( $ _REQUEST [ 'paged' ] ) ? absint ( $ _REQUEST [ 'paged' ] ) : 0 ; if ( isset ( $ this -> pagination_args [ 'total_pages' ] ) && $ pagenum > $ this -> pagination_args [ 'total_pages' ] ) { $ pagenum = $ this -> pagination_args [ 'total_pages' ] ; } return max ( 1 , ...
Get the current page number
19,188
protected function get_items_per_page ( $ option , $ default = 20 ) { $ per_page = ( int ) get_user_option ( $ option ) ; if ( empty ( $ per_page ) || $ per_page < 1 ) { $ per_page = $ default ; } return ( int ) apply_filters ( $ option , $ per_page ) ; }
Get number of items to display on a single page
19,189
protected function pagination ( $ which ) { if ( empty ( $ this -> pagination_args ) ) { return ; } extract ( $ this -> pagination_args , EXTR_SKIP ) ; $ output = '<span class="displaying-num">' . sprintf ( _n ( '1 item' , '%s items' , $ total_items ) , number_format_i18n ( $ total_items ) ) . '</span>' ; $ current = $...
Display the pagination .
19,190
protected function get_column_info ( ) { if ( isset ( $ this -> column_headers ) ) { return $ this -> column_headers ; } $ columns = get_column_headers ( $ this -> screen ) ; $ hidden = get_hidden_columns ( $ this -> screen ) ; $ _sortable = apply_filters ( "manage_{$this->screen->id}_sortable_columns" , $ this -> get_...
Get a list of all hidden and sortable columns with filter applied
19,191
public function get_column_count ( ) { list ( $ columns , $ hidden ) = $ this -> get_column_info ( ) ; $ hidden = array_intersect ( array_keys ( $ columns ) , array_filter ( $ hidden ) ) ; return count ( $ columns ) - count ( $ hidden ) ; }
Return number of visible columns .
19,192
protected function print_column_headers ( $ with_id = true ) { list ( $ columns , $ hidden , $ sortable ) = $ this -> get_column_info ( ) ; $ current_url = set_url_scheme ( 'http://' . $ _SERVER [ 'HTTP_HOST' ] . $ _SERVER [ 'REQUEST_URI' ] ) ; $ current_url = remove_query_arg ( 'paged' , $ current_url ) ; if ( isset (...
Print column headers accounting for hidden and sortable columns .
19,193
protected function display_tablenav ( $ which ) { if ( 'top' == $ which ) { wp_nonce_field ( 'bulk-' . $ this -> args [ 'plural' ] ) ; } ?> <div class="tablenav <?php echo esc_attr ( $ which ) ?> "> <div class="alignleft actions"> <?php $ this -> bulk_actions ( ) ?> </div> <?php $ this -> extra_tabl...
Generate the table navigation above or below the table .
19,194
protected function single_row_columns ( $ item ) { list ( $ columns , $ hidden ) = $ this -> get_column_info ( ) ; foreach ( $ columns as $ column_name => $ column_display_name ) { $ class = "class='$column_name column-$column_name'" ; $ style = '' ; if ( in_array ( $ column_name , $ hidden ) ) { $ style = ' style="dis...
Generates the columns for a single row of the table .
19,195
protected function js_vars ( ) { $ args = array ( 'class' => get_class ( $ this ) , 'screen' => array ( 'id' => $ this -> screen -> id , 'base' => $ this -> screen -> base , ) ) ; printf ( "<script type='text/javascript'>list_args = %s;</script>\n" , json_encode ( $ args ) ) ; }
Send required variables to JavaScript land .
19,196
public function find ( $ only_count = false ) { global $ wpdb ; $ model = $ this -> model ; if ( $ only_count ) { return ( int ) $ wpdb -> get_var ( $ this -> compose_query ( true ) ) ; } $ results = $ wpdb -> get_results ( $ this -> compose_query ( false ) ) ; if ( $ results ) { foreach ( $ results as $ index => $ res...
Compose & execute our query .
19,197
public function register ( ) { $ this -> binder = new BindingResolver ( [ $ this -> app , 'make' ] ) ; $ this -> app -> instance ( 'bindingResolver' , $ this -> binder ) ; $ this -> dispatcher = new FastRouteDispatcher ( null ) ; $ this -> dispatcher -> setBindingResolver ( $ this -> binder ) ; $ this -> dispatcher -> ...
Register the service by registering our custom dispatcher .
19,198
protected function getRoutesResolver ( ) { return function ( ) { $ routeCollector = new RouteCollector ( new RouteParser , new DataGenerator ) ; foreach ( $ this -> getRoutes ( ) as $ route ) { $ routeCollector -> addRoute ( $ route [ 'method' ] , $ route [ 'uri' ] , $ route [ 'action' ] ) ; } return $ routeCollector -...
Get route resolver used to get routes data when the request is dispatched .
19,199
protected function getRoutes ( ) { $ router = property_exists ( $ this -> app , 'router' ) ? $ this -> app -> router : $ this -> app ; return $ router -> getRoutes ( ) ; }
Get routes data .