idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
59,700
protected function extractVisibility ( $ comments = '' ) { $ visible = TRUE ; preg_match ( '/@visible\ (true|false)\n/i' , $ comments , $ visibility ) ; if ( count ( $ visibility ) ) { $ visible = ! ( 'false' === $ visibility [ 1 ] ) ; } return $ visible ; }
Extract visibility from doc comments
59,701
protected function extractDescription ( $ comments = '' ) { $ description = '' ; $ docs = explode ( "\n" , $ comments ) ; if ( count ( $ docs ) ) { foreach ( $ docs as & $ doc ) { if ( ! preg_match ( '/(\*\*|\@)/' , $ doc ) && preg_match ( '/\*\ /' , $ doc ) ) { $ doc = explode ( '* ' , $ doc ) ; $ description = $ doc [ 1 ] ; } } } return $ description ; }
Method that extract the description for the endpoint
59,702
public static function extractVarType ( $ comments = '' ) { $ type = 'string' ; preg_match ( '/@var\ (.*) (.*)\n/i' , $ comments , $ varType ) ; if ( count ( $ varType ) ) { $ aux = trim ( $ varType [ 1 ] ) ; $ type = str_replace ( ' ' , '' , strlen ( $ aux ) > 0 ? $ varType [ 1 ] : $ varType [ 2 ] ) ; } return $ type ; }
Method that extract the type of a variable
59,703
protected function extractPayload ( $ model , $ comments = '' ) { $ payload = [ ] ; preg_match ( '/@payload\ (.*)\n/i' , $ comments , $ doc ) ; $ isArray = false ; if ( count ( $ doc ) ) { $ namespace = str_replace ( '{__API__}' , $ model , $ doc [ 1 ] ) ; if ( false !== strpos ( $ namespace , '[' ) && false !== strpos ( $ namespace , ']' ) ) { $ namespace = str_replace ( ']' , '' , str_replace ( '[' , '' , $ namespace ) ) ; $ isArray = true ; } $ payload = $ this -> extractModelFields ( $ namespace ) ; $ reflector = new \ ReflectionClass ( $ namespace ) ; $ shortName = $ reflector -> getShortName ( ) ; } else { $ namespace = $ model ; $ shortName = $ model ; } return [ $ namespace , $ shortName , $ payload , $ isArray ] ; }
Method that extract the payload for the endpoint
59,704
protected function extractDtoProperties ( $ class ) { $ properties = [ ] ; $ reflector = new \ ReflectionClass ( $ class ) ; if ( $ reflector -> isSubclassOf ( self :: DTO_INTERFACE ) ) { $ properties = array_merge ( $ properties , InjectorHelper :: extractVariables ( $ reflector ) ) ; } return $ properties ; }
Extract all the properties from Dto class
59,705
protected function extractReturn ( $ model , $ comments = '' ) { $ modelDto = [ ] ; preg_match ( '/\@return\ (.*)\((.*)\)\n/i' , $ comments , $ returnTypes ) ; if ( count ( $ returnTypes ) ) { if ( array_key_exists ( 1 , $ returnTypes ) ) { $ modelDto = $ this -> extractDtoProperties ( $ returnTypes [ 1 ] ) ; } if ( array_key_exists ( 2 , $ returnTypes ) ) { $ subDtos = preg_split ( '/,?\ /' , str_replace ( '{__API__}' , $ model , $ returnTypes [ 2 ] ) ) ; if ( count ( $ subDtos ) ) { foreach ( $ subDtos as $ subDto ) { list ( $ field , $ dtoName ) = explode ( '=' , $ subDto ) ; $ isArray = false ; if ( false !== strpos ( $ dtoName , '[' ) && false !== strpos ( $ dtoName , ']' ) ) { $ dtoName = str_replace ( ']' , '' , str_replace ( '[' , '' , $ dtoName ) ) ; $ isArray = true ; } $ dto = $ this -> extractModelFields ( $ dtoName ) ; $ modelDto [ $ field ] = $ isArray ? [ $ dto ] : $ dto ; $ modelDto [ 'objects' ] [ $ dtoName ] = $ dto ; $ modelDto = $ this -> checkDtoAttributes ( $ dto , $ modelDto , $ dtoName ) ; } } } } return $ modelDto ; }
Extract return class for api endpoint
59,706
protected function extractModelFields ( $ namespace ) { $ payload = [ ] ; try { $ reflector = new \ ReflectionClass ( $ namespace ) ; if ( NULL !== $ reflector && $ reflector -> isSubclassOf ( self :: MODEL_INTERFACE ) ) { $ tableMap = $ namespace :: TABLE_MAP ; $ tableMap = $ tableMap :: getTableMap ( ) ; foreach ( $ tableMap -> getColumns ( ) as $ field ) { list ( $ type , $ format ) = DocumentorHelper :: translateSwaggerFormats ( $ field -> getType ( ) ) ; $ info = [ "required" => $ field -> isNotNull ( ) , 'format' => $ format , ] ; if ( count ( $ field -> getValueSet ( ) ) ) { $ info [ 'enum' ] = array_values ( $ field -> getValueSet ( ) ) ; } if ( null !== $ field -> getDefaultValue ( ) ) { $ info [ 'default' ] = $ field -> getDefaultValue ( ) ; } $ payload [ ApiHelper :: getColumnMapName ( $ field ) ] = $ info ; } } elseif ( null !== $ reflector && $ reflector -> isSubclassOf ( self :: DTO_INTERFACE ) ) { $ payload = $ this -> extractDtoProperties ( $ namespace ) ; } } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_ERR ) ; } return $ payload ; }
Extract all fields from a ActiveResource model
59,707
protected function extractMethodInfo ( $ namespace , \ ReflectionMethod $ method , \ ReflectionClass $ reflection , $ module ) { $ methodInfo = NULL ; $ docComments = $ method -> getDocComment ( ) ; if ( FALSE !== $ docComments && preg_match ( '/\@route\ /i' , $ docComments ) ) { $ api = $ this -> extractApi ( $ reflection -> getDocComment ( ) ) ; list ( $ route , $ info ) = RouterHelper :: extractRouteInfo ( $ method , $ api , $ module ) ; $ route = explode ( '#|#' , $ route ) ; $ modelNamespace = str_replace ( 'Api' , 'Models' , $ namespace ) ; if ( $ info [ 'visible' ] && ! $ this -> checkDeprecated ( $ docComments ) ) { try { $ return = $ this -> extractReturn ( $ modelNamespace , $ docComments ) ; $ url = array_pop ( $ route ) ; $ methodInfo = [ 'url' => str_replace ( '/' . $ module . '/api' , '' , $ url ) , 'method' => $ info [ 'http' ] , 'description' => $ info [ 'label' ] , 'return' => $ return , 'objects' => array_key_exists ( 'objects' , $ return ) ? $ return [ 'objects' ] : [ ] , 'class' => $ reflection -> getShortName ( ) , ] ; unset ( $ methodInfo [ 'return' ] [ 'objects' ] ) ; $ this -> setRequestParams ( $ method , $ methodInfo , $ modelNamespace , $ docComments ) ; $ this -> setQueryParams ( $ method , $ methodInfo ) ; $ this -> setRequestHeaders ( $ reflection , $ methodInfo ) ; } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_ERR ) ; } } } return $ methodInfo ; }
Method that extract all the needed info for each method in each API
59,708
public static function extractProperties ( \ ReflectionClass $ reflector , $ type = \ ReflectionProperty :: IS_PROTECTED , $ pattern = self :: INJECTABLE_PATTERN ) { $ properties = [ ] ; foreach ( $ reflector -> getProperties ( $ type ) as $ property ) { $ doc = $ property -> getDocComment ( ) ; if ( preg_match ( $ pattern , $ doc ) ) { $ instanceType = self :: extractVarType ( $ property -> getDocComment ( ) ) ; if ( null !== $ instanceType ) { $ properties [ $ property -> getName ( ) ] = $ instanceType ; } } } return $ properties ; }
Method that extract the properties of a Class
59,709
public static function checkIsRequired ( $ doc ) { $ required = false ; if ( false !== preg_match ( '/@required/' , $ doc , $ matches ) ) { $ required = ( bool ) count ( $ matches ) ; } return $ required ; }
Method extract if a variable is required
59,710
public static function checkIsVisible ( $ doc ) { $ visible = false ; if ( false !== preg_match ( '/@visible\s+([^\s]+)/' , $ doc , $ matches ) ) { $ visible = count ( $ matches ) < 2 || 'false' !== strtolower ( $ matches [ 1 ] ) ; } return $ visible ; }
Method extract if a class or variable is visible
59,711
public static function getClassProperties ( $ class ) { $ properties = [ ] ; Logger :: log ( 'Extracting annotations properties from class ' . $ class ) ; $ selfReflector = new \ ReflectionClass ( $ class ) ; if ( false !== $ selfReflector -> getParentClass ( ) ) { $ properties = self :: getClassProperties ( $ selfReflector -> getParentClass ( ) -> getName ( ) ) ; } $ properties = array_merge ( $ properties , self :: extractProperties ( $ selfReflector ) ) ; return $ properties ; }
Method that extract all the properties of a class
59,712
protected static function saveConfigParams ( array $ data , array $ extra ) { Logger :: log ( 'Saving required config parameters' ) ; if ( array_key_exists ( 'label' , $ extra ) && is_array ( $ extra [ 'label' ] ) ) { foreach ( $ extra [ 'label' ] as $ index => $ field ) { if ( array_key_exists ( $ index , $ extra [ 'value' ] ) && ! empty ( $ extra [ 'value' ] [ $ index ] ) ) { $ data [ $ field ] = $ extra [ 'value' ] [ $ index ] ; } } } return $ data ; }
Method that saves the configuration
59,713
protected static function saveExtraParams ( array $ data ) { $ final_data = array ( ) ; if ( count ( $ data ) > 0 ) { Logger :: log ( 'Saving extra configuration parameters' ) ; foreach ( $ data as $ key => $ value ) { if ( null !== $ value || $ value !== '' ) { $ final_data [ $ key ] = $ value ; } } } return $ final_data ; }
Method that saves the extra parameters into the configuration
59,714
public function isConfigured ( ) { Logger :: log ( 'Checking configuration' ) ; $ configured = ( count ( $ this -> config ) > 0 ) ; if ( $ configured ) { foreach ( static :: $ required as $ required ) { if ( ! array_key_exists ( $ required , $ this -> config ) ) { $ configured = false ; break ; } } } return $ configured || $ this -> checkTryToSaveConfig ( ) || self :: isTest ( ) ; }
Method that checks if the platform is proper configured
59,715
public function checkTryToSaveConfig ( ) { $ uri = Request :: getInstance ( ) -> getRequestUri ( ) ; $ method = Request :: getInstance ( ) -> getMethod ( ) ; return ( preg_match ( '/^\/admin\/(config|setup)$/' , $ uri ) !== false && strtoupper ( $ method ) === 'POST' ) ; }
Method that check if the user is trying to save the config
59,716
public static function save ( array $ data , array $ extra = null ) { $ data = self :: saveConfigParams ( $ data , $ extra ) ; $ final_data = self :: saveExtraParams ( $ data ) ; $ saved = false ; try { $ final_data = array_filter ( $ final_data , function ( $ key , $ value ) { return in_array ( $ key , self :: $ required , true ) || ! empty ( $ value ) ; } , ARRAY_FILTER_USE_BOTH ) ; $ saved = ( false !== file_put_contents ( CONFIG_DIR . DIRECTORY_SEPARATOR . self :: CONFIG_FILE , json_encode ( $ final_data , JSON_PRETTY_PRINT ) ) ) ; self :: getInstance ( ) -> loadConfigData ( ) ; $ saved = true ; } catch ( ConfigException $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_ERR ) ; } return $ saved ; }
Method that saves all the configuration in the system
59,717
public function loadConfigData ( ) { $ this -> config = json_decode ( file_get_contents ( CONFIG_DIR . DIRECTORY_SEPARATOR . self :: CONFIG_FILE ) , true ) ? : [ ] ; $ this -> debug = array_key_exists ( 'debug' , $ this -> config ) ? ( bool ) $ this -> config [ 'debug' ] : FALSE ; }
Method that reloads config file
59,718
public static function getParam ( $ key , $ defaultValue = null , $ module = null ) { if ( null !== $ module ) { return self :: getParam ( strtolower ( $ module ) . '.' . $ key , self :: getParam ( $ key , $ defaultValue ) ) ; } $ param = self :: getInstance ( ) -> get ( $ key ) ; return ( null !== $ param ) ? $ param : $ defaultValue ; }
Static wrapper for extracting params
59,719
public static function setCookieHeaders ( $ cookies ) { if ( ! empty ( $ cookies ) && is_array ( $ cookies ) && false === headers_sent ( ) && ! self :: isTest ( ) ) { foreach ( $ cookies as $ cookie ) { setcookie ( $ cookie [ "name" ] , $ cookie [ "value" ] , ( array_key_exists ( 'expire' , $ cookie ) ) ? $ cookie [ "expire" ] : NULL , ( array_key_exists ( 'path' , $ cookie ) ) ? $ cookie [ "path" ] : "/" , ( array_key_exists ( 'domain' , $ cookie ) ) ? $ cookie [ "domain" ] : Request :: getInstance ( ) -> getRootUrl ( FALSE ) , ( array_key_exists ( 'secure' , $ cookie ) ) ? $ cookie [ "secure" ] : FALSE , ( array_key_exists ( 'http' , $ cookie ) ) ? $ cookie [ "http" ] : true ) ; } } }
Method that sets the cookie headers
59,720
public function toHtmlInternal ( $ value = null ) { $ strOutput = "<optgroup label=\"{$this->__label}\">\n" ; foreach ( $ this -> __options as $ option ) { $ strOutput .= $ option -> toHtmlInternal ( $ value ) ; } $ strOutput .= "</optgroup>\n" ; return $ strOutput ; }
Generte HTML output
59,721
public function setColor ( $ color ) : DeliveryOptions { if ( ! in_array ( $ color , static :: getOptionsForColor ( ) ) ) { throw new InvalidArgumentException ( sprintf ( 'Property %s is not supported for %s' , $ color , __FUNCTION__ ) ) ; } $ this -> data [ 'color' ] = $ color ; return $ this ; }
The option specifies whether a color or black - and - white printing is carried out
59,722
public function setCoverLetter ( $ coverLetter ) : DeliveryOptions { if ( ! in_array ( $ coverLetter , static :: getOptionsForCoverLetter ( ) ) ) { throw new InvalidArgumentException ( sprintf ( 'Property %s is not supported for %s' , $ coverLetter , __FUNCTION__ ) ) ; } $ this -> data [ 'coverLetter' ] = $ coverLetter ; return $ this ; }
The option specifies whether a cover letter is generated for delivery or if it is included in the PDF attachment
59,723
public function detectWhenRequestHasNotBeenHandled ( ) { add_action ( 'wp_footer' , function ( ) { $ this -> requestHasBeenHandled ( ) ; } ) ; add_action ( 'shutdown' , function ( ) { if ( ! $ this -> hasRequestBeenHandled ( ) ) { if ( $ this -> has ( '__wp-controller-miss-template' ) && $ this -> has ( '__wp-controller-miss-controller' ) ) { wp_die ( 'Loaded template <code>' . $ this -> get ( '__wp-controller-miss-template' ) . '</code> but couldn\'t find class <code>' . $ this -> get ( '__wp-controller-miss-controller' ) . '</code>' ) ; } } } ) ; }
Detect when the request has not been handled and throw an exception
59,724
public function getTranslations ( $ locale ) { if ( null === $ locale ) { $ locale = Config :: getParam ( 'default.language' , 'es_ES' ) ; } $ translations = $ this -> tpl -> regenerateTemplates ( ) ; $ localePath = realpath ( BASE_DIR . DIRECTORY_SEPARATOR . 'locale' ) ; $ localePath .= DIRECTORY_SEPARATOR . $ locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR ; $ translations = array_merge ( $ translations , GeneratorService :: findTranslations ( SOURCE_DIR , $ locale ) ) ; $ translations = array_merge ( $ translations , GeneratorService :: findTranslations ( CORE_DIR , $ locale ) ) ; $ translations = array_merge ( $ translations , GeneratorService :: findTranslations ( CACHE_DIR , $ locale ) ) ; $ translations [ ] = "msgfmt {$localePath}translations.po -o {$localePath}translations.mo" ; $ translations [ ] = shell_exec ( 'export PATH=\$PATH:/opt/local/bin:/bin:/sbin; msgfmt ' . $ localePath . 'translations.po -o ' . $ localePath . 'translations.mo' ) ; return $ this -> render ( 'translations.html.twig' , array ( 'translations' => $ translations , ) ) ; }
Method that regenerates the translations
59,725
public function addField ( $ name , $ type , $ validationRules = array ( ) , $ errorHandlers = array ( ) , $ meta = array ( ) ) { foreach ( [ 'dynamic' , 'dynamicLabel' , 'dynamicRemoveLabel' ] as $ metaKey ) { if ( array_key_exists ( $ metaKey , $ meta ) ) { unset ( $ meta [ $ metaKey ] ) ; } } $ objField = ValidForm :: renderField ( $ name , "" , $ type , $ validationRules , $ errorHandlers , $ meta ) ; $ objField -> setMeta ( "parent" , $ this , true ) ; $ this -> __fields -> addObject ( $ objField ) ; if ( $ this -> __dynamic ) { $ intDynamicCount = ( isset ( $ meta [ "dynamicCount" ] ) ) ? $ meta [ "dynamicCount" ] : 0 ; $ objHiddenField = new Hidden ( $ objField -> getId ( ) . "_dynamic" , ValidForm :: VFORM_INTEGER , array ( "default" => $ intDynamicCount , "dynamicCounter" => true ) ) ; $ this -> __fields -> addObject ( $ objHiddenField ) ; $ objField -> setDynamicCounter ( $ objHiddenField ) ; } return $ objField ; }
Add a field to the MultiField collection .
59,726
public function addText ( $ strText , $ meta = array ( ) ) { $ objString = new StaticText ( $ strText , $ meta ) ; $ objString -> setMeta ( "parent" , $ this , true ) ; $ this -> __fields -> addObject ( $ objString ) ; return $ objString ; }
Add text to the multifield .
59,727
protected function getDynamicHtml ( ) { $ strReturn = "" ; if ( $ this -> __dynamic && ! empty ( $ this -> __dynamicLabel ) ) { $ arrFields = array ( ) ; foreach ( $ this -> __fields as $ field ) { if ( ( get_class ( $ field ) == "ValidFormBuilder\\Hidden" ) && $ field -> isDynamicCounter ( ) ) { continue ; } if ( ! empty ( $ field -> getName ( ) ) ) { $ arrFields [ $ field -> getId ( ) ] = $ field -> getName ( ) ; } } $ strReturn .= "<div class=\"vf__dynamic\">" ; $ strReturn .= "<a href=\"#\" data-target-id=\"" . implode ( "|" , array_keys ( $ arrFields ) ) . "\" data-target-name=\"" . implode ( "|" , array_values ( $ arrFields ) ) . "\"{$this->__getDynamicLabelMetaString()}>{$this->__dynamicLabel}</a>" ; $ strReturn .= "</div>" ; } return $ strReturn ; }
Generate dynamic HTML for client - side field duplication
59,728
public function hasContent ( $ intCount = 0 ) { $ blnReturn = false ; foreach ( $ this -> __fields as $ objField ) { if ( get_class ( $ objField ) !== "ValidFormBuilder\\Hidden" ) { $ objValidator = $ objField -> getValidator ( ) ; if ( is_object ( $ objValidator ) ) { $ varValue = $ objValidator -> getValue ( $ intCount ) ; if ( ! empty ( $ varValue ) ) { $ blnReturn = true ; break ; } } } } return $ blnReturn ; }
Loop through all child fields and check their values . If one value is not empty the MultiField has content .
59,729
protected function setFromMixedSource ( $ ip ) { if ( is_int ( $ ip ) || is_string ( $ ip ) ) { if ( is_int ( $ ip ) ) { $ ip = long2ip ( $ ip ) ; } if ( is_string ( $ ip ) ) { $ ip = ip2long ( $ ip ) ; } } else { $ ip = false ; } if ( $ ip === false ) { throw new \ Exception ( __METHOD__ . ' requires valid IPV4 address string in dot-notation (aaa.bbb.ccc.ddd).' ) ; } $ this -> set ( $ ip ) ; }
Format and validate for given string or integer formatted IPV4 network address .
59,730
public function get ( $ format = self :: FORMAT_LONG_NOTATION ) { return $ format === self :: FORMAT_DOTTED_NOTATION ? long2ip ( $ this -> address ) : $ this -> address ; }
Get the integer or dot - notated - string representation of the address .
59,731
protected function getCountersRecursive ( $ objFields , $ objCollection = null ) { if ( is_null ( $ objCollection ) ) { $ objCollection = new Collection ( ) ; } foreach ( $ objFields as $ objField ) { if ( $ objField instanceof Element && $ objField -> isDynamicCounter ( ) ) { $ objCollection -> addObject ( $ objField ) ; } if ( $ objField -> hasFields ( ) ) { $ this -> getCountersRecursive ( $ objField -> getFields ( ) , $ objCollection ) ; } } return $ objCollection ; }
Get a collection of fields and look for dynamic counters recursively
59,732
public function addCondition ( $ strType , $ blnValue , $ arrComparisons , $ intComparisonType = ValidForm :: VFORM_MATCH_ANY ) { if ( $ this -> hasCondition ( $ strType ) ) { $ objCondition = $ this -> getCondition ( $ strType ) ; } else { $ objCondition = new Condition ( $ this , $ strType , $ blnValue , $ intComparisonType ) ; } if ( is_array ( $ arrComparisons ) && count ( $ arrComparisons ) > 0 ) { foreach ( $ arrComparisons as $ varComparison ) { if ( is_array ( $ varComparison ) || get_class ( $ varComparison ) === "ValidFormBuilder\\Comparison" ) { try { $ objCondition -> addComparison ( $ varComparison ) ; } catch ( \ InvalidArgumentException $ e ) { throw new \ Exception ( "Could not set condition: " . $ e -> getMessage ( ) , 1 ) ; } } else { throw new \ InvalidArgumentException ( "Invalid or no comparison(s) supplied." , 1 ) ; } } array_push ( $ this -> __conditions , $ objCondition ) ; } else { throw new \ InvalidArgumentException ( "Invalid or no comparison(s) supplied." , 1 ) ; } }
Add a new condition to the current field
59,733
public function getCondition ( $ strProperty ) { $ objReturn = null ; $ objConditions = $ this -> getConditions ( ) ; foreach ( $ objConditions as $ objCondition ) { if ( $ objCondition -> getProperty ( ) === strtolower ( $ strProperty ) ) { $ objReturn = $ objCondition ; break ; } } if ( is_null ( $ objReturn ) && is_object ( $ this -> __parent ) ) { $ objReturn = $ this -> __parent -> getCondition ( $ strProperty ) ; } return $ objReturn ; }
Get element s Condition object
59,734
public function hasCondition ( $ strProperty ) { $ blnReturn = false ; foreach ( $ this -> __conditions as $ objCondition ) { if ( $ objCondition -> getProperty ( ) === strtolower ( $ strProperty ) ) { $ blnReturn = true ; break ; } } return $ blnReturn ; }
Check if the current field contains a condition object of a specific type
59,735
public function getDynamicButtonMeta ( ) { $ strReturn = "" ; $ objCondition = $ this -> getCondition ( "visible" ) ; if ( is_object ( $ objCondition ) ) { $ blnResult = $ objCondition -> isMet ( ) ; if ( $ blnResult ) { if ( ! $ objCondition -> getValue ( ) ) { $ strReturn = " style=\"display:none;\"" ; } } else { if ( $ objCondition -> getValue ( ) ) { $ strReturn = " style=\"display:none;\"" ; } } } return $ strReturn ; }
This method determines wheter or not to show the add extra field dynamic button based on it s parent s condition state .
59,736
public function setConditionalMeta ( ) { foreach ( $ this -> __conditions as $ objCondition ) { $ blnResult = $ objCondition -> isMet ( ) ; switch ( $ objCondition -> getProperty ( ) ) { case "visible" : if ( $ blnResult ) { if ( $ objCondition -> getValue ( ) ) { $ this -> setMeta ( "style" , "display: block;" ) ; } else { $ this -> setMeta ( "style" , "display: none;" ) ; } } else { if ( $ objCondition -> getValue ( ) ) { $ this -> setMeta ( "style" , "display: none;" ) ; } else { $ this -> setMeta ( "style" , "display: block;" ) ; } } case "required" : if ( get_class ( $ objCondition -> getSubject ( ) ) !== "ValidFormBuilder\\Paragraph" ) { if ( $ blnResult ) { if ( $ objCondition -> getValue ( ) ) { if ( get_class ( $ this ) !== "ValidFormBuilder\\Fieldset" ) { } } else { if ( get_class ( $ this ) !== "ValidFormBuilder\\Fieldset" ) { } } } else { if ( $ objCondition -> getValue ( ) ) { if ( get_class ( $ this ) !== "ValidFormBuilder\\Fieldset" ) { } } else { if ( get_class ( $ this ) !== "ValidFormBuilder\\Fieldset" ) { } } } } break ; case "enabled" : if ( get_class ( $ objCondition -> getSubject ( ) ) !== "ValidFormBuilder\\Paragraph" && get_class ( $ objCondition -> getSubject ( ) ) !== "ValidFormBuilder\\Group" ) { if ( $ blnResult ) { if ( $ objCondition -> getValue ( ) ) { $ this -> setFieldMeta ( "disabled" , "" , true ) ; } else { $ this -> setFieldMeta ( "disabled" , "disabled" , true ) ; } } else { if ( $ objCondition -> getValue ( ) ) { $ this -> setFieldMeta ( "disabled" , "disabled" , true ) ; } else { $ this -> setFieldMeta ( "disabled" , "" , true ) ; } } } break ; } } }
Based on which conditions are met corresponding metadata is set on the object .
59,737
public function setMeta ( $ property , $ value , $ blnOverwrite = false ) { return $ this -> __setMeta ( $ property , $ value , $ blnOverwrite ) ; }
Set meta property .
59,738
public function setFieldMeta ( $ property , $ value , $ blnOverwrite = false ) { return $ this -> __setMeta ( "field" . $ property , $ value , $ blnOverwrite ) ; }
Set field specific meta data
59,739
public function getFieldMeta ( $ property = null , $ fallbackValue = "" ) { if ( is_null ( $ property ) ) { $ varReturn = $ this -> __fieldmeta ; } elseif ( isset ( $ this -> __fieldmeta [ $ property ] ) && ! is_null ( $ this -> __fieldmeta [ $ property ] ) ) { $ varReturn = $ this -> __fieldmeta [ $ property ] ; } else { $ varReturn = $ fallbackValue ; } return $ varReturn ; }
Get field meta property .
59,740
public function setLabelMeta ( $ property , $ value , $ blnOverwrite = false ) { return $ this -> __setMeta ( "label" . $ property , $ value , $ blnOverwrite ) ; }
Set label specific meta data
59,741
public function setTipMeta ( $ property , $ value , $ blnOverwrite = false ) { return $ this -> __setMeta ( "tip" . $ property , $ value , $ blnOverwrite ) ; }
Set tip specific meta data
59,742
public function setDynamicLabelMeta ( $ property , $ value , $ blnOverwrite = false ) { return $ this -> __setMeta ( "dynamicLabel" . $ property , $ value , $ blnOverwrite ) ; }
Set dynamic label specific meta data
59,743
public function setDynamicRemoveLabelMeta ( $ property , $ value , $ blnOverwrite = false ) { return $ this -> __setMeta ( "dynamicRemoveLabel" . $ property , $ value , $ blnOverwrite ) ; }
Set dynamic remove label specific meta data
59,744
public function getMeta ( $ property = null , $ fallbackValue = "" ) { if ( is_null ( $ property ) ) { $ varReturn = $ this -> __meta ; } elseif ( isset ( $ this -> __meta [ $ property ] ) && ! is_null ( $ this -> __meta [ $ property ] ) ) { $ varReturn = $ this -> __meta [ $ property ] ; } else { $ varReturn = $ fallbackValue ; } return $ varReturn ; }
Get meta property .
59,745
public function getLabelMeta ( $ property = null , $ fallbackValue = "" ) { if ( is_null ( $ property ) ) { $ varReturn = $ this -> __labelmeta ; } elseif ( isset ( $ this -> __labelmeta [ $ property ] ) && ! is_null ( $ this -> __labelmeta [ $ property ] ) ) { $ varReturn = $ this -> __labelmeta [ $ property ] ; } else { $ varReturn = $ fallbackValue ; } return $ varReturn ; }
Get label meta property .
59,746
protected function conditionsToJs ( $ intDynamicPosition = 0 ) { $ strReturn = "" ; if ( $ this -> hasConditions ( ) && ( count ( $ this -> getConditions ( ) ) > 0 ) ) { foreach ( $ this -> getConditions ( ) as $ objCondition ) { $ strReturn .= "objForm.addCondition(" . json_encode ( $ objCondition -> jsonSerialize ( $ intDynamicPosition ) ) . ");\n" ; } } return $ strReturn ; }
Generates needed javascript initialization code for client - side conditional logic
59,747
protected function matchWithToJs ( $ intDynamicPosition = 0 ) { $ strReturn = "" ; $ objMatchWith = $ this -> getValidator ( ) -> getMatchWith ( ) ; if ( is_object ( $ objMatchWith ) ) { $ strId = ( $ intDynamicPosition == 0 ) ? $ this -> __id : $ this -> __id . "_" . $ intDynamicPosition ; $ strMatchId = ( $ intDynamicPosition == 0 ) ? $ objMatchWith -> getId ( ) : $ objMatchWith -> getId ( ) . "_" . $ intDynamicPosition ; $ strReturn = "objForm.matchfields('{$strId}', '{$strMatchId}', '" . $ this -> __validator -> getMatchWithError ( ) . "');\n" ; } return $ strReturn ; }
Generate matchWith javascript code
59,748
protected function __sanitizeCheckForJs ( $ strCheck ) { $ strCheck = ( empty ( $ strCheck ) ) ? "''" : str_replace ( "'" , "\\'" , $ strCheck ) ; $ strCheck = ( mb_substr ( $ strCheck , - 1 ) == "u" ) ? mb_substr ( $ strCheck , 0 , - 1 ) : $ strCheck ; return $ strCheck ; }
Sanitize a regular expression check for javascript .
59,749
protected function __getMetaString ( ) { $ strOutput = "" ; foreach ( $ this -> __meta as $ key => $ value ) { if ( ! in_array ( $ key , array_merge ( $ this -> __reservedmeta , $ this -> __fieldmeta ) ) ) { $ strOutput .= " {$key}=\"{$value}\"" ; } } return $ strOutput ; }
Convert meta array to html attributes + values
59,750
protected function __getFieldMetaString ( ) { $ strOutput = "" ; if ( is_array ( $ this -> __fieldmeta ) ) { foreach ( $ this -> __fieldmeta as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> __reservedmeta ) ) { $ strOutput .= " {$key}=\"{$value}\"" ; } } } return $ strOutput ; }
Convert fieldmeta array to html attributes + values
59,751
protected function __getLabelMetaString ( ) { $ strOutput = "" ; if ( is_array ( $ this -> __labelmeta ) ) { foreach ( $ this -> __labelmeta as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> __reservedmeta ) ) { $ strOutput .= " {$key}=\"{$value}\"" ; } } } return $ strOutput ; }
Convert labelmeta array to html attributes + values
59,752
protected function __getTipMetaString ( ) { $ strOutput = "" ; if ( is_array ( $ this -> __tipmeta ) ) { foreach ( $ this -> __tipmeta as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> __reservedmeta ) ) { $ strOutput .= " {$key}=\"{$value}\"" ; } } } return $ strOutput ; }
Convert tipmeta array to html attributes + values
59,753
protected function __getDynamicLabelMetaString ( ) { $ strOutput = "" ; if ( is_array ( $ this -> __dynamiclabelmeta ) ) { foreach ( $ this -> __dynamiclabelmeta as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> __reservedmeta ) ) { $ strOutput .= " {$key}=\"{$value}\"" ; } } } return $ strOutput ; }
Convert dynamiclabelmeta array to html attributes + values
59,754
protected function __getDynamicRemoveLabelMetaString ( ) { $ strOutput = "" ; if ( is_array ( $ this -> __dynamicremovelabelmeta ) ) { foreach ( $ this -> __dynamicremovelabelmeta as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> __reservedmeta ) ) { $ strOutput .= " {$key}=\"{$value}\"" ; } } } return $ strOutput ; }
Convert dynamicRemoveLabelMeta array to html attributes + values
59,755
protected function __setMeta ( $ property , $ value , $ blnOverwrite = false ) { $ internalMetaArray = & $ this -> __meta ; $ strMagicKey = null ; foreach ( $ this -> __magicmeta as $ strMagicMeta ) { if ( strpos ( strtolower ( $ property ) , strtolower ( $ strMagicMeta ) ) === 0 && strlen ( $ property ) !== strlen ( $ strMagicMeta ) ) { $ strMagicKey = $ strMagicMeta ; break ; } } if ( ! is_null ( $ strMagicKey ) ) { switch ( $ strMagicKey ) { case "field" : $ internalMetaArray = & $ this -> __fieldmeta ; $ property = strtolower ( substr ( $ property , - ( strlen ( $ property ) - 5 ) ) ) ; break ; case "label" : $ internalMetaArray = & $ this -> __labelmeta ; $ property = strtolower ( substr ( $ property , - ( strlen ( $ property ) - 5 ) ) ) ; break ; case "tip" : $ internalMetaArray = & $ this -> __tipmeta ; $ property = strtolower ( substr ( $ property , - ( strlen ( $ property ) - 3 ) ) ) ; break ; case "dynamicLabel" : $ internalMetaArray = & $ this -> __dynamiclabelmeta ; $ property = strtolower ( substr ( $ property , - ( strlen ( $ property ) - 12 ) ) ) ; break ; case "dynamicRemoveLabel" : $ internalMetaArray = & $ this -> __dynamicremovelabelmeta ; $ property = strtolower ( substr ( $ property , - ( strlen ( $ property ) - 18 ) ) ) ; break ; default : } } if ( $ blnOverwrite ) { if ( empty ( $ value ) || is_null ( $ value ) ) { unset ( $ internalMetaArray [ $ property ] ) ; } else { $ internalMetaArray [ $ property ] = $ value ; } return $ value ; } else { $ varMeta = ( isset ( $ internalMetaArray [ $ property ] ) ) ? $ internalMetaArray [ $ property ] : "" ; if ( $ property == "id" && $ varMeta != "" ) { return $ varMeta ; } switch ( $ property ) { case "style" : $ strDelimiter = ";" ; break ; default : $ strDelimiter = " " ; } $ arrMeta = ( ! is_array ( $ varMeta ) ) ? explode ( $ strDelimiter , $ varMeta ) : $ varMeta ; $ arrMeta [ ] = $ value ; $ arrMeta = array_filter ( $ arrMeta ) ; if ( strtolower ( $ property ) === 'class' ) { $ arrMeta = array_unique ( $ arrMeta ) ; } $ varMeta = implode ( $ strDelimiter , $ arrMeta ) ; $ internalMetaArray [ $ property ] = $ varMeta ; return $ varMeta ; } }
Helper method to set meta data
59,756
public function getQuery ( $ queryParams ) { return array_key_exists ( $ queryParams , $ this -> query ) ? $ this -> query [ $ queryParams ] : null ; }
Get query params
59,757
public function getRootUrl ( $ hasProtocol = true ) { $ url = $ this -> getServerName ( ) ; $ protocol = $ hasProtocol ? $ this -> getProtocol ( ) : '' ; if ( ! empty ( $ protocol ) ) { $ url = $ protocol . $ url ; } if ( ! in_array ( ( integer ) $ this -> getServer ( 'SERVER_PORT' ) , [ 80 , 443 ] , true ) ) { $ url .= ':' . $ this -> getServer ( 'SERVER_PORT' ) ; } return $ url ; }
Devuelve la url completa de base
59,758
protected function hydrateOrders ( ) { if ( count ( $ this -> query ) ) { Logger :: log ( static :: class . ' gathering query string' , LOG_DEBUG ) ; foreach ( $ this -> query as $ key => $ value ) { if ( $ key === self :: API_ORDER_FIELD && is_array ( $ value ) ) { foreach ( $ value as $ field => $ direction ) { $ this -> order -> addOrder ( $ field , $ direction ) ; } } } } }
Hydrate order from request
59,759
protected function extractPagination ( ) { Logger :: log ( static :: class . ' extract pagination start' , LOG_DEBUG ) ; $ page = array_key_exists ( self :: API_PAGE_FIELD , $ this -> query ) ? $ this -> query [ self :: API_PAGE_FIELD ] : 1 ; $ limit = array_key_exists ( self :: API_LIMIT_FIELD , $ this -> query ) ? $ this -> query [ self :: API_LIMIT_FIELD ] : 100 ; Logger :: log ( static :: class . ' extract pagination end' , LOG_DEBUG ) ; return array ( $ page , ( int ) $ limit ) ; }
Extract pagination values
59,760
private function addOrders ( ModelCriteria & $ query ) { Logger :: log ( static :: class . ' extract orders start ' , LOG_DEBUG ) ; $ orderAdded = FALSE ; $ tableMap = $ this -> getTableMap ( ) ; foreach ( $ this -> order -> getOrders ( ) as $ field => $ direction ) { if ( $ column = ApiHelper :: checkFieldExists ( $ tableMap , $ field ) ) { $ orderAdded = TRUE ; if ( $ direction === Order :: ASC ) { $ query -> addAscendingOrderByColumn ( $ column -> getPhpName ( ) ) ; } else { $ query -> addDescendingOrderByColumn ( $ column -> getPhpName ( ) ) ; } } } if ( ! $ orderAdded ) { $ pks = $ this -> getPkDbName ( ) ; foreach ( array_keys ( $ pks ) as $ key ) { $ query -> addAscendingOrderByColumn ( $ key ) ; } } Logger :: log ( static :: class . ' extract orders end' , LOG_DEBUG ) ; }
Add order fields to query
59,761
protected function addFilters ( ModelCriteria & $ query ) { if ( count ( $ this -> query ) > 0 ) { $ tableMap = $ this -> getTableMap ( ) ; foreach ( $ this -> query as $ field => $ value ) { if ( self :: API_COMBO_FIELD === $ field ) { ApiHelper :: composerComboField ( $ tableMap , $ query , $ this -> extraColumns , $ value ) ; } elseif ( ! preg_match ( '/^__/' , $ field ) ) { ApiHelper :: addModelField ( $ tableMap , $ query , $ field , $ value ) ; } } } }
Add filters fields to query
59,762
private function paginate ( ) { $ this -> list = null ; try { $ query = $ this -> prepareQuery ( ) ; $ this -> addFilters ( $ query ) ; $ this -> checkReturnFields ( $ query ) ; $ this -> addOrders ( $ query ) ; list ( $ page , $ limit ) = $ this -> extractPagination ( ) ; if ( $ limit === - 1 ) { $ this -> list = $ query -> find ( $ this -> con ) ; } else { $ this -> list = $ query -> paginate ( $ page , $ limit , $ this -> con ) ; } } catch ( \ Exception $ e ) { Logger :: log ( $ e -> getMessage ( ) , LOG_ERR ) ; } }
Generate list page for model
59,763
protected function hydrateRequestData ( ) { $ request = Request :: getInstance ( ) ; $ this -> query = array_merge ( $ this -> query , $ request -> getQueryParams ( ) ) ; $ this -> data = array_merge ( $ this -> data , $ request -> getRawData ( ) ) ; }
Hydrate data from request
59,764
public function assertNotThrows ( string $ class , callable $ execute ) : void { try { $ execute ( ) ; } catch ( ExpectationFailedException $ e ) { throw $ e ; } catch ( Throwable $ e ) { static :: assertThat ( $ e , new LogicalNot ( new ConstraintException ( $ class ) ) ) ; return ; } static :: assertThat ( null , new LogicalNot ( new ConstraintException ( $ class ) ) ) ; }
Asserts that the callable doesn t throw a specified exception .
59,765
public function assertThrows ( string $ class , callable $ execute , callable $ inspect = null ) : void { try { $ execute ( ) ; } catch ( ExpectationFailedException $ e ) { throw $ e ; } catch ( Throwable $ e ) { static :: assertThat ( $ e , new ConstraintException ( $ class ) ) ; if ( $ inspect !== null ) { $ inspect ( $ e ) ; } return ; } static :: assertThat ( null , new ConstraintException ( $ class ) ) ; }
Asserts that the callable throws a specified throwable . If successful and the inspection callable is not null then it is called and the caught exception is passed as argument .
59,766
public function cachePoints ( $ metricId , $ num = 1000 , $ page = 1 ) { if ( $ this -> cached != null ) { return $ this -> cached ; } $ this -> cached = $ this -> client -> call ( 'GET' , "metrics/$metricId/points" , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; return $ this -> cached ; }
Cache Points for performance improvement .
59,767
public function indexPoints ( $ metricId , $ num = 1000 , $ page = 1 ) { if ( $ this -> cache != false ) { return $ this -> cachePoints ( $ metricId , $ num , $ page ) ; } return $ this -> client -> call ( 'GET' , "metrics/$metricId/points" , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; }
Get a defined number of Points .
59,768
public function searchPoints ( $ metricId , $ search , $ by , $ limit = 1 , $ num = 1000 , $ page = 1 ) { $ points = $ this -> indexPoints ( $ metricId , $ num , $ page ) [ 'data' ] ; $ filtered = array_filter ( $ points , function ( $ point ) use ( $ search , $ by ) { if ( array_key_exists ( $ by , $ point ) ) { if ( strpos ( $ point [ $ by ] , $ search ) !== false ) { return $ point ; } if ( $ point [ $ by ] === $ search ) { return $ point ; } } return false ; } ) ; if ( $ limit == 1 ) { return array_shift ( $ filtered ) ; } return array_slice ( $ filtered , 0 , $ limit ) ; }
Search if a defined number of Points exists .
59,769
public function getAllRoutes ( ) { $ routes = [ ] ; foreach ( $ this -> getRoutes ( ) as $ path => $ route ) { if ( array_key_exists ( 'slug' , $ route ) ) { $ routes [ $ route [ 'slug' ] ] = $ path ; } } return $ routes ; }
Method that extract all routes in the platform
59,770
private function generateSlugs ( $ absoluteTranslationFileName ) { $ translations = I18nHelper :: generateTranslationsFile ( $ absoluteTranslationFileName ) ; foreach ( $ this -> routing as $ key => & $ info ) { $ keyParts = explode ( '#|#' , $ key ) ; $ keyParts = array_key_exists ( 1 , $ keyParts ) ? $ keyParts [ 1 ] : $ keyParts [ 0 ] ; $ slug = RouterHelper :: slugify ( $ keyParts ) ; if ( NULL !== $ slug && ! array_key_exists ( $ slug , $ translations ) ) { $ translations [ $ slug ] = $ info [ 'label' ] ; file_put_contents ( $ absoluteTranslationFileName , "\$translations[\"{$slug}\"] = t(\"{$info['label']}\");\n" , FILE_APPEND ) ; } $ this -> slugs [ $ slug ] = $ key ; $ info [ 'slug' ] = $ slug ; } }
Parse slugs to create translations
59,771
public function setSystemMessageType ( $ messageType ) : Envelope { if ( ! in_array ( $ messageType , static :: getLetterTypeOptions ( ) ) ) { throw new InvalidArgumentException ( sprintf ( 'Property %s is not supported for %s' , $ messageType , __FUNCTION__ ) ) ; } $ this -> data [ 'letterType' ] [ 'systemMessageType' ] = $ messageType ; return $ this ; }
Specify the type of E - POST letter
59,772
public function addRecipientPrinted ( Recipient \ Hybrid $ recipient ) : Envelope { if ( $ this -> isNormalLetter ( ) ) { throw new LogicException ( sprintf ( 'Can not set recipientsPrinted if message type is "%s"' , self :: LETTER_TYPE_NORMAL ) ) ; } if ( count ( $ this -> getRecipients ( ) ) ) { throw new LogicException ( 'It must not be set more than one printed recipient' ) ; } $ this -> data [ 'recipientsPrinted' ] [ ] = $ recipient ; return $ this ; }
Add a hybrid recipient for printed letters
59,773
public function getRecipients ( ) { switch ( $ this -> getSystemMessageType ( ) ) { case self :: LETTER_TYPE_NORMAL : return $ this -> data [ 'recipients' ] ; break ; case self :: LETTER_TYPE_HYBRID : return $ this -> data [ 'recipientsPrinted' ] ; break ; } return null ; }
Get the recipients added to the envelope
59,774
public function getEnvelope ( ) : Envelope { if ( null === $ this -> envelope ) { throw new MissingEnvelopeException ( 'No Envelope provided! Provide one beforehand' ) ; } if ( empty ( $ this -> envelope -> getRecipients ( ) ) ) { throw new MissingRecipientException ( 'No recipients provided! Add them beforehand' ) ; } return $ this -> envelope ; }
Get the envelope
59,775
public function setDeliveryOptions ( DeliveryOptions $ deliveryOptions ) : Letter { if ( $ this -> envelope && $ this -> envelope -> isNormalLetter ( ) ) { throw new LogicException ( 'Delivery options are not supported for non-printed letters.' ) ; } $ this -> deliveryOptions = $ deliveryOptions ; return $ this ; }
Set the delivery options
59,776
public function getPostageInfo ( ) { if ( null === $ this -> postageInfo ) { throw new MissingPreconditionException ( 'No postage info provided! Provide them beforehand' ) ; } if ( null === $ this -> postageInfo -> getDeliveryOptions ( ) && null !== $ this -> getDeliveryOptions ( ) ) { $ this -> postageInfo -> setDeliveryOptions ( $ this -> getDeliveryOptions ( ) ) ; } if ( ! $ this -> postageInfo -> getLetterSize ( ) && $ this -> postageInfo -> isNormalLetter ( ) && $ this -> attachments ) { $ size = array_reduce ( $ this -> attachments , function ( $ carry , $ path ) { $ carry += filesize ( $ path ) ; return $ carry ; } , 0 ) ; $ this -> postageInfo -> setLetterSize ( ceil ( $ size / 1048576 ) ) ; } return $ this -> postageInfo ; }
Get the postage info
59,777
public function create ( ) : Letter { $ multipartElements = [ [ 'name' => 'envelope' , 'contents' => \ GuzzleHttp \ json_encode ( $ this -> getEnvelope ( ) ) , 'headers' => [ 'Content-Type' => $ this -> getEnvelope ( ) -> getMimeType ( ) ] , ] , ] ; if ( $ this -> getCoverLetter ( ) ) { $ multipartElements [ ] = [ 'name' => 'cover_letter' , 'contents' => $ this -> getCoverLetter ( ) , 'headers' => [ 'Content-Type' => 'text/html' ] , ] ; } foreach ( $ this -> getAttachments ( ) as $ attachment ) { $ multipartElements [ ] = [ 'name' => 'file' , 'contents' => fopen ( $ attachment , 'rb' ) , 'headers' => [ 'Content-Type' => static :: getMimeTypeOfFile ( $ attachment ) ] , ] ; } $ multipart = new MultipartStream ( $ multipartElements ) ; $ requestOptions = [ 'headers' => [ 'Content-Type' => 'multipart/mixed; boundary=' . $ multipart -> getBoundary ( ) , ] , 'body' => $ multipart , ] ; $ response = $ this -> getHttpClientForMailbox ( ) -> request ( 'POST' , '/letters' , $ requestOptions ) ; $ data = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ; $ this -> setLetterId ( $ data -> letterId ) ; return $ this ; }
Create a draft by given envelope and attachments
59,778
public function send ( ) : Letter { $ options = [ 'headers' => [ 'Content-Source' => $ this -> getEndpointMailbox ( ) . '/letters/' . $ this -> getLetterId ( ) , ] , ] ; if ( $ this -> getEnvelope ( ) -> isHybridLetter ( ) && null !== $ this -> getDeliveryOptions ( ) ) { $ options [ 'headers' ] [ 'Content-Type' ] = $ this -> getDeliveryOptions ( ) -> getMimeType ( ) ; $ options [ 'json' ] = $ this -> getDeliveryOptions ( ) ; } $ this -> getHttpClientForSend ( ) -> request ( 'POST' , '/deliveries' , $ options ) ; return $ this ; }
Send the given letter . Delivery options should be set optionally for physical letters
59,779
private static function getMimeTypeOfFile ( $ path ) { $ fileInfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ mime = finfo_file ( $ fileInfo , $ path ) ; finfo_close ( $ fileInfo ) ; return $ mime ; }
Get a file s mime type
59,780
public function getCharacter ( $ characterId , $ fields = [ '*' ] ) { $ apiUrl = $ this -> getEndpoint ( 'characters' ) ; $ apiUrl .= $ characterId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get character information
59,781
public function getCompany ( $ companyId , $ fields = [ '*' ] ) { $ apiUrl = $ this -> getEndpoint ( 'companies' ) ; $ apiUrl .= $ companyId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get company information by ID
59,782
public function getFranchise ( $ franchiseId , $ fields = [ '*' ] ) { $ apiUrl = $ this -> getEndpoint ( 'franchises' ) ; $ apiUrl .= $ franchiseId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get franchise information
59,783
public function getGameMode ( $ gameModeId , $ fields = [ 'name' , 'slug' , 'url' ] ) { $ apiUrl = $ this -> getEndpoint ( 'game_modes' ) ; $ apiUrl .= $ gameModeId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get game mode information by ID
59,784
public function searchGameModes ( $ search , $ fields = [ 'name' , 'slug' , 'url' ] , $ limit = 10 , $ offset = 0 ) { $ apiUrl = $ this -> getEndpoint ( 'game_modes' ) ; $ params = array ( 'fields' => implode ( ',' , $ fields ) , 'limit' => $ limit , 'offset' => $ offset , 'search' => $ search , ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeMultiple ( $ apiData ) ; }
Search game modes by name
59,785
public function getGame ( $ gameId , $ fields = [ '*' ] ) { $ apiUrl = $ this -> getEndpoint ( 'games' ) ; $ apiUrl .= $ gameId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get game information by ID
59,786
public function searchGames ( $ search , $ fields = [ '*' ] , $ limit = 10 , $ offset = 0 , $ order = null ) { $ apiUrl = $ this -> getEndpoint ( 'games' ) ; $ params = array ( 'fields' => implode ( ',' , $ fields ) , 'limit' => $ limit , 'offset' => $ offset , 'order' => $ order , 'search' => $ search , ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeMultiple ( $ apiData ) ; }
Search games by name
59,787
public function getGenre ( $ genreId , $ fields = [ 'name' , 'slug' , 'url' ] ) { $ apiUrl = $ this -> getEndpoint ( 'genres' ) ; $ apiUrl .= $ genreId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get genre information by ID
59,788
public function getKeyword ( $ keywordId , $ fields = [ 'name' , 'slug' , 'url' ] ) { $ apiUrl = $ this -> getEndpoint ( 'keywords' ) ; $ apiUrl .= $ keywordId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get keyword information by ID
59,789
public function getPerson ( $ personId , $ fields = [ '*' ] ) { $ apiUrl = $ this -> getEndpoint ( 'people' ) ; $ apiUrl .= $ personId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get people information by ID
59,790
public function getPlatform ( $ platformId , $ fields = [ 'name' , 'logo' , 'slug' , 'url' ] ) { $ apiUrl = $ this -> getEndpoint ( 'platforms' ) ; $ apiUrl .= $ platformId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get platform information by ID
59,791
public function getPlayerPerspective ( $ perspectiveId , $ fields = [ 'name' , 'slug' , 'url' ] ) { $ apiUrl = $ this -> getEndpoint ( 'player_perspectives' ) ; $ apiUrl .= $ perspectiveId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get player perspective information by ID
59,792
public function getPulse ( $ pulseId , $ fields = [ '*' ] ) { $ apiUrl = $ this -> getEndpoint ( 'pulses' ) ; $ apiUrl .= $ pulseId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get pulse information by ID
59,793
public function fetchPulses ( $ fields = [ '*' ] , $ limit = 10 , $ offset = 0 ) { $ apiUrl = $ this -> getEndpoint ( 'pulses' ) ; $ params = array ( 'fields' => implode ( ',' , $ fields ) , 'limit' => $ limit , 'offset' => $ offset ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeMultiple ( $ apiData ) ; }
Search pulses by title
59,794
public function getCollection ( $ collectionId , $ fields = [ '*' ] ) { $ apiUrl = $ this -> getEndpoint ( 'collections' ) ; $ apiUrl .= $ collectionId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get collection information by ID
59,795
public function getTheme ( $ themeId , $ fields = [ 'name' , 'slug' , 'url' ] ) { $ apiUrl = $ this -> getEndpoint ( 'themes' ) ; $ apiUrl .= $ themeId ; $ params = array ( 'fields' => implode ( ',' , $ fields ) ) ; $ apiData = $ this -> apiGet ( $ apiUrl , $ params ) ; return $ this -> decodeSingle ( $ apiData ) ; }
Get themes information by ID
59,796
private function decodeMultiple ( & $ apiData ) { $ resObj = json_decode ( $ apiData ) ; if ( isset ( $ resObj -> status ) ) { $ msg = "Error " . $ resObj -> status . " " . $ resObj -> message ; throw new \ Exception ( $ msg ) ; } else { if ( ! is_array ( $ resObj ) ) { return false ; } else { return $ resObj ; } } }
Decode the response from IGDB extract the multiple resource object .
59,797
private function checkAuth ( ) { $ namespace = explode ( '\\' , $ this -> getModelTableMap ( ) ) ; $ module = strtolower ( $ namespace [ 0 ] ) ; $ secret = Config :: getInstance ( ) -> get ( $ module . '.api.secret' ) ; if ( NULL === $ secret ) { $ secret = Config :: getInstance ( ) -> get ( "api.secret" ) ; } if ( NULL === $ secret ) { $ auth = TRUE ; } else { $ token = Request :: getInstance ( ) -> getHeader ( 'X-API-SEC-TOKEN' ) ; if ( array_key_exists ( 'API_TOKEN' , $ this -> query ) ) { $ token = $ this -> query [ 'API_TOKEN' ] ; } $ auth = SecurityHelper :: checkToken ( $ token ? : '' , $ secret , $ module ) ; } return $ auth || $ this -> isAdmin ( ) ; }
Check service authentication
59,798
public function cacheGroups ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cached != null ) { return $ this -> cached ; } $ this -> cached = $ this -> client -> call ( 'GET' , 'components/groups' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; return $ this -> cached ; }
Cache Group for performance improvement .
59,799
public function indexGroups ( $ num = 1000 , $ page = 1 ) { if ( $ this -> cache != false ) { return $ this -> cacheGroups ( $ num , $ page ) ; } return $ this -> client -> call ( 'GET' , 'components/groups' , [ 'query' => [ 'per_page' => $ num , 'current_page' => $ page , ] , ] ) ; }
Get a defined number of Groups .