idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
1,000
public static function getActionableViews ( ) { static $ views ; if ( isset ( $ views ) ) { return $ views ; } $ views = [ ] ; $ plugin = elgg_get_plugin_from_id ( 'hypeInteractions' ) ; $ settings = $ plugin -> getAllSettings ( ) ; foreach ( $ settings as $ key => $ value ) { if ( ! $ value ) { continue ; } list ( $ p...
Get views which custom threads should be created for
1,001
public static function syncRiverObjectAccess ( $ event , $ type , $ entity ) { if ( ! $ entity instanceof \ ElggObject ) { return ; } $ ia = elgg_set_ignore_access ( true ) ; $ options = array ( 'type' => 'object' , 'subtype' => RiverObject :: class , 'container_guid' => $ entity -> guid , 'wheres' => array ( "e.access...
Update river object access to match that of the container
1,002
public static function enumTypes ( ) { return [ ButtonInterface :: BUTTON_TYPE_DANGER , ButtonInterface :: BUTTON_TYPE_DEFAULT , ButtonInterface :: BUTTON_TYPE_INFO , ButtonInterface :: BUTTON_TYPE_LINK , ButtonInterface :: BUTTON_TYPE_PRIMARY , ButtonInterface :: BUTTON_TYPE_SUCCESS , ButtonInterface :: BUTTON_TYPE_WA...
Enumerates the types .
1,003
protected function generateDocBlock ( array $ columns ) : void { $ this -> codeStore -> append ( '/**' ) ; $ this -> codeStore -> append ( ' * @todo describe routine' , false ) ; $ this -> codeStore -> append ( ' * ' , false ) ; $ padding = $ this -> getMaxColumnLength ( $ columns ) ; $ format = sprintf ( ' * @param p_...
Generates the doc block for the stored routine .
1,004
protected function generateMainPart ( array $ columns ) : void { $ this -> codeStore -> append ( sprintf ( 'create procedure %s(' , $ this -> spName ) ) ; $ padding = $ this -> getMaxColumnLength ( $ columns ) ; $ offset = mb_strlen ( $ this -> codeStore -> getLastLine ( ) ) ; $ first = true ; foreach ( $ columns as $ ...
Generates the function name and parameters of the stored routine .
1,005
protected function getMaxColumnLength ( array $ columns ) : int { $ length = 0 ; foreach ( $ columns as $ column ) { $ length = max ( mb_strlen ( $ column [ 'column_name' ] ) , $ length ) ; } return $ length ; }
Returns the length the longest column name of a table .
1,006
public function delete ( string $ id ) : bool { if ( \ array_key_exists ( $ id , $ this -> cache ) ) { unset ( $ this -> cache [ $ id ] ) ; return true ; } return false ; }
Delete value from container .
1,007
public function resolve ( string $ class , array $ rules = [ ] ) { $ this -> tree = [ ] ; $ this -> rules = \ array_merge ( $ this -> rules , $ rules ) ; $ this -> buildTree ( $ class ) ; $ this -> buildObjects ( ) ; return $ this -> cache [ $ class ] ?? null ; }
Resolve dependencies for given class .
1,008
private function buildTree ( string $ class ) : void { $ level = 0 ; $ stack = new SplStack ( ) ; while ( true ) { if ( empty ( $ this -> tree [ $ level ] [ $ class ] ) ) { $ this -> tree [ $ level ] [ $ class ] = [ ] ; } $ parameters = ( new ReflectionClass ( $ class ) ) -> getConstructor ( ) -> getParameters ( ) ; fo...
Create a dependencies map for a class .
1,009
private function buildObjects ( ) : void { for ( $ i = \ count ( $ this -> tree ) - 1 ; $ i >= 0 ; $ i -- ) { foreach ( $ this -> tree [ $ i ] as $ class => $ arguments ) { $ object = $ this -> cache [ $ class ] ?? null ; if ( $ object === null && \ count ( $ arguments ) ) { $ args = $ this -> buildArguments ( $ class ...
Build objects from dependencyTree .
1,010
private function buildArguments ( string $ class , array $ dependency ) : array { $ args = [ ] ; foreach ( $ dependency as $ argValue ) { if ( \ class_exists ( ( string ) $ argValue -> getType ( ) ) ) { $ paramClass = $ argValue -> getClass ( ) -> name ; $ args [ ] = $ this -> cache [ $ paramClass ] ; continue ; } $ ar...
Build dependency for a object .
1,011
public function bootstrapRowButtonDefaultFunction ( array $ args = [ ] ) { $ editButton = $ this -> bootstrapRowButtonEditFunction ( [ "href" => ArrayHelper :: get ( $ args , "edit_href" ) ] ) ; $ deleteButton = $ this -> bootstrapRowButtonDeleteFunction ( [ "href" => ArrayHelper :: get ( $ args , "delete_href" ) ] ) ;...
Displays a Bootstrap row button default .
1,012
public function bootstrapRowButtonDeleteFunction ( array $ args = [ ] ) { $ txt = $ this -> getTranslator ( ) -> trans ( "label.delete" , [ ] , "WBWBootstrapBundle" ) ; $ but = $ this -> getButtonTwigExtension ( ) -> bootstrapButtonDangerFunction ( [ "title" => $ txt , "icon" => "g:trash" ] ) ; return $ this -> getButt...
Displays a Bootstrap row button delete .
1,013
public function bootstrapRowButtonEditFunction ( array $ args = [ ] ) { $ txt = $ this -> getTranslator ( ) -> trans ( "label.edit" , [ ] , "WBWBootstrapBundle" ) ; $ but = $ this -> getButtonTwigExtension ( ) -> bootstrapButtonDefaultFunction ( [ "title" => $ txt , "icon" => "g:pencil" ] ) ; return $ this -> getButton...
Displays a Bootstrap row button edit .
1,014
protected function bootstrapAlert ( $ content , $ dismissible , $ class ) { $ span = static :: coreHTMLElement ( "span" , "×" , [ "aria-hidden" => "true" ] ) ; $ button = static :: coreHTMLElement ( "button" , $ span , [ "class" => "close" , "type" => "button" , "data-dismiss" => "alert" , "aria-label" => "Close"...
Displays a Bootstrap alert .
1,015
protected function bootstrapHeading ( $ size , $ content , $ description , $ class ) { $ sizes = [ 1 , 2 , 3 , 4 , 5 , 6 ] ; $ attributes = [ ] ; $ attributes [ "class" ] = [ $ class ] ; $ element = "h" . ( true === in_array ( $ size , $ sizes ) ? $ size : 1 ) ; $ secondary = null !== $ description ? " <small>" . $ des...
Displays a Bootstrap heading .
1,016
public function bootstrapHeading1Function ( array $ args = [ ] ) { return $ this -> bootstrapHeading ( 1 , ArrayHelper :: get ( $ args , "content" ) , ArrayHelper :: get ( $ args , "description" ) , ArrayHelper :: get ( $ args , "class" ) ) ; }
Displays a Boostrap heading 1 .
1,017
public function bootstrapHeading2Function ( array $ args = [ ] ) { return $ this -> bootstrapHeading ( 2 , ArrayHelper :: get ( $ args , "content" ) , ArrayHelper :: get ( $ args , "description" ) , ArrayHelper :: get ( $ args , "class" ) ) ; }
Displays a Bootstrap heading 2 .
1,018
public function bootstrapHeading3Function ( array $ args = [ ] ) { return $ this -> bootstrapHeading ( 3 , ArrayHelper :: get ( $ args , "content" ) , ArrayHelper :: get ( $ args , "description" ) , ArrayHelper :: get ( $ args , "class" ) ) ; }
Displays a Bootstrap heading 3 .
1,019
public function bootstrapHeading4Function ( array $ args = [ ] ) { return $ this -> bootstrapHeading ( 4 , ArrayHelper :: get ( $ args , "content" ) , ArrayHelper :: get ( $ args , "description" ) , ArrayHelper :: get ( $ args , "class" ) ) ; }
Displays a Bootstrap heading 4 .
1,020
public function bootstrapHeading5Function ( array $ args = [ ] ) { return $ this -> bootstrapHeading ( 5 , ArrayHelper :: get ( $ args , "content" ) , ArrayHelper :: get ( $ args , "description" ) , ArrayHelper :: get ( $ args , "class" ) ) ; }
Displays a heading 5 .
1,021
public function bootstrapHeading6Function ( array $ args = [ ] ) { return $ this -> bootstrapHeading ( 6 , ArrayHelper :: get ( $ args , "content" ) , ArrayHelper :: get ( $ args , "description" ) , ArrayHelper :: get ( $ args , "class" ) ) ; }
Displays a Bootstrap heading 6 .
1,022
public static function createNewClient ( string $ name , $ redirectUris = null ) : Client { if ( isset ( $ redirectUris ) && is_string ( $ redirectUris ) ) { $ redirectUris = explode ( ' ' , $ redirectUris ) ; } if ( isset ( $ redirectUris ) && is_array ( $ redirectUris ) ) { foreach ( $ redirectUris as & $ redirectUri...
Create a new Client
1,023
public function generateSecret ( ) { $ secret = bin2hex ( random_bytes ( 20 ) ) ; $ this -> secret = password_hash ( $ secret , PASSWORD_DEFAULT ) ; return $ secret ; }
Creates a strong unique secret and crypt it on the model
1,024
public function getRiverItem ( ) { if ( isset ( $ this -> _river_item ) ) { return $ this -> _river_item ; } $ id = $ this -> river_id ; $ items = elgg_get_river ( array ( 'ids' => $ id , 'limit' => 1 , ) ) ; $ this -> _river_item = ( is_array ( $ items ) && count ( $ items ) ) ? $ items [ 0 ] : false ; return $ this -...
Get river item
1,025
public static function nonStatic ( string $ source , ? string $ sourceClass = null , ? string $ targetClass = null ) : string { $ source = preg_replace ( '/(public|protected|private)\s+static(\s+)\$/i' , '${1}${2}$' , $ source ) ; $ source = preg_replace ( '/self::\$/' , '$this->' , $ source ) ; $ source = preg_replace...
Returns the code for a non static class based on a static class .
1,026
public function show ( $ publicId , $ options = array ( ) ) { $ defaults = $ this -> config -> get ( 'cloudinary::scaling' ) ; $ options = array_merge ( $ defaults , $ options ) ; return $ this -> getCloudinary ( ) -> cloudinary_url ( $ publicId , $ options ) ; }
Display image .
1,027
public function toArray ( ) : array { return [ 'name' => $ this -> name , 'method' => $ this -> method , 'url' => $ this -> url , 'model' => $ this -> model , 'view' => $ this -> view , 'controller' => $ this -> controller , 'action' => $ this -> action , 'default' => $ this -> default , 'param' => $ this -> param , 'c...
Return route array .
1,028
private function protect ( Authentication $ authentication , int $ httpResponseCode = 403 ) : void { if ( ( $ this -> authentication = $ authentication -> isLogged ( ) ) === false ) { \ http_response_code ( $ httpResponseCode ) ; throw new AuthenticationException ( '' ) ; } }
Allow access to controller class or methods only if logged . Return a status code useful with AJAX requests .
1,029
private function protectWithRedirect ( Authentication $ authentication , string $ location ) : void { if ( ( $ this -> authentication = $ authentication -> isLogged ( ) ) === false ) { \ header ( 'Location: ' . $ location ) ; throw new AuthenticationException ( '' ) ; } }
Allow access to controller class or methods only if logged and do a redirection .
1,030
public function bootstrapFormButtonDefaultFunction ( array $ args = [ ] ) { $ cancelButton = $ this -> bootstrapFormButtonCancelFunction ( [ "href" => ArrayHelper :: get ( $ args , "cancel_href" ) ] ) ; $ submitButton = $ this -> bootstrapFormButtonSubmitFunction ( ) ; return implode ( " " , [ $ cancelButton , $ submit...
Displays a Bootstrap form buttons default .
1,031
public function bootstrapFormButtonSubmitFunction ( ) { $ txt = $ this -> getTranslator ( ) -> trans ( "label.submit" , [ ] , "WBWBootstrapBundle" ) ; $ but = $ this -> getButtonTwigExtension ( ) -> bootstrapButtonPrimaryFunction ( [ "content" => $ txt , "title" => $ txt , "icon" => "g:ok" ] ) ; return $ this -> getBut...
Displays a Bootstrap form button submit .
1,032
public function validate ( string $ requestUri , string $ requestMethod ) : bool { $ route = $ this -> findRoute ( $ this -> filterUri ( $ requestUri ) , $ requestMethod ) ; if ( $ route instanceof Route ) { $ this -> buildValidRoute ( $ route ) ; return true ; } $ this -> buildErrorRoute ( ) ; return false ; }
Evaluate request uri .
1,033
private function findRoute ( string $ uri , string $ method ) : RouteInterface { $ matches = [ ] ; $ route = new NullRoute ( ) ; foreach ( $ this -> routes as $ value ) { $ urlMatch = \ preg_match ( '`^' . \ preg_replace ( $ this -> matchTypes , $ this -> types , $ value -> url ) . '/?$`' , $ uri , $ matches ) ; $ meth...
Find if provided route match with one of registered routes .
1,034
private function buildValidRoute ( Route $ route ) : void { $ matches = $ this -> routeMatches ; if ( \ count ( $ matches ) > 1 ) { $ route -> action = $ matches [ 1 ] ; $ route -> url = \ preg_replace ( '`\([0-9A-Za-z\|]++\)`' , $ matches [ 1 ] , $ route -> url ) ; } $ route -> param = $ this -> buildParam ( $ route )...
Build a valid route .
1,035
private function buildParam ( Route $ route ) : array { $ param = [ ] ; $ url = \ explode ( '/' , $ route -> url ) ; $ matches = \ explode ( '/' , $ this -> routeMatches [ 0 ] ) ; $ rawParam = \ array_diff ( $ matches , $ url ) ; foreach ( $ rawParam as $ key => $ value ) { $ paramName = \ strtr ( $ url [ $ key ] , [ '...
Try to find parameters in a valid route and return it .
1,036
private function buildErrorRoute ( ) : void { if ( ( $ key = \ array_search ( $ this -> badRoute , \ array_column ( $ this -> routes -> getArrayCopy ( ) , 'name' ) , true ) ) === false ) { $ this -> route = new NullRoute ( ) ; return ; } $ this -> route = $ this -> routes [ $ key ] ; }
Actions for error route .
1,037
private function filterUri ( string $ passedUri ) : string { $ url = \ filter_var ( $ passedUri , FILTER_SANITIZE_URL ) ; $ url = \ str_replace ( $ this -> rewriteModeOffRouter , '' , $ url ) ; $ url = \ substr ( $ url , \ strlen ( $ this -> basePath ) ) ; $ url = \ str_replace ( '//' , '/' , $ url ) ; return ( \ subst...
Analize current uri sanitize and return it .
1,038
private function refresh ( ) : void { $ time = \ time ( ) ; if ( isset ( $ this -> data [ 'time' ] ) && $ this -> data [ 'time' ] <= ( $ time - $ this -> expire ) ) { $ this -> data = [ ] ; $ this -> regenerate ( ) ; } $ this -> setSessionData ( $ time ) ; }
Refresh session .
1,039
private function setSessionData ( int $ time ) : void { $ this -> id = \ session_id ( ) ; $ this -> data [ 'time' ] = $ time ; $ this -> data [ 'expire' ] = $ this -> expire ; $ this -> status = \ session_status ( ) ; }
Set Session Data .
1,040
protected function notifyDanger ( $ content ) { $ notification = NotificationFactory :: newDangerNotification ( $ content ) ; return $ this -> notify ( NotificationEvents :: NOTIFICATION_DANGER , $ notification ) ; }
Notify danger .
1,041
protected function notifyInfo ( $ content ) { $ notification = NotificationFactory :: newInfoNotification ( $ content ) ; return $ this -> notify ( NotificationEvents :: NOTIFICATION_INFO , $ notification ) ; }
Notify info .
1,042
protected function notifySuccess ( $ content ) { $ notification = NotificationFactory :: newSuccessNotification ( $ content ) ; return $ this -> notify ( NotificationEvents :: NOTIFICATION_SUCCESS , $ notification ) ; }
Notify success .
1,043
protected function notifyWarning ( $ content ) { $ notification = NotificationFactory :: newWarningNotification ( $ content ) ; return $ this -> notify ( NotificationEvents :: NOTIFICATION_WARNING , $ notification ) ; }
Notify warning .
1,044
public static function getGlyphiconBreadcrumbNodes ( ) { $ breadcrumbNodes = [ ] ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.edit_profile" , "g:user" , "fos_user_profile_edit" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.show_profile" , "g:user" , ...
Get a FOSUser breadcrumb node with Glyphicon icons .
1,045
public function showPrivacyCookieBanner ( Twig_Environment $ twigEnvironment , $ policyPageUrl = null , array $ options = array ( ) ) { $ options [ 'policyPageUrl' ] = $ policyPageUrl ; return $ twigEnvironment -> render ( 'EzSystemsPrivacyCookieBundle::privacycookie.html.twig' , $ this -> bannerOptions -> map ( $ opti...
Renders cookie privacy banner snippet code . This helper should be included at the end of template before the body ending tag .
1,046
protected function bootstrapButton ( ButtonInterface $ button , $ icon ) { $ attributes = [ ] ; $ attributes [ "class" ] = [ "btn" , ButtonRenderer :: renderType ( $ button ) ] ; $ attributes [ "class" ] [ ] = ButtonRenderer :: renderBlock ( $ button ) ; $ attributes [ "class" ] [ ] = ButtonRenderer :: renderSize ( $ b...
Displays a Bootstrap button .
1,047
protected function bootstrapNavs ( array $ items , $ class , $ stacked ) { $ attributes = [ ] ; $ attributes [ "class" ] [ ] = "nav" ; $ attributes [ "class" ] [ ] = $ class ; $ attributes [ "class" ] [ ] = true === $ stacked ? "nav-stacked" : null ; $ innerHTML = [ ] ; foreach ( $ items as $ current ) { $ innerHTML [ ...
Displays a Bootstrap navs .
1,048
private function askForCreateSP ( string $ spType , string $ tableName ) : void { $ question = sprintf ( 'Create SP for <dbo>%s</dbo> ? (default Yes): ' , $ spType ) ; $ question = new ConfirmationQuestion ( $ question , true ) ; if ( $ this -> helper -> ask ( $ this -> input , $ this -> output , $ question ) ) { $ def...
Asking function for create or not stored procedure .
1,049
private function generateSP ( string $ tableName , string $ spType , string $ spName ) : string { switch ( $ spType ) { case 'UPDATE' : $ routine = new UpdateRoutine ( $ this -> input , $ this -> output , $ this -> helper , $ spType , $ spName , $ tableName , $ this -> dataSchema ) ; break ; case 'DELETE' : $ routine =...
Generate code for stored routine .
1,050
private function printAllTables ( array $ tableList ) : void { if ( $ this -> input -> getOption ( 'tables' ) ) { $ tableData = array_chunk ( $ tableList , 4 ) ; $ array = [ ] ; foreach ( $ tableData as $ parts ) { $ partsArray = [ ] ; foreach ( $ parts as $ part ) { $ partsArray [ ] = $ part [ 'table_name' ] ; } $ arr...
Check option - t for show all tables .
1,051
private function startAsking ( array $ tableList ) : void { $ question = new Question ( 'Please enter <note>TABLE NAME</note>: ' ) ; $ tableName = $ this -> helper -> ask ( $ this -> input , $ this -> output , $ question ) ; $ key = StaticDataLayer :: searchInRowSet ( 'table_name' , $ tableName , $ tableList ) ; if ( !...
Main function for asking .
1,052
public function image ( $ large , $ small = null ) { $ this -> image = [ 'smallImageUrl' => $ small ?? $ large , 'largeImageUrl' => $ large , ] ; return $ this ; }
Set the card image .
1,053
public static function createNewScope ( int $ id , string $ name , string $ description = null , bool $ isDefault = false ) : Scope { $ scope = new static ( ) ; $ scope -> id = $ id ; $ scope -> name = $ name ; $ scope -> description = $ description ; $ scope -> isDefault = $ isDefault ; return $ scope ; }
Create a new Scope
1,054
public function login ( string $ userName , string $ password , string $ storedUserName = '' , string $ storedPassword = '' , int $ storedId ) : bool { if ( $ userName === $ storedUserName && $ this -> password -> verify ( $ password , $ storedPassword ) ) { $ this -> session -> loginTime = \ time ( ) ; $ this -> sessi...
Try to attemp login with the informations passed by param .
1,055
private function refresh ( ) : bool { if ( empty ( $ this -> session -> login ) ) { return false ; } $ time = \ time ( ) ; if ( ( $ this -> session -> loginTime + $ this -> session -> expire ) < $ time ) { return false ; } $ this -> session -> loginTime = $ time ; $ this -> data = $ this -> session -> login ; return tr...
Check if user is logged get login data from session and update it .
1,056
public function registerClient ( string $ name , array $ redirectUris ) : array { do { $ client = Client :: createNewClient ( $ name , $ redirectUris ) ; } while ( $ this -> clientRepository -> idExists ( $ client -> getId ( ) ) ) ; $ secret = $ client -> generateSecret ( ) ; $ client = $ this -> clientRepository -> sa...
Register a new client and generate a strong secret
1,057
protected function bootstrapImage ( $ src , $ alt , $ width , $ height , $ class , $ usemap ) { $ template = "<img %attributes%/>" ; $ attributes = [ ] ; $ attributes [ "src" ] = $ src ; $ attributes [ "alt" ] = $ alt ; $ attributes [ "width" ] = $ width ; $ attributes [ "height" ] = $ height ; $ attributes [ "class" ]...
Displays a Bootstrap image .
1,058
public function bootstrapNavsPills ( array $ args = [ ] ) { return $ this -> bootstrapNavs ( ArrayHelper :: get ( $ args , "items" , [ ] ) , "nav-pills" , ArrayHelper :: get ( $ args , "stacked" , false ) ) ; }
Displays a Bootstrap navs Pills .
1,059
public function getOffset ( $ limit = self :: LIMIT , $ order = 'desc' ) { if ( $ limit === 0 ) { return 0 ; } if ( $ order == 'asc' || $ order == 'time_created::asc' ) { $ before = $ this -> getCommentsBefore ( array ( 'count' => true , 'offset' => 0 ) ) ; } else { $ before = $ this -> getCommentsAfter ( array ( 'coun...
Calculate a page offset to the given comment
1,060
public function delete ( $ recursive = true ) { $ success = 0 ; $ count = $ this -> getCount ( ) ; $ comments = $ this -> getAll ( ) -> setIncrementOffset ( false ) ; foreach ( $ comments as $ comment ) { if ( $ comment -> delete ( $ recursive ) ) { $ success ++ ; } } return ( $ success == $ count ) ; }
Delete all comments in a thread
1,061
public function getAll ( $ getter = 'elgg_get_entities_from_metadata' , $ options = array ( ) ) { $ options [ 'limit' ] = 0 ; $ options = $ this -> getFilterOptions ( $ options ) ; return new ElggBatch ( $ getter , $ options ) ; }
Get all comments as batch
1,062
public function getCommentsBefore ( array $ options = array ( ) ) { $ options [ 'wheres' ] [ ] = " e.time_created < {$this->comment->time_created} " ; $ options [ 'order_by' ] = 'e.time_created ASC' ; $ comments = elgg_get_entities_from_metadata ( $ this -> getFilterOptions ( $ options ) ) ; if ( is_array ( $ commen...
Get preceding comments
1,063
private function generateWrapperClass ( ) : void { $ this -> io -> title ( 'Wrapper' ) ; $ mangler = new $ this -> nameMangler ( ) ; $ routines = $ this -> readRoutineMetadata ( ) ; if ( ! empty ( $ routines ) ) { $ sorted_routines = [ ] ; foreach ( $ routines as $ routine ) { $ method_name = $ mangler -> getMethodName...
Generates the wrapper class .
1,064
private function readRoutineMetadata ( ) : array { $ data = file_get_contents ( $ this -> metadataFilename ) ; $ routines = ( array ) json_decode ( $ data , true ) ; if ( json_last_error ( ) != JSON_ERROR_NONE ) { throw new RuntimeException ( "Error decoding JSON: '%s'." , json_last_error_msg ( ) ) ; } return $ routine...
Returns the metadata of stored routines .
1,065
private function storeWrapperClass ( ) : void { $ code = $ this -> codeStore -> getCode ( ) ; switch ( $ this -> wrapperClassType ) { case 'static' : break ; case 'non static' : $ code = NonStatic :: nonStatic ( $ code ) ; break ; default : throw new FallenException ( 'wrapper class type' , $ this -> wrapperClassType )...
Writes the wrapper class to the filesystem .
1,066
private function writeClassHeader ( ) : void { $ p = strrpos ( $ this -> wrapperClassName , '\\' ) ; if ( $ p !== false ) { $ namespace = ltrim ( substr ( $ this -> wrapperClassName , 0 , $ p ) , '\\' ) ; $ class_name = substr ( $ this -> wrapperClassName , $ p + 1 ) ; } else { $ namespace = null ; $ class_name = $ thi...
Generate a class header for stored routine wrapper .
1,067
private function writeClassTrailer ( ) : void { $ this -> codeStore -> appendSeparator ( ) ; $ this -> codeStore -> append ( '}' ) ; $ this -> codeStore -> append ( '' ) ; $ this -> codeStore -> appendSeparator ( ) ; }
Generate a class trailer for stored routine wrapper .
1,068
private function writeRoutineFunction ( array $ routine , NameMangler $ nameMangler ) : void { $ wrapper = Wrapper :: createRoutineWrapper ( $ routine , $ this -> codeStore , $ nameMangler , $ this -> lobAsString ) ; $ wrapper -> writeRoutineFunction ( ) ; $ this -> imports = array_merge ( $ this -> imports , $ wrapper...
Generates a complete wrapper method for a stored routine .
1,069
public function getAttemptsLeftWithSameUser ( string $ userName ) : int { $ attemptsLeft = ( ( int ) $ this -> maxAttemptsForUserName ) - $ this -> enhancedAuthenticationMapper -> fetchAttemptsWithSameUser ( $ userName , $ this -> banTimeInSeconds ) ; return \ max ( 0 , $ attemptsLeft ) ; }
Return how many attemps are left for incorrect password .
1,070
public function getAttemptsLeftWithSameSession ( string $ sessionId ) : int { $ attemptsLeft = ( ( int ) $ this -> maxAttemptsForSessionId ) - $ this -> enhancedAuthenticationMapper -> fetchAttemptsWithSameSession ( $ sessionId , $ this -> banTimeInSeconds ) ; return \ max ( 0 , $ attemptsLeft ) ; }
Return how many attemps are left for same session id .
1,071
public function getAttemptsLeftWithSameIp ( string $ ipAddress ) : int { $ attemptsLeft = ( ( int ) $ this -> maxAttemptsForIpAddress ) - $ this -> enhancedAuthenticationMapper -> fetchAttemptsWithSameIp ( $ ipAddress , $ this -> banTimeInSeconds ) ; return \ max ( 0 , $ attemptsLeft ) ; }
Return how many attemps are left for same ip .
1,072
private function extractAccessToken ( ServerRequestInterface $ request ) { if ( $ request -> hasHeader ( 'Authorization' ) ) { $ parts = explode ( ' ' , $ request -> getHeaderLine ( 'Authorization' ) ) ; if ( count ( $ parts ) < 2 ) { return null ; } return end ( $ parts ) ; } $ queryParams = $ request -> getQueryParam...
Extract the token either from Authorization header or query params
1,073
protected function returnStorageObject ( ) { $ driver = $ this -> driver ; $ options = $ this -> options ; if ( isset ( $ this -> supportedDriver [ $ driver ] ) ) { $ class = $ this -> supportedDriver [ $ driver ] ; return new $ class ( $ options ) ; } throw new InvalidArgumentException ( "[{$driver}] not supported." )...
Return Storage Object .
1,074
public function run ( ) : void { $ this -> model -> attach ( $ this -> view ) ; $ this -> beforeAfterController ( 'before' ) ; $ this -> beforeAfterControllerAction ( 'before' ) ; $ this -> runController ( ) ; $ this -> beforeAfterControllerAction ( 'after' ) ; $ this -> beforeAfterController ( 'after' ) ; $ this -> mo...
Run mvc pattern .
1,075
private function beforeAfterControllerAction ( string $ when ) : void { $ method = $ when . \ ucfirst ( $ this -> routeAction ) ; if ( \ method_exists ( $ this -> controller , $ method ) && $ method !== $ when ) { \ call_user_func ( [ $ this -> controller , $ method ] ) ; } }
Run action before or after controller action execution .
1,076
private function beforeAfterController ( string $ when ) : void { if ( \ method_exists ( $ this -> controller , $ when ) ) { \ call_user_func ( [ $ this -> controller , $ when ] ) ; } }
Run action before or after controller execution .
1,077
private function runController ( ) : void { $ action = $ this -> routeAction ; $ param = $ this -> routeParam ; if ( ! empty ( $ param ) ) { \ call_user_func_array ( [ $ this -> controller , $ action ] , $ param ) ; return ; } if ( $ action ) { \ call_user_func ( [ $ this -> controller , $ action ] ) ; } }
Run controller .
1,078
private function runView ( ) : void { $ action = ( $ this -> routeAction ) ? $ this -> routeAction : 'index' ; \ call_user_func ( [ $ this -> view , $ action ] ) ; }
Run view .
1,079
public function getMarkedQuery ( string $ style = 'error' ) : array { $ query = trim ( $ this -> query ) ; $ message = [ ] ; if ( strpos ( $ query , PHP_EOL ) !== false && $ this -> isQueryError ( ) ) { $ error_line = trim ( strrchr ( $ this -> error , ' ' ) ) ; $ lines = explode ( PHP_EOL , $ query ) ; $ digits = ceil...
Returns an array with the lines of the SQL statement . The line where the error occurred will be styled .
1,080
private function applyColor ( $ label , $ content , $ color ) { $ searches = ">" . $ content ; $ replaces = " style=\"background-color:" . $ color . ";\"" . $ searches ; return StringHelper :: replace ( $ label , [ $ searches ] , [ $ replaces ] ) ; }
Apply the color .
1,081
public function bootstrapRoleLabelFunction ( UserInterface $ user = null , array $ roleColors = [ ] , array $ roleTrans = [ ] ) { if ( null === $ user ) { return "" ; } $ output = [ ] ; foreach ( $ user -> getRoles ( ) as $ current ) { $ role = true === $ current instanceof Role ? $ current -> getRole ( ) : $ current ;...
Display a Bootstrap role label .
1,082
public static function createRoutineWrapper ( array $ routine , PhpCodeStore $ codeStore , NameMangler $ nameMangler , bool $ lobAsString ) : Wrapper { switch ( $ routine [ 'designation' ] ) { case 'bulk' : $ wrapper = new BulkWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'bulk_inse...
A factory for creating the appropriate object for generating a wrapper method for a stored routine .
1,083
public function isBlobParameter ( ? array $ parameters ) : bool { $ hasBlob = false ; if ( $ parameters ) { foreach ( $ parameters as $ parameter_info ) { $ hasBlob = $ hasBlob || DataTypeHelper :: isBlobParameter ( $ parameter_info [ 'data_type' ] ) ; } } return $ hasBlob ; }
Returns true if one of the parameters is a BLOB or CLOB .
1,084
public function writeRoutineFunction ( ) : void { if ( ! $ this -> lobAsStringFlag && $ this -> isBlobParameter ( $ this -> routine [ 'parameters' ] ) ) { $ this -> writeRoutineFunctionWithLob ( ) ; } else { $ this -> writeRoutineFunctionWithoutLob ( ) ; } }
Generates a complete wrapper method .
1,085
public function writeRoutineFunctionWithoutLob ( ) : void { $ wrapperArgs = $ this -> getWrapperArgs ( ) ; $ methodName = $ this -> nameMangler -> getMethodName ( $ this -> routine [ 'routine_name' ] ) ; $ returnType = $ this -> getReturnTypeDeclaration ( ) ; $ this -> codeStore -> appendSeparator ( ) ; $ this -> gener...
Returns a wrapper method for a stored routine without LOB parameters .
1,086
protected function getRoutineArgs ( ) : string { $ ret = '' ; foreach ( $ this -> routine [ 'parameters' ] as $ parameter_info ) { $ mangledName = $ this -> nameMangler -> getParameterName ( $ parameter_info [ 'parameter_name' ] ) ; if ( $ ret ) $ ret .= ',' ; $ ret .= DataTypeHelper :: escapePhpExpression ( $ paramete...
Returns code for the arguments for calling the stored routine in a wrapper method .
1,087
protected function getWrapperArgs ( ) : string { $ ret = '' ; if ( $ this -> routine [ 'designation' ] == 'bulk' ) { $ ret .= 'BulkHandler $bulkHandler' ; } foreach ( $ this -> routine [ 'parameters' ] as $ i => $ parameter ) { if ( $ ret != '' ) $ ret .= ', ' ; $ dataType = DataTypeHelper :: columnTypeToPhpTypeHinting...
Returns code for the parameters of the wrapper method for the stored routine .
1,088
private function generatePhpDoc ( ) : void { $ this -> codeStore -> append ( '/**' , false ) ; $ this -> generatePhpDocSortDescription ( ) ; $ this -> generatePhpDocLongDescription ( ) ; $ this -> generatePhpDocParameters ( ) ; $ this -> generatePhpDocBlockReturn ( ) ; $ this -> codeStore -> append ( ' */' , false ) ; ...
Generate php doc block in the data layer for stored routine .
1,089
private function generatePhpDocBlockReturn ( ) : void { $ return = $ this -> getDocBlockReturnType ( ) ; if ( $ return !== '' ) { $ this -> codeStore -> append ( ' *' , false ) ; $ this -> codeStore -> append ( ' * @return ' . $ return , false ) ; } }
Generates the PHP doc block for the return type of the stored routine wrapper .
1,090
private function generatePhpDocLongDescription ( ) : void { if ( $ this -> routine [ 'phpdoc' ] [ 'long_description' ] !== '' ) { $ this -> codeStore -> append ( ' * ' . $ this -> routine [ 'phpdoc' ] [ 'long_description' ] , false ) ; } }
Generates the long description of stored routine wrapper .
1,091
private function generatePhpDocParameters ( ) : void { $ parameters = [ ] ; foreach ( $ this -> routine [ 'phpdoc' ] [ 'parameters' ] as $ parameter ) { $ mangledName = $ this -> nameMangler -> getParameterName ( $ parameter [ 'parameter_name' ] ) ; $ parameters [ ] = [ 'php_name' => '$' . $ mangledName , 'description'...
Generates the doc block for parameters of stored routine wrapper .
1,092
private function generatePhpDocSortDescription ( ) : void { if ( $ this -> routine [ 'phpdoc' ] [ 'sort_description' ] !== '' ) { $ this -> codeStore -> append ( ' * ' . $ this -> routine [ 'phpdoc' ] [ 'sort_description' ] , false ) ; } }
Generates the sort description of stored routine wrapper .
1,093
public static function matchPath ( string $ pattern , string $ path , bool $ isCaseSensitive = true ) : bool { if ( $ path == '' && $ pattern == '**/*' ) { return false ; } $ dirSep = preg_quote ( DIRECTORY_SEPARATOR , '/' ) ; $ trailingDirSep = '((' . $ dirSep . ')?|(' . $ dirSep . ').+)' ; $ patternReplacements = [ $...
Tests whether or not a given path matches a given pattern .
1,094
public function resize ( $ dropletId , array $ parameters ) { if ( ! array_key_exists ( 'size_id' , $ parameters ) || ! is_int ( $ parameters [ 'size_id' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide an integer "size_id".' ) ; } return $ this -> processQuery ( $ this -> buildQuery ( $ dropletId , ...
Resizes a specific droplet to a different size . This will affect the number of processors and memory allocated to the droplet . The size_id key is required .
1,095
public function snapshot ( $ dropletId , array $ parameters = array ( ) ) { return $ this -> processQuery ( $ this -> buildQuery ( $ dropletId , DropletsActions :: ACTION_SNAPSHOT , $ parameters ) ) ; }
Takes a snapshot of the running droplet which can later be restored or used to create a new droplet from the same image . Please be aware this may cause a reboot . The name key is optional .
1,096
public function restore ( $ dropletId , array $ parameters ) { if ( ! array_key_exists ( 'image_id' , $ parameters ) || ! is_int ( $ parameters [ 'image_id' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the "image_id" to restore.' ) ; } return $ this -> processQuery ( $ this -> buildQuery ( $ drop...
Restores a droplet with a previous image or snapshot . This will be a mirror copy of the image or snapshot to your droplet . Be sure you have backed up any necessary information prior to restore . The image_id is required .
1,097
public function rebuild ( $ dropletId , array $ parameters ) { if ( ! array_key_exists ( 'image_id' , $ parameters ) || ! is_int ( $ parameters [ 'image_id' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide the "image_id" to rebuild.' ) ; } return $ this -> processQuery ( $ this -> buildQuery ( $ drop...
Reinstalls a droplet with a default image . This is useful if you want to start again but retain the same IP address for your droplet . The image_id is required .
1,098
public function rename ( $ dropletId , array $ parameters ) { if ( ! array_key_exists ( 'name' , $ parameters ) || ! is_string ( $ parameters [ 'name' ] ) ) { throw new \ InvalidArgumentException ( 'You need to provide a string "name".' ) ; } return $ this -> processQuery ( $ this -> buildQuery ( $ dropletId , Droplets...
Renames a specific droplet to a different name . The name key is required .
1,099
public function queryWithParam ( string $ query , array $ param ) : PDOStatement { $ statement = $ this -> prepare ( $ query ) ; foreach ( $ param as $ value ) { $ this -> checkValue ( $ value ) ; $ ref = $ value ; $ ref [ 1 ] = & $ value [ 1 ] ; \ call_user_func_array ( [ $ statement , "bindParam" ] , $ ref ) ; } $ th...
Executes an SQL statement with parameters returning a result set as a PDOStatement object