idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
16,200
public function isLanguageIncludedInRoutes ( $ state = null ) { if ( isset ( $ state ) ) { $ this -> languageIncludedInRoutes = ( bool ) $ state ; } return $ this -> languageIncludedInRoutes ; }
Determine if languages are included in a route .
16,201
protected function applyCallback ( stdClass $ schema ) : stdClass { if ( is_callable ( $ this -> callback ) ) { $ result = call_user_func_array ( $ this -> callback , [ Convert :: objectToArray ( $ schema ) ] ) ; if ( is_null ( $ result ) ) { throw new InvalidArgumentException ( 'Callback returned `null`. Did you forge...
Apply the optional callback .
16,202
public function checkFieldsActivation ( ) { foreach ( $ this -> getFormObject ( ) -> getConfiguration ( ) -> getFields ( ) as $ field ) { if ( false === $ this -> result -> fieldIsDeactivated ( $ field ) ) { $ this -> checkFieldActivation ( $ field ) ; } } return $ this ; }
This function will take care of deactivating the validation for fields that do not match their activation condition .
16,203
public function addCache ( CacheInterface $ cache ) { $ this -> cacheMap [ $ cache -> getName ( ) ] = $ cache ; $ this -> cacheNames [ ] = $ cache -> getName ( ) ; }
Adds a Cache
16,204
public function query ( $ cql , array $ values = [ ] , $ consistency = ConsistencyEnum :: CONSISTENCY_QUORUM ) { if ( $ this -> batchQuery && in_array ( substr ( $ cql , 0 , 6 ) , [ 'INSERT' , 'UPDATE' , 'DELETE' ] ) ) { $ this -> appendQueryToStack ( $ cql , $ values ) ; return true ; } if ( empty ( $ values ) ) { $ r...
Send query into database
16,205
protected function getFormzConfiguration ( ) { $ rootConfigurationArray = $ this -> getFormObject ( ) -> getConfiguration ( ) -> getRootConfiguration ( ) -> toArray ( ) ; $ cleanFormzConfigurationArray = [ 'view' => $ rootConfigurationArray [ 'view' ] ] ; return ArrayService :: get ( ) -> arrayToJavaScriptJson ( $ clea...
Returns a JSON array containing the FormZ configuration .
16,206
private function setDefaultConfiguration ( ) : void { $ this -> parameterBag -> set ( 'app.devmode' , false ) ; $ this -> parameterBag -> set ( 'container.dumper.inline_class_loader' , true ) ; $ this -> config -> addPass ( $ this -> parameterBag ) ; }
Configures the default parameters and appends the handler
16,207
public function dump ( ) { $ methods = $ this -> specification -> getMethods ( ) ; $ result = '<?php/* * This file is part of PHP Selenium Library. * (c) Alexandre Salomé <alexandre.salome@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source...
Dumps to source code
16,208
protected function dumpMethod ( Method $ method ) { $ builder = new MethodBuilder ( ) ; $ documentation = $ method -> getDescription ( ) . "\n\n" ; $ signature = array ( ) ; foreach ( $ method -> getParameters ( ) as $ parameter ) { $ builder -> addParameter ( $ parameter -> getName ( ) ) ; $ documentation .= "@param s...
Dumps a method .
16,209
private function createCache ( array $ config , ContainerBuilder $ container ) { $ type = $ config [ 'type' ] ; if ( array_key_exists ( $ type , $ this -> cacheFactories ) ) { $ id = sprintf ( 'tbbc_cache.%s_cache' , $ config [ 'name' ] ) ; $ this -> cacheFactories [ $ type ] -> create ( $ container , $ id , $ config )...
Creates a single cache service
16,210
private function createCacheFactories ( ) { if ( null !== $ this -> cacheFactories ) { return $ this -> cacheFactories ; } $ tempContainer = new ContainerBuilder ( ) ; $ loader = new Loader \ XmlFileLoader ( $ tempContainer , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'cache_factories.x...
Creates the cache factories
16,211
public function sanitizeValidatorResult ( Result $ result , $ validationName ) { $ newResult = new Result ; $ this -> sanitizeValidatorResultMessages ( 'error' , $ result -> getFlattenedErrors ( ) , $ newResult , $ validationName ) ; $ this -> sanitizeValidatorResultMessages ( 'warning' , $ result -> getFlattenedWarnin...
This function will go through all errors warnings and notices and check if they are instances of FormzMessageInterface . If not they are converted in order to have more informations that are needed later .
16,212
public function filterMessages ( array $ messages , array $ supportedMessages , $ canCreateNewMessages = false ) { $ addValueToArray = function ( array & $ a ) { foreach ( $ a as $ k => $ v ) { if ( false === isset ( $ v [ 'value' ] ) ) { $ a [ $ k ] [ 'value' ] = '' ; } if ( false === isset ( $ v [ 'extension' ] ) ) {...
Will return an array by considering the supported messages and filling the supported ones with the given values .
16,213
public function render ( ElementInterface $ formElement , $ value = '' , $ attributes = array ( ) ) { $ this -> checkDependencies ( ) ; $ config = $ this -> di -> get ( 'config' ) ; if ( empty ( $ this -> templateName ) && ! empty ( $ config -> forms -> templates -> default_name ) ) { $ this -> templateName = $ config ...
Render form element with current templatePath and templateName . If templatePath or templateName are not set render default .
16,214
private function checkDependencies ( ) { if ( ! ( $ this -> di instanceof DiInterface ) ) { throw new DiNotSetException ( ) ; } if ( ! $ this -> di -> has ( 'view' ) ) { throw new ViewNotSetException ( ) ; } if ( ! $ this -> di -> has ( 'assets' ) ) { throw new InvalidAssetsManagerException ( ) ; } }
Check for required DI services .
16,215
protected function getFilePath ( string $ path ) : string { if ( empty ( $ path ) ) { $ path = $ this -> fileName ; } return $ path ; }
Get file path string
16,216
protected function getDistributionFilePath ( string $ path ) : string { $ postfix = self :: DIST_FILENAME_POSTFIX ; if ( empty ( $ path ) ) { $ path = $ this -> fileName ; } $ pathinfo = pathinfo ( $ path ) ; $ postfixIndex = strlen ( $ pathinfo [ 'filename' ] ) - strlen ( $ postfix ) ; $ isDistributionFile = substr ( ...
Get file path string for the corresponding distribution file
16,217
protected function validatePath ( string $ path ) : void { if ( empty ( $ path ) ) { $ this -> fail ( new InvalidArgumentException ( "Path is not specified" ) ) ; } if ( ! is_string ( $ path ) ) { $ this -> fail ( new InvalidArgumentException ( "Path is not a string" ) ) ; } }
Validate path string
16,218
protected function addFileExtension ( string $ path ) : string { $ extension = pathinfo ( $ path , PATHINFO_EXTENSION ) ; if ( empty ( $ extension ) ) { $ path .= $ this -> extension ; } return $ path ; }
Add default extension if path doesn t have one
16,219
protected function getSubmittedFormValues ( ) { $ result = [ ] ; $ formName = $ this -> getFormObject ( ) -> getName ( ) ; $ originalRequest = $ this -> getControllerContext ( ) -> getRequest ( ) -> getOriginalRequest ( ) ; if ( null !== $ originalRequest && $ originalRequest -> hasArgument ( $ formName ) ) { $ result ...
Will fetch the values of the fields of the submitted form if a form has been submitted .
16,220
private function encryptAndRenderCookies ( $ resCookies ) { $ renderable = [ ] ; foreach ( $ resCookies as $ cookie ) { if ( is_string ( $ cookie ) ) { $ cookie = SetCookie :: fromSetCookieString ( $ cookie ) ; } if ( $ cookie instanceof SetCookie ) { $ val = $ cookie -> getValue ( ) ; if ( $ val instanceof OpaquePrope...
Parse all cookies set on the response
16,221
public function formatTimepoint ( $ time , $ format ) { if ( $ time instanceof TimePoint ) { return $ time -> format ( $ format , $ this -> displayTimezone ) ; } if ( $ time instanceof DateTime ) { $ formatted = clone $ time ; $ formatted -> setTimezone ( new DateTimeZone ( $ this -> displayTimezone ) ) ; return $ form...
Format a DateTime or TimePoint . Invalid values will output an empty string .
16,222
public function processRequest ( RequestInterface $ request , ResponseInterface $ response ) { $ this -> result = new AjaxResult ; try { $ this -> processRequestParent ( $ request , $ response ) ; } catch ( Exception $ exception ) { if ( false === $ this -> protectedRequestMode ) { throw $ exception ; } $ this -> resul...
Will process the request but also prevent any external message to be displayed and catch any exception that could occur during the validation .
16,223
protected function initializeActionMethodValidators ( ) { $ this -> initializeActionMethodValidatorsParent ( ) ; $ request = $ this -> getRequest ( ) ; if ( false === $ request -> hasArgument ( 'name' ) ) { throw MissingArgumentException :: ajaxControllerNameArgumentNotSet ( ) ; } if ( false === $ request -> hasArgumen...
Will take care of adding a new argument to the request based on the form name and the form class name found in the request arguments .
16,224
public function runAction ( $ name , $ className , $ fieldName , $ validatorName ) { $ this -> formName = $ name ; $ this -> formClassName = $ className ; $ this -> fieldName = $ fieldName ; $ this -> validatorName = $ validatorName ; $ this -> form = $ this -> getForm ( ) ; $ this -> formObject = $ this -> getFormObje...
Main action that will process the field validation .
16,225
protected function normalize ( array $ data , string $ prefix = null ) : array { if ( $ prefix ) { $ prefix .= '.' ; } $ result = [ ] ; foreach ( $ data as $ item ) { $ value = [ 'label' => ( string ) $ item [ 'label' ] , 'inactive' => ( bool ) $ item [ 'inactive' ] ] ; if ( ! empty ( $ item [ 'children' ] ) ) { $ valu...
Method that restructures list options csv data for better handling .
16,226
protected function filter ( array $ data ) : array { $ result = [ ] ; foreach ( $ data as $ key => $ value ) { if ( $ value [ 'inactive' ] ) { continue ; } $ result [ $ key ] = $ value ; if ( isset ( $ value [ 'children' ] ) ) { $ result [ $ key ] [ 'children' ] = $ this -> filter ( $ value [ 'children' ] ) ; } } retur...
Method that filters list options excluding non - active ones
16,227
protected function flatten ( array $ data ) : array { $ result = [ ] ; foreach ( $ data as $ key => $ value ) { $ item = [ 'label' => $ value [ 'label' ] , 'inactive' => $ value [ 'inactive' ] ] ; $ result [ $ key ] = $ item ; if ( isset ( $ value [ 'children' ] ) ) { $ result = array_merge ( $ result , $ this -> flatt...
Flatten list options .
16,228
protected function setOptions ( array $ options = [ ] ) : void { $ this -> options = $ options ; $ this -> configName = empty ( $ options [ 'cacheConfig' ] ) ? static :: DEFAULT_CONFIG : ( string ) $ options [ 'cacheConfig' ] ; $ this -> skipCache = empty ( $ this -> options [ 'cacheSkip' ] ) ? false : ( bool ) $ this ...
Set cache options
16,229
public function getKey ( array $ params ) : string { $ params [ ] = $ this -> options ; $ params = json_encode ( $ params ) ; $ params = $ params ? : microtime ( ) ; $ params = md5 ( $ params ) ; $ result = $ this -> name . '_' . $ params ; return $ result ; }
Generate cache key
16,230
public function readFrom ( string $ key ) { $ result = false ; if ( $ this -> skipCache ( ) ) { $ this -> warnings [ ] = 'Skipping read from cache' ; return $ result ; } $ cachedData = CakeCache :: read ( $ key , $ this -> getConfig ( ) ) ; if ( ! $ this -> isValidCache ( $ cachedData ) ) { CakeCache :: delete ( $ key ...
Read cached value from a given key
16,231
protected function getLogicalResult ( callable $ logicalAndFunction , callable $ logicalOrFunction ) { switch ( $ this -> operator ) { case ConditionParser :: LOGICAL_AND : $ result = call_user_func ( $ logicalAndFunction ) ; break ; case ConditionParser :: LOGICAL_OR : $ result = call_user_func ( $ logicalOrFunction )...
Global function to get the result of a logical operation the processor does not matter .
16,232
protected function processLogicalOrPhp ( PhpConditionDataObject $ dataObject ) { return $ this -> leftNode -> getPhpResult ( $ dataObject ) || $ this -> rightNode -> getPhpResult ( $ dataObject ) ; }
Will process a logical or operation on the two given nodes .
16,233
public function requireDefaultRecords ( ) { parent :: requireDefaultRecords ( ) ; if ( ! self :: config ( ) -> create_default_pages ) { return ; } if ( ! file_exists ( ASSETS_PATH ) ) { mkdir ( ASSETS_PATH ) ; } $ code = self :: $ defaults [ 'ErrorCode' ] ; $ page = UtilityPage :: get ( ) -> filter ( 'ErrorCode' , $ co...
Create default Utility Page setup Ensures that there is always a 503 Utility page by checking if there s an instance of ErrorPage with a 503 error code . If there is not one is created when the DB is built .
16,234
public static function get_top_level_templates ( ) { $ ss_templates_array = array ( ) ; $ current_theme_path = THEMES_PATH . '/' . Config :: inst ( ) -> get ( 'SSViewer' , 'theme' ) ; $ search_dir_array = array ( MAINTENANCE_MODE_PATH . '/templates' , $ current_theme_path . '/templates' ) ; foreach ( $ search_dir_array...
This function returns an array of top - level theme templates
16,235
public function getInstanceFromClassName ( $ className , $ name ) { if ( false === class_exists ( $ className ) ) { throw ClassNotFoundException :: wrongFormClassName ( $ className ) ; } if ( false === in_array ( FormInterface :: class , class_implements ( $ className ) ) ) { throw InvalidArgumentTypeException :: wrong...
Will create an instance of FormObject based on a class which implements the interface FormInterface .
16,236
protected function createInstance ( $ className , $ name ) { $ formConfiguration = $ this -> typoScriptService -> getFormConfiguration ( $ className ) ; $ instance = Core :: instantiate ( FormObject :: class , $ className , $ name , $ formConfiguration ) ; $ this -> insertObjectProperties ( $ instance ) ; $ instance ->...
Creates and initializes a new FormObject instance .
16,237
protected function insertObjectProperties ( FormObject $ instance ) { $ className = $ instance -> getClassName ( ) ; $ reflectionService = GeneralUtility :: makeInstance ( ReflectionService :: class ) ; $ reflectionProperties = $ reflectionService -> getClassPropertyNames ( $ className ) ; $ classReflection = new \ Ref...
Will insert all the accessible properties of the given instance .
16,238
public function addTerm ( $ term_id ) { $ term = ( $ term_id instanceof Term ) ? $ term_id : Term :: findOrFail ( $ term_id ) ; $ term_relation = [ 'term_id' => $ term -> id , 'vocabulary_id' => $ term -> vocabulary_id , ] ; return $ this -> related ( ) -> save ( new TermRelation ( $ term_relation ) ) ; }
Add an existing term to the inheriting model
16,239
public function hasTerm ( $ term_id ) { $ term = ( $ term_id instanceof Term ) ? $ term_id : Term :: findOrFail ( $ term_id ) ; $ term_relation = [ 'term_id' => $ term -> id , 'vocabulary_id' => $ term -> vocabulary_id , ] ; return ( $ this -> related ( ) -> where ( 'term_id' , $ term_id ) -> count ( ) ) ? TRUE : FALSE...
Check if the Model instance has the passed term as an existing relation
16,240
public function getTermsByVocabularyName ( $ name ) { $ vocabulary = \ Taxonomy :: getVocabularyByName ( $ name ) ; return $ this -> related ( ) -> where ( 'vocabulary_id' , $ vocabulary -> id ) -> get ( ) ; }
Get all the terms for a given vocabulary that are linked to the current Model .
16,241
public function getTermsByVocabularyNameAsArray ( $ name ) { $ vocabulary = \ Taxonomy :: getVocabularyByName ( $ name ) ; $ term_relations = $ this -> related ( ) -> where ( 'vocabulary_id' , $ vocabulary -> id ) -> get ( ) ; $ data = [ ] ; foreach ( $ term_relations as $ term_relation ) { $ data [ $ term_relation -> ...
Get all the terms for a given vocabulary that are linked to the current Model as a key value pair array .
16,242
public function removeTerm ( $ term_id ) { $ term_id = ( $ term_id instanceof Term ) ? $ term_id -> id : $ term_id ; return $ this -> related ( ) -> where ( 'term_id' , $ term_id ) -> delete ( ) ; }
Unlink the given term with the current model object
16,243
public function applyBehavioursOnSubmittedForm ( ControllerContext $ controllerContext ) { if ( $ this -> formObject -> formWasSubmitted ( ) ) { $ request = $ controllerContext -> getRequest ( ) -> getOriginalRequest ( ) ; $ formName = $ this -> formObject -> getName ( ) ; if ( $ request && $ request -> hasArgument ( $...
Will loop on the submitted form fields and apply behaviours if their configuration contains .
16,244
public function getActivationConditionTreeForField ( Field $ field ) { $ key = $ field -> getName ( ) ; if ( false === array_key_exists ( $ key , $ this -> fieldsTrees ) ) { $ this -> fieldsTrees [ $ key ] = $ this -> getConditionTree ( $ field -> getActivation ( ) ) ; } $ this -> fieldsTrees [ $ key ] -> injectDepende...
Returns the condition tree for a given field instance giving access to CSS JavaScript and PHP transpiled results .
16,245
public function getActivationConditionTreeForValidation ( Validation $ validation ) { $ key = $ validation -> getParentField ( ) -> getName ( ) . '->' . $ validation -> getName ( ) ; if ( false === array_key_exists ( $ key , $ this -> validationsTrees ) ) { $ this -> validationsTrees [ $ key ] = $ this -> getConditionT...
Returns the condition tree for a given validation instance giving access to CSS JavaScript and PHP transpiled results .
16,246
public function calculateAllTrees ( ) { $ fields = $ this -> formObject -> getConfiguration ( ) -> getFields ( ) ; foreach ( $ fields as $ field ) { $ this -> getActivationConditionTreeForField ( $ field ) ; foreach ( $ field -> getValidation ( ) as $ validation ) { $ this -> getActivationConditionTreeForValidation ( $...
Function that will calculate all trees from fields and their validation rules .
16,247
public function exceptionHandler ( $ e ) : void { $ this -> setError ( ( int ) $ e -> getCode ( ) , ( string ) $ e -> getMessage ( ) , ( string ) $ e -> getFile ( ) , ( int ) $ e -> getLine ( ) , ( string ) get_class ( $ e ) , $ e -> getTrace ( ) ) ; View :: render ( '500.php' , ( object ) $ this -> errors ) ; }
exception handler .
16,248
public function fatalHandler ( ) : void { $ errors = error_get_last ( ) ; if ( is_array ( $ errors ) ) { $ this -> setError ( ( int ) $ errors [ 'type' ] , ( string ) $ errors [ 'message' ] , ( string ) $ errors [ 'file' ] , ( int ) $ errors [ 'line' ] , 'FatalErrorException' ) ; View :: render ( '500.php' , ( object )...
error handler method .
16,249
public function migrateModels ( $ models ) { $ this -> set ( function ( $ c ) use ( $ models ) { $ c -> notice ( 'Preparing to migrate models' ) ; $ p = $ c -> app -> db ; foreach ( $ models as $ model ) { if ( ! is_object ( $ model ) ) { $ model = $ this -> factory ( $ model ) ; $ p -> add ( $ model ) ; } $ m = new \ ...
Provided with array of models perform migration for each of them .
16,250
public function getExtensionConfiguration ( $ configurationName ) { $ result = null ; $ extensionConfiguration = $ this -> getFullExtensionConfiguration ( ) ; if ( null === $ configurationName ) { $ result = $ extensionConfiguration ; } elseif ( ArrayUtility :: isValidPath ( $ extensionConfiguration , $ configurationNa...
Return the wanted extension configuration .
16,251
public function expireCookie ( ResponseInterface $ response , $ name ) { $ cookie = SetCookie :: createExpired ( $ name ) -> withMaxAge ( $ this -> configuration [ 'maxAge' ] ) -> withPath ( $ this -> configuration [ 'path' ] ) -> withDomain ( $ this -> configuration [ 'domain' ] ) -> withSecure ( $ this -> configurati...
Expire a cookie in the response .
16,252
protected function addError ( $ key , $ code , array $ arguments = [ ] , $ title = '' ) { $ message = $ this -> addMessage ( Error :: class , $ key , $ code , $ arguments , $ title ) ; $ this -> result -> addError ( $ message ) ; }
Creates a new validation error and adds it to the result .
16,253
protected function addWarning ( $ key , $ code , array $ arguments = [ ] , $ title = '' ) { $ message = $ this -> addMessage ( Warning :: class , $ key , $ code , $ arguments , $ title ) ; $ this -> result -> addWarning ( $ message ) ; }
Creates a new validation warning and adds it to the result .
16,254
protected function addNotice ( $ key , $ code , array $ arguments = [ ] , $ title = '' ) { $ message = $ this -> addMessage ( Notice :: class , $ key , $ code , $ arguments , $ title ) ; $ this -> result -> addNotice ( $ message ) ; }
Creates a new validation notice and adds it to the result .
16,255
public function addProperty ( $ name ) { if ( false === $ this -> hasProperty ( $ name ) ) { $ this -> properties [ ] = $ name ; $ this -> hashService -> resetHash ( ) ; } return $ this ; }
Registers a new property for this form .
16,256
protected function read ( $ length ) { if ( $ this -> length < $ length ) { throw new \ Exception ( 'Reading while at end of stream' ) ; } $ output = substr ( $ this -> data , 0 , $ length ) ; $ this -> data = substr ( $ this -> data , $ length ) ; $ this -> length -= $ length ; return $ output ; }
Read data from stream .
16,257
public function readInt ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) { $ length = $ this -> readShort ( ) ; return unpack ( 'l' , strrev ( $ this -> read ( $ length ) ) ) [ 1 ] ; } return unpack ( 'l' , strrev ( $ this -> read ( 4 ) ) ) [ 1 ] ; }
Read unsigned int .
16,258
function readBigInt ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) { $ length = $ this -> readShort ( ) ; } else { $ length = 8 ; } $ data = $ this -> read ( $ length ) ; $ arr = unpack ( 'N2' , $ data ) ; if ( PHP_INT_SIZE == 4 ) { $ hi = $ arr [ 1 ] ; $ lo = $ arr [ 2 ] ; $ isNeg = $ hi < 0 ; if ( $...
Read unsigned big int ;
16,259
public function readBytes ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) $ this -> readShort ( ) ; $ length = $ this -> readInt ( ) ; if ( $ length == - 1 ) return null ; return $ this -> read ( $ length ) ; }
Read bytes .
16,260
public function readUuid ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) $ this -> readShort ( ) ; $ uuid = '' ; $ data = $ this -> read ( 16 ) ; for ( $ i = 0 ; $ i < 16 ; ++ $ i ) { if ( $ i == 4 || $ i == 6 || $ i == 8 || $ i == 10 ) { $ uuid .= '-' ; } $ uuid .= str_pad ( dechex ( ord ( $ data { $ ...
Read uuid .
16,261
public function readList ( $ valueType ) { $ list = array ( ) ; $ count = $ this -> readShort ( ) ; for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { $ list [ ] = $ this -> readByType ( $ valueType , true ) ; } return $ list ; }
Read list .
16,262
public function readMap ( $ keyType , $ valueType ) { $ map = array ( ) ; $ count = $ this -> readShort ( ) ; for ( $ i = 0 ; $ i < $ count ; ++ $ i ) { $ map [ $ this -> readByType ( $ keyType , true ) ] = $ this -> readByType ( $ valueType , true ) ; } return $ map ; }
Read map .
16,263
public function readFloat ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) { $ this -> readShort ( ) ; } return unpack ( 'f' , strrev ( $ this -> read ( 4 ) ) ) [ 1 ] ; }
Read float .
16,264
public function readDouble ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) { $ this -> readShort ( ) ; } return unpack ( 'd' , strrev ( $ this -> read ( 8 ) ) ) [ 1 ] ; }
Read double .
16,265
public function readInet ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) { $ data = $ this -> read ( $ this -> readShort ( ) ) ; } else { $ data = $ this -> data ; } return inet_ntop ( $ data ) ; }
Read inet .
16,266
public function readVarint ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) { $ length = $ this -> readShort ( ) ; } else { $ length = strlen ( $ this -> data ) ; } $ hex = unpack ( 'H*' , $ this -> read ( $ length ) ) ; return $ this -> bchexdec ( $ hex [ 1 ] ) ; }
Read variable length integer .
16,267
public function readDecimal ( $ isCollectionElement = false ) { if ( $ isCollectionElement ) { $ this -> readShort ( ) ; } $ scale = $ this -> readInt ( ) ; $ value = $ this -> readVarint ( $ isCollectionElement ) ; $ len = strlen ( $ value ) ; return substr ( $ value , 0 , $ len - $ scale ) . '.' . substr ( $ value , ...
Read variable length decimal .
16,268
public function setModel ( \ atk4 \ data \ Model $ m ) { $ this -> table ( $ m -> table ) ; foreach ( $ m -> elements as $ field ) { if ( ! $ field instanceof \ atk4 \ data \ Field ) { continue ; } if ( $ field -> never_persist ) { continue ; } if ( $ field instanceof \ atk4 \ data \ Field_SQL_Expression ) { continue ;...
Sets model .
16,269
public function mode ( $ mode ) { if ( ! isset ( $ this -> templates [ $ mode ] ) ) { throw new Exception ( [ 'Structure builder does not have this mode' , 'mode' => $ mode ] ) ; } $ this -> mode = $ mode ; $ this -> template = $ this -> templates [ $ mode ] ; return $ this ; }
Set SQL expression template .
16,270
public function _render_statements ( ) { $ result = [ ] ; if ( isset ( $ this -> args [ 'dropField' ] ) ) { foreach ( $ this -> args [ 'dropField' ] as $ field => $ junk ) { $ result [ ] = 'drop column ' . $ this -> _escape ( $ field ) ; } } if ( isset ( $ this -> args [ 'newField' ] ) ) { foreach ( $ this -> args [ 'n...
Renders statement .
16,271
public function getModelFieldType ( $ type ) { $ type = preg_replace ( '/\(.*/' , '' , strtolower ( $ type ) ) ; if ( substr ( $ type , 0 , 7 ) == 'varchar' || substr ( $ type , 0 , 4 ) == 'char' || substr ( $ type , 0 , 4 ) == 'enum' ) { $ type = null ; } if ( $ type == 'tinyint' ) { $ type = 'boolean' ; } if ( $ type...
Convert SQL field types to Agile Data field types .
16,272
public function getSQLFieldType ( $ type , $ options = [ ] ) { $ type = strtolower ( $ type ) ; $ len = null ; switch ( $ type ) { case 'boolean' : $ type = 'tinyint' ; $ len = 1 ; break ; case 'integer' : $ type = 'int' ; break ; case 'money' : $ type = 'decimal' ; $ len = '12,2' ; break ; case 'float' : $ type = 'dec...
Convert Agile Data field types to SQL field types .
16,273
public function importTable ( $ table ) { $ this -> table ( $ table ) ; $ has_fields = false ; foreach ( $ this -> describeTable ( $ table ) as $ row ) { $ has_fields = true ; if ( $ row [ 'pk' ] ) { $ this -> id ( $ row [ 'name' ] ) ; continue ; } $ type = $ this -> getModelFieldType ( $ row [ 'type' ] ) ; $ this -> f...
Import fields from database into migration field config .
16,274
public function id ( $ name = null ) { if ( ! $ name ) { $ name = 'id' ; } $ val = $ this -> connection -> expr ( $ this -> primary_key_expr ) ; $ this -> args [ 'field' ] = [ $ name => $ val ] + ( isset ( $ this -> args [ 'field' ] ) ? $ this -> args [ 'field' ] : [ ] ) ; return $ this ; }
Add ID field in template .
16,275
protected function _render_one_field ( $ field , $ options ) { $ name = $ options [ 'name' ] ?? $ field ; $ type = $ this -> getSQLFieldType ( $ options [ 'type' ] ?? null , $ options ) ; return $ this -> _escape ( $ name ) . ' ' . $ type ; }
Renders one field .
16,276
protected function _set_args ( $ what , $ alias , $ value ) { if ( $ alias === null ) { $ this -> args [ $ what ] [ ] = $ value ; } else { if ( isset ( $ this -> args [ $ what ] [ $ alias ] ) ) { throw new Exception ( [ ucfirst ( $ what ) . ' alias should be unique' , 'alias' => $ alias , ] ) ; } $ this -> args [ $ wha...
Sets value in args array . Doesn t allow duplicate aliases .
16,277
protected function getFinder ( ) : PathFinderInterface { $ result = ClassFactory :: createFinder ( $ this -> configType , $ this -> options ) ; return $ result ; }
Get path finder instance
16,278
public function createSchema ( array $ config = [ ] ) : SchemaInterface { $ path = rtrim ( Configure :: read ( 'ModuleConfig.schemaPath' ) , '/' ) ; $ file = $ this -> configType . '.json' ; $ schemaPath = implode ( DIRECTORY_SEPARATOR , [ $ path , $ file ] ) ; return new Schema ( $ schemaPath , null , $ config ) ; }
Creates a new Schema instance for the current config type .
16,279
public function find ( bool $ validate = true ) { $ cache = $ finder = $ exception = $ cacheKey = $ result = null ; try { $ cache = new Cache ( __FUNCTION__ , $ this -> options ) ; $ cacheKey = $ cache -> getKey ( [ $ this -> module , $ this -> configType , $ this -> configFile , $ validate ] ) ; $ result = $ cache -> ...
Find module configuration file
16,280
public function parse ( ) { $ result = new stdClass ( ) ; $ cache = $ parser = $ exception = $ cacheKey = $ path = null ; try { $ path = $ this -> find ( false ) ; $ cache = new PathCache ( __FUNCTION__ , $ this -> options ) ; $ cacheKey = $ cache -> getKey ( [ $ path ] ) ; $ result = $ cache -> readFrom ( $ cacheKey )...
Parse module configuration file
16,281
protected function mergeMessages ( $ source = null , string $ caller = 'ModuleConfig' ) : void { $ source = is_object ( $ source ) ? $ source : new stdClass ( ) ; if ( $ source instanceof InvalidArgumentException ) { $ this -> errors = array_merge ( $ this -> errors , $ this -> formatMessages ( $ source -> getMessage (...
Merge warning and error messages
16,282
public static function exists ( string $ moduleName , array $ options = [ ] ) : bool { $ config = ( new ModuleConfig ( ConfigType :: MIGRATION ( ) , $ moduleName , null , $ options ) ) -> parseToArray ( ) ; if ( empty ( $ config ) ) { return false ; } $ config = ( new ModuleConfig ( ConfigType :: MODULE ( ) , $ moduleN...
Checks if the provided module name exists
16,283
public static function hasMigrationFields ( string $ moduleName , array $ fields , array $ options = [ ] ) : bool { $ config = ( new ModuleConfig ( ConfigType :: MIGRATION ( ) , $ moduleName , null , $ options ) ) -> parseToArray ( ) ; $ fieldKeys = array_flip ( $ fields ) ; $ diff = array_diff_key ( $ fieldKeys , $ co...
Checks whether the provided fields exists in migration configuration
16,284
public function readEvent ( ) { $ rawRequestBody = $ this -> httpClient -> getRawRequest ( ) ; $ webhookEvent = ! empty ( $ rawRequestBody [ 'webhook_event' ] ) ? json_decode ( $ rawRequestBody [ 'webhook_event' ] , true ) : false ; return $ webhookEvent ? $ this -> dataFactory -> create ( $ webhookEvent ) : false ; }
Read webhook event from request
16,285
public function includeGeneratedCss ( ) { $ filePath = $ this -> assetHandlerConnectorManager -> getFormzGeneratedFilePath ( ) . '.css' ; $ this -> assetHandlerConnectorManager -> createFileInTemporaryDirectory ( $ filePath , function ( ) { $ errorContainerDisplayCssAssetHandler = $ this -> assetHandlerConnectorManager...
Will take care of generating the CSS with the AssetHandlerFactory . The code will be put in a . css file in the typo3temp directory .
16,286
public function includeDefaultAssets ( ) { if ( false === $ this -> assetHandlerConnectorStates -> defaultAssetsWereIncluded ( ) ) { $ this -> assetHandlerConnectorStates -> markDefaultAssetsAsIncluded ( ) ; $ this -> getJavaScriptAssetHandlerConnector ( ) -> includeDefaultJavaScriptFiles ( ) ; $ this -> getCssAssetHan...
Will take care of including internal FormZ JavaScript and CSS files . They will be included only once even if the view helper is used several times in the same page .
16,287
public function getFormzGeneratedFilePath ( $ prefix = '' ) { $ formObject = $ this -> assetHandlerFactory -> getFormObject ( ) ; $ formIdentifier = CacheService :: get ( ) -> getFormCacheIdentifier ( $ formObject -> getClassName ( ) , $ formObject -> getName ( ) ) ; $ prefix = ( false === empty ( $ prefix ) ) ? $ pref...
Returns a file name based on the form object class name .
16,288
public function createFileInTemporaryDirectory ( $ relativePath , callable $ callback ) { $ result = false ; $ absolutePath = GeneralUtility :: getFileAbsFileName ( $ relativePath ) ; if ( false === $ this -> fileExists ( $ absolutePath ) ) { $ content = call_user_func ( $ callback ) ; $ result = $ this -> writeTempora...
This function will check if the file at the given path exists . If it does not the callback is called to get the content of the file which is put in the created file .
16,289
public function getContextHash ( ) { return ( $ this -> environmentService -> isEnvironmentInFrontendMode ( ) ) ? 'fe-' . Core :: get ( ) -> getPageController ( ) -> id : 'be-' . StringService :: get ( ) -> sanitizeString ( GeneralUtility :: _GET ( 'M' ) ) ; }
Returns a unique hash for the context of the current request depending on whether the request comes from frontend or backend .
16,290
public function getLanguageKey ( ) { $ languageKey = 'unknown' ; if ( $ this -> environmentService -> isEnvironmentInFrontendMode ( ) ) { $ pageController = Core :: get ( ) -> getPageController ( ) ; if ( isset ( $ pageController -> config [ 'config' ] [ 'language' ] ) ) { $ languageKey = $ pageController -> config [ '...
Returns the current language key .
16,291
public function addOptions ( array $ options ) { $ existingOptions = $ this -> getOptions ( ) ; $ newOptions = empty ( $ existingOptions ) ? $ options : array_merge ( ( array ) $ existingOptions , $ options ) ; $ this -> setOptions ( $ newOptions ) ; return $ this ; }
Allows to add multiple options at once when providing just one array .
16,292
protected function getDataFromPath ( string $ path ) : string { $ isPathRequired = $ this -> getConfig ( 'pathRequired' ) ; try { Utility :: validatePath ( $ path ) ; } catch ( InvalidArgumentException $ e ) { if ( $ isPathRequired ) { throw $ e ; } $ this -> warnings [ ] = $ e -> getMessage ( ) ; return ( string ) jso...
Read raw data from path .
16,293
protected function validate ( stdClass $ data ) : void { $ config = $ this -> getConfig ( ) ; $ schema = $ this -> readSchema ( ) ; $ dataArray = Convert :: objectToArray ( $ data ) ; if ( empty ( $ dataArray ) ) { if ( $ config [ 'allowEmptyData' ] === false ) { throw new JsonValidationException ( 'Empty data is not a...
Validate the JSON object against the schema .
16,294
protected function readSchema ( ) : \ stdClass { $ schema = $ this -> getEmptyResult ( ) ; try { $ schema = $ this -> getSchema ( ) -> read ( ) ; } catch ( InvalidArgumentException $ e ) { $ this -> errors [ ] = $ e -> getMessage ( ) ; throw new JsonValidationException ( "Schema file `{$this->schema->getSchemaPath()}` ...
Reads the schema .
16,295
protected function runValidator ( stdClass $ data , stdClass $ schema ) : void { $ config = $ this -> getConfig ( ) ; $ validator = new Validator ; $ validator -> validate ( $ data , $ schema , $ config [ 'validationMode' ] ) ; if ( ! $ validator -> isValid ( ) ) { foreach ( $ validator -> getErrors ( ) as $ error ) { ...
Runs the json validation .
16,296
final protected function renderForm ( array $ arguments ) { $ this -> formService -> activateFormContext ( ) ; $ this -> formService -> applyBehavioursOnSubmittedForm ( $ this -> controllerContext ) ; $ this -> addDefaultClass ( ) ; $ this -> handleDataAttributes ( ) ; $ this -> handleAssets ( ) ; $ this -> timeTracker...
Will render the whole form and return the HTML result .
16,297
protected function addDefaultClass ( ) { $ formDefaultClass = $ this -> formObject -> getConfiguration ( ) -> getSettings ( ) -> getDefaultClass ( ) ; $ class = $ this -> tag -> getAttribute ( 'class' ) ; if ( false === empty ( $ formDefaultClass ) ) { $ class = ( ! empty ( $ class ) ? $ class . ' ' : '' ) . $ formDefa...
Will add a default class to the form element .
16,298
protected function handleDataAttributes ( ) { $ dataAttributes = [ ] ; $ dataAttributesAssetHandler = $ this -> getDataAttributesAssetHandler ( ) ; if ( $ this -> formObject -> hasForm ( ) ) { if ( false === $ this -> formObject -> hasFormResult ( ) ) { $ form = $ this -> formObject -> getForm ( ) ; $ formValidator = $...
Adds custom data attributes to the form element based on the submitted form values and results .
16,299
protected function handleAssets ( ) { $ assetHandlerConnectorManager = $ this -> getAssetHandlerConnectorManager ( ) ; $ assetHandlerConnectorManager -> includeDefaultAssets ( ) ; $ assetHandlerConnectorManager -> getJavaScriptAssetHandlerConnector ( ) -> generateAndIncludeFormzConfigurationJavaScript ( ) -> generateAn...
Will include all JavaScript and CSS assets needed for this form .