idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
19,700
public function set ( $ name , $ value ) { $ context = $ this -> _context ; if ( ! $ context -> started ) { $ this -> _start ( ) ; } $ context -> is_dirty = true ; $ context -> _SESSION [ $ name ] = $ value ; }
Sets a session variable in an application context
19,701
public function has ( $ name ) { $ context = $ this -> _context ; if ( ! $ context -> started ) { $ this -> _start ( ) ; } return isset ( $ context -> _SESSION [ $ name ] ) ; }
Check whether a session variable is set in an application context
19,702
public function remove ( $ name ) { $ context = $ this -> _context ; if ( ! $ context -> started ) { $ this -> _start ( ) ; } $ context -> is_dirty = true ; unset ( $ context -> _SESSION [ $ name ] ) ; }
Removes a session variable from an application context
19,703
private function loadCore ( ContainerBuilder $ container , Loader \ YamlFileLoader $ loader , $ config ) { $ isCacheEnabled = $ config [ 'metadata_cache' ] ; $ container -> setParameter ( 'ma27_api_key_authentication.model_name' , $ config [ 'model_name' ] ) ; $ container -> setParameter ( 'ma27_api_key_authentication.object_manager' , $ config [ 'object_manager' ] ) ; $ container -> setParameter ( 'ma27_api_key_authentication.property.apiKeyLength' , $ config [ 'api_key_length' ] ) ; $ container -> setParameter ( 'ma27_api_key_authentication.metadata_cache_enabled' , $ isCacheEnabled ) ; if ( $ isCacheEnabled ) { $ loader -> load ( 'metadata_cache_warmer.yml' ) ; } $ this -> loadPassword ( $ container , $ config [ 'password' ] , $ loader ) ; }
Loads the user and core related stuff of the bundle .
19,704
private function loadPassword ( ContainerBuilder $ container , $ passwordConfig , Loader \ YamlFileLoader $ loader ) { $ container -> setParameter ( 'ma27_api_key_authentication.password_hashing_service' , $ passwordConfig [ 'strategy' ] ) ; $ container -> setParameter ( 'ma27_api_key_authentication.password_hasher.phpass.iteration_length' , 8 ) ; $ container -> setParameter ( 'ma27_api_key_authentication.password_hasher.php55.cost' , 12 ) ; $ loader -> load ( 'hashers.yml' ) ; }
Loads the password strategy .
19,705
private function loadServices ( Loader \ YamlFileLoader $ loader ) { foreach ( array ( 'security_key' , 'authentication' , 'security' , 'annotation' ) as $ file ) { $ loader -> load ( sprintf ( '%s.yml' , $ file ) ) ; } }
Loads all internal services .
19,706
private function loadApiKeyPurger ( ContainerBuilder $ container , Loader \ YamlFileLoader $ loader , array $ purgerConfig ) { $ container -> setParameter ( 'ma27_api_key_authentication.cleanup_command.date_time_rule' , $ purgerConfig [ 'outdated_rule' ] ) ; $ loader -> load ( 'session_cleanup.yml' ) ; if ( $ this -> isConfigEnabled ( $ container , $ purgerConfig [ 'last_action_listener' ] ) ) { $ loader -> load ( 'last_action_listener.yml' ) ; } }
Loads the purger job command into the container .
19,707
private function overrideServices ( ContainerBuilder $ container , array $ services ) { $ serviceConfig = array ( 'auth_handler' => 'ma27_api_key_authentication.auth_handler' , 'key_factory' => 'ma27_api_key_authentication.key_factory' , ) ; foreach ( $ serviceConfig as $ configIndex => $ replaceableServiceId ) { if ( ! isset ( $ services [ $ configIndex ] ) || null === $ serviceId = $ services [ $ configIndex ] ) { continue ; } $ container -> removeDefinition ( $ replaceableServiceId ) ; $ container -> setAlias ( $ replaceableServiceId , new Alias ( $ serviceId ) ) ; } }
Processes the service override configuration into the container .
19,708
public function text ( $ key ) { return nl2br ( \ Cms \ Model \ Text :: textByKeyLang ( $ key , \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) -> request -> lang ) ) ; }
Generuje tekst statyczny
19,709
public function getSites ( ) { $ sites = [ ] ; $ defaultSet = false ; if ( ! $ this -> getValid ( ) ) { return $ sites ; } foreach ( $ this -> xml -> children ( ) as $ child ) { if ( $ child -> getName ( ) == "site" ) { $ site = $ this -> parseSite ( $ child ) ; if ( $ site !== false ) { if ( $ defaultSet && $ site [ 'default' ] ) { $ this -> logger -> error ( 'There can be only one default site.' ) ; } else { $ sites [ $ site [ 'url' ] ] = $ site ; $ defaultSet |= $ site [ 'default' ] ; } } } } return $ sites ; }
Get an array of sites from the configuration file .
19,710
public function getStaticTokens ( ) { $ tokens = [ ] ; $ sites = [ ] ; if ( ! $ this -> getValid ( ) ) { return $ sites ; } foreach ( $ this -> xml -> children ( ) as $ child ) { if ( $ child -> getName ( ) == "token" ) { $ token = $ this -> parseToken ( $ child ) ; if ( $ token !== false ) { $ tokens [ $ token [ 'token' ] ] = $ token ; } } } return $ tokens ; }
Get an array of static tokens from the configuration file .
19,711
public function setObjectACL ( $ entity , $ aces , $ type ) { if ( $ type != "object" ) { throw new \ RuntimeException ( 'ACEs of type ' . $ type . ' are not supported.' ) ; } $ acl = $ this -> getAcl ( $ entity ) ; $ oldAces = $ acl -> getObjectAces ( ) ; foreach ( array_reverse ( array_keys ( $ oldAces ) ) as $ idx ) { $ acl -> deleteObjectAce ( intval ( $ idx ) ) ; } $ this -> aclProvider -> updateAcl ( $ acl ) ; foreach ( array_reverse ( $ aces ) as $ idx => $ ace ) { if ( $ ace [ 'mask' ] === 0 ) { continue ; } $ acl -> insertObjectAce ( $ ace [ 'sid' ] , $ ace [ 'mask' ] ) ; } $ this -> aclProvider -> updateAcl ( $ acl ) ; }
Update ACEs for entity
19,712
public function getACL ( $ entity , $ create = true ) { $ acl = null ; $ oid = $ this -> getEntityObjectId ( $ entity ) ; try { $ acl = $ this -> aclProvider -> findAcl ( $ oid ) ; } catch ( NotAllAclsFoundException $ e ) { $ acl = $ e -> getPartialResult ( ) ; } catch ( AclNotFoundException $ e ) { if ( $ create ) { $ acl = $ this -> aclProvider -> createAcl ( $ oid ) ; } } return $ acl ; }
Get ACL object manager .
19,713
protected function _modeSimple ( ) { if ( $ this -> getToolbars ( ) === null ) { $ this -> setToolbars ( 'bold italic underline strikethrough | alignleft aligncenter alignright alignjustify' ) ; } if ( $ this -> getContextMenu ( ) === null ) { $ this -> setContextMenu ( 'link image inserttable | cell row column deletetable' ) ; } if ( $ this -> getResize ( ) === null ) { $ this -> setResize ( false ) ; } if ( $ this -> getMenubar ( ) === null ) { $ this -> setMenubar ( false ) ; } }
Konfiguracja dla trybu Simple
19,714
protected function _modeAdvanced ( ) { if ( $ this -> getToolbars ( ) === null ) { $ this -> setToolbars ( [ 'undo redo | cut copy paste pastetext | searchreplace | bold italic underline strikethrough | subscript superscript | alignleft aligncenter alignright alignjustify | fontselect fontsizeselect | forecolor backcolor' , 'styleselect | table | bullist numlist outdent indent blockquote | link unlink anchor | image media lioniteimages | preview fullscreen code | charmap visualchars nonbreaking inserttime hr' ] ) ; } if ( $ this -> getContextMenu ( ) === null ) { $ this -> setContextMenu ( 'link image media inserttable | cell row column deletetable' ) ; } }
Konfiguracja dla trybu Advanced
19,715
protected function _modeDefault ( ) { if ( $ this -> getToolbars ( ) === null ) { $ this -> setToolbars ( 'undo redo | bold italic underline strikethrough | forecolor backcolor | styleselect | bullist numlist outdent indent | fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | link unlink anchor | image media lioniteimages | preview' ) ; } if ( $ this -> getContextMenu ( ) === null ) { $ this -> setContextMenu ( 'link image media inserttable | cell row column deletetable' ) ; } }
Konfiguracja dla trybu Default
19,716
public static function lang ( ) { if ( ! \ Mmi \ App \ FrontController :: getInstance ( ) -> getRequest ( ) -> lang ) { return new self ; } return ( new self ) -> whereLang ( ) -> equals ( \ Mmi \ App \ FrontController :: getInstance ( ) -> getRequest ( ) -> lang ) -> orFieldLang ( ) -> equals ( null ) -> orderDescLang ( ) ; }
Zapytanie po langu z requesta
19,717
public function getParam ( $ name , $ default = null ) { $ params = $ this -> _context -> params ; return isset ( $ params [ $ name ] ) ? $ params [ $ name ] : $ default ; }
Gets a param by its name or numeric index
19,718
public function dispatch ( $ router ) { $ context = $ this -> _context ; if ( $ router instanceof RouterContext ) { $ area = $ router -> area ; $ controller = $ router -> controller ; $ action = $ router -> action ; $ params = $ router -> params ; } else { $ area = $ router -> getArea ( ) ; $ controller = $ router -> getController ( ) ; $ action = $ router -> getAction ( ) ; $ params = $ router -> getParams ( ) ; } if ( $ area ) { $ area = strpos ( $ area , '_' ) === false ? ucfirst ( $ area ) : Text :: camelize ( $ area ) ; $ context -> area = $ area ; } $ controller = strpos ( $ controller , '_' ) === false ? ucfirst ( $ controller ) : Text :: camelize ( $ controller ) ; $ context -> controller = $ controller ; $ action = strpos ( $ action , '_' ) === false ? $ action : lcfirst ( Text :: camelize ( $ action ) ) ; $ context -> action = $ action ; $ context -> params = $ params ; if ( $ area ) { if ( $ action === 'index' ) { if ( $ controller === 'Index' ) { $ context -> path = $ area === 'Index' ? '/' : '/' . Text :: underscore ( $ area ) ; } else { $ context -> path = '/' . Text :: underscore ( $ area ) . '/' . Text :: underscore ( $ controller ) ; } } else { $ context -> path = '/' . Text :: underscore ( $ area ) . '/' . Text :: underscore ( $ controller ) . '/' . Text :: underscore ( $ action ) ; } } else { if ( $ action === 'index' ) { $ context -> path = $ controller === 'Index' ? '/' : '/' . Text :: underscore ( $ controller ) ; } else { $ context -> path = '/' . Text :: underscore ( $ controller ) . '/' . Text :: underscore ( $ action ) ; } } $ controllerClassName = $ this -> _getControllerClassName ( ) ; $ controllerInstance = $ this -> _di -> getShared ( $ controllerClassName ) ; $ context -> controllerInstance = $ controllerInstance ; return $ this -> invokeAction ( $ controllerInstance , $ action , $ params ) ; }
Dispatches a handle action taking into account the routing parameters
19,719
public function encode ( $ id , $ type = '' ) { if ( ! isset ( $ this -> _keys [ $ type ] ) ) { if ( $ this -> _key === null ) { $ this -> _key = $ this -> crypt -> getDerivedKey ( 'secint' ) ; } $ this -> _keys [ $ type ] = md5 ( $ this -> _key . $ type , true ) ; } while ( true ) { $ rand = mt_rand ( ) & 0xFFFF0000 ; $ r = base64_encode ( mcrypt_encrypt ( MCRYPT_XTEA , $ this -> _keys [ $ type ] , pack ( 'VV' , $ id , $ rand ) , MCRYPT_MODE_ECB ) ) ; if ( strcspn ( $ r , '+/' ) === 12 ) { return substr ( $ r , 0 , - 1 ) ; } } return $ id ; }
Encodes a variable number of parameters to generate a hash .
19,720
public function decode ( $ hash , $ type = '' ) { if ( strlen ( $ hash ) !== 11 ) { return false ; } if ( ! isset ( $ this -> _keys [ $ type ] ) ) { if ( $ this -> _key === null ) { $ this -> _key = $ this -> crypt -> getDerivedKey ( 'secint' ) ; } $ this -> _keys [ $ type ] = md5 ( $ this -> _key . $ type , true ) ; } $ r = unpack ( 'Vid/Vr' , mcrypt_decrypt ( MCRYPT_XTEA , $ this -> _keys [ $ type ] , base64_decode ( $ hash . '=' ) , MCRYPT_MODE_ECB ) ) ; if ( $ r [ 'r' ] & 0xFFFF ) { return false ; } else { return $ r [ 'id' ] ; } }
Decodes a hash to the original parameter values .
19,721
protected function getConfigurationDirectory ( ) { $ reflector = new \ ReflectionClass ( $ this ) ; $ fileName = $ reflector -> getFileName ( ) ; if ( ! is_dir ( $ directory = dirname ( $ fileName ) . $ this -> configDirectory ) ) { throw new \ RuntimeException ( sprintf ( 'The configuration directory "%s" does not exists.' , $ directory ) ) ; } return $ directory ; }
Get the configuration directory
19,722
public function postCreate ( ) { $ response = array ( "method" => "create" , "success" => false , "user" => "" , "error_code" => 0 , "error_message" => "" ) ; try { AuthorizerHelper :: can ( UserValidator :: USER_CAN_SAVE ) ; $ data = json_decode ( file_get_contents ( "php://input" ) ) ; if ( empty ( $ data ) ) { $ data = ( object ) $ _POST ; } $ userModel = new User ( ) ; $ requiredParams = array ( 'email' , 'name' , 'role' , 'password' ) ; $ params = ( array ) $ data ; foreach ( $ requiredParams as $ param ) { if ( empty ( $ params [ $ param ] ) ) { throw new \ Exception ( ucfirst ( $ param ) . ' is required.' ) ; } } if ( ! empty ( $ data -> email ) ) { if ( false === $ userModel -> isEmailUnique ( $ data -> email ) ) { throw new \ Exception ( "The email you entered already exists." ) ; } } $ userId = $ userModel -> save ( $ data ) ; if ( empty ( $ userId ) ) { throw new \ Exception ( 'Could not create new user.' ) ; } $ user = $ userModel -> getById ( $ userId ) ; $ output = array ( 'id' => $ user -> getId ( ) , 'email' => $ user -> getEmail ( ) , 'role' => $ this -> getRoleInfo ( $ user ) , 'name' => $ user -> getName ( ) , 'last_login' => $ user -> getLastLogin ( ) , 'gateway_customer_id' => $ user -> getGatewayCustomerId ( ) ) ; $ response [ 'user' ] = $ output ; $ response [ 'success' ] = true ; $ this -> setStatusCode ( 200 ) ; } catch ( \ Exception $ e ) { $ response [ 'error_message' ] = $ e -> getMessage ( ) ; $ response [ 'error_code' ] = $ e -> getCode ( ) ; } $ this -> setContent ( $ response ) ; }
User CRUD actions
19,723
public function onResponseCreation ( OnAssembleResponseEvent $ event ) { if ( $ event -> isSuccess ( ) ) { $ event -> setResponse ( new JsonResponse ( array ( $ this -> apiKeyValue => $ this -> metadata -> getPropertyValue ( $ event -> getUser ( ) , ClassMetadata :: API_KEY_PROPERTY ) , ) ) ) ; return ; } $ event -> setResponse ( new JsonResponse ( array ( $ this -> messageValue => $ this -> translator -> trans ( $ event -> getException ( ) -> getMessage ( ) ? : 'Credentials refused!' ) ) , JsonResponse :: HTTP_UNAUTHORIZED ) ) ; }
Assembles the response .
19,724
public static function fromRawEntry ( $ entry ) { $ className = get_called_class ( ) ; $ class = new $ className ( ) ; foreach ( $ entry as $ property => $ value ) $ class -> { $ property } = $ value ; return $ class ; }
Constructs an appropriate object based on the raw entry
19,725
function abs_end ( ) { $ Node = $ this ; while ( $ Child = end ( $ Node -> children ) ) { $ Node = $ Child ; } return $ Node ; }
recursively get last element in entire tree
19,726
function abs_pop ( ) { $ Node = $ this -> abs_end ( ) ; if ( is_null ( $ Node -> pidx ) ) { return false ; } return $ Node -> get_parent ( ) -> pop ( ) ; }
Recursively pop last element from extremity tree
19,727
function terminate ( $ tok ) { if ( is_scalar ( $ tok ) ) { if ( is_null ( $ this -> t ) ) { $ this -> t = $ tok ; } $ this -> value = $ tok ; } else if ( is_array ( $ tok ) ) { $ this -> t = $ tok [ 0 ] ; $ this -> value = $ tok [ 1 ] ; if ( isset ( $ tok [ 2 ] ) ) { $ this -> l = $ tok [ 2 ] ; if ( isset ( $ tok [ 3 ] ) ) { $ this -> c = $ tok [ 3 ] ; } } } while ( $ Child = $ this -> pop ( ) ) { $ Child -> destroy ( ) ; } }
Terminate this node with a terminal symbol or token
19,728
function get_child ( $ i ) { return isset ( $ this -> children [ $ i ] ) ? $ this -> children [ $ i ] : null ; }
Get child at given index
19,729
function get_line_num ( ) { if ( ! isset ( $ this -> l ) ) { if ( isset ( $ this -> children [ 0 ] ) ) { $ this -> l = $ this -> children [ 0 ] -> get_line_num ( ) ; } else { $ this -> l = 0 ; } } return $ this -> l ; }
Get line number . This will search recursively until a terminal node is reached .
19,730
function get_col_num ( ) { if ( ! isset ( $ this -> c ) ) { if ( isset ( $ this -> children [ 0 ] ) ) { $ this -> c = $ this -> children [ 0 ] -> get_col_num ( ) ; } else { $ this -> c = 0 ; } } return $ this -> c ; }
Get column number . This will search recursively until a terminal node is reached .
19,731
function push ( ParseNode $ Node , $ recursion = true ) { if ( $ Node -> pidx ) { trigger_error ( "Node $Node->idx already has parent $Node->pidx" , E_USER_WARNING ) ; } if ( $ this -> t === $ Node -> t && $ Node -> length ) { if ( isset ( $ Node -> recursion ) ) { $ recursion = $ Node -> recursion ; } if ( ! $ recursion ) { $ this -> push_thru ( $ Node ) ; $ Node -> destroy ( ) ; return $ this -> length ; } } $ Node -> pidx = $ this -> idx ; $ Node -> depth = $ this -> depth + 1 ; $ this -> p = 0 ; return $ this -> length = array_push ( $ this -> children , $ Node ) ; }
Append a child node immediately onto self
19,732
function push_thru ( ParseNode $ Node ) { foreach ( $ Node -> children as $ Child ) { $ Node -> remove ( $ Child ) ; $ this -> push ( $ Child ) ; } return $ this -> length ; }
Push the child nodes of a node onto this node
19,733
function pop ( ) { if ( ! $ this -> length ) { return null ; } if ( -- $ this -> length <= 0 ) { $ this -> length = 0 ; $ this -> p = null ; } else { $ this -> p = 0 ; } $ Node = array_pop ( $ this -> children ) ; $ Node -> pidx = null ; $ Node -> depth = 0 ; return $ Node ; }
Remove immediate child from the end of this node
19,734
function remove ( ParseNode $ Node ) { foreach ( $ this -> children as $ i => $ Child ) { if ( $ Child -> idx === $ Node -> idx ) { return $ this -> remove_at ( $ i ) ; } } }
Remove passed child node from this node
19,735
function remove_at ( $ i ) { $ Child = $ this -> children [ $ i ] ; $ Child -> pidx = null ; $ Child -> depth = 0 ; array_splice ( $ this -> children , $ i , 1 ) ; if ( ! -- $ this -> length ) { $ this -> p = null ; } else { $ this -> p = 0 ; } return $ Child ; }
Remove child node at known index from this node
19,736
function splice ( ParseNode $ Node , array $ nodes ) { foreach ( $ this -> children as $ i => $ Child ) { if ( $ Child -> idx === $ Node -> idx ) { return $ this -> splice_at ( $ i , $ nodes , 1 ) ; } } }
Replace child node with other nodes
19,737
function splice_at ( $ i , array $ nodes , $ len = 0 ) { $ Child = $ this -> children [ $ i ] ; $ Child -> pidx = null ; $ Child -> depth = 0 ; array_splice ( $ this -> children , $ i , $ len , $ nodes ) ; foreach ( $ nodes as $ Node ) { $ Node -> pidx = $ this -> idx ; } $ this -> length = count ( $ this -> children ) ; $ this -> p = 0 ; return $ Child ; }
Replace child node at known index with other nodes
19,738
function get_parent ( ) { if ( ! is_null ( $ this -> pidx ) && isset ( self :: $ reg [ $ this -> pidx ] ) ) { return self :: $ reg [ $ this -> pidx ] ; } else { return null ; } }
Get this node s parent
19,739
function export ( ) { if ( $ this -> is_terminal ( ) ) { if ( $ this -> t === $ this -> value ) { return $ this -> value ; } return array ( $ this -> t , $ this -> value ) ; } $ a = array ( ) ; foreach ( $ this -> children as $ Child ) { $ a [ ] = array ( $ this -> t , $ Child -> export ( ) ) ; } return $ a ; }
Export tree as array . Terminal nodes become tokens non terminals branches .
19,740
function dump ( Lex $ Lex , $ tab = '' ) { $ tag = $ Lex -> name ( $ this -> t ) ; if ( $ this -> is_terminal ( ) ) { if ( $ this -> value && $ this -> value !== $ this -> t ) { echo $ tab , '<' , $ tag , ">\n " , $ tab , htmlspecialchars ( $ this -> value ) , "\n" , $ tab , '</' , $ tag , ">\n" ; } else { echo $ tab , htmlspecialchars ( $ this -> value ) , "\n" ; } } else if ( ! $ this -> length ) { echo $ tab , '<' , $ tag , " />\n" ; } else { echo $ tab , '<' , $ tag , ">\n" ; foreach ( $ this -> children as $ Child ) { $ Child -> dump ( $ Lex , " " . $ tab ) ; } echo $ tab , '</' , $ tag , ">\n" ; } }
Debugging function to inspect the node tree
19,741
public static function run ( Event $ event ) { $ event -> getIO ( ) -> write ( '<info>Now running setup tasks...</info>' ) ; $ config = static :: getConfig ( $ event ) ; $ tasks = static :: getSetupTasks ( $ event ) ; foreach ( $ tasks as $ task ) { $ taskStep = new $ task ( $ config , $ event ) ; $ event -> getIO ( ) -> write ( sprintf ( '<info>Task %1$s</info>' , $ taskStep -> getName ( ) ) ) ; $ taskStep -> complete ( ) ; } $ event -> getIO ( ) -> write ( '<info>Setup tasks complete, cleaning up...</info>' ) ; }
Run the setup one task at a time .
19,742
protected static function getSetupTasks ( Event $ event ) { return [ AskAboutProjectParameters :: class , VerifyProjectParameters :: class , RemoveExistingRootFiles :: class , ReplacePlaceholdersInTemplateFiles :: class , MoveTemplateFilesToRootFolder :: class , RemoveConfigFolder :: class , RemoveTemplatesFolder :: class , RemoveOriginalVCSData :: class , InitializeVCS :: class , RemoveVendorFolder :: class , ] ; }
Get the set of tasks to complete in the correct order .
19,743
public function update ( int $ vehicleId , int $ sharingId , ? string $ description , ? string $ duration = '1D' ) : Response { $ this -> requiresAccessToken ( ) ; return $ this -> sendJson ( 'PATCH' , "vehicles/{$vehicleId}/sharing/{$sharingId}" , $ this -> getApiHeaders ( ) , $ this -> mergeApiBody ( \ compact ( 'description' , 'duration' ) ) ) ; }
Update an existing share .
19,744
public function destroy ( int $ vehicleId , int $ sharingId ) : Response { $ this -> requiresAccessToken ( ) ; return $ this -> send ( 'DELETE' , "vehicles/{$vehicleId}/sharing/{$sharingId}" , $ this -> getApiHeaders ( ) ) ; }
Delete an existing share .
19,745
protected function conn ( $ db_config_name = '' ) { $ db_config_name = $ db_config_name ? $ db_config_name : $ this -> db_config_name ; if ( ! isset ( self :: $ _db_handle [ $ db_config_name ] ) ) { if ( true == C ( 'sql_log' ) ) { wlog ( 'SQL-Log' , '#' . $ db_config_name ) ; } $ dbdriver = 'db_' . C ( 'dbdriver' ) ; include_once FW_PATH . '/dbdrivers/' . $ dbdriver . '.class.php' ; self :: $ _db_handle [ $ db_config_name ] = $ this -> db = new $ dbdriver ( $ db_config_name ) ; } else { $ this -> db = self :: $ _db_handle [ $ db_config_name ] ; } return $ this -> db ; }
What de will be connect
19,746
protected function processNoDataRelationship ( $ source , DocumentHydrator $ hydrator ) : NoDataRelationship { $ relationship = new NoDataRelationship ( ) ; $ hydrator -> hydrateObject ( $ relationship , $ source ) ; return $ relationship ; }
Process relationship contains no data
19,747
protected function processSingleIdentifierRelationship ( $ source , DocumentHydrator $ hydrator ) : SingleIdentifierRelationship { $ identifier = $ this -> createResourceIdentifier ( $ source -> data , $ hydrator ) ; $ relationship = new SingleIdentifierRelationship ( $ identifier ) ; $ hydrator -> hydrateObject ( $ relationship , $ source ) ; return $ relationship ; }
Process relationship with single resource identifier
19,748
protected function processIdentifierCollectionRelationship ( $ source , DocumentHydrator $ hydrator ) : IdentifierCollectionRelationship { $ relationship = new IdentifierCollectionRelationship ( ) ; foreach ( $ source -> data as $ resourceSrc ) { $ relationship -> addIdentifier ( $ this -> createResourceIdentifier ( $ resourceSrc , $ hydrator ) ) ; } $ hydrator -> hydrateObject ( $ relationship , $ source ) ; return $ relationship ; }
Process relationship with collection of resource identifiers
19,749
protected function createException ( GuzzleRequestException $ exception ) : RequestException { if ( $ exception instanceof GuzzleResponseException ) { return new ResponseException ( $ exception -> getRequest ( ) , $ exception -> getResponse ( ) , $ exception ) ; } throw new RequestException ( $ exception -> getRequest ( ) , $ exception ) ; }
Create HTTP - Client RequestException by a Guzzle exception
19,750
public function setMetadataAttribute ( string $ name , $ value ) { if ( array_key_exists ( $ name , $ this -> metadata ) ) { throw new MetadataAttributeOverrideException ( $ this , $ name ) ; } $ this -> metadata [ $ name ] = $ value ; }
Set attribute of metadata
19,751
public function getMetadataAttribute ( string $ name ) { if ( array_key_exists ( $ name , $ this -> metadata ) ) { return $ this -> metadata [ $ name ] ; } throw new MetadataAttributeNotFoundException ( $ this , $ name ) ; }
Get attribute of metadata
19,752
public function setup ( ) { $ this -> id = Splash :: configuration ( ) -> WsIdentifier ; $ this -> key = Splash :: configuration ( ) -> WsEncryptionKey ; if ( ! empty ( Splash :: configuration ( ) -> WsHost ) ) { $ this -> host = Splash :: configuration ( ) -> WsHost ; } else { $ this -> host = self :: SPLASHHOST ; } if ( isset ( Splash :: configuration ( ) -> HttpAuth ) && ! empty ( Splash :: configuration ( ) -> HttpAuth ) ) { $ this -> httpAuth = true ; } if ( $ this -> httpAuth && isset ( Splash :: configuration ( ) -> HttpUser ) ) { $ this -> httpUser = Splash :: configuration ( ) -> HttpUser ; } if ( $ this -> httpAuth && isset ( Splash :: configuration ( ) -> HttpPassword ) ) { $ this -> httpPassword = Splash :: configuration ( ) -> HttpPassword ; } if ( ! $ this -> verify ( ) ) { return false ; } return Splash :: log ( ) -> deb ( 'MsgWsSetParams' ) ; }
Initialise Class with webservice parameters
19,753
public function pack ( $ data , $ isUncrypted = false ) { Splash :: log ( ) -> deb ( 'MsgWsPack' ) ; if ( 'XML' == Splash :: configuration ( ) -> WsEncode ) { $ serial = Splash :: xml ( ) -> objectToXml ( $ data ) ; } else { $ serial = serialize ( $ data ) ; } if ( ! $ isUncrypted ) { $ out = $ this -> crypt ( 'encrypt' , $ serial , $ this -> key , $ this -> id ) ; } else { $ out = base64_encode ( $ serial ) ; } if ( defined ( 'SPLASH_SERVER_MODE' ) && ! empty ( SPLASH_SERVER_MODE ) && ( Splash :: configuration ( ) -> TraceOut ) ) { Splash :: log ( ) -> war ( 'MsgWsFinalPack' , print_r ( $ serial , true ) ) ; } return $ out ; }
Prepare Data Packets for transmit .
19,754
public function unPack ( $ data , $ isUncrypted = false ) { Splash :: log ( ) -> deb ( 'MsgWsunPack' ) ; if ( ! empty ( $ data ) && ! $ isUncrypted ) { $ decode = $ this -> crypt ( 'decrypt' , $ data , $ this -> key , $ this -> id ) ; } else { $ decode = base64_decode ( $ data , true ) ; } if ( 'XML' == Splash :: configuration ( ) -> WsEncode ) { if ( $ decode && false !== strpos ( $ decode , '<SPLASH>' ) ) { $ out = Splash :: xml ( ) -> XmlToArrayObject ( $ decode ) ; } } else { if ( ! empty ( $ decode ) ) { $ out = unserialize ( $ decode ) ; } } if ( empty ( $ out ) ) { Splash :: log ( ) -> err ( 'ErrWsunPack' ) ; } return empty ( $ out ) ? false : $ out ; }
Unpack received Data Packets .
19,755
public function call ( $ service , $ tasks = null , $ isUncrypted = false , $ clean = true ) { if ( ! $ this -> init ( $ service ) ) { return false ; } if ( ! $ this -> addTasks ( $ tasks ) ) { return false ; } $ this -> rawOut = array ( 'id' => $ this -> id , 'data' => $ this -> pack ( $ this -> outputs , $ isUncrypted ) , ) ; if ( false === $ this -> buildClient ( ) ) { return false ; } $ this -> rawIn = Splash :: com ( ) -> call ( $ this -> outputs -> service , $ this -> rawOut ) ; if ( ! $ this -> decodeResponse ( $ isUncrypted ) ) { return false ; } if ( $ clean ) { $ this -> cleanOut ( ) ; } return $ this -> inputs ; }
Perform operation with WebService Client
19,756
public function simulate ( $ service , $ tasks = null , $ isUncrypted = false , $ clean = true ) { if ( ! $ this -> init ( $ service ) ) { return false ; } if ( ! $ this -> addTasks ( $ tasks ) ) { return false ; } $ response = SplashServer :: $ service ( Splash :: configuration ( ) -> WsIdentifier , $ this -> pack ( $ this -> outputs , $ isUncrypted ) ) ; if ( $ clean ) { $ this -> cleanOut ( ) ; } return $ response ; }
Simulate operation on Local WebService Client
19,757
public function addTask ( $ name , $ params , $ desc = 'No Description' ) { $ task = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; $ taskId = $ this -> tasks -> count ( ) + 1 ; $ task [ 'id' ] = $ taskId ; $ task [ 'name' ] = $ name ; $ task [ 'desc' ] = $ desc ; $ task [ 'params' ] = $ params ; $ this -> tasks [ $ taskId ] = $ task ; Splash :: log ( ) -> deb ( 'TasksAdd' , $ task [ 'name' ] , $ task [ 'desc' ] ) ; return $ this ; }
Add a new task for NuSOAP Call Request
19,758
public static function getNextResult ( & $ response ) { $ task = self :: getNextTask ( $ response ) ; if ( ! $ task || ! isset ( $ task -> data ) ) { return false ; } return $ task -> data ; }
Get Next Task Result Available in Response Tasks Buffer
19,759
public static function getNextTask ( & $ response ) { if ( ! $ response || ! isset ( $ response -> result ) || ( true != $ response -> result ) ) { return false ; } if ( ! Splash :: count ( $ response -> tasks ) ) { return false ; } if ( $ response -> tasks instanceof ArrayObject ) { $ response -> tasks = $ response -> tasks -> getArrayCopy ( ) ; } return array_shift ( $ response -> tasks ) ; }
Get Next Task Available in Response Tasks Buffer
19,760
public function getServerInfos ( ) { $ response = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; $ response -> ServerType = 'PHP' ; $ response -> ServerVersion = PHP_VERSION ; $ response -> ProtocolVersion = SPL_PROTOCOL ; $ response -> Self = Splash :: input ( 'PHP_SELF' ) ; $ response -> ServerAddress = Splash :: input ( 'SERVER_ADDR' ) ; $ response -> ServerRoot = realpath ( ( string ) Splash :: input ( 'DOCUMENT_ROOT' ) ) ; $ response -> UserAgent = Splash :: input ( 'HTTP_USER_AGENT' ) ; $ response -> WsMethod = Splash :: configuration ( ) -> WsMethod ; $ response -> ServerHost = $ this -> getServerName ( ) ; $ response -> ServerIP = Splash :: input ( 'SERVER_ADDR' ) ; if ( isset ( Splash :: configuration ( ) -> ServerPath ) ) { $ response -> ServerPath = Splash :: configuration ( ) -> ServerPath ; } else { $ fullPath = dirname ( __DIR__ ) ; $ relPath = explode ( ( string ) $ response -> ServerRoot , $ fullPath ) ; if ( is_array ( $ relPath ) && isset ( $ relPath [ 1 ] ) ) { $ response -> ServerPath = $ relPath [ 1 ] . '/soap.php' ; } else { $ response -> ServerPath = null ; } } $ response -> setFlags ( ArrayObject :: STD_PROP_LIST ) ; return $ response ; }
Return Server Informations
19,761
public function getServerName ( ) { if ( isset ( Splash :: configuration ( ) -> ServerHost ) ) { return Splash :: configuration ( ) -> ServerHost ; } if ( ! empty ( Splash :: input ( 'SERVER_NAME' ) ) ) { return Splash :: input ( 'SERVER_NAME' ) ; } if ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) ) { return $ _SERVER [ 'SERVER_NAME' ] ; } return '' ; }
Safe Get Client Server Url
19,762
private function verify ( ) { if ( empty ( $ this -> host ) ) { return Splash :: log ( ) -> err ( 'ErrWsNoHost' ) ; } if ( empty ( $ this -> id ) ) { return Splash :: log ( ) -> err ( 'ErrWsNoId' ) ; } if ( empty ( $ this -> key ) ) { return Splash :: log ( ) -> err ( 'ErrWsNoKey' ) ; } if ( $ this -> httpAuth ) { if ( empty ( $ this -> httpUser ) ) { return Splash :: log ( ) -> err ( 'ErrWsNoHttpUser' ) ; } if ( empty ( $ this -> httpPassword ) ) { return Splash :: log ( ) -> err ( 'ErrWsNoHttpPwd' ) ; } } return true ; }
Verify Webservice parameters
19,763
private function cleanIn ( ) { $ this -> inputs = null ; $ this -> inputs = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; return true ; }
Clean Ws Input Buffer before Call Request
19,764
private function cleanOut ( ) { $ this -> tasks = null ; $ this -> tasks = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; $ this -> outputs = null ; $ this -> outputs = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; return true ; }
Clean parameters of Ws Call Request
19,765
private function init ( $ service ) { Splash :: log ( ) -> deb ( 'MsgWsCall' ) ; if ( ! $ this -> verify ( ) ) { return Splash :: log ( ) -> err ( 'ErrWsInValid' ) ; } $ this -> cleanIn ( ) ; $ this -> outputs -> server = $ this -> getServerInfos ( ) ; $ this -> outputs -> service = $ service ; $ this -> outputs -> debug = ( int ) SPLASH_DEBUG ; return true ; }
Init WebService Call
19,766
private function addTasks ( $ tasks = null ) { if ( is_null ( $ tasks ) && empty ( $ this -> tasks ) ) { return true ; } if ( ! empty ( $ this -> tasks ) ) { $ this -> outputs -> tasks = $ this -> tasks ; $ this -> outputs -> taskscount = count ( $ this -> outputs -> tasks ) ; Splash :: log ( ) -> deb ( '[WS] Call Loaded ' . $ this -> outputs -> tasks -> count ( ) . ' Internal tasks' ) ; } else { $ this -> outputs -> tasks = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; } if ( ! empty ( $ tasks ) ) { $ this -> outputs -> tasks -> append ( $ tasks ) ; $ this -> outputs -> taskscount = count ( $ tasks ) ; Splash :: log ( ) -> deb ( '[WS] Call Loaded ' . count ( $ tasks ) . ' External tasks' ) ; } return true ; }
Add Tasks to WebService Request
19,767
private function buildClient ( ) { if ( ( false === strpos ( $ this -> host , 'http://' ) ) && ( false === strpos ( $ this -> host , 'https://' ) ) ) { $ this -> url = 'https://' . $ this -> host ; } else { $ this -> url = $ this -> host ; } Splash :: com ( ) -> buildClient ( $ this -> url , $ this -> httpUser , $ this -> httpPassword ) ; return true ; }
Create & Setup WebService Client
19,768
private function decodeResponse ( $ isUncrypted ) { if ( ! empty ( $ this -> rawIn ) ) { $ this -> inputs = $ this -> unPack ( $ this -> rawIn , $ isUncrypted ) ; if ( isset ( $ this -> inputs -> log ) ) { Splash :: log ( ) -> merge ( $ this -> inputs -> log ) ; } } else { Splash :: log ( ) -> deb ( "[WS] Id='" . print_r ( $ this -> id , true ) . "'" ) ; return Splash :: log ( ) -> err ( 'ErrWsNoResponse' , $ this -> outputs -> service , $ this -> url ) ; } return true ; }
Decode WebService Client Response
19,769
private function getClientUrl ( ) { $ serverInfos = $ this -> getServerInfos ( ) ; $ host = $ serverInfos [ 'ServerHost' ] ; if ( ( false !== strpos ( $ host , 'http://' ) ) || ( false !== strpos ( $ host , 'https://' ) ) ) { return $ host . $ serverInfos [ 'ServerPath' ] ; } return $ this -> getServerScheme ( ) . '://' . $ host . $ serverInfos [ 'ServerPath' ] ; }
Build WebService Client Url
19,770
private function getClientDebugLink ( ) { $ url = $ this -> getClientUrl ( ) ; $ params = '?node=' . $ this -> id ; return '<a href="' . $ url . $ params . '" target="_blank" >' . $ url . '</a>' ; }
Build WebService Client Debug Html Link
19,771
protected function getClient ( array $ config ) { $ client = new CloudsearchClient ( $ config [ 'client_id' ] , $ config [ 'client_secret' ] , $ config [ 'host' ] , 'aliyun' ) ; $ search = new CloudsearchSearch ( $ client ) ; $ search -> addIndex ( $ config [ 'app' ] ) ; return $ search ; }
Get the opensearch client .
19,772
protected function setGenericObject ( $ fieldName , $ fieldData , $ objectName = "object" , $ nullable = true ) { $ newId = null ; if ( $ fieldData && method_exists ( $ fieldData , "getId" ) && $ fieldData -> getId ( ) ) { $ newId = $ fieldData -> getId ( ) ; } $ currentId = $ this -> getObjectId ( $ fieldName , $ objectName ) ; if ( $ newId == $ currentId ) { return $ this ; } if ( null == $ newId ) { if ( $ nullable ) { $ this -> { $ objectName } -> { "set" . $ fieldName } ( null ) ; $ this -> needUpdate ( ) ; } return $ this ; } $ this -> { $ objectName } -> { "set" . $ fieldName } ( $ fieldData ) ; $ this -> needUpdate ( ) ; return $ this ; }
Convert Splash ObjectId String to Local Object
19,773
protected function getGeneric ( $ fieldName , $ objectName = "object" ) { $ this -> out [ $ fieldName ] = $ this -> { $ objectName } -> { "get" . $ fieldName } ( ) ; return $ this ; }
Common reading of a Field using Generic Getters & Setters
19,774
protected function getGenericBool ( $ fieldName , $ objectName = "object" ) { $ this -> out [ $ fieldName ] = $ this -> { $ objectName } -> { "is" . $ fieldName } ( ) ; return $ this ; }
Common reading of a Field using Generic Boolean Getters & Setters
19,775
protected function getGenericDate ( $ fieldName , $ objectName = "object" ) { $ date = $ this -> { $ objectName } -> { "get" . $ fieldName } ( ) ; $ this -> out [ $ fieldName ] = $ date ? $ date -> format ( SPL_T_DATECAST ) : "" ; return $ this ; }
Common reading of a Date Field using Generic Getters & Setters
19,776
protected function setGenericDate ( $ fieldName , $ fieldData , $ objectName = "object" ) { $ current = $ this -> { $ objectName } -> { "get" . $ fieldName } ( ) ; if ( ( $ current instanceof DateTime ) && ( $ current -> format ( SPL_T_DATECAST ) == $ fieldData ) ) { return $ this ; } $ this -> { $ objectName } -> { "set" . $ fieldName } ( $ fieldData ? new DateTime ( $ fieldData ) : null ) ; $ this -> needUpdate ( $ objectName ) ; return $ this ; }
Common Writing of a Date Field using Generic Getters & Setters
19,777
protected function getGenericDateTime ( $ fieldName , $ objectName = "object" ) { $ date = $ this -> { $ objectName } -> { "get" . $ fieldName } ( ) ; $ this -> out [ $ fieldName ] = $ date ? $ date -> format ( SPL_T_DATETIMECAST ) : "" ; return $ this ; }
Common reading of a DateTime Field using Generic Getters & Setters
19,778
protected function setGenericDateTime ( $ fieldName , $ fieldData , $ objectName = "object" ) { $ current = $ this -> { $ objectName } -> { "get" . $ fieldName } ( ) ; if ( ( $ current instanceof DateTime ) && ( $ current -> format ( SPL_T_DATETIMECAST ) == $ fieldData ) ) { return $ this ; } $ this -> { $ objectName } -> { "set" . $ fieldName } ( $ fieldData ? new DateTime ( $ fieldData ) : null ) ; $ this -> needUpdate ( $ objectName ) ; return $ this ; }
Common Writing of a DateTime Field using Generic Getters & Setters
19,779
protected function resolveType ( string $ class ) : string { $ name = str_replace ( [ '\\' , '_' ] , $ this -> delimiter , ucwords ( $ class , '\\_' ) ) ; if ( $ this -> fullName ) { return $ name ; } $ pos = strrpos ( $ name , $ this -> delimiter ) ; if ( $ pos === false ) { return $ name ; } return substr ( $ name , $ pos + 1 ) ; }
Resolve type by class
19,780
private function printServerFinger ( ) { $ version = $ this -> version ; $ software = SERVER_MODE === 'swoole' ? 'Swoole Server' : 'PHP Development Server' ; $ document_root = APP_PATH . '/public' ; echo <<<EOT-----------------------------------\033[32m _ __ __ _ /\ _`\ /\ \/\ \/\ _`\ __\ \ \ \ \ \ \_\ \ \ \ \ \ /'__`\ \ ,__/\ \ _ \ \ ,__//\ __/\ \ \ \ \ \ \ \ \ \\ \ _ \\ \_\ \ \_\ \_\ \_\ \/ _/ \/_/ \/_/\/_/\/_/ \033[43;37mv{$version}\033[0m \033[0m>>> \033[35m{$software}\033[0m started ...Listening on \033[36;4mhttp://{$this->config['host']}:{$this->config['port']}/\033[0mDocument root is \033[34m{$document_root}\033[0mPress Ctrl-C to quit.-----------------------------------EOT ; echo "\033[32m>>> Http Server is enabled\033[0m \n" ; if ( ! empty ( $ this -> config [ 'enable_websocket' ] ) ) { echo "\033[32m>>> WebSocket Server is enabled\033[0m \n" ; } echo "-----------------------------------\n" ; }
Print server finger description
19,781
public function devServer ( string $ host , int $ port ) { define ( 'SERVER_MODE' , 'buildin' ) ; $ this -> config [ 'host' ] = $ host ; $ this -> config [ 'port' ] = $ port ; $ this -> printServerFinger ( ) ; $ bind_http = $ host . ':' . $ port ; passthru ( "php -S {$bind_http} -t " . APP_PATH . "/public" ) ; }
Start a PHP Development Server
19,782
public function createServer ( array $ config ) { define ( 'SERVER_MODE' , 'swoole' ) ; $ this -> config = $ config + [ 'host' => '0.0.0.0' , 'port' => '8000' , 'task_worker_num' => 0 , 'enable_websocket' => false ] ; if ( empty ( $ config [ 'enable_websocket' ] ) ) { $ this -> server = new \ Swoole \ Http \ Server ( $ this -> config [ 'host' ] , $ this -> config [ 'port' ] ) ; } else { $ this -> config [ 'open_http_protocol' ] = true ; $ this -> server = new \ Swoole \ WebSocket \ Server ( $ config [ 'host' ] , $ config [ 'port' ] , SWOOLE_PROCESS , SWOOLE_SOCK_TCP ) ; } $ this -> server -> set ( $ this -> config ) ; $ this -> printServerFinger ( ) ; return $ this ; }
Create a swoole server
19,783
public function add_event_listener ( string $ event ) { if ( class_exists ( "\App\Boot" ) ) { $ boot = new \ App \ Boot ( ) ; if ( method_exists ( $ boot , $ event ) ) { call_user_func ( [ $ boot , $ event ] , $ this -> server ) ; } if ( $ event == 'onBoot' ) { $ this -> server -> on ( 'task' , [ $ boot , 'onTask' ] ) ; $ this -> server -> on ( 'finish' , [ $ boot , 'onFinish' ] ) ; } } }
Add envent Listener
19,784
public function start ( ) { $ this -> server -> on ( 'request' , [ $ this , 'onRequest' ] ) ; $ this -> server -> on ( 'start' , [ $ this , 'onStart' ] ) ; $ this -> server -> on ( 'shutdown' , [ $ this , 'onShutdown' ] ) ; $ this -> server -> on ( 'workerStart' , [ $ this , 'onWorkerStart' ] ) ; $ this -> server -> on ( 'workerStop' , [ $ this , 'onWorkerStop' ] ) ; $ this -> server -> on ( 'workerError' , [ $ this , 'onWorkerError' ] ) ; if ( ! empty ( $ this -> config [ 'enable_websocket' ] ) ) { $ this -> server -> on ( 'open' , [ $ this , 'onOpen' ] ) ; $ this -> server -> on ( 'message' , [ $ this , 'onMessage' ] ) ; $ this -> server -> on ( 'close' , [ $ this , 'onClose' ] ) ; } $ this -> add_event_listener ( 'onBoot' ) ; $ this -> server -> start ( ) ; }
Start swoole server
19,785
public function onRequest ( Request $ request , Response $ response ) { $ this -> _compatFPM ( $ request ) ; $ GLOBALS [ '__$response' ] = $ response ; $ response -> header ( 'Server' , 'ePHP/' . $ this -> version ) ; $ filename = APP_PATH . '/public' . $ _SERVER [ 'PATH_INFO' ] ; if ( ! is_file ( $ filename ) ) { ob_start ( ) ; ( new \ ePHP \ Core \ Application ( ) ) -> run ( ) ; $ h = ob_get_clean ( ) ; $ response -> end ( $ h ) ; } else { $ extname = substr ( $ filename , strrpos ( $ filename , '.' ) + 1 ) ; if ( isset ( $ this -> contentType [ $ extname ] ) ) { $ response -> header ( 'Content-Type' , $ this -> contentType [ $ extname ] ) ; } $ response -> sendfile ( $ filename ) ; } $ this -> printAccessLog ( ) ; }
Linsten http server onRequest
19,786
public function onWorkerStart ( \ Swoole \ Server $ server , int $ worker_id ) { if ( getenv ( 'STDOUT_LOG' ) ) { echo date ( 'Y-m-d H:i:s' ) . " |\033[31m ...... http worker process start[id={$worker_id} pid={$server->worker_pid}] ......\033[0m \n" ; } $ this -> add_event_listener ( 'onWorkerStart' ) ; }
On wroker started
19,787
public function onWorkerError ( \ Swoole \ Server $ server , int $ worker_id , int $ worker_pid , int $ exit_code ) { echo date ( 'Y-m-d H:i:s' ) . " |\033[31m http worker process error[id={$worker_id} pid={$worker_pid}] ......\033[0m \n" ; $ this -> add_event_listener ( 'onWorkerError' ) ; }
On work stop
19,788
public function onOpen ( \ Swoole \ WebSocket \ Server $ server , \ Swoole \ Http \ Request $ request ) { $ this -> _compatFPM ( $ request ) ; $ controller_class = ( \ ePHP \ Core \ Route :: init ( ) ) -> findWebSocketRoute ( ) ; if ( ! empty ( $ controller_class ) ) { self :: $ websocketFrameContext [ $ request -> fd ] = [ 'get' => $ _GET , 'cookie' => $ _COOKIE , 'controller_class' => $ controller_class ] ; call_user_func ( [ new $ controller_class ( ) , 'onOpen' ] , $ server , $ request ) ; } }
WebSocket on open
19,789
public function onMessage ( \ Swoole \ WebSocket \ Server $ server , \ Swoole \ WebSocket \ Frame $ frame ) { if ( empty ( self :: $ websocketFrameContext [ $ frame -> fd ] ) ) { if ( getenv ( 'STDOUT_LOG' ) ) { echo date ( 'Y-m-d H:i:s' ) . " |\033[31m [ERROR][onMessage] WebSocket has been stoped before frame sending data\033[0m \n" ; } return ; } $ context = self :: $ websocketFrameContext [ $ frame -> fd ] ; $ _POST = $ _SERVER = [ ] ; $ _GET = $ _REQUEST = $ context [ 'get' ] ; $ _COOKIE = $ context [ 'cookie' ] ; $ controller_class = $ context [ 'controller_class' ] ; call_user_func ( [ new $ controller_class ( ) , 'onMessage' ] , $ server , $ frame ) ; }
WebSocket on message
19,790
public function onClose ( \ Swoole \ WebSocket \ Server $ server , int $ fd ) { if ( empty ( self :: $ websocketFrameContext [ $ fd ] ) ) { if ( getenv ( 'STDOUT_LOG' ) ) { echo date ( 'Y-m-d H:i:s' ) . " |\033[31m [ERROR][onClose] fd{$fd} WebSocket has been stoped...\033[0m \n" ; } return ; } $ context = self :: $ websocketFrameContext [ $ fd ] ; $ _POST = $ _SERVER = [ ] ; $ _GET = $ _REQUEST = $ context [ 'get' ] ; $ _COOKIE = $ context [ 'cookie' ] ; $ controller_class = $ context [ 'controller_class' ] ; unset ( self :: $ websocketFrameContext [ $ fd ] ) ; call_user_func ( [ new $ controller_class ( ) , 'onClose' ] , $ server , $ fd ) ; }
WebSocket on close
19,791
public function prepareItems ( $ items ) { if ( ! is_array ( $ items ) ) { return $ items ; } elseif ( self :: isAssoc ( $ items ) ) { $ items = $ this -> prepareItem ( $ items ) ; } else { foreach ( $ items as $ key => $ item ) { $ items [ $ key ] = $ this -> prepareItem ( $ item ) ; } } return $ items ; }
Prepare elements recursive .
19,792
protected function prepareItem ( $ item ) { if ( ! isset ( $ item [ "type" ] ) ) { return $ item ; } if ( isset ( $ item [ "children" ] ) ) { $ item [ "children" ] = $ this -> prepareItems ( $ item [ "children" ] ) ; } switch ( $ item [ 'type' ] ) { case 'select' : if ( isset ( $ item [ 'sql' ] ) ) { $ connectionName = isset ( $ item [ 'connection' ] ) ? $ item [ 'connection' ] : 'default' ; $ sql = $ item [ 'sql' ] ; $ options = isset ( $ item [ "options" ] ) ? $ item [ "options" ] : array ( ) ; unset ( $ item [ 'sql' ] ) ; unset ( $ item [ 'connection' ] ) ; $ connection = $ this -> container -> get ( "doctrine.dbal.{$connectionName}_connection" ) ; $ all = $ connection -> fetchAll ( $ sql ) ; foreach ( $ all as $ option ) { $ options [ ] = array ( reset ( $ option ) , end ( $ option ) ) ; } $ item [ "options" ] = $ options ; } if ( isset ( $ item [ 'service' ] ) ) { $ serviceInfo = $ item [ 'service' ] ; $ serviceName = isset ( $ serviceInfo [ 'serviceName' ] ) ? $ serviceInfo [ 'serviceName' ] : 'default' ; $ method = isset ( $ serviceInfo [ 'method' ] ) ? $ serviceInfo [ 'method' ] : 'get' ; $ args = isset ( $ serviceInfo [ 'args' ] ) ? $ item [ 'args' ] : '' ; $ service = $ this -> container -> get ( $ serviceName ) ; $ options = $ service -> $ method ( $ args ) ; $ item [ 'options' ] = $ options ; } if ( isset ( $ item [ 'dataStore' ] ) ) { $ dataStoreInfo = $ item [ 'dataStore' ] ; $ dataStore = $ this -> container -> get ( 'data.source' ) -> get ( $ dataStoreInfo [ "id" ] ) ; $ options = array ( ) ; foreach ( $ dataStore -> search ( ) as $ dataItem ) { $ options [ $ dataItem -> getId ( ) ] = $ dataItem -> getAttribute ( $ dataStoreInfo [ "text" ] ) ; } if ( isset ( $ item [ 'dataStore' ] [ 'popupItems' ] ) ) { $ item [ 'dataStore' ] [ 'popupItems' ] = $ this -> prepareItems ( $ item [ 'dataStore' ] [ 'popupItems' ] ) ; } $ item [ 'options' ] = $ options ; } break ; } return $ item ; }
Prepare element by type
19,793
public function decodeRequest ( array $ request ) { foreach ( $ request as $ key => $ value ) { if ( is_array ( $ value ) ) { $ request [ $ key ] = $ this -> decodeRequest ( $ value ) ; } elseif ( strpos ( $ key , '[' ) ) { preg_match ( '/(.+?)\[(.+?)\]/' , $ key , $ matches ) ; list ( $ match , $ name , $ subKey ) = $ matches ; if ( ! isset ( $ request [ $ name ] ) ) { $ request [ $ name ] = array ( ) ; } $ request [ $ name ] [ $ subKey ] = $ value ; unset ( $ request [ $ key ] ) ; } } return $ request ; }
Decode request array variables
19,794
public static function getType ( ) { $ clsInfo = explode ( '\\' , get_called_class ( ) ) ; $ namespaceParts = array_slice ( $ clsInfo , 0 , - 1 ) ; $ namespaceParts [ ] = "Type" ; $ bareClassName = implode ( '' , array_slice ( $ clsInfo , - 1 ) ) ; return implode ( '\\' , $ namespaceParts ) . '\\' . $ bareClassName . 'AdminType' ; }
Auto - calculation of AdminType class from Element class name . Bare - bones reimplementation of deprecated upstream method .
19,795
private static function autoTemplate ( $ section , $ suffix = '.html.twig' ) { $ cls = get_called_class ( ) ; $ bundleName = str_replace ( '\\' , '' , preg_replace ( '/^([\w]+\\\\)*?(\w+\\\\\w+Bundle).*$/' , '\2' , $ cls ) ) ; $ elementName = implode ( '' , array_slice ( explode ( '\\' , $ cls ) , - 1 ) ) ; $ elementSnakeCase = strtolower ( preg_replace ( '/([^A-Z])([A-Z])/' , '\\1_\\2' , $ elementName ) ) ; return "{$bundleName}:{$section}:{$elementSnakeCase}{$suffix}" ; }
Auto - calculation of template reference from class name . Bare - bones reimplementation of deprecated upstream method .
19,796
protected function identifiersToArray ( ) : array { $ data = [ ] ; foreach ( $ this -> getIdentifiers ( ) as $ identifier ) { $ data [ ] = $ identifier -> toArray ( ) ; } return $ data ; }
Cast identifiers to an array
19,797
protected function instantiateQuery ( $ queryClass , $ apiQueryName ) { if ( ! is_a ( $ queryClass , static :: $ queryInterface , true ) ) { throw new RuntimeException ( "Query class '{$queryClass}' does not implements '" . static :: $ queryInterface . "' interface." ) ; } return new $ queryClass ( $ apiQueryName ) ; }
Method check query class and return new query object
19,798
public function withUri ( UriInterface $ uri , $ preserveHost = false ) { $ clone = clone $ this ; $ clone -> uri = $ uri ; if ( $ preserveHost ) { $ headerHost = $ this -> getHeader ( 'Host' ) ; if ( empty ( $ headerHost ) && $ uri -> getHost ( ) !== '' ) { return $ clone -> withHeader ( 'Host' , $ uri -> getHost ( ) ) ; } } return $ clone ; }
Renvoie une instance avec l URI fourni .
19,799
private function ip ( $ ip ) { return ( ( false === ip2long ( $ ip ) ) || ( long2ip ( ip2long ( $ ip ) ) !== $ ip ) ) ? false : true ; }
Check if is ip