idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
59,100
|
public function getBreadcrumb ( ) : Breadcrumb { if ( $ this -> breadcrumb === null ) { $ this -> breadcrumb = new Breadcrumb ( $ this -> translator ) ; if ( $ this -> baseUrl !== null ) { $ this -> breadcrumb -> addLink ( $ this -> baseUrl -> name , $ this -> baseUrl -> link ) ; } $ current = $ this -> setCurrent ( ) ; if ( $ current !== null ) { $ links = $ current -> getActualLinks ( ) ; foreach ( array_reverse ( $ links ) as $ link ) { $ this -> breadcrumb -> addLink ( $ link -> getName ( false ) , $ link -> link , $ link -> arguments ) ; } } } return $ this -> breadcrumb ; }
|
Vrati drobeckovou navidaci
|
59,101
|
public function get ( $ i ) { if ( ! isset ( $ this -> fragments [ $ i ] ) ) { return null ; } if ( ! isset ( $ this -> halved [ $ i ] ) || ! $ this -> fragments [ $ i ] || ! isset ( $ this -> sizes [ $ i ] ) ) { return $ this -> fragments [ $ i ] ; } $ half = ( int ) floor ( $ this -> sizes [ $ i ] / 2 ) ; $ value = $ this -> fragments [ $ i ] ; if ( $ value === $ half ) { $ value = 0 ; } if ( $ this -> halved [ $ i ] ) { $ value += $ half ; } return $ value ; }
|
Get time fragment FIXED VALUE checking if it has been halved or not .
|
59,102
|
public function withHalved ( $ index , $ value ) { $ res = clone $ this ; $ res -> halved = $ this -> insertInList ( $ res -> halved , $ index , $ value ) ; return $ res ; }
|
Set time fragment halved adding null values if needed .
|
59,103
|
public function withHalveds ( array $ halved ) { $ res = clone $ this ; $ this -> halved = $ this -> fillArrayInput ( $ halved , false ) ; return $ res ; }
|
Set all halved adding null values if needed .
|
59,104
|
public static function bootMetable ( ) { static :: saved ( function ( $ model ) { $ model -> syncMetableTableAttributes ( ) ; } ) ; static :: deleted ( function ( $ model ) { $ model -> handleDeletedModelMetas ( ) ; } ) ; static :: registerModelEvent ( 'restored' , function ( $ model ) { $ model -> handleRestoredModelMetas ( ) ; } ) ; }
|
Trait boot method called by parent model class .
|
59,105
|
public function metasArray ( ) { $ metas = array ( ) ; foreach ( $ this -> metas as $ meta ) { if ( ! isset ( $ meta -> pivot ) ) { continue ; } $ metas [ $ meta -> name ] = $ meta -> pivot -> value ; } return $ metas ; }
|
Return an array of all metas associated with this model .
|
59,106
|
public function meta ( $ meta , $ default = null ) { $ single = ( $ meta instanceof Collection ) ? false : is_array ( $ meta ) ? false : true ; $ metas = ( $ meta instanceof Collection ) ? $ meta -> all ( ) : is_array ( $ meta ) ? $ meta : array ( $ meta ) ; $ values = array ( ) ; foreach ( $ metas as $ m ) { if ( is_object ( $ m ) ) { $ values [ $ m -> name ] = $ this -> metas -> find ( $ m -> id , $ default ) ; continue ; } $ found = $ this -> metas -> filter ( function ( $ m2 ) use ( $ m ) { return $ m2 -> name == $ m ; } ) ; if ( ! $ found -> isEmpty ( ) ) { if ( isset ( $ found -> first ( ) -> pivot ) ) { $ values [ $ m ] = $ found -> first ( ) -> pivot -> value ; continue ; } } $ values [ $ m ] = $ default ; } return $ single ? current ( $ values ) : $ values ; }
|
Retrieve one or more values from the current model . Can be either a meta name a meta model a collection of models or an array of models .
|
59,107
|
public function setMeta ( $ meta , $ value = null ) { $ metas = is_array ( $ meta ) ? $ meta : array ( $ meta => $ value ) ; foreach ( $ metas as $ m => $ v ) { if ( ! is_object ( $ m ) ) { $ m = $ this -> findMetaByNameOrCreate ( $ m ) ; } if ( ! $ m || ! $ m instanceof Eloquent ) { continue ; } if ( $ this -> hasMeta ( $ m ) ) { if ( is_null ( $ v ) ) { $ this -> unsetMeta ( $ m ) ; continue ; } $ attributes = array ( 'value' => $ v , 'meta_updated_at' => date ( 'Y-m-d H:i:s' ) , ) ; $ this -> metas ( ) -> updateExistingPivot ( $ m -> id , array_merge ( $ this -> metableTableSyncAttributes ( ) , $ attributes ) ) ; $ this -> metas -> find ( $ m -> id ) -> pivot -> value = $ v ; $ this -> metas -> find ( $ m -> id ) -> pivot -> meta_updated_at = $ attributes [ 'meta_updated_at' ] ; } else { if ( is_null ( $ v ) ) { continue ; } $ this -> metas ( ) -> attach ( $ m , array_merge ( $ this -> metableTableSyncAttributes ( ) , array ( 'value' => $ v , 'meta_created_at' => date ( 'Y-m-d H:i:s' ) , 'meta_updated_at' => date ( 'Y-m-d H:i:s' ) , ) ) ) ; $ m -> increment ( 'num_items' ) ; $ this -> metas -> add ( $ m ) ; } } return $ this ; }
|
Add one or more metas to the current model . Can be either a meta name a meta model or an array of models .
|
59,108
|
public function unsetMeta ( $ meta = null ) { $ args = func_get_args ( ) ; if ( 0 == count ( $ args ) ) { $ args [ ] = $ this -> metas ; } foreach ( $ args as $ arg ) { $ metas = ( $ arg instanceof Collection ) ? $ arg -> all ( ) : is_array ( $ arg ) ? $ arg : array ( $ arg ) ; foreach ( $ metas as $ m ) { if ( ! is_object ( $ m ) ) { $ m = $ this -> findMetaByName ( $ m ) ; } if ( ! $ m || ! $ m instanceof Eloquent ) { continue ; } if ( ! $ this -> hasMeta ( $ m ) ) { return ; } $ this -> metas ( ) -> detach ( $ m ) ; $ m -> decrement ( 'num_items' ) ; foreach ( $ this -> metas as $ idx => $ cur_meta ) { if ( $ cur_meta -> getKey ( ) == $ m -> getKey ( ) ) { $ this -> metas -> pull ( $ idx ) ; break ; } } } } return $ this ; }
|
Remove one or more metas from the current model . Can be either a meta name a meta model a collection of models or an array of models . Will remove all metas if no paramter is passed .
|
59,109
|
private function newMetaQuery ( ) { $ meta_model = $ this -> metaModel ( ) ; $ meta_instance = new $ meta_model ; $ query = $ meta_instance -> newQuery ( ) ; if ( method_exists ( $ this , 'metaContext' ) ) { if ( method_exists ( $ meta_model , 'applyQueryContext' ) ) { call_user_func_array ( array ( $ meta_model , 'applyQueryContext' ) , array ( $ query , $ this -> metaContext ( ) ) ) ; } } return $ query ; }
|
Return a new meta table query .
|
59,110
|
private function findMetaByNameOrCreate ( $ name ) { if ( $ meta = $ this -> findMetaByName ( $ name ) ) { return $ meta ; } $ meta_model = $ this -> metaModel ( ) ; $ meta = new $ meta_model ; $ meta -> name = $ name ; $ meta -> num_items = 0 ; if ( method_exists ( $ this , 'metaContext' ) ) { if ( method_exists ( $ meta_model , 'applyModelContext' ) ) { call_user_func_array ( array ( $ meta_model , 'applyModelContext' ) , array ( $ meta , $ this -> metaContext ( ) ) ) ; } } $ meta -> save ( ) ; return $ meta ; }
|
Find a meta from the given name or create it if not found .
|
59,111
|
private function metableTableSyncAttributes ( ) { if ( ! isset ( $ this -> metable_table_sync ) ) { return array ( ) ; } $ attributes = array ( ) ; foreach ( $ this -> metable_table_sync as $ attr ) { $ attributes [ $ attr ] = $ this -> getAttribute ( $ attr ) ; } return $ attributes ; }
|
Return an array of model attributes to sync on the metable_table records .
|
59,112
|
public function metableTableSoftDeletes ( ) { if ( method_exists ( $ this , 'getDeletedAtColumn' ) ) { if ( array_key_exists ( $ this -> getDeletedAtColumn ( ) , $ this -> metableTableSyncAttributes ( ) ) ) { return true ; } } return false ; }
|
Returns whether or not we are soft - deleting metable table records .
|
59,113
|
public function syncMetableTableAttributes ( ) { if ( empty ( $ this -> metableTableSyncAttributes ( ) ) ) { return ; } DB :: table ( $ this -> metableTable ( ) ) -> where ( 'xref_id' , $ this -> getKey ( ) ) -> update ( $ this -> metableTableSyncAttributes ( ) ) ; }
|
Sync metable table attributes to all metas associated with this model .
|
59,114
|
private function handleDeletedModelMetas ( ) { if ( $ this -> metableTableSoftDeletes ( ) ) { foreach ( $ this -> metas as $ meta ) { $ this -> syncMetableTableAttributes ( ) ; $ meta -> decrement ( 'num_items' ) ; } return ; } $ this -> unsetMeta ( ) ; }
|
Delete metable table records for this current model since it was just deleted .
|
59,115
|
private function handleRestoredModelMetas ( ) { if ( ! $ this -> metableTableSoftDeletes ( ) ) { return ; } foreach ( $ this -> metas as $ meta ) { $ this -> syncMetableTableAttributes ( ) ; $ meta -> increment ( 'num_items' ) ; } }
|
Restore metable table records for this current model since it was just restorede .
|
59,116
|
public static function queryMetas ( ) { $ model = new static ; $ conn = $ model -> getConnection ( ) ; $ query = new QueryBuilder ( $ conn , $ conn -> getQueryGrammar ( ) , $ conn -> getPostProcessor ( ) ) ; $ query -> setModel ( $ model ) ; return $ query ; }
|
Begin querying the model s metable table .
|
59,117
|
public function build ( $ field ) { $ return = '' ; if ( \ is_array ( $ field ) ) { $ field = $ this -> fieldFactory -> build ( $ field ) ; } $ this -> field = $ field ; $ this -> props = $ field -> props ; $ id = $ field -> getId ( ) ; $ isBuilding = \ in_array ( $ id , $ this -> building ) ; $ uniqueId = $ field -> getUniqueId ( ! $ isBuilding ) ; $ this -> setIds ( $ uniqueId ) ; if ( ! $ isBuilding ) { $ this -> building [ ] = $ id ; } $ this -> addAttributes ( ) ; if ( ! $ isBuilding ) { $ return = $ field -> doBuild ( ) ; } if ( ! $ return ) { $ return = $ this -> doBuild ( ) ; } $ return = $ this -> removeEmptyTags ( $ return ) ; $ key = \ array_search ( $ id , $ this -> building ) ; if ( $ key !== false ) { unset ( $ this -> building [ $ key ] ) ; } return $ return ; }
|
Build a form input control
|
59,118
|
protected function doBuild ( ) { switch ( $ this -> props [ 'attribs' ] [ 'type' ] ) { case 'checkbox' : $ return = $ this -> buildCheckbox ( ) ; break ; case 'html' : $ return = $ this -> props [ 'attribs' ] [ 'value' ] ; break ; case 'radio' : $ return = $ this -> buildRadio ( ) ; break ; case 'select' : $ return = $ this -> buildSelect ( ) ; break ; case 'textarea' : $ return = $ this -> buildTextarea ( ) ; break ; case 'button' : case 'reset' : case 'submit' : $ return = $ this -> buildButton ( ) ; break ; case 'static' : $ return = $ this -> buildStatic ( ) ; break ; default : $ return = $ this -> buildDefault ( ) ; } return $ return ; }
|
Build the html for the given
|
59,119
|
protected function buildAttribStrings ( $ props ) { $ attribStrings = array ( ) ; foreach ( $ props as $ k => $ v ) { if ( \ strpos ( $ k , 'attribs' ) === 0 ) { $ attribStrings [ $ k ] = \ trim ( Html :: buildAttribString ( $ v ) ) ; } } return $ attribStrings ; }
|
Build attribute strings
|
59,120
|
protected function buildButton ( ) { $ attribStrings = $ this -> buildAttribStrings ( $ this -> props ) ; $ props = \ array_merge ( $ this -> props , $ attribStrings ) ; if ( empty ( $ props [ 'input' ] ) ) { if ( empty ( $ props [ 'label' ] ) && ! empty ( $ this -> props [ 'attribs' ] [ 'value' ] ) ) { $ props [ 'label' ] = $ this -> props [ 'attribs' ] [ 'value' ] ; } $ props [ 'input' ] = Html :: buildTag ( $ props [ 'tagname' ] , $ props [ 'attribs' ] , $ props [ 'label' ] ) ; } $ props [ 'label' ] = null ; return $ props [ 'tagOnly' ] ? $ props [ 'input' ] : Str :: quickTemp ( $ props [ 'template' ] , $ props ) ; }
|
Build a button control
|
59,121
|
protected function buildInputGroup ( ) { $ props = $ this -> props ; if ( $ props [ 'tagOnly' ] ) { return $ props [ 'input' ] ; } if ( ! $ props [ 'addonBefore' ] && ! $ props [ 'addonAfter' ] ) { return $ props [ 'input' ] ; } if ( $ props [ 'addonBefore' ] ) { $ addonClass = \ preg_match ( '#<(a|button)\b#i' , $ props [ 'addonBefore' ] ) ? 'input-group-btn' : 'input-group-addon' ; $ props [ 'addonBefore' ] = '<span class="' . $ addonClass . '">' . $ props [ 'addonBefore' ] . '</span>' ; } if ( $ props [ 'addonAfter' ] ) { $ addonClass = \ preg_match ( '#<(a|button)\b#i' , $ props [ 'addonAfter' ] ) ? 'input-group-btn' : 'input-group-addon' ; $ props [ 'addonAfter' ] = '<span class="' . $ addonClass . '">' . $ props [ 'addonAfter' ] . '</span>' ; } $ propsInputGroup = $ this -> mergeProps ( array ( array ( 'attribs' => array ( 'class' => 'input-group' ) , ) , array ( 'attribs' => isset ( $ props [ 'attribsInputGroup' ] ) ? $ props [ 'attribsInputGroup' ] : array ( ) , ) , ) ) ; $ attribsInputGroup = $ propsInputGroup [ 'attribs' ] ; return '<div' . Html :: buildAttribString ( $ attribsInputGroup ) . '>' . "\n" . $ props [ 'addonBefore' ] . "\n" . $ props [ 'input' ] . "\n" . $ props [ 'addonAfter' ] . "\n" . '</div>' ; }
|
Handles pressence of addonAfter or addonBefore
|
59,122
|
protected function buildRadio ( ) { if ( $ this -> props [ 'useFieldset' ] ) { $ this -> props [ 'template' ] = \ preg_replace ( '#^<div([^>]*)>(.+)</div>$#s' , '<fieldset$1>$2</fieldset>' , $ this -> props [ 'template' ] ) ; $ this -> props [ 'template' ] = \ preg_replace ( '#<label([^>]*)>(.+)</label>#s' , '<legend>$2</legend>' , $ this -> props [ 'template' ] ) ; } $ attribStrings = $ this -> buildAttribStrings ( $ this -> props ) ; $ props = \ array_merge ( $ this -> props , $ attribStrings ) ; $ props [ 'input' ] = $ this -> buildCheckboxRadioGroup ( ) ; if ( $ this -> props [ 'tagOnly' ] ) { return $ this -> props ; } else { return Str :: quickTemp ( $ props [ 'template' ] , $ props ) ; } }
|
Builds radio controls
|
59,123
|
protected function buildSelectOptions ( $ options , $ selectedValues = array ( ) ) { $ str = '' ; $ inOptgroup = false ; foreach ( $ options as $ opt ) { if ( isset ( $ opt [ 'optgroup' ] ) ) { if ( $ inOptgroup ) { $ str .= '</optgroup>' . "\n" ; $ inOptgroup = false ; } if ( $ opt [ 'optgroup' ] ) { $ attribs = $ opt [ 'attribs' ] ; $ attribs [ 'label' ] = $ opt [ 'label' ] ; $ str .= '<optgroup' . Html :: buildAttribString ( $ attribs ) . '>' . "\n" ; $ inOptgroup = true ; } } else { $ optAttribs = \ array_merge ( array ( 'selected' => \ in_array ( $ opt [ 'attribs' ] [ 'value' ] , $ selectedValues ) , ) , $ opt [ 'attribs' ] ) ; $ str .= Html :: buildTag ( 'option' , $ optAttribs , \ htmlspecialchars ( $ opt [ 'label' ] ) ) . "\n" ; } } if ( $ inOptgroup ) { $ str .= '</optgroup>' . "\n" ; } return $ str ; }
|
Build selects option list
|
59,124
|
protected function buildStatic ( ) { $ innerhtml = \ htmlspecialchars ( $ this -> props [ 'attribs' ] [ 'value' ] ) ; $ this -> props [ 'attribs' ] = \ array_diff_key ( $ this -> props [ 'attribs' ] , \ array_flip ( array ( 'name' , 'type' , 'value' ) ) ) ; $ attribStrings = $ this -> buildAttribStrings ( $ this -> props ) ; $ props = \ array_merge ( $ this -> props , $ attribStrings ) ; if ( empty ( $ props [ 'input' ] ) ) { $ props [ 'input' ] = Html :: buildTag ( $ props [ 'tagname' ] , $ props [ 'attribs' ] , $ innerhtml ) ; } return $ props [ 'tagOnly' ] ? $ props [ 'input' ] : Str :: quickTemp ( $ props [ 'template' ] , $ props ) ; }
|
Build static control
|
59,125
|
protected function removeEmptyTags ( $ html ) { if ( ! \ is_string ( $ html ) ) { return $ html ; } $ html = \ preg_replace ( '#^\s*<(div|label|legend|span)\b[^>]*>\s*</\1>\n#m' , '' , $ html ) ; $ html = \ preg_replace ( '#^\s*\n#m' , '' , $ html ) ; $ html = \ preg_replace ( '#<(\w+) >#' , '<$1>' , $ html ) ; return $ html ; }
|
Remove empty tags from string
|
59,126
|
protected function setIds ( $ id ) { if ( $ id ) { $ this -> props = $ this -> mergeProps ( array ( $ this -> props , array ( 'attribsContainer' => array ( 'id' => $ id . '_container' , ) , 'attribs' => array ( 'id' => $ id , ) , 'attribsLabel' => array ( 'for' => $ id , ) , 'attribsHelpBlock' => array ( 'id' => $ id . '_help_block' , ) , ) , ) ) ; } }
|
Set ID attributes
|
59,127
|
public static function Pmp ( array $ a , array $ b , array & $ amb ) { $ amb [ 0 ] = $ a [ 0 ] - $ b [ 0 ] ; $ amb [ 1 ] = $ a [ 1 ] - $ b [ 1 ] ; $ amb [ 2 ] = $ a [ 2 ] - $ b [ 2 ] ; return ; }
|
- - - - - - - i a u P m p - - - - - - -
|
59,128
|
private function getAllTableNames ( ) { $ handler = $ this -> databaseConnection -> queryAndHandle ( "SHOW TABLES FROM `" . $ this -> databaseConnection -> getDatabaseName ( ) . "`" ) ; $ tableNames = array ( ) ; if ( $ handler -> getResultSize ( ) > 0 ) { while ( $ oDatabaseResultRow = $ handler -> fetchNextResultObject ( ) ) { $ tablesInVariableName = "Tables_in_" . $ this -> databaseConnection -> getDatabaseName ( ) ; if ( substr ( $ oDatabaseResultRow -> $ tablesInVariableName , 0 , strlen ( $ this -> databaseConnection -> getTablePrefix ( ) ) ) == $ this -> databaseConnection -> getTablePrefix ( ) ) { array_push ( $ tableNames , $ oDatabaseResultRow -> $ tablesInVariableName ) ; } } } return $ tableNames ; }
|
Returns all tablenames of the current connected database matching to the table prefix in the used connection .
|
59,129
|
private function createTable ( MWebfile $ webfile , $ dropTableIfExists = true ) { $ tableName = $ this -> resolveTableNameFromWebfile ( $ webfile ) ; if ( ! $ this -> metadataExist ( $ tableName ) ) { $ this -> addMetadata ( $ webfile :: $ m__sClassName , '1' , $ tableName ) ; } $ attributeArray = $ webfile -> getAttributes ( ) ; $ table = new MDatabaseTable ( $ this -> databaseConnection , $ tableName ) ; $ table -> specifyIdentifier ( "id" , 10 ) ; foreach ( $ attributeArray as $ oAttribute ) { $ sAttributeName = $ oAttribute -> getName ( ) ; if ( MWebfile :: isSimpleDatatype ( $ sAttributeName ) && MWebfile :: getSimplifiedAttributeName ( $ sAttributeName ) != "id" ) { $ tableColum = $ this -> createTableColumnFromAttributeName ( $ sAttributeName ) ; $ table -> addColumnObject ( $ tableColum ) ; } } if ( $ dropTableIfExists && $ this -> tableExistsByWebfile ( $ webfile ) ) { $ table -> drop ( ) ; } $ table -> create ( ) ; }
|
Creates a database table to persist objects of this type .
|
59,130
|
public function deleteAll ( ) { $ tablenames = $ this -> getAllTableNames ( ) ; foreach ( $ tablenames as $ tablename ) { $ this -> databaseConnection -> query ( "DROP TABLE " . $ tablename ) ; } }
|
Deletes all webfiles in the store and all metadata
|
59,131
|
private function getBrowsersCountFromSessions ( Carbon $ start , Carbon $ end ) { return $ this -> getVisitorsFilteredByDateRange ( $ start , $ end ) -> filter ( function ( Visitor $ visitor ) { return $ visitor -> hasUserAgent ( ) ; } ) -> transform ( function ( Visitor $ visitor ) { return $ visitor -> agent ; } ) -> groupBy ( 'browser' ) -> transform ( function ( Collection $ items , $ key ) { return [ 'name' => $ key , 'count' => $ items -> count ( ) , ] ; } ) -> sortByDesc ( 'count' ) ; }
|
Get the browsers count from sessions .
|
59,132
|
public function getCache ( ) { if ( null == $ this -> cache ) { $ this -> setCache ( Cache :: get ( Cache :: CACHE_MEMORY ) ) ; } return $ this -> cache ; }
|
Gets cache storage for this identity map
|
59,133
|
private static function show ( $ env = null ) { if ( ! isset ( $ env ) ) { $ env = $ GLOBALS ; } static :: $ current -> display ( static :: $ SHOWMODEL , $ env ) ; exit ( ) ; }
|
Show the rendering using a child rendering class
|
59,134
|
final public static function doDisplay ( $ layout = null , $ env = null ) { if ( $ env === null ) { $ env = $ GLOBALS ; } static :: $ current -> display ( $ layout , $ env ) ; return true ; }
|
Call the display function
|
59,135
|
public static function endCurrentLayout ( $ env = array ( ) ) { if ( ! ob_get_level ( ) || empty ( static :: $ layoutStack ) ) { return false ; } $ env [ 'Content' ] = ob_get_clean ( ) ; static :: $ current -> display ( array_pop ( static :: $ layoutStack ) , $ env ) ; return true ; }
|
End the current layout
|
59,136
|
public function connect ( ) { $ connection = $ this -> config -> get ( 'redis_connection' ) ; $ params = array ( 'prefix' => $ this -> config -> get ( 'redis_prefix' ) . ':' ) ; $ this -> redis = new \ Predis \ Client ( $ connection , $ params ) ; }
|
Start the redis connection
|
59,137
|
public function flush ( ) { $ cache_keys = $ this -> redis -> keys ( '*' ) ; foreach ( $ cache_keys as $ key ) { $ this -> redis -> del ( $ key ) ; } unset ( $ cache_keys ) ; return true ; }
|
Clear all cached items for this driver
|
59,138
|
public static function rot47 ( $ str ) { $ result = '' ; foreach ( str_split ( $ str ) as $ char ) { $ ord = ord ( $ char ) ; $ result .= ( namespace \ Utils :: numberBetween ( $ ord , 33 , 126 ) ) ? chr ( namespace \ Utils :: numberWrap ( $ ord + 47 , 33 , 126 ) ) : $ char ; } return $ result ; }
|
Offsets every ASCII character from ! to ~ by 47 bits wrapping overflow
|
59,139
|
protected function slug ( $ string , $ isDomain = false ) { $ pattern = ( $ isDomain ? '/[^A-Za-z0-9-\.]+/' : '/[^A-Za-z0-9-]+/' ) ; return strtolower ( trim ( preg_replace ( $ pattern , '-' , $ string ) ) ) ; }
|
Generate a slug from a given string .
|
59,140
|
public function getFileSystem ( ) { if ( null == $ this -> fileSystem ) { $ this -> setFileSystem ( Helper :: getFileSystem ( ) ) ; } return $ this -> fileSystem ; }
|
get filesystem instance
|
59,141
|
protected function saveAccessToken ( $ token , $ expire ) { $ data = [ 'token' => $ token , 'expire' => intval ( $ expire ) , 'time' => time ( ) ] ; return ( $ this -> getFileSystem ( ) -> put ( $ this -> getTokenFilePath ( ) , json_encode ( $ data ) , true ) > 0 ) ; }
|
save access token to file
|
59,142
|
protected function readAccessToken ( ) { if ( ! $ this -> getFileSystem ( ) -> isFile ( $ this -> getTokenFilePath ( ) ) ) { return '' ; } $ content = trim ( $ this -> getFileSystem ( ) -> get ( $ this -> getTokenFilePath ( ) ) ) ; $ result = json_decode ( $ content , true ) ; if ( isset ( $ result [ 'token' ] ) && isset ( $ result [ 'expire' ] ) && isset ( $ result [ 'time' ] ) ) { $ expireTime = $ result [ 'time' ] + $ result [ 'expire' ] - self :: TOKEN_EXPIRE_SUB_TIME ; if ( $ expireTime > time ( ) ) { return $ result [ 'token' ] ; } } return '' ; }
|
read access token from file
|
59,143
|
public function getAccessToken ( ) { $ result = $ this -> readAccessToken ( ) ; if ( '' != $ result ) { return $ result ; } $ data = $ this -> getAccessTokenFromWeChat ( ) ; $ this -> saveAccessToken ( $ data [ 'token' ] , $ data [ 'expire' ] ) ; return $ data [ 'token' ] ; }
|
get access token
|
59,144
|
protected function setUpEnvironment ( ) { $ dotEnv = new Dotenv ( ) ; $ dotEnv -> populate ( $ this -> getEnvironmentVars ( ) ) ; $ envFilePath = Path :: getProjectRoot ( '/.env' ) ; if ( is_readable ( $ envFilePath ) ) { $ dotEnv -> load ( $ envFilePath ) ; } $ errorLogFile = getenv ( 'ERROR_LOG' ) ; ini_set ( 'error_log' , Path :: getProjectRoot ( $ errorLogFile ) ) ; }
|
Load . env if it set and merge with environment
|
59,145
|
protected function mapCustomInstallPaths ( array $ paths , string $ name , string $ type , string $ vendor = '' ) : string { foreach ( $ paths as $ path => $ names ) { if ( in_array ( $ name , $ names ) || in_array ( 'type:' . $ type , $ names ) ) { return $ path ; } if ( ! empty ( $ vendor ) && in_array ( 'vendor:' . $ vendor , $ names ) ) { return $ path ; } } return '' ; }
|
Search through a paths array for a custom install path .
|
59,146
|
public function init ( ) { $ attributes = $ this -> getAttributes ( ) ; $ fullPath = storage_path ( $ attributes [ 'path' ] ) ; if ( Support \ is_path_exists ( $ fullPath ) ) $ this -> settings = Support \ get_file_contents ( $ fullPath ) ; else Support \ dump_file ( $ fullPath , json_encode ( [ ] ) ) ; register_shutdown_function ( function ( ) use ( $ fullPath ) { Support \ dump_file ( $ fullPath , $ this -> packData ( $ this -> settings ) ) ; } ) ; }
|
Set settings .
|
59,147
|
public function insert ( $ key , $ value , $ group = self :: DEFAULT_GROUP ) { return $ this -> update ( $ key , $ value , $ group ) ; }
|
Insert a new option and set value .
|
59,148
|
public function clear ( $ group = null ) { if ( isset ( $ group ) ) unset ( $ this -> settings [ $ group ] ) ; else $ this -> settings = [ ] ; return $ this ; }
|
delete all options entries from .
|
59,149
|
private function check_timestamp ( $ timestamp ) { if ( ! $ timestamp ) throw new Exception ( 'Missing timestamp parameter. The parameter is required' ) ; $ now = time ( ) ; if ( abs ( $ now - $ timestamp ) > $ this -> timestamp_threshold ) { throw new Exception ( "Expired timestamp, yours $timestamp, ours $now" ) ; } }
|
Check that the timestamp is new enough
|
59,150
|
private function check_nonce ( $ consumer , $ token , $ nonce , $ timestamp ) { if ( ! $ nonce ) throw new Exception ( 'Missing nonce parameter. The parameter is required' ) ; $ found = $ this -> data_store -> lookup_nonce ( $ consumer , $ token , $ nonce , $ timestamp ) ; if ( $ found ) { throw new Exception ( "Nonce already used: $nonce" ) ; } }
|
Check that the nonce is not repeated
|
59,151
|
public static function Sxp ( $ s , array $ p , array & $ sp ) { $ sp [ 0 ] = $ s * $ p [ 0 ] ; $ sp [ 1 ] = $ s * $ p [ 1 ] ; $ sp [ 2 ] = $ s * $ p [ 2 ] ; return ; }
|
- - - - - - - i a u S x p - - - - - - -
|
59,152
|
protected function _countIterable ( $ iterable ) { $ resolve = function ( $ it ) { try { return $ this -> _resolveIterator ( $ it , function ( $ it ) { return $ it instanceof Countable ; } ) ; } catch ( RootException $ e ) { return ; } } ; if ( $ iterable instanceof stdClass ) { $ iterable = ( array ) $ iterable ; } if ( is_array ( $ iterable ) || $ iterable instanceof Countable ) { return count ( $ iterable ) ; } if ( $ countable = $ resolve ( $ iterable ) ) { return count ( $ countable ) ; } return iterator_count ( $ iterable ) ; }
|
Counts the elements in an iterable .
|
59,153
|
public function json ( array $ data ) { $ data = json_encode ( $ data ) ; $ response = $ this -> withHeader ( 'Content-Type' , 'application/json' ) ; $ response -> getBody ( ) -> write ( $ data ) ; return $ response ; }
|
set content - type = json and response json
|
59,154
|
public function withStatus ( $ code , $ reasonPhrase = '' ) { if ( ! is_string ( $ reasonPhrase ) && ! method_exists ( $ reasonPhrase , '__toString' ) ) { throw new InvalidArgumentException ( 'ReasonPhrase must be a string' ) ; } $ clone = clone $ this ; $ clone -> statusCode = $ code ; if ( $ reasonPhrase === '' && isset ( Header :: $ messages [ $ code ] ) ) { $ reasonPhrase = Header :: $ messages [ $ code ] ; } $ clone -> reasonPhrase = $ reasonPhrase ; return $ clone ; }
|
set response status
|
59,155
|
protected function parse ( $ resource ) { $ fp = fopen ( $ resource , 'r' ) ; $ messages = array ( ) ; $ pair = array ( ) ; while ( ! feof ( $ fp ) ) { $ line = fgets ( $ fp ) ; if ( strncmp ( $ line , 'msgid' , strlen ( 'msgid' ) ) === 0 ) { $ str = $ this -> normalize ( substr ( $ line , strlen ( 'msgid' ) + 1 , strlen ( $ line ) ) ) ; if ( ! empty ( $ str ) ) { $ pair [ ] = $ str ; } } elseif ( strncmp ( $ line , 'msgstr' , strlen ( 'msgstr' ) ) === 0 ) { $ str = $ this -> normalize ( substr ( $ line , strlen ( 'msgstr' ) + 1 , strlen ( $ line ) ) ) ; if ( ! empty ( $ pair ) ) { $ pair [ ] = $ str ; } } if ( count ( $ pair ) == 2 ) { $ messages [ $ pair [ 0 ] ] = $ pair [ 1 ] ; $ pair = array ( ) ; } } fclose ( $ fp ) ; return $ messages ; }
|
Parse a POT file extracting translation units
|
59,156
|
public function append ( $ value ) { $ values = $ this -> sanitize ( $ value ) ; foreach ( $ values as $ class ) { parent :: append ( $ class ) ; } return $ this ; }
|
Append a value to the end of the container .
|
59,157
|
public function setSeparator ( $ separator ) { if ( ! in_array ( $ separator , [ ' ' , '-' ] , true ) ) { $ separator = ' ' ; } $ this -> separator = $ separator ; return $ this ; }
|
Set Separator .
|
59,158
|
public function renderMenu ( \ Twig_Environment $ environment , $ name , array $ options = array ( ) ) { $ menu = $ this -> loadMenu ( $ name ) ; $ builder = $ menu -> getBuilder ( ) ; return $ environment -> render ( $ builder -> getTemplateName ( ) , array ( 'menu' => $ menu ) ) ; }
|
Renders a menu
|
59,159
|
private function loadMenu ( $ name ) { if ( $ name instanceof Menu ) { return $ name ; } $ menu = $ this -> menuRepository -> findOneBy ( array ( 'name' => $ name ) ) ; if ( ! $ menu ) { throw new \ RuntimeException ( sprintf ( 'Unable to load menu "%s"' , $ name ) ) ; } return $ menu ; }
|
Loads a Menu entity given its name
|
59,160
|
public function renderTwig ( \ Twig_Environment $ environment , $ template , array $ parameters = array ( ) ) { $ template = $ this -> loadStringTemplate ( $ environment , $ template ) ; return $ template -> render ( $ parameters ) ; }
|
Renders raw Twig
|
59,161
|
private function loadStringTemplate ( \ Twig_Environment $ environment , $ template ) { $ existingLoader = $ environment -> getLoader ( ) ; $ environment -> setLoader ( $ this -> stringLoader ) ; try { $ template = $ environment -> loadTemplate ( $ template ) ; } catch ( \ Exception $ e ) { $ environment -> setLoader ( $ existingLoader ) ; throw $ e ; } $ environment -> setLoader ( $ existingLoader ) ; return $ template ; }
|
Loads raw Twig using the given Environment
|
59,162
|
public function getItemFormView ( array $ options = array ( ) ) { $ item = new CartItem ( ) ; $ form = $ this -> container -> get ( 'form.factory' ) -> create ( 'EcommerceBundle\Form\CartItemSimpleType' , $ item , $ options ) ; return $ form -> createView ( ) ; }
|
Returns cart item form view .
|
59,163
|
public function shareUrl ( $ url , $ big = false ) { if ( ! is_numeric ( strpos ( $ url , 'http' ) ) ) { $ core = $ this -> container -> getParameter ( 'core' ) ; $ url = $ core [ 'server_base_url' ] . $ url ; } $ text = 'Check out this site:' ; $ tweetUrl = 'https://twitter.com/share?url=' . $ url . '&counturl=' . $ url . '&text=' . $ text ; $ faceUrl = 'http://www.facebook.com/sharer/sharer.php?u=' . $ url . '&text=' . $ text ; $ googleUrl = 'https://plus.google.com/share?url=' . $ url ; $ linkedUrl = 'https://www.linkedin.com/shareArticle?summary=&ro=false&title=' . $ text . '&mini=true&url=' . $ url . '&source=' ; $ twig = $ this -> container -> get ( 'twig' ) ; $ content = $ twig -> render ( 'EcommerceBundle:Product:share.html.twig' , array ( "tweetUrl" => $ tweetUrl , "faceUrl" => $ faceUrl , "googleUrl" => $ googleUrl , "linkedUrl" => $ linkedUrl , "id" => uniqid ( ) , "big" => $ big ) ) ; return $ content ; }
|
Returns the part of a feedID
|
59,164
|
public function getProductStats ( Product $ product , $ start , $ end ) { $ adminManager = $ this -> container -> get ( 'checkout_manager' ) ; $ stats = $ adminManager -> getProductStats ( $ product , $ start , $ end ) ; return $ stats ; }
|
Returns statistics from product
|
59,165
|
public static function validator ( String $ scheme , String $ host , array $ routes ) { self :: validate_domain ( $ scheme , $ host ) ; foreach ( $ routes as $ route ) { if ( ! isset ( $ route [ 'method' ] ) ) throw new Exception ( 'Method is not set in routes.' ) ; if ( ! isset ( $ route [ 'route' ] ) ) throw new Exception ( 'Route is not set in routes.' ) ; if ( ! isset ( $ route [ 'controller' ] ) ) throw new Exception ( 'Controller is not set in routes.' ) ; if ( ! in_array ( $ route [ 'method' ] , self :: METHODS ) ) throw new Exception ( 'Method: "' . $ route [ 'method' ] . '" is not a valid method. Use one of: [' . implode ( ', ' , self :: METHODS ) . '].' ) ; } }
|
Validate scheme host & routes
|
59,166
|
public function shutdown ( $ priorityName = null ) { if ( $ priorityName === null ) { foreach ( $ this -> streams as $ stream ) { if ( is_resource ( $ stream ) ) { fclose ( $ stream ) ; } } } elseif ( isset ( $ this -> streams [ $ priorityName ] ) && is_resource ( $ this -> streams [ $ priorityName ] ) ) { fclose ( $ this -> streams [ $ priorityName ] ) ; } return $ this ; }
|
Close the stream resource .
|
59,167
|
private function _createCurrentStream ( $ priorityName , $ subPriority = null ) { $ priorityName = strtolower ( $ priorityName ) ; if ( $ subPriority !== null ) { $ priorityName = strtolower ( $ subPriority ) ; } $ streamDir = $ this -> baseDir . DIRECTORY_SEPARATOR . str_ireplace ( '-' , DIRECTORY_SEPARATOR , $ this -> date -> format ( 'Y-m-d' ) ) ; if ( ! is_dir ( $ streamDir ) ) { umask ( 0000 ) ; if ( ! mkdir ( $ streamDir , 0777 , true ) ) { $ msg = "Dir '$streamDir' cannot be created" ; throw new \ Zend_Log_Exception ( $ msg ) ; } $ this -> shutdown ( $ priorityName ) ; } $ filepath = $ streamDir . DIRECTORY_SEPARATOR . $ priorityName . '.log' ; if ( ! $ this -> streams [ $ priorityName ] = @ fopen ( $ filepath , $ this -> mode , false ) ) { $ msg = "File '$filepath' cannot be opened with mode '$this->mode'" ; throw new \ Zend_Log_Exception ( $ msg ) ; } return $ this -> streams [ $ priorityName ] ; }
|
Create current stream for log priority .
|
59,168
|
public function length2 ( ) : float { $ value = 0 ; $ count = count ( $ this -> elements ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ value += ( $ this [ $ i ] * $ this [ $ i ] ) ; } return $ value ; }
|
Squared vector length .
|
59,169
|
public function normalize ( ) { $ len = $ this -> length ( ) ; if ( $ len === 0.0 ) { return ; } $ count = count ( $ this -> elements ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ this [ $ i ] /= $ len ; } }
|
Normalizes the vector .
|
59,170
|
public function toArray ( ) { $ result = [ ] ; $ count = count ( $ this -> elements ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ result [ ] = $ this -> elements [ $ i ] ; } return $ result ; }
|
Convert the vector to an array .
|
59,171
|
public function fromArray ( array $ vector ) { $ count = count ( $ vector ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ this -> elements [ $ i ] = $ vector [ $ i ] ; } }
|
Set vector to values from passed array .
|
59,172
|
protected function originalIsEquivalent ( $ key , $ current ) { if ( array_key_exists ( $ key , $ this -> attachedFiles ) ) { return true ; } return parent :: originalIsEquivalent ( $ key , $ current ) ; }
|
Overridden to prevent attempts to persist attachment attributes directly .
|
59,173
|
public function serialize ( Job $ job ) : array { $ this -> ensureReflectorsInitialized ( ) ; return [ 'id' => $ job -> getId ( ) -> __toString ( ) , 'name' => $ this -> jobPropertyReflectors [ 'name' ] -> getValue ( $ job ) , 'arguments' => \ json_encode ( $ this -> jobPropertyReflectors [ 'arguments' ] -> getValue ( $ job ) ) , 'max_retries' => $ this -> jobPropertyReflectors [ 'maxRetries' ] -> getValue ( $ job ) , 'retries' => $ this -> jobPropertyReflectors [ 'retries' ] -> getValue ( $ job ) , ] ; }
|
Serializes the job instance into an array .
|
59,174
|
public function deserialize ( array $ serialized ) : Job { $ this -> ensureReflectorsInitialized ( ) ; $ job = $ this -> instantiator -> instantiate ( Job :: class ) ; $ arguments = \ json_decode ( $ serialized [ 'arguments' ] , true ) ; \ assert ( \ is_array ( $ arguments ) ) ; $ this -> jobPropertyReflectors [ 'id' ] -> setValue ( $ job , new JobId ( Uuid :: fromString ( $ serialized [ 'id' ] ) ) ) ; $ this -> jobPropertyReflectors [ 'name' ] -> setValue ( $ job , $ serialized [ 'name' ] ) ; $ this -> jobPropertyReflectors [ 'arguments' ] -> setValue ( $ job , $ arguments ) ; $ this -> jobPropertyReflectors [ 'maxRetries' ] -> setValue ( $ job , $ serialized [ 'max_retries' ] ) ; $ this -> jobPropertyReflectors [ 'retries' ] -> setValue ( $ job , $ serialized [ 'retries' ] ) ; return $ job ; }
|
Deserializes an array generated by this class into a job instance .
|
59,175
|
public function setHost ( ? string $ host ) : PgSQL { if ( ! $ this -> _supportedAttributes -> get ( 'host' ) -> validateValue ( $ host ) ) { throw new ArgumentException ( 'host' , $ host , 'Invalid host!' ) ; } $ this -> _attributes [ 'host' ] = $ host ; return $ this ; }
|
Sets the host name or ip address of the PgSQL server .
|
59,176
|
public function setPort ( $ port ) : PgSQL { if ( null === $ port ) { $ this -> _attributes [ 'port' ] = $ port ; return $ this ; } $ port = false ; if ( \ is_string ( $ port ) ) { $ port = ( int ) $ port ; } else if ( TypeTool :: IsInteger ( $ port ) ) { $ port = ( int ) $ port ; } else if ( TypeTool :: IsStringConvertible ( $ port , $ portStr ) ) { $ port = ( int ) $ portStr ; } if ( ! \ is_int ( $ port ) || ! $ this -> _supportedAttributes -> get ( 'port' ) -> validateValue ( $ port ) ) { throw new ArgumentException ( 'port' , $ port , 'Invalid port!' ) ; } $ this -> _attributes [ 'port' ] = $ port ; return $ this ; }
|
Sets the optional port number of the PgSQL server .
|
59,177
|
public function setDbName ( ? string $ dbName ) : PgSQL { if ( ! $ this -> _supportedAttributes -> get ( 'dbname' ) -> validateValue ( $ dbName ) ) { throw new ArgumentException ( 'dbname' , $ dbName , 'Invalid database name!' ) ; } $ this -> _attributes [ 'dbname' ] = $ dbName ; return $ this ; }
|
Sets the optional name of the initial connected database .
|
59,178
|
public function icoAction ( ) { $ options = $ this -> getServiceLocator ( ) -> get ( 'Config' ) [ 'view_manager' ] [ 'head_defaults' ] ; if ( empty ( $ options [ 'headLink' ] [ 'favicon' ] [ 'href' ] ) ) { $ redirect = '/uploads/_central/settings/favicon.ico' ; } else { $ redirect = $ options [ 'headLink' ] [ 'favicon' ] [ 'href' ] ; } return $ this -> redirect ( ) -> toUrl ( $ redirect ) ; }
|
favicon . ico
|
59,179
|
function get ( $ parm = false ) { if ( isset ( $ this -> __columns [ $ parm ] ) ) return $ this -> __columns [ $ parm ] ; return false ; }
|
GET Get parameter value
|
59,180
|
function set ( $ parm , $ value = null ) { if ( is_array ( $ parm ) ) { foreach ( $ parm as $ k => $ v ) { $ this -> __columns [ $ k ] = $ v ; } return $ this ; } elseif ( isset ( $ this -> __columns [ $ parm ] ) ) { $ this -> __columns [ $ parm ] = $ value ; return $ this ; } else return false ; }
|
SET Set parameter
|
59,181
|
public function stream_seek ( $ aOffset , $ aWhence ) { switch ( $ aWhence ) { case SEEK_SET : $ this -> position = $ aOffset ; if ( $ aOffset > strlen ( self :: $ string [ $ this -> path ] ) ) { $ this -> stream_truncate ( $ aOffset ) ; } return true ; case SEEK_CUR : $ this -> position += $ aOffset ; return true ; case SEEK_END : $ this -> position = strlen ( self :: $ string [ $ this -> path ] ) + $ aOffset ; if ( ( $ this -> position + $ aOffset ) > strlen ( self :: $ string [ $ this -> path ] ) ) { $ this -> stream_truncate ( strlen ( self :: $ string [ $ this -> path ] ) + $ aOffset ) ; } return true ; default : return false ; } }
|
Seek to new position
|
59,182
|
public function unfold ( ) { if ( is_null ( $ this -> unfolded ) ) { $ string = $ this -> input -> run ( ) ; $ transformer = new TransformerWorker ( $ string ) ; foreach ( $ this -> modifiers as $ modifier ) { call_user_func_array ( array ( $ transformer , $ modifier [ 'name' ] ) , $ modifier [ 'args' ] ) ; } $ this -> unfolded = ( string ) $ transformer ; } return $ this -> unfolded ; }
|
Apply all modifiers for given input and return formatted string .
|
59,183
|
private function getParametersFromRequest ( Request $ request ) { $ parameters = $ request -> query -> all ( ) ; if ( $ routeParameters = $ request -> attributes -> get ( '_route_params' ) ) { $ parameters = array_merge ( $ routeParameters , $ parameters ) ; } return $ parameters ; }
|
Get parameters from request .
|
59,184
|
public function addFields ( array $ fields ) { foreach ( $ fields as $ field ) { if ( ! $ field instanceof FieldDefinitionInterface ) { continue ; } $ this -> addField ( $ field ) ; } return $ this ; }
|
Add multiple fields to form .
|
59,185
|
public function setResults ( array $ values ) { foreach ( $ values as $ field => $ value ) { if ( empty ( $ value ) ) { continue ; } $ this -> setResult ( $ field , $ value ) ; } return $ this ; }
|
Set form results .
|
59,186
|
public function setResult ( $ field , $ value ) { if ( ! isset ( $ this -> results [ $ field ] ) ) { $ this -> results [ $ field ] = $ value ; } return $ this ; }
|
Set for result .
|
59,187
|
public function process ( ) { $ this -> results = $ this -> processFields ( $ this -> fields , $ this -> results ) ; return $ this ; }
|
Process form fields .
|
59,188
|
public function save ( callable $ function , $ confirm_save = true , $ confirm_message = 'Save results?' ) { $ save = true ; $ this -> process ( ) ; if ( $ confirm_save ) { $ question = $ this -> helperSet -> get ( 'question' ) ; $ save = $ question -> ask ( $ this -> input , $ this -> output , new ConfirmationQuestion ( sprintf ( '%s [yes] ' , $ confirm_message ) ) ) ; } if ( $ save ) { call_user_func_array ( $ function , [ $ this -> getResults ( ) ] ) ; } }
|
Save form results .
|
59,189
|
protected function processFields ( array $ fields , array $ results = [ ] ) { $ input = $ this -> input ; $ output = $ this -> output ; $ helper = $ this -> helperSet -> get ( 'question' ) ; foreach ( $ fields as $ field ) { if ( ! $ field instanceof FieldDefinitionInterface ) { continue ; } $ field_name = $ field -> getName ( ) ; if ( isset ( $ results [ $ field_name ] ) ) { continue ; } if ( ! $ field instanceof FieldGroup ) { if ( $ field -> hasCondition ( ) && ! $ this -> fieldConditionMet ( $ field , $ results ) ) { continue ; } if ( $ field -> hasFieldCallback ( ) ) { $ field -> onFieldCallback ( $ results ) ; } if ( $ input -> isInteractive ( ) ) { try { $ value = $ helper -> ask ( $ input , $ output , $ field -> asQuestion ( ) ) ; if ( $ field -> hasSubform ( ) ) { $ subform = new static ( ) ; $ field -> onSubformProcess ( $ subform , $ value ) ; $ results [ $ field_name ] = $ subform -> setInput ( $ input ) -> setOutput ( $ output ) -> setHelperSet ( $ this -> helperSet ) -> process ( ) -> getResults ( ) ; } else { $ results [ $ field_name ] = $ field -> formattedValue ( $ value ) ; } } catch ( \ Exception $ e ) { throw new FormException ( trim ( $ e -> getMessage ( ) ) ) ; } } } else { $ groups = [ ] ; do { $ result = $ this -> processFields ( $ field -> getGroupFields ( ) ) ; $ continue = false ; if ( $ field -> hasLoopUntil ( ) ) { $ continue = $ field -> loopUntil ( [ $ result ] ) ; if ( $ continue ) { $ groups [ ] = $ result ; } } else { $ groups [ ] = $ result ; } } while ( $ continue ) ; $ results [ $ field_name ] = $ groups ; } } return $ results ; }
|
Process fields .
|
59,190
|
protected function fieldConditionMet ( FieldInterface $ field , array $ results ) { $ conditions = [ ] ; foreach ( $ field -> getCondition ( ) as $ field_name => $ condition ) { $ value = $ condition [ 'value' ] ; $ operation = $ condition [ 'operation' ] ; $ field_value = $ this -> getFieldValue ( $ field_name , $ results ) ; if ( is_array ( $ field_value ) && key_exists ( $ field_name , $ field_value ) ) { $ field_value = $ field_value [ $ field_name ] ; } switch ( $ operation ) { case "!=" : $ conditions [ ] = $ field_value != $ value ; break ; case '=' : default : $ conditions [ ] = $ field_value == $ value ; break ; } } $ conditions = array_unique ( $ conditions ) ; return count ( $ conditions ) === 1 ? reset ( $ conditions ) : false ; }
|
Check if field condition are met .
|
59,191
|
public static function createColumnDefinition ( $ datatype , $ name , $ tableName = null , $ schemaName = null ) { if ( ! array_key_exists ( $ datatype , self :: $ typesMap ) ) { throw new Exception \ UnsupportedTypeException ( __METHOD__ . " Type '$datatype' is not supported." ) ; } $ class = __NAMESPACE__ . '\\Column\\' . self :: $ typesMap [ $ datatype ] ; return new $ class ( $ name , $ tableName , $ schemaName ) ; }
|
Create a data column definition .
|
59,192
|
public static function getReflectionCallable ( $ callable ) { if ( is_callable ( $ callable , true ) ) { try { if ( is_object ( $ callable ) ) { return new ReflectionFunction ( $ callable ) ; } if ( is_array ( $ callable ) ) { return new ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ; } if ( strpos ( $ callable , '::' ) === false ) { return new ReflectionFunction ( $ callable ) ; } return new ReflectionMethod ( $ callable ) ; } catch ( ReflectionException $ exception ) { } } return false ; }
|
Get ReflectionFunctionAbstract of a variable if it was callable .
|
59,193
|
public static function getReflectionCallableName ( ReflectionFunctionAbstract $ reflector ) { $ class = $ reflector instanceof ReflectionFunction ? $ reflector -> getClosureScopeClass ( ) : $ reflector -> getDeclaringClass ( ) ; if ( is_null ( $ class ) ) { return $ reflector -> getName ( ) ; } return $ class -> getName ( ) . '::' . $ reflector -> getName ( ) ; }
|
Get callable name from reflection .
|
59,194
|
public function beforeSnippet ( ) { $ event = new SnippetEvent ( ) ; $ this -> trigger ( self :: EVENT_BEFORE_SNIPPET , $ event ) ; return $ event -> isValid ; }
|
This method is invoked right before an action is executed .
|
59,195
|
protected function callFunction ( $ function , array $ params = [ ] ) { if ( is_string ( $ function ) ) { $ function = trim ( $ function ) ; if ( strpos ( $ function , '.' ) !== false ) { $ function = explode ( '.' , $ function ) ; } else { return $ this -> template -> getSnippet ( $ function , $ params ) ; } } if ( is_array ( $ function ) ) { if ( $ function [ 0 ] === 'context' ) { $ function [ 0 ] = $ this -> template -> getContext ( ) ; return call_user_func_array ( $ function , $ params ) ; } elseif ( is_string ( $ function [ 0 ] ) ) { if ( class_exists ( '\rock\di\Container' ) && Container :: exists ( $ function [ 0 ] ) ) { $ function [ 0 ] = Container :: load ( $ function [ 0 ] ) ; } return call_user_func_array ( $ function , $ params ) ; } } return call_user_func_array ( $ function , $ params ) ; }
|
Call function .
|
59,196
|
public function handle ( array $ record ) { if ( ! $ this -> isHandling ( $ record ) ) { return false ; } if ( class_exists ( 'Drips\Debugbar\Debugbar' ) ) { $ debugbar = Debugbar :: getInstance ( ) ; if ( ! $ debugbar -> hasTab ( 'logger' ) ) { $ debugbar -> registerTab ( 'logger' , 'Logs' , '<style>' . file_get_contents ( __DIR__ . '/style.css' ) . '</style>' ) ; } $ color = $ this -> logLevels [ $ record [ 'level' ] ] ; $ channel = $ record [ 'channel' ] ; $ level = $ record [ 'level_name' ] ; $ message = $ record [ 'message' ] ; $ log_message = " <code class='drips-logger-record' style='color: $color'> <table> <tr> <td valign='top'><span class='debug-badge debug-channel'>$channel</span></td> <td valign='top'><strong class='debug-badge' style='background-color: $color'>$level</strong></td> <td valign='top' style='color: $color'>$message</td> </tr> </table> </code> " ; $ debugbar -> appendTab ( 'logger' , $ log_message ) ; } return false === $ this -> bubble ; }
|
Schreibt die einzelnen Log - Records in die Debugbar
|
59,197
|
public function onBeforeDeleteUser ( UserEvent $ event ) { $ user = $ event -> getUser ( ) ; $ locks = $ this -> entityManager -> getRepository ( 'PhlexibleElementBundle:ElementLock' ) -> findBy ( [ 'userId' => $ user -> getId ( ) ] ) ; foreach ( $ locks as $ lock ) { $ this -> entityManager -> remove ( $ lock ) ; } }
|
User delete callback Cleanup users locks .
|
59,198
|
public function apply ( ModelCriteria $ query ) { if ( $ this -> query ) { $ query -> mergeWith ( $ this -> query ) ; } return $ query ; }
|
Applies modifiers and merge query if one has been set
|
59,199
|
public function getDsn ( ) { if ( $ this -> driver === 'sqlite' ) { return "sqlite:$this->schema" ; } $ opts = [ ] ; $ opts [ 'host' ] = $ this -> host ; if ( $ this -> schema ) { $ opts [ 'dbname' ] = $ this -> schema ; } $ dsnOpts = array_merge ( [ ] , $ this -> dsnOpts , $ opts ) ; return "$this->driver:" . implode ( ';' , Map :: zip ( '=' , $ dsnOpts ) ) ; }
|
Generate a DSN using the info encapsulated in the instance .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.