idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
56,200
|
public static function boot ( ) { $ links = array_merge_recursive ( Blender :: $ sectionLinks , Blender :: $ pageLinks ) ; ob_start ( "ob_gzhandler" ) ; echo "<!DOCTYPE html>" ; echo "<html lang='pt-br'>" ; echo "<head>" ; echo "<title>" . Blender :: $ title . " | " . Blender :: $ subtitle . "</title>" ; echo "<!--Page metas ; echo "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">" ; echo "<meta charset='UTF-8'>" ; foreach ( Blender :: $ metaTags as $ key => $ value ) echo "<meta name=\"" . $ key . "\" content=\"" . $ value . "\">" ; echo "<!--Page stylesheets ; foreach ( $ links [ "css" ] as $ key => $ value ) { if ( preg_match ( "/\A(\/|\\|\Ahttp)/" , $ value ) ) echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . Blender :: $ siteUrl . "/public/css" . $ value . "\">" ; else echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"" . $ value . "\">" ; } echo "<!--Page fonts ; foreach ( $ links [ "font" ] as $ key => $ value ) { if ( preg_match ( "/(\A(\/|\\|\Ahttp)|)/" , $ value ) ) echo "<link rel=\"stylesheet\" href=\"" . Blender :: $ siteUrl . "public/fonts" . $ value . "\">" ; else echo "<link rel=\"stylesheet\" href=\"" . $ value . "\">" ; } echo "<!--Page favicon ; if ( Blender :: $ favicon != "" ) echo "<link rel=\"shortcut icon\" href=\"" . Blender :: $ siteUrl . "/public/img/" . Blender :: $ favicon . "\">" ; echo "</head>" ; echo "<body>" ; if ( ! Blender :: safeRequire ( "app/View/Layouts/" . Blender :: $ layout . ".php" ) ) Blender :: safeRequire ( "app/View/Layouts/" . Blender :: $ target . ".php" ) ; for ( $ i = 0 ; $ i < count ( Blender :: $ dump ) ; $ i ++ ) echo Blender :: $ dump [ $ i ] ; echo "<!-- Modals ; echo "<section>" ; foreach ( Blender :: $ modals as $ key => $ value ) require_once "app/view/modals/" . $ value . ".php" ; echo "</section>" ; echo "<!-- Scripts ; echo "<section>" ; foreach ( $ links [ "js" ] as $ key => $ value ) { if ( preg_match ( "/\A(\/|\\|\Ahttp)/" , $ value ) ) echo "<script type=\"text/javascript\" src=\"" . Blender :: $ siteUrl . "/public/js" . $ value . "\"></script>" ; else echo "<script type=\"text/javascript\" src=\"" . $ value . "\"></script>" ; } if ( count ( Blender :: $ code ) > 0 ) { echo "<script>" ; foreach ( Blender :: $ code as $ key => $ value ) echo $ value ; echo "</script>" ; } echo "</section>" ; echo "</body>" ; echo "</html>" ; ob_end_flush ( ) ; }
|
Boot up the entire page for visualization
|
56,201
|
public static function startClass ( string $ classpath , string $ namespace = "" ) { $ class = substr ( strrchr ( $ classpath , '/' ) , 1 ) ; $ class = str_replace ( ".class" , "" , $ class ) ; $ classpath = strtolower ( $ classpath ) ; if ( ! file_exists ( "app/" . $ classpath . ".php" ) ) return false ; require_once "app/" . $ classpath . ".php" ; if ( $ namespace != "" ) $ class = $ namespace . "\\" . $ class ; return new $ class ( ) ; }
|
path with class file name
|
56,202
|
private function passAsReference ( & $ target ) { foreach ( Blender :: $ sharedClasses as $ key => $ value ) { if ( ! property_exists ( $ target , $ key ) && $ value != $ target ) $ target -> $ key = $ value ; } }
|
Pass as reference the shared classes propertie to the target object
|
56,203
|
private function safeMethod ( & $ target , string $ method ) { if ( method_exists ( $ target , $ method ) ) { $ target -> $ method ( ) ; return true ; } else { return false ; } }
|
Safe method call if the name doesn t match won t throw an error
|
56,204
|
protected static function safeRequire ( string $ path ) { if ( file_exists ( Blender :: $ root . $ path ) ) { require_once Blender :: $ root . $ path ; return true ; } return false ; }
|
Safe require call won t generate error upon file not found
|
56,205
|
public static function resetLinks ( int $ target = 0 ) { switch ( $ target ) { case 1 : Blender :: $ sectionLinks = [ "js" => [ ] , "css" => [ ] , "font" => [ ] ] ; break ; case 2 : Blender :: $ pageLinks = [ "js" => [ ] , "css" => [ ] , "font" => [ ] ] ; break ; default : Blender :: $ sectionLinks = [ "js" => [ ] , "css" => [ ] , "font" => [ ] ] ; Blender :: $ pageLinks = [ "js" => [ ] , "css" => [ ] , "font" => [ ] ] ; break ; } }
|
Reset the modules
|
56,206
|
public function many ( $ property , $ entity = null ) { $ builder = new Many ( ) ; $ builder -> property ( $ property ) ; if ( $ entity ) { $ builder -> entity ( $ entity ) ; } return $ builder ; }
|
Start mapping a ReferenceMany reference . Entity is optional as ODM allows document type mixing .
|
56,207
|
protected function getCode ( $ Block ) { if ( ! isset ( $ Block [ 'element' ] [ 'text' ] [ 'text' ] ) ) { return null ; } $ text = $ Block [ 'element' ] [ 'text' ] [ 'text' ] ; if ( $ this -> pygments && $ language = $ this -> getLanguage ( $ Block ) ) { return $ this -> pygments -> highlight ( $ text , $ language ) ; } return htmlspecialchars ( $ text , ENT_NOQUOTES , 'UTF-8' ) ; }
|
Process code content
|
56,208
|
private static function _pushTime ( $ cmd ) { $ mt = microtime ( ) ; if ( $ cmd == static :: CMD_START ) { if ( static :: $ _running === true ) { return ; } static :: $ _running = true ; } else if ( $ cmd == static :: CMD_STOP ) { if ( static :: $ _running === false ) { return ; } static :: $ _running = false ; } else { return ; } if ( $ cmd === static :: CMD_START ) { $ mt = microtime ( ) ; } list ( $ usec , $ sec ) = explode ( ' ' , $ mt ) ; $ sec = ( int ) $ sec ; $ usec = ( float ) $ usec ; $ usec = ( int ) ( $ usec * static :: USECDIV ) ; $ time = array ( $ cmd => array ( 'sec' => $ sec , 'usec' => $ usec , ) , ) ; if ( $ cmd == static :: CMD_START ) { array_push ( static :: $ _queue , $ time ) ; } else if ( $ cmd == static :: CMD_STOP ) { $ count = count ( static :: $ _queue ) ; $ array = & static :: $ _queue [ $ count - 1 ] ; $ array = array_merge ( $ array , $ time ) ; } }
|
Add a time entry to the queue
|
56,209
|
public static function get ( $ format = self :: SECONDS ) { if ( static :: $ _running === true ) { static :: stop ( ) ; } $ sec = 0 ; $ usec = 0 ; foreach ( static :: $ _queue as $ time ) { $ start = $ time [ static :: CMD_START ] ; $ end = $ time [ static :: CMD_STOP ] ; $ sec_diff = $ end [ 'sec' ] - $ start [ 'sec' ] ; if ( $ sec_diff === 0 ) { $ usec += ( $ end [ 'usec' ] - $ start [ 'usec' ] ) ; } else { $ sec += $ sec_diff - 1 ; $ usec += ( static :: USECDIV - $ start [ 'usec' ] ) + $ end [ 'usec' ] ; } } if ( $ usec > static :: USECDIV ) { $ sec += ( int ) floor ( $ usec / static :: USECDIV ) ; $ usec = $ usec % static :: USECDIV ; } switch ( $ format ) { case static :: MICROSECONDS : return ( $ sec * static :: USECDIV ) + $ usec ; case static :: MILLISECONDS : return ( $ sec * 1000 ) + ( int ) round ( $ usec / 1000 , 0 ) ; case static :: SECONDS : default : return ( float ) $ sec + ( float ) ( $ usec / static :: USECDIV ) ; } }
|
Get time of execution from all queue entries
|
56,210
|
public static function getAverage ( $ format = self :: SECONDS ) { $ count = count ( static :: $ _queue ) ; $ sec = 0 ; $ usec = static :: get ( static :: MICROSECONDS ) ; if ( $ usec > static :: USECDIV ) { $ sec += ( int ) floor ( $ usec / static :: USECDIV ) ; $ usec = $ usec % static :: USECDIV ; } switch ( $ format ) { case static :: MICROSECONDS : $ value = ( $ sec * static :: USECDIV ) + $ usec ; return round ( $ value / $ count , 2 ) ; case static :: MILLISECONDS : $ value = ( $ sec * 1000 ) + ( int ) round ( $ usec / 1000 , 0 ) ; return round ( $ value / $ count , 2 ) ; case static :: SECONDS : default : $ value = ( float ) $ sec + ( float ) ( $ usec / static :: USECDIV ) ; return round ( $ value / $ count , 2 ) ; } }
|
Get the average time of execution from all queue entries
|
56,211
|
final public function import ( $ content ) { if ( ! ! filter_var ( $ content , FILTER_VALIDATE_URL ) || ! ! is_readable ( $ content ) ) { $ content = @ file_get_contents ( $ content , false , $ this -> context ) ; return ! ! $ this -> isStringHtml ( $ content ) ? $ content : False ; } return ! ! $ this -> isStringHtml ( $ content ) ? $ content : NULL ; }
|
Este metodo permite importar el contenido proveniente de una url path o texto .
|
56,212
|
protected function setOrderByFunction ( String $ query , String $ functionName ) : String { if ( $ functionName !== null && $ functionName !== '' ) { $ query = ' ORDER BY ' . $ functionName . '(' . $ query . ')' ; } return $ query ; }
|
This method is used to set a field on ORDER BY clause .
|
56,213
|
public function getProspectMapper ( ) { if ( $ this -> prospectMapper == null ) { $ this -> prospectMapper = $ this -> serviceLocator -> get ( 'playgroundflow_prospect_mapper' ) ; } return $ this -> prospectMapper ; }
|
Retrieve service manager instance
|
56,214
|
public function get ( $ language ) { if ( ! isset ( $ this -> alphabets [ $ language ] ) ) { return null ; } return $ this -> alphabets [ $ language ] ; }
|
Get alphabet for language
|
56,215
|
public function load ( $ filepath = null , $ preview = false ) { Environment :: increaseTimeLimitTo ( 3600 ) ; Environment :: increaseMemoryLimitTo ( '512M' ) ; $ this -> mappableFields_cache = $ this -> getMappableColumns ( ) ; return $ this -> processAll ( $ filepath , $ preview ) ; }
|
Start loading of data
|
56,216
|
public function scaffoldMappableFields ( $ includerelations = true ) { $ map = $ this -> getMappableFieldsForClass ( $ this -> objectClass ) ; if ( $ includerelations ) { if ( $ has_ones = singleton ( $ this -> objectClass ) -> hasOne ( ) ) { foreach ( $ has_ones as $ relationship => $ type ) { $ fields = $ this -> getMappableFieldsForClass ( $ type ) ; foreach ( $ fields as $ field => $ title ) { $ map [ $ relationship . "." . $ field ] = $ this -> formatMappingFieldLabel ( $ relationship , $ title ) ; } } } } return $ map ; }
|
Generate a field - label list of fields that data can be mapped into .
|
56,217
|
protected function getMappableFieldsForClass ( $ class ) { $ singleton = singleton ( $ class ) ; $ fields = ( array ) $ singleton -> fieldLabels ( false ) ; foreach ( $ fields as $ field => $ label ) { if ( ! $ singleton -> hasField ( $ field ) ) { unset ( $ fields [ $ field ] ) ; } } return $ fields ; }
|
Get the fields and labels for a given class
|
56,218
|
public function preprocessChecks ( ) { if ( ! $ this -> objectClass ) { user_error ( _t ( 'Consumer.NoObjectClass' , 'No objectClass set in the subclass' ) , E_USER_WARNING ) ; } if ( ! is_array ( $ this -> columnMap ) ) { user_error ( _t ( 'Consumer.NoColumnMap' , 'No columnMap set in the subclass' ) , E_USER_WARNING ) ; } if ( ! is_array ( $ this -> duplicateChecks ) ) { user_error ( _t ( 'Consumer.NoDuplicateChecks' , 'No duplicateChecks set in subclass' ) , E_USER_WARNING ) ; } }
|
Check that the class has the required settings
|
56,219
|
public function updateRecords ( array $ apidata , $ preview = false ) { if ( is_array ( $ apidata ) ) { $ this -> setSource ( new ArrayBulkLoaderSource ( $ apidata ) ) ; } $ this -> addNewRecords = false ; $ this -> preprocessChecks ( ) ; return $ this -> load ( null , $ preview ) ; }
|
Update the dataobject with data from the external API
|
56,220
|
public function deleteManyRecords ( array $ apidata , $ preview = false ) { if ( is_array ( $ apidata ) ) { $ this -> setSource ( new ArrayBulkLoaderSource ( $ apidata ) ) ; } $ this -> preprocessChecks ( ) ; $ this -> mappableFields_cache = $ this -> getMappableColumns ( ) ; $ results = new BulkLoaderResult ( ) ; $ iterator = $ this -> getSource ( ) -> getIterator ( ) ; foreach ( $ iterator as $ record ) { $ record = $ this -> columnMapRecord ( $ record ) ; $ modelClass = $ this -> objectClass ; $ placeholder = new $ modelClass ( ) ; foreach ( $ this -> mappableFields_cache as $ field => $ label ) { if ( ! isset ( $ record [ $ field ] ) || empty ( $ record [ $ field ] ) ) { continue ; } $ this -> transformField ( $ placeholder , $ field , $ record [ $ field ] ) ; } $ data = $ placeholder -> getQueriedDatabaseFields ( ) ; $ existing = $ this -> findExistingObject ( $ data ) ; if ( $ existing ) { $ results -> addDeleted ( $ existing , 'Record deleted' ) ; if ( ! $ preview ) { $ existing -> delete ( ) ; } } else { $ results -> addSkipped ( 'Record not deleted' ) ; } } return $ results ; }
|
Delete dataobjects that match to the API data
|
56,221
|
public function append ( $ bean ) { $ this -> validate ( $ bean ) ; parent :: offsetSet ( $ bean -> getIndex ( ) , $ bean ) ; $ this -> rewind ( ) ; }
|
Appends the value
|
56,222
|
public function diff ( AbstractCollection $ collection ) { $ newCollection = $ this -> newInstance ( ) ; $ this -> each ( function ( AbstractBean $ collectable ) use ( $ newCollection , $ collection ) { if ( ! $ collection -> containsIndex ( $ collectable -> getIndex ( ) ) ) { $ newCollection -> append ( $ collectable ) ; } } ) ; return $ newCollection ; }
|
Diff two Collections
|
56,223
|
private function _fill ( ) { if ( empty ( $ this -> db ) ) return false ; $ sql = ( string ) "SHOW VARIABLES" ; $ res = $ this -> db -> query ( ( string ) $ sql ) ; if ( ! $ res ) return false ; $ data = $ this -> db -> fetch_assoc_list ( $ res ) ; if ( ! empty ( $ data ) ) { foreach ( $ data as $ variable ) { $ this -> $ variable [ ( string ) 'Variable_name' ] = ( string ) $ variable [ 'Value' ] ; } $ this -> db -> free ( $ res ) ; } unset ( $ this -> db , $ data , $ variable ) ; return true ; }
|
method that gets all the mysql database settings an fills them into properties of this object
|
56,224
|
public static function setSigningKey ( $ keyPairId , $ signingKey , $ isFile = true ) { self :: $ __signingKeyPairId = $ keyPairId ; if ( ( self :: $ __signingKeyResource = openssl_pkey_get_private ( $ isFile ? fgc ( $ signingKey ) : $ signingKey ) ) !== false ) { return true ; } self :: __triggerError ( 'S3::setSigningKey(): Unable to open load private key: ' . $ signingKey , __FILE__ , __LINE__ ) ; return false ; }
|
Set signing key
|
56,225
|
public static function listBuckets ( $ detailed = false ) { $ rest = new S3Request ( 'GET' , '' , '' , self :: $ endpoint ) ; $ rest = $ rest -> getResponse ( ) ; if ( $ rest -> error === false && $ rest -> code !== 200 ) { $ rest -> error = array ( 'code' => $ rest -> code , 'message' => 'Unexpected HTTP status' ) ; } if ( $ rest -> error !== false ) { self :: __triggerError ( sprintf ( "S3::listBuckets(): [%s] %s" , $ rest -> error [ 'code' ] , $ rest -> error [ 'message' ] ) , __FILE__ , __LINE__ ) ; return false ; } $ results = array ( ) ; if ( ! isset ( $ rest -> body -> Buckets ) ) { return $ results ; } if ( $ detailed ) { if ( isset ( $ rest -> body -> Owner , $ rest -> body -> Owner -> ID , $ rest -> body -> Owner -> DisplayName ) ) { $ results [ 'owner' ] = array ( 'id' => ( string ) $ rest -> body -> Owner -> ID , 'name' => ( string ) $ rest -> body -> Owner -> ID ) ; } $ results [ 'buckets' ] = array ( ) ; foreach ( $ rest -> body -> Buckets -> Bucket as $ b ) { $ results [ 'buckets' ] [ ] = array ( 'name' => ( string ) $ b -> Name , 'time' => strtotime ( ( string ) $ b -> CreationDate ) ) ; } } else { foreach ( $ rest -> body -> Buckets -> Bucket as $ b ) { $ results [ ] = ( string ) $ b -> Name ; } } return $ results ; }
|
Get a list of buckets
|
56,226
|
public function resolve ( $ name ) { if ( ! isset ( self :: $ resources [ $ name ] ) ) { throw new Exception ( "[$name] is not a known resource." ) ; } return isAke ( self :: $ resources , $ name ) ; }
|
Attempts to return the named resource to a valid class name .
|
56,227
|
public function getDefaultValue ( ) : Node \ Expr { $ factory = new BuilderFactory ( ) ; if ( $ this -> nullable || $ this -> mixed || $ this -> class ) { return $ factory -> val ( null ) ; } switch ( $ this -> name ) { case 'array' : return $ factory -> val ( [ ] ) ; case 'bool' : return $ factory -> val ( false ) ; case 'float' : return $ factory -> val ( 0.0 ) ; case 'int' : return $ factory -> val ( 0 ) ; case 'string' : return $ factory -> val ( '' ) ; default : return $ factory -> val ( null ) ; } }
|
Returns default value for this type
|
56,228
|
public function toTypeHint ( ) : string { if ( $ this -> mixed ) { throw new LogicException ( 'Cannot make typehint for mixed type' ) ; } if ( $ this -> nullable ) { return '?' . $ this -> name ; } return $ this -> name ; }
|
Makes typehint from Type
|
56,229
|
public static function add ( $ element , $ location = [ ] ) { if ( ! isset ( self :: $ _elements [ $ element ] ) ) { self :: $ _elements [ $ element ] = [ ] ; } if ( empty ( $ location ) ) { $ default_location = self :: get_default_location ( $ element ) ; if ( $ default_location ) { self :: $ _elements [ $ element ] [ ] = [ $ default_location ] ; } else { throw new \ Exception ( 'Element ' . $ element . ' does not have a default location. You must supply the $location parameter.' ) ; } } else { self :: $ _elements [ $ element ] [ ] = [ $ location ] ; } add_action ( 'init' , [ __CLASS__ , 'register_elements' ] ) ; }
|
Init . Takes the location and the elements to register in that location .
|
56,230
|
public static function register_elements ( ) { foreach ( self :: $ _elements as $ element => $ locations ) { $ class = self :: get_element_class_name ( $ element ) ; if ( method_exists ( $ class , 'init' ) ) { call_user_func ( [ $ class , 'init' ] , $ locations ) ; } } }
|
Register required elements .
|
56,231
|
public static function options_page ( $ sub_pages = [ ] ) { if ( function_exists ( 'acf_add_options_page' ) ) { acf_add_options_page ( [ 'page_title' => 'Options' , 'menu_title' => 'Options' , 'menu_slug' => self :: OPTIONS_PAGE , 'capability' => 'edit_posts' , 'redirect' => false , 'position' => 4 , ] ) ; foreach ( $ sub_pages as $ sub_page ) { switch ( $ sub_page ) { case self :: GENERAL_PAGE : acf_add_options_sub_page ( [ 'page_title' => 'General Options' , 'menu_title' => 'General' , 'parent_slug' => self :: OPTIONS_PAGE , 'menu_slug' => self :: GENERAL_PAGE , ] ) ; break ; default : continue ; } } } }
|
Set - up an options page and some pre - defined sub pages .
|
56,232
|
public function setImageFile ( File $ imageFile = null ) { $ this -> imageFile = $ imageFile ; if ( $ imageFile ) { $ this -> modified = new \ DateTimeImmutable ( ) ; } return $ this ; }
|
imageFile property is not persisted!
|
56,233
|
protected function registerMigration ( ) { $ this -> app -> singleton ( 'orchestra.publisher.migrate' , function ( Application $ app ) { $ app -> make ( 'migration.repository' ) ; return new MigrateManager ( $ app , $ app -> make ( 'migrator' ) ) ; } ) ; }
|
Register the service provider for Orchestra Platform migrator .
|
56,234
|
protected function registerAssetPublisher ( ) { $ this -> app -> singleton ( 'orchestra.publisher.asset' , function ( Application $ app ) { return new AssetManager ( $ app , $ app -> make ( 'asset.publisher' ) ) ; } ) ; }
|
Register the service provider for Orchestra Platform asset publisher .
|
56,235
|
public function create ( $ persisted = true ) { return Phactory :: createBlueprint ( $ this -> name , $ this -> type , $ this -> override , $ persisted ) ; }
|
Creates the relationship object
|
56,236
|
public function performAccessTokenFlow ( $ directResponse = true , Array $ input = array ( ) ) { $ authServer = $ this -> getOAuth ( ) -> getAuthServer ( ) ; try { if ( empty ( $ input ) ) { $ input = $ this -> getRequest ( ) -> all ( ) ; } if ( $ directResponse ) { return $ this -> resourceJson ( $ authServer -> issueAccessToken ( $ input ) ) ; } return $ authServer -> issueAccessToken ( $ input ) ; } catch ( ClientException $ e ) { $ response = array ( 'message' => $ authServer -> getExceptionType ( $ e -> getCode ( ) ) , 'description' => $ e -> getMessage ( ) ) ; $ error = $ authServer -> getExceptionType ( $ e -> getCode ( ) ) ; $ headers = $ authServer -> getExceptionHttpHeaders ( $ error ) ; if ( $ directResponse ) { return $ this -> resourceJson ( $ response , self :: $ exceptionHttpStatusCodes [ $ error ] , $ headers ) ; } $ response [ 'status' ] = self :: $ exceptionHttpStatusCodes [ $ error ] ; $ response [ 'headers' ] = $ headers ; return $ response ; } catch ( Exception $ e ) { $ response = array ( 'message' => 'undefined_error' , 'description' => $ e -> getMessage ( ) ) ; if ( $ directResponse ) { return $ this -> resourceJson ( $ response , 500 ) ; } $ response [ 'status' ] = 500 ; return $ response ; } }
|
Perform the access token flow
|
56,237
|
public function validateAccessToken ( Array $ scopes = array ( ) ) { try { $ this -> getResource ( ) -> isValid ( $ this -> getConfig ( 'oauth2.http_headers_only' ) ) ; } catch ( InvalidAccessTokenException $ e ) { return $ this -> resourceJson ( array ( 'message' => 'forbidden' , 'description' => $ e -> getMessage ( ) , ) , 403 ) ; } if ( ! empty ( $ scopes ) ) { foreach ( $ scopes as $ item ) { if ( ! $ this -> getResource ( ) -> hasScope ( $ item ) ) { return $ this -> resourceJson ( array ( 'message' => 'forbidden' , 'description' => 'Only access token with scope ' . $ item . ' can be use in this endpoint' , ) , 403 ) ; } } } }
|
Validate OAuth token
|
56,238
|
public function isValidMD5 ( ) { $ client = $ this -> getClient ( ) ; $ clientSecret = '' ; if ( ! is_null ( $ client ) ) { $ clientSecret = $ client -> secret ; } unset ( $ client ) ; $ md5 = $ this -> getRequest ( ) -> header ( 'CONTENT_MD5' ) ; if ( $ this -> getRequest ( ) -> isJson ( ) ) { $ content = $ this -> getRequest ( ) -> getContent ( ) ; if ( empty ( $ md5 ) and empty ( $ content ) ) { return true ; } return ( md5 ( $ content . $ clientSecret ) == $ md5 ) ; } $ input = $ this -> getRequest ( ) -> all ( ) ; if ( ! empty ( $ input ) ) { foreach ( $ input as $ key => $ item ) { if ( str_contains ( $ key , '/' ) ) { unset ( $ input [ $ key ] ) ; } } } if ( empty ( $ md5 ) and empty ( $ input ) ) { return true ; } return ( md5 ( http_build_query ( $ input ) . $ clientSecret ) == $ md5 ) ; }
|
Check client content MD5 .
|
56,239
|
public function checkRequestLimit ( ) { $ isLimitReached = false ; $ client = $ this -> getClient ( ) ; if ( ! is_null ( $ client ) ) { $ currentTotalRequest = 1 ; $ currentTime = time ( ) ; $ requestLimitUntil = $ currentTime ; $ requestLimitUntil = strtotime ( $ client -> request_limit_until ) ; if ( $ requestLimitUntil < 0 ) { $ requestLimitUntil = $ currentTime ; } if ( $ currentTime <= $ requestLimitUntil ) { $ currentTotalRequest = $ client -> current_total_request + 1 ; if ( $ currentTotalRequest > $ client -> request_limit ) { $ isLimitReached = true ; } } if ( $ currentTime > $ requestLimitUntil ) { $ dateTime = new DateTime ( '+1 hour' ) ; $ requestLimitUntil = $ dateTime -> getTimestamp ( ) ; unset ( $ dateTime ) ; } if ( ! $ isLimitReached ) { $ dateTime = new DateTime ( ) ; $ client -> current_total_request = $ currentTotalRequest ; $ client -> request_limit_until = $ dateTime -> setTimestamp ( $ requestLimitUntil ) -> format ( 'Y-m-d H:i:s' ) ; $ client -> last_request_at = $ dateTime -> setTimestamp ( $ currentTime ) -> format ( 'Y-m-d H:i:s' ) ; $ client -> save ( ) ; unset ( $ dateTime ) ; } } unset ( $ client ) ; return $ isLimitReached ; }
|
Check client request limit and update .
|
56,240
|
private function getRequestLimitHeader ( ) { $ headers = array ( ) ; $ client = $ this -> getClient ( ) ; if ( ! is_null ( $ client ) ) { $ headers [ 'X-Rate-Limit-Limit' ] = $ client -> request_limit ; $ headers [ 'X-Rate-Limit-Remaining' ] = $ client -> request_limit - $ client -> current_total_request ; $ headers [ 'X-Rate-Limit-Reset' ] = strtotime ( $ client -> request_limit_until ) - time ( ) ; } unset ( $ client ) ; return $ headers ; }
|
Return request limit header .
|
56,241
|
private function identifyClientFromRequest ( ) { $ clientId = $ this -> getRequest ( ) -> input ( 'client_id' , '' ) ; $ clientSecret = $ this -> getRequest ( ) -> input ( 'client_secret' , null ) ; $ redirectUri = $ this -> getRequest ( ) -> input ( 'redirect_uri' , null ) ; try { $ this -> accessToken = $ this -> getResource ( ) -> determineAccessToken ( ) ; $ sessionRepository = new FluentSession ( ) ; $ sesion = $ sessionRepository -> validateAccessToken ( $ this -> accessToken ) ; if ( $ sesion !== false ) { $ clientId = $ sesion [ 'client_id' ] ; $ clientSecret = $ sesion [ 'client_secret' ] ; } unset ( $ sessionRepository ) ; unset ( $ sesion ) ; } catch ( InvalidAccessTokenException $ e ) { } if ( ! empty ( $ clientId ) ) { $ clientRepository = new FluentClient ( ) ; $ client = $ clientRepository -> getClient ( $ clientId , $ clientSecret , $ redirectUri ) ; if ( $ client !== false ) { $ client [ 'id' ] = $ clientId ; $ client [ 'secret' ] = $ client [ 'client_secret' ] ; unset ( $ client [ 'client_id' ] ) ; unset ( $ client [ 'client_secret' ] ) ; unset ( $ client [ 'redirect_uri' ] ) ; unset ( $ client [ 'metadata' ] ) ; $ this -> client = new OauthClient ( ) ; $ this -> client -> fill ( $ client ) ; $ this -> client -> exists = true ; $ this -> client -> syncOriginal ( ) ; } unset ( $ client ) ; unset ( $ clientRepository ) ; } unset ( $ clientId ) ; unset ( $ clientSecret ) ; unset ( $ redirectUri ) ; }
|
Identify client identifed from current request .
|
56,242
|
private function initResolvers ( ) { $ this -> groupOptionsResolver = new OptionsResolver ( ) ; $ this -> groupOptionsResolver -> setDefaults ( [ 'name' => null , 'label' => null , 'icon' => null , 'position' => 1 , 'domain' => 'messages' , 'route' => null , ] ) -> setAllowedTypes ( 'name' , 'string' ) -> setAllowedTypes ( 'label' , 'string' ) -> setAllowedTypes ( 'icon' , 'string' ) -> setAllowedTypes ( 'position' , 'int' ) -> setAllowedTypes ( 'domain' , 'string' ) -> setAllowedTypes ( 'route' , [ 'string' , 'null' ] ) ; $ this -> entryOptionsResolver = new OptionsResolver ( ) ; $ this -> entryOptionsResolver -> setDefaults ( [ 'name' => null , 'label' => null , 'route' => null , 'position' => 1 , 'domain' => 'messages' , 'resource' => null , ] ) -> setAllowedTypes ( 'name' , 'string' ) -> setAllowedTypes ( 'label' , 'string' ) -> setAllowedTypes ( 'route' , 'string' ) -> setAllowedTypes ( 'position' , 'int' ) -> setAllowedTypes ( 'domain' , 'string' ) -> setAllowedTypes ( 'resource' , 'string' ) ; }
|
Initializes the options resolvers .
|
56,243
|
public function createGroup ( array $ options ) { if ( $ this -> prepared ) { throw new \ RuntimeException ( 'MenuPool has been prepared and can\'t receive new groups.' ) ; } $ group = new MenuGroup ( $ this -> groupOptionsResolver -> resolve ( $ options ) ) ; $ this -> addGroup ( $ group ) ; }
|
Creates a menu group .
|
56,244
|
public function createEntry ( $ group_name , array $ options ) { if ( ! $ this -> hasGroup ( $ group_name ) ) { throw new \ RuntimeException ( 'Menu Group "' . $ group_name . '" not found.' ) ; } $ entry = new MenuEntry ( $ this -> entryOptionsResolver -> resolve ( $ options ) ) ; $ group = $ this -> getGroup ( $ group_name ) ; $ group -> addEntry ( $ entry ) ; }
|
Creates a menu entry .
|
56,245
|
private function addGroup ( MenuGroup $ group ) { if ( ! $ this -> hasGroup ( $ group -> getName ( ) ) ) { $ this -> groups [ $ group -> getName ( ) ] = $ group ; } }
|
Add group to menu
|
56,246
|
public function prepare ( ) { if ( $ this -> prepared ) { return ; } usort ( $ this -> groups , function ( MenuGroup $ a , MenuGroup $ b ) { if ( $ a -> getPosition ( ) == $ b -> getPosition ( ) ) { return 0 ; } return $ a -> getPosition ( ) > $ b -> getPosition ( ) ? 1 : - 1 ; } ) ; foreach ( $ this -> groups as $ group ) { $ group -> prepare ( ) ; } $ this -> prepared = true ; }
|
Prepares the pool for rendering .
|
56,247
|
public static function getNotDeleted ( $ objects ) { if ( null === $ objects ) { return null ; } if ( ! $ objects instanceof Collection ) { $ objects = new ArrayCollection ( $ objects ) ; } foreach ( $ objects as $ object ) { $ functionDeletedOld = [ $ object , "getDeleted" ] ; $ functionDeletedNew = [ $ object , "isDeleted" ] ; if ( true === is_callable ( $ functionDeletedOld ) && true === $ object -> getDeleted ( ) ) { $ objects -> removeElement ( $ object ) ; } elseif ( true === is_callable ( $ functionDeletedNew ) && true === $ object -> isDeleted ( ) ) { $ objects -> removeElement ( $ object ) ; } } return $ objects ; }
|
Get Not deleted
|
56,248
|
public static function delete ( $ object ) { if ( null === $ object ) { throw new \ LogicException ( "No object" ) ; } $ setterDelete = [ $ object , "setDeleted" ] ; if ( false === is_callable ( $ setterDelete ) ) { throw new \ LogicException ( sprintf ( "%s is not softdeletable" , get_class ( $ object ) ) ) ; } $ object -> setDeleted ( true ) ; $ oReflectionClass = new \ ReflectionClass ( $ object ) ; foreach ( $ oReflectionClass -> getProperties ( ) as $ property ) { $ property -> setAccessible ( true ) ; $ propertyValue = $ property -> getValue ( $ object ) ; if ( $ propertyValue instanceof Collection || true === is_array ( $ propertyValue ) ) { foreach ( $ propertyValue as $ propertyValueRelation ) { $ setterDelete = [ $ propertyValueRelation , "setDeleted" ] ; if ( true === is_callable ( $ setterDelete ) ) { $ propertyValueRelation -> setDeleted ( true ) ; } } } } }
|
Soft delete given object and relations
|
56,249
|
private function extract_data_urls ( $ css ) { $ max_index = strlen ( $ css ) - 1 ; $ append_index = $ index = $ last_index = $ offset = 0 ; $ sb = array ( ) ; $ pattern = '/url\(\s*(["\']?)data\:/i' ; while ( preg_match ( $ pattern , $ css , $ m , 0 , $ offset ) ) { $ index = $ this -> index_of ( $ css , $ m [ 0 ] , $ offset ) ; $ last_index = $ index + strlen ( $ m [ 0 ] ) ; $ start_index = $ index + 4 ; $ end_index = $ last_index - 1 ; $ terminator = $ m [ 1 ] ; $ found_terminator = FALSE ; if ( strlen ( $ terminator ) === 0 ) { $ terminator = ')' ; } while ( $ found_terminator === FALSE && $ end_index + 1 <= $ max_index ) { $ end_index = $ this -> index_of ( $ css , $ terminator , $ end_index + 1 ) ; if ( $ end_index > 0 && substr ( $ css , $ end_index - 1 , 1 ) !== '\\' ) { $ found_terminator = TRUE ; if ( ')' != $ terminator ) { $ end_index = $ this -> index_of ( $ css , ')' , $ end_index ) ; } } } $ sb [ ] = $ this -> substring ( $ css , $ append_index , $ index ) ; if ( $ found_terminator ) { $ token = $ this -> substring ( $ css , $ start_index , $ end_index ) ; $ token = preg_replace ( '/\s+/' , '' , $ token ) ; $ this -> preserved_tokens [ ] = $ token ; $ preserver = 'url(' . self :: TOKEN . ( count ( $ this -> preserved_tokens ) - 1 ) . ' )' ; $ sb [ ] = $ preserver ; $ append_index = $ end_index + 1 ; } else { $ sb [ ] = $ this -> substring ( $ css , $ index , $ last_index ) ; $ append_index = $ last_index ; } $ offset = $ last_index ; } $ sb [ ] = $ this -> substring ( $ css , $ append_index ) ; return implode ( '' , $ sb ) ; }
|
Utility method to replace all data urls with tokens before we start compressing to avoid performance issues running some of the subsequent regexes against large strings chunks .
|
56,250
|
public static function get_filename ( $ name = '' ) { $ name = str_replace ( '.svg' , '' , $ name ) ; $ filename = dirname ( dirname ( __DIR__ ) ) . "/svg/$name.svg" ; if ( file_exists ( $ filename ) ) { return $ filename ; } return '' ; }
|
Gets the full file path of the filenamename passed in .
|
56,251
|
public static function get ( $ name = '' ) { $ name = self :: sanitize ( $ name ) ; $ filename = self :: get_filename ( $ name ) ; return $ filename ? @ file_get_contents ( $ filename ) : '' ; }
|
Retreives an SVG from a filename .
|
56,252
|
public function transform ( $ value ) { $ parts = array ( 'date' => null , 'time' => null , ) ; if ( $ value ) { $ parts [ 'date' ] = new \ DateTime ( $ value -> format ( 'Y-m-d' ) ) ; $ parts [ 'time' ] = new \ DateTime ( $ value -> format ( 'H:i:s' ) ) ; } return $ parts ; }
|
Transforms a DateTime into an array .
|
56,253
|
public function reverseTransform ( $ value ) { if ( $ value [ 'date' ] && $ value [ 'time' ] ) { return new \ DateTime ( sprintf ( '%s %s' , $ value [ 'date' ] -> format ( 'Y-m-d' ) , $ value [ 'time' ] -> format ( 'H:i:s' ) ) ) ; } if ( $ value [ 'date' ] ) { return new \ DateTime ( sprintf ( '%s' , $ value [ 'date' ] -> format ( 'Y-m-d' ) ) ) ; } if ( $ value [ 'time' ] ) { return new \ DateTime ( sprintf ( '%s' , $ value [ 'time' ] -> format ( 'H:i:s' ) ) ) ; } return null ; }
|
Transforms an array into a DateTime .
|
56,254
|
protected function getPluginNames ( $ makefile ) { $ mkdata = file_get_contents ( $ makefile ) ; preg_match ( '/bootstrap(\:|\/js\/\*\.js: js\/\*\.js)\s?\n(\n|.)*?((cat\s)(?P<files>.*?))\s>/i' , $ mkdata , $ matches ) ; return array_map ( function ( $ value ) { return preg_replace ( '/(js\/bootstrap-([\w_-]+)\.js)/' , '\2' , $ value ) ; } , preg_split ( '/\s+/' , $ matches [ 'files' ] ) ) ; }
|
Get the plugin names from the makefile .
|
56,255
|
private function setCurrentVersion ( ) { if ( $ this -> getCurrentVersion ( ) !== null ) { update_option ( $ this -> getVersionOptionKey ( ) , $ this -> getVersion ( ) ) ; } else { add_option ( $ this -> getVersionOptionKey ( ) , $ this -> getVersion ( ) ) ; } return $ this ; }
|
Set the current installed database version .
|
56,256
|
public function synchronize ( $ lang , $ area ) { $ locale = $ lang -> code ; $ translations = $ this -> translationsFromFiles ( $ locale ) ; if ( empty ( $ translations ) ) { $ translations = $ this -> translationsFromFiles ( lang ( ) -> code ) ; } $ items = Translation :: where ( 'locale' , $ locale ) -> where ( 'area' , $ area ) -> get ( ) ; $ grouped = [ ] ; foreach ( $ items as $ item ) { $ grouped [ $ item -> group ] [ $ item -> key ] = $ item -> value ; } $ deletes = [ ] ; foreach ( $ grouped as $ name => $ group ) { if ( ! isset ( $ translations [ $ name ] ) ) { continue ; } $ deleted = array_diff ( $ group , $ translations [ $ name ] ) ; if ( ! empty ( $ deleted ) ) { $ deletes [ $ name ] = $ deleted ; } } $ this -> delete ( $ lang -> id , $ area , $ deletes ) ; $ this -> insert ( $ locale , $ area , $ translations ) ; }
|
synchronize translations between database and translation files
|
56,257
|
public function translationsFromFiles ( $ locale ) { $ grouped = [ ] ; foreach ( $ this -> hints as $ name => $ hint ) { $ languageDirectory = $ hint . DIRECTORY_SEPARATOR . $ locale ; if ( ! is_dir ( $ languageDirectory ) ) { continue ; } $ files = $ this -> filesystem -> allFiles ( $ languageDirectory ) ; foreach ( $ files as $ filename ) { $ file = str_replace ( '.' . $ filename -> getExtension ( ) , '' , $ filename -> getFilename ( ) ) ; $ translations = array_dot ( require $ filename -> getRealPath ( ) ) ; foreach ( $ translations as $ key => $ translation ) { $ grouped [ $ name ] [ $ file . '.' . $ key ] = $ translation ; } } } return $ grouped ; }
|
gets translations from files
|
56,258
|
protected function translations ( array $ files = array ( ) ) { $ return = [ ] ; foreach ( $ files as $ file ) { $ translation = $ this -> getStringsBetween ( $ file -> getContents ( ) , 'trans(\'' , "')" ) ; $ translation = array_filter ( $ translation , function ( $ element ) { if ( str_contains ( $ element , ', {' ) ) { return false ; } return $ element ; } ) ; $ translationWithParams = $ this -> getStringsBetween ( $ file -> getContents ( ) , 'trans(\'' , "', {" ) ; $ translation = array_merge ( $ translation , $ translationWithParams ) ; $ return = array_merge ( $ return , $ translation ) ; } return $ return ; }
|
get translations from source files
|
56,259
|
protected function getStringsBetween ( $ string , $ start , $ end ) { $ pattern = sprintf ( '/%s(.*?)%s/' , preg_quote ( $ start ) , preg_quote ( $ end ) ) ; preg_match_all ( $ pattern , $ string , $ matches ) ; return $ matches [ 1 ] ; }
|
search all occurences between strings
|
56,260
|
public static function encrypt ( $ value ) { $ iv = mcrypt_create_iv ( static :: iv_size ( ) , static :: randomizer ( ) ) ; $ value = static :: pad ( $ value ) ; $ value = mcrypt_encrypt ( static :: $ cipher , static :: key ( ) , $ value , static :: $ mode , $ iv ) ; return base64_encode ( $ iv . $ value ) ; }
|
Encrypt a string using Mcrypt .
|
56,261
|
public static function decrypt ( $ value ) { $ value = base64_decode ( $ value ) ; $ iv = substr ( $ value , 0 , static :: iv_size ( ) ) ; $ value = substr ( $ value , static :: iv_size ( ) ) ; $ key = static :: key ( ) ; $ value = mcrypt_decrypt ( static :: $ cipher , $ key , $ value , static :: $ mode , $ iv ) ; return static :: unpad ( $ value ) ; }
|
Decrypt a string using Mcrypt .
|
56,262
|
protected static function pad ( $ value ) { $ pad = static :: $ block - ( Inflector :: length ( $ value ) % static :: $ block ) ; return $ value .= str_repeat ( chr ( $ pad ) , $ pad ) ; }
|
Add PKCS7 compatible padding on the given value .
|
56,263
|
protected static function unpad ( $ value ) { $ pad = ord ( $ value [ ( $ length = Inflector :: length ( $ value ) ) - 1 ] ) ; if ( $ pad and $ pad < static :: $ block ) { if ( preg_match ( '/' . chr ( $ pad ) . '{' . $ pad . '}$/' , $ value ) ) { return substr ( $ value , 0 , $ length - $ pad ) ; } else { throw new Exception ( "Decryption error. Padding is invalid." ) ; } } return $ value ; }
|
Remove the PKCS7 compatible padding from the given value .
|
56,264
|
public function check ( array $ required , array $ values ) { foreach ( $ required as $ key ) { if ( ! array_key_exists ( $ key , $ values ) ) { return false ; } } return true ; }
|
Check required values .
|
56,265
|
public function populate ( array $ vars ) { foreach ( $ vars as $ key => $ value ) { if ( false === getenv ( $ key ) ) { $ _ENV [ $ key ] = $ value ; $ _SERVER [ $ key ] = $ value ; putenv ( "{$key}={$value}" ) ; } } }
|
Populate environment vars .
|
56,266
|
protected function getFile ( $ location ) { if ( $ location == 'production' && file_exists ( $ envFile = $ this -> getPath ( ) . ".env.php" ) ) { return $ envFile ; } return $ this -> getPath ( ) . ".env.{$location}.php" ; }
|
Return the . env file path .
|
56,267
|
public function getValue ( ) { $ options = $ this -> options ( ) ; if ( $ this -> multiSelected ( ) ) { $ values = array ( ) ; foreach ( $ this -> selected ( ) as $ val ) { $ values [ ] = $ options [ $ val ] ; } return $ values ; } else { return $ options [ $ this -> selected ( ) ] ; } }
|
Get the selected options .
|
56,268
|
public function isSelected ( $ val ) { if ( $ this -> isMulti ( ) ) { return in_array ( $ val , $ this -> getValue ( ) ) ; } else { return $ val === $ this -> getValue ( ) ; } }
|
Check if the given value is selected .
|
56,269
|
public function update ( ) { $ this -> left = $ this -> x ; $ this -> right = $ this -> x + $ this -> width ; $ this -> top = $ this -> y ; $ this -> bottom = $ this -> y + $ this -> height ; }
|
Update the left right top and bottom coordinates .
|
56,270
|
public function intersects ( Box $ box , $ strict = true ) : bool { $ class = Comparators :: class ; $ comparator = $ strict ? array ( $ class , 'strictComparator' ) : array ( $ class , 'nonStrictComparator' ) ; return $ comparator ( $ this -> getLeft ( ) , $ box -> getRight ( ) ) && $ comparator ( $ box -> getLeft ( ) , $ this -> getRight ( ) ) && $ comparator ( $ this -> getTop ( ) , $ box -> getBottom ( ) ) && $ comparator ( $ box -> getTop ( ) , $ this -> getBottom ( ) ) ; }
|
Detect box collision This algorithm only works with Axis - Aligned boxes!
|
56,271
|
public function getServiceBroker ( ) { if ( ! $ this -> serviceBroker ) { $ locator = $ this -> getLocator ( ) ; $ this -> setServiceBroker ( $ locator -> get ( 'ServiceBroker' ) ) ; } return $ this -> serviceBroker ; }
|
Get service broker instance
|
56,272
|
protected function getLocator ( ) { if ( $ this -> locator ) { return $ this -> locator ; } $ controller = $ this -> getController ( ) ; if ( ! $ controller instanceof ServiceLocatorAwareInterface ) { throw new \ Exception ( 'ServiceBroker plugin requires controller implements ServiceLocatorAwareInterface' ) ; } $ locator = $ controller -> getServiceLocator ( ) ; if ( ! $ locator instanceof ServiceLocatorInterface ) { throw new \ Exception ( 'ServiceBroker plugin requires controller implements ServiceLocatorInterface' ) ; } $ this -> locator = $ locator ; return $ this -> locator ; }
|
Get the locator
|
56,273
|
protected function loadIntermediateContainerInstance ( $ containerClass ) : ContainerInterface { $ arguments = $ this -> getConfiguration ( ) [ AbstractFileConfiguration :: SERVICE_INIT_ARGUMENTS ] ?? NULL ; $ cfg = $ this -> getConfiguration ( ) [ AbstractFileConfiguration :: SERVICE_INIT_CONFIGURATION ] ?? NULL ; try { $ instance = $ this -> serviceManager -> makeServiceInstance ( $ containerClass , $ arguments , $ cfg ) ; if ( $ instance instanceof ContainerInterface ) return $ instance ; throw new ServiceException ( "Class $containerClass does not implement " . ContainerInterface :: class , 893 ) ; } catch ( \ Throwable $ e ) { $ e = new BadContainerException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; $ e -> setServiceName ( $ this -> serviceName ) ; $ e -> setContainer ( NULL ) ; throw $ e ; } }
|
Loads the container from configuration that is able to create the final service instance .
|
56,274
|
protected function loadInstanceFromContainer ( $ containerClass ) { $ this -> containerInstance = $ this -> loadIntermediateContainerInstance ( $ containerClass ) ; try { $ this -> instance = $ this -> containerInstance -> getInstance ( ) ; } catch ( BadConfigurationException $ e ) { $ e = new ServiceException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; $ e -> setServiceName ( $ this -> serviceName ) ; throw $ e ; } }
|
Loads the service instance by creating an intermediate container and get its service instance
|
56,275
|
protected function loadInstanceFromClass ( $ class ) { $ arguments = $ this -> getConfiguration ( ) [ AbstractFileConfiguration :: SERVICE_INIT_ARGUMENTS ] ?? NULL ; $ config = $ this -> getConfiguration ( ) [ AbstractFileConfiguration :: SERVICE_INIT_CONFIGURATION ] ?? NULL ; $ this -> instance = $ this -> serviceManager -> makeServiceInstance ( $ class , $ arguments , $ config ) ; }
|
Loads the service instance directly by using a class name .
|
56,276
|
protected function loadInstanceFromFile ( $ file ) { if ( file_exists ( $ file ) ) { $ arguments = $ this -> getConfiguration ( ) [ AbstractFileConfiguration :: SERVICE_INIT_ARGUMENTS ] ?? NULL ; $ object = _context_less_require ( $ file , $ arguments , $ this -> serviceManager ) ; if ( is_object ( $ object ) ) { $ this -> instance = $ object ; if ( method_exists ( $ object , 'setConfiguration' ) && ( $ cfg = $ this -> getConfiguration ( ) [ AbstractFileConfiguration :: SERVICE_INIT_CONFIGURATION ] ?? NULL ) ) $ object -> setConfiguration ( $ cfg ) ; } else { $ e = new InvalidServiceException ( "Executation of file $file did not return an object" ) ; $ e -> setServiceName ( $ this -> serviceName ) ; $ e -> setServiceObject ( $ object ) ; throw $ e ; } } else { $ e = new FileNotFoundException ( "File $file does not exist" ) ; $ e -> setServiceName ( $ this -> serviceName ) ; $ e -> setFilename ( $ file ) ; throw $ e ; } }
|
Loads a service instance from return value from a required file
|
56,277
|
public function seek ( $ num ) { if ( $ num >= 0 && $ num <= $ this -> count ( ) - 1 ) { if ( ! $ this -> resource -> data_seek ( $ num ) ) { return false ; } $ this -> cursor_position = $ num ; return true ; } return false ; }
|
Set cursor to a given position in the record set .
|
56,278
|
public function next ( ) { if ( $ this -> cursor_position < $ this -> count ( ) && $ row = $ this -> resource -> fetch_assoc ( ) ) { $ this -> setCurrentRow ( $ row ) ; ++ $ this -> cursor_position ; return true ; } return false ; }
|
Return next record in result set .
|
56,279
|
public function toArrayIndexedBy ( $ field_or_getter ) { $ result = [ ] ; foreach ( $ this as $ row ) { if ( $ this -> return_mode === ConnectionInterface :: RETURN_ARRAY ) { $ result [ $ row [ $ field_or_getter ] ] = $ row ; } else { $ result [ $ row -> $ field_or_getter ( ) ] = $ row ; } } return $ result ; }
|
Returns DBResult indexed by value of a field or by result of specific getter method .
|
56,280
|
public function jsonSerialize ( ) { if ( ! $ this -> count ( ) ) { return [ ] ; } $ records = [ ] ; foreach ( $ this as $ record ) { if ( $ record instanceof JsonSerializable ) { $ records [ ] = $ record -> jsonSerialize ( ) ; } else { $ records [ ] = $ record ; } } return $ records ; }
|
Return array or property = > value pairs that describes this object .
|
56,281
|
protected function setCurrentRow ( $ row ) { if ( ! in_array ( $ this -> return_mode , [ ConnectionInterface :: RETURN_OBJECT_BY_CLASS , ConnectionInterface :: RETURN_OBJECT_BY_FIELD ] , true ) ) { $ this -> current_row = $ row ; $ this -> getValueCaster ( ) -> castRowValues ( $ this -> current_row ) ; return ; } $ class_name = $ this -> return_mode === ConnectionInterface :: RETURN_OBJECT_BY_CLASS ? $ this -> return_class_or_field : $ row [ $ this -> return_class_or_field ] ; if ( empty ( $ this -> constructor_arguments ) ) { $ this -> current_row = new $ class_name ( ) ; } else { $ this -> current_row = ( new ReflectionClass ( $ class_name ) ) -> newInstanceArgs ( $ this -> constructor_arguments ) ; } if ( $ this -> current_row instanceof ContainerAccessInterface && $ this -> container ) { $ this -> current_row -> setContainer ( $ this -> container ) ; } $ this -> current_row -> loadFromRow ( $ row ) ; }
|
Set current row .
|
56,282
|
public function handle ( $ old , $ new ) { if ( ! $ this -> canHandle ( $ old ) || ! $ this -> canHandle ( $ new ) ) { return null ; } if ( ( ( string ) $ new -> getReturnType ( ) ) ) { return false ; } if ( ( ( string ) $ new -> getReturnType ( ) ) == ( ( string ) $ old -> getReturnType ( ) ) ) { return false ; } $ this -> lastException = new FailedConstraint ( sprintf ( '%s::%s() return type "%s" were removed' , $ old -> getAttribute ( 'parent' ) -> namespacedName , $ old -> name , $ old -> getReturnType ( ) , $ new -> getReturnType ( ) ) ) ; return true ; }
|
Check if return type changed .
|
56,283
|
protected function getLoginCredential ( $ credentials = array ( ) ) { $ loginField = $ this -> app [ 'config' ] [ 'auth.credentials.login' ] ; if ( isset ( $ credentials [ $ loginField ] ) ) { return $ credentials [ $ loginField ] ; } else if ( Input :: has ( $ loginField ) ) { return Input :: get ( $ loginField ) ; } else if ( isset ( $ credentials [ 'user_login' ] ) ) { return $ credentials [ 'user_login' ] ; } else if ( isset ( $ credentials [ 'log' ] ) ) { return $ credentials [ 'log' ] ; } throw new InvalidArgumentException ( "Login field not found" ) ; }
|
Return the login value from the credentials
|
56,284
|
protected function getPasswordCredential ( $ credentials = array ( ) ) { $ passField = $ this -> app [ 'config' ] [ 'auth.credentials.password' ] ; if ( isset ( $ credentials [ $ passField ] ) ) { return $ credentials [ $ passField ] ; } else if ( Input :: has ( $ passField ) ) { return Input :: get ( $ passField ) ; } else if ( isset ( $ credentials [ 'user_password' ] ) ) { return $ credentials [ 'user_password' ] ; } else if ( isset ( $ credentials [ 'pwd' ] ) ) { return $ credentials [ 'pwd' ] ; } throw new InvalidArgumentException ( "Password field not found" ) ; }
|
Return the password value from the credentials
|
56,285
|
public function is ( $ roles ) { if ( ! $ this -> user ( ) ) { return false ; } $ userRoles = $ this -> getUser ( ) -> roles ; foreach ( ( array ) $ roles as $ role ) { if ( in_array ( mb_strtolower ( $ role ) , $ userRoles ) || in_array ( $ role , $ userRoles ) ) { return true ; } } return false ; }
|
Checks if the user is a certain role or is one of many roles if passed an array .
|
56,286
|
public function can ( $ capability , $ args = null ) { if ( ! $ this -> user ( ) ) { return false ; } $ userCan = false ; if ( is_array ( $ capability ) ) { foreach ( $ capability as $ cap ) { if ( current_user_can ( $ cap , $ args ) === true ) { $ userCan = true ; break ; } } } else { $ userCan = current_user_can ( $ capability , $ args ) ; } return $ userCan ; }
|
Checks if the user is has a certain permission or has one of many permissions if passed an array .
|
56,287
|
public function level ( $ level , $ operator = '>=' ) { if ( ! $ this -> user ( ) ) { return false ; } $ userCaps = array_keys ( $ this -> getUser ( ) -> allcaps ) ; foreach ( $ userCaps as $ cap ) { if ( substr ( $ cap , 0 , 6 ) === 'level_' ) { return $ this -> checkWithOperator ( substr ( $ cap , 6 ) , $ level , $ operator ) ; } } return false ; }
|
Each role can have a numerical level as well ; this is useful if you want to check someone has a higher role than someone else .
|
56,288
|
private function addError ( array & $ errors , string $ message , array $ nodes ) { $ errors [ ] = [ 'text' => $ message , 'nodes' => $ nodes ] ; $ errorGraph = null ; foreach ( $ nodes as $ node ) { if ( $ errorGraph === null ) { $ errorGraph = $ node -> getGraph ( ) ; } else { $ nodeGraph = $ node -> getGraph ( ) ; if ( $ nodeGraph !== $ errorGraph ) { $ errorGraph = $ node -> getRootGraph ( ) ; break ; } } } $ errorNodeId = '_error_' . md5 ( $ message ) . '_' . count ( $ errors ) ; $ errorNode = $ errorGraph -> createNode ( $ errorNodeId , [ 'label' => $ message , 'type' => 'error' ] ) ; foreach ( $ nodes as $ node ) { $ errorGraph -> createEdge ( null , $ errorNode , $ node , [ 'type' => 'error' ] ) ; } }
|
Add error to the graph
|
56,289
|
public function get ( $ id ) { if ( ! isset ( $ this -> processors [ $ id ] ) ) { throw new \ InvalidArgumentException ( sprintf ( "processor with id '%s' does not exist" , $ id ) ) ; } return $ this -> processors [ $ id ] ; }
|
Get processor instance
|
56,290
|
public function setParameter ( $ parameter ) { if ( ! is_string ( $ parameter ) && ! is_int ( $ parameter ) ) { throw new InvalidArgumentException ( 'Binding parameter value must be a string or an integer.' ) ; } $ this -> parameter = $ parameter ; return $ this ; }
|
Set the value of the parameter property .
|
56,291
|
public function isBoolean ( ) { return $ this -> data_type === PDO :: PARAM_BOOL || $ this -> data_type === ( PDO :: PARAM_BOOL | PDO :: PARAM_INPUT_OUTPUT ) ; }
|
Determine if the data_type property represents a boolean value .
|
56,292
|
public function isInteger ( ) { return $ this -> data_type === PDO :: PARAM_INT || $ this -> data_type === ( PDO :: PARAM_INT | PDO :: PARAM_INPUT_OUTPUT ) ; }
|
Determine if the data_type property represents an integer value .
|
56,293
|
public function isString ( ) { return $ this -> data_type === PDO :: PARAM_STR || $ this -> data_type === ( PDO :: PARAM_STR | PDO :: PARAM_INPUT_OUTPUT ) ; }
|
Determine if the data_type property represents a string value .
|
56,294
|
public function isLargeObject ( ) { return $ this -> data_type === PDO :: PARAM_LOB || $ this -> data_type === ( PDO :: PARAM_LOB | PDO :: PARAM_INPUT_OUTPUT ) ; }
|
Determine if the data_type property represents a large object value .
|
56,295
|
public function isStatement ( ) { return $ this -> data_type === PDO :: PARAM_STMT || $ this -> data_type === ( PDO :: PARAM_STMT | PDO :: PARAM_INPUT_OUTPUT ) ; }
|
Determine if the data_type property represents a statement value .
|
56,296
|
public function getPackageManager ( ) { if ( $ this -> packageManager === null ) { $ this -> packageManager = new PackageManager ( $ this ) ; } return $ this -> packageManager ; }
|
Returns the package manager
|
56,297
|
public function getModuleManager ( ) { if ( $ this -> moduleManager === null ) { $ this -> moduleManager = new ModuleManager ( $ this ) ; } return $ this -> moduleManager ; }
|
Returns the module manager
|
56,298
|
public function getAuthManager ( ) { if ( $ this -> authManager === null ) { $ this -> authManager = new AuthManager ( $ this ) ; } return $ this -> authManager ; }
|
Returns the auth manager
|
56,299
|
public function getFirewall ( ) { if ( $ this -> firewall === null ) { $ this -> firewall = new Firewall ( $ this ) ; } return $ this -> firewall ; }
|
Returns the firewall
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.