idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
16,300 | protected function getErrorText ( Result $ result ) { $ view = Core :: instantiate ( StandaloneView :: class ) ; $ view -> setTemplatePathAndFilename ( GeneralUtility :: getFileAbsFileName ( 'EXT:' . ExtensionService :: get ( ) -> getExtensionKey ( ) . '/Resources/Private/Templates/Error/ConfigurationErrorBlock.html' ) ) ; $ layoutRootPath = StringService :: get ( ) -> getExtensionRelativePath ( 'Resources/Private/Layouts' ) ; $ view -> setLayoutRootPaths ( [ $ layoutRootPath ] ) ; $ view -> assign ( 'result' , $ result ) ; $ templatePath = GeneralUtility :: getFileAbsFileName ( 'EXT:' . ExtensionService :: get ( ) -> getExtensionKey ( ) . '/Resources/Public/StyleSheets/Form.ErrorBlock.css' ) ; $ this -> pageRenderer -> addCssFile ( StringService :: get ( ) -> getResourceRelativePath ( $ templatePath ) ) ; return $ view -> render ( ) ; } | Will return an error text from a Fluid view . |
16,301 | protected function getFormObjectArgument ( ) { $ objectArgument = $ this -> arguments [ 'object' ] ; if ( null === $ objectArgument ) { return null ; } if ( false === is_object ( $ objectArgument ) ) { throw InvalidOptionValueException :: formViewHelperWrongFormValueType ( $ objectArgument ) ; } if ( false === $ objectArgument instanceof FormInterface ) { throw InvalidOptionValueException :: formViewHelperWrongFormValueObjectType ( $ objectArgument ) ; } $ formClassName = $ this -> getFormClassName ( ) ; if ( false === $ objectArgument instanceof $ formClassName ) { throw InvalidOptionValueException :: formViewHelperWrongFormValueClassName ( $ formClassName , $ objectArgument ) ; } return $ objectArgument ; } | Checks the type of the argument object and returns it if everything is ok . |
16,302 | protected function getFormClassNameFromControllerAction ( ) { return $ this -> controllerService -> getFormClassNameFromControllerAction ( $ this -> getControllerName ( ) , $ this -> getControllerActionName ( ) , $ this -> getFormObjectName ( ) ) ; } | Will fetch the name of the controller action argument bound to this request . |
16,303 | public static function truncate ( $ html , $ length , $ opts = array ( ) ) { if ( is_string ( $ opts ) ) $ opts = array ( 'ellipsis' => $ opts ) ; $ opts = array_merge ( static :: $ default_options , $ opts ) ; $ html = "<div>" . static :: utf8_for_xml ( $ html ) . "</div>" ; $ root_node = null ; if ( class_exists ( 'HTML5Lib\\Parser' ) ) { try { $ doc = \ HTML5Lib \ Parser :: parse ( $ html ) ; $ root_node = $ doc -> documentElement -> lastChild -> lastChild ; } catch ( \ Exception $ e ) { ; } } if ( $ root_node === null ) { $ doc = new DOMDocument ; $ doc -> formatOutput = false ; $ doc -> preserveWhitespace = true ; $ prev_use_errors = libxml_use_internal_errors ( true ) ; if ( $ doc -> loadHTML ( $ html ) ) { $ root_node = $ doc -> documentElement -> lastChild -> lastChild ; } else if ( $ doc -> loadXML ( $ html ) ) { $ root_node = $ doc -> documentElement ; } else { libxml_use_internal_errors ( $ prev_use_errors ) ; throw new InvalidHtmlException ; } libxml_use_internal_errors ( $ prev_use_errors ) ; } list ( $ text , $ _ , $ opts ) = static :: _truncate_node ( $ doc , $ root_node , $ length , $ opts ) ; $ text = ht_substr ( ht_substr ( $ text , 0 , - 6 ) , 5 ) ; return $ text ; } | Truncate given HTML string to specified length . If length_in_chars is false it s trimmed by number of words otherwise by number of characters . |
16,304 | protected function getValidatorData ( $ validatorClassName ) { if ( false === isset ( $ this -> validatorsData [ $ validatorClassName ] ) ) { $ this -> validatorsData [ $ validatorClassName ] = [ ] ; if ( in_array ( AbstractValidator :: class , class_parents ( $ validatorClassName ) ) ) { $ validatorReflection = new \ ReflectionClass ( $ validatorClassName ) ; $ validatorProperties = $ validatorReflection -> getDefaultProperties ( ) ; unset ( $ validatorReflection ) ; $ validatorData = [ 'supportedOptions' => $ validatorProperties [ 'supportedOptions' ] , 'acceptsEmptyValues' => $ validatorProperties [ 'acceptsEmptyValues' ] ] ; if ( in_array ( FormzAbstractValidator :: class , class_parents ( $ validatorClassName ) ) ) { $ validatorData [ 'formzValidator' ] = true ; $ validatorData [ 'supportedMessages' ] = $ validatorProperties [ 'supportedMessages' ] ; $ validatorData [ 'supportsAllMessages' ] = $ validatorProperties [ 'supportsAllMessages' ] ; } $ this -> validatorsData [ $ validatorClassName ] = $ validatorData ; } } return $ this -> validatorsData [ $ validatorClassName ] ; } | Will clone the data of the given validator class name . Please note that it will use reflection to get the default value of the class properties . |
16,305 | protected function moveCoreFiles ( $ downloadPath , $ wildcard = '*.php' ) { $ dir = realpath ( $ downloadPath ) ; $ dst = dirname ( $ dir ) ; if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { shell_exec ( "move /Y $dir/$wildcard $dst/" ) ; } else { shell_exec ( "mv -f $dir/$wildcard $dst/" ) ; } if ( count ( glob ( "$dir/*.php" ) ) === 0 ) { if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { shell_exec ( "rd /S /Q $dir" ) ; } else { shell_exec ( "rm -Rf $dir" ) ; } } } | Move files out of the package directory up one level |
16,306 | public function getFieldsValuesDataAttributes ( FormResult $ formResult ) { $ result = [ ] ; $ formObject = $ this -> getFormObject ( ) ; $ formInstance = $ formObject -> getForm ( ) ; foreach ( $ formObject -> getConfiguration ( ) -> getFields ( ) as $ field ) { $ fieldName = $ field -> getName ( ) ; if ( false === $ formResult -> fieldIsDeactivated ( $ field ) ) { $ value = ObjectAccess :: getProperty ( $ formInstance , $ fieldName ) ; $ value = ( is_array ( $ value ) ) ? implode ( ' ' , $ value ) : $ value ; if ( false === empty ( $ value ) ) { $ result [ self :: getFieldDataValueKey ( $ fieldName ) ] = $ value ; } } } return $ result ; } | Handles the data attributes containing the values of the form fields . |
16,307 | public function getFieldsMessagesDataAttributes ( ) { $ result = [ ] ; $ formConfiguration = $ this -> getFormObject ( ) -> getConfiguration ( ) ; $ formResult = $ this -> getFormObject ( ) -> getFormResult ( ) ; foreach ( $ formResult -> getSubResults ( ) as $ fieldName => $ fieldResult ) { if ( true === $ formConfiguration -> hasField ( $ fieldName ) && false === $ formResult -> fieldIsDeactivated ( $ formConfiguration -> getField ( $ fieldName ) ) ) { $ result += $ this -> getFieldErrorMessages ( $ fieldName , $ fieldResult ) ; $ result += $ this -> getFieldWarningMessages ( $ fieldName , $ fieldResult ) ; $ result += $ this -> getFieldNoticeMessages ( $ fieldName , $ fieldResult ) ; } } return $ result ; } | Handles the data attributes for the fields which got errors warnings and notices . |
16,308 | public function getFieldsValidDataAttributes ( ) { $ result = [ ] ; $ formConfiguration = $ this -> getFormObject ( ) -> getConfiguration ( ) ; $ formResult = $ this -> getFormObject ( ) -> getFormResult ( ) ; foreach ( $ formConfiguration -> getFields ( ) as $ field ) { $ fieldName = $ field -> getName ( ) ; if ( false === $ formResult -> fieldIsDeactivated ( $ field ) && false === $ formResult -> forProperty ( $ fieldName ) -> hasErrors ( ) ) { $ result [ self :: getFieldDataValidKey ( $ fieldName ) ] = '1' ; } } return $ result ; } | Handles the data attributes for the fields which are valid . |
16,309 | public static function getFieldDataValidationMessageKey ( $ fieldName , $ type , $ validationName , $ messageKey ) { $ stringService = StringService :: get ( ) ; return vsprintf ( 'fz-%s-%s-%s-%s' , [ $ type , $ stringService -> sanitizeString ( $ fieldName ) , $ stringService -> sanitizeString ( $ validationName ) , $ stringService -> sanitizeString ( $ messageKey ) ] ) ; } | Formats the data message attribute key for a given failed validation for the given field name . |
16,310 | public function title ( ) { if ( in_array ( $ this -> type ( ) , [ null , 'about:blank' ] , true ) ) { return $ this -> determineStatusPhrase ( $ this -> status ( ) ) ; } return $ this -> title ; } | A short human - readable summary of the problem type . |
16,311 | public function load ( $ file ) { if ( ! file_exists ( $ file ) ) { throw new \ RuntimeException ( sprintf ( 'The file "%s" does not exists' , $ file ) ) ; } $ content = file_get_contents ( $ file ) ; $ content = str_replace ( '<param' , '<parameter' , $ content ) ; $ content = str_replace ( '</param' , '</parameter' , $ content ) ; $ crawler = new Crawler ( ) ; $ crawler -> addContent ( $ content , 'xml' ) ; foreach ( $ crawler -> filterXPath ( '//function' ) as $ node ) { $ method = $ this -> getMethod ( $ node ) ; $ this -> specification -> addMethod ( $ method ) ; } } | Loads the specification from a XML file |
16,312 | public function getMethod ( \ DOMNode $ node ) { $ crawler = new Crawler ( $ node ) ; $ name = $ crawler -> attr ( 'name' ) ; $ method = new Method ( $ name ) ; $ method -> setType ( preg_match ( '/(^(get|is)|ToString$)/' , $ name ) ? Method :: TYPE_ACCESSOR : Method :: TYPE_ACTION ) ; $ descriptions = $ crawler -> filterXPath ( '//comment' ) ; if ( count ( $ descriptions ) !== 1 ) { throw new \ Exception ( 'Only one comment expected' ) ; } $ descriptions -> rewind ( ) ; $ description = $ this -> getInner ( $ descriptions -> current ( ) ) ; $ method -> setDescription ( $ description ) ; foreach ( $ crawler -> filterXPath ( '//parameter' ) as $ node ) { $ method -> addParameter ( $ this -> getParameter ( $ node ) ) ; } $ returnNodes = $ crawler -> filterXPath ( '//return' ) ; if ( count ( $ returnNodes ) > 1 ) { throw new \ Exception ( "Should not be more than one return node" ) ; } elseif ( count ( $ returnNodes ) == 1 ) { $ returnNodes -> rewind ( ) ; list ( $ type , $ description ) = $ this -> getReturn ( $ returnNodes -> current ( ) ) ; $ method -> setReturnType ( $ type ) ; $ method -> setReturnDescription ( $ description ) ; } return $ method ; } | Returns a method in the current specification from a DOMNode |
16,313 | protected function getParameter ( \ DOMNode $ node ) { $ name = $ node -> getAttribute ( 'name' ) ; $ parameter = new Parameter ( $ name ) ; $ parameter -> setDescription ( $ this -> getInner ( $ node ) ) ; return $ parameter ; } | Get a parameter model object from a DOMNode |
16,314 | protected function getInner ( \ DOMNode $ node ) { $ c14n = $ node -> C14N ( ) ; $ begin = strpos ( $ c14n , '>' ) ; $ end = strrpos ( $ c14n , '<' ) ; $ content = substr ( $ c14n , $ begin + 1 , $ end - $ begin - 1 ) ; return $ content ; } | Get the inner content of a DOMNode . |
16,315 | public function beforeSave ( Event $ event , EntityInterface $ entity , ArrayObject $ options ) : void { $ entity = $ this -> encryptEntity ( $ entity ) ; } | Modele . beforeSave callback which runs the entity encryption . |
16,316 | public function encryptEntity ( EntityInterface $ entity ) : EntityInterface { if ( ! $ this -> isEncryptable ( $ entity ) ) { return $ entity ; } $ fields = $ this -> getFields ( ) ; $ encryptionKey = $ this -> getConfig ( 'encryptionKey' ) ; $ base64 = $ this -> getConfig ( 'base64' ) ; $ table = $ this -> getTable ( ) ; $ patch = [ ] ; foreach ( $ fields as $ name => $ field ) { if ( ! $ table -> hasField ( $ name ) ) { continue ; } $ value = $ entity -> get ( $ name ) ; if ( $ value === null || is_resource ( $ value ) ) { continue ; } $ encrypted = Security :: encrypt ( $ value , $ encryptionKey ) ; if ( $ base64 === true ) { $ encrypted = base64_encode ( $ encrypted ) ; } $ patch [ $ name ] = $ encrypted ; } if ( ! empty ( $ patch ) ) { $ accessible = array_fill_keys ( array_keys ( $ patch ) , true ) ; $ entity = $ table -> patchEntity ( $ entity , $ patch , [ 'accessibleFields' => $ accessible , ] ) ; } return $ entity ; } | Encrypts the fields . |
16,317 | public function isEncryptable ( EntityInterface $ entity ) : bool { $ enabled = $ this -> getConfig ( 'enabled' ) ; if ( is_callable ( $ enabled ) ) { $ enabled = $ enabled ( $ entity ) ; if ( ! is_bool ( $ enabled ) ) { throw new RuntimeException ( 'Condition callable must return a boolean.' ) ; } } return $ enabled ; } | Checks whether the given entity can be encrypted . |
16,318 | public function decryptEntity ( EntityInterface $ entity , array $ fields ) : EntityInterface { if ( ! $ this -> isEncryptable ( $ entity ) ) { return $ entity ; } foreach ( $ fields as $ field ) { $ value = $ this -> decryptEntityField ( $ entity , $ field ) ; if ( $ value !== null ) { $ entity -> set ( [ $ field => $ value ] , [ 'guard' => false ] ) ; $ entity -> setDirty ( $ field , false ) ; } } return $ entity ; } | Decrypts entity fields and runs the conditions check to determine whether the given entity can be decrypted . |
16,319 | public function decryptEntityField ( EntityInterface $ entity , string $ field ) { if ( ! $ this -> canDecryptField ( $ entity , $ field ) ) { return null ; } $ encryptionKey = $ this -> getConfig ( 'encryptionKey' ) ; $ base64 = $ this -> getConfig ( 'base64' ) ; $ encoded = $ entity -> get ( $ field ) ; if ( empty ( $ encoded ) || $ encoded === false ) { return null ; } if ( $ base64 === true ) { $ encoded = base64_decode ( $ encoded , true ) ; if ( $ encoded === false ) { return null ; } } $ decrypted = Security :: decrypt ( $ encoded , $ encryptionKey ) ; if ( $ decrypted === false ) { throw new RuntimeException ( "Unable to decypher `{$field}`. Check your enryption key." ) ; } return $ decrypted ; } | Returns the decrypted field value . Assumes that the field is actually encrypted . |
16,320 | protected function canDecryptField ( EntityInterface $ entity , string $ field ) : bool { if ( ! $ this -> getTable ( ) -> hasField ( $ field ) ) { return false ; } $ decryptAll = $ this -> getConfig ( 'decryptAll' ) ; if ( $ decryptAll === true ) { return true ; } $ fields = $ this -> getFields ( ) ; if ( ! isset ( $ fields [ $ field ] ) ) { return false ; } $ decrypt = $ fields [ $ field ] [ 'decrypt' ] ; if ( is_callable ( $ decrypt ) ) { $ decrypt = $ decrypt ( $ entity , $ field ) ; } return $ decrypt ; } | Returns true when the field can be decrypted . |
16,321 | protected function getFields ( ) : array { $ fields = $ this -> getConfig ( 'fields' ) ; $ defaults = [ 'decrypt' => false , ] ; $ result = [ ] ; foreach ( $ fields as $ field => $ values ) { if ( is_numeric ( $ field ) ) { $ field = $ values ; $ values = [ ] ; } $ values = array_merge ( $ defaults , $ values ) ; $ result [ $ field ] = $ values ; } return $ result ; } | Returns a processed list of fields with applied default values . |
16,322 | private function initializeValidator ( $ form ) { if ( false === $ form instanceof FormInterface ) { throw InvalidArgumentTypeException :: validatingWrongFormType ( get_class ( $ form ) ) ; } $ this -> form = $ form ; $ this -> result = new FormResult ; $ this -> formValidatorExecutor = $ this -> getFormValidatorExecutor ( $ form ) ; } | Initializes all class variables . |
16,323 | final public function validate ( $ form ) { $ this -> initializeValidator ( $ form ) ; $ formObject = $ this -> formValidatorExecutor -> getFormObject ( ) ; $ formObject -> markFormAsSubmitted ( ) ; $ formObject -> setForm ( $ form ) ; $ this -> validateGhost ( $ form , false ) ; $ formObject -> setFormResult ( $ this -> result ) ; return $ this -> result ; } | Checks the given form instance and launches the validation if it is a correct form . |
16,324 | public function validateGhost ( $ form , $ initialize = true ) { if ( $ initialize ) { $ this -> initializeValidator ( $ form ) ; } $ this -> isValid ( $ form ) ; return $ this -> result ; } | Validates the form but won t save form data in the form object . |
16,325 | final public function isValid ( $ form ) { $ this -> formValidatorExecutor -> applyBehaviours ( ) ; $ this -> formValidatorExecutor -> checkFieldsActivation ( ) ; $ this -> beforeValidationProcess ( ) ; $ this -> formValidatorExecutor -> validateFields ( function ( Field $ field ) { $ this -> callAfterFieldValidationMethod ( $ field ) ; } ) ; $ this -> afterValidationProcess ( ) ; if ( $ this -> result -> hasErrors ( ) ) { FormService :: addFormWithErrors ( $ form ) ; } } | Runs the whole validation workflow . |
16,326 | private function callAfterFieldValidationMethod ( Field $ field ) { $ functionName = lcfirst ( $ field -> getName ( ) . 'Validated' ) ; if ( method_exists ( $ this , $ functionName ) ) { call_user_func ( [ $ this , $ functionName ] ) ; } } | After each field has been validated a matching method can be called if it exists in the child class . |
16,327 | public function getJavaScriptCode ( ) { $ fieldsJavaScriptCode = [ ] ; $ formConfiguration = $ this -> getFormObject ( ) -> getConfiguration ( ) ; foreach ( $ formConfiguration -> getFields ( ) as $ field ) { $ fieldsJavaScriptCode [ ] = $ this -> processField ( $ field ) ; } $ formName = GeneralUtility :: quoteJSvalue ( $ this -> getFormObject ( ) -> getName ( ) ) ; $ fieldsJavaScriptCode = implode ( CRLF , $ fieldsJavaScriptCode ) ; return <<<JS(function() { Fz.Form.get( $formName, function(form) { var field = null;$fieldsJavaScriptCode } );})();JS ; } | Main function of this asset handler . See class description . |
16,328 | protected function processField ( $ field ) { $ javaScriptCode = [ ] ; $ fieldName = $ field -> getName ( ) ; foreach ( $ field -> getValidation ( ) as $ validationName => $ validationConfiguration ) { $ validatorClassName = $ validationConfiguration -> getClassName ( ) ; if ( in_array ( AbstractValidator :: class , class_parents ( $ validatorClassName ) ) ) { $ javaScriptCode [ ] = ( string ) $ this -> getInlineJavaScriptValidationCode ( $ field , $ validationName , $ validationConfiguration ) ; } } $ javaScriptCode = implode ( CRLF , $ javaScriptCode ) ; $ javaScriptFieldName = GeneralUtility :: quoteJSvalue ( $ fieldName ) ; return <<<JS /*************************** * Field: "$fieldName" ****************************/ field = form.getFieldByName($javaScriptFieldName); if (null !== field) {$javaScriptCode }JS ; } | Will run the process for the given field . |
16,329 | protected function getInlineJavaScriptValidationCode ( Field $ field , $ validationName , Validation $ validatorConfiguration ) { $ javaScriptValidationName = GeneralUtility :: quoteJSvalue ( $ validationName ) ; $ validatorName = addslashes ( $ validatorConfiguration -> getClassName ( ) ) ; $ validatorConfigurationFinal = $ this -> getValidationConfiguration ( $ field , $ validationName , $ validatorConfiguration ) ; $ validatorConfigurationFinal = $ this -> handleValidationConfiguration ( $ validatorConfigurationFinal ) ; return <<<JS /* * Validation rule "$validationName" */ field.addValidation($javaScriptValidationName, '$validatorName', $validatorConfigurationFinal);JS ; } | Generates the JavaScript code to add a validation rule to a field . |
16,330 | protected function getValidationConfiguration ( Field $ field , $ validationName , Validation $ validatorConfiguration ) { $ acceptsEmptyValues = ValidatorService :: get ( ) -> validatorAcceptsEmptyValues ( $ validatorConfiguration -> getClassName ( ) ) ; $ formzLocalizationJavaScriptAssetHandler = $ this -> assetHandlerFactory -> getAssetHandler ( FormzLocalizationJavaScriptAssetHandler :: class ) ; $ messages = $ formzLocalizationJavaScriptAssetHandler -> getTranslationKeysForFieldValidation ( $ field , $ validationName ) ; return ArrayService :: get ( ) -> arrayToJavaScriptJson ( [ 'options' => $ validatorConfiguration -> getOptions ( ) , 'messages' => $ messages , 'settings' => $ validatorConfiguration -> toArray ( ) , 'acceptsEmptyValues' => $ acceptsEmptyValues ] ) ; } | Returns a JSON array containing the validation configuration needed by JavaScript . |
16,331 | private function callBuilderMethod ( $ item ) { $ settings = new InputSettingsForm ; if ( ! $ settings -> isValid ( $ item ) ) { throw new InvalidInputSettingsException ; } $ settings -> bind ( $ item , new \ stdClass ) ; $ className = $ item [ InputSettingsForm :: TYPE_PARAM ] ; if ( ! class_exists ( $ className ) ) { throw new NotFoundException ( ) ; } if ( ! in_array ( $ className , $ this -> builders ) ) { throw new NotDefinedException ( ) ; } $ method = new \ ReflectionMethod ( $ className , self :: BUILDER_METHOD ) ; return $ method -> invokeArgs ( new $ className , array ( $ settings ) ) ; } | Proxies factory create call to specific responsible builder . |
16,332 | private function callAdditionalOptionsMethod ( $ item ) { $ settings = new InputSettingsForm ; if ( ! $ settings -> isValid ( $ item ) ) { throw new InvalidInputSettingsException ; } $ settings -> bind ( $ item , new \ stdClass ) ; $ className = $ item [ InputSettingsForm :: TYPE_PARAM ] ; if ( ! class_exists ( $ className ) ) { throw new NotFoundException ( ) ; } if ( ! in_array ( $ className , $ this -> builders ) ) { throw new NotDefinedException ( ) ; } $ builderObject = new $ className ; $ builderObject -> setAdditionalOptions ( ) ; return $ builderObject -> getAdditionalOptions ( ) ; $ setMethod = new \ ReflectionMethod ( $ className , self :: INIT_ELEMENT_METHOD ) ; $ getMethod = new \ ReflectionMethod ( $ className , self :: ADDITIONAL_OPTIONS_METHOD ) ; $ setMethod -> invokeArgs ( $ builderObject , array ( $ settings ) ) ; return $ getMethod -> invokeArgs ( $ builderObject , array ( $ settings ) ) ; } | Proxies factory create call for additional fields to specific responsible builder . |
16,333 | public function render ( ) { $ elements = [ ] ; foreach ( $ this -> builders as $ builder ) { $ object = new $ builder ; $ elements [ ] = [ 'element' => $ object -> initElement ( ) , 'options' => $ object -> getAdditionalOptions ( ) ] ; } return $ elements ; } | Method create object for render each element . Execute initElement method |
16,334 | public function getDataFromProvider ( ) { $ select = $ this -> get ( self :: DATA_PARAM ) ; if ( is_null ( $ select -> getValue ( ) ) ) { return array ( ) ; } $ classname = $ select -> getValue ( ) ; if ( ! class_exists ( $ classname ) || ! array_key_exists ( $ classname , $ select -> getOptions ( ) ) ) { throw new NotFoundException ; } return ( new $ classname ) -> getData ( ) ; } | Proxy method to retrieve data to populate select lists . |
16,335 | public function addDataProviderInput ( ) { $ input = ( new Select ( self :: DATA_PARAM ) ) -> setOptions ( array ( null => '---' ) ) ; $ dataProviderClasses = array ( ) ; foreach ( $ this -> di -> get ( 'config' ) -> formFactory -> dataProviders as $ classname ) { $ provider = new $ classname ; if ( $ provider instanceof DataProviderInterface ) { $ dataProviderClasses [ $ classname ] = $ provider -> getName ( ) ; } } $ input -> addOptions ( $ dataProviderClasses ) -> setLabel ( 'Data provider' ) ; $ this -> add ( $ input ) ; } | Adds selectable list of data providers . Usable only for selectable input types . |
16,336 | public function getCacheInstance ( ) { if ( null === $ this -> cacheInstance ) { $ this -> cacheInstance = $ this -> cacheManager -> getCache ( self :: CACHE_IDENTIFIER ) ; } return $ this -> cacheInstance ; } | Returns the cache instance used by this extension . |
16,337 | public function getFormCacheIdentifier ( $ formClassName , $ formName ) { $ shortClassName = end ( explode ( '\\' , $ formClassName ) ) ; return StringService :: get ( ) -> sanitizeString ( $ shortClassName . '-' . $ formName ) ; } | Generic cache identifier creation for usages in the extension . |
16,338 | public function clearCacheCommand ( $ parameters ) { if ( in_array ( $ parameters [ 'cacheCmd' ] , [ 'all' , 'system' ] ) ) { $ files = $ this -> getFilesInPath ( self :: GENERATED_FILES_PATH . '*' ) ; foreach ( $ files as $ file ) { $ this -> clearFile ( $ file ) ; } } } | Function called when clearing TYPO3 caches . It will remove the temporary asset files created by FormZ . |
16,339 | public static function render ( $ file , $ ex ) : void { if ( php_sapi_name ( ) === 'cli' ) { exit ( json_encode ( $ ex ) ) ; } http_response_code ( 500 ) ; require ouch_views ( $ file ) ; exit ( 1 ) ; } | render view method . |
16,340 | public function deleteDestroy ( $ id ) { $ vocabulary = $ this -> vocabulary -> find ( $ id ) ; $ terms = $ vocabulary -> terms -> lists ( 'id' ) -> toArray ( ) ; TermRelation :: whereIn ( 'term_id' , $ terms ) -> delete ( ) ; Term :: destroy ( $ terms ) ; $ this -> vocabulary -> destroy ( $ id ) ; return response ( ) -> json ( [ 'OK' ] ) ; } | Destory a resource . |
16,341 | public function putUpdate ( Request $ request , $ id ) { $ this -> validate ( $ request , isset ( $ this -> vocabulary -> rules_create ) ? $ this -> vocabulary -> rules_create : $ this -> vocabulary -> rules ) ; $ vocabulary = $ this -> vocabulary -> findOrFail ( $ id ) ; $ vocabulary -> update ( Input :: only ( 'name' ) ) ; return Redirect :: to ( action ( '\Devfactory\Taxonomy\Controllers\TaxonomyController@getIndex' ) ) -> with ( 'success' , 'Updated' ) ; } | Update a resource . |
16,342 | public function getConfigurationObject ( ) { if ( null === $ this -> configurationObject || $ this -> lastConfigurationHash !== $ this -> formObject -> getHash ( ) ) { $ this -> lastConfigurationHash = $ this -> formObject -> getHash ( ) ; $ this -> configurationObject = $ this -> getConfigurationObjectFromCache ( ) ; } return $ this -> configurationObject ; } | Returns an instance of configuration object . Checks if it was previously stored in cache otherwise it is created from scratch . |
16,343 | public function getConfigurationValidationResult ( ) { if ( null === $ this -> configurationValidationResult || $ this -> lastConfigurationHash !== $ this -> formObject -> getHash ( ) ) { $ configurationObject = $ this -> getConfigurationObject ( ) ; $ this -> configurationValidationResult = $ this -> refreshConfigurationValidationResult ( $ configurationObject ) ; } return $ this -> configurationValidationResult ; } | This function will merge and return the validation results of both the global FormZ configuration object and this form configuration object . |
16,344 | protected function refreshConfigurationValidationResult ( ConfigurationObjectInstance $ configurationObject ) { $ result = new Result ; $ formzConfigurationValidationResult = $ this -> configurationFactory -> getFormzConfiguration ( ) -> getValidationResult ( ) ; $ result -> merge ( $ formzConfigurationValidationResult ) ; $ result -> forProperty ( 'forms.' . $ this -> formObject -> getClassName ( ) ) -> merge ( $ configurationObject -> getValidationResult ( ) ) ; return $ result ; } | Resets the validation result and merges it with the global FormZ configuration . |
16,345 | protected function sanitizeConfiguration ( array $ configuration ) { $ sanitizedFieldsConfiguration = [ ] ; $ fieldsConfiguration = ( isset ( $ configuration [ 'fields' ] ) ) ? $ configuration [ 'fields' ] : [ ] ; foreach ( $ this -> formObject -> getProperties ( ) as $ property ) { $ sanitizedFieldsConfiguration [ $ property ] = ( isset ( $ fieldsConfiguration [ $ property ] ) ) ? $ fieldsConfiguration [ $ property ] : [ ] ; } $ configuration [ 'fields' ] = $ sanitizedFieldsConfiguration ; return $ configuration ; } | This function will clean the configuration array by removing useless data and updating needed ones . |
16,346 | public function getTool ( $ name ) { if ( ! isset ( $ this -> tools [ $ name ] ) ) { $ this -> tools [ $ name ] = $ this -> createTool ( $ name ) ; } return $ this -> tools [ $ name ] ; } | Get tool by name |
16,347 | public function reset ( ) { foreach ( array_keys ( $ this -> objectInstances ) as $ className ) { if ( $ className !== self :: class ) { unset ( $ this -> objectInstances [ $ className ] ) ; } } } | Used in unit tests . |
16,348 | protected function initializeClassNames ( ) { list ( $ this -> classNameSpace , $ this -> className ) = GeneralUtility :: trimExplode ( '.' , $ this -> arguments [ 'name' ] ) ; if ( false === in_array ( $ this -> classNameSpace , self :: $ acceptedClassesNameSpace ) ) { throw InvalidEntryException :: invalidCssClassNamespace ( $ this -> arguments [ 'name' ] , self :: $ acceptedClassesNameSpace ) ; } } | Will initialize the namespace and name of the class which is given as argument to this ViewHelper . |
16,349 | protected function initializeFieldName ( ) { $ this -> fieldName = $ this -> arguments [ 'field' ] ; if ( empty ( $ this -> fieldName ) && $ this -> fieldService -> fieldContextExists ( ) ) { $ this -> fieldName = $ this -> fieldService -> getCurrentField ( ) -> getName ( ) ; } if ( null === $ this -> fieldName ) { throw EntryNotFoundException :: classViewHelperFieldNotFound ( $ this -> arguments [ 'name' ] ) ; } } | Fetches the name of the field which should refer to this class . It can either be a given value or be empty if the ViewHelper is used inside a FieldViewHelper . |
16,350 | protected function initializeClassValue ( ) { $ classesConfiguration = $ this -> formService -> getFormObject ( ) -> getConfiguration ( ) -> getRootConfiguration ( ) -> getView ( ) -> getClasses ( ) ; $ class = ObjectAccess :: getProperty ( $ classesConfiguration , $ this -> classNameSpace ) ; if ( false === $ class -> hasItem ( $ this -> className ) ) { throw UnregisteredConfigurationException :: cssClassNameNotFound ( $ this -> arguments [ 'name' ] , $ this -> classNameSpace , $ this -> className ) ; } $ this -> classValue = $ class -> getItem ( $ this -> className ) ; } | Fetches the corresponding value of this class which was defined in TypoScript . |
16,351 | protected function getFormResultClass ( ) { $ result = '' ; $ formObject = $ this -> formService -> getFormObject ( ) ; if ( $ formObject -> formWasSubmitted ( ) && $ formObject -> hasFormResult ( ) ) { $ fieldResult = $ formObject -> getFormResult ( ) -> forProperty ( $ this -> fieldName ) ; $ result = $ this -> getPropertyResultClass ( $ fieldResult ) ; } return $ result ; } | Checks if the form was submitted then parses its result to handle classes depending on TypoScript configuration . |
16,352 | public function parse ( ActivationInterface $ activation ) { $ hash = 'condition-tree-' . HashService :: get ( ) -> getHash ( serialize ( [ $ activation -> getExpression ( ) , $ activation -> getConditions ( ) ] ) ) ; if ( false === array_key_exists ( $ hash , $ this -> trees ) ) { $ this -> trees [ $ hash ] = $ this -> getConditionTree ( $ hash , $ activation ) ; } return $ this -> trees [ $ hash ] ; } | Will parse a condition expression to build a tree containing one or several nodes which represent the condition . See the class ConditionTree for more information . |
16,353 | public function loadRoutes ( App $ slim , array $ routes ) { foreach ( $ routes as $ name => $ details ) { if ( $ children = $ this -> nullable ( 'routes' , $ details ) ) { $ middlewares = $ this -> nullable ( 'stack' , $ details ) ? : [ ] ; $ prefix = $ this -> nullable ( 'route' , $ details ) ? : '' ; $ loader = [ $ this , 'loadRoutes' ] ; $ groupLoader = function ( ) use ( $ slim , $ children , $ loader ) { $ loader ( $ slim , $ children ) ; } ; $ group = $ slim -> group ( $ prefix , $ groupLoader ) ; while ( $ mw = array_pop ( $ middlewares ) ) { $ group -> add ( $ mw ) ; } } else { $ this -> loadRoute ( $ slim , $ name , $ details ) ; } } } | Load routes into the application . |
16,354 | private function loadRoute ( App $ slim , $ name , array $ details ) { $ methods = $ this -> methods ( $ details ) ; $ pattern = $ this -> nullable ( 'route' , $ details ) ; $ stack = $ this -> nullable ( 'stack' , $ details ) ? : [ ] ; $ controller = array_pop ( $ stack ) ; $ route = $ slim -> map ( $ methods , $ pattern , $ controller ) ; $ route -> setName ( $ name ) ; while ( $ middleware = array_pop ( $ stack ) ) { $ route -> add ( $ middleware ) ; } return $ route ; } | Load a route into the application . |
16,355 | protected function fail ( $ message ) : void { if ( is_string ( $ message ) ) { $ message = new RuntimeException ( $ message ) ; } $ this -> errors [ ] = $ message -> getMessage ( ) ; throw $ message ; } | Fail execution with a given error |
16,356 | public function toHtml ( $ json ) { $ input = json_decode ( $ json , true ) ; $ html = '' ; foreach ( $ input [ 'data' ] as $ block ) { $ html .= $ this -> convert ( new SirTrevorBlock ( $ block [ 'type' ] , $ block [ 'data' ] ) ) ; } return $ html ; } | Converts the outputted json from Sir Trevor to html |
16,357 | private function convert ( SirTrevorBlock $ block ) { foreach ( $ this -> converters as $ converter ) { if ( $ converter -> matches ( $ block -> getType ( ) ) ) { return $ converter -> toHtml ( $ block -> getData ( ) ) ; } } } | Converts on array to an html string |
16,358 | public function on ( ) : self { $ this -> handler -> setErrorHandler ( ) ; $ this -> handler -> setExceptionHandler ( ) ; $ this -> handler -> setFatalHandler ( ) ; return $ this ; } | enable ouch error handler . |
16,359 | public function start ( $ type = '*firefox' , $ startUrl = 'http://localhost' ) { if ( null !== $ this -> sessionId ) { throw new Exception ( "Session already started" ) ; } $ response = $ this -> doExecute ( 'getNewBrowserSession' , $ type , $ startUrl ) ; if ( preg_match ( '/^OK,(.*)$/' , $ response , $ vars ) ) { $ this -> sessionId = $ vars [ 1 ] ; } else { throw new Exception ( "Invalid response from server : $response" ) ; } } | Starts a new session . |
16,360 | public function getString ( $ command , $ target = null , $ value = null ) { $ result = $ this -> doExecute ( $ command , $ target , $ value ) ; if ( ! preg_match ( '/^OK,/' , $ result ) ) { throw new Exception ( "Unexpected response from Selenium server : " . $ result ) ; } return strlen ( $ result ) > 3 ? substr ( $ result , 3 ) : '' ; } | Executes a command on the server and returns a string . |
16,361 | public function getStringArray ( $ command , $ target = null , $ value = null ) { $ string = $ this -> getString ( $ command , $ target , $ value ) ; $ results = preg_split ( '/(?<!\\\),/' , $ string ) ; foreach ( $ results as & $ result ) { $ result = str_replace ( '\,' , ',' , $ result ) ; } return $ results ; } | Executes a command on the server and returns an array of string . |
16,362 | public function getNumber ( $ command , $ target = null , $ value = null ) { $ string = $ this -> getString ( $ command , $ target , $ value ) ; return ( int ) $ string ; } | Executes a command on the server and returns a number . |
16,363 | public function getBoolean ( $ command , $ target = null , $ value = null ) { $ string = $ this -> getString ( $ command , $ target , $ value ) ; return $ string == 'true' ; } | Executes a command on the server and returns a boolean . |
16,364 | public function stop ( ) { if ( null === $ this -> sessionId ) { throw new Exception ( "Session not started" ) ; } $ this -> doExecute ( 'testComplete' ) ; $ this -> sessionId = null ; } | Stops the session . |
16,365 | protected function doExecute ( $ command , $ target = null , $ value = null ) { $ postFields = array ( ) ; $ query = array ( 'cmd' => $ command ) ; if ( $ target !== null ) { $ postFields [ 1 ] = $ target ; } if ( $ value !== null ) { $ postFields [ 2 ] = $ value ; } if ( null !== $ this -> sessionId ) { $ query [ 'sessionId' ] = $ this -> sessionId ; } $ query = http_build_query ( $ query ) ; $ url = $ this -> url . '?' . $ query ; $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_POST , count ( $ postFields ) ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , http_build_query ( $ postFields ) ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ this -> timeout ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; $ result = curl_exec ( $ ch ) ; $ curlErrno = curl_errno ( $ ch ) ; curl_close ( $ ch ) ; if ( $ curlErrno > 0 ) { throw new Exception ( "Unable to connect ! " ) ; } if ( false === $ result ) { throw new Exception ( "Connection refused" ) ; } return $ result ; } | Executes a raw command on the server and integrate the current session identifier if available . |
16,366 | private function unpackThrowables ( $ throwable ) { if ( ! $ throwable instanceof Throwable ) { return [ ] ; } $ throwables = [ $ throwable ] ; while ( $ throwable = $ throwable -> getPrevious ( ) ) { $ throwables [ ] = $ throwable ; } return $ throwables ; } | Unpack nested throwables into a flat array |
16,367 | public static function renderStatic ( array $ arguments , Closure $ renderChildrenClosure , RenderingContextInterface $ renderingContext ) { $ fieldService = Core :: instantiate ( FieldViewHelperService :: class ) ; if ( false === $ fieldService -> fieldContextExists ( ) ) { throw ContextNotFoundException :: slotRenderViewHelperFieldContextNotFound ( ) ; } $ slotService = Core :: instantiate ( SlotViewHelperService :: class ) ; $ slotName = $ arguments [ 'slot' ] ; $ result = '' ; if ( $ slotService -> hasSlot ( $ slotName ) ) { $ currentVariables = version_compare ( VersionNumberUtility :: getCurrentTypo3Version ( ) , '8.0.0' , '<' ) ? $ renderingContext -> getTemplateVariableContainer ( ) -> getAll ( ) : $ renderingContext -> getVariableProvider ( ) -> getAll ( ) ; ArrayUtility :: mergeRecursiveWithOverrule ( $ currentVariables , $ arguments [ 'arguments' ] ) ; $ slotService -> addTemplateVariables ( $ slotName , $ currentVariables ) ; $ slotClosure = $ slotService -> getSlotClosure ( $ slotName ) ; $ result = $ slotClosure ( ) ; $ slotService -> restoreTemplateVariables ( $ slotName ) ; } return $ result ; } | Will render the slot with the given name only if the slot is found . |
16,368 | public function handle ( $ throwable ) { if ( $ throwable instanceof Exception ) { $ response = $ this -> handler -> handleException ( $ this -> defaultRequest , $ this -> defaultResponse , $ throwable ) ; } elseif ( $ throwable instanceof Throwable ) { $ response = $ this -> handler -> handleThrowable ( $ this -> defaultRequest , $ this -> defaultResponse , $ throwable ) ; } else { return false ; } if ( $ response instanceof ResponseInterface ) { $ this -> renderResponse ( $ response ) ; return true ; } else { return false ; } } | Handle a throwable and return whether it was handled and the remaining stack should be aborted . |
16,369 | protected function storeViewDataLegacy ( ) { $ originalArguments = [ ] ; $ variableProvider = $ this -> getVariableProvider ( ) ; foreach ( self :: $ reservedVariablesNames as $ key ) { if ( $ variableProvider -> exists ( $ key ) ) { $ originalArguments [ $ key ] = $ variableProvider -> get ( $ key ) ; } } $ viewHelperVariableContainer = $ this -> renderingContext -> getViewHelperVariableContainer ( ) ; $ currentView = $ viewHelperVariableContainer -> getView ( ) ; return function ( array $ templateArguments ) use ( $ originalArguments , $ variableProvider , $ viewHelperVariableContainer , $ currentView ) { $ viewHelperVariableContainer -> setView ( $ currentView ) ; foreach ( $ variableProvider -> getAllIdentifiers ( ) as $ identifier ) { if ( array_key_exists ( $ identifier , $ templateArguments ) ) { $ variableProvider -> remove ( $ identifier ) ; } } foreach ( $ originalArguments as $ key => $ value ) { if ( $ variableProvider -> exists ( $ key ) ) { $ variableProvider -> remove ( $ key ) ; } $ variableProvider -> add ( $ key , $ value ) ; } } ; } | Temporary solution for TYPO3 6 . 2 to 7 . 6 that will store the current view variables to be able to restore them later . |
16,370 | protected function injectFieldInService ( $ fieldName ) { $ formObject = $ this -> formService -> getFormObject ( ) ; $ formConfiguration = $ formObject -> getConfiguration ( ) ; if ( false === is_string ( $ fieldName ) ) { throw InvalidArgumentTypeException :: fieldViewHelperInvalidTypeNameArgument ( ) ; } elseif ( false === $ formConfiguration -> hasField ( $ fieldName ) ) { throw PropertyNotAccessibleException :: fieldViewHelperFieldNotAccessibleInForm ( $ formObject , $ fieldName ) ; } $ this -> fieldService -> setCurrentField ( $ formConfiguration -> getField ( $ fieldName ) ) ; } | Will check that the given field exists in the current form definition and inject it in the FieldService as currentField . |
16,371 | protected function getLayout ( View $ viewConfiguration ) { $ layout = $ this -> arguments [ 'layout' ] ; if ( false === is_string ( $ layout ) ) { throw InvalidArgumentTypeException :: invalidTypeNameArgumentFieldViewHelper ( $ layout ) ; } list ( $ layoutName , $ templateName ) = GeneralUtility :: trimExplode ( '.' , $ layout ) ; if ( empty ( $ templateName ) ) { $ templateName = 'default' ; } if ( empty ( $ layoutName ) ) { throw InvalidArgumentValueException :: fieldViewHelperEmptyLayout ( ) ; } if ( false === $ viewConfiguration -> hasLayout ( $ layoutName ) ) { throw EntryNotFoundException :: fieldViewHelperLayoutNotFound ( $ layout ) ; } if ( false === $ viewConfiguration -> getLayout ( $ layoutName ) -> hasItem ( $ templateName ) ) { throw EntryNotFoundException :: fieldViewHelperLayoutItemNotFound ( $ layout , $ templateName ) ; } return $ viewConfiguration -> getLayout ( $ layoutName ) -> getItem ( $ templateName ) ; } | Returns the layout instance used by this field . |
16,372 | protected function getTemplateArguments ( ) { $ templateArguments = $ this -> arguments [ 'arguments' ] ? : [ ] ; ArrayUtility :: mergeRecursiveWithOverrule ( $ templateArguments , $ this -> fieldService -> getFieldOptions ( ) ) ; return $ templateArguments ; } | Merging the arguments with the ones registered with the OptionViewHelper . |
16,373 | public static function valueToBytes ( $ value ) : int { if ( is_int ( $ value ) ) { return $ value ; } $ value = trim ( $ value ) ; if ( ctype_digit ( ltrim ( $ value , '-' ) ) ) { return ( int ) $ value ; } $ signed = ( substr ( $ value , 0 , 1 ) === '-' ) ? - 1 : 1 ; if ( preg_match ( '/(\d+)K$/i' , $ value , $ matches ) ) { return ( int ) ( $ matches [ 1 ] * $ signed * 1024 ) ; } if ( preg_match ( '/(\d+)M$/i' , $ value , $ matches ) ) { return ( int ) ( $ matches [ 1 ] * $ signed * 1024 * 1024 ) ; } if ( preg_match ( '/(\d+)G$/i' , $ value , $ matches ) ) { return ( int ) ( $ matches [ 1 ] * $ signed * 1024 * 1024 * 1024 ) ; } throw new InvalidArgumentException ( "Failed to find K, M, or G in a non-integer value [$value]" ) ; } | Convert value to bytes |
16,374 | public static function objectToArray ( $ source ) : array { $ result = [ ] ; if ( is_array ( $ source ) ) { return $ source ; } if ( ! is_object ( $ source ) ) { return $ result ; } $ json = json_encode ( $ source ) ; if ( $ json === false ) { return $ result ; } $ array = json_decode ( $ json , true ) ; if ( $ array === null ) { return $ result ; } $ result = $ array ; return $ result ; } | Convert an object to associative array |
16,375 | public static function dataToJson ( string $ data , bool $ lint = false ) : stdClass { if ( $ lint ) { $ linter = new JsonParser ( ) ; $ linter -> parse ( $ data ) ; } $ data = json_decode ( $ data ) ; if ( $ data === null ) { throw new InvalidArgumentException ( "Failed to decode json" ) ; } return ( object ) $ data ; } | Returns the json encoded data and applies linting if necessary . |
16,376 | public function getQueryParam ( UriInterface $ uri , $ param ) { if ( ! $ query = $ uri -> getQuery ( ) ) { return null ; } parse_str ( $ query , $ params ) ; if ( ! array_key_exists ( $ param , $ params ) ) { return null ; } return $ params [ $ param ] ; } | Get a query parameter from a PSR - 7 UriInterface |
16,377 | public function uriFor ( $ route , array $ params = [ ] , array $ query = [ ] ) { if ( ! $ route ) { return '' ; } return $ this -> router -> relativePathFor ( $ route , $ params , $ query ) ; } | Get the relative URL for a given route name . |
16,378 | public function absoluteURIFor ( UriInterface $ uri , $ route , array $ params = [ ] , array $ query = [ ] ) { $ path = $ this -> uriFor ( $ route , $ params ) ; return ( string ) $ uri -> withUserInfo ( '' ) -> withPath ( $ path ) -> withQuery ( http_build_query ( $ query ) ) -> withFragment ( '' ) ; } | Get the absolute URL for a given route name . You must provide the current request Uri to retrieve the scheme and host . |
16,379 | private function getTypeObject ( $ type , $ args ) { if ( $ type instanceof AbstractType ) { $ object = $ type ; } else { $ class = $ this -> getTypeClass ( $ type ) ; if ( ! \ class_exists ( $ class ) ) { $ class = TextType :: class ; } $ object = new $ class ( $ args , $ this ) ; } return $ object ; } | Returns a new instance of the given form type . |
16,380 | public function applyBehaviourOnFormInstance ( FormObject $ formObject ) { if ( $ formObject -> hasForm ( ) ) { $ formInstance = $ formObject -> getForm ( ) ; foreach ( $ formObject -> getConfiguration ( ) -> getFields ( ) as $ fieldName => $ field ) { if ( ObjectAccess :: isPropertyGettable ( $ formInstance , $ fieldName ) && ObjectAccess :: isPropertySettable ( $ formInstance , $ fieldName ) ) { $ propertyValue = ObjectAccess :: getProperty ( $ formInstance , $ fieldName ) ; foreach ( $ field -> getBehaviours ( ) as $ behaviour ) { $ behaviourInstance = GeneralUtility :: makeInstance ( $ behaviour -> getClassName ( ) ) ; $ propertyValue = $ behaviourInstance -> applyBehaviour ( $ propertyValue ) ; } ObjectAccess :: setProperty ( $ formInstance , $ fieldName , $ propertyValue ) ; } } } } | This is the same function as applyBehaviourOnPropertiesArray but works with an actual form object instance . |
16,381 | public function registerCondition ( $ name , $ className ) { if ( false === is_string ( $ name ) ) { throw InvalidArgumentTypeException :: conditionNameNotString ( $ name ) ; } if ( false === class_exists ( $ className ) ) { throw ClassNotFoundException :: conditionClassNameNotFound ( $ name , $ className ) ; } if ( false === in_array ( ConditionItemInterface :: class , class_implements ( $ className ) ) ) { throw InvalidArgumentTypeException :: conditionClassNameNotValid ( $ className ) ; } $ this -> conditions [ $ name ] = $ className ; return $ this ; } | Use this function to register a new condition type which can then be used in the TypoScript configuration . This function should be called from ext_localconf . php . |
16,382 | public function registerDefaultConditions ( ) { if ( false === $ this -> defaultConditionsWereRegistered ) { $ this -> defaultConditionsWereRegistered = true ; $ this -> registerCondition ( FieldHasValueCondition :: CONDITION_NAME , FieldHasValueCondition :: class ) -> registerCondition ( FieldHasErrorCondition :: CONDITION_NAME , FieldHasErrorCondition :: class ) -> registerCondition ( FieldIsValidCondition :: CONDITION_NAME , FieldIsValidCondition :: class ) -> registerCondition ( FieldIsEmptyCondition :: CONDITION_NAME , FieldIsEmptyCondition :: class ) -> registerCondition ( FieldIsFilledCondition :: CONDITION_IDENTIFIER , FieldIsFilledCondition :: class ) -> registerCondition ( FieldCountValuesCondition :: CONDITION_IDENTIFIER , FieldCountValuesCondition :: class ) ; } } | Registers all default conditions from FormZ core . |
16,383 | public function getFormConfiguration ( $ formClassName ) { $ formzConfiguration = $ this -> getExtensionConfiguration ( ) ; return ( isset ( $ formzConfiguration [ 'forms' ] [ $ formClassName ] ) ) ? $ formzConfiguration [ 'forms' ] [ $ formClassName ] : [ ] ; } | Returns the TypoScript configuration for the given form class name . |
16,384 | protected function getExtensionConfiguration ( ) { $ cacheInstance = CacheService :: get ( ) -> getCacheInstance ( ) ; $ hash = $ this -> getContextHash ( ) ; if ( $ cacheInstance -> has ( $ hash ) ) { $ result = $ cacheInstance -> get ( $ hash ) ; } else { $ result = $ this -> getFullConfiguration ( ) ; $ result = ( ArrayUtility :: isValidPath ( $ result , self :: EXTENSION_CONFIGURATION_PATH , '.' ) ) ? ArrayUtility :: getValueByPath ( $ result , self :: EXTENSION_CONFIGURATION_PATH , '.' ) : [ ] ; if ( ArrayUtility :: isValidPath ( $ result , 'settings.typoScriptIncluded' , '.' ) ) { $ cacheInstance -> set ( $ hash , $ result ) ; } } return $ result ; } | This function will fetch the extension TypoScript configuration and store it in cache for further usage . |
16,385 | protected function getFullConfiguration ( ) { $ contextHash = $ this -> getContextHash ( ) ; if ( false === array_key_exists ( $ contextHash , $ this -> configuration ) ) { $ typoScriptArray = ( $ this -> environmentService -> isEnvironmentInFrontendMode ( ) ) ? $ this -> getFrontendTypoScriptConfiguration ( ) : $ this -> getBackendTypoScriptConfiguration ( ) ; $ this -> configuration [ $ contextHash ] = $ this -> typoScriptService -> convertTypoScriptArrayToPlainArray ( $ typoScriptArray ) ; } return $ this -> configuration [ $ contextHash ] ; } | Returns the full TypoScript configuration based on the context of the current request . |
16,386 | public function generate ( ContainerConfiguration $ config , ConfigCache $ dump ) : ContainerInterface { $ this -> compiler -> compile ( $ config , $ dump , $ this ) ; return $ this -> loadContainer ( $ config , $ dump ) ; } | Loads the container |
16,387 | public function toJson ( $ html ) { $ html = preg_replace ( '~>\s+<~' , '><' , $ html ) ; $ document = new \ DOMDocument ( ) ; $ document -> loadHTML ( '<?xml encoding="UTF-8">' . $ html ) ; $ document -> encoding = 'UTF-8' ; $ body = $ document -> getElementsByTagName ( "body" ) -> item ( 0 ) ; $ data = array ( ) ; if ( $ body ) { foreach ( $ body -> childNodes as $ node ) { $ data [ ] = $ this -> convert ( $ node ) ; } } return json_encode ( array ( 'data' => $ data ) ) ; } | Converts html to the json Sir Trevor requires |
16,388 | private function convert ( \ DOMElement $ node ) { foreach ( $ this -> converters as $ converter ) { if ( $ converter -> matches ( $ node ) ) { return $ converter -> toJson ( $ node ) ; } } } | Converts one node to json |
16,389 | public function getConditions ( ) { $ conditionList = $ this -> withFirstParent ( Form :: class , function ( Form $ formConfiguration ) { return $ formConfiguration -> getConditionList ( ) ; } ) ; $ conditionList = ( $ conditionList ) ? : [ ] ; ArrayUtility :: mergeRecursiveWithOverrule ( $ conditionList , $ this -> conditions ) ; return $ conditionList ; } | Will merge the conditions with the condition list of the parent form . |
16,390 | public function getCondition ( $ name ) { if ( false === $ this -> hasCondition ( $ name ) ) { throw EntryNotFoundException :: activationConditionNotFound ( $ name ) ; } $ items = $ this -> getConditions ( ) ; return $ items [ $ name ] ; } | Return the condition with the given name . |
16,391 | public static function getFormWithErrors ( $ formClassName ) { GeneralUtility :: logDeprecatedFunction ( ) ; return ( isset ( self :: $ formWithErrors [ $ formClassName ] ) ) ? self :: $ formWithErrors [ $ formClassName ] : null ; } | If a form has been submitted with errors use this function to get it back . This is useful because an action is forwarded if the submitted argument has errors . |
16,392 | protected function getNodeRecursive ( ) { while ( false === empty ( $ this -> scope -> getExpression ( ) ) ) { $ currentExpression = $ this -> scope -> getExpression ( ) ; $ this -> processToken ( $ currentExpression [ 0 ] ) ; $ this -> processLogicalAndNode ( ) ; } $ this -> processLastLogicalOperatorNode ( ) ; $ node = $ this -> scope -> getNode ( ) ; unset ( $ this -> scope ) ; return $ node ; } | Recursive function to convert an array of condition data to a nodes tree . |
16,393 | protected function processToken ( $ token ) { switch ( $ token ) { case ')' : $ this -> processTokenClosingParenthesis ( ) ; break ; case '(' : $ this -> processTokenOpeningParenthesis ( ) ; break ; case self :: LOGICAL_OR : case self :: LOGICAL_AND : $ this -> processTokenLogicalOperator ( $ token ) ; break ; default : $ this -> processTokenCondition ( $ token ) ; break ; } return $ this ; } | Will process a given token which should be in the list of know tokens . |
16,394 | protected function processTokenOpeningParenthesis ( ) { $ groupNode = $ this -> getGroupNode ( $ this -> scope -> getExpression ( ) ) ; $ scopeSave = $ this -> scope ; $ expression = array_slice ( $ scopeSave -> getExpression ( ) , count ( $ groupNode ) + 2 ) ; $ scopeSave -> setExpression ( $ expression ) ; $ this -> scope = $ this -> getNewScope ( ) ; $ this -> scope -> setExpression ( $ groupNode ) ; $ node = $ this -> getNodeRecursive ( ) ; $ this -> scope = $ scopeSave ; $ this -> scope -> setNode ( $ node ) ; } | Will process the opening parenthesis token ( . |
16,395 | protected function processTokenLogicalOperator ( $ operator ) { if ( null === $ this -> scope -> getNode ( ) ) { $ this -> addError ( 'Logical operator must be preceded by a valid operation.' , self :: ERROR_CODE_LOGICAL_OPERATOR_PRECEDED ) ; } else { if ( self :: LOGICAL_OR === $ operator ) { if ( null !== $ this -> scope -> getLastOrNode ( ) ) { $ node = new BooleanNode ( $ this -> scope -> getLastOrNode ( ) , $ this -> scope -> getNode ( ) , $ operator ) ; $ this -> scope -> setNode ( $ node ) ; } $ this -> scope -> setLastOrNode ( $ this -> scope -> getNode ( ) ) ; } else { $ this -> scope -> setCurrentLeftNode ( $ this -> scope -> getNode ( ) ) -> deleteNode ( ) ; } $ this -> scope -> setCurrentOperator ( $ operator ) -> shiftExpression ( ) ; } } | Will process the logical operator tokens && and || . |
16,396 | protected function processTokenCondition ( $ condition ) { if ( false === $ this -> condition -> hasCondition ( $ condition ) ) { $ this -> addError ( 'The condition "' . $ condition . '" does not exist.' , self :: ERROR_CODE_CONDITION_NOT_FOUND ) ; } else { $ node = new ConditionNode ( $ condition , $ this -> condition -> getCondition ( $ condition ) ) ; $ this -> scope -> setNode ( $ node ) -> shiftExpression ( ) ; } } | Will process the condition token . |
16,397 | protected function processLogicalAndNode ( ) { if ( null !== $ this -> scope -> getCurrentLeftNode ( ) && null !== $ this -> scope -> getNode ( ) && null !== $ this -> scope -> getCurrentOperator ( ) ) { $ node = new BooleanNode ( $ this -> scope -> getCurrentLeftNode ( ) , $ this -> scope -> getNode ( ) , $ this -> scope -> getCurrentOperator ( ) ) ; $ this -> scope -> setNode ( $ node ) -> deleteCurrentLeftNode ( ) -> deleteCurrentOperator ( ) ; } return $ this ; } | Will check if a logical and node should be created depending on which tokens were processed before . |
16,398 | protected function processLastLogicalOperatorNode ( ) { if ( null !== $ this -> scope -> getCurrentLeftNode ( ) ) { $ this -> addError ( 'Logical operator must be followed by a valid operation.' , self :: ERROR_CODE_LOGICAL_OPERATOR_FOLLOWED ) ; } elseif ( null !== $ this -> scope -> getLastOrNode ( ) ) { $ node = new BooleanNode ( $ this -> scope -> getLastOrNode ( ) , $ this -> scope -> getNode ( ) , self :: LOGICAL_OR ) ; $ this -> scope -> setNode ( $ node ) ; } return $ this ; } | Will check if a last logical operator node is remaining . |
16,399 | protected function getGroupNodeClosingIndex ( array $ expression ) { $ parenthesis = 1 ; $ index = 0 ; while ( $ parenthesis > 0 ) { $ index ++ ; if ( $ index > count ( $ expression ) ) { $ this -> addError ( 'Parenthesis not correctly closed.' , self :: ERROR_CODE_CLOSING_PARENTHESIS_NOT_FOUND ) ; } if ( '(' === $ expression [ $ index ] ) { $ parenthesis ++ ; } elseif ( ')' === $ expression [ $ index ] ) { $ parenthesis -- ; } } return $ index ; } | Returns the index of the closing parenthesis that matches the opening parenthesis at index 0 of the given expression . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.