idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
6,200
|
public function saveAggregateRoots ( ) { foreach ( $ this -> aggregateRoots as $ aggregateRootHash => $ aggregateRoot ) { $ this -> aggregateRootSaveCallbacks [ $ aggregateRootHash ] -> save ( $ aggregateRoot ) ; } }
|
Triggers all saving callbacks on all staged aggregates .
|
6,201
|
public static function get ( string $ file , bool $ guess = true ) : string { if ( $ guess === true ) { $ extension = pathinfo ( $ file , PATHINFO_EXTENSION ) ; if ( isset ( self :: $ defaultMime [ $ extension ] ) ) { return self :: $ defaultMime [ $ extension ] ; } } $ info = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ info , $ file ) ; finfo_close ( $ info ) ; if ( false === $ mime ) { $ mime = 'application/octet-stream' ; } return $ mime ; }
|
Returns the mime type of a file .
|
6,202
|
public function getMailQueue ( ) : ? MailQueue { if ( ! $ this -> hasMailQueue ( ) ) { $ this -> setMailQueue ( $ this -> getDefaultMailQueue ( ) ) ; } return $ this -> mailQueue ; }
|
Get mail queue
|
6,203
|
public static function setColor ( $ color , $ string ) { if ( ! isset ( self :: $ colorTable [ $ color ] ) ) { throw new \ Exception ( 'ansi color is not defined' ) ; } return sprintf ( "\033[%sm%s\033[0m" , self :: $ colorTable [ $ color ] , $ string ) ; }
|
Make string appear in color
|
6,204
|
function get ( $ wsdl ) { $ filename = $ this -> createFilename ( $ wsdl ) ; if ( $ this -> obtainMutex ( $ filename , "r" ) ) { if ( $ this -> cache_lifetime > 0 ) { if ( file_exists ( $ filename ) && ( time ( ) - filemtime ( $ filename ) > $ this -> cache_lifetime ) ) { unlink ( $ filename ) ; $ this -> debug ( "Expired $wsdl ($filename) from cache" ) ; $ this -> releaseMutex ( $ filename ) ; return NULL ; } } if ( ! file_exists ( $ filename ) ) { $ this -> debug ( "$wsdl ($filename) not in cache (1)" ) ; $ this -> releaseMutex ( $ filename ) ; return NULL ; } $ fp = @ fopen ( $ filename , "r" ) ; if ( $ fp ) { $ s = implode ( "" , @ file ( $ filename ) ) ; fclose ( $ fp ) ; $ this -> debug ( "Got $wsdl ($filename) from cache" ) ; } else { $ s = NULL ; $ this -> debug ( "$wsdl ($filename) not in cache (2)" ) ; } $ this -> releaseMutex ( $ filename ) ; return ( ! is_null ( $ s ) ) ? unserialize ( $ s ) : NULL ; } else { $ this -> debug ( "Unable to obtain mutex for $filename in get" ) ; } return NULL ; }
|
gets a wsdl instance from the cache
|
6,205
|
function obtainMutex ( $ filename , $ mode ) { if ( isset ( $ this -> fplock [ md5 ( $ filename ) ] ) ) { $ this -> debug ( "Lock for $filename already exists" ) ; return FALSE ; } $ this -> fplock [ md5 ( $ filename ) ] = fopen ( $ filename . ".lock" , "w" ) ; if ( $ mode == "r" ) { return flock ( $ this -> fplock [ md5 ( $ filename ) ] , LOCK_SH ) ; } else { return flock ( $ this -> fplock [ md5 ( $ filename ) ] , LOCK_EX ) ; } }
|
obtains the local mutex
|
6,206
|
public function has ( $ primaryKey , $ column = null ) { if ( null === $ column ) { $ column = $ this -> getPrimaryKey ( ) ; } return ( boolean ) $ this -> app [ 'db' ] -> fetchColumn ( 'SELECT COUNT(:column) FROM ' . $ this -> getTable ( ) . ' WHERE ' . $ this -> getPrimaryKey ( ) . ' = :pk' , [ 'column' => $ column , 'pk' => $ primaryKey ] ) ; }
|
Indicate if a given entry exists .
|
6,207
|
public function insert ( array $ data ) { $ this -> normalizeDataColumns ( $ data ) ; $ this -> setSearchIndexableData ( $ data ) ; return $ this -> app [ 'db' ] -> insert ( $ this -> getTable ( ) , $ data ) ; }
|
Insert an entry .
|
6,208
|
public function update ( array $ data , $ primaryKey ) { $ this -> normalizeDataColumns ( $ data ) ; $ this -> setSearchIndexableData ( $ data ) ; return $ this -> app [ 'db' ] -> update ( $ this -> getTable ( ) , $ data , [ $ this -> getPrimaryKey ( ) => $ primaryKey ] ) ; }
|
Update an entry .
|
6,209
|
public function delete ( $ primaryKey ) { return $ this -> app [ 'db' ] -> delete ( $ this -> getTable ( ) , [ $ this -> getPrimaryKey ( ) => $ primaryKey ] ) ; }
|
Delete an entry .
|
6,210
|
public function getColumns ( $ bWithoutForeignKey = true , $ bAliased = true , $ bPrefixed = false ) { $ aColumns = $ this -> columns ; if ( $ bWithoutForeignKey ) { $ aColumns = $ this -> removeForeignKeyColumns ( $ aColumns ) ; } if ( $ bAliased ) { $ aColumns = $ this -> aliaseColumns ( $ aColumns , $ this -> getAlias ( ) ) ; } if ( $ bPrefixed ) { $ aColumns = $ this -> prefixeColumns ( $ aColumns , $ this -> getAlias ( ) ) ; } return $ aColumns ; }
|
Get the columns names .
|
6,211
|
public function getPrimaryKey ( $ bAliased = false ) { return $ bAliased ? $ this -> getAlias ( ) . '.' . $ this -> primaryKey : $ this -> primaryKey ; }
|
Get the table primary key .
|
6,212
|
public function loadQueues ( ContainerBuilder $ container , array $ config ) { foreach ( $ config as $ name => $ attributes ) { $ container -> setDefinition ( self :: getQueueServiceKey ( $ name ) , new Definition ( $ container -> getParameter ( 'llssqs.model.queue.class' ) , array ( new Reference ( LLSAWSExtension :: getServiceServiceKey ( $ attributes [ 'service' ] ) ) , new Reference ( 'llssqs.model.message.factory' ) , $ attributes [ 'name' ] ) ) ) ; } return $ this ; }
|
Load queues from user configuration
|
6,213
|
public function getConfigLoader ( ) : ? ConfigLoader { if ( ! $ this -> hasConfigLoader ( ) ) { $ this -> setConfigLoader ( $ this -> getDefaultConfigLoader ( ) ) ; } return $ this -> configLoader ; }
|
Get config loader
|
6,214
|
public function setHoverControl ( Control $ hoverControl ) { $ hoverControl -> checkId ( ) ; if ( $ hoverControl instanceof Scriptable ) { $ hoverControl -> setScriptEvents ( true ) ; } $ this -> hoverControl = $ hoverControl ; return $ this ; }
|
Set the Hover Control
|
6,215
|
public function setTooltipControl ( Control $ tooltipControl ) { $ tooltipControl -> checkId ( ) ; $ tooltipControl -> setVisible ( false ) ; $ this -> tooltipControl = $ tooltipControl ; return $ this ; }
|
Set the Tooltip Control
|
6,216
|
public function setLogin ( $ login ) { $ this -> login = ( string ) $ login ; $ this -> ip = null ; $ this -> port = null ; return $ this ; }
|
Set the server login
|
6,217
|
public function setIp ( $ ip , $ port = null ) { $ this -> login = null ; $ this -> ip = ( string ) $ ip ; if ( $ port ) { $ this -> setPort ( $ port ) ; } return $ this ; }
|
Set the server ip and port
|
6,218
|
protected function show_message ( $ msg , $ error = false ) { add_action ( "admin_notices" , function ( ) use ( $ msg , $ error ) { printf ( '<div class="%s"><p>%s</p></div>' , $ error ? 'error' : 'updated' , esc_html ( $ msg ) ) ; } ) ; }
|
Show message on admin screen
|
6,219
|
protected function publishToExchange ( Message $ message , \ AMQPExchange $ exchange ) { $ isPublished = $ exchange -> publish ( $ message -> getMessage ( ) , $ message -> getRoutingKey ( ) , $ message -> getFlags ( ) , $ message -> getAttributes ( ) ) ; if ( ! $ isPublished ) { throw FailedToPublishException :: fromMessage ( $ message ) ; } return $ isPublished ; }
|
Publish the message to AMQP exchange
|
6,220
|
public function setCountry ( Country $ v = null ) { if ( $ v === null ) { $ this -> setCountryId ( NULL ) ; } else { $ this -> setCountryId ( $ v -> getId ( ) ) ; } $ this -> aCountry = $ v ; if ( $ v !== null ) { $ v -> addCustomer ( $ this ) ; } return $ this ; }
|
Declares an association between this object and a Country object .
|
6,221
|
public function getCountry ( PropelPDO $ con = null , $ doQuery = true ) { if ( $ this -> aCountry === null && ( $ this -> country_id !== null ) && $ doQuery ) { $ this -> aCountry = CountryQuery :: create ( ) -> findPk ( $ this -> country_id , $ con ) ; } return $ this -> aCountry ; }
|
Get the associated Country object
|
6,222
|
public function initRemoteApps ( $ overrideExisting = true ) { if ( null !== $ this -> collRemoteApps && ! $ overrideExisting ) { return ; } $ this -> collRemoteApps = new PropelObjectCollection ( ) ; $ this -> collRemoteApps -> setModel ( 'RemoteApp' ) ; }
|
Initializes the collRemoteApps collection .
|
6,223
|
public function getRemoteApps ( $ criteria = null , PropelPDO $ con = null ) { $ partial = $ this -> collRemoteAppsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collRemoteApps || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collRemoteApps ) { $ this -> initRemoteApps ( ) ; } else { $ collRemoteApps = RemoteAppQuery :: create ( null , $ criteria ) -> filterByCustomer ( $ this ) -> find ( $ con ) ; if ( null !== $ criteria ) { if ( false !== $ this -> collRemoteAppsPartial && count ( $ collRemoteApps ) ) { $ this -> initRemoteApps ( false ) ; foreach ( $ collRemoteApps as $ obj ) { if ( false == $ this -> collRemoteApps -> contains ( $ obj ) ) { $ this -> collRemoteApps -> append ( $ obj ) ; } } $ this -> collRemoteAppsPartial = true ; } $ collRemoteApps -> getInternalIterator ( ) -> rewind ( ) ; return $ collRemoteApps ; } if ( $ partial && $ this -> collRemoteApps ) { foreach ( $ this -> collRemoteApps as $ obj ) { if ( $ obj -> isNew ( ) ) { $ collRemoteApps [ ] = $ obj ; } } } $ this -> collRemoteApps = $ collRemoteApps ; $ this -> collRemoteAppsPartial = false ; } } return $ this -> collRemoteApps ; }
|
Gets an array of RemoteApp objects which contain a foreign key that references this object .
|
6,224
|
public function countRemoteApps ( Criteria $ criteria = null , $ distinct = false , PropelPDO $ con = null ) { $ partial = $ this -> collRemoteAppsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collRemoteApps || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collRemoteApps ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getRemoteApps ( ) ) ; } $ query = RemoteAppQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByCustomer ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collRemoteApps ) ; }
|
Returns the number of related RemoteApp objects .
|
6,225
|
public function addRemoteApp ( RemoteApp $ l ) { if ( $ this -> collRemoteApps === null ) { $ this -> initRemoteApps ( ) ; $ this -> collRemoteAppsPartial = true ; } if ( ! in_array ( $ l , $ this -> collRemoteApps -> getArrayCopy ( ) , true ) ) { $ this -> doAddRemoteApp ( $ l ) ; if ( $ this -> remoteAppsScheduledForDeletion and $ this -> remoteAppsScheduledForDeletion -> contains ( $ l ) ) { $ this -> remoteAppsScheduledForDeletion -> remove ( $ this -> remoteAppsScheduledForDeletion -> search ( $ l ) ) ; } } return $ this ; }
|
Method called to associate a RemoteApp object to this object through the RemoteApp foreign key attribute .
|
6,226
|
public function initUserCustomerRelations ( $ overrideExisting = true ) { if ( null !== $ this -> collUserCustomerRelations && ! $ overrideExisting ) { return ; } $ this -> collUserCustomerRelations = new PropelObjectCollection ( ) ; $ this -> collUserCustomerRelations -> setModel ( 'UserCustomerRelation' ) ; }
|
Initializes the collUserCustomerRelations collection .
|
6,227
|
public function addUserCustomerRelation ( UserCustomerRelation $ l ) { if ( $ this -> collUserCustomerRelations === null ) { $ this -> initUserCustomerRelations ( ) ; $ this -> collUserCustomerRelationsPartial = true ; } if ( ! in_array ( $ l , $ this -> collUserCustomerRelations -> getArrayCopy ( ) , true ) ) { $ this -> doAddUserCustomerRelation ( $ l ) ; if ( $ this -> userCustomerRelationsScheduledForDeletion and $ this -> userCustomerRelationsScheduledForDeletion -> contains ( $ l ) ) { $ this -> userCustomerRelationsScheduledForDeletion -> remove ( $ this -> userCustomerRelationsScheduledForDeletion -> search ( $ l ) ) ; } } return $ this ; }
|
Method called to associate a UserCustomerRelation object to this object through the UserCustomerRelation foreign key attribute .
|
6,228
|
public function getQuote ( ) { if ( is_null ( $ this -> quotes ) ) return $ this -> no_quotes_message ; return $ this -> quotes [ rand ( 1 , sizeof ( $ this -> quotes ) - 1 ) ] ; }
|
Get single quote
|
6,229
|
public function getQuotesAsStore ( ) { if ( is_null ( $ this -> quotes ) ) return array ( array ( 'id' => 0 , 'quote' => $ this -> no_quotes_message ) ) ; $ return = array ( ) ; foreach ( $ this -> quotes as $ id => $ quote ) array_push ( $ return , array ( 'id' => $ id , 'quote' => $ quote ) ) ; return $ return ; }
|
Get all quotes as a store
|
6,230
|
private function getObserverList ( string $ name ) : \ SplObjectStorage { if ( empty ( $ this -> observerContainer [ $ name ] ) ) { $ this -> observerContainer [ $ name ] = new \ SplObjectStorage ( ) ; } return $ this -> observerContainer [ $ name ] ; }
|
Retrieve observer list .
|
6,231
|
private function hasObserver ( string $ name ) : bool { return ! empty ( $ this -> observerContainer [ $ name ] ) && $ this -> observerContainer [ $ name ] -> count ( ) ; }
|
Check whatever observer container has at least one observer .
|
6,232
|
public function when ( $ value , callable $ callback ) : CollectionInterface { if ( $ value ) { $ this -> generator = $ callback ( $ this ) -> generator ; } return $ this ; }
|
Apply the callback if the value is truthy .
|
6,233
|
public function flatten ( $ depth = INF ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ data ) use ( $ depth ) { $ lowerDepth = $ depth === INF ? INF : $ depth - 1 ; foreach ( $ data as $ key => $ datum ) { if ( $ lowerDepth >= 0 && is_iterable ( $ datum ) ) { $ collection = $ this :: make ( $ datum ) ; foreach ( $ collection -> flatten ( $ lowerDepth ) -> getIterator ( ) as $ item ) { yield $ item ; } } else { yield $ datum ; } } } ) ; }
|
Get a flattened array of the items in the collection .
|
6,234
|
public function flatMap ( callable $ callback , $ depth = INF ) : CollectionInterface { return $ this -> map ( $ callback ) -> flatten ( $ depth ) ; }
|
Map then flatten
|
6,235
|
public function flip ( ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ data ) { foreach ( $ data as $ key => $ item ) { yield $ item => $ key ; } } ) ; }
|
Flip the items in the collection .
|
6,236
|
public function keys ( ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ data ) { foreach ( $ data as $ key => $ value ) { yield $ key ; } } ) ; }
|
Get the keys of the collection items .
|
6,237
|
public function last ( callable $ callback = null , $ default = null ) { $ collection = $ callback ? $ this -> filter ( $ callback ) : $ this ; foreach ( $ collection -> all ( ) as $ key => $ value ) { } return isset ( $ value ) ? $ value : $ default ; }
|
Return the last element
|
6,238
|
private function accessKey ( $ mixed , $ key , $ givenKey = null ) { if ( is_callable ( $ key ) ) { return $ key ( $ mixed , $ givenKey ) ; } if ( is_string ( $ mixed ) || is_array ( $ mixed ) || $ mixed instanceof ArrayAccess ) { return $ mixed [ $ key ] ; } if ( is_object ( $ mixed ) ) { return $ mixed -> { $ key } ; } throw new InvalidArgumentException ( 'Invalid object type provided, cannot access key.' ) ; }
|
Get a value from a mixed key
|
6,239
|
public function append ( $ items , bool $ preserveKeys = true ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ data ) use ( $ items , $ preserveKeys ) { $ lists = [ $ data , self :: make ( $ items ) ] ; foreach ( $ lists as $ list ) { foreach ( $ list as $ key => $ item ) { if ( $ preserveKeys ) { yield $ key => $ item ; } else { yield $ item ; } } } } ) ; }
|
Append items onto this collection
|
6,240
|
public function combine ( $ values ) : CollectionInterface { if ( $ values instanceof IteratorAggregate ) { $ values = $ values -> getIterator ( ) ; } elseif ( is_array ( $ values ) ) { $ values = new ArrayIterator ( $ values ) ; } return $ this -> wrap ( function ( Iterator $ keys ) use ( $ values ) { foreach ( $ keys as $ key ) { yield $ key => $ values -> current ( ) ; $ values -> next ( ) ; } } ) ; }
|
Create a collection by using this collection for keys and another for its values .
|
6,241
|
public function put ( $ key , $ value ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ data ) use ( $ key , $ value ) { $ replaced = false ; foreach ( $ data as $ dataKey => $ datum ) { if ( $ key === $ dataKey ) { yield $ key => $ value ; $ replaced = true ; } else { yield $ dataKey => $ datum ; } } if ( ! $ replaced ) { yield $ key => $ value ; } } ) ; }
|
Put an item in the collection by key .
|
6,242
|
public function reduce ( callable $ callback , $ initial = null ) { foreach ( $ this -> generator as $ key => $ value ) { $ initial = $ callback ( $ initial , $ value , $ key ) ; } return $ initial ; }
|
Reduce the collection to a single value .
|
6,243
|
public function slice ( $ offset , $ length = null ) : CollectionInterface { if ( $ length < 0 ) { throw new InvalidArgumentException ( 'Negative slice lengths are not supported' ) ; } $ result = $ this ; if ( $ offset < 0 ) { $ result = $ this -> take ( $ offset ) ; } elseif ( $ offset > 0 ) { $ result = $ this -> offset ( $ offset ) ; } if ( $ length !== null ) { $ result = $ result -> take ( $ length ) ; } return $ result ; }
|
Slice the underlying collection array .
|
6,244
|
private function offset ( $ offset ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ iterator ) use ( $ offset ) { while ( $ offset -- > 0 && $ iterator -> valid ( ) ) { $ iterator -> next ( ) ; } while ( $ iterator -> valid ( ) ) { yield $ iterator -> key ( ) => $ iterator -> current ( ) ; $ iterator -> next ( ) ; } } ) ; }
|
Get items past an offset
|
6,245
|
public function takeFirst ( int $ count ) { return $ this -> wrap ( function ( Iterator $ data ) use ( $ count ) { $ first = true ; while ( $ count -- && $ data -> valid ( ) ) { if ( ! $ first ) { $ data -> next ( ) ; } yield $ data -> key ( ) => $ data -> current ( ) ; $ first = false ; } } ) ; }
|
Take items from the beginning of the collection
|
6,246
|
public function takeLast ( int $ count ) { return $ this -> wrap ( function ( Iterator $ data ) use ( $ count ) { $ limit = max ( 0 , $ count ) ; $ chunk = [ ] ; foreach ( $ data as $ key => $ datum ) { $ chunk [ ] = [ $ key , $ datum ] ; if ( count ( $ chunk ) > $ limit ) { array_shift ( $ chunk ) ; } } foreach ( $ chunk as $ item ) { [ $ key , $ datum ] = $ item ; yield $ key => $ datum ; } } ) ; }
|
Take items from the end of the collection
|
6,247
|
public function values ( ) : CollectionInterface { return $ this -> wrap ( function ( Iterator $ data ) { foreach ( $ data as $ item ) { yield $ item ; } } ) ; }
|
Reset the keys on the underlying array .
|
6,248
|
public function respond ( array $ data = [ ] , array $ headers = [ ] ) : JsonResponse { $ meta = [ 'meta' => [ 'server_time' => time ( ) , 'server_timezone' => date_default_timezone_get ( ) , 'api_version' => 'v1' , ] , ] ; return response ( ) -> json ( array_merge ( $ data , $ meta ) , $ this -> getStatusCode ( ) , $ headers ) ; }
|
Return JSON encoded response .
|
6,249
|
public function respondWithError ( $ code = null , $ message = null , array $ data = [ ] ) : JsonResponse { return $ this -> respond ( [ 'status' => [ 'type' => 'error' , 'message' => $ this -> getDefaultMessage ( $ code , $ message ) , 'code' => $ code , 'http_code' => $ this -> getStatusCode ( ) , ] , 'exception' => $ data , ] ) ; }
|
Return response with error .
|
6,250
|
public function respondWithSuccess ( array $ data = [ ] ) : JsonResponse { return $ this -> setStatusCode ( IlluminateResponse :: HTTP_OK ) -> respond ( [ 'status' => [ 'http_code' => $ this -> getStatusCode ( ) , ] , 'data' => $ data , ] ) ; }
|
Returns 200 response with data .
|
6,251
|
public function respondCreated ( $ code = ApiResponse :: CODE_SUCCESS , array $ data = [ ] , $ message = null ) : JsonResponse { return $ this -> setStatusCode ( IlluminateResponse :: HTTP_CREATED ) -> respond ( [ 'status' => [ 'type' => 'success' , 'message' => $ this -> getDefaultMessage ( $ code , $ message ) , 'code' => $ code , 'http_code' => $ this -> getStatusCode ( ) , ] , 'data' => $ data , ] ) ; }
|
Returns 201 response with data .
|
6,252
|
public function respondDeleted ( $ code = ApiResponse :: CODE_DELETED , array $ data = [ ] , $ message = null ) : JsonResponse { return $ this -> setStatusCode ( IlluminateResponse :: HTTP_NO_CONTENT ) -> respond ( [ 'status' => [ 'type' => 'success' , 'message' => $ this -> getDefaultMessage ( $ code , $ message ) , 'code' => $ code , 'http_code' => $ this -> getStatusCode ( ) , ] , 'data' => $ data , ] ) ; }
|
Returns 204 response enacted but the response does not include an entity .
|
6,253
|
protected function getDefaultMessage ( $ code , $ message ) : string { if ( $ code !== null && $ message === null ) { return ApiResponse :: $ statusTexts [ $ code ] [ 'message' ] ; } return $ message ; }
|
Checks if specified code already has default message .
|
6,254
|
public function formatAttributes ( array $ attributes ) { foreach ( $ attributes as $ key => $ attr ) { if ( $ attr instanceof Closure ) { $ attributes [ $ key ] = call_user_func ( $ attr , $ this ) ; } else if ( $ this -> hasKeyword ( $ attr ) ) { $ attributes [ $ key ] = $ this -> getKeyword ( $ attr ) ; } else if ( $ attr === true ) { $ attributes [ $ key ] = $ this -> getKeyword ( $ key ) ; } else { $ attributes [ $ key ] = ( string ) $ attr ; } } return $ attributes ; }
|
Prepare the list of attributes for rendering . If an attribute is found within a keyword use the keyword .
|
6,255
|
public function formatColumns ( Schema $ schema ) { $ columns = [ ] ; foreach ( $ schema -> getColumns ( ) as $ column => $ options ) { $ dataType = $ this -> getDriver ( ) -> getType ( $ options [ 'type' ] ) ; $ options = $ options + $ dataType -> getDefaultOptions ( ) ; $ type = $ options [ 'type' ] ; if ( ! empty ( $ options [ 'length' ] ) ) { $ type .= '(' . $ options [ 'length' ] . ')' ; } $ output = [ $ this -> quote ( $ column ) , strtoupper ( $ type ) ] ; if ( ! empty ( $ options [ 'unsigned' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: UNSIGNED ) ; } if ( ! empty ( $ options [ 'zerofill' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: ZEROFILL ) ; } if ( ! empty ( $ options [ 'charset' ] ) ) { $ output [ ] = sprintf ( $ this -> getClause ( self :: CHARACTER_SET ) , $ options [ 'charset' ] ) ; } if ( ! empty ( $ options [ 'collate' ] ) ) { $ output [ ] = sprintf ( $ this -> getClause ( self :: COLLATE ) , $ options [ 'collate' ] ) ; } if ( ! empty ( $ options [ 'primary' ] ) || ! empty ( $ options [ 'unique' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: NOT_NULL ) ; } else { $ output [ ] = $ this -> getKeyword ( empty ( $ options [ 'null' ] ) ? self :: NOT_NULL : self :: NULL ) ; } if ( array_key_exists ( 'default' , $ options ) ) { $ output [ ] = $ this -> formatDefault ( $ options [ 'default' ] ) ; } if ( ! empty ( $ options [ 'ai' ] ) ) { $ output [ ] = $ this -> getKeyword ( self :: AUTO_INCREMENT ) ; } if ( ! empty ( $ options [ 'comment' ] ) ) { $ output [ ] = sprintf ( $ this -> getClause ( self :: COMMENT ) , $ this -> getDriver ( ) -> escape ( substr ( $ options [ 'comment' ] , 0 , 255 ) ) ) ; } $ columns [ ] = trim ( implode ( ' ' , $ output ) ) ; } return implode ( ",\n" , $ columns ) ; }
|
Format columns for a table schema .
|
6,256
|
public function formatDefault ( $ value ) { if ( $ value === '' ) { return '' ; } if ( $ value instanceof Closure ) { $ value = call_user_func ( $ value , $ this ) ; } else if ( is_string ( $ value ) || $ value === null ) { $ value = $ this -> getDriver ( ) -> escape ( $ value ) ; } return sprintf ( $ this -> getClause ( self :: DEFAULT_TO ) , $ value ) ; }
|
Format the default value of a column .
|
6,257
|
public function formatExpression ( Expr $ expr ) { $ field = $ expr -> getField ( ) ; $ operator = $ expr -> getOperator ( ) ; $ value = $ expr -> getValue ( ) ; if ( $ operator === Expr :: AS_ALIAS ) { return sprintf ( $ this -> getClause ( self :: AS_ALIAS ) , $ this -> quote ( $ field ) , $ this -> quote ( $ value ) ) ; } else if ( ! $ expr -> useValue ( ) && ! ( $ operator === Expr :: NULL || $ operator === Expr :: NOT_NULL ) ) { return $ this -> quote ( $ field ) ; } $ isSubQuery = ( $ value instanceof SubQuery ) ; if ( $ field instanceof Func ) { $ field = $ this -> formatFunction ( $ field ) ; } else if ( $ field instanceof RawExpr ) { $ field = $ field -> getValue ( ) ; } else { $ field = $ this -> quote ( $ field ) ; } if ( $ operator === Expr :: IN || $ operator === Expr :: NOT_IN ) { if ( $ isSubQuery ) { $ clause = sprintf ( $ this -> getClause ( $ operator ) , $ field , '?' ) ; $ clause = str_replace ( [ '(' , ')' ] , '' , $ clause ) ; } else { $ clause = sprintf ( $ this -> getClause ( $ operator ) , $ field , implode ( ', ' , array_fill ( 0 , count ( $ value ) , '?' ) ) ) ; } } else if ( $ this -> hasClause ( $ operator ) ) { $ clause = sprintf ( $ this -> getClause ( $ operator ) , $ field ) ; } else { $ clause = sprintf ( $ this -> getClause ( self :: EXPRESSION ) , $ field , $ operator ) ; } if ( $ isSubQuery ) { if ( in_array ( $ value -> getFilter ( ) , [ SubQuery :: EXISTS , SubQuery :: NOT_EXISTS ] , true ) ) { $ clause = $ this -> formatSubQuery ( $ value ) ; } else { $ clause = str_replace ( '?' , $ this -> formatSubQuery ( $ value ) , $ clause ) ; } } return $ clause ; }
|
Format database expressions .
|
6,258
|
public function formatFunction ( Func $ func ) { $ arguments = [ ] ; foreach ( $ func -> getArguments ( ) as $ arg ) { $ type = $ arg [ 'type' ] ; $ value = $ arg [ 'value' ] ; if ( $ value instanceof Func ) { $ value = $ this -> formatFunction ( $ value ) ; } else if ( $ value instanceof SubQuery ) { $ value = $ this -> formatSubQuery ( $ value ) ; } else if ( $ type === Func :: FIELD ) { $ value = $ this -> quote ( $ value ) ; } else if ( $ type === Func :: LITERAL ) { } else if ( is_string ( $ value ) || $ value === null ) { $ value = $ this -> getDriver ( ) -> escape ( $ value ) ; } $ arguments [ ] = $ value ; } $ output = sprintf ( $ this -> getClause ( self :: FUNC ) , $ func -> getName ( ) , implode ( $ func -> getSeparator ( ) , $ arguments ) ) ; if ( $ alias = $ func -> getAlias ( ) ) { $ output = sprintf ( $ this -> getClause ( self :: AS_ALIAS ) , $ output , $ this -> quote ( $ alias ) ) ; } return $ output ; }
|
Format a database function .
|
6,259
|
public function formatGroupBy ( array $ groupBy ) { if ( $ groupBy ) { return sprintf ( $ this -> getClause ( self :: GROUP_BY ) , $ this -> quoteList ( $ groupBy ) ) ; } return '' ; }
|
Format the group by .
|
6,260
|
public function formatHaving ( Predicate $ having ) { if ( $ having -> getParams ( ) ) { return sprintf ( $ this -> getClause ( self :: HAVING ) , $ this -> formatPredicate ( $ having ) ) ; } return '' ; }
|
Format the having clause .
|
6,261
|
public function formatJoins ( array $ joins ) { if ( $ joins ) { $ output = [ ] ; foreach ( $ joins as $ join ) { $ conditions = [ ] ; foreach ( $ join -> getOn ( ) as $ pfk => $ rfk ) { $ conditions [ ] = $ this -> quote ( $ pfk ) . ' = ' . $ this -> quote ( $ rfk ) ; } $ output [ ] = sprintf ( $ this -> getClause ( $ join -> getType ( ) ) , $ this -> formatTable ( $ join -> getTable ( ) , $ join -> getAlias ( ) ) , implode ( ' ' . $ this -> getKeyword ( self :: ALSO ) . ' ' , $ conditions ) ) ; } return implode ( ' ' , $ output ) ; } return '' ; }
|
Format the list of joins .
|
6,262
|
public function formatLimit ( $ limit ) { if ( $ limit ) { return sprintf ( $ this -> getClause ( self :: LIMIT ) , ( int ) $ limit ) ; } return '' ; }
|
Format the limit .
|
6,263
|
public function formatLimitOffset ( $ limit , $ offset = 0 ) { if ( $ limit && $ offset ) { return sprintf ( $ this -> getClause ( self :: LIMIT_OFFSET ) , ( int ) $ limit , ( int ) $ offset ) ; } return $ this -> formatLimit ( $ limit ) ; }
|
Format the limit and offset .
|
6,264
|
public function formatOrderBy ( array $ orderBy ) { if ( $ orderBy ) { $ output = [ ] ; foreach ( $ orderBy as $ field => $ direction ) { if ( $ direction instanceof Func ) { $ output [ ] = $ this -> formatFunction ( $ direction ) ; } else { $ output [ ] = $ this -> quote ( $ field ) . ' ' . $ this -> getKeyword ( $ direction ) ; } } return sprintf ( $ this -> getClause ( self :: ORDER_BY ) , implode ( ', ' , $ output ) ) ; } return '' ; }
|
Format the order by .
|
6,265
|
public function formatPredicate ( Predicate $ predicate ) { $ output = [ ] ; foreach ( $ predicate -> getParams ( ) as $ param ) { if ( $ param instanceof Predicate ) { $ output [ ] = sprintf ( $ this -> getClause ( self :: GROUP ) , $ this -> formatPredicate ( $ param ) ) ; } else if ( $ param instanceof Expr ) { $ output [ ] = $ this -> formatExpression ( $ param ) ; } } return implode ( ' ' . $ this -> getKeyword ( $ predicate -> getType ( ) ) . ' ' , $ output ) ; }
|
Format the predicate object by grouping nested predicates and parameters .
|
6,266
|
public function formatSubQuery ( SubQuery $ query ) { $ alias = $ query -> getAlias ( ) ; $ query -> asAlias ( null ) ; if ( method_exists ( $ this , 'buildSelect' ) ) { $ output = sprintf ( $ this -> getClause ( self :: SUB_QUERY ) , trim ( $ this -> buildSelect ( $ query ) , ';' ) ) ; } else { throw new UnsupportedQueryStatementException ( 'Sub-query building requires a buildSelect() method' ) ; } if ( $ alias ) { $ output = sprintf ( $ this -> getClause ( self :: AS_ALIAS ) , $ output , $ this -> quote ( $ alias ) ) ; } if ( $ filter = $ query -> getFilter ( ) ) { $ output = $ this -> getKeyword ( $ filter ) . ' ' . $ output ; } return $ output ; }
|
Format a sub - query .
|
6,267
|
public function formatTable ( $ table , $ alias = null ) { if ( ! $ table ) { throw new InvalidTableException ( 'Missing table name for query' ) ; } $ output = $ this -> quote ( $ table ) ; if ( $ alias && $ table !== $ alias ) { $ output = sprintf ( $ this -> getClause ( self :: AS_ALIAS ) , $ output , $ this -> quote ( $ alias ) ) ; } return $ output ; }
|
Format the table name and alias name .
|
6,268
|
public function formatTableForeign ( array $ data ) { $ ref = explode ( '.' , $ data [ 'references' ] ) ; $ key = sprintf ( $ this -> getClause ( self :: FOREIGN_KEY ) , $ this -> quote ( $ data [ 'column' ] ) , $ this -> quote ( $ ref [ 0 ] ) , $ this -> quote ( $ ref [ 1 ] ) ) ; if ( $ data [ 'constraint' ] ) { $ key = sprintf ( $ this -> getClause ( self :: CONSTRAINT ) , $ this -> quote ( $ data [ 'constraint' ] ) ) . ' ' . $ key ; } $ actions = $ data ; unset ( $ actions [ 'references' ] , $ actions [ 'constraint' ] , $ actions [ 'column' ] ) ; foreach ( $ actions as $ clause => $ action ) { $ value = '' ; if ( $ this -> hasKeyword ( $ action ) ) { $ value = $ this -> getKeyword ( $ action ) ; } $ key .= ' ' . sprintf ( $ this -> getClause ( $ clause ) , $ value ) ; } return $ key ; }
|
Format a table foreign key .
|
6,269
|
public function formatTableIndex ( $ index , array $ columns ) { return sprintf ( $ this -> getClause ( self :: INDEX ) , $ this -> quote ( $ index ) , $ this -> quoteList ( $ columns ) ) ; }
|
Format a table index key .
|
6,270
|
public function formatTableOptions ( array $ options ) { $ output = [ ] ; foreach ( $ this -> formatAttributes ( $ options ) as $ key => $ value ) { if ( $ this -> hasClause ( $ key ) ) { $ option = sprintf ( $ this -> getClause ( $ key ) , $ value ) ; } else { $ option = $ this -> getKeyword ( $ key ) ; if ( $ value !== true ) { $ option .= ' ' . $ value ; } } $ output [ ] = $ option ; } return implode ( ' ' , $ output ) ; }
|
Format the table options for a create table statement .
|
6,271
|
public function formatTablePrimary ( array $ data ) { $ key = sprintf ( $ this -> getClause ( self :: PRIMARY_KEY ) , $ this -> quoteList ( $ data [ 'columns' ] ) ) ; if ( $ data [ 'constraint' ] ) { $ key = sprintf ( $ this -> getClause ( self :: CONSTRAINT ) , $ this -> quote ( $ data [ 'constraint' ] ) ) . ' ' . $ key ; } return $ key ; }
|
Format a table primary key .
|
6,272
|
public function formatTableUnique ( array $ data ) { $ key = sprintf ( $ this -> getClause ( self :: UNIQUE_KEY ) , $ this -> quote ( $ data [ 'index' ] ) , $ this -> quoteList ( $ data [ 'columns' ] ) ) ; if ( $ data [ 'constraint' ] ) { $ key = sprintf ( $ this -> getClause ( self :: CONSTRAINT ) , $ this -> quote ( $ data [ 'constraint' ] ) ) . ' ' . $ key ; } return $ key ; }
|
Format a table unique key .
|
6,273
|
public function formatValues ( Query $ query ) { $ fields = $ query -> getData ( ) ; switch ( $ query -> getType ( ) ) { case Query :: INSERT : return sprintf ( $ this -> getClause ( self :: GROUP ) , implode ( ', ' , array_fill ( 0 , count ( $ fields ) , '?' ) ) ) ; break ; case Query :: MULTI_INSERT : $ value = sprintf ( $ this -> getClause ( self :: GROUP ) , implode ( ', ' , array_fill ( 0 , count ( $ fields [ 0 ] ) , '?' ) ) ) ; return implode ( ', ' , array_fill ( 0 , count ( $ fields ) , $ value ) ) ; break ; } return '' ; }
|
Format the fields values structure depending on the type of query .
|
6,274
|
public function formatWhere ( Predicate $ where ) { if ( $ where -> getParams ( ) ) { return sprintf ( $ this -> getClause ( self :: WHERE ) , $ this -> formatPredicate ( $ where ) ) ; } return '' ; }
|
Format the where clause .
|
6,275
|
public static function redirect ( $ location , $ stop_execution = true , $ code = null ) { if ( preg_match ( '{^(http(s)?:)?//}' , $ location ) == false ) { $ base_url = 'http' ; $ base_url .= ! empty ( $ _SERVER [ 'HTTPS' ] ) ? 's' : '' ; $ base_url .= '://' . $ _SERVER [ 'SERVER_NAME' ] ; if ( strpos ( $ location , '/' ) !== 0 ) { $ base_url .= '/' ; } $ location = $ base_url . $ location ; } header ( 'Location: ' . $ location , $ replace = true , $ code ) ; if ( $ stop_execution == false ) { return ; } exit ; }
|
redirect a browser session to a new url also exists flow
|
6,276
|
public static function get_method ( ) { if ( empty ( $ _SERVER [ 'REQUEST_METHOD' ] ) ) { return 'GET' ; } $ allowed_methods = [ 'GET' , 'PUT' , 'POST' , 'PATCH' , 'DELETE' , 'OPTIONS' , 'HEAD' ] ; if ( in_array ( $ _SERVER [ 'REQUEST_METHOD' ] , $ allowed_methods ) == false ) { return false ; } return $ _SERVER [ 'REQUEST_METHOD' ] ; }
|
get the http method used for the current session
|
6,277
|
public static function get_primary_accept ( ) { if ( empty ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ) { return '*' ; } if ( strpos ( $ _SERVER [ 'HTTP_ACCEPT' ] , 'text/html,' ) === 0 ) { return 'html' ; } if ( strpos ( $ _SERVER [ 'HTTP_ACCEPT' ] , 'application/json,' ) === 0 ) { return 'json' ; } return self :: get_primary_mime_type ( $ _SERVER [ 'HTTP_ACCEPT' ] ) ; }
|
get the primary http accepted output format for the current session
|
6,278
|
public static function get_basic_auth ( ) { if ( ! empty ( $ _SERVER [ 'PHP_AUTH_USER' ] ) ) { return [ 'USER' => $ _SERVER [ 'PHP_AUTH_USER' ] , 'PW' => $ _SERVER [ 'PHP_AUTH_PW' ] , ] ; } if ( ! empty ( $ _SERVER [ 'REDIRECT_REMOTE_USER' ] ) && strpos ( $ _SERVER [ 'REDIRECT_REMOTE_USER' ] , 'Basic ' ) === 0 ) { $ credentials = substr ( $ _SERVER [ 'REDIRECT_REMOTE_USER' ] , strlen ( 'Basic ' ) ) ; $ credentials = base64_decode ( $ credentials ) ; if ( strpos ( $ credentials , ':' ) ) { $ credentials = explode ( ':' , $ credentials ) ; return [ 'USER' => $ credentials [ 0 ] , 'PW' => $ credentials [ 1 ] , ] ; } } return null ; }
|
returns basic auth credentials this works around php cgi mode not passing them directly
|
6,279
|
private static function get_primary_mime_type ( $ type ) { if ( strpos ( $ type , ',' ) ) { $ type = substr ( $ type , 0 , strpos ( $ type , ',' ) ) ; } if ( strpos ( $ type , '/' ) ) { $ type = substr ( $ type , strpos ( $ type , '/' ) + 1 ) ; } if ( strpos ( $ type , ';' ) ) { $ type = substr ( $ type , 0 , strpos ( $ type , ';' ) ) ; } if ( strpos ( $ type , '+' ) ) { $ type = substr ( $ type , strpos ( $ type , '+' ) + 1 ) ; } return $ type ; }
|
gets a friendly version of a mime type
|
6,280
|
function executeRedirect ( $ source_url = null , $ return = null ) { if ( ! $ this -> secret ) { if ( count ( $ this -> cookies ) ) { if ( empty ( $ return ) ) { $ return = Application :: getInstance ( ) -> input -> getBase64 ( 'return' , '' ) ; if ( $ return ) { $ return = base64_decode ( $ return ) ; if ( stripos ( $ return , 'http://' ) === false && stripos ( $ return , 'https://' ) === false ) { $ return = ltrim ( $ return , '/' ) ; $ return = $ source_url . $ return ; } } } $ api = null ; $ data = array ( ) ; foreach ( $ this -> cookies as $ key => $ cookies ) { $ api = new Api ( $ key , $ this -> secret ) ; if ( $ api -> set ( 'Cookie' , 'Cookies' , $ cookies ) ) { $ data [ 'url' ] [ $ api -> url ] = $ api -> sid ; } } if ( $ api ) { unset ( $ data [ 'url' ] [ $ api -> url ] ) ; $ api -> execute ( 'cookie' , 'cookies' , $ data , $ return ) ; } } if ( ! empty ( $ return ) ) { Framework :: redirect ( $ return ) ; } } }
|
Execute the cross domain login redirects
|
6,281
|
public function generateRedirectUri ( $ state = null , $ queryDelimeter = '?' ) { $ uri = $ this -> getRedirectUri ( ) ; $ uri .= ( strstr ( $ this -> getRedirectUri ( ) , $ queryDelimeter ) === false ) ? $ queryDelimeter : '&' ; return $ uri . http_build_query ( [ 'code' => $ this -> getId ( ) , 'state' => $ state , ] ) ; }
|
Generate a redirect URI
|
6,282
|
public static function scandir ( $ path , $ filter = 0 , $ order = SCANDIR_SORT_ASCENDING ) { if ( ! $ filter || ( ( $ filter & self :: FILE ) != self :: FILE && ( $ filter & self :: DIRECTORY ) != self :: DIRECTORY ) ) { $ filter = self :: FILE | self :: DIRECTORY ; } $ path = self :: getRealPath ( $ path ) ; $ wrap = Utf8 :: wrapPath ( $ path ) ; $ folders = [ ] ; foreach ( new \ DirectoryIterator ( $ wrap ) as $ file ) { try { if ( $ file -> getFilename ( ) [ 0 ] != '.' && substr ( $ file -> getFilename ( ) , - 1 ) != '~' && $ file -> getFilename ( ) != 'pagefile.sys' && $ file -> isReadable ( ) && ( ( ( $ filter & self :: FILE ) == self :: FILE && $ file -> isFile ( ) ) || ( ( $ filter & self :: DIRECTORY ) == self :: DIRECTORY && $ file -> isDir ( ) ) ) ) { $ folders [ $ file -> getFilename ( ) ] = [ 'name' => $ file -> getFilename ( ) , 'path' => $ path . $ file -> getFilename ( ) . DIRECTORY_SEPARATOR , ] ; } } catch ( \ Exception $ e ) { } } if ( $ order == SCANDIR_SORT_ASCENDING ) { ksort ( $ folders ) ; } elseif ( $ order == SCANDIR_SORT_DESCENDING ) { ksort ( $ folders ) ; $ folders = array_reverse ( $ folders ) ; } if ( substr_count ( $ path , DIRECTORY_SEPARATOR ) > 1 ) { $ pos = strrpos ( substr ( $ path , 0 , - 1 ) , DIRECTORY_SEPARATOR ) + 1 ; array_unshift ( $ folders , [ 'name' => '..' , 'path' => substr ( $ path , 0 , $ pos ) , ] ) ; } return array_values ( $ folders ) ; }
|
List files and directories inside the specified path .
|
6,283
|
public function load ( string $ file ) { $ this -> data = Yaml :: parse ( file_get_contents ( $ file ) ) ; $ this -> filename = basename ( $ file ) ; }
|
Loads a YAML file to be processed
|
6,284
|
public static function manage ( ) { $ back = ( Session :: has ( 'back' ) ) ? Session :: get ( 'back' ) : [ ] ; if ( URL :: current ( ) == end ( $ back ) ) { array_pop ( $ back ) ; } elseif ( URL :: previous ( ) != end ( $ back ) ) { $ back [ ] = URL :: previous ( ) ; } if ( count ( $ back ) ) { Session :: set ( 'back' , $ back ) ; } elseif ( Session :: has ( 'back' ) ) { Session :: forget ( 'back' ) ; } }
|
manage the return stack
|
6,285
|
protected function log ( ) { if ( class_exists ( 'CCLog' ) ) { try { \ CCLog :: add ( $ this -> inspector -> exception ( ) -> getMessage ( ) . " - " . str_replace ( CCROOT , '' , $ this -> inspector -> exception ( ) -> getFile ( ) ) . ":" . $ this -> inspector -> exception ( ) -> getLine ( ) , 'exception' ) ; \ CCLog :: write ( ) ; } catch ( \ Exception $ e ) { } } }
|
Try to log that something went wrong
|
6,286
|
public function handle ( ) { $ this -> log ( ) ; if ( ! ClanCats :: in_development ( ) && ! ClanCats :: is_cli ( ) ) { CCResponse :: error ( 500 ) -> send ( true ) ; } else { $ this -> respond ( ) ; } }
|
trigger the handler
|
6,287
|
public static function copyFromTabButtonable ( TabButtonable $ tabButtonable ) { $ valueObject = new static ( ) ; $ valueObject -> setButtonLabel ( $ tabButtonable -> getButtonLabel ( ) ) ; $ valueObject -> setFullButtonLabel ( $ tabButtonable -> getFullButtonLabel ( ) ) ; $ valueObject -> setButtonLeftIcon ( $ tabButtonable -> getButtonLeftIcon ( ) ) ; $ valueObject -> setButtonRightIcon ( $ tabButtonable -> getButtonRightIcon ( ) ) ; $ valueObject -> setButtonMode ( $ tabButtonable -> getButtonMode ( ) ) ; $ valueObject -> setTabLabel ( $ tabButtonable -> getTabLabel ( ) ) ; $ valueObject -> setTabRequestMeta ( $ tabButtonable -> getTabRequestMeta ( ) ) ; return $ valueObject ; }
|
Creates a copy of an tabButtonable
|
6,288
|
public function generateLabel ( ) { if ( $ this -> strLabel === '' ) { return '' ; } return sprintf ( '<span %s>%s%s</span>' , ( '' !== $ this -> strClass ? ' class="' . $ this -> strClass . '"' : '' ) , $ this -> strLabel , ( $ this -> required ? '<span class="mandatory">*</span>' : '' ) ) ; }
|
Generate the label and return it as string .
|
6,289
|
protected function getCsvRow ( $ fh ) { if ( version_compare ( PHP_VERSION , '5.3.0' , '>' ) ) { $ rows = fgetcsv ( $ fh , NULL , $ this -> delimiter , $ this -> enclosure , $ this -> escape ) ; } else { $ rows = fgetcsv ( $ fh , NULL , $ this -> delimiter , $ this -> enclosure ) ; } if ( $ rows === false ) { return false ; } for ( $ i = 0 ; $ i < $ this -> ignoreColumnCount ; $ i ++ ) { array_shift ( $ rows ) ; } return $ rows ; }
|
Returns a row from the csv file in an indexed array .
|
6,290
|
public function getDefaultDb ( ) : ? ConnectionInterface { $ manager = DB :: getFacadeRoot ( ) ; if ( isset ( $ manager ) ) { return $ manager -> connection ( ) ; } return $ manager ; }
|
Get a default db value if any is available
|
6,291
|
public function showStatusBar ( ) { return $ this ; if ( array_key_exists ( 'noverbose' , $ this -> options ) ) unset ( $ this -> options [ 'noverbose' ] ) ; $ this -> options [ 'v' ] = '' ; return $ this ; }
|
This shows the status bar at the bottom of the screen with image about the file being displayed in it .
|
6,292
|
public function withoutStatusBar ( ) { return $ this ; if ( array_key_exists ( 'v' , $ this -> options ) ) unset ( $ this -> options [ 'v' ] ) ; $ this -> options [ 'noverbose' ] = '' ; return $ this ; }
|
Don t display the status bar at the bottom of the screen
|
6,293
|
public function display ( ) { $ options = $ this -> _compileOptions ( ) ; $ command = system ( 'sudo fbi --noverbose ' . $ this -> _compileOptions ( ) . ' ' . $ this -> file . ' > /dev/null 2>&1' ) ; if ( $ this -> displayFor > 0 ) { sleep ( $ this -> displayFor ) ; $ this -> terminate ( ) ; } }
|
Display The Image
|
6,294
|
public function _compileOptions ( ) { $ compiled = '' ; foreach ( $ this -> options as $ option => $ value ) : if ( strlen ( $ option ) > 1 ) $ compiled .= "--{$option} {$value} " ; else $ compiled .= "-{$option} {$value}" ; endforeach ; return $ compiled ; }
|
Compile the options to a string passable to the command
|
6,295
|
public function hasGroup ( $ group ) { if ( $ this -> user ( ) === null ) { return null ; } return in_array ( $ group , $ this -> groups , true ) ; }
|
Check if authenticate user has group
|
6,296
|
public function hasGroups ( $ groups ) { if ( $ this -> user ( ) === null ) { return null ; } if ( ! is_array ( $ groups ) ) { $ groups = func_get_args ( ) ; } return count ( array_intersect ( $ groups , $ this -> groups ) ) === count ( $ groups ) ; }
|
Check if authenticated user has all groups passed by parameter
|
6,297
|
public function hasRole ( $ role ) { if ( $ this -> user ( ) === null ) { return null ; } return in_array ( $ role , $ this -> roles , true ) ; }
|
Check if authenticate user has role
|
6,298
|
public function hasRoles ( $ roles ) { if ( $ this -> user ( ) === null ) { return null ; } if ( ! is_array ( $ roles ) ) { $ roles = func_get_args ( ) ; } return count ( array_intersect ( $ roles , $ this -> roles ) ) === count ( $ roles ) ; }
|
Check if authenticated user has all roles passed by parameter
|
6,299
|
public function hasPermission ( $ permission ) { if ( $ this -> user ( ) === null ) { return null ; } return in_array ( $ permission , $ this -> permissions , true ) ; }
|
Check if authenticated user has permission
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.