idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
20,100
public static function Join ( $ sKey , $ sAppend ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; return ( array_key_exists ( $ sKey , $ oThis -> aList ) ) ? ( ( is_string ( $ oThis -> aList [ $ sKey ] ) ) ? $ oThis -> aList [ $ sKey ] . $ sAppend : false ) : false ; }
Function to concatenate data stored
20,101
public static function AssignSmarty ( & $ oSmarty ) { $ oThis = self :: CreateInstanceIfNotExists ( ) ; $ aStorage = Storage :: GetList ( ) ; $ oSmartyVars = array ( ) ; function ReturnSubKeys ( $ sKeyRoot , $ mValue ) { $ aKey = explode ( "." , $ sKeyRoot ) ; $ aArray = array ( ) ; if ( count ( $ aKey ) > 1 ) { $ aSubKeys = ReturnSubKeys ( str_replace ( $ aKey [ 0 ] . "." , "" , $ sKeyRoot ) , $ mValue ) ; $ aArray [ $ aSubKeys [ "key" ] ] = @ ( is_array ( $ aArray [ $ aSubKeys [ "key" ] ] ) ? @ array_merge_recursive ( $ aArray [ $ aSubKeys [ "key" ] ] , $ aSubKeys [ "result" ] ) : $ aSubKeys [ "result" ] ) ; return array ( "result" => $ aArray , "key" => $ aKey [ 0 ] ) ; } else { return array ( "result" => $ mValue , "key" => $ sKeyRoot ) ; } } foreach ( $ aStorage as $ sKey => $ mValue ) { $ aResult = ReturnSubKeys ( $ sKey , $ mValue ) ; $ oSmartyVars [ $ aResult [ "key" ] ] = @ ( is_array ( $ oSmartyVars [ $ aResult [ "key" ] ] ) ? @ array_merge_recursive ( $ oSmartyVars [ $ aResult [ "key" ] ] , $ aResult [ "result" ] ) : $ aResult [ "result" ] ) ; $ oSmarty -> assign ( $ aResult [ "key" ] , $ oSmartyVars [ $ aResult [ "key" ] ] ) ; } }
Function to transform the variables Storage variables in Smarty Template Engine
20,102
private function getFileNameFor ( string $ name , string $ sourceLanguage , string $ targetLanguage ) : string { if ( '' !== $ this -> subDirectoryMask ) { return $ this -> rootDir . DIRECTORY_SEPARATOR . strtr ( $ this -> subDirectoryMask , [ '{source}' => $ sourceLanguage , '{target}' => $ targetLanguage ] ) . DIRECTORY_SEPARATOR . $ name . '.xlf' ; } return $ this -> rootDir . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $ name . '.xlf' ; }
Generate the file name for a dictionary .
20,103
private function getFinder ( ) : \ Iterator { return Finder :: create ( ) -> in ( $ this -> rootDir ) -> ignoreUnreadableDirs ( ) -> files ( ) -> name ( '*.xlf' ) -> getIterator ( ) ; }
Create a finder instance .
20,104
private function guardLanguages ( string $ sourceLanguage , string $ targetLanguage , DictionaryInterface $ dictionary ) : void { if ( $ dictionary -> getSourceLanguage ( ) !== $ sourceLanguage || $ dictionary -> getTargetLanguage ( ) !== $ targetLanguage ) { throw new LanguageMismatchException ( $ sourceLanguage , $ dictionary -> getSourceLanguage ( ) , $ targetLanguage , $ dictionary -> getTargetLanguage ( ) ) ; } }
Guard the language .
20,105
public function getLastCurlBracketPositionFromClass ( $ domainClass ) { $ matches = [ ] ; $ lastClassCurlBracketPattern = "/\}[ \r\n]*[^{}]\$/" ; preg_match ( $ lastClassCurlBracketPattern , $ domainClass . " " , $ matches , PREG_OFFSET_CAPTURE ) ; $ lastClassBracketIdx = $ matches [ 0 ] [ 1 ] ; if ( $ lastClassBracketIdx == 0 ) { throw new \ Exception ( "Can't append function" ) ; } return $ lastClassBracketIdx ; }
Get the Last Curl Bracket of a class
20,106
public function addSchemaToClassBottom ( $ domainClass , $ actionSchema ) { $ lastClassBracketIdx = $ this -> getLastCurlBracketPositionFromClass ( $ domainClass ) ; $ domainClass = substr_replace ( $ domainClass , $ actionSchema , $ lastClassBracketIdx ) ; $ domainClass .= "\n}" ; return $ domainClass ; }
Append an action schema to an existing class
20,107
public function createDomain ( string $ domainName , string $ synopsis , string $ enabledString , bool $ force = false ) : bool { $ domainClassName = DomainActionNameGenerator :: getDomainClassName ( $ domainName ) ; $ domainSchemaCode = $ this -> fileMan -> loadSchemaCode ( "Domain" ) ; $ this -> generatingDomainMsg ( $ domainName ) ; if ( $ domainSchemaCode != null ) { if ( $ enabledString == "false" ) { $ this -> domainGeneratedAsDisabledMsg ( ) ; } $ this -> setSynopsisMsg ( $ synopsis ) ; $ this -> replaceParam ( "DOMAINNAME" , $ domainClassName , $ domainSchemaCode ) ; $ this -> replaceParam ( "SYNOPSIS" , $ synopsis , $ domainSchemaCode ) ; $ this -> replaceParam ( "ENABLED" , $ enabledString , $ domainSchemaCode ) ; $ isStored = $ this -> fileMan -> storeDomainCode ( $ domainName , $ domainSchemaCode , $ force ) ; if ( $ isStored ) { $ this -> domainCreatedMsg ( $ domainClassName ) ; return true ; } $ this -> domainNotCreatedMsg ( $ domainClassName ) ; return false ; } $ this -> schemaNotFoundMsg ( $ domainName ) ; return false ; }
Create a domain class
20,108
public function disableDomain ( string $ domainName ) { $ domainClassCode = $ this -> fileMan -> loadDomainCode ( $ domainName ) ; $ domainClassCode = str_replace ( "@SET\DomainEnabled(true)" , "@SET\DomainEnabled(false)" , $ domainClassCode ) ; return $ this -> fileMan -> storeDomainCode ( $ domainName , $ domainClassCode , true ) ; }
Disable an existing domain
20,109
private function isActionMethodAlreadyPresent ( string $ actionName , string $ domainClassCode ) : bool { $ functionPattern = '/public function[ \t\n\r]+' . $ actionName . '[ \t\n\r]*\([ \t\r\n]*.*[ \t\r\n]*\)/' ; return preg_match ( $ functionPattern , $ domainClassCode ) > 0 ? true : false ; }
Check if the Action method is already present in the domain class code
20,110
private function getRemoteHostname ( ) { $ hostname = NULL ; if ( ! is_null ( $ this -> ip ) ) { $ hostname = gethostbyaddr ( $ this -> ip ) ; } return $ hostname ; }
Permite obtener el hostname de la IP
20,111
private function getIpForwarded ( ) { if ( ! ! $ this -> isHttpXForwardedFor ( ) ) { $ entries = $ this -> getHttpXForwardedForEntities ( ) ; $ this -> ip = $ this -> getXForwardedIp ( $ entries ) ; } }
Permite obtener la IP proveniente de un servidor proxy
20,112
private function getXForwardedIp ( $ entries ) { $ ip = $ this -> ip ; while ( list ( , $ entry ) = each ( $ entries ) ) { $ entry = trim ( $ entry ) ; if ( preg_match ( "/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/" , $ entry , $ ip_list ) ) { $ found_ip = preg_replace ( $ this -> privateIp , $ ip , $ ip_list [ 1 ] ) ; if ( $ ip != $ found_ip ) { $ ip = $ found_ip ; break ; } } } return $ ip ; }
Permite obtener la IP real proveniente de un servidor proxy .
20,113
private function getRemodeAddr ( ) { $ ip = NULL ; if ( PHP_SAPI == 'cli' ) { $ ip = gethostbyname ( gethostname ( ) ) ; } elseif ( $ this -> hasServerRemoteAddr ( ) ) { $ ip = $ this -> server [ 'REMOTE_ADDR' ] ; } elseif ( $ this -> hasEnvRemoteAddr ( ) ) { $ ip = $ this -> env [ 'REMOTE_ADDR' ] ; } return $ ip ; }
Permite obtener la IP real del cliente .
20,114
private function _parseArgs ( array $ args ) { $ arg = '' ; if ( count ( $ args ) > 0 ) { foreach ( $ args as $ number => $ argument ) { if ( $ number === 0 ) { $ arg .= $ argument ; } else { $ arg .= ', ' . $ argument ; } } } return $ arg ; }
This method parse the argument that should passed to the MySql Function .
20,115
public function write ( $ file , $ settings ) { $ file = '/settings/' . $ file ; $ settings = json_decode ( json_encode ( $ settings ) , true ) ; $ settings = $ this -> yaml -> dump ( $ settings ) ; $ this -> source_filesystem -> put ( $ file . '.yml' , $ settings ) ; }
Writes a settings file .
20,116
public function read ( $ file ) { $ file = '/settings/' . $ file ; $ result = [ ] ; if ( $ this -> source_filesystem -> has ( $ file . '.yml' ) ) { $ result = $ this -> yaml -> parse ( $ this -> source_filesystem -> read ( $ file . '.yml' ) ) ; } return $ result ; }
Reads a settings file .
20,117
public static function conceive ( $ options = array ( ) ) { if ( is_callable ( $ options ) ) { $ options = call_user_func ( $ options ) ; } static :: _initializeCache ( ) ; static :: $ _options = Option :: merge ( static :: $ _options , $ options ) ; if ( false === ( $ _conceived = static :: get ( CoreSettings :: CONCEPTION ) ) ) { \ register_shutdown_function ( function ( $ eventName = KismaEvents :: DEATH ) { \ Kisma :: __sleep ( ) ; EventManager :: trigger ( $ eventName ) ; } ) ; Detector :: framework ( ) ; static :: set ( CoreSettings :: CONCEPTION , true ) ; if ( null === static :: get ( CoreSettings :: AUTO_LOADER ) && class_exists ( '\\ComposerAutoloaderInit' , false ) ) { static :: set ( CoreSettings :: AUTO_LOADER , \ ComposerAutoloaderInit :: getLoader ( ) ) ; } EventManager :: trigger ( KismaEvents :: BIRTH ) ; } static :: __wakeup ( ) ; return $ _conceived ; }
Plant the seed of life into Kisma!
20,118
protected static function _initializeCache ( ) { if ( ! static :: $ _options [ CoreSettings :: ENABLE_CACHE ] ) { return false ; } try { return static :: $ _cache = Flexistore :: createMemcachedStore ( array ( 'host' => 'localhost' ) ) ; } catch ( \ Exception $ _ex ) { } try { return static :: $ _cache = Flexistore :: createMemcacheStore ( array ( 'host' => 'localhost' ) ) ; } catch ( \ Exception $ _ex ) { } if ( false === ( $ _path = static :: _getCachePath ( ) ) ) { return false ; } return static :: $ _cache = Flexistore :: createFileStore ( $ _path ) ; }
Initialize my settings cache ...
20,119
public function getTreeByCalcId ( $ calcId ) { $ where = Entity :: A_CALC_ID . '=' . ( int ) $ calcId ; $ entities = $ this -> get ( $ where ) ; $ result = [ ] ; foreach ( $ entities as $ entity ) { $ result [ ] = $ entity -> get ( ) ; } return $ result ; }
Get compressed tree for given calculation .
20,120
protected function getFactories ( ) { $ escaper = $ this -> escaper ; $ input = ( new AuraFactory ( ) ) -> newInputInstance ( ) ; $ factories = [ 'escape' => function ( ) use ( $ escaper ) { return $ escaper ; } , 'input' => function ( ) use ( $ input ) { return $ input ; } ] ; foreach ( $ this -> helpers as $ name => $ class ) { $ factories [ $ name ] = function ( ) use ( $ class , $ escaper ) { return new $ class ( $ escaper ) ; } ; } return $ factories ; }
create array of factories
20,121
public static function get ( ) { if ( sizeof ( func_num_args ( ) ) == 0 ) { echo 'No arguments passed for this resource' ; exit ( ) ; } $ args = func_get_args ( ) ; $ key = array_shift ( $ args ) ; if ( isset ( self :: $ instances [ $ key ] ) ) { return self :: $ instances [ $ key ] ; } else { if ( in_array ( $ key , self :: $ resources ) ) { $ instance = self :: getInstance ( $ key , $ args ) ; if ( $ instance ) $ set = self :: setInstance ( $ key , $ instance ) ; if ( $ set ) return self :: $ instances [ $ key ] ; } else { echo "We have decided to throw an exception" ; } } }
This method gets the occurance of an object instances and returns the object instance
20,122
public static function setConfig ( $ config ) { self :: $ errorFilePath = dirname ( dirname ( __FILE__ ) ) . '/Exceptions/' ; self :: $ config = $ config ; }
This method sets the configuration settings of this application
20,123
private static function getInstance ( $ key , $ args ) { $ key = 'get' . ucfirst ( $ key ) ; $ instance = self :: { "{$key}" } ( $ args ) ; return $ instance ; }
This method gets and returns the object instance of a resource
20,124
public static function getDatabase ( ) { global $ database ; $ instance = new BaseDb ( $ database [ 'default' ] , $ database [ $ database [ 'default' ] ] ) ; $ instance = $ instance -> initialize ( ) -> connect ( ) ; return $ instance ; }
This method returns an instance of the database class
20,125
public function combine ( $ reporter ) { $ this -> passed += $ reporter -> passed ; $ this -> failed += $ reporter -> failed ; }
Takes the reported values in the incoming Reporter and adds them to this one s values .
20,126
public function pass ( ) { if ( $ this -> output && ! $ this -> output -> isQuiet ( ) ) { $ this -> output -> write ( "." ) ; } $ this -> passed += 1 ; }
Increments the number of passed tests .
20,127
public function fail ( $ label , $ computed , $ test , $ expected ) { if ( $ this -> output && ! $ this -> output -> isQuiet ( ) ) { $ this -> output -> write ( "<fg=red>F</fg=red>" ) ; } $ this -> failed += 1 ; $ this -> failures [ ] = array ( 'label' => $ label , 'computed' => $ computed , 'test' => $ test , 'expected' => $ expected ) ; }
Increments the number of failed tests .
20,128
protected static function fixDynModulesCache ( $ cache ) { $ result = [ ] ; foreach ( $ cache as $ numMid => $ info ) { $ expParentUid = $ parentNumber = $ info [ 'parent_uid' ] ; while ( ! empty ( $ parentNumber ) ) { if ( empty ( $ cache [ $ parentNumber ] [ 'parent_uid' ] ) ) break ; else $ parentNumber = $ cache [ $ parentNumber ] [ 'parent_uid' ] ; $ expParentUid = $ parentNumber . '/' . $ expParentUid ; } $ cache [ $ numMid ] [ 'parent_uid_expanded' ] = $ expParentUid ; $ cache [ $ numMid ] [ 'module_uid_expanded' ] = ( empty ( $ expParentUid ) ? '' : ( $ expParentUid . '/' ) ) . $ numMid ; $ idx = static :: fromnumberModuleUniqueId ( $ cache [ $ numMid ] [ 'module_uid_expanded' ] ) ; $ result [ $ idx ] = $ cache [ $ numMid ] ; } return $ result ; }
Expand one - number module s uniqueId into chain
20,129
public static function registeredModuleName ( $ moduleUid ) { if ( ! empty ( static :: $ _dynModulesCache [ $ moduleUid ] [ 'name' ] ) ) { $ name = static :: $ _dynModulesCache [ $ moduleUid ] [ 'name' ] ; return $ name ; } return false ; }
Get name of registered module or false if not refistered
20,130
protected function fixUrlPrefixes ( $ moduleUid , $ routesConfig ) { $ result = [ ] ; $ module = Yii :: $ app -> getModule ( $ moduleUid ) ; foreach ( $ routesConfig as $ type => $ config ) { $ urlPrefix = RoutesBuilder :: correctUrlPrefix ( '' , $ module , $ type ) ; if ( ! empty ( $ urlPrefix ) ) { if ( is_string ( $ config ) ) { $ config = $ urlPrefix ; } elseif ( is_array ( $ config ) ) { $ config [ 'urlPrefix' ] = $ urlPrefix ; } } $ result [ $ type ] = $ config ; } return $ result ; }
Correct URL prefixes
20,131
public function draw ( $ name ) { $ this -> bstall -> load ( $ name ) ; $ pixels = Input :: get ( 'pixels' ) ; foreach ( $ pixels as $ p ) { if ( isset ( $ p [ 'x' ] ) && isset ( $ p [ 'y' ] ) && isset ( $ p [ 'c' ] ) ) { $ this -> bstall -> write ( $ p [ 'x' ] , $ p [ 'y' ] , $ p [ 'c' ] ) ; } } $ this -> bstall -> save ( $ name ) ; return Response :: json ( [ "success" => true ] ) ; }
Scratch onto the stall
20,132
public function map ( $ callback ) { $ values = $ this -> _map ( $ callback ) ; $ this -> setValues ( $ values ) ; return new Collection ( $ values ) ; }
Applies a callback to all elements
20,133
public static function run ( $ wizardDescription , $ params = [ ] ) { $ runner = self :: getRunner ( $ params ) ; $ runner -> setWizardDescription ( $ wizardDescription ) ; $ runner -> go ( $ params ) ; }
The main entry point for the anyen framework s wizards . Users of the framework call this method to execute their wizards .
20,134
public function getValidator ( ) { if ( ! $ this -> validator ) { $ this -> setValidator ( $ this -> validatorFactory -> createValidator ( $ this -> form ) ) ; } return $ this -> validator ; }
Return the setted validator whatever validator it is
20,135
public function setValidator ( $ validator ) { $ this -> callBeforeListeners ( 'setValidator' , [ $ validator ] ) ; $ this -> validator = $ validator ; $ this -> callAfterListeners ( 'setValidator' , [ $ validator ] ) ; }
Set a validator of any type the broker has to care about it
20,136
private function taxonomyAddDefaultTerms ( $ parent , $ terms ) { foreach ( $ terms as $ term ) { return $ this -> addDefaultTaxTerm ( $ parent , $ terms ) ; } }
Adds default terms to taxonomy
20,137
private function registerTaxonomy ( $ tax , $ cpt_singular , $ cpt_plural ) { $ singular_name = $ this -> getSingularTaxName ( $ tax ) ; $ plural_name = $ this -> getPluralTaxName ( $ tax ) ; $ hierarchical = isset ( $ tax [ 'hierarchical' ] ) ? $ tax [ 'hierarchical' ] : true ; $ default_terms = isset ( $ tax [ 'default_terms' ] ) ? $ tax [ 'default_terms' ] : [ ] ; $ builder = new Cpt ; $ args = [ 'public' => true , 'show_ui' => true , 'show_in_nav_menus' => true , 'show_admin_column' => true , 'hierarchical' => $ hierarchical , 'query_var' => $ singular_name , 'capabilities' => $ this -> getCapabilities ( $ cpt_singular , $ cpt_plural ) , 'labels' => $ this -> getLabels ( $ tax ) ] ; register_taxonomy ( $ singular_name , [ $ cpt_singular ] , $ args ) ; $ this -> taxonomyAddDefaultTerms ( $ singular_name , $ default_terms ) ; }
Register taxonomies for the plugin . \
20,138
public static function encode ( String $ string ) : String { $ secBadChars = self :: $ scriptBadChars ; if ( ! empty ( $ secBadChars ) ) { foreach ( $ secBadChars as $ badChar => $ changeChar ) { if ( is_numeric ( $ badChar ) ) { $ badChar = $ changeChar ; $ changeChar = '' ; } $ badChar = trim ( $ badChar , '/' ) ; $ string = preg_replace ( '/' . $ badChar . '/xi' , $ changeChar , $ string ) ; } } return $ string ; }
Encode Cross Site Scripting
20,139
public function check ( $ token , array $ options = [ ] ) { $ conditions = compact ( 'token' ) ; foreach ( [ 'user_id' , 'type' ] as $ key ) { $ conditions [ $ key ] = array_key_exists ( $ key , $ options ) ? $ options [ $ key ] : null ; } return ! $ this -> find ( $ conditions ) -> isEmpty ( ) ; }
Checks if a token exists and is active .
20,140
public function create ( $ token , array $ options = [ ] ) { $ entity = new Token ( compact ( 'token' ) ) ; foreach ( [ 'user_id' , 'type' , 'extra' , 'expiry' ] as $ key ) { if ( array_key_exists ( $ key , $ options ) ) { $ entity -> set ( $ key , $ options [ $ key ] ) ; } } if ( ! $ this -> getTable ( ) -> save ( $ entity ) ) { $ field = collection ( array_keys ( $ entity -> getErrors ( ) ) ) -> first ( ) ; $ error = collection ( collection ( ( $ entity -> getErrors ( ) ) ) -> first ( ) ) -> first ( ) ; throw new LogicException ( sprintf ( 'Error for `%s` field: %s' , $ field , lcfirst ( $ error ) ) ) ; } return $ entity -> token ; }
Creates a token .
20,141
public function delete ( $ token ) { $ query = $ this -> find ( compact ( 'token' ) ) ; return $ query -> count ( ) ? $ this -> getTable ( ) -> delete ( $ query -> first ( ) ) : false ; }
Deletes a token
20,142
private function setCustomRoutesFromConfig ( ) { $ configgeration = Registry :: ahoy ( ) -> get ( 'routes' ) ; foreach ( $ configgeration as $ route => $ options ) { $ this -> routes [ ] = new Route ( $ route , $ options ) ; } }
gets custom routes from config
20,143
private function setParams ( ) { $ method = $ this -> request -> getMethod ( ) ; $ getParams = $ this -> request -> getQueryParams ( ) ; $ postParams = $ this -> request -> getParsedBody ( ) ; if ( $ method == "POST" && is_array ( $ postParams ) ) { $ this -> params = array_merge ( $ this -> params , $ postParams ) ; } $ this -> params = array_merge ( $ this -> params , $ getParams ) ; }
Merges params from config
20,144
public function parseRoute ( ) { $ this -> sailHome ( ) ; $ path = $ this -> uri ; if ( $ path != '/' ) { $ this -> setCustomRoutesFromConfig ( ) ; $ this -> matchRoute ( ) ; } $ this -> setParams ( ) ; }
Figger out where we be goin
20,145
public function setupWithArray ( Array $ arrData ) { foreach ( $ arrData as $ strProperty => $ mixOptions ) { if ( ! is_array ( $ mixOptions ) ) { $ strProperty = $ mixOptions ; $ mixOptions = array ( ) ; } $ strProperty = $ this -> _formatPropertyName ( $ strProperty ) ; $ this -> _arrProperties [ ] = $ strProperty ; $ this -> _arrOptions [ $ strProperty ] = new SynthesizeOption ( $ mixOptions ) ; $ this -> _arrData [ $ strProperty ] = $ this -> _create ( $ this -> _arrOptions [ $ strProperty ] ) ; } }
Setup With Array Method
20,146
public function setupWithJSON ( $ strData ) { if ( $ arrData = json_decode ( $ strData , true ) ) { $ this -> setupWithArray ( $ arrData ) ; } else { throw new InvalidJSONException ( $ strData ) ; } }
Setup With JSON Method
20,147
public function asObject ( $ strProperty ) { $ strProperty = $ this -> _formatPropertyName ( $ strProperty ) ; return $ this -> _arrData [ $ strProperty ] -> asObject ( ) ; }
As Object Method
20,148
public function setObject ( $ strProperty , $ mixValue ) { $ strProperty = $ this -> _formatPropertyName ( $ strProperty ) ; $ this -> _arrData [ $ strProperty ] = $ mixValue ; }
Set Object Method
20,149
public function hasProperty ( $ strProperty ) { $ strProperty = $ this -> _formatPropertyName ( $ strProperty ) ; if ( in_array ( $ strProperty , $ this -> _arrProperties ) ) { return true ; } return false ; }
Has Property Method
20,150
public function getHeaders ( $ name ) { $ ucName = strtoupper ( $ name ) ; if ( isset ( $ this -> ucNames [ $ ucName ] ) ) { $ name = $ this -> ucNames [ $ ucName ] ; return $ this -> headers [ $ name ] ; } throw new HTTPException ( sprintf ( 'Header field is not assigned: %s' , $ name ) ) ; }
Retrieve assigned header values for the specified field name
20,151
public function clearHeaders ( $ name ) { $ ucName = strtoupper ( $ name ) ; if ( isset ( $ this -> ucNames [ $ ucName ] ) ) { $ name = $ this -> ucNames [ $ ucName ] ; unset ( $ this -> ucNames [ $ ucName ] ) ; unset ( $ this -> headers [ $ name ] ) ; } }
Remove all entries for a particular header name
20,152
public function setForm ( EntityForm $ form ) { if ( ! $ form -> isValid ( ) ) { throw new InvalidFormDataException ( "Submitted form data is not valid." ) ; } $ this -> setData ( $ form -> getData ( ) ) ; $ this -> form = $ form ; return $ this ; }
Set entity for
20,153
public function output ( ) { header ( 'Content-type: application/json' ) ; $ data = array ( 'status' => $ this -> status , 'data' => $ this -> data ) ; echo json_encode ( $ data ) ; die ( ) ; }
Outputs the JSON response status and data
20,154
public function getId ( ) { if ( ! isset ( $ this -> attributes [ 'id' ] ) ) { $ this -> buildIdAttr ( Container :: getRequest ( ) -> getParam ( self :: AI_KEY ) ) ; } return $ this -> attributes [ 'id' ] ; }
Id attribute of table element
20,155
public static function getWebServerSoftWare ( ) : string { static $ type ; if ( isset ( $ type ) ) { return $ type ; } $ software = isset ( $ _SERVER [ 'SERVER_SOFTWARE' ] ) ? $ _SERVER [ 'SERVER_SOFTWARE' ] : null ; $ type = self :: SERVER_TYPE_UNKNOWN ; if ( stripos ( $ software , 'lighttpd' ) !== false ) { $ type = self :: SERVER_TYPE_LIGHTTPD ; } if ( strpos ( $ software , 'Hiawatha' ) !== false ) { $ type = self :: SERVER_TYPE_HIAWATHA ; } if ( strpos ( $ software , 'Apache' ) !== false ) { $ type = self :: SERVER_TYPE_APACHE ; } elseif ( strpos ( $ software , 'Litespeed' ) !== false ) { $ type = self :: SERVER_TYPE_LITESPEED ; } if ( strpos ( $ software , 'nginx' ) !== false ) { $ type = self :: SERVER_TYPE_NGINX ; } if ( $ type !== self :: SERVER_TYPE_APACHE && $ type !== self :: SERVER_TYPE_LITESPEED && strpos ( $ software , 'Microsoft-IIS' ) !== false && strpos ( $ software , 'ExpressionDevServer' ) !== false ) { $ type = self :: SERVER_TYPE_IIS ; if ( intval ( substr ( $ software , strpos ( $ software , 'Microsoft-IIS/' ) + 14 ) ) >= 7 ) { $ type = self :: SERVER_TYPE_IIS7 ; } } if ( function_exists ( 'apache_get_modules' ) ) { if ( in_array ( 'mod_security' , apache_get_modules ( ) ) ) { $ type = self :: SERVER_TYPE_APACHE ; } if ( $ type == self :: SERVER_TYPE_UNKNOWN && function_exists ( 'apache_get_version' ) ) { $ type = self :: SERVER_TYPE_APACHE ; } } return $ type ; }
Get Web Server Type
20,156
public static function getConvertAliasLogLevel ( int $ code ) : int { switch ( $ code ) { case Logger :: ALERT : return Logger :: ALERT ; case Logger :: CRITICAL : return Logger :: CRITICAL ; case E_ALL : case Logger :: DEBUG : return Logger :: DEBUG ; case E_NOTICE : case E_USER_NOTICE : case E_DEPRECATED : case E_USER_DEPRECATED : case Logger :: NOTICE : return Logger :: NOTICE ; case E_ERROR : case E_CORE_ERROR : case E_COMPILE_ERROR : case Logger :: ERROR : return Logger :: ERROR ; case Logger :: INFO : return Logger :: INFO ; case Logger :: EMERGENCY : return Logger :: EMERGENCY ; case E_WARNING : case E_USER_WARNING : case E_COMPILE_WARNING : case Logger :: WARNING : return Logger :: WARNING ; } return 0 ; }
Get Alias Log Level
20,157
public static function getLogStringByCode ( $ code ) { $ code = is_numeric ( $ code ) && ! is_float ( $ code ) ? abs ( $ code ) : $ code ; if ( ! is_int ( $ code ) ) { return null ; } switch ( self :: getConvertAliasLogLevel ( $ code ) ) { case Logger :: NOTICE : return 'notice' ; case Logger :: ERROR : return 'error' ; case Logger :: WARNING : return 'warning' ; case Logger :: INFO : return 'info' ; case Logger :: DEBUG : return 'debug' ; case Logger :: EMERGENCY : return 'emergency' ; case Logger :: CRITICAL : return 'critical' ; case Logger :: ALERT : return 'alert' ; } return null ; }
Get Default Log Name By Code
20,158
public static function isAbsolutePath ( $ path ) : bool { if ( realpath ( $ path ) == $ path ) { return true ; } if ( strlen ( $ path ) == 0 || $ path [ 0 ] == '.' ) { return false ; } if ( preg_match ( '#^[a-zA-Z]:\\\\#' , $ path ) ) { return true ; } return ( $ path [ 0 ] == '/' || $ path [ 0 ] == '\\' ) ; }
Test if a give filesystem path is absolute .
20,159
protected function registerEnv ( ) { $ file_env = $ this -> basePath ( '.env' ) ; $ env = new Dotenv ( $ this -> basePath ( ) , '.env' ) ; if ( file_exists ( $ file_env ) ) { $ env -> load ( ) ; } }
Register the env bindings into the container .
20,160
public function register ( $ provider ) { $ keyProvider = is_string ( $ provider ) ? $ provider : get_class ( $ provider ) ; if ( array_key_exists ( $ keyProvider , $ this -> serviceProviders ) ) { return $ this -> serviceProviders [ $ keyProvider ] ; } if ( is_string ( $ provider ) ) { $ provider = new $ provider ( $ this ) ; } if ( method_exists ( $ provider , 'register' ) ) { $ provider -> register ( ) ; } $ this -> serviceProviders [ $ keyProvider ] = $ provider ; if ( $ this -> booted ) { $ this -> bootProvider ( $ provider ) ; } return $ provider ; }
Register services providers .
20,161
public function set ( string $ locale , string $ collate ) : bool { $ auth = false ; try { if ( ! empty ( $ locale ) ) { $ _locale = preg_replace ( "/^(\w{2})-(\w{2})$/" , "$1_$2" , $ locale ) ; locale_set_default ( $ _locale ) ; if ( ! empty ( $ collate ) ) { $ _locale .= "." . strtoupper ( $ collate ) ; } setlocale ( LC_ALL , $ _locale ) ; $ auth = true ; } } catch ( Exception $ ex ) { $ auth = false ; throw $ ex ; } return $ auth ; }
- Set locale and collate
20,162
public static function estimate ( $ text , $ units = array ( ' minute' , ' minutes' ) ) { $ wordCount = self :: countWords ( $ text ) ; $ wordSeconds = ( $ wordCount / self :: $ wordsPerMinute ) * 60 ; $ imageCount = self :: countImages ( $ text ) ; $ imageSeconds = $ imageCount * self :: $ secondsPerImage ; $ codeCount = self :: countCode ( $ text ) ; $ codeSeconds = ( $ codeCount / self :: $ codewordsPerMinute ) * 60 ; $ minutes = round ( ( $ wordSeconds + $ imageSeconds + $ codeSeconds ) / 60 ) ; $ minutes = $ minutes > 1 ? $ minutes : 1 ; if ( is_string ( $ units ) === true ) { return $ minutes . $ units ; } if ( is_array ( $ units ) === true && count ( $ units ) === 2 ) { $ units = array_values ( $ units ) ; return $ minutes . ( $ minutes === 1 ? $ units [ 0 ] : $ units [ 1 ] ) ; } return $ minutes ; }
Estimates the time needed to read a given string .
20,163
private static function countWords ( $ text ) { $ words = trim ( preg_replace ( '/!\[([^\[]+)\]\(([^\)]+)\)/i' , ' ' , $ text ) ) ; $ words = trim ( preg_replace ( '/<img[^>]*>/i' , ' ' , $ words ) ) ; $ words = trim ( preg_replace ( '/<picture[^>]*>([\s\S]*?)<\/picture>/i' , ' ' , $ words ) ) ; $ words = trim ( preg_replace ( '/(?<=(?<!`))`[^`\n\r]+`(?=(?!`))|```[\w+]?[^`]*```/i' , ' ' , $ words ) ) ; $ words = trim ( preg_replace ( '/<code>([\s\S]*?)<\/code>/i' , ' ' , $ words ) ) ; $ words = strip_tags ( $ words ) ; $ words = explode ( ' ' , $ words ) ; return count ( $ words ) ; }
Counts how many words are in a specific text .
20,164
private static function countImages ( $ text ) { $ markdownImages = preg_match_all ( '/!\[([^\[]+)\]\(([^\)]+)\)/i' , $ text , $ matches ) ; $ imgTags = preg_match_all ( '/<img[^>]*>/i' , $ text , $ matches ) ; return $ markdownImages + $ imgTags ; }
Counts how many images are in a specific text .
20,165
private static function countCode ( $ text ) { $ text = preg_replace ( '/"[^"]*"/i' , '' , $ text ) ; $ regex = '/(?<=(?<!`))`([^`\n\r]+)`(?=(?!`))|```[a-zA-Z]*([^`]*)```/i' ; $ markdownCount = preg_match_all ( $ regex , $ text , $ markdownMatches , PREG_PATTERN_ORDER ) ; $ text = trim ( preg_replace ( '/(?<=(?<!`))`[^`\n\r]+`(?=(?!`))|```[a-zA-Z]*[^`]*```/i' , ' ' , $ text ) ) ; $ regex = '/<code>([\s\S]*?)<\/code>/i' ; $ htmlCount = preg_match_all ( $ regex , $ text , $ htmlMatches , PREG_PATTERN_ORDER ) ; if ( $ markdownCount === 0 && $ htmlCount === 0 ) { return 0 ; } $ code = implode ( $ markdownMatches [ 1 ] , ' ' ) . ' ' . implode ( $ markdownMatches [ 2 ] , ' ' ) . ' ' . implode ( $ htmlMatches [ 1 ] , ' ' ) ; $ code = preg_replace ( [ '/\s+/' , '/^\s/' ] , [ ' ' , '' ] , $ code ) ; return count ( array_filter ( explode ( ' ' , $ code ) ) ) ; }
Counts how many code words are in a specific text .
20,166
public static function configure ( array $ config = [ ] ) { $ config = array_merge ( [ 'wordsPerMinute' => self :: $ wordsPerMinute , 'secondsPerImage' => self :: $ secondsPerImage , 'codewordsPerMinute' => self :: $ codewordsPerMinute , ] , $ config ) ; self :: $ wordsPerMinute = $ config [ 'wordsPerMinute' ] ; self :: $ secondsPerImage = $ config [ 'secondsPerImage' ] ; self :: $ codewordsPerMinute = $ config [ 'codewordsPerMinute' ] ; }
Alters the configuration .
20,167
public static function parse ( $ url ) { if ( ! strlen ( $ url ) ) { return null ; } $ _urls = array_merge ( @ parse_url ( $ url ) , array ( 'params' => array ( ) ) ) ; if ( isset ( $ _urls [ 'query' ] ) ) { parse_str ( $ _urls [ 'query' ] , $ _urls [ 'params' ] ) ; } return $ _urls ; }
Parse an URL and returns its composition as an array with the URI query if so
20,168
public static function getAbsoluteUrl ( $ url = null ) { if ( is_null ( $ url ) ) { return '' ; } if ( self :: isUrl ( $ url ) ) { return $ url ; } $ url = '/' . self :: resolvePath ( $ url ) ; $ current_url = self :: getRequestUrl ( true , true ) ; $ curr = substr ( $ current_url , 0 , strrpos ( $ current_url , '/' ) ) ; return $ curr . $ url ; }
Returns if possible an absolute URL in the current system
20,169
public static function url ( $ param = null , $ value = null , $ url = null ) { if ( is_null ( $ param ) ) { return '' ; } if ( is_null ( $ url ) || ! strlen ( $ url ) ) { $ url = self :: getRequestUrl ( ) ; } if ( ! is_null ( $ param ) ) { if ( is_array ( $ param ) && is_null ( $ value ) ) { foreach ( $ param as $ param_p => $ value_p ) { $ url = self :: setParameter ( $ param_p , $ value_p , $ url ) ; } } elseif ( is_null ( $ value ) ) { $ parsed_url = self :: parse ( $ url ) ; if ( isset ( $ parsed_url [ 'params' ] ) && isset ( $ parsed_url [ 'params' ] [ $ param ] ) ) { return $ parsed_url [ 'params' ] [ $ param ] ; } return false ; } elseif ( ! is_null ( $ value ) ) { $ url = self :: setParameter ( $ param , $ value , $ url ) ; } } return self :: build ( self :: parse ( $ url ) ) ; }
Global URL builder
20,170
public static function getParameter ( $ param = false , $ url = false ) { if ( empty ( $ param ) ) { return null ; } if ( ! $ url || ! strlen ( $ url ) ) { $ url = self :: getRequestUrl ( ) ; } $ parsed_url = self :: parse ( $ url ) ; $ params = ( isset ( $ parsed_url [ 'params' ] ) && count ( $ parsed_url [ 'params' ] ) ) ? $ parsed_url [ 'params' ] : false ; if ( $ param && strlen ( $ param ) ) { if ( $ params ) { foreach ( $ params as $ p => $ v ) { if ( $ p == $ param ) return $ v ; } } return false ; } return $ params ; }
Get the value of an URL parameter
20,171
public static function setParameter ( $ var = '' , $ val = false , $ url = false , $ rebuild = true ) { $ url_entree = $ url ; if ( ! $ url || ! is_array ( $ url ) ) { $ _url = $ url ? $ url : self :: getRequestUrl ( ) ; $ url = self :: parse ( $ _url ) ; } $ url [ 'params' ] [ $ var ] = $ val ; if ( $ rebuild ) { return self :: build ( $ url ) ; } return $ url ; }
Set the value of an URL parameter
20,172
public static function build ( array $ url_components = null , $ not_toput = null ) { if ( ! is_array ( $ url_components ) ) { return null ; } $ _ntp = $ not_toput ? ( is_array ( $ not_toput ) ? $ not_toput : array ( $ not_toput ) ) : array ( ) ; if ( isset ( $ _urls [ 'params' ] ) ) $ _urls [ 'params' ] = array_filter ( $ _urls [ 'params' ] ) ; $ n_url = ( ( isset ( $ url_components [ 'scheme' ] ) && ! in_array ( 'scheme' , $ _ntp ) ) ? $ url_components [ 'scheme' ] . '://' : 'http://' ) . ( ( isset ( $ url_components [ 'user' ] ) && ! in_array ( 'user' , $ _ntp ) ) ? $ url_components [ 'user' ] : '' ) . ( ( isset ( $ url_components [ 'pass' ] ) && ! in_array ( 'pass' , $ _ntp ) ) ? ':' . $ url_components [ 'pass' ] : '' ) . ( ( ( isset ( $ url_components [ 'user' ] ) && ! in_array ( 'user' , $ _ntp ) ) || ( isset ( $ url_components [ 'pass' ] ) && ! in_array ( 'pass' , $ _ntp ) ) ) ? '@' : '' ) . ( ( isset ( $ url_components [ 'host' ] ) && ! in_array ( 'host' , $ _ntp ) ) ? $ url_components [ 'host' ] : '' ) . ( ( isset ( $ url_components [ 'port' ] ) && ! in_array ( 'port' , $ _ntp ) ) ? ':' . $ url_components [ 'port' ] : '' ) . ( ( isset ( $ url_components [ 'path' ] ) && ! in_array ( 'path' , $ _ntp ) ) ? $ url_components [ 'path' ] : '' ) . ( ( isset ( $ url_components [ 'params' ] ) && ! in_array ( 'params' , $ _ntp ) ) ? '?' . http_build_query ( $ url_components [ 'params' ] ) : '' ) . ( ( isset ( $ url_components [ 'hash' ] ) && ! in_array ( 'hash' , $ _ntp ) ) ? '#' . $ url_components [ 'hash' ] : '' ) ; return trim ( $ n_url , '?&' ) ; }
Rebuild a full URL string from an array of elements
20,173
public static function _randString ( $ length , $ lettersNumbersOnly = false ) { $ str = '' ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { if ( $ lettersNumbersOnly ) { $ str .= self :: $ lettersNums [ self :: _getRand ( 0 , strlen ( self :: $ lettersNums ) - 1 ) ] ; } else { $ str .= self :: _randCharacter ( ) ; } } return $ str ; }
Creates a random string of the specified length
20,174
public static function _randCharacter ( $ start = 32 , $ end = 126 ) { $ amountToAdd = $ end - $ start ; return chr ( $ start + self :: _getRand ( 0 , $ amountToAdd ) ) ; }
Returns a random character within the start and end ascii characters
20,175
private function configureErrorPresentationFactory ( array $ factoryConfig , ContainerBuilder $ container ) : void { if ( $ this -> isConfigEnabled ( $ container , $ factoryConfig [ 'validation' ] ) ) { $ container -> getDefinition ( 'fivelab.resource.error_presentation_factory.validation_failed' ) -> setAbstract ( false ) -> replaceArgument ( 0 , $ factoryConfig [ 'validation' ] [ 'message' ] ) -> replaceArgument ( 1 , $ factoryConfig [ 'validation' ] [ 'reason' ] ) ; } }
Configure error presentation factories
20,176
private function configureExceptionListener ( array $ loggingConfig , array $ exceptionListenerConfig , ContainerBuilder $ container ) : void { if ( $ this -> isConfigEnabled ( $ container , $ loggingConfig ) ) { $ definition = $ container -> getDefinition ( 'fivelab.resource.event_listener.exception_logging' ) -> replaceArgument ( 2 , $ loggingConfig [ 'level' ] ) -> setAbstract ( false ) -> addTag ( 'monolog.logger' , [ 'channel' => $ loggingConfig [ 'channel' ] ] ) ; } else { $ definition = $ container -> getDefinition ( 'fivelab.resource.event_listener.logging' ) ; } $ container -> getDefinition ( 'fivelab.resource.event_listener.exception' ) -> replaceArgument ( 3 , $ exceptionListenerConfig [ 'debug_parameter' ] ) ; $ definition -> addTag ( 'kernel.event_listener' , [ 'event' => KernelEvents :: EXCEPTION , 'method' => 'onKernelException' , ] ) ; }
Configure exception listener
20,177
public function create ( $ name ) { $ config = $ this -> getConfiguration ( $ name ) ; if ( null === $ config ) { throw new \ RuntimeException ( "Connection with name: $name not found." ) ; } return new Client ( $ config ) ; }
Creates new redis client
20,178
public function addConfiguration ( $ name , array $ config ) { if ( array_key_exists ( $ name , $ this -> configs ) ) { throw new \ RuntimeException ( "Connection with given name already exists!" ) ; } $ this -> configs [ $ name ] = $ config ; }
Adds connection config
20,179
public static function toNativePropertyName ( $ property ) { $ propertyNames = array_keys ( static :: getPropertyPrototypes ( ) ) ; if ( ! in_array ( $ property , $ propertyNames ) ) { foreach ( $ propertyNames as $ propertyName ) { if ( strtolower ( $ propertyName ) === strtolower ( $ property ) ) { return $ propertyName ; } } } return $ property ; }
If column does not directly match with a property name a case insensitive compare is performed to detect the correct property name .
20,180
public static function getProperties ( $ entityNamespace ) { $ reflectionClass = new \ ReflectionClass ( $ entityNamespace ) ; $ reflectionProperties = $ reflectionClass -> getProperties ( ) ; $ properties = [ ] ; foreach ( $ reflectionProperties as $ reflectionProperty ) { $ property = self :: createProperty ( $ reflectionProperty ) ; if ( $ property ) { $ properties [ $ property -> getName ( ) ] = $ property ; } } return $ properties ; }
Returns Properties determined by Entity - Namespace
20,181
protected static function createProperty ( \ ReflectionProperty $ reflectionProperty ) { $ property = new Property ( ) ; $ property -> setName ( $ reflectionProperty -> getName ( ) ) ; $ annotationReader = new AnnotationReader ( ) ; $ annotations = $ annotationReader -> getPropertyAnnotations ( $ reflectionProperty ) ; foreach ( $ annotations as $ annotation ) { $ annotationClassName = get_class ( $ annotation ) ; if ( $ annotationClassName == 'Doctrine\ORM\Mapping\Column' || $ annotationClassName == 'Doctrine\ORM\Mapping\Id' ) { $ property -> setAnnotation ( $ annotation ) ; $ property -> setType ( Property :: PROPERTY_TYPE_COLUMN ) ; } elseif ( $ annotationClassName == 'Doctrine\ORM\Mapping\ManyToOne' || $ annotationClassName == 'Doctrine\ORM\Mapping\OneToOne' ) { $ property -> setAnnotation ( $ annotation ) ; $ property -> setType ( Property :: PROPERTY_TYPE_REF_ONE ) ; $ property -> setTargetEntity ( $ annotation -> targetEntity ) ; } elseif ( $ annotationClassName == 'Doctrine\ORM\Mapping\ManyToMany' || $ annotationClassName == 'Doctrine\ORM\Mapping\OneToMany' ) { $ property -> setAnnotation ( $ annotation ) ; $ property -> setType ( Property :: PROPERTY_TYPE_REF_MANY ) ; $ property -> setTargetEntity ( $ annotation -> targetEntity ) ; } } if ( $ property -> getType ( ) == - 1 ) { throw new \ Exception ( 'Entity "' . $ reflectionProperty -> getDeclaringClass ( ) -> getName ( ) . '": defining annotation is missing at property "' . $ property -> getName ( ) . '"!' ) ; } return $ property ; }
Returns created Property - Object gets Information from Reflection - Property which contains Doctrine - Annotations
20,182
public function getCssCode ( ) { $ html = '' ; foreach ( $ this -> css as $ css ) { $ html .= sprintf ( '<link rel="stylesheet" href="%s"/>' , $ css ) ; } return $ html ; }
get link code for all css assets
20,183
public function getJsCode ( ) { $ html = '' ; foreach ( $ this -> js as $ js ) { $ html .= sprintf ( '<script src="%s"></script>' , $ js ) ; } foreach ( $ this -> entry as $ entry ) { $ html .= sprintf ( '<script>System.import(\'%s\')</script>' , $ entry ) ; } return $ html ; }
get script code for all js assets
20,184
function renderStatusLine ( ) { $ status = sprintf ( 'HTTP/%s %d %s' , $ this -> getVersion ( ) , $ this -> getStatusCode ( ) , $ this -> getStatusReason ( ) ) ; return trim ( $ status ) ; }
Render the status line header
20,185
function setStatusCode ( $ status ) { if ( ! is_numeric ( $ status ) || is_float ( $ status ) || $ status < 100 || $ status >= 600 ) throw new \ InvalidArgumentException ( sprintf ( 'Invalid status code "%s"; must be an integer between 100 and 599, inclusive' , ( is_scalar ( $ status ) ? $ status : gettype ( $ status ) ) ) ) ; $ this -> statCode = $ status ; return $ this ; }
Set Response Status Code
20,186
function getStatusReason ( ) { if ( $ this -> statReason ) return $ this -> statReason ; ( $ reason = \ Poirot \ Http \ Response \ getStatReasonFromCode ( $ this -> getStatusCode ( ) ) ) ? : $ reason = 'Unknown' ; return $ reason ; }
Get Status Code Reason
20,187
public function track ( EventStream $ stream ) { if ( ! in_array ( $ stream , $ this -> tracking , true ) ) { $ this -> tracking [ ] = $ stream ; } }
When tracking appended events are also appended to the tracking streams .
20,188
public function prepareWithPagination ( $ statement , PaginationInterface $ pagination , $ driver_options = [ ] ) { $ this -> pagination = $ pagination ; return $ this -> prepare ( $ statement , $ driver_options ) ; }
Prepare a statement with pagination
20,189
protected function convertToCountQuery ( $ sql ) { try { $ this -> checkForMainOffsetOrLimit ( $ sql ) ; } catch ( \ Exception $ e ) { throw $ e ; } return "SELECT COUNT(*) as pagination_count " . $ this -> stripQueryToUnnestedKeyword ( $ sql ) . " LIMIT 1" ; }
Convert the query to a single row count
20,190
protected function checkForMainOffsetOrLimit ( $ sql ) { if ( "" !== $ this -> stripQueryToUnnestedKeyword ( $ sql , $ unnested_keyword = 'LIMIT' ) ) { throw new \ LogicException ( "Query cannot contain an unnested LIMIT when trying to paginate" ) ; } if ( "" !== $ this -> stripQueryToUnnestedKeyword ( $ sql , $ unnested_keyword = 'OFFSET' ) ) { throw new \ LogicException ( "Query cannot contain an unnested OFFSET when trying to paginate" ) ; } return true ; }
Ensure that the query can be paginated
20,191
public function offsetGet ( $ offset ) { return isset ( $ this -> hashedContainer [ $ offset ] ) ? $ this -> hashedContainer [ $ offset ] : null ; }
ArrayAccess Offset Get .
20,192
public function offsetSet ( $ offset , $ argModel ) { if ( is_null ( $ offset ) ) { $ this -> hashedContainer [ $ argModel -> getName ( ) ] = $ argModel ; $ this -> indexedContainer [ ] = $ argModel ; return ; } $ this -> hashedContainer [ $ offset ] = $ argModel ; $ this -> indexedContainer [ $ offset ] = $ argModel ; }
ArrayAccess Offset Set .
20,193
static public function search ( $ keyword , $ models = [ 'App\User' ] , $ perPage = 15 , $ currentPage = null , array $ options = [ ] ) { $ query = null ; if ( empty ( $ options ) ) { $ options = [ 'path' => Paginator :: resolveCurrentPath ( ) ] ; } foreach ( $ models as $ model ) { if ( $ model === reset ( $ models ) ) { $ query = self :: searchModel ( new $ model , $ keyword ) ; } $ query = $ query -> merge ( self :: searchModel ( new $ model , $ keyword ) ) ; } return new LengthAwarePaginator ( $ query -> forPage ( null , $ perPage ) , $ query -> count ( ) , $ perPage , $ currentPage , $ options ) ; }
Search for keyword in the given models .
20,194
public function parse ( TokenStream $ stream , $ names = array ( ) ) { $ this -> stream = $ stream ; $ this -> names = $ names ; $ node = $ this -> parseExpression ( ) ; if ( ! $ stream -> isEOF ( ) ) { throw new SyntaxError ( sprintf ( 'Unexpected token "%s" of value "%s"' , $ stream -> current -> type , $ stream -> current -> value ) , $ stream -> current -> cursor ) ; } return $ node ; }
Converts a token stream to a node tree .
20,195
public function pushMultiple ( array $ users ) { $ failed = array ( ) ; foreach ( $ users as $ user ) { $ push = $ this -> push ( $ user ) ; if ( ! $ push ) { $ failed [ ] = $ user ; } } return ! count ( $ failed ) ; }
Push to multiple users
20,196
public function push ( $ user ) { if ( ! isset ( $ this -> data [ 'message' ] ) ) { throw new Exception ( 'You must supply a message' ) ; } $ data = array_merge ( $ this -> data , array ( 'user' => $ user , ) ) ; $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , $ this -> api_url ) ; curl_setopt ( $ curl , CURLOPT_POST , true ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ data ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; $ result = json_decode ( curl_exec ( $ curl ) , true ) ; curl_close ( $ curl ) ; return isset ( $ result [ 'status' ] ) && ( int ) $ result [ 'status' ] === 1 ; }
Push a notification to a specific user
20,197
public function getMatchRoad ( File $ file ) { foreach ( $ this -> roadMap as $ road ) { if ( $ road -> resourceCheck ( $ file ) ) { return $ road ; } } return NULL ; }
Returns the first match road for the target resource file with auto registration for the matched resource file .
20,198
public function getSourceDirs ( ) { $ dirs = array ( ) ; foreach ( $ this -> roadMap as $ road ) { array_push ( $ dirs , $ road -> getSourceDir ( ) ) ; } return $ dirs ; }
Returns all the source directory objects from roadmap .
20,199
public function getReleaseDirs ( ) { $ dirs = array ( ) ; foreach ( $ this -> roadMap as $ road ) { $ release_dir = $ road -> getReleaseDir ( ) ; if ( empty ( $ release_dir ) ) { continue ; } if ( ! $ release_dir -> exists ( ) ) { if ( ! $ release_dir -> mkdirs ( ) ) { continue ; } } array_push ( $ dirs , $ release_dir ) ; } return $ dirs ; }
Returns all the release directory objects from roadmap .