idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
10,200
public function descTable ( $ table ) { $ sql = "DESC `{$table}`" ; $ fields = $ this -> getResults ( $ sql ) ; $ desc = [ ] ; $ count = 0 ; $ before = false ; foreach ( $ fields as $ field ) { $ field [ 'First' ] = $ count === 0 ; $ field [ 'Before' ] = $ before ; $ desc [ $ field [ 'Field' ] ] = $ field ; $ before = ...
describe table .
10,201
public function apply ( $ schema , $ columns = null , $ notation = null ) { if ( is_string ( $ schema ) ) { $ schema = [ $ schema => is_string ( $ columns ) ? [ $ columns => $ notation ] : $ columns , ] ; } if ( ! $ schema || count ( $ schema ) == 0 || ! is_array ( $ schema ) ) { $ this -> error ( 'generic' , 'empty sc...
Apply schema on the database .
10,202
public function applyTable ( $ table , $ schema , $ parse = true ) { $ queries = $ this -> diffTable ( $ table , $ schema , $ parse ) ; if ( $ queries && count ( $ queries ) > 0 ) { foreach ( $ queries as $ sql ) { $ this -> execute ( $ sql ) ; } } return $ queries ; }
Update database table via schema .
10,203
public function diff ( $ schema , $ parse = true ) { if ( $ parse ) { $ this -> getParser ( ) -> parse ( $ schema ) ; } $ queries = [ ] ; foreach ( $ schema as $ table => & $ attributes ) { $ table = $ parse ? $ this -> getPrefix ( $ table ) : $ table ; $ query = $ this -> diffTable ( $ table , $ attributes , false ) ;...
Generate SQL query to align database compare real database and passed schema .
10,204
private function diffTableFieldAttributes ( $ field , & $ attributes , & $ fields ) { foreach ( $ fields [ $ field ] as $ key => $ value ) { if ( $ attributes [ $ key ] == $ value ) { continue ; } if ( $ this -> isDebug ( ) ) { } return true ; } return false ; }
Evaluate diff between a field and their attributes vs fields set definitions releaved direct from db .
10,205
public function profile ( $ values ) { $ profile = [ ] ; foreach ( array_keys ( $ values ) as $ field ) { $ profile [ $ field ] = '' ; } return $ profile ; }
Get values profile .
10,206
private function getUpdateWhere ( $ query , & $ params ) { $ whereArray = [ ] ; if ( isset ( $ query [ 'where' ] ) ) { $ whereArray [ ] = '(' . $ query [ 'where' ] . ')' ; unset ( $ query [ 'where' ] ) ; } foreach ( $ query as $ field => $ value ) { if ( $ field [ 0 ] == ':' ) { $ params [ $ field ] = $ value ; continu...
Build where conditions .
10,207
public function getItems ( ) { if ( $ this -> isModulesFetched === false ) { $ this -> isModulesFetched = true ; foreach ( Yii :: $ app -> getModules ( ) as $ id => $ module ) { $ module = Yii :: $ app -> getModule ( $ id ) ; if ( method_exists ( $ module , 'coreMenu' ) ) { $ this -> addItems ( $ module -> coreMenu ( )...
Get all tree menu items
10,208
public function addItems ( array $ items , $ append = true ) { $ this -> _items = $ this -> mergeItems ( $ this -> _items , $ items , $ append ) ; }
Add tree menu items
10,209
public function getBreadcrumbs ( $ url = null ) { $ url = $ url ? : $ this -> getRequestedRoute ( ) ; $ itemModel = $ this -> getItem ( $ url , $ parents ) ; if ( ! $ itemModel || ( empty ( $ parents ) && $ this -> isHomeUrl ( $ itemModel -> normalizedUrl ) ) ) { return [ ] ; } $ parents = array_reverse ( ( array ) $ p...
Return breadcrumbs links for widget \ yii \ widgets \ Breadcrumbs
10,210
public function getItemUrl ( $ item ) { $ item = $ this -> getItem ( $ item ) ; return $ item ? $ item -> normalizedUrl : null ; }
Find item by url or route and return it url
10,211
protected function current ( ) { if ( $ this -> author ( ) === 'You ' ) { return 'You removed yourself from the "' . $ this -> wrappedObject -> new_value . '" group.' ; } return $ this -> author ( ) . 'removed you from the "' . $ this -> wrappedObject -> new_value . '" group.' ; }
Get the change description from the context of the change being made to the current user .
10,212
public static function load ( $ query , $ fields = null ) { static :: applySchema ( ) ; if ( is_array ( $ query ) ) { return static :: loadByQuery ( $ query , $ fields ) ; } $ key = static :: getPrimaryKey ( ) ; return $ key ? static :: loadByPrimaryKey ( $ query , $ fields ) : static :: loadByMainField ( $ query , $ f...
Load item from DB .
10,213
protected static function loadByPrimaryKey ( $ index , $ fields = null ) { $ table = static :: getTable ( ) ; $ key = static :: getPrimaryKey ( ) ; $ alias = static :: getClassName ( ) ; $ join = null ; $ requestedFields = $ fields ? $ fields : static :: getDefaultFields ( ) ; $ selectFields = static :: getDatabase ( )...
Load a record by primary key .
10,214
protected static function loadByQuery ( $ query , $ fields = null ) { $ table = static :: getTable ( ) ; $ writer = static :: getDatabase ( ) -> getWriter ( ) ; $ alias = static :: getClassName ( ) ; $ join = null ; $ allFields = $ fields ? $ fields : static :: getDefaultFields ( ) ; $ selectFields = $ writer -> select...
Load one record by array - query .
10,215
protected function initializeFromStorage ( ) { $ this -> debugLog ( 'initializeFromStorage()' ) ; $ this -> lists = $ this -> storage -> getLists ( ) ; $ this -> next_request_timestamp = $ this -> storage -> getNextRunTimestamp ( ) ; $ this -> error_count = $ this -> storage -> getErrorCount ( ) ; $ this -> debugLog ( ...
Initializes object state from storage backend
10,216
protected function serializeToStorage ( ) { $ this -> debugLog ( 'serializeToStorage()' ) ; $ this -> storage -> updateLists ( $ this -> lists ) ; $ this -> storage -> setUpdaterState ( $ this -> next_request_timestamp , $ this -> error_count ) ; $ this -> debugLog ( 'current memory usage: ' . memory_get_usage ( ) ) ; ...
stores object state to storage backend
10,217
public function setLists ( $ lists ) { $ this -> lists = $ lists ; $ this -> storage -> updateLists ( $ this -> lists ) ; }
Set the current lists
10,218
protected function pcntlSignalSetup ( ) { if ( function_exists ( 'pcntl_signal' ) ) { pcntl_signal ( SIGHUP , array ( $ this , 'exitSignalHandler' ) ) ; pcntl_signal ( SIGTERM , array ( $ this , 'exitSignalHandler' ) ) ; pcntl_signal ( SIGINT , array ( $ this , 'exitSignalHandler' ) ) ; $ this -> pcntl_enabled = true ;...
Set up signal handling if supported
10,219
private function prepareUsers ( array $ data ) { $ users = [ ] ; $ now = Carbon :: now ( ) ; foreach ( $ data as $ user ) { $ users [ ] = [ 'username' => $ user [ 'username' ] , 'first_name' => Arr :: get ( $ user , 'first_name' , null ) , 'last_name' => Arr :: get ( $ user , 'last_name' , null ) , 'email' => $ user [ ...
Prepare users .
10,220
public function getTranslation ( $ language = null ) { $ language = $ language ? : Yii :: $ app -> language ; $ translations = $ this -> getModelTranslations ( ) ; foreach ( $ translations as $ translation ) { if ( $ translation -> getAttribute ( $ this -> translationLanguageAttrName ) === $ language ) { $ this -> tran...
Returns translation entity object for needed language .
10,221
public function hasTranslation ( $ language = null ) { $ language = $ language ? : Yii :: $ app -> language ; foreach ( $ this -> getModelTranslations ( ) as $ translation ) { if ( $ translation -> getAttribute ( $ this -> translationLanguageAttrName ) === $ language ) { return true ; } } return false ; }
Check whether translation exists .
10,222
public function afterValidate ( ) { $ translations = $ this -> getModelTranslations ( ) ; $ isValid = Model :: validateMultiple ( $ translations , $ this -> translationAttributeList ) ; if ( ! $ isValid ) { foreach ( $ translations as $ translation ) { foreach ( $ translation -> getErrors ( ) as $ attribute => $ errors...
Triggers after validation of the main model .
10,223
public function afterSave ( ) { foreach ( $ this -> translationsBuffer as $ translation ) { $ this -> owner -> link ( $ this -> translationRelationName , $ translation ) ; } }
Triggers after saving of the main model .
10,224
public function setCacheDir ( $ cacheDir ) { if ( ! $ cacheDir ) { throw new \ InvalidArgumentException ( 'The parameter $cacheDir must not be empty.' ) ; } if ( ! is_dir ( $ cacheDir ) && ! mkdir ( $ cacheDir , 0777 , true ) ) { throw new \ RuntimeException ( 'Unable to create the directory "' . $ cacheDir . '"' ) ; }...
Sets the cache directory to use .
10,225
protected function setPermissions ( $ permissions ) { foreach ( $ permissions as $ action => $ permission ) { $ this -> setPermission ( $ action , $ permission ) ; } }
Set the permissions .
10,226
private function addColumnForOrdering ( $ builder , $ columnConfiguration , $ item , $ direction ) { $ c = $ this -> getColumnFromConfiguration ( $ columnConfiguration , $ item ) ; if ( $ c -> getOrder ( ) -> isOrderable ( ) ) { $ builder -> columnOrder ( $ c -> getName ( ) , $ direction ) ; } }
Add a column for ordering to the QueryConfigurationBuilder
10,227
private function setVersionFromRequest ( array $ versions ) { $ this -> setDefaultVersion ( $ versions ) ; foreach ( $ versions as $ v ) { if ( $ v -> canParseRequest ( ) ) { $ this -> version = $ v ; break ; } } }
Pick the verison of an engine that can parse a request .
10,228
protected function getLeadingLinePointer ( File $ phpcsFile , $ fromStackPtr , $ toStackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ fromToken = $ tokens [ $ fromStackPtr ] ; $ prevCommentPtr = $ phpcsFile -> findPrevious ( T_COMMENT , ( $ fromStackPtr - 1 ) , $ toStackPtr ) ; if ( $ prevCommentPtr === false ) {...
Returns leading comment stack pointer or own stack pointer when no comment found .
10,229
protected function getDisplayerClass ( ) { $ class = $ this -> wrappedObject -> revisionable_type ; do { if ( class_exists ( $ displayer = $ this -> generateDisplayerName ( $ class ) ) ) { return $ displayer ; } } while ( $ class = get_parent_class ( $ class ) ) ; throw new Exception ( 'No displayers could be found' ) ...
Get the relevant displayer class .
10,230
protected function generateDisplayerName ( $ class ) { $ shortArray = explode ( '\\' , $ class ) ; $ short = end ( $ shortArray ) ; $ field = studly_case ( $ this -> field ( ) ) ; $ temp = str_replace ( $ short , 'RevisionDisplayers\\' . $ short . '\\' . $ field . 'Displayer' , $ class ) ; return str_replace ( 'Model' ...
Generate a possible displayer class name .
10,231
public function field ( ) { if ( strpos ( $ this -> wrappedObject -> key , '_id' ) ) { return str_replace ( '_id' , '' , $ this -> wrappedObject -> key ) ; } return $ this -> wrappedObject -> key ; }
Get the change field .
10,232
public function wasByCurrentUser ( ) { return $ this -> credentials -> check ( ) && $ this -> credentials -> getUser ( ) -> id == $ this -> wrappedObject -> user_id ; }
Was the event invoked by the current user?
10,233
public function deleteProfile ( ) { $ user = Credentials :: getUser ( ) ; $ this -> checkUser ( $ user ) ; $ email = $ user -> getLogin ( ) ; Credentials :: logout ( ) ; try { $ user -> delete ( ) ; } catch ( \ Exception $ e ) { return Redirect :: to ( Config :: get ( 'credentials.home' , '/' ) ) -> with ( 'error' , 'T...
Delete the user s profile .
10,234
public function patchDetails ( ) { $ input = Binput :: only ( [ 'first_name' , 'last_name' , 'email' ] ) ; $ val = UserRepository :: validate ( $ input , array_keys ( $ input ) ) ; if ( $ val -> fails ( ) ) { return Redirect :: route ( 'account.profile' ) -> withInput ( ) -> withErrors ( $ val -> errors ( ) ) ; } $ use...
Update the user s details .
10,235
public function checkShort ( File $ phpcsFile , $ stackPtr , $ short , $ errorPos ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ classToken = null ; foreach ( $ tokens [ $ stackPtr ] [ 'conditions' ] as $ condPtr => $ condition ) { if ( $ condition === T_CLASS || $ condition === T_INTERFACE || $ condition === T_TRAIT ...
Process the short description of a function comment .
10,236
public function fetch ( $ type = SQLAnywhereClient :: FETCH_ASSOC ) { $ data = null ; if ( $ this -> result ) { switch ( $ type ) { case 'array' : $ data = sasql_fetch_array ( $ this -> result ) ; break ; case 'assoc' : $ data = sasql_fetch_assoc ( $ this -> result ) ; break ; case 'row' : $ data = sasql_fetch_row ( $ ...
Return one row of result
10,237
public function fetchAll ( $ type = SQLAnywhereClient :: FETCH_ASSOC ) { $ data = array ( ) ; if ( $ this -> result ) { switch ( $ type ) { case 'array' : while ( $ row = sasql_fetch_array ( $ this -> result ) ) array_push ( $ data , $ row ) ; break ; case 'assoc' : while ( $ row = sasql_fetch_assoc ( $ this -> result ...
Return All values of Results in one choose format
10,238
public function authorize ( ) { $ this -> application -> loadAppToken ( ) ; if ( ! $ this -> application -> haveAppToken ( ) ) { $ this -> askAuthorization ( ) ; while ( in_array ( $ this -> status , [ self :: STATUS_UNKNOWN , self :: STATUS_PENDING ] ) ) { $ this -> getAuthorizationStatus ( ) ; if ( $ this -> status =...
Check if an app token is defined and launch the association process otherwise
10,239
private function encodePaths ( array $ paths ) { $ paths_b64 = [ ] ; foreach ( $ paths as $ path ) { $ paths_b64 [ ] = $ this -> encodePath ( $ path ) ; } return $ paths_b64 ; }
Base64 encode paths
10,240
public function archive ( array $ fileParts , $ destination ) { $ destination_b64 = $ this -> encodePath ( $ destination ) ; $ fileParts_b64 = $ this -> encodePaths ( $ fileParts ) ; $ result = $ this -> callService ( 'POST' , self :: API_FS_ARCHIVE , [ 'files' => $ fileParts_b64 , 'dst' => $ destination_b64 , ] ) ; re...
Create an archive
10,241
public function extract ( $ source , $ destination , $ password = '' , $ isToDelete = false , $ isToOverwrite = false ) { $ source_b64 = $ this -> encodePath ( $ source ) ; $ destination_b64 = $ this -> encodePath ( $ destination ) ; $ result = $ this -> callService ( 'POST' , self :: API_FS_EXTRACT , [ 'src' => $ sour...
Extract an archive
10,242
public function repair ( $ source , $ isToDelete = false ) { $ source_b64 = $ this -> encodePath ( $ source ) ; $ result = $ this -> callService ( 'POST' , self :: API_FS_REPAIR , [ 'src' => $ source_b64 , 'delete_archive' => $ isToDelete , ] ) ; return $ result -> getModel ( models \ FileSystem \ FsTask :: class ) ; }
Repair files from a . par2
10,243
public function createDirectory ( $ parentDirectory , $ newDirectoryName ) { $ result = $ this -> callService ( 'POST' , self :: API_FS_MKDIR , [ 'parent' => $ this -> encodePath ( $ parentDirectory ) , 'dirname' => $ newDirectoryName , ] ) ; return $ result -> getSuccess ( ) ; }
Create a directory Contrary to other file system tasks this operation is done synchronously . Instead of a returning a FsTask a call to this API will only return success status
10,244
public static function create ( $ name = null , $ data = null , \ Closure $ ready = null ) { $ task = new self ( $ data ) ; $ task -> name ( $ name ) ; if ( is_callable ( $ ready ) ) { call_user_func ( $ ready , $ task ) ; } return $ task ; }
create a new task .
10,245
protected function beforeRun ( ) { $ this -> reset ( ) ; $ pass = $ this -> callHookHandler ( 'beforeRun' ) ; if ( $ pass ) { $ this -> status = static :: RUNNING ; $ this -> time [ 'started_at' ] = microtime ( ) ; } return $ pass ; }
before run task .
10,246
protected function reset ( ) { $ this -> status = null ; $ this -> results = [ ] ; $ this -> currentDriver = null ; $ this -> time [ 'started_at' ] = 0 ; $ this -> time [ 'finished_at' ] = 0 ; return $ this ; }
reset states .
10,247
protected function afterRun ( $ success ) { $ this -> status = static :: FINISHED ; $ this -> time [ 'finished_at' ] = microtime ( ) ; $ return = [ ] ; $ return [ 'success' ] = $ success ; $ return [ 'time' ] = $ this -> time ; $ return [ 'logs' ] = $ this -> results ; $ data = $ this -> callHookHandler ( 'afterRun' , ...
after run task .
10,248
public function runDriver ( $ name ) { $ driver = $ this -> getDriver ( $ name ) ; if ( ! $ driver ) { return false ; } $ this -> currentDriver = $ driver ; $ currentDriverEnable = $ this -> callHookHandler ( 'beforeDriverRun' , $ driver ) ; if ( ! $ currentDriverEnable ) { return $ this -> tryNextDriver ( ) ; } $ resu...
run driver by name .
10,249
public function tryNextDriver ( ) { $ backupDriverName = array_pop ( $ this -> backupDrivers ) ; if ( $ backupDriverName ) { return $ this -> runDriver ( $ backupDriverName ) ; } return false ; }
try to use next backup driver .
10,250
public function getDriverNameByWeight ( ) { $ count = $ base = 0 ; $ map = [ ] ; foreach ( $ this -> drivers as $ driver ) { $ count += $ driver -> weight ; if ( $ driver -> weight ) { $ max = $ base + $ driver -> weight ; $ map [ ] = [ 'min' => $ base , 'max' => $ max , 'driver' => $ driver -> name , ] ; $ base = $ ma...
get a driver s name from drivers by driver s weight .
10,251
public function driver ( ) { $ args = func_get_args ( ) ; $ props = Driver :: parseArgs ( $ args ) ; $ newProps = $ this -> callHookHandler ( 'beforeCreateDriver' , $ props ) ; if ( is_array ( $ newProps ) ) { $ props = array_merge ( $ props , $ newProps ) ; } extract ( $ props ) ; $ driver = Driver :: create ( $ this ...
create a new driver instance for current task .
10,252
public function removeDriver ( $ driver ) { if ( $ driver instanceof Driver ) { $ driver = $ driver -> name ; } if ( ! $ this -> hasDriver ( $ driver ) ) { return ; } $ this -> removeFromBackupDrivers ( $ driver ) ; unset ( $ this -> drivers [ $ driver ] ) ; }
remove driver .
10,253
public function initBackupDrivers ( array $ excepted = [ ] ) { $ this -> backupDrivers = [ ] ; foreach ( $ this -> drivers as $ name => $ driver ) { if ( $ driver -> backup && ! in_array ( $ name , $ excepted ) ) { array_unshift ( $ this -> backupDrivers , $ name ) ; } } }
initialize back up drivers .
10,254
public function appendToBackupDrivers ( $ driver ) { if ( $ driver instanceof Driver ) { $ driver = $ driver -> name ; } if ( ! in_array ( $ driver , $ this -> backupDrivers ) ) { array_push ( $ this -> backupDrivers , $ driver ) ; } }
append driver to backup drivers .
10,255
public function removeFromBackupDrivers ( $ driver ) { if ( $ driver instanceof Driver ) { $ driver = $ driver -> name ; } if ( in_array ( $ driver , $ this -> backupDrivers ) ) { $ index = array_search ( $ driver , $ this -> backupDrivers ) ; array_splice ( $ this -> backupDrivers , $ index , 1 ) ; } }
remove driver from backup drivers .
10,256
public function name ( $ name ) { if ( ! is_string ( $ name ) || empty ( $ name ) ) { throw new TaskBalancerException ( 'Expected task name to be a non-empty string.' ) ; } $ this -> name = $ name ; return $ this ; }
set the name of task .
10,257
public function hook ( $ hookName , $ handler = null , $ override = false ) { if ( is_callable ( $ handler ) && is_string ( $ hookName ) ) { if ( in_array ( $ hookName , self :: $ hooks ) ) { if ( ! isset ( $ this -> handlers [ $ hookName ] ) ) { $ this -> handlers [ $ hookName ] = [ ] ; } if ( $ override ) { $ this ->...
set hook s handlers .
10,258
protected function callHookHandler ( $ hookName , $ data = null ) { if ( array_key_exists ( $ hookName , $ this -> handlers ) ) { $ handlers = $ this -> handlers [ $ hookName ] ? : [ ] ; $ result = null ; foreach ( $ handlers as $ index => $ handler ) { $ handlerArgs = $ data === null ? [ $ this , $ index , & $ handler...
call hook s handlers .
10,259
public function sortInjections ( $ group = null ) { if ( $ group ) { usort ( $ this -> groupedInjections [ $ group ] , [ $ this , 'sortInjection' ] ) ; } else { foreach ( $ this -> groupedInjections as $ injections ) { usort ( $ injections , [ $ this , 'sortInjection' ] ) ; } } }
Sort by priority ASC .
10,260
static protected function sortInjection ( BasicInjectionContract $ a , BasicInjectionContract $ b ) { if ( $ a -> priority ( ) == $ b -> priority ( ) ) { return 0 ; } return ( $ a -> priority ( ) < $ b -> priority ( ) ) ? - 1 : 1 ; }
Custom function for usort used by sortAllInjections .
10,261
public function setStatusHeader ( $ status , $ protocol = null ) { if ( is_null ( $ protocol ) && isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ) { $ protocol = $ _SERVER [ 'SERVER_PROTOCOL' ] ; } elseif ( is_null ( $ protocol ) && ! isset ( $ _SERVER [ 'SERVER_PROTOCOL' ] ) ) { $ protocol = 'HTTP/1.1' ; } $ this -> status...
Set the HTTP status header
10,262
public function sendAllHeaders ( ) { if ( $ this -> status_header !== null ) { header ( $ this -> status_header ) ; } foreach ( $ this -> headers as $ name => $ value ) { header ( $ name . ': ' . $ value ) ; } }
Send all headers at once
10,263
public function getRouterJavascriptResponse ( ) { $ fh = fopen ( 'php://temp' , 'rw' ) ; $ stream = new Stream ( $ fh ) ; $ stream -> write ( $ this -> getRouterJavascript ( ) ) ; return ( new Response ( ) ) -> withBody ( $ stream ) -> withHeader ( 'Content-Type' , 'application/javascript' ) ; }
Returns a Response object for returning the router Javascript code as HTTP response .
10,264
protected function newModelInstance ( ) { if ( is_null ( $ this -> fullModelClassName ) ) { $ this -> fullModelClassName = $ this -> model ( ) ; } return new $ this -> fullModelClassName ; }
Make a new Model instance .
10,265
protected function getConfig ( $ key , $ default = null ) { $ config = $ this -> getApp ( ) -> make ( 'config' ) ; return $ config -> get ( $ key , $ default ) ; }
Read configure from configure file if it s not exists default will be returned .
10,266
protected function initialize ( ) { $ this -> injectionContainer = new InjectionContainer ( ) ; $ model = $ this -> newModelInstance ( ) ; if ( ! $ model instanceof Model ) { throw new RepositoryException ( "Class \"" . get_class ( $ model ) . "\" must be an instance of " . Model :: class ) ; } $ this -> perPage = $ th...
Validate the model that provided by model method and load configures .
10,267
protected function resetPlan ( ) { $ this -> defaultPlan = new Plan ( $ this -> newModelInstance ( ) ) ; $ this -> plans = [ ] ; $ this -> planStep = null ; }
Reset the Plan object for the next use .
10,268
public function paginate ( $ limit = null , $ columns = [ '*' ] , $ pageName = 'page' , $ page = null ) { return $ this -> simpleWrap ( Action :: READ , [ $ this , '_paginate' ] ) ; }
Same as the paginate method of Eloquent .
10,269
public function getByField ( $ field , $ value = null , $ columns = [ '*' ] ) { return $ this -> simpleWrap ( Action :: READ , [ $ this , '_getByField' ] ) ; }
Get models by a simple equality query .
10,270
protected function generateNonce ( ) { $ nonce = '' ; for ( $ i = 0 ; $ i < 64 ; $ i ++ ) { $ nonce .= chr ( mt_rand ( 33 , 126 ) ) ; } return base64_encode ( $ nonce ) ; }
Generate a nonce for each request
10,271
public function getRedirections ( ) { $ rest = $ this -> getService ( self :: API_UPNP_IGD_REDIRECTION ) ; $ rest -> GET ( ) ; return $ rest -> getResultAsArray ( models \ UPnP \ UpnpIgdRedirection :: class ) ; }
Get the list of current redirection
10,272
public function deleteRedirectionFromId ( $ redirectionId ) { $ rest = $ this -> getService ( self :: API_UPNP_IGD_REDIRECTION . $ redirectionId ) ; $ rest -> DELETE ( ) ; return $ rest -> getSuccess ( ) ; }
Delete a redirection
10,273
public function getReservations ( ) { $ rest = $ this -> getService ( self :: API_VPN_IPPOOL ) ; $ rest -> GET ( ) ; return $ rest -> getResult ( ) ; }
Get the VPN server IP pool reservations
10,274
public function disable ( PaymentInstrumentInterface $ paymentInstrument ) : ? bool { $ uri = $ this -> getEndPoint ( ) . '/' . $ paymentInstrument -> getToken ( ) ; return $ this -> request ( 'delete' , $ paymentInstrument , $ uri ) ; }
Delete an paymentInstrument from server .
10,275
protected function createFlashNotifier ( $ alerts ) { if ( $ session = $ this -> createSession ( ) ) { $ alerts -> addNotifier ( new FlashNotifier ( 'flash' , static :: $ config , $ session ) ) ; } }
Creates and adds a new flash notifier .
10,276
protected function createSession ( ) { if ( class_exists ( 'Illuminate\Filesystem\Filesystem' ) && class_exists ( 'Illuminate\Session\FileSessionHandler' ) ) { $ fileSessionHandler = new FileSessionHandler ( new Filesystem ( ) , __DIR__ . '/../../../../../storage/sessions' , 5 ) ; $ store = new Store ( 'alerts' , $ fil...
Creates a session instance .
10,277
public function addFromUrl ( $ download_url , $ download_dir = null , $ recursive = false , $ username = null , $ password = null , $ archive_password = null , $ cookies = null ) { $ this -> addFromUrls ( [ $ download_url ] , $ download_dir , $ recursive , $ username , $ password , $ archive_password , $ cookies ) ; }
Add a download task with the specified URL
10,278
public function addFromUrls ( $ download_urls = [ ] , $ download_dir = null , $ recursive = false , $ username = null , $ password = null , $ archive_password = null , $ cookies = null ) { $ params = [ ] ; if ( empty ( $ download_urls ) ) { throw new \ Exception ( 'At lease one url is needed' ) ; } if ( count ( $ downl...
Add a download task with all the specified URLs
10,279
public function updateFilePriority ( $ downloadTaskId , $ FileId , $ Priority ) { $ Service = sprintf ( self :: API_DOWNLOAD_FILES , $ downloadTaskId ) ; $ rest = $ this -> getService ( $ Service . DIRECTORY_SEPARATOR . $ FileId ) ; $ rest -> PUT ( [ 'priority' => $ Priority , ] ) ; return $ rest -> getSuccess ( ) ; }
Update a download priority
10,280
public function handle ( ) { $ this -> header_manager -> addHeader ( "Access-Control-Allow-Origin" , join ( ', ' , $ this -> cors_allowed_origin ) ) ; $ http_methods_allowed = HttpMethods :: getMethodsWhereRequestBodyIsAllowed ( ) ; $ http_methods_allowed [ ] = HttpMethods :: GET ; if ( in_array ( $ this -> getMethod (...
This is the main method every webserver must have called
10,281
protected function handleCorsPreflightRequest ( ) { $ existing_verbs = array ( ) ; foreach ( HttpMethods :: getAllMethods ( ) as $ http_verb ) { if ( isset ( $ this -> map [ $ http_verb ] ) ) { $ urls = $ this -> map [ $ http_verb ] ; foreach ( array_keys ( $ urls ) as $ url ) { if ( strstr ( $ url , '$' ) ) { $ matche...
Handle CORS preflight requests automatically
10,282
public function handleError ( $ status_code , $ error_message = null ) { $ method = "handle$status_code" ; foreach ( $ this -> errorClasses as $ class ) { $ reflection = Utilities :: reflectionClassFromObjectOrClass ( $ class ) ; if ( isset ( $ reflection ) && $ reflection -> hasMethod ( $ method ) ) { $ obj = is_strin...
Handles all error cases . Mostly sets a header and formats an error message to respond to the client
10,283
public function getFormat ( ) { if ( $ this -> format !== null ) { return $ this -> format ; } $ format = $ this -> default_format ; if ( isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ) { $ accept_header = Utilities :: sortByPriority ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ; foreach ( $ accept_header as $ mime_type => $ priority ) { i...
Determine the requested format by the API client
10,284
public function setRoot ( $ root ) { if ( empty ( $ root ) ) { return null ; } $ root = trim ( $ root , '/' ) ; $ root .= '/' ; $ this -> root = $ root ; }
Set an URL prefix
10,285
public function setDefaultFormat ( $ mime_type ) { if ( Format :: isMimeTypeSupported ( $ mime_type ) ) { $ this -> default_format = $ mime_type ; return true ; } else { return false ; } }
Setting a default output format .
10,286
public function getAll ( ) { $ rest = $ this -> getService ( self :: API_WIFI_MAC_FILTER ) ; $ rest -> GET ( ) ; return $ rest -> getResultAsArray ( models \ WiFi \ MacFilter :: class ) ; }
Get all MacFilters
10,287
public function getFromId ( $ MacFilterId ) { $ rest = $ this -> getService ( self :: API_WIFI_MAC_FILTER . $ MacFilterId ) ; $ rest -> GET ( ) ; return $ rest -> getResult ( models \ WiFi \ MacFilter :: class ) ; }
Get a specific MacFilter
10,288
public function update ( models \ WiFi \ MacFilter $ MacFilter ) { $ rest = $ this -> getService ( self :: API_WIFI_MAC_FILTER . $ MacFilter -> getId ( ) ) ; $ rest -> PUT ( $ MacFilter ) ; return $ rest -> getResult ( models \ WiFi \ MacFilter :: class ) ; }
Update a MacFilter
10,289
public function deleteFromId ( $ MacFilterId ) { $ rest = $ this -> getService ( self :: API_WIFI_MAC_FILTER . $ MacFilterId ) ; $ rest -> DELETE ( ) ; return $ rest -> getSuccess ( ) ; }
Delete a MacFilter with the specified id
10,290
public function add ( models \ WiFi \ MacFilter $ MacFilter ) { $ rest = $ this -> getService ( self :: API_WIFI_MAC_FILTER ) ; $ rest -> POST ( $ MacFilter ) ; return $ rest -> getResult ( models \ WiFi \ MacFilter :: class ) ; }
Add a new MacFilter
10,291
public static function getMimeTypeFromFormatAbbreviation ( $ format_abbreviation ) { if ( array_key_exists ( $ format_abbreviation , self :: $ formats ) ) { return self :: $ formats [ $ format_abbreviation ] ; } else { return false ; } }
Get the MIME type for a known format abbreviation
10,292
public function setQueueOptions ( array $ options = [ ] , $ queue = self :: PRIORITY_NORM ) { msg_set_queue ( $ this -> queues [ $ queue ] , $ options ) ; }
Setting the queue option
10,293
public function logOut ( ) { $ data [ "Envelope" ] = array ( "Body" => array ( "Logout" => "" ) , ) ; $ response = $ this -> _request ( $ data ) ; $ result = $ response [ "Envelope" ] [ "Body" ] [ "RESULT" ] ; return $ this -> _isSuccess ( $ result ) ; }
Terminate the session with Silverpop .
10,294
public function getLists ( $ listType = 2 , $ isPrivate = true , $ folder = null ) { $ data [ "Envelope" ] = array ( "Body" => array ( "GetLists" => array ( "VISIBILITY" => ( $ isPrivate ? '0' : '1' ) , "FOLDER_ID" => $ folder , "LIST_TYPE" => $ listType , ) , ) , ) ; $ response = $ this -> _request ( $ data ) ; $ resu...
Fetches the contents of a list
10,295
public function getMailingTemplates ( $ isPrivate = true ) { $ data [ "Envelope" ] = array ( "Body" => array ( "GetMailingTemplates" => array ( "VISIBILITY" => ( $ isPrivate ? '0' : '1' ) , ) , ) , ) ; $ response = $ this -> _request ( $ data ) ; $ result = $ response [ "Envelope" ] [ "Body" ] [ "RESULT" ] ; if ( $ thi...
Get mailing templates
10,296
public function getScheduledMailings ( ) { $ data [ 'Envelope' ] = array ( 'Body' => array ( 'GetSentMailingsForOrg' => array ( 'SCHEDULED' => null , ) , ) , ) ; $ response = $ this -> _request ( $ data ) ; $ result = $ response [ "Envelope" ] [ "Body" ] [ "RESULT" ] ; if ( $ this -> _isSuccess ( $ result ) ) { return ...
Get scheduled mailings
10,297
public function getListMetaData ( $ databaseID ) { $ data [ "Envelope" ] = array ( "Body" => array ( "GetListMetaData" => array ( "LIST_ID" => $ databaseID , ) , ) , ) ; $ response = $ this -> _request ( $ data ) ; $ result = $ response [ "Envelope" ] [ "Body" ] [ "RESULT" ] ; if ( $ this -> _isSuccess ( $ result ) ) {...
Get the meta information for a list
10,298
public function doubleOptInContact ( $ databaseID , $ email ) { $ data [ "Envelope" ] = array ( "Body" => array ( "DoubleOptInRecipient" => array ( "LIST_ID" => $ databaseID , "COLUMN" => array ( array ( 'NAME' => 'EMAIL' , 'VALUE' => $ email , ) , ) , ) , ) , ) ; $ response = $ this -> _request ( $ data ) ; $ result =...
Double opt in a contact
10,299
public function updateContact ( $ databaseID , $ oldEmail , $ columns , $ visitorKey = '' , $ syncFields = [ ] ) { $ data [ "Envelope" ] = array ( "Body" => array ( "UpdateRecipient" => array ( "LIST_ID" => $ databaseID , "OLD_EMAIL" => $ oldEmail , "CREATED_FROM" => 1 , "VISITOR_KEY" => $ visitorKey , "COLUMN" => arra...
Update a contact .