idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
20,500
public function initialize ( $ container , PaymentServiceProvider $ psp ) { parent :: initialize ( $ container , $ psp ) ; if ( isset ( $ this -> parameters [ 'host' ] ) ) $ this -> setHost ( $ this -> parameters [ 'host' ] ) ; if ( isset ( $ this -> parameters [ 'client_id' ] ) ) $ this -> setClientId ( $ this -> parameters [ 'client_id' ] ) ; if ( isset ( $ this -> parameters [ 'secret' ] ) ) $ this -> setSecret ( $ this -> parameters [ 'secret' ] ) ; if ( isset ( $ this -> parameters [ 'return_url' ] ) ) $ this -> setReturnUrl ( $ this -> parameters [ 'return_url' ] ) ; if ( isset ( $ this -> parameters [ 'cancel_url' ] ) ) $ this -> setCancelUrl ( $ this -> parameters [ 'cancel_url' ] ) ; return $ this ; }
Constructor with Paypal configuration
20,501
public function cancelation ( Request $ request ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( ) ; if ( $ request -> get ( 'token' ) != '' ) { $ token = $ request -> get ( 'token' ) ; $ transaction = $ em -> getRepository ( 'EcommerceBundle:Transaction' ) -> findOnPaymentDetails ( $ token ) ; if ( $ transaction instanceof Transaction ) { $ transaction -> setStatus ( Transaction :: STATUS_CANCELLED ) ; $ em -> flush ( ) ; } $ this -> container -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'danger' , 'transaction.cancel' ) ; return $ this -> redirect ( $ this -> generateUrl ( 'core_profile_index' , array ( 'transactions' => true ) ) ) ; } }
Cancelation payment OK
20,502
protected static function _HashHMAC ( $ HashMethod , $ Data , $ Key ) { $ PackFormats = array ( 'md5' => 'H32' , 'sha1' => 'H40' ) ; if ( ! isset ( $ PackFormats [ $ HashMethod ] ) ) return false ; $ PackFormat = $ PackFormats [ $ HashMethod ] ; if ( isset ( $ Key [ 63 ] ) ) $ Key = pack ( $ PackFormat , $ HashMethod ( $ Key ) ) ; else $ Key = str_pad ( $ Key , 64 , chr ( 0 ) ) ; $ InnerPad = ( substr ( $ Key , 0 , 64 ) ^ str_repeat ( chr ( 0x36 ) , 64 ) ) ; $ OuterPad = ( substr ( $ Key , 0 , 64 ) ^ str_repeat ( chr ( 0x5C ) , 64 ) ) ; return $ HashMethod ( $ OuterPad . pack ( $ PackFormat , $ HashMethod ( $ InnerPad . $ Data ) ) ) ; }
Returns the provided data hashed with the specified method using the specified key .
20,503
public function SetIdentity ( $ UserID , $ Persist = FALSE ) { if ( is_null ( $ UserID ) ) { $ this -> _ClearIdentity ( ) ; return ; } $ this -> UserID = $ UserID ; $ PayloadExpires = time ( ) ; if ( $ Persist ) { $ PayloadExpires += ( 86400 * self :: COOKIE_PERSIST_DAYS ) ; $ CookieExpires = $ PayloadExpires ; } else { $ PayloadExpires += ( 86400 * self :: COOKIE_SESSION_DAYS ) ; $ CookieExpires = 0 ; } $ KeyData = $ UserID . '-' . $ PayloadExpires ; $ this -> _SetCookie ( $ this -> CookieName , $ KeyData , array ( $ UserID , $ PayloadExpires ) , $ CookieExpires ) ; $ this -> SetVolatileMarker ( $ UserID ) ; }
Generates the user s session cookie .
20,504
protected function _SetCookie ( $ CookieName , $ KeyData , $ CookieContents , $ CookieExpires ) { self :: SetCookie ( $ CookieName , $ KeyData , $ CookieContents , $ CookieExpires , $ this -> CookiePath , $ this -> CookieDomain , $ this -> CookieHashMethod , $ this -> CookieSalt ) ; }
Set a cookie using path domain salt and hash method from core config
20,505
public static function SetCookie ( $ CookieName , $ KeyData , $ CookieContents , $ CookieExpires , $ Path = NULL , $ Domain = NULL , $ CookieHashMethod = NULL , $ CookieSalt = NULL ) { if ( is_null ( $ Path ) ) $ Path = Gdn :: Config ( 'Garden.Cookie.Path' , '/' ) ; if ( is_null ( $ Domain ) ) $ Domain = Gdn :: Config ( 'Garden.Cookie.Domain' , '' ) ; $ CurrentHost = Gdn :: Request ( ) -> Host ( ) ; if ( ! StringEndsWith ( $ CurrentHost , trim ( $ Domain , '.' ) ) ) $ Domain = '' ; if ( ! $ CookieHashMethod ) $ CookieHashMethod = Gdn :: Config ( 'Garden.Cookie.HashMethod' ) ; if ( ! $ CookieSalt ) $ CookieSalt = Gdn :: Config ( 'Garden.Cookie.Salt' ) ; $ KeyHash = self :: _Hash ( $ KeyData , $ CookieHashMethod , $ CookieSalt ) ; $ KeyHashHash = self :: _HashHMAC ( $ CookieHashMethod , $ KeyData , $ KeyHash ) ; $ Cookie = array ( $ KeyData , $ KeyHashHash , time ( ) ) ; if ( ! is_null ( $ CookieContents ) ) { $ CookieContents = ( array ) $ CookieContents ; $ Cookie = array_merge ( $ Cookie , $ CookieContents ) ; } $ CookieContents = implode ( '|' , $ Cookie ) ; setcookie ( $ CookieName , $ CookieContents , $ CookieExpires , $ Path , $ Domain , NULL , TRUE ) ; $ _COOKIE [ $ CookieName ] = $ CookieContents ; }
Set a cookie using specified path domain salt and hash method
20,506
private function isValid ( $ forceValidate ) { if ( $ this -> storage -> exists ( ) && $ this -> resources -> isValid ( $ this -> storage -> getLastWriteTime ( ) ) ) { return ( $ forceValidate || $ this -> isDebugging ( ) ) ? $ this -> validateManifest ( ) : true ; } return false ; }
Checks if the cache is valid .
20,507
public function load ( RouteLoaderInterface $ loader , $ forceValidate = false ) { if ( ! $ this -> isValid ( $ forceValidate ) ) { $ loader -> addListener ( $ this ) ; $ this -> doLoadResources ( $ loader , $ forceValidate ) ; $ loader -> removeListener ( $ this ) ; } return $ this -> storage -> read ( ) ; }
Loads the routes into a collection .
20,508
public function onLoaded ( ResourceInterface $ resource ) { if ( ! $ this -> isDebugging ( ) || $ this -> current === $ resource ) { return ; } $ this -> ensureCollector ( $ this -> current ) ; $ this -> meta [ $ this -> current ] -> addResource ( $ resource ) ; }
Loading callback .
20,509
private function setResources ( $ resources ) { if ( ! $ resources instanceof ResourcesInterface ) { $ files = ( array ) $ resources ; $ resources = new Resources ; array_walk ( $ files , [ $ resources , 'addFileResource' ] ) ; } $ this -> resources = $ resources ; }
Set the main resource files .
20,510
private function doLoadResources ( RouteLoaderInterface $ loader , $ forceValidate ) { $ collection = [ ] ; foreach ( $ this -> resources -> all ( ) as $ i => $ resource ) { $ this -> current = ( string ) $ resource ; if ( $ loaded = $ loader -> loadRoutes ( $ resource ) ) { $ collection [ ] = $ loaded -> all ( ) ; } } $ routes = call_user_func_array ( 'array_merge' , $ collection ) ; if ( $ this -> isDebugging ( ) || $ forceValidate ) { $ this -> writeManifests ( ) ; } $ this -> current = null ; $ this -> storage -> write ( new Routes ( $ routes ) ) ; }
Loads the main resources and caches the results .
20,511
public function makeContextUrl ( Context $ context , $ path = '' , array $ query = [ ] ) : string { if ( $ context -> isHost ( ) ) { $ url = $ context -> isSsl ( ) ? "https://" : "http://" ; $ url .= $ context -> getHost ( ) ; $ port = $ context -> getPort ( ) ; if ( $ port > 0 && $ port !== 80 ) { $ url .= ":" . $ port ; } $ url .= $ this -> isBasePrefix ( ) ? $ this -> base_prefix : "/" ; } else { $ url = $ this -> getPrefix ( ) ; } if ( $ context -> isQuery ( ) ) { foreach ( $ context -> getQuery ( ) as $ name => $ value ) { if ( is_array ( $ value ) ) { if ( ! isset ( $ query [ $ name ] ) || ! in_array ( $ query [ $ name ] , $ value ) ) { $ query [ $ name ] = current ( $ value ) ; } } else { $ query [ $ name ] = $ value ; } } } if ( is_array ( $ path ) ) { $ path = implode ( "/" , $ path ) ; } else if ( strlen ( $ path ) && $ path [ 0 ] === "/" ) { $ path = substr ( $ path , 1 ) ; } if ( $ context -> isPath ( ) ) { $ path = trim ( $ context -> getPath ( ) , "/" ) . "/" . $ path ; } return $ this -> getModeUrl ( $ url , $ path , $ query ) ; }
Get full url scheme string
20,512
public function makeUrl ( $ path = '' , array $ query = [ ] , bool $ context = false , bool $ full = null ) : string { if ( is_null ( $ full ) ) { $ url = $ this -> base ; } else if ( $ full ) { $ url = $ this -> getPrefix ( ) ; } else { $ url = $ this -> isBasePrefix ( ) ? $ this -> base_prefix : "/" ; } if ( is_array ( $ path ) ) { $ path = implode ( '/' , $ path ) ; } else if ( strlen ( $ path ) && $ path [ 0 ] === "/" ) { $ path = substr ( $ path , 1 ) ; } if ( $ context && $ this -> isContext ( ) ) { if ( strlen ( $ path ) ) { $ path = substr ( $ this -> context , 1 ) . $ path ; } else { $ path = trim ( $ this -> context , "/" ) ; } } return $ this -> getModeUrl ( $ url , $ path , $ query ) ; }
Get url string
20,513
public static function decode ( $ json , $ options = 0 , $ depth = 512 ) { $ data = json_decode ( $ json , true , $ depth , $ options ) ; self :: throwExceptionOnError ( $ data ) ; return $ data ; }
Decodes a JSON string to an array .
20,514
protected function resolvePageOptions ( array $ options = array ( ) ) { $ resolver = new OptionsResolver ; $ this -> setDefaultPageOptions ( $ resolver ) ; if ( ! empty ( $ this -> pageOptions ) ) { $ resolver -> setDefaults ( $ this -> pageOptions ) ; } return $ resolver -> resolve ( $ options ) ; }
Resolve page options
20,515
public function setConnection ( $ nameDB , $ table ) { $ this -> nameDB = $ nameDB ; $ this -> table = $ table ; $ this -> connection = $ this -> connection -> changeConnection ( $ nameDB ) ; }
Setea la conexion a la base de datos en base a la definicion seleccionada y la tabla indicada
20,516
public function mergeContext ( array $ moreContext ) { $ this -> context = array_replace_recursive ( isset ( $ this -> context ) ? $ this -> context : [ ] , $ moreContext ) ; return $ this ; }
Merge more context to current context
20,517
public function done ( ) { $ graph = clone $ this -> graph ; foreach ( $ this -> nodeFactories as $ factory ) { if ( ! $ factory -> isValid ( ) ) { throw new LackOfCoffeeException ( vsprintf ( 'Definition for the node "%s" is invalid.' , [ $ factory -> getName ( ) ] ) ) ; } $ graph -> add ( $ factory -> getName ( ) , $ factory -> getDependencies ( ) , $ factory -> getSpec ( ) ) ; } return $ graph ; }
Return the finished SpecGraph .
20,518
protected function findFactoryMethod ( ReflectionClass $ reflectedFactoryClass , MethodSelector $ factoryMethodSelector ) { $ allMatchingMethods = $ this -> findMatchingMethods ( $ reflectedFactoryClass , $ factoryMethodSelector ) ; $ this -> throwExceptionIfWrongNumberOfFactoryMethods ( $ allMatchingMethods ) ; return $ allMatchingMethods [ 0 ] ; }
Gets the factory method . The selector must pick exactly 1 object .
20,519
public function set ( $ name , $ service ) { if ( isset ( $ this -> registry [ $ name ] ) ) { unset ( $ this -> registry [ $ name ] ) ; } if ( isset ( $ this -> instances [ $ name ] ) ) { unset ( $ this -> instances [ $ name ] ) ; } if ( null === $ service ) { return $ this ; } if ( ! is_string ( $ service ) ) { $ this -> instances [ $ name ] = $ service ; return $ this ; } $ this -> registry [ $ name ] = $ service ; return $ this ; }
Sets the service .
20,520
public function get ( $ name ) { if ( isset ( $ this -> instances [ $ name ] ) ) { return $ this -> instances [ $ name ] ; } if ( ! isset ( $ this -> registry [ $ name ] ) ) { $ exceptionClass = static :: NOT_FOUND_EXCEPTION ; throw new $ exceptionClass ( sprintf ( static :: NOT_FOUND_MESSAGE , $ name ) ) ; } try { $ this -> instances [ $ name ] = $ this -> build ( $ this -> registry [ $ name ] , $ name ) ; } catch ( Exception $ e ) { throw new RuntimeException ( sprintf ( static :: BUILD_FAILURE_MESSAGE , $ name ) , null , $ e ) ; } return $ this -> instances [ $ name ] ; }
Gets the service .
20,521
public function build ( $ classNameOrSpecification , $ serviceName = '' ) { if ( false !== strpos ( $ classNameOrSpecification , '::' ) ) { $ specification = explode ( '::' , $ classNameOrSpecification ) ; $ className = $ specification [ 0 ] ; $ factoryMethod = $ specification [ 1 ] ; if ( ! class_exists ( $ className , true ) ) { throw new RuntimeException ( sprintf ( 'Factory "%s" not found.' , $ className ) ) ; } if ( ! is_callable ( [ $ className , $ factoryMethod ] ) ) { throw new RuntimeException ( sprintf ( 'Factory method "%s" of class "%s" is not callable.' , $ factoryMethod , $ className ) ) ; } if ( count ( $ specification ) > 2 ) { $ instance = call_user_func ( [ $ className , $ factoryMethod ] , ( string ) $ serviceName ) ; } else { $ instance = call_user_func ( [ $ className , $ factoryMethod ] ) ; } } else { $ className = $ classNameOrSpecification ; if ( ! class_exists ( $ className , true ) ) { throw new RuntimeException ( sprintf ( 'Class "%s" not found.' , $ className ) ) ; } $ instance = new $ className ( ) ; } return $ instance ; }
Builds an object .
20,522
public function set ( $ key , $ value ) { if ( null === $ key ) { $ this -> _data [ ] = $ value ; } else { $ this -> _data [ $ key ] = $ value ; } }
Set an item value by key .
20,523
public function extract ( ) { $ method = NULL ; $ name = explode ( ',' , $ this -> match [ 'raw' ] ) ; if ( strpos ( $ name [ 0 ] , '.' ) ) { $ parts = explode ( '.' , $ name [ 0 ] ) ; $ method = str_replace ( array ( '[' , ']' ) , '' , $ parts [ 1 ] ) ; } elseif ( isset ( $ this -> match [ 'params' ] [ 'method' ] ) ) { $ method = $ this -> match [ 'params' ] [ 'method' ] ; unset ( $ this -> match [ 'params' ] [ 'method' ] ) ; } if ( ! is_null ( $ method ) ) { return $ this -> fireMethod ( $ method ) ; } throw new InvalidClassMethodCalled ( $ method , $ this -> match [ 'raw' ] ) ; }
Returns the mask value based on mask and params ;
20,524
public function fireMethod ( $ methodName ) { if ( $ this -> reflection -> hasMethod ( $ methodName ) ) { $ method = $ this -> reflection -> getMethod ( $ methodName ) ; $ instance = $ this -> reflection -> newInstance ( ) ; return $ method -> invokeArgs ( $ instance , $ this -> match [ 'params' ] ) ; } throw new InvalidClassMethodCalled ( $ methodName , $ this -> match [ 'raw' ] ) ; }
Fires the chosen method of the class
20,525
public static function create ( int $ statusCode , string $ message , $ reason = null , string $ path = null , array $ attributes = [ ] , $ identifier = null ) : PresentationInterface { $ error = new ErrorResource ( $ message , $ reason , $ path , $ attributes , $ identifier ) ; return PresentationFactory :: create ( $ statusCode , $ error ) ; }
Create default error presentation .
20,526
public static function badRequest ( string $ message , $ reason = null , string $ path = null , array $ attributes = [ ] , $ identifier = null ) : PresentationInterface { $ error = new ErrorResource ( $ message , $ reason , $ path , $ attributes , $ identifier ) ; return PresentationFactory :: badRequest ( $ error ) ; }
Create the bad request error presentation .
20,527
public static function toNameStrict ( string $ name ) { $ len = strlen ( $ name ) ; if ( $ len < 1 || $ len > 50 ) { return false ; } $ name = str_replace ( "-" , "_" , $ name ) ; if ( strpos ( $ name , "__" ) !== false || $ name [ 0 ] === "_" || $ len > 1 && $ name [ $ len - 1 ] === "_" ) { return false ; } if ( strpos ( $ name , "_" ) !== false || ! ctype_upper ( $ name [ 0 ] ) ) { $ name = self :: toName ( $ name ) ; } if ( is_numeric ( $ name [ 0 ] ) || preg_match ( '/[^a-zA-Z0-9]/' , $ name ) ) { return false ; } return $ name ; }
Format and validate module name
20,528
public static function hasInstall ( string $ name , bool $ result_id = false ) : bool { if ( $ name === "@core" ) { return Helper :: isSystemInstall ( true ) ? ( $ result_id ? 0 : true ) : false ; } try { $ row = self :: getModuleScheme ( $ name , false , [ "id" , "install" ] ) ; } catch ( NotFoundException $ e ) { return false ; } if ( $ row -> install < 1 ) { return false ; } return $ result_id ? ( int ) $ row -> id : true ; }
Has module install
20,529
public static function create ( array $ args ) { $ job = new Job ( $ args [ 'body' ] ) ; if ( isset ( $ args [ 'id' ] ) ) { $ job -> setId ( $ args [ 'id' ] ) ; $ job -> setTtl ( hexdec ( substr ( $ job -> getId ( ) , - 4 ) ) ) ; } if ( isset ( $ args [ 'queue' ] ) ) { $ job -> setQueue ( $ args [ 'queue' ] ) ; } if ( isset ( $ args [ 'ttl' ] ) ) { $ job -> setTtl ( $ args [ 'ttl' ] ) ; } if ( isset ( $ args [ 'retry' ] ) ) { $ job -> setRetry ( $ args [ 'retry' ] ) ; } return $ job ; }
Job Factory method .
20,530
public function create ( ) { if ( ! $ this -> exists ( ) && $ this -> canCreate ( ) ) { $ this -> adapter -> mkdir ( $ this -> path , 0755 , true ) ; } return $ this ; }
Creates the directory if it doesn t exist .
20,531
public function copyAs ( $ dest ) { $ dest = rtrim ( $ dest , '/' ) . '/' ; $ copy = new Directory ( $ dest , $ this -> adapter ) ; foreach ( $ this -> fs ( ) -> find ( '*' ) -> asArray ( ) as $ file ) { $ file -> copyAs ( $ dest . $ file -> name ( ) ) ; } return $ copy ; }
Copies the directory to the provided destination and returns the copy .
20,532
public function registerPageMargins ( ) : PdfInterface { $ mpdf = $ this -> mpdf ; $ mpdf -> SetLeftMargin ( $ this -> marginLeft ) ; $ mpdf -> SetTopMargin ( $ this -> marginTop ) ; $ mpdf -> SetRightMargin ( $ this -> marginRight ) ; $ mpdf -> SetAutoPageBreak ( true , $ this -> marginBottom ) ; $ mpdf -> margin_header = $ this -> marginHeader ; $ mpdf -> margin_footer = $ this -> marginFooter ; $ mpdf -> orig_lMargin = $ mpdf -> DeflMargin = $ mpdf -> lMargin = $ this -> marginLeft ; $ mpdf -> orig_tMargin = $ mpdf -> tMargin = $ this -> marginTop ; $ mpdf -> orig_rMargin = $ mpdf -> DefrMargin = $ mpdf -> rMargin = $ this -> marginRight ; $ mpdf -> orig_bMargin = $ mpdf -> bMargin = $ this -> marginBottom ; $ mpdf -> orig_hMargin = $ mpdf -> margin_header = $ this -> marginHeader ; $ mpdf -> orig_fMargin = $ mpdf -> margin_footer = $ this -> marginFooter ; $ mpdf -> pgwidth = $ mpdf -> w - $ mpdf -> lMargin - $ mpdf -> rMargin ; return $ this ; }
Registering the page size and margins .
20,533
public function setFontSize ( int $ size ) : PdfInterface { $ this -> fontSize = ( int ) $ size ; $ this -> mpdf -> SetDefaultFontSize ( $ this -> fontSize ) ; return $ this ; }
Set the default font size .
20,534
public function importPages ( string $ filePath ) : PdfInterface { if ( ! is_file ( $ filePath ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The file "%s" does not exist.' , $ filePath ) ) ; } $ numberPagesCurrentFile = count ( $ this -> mpdf -> pages ) ; $ numberPagesExternalFile = $ this -> mpdf -> setSourceFile ( $ filePath ) ; $ numberTotalPages = $ numberPagesCurrentFile + $ numberPagesExternalFile ; $ this -> mpdf -> setImportUse ( ) ; for ( $ i = 1 ; $ i <= $ numberPagesExternalFile ; $ i ++ ) { if ( $ i < $ numberTotalPages ) { $ this -> mpdf -> addPage ( ) ; } $ this -> mpdf -> useTemplate ( $ this -> mpdf -> importPage ( $ i ) ) ; } return $ this ; }
Import external file pages and merge with current .
20,535
public function setOutputDestination ( string $ destination ) : PdfInterface { $ this -> setProperty ( 'outputDestination' , strtoupper ( $ destination [ 0 ] ) === 'B' ? 'I' : strtoupper ( $ destination [ 0 ] ) ) ; return $ this ; }
Set the output destination .
20,536
public function initializePageSetup ( string $ pageSize = null , string $ orientation = null ) : PdfInterface { in_array ( $ pageSize , $ this -> pageTypes ) ? $ this -> setProperty ( 'mpdf' , new \ mPDF ( 'utf-8' , $ pageSize . '-' . $ orientation [ 0 ] , $ this -> fontSize , $ this -> fontType , $ this -> marginLeft , $ this -> marginRight , $ this -> marginTop , $ this -> marginBottom , $ this -> marginHeader , $ this -> marginFooter , $ orientation [ 0 ] ) ) : $ this -> setProperty ( 'mpdf' , new \ mPDF ( 'UTF-8' , 'Letter-P' ) ) ; return $ this ; }
Initialize a new PDF document by specifying page size and orientation .
20,537
public function filter ( $ filter ) { if ( is_array ( $ filter ) != true ) { $ filter = [ $ filter ] ; } foreach ( $ filter as $ item ) { $ this -> filters [ ] = str_replace ( './' , $ this -> outpath . '/' , $ item ) ; } return $ this ; }
Registrar filtro do template .
20,538
public function add ( $ item , $ quoted = false ) { if ( true === $ quoted ) { $ item = '"' . $ item . '"' ; } $ this -> parts [ ] = $ item ; }
adds a CLI part . This function exposes the full functionality to end users
20,539
public function addRole ( $ role ) { if ( is_array ( $ role ) || $ role instanceof \ Traversable ) return $ this -> addMultipleRoles ( $ role ) ; else return $ this -> addSingleRole ( $ role ) ; }
Add a role to the user . The argument can be the role name ID Role object or an array of the previous
20,540
public function addSingleRole ( $ role ) { if ( is_string ( $ role ) ) return $ this -> addRoleByName ( $ role ) ; elseif ( is_numeric ( $ role ) ) return $ this -> addRoleById ( $ role ) ; elseif ( $ role instanceof BridgeRole ) return $ this -> addRoleByObject ( $ role ) ; else throw new \ InvalidArgumentException ( 'Role must be a name, ID, or Role object.' ) ; }
Add a single role . The argument is a string integer or instance of BridgeRole
20,541
public function addRoleByName ( $ role_name ) { $ role = static :: $ app [ 'db' ] -> connection ( ) -> table ( 'roles' ) -> where ( 'name' , '=' , $ role_name ) -> first ( ) ; if ( ! $ role ) throw new \ RuntimeException ( 'No role with that name found.' ) ; if ( is_array ( $ role ) ) return $ this -> addRoleById ( $ role [ 'id' ] ) ; elseif ( is_object ( $ role ) ) return $ this -> addRoleById ( $ role -> id ) ; else throw new \ UnexpectedValueException ( 'Value returned not array or instance of BridgeRole.' ) ; }
Add a single role to the user by name
20,542
public function addRoleByObject ( BridgeRole $ role_obj ) { if ( ! $ role_obj -> exists ) $ role_obj -> save ( ) ; $ role_id = $ role_obj -> getKey ( ) ; return $ this -> addRoleById ( $ role_id ) ; }
Add a single role to the user by using the Role object
20,543
public function hasRole ( $ role ) { $ roles = $ this -> roles ; foreach ( $ roles as $ role_obj ) if ( $ this -> checkRole ( $ role , $ role_obj ) ) return true ; return false ; }
Checks to see if a user has a certain role
20,544
public function checkRole ( $ check , BridgeRole $ has ) { if ( is_string ( $ check ) ) return $ this -> checkRoleByName ( $ check , $ has ) ; elseif ( is_numeric ( $ check ) ) return $ this -> checkRoleById ( $ check , $ has ) ; elseif ( $ check instanceof BridgeRole ) return $ this -> checkRoleByObject ( $ check , $ has ) ; else throw new \ InvalidArgumentException ( 'Role to check must be a name, ID, or Role object.' ) ; }
Checks to see if a given role is equal to a role the user already has
20,545
public function checkRoleByObject ( BridgeRole $ check , BridgeRole $ has ) { return $ this -> checkRoleById ( $ check -> id , $ has ) ; }
Check to see if the Role provided is the same as the BridgeRole object passed in
20,546
public function hasPermission ( $ permission ) { $ perm_id = $ this -> getPermissionId ( $ permission ) ; $ roles = $ this -> getRolesWithPermission ( $ perm_id ) ; foreach ( $ roles as $ role ) if ( $ this -> hasRole ( $ role ) ) return true ; return false ; }
Check to see if the user has the given permission . Permission can be an ID name or Permission object
20,547
public function getPermissionId ( $ permission ) { if ( is_numeric ( $ permission ) ) return $ permission ; elseif ( is_string ( $ permission ) ) return $ this -> getPermissionIdFromName ( $ permission ) ; elseif ( $ permission instanceof BridgePermission ) return $ permission -> id ; else throw new \ InvalidArgumentException ( 'Permission to check must be a name, ID, or Permission object.' ) ; }
Get the ID of the passed in permission . Permission can be an ID name or Permission object
20,548
public function getPermissionIdFromName ( $ perm_name ) { $ permission = static :: $ app [ 'db' ] -> connection ( ) -> table ( 'permissions' ) -> where ( 'name' , '=' , $ perm_name ) -> first ( ) ; return $ permission -> id ; }
Get the ID of a permission with the passed in name
20,549
public function getRolesWithPermission ( $ perm_id ) { $ roles = static :: $ app [ 'db' ] -> connection ( ) -> table ( 'roles_permissions' ) -> where ( 'permission_id' , '=' , $ perm_id ) -> lists ( 'role_id' ) ; $ roles = array_map ( 'intval' , $ roles ) ; return $ roles ; }
Get the roles who have the given permission
20,550
public function addChildren ( $ dirPathname ) { $ files = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ dirPathname , \ FilesystemIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ files as $ info ) { $ relativePathname = $ this -> subtractBasedir ( $ info -> getPathname ( ) , $ dirPathname ) ; if ( $ info -> isDir ( ) ) { $ this -> zip -> addEmptyDir ( $ relativePathname ) ; } else { $ this -> zip -> addFile ( $ info -> getPathname ( ) , $ relativePathname ) ; } } }
Recursively add children of directory to archive
20,551
public function addFileFromBasedir ( $ pathname , $ basedir = '' ) { $ info = new \ SplFileInfo ( $ pathname ) ; if ( ! $ info -> isFile ( ) ) { throw new InvalidArgumentException ( sprintf ( 'File not found: %s' , $ pathname ) ) ; } if ( ! $ info -> isReadable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'File not readable: %s' , $ pathname ) ) ; } $ relativePathname = $ this -> subtractBasedir ( $ pathname , $ basedir ) ; if ( $ basedir && $ pathname === '/' . $ relativePathname ) { throw new InvalidArgumentException ( sprintf ( 'Invalid basedir: %s' , $ basedir ) ) ; } $ this -> zip -> addFile ( $ pathname , $ relativePathname ) ; }
Calculate relative pathname within archive and add file
20,552
protected function subtractBasedir ( $ pathname , $ baseDir ) { $ baseDir = str_replace ( '/' , '\/' , trim ( $ baseDir , '/' ) ) ; return trim ( preg_replace ( sprintf ( '/%s/' , $ baseDir ) , '' , $ pathname ) , '/' ) ; }
Subtract baseDir from pathname
20,553
public function add ( ) { if ( ! $ this -> request -> isAll ( [ 'ajax' , 'post' ] ) ) { throw new MethodNotAllowedException ( ) ; } $ model = $ this -> request -> data ( 'model' ) ; $ foreignKey = ( int ) $ this -> request -> data ( 'foreign_key' ) ; $ languageId = Wasabi :: contentLanguage ( ) -> id ; $ url = $ this -> _formatUrl ( $ this -> request -> data ( 'url' ) ) ; $ routeType = ( int ) $ this -> request -> data ( 'route_type' ) ; $ element = $ this -> request -> data ( 'element' ) ; $ routeData = [ 'url' => $ url , 'model' => $ model , 'foreign_key' => $ foreignKey , 'language_id' => $ languageId , ] ; $ route = $ this -> _addRoute ( $ routeType , $ routeData ) ; $ this -> _render ( $ route , $ element ) ; }
Add action AJAX POST
20,554
public function makeDefault ( $ id ) { if ( ! $ this -> request -> isAll ( [ 'ajax' , 'post' ] ) ) { throw new MethodNotAllowedException ( ) ; } $ route = $ this -> Routes -> get ( $ id ) ; $ connection = $ this -> Routes -> connection ( ) ; $ connection -> begin ( ) ; $ route -> set ( [ 'redirect_to' => null , 'status_code' => null ] ) ; if ( $ this -> Routes -> save ( $ route ) ) { $ otherRoutes = $ this -> Routes -> getOtherRoutesExcept ( $ route -> id , $ route -> model , $ route -> foreign_key , $ route -> language_id ) ; $ this -> Routes -> redirectRoutesToId ( $ otherRoutes , $ route -> id ) ; $ connection -> commit ( ) ; $ this -> Flash -> success ( __d ( 'wasabi_core' , '<strong>{0}</strong> is now the new Default Route.' , $ route -> url ) , 'routes' ) ; } else { $ connection -> rollback ( ) ; $ this -> Flash -> error ( $ this -> dbErrorMessage , 'routes' ) ; } $ this -> _render ( $ route , $ this -> request -> query ( 'element' ) ) ; }
MakeDefault action AJAX POST
20,555
public function delete ( $ id ) { if ( ! $ this -> request -> isAll ( [ 'ajax' , 'post' ] ) ) { throw new MethodNotAllowedException ( ) ; } $ route = $ this -> Routes -> get ( $ id ) ; $ otherRoutes = $ this -> Routes -> getOtherRoutesExcept ( $ route -> id , $ route -> model , $ route -> foreign_key , $ route -> language_id ) ; if ( ! empty ( $ otherRoutes ) && $ otherRoutes -> count ( ) >= 1 ) { $ connection = $ this -> Routes -> connection ( ) ; $ connection -> begin ( ) ; $ this -> Routes -> delete ( $ route ) ; if ( $ route -> redirect_to === null ) { $ newDefaultRoute = $ otherRoutes -> first ( ) ; $ newDefaultRoute -> set ( [ 'redirect_to' => null , 'status_code' => null ] ) ; $ this -> Routes -> save ( $ newDefaultRoute ) ; $ newRedirectRoutes = $ otherRoutes -> skip ( 1 ) ; foreach ( $ newRedirectRoutes as $ r ) { $ r -> set ( [ 'redirect_to' => $ newDefaultRoute -> id , 'status_code' => 301 ] ) ; $ this -> Routes -> save ( $ r ) ; } } $ connection -> commit ( ) ; $ this -> Flash -> success ( __d ( 'wasabi_core' , 'The URL <strong>{0}</strong> has been deleted.' , $ route -> url ) , 'routes' ) ; } else { $ this -> Flash -> error ( __d ( 'wasabi_core' , 'The URL <strong>{0}</strong> cannot be deleted. Please create another URL first.' , $ route -> url ) , 'routes' ) ; } $ this -> _render ( $ route , $ this -> request -> query ( 'element' ) ) ; }
Delete action AJAX POST
20,556
protected function _render ( $ route , $ element ) { $ routes = $ this -> Routes -> findAllFor ( $ route -> model , $ route -> foreign_key , $ route -> language_id ) -> order ( [ $ this -> Routes -> aliasField ( 'url' ) => 'asc' ] ) ; $ this -> set ( [ 'routes' => $ routes , 'routeTypes' => RouteTypes :: getForSelect ( ) , 'model' => $ route -> model , 'element' => $ element , 'formRoute' => $ route ] ) ; $ this -> render ( 'add' ) ; }
Global render method for all actions of this controller .
20,557
protected function _addRoute ( $ routeType , $ routeData ) { switch ( $ routeType ) { case RouteTypes :: TYPE_DEFAULT_ROUTE : $ route = $ this -> _addDefaultRoute ( $ routeData ) ; break ; case RouteTypes :: TYPE_REDIRECT_ROUTE : $ route = $ this -> _addRedirectRoute ( $ routeData ) ; break ; default : throw new BadRequestException ( ) ; } return $ route ; }
Add the given route .
20,558
protected function _addDefaultRoute ( array $ routeData ) { $ connection = $ this -> Routes -> connection ( ) ; $ connection -> begin ( ) ; $ defaultRoute = $ this -> Routes -> newEntity ( $ routeData ) ; if ( $ this -> Routes -> save ( $ defaultRoute ) ) { $ otherRoutes = $ this -> Routes -> getOtherRoutesExcept ( $ defaultRoute -> id , $ defaultRoute -> model , $ defaultRoute -> foreign_key , $ defaultRoute -> language_id ) ; $ this -> Routes -> redirectRoutesToId ( $ otherRoutes , $ defaultRoute -> id ) ; $ connection -> commit ( ) ; $ this -> Flash -> success ( __d ( 'wasabi_core' , 'New default URL <strong>{0}</strong> has been added.' , $ defaultRoute -> url ) , 'routes' ) ; $ this -> request -> data = [ ] ; } else { $ connection -> rollback ( ) ; $ this -> Flash -> error ( $ this -> formErrorMessage , 'routes' ) ; $ defaultRoute -> set ( 'type' , RouteTypes :: TYPE_DEFAULT_ROUTE ) ; } return $ defaultRoute ; }
Add a new default route .
20,559
protected function _addRedirectRoute ( $ routeData ) { $ defaultRoute = $ this -> Routes -> getDefaultRoute ( $ routeData [ 'model' ] , $ routeData [ 'foreign_key' ] , $ routeData [ 'language_id' ] ) ; $ redirectRoute = $ this -> Routes -> newEntity ( $ routeData ) ; if ( ! empty ( $ defaultRoute ) ) { $ redirectRoute -> set ( 'redirect_to' , $ defaultRoute -> id ) ; $ redirectRoute -> set ( 'status_code' , 301 ) ; if ( $ this -> Routes -> save ( $ redirectRoute ) ) { $ this -> Flash -> success ( __d ( 'wasabi_core' , 'New redirect URL <strong>{0}</strong> has been added.' , $ redirectRoute -> url ) , 'routes' ) ; $ this -> request -> data = [ ] ; } else { $ this -> Flash -> error ( $ this -> formErrorMessage , 'routes' ) ; $ redirectRoute -> set ( 'type' , RouteTypes :: TYPE_REDIRECT_ROUTE ) ; } } else { $ this -> Flash -> error ( __d ( 'wasabi_core' , 'Please create a default route first.' ) , 'routes' ) ; $ redirectRoute -> set ( 'type' , RouteTypes :: TYPE_REDIRECT_ROUTE ) ; } return $ redirectRoute ; }
Add a new redirect route .
20,560
public function calcDiskSize ( $ path , $ bytes = 0 ) { if ( $ this -> plugin [ 'files' ] -> exists ( $ path ) ) { if ( $ this -> plugin [ 'files' ] -> isDirectory ( $ path ) ) { foreach ( $ this -> plugin [ 'files' ] -> glob ( $ path ) as $ file ) { $ bytes += $ this -> plugin [ 'files' ] -> size ( $ file ) ; } } else { $ bytes += $ this -> plugin [ 'files' ] -> size ( $ path ) ; } } $ units = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ] ; for ( $ i = 0 ; $ bytes > 1024 ; $ i ++ ) { $ bytes /= 1024 ; } $ size = round ( $ bytes , 2 ) ; return ( $ size == 0 ? '-' : $ size . ' ' . $ units [ $ i ] ) ; }
Format File Sizes
20,561
public function createBaseString ( ) { if ( $ this -> timestamp === 0 ) { $ this -> setTimestamp ( ) ; } $ paramArray = array ( 'oauth_nonce' => $ this -> getNonce ( ) , 'oauth_callback' => $ this -> callback , 'oauth_signature_method' => $ this -> signatureMethod , 'oauth_timestamp' => $ this -> getTimestamp ( ) , 'oauth_consumer_key' => $ this -> consumerCredential -> getIdentifier ( ) , 'oauth_token' => $ this -> userCredential -> getIdentifier ( ) , 'oauth_version' => $ this -> version , 'oauth_verifier' => $ this -> getVerifier ( ) ) ; return $ this -> buildBaseString ( $ paramArray ) ; }
Create the base string for the signature
20,562
public function buildBaseString ( array $ oauthParams ) { $ tempArray = array ( ) ; ksort ( $ oauthParams ) ; if ( $ oauthParams [ 'oauth_callback' ] === '' ) { unset ( $ oauthParams [ 'oauth_callback' ] ) ; } if ( $ oauthParams [ 'oauth_verifier' ] === '' ) { unset ( $ oauthParams [ 'oauth_verifier' ] ) ; } array_walk ( $ oauthParams , function ( $ value , $ key ) use ( & $ tempArray ) { $ tempArray [ ] = $ key . '=' . rawurlencode ( $ value ) ; } ) ; $ parsedUrl = parse_url ( $ this -> resourceURL ) ; $ baseString = $ this -> httpMethod . '&' ; $ baseString .= rawurlencode ( $ parsedUrl [ 'scheme' ] . '://' . $ parsedUrl [ 'host' ] . $ parsedUrl [ 'path' ] ) ; $ baseString .= ( isset ( $ parsedUrl [ 'query' ] ) ) ? '&' . rawurlencode ( $ parsedUrl [ 'query' ] ) . '%26' : '&' ; $ baseString .= rawurlencode ( implode ( '&' , $ tempArray ) ) ; array_walk ( $ this -> postFields , function ( $ value , $ key ) use ( & $ baseString ) { $ baseString .= '%26' . $ key . rawurlencode ( '=' . $ value ) ; } ) ; return $ baseString ; }
Build the base string based off the values that are passed in
20,563
private function createCompositeKey ( ) { $ key = rawurlencode ( $ this -> consumerCredential -> getSecret ( ) ) . '&' ; if ( ( $ userSecret = $ this -> userCredential -> getSecret ( ) ) !== '' ) { $ key .= rawurlencode ( $ userSecret ) ; } return $ key ; }
Method to generate the composite key
20,564
public function send ( $ recipient , $ message ) { try { return $ this -> gateway -> sendMessage ( $ recipient , $ message ) ; } catch ( AfricasTalkingGatewayException $ e ) { echo "Encountered an error while sending: " . $ e -> getMessage ( ) ; } }
Method to send a message
20,565
public function getSeederName ( $ name ) { $ name = Str :: studly ( $ name ) ; $ namespace = $ this -> laravel [ 'components' ] -> config ( 'namespace' ) ; return $ namespace . '\\' . $ name . '\Database\Seeders\\' . $ name . 'DatabaseSeeder' ; }
Get master database seeder name for the specified component .
20,566
public function getChildren ( ) { $ nodes = [ ] ; try { $ child = $ this -> firstChild ( ) ; do { $ nodes [ ] = $ child ; $ child = $ this -> nextChild ( $ child -> id ( ) ) ; } while ( ! is_null ( $ child ) ) ; } catch ( ChildNotFoundException $ e ) { } return $ nodes ; }
Returns a new array of child nodes
20,567
public function isChild ( $ id ) { foreach ( $ this -> children as $ childId => $ child ) { if ( $ id == $ childId ) { return true ; } } return false ; }
Checks if the given node id is a child of the current node .
20,568
protected function generateCookieValue ( $ username , $ password ) { return $ this -> encodeCookie ( array ( base64_encode ( $ username ) , $ this -> generateCookieHash ( $ username , $ password ) , ) ) ; }
Generates the cookie value .
20,569
protected function cleanValue ( $ key , $ value ) { if ( is_array ( $ value ) ) { return $ this -> cleanArray ( $ value ) ; } return $ this -> transform ( $ key , $ value ) ; }
Clean the given value .
20,570
public function validate ( string ... $ urls ) : ResultInterface { $ messages = array_filter ( array_map ( function ( string $ url ) : ? string { return $ this -> getMessage ( $ url ) ; } , $ urls ) ) ; return $ this -> report ( ... $ messages ) ; }
Validates URLs return expected status code .
20,571
protected function getMessage ( string $ url ) : ? string { $ response = wp_remote_get ( $ url ) ; $ responseCode = wp_remote_retrieve_response_code ( $ response ) ; if ( ! is_int ( $ responseCode ) ) { return 'Unable to reach ' . $ url ; } return ( $ this -> expectedStatusCode === $ responseCode ) ? null : $ url . ' returns ' . $ responseCode ; }
Check the URL s status code .
20,572
public function start ( ) { if ( ! $ this -> isOpened ( ) ) { $ this -> open ( ) ; } if ( ! $ this -> isLoaded ( ) ) { $ this -> read ( ) ; } return $ this ; }
Start the current session and read it
20,573
public function open ( ) { if ( version_compare ( PHP_VERSION , '5.4' , '>' ) ) { if ( session_status ( ) == PHP_SESSION_NONE ) { session_start ( ) ; } } else { @ session_start ( ) ; } $ this -> is_opened = true ; return $ this ; }
Open the current session
20,574
public function read ( ) { if ( isset ( $ _SESSION [ static :: SESSION_NAME ] ) ) { $ sess_table = $ this -> _uncrypt ( $ _SESSION [ static :: SESSION_NAME ] ) ; if ( isset ( $ sess_table [ static :: SESSION_ATTRIBUTESNAME ] ) ) { $ this -> attributes = $ sess_table [ static :: SESSION_ATTRIBUTESNAME ] ; } } $ this -> addSessionTable ( static :: SESSION_ATTRIBUTESNAME , $ this -> attributes ) ; $ this -> is_loaded = true ; return $ this ; }
Read the current session contents
20,575
public function has ( $ param ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } return isset ( $ this -> attributes [ $ param ] ) ; }
Test if the current session has a parameter
20,576
public function get ( $ param ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } return isset ( $ this -> attributes [ $ param ] ) ? $ this -> attributes [ $ param ] : null ; }
Get current session parameter
20,577
public function set ( $ param , $ value ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } $ this -> attributes [ $ param ] = $ value ; return $ this ; }
Set current session parameter
20,578
public function remove ( $ param ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } if ( isset ( $ this -> attributes [ $ param ] ) ) { unset ( $ this -> attributes [ $ param ] ) ; } return $ this ; }
Delete a session parameter
20,579
public function getBackup ( $ param ) { if ( $ this -> isOpened ( ) ) { if ( ! empty ( $ param ) ) { return isset ( $ this -> request_session [ $ param ] ) ? $ this -> request_session [ $ param ] : null ; } return $ this -> request_session ; } }
Get an initial session value
20,580
public static function createTemporary ( $ extension = NULL ) { $ tmpfile = tempnam ( sys_get_temp_dir ( ) , mb_substr ( uniqid ( ) , 0 , 3 ) ) ; if ( $ extension ) { rename ( $ tmpfile , $ tmpfile = $ tmpfile . '.' . ltrim ( $ extension , '.' ) ) ; } return new static ( $ tmpfile ) ; }
Creates a temporary File in the system temp directory
20,581
protected function constructString ( $ file ) { if ( mb_strlen ( $ file ) == 0 ) throw new Exception ( 'keine Datei angegeben' ) ; $ dir = NULL ; try { $ dir = Dir :: extract ( $ file ) ; } catch ( Exception $ e ) { } $ filename = self :: extractFilename ( $ file ) ; $ this -> constructDefault ( $ filename , $ dir ) ; }
Creates a new File instance from single string
20,582
protected function constructDefault ( $ filename , Dir $ directory = NULL ) { $ this -> setName ( $ filename ) ; if ( isset ( $ directory ) ) $ this -> setDirectory ( $ directory ) ; }
Creates a new File from filename and Directory Object
20,583
public function move ( File $ fileDestination , $ overwrite = FALSE ) { if ( ! $ this -> exists ( ) ) throw new Exception ( 'Quelle von move existiert nicht. ' . $ this ) ; if ( $ fileDestination -> exists ( ) && ! $ overwrite ) { throw new Exception ( 'Das Ziel von move existiert bereits' . $ fileDestination ) ; } if ( ! $ fileDestination -> getDirectory ( ) -> exists ( ) ) { throw new Exception ( 'Das ZielVerzeichnis von move existiert nicht: ' . $ fileDestination -> getDirectory ( ) ) ; } if ( $ fileDestination -> exists ( ) && $ overwrite && substr ( PHP_OS , 0 , 3 ) == 'WIN' ) { $ fileDestination -> delete ( ) ; } $ ret = rename ( ( string ) $ this , ( string ) $ fileDestination ) ; if ( $ ret ) { $ this -> setDirectory ( $ fileDestination -> getDirectory ( ) ) ; $ this -> setName ( $ fileDestination -> getName ( ) ) ; } return $ ret ; }
Moves the File to another file and changes the internal state to the destination
20,584
public function copy ( $ destination ) { if ( ! $ this -> exists ( ) ) { throw new Exception ( 'Source from copy does not exist: ' . $ this ) ; } if ( $ destination instanceof Dir ) { $ destination = $ destination -> getFile ( $ this -> getName ( ) ) ; } elseif ( ! ( $ destination instanceof File ) ) { throw new InvalidArgumentException ( 'Invalid Argument. $destination must be file or dir' ) ; } if ( ! $ destination -> getDirectory ( ) -> exists ( ) ) { throw new Exception ( 'The directory from the destination file does not exist: ' . $ destination ) ; } $ ret = @ copy ( ( string ) $ this , ( string ) $ destination ) ; if ( ! $ ret ) { throw new Exception ( 'PHP Error while copying ' . $ this . ' onto ' . $ destination ) ; } return $ this ; }
Copys the file to another file or into an directory
20,585
public function setName ( $ name ) { if ( ( $ pos = mb_strrpos ( $ name , '.' ) ) !== FALSE ) { $ this -> name = mb_substr ( $ name , 0 , $ pos ) ; $ this -> extension = mb_substr ( $ name , $ pos + 1 ) ; } else { $ this -> name = $ name ; } return $ this ; }
Sets the name of the file
20,586
public function getQuotedString ( ) { $ str = ( string ) $ this ; if ( mb_strpos ( $ str , ' ' ) !== FALSE ) { return escapeshellarg ( $ str ) ; } return $ str ; }
Returns the filename with quotes if dir or file have whitespace in their names
20,587
public function findExtension ( Array $ possibleExtensions ) { foreach ( $ possibleExtensions as $ extension ) { $ file = clone $ this ; $ file -> setExtension ( $ extension ) ; if ( $ file -> exists ( ) ) { return $ file ; } } throw FileNotFoundException :: fromFileAndExtensions ( $ this , $ possibleExtensions ) ; }
Returns the first file that exists with one of the given extensions
20,588
public static function extractFilename ( $ string ) { if ( mb_strlen ( $ string ) == 0 ) throw new Exception ( 'Cannot extract filename from empty string' ) ; $ file = basename ( $ string ) ; if ( mb_strlen ( $ file ) == 0 ) throw new Exception ( 'PHP could not extract the basename of the file: ' . $ file ) ; return $ file ; }
Extrahiert eine Datei als String aus einer Pfadangabe
20,589
public function getURL ( Dir $ relativeDir = NULL ) { return rtrim ( $ this -> directory -> getURL ( $ relativeDir ) , '/' ) . '/' . rawurlencode ( $ this -> getName ( self :: WITH_EXTENSION ) ) ; }
Returns the URL for the File relative to a directory
20,590
public function getSha1 ( ) { if ( ! isset ( $ this -> sha1 ) ) { $ this -> sha1 = sha1_file ( ( string ) $ this ) ; } return $ this -> sha1 ; }
returns the SHA1 of the file
20,591
public function buildBlock ( $ code ) { $ lines = $ this -> parser -> splitIntoLines ( $ code ) ; $ result = [ ] ; foreach ( array_filter ( $ lines ) as $ line ) { $ result [ ] = $ this -> printer -> toString ( eval ( "return {$line};" ) ) ; } return sprintf ( "```php\n%s```\n```\n%s\n```\n" , implode ( "\n" , $ lines ) , implode ( "\n" , $ result ) ) ; }
Build an example block .
20,592
public function getModularInfo ( ) : array { return [ static :: NAME => $ this -> getModularName ( ) , static :: VERSION => $ this -> getModularVersion ( ) , static :: URI => $ this -> getModularUri ( ) , static :: AUTHOR => $ this -> getModularAuthor ( ) , static :: AUTHOR_URI => $ this -> getModularAuthorUri ( ) , static :: DESCRIPTION => $ this -> getModularDescription ( ) , static :: CLASS_NAME => get_class ( $ this ) , static :: FILE_PATH => $ this -> getModularRealPath ( ) , static :: SELECTOR => $ this -> getModularNameSelector ( ) , ] ; }
Get Modular Info
20,593
protected function retrieveOrException ( $ attrName , $ methodName = "this method" , $ reason = "" ) { if ( property_exists ( $ this , $ attrName ) === false ) { throw new \ Exception ( "Property $attrName not found in class." ) ; } if ( $ this -> $ attrName === null ) { $ message = $ reason !== "" ? "Because you $reason, " : "You " ; $ message .= "must set $attrName for this object before calling $methodName." ; throw new \ Exception ( $ message ) ; } return $ this -> $ attrName ; }
If it has been set retrieve the indicated property from this builder . If not throw exception .
20,594
public function createNew ( $ className ) { $ constructArguments = func_get_args ( ) ; $ object = $ this -> _createNew ( ... $ constructArguments ) ; $ traits = class_uses ( $ object ) ; if ( isset ( $ traits [ Framework :: class ] ) == true ) { $ object -> setContainer ( $ this -> container ) ; } return $ object ; }
Create a new instance of a given class
20,595
public function initialize ( $ container , PaymentServiceProvider $ psp ) { parent :: initialize ( $ container , $ psp ) ; if ( isset ( $ this -> parameters [ 'environment' ] ) ) Braintree_Configuration :: environment ( $ this -> parameters [ 'environment' ] ) ; if ( isset ( $ this -> parameters [ 'merchant_id' ] ) ) Braintree_Configuration :: merchantId ( $ this -> parameters [ 'merchant_id' ] ) ; if ( isset ( $ this -> parameters [ 'public_key' ] ) ) Braintree_Configuration :: publicKey ( $ this -> parameters [ 'public_key' ] ) ; if ( isset ( $ this -> parameters [ 'private_key' ] ) ) Braintree_Configuration :: privateKey ( $ this -> parameters [ 'private_key' ] ) ; return $ this ; }
Constructor with Braintree configuration
20,596
public function get ( $ serviceName , array $ attributes = array ( ) , $ methodName = 'factory' ) { $ className = 'Braintree_' . ucfirst ( $ serviceName ) ; if ( class_exists ( $ className ) && method_exists ( $ className , $ methodName ) ) { if ( $ methodName == 'factory' ) return $ className :: $ methodName ( $ attributes ) ; else return $ className :: $ methodName ( ) ; } else { throw new InvalidServiceException ( 'Invalid service ' . $ serviceName ) ; } }
Factory method for creating and getting Braintree services
20,597
protected function isRed ( ? RedBlackNode $ node ) : bool { if ( $ node === null ) { return false ; } return $ node -> color ( ) === RedBlackNode :: RED ; }
Checks if a node is red
20,598
protected function nodeSet ( $ key , $ value , ? RedBlackNode $ node ) : RedBlackNode { if ( $ node === null ) { return new RedBlackNode ( $ key , $ value , 1 , RedBlackNode :: RED ) ; } $ comp = $ this -> comparator -> compare ( $ key , $ node -> key ( ) ) ; if ( $ comp < 0 ) { $ node -> setLeft ( $ this -> nodeSet ( $ key , $ value , $ node -> left ( ) ) ) ; } elseif ( $ comp > 0 ) { $ node -> setRight ( $ this -> nodeSet ( $ key , $ value , $ node -> right ( ) ) ) ; } else { $ node -> setValue ( $ value ) ; } return $ this -> balanceOnInsert ( $ node ) ; }
Inserts a key - value pair in a subtree
20,599
protected function nodeGet ( $ key , ? RedBlackNode $ node ) : ? RedBlackNode { while ( $ node !== null ) { $ comp = $ this -> comparator -> compare ( $ key , $ node -> key ( ) ) ; if ( $ comp < 0 ) { $ node = $ node -> left ( ) ; } elseif ( $ comp > 0 ) { $ node = $ node -> right ( ) ; } else { return $ node ; } } return null ; }
Retrieves a node by key and subtree