idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
28,400
public static function prepend ( $ key , $ value = null , $ dimensionize = true , & $ array = null ) { return self :: set ( $ key , $ value , $ dimensionize , $ array , 'prepend' ) ; }
Prependes a value to the array pointed by the key
28,401
public static function get ( $ key = null , $ default = null , $ array = null ) { if ( ( $ value = self :: getRef ( $ key , $ array ) ) !== null ) { return $ value ; } return $ default ; }
Gets a value using its associatied key from the store
28,402
public static function has ( $ key , $ array = null ) { $ segments = self :: splitArrayPath ( $ key ) ; $ key = array_pop ( $ segments ) ; $ parentArrayKey = count ( $ segments ) ? implode ( '.' , $ segments ) : null ; $ parentArray = self :: getRef ( $ parentArrayKey , $ array ) ; return ! empty ( $ parentArray ) && self :: arrayHasKey ( $ key , $ parentArray ) ; }
Checks if a key is defined in the store
28,403
public static function delete ( $ key , & $ array = null ) { $ segments = self :: splitArrayPath ( $ key ) ; $ key = array_pop ( $ segments ) ; $ parentArrayKey = count ( $ segments ) ? implode ( '.' , $ segments ) : null ; $ parentArray = & self :: getRef ( $ parentArrayKey , $ array ) ; if ( $ parentArray === null || ! self :: arrayHasKey ( $ key , $ parentArray ) ) { throw new AtomikException ( "Key '$key' does not exists" ) ; } $ value = $ parentArray [ $ key ] ; unset ( $ parentArray [ $ key ] ) ; return $ value ; }
Deletes a key from the store
28,404
public static function & getRef ( $ key = null , & $ array = null ) { $ null = null ; if ( $ array === null ) { $ array = & self :: $ store ; } if ( $ key === null ) { return $ array ; } if ( ! is_array ( $ key ) ) { if ( ! strpos ( $ key , '.' ) ) { if ( self :: arrayHasKey ( $ key , $ array ) ) { $ value = & $ array [ $ key ] ; return $ value ; } return $ null ; } $ key = self :: splitArrayPath ( $ key ) ; } $ firstKey = array_shift ( $ key ) ; if ( self :: arrayHasKey ( $ firstKey , $ array ) ) { if ( count ( $ key ) > 0 ) { return self :: getRef ( $ key , $ array [ $ firstKey ] ) ; } else if ( ! is_array ( $ array ) ) { $ value = $ array [ $ firstKey ] ; return $ value ; } else { $ value = & $ array [ $ firstKey ] ; return $ value ; } } return $ null ; }
Gets a reference to a value from the store using its associatied key
28,405
public static function reset ( $ key = null , $ value = null , $ dimensionize = true ) { if ( $ key !== null ) { self :: set ( $ key , $ value , $ dimensionize , self :: $ reset ) ; self :: set ( $ key , $ value , $ dimensionize ) ; return ; } self :: $ store = self :: mergeRecursive ( self :: $ store , self :: $ reset ) ; }
Resets the global store
28,406
public static function listenEvent ( $ event , $ callback , $ priority = 50 , $ important = false ) { if ( ! isset ( self :: $ events [ $ event ] ) ) { self :: $ events [ $ event ] = array ( ) ; } while ( isset ( self :: $ events [ $ event ] [ $ priority ] ) ) { $ priority += $ important ? - 1 : 1 ; } self :: $ events [ $ event ] [ $ priority ] = $ callback ; }
Registers a callback to an event
28,407
public static function attachClassListeners ( $ class ) { $ methods = get_class_methods ( $ class ) ; foreach ( $ methods as $ method ) { if ( preg_match ( '/^on[A-Z].*$/' , $ method ) ) { $ event = preg_replace ( '/(?<=\\w)([A-Z])/' , '::\1' , substr ( $ method , 2 ) ) ; self :: listenEvent ( $ event , array ( $ class , $ method ) ) ; } } }
Automatically registers event listeners for methods starting with on
28,408
public static function loadPlugin ( $ name ) { $ name = ucfirst ( $ name ) ; if ( ( $ config = & self :: getRef ( "plugins.$name" ) ) === null ) { $ config = array ( ) ; } return self :: loadCustomPlugin ( $ name , $ config ) ; }
Loads a plugin using the configuration specified under plugins
28,409
public static function loadPluginIfAvailable ( $ plugin ) { if ( ! self :: isPluginLoaded ( $ plugin ) && self :: isPluginAvailable ( $ plugin ) ) { self :: loadPlugin ( $ plugin ) ; } }
Loads a plugin only if it s available
28,410
public static function loadCustomPluginIfAvailable ( $ plugin , $ config = array ( ) , $ options = array ( ) ) { if ( ! self :: isPluginLoaded ( $ plugin ) && self :: isPluginAvailable ( $ plugin ) ) { self :: loadCustomPlugin ( $ plugin , $ config , $ options ) ; } }
Loads a custom plugin only if it s available
28,411
public static function isPluginAvailable ( $ plugin ) { $ plugin = ucfirst ( $ plugin ) ; $ dirs = self :: path ( self :: get ( 'atomik.dirs.plugins' ) ) ; if ( self :: findFile ( "$plugin.php" , $ dirs ) === false ) { return self :: findFile ( $ plugin , $ dirs ) !== false ; } return true ; }
Checks if a plugin is available
28,412
public static function registerPluggableApplication ( $ plugin , $ route = null , $ config = array ( ) ) { $ plugin = ucfirst ( $ plugin ) ; self :: fireEvent ( 'Atomik::Registerpluggableapplication' , array ( & $ plugin , & $ route , & $ config ) ) ; if ( empty ( $ plugin ) ) { return ; } $ config [ 'route' ] = $ route ? : ( strtolower ( $ plugin ) . '*' ) ; self :: $ pluggableApplications [ $ plugin ] = $ config ; }
Registers a pluggable application
28,413
private function scoped ( $ __filename , $ __vars = array ( ) , $ __allowShortTags = false ) { extract ( ( array ) $ __vars ) ; ob_start ( ) ; if ( $ __allowShortTags && version_compare ( PHP_VERSION , '5.4.0' , '<' ) && ( bool ) @ ini_get ( 'short_open_tag' ) === false ) { eval ( '?>' . preg_replace ( "/;*\s*\?>/" , "; ?>" , str_replace ( '<?=' , '<?php echo ' , file_get_contents ( $ __filename ) ) ) ) ; } else { include ( $ __filename ) ; } $ content = ob_get_clean ( ) ; $ vars = array ( ) ; foreach ( get_defined_vars ( ) as $ name => $ value ) { if ( substr ( $ name , 0 , 1 ) != '_' ) { $ vars [ $ name ] = $ value ; } } return array ( $ content , $ vars ) ; }
Includes a file in the method scope and returns public variables and the output buffer
28,414
public static function findFile ( $ filename , $ dirs , $ isInclude = false ) { if ( empty ( $ filename ) ) { return false ; } foreach ( array_reverse ( ( array ) $ dirs ) as $ ns => $ dir ) { if ( $ dir === false ) { continue ; } if ( $ isInclude && is_numeric ( $ ns ) ) { $ ns = '' ; } if ( $ pathname = self :: path ( $ filename , $ dir ) ) { return $ isInclude ? array ( $ pathname , $ ns ) : $ pathname ; } } return false ; }
Finds a file in an array of directories
28,415
public static function path ( $ filename , $ relativeTo = null , $ checkExists = true , $ ds = null ) { $ ds = $ ds ? : DIRECTORY_SEPARATOR ; if ( is_array ( $ filename ) ) { $ pathnames = array ( ) ; foreach ( $ filename as $ k => $ f ) { $ pathnames [ $ k ] = self :: path ( $ f , $ relativeTo , $ checkExists ) ; } return $ pathnames ; } $ relativeTo = $ relativeTo ? : self :: $ rootDirectory ; $ pathname = $ filename ; if ( $ filename { 0 } != '/' && ! preg_match ( '#^[A-Z]:(\\\\|/)#' , $ filename ) ) { if ( strlen ( $ filename ) >= 2 && substr ( $ filename , 0 , 2 ) == './' ) { $ filename = substr ( $ filename , 2 ) ; } $ pathname = rtrim ( $ relativeTo , $ ds ) . $ ds . $ filename ; } if ( $ checkExists ) { return realpath ( $ pathname ) ; } return $ pathname ; }
Makes a filename relative to another one
28,416
public static function pluginAsset ( $ plugin , $ filename , $ params = array ( ) ) { $ template = self :: get ( 'atomik.plugin_assets_tpl' , 'app/plugins/%s/assets' ) ; $ dirname = rtrim ( sprintf ( $ template , ucfirst ( $ plugin ) ) , '/' ) ; $ filename = '/' . ltrim ( $ filename , '/' ) ; return self :: url ( $ dirname . $ filename , $ params , false , false ) ; }
Returns the url of a plugin s asset file following the path template defined in the configuration .
28,417
public function save ( ) { if ( ! $ this -> is_loaded ( ) ) return false ; $ this -> fill_defaults ( ) ; $ error = null ; $ id = wp_insert_post ( $ this -> attributes , $ error ) ; if ( ! empty ( $ id ) ) { $ this -> attributes [ 'ID' ] = $ id ; $ this -> save_meta_all ( ) ; } return $ error === false ? true : $ error ; }
Saves current model in the db .
28,418
public function delete ( ) { if ( ! $ this -> is_loaded ( ) ) return false ; $ error = wp_delete_post ( $ this -> attributes [ 'ID' ] , $ this -> forceDelete ) ; return $ error !== false ; }
Deletes current model in the db .
28,419
public function to_array ( ) { $ output = array ( ) ; foreach ( $ this -> attributes as $ property => $ value ) { $ output [ $ this -> get_alias ( $ property ) ] = $ value ; } foreach ( $ this -> meta as $ key => $ value ) { $ alias = $ this -> get_alias ( 'meta_' . $ key ) ; if ( $ alias != 'meta_' . $ key ) { $ output [ $ alias ] = $ value ; } } foreach ( $ this -> aliases as $ alias => $ property ) { if ( preg_match ( '/func_/' , $ property ) ) { $ function_name = preg_replace ( '/func_/' , '' , $ property ) ; $ output [ $ alias ] = $ this -> $ function_name ( ) ; } } foreach ( $ this -> hidden as $ key ) { unset ( $ output [ $ key ] ) ; } return $ output ; }
Returns object converted to array .
28,420
private function fill_defaults ( ) { if ( ! array_key_exists ( 'ID' , $ this -> attributes ) ) { $ this -> attributes [ 'post_type' ] = $ this -> type ; $ this -> attributes [ 'post_status' ] = $ this -> status ; } }
Fills default when about to create object
28,421
private function get_alias_property ( $ alias ) { if ( array_key_exists ( $ alias , $ this -> aliases ) ) return $ this -> aliases [ $ alias ] ; return $ alias ; }
Returns property mapped to alias .
28,422
private function get_alias ( $ property ) { if ( in_array ( $ property , $ this -> aliases ) ) return array_search ( $ property , $ this -> aliases ) ; return $ property ; }
Returns alias name mapped to property .
28,423
protected static function strBrToUs ( $ date ) { if ( is_string ( $ date ) ) { $ expreg = '/^(0[1-9]|[1-2][0-9]|3[0-1])\/(0[1-9]|1[0-2])\/(\d{4})(T| ){0,1}(([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])){0,1}$/' ; if ( preg_match ( $ expreg , $ date , $ datebit ) ) { @ list ( $ tudo , $ dia , $ mes , $ ano , $ tz , $ time , $ hora , $ min , $ seg ) = $ datebit ; return "$ano-$mes-$dia" . ( $ hora | $ min | $ seg ? "$hora:$min:$seg" : "" ) ; } } return null ; }
Utilizado pelo construtor da classe
28,424
public function getAttribute ( $ name ) { foreach ( self :: $ mutation_handlers as $ controller ) { $ controller -> setModel ( $ this ) ; if ( $ controller -> hasGetMutator ( $ name ) ) { return $ controller -> callGetMutator ( $ name ) ; } } return parent :: getAttribute ( $ name ) ; }
Get attribute .
28,425
public function saveFormData ( Request $ request , $ session , $ modelName , $ id ) { Log :: debug ( __CLASS__ . ':' . __TRAIT__ . ':' . __FILE__ . ':' . __LINE__ . ':' . __FUNCTION__ . ':' . ' Save form handle from config' ) ; $ config = app ( 'itemconfig' ) ; $ fieldFactory = app ( 'admin_field_factory' ) ; $ actionFactory = app ( 'admin_action_factory' ) ; if ( $ formRequestClass = $ config -> getOption ( 'form_request' ) ) { $ request = app ( $ formRequestClass ) ; } $ request -> merge ( [ 'pagetype' => ".blade.php" , ] ) ; $ save = $ config -> save ( $ request , $ fieldFactory -> getEditFields ( ) , $ actionFactory -> getActionPermissions ( ) , $ id ) ; if ( $ save !== true ) { return redirect ( ) -> back ( ) -> withErrors ( $ config -> getCustomValidator ( ) ) ; } app ( 'admin_config_factory' ) -> updateConfigOptions ( ) ; $ columnFactory = app ( 'admin_column_factory' ) ; $ fields = $ fieldFactory -> getEditFields ( ) ; $ model = $ config -> getModel ( $ id , $ fields , $ columnFactory -> getIncludedColumns ( $ fields ) ) ; if ( $ model -> exists ) { $ model = $ config -> updateModel ( $ model , $ fieldFactory , $ actionFactory ) ; } return redirect ( ) -> route ( 'admin_index' , [ $ modelName ] ) ; }
Handle custom save form
28,426
public function setStartState ( $ stateId ) { $ state = $ this -> stateMachine -> getState ( StateMachine :: STATE_INITIAL ) ; if ( $ state === null ) { $ state = new InitialState ( StateMachine :: STATE_INITIAL ) ; $ this -> stateMachine -> addState ( $ state ) ; } $ this -> addTransition ( StateMachine :: STATE_INITIAL , $ stateId , StateMachine :: EVENT_START ) ; }
Sets the given state as the start state of the state machine .
28,427
public function setEndState ( $ stateId , $ eventId ) { if ( $ this -> stateMachine -> getState ( StateMachine :: STATE_FINAL ) === null ) { $ this -> stateMachine -> addState ( new FinalState ( StateMachine :: STATE_FINAL ) ) ; } $ this -> addTransition ( $ stateId , StateMachine :: STATE_FINAL , $ eventId ) ; }
Sets the given state as an end state of the state machine .
28,428
public function addTransition ( $ stateId , $ nextStateId , $ eventId ) { $ state = $ this -> stateMachine -> getState ( $ stateId ) ; if ( $ state === null ) { throw new StateNotFoundException ( sprintf ( 'The state "%s" is not found.' , $ stateId ) ) ; } $ nextState = $ this -> stateMachine -> getState ( $ nextStateId ) ; if ( $ nextState === null ) { throw new StateNotFoundException ( sprintf ( 'The state "%s" is not found.' , $ nextStateId ) ) ; } $ event = $ state -> getTransitionEvent ( $ eventId ) ; if ( $ event === null ) { $ event = new Event ( $ eventId ) ; } $ this -> stateMachine -> addTransition ( new Transition ( $ nextState , $ state , $ event ) ) ; }
Adds an state transition to the state machine .
28,429
private function transition ( TransitionalStateInterface $ fromState , EventInterface $ event ) { if ( $ fromState instanceof StateActionInterface ) { $ exitEvent = $ fromState -> getExitEvent ( ) ; if ( $ exitEvent !== null ) { if ( $ this -> eventDispatcher !== null ) { $ this -> eventDispatcher -> dispatch ( StateMachineEvents :: EVENT_EXIT , new StateMachineEvent ( $ this , $ fromState , $ exitEvent ) ) ; } $ this -> runAction ( $ exitEvent ) ; } } $ transition = $ this -> getTransition ( $ fromState , $ event ) ; $ transition -> setToken ( $ fromState -> getToken ( ) ) ; $ this -> previousState = $ fromState ; $ this -> currentState = null ; if ( $ this -> eventDispatcher !== null ) { $ this -> eventDispatcher -> dispatch ( StateMachineEvents :: EVENT_TRANSITION , new StateMachineEvent ( $ this , null , $ event , $ transition ) ) ; } $ this -> runAction ( $ event , $ transition ) ; $ transition -> getToState ( ) -> setToken ( $ transition -> getToken ( ) ) ; $ toState = $ this -> stateCollection -> getCurrentState ( ) ; $ this -> currentState = $ toState ; $ this -> transitionLog [ ] = $ this -> createTransitionLogEntry ( $ transition ) ; if ( $ toState instanceof StateActionInterface ) { $ entryEvent = $ toState -> getEntryEvent ( ) ; if ( $ entryEvent !== null ) { if ( $ this -> eventDispatcher !== null ) { $ this -> eventDispatcher -> dispatch ( StateMachineEvents :: EVENT_ENTRY , new StateMachineEvent ( $ this , $ toState , $ entryEvent ) ) ; } $ this -> runAction ( $ entryEvent ) ; } } }
Transitions to the next state .
28,430
private function evaluateGuard ( EventInterface $ event ) { foreach ( ( array ) $ this -> guardEvaluators as $ guardEvaluator ) { $ result = call_user_func ( [ $ guardEvaluator , 'evaluate' ] , $ event , $ this -> getPayload ( ) , $ this ) ; if ( ! $ result ) { return false ; } } return true ; }
Evaluates the guard for the given event .
28,431
private function runAction ( EventInterface $ event , TransitionInterface $ transition = null ) { foreach ( ( array ) $ this -> actionRunners as $ actionRunner ) { call_user_func ( [ $ actionRunner , 'run' ] , $ event , $ this -> getPayload ( ) , $ this , $ transition ) ; } }
Runs the action for the given event .
28,432
public function onReplaceInsertTags ( $ tag ) { $ elements = explode ( '::' , $ tag ) ; $ key = strtolower ( $ elements [ 0 ] ) ; if ( in_array ( $ key , $ this -> supportedTags , true ) ) { return $ this -> replaceThemeInsertTag ( $ elements [ 1 ] , $ elements [ 2 ] ) ; } return false ; }
Replaces theme insert tags .
28,433
private function replaceThemeInsertTag ( $ tagType , $ themeTag ) { $ this -> framework -> initialize ( ) ; switch ( $ tagType ) { case 'content' : $ adapter = $ this -> framework -> getAdapter ( ArticleModel :: class ) ; if ( null === ( $ article = $ adapter -> findOneBy ( 'pdir_th_tag' , $ themeTag ) ) ) { return '' ; } return $ this -> generateArticleReplacement ( $ article ) ; break ; } return false ; }
Replaces an event - related insert tag .
28,434
private function generateArticleReplacement ( ArticleModel $ article ) { $ adapter = $ this -> framework -> getAdapter ( ContentElement :: class ) ; return $ adapter -> getArticle ( $ article ) ; }
Generates the article replacement string .
28,435
public function setValue ( int $ state ) : bool { if ( $ this -> type == GPIO :: IN ) { throw new GPIOException ( 'Setting the value of a GPIO input pin is not supported!' ) ; } return $ this -> adapter -> write ( $ this -> pin , $ state ) ; }
Set the value of a GPIO output pin .
28,436
public function registerJs ( $ view , $ settings = [ ] ) { if ( $ this -> settings || $ settings ) { $ settings = Json :: htmlEncode ( array_merge ( $ this -> settings , $ settings ) ) ; $ view -> registerJs ( "jQuery.extend(jQuery.timeago.settings, $settings);" , $ view :: POS_READY , 'timeagoOptions' ) ; } $ view -> registerJs ( "jQuery('time.timeago').timeago();" , $ view :: POS_READY , 'timeago' ) ; }
Registers timeago javascript .
28,437
public static function flash ( $ message , $ label = 'default' ) { if ( ! isset ( $ _SESSION ) ) { throw new AtomikException ( 'The session must be started before using Atomik::flash()' ) ; } Atomik :: fireEvent ( 'Atomik::Flash' , array ( & $ message , & $ label ) ) ; if ( ! Atomik :: has ( "session.__FLASH.$label" ) ) { Atomik :: set ( "session.__FLASH.$label" , array ( ) ) ; } Atomik :: add ( "session.__FLASH.$label" , $ message ) ; }
Saves a message that can be retrieve only once
28,438
public static function getFlashMessages ( $ label = null , $ delete = true ) { if ( ! Atomik :: has ( 'session.__FLASH' ) ) { return array ( ) ; } if ( $ label === null ) { if ( $ delete ) { return Atomik :: delete ( 'session.__FLASH' ) ; } return Atomik :: get ( 'session.__FLASH' ) ; } if ( ! Atomik :: has ( "session.__FLASH.$label" ) ) { return array ( ) ; } if ( $ delete ) { return Atomik :: delete ( "session.__FLASH.$label" ) ; } return Atomik :: get ( "session.__FLASH.$label" ) ; }
Returns the flash messages saved in the session
28,439
public static function renderFlashMessages ( $ id = 'flash-messages' ) { $ html = '' ; foreach ( self :: getFlashMessages ( ) as $ label => $ messages ) { foreach ( $ messages as $ message ) { $ html .= sprintf ( '<li class="%s">%s</li>' , $ label , $ message ) ; } } if ( empty ( $ html ) ) { return '' ; } return '<ul id="' . $ id . '">' . $ html . '</ul>' ; }
Renders the messages as html
28,440
public function defineOwnProperty ( Context $ context , NameValue $ key , Value $ value , int $ attributes = PropertyAttribute :: NONE ) : bool { }
Implements DefineOwnProperty .
28,441
public function getPropertyNames ( Context $ context , int $ mode = KeyCollectionMode :: kOwnOnly , int $ property_filter = PropertyFilter :: ALL_PROPERTIES , int $ index_filter = IndexFilter :: kIncludeIndices , bool $ convert_to_strings = false ) : ArrayObject { }
Returns an array containing the names of the enumerable properties of this object including properties from prototype objects . The array returned by this method contains the same values as would be enumerated by a for - in statement over this object .
28,442
public function getOwnPropertyNames ( Context $ context , int $ filter = PropertyFilter :: ALL_PROPERTIES , bool $ convert_to_strings = false ) : ArrayObject { }
This function has the same functionality as GetPropertyNames but the returned array doesn t contain the names of properties from prototype objects .
28,443
public function generateKeyPair ( ) : KeyPair { $ generator = EccFactory :: getNistCurves ( ) -> generator256 ( ) ; $ eccPrivateKey = $ generator -> createPrivateKey ( ) ; $ privateKey = PrivateKey :: createFromEccKey ( $ eccPrivateKey ) ; return new KeyPair ( $ privateKey , $ privateKey -> getPublicKey ( ) ) ; }
Generate a KeyPair .
28,444
public static function createFromEccKey ( PrivateKeyInterface $ eccKey ) : self { $ key = new self ( ) ; $ key -> eccKey = $ eccKey ; return $ key ; }
Create a private key from a Mdanter Ecc Private Key .
28,445
public function calculateSharedSecret ( PublicKey $ publicKey ) : SharedSecret { $ exchange = $ this -> getEccKey ( ) -> createExchange ( $ publicKey -> getEccKey ( ) ) ; $ binary = new BinaryString ( gmp_export ( $ exchange -> calculateSharedKey ( ) ) ) ; return new SharedSecret ( $ binary ) ; }
Calculate a shared secret .
28,446
private function findItemIn ( $ item , $ key ) { $ array = $ this -> find ( $ key ) ; if ( $ array ) return $ this -> array_get ( $ array , $ item ) ; return false ; }
Recursively finds an item from the commonSettings array
28,447
public function isExist ( $ key = null ) { return $ key = is_null ( $ key ) ? false : ( $ this -> find ( $ key ) ? true : false ) ; }
Checks if the given item exists in the array that is currently available after find call
28,448
protected static function formHead ( ParticleInterface $ particle , array $ pack , string $ name , array $ args ) : \ Pho \ Lib \ Graph \ NodeInterface { $ class = static :: findFormativeClass ( $ name , $ args , $ pack ) ; if ( count ( $ args ) > 0 ) { return new $ class ( $ particle , $ particle -> where ( ) , ... $ args ) ; } return new $ class ( $ particle , $ particle -> where ( ) ) ; }
Forms the head particle .
28,449
protected static function findFormativeClass ( string $ name , array $ args , array $ pack ) : string { $ argline = "" ; if ( count ( $ args ) > 0 ) { foreach ( $ args as $ arg ) { $ argline .= sprintf ( "%s:::" , str_replace ( "\\" , ":" , gettype ( $ arg ) ) ) ; } $ argline = substr ( $ argline , 0 , - 3 ) ; } else { $ argline = ":::" ; } foreach ( $ pack [ "out" ] -> formative_patterns [ $ name ] as $ formable => $ pattern ) { if ( preg_match ( "/^" . $ pattern . "$/" , $ argline ) ) { return $ formable ; } } throw new UnrecognizedSetOfParametersForFormativeEdgeException ( $ argline , $ pack [ "out" ] -> formative_patterns [ $ name ] ) ; }
Based on given arguments helps find the matching class to form .
28,450
public function loadHistoryForReport ( $ reportUri , $ limitByCurrentUser = true , $ options = array ( ) ) { $ options [ 'resource' ] = $ reportUri ; if ( $ limitByCurrentUser ) { $ options [ 'username' ] = $ this -> securityContext -> getToken ( ) -> getUsername ( ) ; } return $ this -> getReportHistoryRepository ( ) -> filter ( $ options ) ; }
Gets history records for a particular report
28,451
public function getReportHistoryDisplay ( $ reportUri = null , $ limitByCurrentUser = true , $ options = array ( ) ) { if ( $ reportUri ) { $ history = $ this -> loadHistoryForReport ( $ reportUri , $ limitByCurrentUser , $ options ) ; } else { $ history = $ this -> loadRecentHistory ( $ limitByCurrentUser , $ options ) ; } $ displayArray = array ( ) ; foreach ( $ history as $ record ) { $ recordArray = array ( ) ; $ params = $ this -> prettifyParameters ( $ record -> getReportUri ( ) , json_decode ( $ record -> getParameters ( ) , true ) ) ; $ recordArray [ 'report' ] = $ record -> getReportUri ( ) ; $ recordArray [ 'requestId' ] = $ record -> getRequestId ( ) ; $ recordArray [ 'date' ] = $ record -> getDate ( ) ; $ recordArray [ 'username' ] = $ record -> getUsername ( ) ; $ recordArray [ 'status' ] = $ record -> getStatus ( ) ; $ recordArray [ 'formats' ] = $ record -> getFormats ( ) ; $ recordArray [ 'parameters' ] = $ params ; $ displayArray [ ] = $ recordArray ; } return $ displayArray ; }
Gets history records for a particular report or all reports and places them in more display friendly fashion
28,452
public function prettifyParameters ( $ reportUri , array $ parameters ) { try { $ inputControls = $ this -> getReportInputControls ( $ reportUri , true ) ; } catch ( \ Exception $ e ) { $ out = "" ; foreach ( $ parameters as $ k => $ v ) { foreach ( $ v as $ item ) $ out .= $ k . ": " . $ item . "<br/>" ; } return $ out ; } $ output = array ( ) ; foreach ( $ inputControls as $ key => $ inputControl ) { if ( null !== $ inputControl [ 'options' ] ) { if ( isset ( $ parameters [ $ key ] ) ) { $ labels = array ( ) ; foreach ( $ parameters [ $ key ] as $ selection ) { if ( isset ( $ inputControl [ 'options' ] [ $ selection ] ) ) { $ labels [ ] = $ inputControl [ 'options' ] [ $ selection ] ; } else { $ labels [ ] = 'Unrecognized Value' ; } } $ output [ ] = $ inputControl [ 'control' ] -> getLabel ( ) . ': ' . implode ( ', ' , $ labels ) ; } else { $ output [ ] = $ inputControl [ 'control' ] -> getLabel ( ) . ': ---' ; } } else { if ( isset ( $ parameters [ $ key ] ) ) { $ output [ ] = $ inputControl [ 'control' ] -> getLabel ( ) . ': ' . implode ( ', ' , $ parameters [ $ key ] ) ; } else { if ( $ inputControl [ 'control' ] -> getDefaultValue ( ) ) { $ output [ ] = $ inputControl [ 'control' ] -> getLabel ( ) . ': ' . $ inputControl [ 'control' ] -> getDefaultValue ( ) ; } else { $ output [ ] = $ inputControl [ 'control' ] -> getLabel ( ) . ': ---' ; } } } } return implode ( '<br/>' , $ output ) ; }
Converts the JSON parameters column into something human readable
28,453
protected function getReportInputControls ( $ reportUri , $ reindex = true ) { if ( isset ( $ this -> inputControlStash [ $ reportUri ] ) ) { $ inputControls = $ this -> inputControlStash [ $ reportUri ] ; } else { $ inputControls = $ this -> clientService -> getReportInputControls ( $ reportUri , $ this -> clientService -> getDefaultInputOptionsSource ( ) ) ; if ( $ reindex ) { $ newArray = array ( ) ; foreach ( $ inputControls as $ ic ) { $ newArray [ $ ic -> getId ( ) ] = array ( 'control' => $ ic ) ; if ( method_exists ( $ ic , 'getOptionList' ) ) { foreach ( $ ic -> getOptionList ( ) as $ option ) { $ newArray [ $ ic -> getId ( ) ] [ 'options' ] [ $ option -> getId ( ) ] = $ option -> getLabel ( ) ; } } else { $ newArray [ $ ic -> getId ( ) ] [ 'options' ] = null ; } } $ inputControls = $ newArray ; } $ this -> inputControlStash [ $ reportUri ] = $ inputControls ; } return $ inputControls ; }
Gets the input controls for the given report Will stash the return from a call to retrieve from if called again in the history classes lifespan
28,454
public function loadRecentHistory ( $ limitByCurrentUser = true , $ options = array ( ) ) { if ( $ limitByCurrentUser ) { $ options [ 'username' ] = $ this -> securityContext -> getToken ( ) -> getUsername ( ) ; } return $ this -> getReportHistoryRepository ( ) -> filter ( $ options ) ; }
Load all the recently executed reports
28,455
public function setCallbacks ( ) { if ( $ this -> jasperClient ) { $ em = $ this -> container -> get ( 'doctrine' ) -> getManager ( $ this -> entityManager ) ; $ this -> jasperClient -> addPostReportExecutionCallback ( new PostReportExecution ( $ em , $ this -> container -> get ( 'security.context' ) ) ) ; $ this -> jasperClient -> addPostReportCacheCallback ( new PostReportCache ( $ em ) ) ; } }
Creates the callback objects and gives them to the client
28,456
public function buildReportInputForm ( $ reportUri , $ targetRoute = null , $ options = array ( ) ) { $ routeParameters = ( isset ( $ options [ 'routeParameters' ] ) && null != $ options [ 'routeParameters' ] ) ? $ options [ 'routeParameters' ] : array ( ) ; $ getICFrom = ( isset ( $ options [ 'getICFrom' ] ) && null != $ options [ 'getICFrom' ] ) ? $ options [ 'getICFrom' ] : $ this -> defaultInputOptionsSource ; $ data = ( isset ( $ options [ 'data' ] ) && null != $ options [ 'data' ] ) ? $ options [ 'data' ] : null ; $ formOptions = ( isset ( $ options [ 'options' ] ) && null != $ options [ 'options' ] ) ? $ options [ 'options' ] : array ( ) ; $ optionsHandler = $ this -> getOptionsHandler ( ) ; $ icFactory = new InputControlFactory ( $ optionsHandler , $ getICFrom , 'Mesd\Jasper\ReportBundle\InputControl\\' ) ; $ inputControls = $ this -> jasperClient -> getReportInputControl ( $ reportUri , $ getICFrom , $ icFactory ) ; $ form = $ this -> container -> get ( 'form.factory' ) -> createBuilder ( 'form' , null , $ formOptions ) ; if ( $ targetRoute ) { $ form -> setAction ( $ this -> container -> get ( 'router' ) -> generate ( $ targetRoute , $ routeParameters ) ) ; } $ form -> setMethod ( 'POST' ) ; foreach ( $ inputControls as $ inputControl ) { if ( null !== $ data && array_key_exists ( $ inputControl -> getId ( ) , $ data ) ) { $ inputControl -> attachInputToFormBuilder ( $ form , $ data [ $ inputControl -> getId ( ) ] ) ; } else { $ inputControl -> attachInputToFormBuilder ( $ form ) ; } } $ form -> add ( 'Run' , 'submit' ) ; return $ form -> getForm ( ) ; }
Builds a symfony form from the inputs from the requested report uri
28,457
public function getOptionsHandler ( ) { $ optionsHandler = $ this -> container -> get ( $ this -> optionHandlerServiceName ) ; if ( ! in_array ( 'Mesd\Jasper\ReportBundle\Interfaces\AbstractOptionsHandler' , class_parents ( $ optionsHandler ) ) ) { throw new \ Exception ( self :: EXCEPTION_OPTIONS_HANDLER_NOT_INTERFACE ) ; } return $ optionsHandler ; }
Get the options handler service
28,458
public function getReportInputControls ( $ reportUri , $ getICFrom = null ) { $ getICFrom = $ getICFrom ? : $ this -> defaultInputOptionsSource ; $ optionsHandler = $ this -> getOptionsHandler ( ) ; $ icFactory = new InputControlFactory ( $ optionsHandler , $ getICFrom , 'Mesd\Jasper\ReportBundle\InputControl\\' ) ; $ inputControls = $ this -> jasperClient -> getReportInputControl ( $ reportUri , $ getICFrom , $ icFactory ) ; return $ inputControls ; }
Gets the array of input controls for a requested report
28,459
public function createReportBuilder ( $ resourceUri , $ getICFrom = null ) { $ getICFrom = $ getICFrom ? : $ this -> defaultInputOptionsSource ; $ optionsHandler = $ this -> container -> get ( $ this -> optionHandlerServiceName ) ; $ icFactory = new InputControlFactory ( $ optionsHandler , $ getICFrom , 'Mesd\Jasper\ReportBundle\InputControl\\' ) ; $ reportBuilder = $ this -> jasperClient -> createReportBuilder ( $ resourceUri , $ getICFrom , $ icFactory ) ; $ reportBuilder -> setReportCache ( $ this -> reportCacheDir ) ; return $ reportBuilder ; }
Creates a new report builder object with some of the bundle configuration passed in
28,460
public function getResourceList ( $ folderUri = null , $ recursive = false ) { $ folderUri = $ folderUri ? : $ this -> defaultFolder ; $ return = $ this -> jasperClient -> getFolder ( $ folderUri , $ this -> useFolderCache , $ this -> folderCacheDir , $ this -> folderCacheTimeout ) ; if ( $ this -> useSecurity ) { $ newReturn = array ( ) ; foreach ( $ return as $ resource ) { if ( $ this -> container -> get ( 'mesd.jasper.report.security' ) -> canView ( $ resource -> getUriString ( ) ) ) { $ newReturn [ ] = $ resource ; } } $ return = $ newReturn ; } if ( $ recursive ) { foreach ( $ return as $ resource ) { if ( 'folder' === $ resource -> getWsType ( ) ) { $ children = $ this -> getResourceList ( $ resource -> getUriString ( ) , $ recursive ) ; foreach ( $ children as $ child ) { $ resource -> addChildResource ( $ child ) ; } } } } return $ return ; }
Gets a list of resources under the given or default folder
28,461
public function getReportView ( $ reportUri , $ format = 'html' ) { if ( $ this -> isConnected ( ) ) { $ reportViewerEvent = new ReportViewerRequestEvent ( $ format , 1 ) ; $ this -> eventDispatcher -> dispatch ( 'Mesd.jasperreport.report_viewer_request' , $ reportViewerEvent ) ; if ( $ reportViewerEvent -> isPropagationStopped ( ) ) { if ( $ reportViewerEvent -> isAsset ( ) ) { return $ this -> getReportAsset ( $ reportViewerEvent -> getAssetUri ( ) , $ reportViewerEvent -> getJSessionId ( ) ) ; } else { $ params = '&page=' . $ reportViewerEvent -> getReportPage ( ) ; $ format = $ reportViewerEvent -> getReportFormat ( ) ; } } else { $ params = '&page=1' ; } $ report = new Report ( $ reportUri , $ format ) ; $ reportBuilder = new ReportBuilder ( $ this -> jasperClient , $ report , $ params , $ this -> router -> getMatcher ( ) -> getContext ( ) -> getBaseUrl ( ) . $ this -> router -> getMatcher ( ) -> getContext ( ) -> getPathInfo ( ) . '?asset=true' , 'Fallback' ) ; return $ reportBuilder ; } else { return false ; } }
can be passed to the MesdJasperReportBundle_report_view twig function to automatically render the controls and report
28,462
public function getReportAsset ( $ assetUri , $ jSessionId ) { $ assetClient = new Client ( $ this -> reportHost . ':' . $ this -> reportPort , $ this -> reportUser , $ this -> reportPass , $ jSessionId , $ this -> version ) ; return $ assetClient -> getReportAsset ( $ assetUri ) ; }
Returns the asset associated with the asset uri and jsessionid combo
28,463
public function setContainer ( Symfony \ Component \ DependencyInjection \ Container $ container ) { $ this -> container = $ container ; return $ this ; }
Sets the The Symfony Service Container .
28,464
public function addNode ( $ className , array $ info ) { $ this -> nodes [ $ className ] = $ info ; $ this -> leaves [ ] = $ className ; }
Add node to the graph
28,465
public function addConnection ( $ src , $ dst ) { $ this -> edges [ $ src ] [ ] = $ dst ; if ( ( $ id = array_search ( $ dst , $ this -> leaves ) ) !== false ) { unset ( $ this -> leaves [ $ id ] ) ; } }
Add directed connection to the graph
28,466
public function getSortedNodeList ( ) { $ list = array ( ) ; while ( $ leave = array_pop ( $ this -> leaves ) ) { unset ( $ this -> nodes [ $ leave ] ) ; $ list [ ] = $ leave ; if ( ! isset ( $ this -> edges [ $ leave ] ) ) { continue ; } foreach ( $ this -> edges [ $ leave ] as $ node ) { $ count = - 1 ; foreach ( $ this -> edges as $ src => $ dsts ) { foreach ( $ dsts as $ nr => $ dst ) { $ count += ( $ dst === $ node ) ; if ( $ dst === $ leave ) { unset ( $ this -> edges [ $ src ] [ $ nr ] ) ; } } } if ( $ count <= 0 ) { array_push ( $ this -> leaves , $ node ) ; } } unset ( $ this -> edges [ $ leave ] ) ; } if ( count ( $ this -> edges ) ) { var_dump ( $ this -> edges ) ; throw new Exception ( 'Cycle found in graph. This should not happen.' ) ; } return $ list ; }
Remove cycles from the graph
28,467
public function renderGraph ( $ file ) { $ fp = fopen ( $ graphFile = '/tmp/arbit_class_graph.dot' , 'w' ) ; fwrite ( $ fp , "digraph G {\n\n\t node [ fontname=Arial, fontcolor=\"#2e3436\", fontsize=10, style=filled, color=\"#2e3436\", fillcolor=\"#babdb6\" ]; mindist = 0.4; rankdir=RL; splines = true; overlap=false;\n\n" ) ; $ groups = array ( ) ; foreach ( $ this -> nodes as $ name => $ data ) { $ package = ( $ data [ 'package' ] === false ? 'Core' : $ data [ 'package' ] ) ; $ groups [ $ package ] [ ] = $ name ; } foreach ( $ groups as $ group => $ classes ) { fwrite ( $ fp , sprintf ( "\tsubgraph cluster_%s {\n\t\tlabel=\"%s\";\n\n" , $ group , $ group ) ) ; foreach ( $ classes as $ name ) { $ data = $ this -> nodes [ $ name ] ; if ( strpos ( $ name , 'Exception' ) !== false ) { continue ; } fwrite ( $ fp , sprintf ( "\t\tnode [\n\t\t\tlabel = \"%s\",\n\t\t\tshape = \"Mrecord\",\n\t\t\tfillcolor=\"%s\"\n\t\t] \"%s\";\n\n" , $ name . ' | ' . implode ( ' | ' , $ data [ 'functions' ] ) , ( $ data [ 'type' ] === 'class' ? '#eeeeef' : '#729fcf' ) , $ name ) ) ; } fwrite ( $ fp , sprintf ( "\t}\n\n" ) ) ; } foreach ( $ this -> edges as $ src => $ dsts ) { if ( ! is_array ( $ dsts ) || ( strpos ( $ src , 'Exception' ) !== false ) ) { continue ; } foreach ( $ dsts as $ dst ) { fwrite ( $ fp , sprintf ( "\t\"%s\" -> \"%s\"\n" , $ src , $ dst ) ) ; } } fwrite ( $ fp , "\n}\n\n" ) ; fclose ( $ fp ) ; shell_exec ( 'dot -Tpng -o ' . escapeshellarg ( $ file ) . ' ' . escapeshellarg ( $ graphFile ) ) ; unlink ( $ graphFile ) ; }
Render a graph
28,468
public function fromString ( $ uri ) { if ( is_numeric ( $ uri ) ) { $ uri = '' . $ uri ; } if ( ! is_string ( $ uri ) ) { $ uri = '' ; } $ this -> setRelative ( ) ; if ( 0 === strpos ( $ uri , '//' ) ) { $ this -> setAbsolute ( ) ; } $ parsed_url = parse_url ( $ uri ) ; if ( ! $ parsed_url ) { return $ this ; } if ( array_key_exists ( 'scheme' , $ parsed_url ) ) { $ this -> setAbsolute ( ) ; } foreach ( $ parsed_url as $ urlPart => $ value ) { $ method = 'set' . ucfirst ( $ urlPart ) ; if ( method_exists ( $ this , $ method ) ) { $ this -> $ method ( $ value ) ; } } return $ this ; }
Hydrate this object with values from a string
28,469
public function getUri ( ) { $ userPart = '' ; if ( $ this -> getUser ( ) !== null && $ this -> getPass ( ) !== null ) { $ userPart = $ this -> getUser ( ) . ':' . $ this -> getPass ( ) . '@' ; } else if ( $ this -> getUser ( ) !== null ) { $ userPart = $ this -> getUser ( ) . '@' ; } $ schemePart = ( $ this -> getScheme ( ) ? $ this -> getScheme ( ) . '://' : '//' ) ; if ( ! in_array ( $ this -> getScheme ( ) , self :: getSchemesWithAuthority ( ) ) ) { $ schemePart = $ this -> getScheme ( ) . ':' ; } $ portPart = ( $ this -> getPort ( ) ? ':' . $ this -> getPort ( ) : '' ) ; $ queryPart = ( $ this -> getQuery ( ) ? '?' . $ this -> getQuery ( ) : '' ) ; $ fragmentPart = ( $ this -> getFragment ( ) ? '#' . $ this -> getFragment ( ) : '' ) ; if ( $ this -> isRelative ( ) ) { return $ this -> getPath ( ) . $ queryPart . $ fragmentPart ; } $ path = $ this -> getPath ( ) ; if ( 0 !== strlen ( $ path ) && '/' !== $ path [ 0 ] ) { $ path = '/' . $ path ; } return $ schemePart . $ userPart . $ this -> getHost ( ) . $ portPart . $ path . $ queryPart . $ fragmentPart ; }
Get the URI from the set parameters
28,470
public function setScheme ( $ scheme ) { $ this -> scheme = null ; if ( empty ( $ scheme ) || null === $ scheme ) { return $ this ; } $ scheme = preg_replace ( '/[^a-zA-Z0-9\.\:\-]/' , '' , $ scheme ) ; $ scheme = strtolower ( $ scheme ) ; $ scheme = rtrim ( $ scheme , ':/' ) ; $ scheme = trim ( $ scheme , ':/' ) ; $ scheme = str_replace ( '::' , ':' , $ scheme ) ; if ( strlen ( $ scheme ) != 0 ) { if ( $ this -> isRelative ( ) ) { $ exp = explode ( '/' , ltrim ( $ this -> getPath ( ) , '/' ) ) ; $ this -> setHost ( $ exp [ 0 ] ) ; unset ( $ exp [ 0 ] ) ; $ this -> setPath ( null ) ; $ path = implode ( '/' , $ exp ) ; if ( strlen ( $ path ) > 0 ) { $ this -> setPath ( '/' . $ path ) ; } $ this -> setAbsolute ( ) ; } $ this -> scheme = $ scheme ; } return $ this ; }
Set the scheme . If its empty it will be set to null .
28,471
public function _dispatch ( $ action , $ httpMethod , $ vars = array ( ) ) { $ this -> _action = $ action ; $ this -> _data = $ _POST ; $ this -> _params = array_merge ( Atomik :: get ( 'request' ) , $ vars ) ; $ this -> _httpMethod = $ httpMethod ; $ this -> preDispatch ( ) ; $ result = $ this -> _execute ( $ action , $ this -> _params ) ; $ this -> postDispatch ( $ result ) ; return $ result ; }
Dispatches a request to a controller action
28,472
protected function _execute ( $ action , $ params = array ( ) ) { $ methodName = lcfirst ( str_replace ( ' ' , '' , ucwords ( str_replace ( '_' , ' ' , $ action ) ) ) ) ; $ args = array ( ) ; try { $ method = new ReflectionMethod ( $ this , $ methodName ) ; if ( ! $ method -> isPublic ( ) ) { return false ; } foreach ( $ method -> getParameters ( ) as $ param ) { if ( array_key_exists ( $ param -> getName ( ) , $ params ) ) { $ args [ ] = $ params [ $ param -> getName ( ) ] ; } else if ( ! $ param -> isOptional ( ) ) { throw new AtomikException ( "Missing parameter '" . $ param -> getName ( ) . "' in '" . get_class ( $ this ) . "::$methodName()'" ) ; } else { $ args [ ] = $ param -> getDefaultValue ( ) ; } } } catch ( ReflectionException $ e ) { if ( ! method_exists ( $ this , '__call' ) ) { return false ; } } $ className = substr ( get_class ( $ this ) , 0 , - 10 ) ; $ className = trim ( substr ( $ className , strlen ( trim ( Plugin :: $ config [ 'namespace' ] , '\\' ) ) ) , '\\' ) ; $ view = trim ( str_replace ( '\\' , '/' , strtolower ( $ className ) ) . "/$action" , '/' ) ; $ this -> _setView ( $ view ) ; return call_user_func_array ( array ( $ this , $ methodName ) , $ args ) ; }
Forward the current action to another action from the same controller
28,473
public function validate ( $ input ) { $ uuidv4Pattern = '(^([0-9a-fA-F]{8})-?([0-9a-fA-F]{4})-?(4[0-9a-fA-F]{3})-?([89abAB][0-9a-fA-F]{3})-?([0-9a-fA-F]{12})$)' ; if ( preg_match ( $ uuidv4Pattern , $ input , $ matches ) !== 1 ) { throw new phpillowValidationException ( 'A uuid version 4 is required. Something else has been given.' , array ( ) ) ; } return strtolower ( $ matches [ 1 ] . '-' . $ matches [ 2 ] . '-' . $ matches [ 3 ] . '-' . $ matches [ 4 ] . '-' . $ matches [ 5 ] ) ; }
Validate input as uuid version 4
28,474
protected static function getField ( ParticleInterface $ particle , FieldsCargo $ cargo , string $ name , array $ args = [ ] ) { $ name = Utils :: findFieldName ( $ cargo , $ name ) ; return $ particle -> attributes ( ) -> $ name ; }
Returns the field value
28,475
protected static function getEdgeNodes ( ParticleInterface $ particle , array $ pack , string $ name , Direction $ direction , bool $ singular = false ) : array { $ direction = ( string ) $ direction ; $ node_adj = static :: ADJACENCY_EQUIVALENT [ $ direction ] ; $ cargo = $ pack [ $ direction ] ; $ edges = $ particle -> edges ( ) -> $ direction ( ) ; $ haystack = $ singular ? "singularLabel_class_pairs" : "label_class_pairs" ; $ return = [ ] ; array_walk ( $ edges , function ( $ item , $ key ) use ( & $ return , $ name , $ cargo , $ node_adj , $ haystack ) { if ( $ item instanceof $ cargo -> $ haystack [ $ name ] ) { $ return [ ] = $ item -> $ node_adj ( ) -> node ( ) ; } } ) ; return $ return ; }
Getter Catcher for Edges In and Out
28,476
protected static function getEdgeItself ( ParticleInterface $ particle , array $ pack , string $ name , Direction $ direction , bool $ singular = false ) : array { $ direction = ( string ) $ direction ; $ cargo = $ pack [ $ direction ] ; $ haystack = $ singular ? "callable_edge_singularLabel_class_pairs" : "callable_edge_label_class_pairs" ; $ edges = $ particle -> edges ( ) -> $ direction ( $ cargo -> $ haystack [ $ name ] ) ; return array_values ( iterator_to_array ( $ edges ) ) ; }
Getter Catcher for Edge Callables In and Out
28,477
public function getUsername ( ) { $ username = null ; $ link = $ this -> getLink ( ) ; if ( ! empty ( $ link ) ) { $ username = substr ( $ link , strrpos ( $ link , '/' ) + 1 ) ; } return $ username ; }
Get resource owner s username
28,478
public function getAvatar ( ) { $ avatarUrl = null ; $ avatarWidth = 0 ; if ( ! empty ( $ this -> response [ 'pictures' ] [ 'sizes' ] ) && is_array ( $ this -> response [ 'pictures' ] [ 'sizes' ] ) ) { foreach ( $ this -> response [ 'pictures' ] [ 'sizes' ] as $ picture ) { if ( $ picture [ 'width' ] > $ avatarWidth ) { $ avatarUrl = $ picture [ 'link' ] ; $ avatarWidth = $ picture [ 'width' ] ; } } } return $ avatarUrl ; }
Get resource owner s image url
28,479
private static function getItems ( $ ids , $ type ) { $ resultRCS = self :: $ client -> request ( 'POST' , self :: BASEURL . 'services/entreprise/rest/recherche/' . 'resumeEntreprise?typeRecherche=' . $ type , [ 'json' => $ ids , 'headers' => [ 'Content-Type' => 'text/plain' ] , ] ) ; return json_decode ( $ resultRCS -> getBody ( ) ) -> items ; }
Get detailed info on companies from API .
28,480
public static function search ( $ query , ConsoleLogger $ logger = null ) { $ handler = \ GuzzleHttp \ HandlerStack :: create ( ) ; if ( isset ( $ logger ) ) { $ handler -> push ( \ GuzzleHttp \ Middleware :: log ( $ logger , new \ GuzzleHttp \ MessageFormatter ( '{req_headers}' . PHP_EOL . '{req_body}' ) ) ) ; } self :: $ client = new \ GuzzleHttp \ Client ( [ 'cookies' => true , 'handler' => $ handler ] ) ; self :: $ client -> request ( 'GET' , self :: BASEURL . 'services/entreprise/rest/recherche/parPhrase' , [ 'query' => [ 'phrase' => $ query , 'typeProduitMisEnAvant' => 'EXTRAIT' , ] , ] ) ; self :: $ client -> request ( 'GET' , self :: BASEURL . 'societes/recherche-entreprise-dirigeants/' . 'resultats-entreprise-dirigeants.html' ) ; $ response = self :: $ client -> request ( 'GET' , 'https://www.infogreffe.fr/services/entreprise/rest/recherche/' . 'derniereRechercheEntreprise' ) ; $ response = json_decode ( $ response -> getBody ( ) ) ; $ idsRCS = $ idsNoRCS = $ idsRemovedRCS = [ ] ; foreach ( $ response -> entrepRCSStoreResponse -> items as $ result ) { if ( isset ( $ result -> id ) ) { $ idsRCS [ ] = $ result -> id ; } } if ( isset ( $ response -> entrepRadieeStoreResponse ) ) { foreach ( $ response -> entrepRadieeStoreResponse -> items as $ result ) { if ( isset ( $ result -> id ) ) { $ idsRemovedRCS [ ] = $ result -> id ; } } } foreach ( $ response -> entrepHorsRCSStoreResponse -> items as $ result ) { if ( isset ( $ result -> id ) ) { $ idsNoRCS [ ] = $ result -> id ; } } $ items = [ ] ; if ( ! empty ( $ idsRCS ) ) { $ items = array_merge ( $ items , self :: getItems ( $ idsRCS , 'ENTREP_RCS_ACTIF' ) ) ; } if ( ! empty ( $ idsRemovedRCS ) ) { $ items = array_merge ( $ items , self :: getItems ( $ idsRemovedRCS , 'ENTREP_RCS_RADIES' ) ) ; } if ( ! empty ( $ idsNoRCS ) ) { $ items = array_merge ( $ items , self :: getItems ( $ idsNoRCS , 'ENTREP_HORS_RCS' ) ) ; } return self :: getArrayFromJSON ( $ items ) ; }
Search for a company .
28,481
private static function getArrayFromJSON ( $ items ) { $ return = [ ] ; foreach ( $ items as $ item ) { if ( isset ( $ item -> siren ) ) { $ return [ ] = new self ( $ item -> siren , $ item -> nic , $ item -> libelleEntreprise -> denomination , $ item -> adresse -> lignes , $ item -> adresse -> codePostal , $ item -> adresse -> bureauDistributeur , $ item -> radie ) ; } } return $ return ; }
Convert the JSON list returned by infogreffe . fr to an array of Infogreffe objects .
28,482
public static function getRawImage ( $ path ) { $ disk = config ( 'filesystems.default' ) ; $ storage = Storage :: disk ( $ disk ) ; if ( ! $ storage -> exists ( $ path ) ) { return '' ; } $ mime_type = $ storage -> mimeType ( $ path ) ; $ raw_image = "data:$mime_type;base64," . base64_encode ( $ storage -> get ( $ path ) ) ; return $ raw_image ; }
Get raw image attribute based on its path on file storage
28,483
public static function getImageUrl ( $ path ) { $ disk = config ( 'filesystems.default' ) ; $ storage = Storage :: disk ( $ disk ) ; if ( ! $ storage -> exists ( $ path ) ) { return '' ; } switch ( $ disk ) { case 's3' : $ driver = $ storage -> getDriver ( ) ; $ adapter = $ driver -> getAdapter ( ) ; $ client = $ adapter -> getClient ( ) ; $ bucket = config ( 'filesystems.disks.s3.bucket' ) ; $ url = $ client -> getObjectUrl ( $ bucket , $ path ) ; return $ url ; break ; case 'local' : return config ( 'url' ) . '/' . $ path ; break ; default : return static :: getRawImage ( $ path ) ; break ; } }
Get image URL attribute based on its path on file storage
28,484
public static function execute ( $ action , $ method , $ vars , $ context ) { $ className = str_replace ( ' ' , self :: $ config [ 'namespace_separator' ] , ucwords ( str_replace ( '/' , ' ' , trim ( $ action ) ) ) ) ; $ filename = str_replace ( self :: $ config [ 'namespace_separator' ] , DIRECTORY_SEPARATOR , $ className ) . '.php' ; $ className .= 'Action' ; Atomik :: fireEvent ( 'RestExecutor::Execute' , array ( & $ className , & $ filename , & $ context ) ) ; if ( ! ( $ include = Atomik :: actionFilename ( $ filename , null , true ) ) ) { return false ; } list ( $ filename , $ ns ) = $ include ; $ className = trim ( "$ns\\$className" , '\\' ) ; include $ filename ; if ( ! class_exists ( $ className ) ) { throw new AtomikException ( "Class '$className' not found in '$filename'" ) ; } $ instance = new $ className ( $ vars ) ; $ vars = array ( ) ; if ( method_exists ( $ instance , 'execute' ) ) { if ( ! is_array ( $ vars = $ instance -> execute ( Atomik :: get ( 'request' ) ) ) ) { $ vars = array ( ) ; } } if ( method_exists ( $ instance , $ method ) ) { if ( is_array ( $ return = call_user_func ( array ( $ instance , $ method ) , Atomik :: get ( 'request' ) ) ) ) { $ vars = array_merge ( $ vars , $ return ) ; } } $ vars = array_merge ( get_object_vars ( $ instance ) , $ vars ) ; return $ vars ; }
Executor which uses classes to define actions
28,485
public function constructWithCopy ( $ A ) { $ this -> m = count ( $ A ) ; $ this -> n = count ( $ A [ 0 ] ) ; $ X = new Matrix ( $ this -> m , $ this -> n ) ; for ( $ i = 0 ; $ i < $ this -> m ; $ i ++ ) { if ( count ( $ A [ $ i ] ) != $ this -> n ) { trigger_error ( RowLengthException , ERROR ) ; } for ( $ j = 0 ; $ j < $ this -> n ; $ j ++ ) { $ X -> A [ $ i ] [ $ j ] = $ A [ $ i ] [ $ j ] ; } } return $ X ; }
Construct a matrix from a copy of a 2 - D array .
28,486
public function getColumnPackedCopy ( ) { $ P = [ ] ; for ( $ i = 0 ; $ i < $ this -> m ; $ i ++ ) { for ( $ j = 0 ; $ j < $ this -> n ; $ j ++ ) { array_push ( $ P , $ this -> A [ $ j ] [ $ i ] ) ; } } return $ P ; }
getColumnPacked Get a column - packed array
28,487
public function setMatrix ( ) { if ( func_num_args ( ) > 0 ) { $ args = func_get_args ( ) ; $ match = implode ( ',' , array_map ( 'gettype' , $ args ) ) ; switch ( $ match ) { case 'integer,integer,object' : $ M = is_a ( $ args [ 2 ] , 'Matrix' ) ? $ args [ 2 ] : trigger_error ( ArgumentTypeException , ERROR ) ; $ i0 = ( ( $ args [ 0 ] + $ M -> m ) <= $ this -> m ) ? $ args [ 0 ] : trigger_error ( ArgumentBoundsException , ERROR ) ; $ j0 = ( ( $ args [ 1 ] + $ M -> n ) <= $ this -> n ) ? $ args [ 1 ] : trigger_error ( ArgumentBoundsException , ERROR ) ; for ( $ i = $ i0 ; $ i < $ i0 + $ M -> m ; $ i ++ ) { for ( $ j = $ j0 ; $ j < $ j0 + $ M -> n ; $ j ++ ) { $ this -> A [ $ i ] [ $ j ] = $ M -> get ( $ i - $ i0 , $ j - $ j0 ) ; } } break ; case 'integer,integer,array' : $ M = new Matrix ( $ args [ 2 ] ) ; $ i0 = ( ( $ args [ 0 ] + $ M -> m ) <= $ this -> m ) ? $ args [ 0 ] : trigger_error ( ArgumentBoundsException , ERROR ) ; $ j0 = ( ( $ args [ 1 ] + $ M -> n ) <= $ this -> n ) ? $ args [ 1 ] : trigger_error ( ArgumentBoundsException , ERROR ) ; for ( $ i = $ i0 ; $ i < $ i0 + $ M -> m ; $ i ++ ) { for ( $ j = $ j0 ; $ j < $ j0 + $ M -> n ; $ j ++ ) { $ this -> A [ $ i ] [ $ j ] = $ M -> get ( $ i - $ i0 , $ j - $ j0 ) ; } } break ; default : trigger_error ( PolymorphicArgumentException , ERROR ) ; break ; } } else { trigger_error ( PolymorphicArgumentException , ERROR ) ; } }
setMatrix Set a submatrix
28,488
public function checkMatrixDimensions ( $ B = null ) { if ( is_a ( $ B , 'Matrix' ) ) { if ( ( $ this -> m == $ B -> m ) && ( $ this -> n == $ B -> n ) ) { return true ; } else { trigger_error ( MatrixDimensionException , ERROR ) ; } } else { trigger_error ( ArgumentTypeException , ERROR ) ; } }
checkMatrixDimensions Is matrix B the same size?
28,489
public function set ( $ i = null , $ j = null , $ c = null ) { $ this -> A [ $ i ] [ $ j ] = $ c ; }
set Set the i j - th element of the matrix .
28,490
public function & filled ( $ m = null , $ n = null , $ c = 0 ) { if ( is_int ( $ m ) && is_int ( $ n ) && is_numeric ( $ c ) ) { $ R = new Matrix ( $ m , $ n , $ c ) ; return $ R ; } else { trigger_error ( ArgumentTypeException , ERROR ) ; } }
filled Generate a filled matrix
28,491
public function & random ( $ m = null , $ n = null , $ a = RAND_MIN , $ b = RAND_MAX ) { if ( is_int ( $ m ) && is_int ( $ n ) && is_numeric ( $ a ) && is_numeric ( $ b ) ) { $ R = new Matrix ( $ m , $ n ) ; for ( $ i = 0 ; $ i < $ m ; $ i ++ ) { for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { $ R -> set ( $ i , $ j , mt_rand ( $ a , $ b ) ) ; } } return $ R ; } else { trigger_error ( ArgumentTypeException , ERROR ) ; } }
random Generate a random matrix
28,492
public function norm1 ( ) { $ r = 0 ; for ( $ j = 0 ; $ j < $ this -> n ; $ j ++ ) { $ s = 0 ; for ( $ i = 0 ; $ i < $ this -> m ; $ i ++ ) { $ s += abs ( $ this -> A [ $ i ] [ $ j ] ) ; } $ r = ( $ r > $ s ) ? $ r : $ s ; } return $ r ; }
norm1 One norm
28,493
public function normF ( ) { $ f = 0 ; for ( $ i = 0 ; $ i < $ this -> m ; $ i ++ ) { for ( $ j = 0 ; $ j < $ this -> n ; $ j ++ ) { $ f = hypo ( $ f , $ this -> A [ $ i ] [ $ j ] ) ; } } return $ f ; }
normF Frobenius norm
28,494
public function plus ( ) { if ( func_num_args ( ) > 0 ) { $ args = func_get_args ( ) ; $ match = implode ( ',' , array_map ( 'gettype' , $ args ) ) ; switch ( $ match ) { case 'object' : $ M = is_a ( $ args [ 0 ] , 'Matrix' ) ? $ args [ 0 ] : trigger_error ( ArgumentTypeException , ERROR ) ; for ( $ i = 0 ; $ i < $ this -> m ; $ i ++ ) { for ( $ j = 0 ; $ j < $ this -> n ; $ j ++ ) { $ M -> set ( $ i , $ j , $ M -> get ( $ i , $ j ) + $ this -> A [ $ i ] [ $ j ] ) ; } } return $ M ; break ; case 'array' : $ M = new Matrix ( $ args [ 0 ] ) ; for ( $ i = 0 ; $ i < $ this -> m ; $ i ++ ) { for ( $ j = 0 ; $ j < $ this -> n ; $ j ++ ) { $ M -> set ( $ i , $ j , $ M -> get ( $ i , $ j ) + $ this -> A [ $ i ] [ $ j ] ) ; } } return $ M ; break ; default : trigger_error ( PolymorphicArgumentException , ERROR ) ; break ; } } else { trigger_error ( PolymorphicArgumentException , ERROR ) ; } }
plus A + B
28,495
public function mprint ( $ A , $ format = '%01.2f' , $ width = 2 ) { $ spacing = '' ; $ m = count ( $ A ) ; $ n = count ( $ A [ 0 ] ) ; for ( $ i = 0 ; $ i < $ width ; $ i ++ ) { $ spacing .= '&nbsp;' ; } for ( $ i = 0 ; $ i < $ m ; $ i ++ ) { for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { $ formatted = sprintf ( $ format , $ A [ $ i ] [ $ j ] ) ; echo $ formatted . $ spacing ; } echo '<br />' ; } }
Older debugging utility for backwards compatability .
28,496
public function toHTML ( $ width = 2 ) { print ( '<table style="background-color:#eee;">' ) ; for ( $ i = 0 ; $ i < $ this -> m ; $ i ++ ) { print ( '<tr>' ) ; for ( $ j = 0 ; $ j < $ this -> n ; $ j ++ ) { print ( '<td style="background-color:#fff;border:1px solid #000;padding:2px;text-align:center;vertical-align:middle;">' . $ this -> A [ $ i ] [ $ j ] . '</td>' ) ; } print ( '</tr>' ) ; } print ( '</table>' ) ; }
Debugging utility .
28,497
public function getPreviewAttribute ( ) { if ( $ this -> use_html ) { return 'HTML Content' ; } elseif ( $ this -> path ) { $ row_image = ImageHelper :: getImageUrl ( $ this -> path ) ; return '<img src="' . $ row_image . '" class="thumbnail" />' ; } }
Accessor to get preview string
28,498
public function parse ( array $ tokenStruct ) { if ( ! $ tokenStruct [ 0 ] === Lexer :: TOKEN_VARIABLE ) { return $ tokenStruct ; } $ data = $ tokenStruct [ 1 ] ; if ( ! preg_match ( '/^(?P<varname>[^|]+)\|(?P<context>html|attr|js|css|url)$/' , $ data , $ matches ) ) { return $ tokenStruct ; } return [ $ tokenStruct [ 0 ] , $ matches [ 'varname' ] , $ matches [ 'context' ] , ] ; }
Escape a variable .
28,499
public function resolve ( IRequest $ request ) { foreach ( $ this -> grantTypes as $ grantType ) { if ( $ grantType -> match ( $ request ) ) { return $ grantType ; } } throw new UnsupportedGrantTypeException ; }
Resolves grant type for given request