idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
4,800
|
protected function doIterativeUserSelectionSetup ( ) { do { $ modelChoices = $ this -> getIterativeUserSelectionModeChoices ( ) ; if ( empty ( $ modelChoices ) ) return ; $ choice = $ this -> context -> command -> choice ( "Choose a model to set up Sluggable for" , array_merge ( $ modelChoices , [ 'stop' ] ) ) ; if ( $ choice == 'stop' ) return ; if ( ! preg_match ( '#^(\d+):#' , $ choice , $ matches ) ) return ; $ moduleId = ( int ) $ matches [ 1 ] ; $ candidate = $ this -> createCandidateArrayForIterativeUserSelection ( $ moduleId ) ; $ this -> updateModelDataInteractively ( $ moduleId , $ candidate , false ) ; } while ( ! empty ( $ choice ) ) ; }
|
Runs through an iterative process wherein the user interactively selects available models to set up
|
4,801
|
protected function getIterativeUserSelectionModeChoices ( ) { $ choices = [ ] ; foreach ( $ this -> context -> output [ 'models' ] as $ id => $ model ) { if ( in_array ( $ id , $ this -> modelsDone ) ) continue ; $ choices [ ] = $ id . ': ' . $ model [ 'name' ] ; } ksort ( $ choices ) ; return $ choices ; }
|
Returns the choices for the iterative user model setup selection process leaving out the ones already handled
|
4,802
|
protected function createCandidateArrayForIterativeUserSelection ( $ moduleId ) { $ candidate = [ 'translated' => null , 'slug_column' => null , 'slug_sources_normal' => $ this -> context -> output [ 'models' ] [ $ moduleId ] [ 'normal_attributes' ] , 'slug_sources_translated' => $ this -> context -> output [ 'models' ] [ $ moduleId ] [ 'translated_attributes' ] , ] ; if ( ! count ( $ candidate [ 'slug_sources_translated' ] ) ) { $ candidate [ 'translated' ] = false ; } elseif ( ! count ( $ candidate [ 'slug_sources_normal' ] ) ) { $ candidate [ 'translated' ] = true ; } else { $ candidate [ 'translated' ] = $ this -> context -> command -> choice ( "Should the slug source be a translated attribute or not?" , [ 'normal model attribute' , 'translated attribute' ] ) == 'translated attribute' ; } return $ candidate ; }
|
Creates candidate array for handling sluggable interactive process for the user selection approach
|
4,803
|
protected function findSluggableCandidateModels ( ) { $ candidates = [ ] ; foreach ( $ this -> context -> output [ 'models' ] as $ model ) { if ( $ this -> isExcludedSluggable ( $ model [ 'module' ] ) ) continue ; if ( $ result = $ this -> applyOverrideForSluggable ( $ model ) ) { $ candidates [ $ model [ 'module' ] ] = $ result ; continue ; } if ( $ result = $ this -> analyzeModelForSluggable ( $ model ) ) { $ candidates [ $ model [ 'module' ] ] = $ result ; } } return $ candidates ; }
|
Finds all the models that the user might want to make sluggable
|
4,804
|
protected function applyOverrideForSluggable ( array $ model ) { if ( ! array_key_exists ( $ model [ 'module' ] , $ this -> overrides ) ) { return false ; } $ override = $ this -> overrides [ $ model [ 'module' ] ] ; $ analysis = [ 'translated' => false , 'slug_column' => null , 'slug_sources_normal' => [ ] , 'slug_sources_translated' => [ ] , ] ; if ( ! array_key_exists ( 'source' , $ override ) ) { $ this -> context -> log ( "Invalid slugs override configuration for model #{$model['module']}. No source." , Generator :: LOG_LEVEL_ERROR ) ; return false ; } if ( in_array ( $ override [ 'source' ] , $ model [ 'normal_attributes' ] ) ) { $ analysis [ 'slug_sources_normal' ] = [ $ override [ 'source' ] ] ; } elseif ( in_array ( $ override [ 'source' ] , $ model [ 'translated_attributes' ] ) ) { $ analysis [ 'slug_sources_translated' ] = [ $ override [ 'source' ] ] ; } else { $ this -> context -> log ( "Invalid slugs override configuration for model #{$model['module']}. " . "Source attribute '{$override['source']}' does not exist." , Generator :: LOG_LEVEL_ERROR ) ; return false ; } if ( isset ( $ override [ 'slug' ] ) ) { if ( $ override [ 'slug' ] == $ override [ 'source' ] ) { $ this -> context -> log ( "Invalid slugs override configuration for model #{$model['module']}. " . "Slug attribute '{$override['slug']}' is same as source attribute." , Generator :: LOG_LEVEL_ERROR ) ; return false ; } if ( in_array ( $ override [ 'slug' ] , $ model [ 'normal_attributes' ] ) ) { $ analysis [ 'translated' ] = false ; } elseif ( in_array ( $ override [ 'slug' ] , $ model [ 'translated_attributes' ] ) ) { $ analysis [ 'translated' ] = true ; } else { $ this -> context -> log ( "Invalid slugs override configuration for model #{$model['module']}. " . "Slug attribute '{$override['slug']}' does not exist." , Generator :: LOG_LEVEL_ERROR ) ; return false ; } $ analysis [ 'slug_column' ] = $ override [ 'slug' ] ; if ( $ analysis [ 'translated' ] && count ( $ analysis [ 'slug_sources_normal' ] ) || ! $ analysis [ 'translated' ] && count ( $ analysis [ 'slug_sources_translated' ] ) ) { $ this -> context -> log ( "Invalid slugs override configuration for model #{$model['module']}. " . "Either Slug and Source attribute must be translated, or neither." , Generator :: LOG_LEVEL_ERROR ) ; return false ; } } $ analysis [ 'translated' ] = ( count ( $ analysis [ 'slug_sources_translated' ] ) > 0 ) ; return $ analysis ; }
|
Returns overridden analysis result for model after checking it against the model s data
|
4,805
|
protected function analyzeModelForSluggable ( array $ model ) { $ analysis = [ 'translated' => null , 'slug_column' => null , 'slug_sources_normal' => [ ] , 'slug_sources_translated' => [ ] , ] ; $ slugColumns = config ( 'pxlcms.generator.models.slugs.slug_columns' , [ ] ) ; foreach ( $ slugColumns as $ slugColumn ) { foreach ( $ model [ 'normal_attributes' ] as $ attribute ) { if ( $ attribute == $ slugColumn ) { $ analysis [ 'slug_column' ] = $ attribute ; $ analysis [ 'translated' ] = false ; break 2 ; } } foreach ( $ model [ 'translated_attributes' ] as $ attribute ) { if ( $ attribute == $ slugColumn ) { $ analysis [ 'slug_column' ] = $ attribute ; $ analysis [ 'translated' ] = true ; break 2 ; } } } if ( ! $ this -> context -> slugStructurePresent && empty ( $ analysis [ 'slug_column' ] ) ) return false ; $ slugSources = config ( 'pxlcms.generator.models.slugs.slug_source_columns' , [ ] ) ; $ analysis [ 'slug_sources_translated' ] = array_values ( array_intersect ( $ slugSources , $ model [ 'translated_attributes' ] ) ) ; $ analysis [ 'slug_sources_normal' ] = array_values ( array_intersect ( $ slugSources , $ model [ 'normal_attributes' ] ) ) ; if ( $ analysis [ 'translated' ] === true ) { $ analysis [ 'slug_sources_normal' ] = [ ] ; } elseif ( $ analysis === false ) { $ analysis [ 'slug_sources_translated' ] = [ ] ; } if ( ! empty ( $ analysis [ 'slug_column' ] ) || count ( $ analysis [ 'slug_sources_normal' ] ) || count ( $ analysis [ 'slug_sources_translated' ] ) ) { return $ analysis ; } return false ; }
|
Determines whether the model data makes it a sluggable candidate and returns analysis result
|
4,806
|
public function & setBaseClassExtends ( $ class_name ) { if ( $ class_name && class_exists ( $ class_name ) && ( new \ ReflectionClass ( $ class_name ) ) -> isSubclassOf ( Entity :: class ) ) { } else { throw new InvalidArgumentException ( "Class name '$class_name' is not valid" ) ; } $ this -> base_class_extends = $ class_name ; return $ this ; }
|
Set name of a class that base type class should extend .
|
4,807
|
public function getIdField ( ) { if ( empty ( $ this -> id_field ) ) { $ this -> id_field = ( new IntegerField ( 'id' , 0 ) ) -> unsigned ( true ) -> size ( $ this -> getExpectedDatasetSize ( ) ) ; } return $ this -> id_field ; }
|
Return ID field for this type .
|
4,808
|
public function & addField ( FieldInterface $ field ) { if ( empty ( $ this -> fields [ $ field -> getName ( ) ] ) ) { $ this -> fields [ $ field -> getName ( ) ] = $ field ; $ field -> onAddedToType ( $ this ) ; } else { throw new InvalidArgumentException ( "Field '" . $ field -> getName ( ) . "' already exists in this type" ) ; } return $ this ; }
|
Add a single field to the type .
|
4,809
|
public function getAllIndexes ( ) { $ result = [ new Index ( 'id' , [ 'id' ] , IndexInterface :: PRIMARY ) ] ; if ( $ this -> getPolymorph ( ) ) { $ result [ ] = new Index ( 'type' ) ; } if ( ! empty ( $ this -> getIndexes ( ) ) ) { $ result = array_merge ( $ result , $ this -> getIndexes ( ) ) ; } foreach ( $ this -> getAssociations ( ) as $ assosication ) { if ( $ assosication instanceof InjectIndexesInsterface ) { $ association_indexes = $ assosication -> getIndexes ( ) ; if ( ! empty ( $ association_indexes ) ) { $ result = array_merge ( $ result , $ association_indexes ) ; } } } return $ result ; }
|
Return all indexes .
|
4,810
|
public function & orderBy ( $ order_by ) { if ( empty ( $ order_by ) ) { throw new InvalidArgumentException ( 'Order by value is required' ) ; } elseif ( ! is_string ( $ order_by ) && ! is_array ( $ order_by ) ) { throw new InvalidArgumentException ( 'Order by can be string or array' ) ; } $ this -> order_by = ( array ) $ order_by ; return $ this ; }
|
Set how records of this type should be ordered by default .
|
4,811
|
public function & serialize ( ... $ fields ) { if ( ! empty ( $ fields ) ) { $ this -> serialize = array_unique ( array_merge ( $ this -> serialize , $ fields ) ) ; } return $ this ; }
|
Set a list of fields that will be included during object serialization .
|
4,812
|
protected function createRegistrationRecord ( UserInterface $ user ) { $ entityClass = $ this -> getOptions ( ) -> getRegistrationEntityClass ( ) ; $ entity = new $ entityClass ( $ user ) ; $ this -> getEventManager ( ) -> trigger ( __FUNCTION__ , $ this , array ( 'user' => $ user , 'record' => $ entity ) ) ; $ entity -> generateToken ( ) ; $ this -> getUserRegistrationMapper ( ) -> insert ( $ entity ) ; $ this -> getEventManager ( ) -> trigger ( __FUNCTION__ . '.post' , $ this , array ( 'user' => $ user , 'record' => $ entity ) ) ; return $ entity ; }
|
Stored user registration record to database
|
4,813
|
public function trigger ( Color $ color , $ method , $ args ) { if ( is_callable ( array ( $ this , $ method ) ) ) { array_unshift ( $ args , $ color ) ; return call_user_func_array ( array ( $ this , $ method ) , $ args ) ; } return null ; }
|
Handel the method call .
|
4,814
|
public static function overload ( $ envFile = ".env" ) { self :: getLoader ( ) -> overloader = true ; self :: getLoader ( ) -> innerLoad ( $ envFile ) ; }
|
Overload environment config
|
4,815
|
public function load ( ) : void { try { $ keys = $ this -> cache -> get ( self :: INDEXING_KEY ) ; if ( $ keys instanceof Keys ) { $ this -> keys = $ keys ; return ; } } catch ( CacheException $ e ) { trigger_error ( $ e -> getMessage ( ) , E_USER_WARNING ) ; } $ this -> keys = new Keys ( ) ; }
|
Load stored keys from Cache or create new index
|
4,816
|
public static function render ( SQL \ Direction $ item ) { return Compiler :: expression ( array ( Compiler :: name ( $ item -> getContent ( ) ) , $ item -> getDirection ( ) , ) ) ; }
|
Render a Direction object
|
4,817
|
private function addRecordDataAsJsonEncodedField ( $ key , $ label ) { if ( ! empty ( $ this -> record [ $ key ] ) ) { $ this -> addField ( new Field ( $ label , json_encode ( $ this -> record [ $ key ] ) ) ) ; } }
|
Check if a key is available in the record . If so add it as a field .
|
4,818
|
public function turnHexKeyToBin ( ) { if ( ! ctype_xdigit ( $ this -> secret ) ) { throw new InvalidSecretKeyException ( sprintf ( 'The secret key "%s" is not a hex key' , $ this -> secret ) ) ; } $ this -> secret = hex2bin ( $ this -> secret ) ; }
|
Turns the secret hex key into a binary key .
|
4,819
|
public static function create ( string $ name , string $ value = null ) : self { return new self ( $ name , $ value ) ; }
|
creates the cookie
|
4,820
|
private function serviceFactoryMap ( array $ providers ) : array { $ wrap = function ( $ factory ) { return [ $ factory ] ; } ; return array_reduce ( $ providers , function ( $ factories , ServiceProviderInterface $ provider ) use ( $ wrap ) { return array_merge ( $ factories , array_map ( $ wrap , $ provider -> getFactories ( ) ) ) ; } , [ ] ) ; }
|
Return a service factory map from the given service providers .
|
4,821
|
private function serviceExtensionMap ( array $ providers ) : array { $ wrap = function ( $ factory ) { return [ $ factory ] ; } ; return array_reduce ( $ providers , function ( $ extensions , ServiceProviderInterface $ provider ) use ( $ wrap ) { return array_merge_recursive ( $ extensions , array_map ( $ wrap , $ provider -> getExtensions ( ) ) ) ; } , [ ] ) ; }
|
Return a service extension map from the given service providers .
|
4,822
|
public function unverify ( ) { VerifyEmail :: sendVerificationLink ( $ this , function ( Message $ message ) { $ message -> subject ( $ this -> getVerifyEmailSubject ( ) ) ; } ) ; $ this -> setVerified ( false ) ; }
|
Unverify the user s email address .
|
4,823
|
public static function isOn ( $ value , $ flag ) { if ( ! Int :: is ( $ value ) ) { throw new \ InvalidArgumentException ( "The \$value parameter must be of type int." ) ; } if ( ! static :: is ( $ flag ) ) { throw new \ InvalidArgumentException ( "The \$flag parameter must be of type int and a power of 2." ) ; } return static :: is ( $ value & $ flag ) ; }
|
Checks if a flag is set in a given value .
|
4,824
|
public static function setOn ( $ value , $ flag ) { if ( ! Int :: is ( $ value ) ) { throw new \ InvalidArgumentException ( "The \$value parameter must be of type int." ) ; } if ( is_array ( $ flag ) ) { $ ret = $ value ; foreach ( $ flag as $ item ) { $ ret = static :: setOn ( $ ret , $ item ) ; } return $ ret ; } elseif ( ! static :: is ( $ flag ) ) { throw new \ InvalidArgumentException ( "The \$flag parameter must be of type int and a power of 2." ) ; } return ( $ value | $ flag ) ; }
|
Sets a flag into a value .
|
4,825
|
public static function getValues ( $ count ) { if ( ! Int :: is ( $ count ) || $ count < 1 ) { throw new \ InvalidArgumentException ( "The \$count parameter must be of type int and greater than zero." ) ; } $ ret = [ ] ; $ flag = 1 ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ ret [ ] = $ flag ; $ flag <<= 1 ; } return $ ret ; }
|
Gets an array with n consecutive flag values .
|
4,826
|
public static function buildMask ( $ flag1 , $ _ = null ) { if ( ! static :: is ( $ flag1 ) ) { throw new \ InvalidArgumentException ( "The first parameter must be a flag." ) ; } $ mask = $ flag1 ; $ args = array_slice ( func_get_args ( ) , 1 ) ; foreach ( $ args as $ flag ) { if ( ! static :: is ( $ flag ) ) { throw new \ InvalidArgumentException ( "All parameters must be flags." ) ; } $ mask = $ mask | $ flag ; } return $ mask ; }
|
Builds a flag mask with the given flags .
|
4,827
|
public static function mask ( $ value , $ mask ) { if ( ! Int :: is ( $ value ) || ! Int :: is ( $ mask ) ) { throw new \ InvalidArgumentException ( "Both parameters must be integers." ) ; } return ( $ value & $ mask ) ; }
|
Applies the mask to the given value and returns the masked result .
|
4,828
|
public function get ( $ index = null , $ type = null ) { return array_filter ( $ this -> entries , function ( $ entry ) use ( $ index , $ type ) { return $ entry -> match ( $ index , $ type ) ; } ) ; }
|
Get entries for index and type
|
4,829
|
public function getFinalName ( $ name ) { try { return parent :: findTemplate ( $ name ) ; } catch ( \ Twig_Error_Loader $ e ) { $ exts = \ App :: config ( 'TEMPLATE_EXTENSION' ) ; if ( $ exts ) { if ( ! is_array ( $ exts ) ) { $ exts = Array ( $ exts ) ; } foreach ( $ exts as $ e ) { try { return parent :: findTemplate ( $ name . $ e ) ; } catch ( \ Twig_Error_Loader $ e ) { } } } } throw new \ Twig_Error_Loader ( "Twig Error Loader Exception : Could name find template `{$name}`" ) ; }
|
Get the final name where a template lives regardless of whether it was called with an extension or not .
|
4,830
|
public function pageTheme ( ) { view ( ) -> composer ( "*" , function ( $ view ) { $ theme = config ( "pagekit.theme" , null ) ; if ( ! $ theme ) : if ( view ( ) -> exists ( "theme.page.index" ) ) : $ theme = "theme.page." ; else : $ theme = "page::" ; endif ; endif ; view ( ) -> share ( 'pageTheme' , $ theme ) ; } ) ; }
|
get the default theme
|
4,831
|
public function setAuthor ( Author $ author ) { $ this -> attachment [ 'author_name' ] = $ author ; if ( $ author -> hasIcon ( ) ) { $ this -> attachment [ 'author_icon' ] = $ author -> getIcon ( ) ; } if ( $ author -> hasLink ( ) ) { $ this -> attachment [ 'author_link' ] = $ author -> getLink ( ) ; } return $ this ; }
|
The author parameters will display a small section at the top of a message attachment .
|
4,832
|
public function setTitle ( Title $ title ) { $ this -> attachment [ 'title' ] = $ title ; if ( $ title -> hasLink ( ) ) { $ this -> attachment [ 'title_link' ] = $ title -> getLink ( ) ; } return $ this ; }
|
The title is displayed as larger bold text near the top of a message attachment .
|
4,833
|
public function addField ( Field $ field ) { if ( ! isset ( $ this -> attachment [ 'fields' ] ) ) { $ this -> attachment [ 'fields' ] = [ ] ; } $ this -> attachment [ 'fields' ] [ ] = $ field ; return $ this ; }
|
Will be displayed in a table inside the message attachment .
|
4,834
|
public function save ( $ path = null ) { if ( is_null ( $ path ) ) { $ path = $ this -> file ; } imagejpeg ( $ this -> image , $ path ) ; return $ this ; }
|
save as jpeg
|
4,835
|
public function setTypes ( $ attr , $ type = null ) { if ( is_array ( $ attr ) ) $ this -> inputType = array_merge ( $ this -> inputType , $ attr ) ; else $ this -> inputType [ $ attr ] = $ type ; return $ this ; }
|
Sets the Input types .
|
4,836
|
public function setTypesGroup ( $ types , $ attr = null ) { if ( ! is_array ( $ types ) ) $ types = [ $ types => $ attr ] ; foreach ( $ types as $ type => $ attrList ) { if ( ! is_array ( $ attrList ) ) $ attrList = [ $ attrList ] ; foreach ( $ attrList as $ attr ) $ this -> inputType [ $ attr ] = $ type ; } return $ this ; }
|
Set new or change input types
|
4,837
|
private function binCheck ( $ bin , $ args = [ '--help' ] ) { $ isExecutable = is_executable ( $ bin ) ; if ( ! $ isExecutable ) { throw new \ Exception ( 'Couldn\'t execute the ' . $ bin . ' binary. Make sure it has the right permissions.' ) ; } exec ( $ bin . ' ' . implode ( ' ' , $ args ) , $ output , $ returnVar ) ; if ( $ returnVar !== 0 ) { return false ; } return true ; }
|
Todo move to separatly repository
|
4,838
|
public function getLeafObject ( string $ filepath ) : Leaf { $ leafObject = new $ this -> leafObjectClass ( $ this -> search , $ filepath ) ; if ( $ leafObject instanceof Leaf ) { return $ leafObject ; } throw new \ RuntimeException ( sprintf ( '%s is not a subclass of %s\\Leaf' , $ this -> leafObjectClass , __NAMESPACE__ ) ) ; }
|
Return a new leaf object
|
4,839
|
public function getBannerImageSize ( $ BannerImage , $ BannerType ) { switch ( $ BannerType ) { case self :: BANNER_TYPE_INTERN : return $ this -> getImageSizeInternal ( $ BannerImage ) ; break ; case self :: BANNER_TYPE_EXTERN : return $ this -> getImageSizeExternal ( $ BannerImage ) ; break ; case self :: BANNER_TYPE_TEXT : return false ; break ; default : return false ; break ; } }
|
Get the size of an image
|
4,840
|
protected function getImageSizeInternal ( $ BannerImage ) { try { $ arrImageSize = getimagesize ( TL_ROOT . '/' . $ BannerImage ) ; } catch ( \ Exception $ e ) { $ arrImageSize = false ; } if ( $ arrImageSize === false ) { $ arrImageSize = $ this -> getImageSizeCompressed ( $ BannerImage ) ; } ModuleBannerLog :: writeLog ( __METHOD__ , __LINE__ , 'Image Size: ' . print_r ( $ arrImageSize , true ) ) ; return $ arrImageSize ; }
|
Get the size of an internal image
|
4,841
|
protected function getImageSizeExternal ( $ BannerImage ) { $ token = md5 ( uniqid ( rand ( ) , true ) ) ; $ tmpImage = 'system/tmp/mod_banner_fe_' . $ token . '.tmp' ; if ( \ Config :: get ( 'useProxy' ) && in_array ( 'proxy' , \ ModuleLoader :: getActive ( ) ) ) { $ objRequest = new \ ProxyRequest ( ) ; } else { $ objRequest = new \ Request ( ) ; $ objRequest -> redirect = true ; $ objRequest -> rlimit = 5 ; } $ objRequest -> send ( html_entity_decode ( $ BannerImage , ENT_NOQUOTES , 'UTF-8' ) ) ; try { $ objFile = new \ File ( $ tmpImage ) ; $ objFile -> write ( $ objRequest -> response ) ; $ objFile -> close ( ) ; } catch ( \ Exception $ e ) { if ( $ e -> getCode ( ) == 0 ) { log_message ( '[getImageSizeExternal] tmpFile Problem: notWriteable' , 'error.log' ) ; } else { log_message ( '[getImageSizeExternal] tmpFile Problem: error' , 'error.log' ) ; } return false ; } $ objRequest = null ; unset ( $ objRequest ) ; $ arrImageSize = $ this -> getImageSizeInternal ( $ tmpImage ) ; if ( $ arrImageSize === false ) { $ arrImageSize = $ this -> getImageSizeCompressed ( $ tmpImage ) ; } $ objFile -> delete ( ) ; $ objFile = null ; unset ( $ objFile ) ; ModuleBannerLog :: writeLog ( __METHOD__ , __LINE__ , 'Image Size: ' . print_r ( $ arrImageSize , true ) ) ; return $ arrImageSize ; }
|
Get the size of an external image
|
4,842
|
protected function getImageSizeCompressed ( $ BannerImage ) { $ arrImageSize = false ; $ res = $ this -> uncompressSwcData ( $ BannerImage ) ; if ( $ res ) { $ arrImageSize = array ( $ res [ 0 ] , $ res [ 1 ] , 13 ) ; } ModuleBannerLog :: writeLog ( __METHOD__ , __LINE__ , 'Image Size: ' . print_r ( $ arrImageSize , true ) ) ; return $ arrImageSize ; }
|
getimagesize without zlib doesn t work workaround for this
|
4,843
|
public function getBannerImageSizeNew ( $ oldWidth , $ oldHeight , $ newWidth = 0 , $ newHeight = 0 ) { $ Width = $ oldWidth ; $ Height = $ oldHeight ; $ oriSize = true ; if ( $ newWidth > 0 && $ newHeight > 0 ) { $ Width = $ newWidth ; $ Height = $ newHeight ; $ oriSize = false ; } elseif ( $ newWidth > 0 ) { $ Width = $ newWidth ; $ Height = ceil ( $ newWidth * $ oldHeight / $ oldWidth ) ; $ oriSize = false ; } elseif ( $ newHeight > 0 ) { $ Width = ceil ( $ newHeight * $ oldWidth / $ oldHeight ) ; $ Height = $ newHeight ; $ oriSize = false ; } return array ( $ Width , $ Height , $ oriSize ) ; }
|
Calculate the new size for witdh and height
|
4,844
|
public function getCheckBannerImageSize ( $ arrImageSize , $ maxWidth , $ maxHeight ) { if ( $ arrImageSize [ 0 ] > $ arrImageSize [ 1 ] ) { if ( $ arrImageSize [ 0 ] > $ maxWidth ) { $ newImageSize = $ this -> getBannerImageSizeNew ( $ arrImageSize [ 0 ] , $ arrImageSize [ 1 ] , $ maxWidth , 0 ) ; $ intWidth = $ newImageSize [ 0 ] ; $ intHeight = $ newImageSize [ 1 ] ; $ oriSize = $ newImageSize [ 2 ] ; } else { $ intWidth = $ arrImageSize [ 0 ] ; $ intHeight = $ arrImageSize [ 1 ] ; $ oriSize = true ; } } else { if ( $ arrImageSize [ 1 ] > $ maxWidth ) { if ( ( $ maxWidth * $ arrImageSize [ 0 ] / $ arrImageSize [ 1 ] ) < $ maxHeight ) { $ newImageSize = $ this -> getBannerImageSizeNew ( $ arrImageSize [ 0 ] , $ arrImageSize [ 1 ] , $ maxHeight , 0 ) ; $ intWidth = $ newImageSize [ 0 ] ; $ intHeight = $ newImageSize [ 1 ] ; $ oriSize = $ newImageSize [ 2 ] ; } else { $ newImageSize = $ this -> getBannerImageSizeNew ( $ arrImageSize [ 0 ] , $ arrImageSize [ 1 ] , 0 , $ maxHeight ) ; $ intWidth = $ newImageSize [ 0 ] ; $ intHeight = $ newImageSize [ 1 ] ; $ oriSize = $ newImageSize [ 2 ] ; } } else { $ intWidth = $ arrImageSize [ 0 ] ; $ intHeight = $ arrImageSize [ 1 ] ; $ oriSize = true ; } } return array ( $ intWidth , $ intHeight , $ oriSize ) ; }
|
Calculate the new size if necessary by comparing with maxWidth and maxHeight
|
4,845
|
public function getCheckBannerImageFallback ( $ BannerImage , $ intWidth , $ intHeight ) { $ fallback_content = false ; $ path_parts = pathinfo ( $ BannerImage ) ; if ( is_file ( TL_ROOT . '/' . $ path_parts [ 'dirname' ] . '/' . $ path_parts [ 'filename' ] . '.jpg' ) ) { $ fallback_ext = '.jpg' ; $ fallback_content = true ; } elseif ( is_file ( TL_ROOT . '/' . $ path_parts [ 'dirname' ] . '/' . $ path_parts [ 'filename' ] . '.png' ) ) { $ fallback_ext = '.png' ; $ fallback_content = true ; } elseif ( is_file ( TL_ROOT . '/' . $ path_parts [ 'dirname' ] . '/' . $ path_parts [ 'filename' ] . '.gif' ) ) { $ fallback_ext = '.gif' ; $ fallback_content = true ; } if ( $ fallback_content === true ) { $ src_fallback = \ Image :: get ( $ this -> urlEncode ( $ path_parts [ 'dirname' ] . '/' . $ path_parts [ 'filename' ] . $ fallback_ext ) , $ intWidth , $ intHeight , 'proportional' ) ; return $ src_fallback ; } return false ; }
|
Search and get a flash fallback image path if exists
|
4,846
|
public static function defaultFQDB ( ) { if ( self :: $ defaultFQDB ) return self :: $ defaultFQDB ; if ( is_callable ( self :: $ FQDBCreatorCallback ) ) return self :: setDefaultFQDB ( call_user_func ( self :: $ FQDBCreatorCallback ) ) ; }
|
returns default FQDB
|
4,847
|
public function getUserEmail ( $ info = NULL ) { if ( empty ( $ info ) ) { $ info = $ this -> getUserInfo ( ) ; } $ emails = $ info -> get ( 'emails' ) ; if ( is_array ( $ emails ) && count ( $ emails ) ) { $ email = reset ( $ emails ) ; return $ email [ 'value' ] ; } }
|
Google can return an array of emails . We only give back the first one since we request one e - mail address
|
4,848
|
public function sign ( string $ content , string $ aud , ? string $ kid = null ) : PbjxToken { $ kid = $ kid ? : $ this -> defaultKid ; return PbjxToken :: create ( $ content , $ aud , $ kid , $ this -> getSecret ( $ kid ) ) ; }
|
Creates a new signed token for the provided content .
|
4,849
|
public function validate ( string $ content , string $ aud , string $ token ) : void { $ actualToken = PbjxToken :: fromString ( $ token ) ; $ expectedToken = PbjxToken :: create ( $ content , $ aud , $ actualToken -> getKid ( ) , $ this -> getSecret ( $ actualToken -> getKid ( ) ) , [ 'exp' => $ actualToken -> getExp ( ) , 'iat' => $ actualToken -> getIat ( ) , ] ) ; if ( ! $ actualToken -> equals ( $ expectedToken ) ) { throw new \ InvalidArgumentException ( 'PbjxTokens do not match.' , Code :: INVALID_ARGUMENT ) ; } }
|
Validates that the provided token is valid and okay to use and also creates a new token with the same secret and content and compares our result to the provided token to determine if they are an exact match .
|
4,850
|
public static function beginsWith ( $ input , $ search , $ caseInsensitive = false , $ encoding = self :: DEFAULT_ENCODING ) { $ substr = static :: sub ( $ input , 0 , static :: length ( $ search ) , $ encoding ) ; return ( static :: compare ( $ substr , $ search , $ caseInsensitive ) === 0 ) ; }
|
Verifies if a string begins with a substring .
|
4,851
|
public static function endsWith ( $ input , $ search , $ caseInsensitive = false , $ encoding = self :: DEFAULT_ENCODING ) { if ( ( $ length = static :: length ( $ search , $ encoding ) ) == 0 ) { return true ; } $ substr = static :: sub ( $ input , - $ length , $ length , $ encoding ) ; return ( static :: compare ( $ substr , $ search , $ caseInsensitive ) === 0 ) ; }
|
Verifies if a string ends with a substring .
|
4,852
|
public static function isOneOf ( $ input , array $ values , $ caseInsensitive = false , $ returnIndex = false ) { if ( is_null ( $ input ) ) { return false ; } foreach ( $ values as $ index => $ str ) { if ( static :: equals ( $ input , $ str , $ caseInsensitive ) ) { return ( $ returnIndex ) ? $ index : true ; } } return false ; }
|
Verifies if the input string is one of the values of the given array .
|
4,853
|
public static function match ( $ input , $ pattern , array & $ matches = null , $ flags = 0 , $ offset = 0 ) { return preg_match ( $ pattern , $ input , $ matches , $ flags , $ offset ) ; }
|
Searches the input string for a match to the regular expression given in pattern .
|
4,854
|
public static function length ( $ input , $ encoding = self :: DEFAULT_ENCODING ) { return function_exists ( 'mb_strlen' ) ? mb_strlen ( $ input , $ encoding ) : strlen ( $ input ) ; }
|
Gets the length of the given string .
|
4,855
|
public static function replace ( $ input , $ search , $ replace , $ caseInsensitive = false , $ encoding = self :: DEFAULT_ENCODING , & $ count = null ) { return function_exists ( 'mb_strlen' ) ? static :: mbStrReplaceCaller ( $ search , $ replace , $ input , $ caseInsensitive , $ encoding , $ count ) : ( ( $ caseInsensitive ) ? ( str_ireplace ( $ search , $ replace , $ input , $ count ) ) : ( str_replace ( $ search , $ replace , $ input , $ count ) ) ) ; }
|
Replaces a substring inside a string .
|
4,856
|
protected static function mbStrReplaceCaller ( $ search , $ replace , $ subject , $ caseInsensitive = false , $ encoding = self :: DEFAULT_ENCODING , & $ count = null ) { if ( is_array ( $ subject ) ) { $ result = [ ] ; foreach ( $ subject as $ item ) { $ result [ ] = static :: mbStrReplaceCaller ( $ search , $ replace , $ item , $ caseInsensitive , $ encoding , $ count ) ; } return $ result ; } if ( ! is_array ( $ search ) ) { return static :: mbStrReplaceInternal ( $ search , $ replace , $ subject , $ caseInsensitive , $ encoding , $ count ) ; } $ replaceIsArray = is_array ( $ replace ) ; foreach ( $ search as $ key => $ value ) { $ subject = static :: mbStrReplaceInternal ( $ value , ( $ replaceIsArray ? $ replace [ $ key ] : $ replace ) , $ subject , $ caseInsensitive , $ encoding , $ count ) ; } return $ subject ; }
|
Replaces a substring inside a string with multi - byte support
|
4,857
|
protected static function mbStrReplaceInternal ( $ search , $ replace , $ subject , $ caseInsensitive = false , $ encoding = self :: DEFAULT_ENCODING , & $ count = null ) { $ searchLength = mb_strlen ( $ search , $ encoding ) ; $ subjectLength = mb_strlen ( $ subject , $ encoding ) ; $ offset = 0 ; $ result = '' ; while ( $ offset < $ subjectLength ) { $ match = $ caseInsensitive ? mb_stripos ( $ subject , $ search , $ offset , $ encoding ) : mb_strpos ( $ subject , $ search , $ offset , $ encoding ) ; if ( $ match === false ) { if ( $ offset === 0 ) { return $ subject ; } $ result .= mb_substr ( $ subject , $ offset , $ subjectLength - $ offset , $ encoding ) ; break ; } if ( $ count !== null ) { $ count ++ ; } $ result .= mb_substr ( $ subject , $ offset , $ match - $ offset , $ encoding ) ; $ result .= $ replace ; $ offset = $ match + $ searchLength ; } return $ result ; }
|
Implementation of mb_str_replace . Do not call directly .
|
4,858
|
public static function truncate ( $ input , $ limit , $ continuation = '...' , $ isHtml = false ) { $ offset = 0 ; $ tags = [ ] ; if ( $ isHtml ) { $ input = static :: truncateHtml ( $ input , $ limit , $ offset , $ tags ) ; } $ newString = static :: sub ( $ input , 0 , $ limit = min ( static :: length ( $ input ) , $ limit + $ offset ) ) ; $ newString .= ( static :: length ( $ input ) > $ limit ? $ continuation : '' ) ; $ newString .= count ( $ tags = array_reverse ( $ tags ) ) ? '</' . implode ( '></' , $ tags ) . '>' : '' ; return $ newString ; }
|
Truncates a string to the given length .
|
4,859
|
public static function lower ( $ input , $ encoding = self :: DEFAULT_ENCODING ) { return function_exists ( 'mb_strtolower' ) ? mb_strtolower ( $ input , $ encoding ) : strtolower ( $ input ) ; }
|
Returns a lowercased string .
|
4,860
|
public static function upper ( $ input , $ encoding = self :: DEFAULT_ENCODING ) { return function_exists ( 'mb_strtoupper' ) ? mb_strtoupper ( $ input , $ encoding ) : strtoupper ( $ input ) ; }
|
Returns an uppercased string .
|
4,861
|
public static function lcfirst ( $ input , $ encoding = self :: DEFAULT_ENCODING ) { return function_exists ( 'mb_strtolower' ) ? mb_strtolower ( mb_substr ( $ input , 0 , 1 , $ encoding ) , $ encoding ) . mb_substr ( $ input , 1 , mb_strlen ( $ input , $ encoding ) , $ encoding ) : lcfirst ( $ input ) ; }
|
Returns a string with the first char as lowercase .
|
4,862
|
public static function ucfirst ( $ input , $ encoding = self :: DEFAULT_ENCODING ) { return function_exists ( 'mb_strtoupper' ) ? mb_strtoupper ( mb_substr ( $ input , 0 , 1 , $ encoding ) , $ encoding ) . mb_substr ( $ input , 1 , mb_strlen ( $ input , $ encoding ) , $ encoding ) : ucfirst ( $ input ) ; }
|
Returns a string with the first char as uppercase .
|
4,863
|
public static function ucwords ( $ input , $ encoding = self :: DEFAULT_ENCODING ) { return function_exists ( 'mb_convert_case' ) ? mb_convert_case ( $ input , MB_CASE_TITLE , $ encoding ) : ucwords ( strtolower ( $ input ) ) ; }
|
Returns a string with the words capitalized .
|
4,864
|
protected static function studlyBuildPattern ( array $ separators ) { $ pattern = '' ; foreach ( $ separators as $ separator ) { $ pattern .= '|' . preg_quote ( $ separator ) ; } $ pattern = '/(^' . $ pattern . ')(.)/' ; return $ pattern ; }
|
Builds the studly patter with the given separators .
|
4,865
|
public static function nsprintf ( $ format , array $ args = [ ] ) { $ filterRegex = '/%s/' ; $ format = preg_replace ( $ filterRegex , '#[:~s]#' , $ format ) ; $ pattern = '/(?<=%)([a-zA-Z0-9_]\w*)(?=\$)/' ; $ pool = [ 'cr' => "\r" , 'lf' => "\n" , 'crlf' => "\r\n" , 'tab' => "\t" ] + $ args ; $ args = [ ] ; $ pos = 0 ; $ match = null ; while ( static :: match ( $ format , $ pattern , $ match , PREG_OFFSET_CAPTURE , $ pos ) ) { list ( $ varKey , $ varPos ) = $ match [ 0 ] ; if ( ! array_key_exists ( $ varKey , $ pool ) ) { throw new \ BadFunctionCallException ( "Missing argument '${varKey}'." , E_USER_WARNING ) ; } array_push ( $ args , $ pool [ $ varKey ] ) ; $ format = substr_replace ( $ format , count ( $ args ) , $ varPos , $ wordLength = static :: length ( $ varKey ) ) ; $ pos = $ varPos + $ wordLength ; } $ filterRegex = '/#\[:~s\]#/' ; return preg_replace ( $ filterRegex , '%s' , vsprintf ( $ format , $ args ) ) ; }
|
Function sprintf for named variables inside format .
|
4,866
|
public function getSource ( ) { if ( is_array ( $ this -> source ) ) { if ( count ( $ this -> source ) != 2 ) { user_error ( 'FoundationSwitchField::getSource(): accepts only 2 options' , E_USER_ERROR ) ; } return array_slice ( $ this -> source , 0 , 2 ) ; } }
|
Gets the first two items from source array since SwitchField only works with two values .
|
4,867
|
public function cleanup ( ) { Cache :: clear ( false , 'default' ) ; Cache :: clear ( false , '_cake_model_' ) ; Cache :: clear ( false , '_cake_core_' ) ; $ this -> dispatchShell ( 'orm_cache clear' ) ; $ this -> dispatchShell ( 'orm_cache build' ) ; }
|
Clears the cache
|
4,868
|
public function migrate ( $ plugin = null ) { $ plugin = ( $ plugin === null ) ? '' : ' -p ' . $ plugin ; $ this -> dispatchShell ( 'migrations migrate' . $ plugin ) ; }
|
Run the migration optionally for a plugin
|
4,869
|
public function save ( $ fileName , $ values , $ map = null ) { if ( $ map !== null ) { $ output = $ this -> createOutputWithMap ( $ values , $ map ) ; } else { $ output = $ this -> createOutput ( $ values ) ; } $ this -> saveToFile ( $ fileName , $ output ) ; }
|
Writes configuration array to file
|
4,870
|
public function createOutputWithMap ( array $ values , array $ map ) { $ output = '' ; foreach ( $ map as $ outputLine ) { if ( $ outputLine [ 'type' ] == 'empty' ) { $ output .= PHP_EOL ; } elseif ( $ outputLine [ 'type' ] == 'comment' ) { $ output .= $ outputLine [ 'value' ] . PHP_EOL ; } else { $ output .= $ this -> createLine ( $ outputLine [ 'key' ] , $ values [ $ outputLine [ 'key' ] ] , $ outputLine ) . PHP_EOL ; unset ( $ values [ $ outputLine [ 'key' ] ] ) ; } } $ output .= $ this -> createOutput ( $ values ) ; return $ output ; }
|
Creates output string with provided map
|
4,871
|
public function createOutput ( $ values ) { $ output = '' ; foreach ( $ values as $ key => $ value ) { $ output .= $ this -> createLine ( $ key , $ value ) . PHP_EOL ; } return $ output ; }
|
Creates output string from configuration values
|
4,872
|
protected function fillTheQueue ( array $ middlewares ) { foreach ( $ middlewares as $ mw ) { if ( is_array ( $ mw ) ) { $ this -> push ( $ mw [ 0 ] , $ mw [ 1 ] ) ; } else { $ this -> push ( $ mw ) ; } } }
|
Fill the queue with middlewares
|
4,873
|
protected function evalCondition ( $ condition , RequestInterface $ request , ResponseInterface $ response ) { if ( is_object ( $ condition ) && $ condition instanceof ConditionInterface ) { return $ condition -> evaluate ( $ request , $ response ) ; } elseif ( is_callable ( $ condition ) ) { return $ condition ( $ request , $ response ) ; } else { throw new LogicException ( Message :: get ( Message :: CONDITION_INVALID , $ condition ) , Message :: CONDITION_INVALID ) ; } }
|
Evaluate the condition
|
4,874
|
public function add ( $ request ) { $ this -> onBefore ( $ request ) ; array_push ( $ this -> _requests , $ request ) ; curl_multi_add_handle ( $ this -> _mh , $ request -> curl ) ; $ this -> _updated = true ; }
|
Add request to execute
|
4,875
|
public function getBindedLink ( $ row = [ ] ) { $ bind = array_intersect_key ( $ row , array_fill_keys ( $ this -> getBinds ( ) , '' ) ) ; $ link = str_replace ( '%25' , '%' , $ this -> getLink ( ) ) ; return vsprintf ( $ link , $ bind ) ; }
|
Return the binded link
|
4,876
|
public function getTimeBetween ( $ first , $ second ) { if ( ! isset ( $ this -> lookup [ $ first ] ) ) { throw new \ LogicException ( sprintf ( 'The point %s was not marked in the profiler %s.' , $ first , $ this -> name ) ) ; } if ( ! isset ( $ this -> lookup [ $ second ] ) ) { throw new \ LogicException ( sprintf ( 'The point %s was not marked in the profiler %s.' , $ second , $ this -> name ) ) ; } $ indexFirst = $ this -> lookup [ $ first ] ; $ indexSecond = $ this -> lookup [ $ second ] ; $ firstPoint = $ this -> points [ $ indexFirst ] ; $ secondPoint = $ this -> points [ $ indexSecond ] ; return abs ( $ secondPoint -> getTime ( ) - $ firstPoint -> getTime ( ) ) ; }
|
Get the elapsed time in seconds between the two points .
|
4,877
|
public function setStart ( $ timeStamp = 0.0 , $ memoryBytes = 0 ) { if ( ! empty ( $ this -> points ) ) { throw new \ RuntimeException ( 'The start point cannot be adjusted after points are added to the profiler.' ) ; } $ this -> startTimeStamp = $ timeStamp ; $ this -> startMemoryBytes = $ memoryBytes ; $ point = new ProfilePoint ( 'start' ) ; $ this -> points [ ] = $ point ; $ this -> lookup [ $ point -> getName ( ) ] = \ count ( $ this -> points ) - 1 ; return $ this ; }
|
Creates a profile point with the specified starting time and memory .
|
4,878
|
public function install ( ) { $ publicKey = $ this -> certificateStorage -> load ( CertificateType :: PUBLIC_KEY ( ) ) ; $ response = $ this -> sendInstallationPostRequest ( '/v1/installation' , [ 'json' => [ 'client_public_key' => $ publicKey -> toString ( ) , ] , ] ) ; $ responseArray = \ json_decode ( ( string ) $ response -> getBody ( ) , true ) ; return [ 'token' => $ responseArray [ 'Response' ] [ 1 ] [ 'Token' ] [ 'token' ] , 'public_key' => $ responseArray [ 'Response' ] [ 2 ] [ 'ServerPublicKey' ] [ 'server_public_key' ] , ] ; }
|
Registers your public key with the Bunq API .
|
4,879
|
public function registerDevice ( Token $ token ) { $ this -> sendInstallationPostRequest ( '/v1/device-server' , [ 'headers' => [ 'X-Bunq-Client-Authentication' => $ token -> toString ( ) , ] , 'json' => [ 'description' => 'Bunq PHP API Client' , 'secret' => $ this -> apiKey , 'permitted_ips' => $ this -> permittedIps , ] , ] ) ; }
|
Registers a device with the Bunq API .
|
4,880
|
public function createSession ( Token $ token ) { $ response = $ this -> sendInstallationPostRequest ( '/v1/session-server' , [ 'headers' => [ 'X-Bunq-Client-Authentication' => $ token -> toString ( ) , ] , 'json' => [ 'secret' => $ this -> apiKey , ] , ] ) ; $ responseArray = \ json_decode ( ( string ) $ response -> getBody ( ) , true ) ; return $ responseArray [ 'Response' ] [ 1 ] [ 'Token' ] [ 'token' ] ; }
|
Registers a session with the Bunq API .
|
4,881
|
private function sendInstallationPostRequest ( $ url , array $ options = [ ] ) { try { return $ this -> httpClient -> request ( 'POST' , $ url , $ options ) ; } catch ( ClientException $ exception ) { throw new BunqException ( $ exception ) ; } }
|
Sends a post request using the installation HTTP Client
|
4,882
|
private function authenticate ( ) { $ try = 0 ; while ( true ) { $ try ++ ; try { $ response = $ this -> soapClient -> __soapCall ( 'GetAuthenticationToken' , array ( array ( 'authenticationRequest' => $ this -> authenticationRequest -> toArray ( ) , ) ) ) ; return new AuthenticationTokenResponse ( new \ DateTime ( $ response -> GetAuthenticationTokenResult -> DeprecatedDate ) , $ response -> GetAuthenticationTokenResult -> Key ) ; } catch ( \ SoapFault $ e ) { if ( null !== $ this -> logger ) { $ this -> logger -> critical ( sprintf ( '[%] %s' , __CLASS__ , $ e -> getMessage ( ) ) ) ; } if ( $ try >= $ this -> retries ) { throw $ e ; } usleep ( 500000 ) ; } } }
|
Calls the authentication API
|
4,883
|
protected function getForm ( FieldTypeInterface $ field , $ force = false ) { $ datasource = $ field -> getDataSource ( ) ; if ( $ datasource === null ) { return null ; } if ( ! $ field -> getOption ( 'form_filter' ) ) { return null ; } $ field_oid = spl_object_hash ( $ field ) ; if ( isset ( $ this -> forms [ $ field_oid ] ) && ! $ force ) { return $ this -> forms [ $ field_oid ] ; } $ options = $ field -> getOption ( 'form_options' ) ; $ options = array_merge ( $ options , [ 'required' => false , 'auto_initialize' => false ] ) ; $ form = $ this -> formFactory -> createNamed ( $ datasource -> getName ( ) , $ this -> isFqcnFormTypePossible ( ) ? 'Symfony\Component\Form\Extension\Core\Type\CollectionType' : 'collection' , null , [ 'csrf_protection' => false ] ) ; $ fieldsForm = $ this -> formFactory -> createNamed ( DataSourceInterface :: PARAMETER_FIELDS , $ this -> isFqcnFormTypePossible ( ) ? 'Symfony\Component\Form\Extension\Core\Type\FormType' : 'form' , null , [ 'auto_initialize' => false ] ) ; switch ( $ field -> getComparison ( ) ) { case 'between' : $ this -> buildBetweenComparisonForm ( $ fieldsForm , $ field , $ options ) ; break ; case 'isNull' : $ this -> buildIsNullComparisonForm ( $ fieldsForm , $ field , $ options ) ; break ; default : switch ( $ field -> getType ( ) ) { case 'boolean' : $ this -> buildBooleanForm ( $ fieldsForm , $ field , $ options ) ; break ; default : $ fieldsForm -> add ( $ field -> getName ( ) , $ this -> getFieldFormType ( $ field ) , $ options ) ; } } $ form -> add ( $ fieldsForm ) ; $ this -> forms [ $ field_oid ] = $ form ; return $ this -> forms [ $ field_oid ] ; }
|
Builds form .
|
4,884
|
private function decrypt ( $ cookieValue ) { if ( $ this -> encrypter && ! empty ( $ cookieValue ) ) { return $ this -> encrypter -> decrypt ( $ cookieValue ) ; } return $ cookieValue ; }
|
Decrypt a cookie
|
4,885
|
public function evaluate ( $ expression , $ values = [ ] ) { if ( is_array ( $ values ) ) { return parent :: evaluate ( $ expression , $ values ) ; } else { return $ this -> parse ( $ expression , $ values -> getKeys ( ) ) -> getNodes ( ) -> evaluate ( $ this -> functions , $ values ) ; } }
|
Evaluate an expression . Overridden to allow passing in a SymbolTable .
|
4,886
|
public function resend ( Request $ request ) { $ user = Auth :: user ( ) ; if ( $ user -> getVerified ( ) ) { return redirect ( ) -> back ( ) ; } $ response = VerifyEmail :: sendVerificationLink ( $ user , function ( Message $ message ) use ( $ user ) { $ message -> subject ( $ user -> getVerifyEmailSubject ( ) ) ; } ) ; switch ( $ response ) { case VerifyEmail :: VERIFY_LINK_SENT : return redirect ( ) -> back ( ) -> with ( 'status' , trans ( $ response ) ) ; } }
|
Send another verification email .
|
4,887
|
public function verify ( $ token ) { $ response = VerifyEmail :: verify ( Auth :: user ( ) , $ token ) ; switch ( $ response ) { case VerifyEmail :: EMAIL_VERIFIED : return redirect ( $ this -> redirectPath ( ) ) -> with ( 'status' , trans ( $ response ) ) ; default : return redirect ( ) -> back ( ) -> withErrors ( [ 'email' => trans ( $ response ) ] ) ; } }
|
Attempt to verify a user .
|
4,888
|
public function addColumn ( Column \ Column $ column ) { $ column -> setTable ( $ this ) ; if ( ! $ column -> hasRenderer ( ) ) { $ column -> setRenderer ( $ this -> getRenderer ( ) ) ; } $ this -> columns [ $ column -> getName ( ) ] = $ column ; return $ this ; }
|
Add a single column to the column container
|
4,889
|
public function getColumnByIndex ( $ index ) { $ keys = array_keys ( $ this -> columns ) ; if ( empty ( $ keys [ $ index ] ) || empty ( $ column = $ this -> columns [ $ keys [ $ index ] ] ) ) { throw new \ InvalidArgumentException ( 'Table don\'t have a column index : ' . $ index ) ; } return $ column ; }
|
Return the column from his index
|
4,890
|
public function addRemoteBoolean ( $ name , $ label = '' , $ function = null ) { $ c = new Column \ RemoteBoolean ( $ name , $ label , $ function ) ; $ this -> addColumn ( $ c ) ; return $ c ; }
|
Add boolean switch
|
4,891
|
public function addRemoteText ( $ name , $ label = '' , $ function = null ) { $ c = new Column \ RemoteText ( $ name , $ label , $ function ) ; $ this -> addColumn ( $ c ) ; return $ c ; }
|
Add remote text
|
4,892
|
public function addRemoteSelect ( $ name , $ label = '' , $ index = null , $ option = [ ] , $ function = null ) { $ c = new Column \ RemoteSelect ( $ name , $ label , $ index , $ option , $ function ) ; $ this -> addColumn ( $ c ) ; return $ c ; }
|
Add remote select
|
4,893
|
public function addButton ( $ name , $ label = '%s' , $ link = '#' , $ binds = [ ] , $ attr = [ ] ) { $ c = new Column \ Button ( $ name , $ label , $ link , $ binds , $ attr ) ; $ c -> setOptionAsDefault ( ) ; $ this -> addColumn ( $ c ) ; return $ c ; }
|
Add as Button Column
|
4,894
|
public function addButtonEdit ( $ link = '#' , $ binds = [ ] , $ is_remote = true , $ method = 'post' ) { $ c = new Column \ Button ( configurator ( ) -> get ( 'button.edit.name' ) , configurator ( ) -> get ( 'button.edit.label' ) , $ link , $ binds ) ; $ c -> setOptionAsPrimary ( ) ; $ c -> icon ( configurator ( ) -> get ( 'button.edit.icon' ) ) ; if ( $ is_remote ) { $ c -> enableRemote ( $ method ) ; } $ this -> addColumn ( $ c ) ; return $ c ; }
|
Add default edit button
|
4,895
|
public function addButtonDelete ( $ link = '#' , $ binds = [ ] , $ is_remote = true , $ method = 'delete' ) { $ c = new Column \ Button ( configurator ( ) -> get ( 'button.delete.name' ) , configurator ( ) -> get ( 'button.delete.label' ) , $ link , $ binds ) ; $ c -> setOptionAsDanger ( ) ; $ c -> icon ( configurator ( ) -> get ( 'button.delete.icon' ) ) ; if ( $ is_remote ) { $ c -> enableRemote ( $ method ) ; } $ this -> addColumn ( $ c ) ; return $ c ; }
|
Add default delete button
|
4,896
|
public function addContainer ( $ name , $ label = '' , $ attr = [ ] ) { $ c = new Column \ Container ( $ name , $ label , $ attr ) ; $ this -> addColumn ( $ c ) ; return $ c ; }
|
Add a container columns
|
4,897
|
public function addColor ( $ color ) { if ( ! $ color instanceof Color ) { $ color = new Color ( $ color ) ; } $ this -> colors [ ] = $ color ; }
|
Adds a color to the Mixer .
|
4,898
|
public function mix ( ) : Color { foreach ( $ this -> colors as $ color ) { $ colors = $ color -> dec ( ) ; $ reds [ ] = $ colors [ 0 ] ; $ greens [ ] = $ colors [ 1 ] ; $ blues [ ] = $ colors [ 2 ] ; } $ red = dechex ( round ( array_sum ( $ reds ) / count ( $ reds ) ) ) ; $ green = dechex ( round ( array_sum ( $ greens ) / count ( $ greens ) ) ) ; $ blue = dechex ( round ( array_sum ( $ blues ) / count ( $ blues ) ) ) ; foreach ( [ & $ red , & $ green , & $ blue ] as & $ color ) { if ( strlen ( $ color ) === 1 ) { $ color = "0$color" ; } } return new Color ( $ red . $ green . $ blue ) ; }
|
Get the mixed color .
|
4,899
|
public function isSourceQueryBuilder ( ) { return is_object ( $ this -> getSource ( ) ) && get_class ( $ this -> getSource ( ) ) == \ Illuminate \ Database \ Query \ Builder :: class ; }
|
Return true if the source is an instance of \ Illuminate \ Database \ Query \ Builder
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.