idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
58,100
|
public function execute ( Framework $ framework , WebRequest $ request , Response $ response ) { $ this -> setTitle ( $ this -> translate ( 'Group management' , '\\Zepi\\Web\\AccessControl' ) ) ; $ this -> activateMenuEntry ( 'group-administration' ) ; $ groupTable = new \ Zepi \ Web \ AccessControl \ Table \ GroupTable ( $ framework , true , true ) ; $ response -> setOutput ( $ this -> render ( '\\Zepi\\Web\\AccessControl\\Templates\\Administration\\Groups' , array ( 'groupTable' => $ groupTable , 'tableRenderer' => $ this -> getTableRenderer ( ) ) ) ) ; }
|
Displays the management page for groups .
|
58,101
|
public function execute ( Framework $ framework , CliRequest $ request , Response $ response ) { $ framework -> getRuntimeManager ( ) -> clearCache ( false ) ; $ framework -> getRouteManager ( ) -> clearCache ( false ) ; $ framework -> getModuleManager ( ) -> reactivateModules ( ) ; $ response -> setOutputPart ( 'cacheCleared' , 'The cache was successfully cleared and rebuilt!' ) ; }
|
The RebuildFrameworkCache event handler deletes the events and routes cache and executes the activation method on all modules .
|
58,102
|
public function getContentPath ( ) { if ( $ this -> composer -> getPackage ( ) ) { $ topExtra = $ this -> composer -> getPackage ( ) -> getExtra ( ) ; if ( ! empty ( $ topExtra [ 'wp-content-dir' ] ) ) { return rtrim ( $ topExtra [ 'wp-content-dir' ] , '/\\' ) ; } } return 'wp-content' ; }
|
Calculate path to wp - content
|
58,103
|
public function linkDropins ( PackageInterface $ package ) { $ this -> filesystem -> ensureDirectoryExists ( $ this -> getContentPath ( ) ) ; $ content_dir = realpath ( $ this -> getContentPath ( ) ) ; $ dropins_dir = realpath ( $ this -> getInstallPath ( $ package ) . '/dropins/' ) ; foreach ( new \ DirectoryIterator ( $ dropins_dir ) as $ dropin ) { if ( $ dropin -> isDot ( ) ) { continue ; } $ src = $ content_dir . '/' . $ dropin -> getFilename ( ) ; $ dest = $ dropins_dir . '/' . $ dropin -> getFilename ( ) ; if ( file_exists ( $ src ) ) { $ this -> io -> write ( '<info>Unlinking ' . $ this -> filesystem -> findShortestPath ( $ src , $ dest ) . '</info>' ) ; unlink ( $ src ) ; } $ this -> io -> write ( '<info>Linking ' . $ this -> filesystem -> findShortestPath ( $ src , $ dest ) . '</info>' ) ; $ this -> filesystem -> relativeSymlink ( $ dest , $ src ) ; } }
|
Link dropins to wp - content .
|
58,104
|
public function unlinkDropins ( PackageInterface $ package ) { $ content_dir = realpath ( $ this -> getContentPath ( ) ) ; $ dropins_dir = realpath ( $ this -> getInstallPath ( $ package ) . '/dropins/' ) ; foreach ( new \ DirectoryIterator ( $ dropins_dir ) as $ dropin ) { if ( $ dropin -> isDot ( ) ) { continue ; } $ src = $ content_dir . '/' . $ dropin -> getFilename ( ) ; $ dest = $ dropins_dir . '/' . $ dropin -> getFilename ( ) ; if ( file_exists ( $ src ) ) { $ this -> io -> write ( '<info>Unlinking ' . $ this -> filesystem -> findShortestPath ( $ src , $ dest ) . '</info>' ) ; unlink ( $ src ) ; } } }
|
Unlink dropins from wp - content .
|
58,105
|
public function set ( $ virtualProperty , $ relationEntity ) { if ( ! in_array ( $ virtualProperty , $ this -> structure -> relationProperties ) || ! isset ( $ this -> structure -> relations [ $ virtualProperty ] ) ) { throw new RelationException ( "Relation not defined!" ) ; } if ( ! isset ( self :: $ lazy [ get_class ( $ this -> entity ) ] [ $ virtualProperty ] ) ) { self :: $ lazy [ get_class ( $ this -> entity ) ] [ $ virtualProperty ] = array ( ) ; } $ relation = $ this -> structure -> relations [ $ virtualProperty ] ; if ( ! $ relation instanceof Relation ) { throw new RelationException ( "Relation indexing failed, something is really wrong, please report! Fetch proprty no instance of relation!" ) ; } if ( ! $ relation instanceof OneToOne && ! $ relation instanceof ManyToOne ) { throw new RelationException ( "Only relations OneToOne and ManyToOne could be set!" ) ; } if ( $ relationEntity === null ) { $ this -> entity -> { $ relation -> join -> column } = null ; return ; } $ targetStructure = EntityManager :: getInstance ( ) -> getEntityStructure ( $ relationEntity ) ; if ( ! $ relationEntity -> _saved ) { throw new RelationException ( "Save the relationship entity first!" ) ; } $ id = $ relationEntity -> { $ targetStructure -> primaryColumn -> propertyName } ; $ this -> entity -> { $ relation -> join -> column } = $ id ; self :: $ lazy [ get_class ( $ this -> entity ) ] [ $ virtualProperty ] [ $ id ] = $ relationEntity ; }
|
Set a new relationship value .
|
58,106
|
private static function _createFromTimestamp ( $ timestamp ) { $ date = new DateMilli ( ) ; $ dateTime = new \ DateTime ( ) ; $ intValue = ( int ) $ timestamp ; $ date -> _setMilliseconds ( ( float ) ( $ timestamp - $ intValue ) * 1000 ) ; $ timestamp = $ intValue ; if ( $ dateTime -> setTimestamp ( $ timestamp ) === false ) { throw new DateMilliException ( 'Impossible to create a Date object from the given timestamp value [' . $ timestamp . ']' ) ; } $ date -> _dateTime = $ dateTime ; return $ date ; }
|
Create and return a DateMilli object from a given timestamp
|
58,107
|
public function toString ( $ format = null ) { if ( ! isset ( $ format ) ) { $ format = self :: DATETIME_FORMAT ; } return $ this -> _dateTime -> format ( $ format ) . '.' . self :: _formatMilliseconds ( $ this -> _milliseconds ) ; }
|
Returns a given string format of the current Date instance
|
58,108
|
public function determineFromFilePath ( $ path , $ includeFiles = true , $ includeDirectories = true ) { $ path = $ this -> determineFilePath ( $ path ) ; $ this -> logger -> debug ( sprintf ( 'Searching files in path: %s' , $ path ) ) ; if ( ! file_exists ( $ path ) || ! is_readable ( $ path ) ) { $ this -> logger -> warning ( sprintf ( 'Could not read directory: %s' , $ path ) ) ; return array ( ) ; } $ fileNames = preg_grep ( '/^\.+$/' , scandir ( $ path ) , PREG_GREP_INVERT ) ; $ files = array ( ) ; if ( count ( $ fileNames ) > 0 ) { natcasesort ( $ fileNames ) ; foreach ( $ fileNames as $ fileName ) { $ fileName = $ this -> determineFilePath ( $ fileName , $ path ) ; if ( $ includeFiles && is_file ( $ fileName ) ) { $ files [ ] = $ fileName ; } if ( $ includeDirectories && is_dir ( $ fileName ) ) { $ files [ ] = $ fileName ; } } } $ this -> logger -> debug ( sprintf ( 'Found %d file(s)' , count ( $ files ) ) ) ; $ this -> logger -> debug ( sprintf ( 'Files: %s%s' , PHP_EOL , implode ( $ files , PHP_EOL ) ) ) ; return $ files ; }
|
Method to read Files from directory
|
58,109
|
protected function _decodeFile ( $ fileName , & $ ttl = null ) { if ( ! is_file ( $ fileName ) || false === ( $ _json = file_get_contents ( $ fileName ) ) || empty ( $ _json ) ) { return false ; } if ( false === ( $ _stored = json_decode ( $ _json , true ) ) || JSON_ERROR_NONE != json_last_error ( ) || ! is_array ( $ _stored ) ) { return false ; } if ( array_key_exists ( '.ttl' , $ _stored ) ) { $ ttl = ( integer ) $ _stored [ '.ttl' ] ; } else { $ ttl = - 1 ; } return array_key_exists ( '.data' , $ _stored ) ? ( @ unserialize ( $ _stored [ '.data' ] ) ? : $ _stored [ '.data' ] ) : null ; }
|
Given a file name open it and JSON decode it .
|
58,110
|
protected function _encodeFile ( $ fileName , $ data ) { $ _filePath = dirname ( $ fileName ) ; if ( ! is_dir ( $ _filePath ) ) { if ( false === @ mkdir ( $ _filePath , 0777 , true ) && ! is_dir ( $ _filePath ) ) { return false ; } } elseif ( ! is_writable ( $ _filePath ) ) { return false ; } $ _tempFile = tempnam ( $ _filePath , basename ( $ fileName ) ) ; if ( false !== file_put_contents ( $ _tempFile , json_encode ( $ data ) ) && @ rename ( $ _tempFile , $ fileName ) ) { @ chmod ( $ fileName , 0666 & ~ umask ( ) ) ; return true ; } return false ; }
|
Given a file name and some data encode and save .
|
58,111
|
public function get_title ( ) { $ str = '' ; if ( isset ( $ this -> refno_t ) ) { $ str = $ this -> refno_t ; if ( isset ( $ this -> altrefno_t ) ) { $ str .= ' / ' . $ this -> altrefno_t ; } } return $ str ; }
|
Get document title .
|
58,112
|
public static function getPathinfoPart ( string $ filePath , int $ fileInfOoptions ) : string { if ( $ filePath == '' || is_dir ( $ filePath ) || DirHelper :: endsWithSlash ( $ filePath ) ) { return '' ; } $ info = pathinfo ( $ filePath , $ fileInfOoptions ) ; if ( $ info == '.' && $ fileInfOoptions == PATHINFO_DIRNAME ) { return '' ; } return ( $ info !== null && $ info != '' ) ? $ info : '' ; }
|
Simple pathinfo wrapper .
|
58,113
|
public static function unlinkSafe ( string $ filePath ) : bool { if ( ! FileHelper :: fileExistsSafe ( $ filePath ) ) { return false ; } if ( DirHelper :: isDirSafe ( $ filePath ) ) { return false ; } return unlink ( $ filePath ) ; }
|
unlink file if exists . Return false if exists and unlink fails or if filePath is a dir .
|
58,114
|
public static function fileExistsSafe ( string $ filePath ) : bool { if ( $ filePath == '' ) { return false ; } if ( DirHelper :: isDirSafe ( $ filePath ) ) { return false ; } return file_exists ( $ filePath ) ; }
|
Check if passed file exists or not . If dir passed return false .
|
58,115
|
public static function getMimeType ( string $ fullPathFile ) : string { $ mime_types = self :: $ arrMimeType ; $ ext = strtolower ( self :: getFilenameExtension ( $ fullPathFile ) ) ; if ( array_key_exists ( $ ext , $ mime_types ) ) { return $ mime_types [ $ ext ] ; } $ mimetype = self :: getMimeTypeByMimeContentType ( $ fullPathFile ) ; if ( isNotNullOrEmpty ( $ mimetype ) ) { return $ mimetype ; } $ mimetype = self :: getMimeTypeByFinfo ( $ fullPathFile ) ; if ( isNotNullOrEmpty ( $ mimetype ) ) { return $ mimetype ; } return 'application/octet-stream' ; }
|
Return mime type of a passed file in optimized mode .
|
58,116
|
public static function getMimeTypeByFinfo ( string $ fullPathFile ) : string { if ( ! function_exists ( 'finfo_open' ) ) { return '' ; } $ finfo = finfo_open ( FILEINFO_MIME ) ; $ mimetype = finfo_file ( $ finfo , $ fullPathFile ) ; finfo_close ( $ finfo ) ; if ( $ mimetype === false ) { return '' ; } return $ mimetype ; }
|
Return mime type of a passed file using finfo
|
58,117
|
public function uploadAction ( ) { if ( ! $ filename = $ this -> get ( 'vince_type.manager.redactor' ) -> uploadFile ( ) ) { return new JsonResponse ( array ( 'error' => $ this -> get ( 'translator' ) -> trans ( 'redactor.messages.fileUploadError' , array ( ) , 'Vince' ) , ) ) ; } return new Response ( json_encode ( array ( 'filelink' => $ filename , 'filename' => pathinfo ( $ filename , PATHINFO_FILENAME ) , ) , JSON_UNESCAPED_SLASHES ) , 200 , array ( 'Content-Type' => 'application/json' , ) ) ; }
|
Upload file to user public directory
|
58,118
|
public function listFilesAction ( Request $ request ) { if ( ! $ request -> get ( 'paths' ) ) { throw $ this -> createNotFoundException ( ) ; } $ files = $ this -> get ( 'vince_type.manager.redactor' ) -> listFiles ( $ request -> get ( 'paths' ) ) ; return new Response ( json_encode ( $ files , JSON_UNESCAPED_SLASHES ) , 200 , array ( 'Content-Type' => 'application/json' , ) ) ; }
|
List files in path
|
58,119
|
public function getFilter ( ) { if ( null == $ this -> filter ) { $ this -> filter = new Filter ( [ 'serviceLocator' => $ this -> getServiceLocator ( ) , 'id' => $ this -> getId ( ) , ] ) ; } return $ this -> filter ; }
|
Gets a filter instance from grid . If filter not set then creating an empty filter instance .
|
58,120
|
public function getCells ( ) { if ( $ this -> cells == null ) { $ this -> cells = new CellSet ( [ 'serviceLocator' => $ this -> getServiceLocator ( ) , 'id' => $ this -> getId ( ) , ] ) ; } return $ this -> cells ; }
|
Gets a cells set from grid . If not set creating an empty cells set
|
58,121
|
public function getDataSource ( ) { $ this -> dataSource -> bindCellsset ( $ this -> getCells ( ) ) ; if ( null != $ this -> getDefaultOrderDirection ( ) && null != $ this -> getDefaultOrderField ( ) && ( $ this -> dataSource instanceof \ DataGrid \ DataSource \ DataSourceSortableInterface ) ) { $ this -> dataSource -> addOrderBy ( $ this -> getDefaultOrderField ( ) , $ this -> getDefaultOrderDirection ( ) ) ; } if ( $ this -> hasFilter ( ) ) { $ this -> getFilter ( ) -> applyTo ( $ this -> dataSource ) ; } if ( null != $ this -> getPaginator ( ) ) { $ this -> getPaginator ( ) -> applyTo ( $ this -> dataSource ) ; } return $ this -> dataSource ; }
|
Gets a data source provided for grid . This function apply CellsSet sorting filter and paginator to source
|
58,122
|
public function setDataSource ( $ dataSource ) { if ( ! $ dataSource instanceof DataSourceInterface ) { $ dataSource = $ this -> getServiceLocator ( ) -> get ( 'DataGrid\Factory\DataSource' ) -> get ( $ dataSource ) ; } $ this -> dataSource = $ dataSource ; return $ this ; }
|
Sets a data source for grid .
|
58,123
|
public function getPaginator ( ) { if ( ! empty ( $ this -> paginator ) ) { $ this -> paginator -> setId ( $ this -> getId ( ) ) ; } return $ this -> paginator ; }
|
Gets pagination .
|
58,124
|
public function setPaginator ( $ paginator ) { if ( is_array ( $ paginator ) ) { $ paginator = new Paginator ( $ paginator ) ; } $ this -> paginator = $ paginator ; return $ this ; }
|
Sets pagination .
|
58,125
|
public function setDefaultOrder ( $ defaultOrderField , $ defaultOrderDirection = 'ASC' ) { $ this -> defaultOrderField = $ defaultOrderField ; $ this -> defaultOrderDirection = $ defaultOrderDirection ; return $ this ; }
|
Set default sorting field and direction . Ensure that your data source contains that field .
|
58,126
|
public function buildAuthenticationEndpointUri ( SsoClient $ ssoClient , $ callbackUri ) { $ uri = new Uri ( $ this -> endpointUri ) ; $ arguments = array ( 'callbackUri' => ( string ) $ callbackUri , 'ssoClientIdentifier' => $ ssoClient -> getServiceBaseUri ( ) ) ; ksort ( $ arguments ) ; $ uri -> setQuery ( http_build_query ( $ arguments ) ) ; $ signature = $ this -> rsaWalletService -> sign ( ( string ) $ uri , $ ssoClient -> getPublicKeyFingerprint ( ) ) ; $ arguments [ 'signature' ] = base64_encode ( $ signature ) ; $ uri -> setQuery ( http_build_query ( $ arguments ) ) ; return ( string ) $ uri ; }
|
Build a URI to redirect to the server authentication endpoint
|
58,127
|
public function verifyCallbackSignature ( $ accessTokenCipher , $ signature ) { return $ this -> rsaWalletService -> verifySignature ( $ accessTokenCipher , $ signature , $ this -> publicKey ) ; }
|
Verify the signature of a callback redirect to the client
|
58,128
|
public function touchSession ( SsoClient $ ssoClient , $ sessionId ) { $ serviceUri = $ this -> serviceBaseUri . '/session/' . urlencode ( $ sessionId ) . '/touch' ; $ request = \ TYPO3 \ Flow \ Http \ Request :: create ( new Uri ( $ serviceUri ) , 'POST' ) ; $ request -> setContent ( '' ) ; $ signedRequest = $ this -> requestSigner -> signRequest ( $ request , $ ssoClient -> getPublicKeyFingerprint ( ) , $ ssoClient -> getPublicKeyFingerprint ( ) ) ; $ response = $ this -> requestEngine -> sendRequest ( $ signedRequest ) ; if ( $ response -> getStatusCode ( ) === 404 && $ response -> getHeader ( 'Content-Type' ) === 'application/json' ) { $ data = json_decode ( $ response -> getContent ( ) , TRUE ) ; if ( is_array ( $ data ) && isset ( $ data [ 'error' ] ) && $ data [ 'error' ] === 'SessionNotFound' ) { throw new \ Flowpack \ SingleSignOn \ Client \ Exception \ SessionNotFoundException ( ) ; } } if ( $ response -> getStatusCode ( ) !== 200 ) { throw new Exception ( 'Unexpected status code for touch session when calling "' . ( string ) $ serviceUri . '": "' . $ response -> getStatus ( ) . '"' , 1354030063 ) ; } }
|
Touch a global session
|
58,129
|
public function destroySession ( SsoClient $ ssoClient , $ sessionId ) { $ serviceUri = new Uri ( $ this -> serviceBaseUri . '/session/' . urlencode ( $ sessionId ) . '/destroy' ) ; $ serviceUri -> setQuery ( http_build_query ( array ( 'clientIdentifier' => $ ssoClient -> getServiceBaseUri ( ) ) ) ) ; $ request = \ TYPO3 \ Flow \ Http \ Request :: create ( $ serviceUri , 'DELETE' ) ; $ request -> setContent ( '' ) ; $ signedRequest = $ this -> requestSigner -> signRequest ( $ request , $ ssoClient -> getPublicKeyFingerprint ( ) , $ ssoClient -> getPublicKeyFingerprint ( ) ) ; $ response = $ this -> requestEngine -> sendRequest ( $ signedRequest ) ; if ( $ response -> getStatusCode ( ) !== 200 && $ response -> getStatusCode ( ) !== 404 ) { throw new Exception ( 'Unexpected status code for destroy session when calling "' . ( string ) $ serviceUri . '": "' . $ response -> getStatus ( ) . '"' , 1354132939 ) ; } }
|
Destroy the given global session
|
58,130
|
public static function fromXml ( \ DOMDocument $ xml ) { $ static = new static ( ) ; $ url = $ xml -> getElementsByTagName ( 'resource' ) ; $ static -> autoLoginUrl = StringLiteral :: fromXml ( $ url ) ; $ code = $ xml -> getElementsByTagName ( 'code' ) ; $ static -> code = StringLiteral :: fromXml ( $ code ) ; return $ static ; }
|
Builds a AutoLogin object from XML .
|
58,131
|
public static function Obl80 ( $ date1 , $ date2 ) { $ t ; $ eps0 ; $ t = ( ( $ date1 - DJ00 ) + $ date2 ) / DJC ; $ eps0 = DAS2R * ( 84381.448 + ( - 46.8150 + ( - 0.00059 + ( 0.001813 ) * $ t ) * $ t ) * $ t ) ; return $ eps0 ; }
|
- - - - - - - - - i a u O b l 8 0 - - - - - - - - -
|
58,132
|
public function registerServices ( DiInterface $ dependencyInjection ) { $ registerView = $ this -> getRegisterView ( $ dependencyInjection ) ; $ registerView -> register ( $ dependencyInjection -> get ( 'router' ) -> getModuleName ( ) , $ this -> modulePath ) ; $ dependencyInjection -> get ( 'dispatcher' ) -> setDefaultNamespace ( $ this -> moduleNamespace . "\controllers\\" ) ; }
|
Registers the module - only services
|
58,133
|
public function formatUtm ( string $ ellipsoid = Ellipsoid :: TYPE_WGS_84 ) { return Converter :: LL2Utm ( $ ellipsoid , $ this -> Latitude , $ this -> Longitude ) ; }
|
Formats the coordinate UTM specific and return the resulting string .
|
58,134
|
public function formatDecimal ( int $ precision = 8 ) : string { $ returnValue = '' ; if ( ! $ this -> isValid ( ) ) { return $ returnValue ; } $ returnValue .= $ this -> Latitude -> formatDecimal ( $ precision ) . ', ' . $ this -> Longitude -> formatDecimal ( $ precision ) ; return $ returnValue ; }
|
Formats the coordinate with floating point numbers .
|
58,135
|
public function calcSphericalDistanceTo ( Coordinate $ otherPoint ) { if ( ! $ this -> isValid ( ) ) { return 0 ; } $ b1 = $ this -> Latitude -> getDecimalValue ( ) ; $ l1 = $ this -> Longitude -> getDecimalValue ( ) ; $ b2 = $ otherPoint -> Latitude -> getDecimalValue ( ) ; $ l2 = $ otherPoint -> Longitude -> getDecimalValue ( ) ; $ rbreite1 = $ b1 * self :: DEG2RAD ; $ rlaenge1 = $ l1 * self :: DEG2RAD ; $ rbreite2 = $ b2 * self :: DEG2RAD ; $ rlaenge2 = $ l2 * self :: DEG2RAD ; $ rwinkel = \ acos ( \ sin ( $ rbreite1 ) * \ sin ( $ rbreite2 ) + \ cos ( $ rbreite1 ) * \ cos ( $ rbreite2 ) * \ cos ( \ abs ( $ rlaenge2 - $ rlaenge1 ) ) ) ; $ entfernung = $ rwinkel * 6370 ; return \ round ( $ entfernung , 3 ) ; }
|
Calculate the spherical distance from current coordinate to a other one .
|
58,136
|
public function isValid ( ) : bool { return ! \ is_null ( $ this -> Latitude ) && ! \ is_null ( $ this -> Longitude ) && ( $ this -> Latitude instanceof Latitude ) && ( $ this -> Longitude instanceof Longitude ) ; }
|
Returns if the current instance defines a valid coordinate .
|
58,137
|
public function init ( array $ stack ) : void { $ this -> stack = $ stack ; $ this -> dispatcher = new MiddlemanDispatcher ( $ this -> stack ) ; }
|
Initialize the middleware dispatcher by providing the necessary params .
|
58,138
|
public function responseFilter ( $ data , $ table = '' ) { if ( is_object ( $ data ) ) { $ data = $ data -> toArray ( ) ; } if ( $ table === '' && empty ( static :: DEFAULT_TABLE ) ) { return $ data ; } elseif ( $ table === '' && ! empty ( static :: DEFAULT_TABLE ) ) { $ table = static :: DEFAULT_TABLE ; } $ excludeFields = Config :: getConfig ( 'excludeFields' ) ; if ( ! in_array ( $ table , $ excludeFields ) ) { return $ data ; } else { $ tempData = $ data ; if ( isset ( $ tempData [ 0 ] ) ) { foreach ( $ tempData as $ k => $ v ) { foreach ( $ v as $ index => $ value ) { if ( is_array ( $ value ) ) { $ tempData [ $ k ] [ $ index ] = $ this -> responseFilter ( $ value , $ index ) ; } else { foreach ( $ excludeFields [ $ table ] as $ exKey => $ exVal ) { unset ( $ tempData [ $ k ] [ $ exVal ] ) ; } } } } } else { foreach ( $ tempData as $ index => $ value ) { if ( is_array ( $ value ) ) { $ tempData [ $ k ] [ $ index ] = $ this -> responseFilter ( $ value , $ index ) ; } else { foreach ( $ excludeFields [ $ table ] as $ exKey => $ exVal ) { unset ( $ tempData [ $ k ] [ $ exVal ] ) ; } } } } return $ tempData ; } }
|
Too many bugs!!! may deleted soon!!
|
58,139
|
public function newBranch ( NewBranchEvent $ event ) { $ branch = $ event -> getBranch ( ) ; $ related = $ this -> matcher -> getRelatedIssues ( $ branch ) ; $ branch -> setIssuesRelated ( $ related ) ; $ this -> repository -> persist ( $ branch ) ; }
|
Fills the branch with related issues matched by BranchMatcher .
|
58,140
|
public function setRulesFor ( $ key , $ rules ) { if ( is_array ( $ rules ) || is_string ( $ rules ) ) $ this -> _rules [ $ key ] = $ rules ; return $ this ; }
|
Set rules for an item key .
|
58,141
|
public function getRulesFor ( $ key ) { if ( ! isset ( $ this -> _rules [ $ key ] ) ) return null ; if ( is_string ( $ this -> _rules [ $ key ] ) ) return explode ( '|' , $ this -> _rules [ $ key ] ) ; return $ this -> _rules [ $ key ] ; }
|
Gets the rules for an item if it is set .
|
58,142
|
protected function getInputType ( $ input ) { $ type = gettype ( $ input ) ; if ( $ type == 'integer' || $ type == 'float' || $ type == 'double' ) $ type = 'numeric' ; if ( $ type == 'NULL' || $ type == 'object' || $ type == 'resource' || $ type == 'undefined type' ) $ type = null ; if ( $ type == 'array' && isset ( $ input [ 'type' ] ) && $ input [ 'tmp_name' ] ) $ type = 'file' ; return $ type ; }
|
Checks the type of the input and returns a validation type string of string numeric array or file . Will return null if a non - validation type is found .
|
58,143
|
public function getChoices ( ) { $ choices = $ this -> getOrderedRoles ( ) ; if ( isset ( $ choices [ 'ROLE_SUPER_ADMIN' ] ) ) { unset ( $ choices [ 'ROLE_SUPER_ADMIN' ] ) ; } if ( isset ( $ choices [ 'ROLE_ADMIN' ] ) && ! $ this -> isCurrentUserSuperAdmin ( ) ) { unset ( $ choices [ 'ROLE_ADMIN' ] ) ; } return $ choices ; }
|
Returns a list of choice for user s roles .
|
58,144
|
public function getUserRole ( UserInterface $ user ) { $ currentRole = '' ; $ userRoles = $ user -> getRoles ( ) ; if ( in_array ( $ userRoles [ 0 ] , $ this -> getOrderedRoles ( ) ) ) { $ currentRole = $ userRoles [ 0 ] ; } return $ currentRole ; }
|
Gets the current role of a user .
|
58,145
|
protected function getOrderedRoles ( ) { $ choices = [ ] ; foreach ( $ this -> roles as $ key => $ roles ) { foreach ( $ roles as $ role ) { $ choices [ $ role ] = $ role ; } $ choices [ $ key ] = $ key ; } return $ choices ; }
|
Returns the list of roles ordered by power level .
|
58,146
|
protected function isCurrentUserSuperAdmin ( ) { if ( null === $ token = $ this -> tokenStorage -> getToken ( ) ) { return true ; } if ( ! is_object ( $ user = $ token -> getUser ( ) ) ) { return false ; } return $ user -> isSuperAdmin ( ) ; }
|
Checks that current user is super administrator or not .
|
58,147
|
protected function registerViewer ( ) { $ this -> app -> bindShared ( 'viewer' , function ( $ app ) { $ view = $ app [ 'view' ] ; return new Classes \ Viewer ( $ view ) ; } ) ; }
|
Register the viewer class .
|
58,148
|
public function setAccessControlRequestMethod ( $ accessControlRequestMethod ) { if ( is_string ( $ accessControlRequestMethod ) === false ) { throw new InvalidArgumentException ( 'Parameter "method" is not a string' ) ; } if ( $ accessControlRequestMethod === '' ) { throw new InvalidArgumentException ( 'Parameter "method" cannot be blank' ) ; } $ this -> accessControlRequestMethod = $ accessControlRequestMethod ; return $ this ; }
|
Set access - control - request - method
|
58,149
|
public function setAccessControlRequestHeaders ( array $ accessControlRequestHeaders ) { foreach ( $ accessControlRequestHeaders as $ h ) { if ( is_string ( $ h ) === false ) { throw new InvalidArgumentException ( 'An element in array "accessControlRequestHeaders" is not a string' ) ; } } $ this -> accessControlRequestHeaders = $ accessControlRequestHeaders ; return $ this ; }
|
Set access - control - request - headers
|
58,150
|
public function modify ( Closure $ modify ) { $ contents = $ this -> jsonc -> parseFile ( $ this -> file ) ; $ modifiedContents = $ modify ( $ contents ) ; if ( $ modifiedContents !== NULL ) { $ contents = $ modifiedContents ; } $ this -> file -> writeContents ( $ this -> jsonc -> stringify ( $ contents , JSONConverter :: PRETTY_PRINT ) ) ; }
|
Modifies the JSON read from the file and saves it
|
58,151
|
public function isLoginPage ( ) { if ( is_null ( $ this -> loginPage ) ) { $ this -> loginPage = ( bool ) in_array ( $ this -> getPageNow ( ) , [ 'wp-login.php' , 'wp-register.php' ] ) ; } return $ this -> loginPage ; }
|
Is login page
|
58,152
|
public function ajax ( ) { if ( is_null ( $ this -> ajax ) ) { $ this -> ajax = ( bool ) ( defined ( 'DOING_AJAX' ) && DOING_AJAX ) ; $ this -> ajax = ( bool ) ( $ this -> ajax || parent :: ajax ( ) ) ; } return $ this -> ajax ; }
|
is ajax request
|
58,153
|
public function urlAction ( $ action , array $ query = [ ] ) { $ query [ 'action' ] = $ action ; $ query = array_replace ( $ this -> query ( ) , $ query ) ; return $ this -> url ( ) . '?' . http_build_query ( $ query ) ; }
|
Get the full URL with new action for the requests .
|
58,154
|
public function urlPagination ( $ pagination , array $ query = [ ] ) { $ query [ MbDatabaseQueryBuilder :: getPagination ( ) ] = $ pagination ; $ query = array_replace ( $ this -> query ( ) , $ query ) ; return $ this -> url ( ) . '?' . http_build_query ( $ query ) ; }
|
Get the full URL with new pagination for the requests .
|
58,155
|
public function hasQuery ( $ key ) { $ arrayKeys = array_keys ( $ _GET ) ; $ keys = is_array ( $ key ) ? $ key : func_get_args ( ) ; foreach ( $ keys as $ value ) { if ( ! in_array ( $ value , $ arrayKeys ) || trim ( ( string ) $ _GET [ $ value ] ) === '' ) { return false ; } } return true ; }
|
Determine if the request params contains a non - empty value for an input item .
|
58,156
|
public function route ( array $ classMap , array $ errorMap = null ) { $ this -> classMap = $ classMap ; $ this -> errorMap = $ errorMap === null ? self :: $ defaultErrorMap : array_merge ( self :: $ defaultErrorMap , $ errorMap ) ; $ pageMapper = new PageMapper ( $ this -> getClassMap ( ) ) ; $ page = $ pageMapper -> getPage ( ) ; if ( $ page == null && $ this -> fallThrough ) { return ; } $ pageResolver = new PageResolver ( $ this , $ page , $ pageMapper -> getUriVariables ( ) , $ this -> errorMap ) ; $ pageResolver -> evaluateWebPage ( ) ; $ pageResolver -> createHeader ( ) ; $ echo = $ pageResolver -> getRequestBody ( ) ; if ( ! $ this -> test ) { print $ echo ; } }
|
Main API method to show a page .
|
58,157
|
private function deriveCookiePathFromRequestUrl ( ) { $ path = $ this -> requestUrl -> getPath ( ) ; if ( $ path -> get ( ) == '' || substr ( ( string ) $ path , 0 , 1 ) != '/' ) { return '/' ; } if ( substr_count ( ( string ) $ path , '/' ) === 1 ) { return '/' ; } return substr ( ( string ) $ path , 0 , strrpos ( ( string ) $ path , '/' ) ) ; }
|
Derive the path for a cookie from the request URL
|
58,158
|
public function write ( $ file , $ data ) { $ file = '/data/' . $ file ; $ data = json_decode ( json_encode ( $ data ) , true ) ; $ data_content = isset ( $ data [ 'content' ] ) ? $ data [ 'content' ] : '' ; unset ( $ data [ 'content' ] ) ; $ data = '---' . PHP_EOL . trim ( $ this -> yaml -> dump ( $ data , 5 ) ) . PHP_EOL . '---' . PHP_EOL . $ data_content ; $ this -> source_filesystem -> createDir ( dirname ( $ file ) ) ; $ this -> source_filesystem -> put ( $ file , $ data ) ; }
|
Writes a data file .
|
58,159
|
public function read ( $ file ) { $ file = '/data/' . $ file ; $ result = [ ] ; $ ext = pathinfo ( $ file , PATHINFO_EXTENSION ) ; if ( isset ( $ this -> converters [ $ ext ] ) ) { $ meta = [ ] ; $ content = '' ; $ file_contents = $ this -> source_filesystem -> read ( $ file ) ; if ( $ file_contents ) { $ parts = preg_split ( '/\-{3}/' , $ file_contents , 3 ) ; if ( count ( $ parts ) === 3 ) { $ meta = $ parts [ 1 ] ? : [ ] ; $ content = $ parts [ 2 ] ; } else { $ content = $ file_contents ; } $ result = $ this -> yaml -> parse ( $ meta ) ; $ content = $ this -> converters [ $ ext ] -> convert ( $ content ) ; $ result [ 'content' ] = trim ( $ content ) ; } } return $ result ; }
|
Reads a data file .
|
58,160
|
public function queue ( array $ message , $ template = false , array $ templateVars = [ ] ) { $ message = $ this -> compressMessage ( $ message ) ; $ variables = $ this -> compressMessage ( $ templateVars ) ; $ body = [ 'm' => $ message , 't' => $ template , 'v' => $ variables , ] ; $ body = json_encode ( $ body ) ; return $ this -> getQueue ( ) -> enqueue ( $ body ) ; }
|
Queues an email to be sent .
|
58,161
|
public function processEmail ( Message $ message ) { $ body = json_decode ( $ message -> getBody ( ) ) ; $ message = $ this -> uncompressMessage ( $ body -> m ) ; $ variables = $ message ; if ( property_exists ( $ body , 'v' ) ) { $ variables = $ this -> uncompressMessage ( $ body -> v ) ; } $ this -> send ( $ message , $ body -> t , $ variables ) ; }
|
Handles an email message coming off the queue .
|
58,162
|
public function store ( $ account_id = null , $ identifier = null , $ username = null , $ address , $ verified = null , $ upstream_app_name = null , $ verification_callback = null , $ confirmation_from = null ) { $ fields = [ ] ; if ( ! is_null ( $ account_id ) ) $ fields [ 'account_id' ] = $ account_id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; $ fields [ 'address' ] = $ address ; if ( ! is_null ( $ verified ) ) $ fields [ 'verified' ] = $ verified ; if ( ! is_null ( $ upstream_app_name ) ) $ fields [ 'upstream_app_name' ] = $ upstream_app_name ; if ( ! is_null ( $ verification_callback ) ) $ fields [ 'verification_callback' ] = $ verification_callback ; if ( ! is_null ( $ confirmation_from ) ) $ fields [ 'confirmation_from' ] = $ confirmation_from ; return $ this -> _post ( $ fields ) ; }
|
Create An Email
|
58,163
|
function less ( $ file = "screen.less" , $ iTitle = "" , $ media = "all" ) { ( ! empty ( $ iTitle ) ) ? $ title = " title='$iTitle'" : $ title = '' ; return $ this -> lineBreak . '<link rel="stylesheet/less" type="text/css" href="' . $ file . '"' . $ title . ' media="' . $ media . '" />' ; }
|
not use since it is not cross browser compatible yet
|
58,164
|
public function getJob ( string $ name ) : Definition { if ( ! $ this -> hasJob ( $ name ) ) { throw new \ InvalidArgumentException ( 'Job not found: ' . $ name ) ; } return $ this -> jobs [ $ name ] ; }
|
Get the configuration array for a job .
|
58,165
|
public function getDictionary ( string $ name ) : Definition { if ( ! $ this -> hasDictionary ( $ name ) ) { throw new \ InvalidArgumentException ( 'Dictionary not found: ' . $ name ) ; } return $ this -> dictionaries [ $ name ] ; }
|
Get the configuration for a dictionary .
|
58,166
|
public function Comments ( $ Toggle = '' , $ TransientKey = '' ) { $ this -> Permission ( 'Garden.Settings.Manage' ) ; try { if ( $ this -> Toggle ( $ Toggle , $ TransientKey ) ) Redirect ( 'embed/comments' ) ; } catch ( Gdn_UserException $ Ex ) { $ this -> Form -> AddError ( $ Ex ) ; } $ this -> AddSideMenu ( 'dashboard/embed/comments' ) ; $ this -> Form = new Gdn_Form ( ) ; $ Validation = new Gdn_Validation ( ) ; $ ConfigurationModel = new Gdn_ConfigurationModel ( $ Validation ) ; $ ConfigurationModel -> SetField ( array ( 'Garden.Embed.CommentsPerPage' , 'Garden.Embed.SortComments' , 'Garden.Embed.PageToForum' ) ) ; $ this -> Form -> SetModel ( $ ConfigurationModel ) ; if ( $ this -> Form -> AuthenticatedPostBack ( ) === FALSE ) { $ this -> Form -> SetData ( $ ConfigurationModel -> Data ) ; } else { if ( $ this -> Form -> Save ( ) !== FALSE ) $ this -> InformMessage ( T ( "Your settings have been saved." ) ) ; } $ this -> Title ( T ( 'Blog Comments' ) ) ; $ this -> Render ( ) ; }
|
Display the embedded forum .
|
58,167
|
public function setEagerLoaded ( $ query ) { if ( ! empty ( $ this -> getEagerLoad ( ) ) ) { $ query = $ query -> with ( $ this -> getEagerLoad ( ) ) ; } return $ query ; }
|
Set this query s eager loaded relationships .
|
58,168
|
public function setLazyLoaded ( $ query ) { if ( ! empty ( $ this -> getLazyLoad ( ) ) ) { $ query = $ query -> load ( $ this -> getLazyLoad ( ) ) ; } return $ query ; }
|
Set this query s lazy loaded relationships .
|
58,169
|
function IS ( $ action , $ module , $ bundle , $ output ) { $ match = true ; if ( $ action != '' && $ action != $ this -> action ) { $ match = false ; } if ( $ module != '' && $ module != $ this -> module ) { $ match = false ; } if ( $ bundle != '' && $ bundle != $ this -> bundle ) { $ match = false ; } if ( $ match ) { return $ output ; } return '' ; }
|
Return the output if the route matches
|
58,170
|
function short ( $ action , $ module , $ bundle ) { if ( is_array ( $ this -> get ( 'routes' ) ) ) { foreach ( $ this -> get ( 'routes' ) as $ r ) { if ( $ bundle == $ r [ 'bundle' ] && $ module == $ r [ 'default_module' ] && $ action == $ r [ 'default_action' ] && ! empty ( $ r [ 'short' ] ) ) { return $ r [ 'short' ] ; } } return "/" . $ bundle . "/" . $ module . "/" . $ action ; } return "/" . $ bundle . "/" . $ module . "/" . $ action ; }
|
reverse a route to it s configuration state
|
58,171
|
public function create ( Environment $ environment ) { $ uri = ( new UriFactory ( ) ) -> create ( $ environment ) ; $ uploadFiles = ( new FilesFactory ( ) ) -> create ( $ environment ) ; $ headers = ( new HeadersFactory ( ) ) -> create ( $ environment ) ; $ cookies = $ environment -> getCookies ( ) ; $ requestMethod = $ environment -> getRequestMethod ( ) ; $ bodyStream = new Stream ( $ environment -> getBody ( ) ) ; $ protocol = $ environment -> getProtocolVersion ( ) ; $ serverVariables = $ environment -> getServer ( ) ; $ serverRequest = new ServerRequest ( $ requestMethod , $ uri , $ bodyStream , $ headers , $ serverVariables , $ cookies , $ uploadFiles , $ protocol ) ; if ( $ this -> usePostAsParsed ( $ requestMethod , $ serverRequest ) ) { $ serverRequest = $ serverRequest -> withParsedBody ( $ environment -> getPost ( ) ) ; } return $ serverRequest ; }
|
Create instance of ServerRequest object from instance of Environment object
|
58,172
|
public function formatPhone ( string $ phone , string $ format = '(###) ###-####' ) : string { return $ this -> formatPhoneMask ( $ this -> stripNonNumeric ( $ phone ) , strlen ( $ this -> stripNonNumeric ( $ phone ) ) , $ format ) ; }
|
Format a phone number to a set mask .
|
58,173
|
protected function formatPhoneMask ( string $ phone , int $ length , string $ format ) : string { $ this -> formatPhoneMultiMask ( $ phone , $ length , $ format ) ; return preg_match ( '/^\(?([2-9]{1}\d{2})\)?[-.\s]?([2-9]{1}\d{2})[-.\s]?(\d{4})$/' , $ phone ) ? preg_replace ( '/([0-9]{3})([0-9]{3})([0-9]{4})/' , '($1) $2-$3' , $ phone ) : $ phone ; }
|
Format phone - to - mask .
|
58,174
|
protected function formatPhoneMultiMask ( string $ phone , int $ length , string $ format ) : string { if ( 7 === $ length && 1 === substr_count ( $ format , '-' ) ) { return preg_replace ( '/([0-9]{3})([0-9]{4})/' , '$1-$2' , $ phone ) ; } elseif ( 10 === $ length ) { return $ this -> formatPhoneTenDigitMask ( $ phone , $ format ) ; } }
|
Return the correct digit masking .
|
58,175
|
protected function formatPhoneTenDigitMask ( string $ phone , string $ format ) : string { return ( 1 === substr_count ( $ format , '(###)' ) ) ? preg_replace ( '/([0-9]{3})([0-9]{3})([0-9]{4})/' , '($1) $2-$3' , $ phone ) : preg_replace ( '/([0-9]{3})([0-9]{3})([0-9]{4})/' , '$1-$2-$3' , $ phone ) ; }
|
Format phone with 10 - digit mask .
|
58,176
|
public function formatEID ( string $ employeeID , string $ format = '#########' ) : string { $ employeeID = $ this -> stripNonNumeric ( $ employeeID ) * 1 ; return str_pad ( $ employeeID , strlen ( $ format ) , '0' , STR_PAD_LEFT ) ; }
|
Returns a UCSD formatted EID number .
|
58,177
|
public function formatOfficeLocation ( string $ office ) : string { $ office = strtoupper ( trim ( $ office ) ) ; $ rightAlpha = preg_replace ( '/[^A-Z]/' , '' , substr ( $ office , - 1 ) ) ; $ numbersOnly = substr ( '0000' . ( $ this -> getNumbersOnly ( $ office ) * 1 ) , - 4 ) ; $ numbersOnly = substr ( $ numbersOnly , 0 , 2 ) === '04' ? 'B' . substr ( $ numbersOnly , 1 , 4 ) : $ numbersOnly ; return ( '' === $ office || 'NONE' === $ office ) ? 'None' : sprintf ( '%s %s%s' , 'AP&M' , $ numbersOnly , $ rightAlpha ) ; }
|
Return a correctly formatted UCSD office location .
|
58,178
|
protected function loadElements ( $ tagName , ContainerBuilder $ container , $ methodForConfiguration , $ methodForService ) { $ parserName = 'open_orchestra_bbcode.parser' ; $ tagName = 'open_orchestra_bbcode.' . $ tagName ; if ( $ container -> hasParameter ( $ tagName ) ) { $ parser = $ container -> getDefinition ( $ parserName ) ; $ elements = $ container -> getParameter ( $ tagName ) ; $ parser -> addMethodCall ( $ methodForConfiguration , array ( $ elements ) ) ; } $ this -> addStrategyToManager ( $ container , $ parserName , $ tagName , $ methodForService ) ; }
|
Load validators or code definitions from both configuration and tagged services
|
58,179
|
public function query ( $ name , $ query , $ time = 0 ) { $ this -> _query [ $ name ] = $ query ; $ this -> _time [ $ name ] = $ time ; }
|
Add a new query to the instance
|
58,180
|
public function vars ( $ var ) { if ( is_array ( $ var ) ) { foreach ( $ var as $ key => $ valeur ) { $ this -> _var [ $ key ] = $ valeur ; } } else if ( func_num_args ( ) == 2 ) { $ args = func_get_args ( ) ; $ this -> _var [ $ args [ 0 ] ] = $ args [ 1 ] ; } else if ( func_num_args ( ) == 3 ) { $ args = func_get_args ( ) ; $ this -> _var [ $ args [ 0 ] ] = [ $ args [ 1 ] , $ args [ 2 ] ] ; } }
|
add variables to the instance
|
58,181
|
protected function _getDataRelation ( $ line , $ foreign , $ parent ) { $ class = $ foreign -> referenceEntity ( ) ; $ entity = self :: Entity ( ) -> $ class ( ) ; if ( $ line [ $ foreign -> field ( ) . '_' . $ entity -> name ( ) . '_' . $ entity -> primary ( ) ] != '' ) { foreach ( $ line as $ key => $ field ) { $ value = null ; $ key = str_replace ( $ foreign -> field ( ) . '_' . $ entity -> name ( ) . '_' , '' , $ key ) ; if ( $ entity -> getField ( str_replace ( $ foreign -> field ( ) . '_' . $ entity -> name ( ) . '_' , '' , $ key ) ) != null ) { if ( in_array ( $ entity -> getField ( str_replace ( $ foreign -> field ( ) . '_' . $ entity -> name ( ) . '_' , '' , $ key ) ) -> type , [ Field :: INCREMENT , Field :: INT , Field :: FLOAT , Field :: TEXT , Field :: STRING , Field :: CHAR , Field :: BOOL , Field :: DATE , Field :: DATETIME , Field :: TIMESTAMP , Field :: ENUM ] ) ) { $ value = $ field ; } else { switch ( $ entity -> getField ( str_replace ( $ foreign -> field ( ) . '_' . $ entity -> name ( ) . '_' , '' , $ key ) ) -> type ) { case Field :: FILE : $ file = new File ( '' , '' , '' , '' ) ; $ file -> hydrate ( $ field ) ; $ value = $ file ; break ; } } $ fieldName = str_replace ( $ foreign -> field ( ) . '_' . $ entity -> name ( ) . '_' , '' , $ key ) ; $ entity -> set ( $ fieldName , $ value ) ; } } return $ entity ; } else { return null ; } }
|
If the Entity used has at least one relation we have to get an Entity object instead of the foreign key
|
58,182
|
public function compile ( $ pharOutputPath , $ binPath ) { $ pharBaseName = basename ( $ pharOutputPath ) ; if ( file_exists ( $ pharOutputPath ) ) { unlink ( $ pharOutputPath ) ; } $ phar = $ this -> initialisePhar ( $ pharOutputPath , 0 , $ pharBaseName ) ; $ phar -> startBuffering ( ) ; foreach ( $ this -> files as $ file ) { $ this -> addFileToPhar ( $ file , $ phar ) ; } $ this -> addFileToPhar ( $ binPath , $ phar ) ; $ phar -> setStub ( $ this -> createStub ( $ pharBaseName , $ binPath ) ) ; $ phar -> stopBuffering ( ) ; }
|
Compiles the project into a phar file .
|
58,183
|
public function addDirectory ( $ path ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> ignoreVCS ( true ) -> name ( '*.php' ) -> in ( $ path ) ; foreach ( $ finder as $ file ) { $ this -> addFile ( $ file ) ; } return $ this ; }
|
Add a directory .
|
58,184
|
protected function addFileToPhar ( $ path , Phar $ phar ) { $ realPath = realpath ( $ path ) ; $ content = file_get_contents ( $ realPath ) ; $ phar -> addFromString ( $ realPath , $ content ) ; }
|
Add a directory to the phar file .
|
58,185
|
protected function errorIfCompiledIncludesIsEmpty ( Config $ config ) : ? Error { $ includes = $ config -> compileIncludes ( ) ; return empty ( $ includes ) ? ResultFactory :: makeError ( $ this , 'Includes is empty.' ) : null ; }
|
Returns error if compiled includes is empty .
|
58,186
|
public static function getString ( int $ length = 20 , bool $ forceSeed = false ) : string { $ set = [ "a" , "A" , "b" , "B" , "c" , "C" , "d" , "D" , "e" , "E" , "f" , "F" , "g" , "G" , "h" , "H" , "i" , "I" , "j" , "J" , "k" , "K" , "l" , "L" , "m" , "M" , "n" , "N" , "o" , "O" , "p" , "P" , "q" , "Q" , "r" , "R" , "s" , "S" , "t" , "T" , "u" , "U" , "v" , "V" , "w" , "W" , "x" , "X" , "y" , "Y" , "z" , "Z" , "0" , "1" , "2" , "3" , "4" , "5" , "6" , "7" , "8" , "9" ] ; $ output = "" ; for ( $ i = 1 ; $ i <= $ length ; $ i ++ ) { $ ch = self :: getInt ( 0 , 61 , $ forceSeed ) ; $ output .= $ set [ $ ch ] ; } return $ output ; }
|
Creates a random alphanumeric string with the given length .
|
58,187
|
public static function getInt ( int $ min = 0 , int $ max = - 1 , bool $ forceSeed = false ) : int { if ( self :: $ _seeded === false || $ forceSeed === true ) { self :: _seedRandomizer ( ) ; } if ( $ max > $ min ) { return mt_rand ( $ min , $ max ) ; } else { return mt_rand ( ) ; } }
|
Creates a random integer number within the given range . If the given minimum is greater than the given maximum then the complete 64 bit range of integers will be used .
|
58,188
|
public static function getFloat ( int $ min = 0 , int $ max = 1 , bool $ forceSeed = false ) : float { if ( $ max > $ min ) { return $ min + ( float ) self :: getInt ( 0 , - 1 , $ forceSeed ) / mt_getrandmax ( ) * ( $ max - $ min ) ; } else { return ( float ) self :: getInt ( 0 , - 1 , $ forceSeed ) / mt_getrandmax ( ) ; } }
|
Creates a random floating point number within the given range . If the given minimum is greater than the given maximum then the complete 64 bit range of floats will be used .
|
58,189
|
private static function _seedRandomizer ( ) { self :: $ _seeded = true ; $ seed = \ hexdec ( \ bin2hex ( \ openssl_random_pseudo_bytes ( 8 ) ) ) ; \ mt_srand ( $ seed ) ; }
|
Creates a new random seed for more randomness .
|
58,190
|
public function getDependentPackages ( $ isDevMode ) { $ packages = [ ] ; $ rootPackage = $ this -> composer -> getPackage ( ) ; if ( $ this -> isDependentPackage ( $ rootPackage , ( bool ) $ isDevMode ) ) { $ packages [ ] = new PackageWrapper ( $ rootPackage , getcwd ( ) ) ; } $ manager = $ this -> composer -> getInstallationManager ( ) ; foreach ( $ this -> composer -> getRepositoryManager ( ) -> getLocalRepository ( ) -> getPackages ( ) as $ package ) { if ( $ this -> isDependentPackage ( $ package , $ isDevMode ) ) { $ packages [ ] = new PackageWrapper ( $ package , $ manager -> getInstallPath ( $ package ) ) ; } } return $ packages ; }
|
Get an array of packages that depend on the target package
|
58,191
|
private function isDependentPackage ( PackageInterface $ package , $ devMode = false ) { $ packages = $ package -> getRequires ( ) ; if ( $ devMode ) { $ packages = array_merge ( $ packages , $ package -> getDevRequires ( ) ) ; } foreach ( $ packages as $ link ) { if ( $ this -> targetPackage === $ link -> getTarget ( ) ) { return true ; } } return false ; }
|
Indicate whether a package has the target package as a dependency
|
58,192
|
public function extract ( $ expression , $ capture = 0 ) { $ valid = ( boolean ) preg_match ( $ expression , $ this -> value , $ match ) ; if ( $ valid === false || isset ( $ match [ $ capture ] ) === false ) { return null ; } return $ match [ $ capture ] ; }
|
Extract values from the token using a regular expression .
|
58,193
|
public static function compare ( $ left , $ right ) { if ( $ left < $ right ) { $ result = - 1 ; } else if ( $ left > $ right ) { $ result = 1 ; } else { $ result = 0 ; } return $ result ; }
|
Returns the order of the left and right hand values as an integer
|
58,194
|
public static function reverse ( $ left , $ right ) { if ( $ left < $ right ) { $ result = 1 ; } else if ( $ left > $ right ) { $ result = - 1 ; } else { $ result = 0 ; } return $ result ; }
|
Returns the reverse order of the left and right hand values as an integer
|
58,195
|
protected function dataFormalize ( $ data ) { if ( is_array ( $ data ) ) { $ data = json_encode ( $ data ) ; } else if ( $ data instanceof \ DOMDocument ) { $ data = $ data -> saveXML ( ) ; } else if ( $ data instanceof \ SimpleXMLElement ) { $ data = $ data -> asXML ( ) ; } return $ data ; }
|
If data are in an array tranform it in text
|
58,196
|
protected function useHeadersFromType ( $ type = null ) { $ defaultHeaders [ 'json' ] = array ( 'Accept:application/json' , 'Content-Type:application/json' , ) ; $ defaultHeaders [ 'xml' ] = array ( 'Accept:application/xml' , 'Content-Type:application/xml' , ) ; $ defaultHeaders [ 'custom' ] = null ; if ( ! isset ( $ type ) OR ! isset ( $ defaultHeaders [ $ type ] ) ) { $ this -> resource = 'custom' ; return $ defaultHeaders [ $ this -> defaultResource ] ; } $ this -> resource = $ type ; return $ defaultHeaders [ $ type ] ; }
|
Set headers depending on the type
|
58,197
|
protected function recieveHeaders ( $ headers = null ) { $ this -> resource = $ this -> defaultResource ; if ( is_string ( $ headers ) ) { $ type = trim ( strtolower ( $ headers ) ) ; $ headers = $ this -> useHeadersFromType ( $ type ) ; } else { if ( ! is_array ( $ headers ) ) { $ headers = $ this -> useHeadersFromType ( ) ; } } return $ headers ; }
|
Init curl headers if not exists
|
58,198
|
public function create ( $ service , $ headers = null , $ data = null ) { return $ this -> post ( $ service , $ headers , $ data ) ; }
|
Create request Use HTTP POST to send data
|
58,199
|
public function post ( $ service , $ headers = null , $ data = null ) { return $ this -> customRequest ( $ service , 'POST' , $ headers , $ data ) ; }
|
POST request Use HTTP POST to send data
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.