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 ( $ prefix , $ view ) = explode ( ':' , $ key ) ; if ( $ prefix !== 'stream_object' ) { continue ; } $ views [ ] = $ view ; } return $ views ; }
|
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_id != {$entity->access_id}" ) , 'limit' => 0 , ) ; $ batch = new ElggBatch ( 'elgg_get_entities' , $ options , null , 25 , false ) ; foreach ( $ batch as $ river_object ) { $ river_object -> access_id = $ entity -> access_id ; $ river_object -> save ( ) ; } elgg_set_ignore_access ( $ ia ) ; }
|
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_WARNING , ] ; }
|
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_%%-%ds @todo describe parameter' , $ padding ) ; foreach ( $ columns as $ column ) { $ this -> codeStore -> append ( sprintf ( $ format , $ column [ 'column_name' ] ) , false ) ; } $ this -> codeStore -> append ( ' */' , false ) ; }
|
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 $ column ) { if ( $ first ) { $ format = sprintf ( ' in p_%%-%ds @%%s.%%s%%s@' , $ padding ) ; $ this -> codeStore -> appendToLastLine ( strtolower ( sprintf ( $ format , $ column [ 'column_name' ] , $ this -> tableName , $ column [ 'column_name' ] , '%type' ) ) ) ; } else { $ format = sprintf ( '%%%ds p_%%-%ds @%%s.%%s%%s@' , $ offset + 3 , $ padding ) ; $ this -> codeStore -> append ( strtolower ( sprintf ( $ format , 'in' , $ column [ 'column_name' ] , $ this -> tableName , $ column [ 'column_name' ] , '%type' ) ) , false ) ; } if ( $ column != end ( $ columns ) ) { $ this -> codeStore -> appendToLastLine ( ',' ) ; } else { $ this -> codeStore -> appendToLastLine ( ' )' ) ; } $ first = false ; } }
|
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 ( ) ; foreach ( $ parameters as $ param ) { $ notAlreadyStored = ! \ in_array ( $ param , $ this -> tree [ $ level ] [ $ class ] ) ; if ( \ class_exists ( ( string ) $ param -> getType ( ) ) && $ notAlreadyStored ) { $ stack -> push ( [ $ level , $ class ] ) ; $ this -> tree [ $ level ] [ $ class ] [ ] = $ param ; $ level ++ ; $ class = $ param -> getClass ( ) -> name ; continue 2 ; } if ( $ notAlreadyStored ) { $ this -> tree [ $ level ] [ $ class ] [ ] = $ param ; } } if ( $ stack -> count ( ) === 0 ) { break ; } list ( $ level , $ class ) = $ stack -> pop ( ) ; } }
|
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 , $ arguments ) ; $ this -> cache [ $ class ] = ( new ReflectionClass ( $ class ) ) -> newInstanceArgs ( $ args ) ; continue ; } if ( $ object === null ) { $ this -> cache [ $ class ] = ( new ReflectionClass ( $ class ) ) -> newInstance ( ) ; } } } }
|
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 ; } $ args [ ] = null ; } if ( isset ( $ this -> rules [ $ class ] ) ) { $ args = \ array_replace ( $ args , $ this -> rules [ $ class ] ) ; } return $ args ; }
|
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" ) ] ) ; return implode ( " " , [ $ editButton , $ deleteButton ] ) ; }
|
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 -> getButtonTwigExtension ( ) -> bootstrapButtonLinkFilter ( $ but , ArrayHelper :: get ( $ args , "href" , self :: DEFAULT_HREF ) ) ; }
|
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 -> getButtonTwigExtension ( ) -> bootstrapButtonLinkFilter ( $ but , ArrayHelper :: get ( $ args , "href" , self :: DEFAULT_HREF ) ) ; }
|
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" ] ) ; $ attributes = [ ] ; $ attributes [ "class" ] = [ "alert" , $ class ] ; $ attributes [ "class" ] [ ] = true === $ dismissible ? "alert-dismissible" : null ; $ attributes [ "role" ] = [ "alert" ] ; $ innerHTML = ( true === $ dismissible ? $ button : "" ) . ( null !== $ content ? $ content : "" ) ; return static :: coreHTMLElement ( "div" , $ innerHTML , $ attributes ) ; }
|
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>" . $ description . "</small>" : "" ; $ innerHTML = ( null !== $ content ? $ content : "" ) . $ secondary ; return static :: coreHTMLElement ( $ element , $ innerHTML , $ attributes ) ; }
|
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 ) { $ redirectUri = trim ( ( string ) $ redirectUri ) ; } } $ client = new static ( ) ; $ client -> id = ( string ) Uuid :: uuid4 ( ) ; $ client -> name = $ name ; $ client -> redirectUris = $ redirectUris ?? [ ] ; return $ client ; }
|
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 -> _river_item ; }
|
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 ( '/(public|protected|private)\s+static(\s+)(function)/i' , '${1}${2}${3}' , $ source ) ; $ source = preg_replace ( '/self::/' , '$this->' , $ source ) ; if ( $ sourceClass !== null ) { $ source = preg_replace ( '/(class)(\s+)' . $ sourceClass . '/' , '${1}${2}' . $ targetClass , $ source ) ; } return $ source ; }
|
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 , 'callback' => $ this -> callback ] ; }
|
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 , $ submitButton ] ) ; }
|
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 -> getButtonTwigExtension ( ) -> bootstrapButtonSubmitFilter ( $ but ) ; }
|
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 ) ; $ methodMatch = \ strpos ( $ value -> method , $ method ) ; if ( $ urlMatch && $ methodMatch !== false ) { $ route = clone $ value ; $ this -> routeMatches = $ matches ; break ; } } return $ route ; }
|
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 ) ; $ this -> route = $ 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 ] , [ '[' => '' , ']' => '' ] ) ; $ param [ $ paramName ] = $ value ; } return $ param ; }
|
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 ( \ substr ( $ url , 0 , 1 ) === '/' ) ? $ url : '/' . $ url ; }
|
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" , "fos_user_profile_show" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; $ breadcrumbNodes [ ] = new BreadcrumbNode ( "label.change_password" , "g:lock" , "fos_user_change_password" , NavigationInterface :: NAVIGATION_MATCHER_ROUTER ) ; return $ breadcrumbNodes ; }
|
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 ( $ options , $ this -> banner ) ) ; }
|
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 ( $ button ) ; $ attributes [ "class" ] [ ] = ButtonRenderer :: renderActive ( $ button ) ; $ attributes [ "title" ] = ButtonRenderer :: renderTitle ( $ button ) ; $ attributes [ "type" ] = "button" ; $ attributes [ "data-toggle" ] = ButtonRenderer :: renderDataToggle ( $ button ) ; $ attributes [ "data-placement" ] = ButtonRenderer :: renderDataPLacement ( $ button ) ; $ attributes [ "disabled" ] = ButtonRenderer :: renderDisabled ( $ button ) ; $ glyphicon = null !== $ icon ? RendererTwigExtension :: renderIcon ( $ this -> getTwigEnvironment ( ) , $ icon ) : "" ; $ innerHTML = ButtonRenderer :: renderContent ( $ button ) ; return static :: coreHTMLElement ( "button" , implode ( " " , [ $ glyphicon , $ innerHTML ] ) , $ attributes ) ; }
|
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 [ ] = $ this -> bootstrapNav ( $ current ) ; } return static :: coreHTMLElement ( "ul" , "\n" . implode ( "\n" , $ innerHTML ) . "\n" , $ attributes ) ; }
|
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 ) ) { $ defaultSpName = strtolower ( sprintf ( '%s_%s' , $ tableName , $ spType ) ) ; $ fileName = sprintf ( '%s/%s.psql' , $ this -> sourceDirectory , $ defaultSpName ) ; $ question = new Question ( sprintf ( 'Please enter filename (%s): ' , $ fileName ) , $ fileName ) ; $ spName = $ this -> helper -> ask ( $ this -> input , $ this -> output , $ question ) ; if ( $ spName !== $ fileName ) { $ spName = strtolower ( $ spName ) ; $ fileName = sprintf ( '%s/%s.psql' , $ this -> sourceDirectory , $ spName ) ; } else { $ spName = $ defaultSpName ; } if ( file_exists ( $ fileName ) ) { $ this -> io -> writeln ( sprintf ( 'File <fso>%s</fso> already exists' , $ fileName ) ) ; $ question = 'Overwrite it ? (default No): ' ; $ question = new ConfirmationQuestion ( $ question , false ) ; if ( $ this -> helper -> ask ( $ this -> input , $ this -> output , $ question ) ) { $ code = $ this -> generateSP ( $ tableName , $ spType , $ spName ) ; $ this -> writeTwoPhases ( $ fileName , $ code ) ; } } else { $ code = $ this -> generateSP ( $ tableName , $ spType , $ spName ) ; $ this -> writeTwoPhases ( $ fileName , $ code ) ; } } }
|
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 = new DeleteRoutine ( $ this -> input , $ this -> output , $ this -> helper , $ spType , $ spName , $ tableName , $ this -> dataSchema ) ; break ; case 'SELECT' : $ routine = new SelectRoutine ( $ this -> input , $ this -> output , $ this -> helper , $ spType , $ spName , $ tableName , $ this -> dataSchema ) ; break ; case 'INSERT' : $ routine = new InsertRoutine ( $ this -> input , $ this -> output , $ this -> helper , $ spType , $ spName , $ tableName , $ this -> dataSchema ) ; break ; default : throw new FallenException ( "Unknown type '%s'" , $ spType ) ; } return $ routine -> getCode ( ) ; }
|
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' ] ; } $ array [ ] = $ partsArray ; } $ table = new Table ( $ this -> output ) ; $ table -> setRows ( $ array ) ; $ table -> render ( ) ; } }
|
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 ( ! isset ( $ key ) ) { $ this -> io -> logNote ( "Table '%s' not exist." , $ tableName ) ; } else { $ this -> askForCreateSP ( 'INSERT' , $ tableName ) ; $ this -> askForCreateSP ( 'UPDATE' , $ tableName ) ; $ this -> askForCreateSP ( 'DELETE' , $ tableName ) ; $ this -> askForCreateSP ( 'SELECT' , $ tableName ) ; } }
|
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 -> session -> login = [ 'login' => true , 'user_id' => $ storedId , 'user_name' => $ storedUserName , ] ; $ this -> data = $ this -> session -> login ; $ this -> session -> regenerate ( ) ; $ this -> logged = true ; return true ; } return false ; }
|
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 true ; }
|
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 -> save ( $ client ) ; return [ $ client , $ secret ] ; }
|
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" ] = $ class ; $ attributes [ "usemap" ] = $ usemap ; return StringHelper :: replace ( $ template , [ "%attributes%" ] , [ StringHelper :: parseArray ( $ attributes ) ] ) ; }
|
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 ( 'count' => true , 'offset' => 0 ) ) ; } return floor ( $ before / $ limit ) * $ limit ; }
|
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 ( $ comments ) ) { return array_reverse ( $ comments ) ; } return $ comments ; }
|
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 ( $ routine [ 'routine_name' ] ) ; $ sorted_routines [ $ method_name ] = $ routine ; } ksort ( $ sorted_routines ) ; foreach ( $ sorted_routines as $ method_name => $ routine ) { if ( $ routine [ 'designation' ] != 'hidden' ) { $ this -> writeRoutineFunction ( $ routine , $ mangler ) ; } } } else { echo "No files with stored routines found.\n" ; } $ wrappers = $ this -> codeStore -> getRawCode ( ) ; $ this -> codeStore = new PhpCodeStore ( ) ; $ this -> writeClassHeader ( ) ; $ this -> codeStore -> append ( $ wrappers , false ) ; $ this -> writeClassTrailer ( ) ; $ this -> storeWrapperClass ( ) ; }
|
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 $ routines ; }
|
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 ) ; } $ this -> writeTwoPhases ( $ this -> wrapperFilename , $ code ) ; }
|
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 = $ this -> wrapperClassName ; } $ this -> codeStore -> append ( '<?php' ) ; if ( $ this -> strictTypes ) { $ this -> codeStore -> append ( 'declare(strict_types=1);' ) ; } if ( $ namespace !== null ) { $ this -> codeStore -> append ( '' ) ; $ this -> codeStore -> append ( sprintf ( 'namespace %s;' , $ namespace ) ) ; $ this -> codeStore -> append ( '' ) ; } $ parent_class_name = substr ( $ this -> parentClassName , strrpos ( $ this -> parentClassName , '\\' ) + 1 ) ; if ( $ class_name != $ parent_class_name ) { $ this -> imports [ ] = $ this -> parentClassName ; $ this -> parentClassName = $ parent_class_name ; } if ( ! empty ( $ this -> imports ) ) { $ this -> imports = array_unique ( $ this -> imports , SORT_REGULAR ) ; foreach ( $ this -> imports as $ import ) { $ this -> codeStore -> append ( sprintf ( 'use %s;' , $ import ) ) ; } $ this -> codeStore -> append ( '' ) ; } $ this -> codeStore -> append ( '/**' ) ; $ this -> codeStore -> append ( ' * The data layer.' , false ) ; $ this -> codeStore -> append ( ' */' , false ) ; $ this -> codeStore -> append ( sprintf ( 'class %s extends %s' , $ class_name , $ this -> parentClassName ) ) ; $ this -> codeStore -> append ( '{' ) ; }
|
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 -> getImports ( ) ) ; }
|
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 -> getQueryParams ( ) ; return $ queryParams [ 'access_token' ] ?? null ; }
|
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 -> model -> notify ( ) ; $ this -> runView ( ) ; }
|
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 ( log ( sizeof ( $ lines ) + 1 , 10 ) ) ; $ format = sprintf ( '%%%dd %%s' , $ digits ) ; foreach ( $ lines as $ i => $ line ) { if ( ( $ i + 1 ) == $ error_line ) { $ message [ ] = sprintf ( '<%s>' . $ format . '</%s>' , $ style , $ i + 1 , OutputFormatter :: escape ( $ line ) , $ style ) ; } else { $ message [ ] = sprintf ( $ format , $ i + 1 , OutputFormatter :: escape ( $ line ) ) ; } } } else { $ message [ ] = $ query ; } return $ message ; }
|
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 ; $ trans = $ role ; if ( true === array_key_exists ( $ role , $ roleTrans ) ) { $ trans = $ this -> getTranslator ( ) -> trans ( $ roleTrans [ $ role ] ) ; } $ label = $ this -> getLabelTwigExtension ( ) -> bootstrapLabelDefaultFunction ( [ "content" => $ trans ] ) ; if ( true === array_key_exists ( $ role , $ roleColors ) ) { $ label = $ this -> applyColor ( $ label , $ trans , $ roleColors [ $ role ] ) ; } $ output [ ] = $ label ; } return implode ( " " , $ output ) ; }
|
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_insert' : $ wrapper = new BulkInsertWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'log' : $ wrapper = new LogWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'map' : $ wrapper = new MapWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'none' : $ wrapper = new NoneWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'row0' : $ wrapper = new Row0Wrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'row1' : $ wrapper = new Row1Wrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'rows' : $ wrapper = new RowsWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'rows_with_key' : $ wrapper = new RowsWithKeyWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'rows_with_index' : $ wrapper = new RowsWithIndexWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'singleton0' : $ wrapper = new Singleton0Wrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'singleton1' : $ wrapper = new Singleton1Wrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'function' : $ wrapper = new FunctionWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; case 'table' : $ wrapper = new TableWrapper ( $ routine , $ codeStore , $ nameMangler , $ lobAsString ) ; break ; default : throw new FallenException ( 'routine type' , $ routine [ 'designation' ] ) ; } return $ wrapper ; }
|
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 -> generatePhpDoc ( ) ; $ this -> codeStore -> append ( 'public static function ' . $ methodName . '(' . $ wrapperArgs . ')' . $ returnType ) ; $ this -> codeStore -> append ( '{' ) ; $ this -> writeResultHandler ( ) ; $ this -> codeStore -> append ( '}' ) ; $ this -> codeStore -> append ( '' ) ; }
|
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 ( $ parameter_info , '$' . $ mangledName , $ this -> lobAsStringFlag ) ; } return $ ret ; }
|
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 ( $ parameter ) ; $ declaration = DataTypeHelper :: phpTypeHintingToPhpTypeDeclaration ( $ dataType . '|null' ) ; if ( $ declaration !== '' ) { $ ret .= $ declaration . ' ' ; } $ ret .= '$' . $ this -> nameMangler -> getParameterName ( $ parameter [ 'parameter_name' ] ) ; } return $ ret ; }
|
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' => $ parameter [ 'description' ] , 'php_type' => $ parameter [ 'php_type' ] , 'data_type_descriptor' => $ parameter [ 'data_type_descriptor' ] ] ; } $ this -> enhancePhpDocParameters ( $ parameters ) ; if ( ! empty ( $ parameters ) ) { $ max_name_length = 0 ; $ max_type_length = 0 ; foreach ( $ parameters as $ parameter ) { $ max_name_length = max ( $ max_name_length , mb_strlen ( $ parameter [ 'php_name' ] ) ) ; $ max_type_length = max ( $ max_type_length , mb_strlen ( $ parameter [ 'php_type' ] ) ) ; } $ this -> codeStore -> append ( ' *' , false ) ; foreach ( $ parameters as $ parameter ) { $ format = sprintf ( ' * %%-%ds %%-%ds %%-%ds %%s' , mb_strlen ( '@param' ) , $ max_type_length , $ max_name_length ) ; $ lines = explode ( PHP_EOL , $ parameter [ 'description' ] ?? '' ) ; if ( ! empty ( $ lines ) ) { $ line = array_shift ( $ lines ) ; $ this -> codeStore -> append ( sprintf ( $ format , '@param' , $ parameter [ 'php_type' ] , $ parameter [ 'php_name' ] , $ line ) , false ) ; foreach ( $ lines as $ line ) { $ this -> codeStore -> append ( sprintf ( $ format , ' ' , ' ' , ' ' , $ line ) , false ) ; } } else { $ this -> codeStore -> append ( sprintf ( $ format , '@param' , $ parameter [ 'php_type' ] , $ parameter [ 'php_name' ] , '' ) , false ) ; } if ( $ parameter [ 'data_type_descriptor' ] !== null ) { $ this -> codeStore -> append ( sprintf ( $ format , ' ' , ' ' , ' ' , $ parameter [ 'data_type_descriptor' ] ) , false ) ; } } } }
|
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 = [ $ dirSep . '\*\*' . $ dirSep => $ dirSep . '.*' . $ trailingDirSep , $ dirSep . '\*\*' => $ trailingDirSep , '\*\*' . $ dirSep => '(.*' . $ dirSep . ')?' , '\*\*' => '.*' , '\*' => '[^' . $ dirSep . ']*' , '\?' => '[^' . $ dirSep . ']' ] ; $ rePattern = preg_quote ( $ pattern , '/' ) ; $ rePattern = str_replace ( array_keys ( $ patternReplacements ) , array_values ( $ patternReplacements ) , $ rePattern ) ; $ rePattern = '/^' . $ rePattern . '$/' . ( $ isCaseSensitive ? '' : 'i' ) ; return ( bool ) preg_match ( $ rePattern , $ path ) ; }
|
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 , DropletsActions :: ACTION_RESIZE , $ parameters ) ) ; }
|
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 ( $ dropletId , DropletsActions :: ACTION_RESTORE , $ parameters ) ) ; }
|
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 ( $ dropletId , DropletsActions :: ACTION_REBUILD , $ parameters ) ) ; }
|
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 , DropletsActions :: ACTION_RENAME , $ parameters ) ) ; }
|
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 ) ; } $ this -> lastOperationStatus = $ statement -> execute ( ) ; return $ statement ; }
|
Executes an SQL statement with parameters returning a result set as a PDOStatement object
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.