idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
3,100
public function getMimeTypeByExtension ( $ path ) { if ( ! $ this -> mimeCache ) { $ this -> mimeCache = require \ App :: getAlias ( 'disco.mime' ) ; } if ( isset ( $ this -> mimeCache [ $ this -> getExtension ( $ path ) ] ) ) { return $ this -> mimeCache [ $ this -> getExtension ( $ path ) ] ; } return null ; }
Get a file extension type based on the file MIME info .
3,101
public function chmodRecursive ( $ path , $ mode ) { $ items = $ this -> recursiveIterate ( $ path ) ; foreach ( $ items as $ item ) { chmod ( $ item , $ mode ) ; } }
Change file mode for directory and all contents .
3,102
public function serveAsDownload ( $ path ) { $ this -> isFileOrDie ( $ path ) ; $ this -> downloadHeaders ( $ path ) ; $ this -> serve ( $ path ) ; }
Serve a file as a download .
3,103
public function XServeAsDownload ( $ path ) { $ this -> isFileOrDie ( $ path ) ; $ this -> downloadHeaders ( $ path ) ; $ this -> XServe ( $ path ) ; }
Serve a file as a download using the Apache module XSendFile .
3,104
private function config_home ( $ home ) { if ( ! is_string ( $ home ) || ! $ home || $ home [ 0 ] != '/' ) return ; $ home = rtrim ( $ home , '/' ) . '/' ; $ this -> home = $ home ; }
Home configuration validation .
3,105
private function config_host ( string $ host = null ) { if ( filter_var ( $ host , FILTER_VALIDATE_URL , FILTER_FLAG_PATH_REQUIRED ) === false ) return ; $ host = rtrim ( $ host , '/' ) . '/' ; $ home = $ this -> home ; if ( $ home == '/' ) { $ this -> host = $ host ; return ; } if ( substr ( $ host , - strlen ( $ home ) ) != $ home ) return ; $ this -> host = $ host ; }
Host configuration validation .
3,106
final public function init ( ) { if ( $ this -> request_initted ) return ; $ this -> init_request ( ) ; if ( $ this -> auto_shutdown ) register_shutdown_function ( [ $ this , 'shutdown' ] ) ; $ this -> request_initted = true ; return $ this ; }
Initialize parser and shutdown handler .
3,107
final public function deinit ( ) { $ this -> request_path = null ; $ this -> request_comp = [ ] ; $ this -> home = null ; $ this -> host = null ; $ this -> auto_shutdown = true ; $ this -> request_initted = false ; $ this -> request_handled = false ; $ this -> request_method = null ; $ this -> method_collection = [ ] ; return $ this ; }
Reset properties to default values .
3,108
private function autodetect_home ( ) { if ( $ this -> home !== null ) return ; if ( php_sapi_name ( ) == 'cli' ) return $ this -> home = '/' ; $ home = dirname ( $ _SERVER [ 'SCRIPT_NAME' ] ) ; $ home = ! $ home || $ home [ 0 ] != '/' ? '/' : rtrim ( $ home , '/' ) . '/' ; $ this -> home = $ home ; }
Autodetect home .
3,109
private function autodetect_host ( ) { if ( $ this -> host !== null ) return ; $ proto = isset ( $ _SERVER [ 'HTTPS' ] ) && ! empty ( $ _SERVER [ 'HTTPS' ] ) ? 'https://' : 'http://' ; $ host = isset ( $ _SERVER [ 'SERVER_NAME' ] ) ? $ _SERVER [ 'HTTP_HOST' ] : 'localhost' ; $ port = isset ( $ _SERVER [ 'SERVER_PORT' ] ) ? ( int ) $ _SERVER [ 'SERVER_PORT' ] : null ; $ port = $ this -> verify_port ( $ port , $ proto ) ; if ( $ port && ( strpos ( $ host , ':' ) === false ) ) $ host .= ':' . $ port ; $ host = str_replace ( [ ':80' , ':443' ] , '' , $ host ) ; $ this -> host = $ proto . $ host . $ this -> home ; }
Autodetect host .
3,110
private function verify_port ( int $ port = null , string $ proto ) { if ( ! $ port ) return $ port ; if ( $ port < 0 || $ port > pow ( 2 , 16 ) ) return null ; if ( $ port == 80 && $ proto == 'http' ) return null ; if ( $ port == 443 && $ proto == 'https' ) return null ; return $ port ; }
Verify if port number is valid and not redundant with protocol .
3,111
private function init_request ( ) { $ this -> autodetect_home ( ) ; $ this -> autodetect_host ( ) ; $ url = isset ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : '' ; $ rpath = parse_url ( $ url ) [ 'path' ] ; if ( $ rpath != '/' ) $ rpath = substr ( $ rpath , strlen ( $ this -> home ) - 1 ) ; $ rpath = trim ( $ rpath , "/" ) ; $ this -> request_path = '/' . $ rpath ; $ this -> request_comp = explode ( '/' , $ rpath ) ; self :: $ logger -> debug ( sprintf ( "Router: request path: '%s'." , $ this -> request_path ) ) ; }
Initialize request processing .
3,112
private function verify_route_method ( $ path_method ) { $ this -> request_method = ( isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) && ! empty ( $ _SERVER [ 'REQUEST_METHOD' ] ) ) ? strtoupper ( $ _SERVER [ 'REQUEST_METHOD' ] ) : 'GET' ; $ methods = is_array ( $ path_method ) ? $ methods = array_merge ( $ path_method , [ 'HEAD' ] ) : $ methods = [ $ path_method , 'HEAD' ] ; $ methods = array_unique ( $ methods ) ; foreach ( $ methods as $ method ) { if ( ! in_array ( $ method , $ this -> method_collection ) ) $ this -> method_collection [ ] = $ method ; } if ( ! in_array ( $ this -> request_method , $ methods ) ) return false ; return true ; }
Verify route method .
3,113
private function parse_request_path ( string $ path ) { if ( $ path == $ this -> request_path ) return [ ] ; $ parser = $ this -> path_parser ( $ path ) ; if ( ! $ parser [ 1 ] ) return false ; $ pattern = '!^' . $ parser [ 0 ] . '$!' ; $ matched = preg_match_all ( $ pattern , $ this -> request_path , $ result , PREG_SET_ORDER ) ; if ( ! $ matched ) return false ; unset ( $ result [ 0 ] [ 0 ] ) ; return array_combine ( $ parser [ 1 ] , $ result [ 0 ] ) ; }
Parse request path .
3,114
private function execute_callback ( callable $ callback , array $ args , bool $ is_raw = null ) { $ method = strtolower ( $ this -> request_method ) ; if ( in_array ( $ method , [ 'head' , 'get' , 'options' ] ) ) return $ this -> finish_callback ( $ callback , $ args ) ; if ( $ method == 'post' ) { $ args [ 'post' ] = $ is_raw ? file_get_contents ( "php://input" ) : $ _POST ; if ( isset ( $ _FILES ) && ! empty ( $ _FILES ) ) $ args [ 'files' ] = $ _FILES ; return $ this -> finish_callback ( $ callback , $ args ) ; } if ( in_array ( $ method , [ 'put' , 'delete' , 'patch' ] ) ) { $ args [ $ method ] = file_get_contents ( "php://input" ) ; return $ this -> finish_callback ( $ callback , $ args ) ; } self :: $ logger -> warning ( sprintf ( "Router: %s not supported in '%s'." , $ this -> request_method , $ this -> request_path ) ) ; $ this -> abort ( 405 ) ; return $ this ; }
Execute callback of a matched route .
3,115
private function finish_callback ( callable $ callback , array $ args ) { $ this -> request_handled = true ; $ this -> wrap_callback ( $ callback , $ args ) ; return $ this ; }
Finish callback .
3,116
final public static function path_parser ( string $ path ) { if ( $ path [ 0 ] != '/' ) { self :: throw_error ( "Router: path invalid in '$path'." ) ; } if ( $ path != '/' ) $ path = rtrim ( $ path , '/' ) ; $ valid_chars = 'a-zA-Z0-9\_\.\-@%:' ; $ elf = '<\{' ; $ erg = '>\}' ; $ delims = "\/${elf}${erg}" ; $ non_delims = "[^${delims}]" ; $ valid_key = "[a-z][a-z0-9\_]*" ; if ( ! preg_match ( "!^[${valid_chars}${delims}]+$!" , $ path ) ) { self :: throw_error ( "Router: invalid characters in path: '$path'." ) ; } if ( preg_match ( "!${non_delims}[${elf}]!" , $ path ) || preg_match ( "![${erg}]${non_delims}!" , $ path ) ) { self :: throw_error ( "Router: dynamic path not well-formed: '$path'." ) ; } preg_match_all ( "!/([$elf][^$erg]+[$erg])!" , $ path , $ tokens , PREG_OFFSET_CAPTURE ) ; $ keys = $ symbols = [ ] ; foreach ( $ tokens [ 1 ] as $ token ) { $ key = str_replace ( [ '{' , '}' , '<' , '>' ] , '' , $ token [ 0 ] ) ; if ( ! preg_match ( "!^${valid_key}\$!i" , $ key ) ) { self :: throw_error ( "Router: invalid param key: '$path'." ) ; } $ keys [ ] = $ key ; $ replacement = $ valid_chars ; if ( strpos ( $ token [ 0 ] , '{' ) !== false ) $ replacement .= '/' ; $ replacement = '([' . $ replacement . ']+)' ; $ symbols [ ] = [ $ replacement , $ token [ 1 ] , strlen ( $ token [ 0 ] ) ] ; } if ( count ( $ keys ) > count ( array_unique ( $ keys ) ) ) { self :: throw_error ( "Router: param key reused: '$path'." ) ; } $ idx = 0 ; $ pattern = '' ; while ( $ idx < strlen ( $ path ) ) { $ matched = false ; foreach ( $ symbols as $ symbol ) { if ( $ idx < $ symbol [ 1 ] ) continue ; if ( $ idx == $ symbol [ 1 ] ) { $ matched = true ; $ pattern .= $ symbol [ 0 ] ; $ idx ++ ; $ idx += $ symbol [ 2 ] - 1 ; } } if ( ! $ matched ) { $ pattern .= $ path [ $ idx ] ; $ idx ++ ; } } return [ $ pattern , $ keys ] ; }
Path parser .
3,117
public function wrap_callback ( callable $ callback , array $ args = [ ] ) { self :: $ logger -> debug ( sprintf ( "Router: %s '%s'." , $ this -> request_method , $ this -> request_path ) ) ; $ callback ( $ args ) ; static :: halt ( ) ; }
Callback wrapper .
3,118
private function abort_default ( $ code ) { extract ( self :: get_header_string ( $ code ) ) ; static :: start_header ( $ code ) ; $ uri = htmlspecialchars ( $ _SERVER [ 'REQUEST_URI' ] , ENT_QUOTES ) ; echo "<!doctype html><html> <head> <meta charset=utf-8> <meta name=viewport content='width=device-width, initial-scale=1.0, user-scalable=yes'> <title>$code $msg</title> <style> body {background-color: #eee; font-family: sans-serif;} div {background-color: #fff; border: 1px solid #ddd; padding: 25px; max-width:800px; margin:20vh auto 0 auto; text-align:center;} </style> </head> <body> <div> <h1>$code $msg</h1> <p>The URL <tt>&#039;<a href='$uri'>$uri</a>&#039;</tt> caused an error.</p> </div> </body></html>" ; static :: halt ( ) ; }
Default abort method .
3,119
private function redirect_default ( string $ destination ) { extract ( self :: get_header_string ( 301 ) ) ; static :: start_header ( $ code , 0 , [ "Location: $destination" , ] ) ; $ dst = htmlspecialchars ( $ destination , ENT_QUOTES ) ; echo "<!doctype html><html> <head> <meta charset='utf-8'/> <meta name=viewport content='width=device-width, initial-scale=1.0, user-scalable=yes'> <title>$code $msg</title> <style> body {background-color: #eee; font-family: sans-serif;} div {background-color: #fff; border: 1px solid #ddd; padding: 25px; max-width:800px; margin:20vh auto 0 auto; text-align:center;} </style> </head> <body> <div> <h1>$code $msg</h1> <p>See <tt>&#039;<a href='$dst'>$dst</a>&#039;</tt>.</p> </div> </body></html>" ; static :: halt ( ) ; }
Default redirect .
3,120
private function static_file_default ( string $ path , int $ cache = 0 , string $ disposition = null ) { if ( file_exists ( $ path ) ) static :: send_file ( $ path , $ disposition , 200 , $ cache ) ; $ this -> abort ( 404 ) ; }
Default static file .
3,121
final public function static_file ( string $ path , int $ cache = 0 , $ disposition = null ) { self :: $ logger -> info ( "Router: static: '$path'." ) ; if ( ! method_exists ( $ this , 'static_file_custom' ) ) return $ this -> static_file_default ( $ path , $ cache , $ disposition ) ; return $ this -> static_file_custom ( $ path , $ cache , $ disposition ) ; }
Static file .
3,122
public function get_request_comp ( int $ index = null ) { $ comp = $ this -> request_comp ; if ( $ index === null ) return $ comp ; if ( isset ( $ comp [ $ index ] ) ) return $ comp [ $ index ] ; return null ; }
Get request component .
3,123
public function getRenderer ( ) { if ( $ this -> hasForm ( ) ) { return $ this -> getForm ( ) -> getRenderer ( ) ; } elseif ( $ this -> hasRenderer ( ) ) { return $ this -> renderer ; } else { return null ; } }
Getter for form renderer
3,124
public function getValidator ( ) { if ( ! $ this -> hasValidator ( ) && $ this -> hasForm ( ) ) { $ this -> setValidator ( clone $ this -> getForm ( ) -> getValidator ( ) ) ; $ this -> getValidator ( ) -> clearErrors ( ) -> clearMessages ( ) -> clearRules ( ) ; } return $ this -> validator ; }
getter for form validator
3,125
public function addRule ( $ rule , $ method = null , $ params = [ ] , $ message = null ) { array_unshift ( $ params , $ rule , $ method ) ; call_user_func_array ( [ $ this -> getValidator ( ) , 'addRule' ] , $ params ) ; if ( ! is_null ( $ message ) ) { if ( is_array ( $ message ) ) { foreach ( $ message as $ rule => $ message ) { $ this -> getValidator ( ) -> addMessage ( $ rule , $ message ) ; } } else { $ this -> getValidator ( ) -> addMessage ( $ rule , $ message ) ; } } return $ this ; }
Ajoute un validator
3,126
public function valid ( $ value = null ) { if ( ! is_null ( $ value ) ) { $ value = ( is_string ( $ value ) ) ? trim ( $ value ) : $ value ; if ( $ this -> hasFilterer ( ) ) { $ value = $ this -> getFilterer ( ) -> filter ( $ value ) ; } $ this -> setValue ( $ value ) ; } $ this -> getValidator ( ) -> valid ( $ this -> getValue ( ) ) ; return $ this ; }
Validation de la valeur courant de l element
3,127
public function addFilter ( $ filter , $ method = null , ... $ params ) { if ( ! $ this -> hasFilterer ( ) ) { $ this -> setFilterer ( configurator ( ) -> build ( 'form.filterer.class' ) ) ; } call_user_func_array ( [ $ this -> getFilterer ( ) , 'addFilter' ] , func_get_args ( ) ) ; return $ this ; }
Ajoute un filtre
3,128
public function setFilters ( $ filters ) { if ( ! $ this -> hasFilterer ( ) ) { $ this -> setFilterer ( configurator ( ) -> build ( 'form.filterer.class' ) ) ; } $ this -> getFilterer ( ) -> setFilters ( $ filters ) ; return $ this ; }
Shortcut pour l ajout de filtre
3,129
public function setProps ( $ props ) { if ( ! is_array ( $ props ) && ! ( $ props instanceof \ Traversable ) ) { return $ this ; } foreach ( $ props as $ name => $ value ) { $ this -> set ( $ name , $ value ) ; } return $ this ; }
Set multipe properties to the HTML element
3,130
public function set ( $ name , $ value = null ) { if ( is_string ( $ name ) ) { $ name = $ this -> cleanAttributeName ( $ name ) ; if ( $ value === null && isset ( $ this -> props [ $ name ] ) ) { unset ( $ this -> props [ $ name ] ) ; } elseif ( $ value !== null ) { $ this -> props [ $ name ] = $ value ; } } return $ this ; }
Set a single property to the HTML element
3,131
public function getProps ( $ list = null ) { if ( $ list && is_array ( $ list ) ) { $ result = array ( ) ; foreach ( $ list as $ key ) { $ result [ $ key ] = $ this -> get ( $ key ) ; } return $ result ; } return $ this -> props ; }
Returns some or all of the HTML element s properties
3,132
public function get ( $ name ) { $ name = $ this -> cleanAttributeName ( $ name ) ; return isset ( $ this -> props [ $ name ] ) ? $ this -> props [ $ name ] : null ; }
Returns one of HTML element s properties
3,133
public function addClass ( $ class ) { if ( ! $ this -> hasClass ( $ class ) ) { $ this -> set ( 'class' , trim ( ( string ) $ this -> get ( 'class' ) . ' ' . $ class ) ) ; } return $ this ; }
Add a class to the element s class list
3,134
public function removeClass ( $ class ) { $ classes = $ this -> get ( 'class' ) ; if ( $ classes ) { $ classes = trim ( preg_replace ( '/(^| ){1}' . $ class . '( |$){1}/i' , ' ' , $ classes ) ) ; $ this -> set ( 'class' , $ classes ) ; } return $ this ; }
Remove a class from the element s class list
3,135
public function setContent ( $ content ) { if ( ! $ content ) { return $ this ; } if ( ! is_array ( $ content ) ) { $ content = array ( $ content ) ; } $ this -> clearContent ( ) ; foreach ( $ content as $ child ) { $ this -> addChild ( $ child ) ; } return $ this ; }
Set the content
3,136
protected function getPluggables ( ) { $ pluggables = $ this -> pluggable -> all ( ) ; $ results = [ ] ; foreach ( $ pluggables as $ pluggable ) { $ results [ ] = $ this -> getPluggableInformation ( $ pluggable ) ; } return array_filter ( $ results ) ; }
Get all pluggables .
3,137
private function login ( Request $ request ) { $ user = $ this -> loginProvider -> authenticate ( $ request ) ; if ( null !== $ user ) { try { $ token = $ user -> createToken ( $ this -> tokenSalt ) ; $ this -> tokenStore -> store ( $ request , $ token , $ user ) ; return $ user ; } catch ( \ Exception $ e ) { throw new InternalAuthProviderException ( 'Error while trying to store new token for user: ' . $ e -> getMessage ( ) , $ e ) ; } } return null ; }
performs login when token not found or invalid
3,138
private function readToken ( Request $ request ) { if ( ! $ request -> hasRedirectHeader ( 'HTTP_AUTHORIZATION' ) ) { return null ; } return $ request -> readRedirectHeader ( 'HTTP_AUTHORIZATION' ) -> withFilter ( TokenFilter :: instance ( ) ) ; }
reads token from authorization header
3,139
public function getColumnAttr ( ) { $ attr = [ ] ; foreach ( $ this -> column as $ item ) { if ( is_array ( $ item ) ) $ attr = array_merge ( $ attr , $ item ) ; else $ attr [ ] = $ item ; } return array_unique ( array_values ( $ attr ) ) ; }
Gets all column attributes .
3,140
public function hideColumn ( $ column ) { if ( ! is_array ( $ column ) ) $ column = [ $ column ] ; $ newColumn = [ ] ; foreach ( $ this -> column as $ item ) { if ( is_array ( $ item ) ) { $ new = array_values ( array_diff ( $ item , $ column ) ) ; if ( ! empty ( $ new ) ) $ newColumn [ ] = count ( $ new ) > 1 ? array_values ( $ new ) : $ new [ 0 ] ; } else if ( ! in_array ( $ item , $ column ) ) $ newColumn [ ] = $ item ; } $ this -> column = $ newColumn ; return $ this ; }
Remove one or more columns attributes
3,141
public function checkValue ( & $ value ) { if ( parent :: checkValue ( $ value ) === true ) { if ( ! preg_match ( '/^(?:from|to|(?:\d{1,2}|100)%)$/D' , $ value ) ) { $ this -> setIsValid ( false ) ; $ this -> addValidationError ( "Invalid value '$value' for the keyframe selector." ) ; return false ; } return true ; } return false ; }
Checks the keyframes selector value .
3,142
public final function verifyOnly ( $ fields ) { foreach ( $ fields as $ k ) { $ this -> verifyData ( $ k ) ; } if ( count ( $ this -> errors ) ) { return false ; } return true ; }
Verify only the passed fields data . This comes in handy when you only want to verify a subset of the data models definition .
3,143
public final function verifySetData ( ) { foreach ( $ this -> data as $ k => $ v ) { $ this -> verifyData ( $ k ) ; } if ( count ( $ this -> errors ) ) { return false ; } return true ; }
Verify only data that has been set in the data model and not all data defined by the definitions .
3,144
protected final function setError ( $ key , $ error = null ) { if ( $ e = $ this -> getDefinitionValue ( $ key , 'error' ) ) { $ error = $ e ; } else if ( $ error === null ) { $ error = sprintf ( $ this -> defaultErrorMessage , $ key ) ; } $ this -> errors [ $ key ] = $ error ; return false ; }
Set an error .
3,145
public function getError ( $ key ) { if ( ! isset ( $ this -> errors [ $ key ] ) ) { return false ; } return $ this -> errors [ $ key ] ; }
Get an error .
3,146
public final function setDefinition ( $ key , $ value ) { if ( array_key_exists ( $ key , $ this -> definition ) ) { throw new \ Disco \ exceptions \ Exception ( "Cannot override frozen data model definition `{$key}`" ) ; } $ this -> definition [ $ key ] = $ value ; }
Set a datums definition . Cannot overwrite previously defined definitions .
3,147
public final function getDefinitionValue ( $ key , $ condition ) { if ( ! array_key_exists ( $ key , $ this -> definition ) || ! array_key_exists ( $ condition , $ this -> definition [ $ key ] ) ) { return false ; } return $ this -> definition [ $ key ] [ $ condition ] ; }
Get a single value that resides within a single data definition .
3,148
public function offsetSet ( $ key , $ value ) { if ( ! array_key_exists ( $ key , $ this -> definition ) ) { throw new \ Disco \ exceptions \ Exception ( "Field `{$key}` is not defined by this data model" ) ; } $ this -> data [ $ key ] = $ value ; }
Set a field of the data model using array access syntax .
3,149
protected final function _postMassage ( $ key , $ value ) { if ( ( $ massage = $ this -> getDefinitionValue ( $ key , 'postmassage' ) ) !== false ) { $ this -> data [ $ key ] = $ this -> { $ massage } ( $ value ) ; } }
Apply a post massage function to a data value .
3,150
protected final function _isValidInt ( $ key , $ value ) { if ( ! is_numeric ( $ value ) || strpos ( $ value , '.' ) !== false ) { return $ this -> setError ( $ key , "`{$key}` must be a integer" ) ; } if ( ! $ this -> _isBetweenMinAndMax ( $ key , $ value ) ) { return false ; } return true ; }
Determine if the value is a valid int .
3,151
protected final function _isValidFloat ( $ key , $ value ) { if ( ! is_numeric ( $ value ) ) { return $ this -> setError ( $ key , "`{$key}` must be numeric" ) ; } if ( ! $ this -> _isBetweenMinAndMax ( $ key , $ value ) ) { return false ; } return true ; }
Determine if the value is a valid float .
3,152
protected final function _isBetweenMinAndMax ( $ key , $ value ) { if ( ( $ min = $ this -> getDefinitionValue ( $ key , 'min' ) ) !== false && $ value < $ min ) { return $ this -> setError ( $ key , "`{$key}` must be greater than {$min}" ) ; } if ( ( $ max = $ this -> getDefinitionValue ( $ key , 'max' ) ) !== false && $ value > $ max ) { return $ this -> setError ( $ key , "`{$key}` must be less than {$max}" ) ; } return true ; }
Determine if the value is greater than min if set and less than max if set .
3,153
private function getProgressBar ( OutputInterface $ output , int $ total ) : ProgressBar { return $ this -> getProgressBarFactory ( ) -> getProgressBar ( $ output , $ total ) ; }
Returns the progress bar from the factory .
3,154
protected function registerInstallCommand ( ) { $ this -> app -> singleton ( 'command.hstcms.install' , function ( $ app ) { return new \ Huasituo \ Hstcms \ Console \ Commands \ HstcmsInstallCommand ( $ app [ 'hstcms' ] ) ; } ) ; $ this -> commands ( 'command.hstcms.install' ) ; }
Register the hstcms . install command .
3,155
protected function registerInfoCommand ( ) { $ this -> app -> singleton ( 'command.hstcms.info' , function ( $ app ) { return new \ Huasituo \ Hstcms \ Console \ Commands \ HstcmsInfoCommand ( $ app [ 'hstcms' ] ) ; } ) ; $ this -> commands ( 'command.hstcms.info' ) ; }
Register the hstcms . info command .
3,156
private function disconnect ( ) { if ( is_resource ( $ this -> _conn ) ) { fclose ( $ this -> _conn ) ; } $ this -> _auto_reconnect = false ; $ this -> _conn = null ; }
Disconnect from the DataSift stream
3,157
private function reconnect ( ) { $ auto = $ this -> _auto_reconnect ; $ this -> disconnect ( ) ; $ this -> auto_reconnect = $ auto ; $ this -> connect ( ) ; }
Reconnect to the DataSift stream
3,158
public function getInterfaceTrans ( ) { $ locale = config ( 'app.locale' ) ; $ file = config ( 'crude.defaultInterfaceTrans' ) ; if ( $ file == 'CrudeCRUD::crude' ) { $ available = [ 'en' , 'pl' ] ; $ locale = in_array ( $ locale , $ available ) ? $ locale : 'en' ; } $ this -> interfaceTrans = array_merge ( \ Lang :: get ( $ file , [ ] , $ locale ) , $ this -> interfaceTrans ) ; return $ this -> interfaceTrans ; }
Gets the interface and api labels and messages .
3,159
public function setInterfaceTrans ( $ attr , $ value = null ) { if ( is_array ( $ attr ) ) $ this -> interfaceTrans = array_merge ( $ this -> interfaceTrans , $ attr ) ; else $ this -> interfaceTrans [ $ attr ] = $ value ; return $ this ; }
Sets the interface and api labels and messages .
3,160
protected function location ( $ url ) { $ response = $ this -> getResponse ( ) ; $ response -> getHeaders ( ) -> addHeaderLine ( 'Location' , $ url ) ; $ response -> setStatusCode ( 201 ) ; return $ response ; }
Returns a 201 response with a Location header
3,161
protected function setupSmarty ( ) { $ this -> smarty = new SmartyParser ; if ( $ this -> viewManager -> cachePath ) { $ this -> smarty -> setCacheDir ( $ this -> viewManager -> cachePath . 'smarty/' ) ; } }
Sets Smarty up
3,162
private function writeTrackPoints ( array $ trackPoints ) { $ points = array ( ) ; $ previousPoint = null ; foreach ( $ trackPoints as $ trackPoint ) { $ dateTime = clone $ trackPoint -> dateTime ( ) ; $ dateTime -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; $ distance = 0 ; if ( $ previousPoint !== null ) { $ distance = $ trackPoint -> distanceFromPoint ( $ previousPoint ) ; } $ point = array ( 'time' => $ dateTime -> format ( \ DateTime :: W3C ) , 'latitude' => $ trackPoint -> latitude ( ) , 'longitude' => $ trackPoint -> longitude ( ) , 'elevation' => $ trackPoint -> elevation ( ) , 'distance' => $ distance , 'extensions' => $ this -> writeExtensions ( $ trackPoint -> extensions ( ) ) ) ; $ previousPoint = $ trackPoint ; $ points [ ] = $ point ; } return $ points ; }
Write the track points into an array .
3,163
protected function createMethodsFromInterface ( $ interfaceName ) { if ( ! interface_exists ( $ interfaceName ) ) { return ; } $ refInterface = new \ ReflectionClass ( $ interfaceName ) ; $ methodsReflected = $ refInterface -> getMethods ( ) ; foreach ( $ methodsReflected as $ methodReflected ) { if ( $ this -> getMethodCollection ( ) -> exists ( $ methodReflected -> getName ( ) ) ) { continue ; } $ method = Method :: createFromReflection ( $ methodReflected ) ; $ this -> addMethod ( $ method ) ; } }
Creates methods from Interface .
3,164
protected function createMethodsFromAbstractClass ( $ abstractClass ) { if ( ! class_exists ( $ abstractClass ) ) { return ; } $ refExtends = new \ ReflectionClass ( $ abstractClass ) ; $ methodsRef = $ refExtends -> getMethods ( ) ; foreach ( $ methodsRef as $ methodRef ) { if ( ! $ methodRef -> isAbstract ( ) || $ this -> getMethodCollection ( ) -> exists ( $ methodRef -> getName ( ) ) ) { continue ; } $ method = Method :: createFromReflection ( $ methodRef ) ; $ this -> addMethod ( $ method ) ; } }
Creates methods from Abstract .
3,165
public function generateGettersAndSettersFromProperties ( ) { $ propertyIterator = $ this -> getPropertyCollection ( ) -> getIterator ( ) ; foreach ( $ propertyIterator as $ property ) { $ this -> getMethodCollection ( ) -> add ( Method :: createGetterFromProperty ( $ property ) ) ; $ this -> getMethodCollection ( ) -> add ( Method :: createSetterFromProperty ( $ property ) ) ; } }
Create all getters and setters from Property Collection .
3,166
protected function toStringType ( ) { $ type = 'class ' ; switch ( true ) { case $ this -> isInterface ( ) : $ type = 'interface ' ; break ; case $ this -> isAbstract ( ) : $ type = 'abstract class ' ; break ; case $ this -> isFinal ( ) : $ type = 'final class ' ; break ; case $ this -> isTrait ( ) : $ type = 'trait ' ; } return $ type ; }
Get string based on type set .
3,167
public function log ( $ message ) { if ( null !== $ this -> logger ) { $ logger = $ this -> logger ; $ logger ( $ message ) ; } }
Adds a message to the logger .
3,168
private function requiresLogin ( ) : bool { if ( $ this -> requiresLogin ) { return true ; } $ this -> requiresLogin = $ this -> callbackAnnotatedWith -> requiresLogin ( ) ; return $ this -> requiresLogin ; }
checks whether login is required
3,169
public function requiredRole ( ) { if ( null === $ this -> requiredRole ) { $ this -> requiredRole = $ this -> callbackAnnotatedWith -> requiredRole ( ) ; } return $ this -> requiredRole ; }
returns required role for this route
3,170
public function satisfiedByRoles ( Roles $ roles = null ) : bool { if ( null === $ roles ) { return false ; } if ( $ this -> callbackAnnotatedWith -> rolesAware ( ) ) { return true ; } return $ roles -> contain ( $ this -> requiredRole ( ) ) ; }
checks whether route is satisfied by the given roles
3,171
public function jsonSerialize ( ) : array { $ data = [ 'required' => $ this -> requiresAuth ( ) ] ; if ( $ this -> requiresAuth ( ) ) { $ data [ 'requiresLogin' ] = $ this -> requiresLogin ( ) ; } if ( $ this -> requiresRoles ( ) ) { $ data [ 'requiresRoles' ] = true ; $ data [ 'requiredRole' ] = $ this -> requiredRole ( ) ; } return $ data ; }
returns data suitable for encoding to JSON
3,172
public function addComment ( $ id , $ status ) { if ( $ status == 0 ) { return ; } $ comment = get_comment ( $ id ) ; $ this -> updateHtml ( $ comment -> comment_post_ID ) ; wp_safe_redirect ( get_permalink ( $ comment -> comment_post_ID ) ) ; exit ( ) ; }
Updates static HTML after an approved comment is added .
3,173
public function load ( ) { if ( $ _SERVER [ 'REQUEST_METHOD' ] !== 'GET' ) { return ; } $ file = $ _SERVER [ 'REQUEST_URI' ] . 'index.html' ; if ( is_file ( $ this -> destination . $ file ) ) { $ contents = file_get_contents ( $ this -> destination . $ file ) ; do_action ( 'staticwp_pre_cache_hit' , $ _SERVER [ 'REQUEST_URI' ] ) ; echo apply_filters ( 'staticwp_cache_hit_contents' , $ contents ) ; do_action ( 'staticwp_post_cache_hit' , $ _SERVER [ 'REQUEST_URI' ] ) ; exit ( ) ; } else { do_action ( 'staticwp_cache_miss' , $ _SERVER [ 'REQUEST_URI' ] ) ; } }
Presents a compiled static HTML file when present .
3,174
public function updateHtml ( $ id , $ post = null ) { if ( $ post != null && $ post -> post_status != 'publish' ) { return ; } $ permalink = get_permalink ( $ id ) ; $ uri = substr ( $ permalink , strlen ( get_option ( 'home' ) ) ) ; $ filename = $ this -> destination . $ uri . 'index.html' ; $ dir = $ this -> destination . $ uri ; if ( ! is_dir ( $ dir ) ) { wp_mkdir_p ( $ dir ) ; } if ( is_file ( $ filename ) ) { unlink ( $ filename ) ; } $ curl = curl_init ( $ permalink ) ; curl_setopt ( $ curl , CURLOPT_HEADER , false ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; $ data = null ; if ( ( $ data = curl_exec ( $ curl ) ) === false ) { throw new Exception ( sprintf ( 'Curl error: %s' , curl_error ( $ curl ) ) ) ; } curl_close ( $ curl ) ; do_action ( 'staticwp_pre_cache_update' , $ id ) ; file_put_contents ( $ filename , apply_filters ( 'staticwp_cache_update_contents' , $ data , $ id ) ) ; do_action ( 'staticwp_post_cache_update' , $ id ) ; }
Updates the static HTML for a post .
3,175
protected function resolveDestination ( ) { $ dir = '' ; $ uploads = wp_upload_dir ( ) ; if ( isset ( $ uploads [ 'basedir' ] ) ) { $ dir = $ uploads [ 'basedir' ] . '/' . $ this -> plugin . '/_site' ; } else { $ dir = WP_CONTENT_DIR . '/uploads/' . $ this -> plugin . '/_site' ; } return apply_filters ( 'staticwp_cache_destination' , $ dir ) ; }
Recursively deletes a directory and its contents .
3,176
protected function initialize ( ) { include parent :: getConfigFilePath ( ) ; if ( ! isset ( $ configuration ) || ! is_array ( $ configuration ) ) { throw new WURFL_WURFLException ( "Configuration array must be defined in the configuraiton file" ) ; } $ this -> init ( $ configuration ) ; }
Initialize class - gets called from the parent constructor
3,177
public function getRepository ( $ modelName , $ collection = null ) { return $ this -> repositoryFactory -> getRepository ( $ this , $ modelName , $ collection ) ; }
Allow to get repository for specified model
3,178
public function persist ( $ object , $ collection = null ) { $ repository = $ this -> getRepository ( get_class ( $ object ) , $ collection ) ; $ repository -> getClassMetadata ( ) -> getEventManager ( ) -> execute ( EventManager :: EVENT_PRE_PERSIST , $ object ) ; $ this -> addObject ( $ object , ObjectManager :: OBJ_NEW , $ repository ) ; $ repository -> getClassMetadata ( ) -> getEventManager ( ) -> execute ( EventManager :: EVENT_POST_PERSIST , $ object ) ; return $ this ; }
Persist object in document manager
3,179
public function refresh ( & $ object ) { if ( ! isset ( $ this -> objectsRepository [ spl_object_hash ( $ object ) ] ) ) { return ; } $ repository = $ this -> objectsRepository [ spl_object_hash ( $ object ) ] ; $ id = $ repository -> getHydrator ( ) -> unhydrate ( $ object ) [ "_id" ] ; $ projection = $ repository -> getLastProjection ( $ object ) ; $ collection = $ repository -> getCollection ( ) ; $ hydrator = $ repository -> getHydrator ( ) ; if ( null !== ( $ data = $ collection -> findOne ( [ '_id' => $ id ] , [ 'projection' => $ projection ] ) ) ) { $ hydrator -> hydrate ( $ object , $ data ) ; $ repository -> cacheObject ( $ object ) ; } else { $ object = null ; } return $ object ; }
Refresh an object to last MongoDB values
3,180
private function perfomOperations ( $ insert , $ update , $ remove ) { $ bulkOperations = [ ] ; foreach ( $ insert as $ id => $ document ) { $ repository = $ this -> getObjectRepository ( $ document ) ; if ( $ repository instanceof GridFSRepository ) { $ repository -> insertOne ( $ document ) ; unset ( $ insert [ $ id ] ) ; } else { $ query = $ repository -> insertOne ( $ document , [ 'getQuery' => true ] ) ; $ repositoryId = spl_object_hash ( $ repository ) ; $ bulkOperations [ $ repositoryId ] = isset ( $ bulkOperations [ $ repositoryId ] ) ? $ bulkOperations [ $ repositoryId ] : $ repository -> createBulkWriteQuery ( ) ; $ bulkOperations [ $ repositoryId ] -> addQuery ( $ query ) ; } } foreach ( $ update as $ id => $ document ) { $ repository = $ this -> getObjectRepository ( $ document ) ; $ query = $ repository -> updateOne ( $ document , [ ] , [ 'getQuery' => true ] ) ; $ repositoryId = spl_object_hash ( $ repository ) ; $ bulkOperations [ $ repositoryId ] = isset ( $ bulkOperations [ $ repositoryId ] ) ? $ bulkOperations [ $ repositoryId ] : $ repository -> createBulkWriteQuery ( ) ; $ bulkOperations [ $ repositoryId ] -> addQuery ( $ query ) ; } foreach ( $ remove as $ id => $ document ) { $ repository = $ this -> getObjectRepository ( $ document ) ; if ( $ repository instanceof GridFSRepository ) { $ repository -> deleteOne ( $ document ) ; unset ( $ remove [ $ id ] ) ; } else { $ query = $ repository -> deleteOne ( $ document , [ 'getQuery' => true ] ) ; $ repositoryId = spl_object_hash ( $ repository ) ; $ bulkOperations [ $ repositoryId ] = $ bulkOperations [ $ repositoryId ] ?? $ repository -> createBulkWriteQuery ( ) ; $ bulkOperations [ $ repositoryId ] -> addQuery ( $ query ) ; } } foreach ( array_merge ( $ insert , $ update , $ remove ) as $ id => $ document ) { $ repository = $ this -> getObjectRepository ( $ document ) ; $ repository -> getClassMetadata ( ) -> getEventManager ( ) -> execute ( EventManager :: EVENT_PRE_FLUSH , $ document ) ; } foreach ( $ bulkOperations as $ bulkOperation ) { $ bulkOperation -> execute ( ) ; } foreach ( array_merge ( $ insert , $ update ) as $ id => $ document ) { $ repository = $ this -> getObjectRepository ( $ document ) ; $ repository -> getClassMetadata ( ) -> getEventManager ( ) -> execute ( EventManager :: EVENT_POST_FLUSH , $ document ) ; $ repository -> cacheObject ( $ document ) ; } $ this -> flush ( ) ; }
Perfom operation on collections
3,181
public function generate ( ) { $ toggle = clone $ this -> toggle ; $ toggle -> addAttributes ( $ this -> attributes ) ; $ toggle -> setLabel ( $ toggle -> getLabel ( ) . ' ' . Bootstrap :: getConfigVar ( 'dropdown.toggle' ) ) ; return sprintf ( '%s<ul class="dropdown-menu">%s%s</ul>' , $ toggle , PHP_EOL , $ this -> generateChildren ( ) ) ; }
Generate the dropdown .
3,182
protected function updateTimestamps ( ) { $ time = $ this -> freshTimestamp ( ) ; $ gmt = new Carbon ; $ gmt -> timestamp = $ time -> timestamp - ( get_option ( 'gmt_offset' ) * HOUR_IN_SECONDS ) ; if ( ! $ this -> isDirty ( static :: UPDATED_AT ) ) { $ this -> setUpdatedAt ( $ time ) ; } if ( ! $ this -> exists && ! $ this -> isDirty ( static :: CREATED_AT ) ) { $ this -> setCreatedAt ( $ time ) ; } if ( ! $ this -> isDirty ( 'post_modified_gmt' ) ) { $ this -> post_modified_gmt = $ gmt ; } if ( ! $ this -> exists && ! $ this -> isDirty ( 'post_gmt' ) ) { $ this -> post_gmt = $ gmt ; } }
Update the creation and update timestamps ; WordPress has two timestamp fields obviously .
3,183
public function buildName ( $ pipeline , $ configuration ) { $ name = is_array ( $ configuration ) && array_key_exists ( "name" , $ configuration ) ? $ configuration [ "name" ] : null ; if ( empty ( $ name ) ) { throw new InvalidConfigurationException ( "Missing pipeline name" ) ; } $ pipeline -> setName ( $ name ) ; }
Set the pipeline name . Empty name will throw an exception
3,184
public function buildAction ( $ pipeline , $ actionName , $ actionConfiguration = [ ] ) { $ triggeredByEvents = is_array ( $ actionConfiguration ) && array_key_exists ( "triggered_by_events" , $ actionConfiguration ) ? $ actionConfiguration [ "triggered_by_events" ] : [ ] ; if ( empty ( $ triggeredByEvents ) ) { $ triggeredByEvents = [ $ actionName ] ; } $ action = new Action ( $ actionName ) ; $ actionCreator = new ActionCreator ( $ action ) ; foreach ( $ triggeredByEvents as $ triggeredByEvent ) { $ event = $ pipeline -> hasIncomingEvent ( $ triggeredByEvent ) ? $ pipeline -> getIncomingEvent ( $ triggeredByEvent ) : new Event ( $ triggeredByEvent ) ; $ actionCreator -> addTriggeredByEvent ( $ event ) ; $ pipeline -> addIncomingEvent ( $ event ) ; } $ pipeline -> addAction ( $ action ) ; $ pipeline -> addActionCreator ( $ actionCreator ) ; }
Add actions inside Pipeline based on the configuration provided by Symfony Configuration
3,185
public function removePermission ( $ permission ) { if ( $ this -> hasPermission ( $ permission ) ) { $ index = array_search ( $ permission , $ this -> permissions ) ; unset ( $ this -> permissions [ $ index ] ) ; } return $ this ; }
Remove permission from ermission container
3,186
public function select ( $ select , $ filters = array ( ) ) { if ( false === is_array ( $ select ) ) { $ newSelect = [ $ select => $ filters ] ; } else { $ newSelect = [ ] ; foreach ( $ select as $ key => $ filters ) { if ( true === is_int ( $ key ) || '*' === $ key ) { $ newSelect [ $ filters ] = [ ] ; } else { $ newSelect [ $ key ] = $ filters ; } } } $ this -> select = $ newSelect ; return $ this ; }
The names of the fields that should be selected by the query .
3,187
public function where ( $ key , $ value , $ operator = '=' , $ filters = array ( ) ) { $ this -> where [ ] = [ 'key' => $ key , 'value' => $ value , 'operator' => $ operator , 'filters' => $ filters ] ; return $ this ; }
Add a clause that elements have to match to be returned .
3,188
protected function evaluateWhere ( array $ item ) { $ result = true ; foreach ( $ this -> where as $ clause ) { $ result = $ result && $ this -> whereEvaluation -> evaluate ( $ item , $ clause ) ; } return $ result ; }
Evaluates the where clauses on the given item .
3,189
protected function evaluateSelect ( array $ item , $ scalar ) { $ resultItem = [ ] ; foreach ( $ item as $ key => $ value ) { if ( true === isset ( $ this -> select [ '*' ] ) || true === isset ( $ this -> select [ $ key ] ) ) { if ( true === isset ( $ this -> select [ $ key ] ) ) { $ value = $ this -> selectEvaluation -> evaluate ( $ value , $ this -> select [ $ key ] ) ; } if ( true === $ scalar ) { $ resultItem = $ value ; } else { $ resultItem [ $ key ] = $ value ; } } } return $ resultItem ; }
Evaluates the select .
3,190
public function moveToArchive ( $ bulk = false ) { $ this -> connection -> transact ( function ( ) use ( $ bulk ) { $ this -> triggerEvent ( 'on_before_move_to_archive' , [ $ bulk ] ) ; if ( $ bulk && method_exists ( $ this , 'setOriginalIsArchived' ) ) { $ this -> setOriginalIsArchived ( $ this -> getIsArchived ( ) ) ; } $ this -> setIsArchived ( true ) ; $ this -> save ( ) ; $ this -> triggerEvent ( 'on_after_move_to_archive' , [ $ bulk ] ) ; } ) ; }
Move to archive .
3,191
public function restoreFromArchive ( $ bulk = false ) { if ( $ this -> getIsArchived ( ) ) { $ this -> connection -> transact ( function ( ) use ( $ bulk ) { $ this -> triggerEvent ( 'on_before_restore_from_archive' , [ $ bulk ] ) ; if ( $ bulk && method_exists ( $ this , 'getOriginalIsArchived' ) && method_exists ( $ this , 'setOriginalIsArchived' ) ) { $ this -> setIsArchived ( $ this -> getOriginalIsArchived ( ) ) ; $ this -> setOriginalIsArchived ( false ) ; } else { $ this -> setIsArchived ( false ) ; } $ this -> save ( ) ; $ this -> triggerEvent ( 'on_after_restore_from_archive' , [ $ bulk ] ) ; } ) ; } }
Restore from archive .
3,192
private function requestAPI ( $ method , $ url , array $ options = [ ] ) { try { return $ this -> sendRequest ( ( string ) $ method , ( string ) $ url , $ options ) ; } catch ( SessionWasExpiredException $ e ) { return $ this -> sendRequest ( ( string ) $ method , ( string ) $ url , $ options ) ; } catch ( ClientException $ e ) { throw new BunqException ( $ e ) ; } }
Handles the API Calling .
3,193
public function logWarning ( $ message , $ attachment = null ) { $ this -> messages [ ] = "warning: " . $ message . print_r ( $ attachment , true ) ; }
Log message as warning level
3,194
public function logError ( $ message , $ attachment = null ) { $ this -> messages [ ] = "error: " . $ message . print_r ( $ attachment , true ) ; }
Log message as error level
3,195
public function getLastMessage ( ) { $ messagesClone = $ this -> messages ; $ keys = array_keys ( $ messagesClone ) ; $ key = array_pop ( $ keys ) ; return $ this -> messages [ $ key ] ; }
Get most recent log entry as string
3,196
public function filterByPermissionId ( $ permissionId = null , $ comparison = null ) { if ( is_array ( $ permissionId ) ) { $ useMinMax = false ; if ( isset ( $ permissionId [ 'min' ] ) ) { $ this -> addUsingAlias ( RolePermissionTableMap :: COL_PERMISSION_ID , $ permissionId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ permissionId [ 'max' ] ) ) { $ this -> addUsingAlias ( RolePermissionTableMap :: COL_PERMISSION_ID , $ permissionId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( RolePermissionTableMap :: COL_PERMISSION_ID , $ permissionId , $ comparison ) ; }
Filter the query on the permission_id column
3,197
public function filterByRole ( $ role , $ comparison = null ) { if ( $ role instanceof \ Alchemy \ Component \ Cerberus \ Model \ Role ) { return $ this -> addUsingAlias ( RolePermissionTableMap :: COL_ROLE_ID , $ role -> getId ( ) , $ comparison ) ; } elseif ( $ role instanceof ObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( RolePermissionTableMap :: COL_ROLE_ID , $ role -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterByRole() only accepts arguments of type \Alchemy\Component\Cerberus\Model\Role or Collection' ) ; } }
Filter the query by a related \ Alchemy \ Component \ Cerberus \ Model \ Role object
3,198
public function usePermissionQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinPermission ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Permission' , '\Alchemy\Component\Cerberus\Model\PermissionQuery' ) ; }
Use the Permission relation Permission object
3,199
private function createNewDynamicContainerBlockIfNeeded ( $ dynamicTriggerValue ) { if ( ! isset ( $ this -> dynamicContainerBlock ) && $ dynamicTriggerValue !== null ) { $ this -> dynamicContainerBlock = $ this -> createElement ( 'div' ) ; $ this -> dynamicContainerBlock -> setAttribute ( 'data-dynamic-form' , $ this -> dynamicFormParentName ) ; $ this -> dynamicContainerBlock -> setAttribute ( 'data-dynamic-form-trigger-value' , $ dynamicTriggerValue ) ; $ this -> dynamicContainerBlock -> setAttribute ( 'class' , 'dynamic-form-block trigger' . $ this -> dynamicFormParentName ) ; $ this -> dynamicContainerBlock -> setAttribute ( 'id' , $ this -> dynamicFormParentName . $ dynamicTriggerValue ) ; $ this -> dynamicFormVisible === false ? $ this -> dynamicContainerBlock -> setAttribute ( 'style' , 'display: none;' ) : null ; } }
This creates a containing div for dynamic fields which appear only on another fields value