idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
46,300
public function inner ( $ table , array $ optionalTables = array ( ) ) { $ preparedTablesArray = $ this -> _getPreparedTableObjects ( $ table , $ optionalTables ) ; $ this -> join -> inner ( $ preparedTablesArray [ 'table' ] , $ preparedTablesArray [ 'optionalTables' ] ) ; return $ this ; }
Join the expected table with an inner join . In the second argument can pass optional tables for the join operation .
46,301
public function left ( $ table , array $ optionalTables = array ( ) ) { $ preparedTablesArray = $ this -> _getPreparedTableObjects ( $ table , $ optionalTables ) ; $ this -> join -> left ( $ preparedTablesArray [ 'table' ] , $ preparedTablesArray [ 'optionalTables' ] ) ; return $ this ; }
Join the expected table with a left join . In the second argument can pass optional tables for the join operation .
46,302
public function right ( $ table , array $ optionalTables = array ( ) ) { $ preparedTablesArray = $ this -> _getPreparedTableObjects ( $ table , $ optionalTables ) ; $ this -> join -> right ( $ preparedTablesArray [ 'table' ] , $ preparedTablesArray [ 'optionalTables' ] ) ; return $ this ; }
Join the expected table with a right join . In the second argument can pass optional tables for the join operation .
46,303
public function leftOuter ( $ table , array $ optionalTables = array ( ) ) { $ preparedTablesArray = $ this -> _getPreparedTableObjects ( $ table , $ optionalTables ) ; $ this -> join -> leftOuter ( $ preparedTablesArray [ 'table' ] , $ preparedTablesArray [ 'optionalTables' ] ) ; return $ this ; }
Join the expected table with a left outer join . In the second argument can pass optional tables for the join operation .
46,304
public function rightOuter ( $ table , array $ optionalTables = array ( ) ) { $ preparedTablesArray = $ this -> _getPreparedTableObjects ( $ table , $ optionalTables ) ; $ this -> join -> rightOuter ( $ preparedTablesArray [ 'table' ] , $ preparedTablesArray [ 'optionalTables' ] ) ; return $ this ; }
Join the expected table with a right outer join . In the second argument can pass optional tables for the join operation .
46,305
private function _getPreparedTableObjects ( $ table , array $ optionalTables ) { $ tableObj = $ this -> factory -> references ( 'Table' , $ table ) ; $ optionalTablesObj = array ( ) ; foreach ( $ optionalTables as $ tbl ) { $ optionalTablesObj [ ] = $ this -> factory -> references ( 'Table' , $ tbl ) ; } return array ( 'table' => $ tableObj , 'optionalTables' => $ optionalTablesObj ) ; }
Create table objects from the passed arguments . An array will return with the key table for the main table and optionalTables for optional tables . When no optional tables are passed the key optionalTables return an empty array .
46,306
private function _checkOnArguments ( array $ firstColumn , array $ secondColumn ) { if ( ! array_key_exists ( 'column' , $ firstColumn ) || ! array_key_exists ( 'table' , $ firstColumn ) || ! array_key_exists ( 'column' , $ secondColumn ) || ! array_key_exists ( 'table' , $ secondColumn ) ) { throw new \ InvalidArgumentException ( 'Both arguments of on method require "column" and "table" as key' ) ; } }
Check the passed arguments of the on method . If they don t have keys equivalent to column and table an invalid argument exception will thrown .
46,307
protected function createEach ( ) { foreach ( $ this -> providers as $ class => & $ data ) { if ( ! array_get ( $ data , 'instance' ) ) { $ instance = $ this -> getProviderInvoker ( ) -> create ( $ class , $ this -> getSharedArguments ( ) ) ; array_set ( $ data , 'instance' , $ instance ) ; $ this -> create ( ) ; break ; } } }
Instantiate all providers .
46,308
protected function configureEach ( ) { foreach ( $ this -> providers as $ class => & $ data ) { if ( ! array_contains ( array_get ( $ data , 'tags' ) , ProviderTag :: CONFIGURED ) ) { $ this -> create ( ) ; array_add ( $ data , 'tags' , ProviderTag :: CONFIGURED ) ; $ instance = array_get ( $ data , 'instance' ) ; if ( method_exists ( $ instance , 'configure' ) ) { $ this -> getProviderInvoker ( ) -> configure ( $ instance , $ this -> getSharedArguments ( ) ) ; } $ this -> configureEach ( ) ; break ; } } }
Configure all providers .
46,309
protected function initializeEach ( ) { foreach ( $ this -> providers as $ class => & $ data ) { if ( ! array_contains ( array_get ( $ data , 'tags' ) , ProviderTag :: INITIALIZED ) ) { $ this -> configure ( ) ; array_add ( $ data , 'tags' , ProviderTag :: INITIALIZED ) ; $ instance = array_get ( $ data , 'instance' ) ; if ( method_exists ( $ instance , 'initialize' ) ) { $ this -> getProviderInvoker ( ) -> initialize ( $ instance , $ this -> getSharedArguments ( ) ) ; } $ this -> initializeEach ( ) ; break ; } } }
Initialize all providers .
46,310
protected function bootEach ( ) { foreach ( $ this -> providers as $ class => & $ data ) { if ( ! array_contains ( array_get ( $ data , 'tags' ) , ProviderTag :: BOOTED ) ) { $ this -> initialize ( ) ; array_add ( $ data , 'tags' , ProviderTag :: BOOTED ) ; $ instance = array_get ( $ data , 'instance' ) ; if ( method_exists ( $ instance , 'boot' ) ) { $ this -> getProviderInvoker ( ) -> boot ( $ instance , $ this -> getSharedArguments ( ) ) ; } $ this -> bootEach ( ) ; break ; } } }
Boot all providers .
46,311
protected function shutdownEach ( ) { foreach ( $ this -> providers as $ class => & $ data ) { if ( ! array_contains ( array_get ( $ data , 'tags' ) , ProviderTag :: SHUTDOWN ) ) { $ this -> boot ( ) ; array_add ( $ data , 'tags' , ProviderTag :: SHUTDOWN ) ; $ instance = array_get ( $ data , 'instance' ) ; if ( method_exists ( $ instance , 'shutdown' ) ) { $ this -> getProviderInvoker ( ) -> boot ( $ instance , $ this -> getSharedArguments ( ) ) ; } $ this -> shutdownEach ( ) ; break ; } } }
Shutdown all providers .
46,312
public function add ( $ message , $ code , $ type ) { $ default = [ 'message' => $ message , 'code' => $ code , 'type' => $ type ] ; if ( $ type == 'error' && is_numeric ( $ code ) && $ code >= 0 ) { $ default [ 'descriptor' ] = array_search ( $ code , $ this -> codes [ 'codes' ] ) ; } if ( $ this -> domain !== self :: DEFAULT_DOMAIN ) { $ default [ 'domain' ] = $ this -> domain ; } array_push ( $ this -> messages , $ default ) ; return $ this ; }
add message to container ;
46,313
public function populate ( DbManagement $ db , DbManagementObject $ DbManagementObject , $ query ) { $ keys = array_values ( $ DbManagementObject -> getKeys ( ) ) ; $ db -> add ( $ query , $ keys ) ; $ array = array_values ( $ DbManagementObject -> getValues ( ) ) ; $ db -> query ( $ query , $ array ) ; return $ db -> lastInsertId ( ) ; }
add an Object to the table in the database
46,314
public function getData ( DbManagement $ db , $ query , $ params , DbManagementObject $ DbManagementObject ) { $ keys = $ DbManagementObject -> getKeys ( ) ; $ parsed = $ this -> parseParams ( $ params , $ keys , $ DbManagementObject -> getTypes ( ) ) ; $ array = [ ] ; if ( isset ( $ parsed ) ) { foreach ( $ parsed as $ type => $ values ) { switch ( $ type ) { case "min" : foreach ( $ values as $ key => $ val ) { $ min = $ keys [ $ key ] . "-min" ; $ db -> sortMin ( $ query , $ keys [ $ key ] , $ min ) ; $ array [ ] = $ val ; } break ; case "max" : foreach ( $ values as $ key => $ val ) { $ max = $ keys [ $ key ] . "-max" ; $ db -> sortMax ( $ query , $ keys [ $ key ] , $ max ) ; $ array [ ] = $ val ; } break ; case "up" : foreach ( $ values as $ val ) { $ db -> orderUp ( $ query , $ keys [ $ val ] ) ; } break ; case "down" : foreach ( $ values as $ val ) { $ db -> orderDown ( $ query , $ keys [ $ val ] ) ; } break ; case "equals" : foreach ( $ values as $ key => $ val ) { $ db -> sort ( $ query , $ keys [ $ key ] , $ keys [ $ key ] ) ; $ array [ ] = $ val ; } break ; } } } $ db -> closeQuery ( $ query ) ; $ answer = $ db -> query ( $ query , $ array ) ; $ args = [ ] ; while ( $ row = $ answer -> fetch ( \ PDO :: FETCH_ASSOC ) ) { foreach ( $ keys as $ key => $ val ) { $ argsDbManagementObject [ $ val ] = $ row [ $ val ] ; } $ args [ ] = $ argsDbManagementObject ; } return $ args ; }
get data from the table in the database according to the params and the expected DbManagementObject
46,315
private function convertValue ( $ value , $ type ) { switch ( $ type ) { case "is_numeric" : $ value = floatval ( $ value ) ; break ; case "is_float" : $ value = floatval ( $ value ) ; break ; case "is_string" : $ value = strval ( $ value ) ; break ; default : $ value = strval ( $ value ) ; } return $ value ; }
values are converted thanks to the given type
46,316
public function process ( EventRecord $ eventRecord ) : void { $ this -> eventStore -> append ( $ eventRecord ) ; $ this -> eventDispatcher -> dispatch ( $ eventRecord -> eventMessage ( ) ) ; }
Processes an event record
46,317
public static function create ( $ name , $ content = '' , $ singleTag = false ) : Element { return new Element ( $ name , $ content , $ singleTag ) ; }
creates a new Html object .
46,318
public function isSameString ( $ leftString , $ rightString ) { if ( is_string ( $ leftString ) && is_string ( $ rightString ) && strlen ( $ leftString ) == strlen ( $ rightString ) && md5 ( $ leftString ) == md5 ( $ rightString ) ) { return true ; } return false ; }
check the strings is the same or not
46,319
public function runInstallers ( PackageWrapper $ package , $ isDevMode ) { foreach ( $ this -> installers as $ installer ) { if ( $ installer -> supports ( $ package ) ) { $ this -> io -> write ( sprintf ( '<info>Running %s installer for %s</info>' , $ installer -> getName ( ) , $ package -> getPackage ( ) -> getPrettyName ( ) ) ) ; $ installer -> install ( $ package , $ isDevMode ) ; } } }
Run the installers for a package
46,320
public function runBuildTools ( PackageWrapper $ package , $ isDevMode ) { foreach ( $ this -> buildTools as $ buildTool ) { if ( $ buildTool -> supports ( $ package ) ) { $ this -> io -> write ( sprintf ( '<info>Running %s builder for %s</info>' , $ buildTool -> getName ( ) , $ package -> getPackage ( ) -> getPrettyName ( ) ) ) ; $ buildTool -> build ( $ package , $ isDevMode ) ; } } }
Run the build tools for a package
46,321
public function registerHook ( $ key , Hook $ hook ) { if ( isset ( $ this -> hooks [ $ key ] ) ) { throw new ReregisterHookException ( 'Attempt to re-register hook ' . $ key ) ; } if ( ! $ key || ! is_string ( $ key ) ) { throw new InvalidHookIdentifierException ( 'Invalid hook identifier ' . var_export ( $ key , true ) ) ; } $ this -> hooks [ $ key ] = $ hook ; }
Registers a hook with the application for future interactions .
46,322
public function bindHook ( $ key , $ closure , $ precedence = 0 ) { if ( isset ( $ this -> hooks [ $ key ] ) ) { $ this -> hooks [ $ key ] -> bind ( $ closure , $ precedence ) ; } else { throw new UnregisteredHookException ( 'Attempt to bind unregistered hook ' . $ key ) ; } }
Binds an action to be taken when a hook is triggered . The hook must be registered before it can be bound to an action .
46,323
public function triggerHook ( $ key , $ args = array ( ) , $ precedence = null ) { if ( isset ( $ this -> hooks [ $ key ] ) ) { return $ this -> hooks [ $ key ] -> trigger ( $ args , $ precedence ) ; } else { throw new UnregisteredHookException ( 'Attempt to trigger unregistered hook ' . $ key ) ; } }
Will sequentially call each action bound to the hook . The hook must be registered before it can be bound to an action .
46,324
private static function typeCastModel ( LightModel $ model ) { if ( in_array ( self :: OPTIONS_TYPECAST , self :: $ initOptions ) ) { foreach ( $ model -> getTable ( ) -> getColumns ( ) as $ column ) { if ( in_array ( $ column -> getField ( ) , get_object_vars ( $ model ) ) ) { if ( $ column -> getType ( ) === Column :: TYPE_INT ) { $ field = $ column -> getField ( ) ; settype ( $ model -> $ field , Column :: TYPE_INT ) ; } } } } return $ model ; }
Typecast the models columns to the associated mysql data types .
46,325
public static function init ( PDO $ pdo , $ options = [ ] ) { DB :: init ( $ pdo ) ; self :: $ initOptions = $ options ; }
Set up our options and pass PDO to our DB Singleton
46,326
public function getTableName ( ) : string { if ( $ this -> tableName === null ) { $ this -> tableName = ( new \ ReflectionClass ( $ this ) ) -> getShortName ( ) ; } return $ this -> tableName ; }
Check if tableName has been set or return based on class ;
46,327
private static function handleFilter ( String & $ sql , $ filter , LightModel $ class ) : array { $ params = [ ] ; if ( isset ( $ filter [ self :: FILTER_ORDER ] ) ) { $ order = $ filter [ self :: FILTER_ORDER ] ; unset ( $ filter [ self :: FILTER_ORDER ] ) ; } if ( isset ( $ filter [ self :: FILTER_LIMIT ] ) ) { $ limit = ( int ) $ filter [ self :: FILTER_LIMIT ] ; unset ( $ filter [ self :: FILTER_LIMIT ] ) ; } foreach ( $ filter as $ filter => $ value ) { if ( ! $ class -> getTable ( ) -> hasColumn ( $ filter ) ) continue ; $ operator = '=' ; if ( is_array ( $ value ) ) { $ operator = $ value [ 0 ] ; $ value = $ value [ 1 ] ; } switch ( $ class -> getTable ( ) -> getColumn ( $ filter ) -> getType ( ) ) { case Column :: TYPE_INT : $ value = ( int ) $ value ; break ; default : $ value = ( string ) $ value ; } $ sql .= ' AND `' . $ filter . '` ' . $ operator . ' :' . $ filter ; $ params [ ':' . $ filter ] = $ value ; } if ( isset ( $ order ) ) { $ sql .= ' ORDER BY ' . $ order ; } if ( isset ( $ limit ) ) { $ sql .= ' LIMIT ' . $ limit ; } return $ params ; }
Parse filters & return the associated params for passing into PDO query
46,328
public static function getItems ( $ filter = [ ] ) : array { $ res = [ ] ; $ className = get_called_class ( ) ; $ class = new $ className ; $ sql = 'SELECT * FROM ' . $ class -> getTableName ( ) . ' WHERE 1=1' ; $ params = self :: handleFilter ( $ sql , $ filter , $ class ) ; $ query = DB :: getConnection ( ) -> prepare ( $ sql ) ; $ query -> execute ( $ params ) ; foreach ( $ query -> fetchAll ( PDO :: FETCH_CLASS , $ className ) as $ item ) { $ res [ ] = self :: typeCastModel ( $ item ) ; } return $ res ; }
Get all items based on filter
46,329
public static function getKeys ( $ filter = [ ] ) : array { $ className = get_called_class ( ) ; $ class = new $ className ; $ tableKey = $ class -> getKeyName ( ) ; $ sql = 'SELECT ' . $ tableKey . ' FROM ' . $ class -> getTableName ( ) . ' WHERE 1=1' ; $ params = self :: handleFilter ( $ sql , $ filter , $ class ) ; $ query = DB :: getConnection ( ) -> prepare ( $ sql ) ; $ query -> execute ( $ params ) ; $ res = [ ] ; foreach ( $ query -> fetchAll ( ) as $ key => $ value ) { $ res [ ] = $ value [ 0 ] ; } return $ res ; }
Get array of keys that match the specified filters . Can be used when loading large quantities of models is not an option .
46,330
public static function count ( $ filter = [ ] ) : int { $ className = get_called_class ( ) ; $ class = new $ className ; $ tableKey = $ class -> getKeyName ( ) ; $ sql = 'SELECT COUNT(' . $ tableKey . ') FROM ' . $ class -> getTableName ( ) . ' WHERE 1=1' ; $ params = self :: handleFilter ( $ sql , $ filter , $ class ) ; $ query = DB :: getConnection ( ) -> prepare ( $ sql ) ; $ query -> execute ( $ params ) ; return ( int ) $ query -> fetchColumn ( 0 ) ; }
Count items based on filter
46,331
public function exists ( ) : bool { $ tableKey = $ this -> getKeyName ( ) ; if ( ! isset ( $ this -> $ tableKey ) ) { return false ; } $ sql = 'SELECT EXISTS(SELECT ' . $ tableKey . ' FROM ' . $ this -> getTableName ( ) . ' WHERE ' . $ this -> getKeyName ( ) . ' = :key LIMIT 1)' ; $ query = DB :: getConnection ( ) -> prepare ( $ sql ) ; $ query -> execute ( [ 'key' => $ this -> getKey ( ) ] ) ; return boolval ( $ query -> fetchColumn ( 0 ) ) ; }
Check does the current item exist .
46,332
public function refresh ( ) { $ keyName = $ this -> keyName ; if ( ! isset ( $ this -> $ keyName ) ) { return ; } $ dbItem = self :: getOneByKey ( $ this -> getKey ( ) ) ; if ( $ dbItem == $ this ) { return ; } foreach ( get_object_vars ( $ dbItem ) as $ var => $ val ) { if ( $ this -> $ var !== $ val ) { $ this -> $ var = $ val ; } } }
Reload the current Model
46,333
public function delete ( ) : bool { if ( ! $ this -> exists ( ) ) { return false ; } $ sql = 'DELETE FROM ' . $ this -> getTableName ( ) . ' WHERE ' . $ this -> getKeyName ( ) . ' = :key' ; $ query = DB :: getConnection ( ) -> prepare ( $ sql ) ; return $ query -> execute ( [ 'key' => $ this -> getKey ( ) ] ) ; }
Delete a model from the DB
46,334
protected function belongsTo ( $ class , $ foreignKey ) : ? LightModel { $ identifier = implode ( '_' , [ $ class , $ foreignKey ] ) ; if ( ! isset ( $ this -> _belongsTo [ $ identifier ] ) ) { if ( ! $ this -> getTable ( ) -> hasColumn ( $ foreignKey ) ) { throw new ColumnMissingException ( $ this -> getTableName ( ) . ' does not have column: ' . $ foreignKey ) ; } $ this -> _belongsTo [ $ identifier ] = $ class :: getOneByKey ( $ this -> $ foreignKey ) ; } return $ this -> _belongsTo [ $ identifier ] ; }
Load the specified belongsTo relation model .
46,335
public function getAge ( $ day , $ month , $ year ) { $ years = date ( 'Y' ) - $ year ; if ( date ( 'm' ) < $ month ) $ years -- ; elseif ( date ( 'd' ) < $ day && date ( 'm' ) == $ month ) $ years -- ; return $ years ; }
Permet de calculer un age depuis une date de naissance
46,336
public function getProperties ( ) { $ result = array ( ) ; foreach ( $ this -> getReflectionClass ( ) -> getProperties ( ) as $ m ) { $ result [ ] = PropertyInfo :: __internal_create ( $ this , $ m ) ; } return $ result ; }
Gets a list of all defined properties .
46,337
public function getProperty ( $ name ) { $ m = $ this -> getReflectionClass ( ) -> getProperty ( $ name ) ; return PropertyInfo :: __internal_create ( $ this , $ m ) ; }
Gets a property by its name .
46,338
public function isAssignableFrom ( Type $ type ) { if ( $ type -> getName ( ) === $ this -> getName ( ) ) return true ; if ( ! ( $ type instanceof ClassType ) ) return false ; return $ type -> isSubtypeOf ( $ this ) ; }
Checks whether the provided type equals this type or is a subtype of this type .
46,339
public function isAssignableFromValue ( $ value ) { if ( ! is_object ( $ value ) ) return false ; if ( get_class ( $ value ) === $ this -> getName ( ) ) return true ; return is_subclass_of ( $ value , $ this -> className ) ; }
Checks whether the provided value is an instance of either this type or a subclass of this type .
46,340
public function getImplementedInterfaces ( ) { $ result = array ( ) ; foreach ( $ this -> getReflectionClass ( ) -> getInterfaces ( ) as $ interface ) { $ result [ ] = Type :: byReflectionClass ( $ interface ) ; } return $ result ; }
Gets all interfaces that were implemented by this class .
46,341
public function reverseTransform ( $ modelData , PropertyPathInterface $ propertyPath , $ value ) { if ( false === $ date = $ this -> createDateFromString ( $ value ) ) { $ date = null ; } $ this -> propertyAccessor -> setValue ( $ modelData , $ propertyPath , $ date ) ; }
Transforms date string to DateTime object
46,342
public function getText ( $ sValue ) { foreach ( self :: $ _aCallbacks as $ aOneCallback ) { $ sValueReturn = $ aOneCallback ( $ sValue ) ; if ( $ sValueReturn !== '' ) { return $ sValueReturn ; } } if ( file_exists ( $ this -> getI18nDirectory ( ) . $ this -> getLanguage ( ) . $ this -> getIntermediaiteDirectory ( ) . $ this -> getI18nDomain ( ) . '.json' ) ) { if ( ! Translator :: isConfigurated ( ) ) { Translator :: setConfig ( $ this -> getI18nDirectory ( ) . $ this -> getLanguage ( ) . $ this -> getIntermediaiteDirectory ( ) . $ this -> getI18nDomain ( ) . '.json' ) ; } return Translator :: _ ( $ sValue ) ; } else if ( ! function_exists ( "gettext" ) ) { if ( ! Gettext :: isConfigurated ( ) ) { Gettext :: setConfig ( $ this -> getLanguage ( ) , $ this -> getI18nDomain ( ) , $ this -> getI18nDirectory ( ) ) ; } return Gettext :: _ ( $ sValue ) ; } else { return Mock :: _ ( $ sValue ) ; } }
get a translation
46,343
protected function normalize ( array $ input ) : array { $ normalized = [ ] ; foreach ( $ this -> rules ( ) as $ field => $ value ) { $ normalized [ $ field ] = $ input [ $ field ] ?? '' ; } return $ normalized ; }
Remove unexpected fields and ensure all fields in rules array are present
46,344
public static function prop ( $ value , $ chain ) { if ( empty ( $ chain ) ) { throw new \ InvalidArgumentException ( "Value property name cannot be empty." ) ; } if ( ! is_string ( $ chain ) ) { throw new \ InvalidArgumentException ( sprintf ( "Value property name must be a string, %s given." , gettype ( $ chain ) ) ) ; } $ chain = explode ( '.' , $ chain ) ; foreach ( $ chain as $ property ) { if ( is_object ( $ value ) ) { $ getter = 'get' . ucfirst ( $ property ) ; if ( is_callable ( array ( $ value , $ getter ) ) ) { $ value = $ value -> $ getter ( ) ; } elseif ( isset ( $ value -> { $ property } ) ) { $ value = $ value -> { $ property } ; } else { return null ; } } elseif ( Arrays :: isArray ( $ value ) ) { if ( ! isset ( $ value [ $ property ] ) ) { return null ; } $ value = $ value [ $ property ] ; } elseif ( is_null ( $ value ) ) { return null ; } else { throw new \ InvalidArgumentException ( sprintf ( "Value property '%s' in chain '%s' has invalid type: '%s'." , $ property , $ chain , gettype ( $ value ) ) ) ; } } return $ value ; }
Get chained property
46,345
public static function props ( $ value , array $ chains ) { $ props = array ( ) ; foreach ( $ chains as $ chain ) { $ props [ $ chain ] = static :: prop ( $ value , $ chain ) ; } return $ props ; }
Plural form of prop
46,346
public static function nulls ( array $ data , $ keys = null ) { if ( $ keys === null ) { $ keys = array_keys ( $ data ) ; } if ( ! Arrays :: isArray ( $ keys ) ) { $ keys = array ( $ keys ) ; } foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ data ) && empty ( $ data [ $ key ] ) ) { $ data [ $ key ] = null ; } } return $ data ; }
Filter empty values to be treated as nulls
46,347
public static function string ( $ value ) { if ( static :: stringable ( $ value ) ) { $ value = ( string ) $ value ; } else { $ value = null ; } return $ value ; }
Get value treated as string
46,348
public static function hash ( $ value ) { $ hash = is_object ( $ value ) ? spl_object_hash ( $ value ) : md5 ( Php :: encode ( $ value ) ) ; return $ hash ; }
Get hash for value for any type
46,349
private function generateSelector ( ) : string { $ in_use = true ; while ( $ in_use == true ) { $ this -> setSize ( 6 ) ; $ this -> generateRandomToken ( ) ; $ selector = bin2hex ( $ this -> token ) ; $ in_use = $ this -> db -> count ( 'core_activation_tokens' , 'selector = :selector' , [ 'selector' => $ selector ] ) > 0 ; } $ this -> selector = $ selector ; return $ this -> selector ; }
Creates a random and unique selector
46,350
public function getSelector ( bool $ refresh = false ) : string { if ( ! isset ( $ this -> selector ) || $ refresh ) { $ this -> generateSelector ( ) ; } return $ this -> selector ; }
Returns the selector .
46,351
private function generateActivationToken ( ) : string { $ this -> setSize ( 32 ) ; $ this -> generateRandomToken ( ) ; $ this -> activation_token = hash ( 'sha256' , $ this -> token ) ; return $ this -> activation_token ; }
Generates a random sha265 token
46,352
public function linkTo ( Service $ service , $ name = null ) { $ link = [ 'to_service' => $ service -> getResourceUri ( ) ] ; if ( ! is_null ( $ name ) ) { $ link [ 'name' ] = $ name ; } $ this -> linked_to_service [ ] = $ link ; }
Add a service to link to this service
46,353
public function registerFields ( $ id , $ item , $ depth , $ args ) { foreach ( $ this -> fields as $ _key => $ data ) : $ key = sprintf ( 'menu-item-%s' , $ _key ) ; $ id = sprintf ( 'edit-%s-%s' , $ key , $ item -> ID ) ; $ name = sprintf ( '%s[%s]' , $ key , $ item -> ID ) ; $ value = get_post_meta ( $ item -> ID , $ key , true ) ; $ class = sprintf ( 'field-%s' , $ _key ) ; ?> <p class="description description-wide <?php echo esc_attr ( $ class ) ?> "> <?php if ( $ data [ "type" ] == "bool" ) : ?> <label> <?= esc_html ( $ data [ "name" ] ) ?> <br/> <select id=" <?= esc_attr ( $ id ) ?> " class="widefat <?= esc_attr ( $ id ) ?> " name=" <?= esc_attr ( $ name ) ?> "> <option value="0" <?= $ value !== 1 ? " selected" : "" ?> > <?= __ ( "No" , "theme" ) ?> </option> <option value="1" <?= $ value == 1 ? " selected" : "" ?> > <?= __ ( "Yes" , "theme" ) ?> </option> </select> </label> <?php else : ?> <label> <?= esc_html ( $ data [ "name" ] ) ?> <br/> <input type="text" id=" <?= esc_attr ( $ id ) ?> " class="widefat <?= esc_attr ( $ id ) ?> " name=" <?= esc_attr ( $ name ) ?> " value=" <?= esc_attr ( $ value ) ?> "/> </label> <?php endif ; ?> </p> <?php endforeach ; }
Register fields for menu item required for mega menu
46,354
public function createImage ( $ src , $ alt = '' ) { $ img = $ this -> factory -> create ( 'Elements\Img' ) ; $ img -> setSrc ( $ src ) ; if ( ! empty ( $ alt ) ) { $ img -> setAlt ( $ alt ) ; } return $ this -> content = $ img ; }
Creates a brand imageobject and returns reference .
46,355
private function toJson ( $ object , $ view = null ) { return json_encode ( $ this -> builder -> buildRepresentation ( $ object , $ view ) ) ; }
Handles serializing an object to json
46,356
public function findAll ( $ page = 1 , $ max = 50 ) { $ offset = ( ( $ page - 1 ) * $ max ) ; $ products = $ this -> getEm ( ) -> getRepository ( "AmulenShopBundle:Product" ) -> findBy ( array ( ) , array ( ) , $ max , $ offset ) ; return $ products ; }
Find al Products with pagination options .
46,357
public function send ( ) { $ curl_handle = curl_init ( ) ; $ postfields = array ( ) ; $ postfields [ 'token' ] = $ this -> token ; $ postfields [ 'user' ] = $ this -> userkey ; $ postfields [ 'message' ] = $ this -> message ; $ postfields [ 'url' ] = $ this -> url ; $ postfields [ 'priority' ] = $ this -> priority ; $ postfields [ 'url_title' ] = $ this -> url_title ; $ postfields [ 'retry' ] = $ this -> retry ; $ postfields [ 'expire' ] = $ this -> expire ; curl_setopt_array ( $ curl_handle , array ( CURLOPT_URL => $ this -> pushover_messages_url , CURLOPT_POSTFIELDS => $ postfields , CURLOPT_RETURNTRANSFER => true , ) ) ; $ response = curl_exec ( $ curl_handle ) ; curl_close ( $ curl_handle ) ; if ( isset ( $ response [ 'status' ] ) && $ response [ 'status' ] == 1 ) { return true ; } return false ; }
Send this message
46,358
public function get ( $ value ) { if ( ! empty ( $ this -> _array [ $ value ] ) ) { return $ this -> _array [ $ value ] ; } else { return $ value ; } }
Get element from language array by key
46,359
public static function show ( $ value , $ name , $ code = null ) { if ( is_null ( $ code ) ) $ code = self :: $ _languageCode ; $ file = "../App/Language/$code/$name.php" ; if ( is_readable ( $ file ) ) { $ _array = include ( $ file ) ; } else { echo \ Core \ Error :: display ( "Could not load language file '$code/$name.php'" ) ; die ; } if ( ! empty ( $ _array [ $ value ] ) ) { return $ _array [ $ value ] ; } else { return $ value ; } }
Get language for views
46,360
public function create ( $ tag , $ html , $ useOption = false , $ parseContent = true , $ nestLimit = - 1 , array $ optionValidator = array ( ) , InputValidator $ bodyValidator = null ) { return new $ this -> className ( $ tag , $ html , $ useOption , $ parseContent , $ nestLimit , $ optionValidator , $ bodyValidator ) ; }
Create a new definition
46,361
protected function invokeGetter ( ReflectionProperty $ property ) { $ methodName = $ this -> generateGetterName ( $ property -> getName ( ) ) ; if ( $ this -> hasInternalMethod ( $ methodName ) ) { return $ this -> $ methodName ( ) ; } throw new UndefinedPropertyException ( sprintf ( 'No "%s"() method available for property "%s"' , $ methodName , $ property -> getName ( ) ) ) ; }
Invoke and return the given property s getter - method
46,362
protected function generateGetterName ( string $ propertyName ) : string { static $ methods = [ ] ; if ( isset ( $ methods [ $ propertyName ] ) ) { return $ methods [ $ propertyName ] ; } $ method = 'get' . ucfirst ( Str :: camel ( $ propertyName ) ) ; $ methods [ $ propertyName ] = $ method ; return $ method ; }
Generate and return a getter name based upon the given property name
46,363
private function loadPrincipalFromRememberMeCookie ( ) { $ hash = cookie ( 'remember_me' ) ; if ( $ hash === null ) { return ; } try { list ( $ id , $ token ) = explode ( '|' , base64_decode ( $ hash ) ) ; } catch ( Exception $ e ) { $ this -> deleteRememberMeCookie ( ) ; return ; } $ model = config ( 'auth.model.class' ) ; $ user = call_user_func ( [ $ model , 'find' ] , $ id ) ; if ( $ user !== null && ! empty ( $ token ) && $ token === $ user -> getAttribute ( 'remember_token' ) ) { $ this -> setPrincipal ( $ user -> getId ( ) , $ user -> getAttribute ( 'name' ) , $ user -> getAttribute ( 'role' ) ) ; } }
Read the remember me cookie if exist and store the principal into the session .
46,364
private function getAbilities ( $ role ) { $ abilities = [ ] ; foreach ( config ( 'auth.acl' ) as $ ability => $ roles ) { if ( in_array ( $ role , $ roles ) ) { $ abilities [ ] = $ ability ; } } return $ abilities ; }
Read the abilities from the ACL for the given role .
46,365
private function attribute ( $ key ) { if ( $ this -> attributes === null ) { $ this -> attributes = session ( '_auth' , [ ] ) ; if ( empty ( $ this -> attributes ) ) { $ this -> loadPrincipalFromRememberMeCookie ( ) ; } } return isset ( $ this -> attributes [ $ key ] ) ? $ this -> attributes [ $ key ] : null ; }
Load the user attributes from the session and get the attribute .
46,366
public function getVolumeFeed ( $ location = null ) { if ( $ location == null ) { $ uri = self :: VOLUME_FEED_URI ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( ) ; } else { $ uri = $ location ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Books_VolumeFeed' ) ; }
Retrieves a feed of volumes .
46,367
public function getVolumeEntry ( $ volumeId = null , $ location = null ) { if ( $ volumeId !== null ) { $ uri = self :: VOLUME_FEED_URI . "/" . $ volumeId ; } else if ( $ location instanceof Zend_Gdata_Query ) { $ uri = $ location -> getQueryUrl ( ) ; } else { $ uri = $ location ; } return parent :: getEntry ( $ uri , 'Zend_Gdata_Books_VolumeEntry' ) ; }
Retrieves a specific volume entry .
46,368
public function getUserLibraryFeed ( $ location = null ) { if ( $ location == null ) { $ uri = self :: MY_LIBRARY_FEED_URI ; } else { $ uri = $ location ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Books_VolumeFeed' ) ; }
Retrieves a feed of volumes by default the User library feed .
46,369
public function getUserAnnotationFeed ( $ location = null ) { if ( $ location == null ) { $ uri = self :: MY_ANNOTATION_FEED_URI ; } else { $ uri = $ location ; } return parent :: getFeed ( $ uri , 'Zend_Gdata_Books_VolumeFeed' ) ; }
Retrieves a feed of volumes by default the User annotation feed
46,370
private function findFilter ( $ filterId ) { foreach ( filter_list ( ) as $ filterName ) { if ( filter_id ( $ filterName ) === $ filterId ) { return $ filterName ; } } throw new \ Exception ( 'Could not find filter ' . $ filterId ) ; }
Finds the filter name by filter id
46,371
public function setSanitizeFilter ( $ filter ) { $ this -> filterName = $ this -> findFilter ( $ filter ) ; $ this -> sanitizeFilter = $ filter ; }
Sets sanitization filter
46,372
public function filter ( $ value ) { return $ this -> checkSanitizedValue ( filter_var ( $ value , $ this -> sanitizeFilter , $ this -> sanitizeFlags ) ) ; }
Sanitizes the value with the sanitization filter and flags assigned to this sanitizer
46,373
public function filterEnv ( $ variableName ) { if ( ! is_string ( $ variableName ) ) { throw new \ Exception ( 'Variable name expected as string' ) ; } if ( ! $ this -> filterHas ( \ INPUT_ENV , $ variableName ) ) { return null ; } return $ this -> filter ( getenv ( $ variableName ) ) ; }
Sanitizes a ENV - variable
46,374
public function filterSession ( $ variableName ) { if ( ! is_string ( $ variableName ) ) { throw new \ Exception ( 'Variable name expected as string' ) ; } if ( ! isset ( $ _SESSION [ $ variableName ] ) ) { return null ; } return $ this -> filter ( $ _SESSION [ $ variableName ] ) ; }
Sanitizes a SESSION - variable
46,375
public function filterRequest ( $ variableName ) { if ( ! is_string ( $ variableName ) ) { throw new \ Exception ( 'Variable name expected as string' ) ; } if ( ! isset ( $ _REQUEST [ $ variableName ] ) ) { return null ; } return $ this -> filter ( $ _REQUEST [ $ variableName ] ) ; }
Sanitizes a REQUEST - variable
46,376
public function indexAction ( ) { $ clientSettings = $ this -> configurationManager -> getConfiguration ( \ TYPO3 \ Flow \ Configuration \ ConfigurationManager :: CONFIGURATION_TYPE_SETTINGS , 'Flowpack.SingleSignOn.Client' ) ; $ clientSettingsYaml = \ Symfony \ Component \ Yaml \ Yaml :: dump ( $ clientSettings , 99 , 2 ) ; $ this -> view -> assign ( 'clientSettings' , $ clientSettingsYaml ) ; $ authenticationSettings = $ this -> configurationManager -> getConfiguration ( \ TYPO3 \ Flow \ Configuration \ ConfigurationManager :: CONFIGURATION_TYPE_SETTINGS , 'TYPO3.Flow.security.authentication' ) ; $ authenticationSettingsYaml = \ Symfony \ Component \ Yaml \ Yaml :: dump ( $ authenticationSettings , 99 , 2 ) ; $ this -> view -> assign ( 'authenticationSettings' , $ authenticationSettingsYaml ) ; }
Display configuration of client
46,377
protected static function open ( $ script , $ openTag , $ closeChar , $ phpFunc , $ phpClose ) { $ data = Strings :: splite ( $ script , $ openTag ) ; $ output = $ data [ 0 ] ; for ( $ i = 1 ; $ i < Collection :: count ( $ data ) ; $ i ++ ) { $ items = self :: getParmas ( $ data [ $ i ] , $ closeChar ) ; $ params = $ items [ 'params' ] ; $ rest = $ items [ 'rest' ] ; $ output .= self :: compile ( $ params , $ phpFunc , $ phpClose ) ; $ output .= $ rest ; } return $ output ; }
To compile de open tag .
46,378
protected static function getParmas ( $ row , $ closeChar ) { $ params = '' ; $ rest = '' ; $ taken = false ; $ string = false ; $ opened = 0 ; for ( $ j = 0 ; $ j < strlen ( $ row ) ; $ j ++ ) { if ( $ row [ $ j ] == "'" && ! $ string ) { $ string = 2 ; } elseif ( $ row [ $ j ] == '"' && ! $ string ) { $ string = 1 ; } elseif ( $ row [ $ j ] == "'" && $ string ) { $ string = false ; } elseif ( $ row [ $ j ] == '"' && $ string ) { $ string = false ; } if ( $ row [ $ j ] == '(' ) { $ opened ++ ; } elseif ( $ row [ $ j ] == ')' ) { $ opened -- ; } if ( ! $ string && $ opened == 0 && $ row [ $ j ] == $ closeChar && ! $ taken ) { $ taken = true ; } elseif ( ! $ taken ) { $ params .= $ row [ $ j ] ; } elseif ( $ taken ) { $ rest .= $ row [ $ j ] ; } } return [ 'params' => $ params , 'rest' => $ rest ] ; }
Get Fucntion params and the rest of script .
46,379
public static function toArray ( ) { $ enumClass = get_called_class ( ) ; if ( ! array_key_exists ( $ enumClass , self :: $ cache ) ) { $ reflector = new ReflectionClass ( $ enumClass ) ; self :: $ cache [ $ enumClass ] = $ reflector -> getConstants ( ) ; } return self :: $ cache [ $ enumClass ] ; }
Translate the current enumeration to an associative array
46,380
public static function isValidKey ( $ key ) { if ( ! is_string ( $ key ) ) { throw EnumerationException :: invalidKeyType ( gettype ( $ key ) ) ; } return array_key_exists ( $ key , self :: toArray ( ) ) ; }
Determines that the given key is exist in the current enumeration or not .
46,381
private function prepareDisplay ( ) { \ OWeb \ manage \ Events :: getInstance ( ) -> sendEvent ( 'PrepareContent_Start@OWeb\manage\Template' ) ; ob_start ( ) ; try { \ OWeb \ manage \ Controller :: getInstance ( ) -> display ( ) ; } catch ( \ Exception $ e ) { \ OWeb \ manage \ Events :: getInstance ( ) -> sendEvent ( 'PrepareContent_Fail@OWeb\manage\Template' ) ; ob_end_clean ( ) ; ob_start ( ) ; $ ctr = \ OWeb \ manage \ Controller :: getInstance ( ) -> loadException ( $ e ) ; $ ctr -> addParams ( "exception" , $ e ) ; \ OWeb \ manage \ Controller :: getInstance ( ) -> display ( ) ; } \ OWeb \ manage \ Events :: getInstance ( ) -> sendEvent ( 'PrepareContent_Succ@OWeb\manage\Template' ) ; $ this -> content = ob_get_contents ( ) ; \ OWeb \ manage \ Events :: getInstance ( ) -> sendEvent ( 'PrepareContent_End@OWeb\manage\Template' ) ; ob_end_clean ( ) ; }
Will get the output of the current controller to display it later on .
46,382
public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'model.xml' ) ; $ loader -> load ( 'form.xml' ) ; $ loader -> load ( 'helper.xml' ) ; $ loader -> load ( 'reader.xml' ) ; $ loader -> load ( 'converter.xml' ) ; $ loader -> load ( 'loader.xml' ) ; $ loader -> load ( 'manager.xml' ) ; $ loader -> load ( 'twig_extension.xml' ) ; $ loader -> load ( 'validator.xml' ) ; $ loader -> load ( 'cache.xml' ) ; $ this -> loadRepository ( $ loader , $ container , $ config ) ; $ this -> loadManager ( $ loader , $ container , $ config ) ; $ this -> loadRepoClass ( $ loader , $ container , $ config ) ; $ this -> loadCachePath ( $ container , $ config ) ; $ this -> loadVersionEyeKey ( $ container , $ config ) ; }
Load configuration of Bundle
46,383
protected function loadRepoClass ( $ loader , ContainerBuilder $ container , array $ config ) { if ( isset ( $ config [ 'repository' ] [ 'repo' ] [ 'class' ] ) ) { $ container -> setParameter ( 'snide_travinizer.model.repo.class' , $ config [ 'repository' ] [ 'repo' ] [ 'class' ] ) ; } }
Load repoClass entity
46,384
public function display ( string $ key , array $ data , int $ status = RegularResponse :: HTTP_OK ) : ResponseInterface { $ content = $ this -> templateStrategy -> render ( $ key , $ data ) ; $ this -> responseStrategy -> setContent ( $ content ) ; $ this -> responseStrategy -> setStatusCode ( $ status ) ; return $ this -> responseStrategy ; }
Make templating and give the response
46,385
public function before_insert ( Model $ obj ) { if ( $ this -> _overwrite or empty ( $ obj -> { $ this -> _property } ) ) { $ obj -> { $ this -> _property } = $ this -> _mysql_timestamp ? \ Date :: time ( ) -> format ( 'mysql' ) : \ Date :: time ( ) -> get_timestamp ( ) ; } }
Set the CreatedAt property to the current time .
46,386
public static function getSubscribedEvents ( ) { return [ Events :: UPDATE => [ 'onUpdate' , 0 ] , Events :: STORE => [ 'onStore' , 0 ] , sprintf ( '%s.%s' , Backend :: IDENTIFIER , TransactionEvents :: STORED ) => [ 'onTransactionStored' , 0 ] ] ; }
Returns an array of events to subscribe to and the methods to call when those events are fired
46,387
public function submitForm ( array $ values ) { $ this -> value = isset ( $ values [ $ this -> name ] ) ? $ values [ $ this -> name ] : null ; }
Pass in submitted values to allow the row to assign any values that are required .
46,388
protected function resolve ( Input $ input ) : Input { $ this -> call ( $ input -> value ( ) ) ; $ input -> ignore ( ) ; return $ input ; }
Resuelve un input
46,389
protected function makeElement ( array $ options , $ html ) { if ( isset ( $ options [ 'type' ] ) && $ options [ 'type' ] == 'hidden' ) return $ html ; if ( ! empty ( $ options [ 'before-input' ] ) ) $ html = $ options [ 'before-input' ] . $ html ; $ html = $ this -> getLabel ( $ options ) . $ html ; if ( ! empty ( $ options [ 'after-input' ] ) ) $ html .= $ options [ 'after-input' ] ; $ html .= $ this -> html -> getDivError ( $ options ) ; $ html = $ this -> html -> getFormGroup ( $ options , $ html ) ; if ( ! empty ( $ options [ 'script' ] ) ) $ this -> appendScript ( $ options [ 'script' ] ) ; if ( ! empty ( $ options [ 'mask' ] ) ) $ this -> appendScript ( $ this -> html -> getMaskScript ( $ options ) ) ; return $ this -> html -> getGrid ( $ options , $ html ) ; }
Make an Element
46,390
public static function Initialize ( $ ForceEnable = FALSE , $ ForceMethod = FALSE ) { $ AllowCaching = self :: ActiveEnabled ( $ ForceEnable ) ; $ ActiveCache = Gdn_Cache :: ActiveCache ( ) ; if ( $ ForceMethod !== FALSE ) $ ActiveCache = $ ForceMethod ; $ ActiveCacheClass = 'Gdn_' . ucfirst ( $ ActiveCache ) ; if ( ! $ AllowCaching || ! $ ActiveCache || ! class_exists ( $ ActiveCacheClass ) ) { $ CacheObject = new Gdn_Dirtycache ( ) ; } else $ CacheObject = new $ ActiveCacheClass ( ) ; if ( method_exists ( $ CacheObject , 'Autorun' ) ) $ CacheObject -> Autorun ( ) ; if ( ! func_num_args ( ) && Gdn :: PluginManager ( ) instanceof Gdn_PluginManager ) Gdn :: PluginManager ( ) -> FireEvent ( 'AfterActiveCache' ) ; return $ CacheObject ; }
Determines the currently installed cache solution and returns a fresh instance of its object
46,391
public static function ActiveCache ( ) { if ( defined ( 'CACHE_METHOD_OVERRIDE' ) ) $ ActiveCache = CACHE_METHOD_OVERRIDE ; else $ ActiveCache = C ( 'Cache.Method' , FALSE ) ; if ( ! func_num_args ( ) && Gdn :: PluginManager ( ) instanceof Gdn_PluginManager ) { Gdn :: PluginManager ( ) -> EventArguments [ 'ActiveCache' ] = & $ ActiveCache ; Gdn :: PluginManager ( ) -> FireEvent ( 'BeforeActiveCache' ) ; } return $ ActiveCache ; }
Gets the shortname of the currently active cache
46,392
public static function ActiveEnabled ( $ ForceEnable = FALSE ) { $ AllowCaching = FALSE ; if ( defined ( 'CACHE_ENABLED_OVERRIDE' ) ) $ AllowCaching |= CACHE_ENABLED_OVERRIDE ; $ AllowCaching |= C ( 'Cache.Enabled' , FALSE ) ; $ AllowCaching |= $ ForceEnable ; return ( bool ) $ AllowCaching ; }
Get the status of the active cache
46,393
public static function ActiveStore ( $ ForceMethod = NULL ) { $ ActiveCache = self :: ActiveCache ( ) ; if ( ! is_null ( $ ForceMethod ) ) $ ActiveCache = $ ForceMethod ; $ ActiveCache = ucfirst ( $ ActiveCache ) ; if ( defined ( 'CACHE_STORE_OVERRIDE' ) && defined ( 'CACHE_METHOD_OVERRIDE' ) && CACHE_METHOD_OVERRIDE == $ ActiveCache ) return unserialize ( CACHE_STORE_OVERRIDE ) ; $ apc = false ; if ( C ( 'Garden.Apc' , false ) && C ( 'Garden.Cache.ApcPrecache' , false ) && function_exists ( 'apc_fetch' ) ) $ apc = true ; $ LocalStore = null ; $ ActiveStore = null ; $ ActiveStoreKey = "Cache.{$ActiveCache}.Store" ; if ( is_null ( $ LocalStore ) ) { if ( array_key_exists ( $ ActiveCache , Gdn_Cache :: $ Stores ) ) { $ LocalStore = Gdn_Cache :: $ Stores [ $ ActiveCache ] ; } } if ( is_null ( $ LocalStore ) && $ apc ) { $ LocalStore = apc_fetch ( $ ActiveStoreKey ) ; if ( $ LocalStore ) { Gdn_Cache :: $ Stores [ $ ActiveCache ] = $ LocalStore ; } } if ( is_array ( $ LocalStore ) ) { $ Save = false ; $ ActiveStore = array ( ) ; foreach ( $ LocalStore as $ StoreServerName => & $ StoreServer ) { $ IsDelayed = & $ StoreServer [ 'Delay' ] ; $ IsActive = & $ StoreServer [ 'Active' ] ; if ( is_numeric ( $ IsDelayed ) ) { if ( $ IsDelayed < time ( ) ) { $ IsActive = true ; $ IsDelayed = false ; $ StoreServer [ 'Fails' ] = 0 ; $ Save = true ; } else { if ( $ IsActive ) { $ IsActive = false ; $ Save = true ; } } } if ( $ IsActive ) $ ActiveStore [ ] = $ StoreServer [ 'Server' ] ; } } if ( is_null ( $ ActiveStore ) ) { $ ActiveStore = C ( $ ActiveStoreKey , false ) ; $ LocalStore = array ( ) ; $ ActiveStore = ( array ) $ ActiveStore ; foreach ( $ ActiveStore as $ StoreServer ) { $ StoreServerName = md5 ( $ StoreServer ) ; $ LocalStore [ $ StoreServerName ] = array ( 'Server' => $ StoreServer , 'Active' => true , 'Delay' => false , 'Fails' => 0 ) ; } $ Save = true ; } if ( $ Save ) { Gdn_Cache :: $ Stores [ $ ActiveCache ] = $ LocalStore ; if ( $ apc ) { apc_store ( $ ActiveStoreKey , $ LocalStore , Gdn_Cache :: APC_CACHE_DURATION ) ; } } return $ ActiveStore ; }
Returns the storage data for the active cache
46,394
public function Fail ( $ server ) { $ apc = false ; if ( C ( 'Garden.Apc' , false ) && function_exists ( 'apc_fetch' ) ) $ apc = true ; $ activeCache = Gdn_Cache :: ActiveCache ( ) ; $ activeCache = ucfirst ( $ activeCache ) ; $ sctiveStoreKey = "Cache.{$activeCache}.Store" ; $ localStore = GetValue ( $ activeCache , Gdn_Cache :: $ Stores , null ) ; if ( is_null ( $ localStore ) ) { Gdn_Cache :: ActiveStore ( ) ; $ localStore = GetValue ( $ activeCache , Gdn_Cache :: $ Stores , null ) ; if ( is_null ( $ localStore ) ) { return false ; } } $ storeServerName = md5 ( $ server ) ; if ( ! array_key_exists ( $ storeServerName , $ localStore ) ) { return false ; } $ storeServer = & $ localStore [ $ storeServerName ] ; $ isActive = & $ storeServer [ 'Active' ] ; if ( ! $ isActive ) return false ; $ fails = & $ storeServer [ 'Fails' ] ; $ fails ++ ; $ active = $ isActive ? 'active' : 'inactive' ; if ( $ isActive && $ storeServer [ 'Fails' ] > 3 ) { $ isActive = false ; $ storeServer [ 'Delay' ] = time ( ) + Gdn_Cache :: CACHE_EJECT_DURATION ; } Gdn_Cache :: $ Stores [ $ activeCache ] = $ localStore ; if ( $ apc ) { apc_store ( $ sctiveStoreKey , $ localStore , Gdn_Cache :: APC_CACHE_DURATION ) ; } return true ; }
Register a temporary server connection failure
46,395
public function HasFeature ( $ Feature ) { return isset ( $ this -> Features [ $ Feature ] ) ? $ this -> Features [ $ Feature ] : Gdn_Cache :: CACHEOP_FAILURE ; }
Check whether this cache supports the specified feature
46,396
public function setConnection ( $ pHost , $ pName , $ pUser = NULL , $ pPassword = NULL ) { $ this -> _connection = $ this -> connect ( $ pHost , $ pName , $ pUser , $ pPassword ) ; $ this -> _dbName = $ pName ; return $ this ; }
Connect to database and register the connection .
46,397
public function getConnection ( ) { if ( is_null ( $ this -> _connection ) ) { $ this -> setConnection ( Agl :: app ( ) -> getConfig ( 'main/db/host' ) , Agl :: app ( ) -> getConfig ( 'main/db/name' ) , Agl :: app ( ) -> getConfig ( 'main/db/user' ) , Agl :: app ( ) -> getConfig ( 'main/db/password' ) ) ; } return $ this -> _connection ; }
Return the stored database connection .
46,398
public static function GetCoordinatesToCenterOverARegion ( $ configManager ) { return array ( "lat" => $ configManager -> get ( \ Puzzlout \ Framework \ Enums \ AppSettingKeys :: GoogleMapsCenterLat ) , "lng" => $ configManager -> get ( \ Puzzlout \ Framework \ Enums \ AppSettingKeys :: GoogleMapsCenterLng ) ) ; }
Retrieve the lattitude and longitude from the appsettings . xml to build an associative array in the Google Maps API format
46,399
public static function BuildLatAndLongCoordFromGeoObjects ( $ objects , $ latPropName , $ lngPropName ) { $ coordinates = array ( ) ; foreach ( $ objects as $ object ) { if ( self :: CheckCoordinateValue ( $ object -> $ latPropName ( ) ) && self :: CheckCoordinateValue ( $ object -> $ lngPropName ( ) ) ) { $ coordinate = array ( "lat" => $ object -> $ latPropName ( ) , "lng" => $ object -> $ lngPropName ( ) ) ; array_push ( $ coordinates , $ coordinate ) ; } } return $ coordinates ; }
Retrieve the lattitudes and longitudes from a list of objects based the lattitude and longitude property names filter .