idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
21,200 | public function subtract ( $ latitude , $ longitude ) { $ this -> latitude -= $ latitude ; $ this -> longitude -= $ longitude ; return $ this ; } | Decrease the latitude and longitude of the Location . |
21,201 | public function distance ( Location $ otherLocation ) { $ theta = $ this -> longitude - $ otherLocation -> getLongitude ( ) ; $ distance = ( sin ( deg2rad ( $ this -> latitude ) ) * sin ( deg2rad ( $ otherLocation -> getLatitude ( ) ) ) ) + ( cos ( deg2rad ( $ this -> latitude ) ) * cos ( deg2rad ( $ otherLocation -> getLatitude ( ) ) ) * cos ( deg2rad ( $ theta ) ) ) ; $ distance = acos ( $ distance ) ; $ distance = rad2deg ( $ distance ) ; return ( float ) $ distance * 60 * 1.1515 ; } | Get the distance between the Location and a given Location . |
21,202 | public static function run ( $ pCache = false , $ pDebug = false , $ pConfigPath = NULL ) { if ( self :: $ _instance === NULL ) { self :: $ _instance = new self ( $ pCache , $ pDebug , $ pConfigPath ) ; } else { throw new Exception ( "The application has already been initialized - use app() to get access to it" ) ; } } | Create an instance of Agl and initialize it . |
21,203 | public static function loadModuleLib ( $ pPath , $ pLib ) { $ file = $ pPath . DS . self :: AGL_LIB_DIR . DS . $ pLib ; require_once ( $ file ) ; return true ; } | Load a library linked to a More module . |
21,204 | public function getConfig ( $ pPath , $ pForceGlobalArray = false ) { if ( $ this -> _config === NULL ) { $ this -> _config = new Config ( ) ; } return $ this -> _config -> getConfig ( $ pPath , $ pForceGlobalArray ) ; } | Retrieve a value in the Agl XML configuration file . |
21,205 | public function setPozycjeSzczegolowe ( \ KCH \ PCC3 \ ZalacznikORDZU \ PozycjeSzczegoloweAnonymousType $ pozycjeSzczegolowe ) { $ this -> pozycjeSzczegolowe = $ pozycjeSzczegolowe ; return $ this ; } | Sets a new pozycjeSzczegolowe |
21,206 | public function getMediaType ( ) : ? string { if ( ! $ this -> hasMediaType ( ) ) { $ this -> setMediaType ( $ this -> getDefaultMediaType ( ) ) ; } return $ this -> mediaType ; } | Get media type |
21,207 | public function encode ( $ data , $ options = 0 , $ depth = 512 ) { $ server = $ this -> getServer ( ) ; $ response = $ server -> getResponse ( false ) ; $ json = json_encode ( $ data , $ options , $ depth ) ; if ( false === $ json ) { throw new RuntimeException ( json_last_error_msg ( ) , json_last_error ( ) ) ; } $ response -> getBody ( ) -> write ( $ json ) ; $ result = $ response -> withHeader ( 'Content-Type' , 'application/json;charset=utf-8' ) ; return $ result ; } | Encodes data and returns the response . |
21,208 | public function decode ( $ json , $ assoc = false , $ depth = 512 , $ options = 0 ) { $ result = json_decode ( ( string ) $ json , ( bool ) $ assoc , ( int ) $ depth , ( int ) $ options ) ; if ( null === $ result && JSON_ERROR_NONE !== json_last_error ( ) ) { throw new RuntimeException ( json_last_error_msg ( ) , json_last_error ( ) ) ; } return $ result ; } | Decodes json . |
21,209 | public static function string ( string $ key = null , string $ name = null ) { $ instance = self :: init ( 'string' , $ key , $ name ) ; $ instance -> minLength ( 0 ) ; $ instance -> maxLength ( 0 ) ; return $ instance ; } | Helper methods to initialise a new field of specific types . These should be used to initialise a new field . |
21,210 | public function key ( string $ key = null ) { if ( $ key ) { $ this -> field [ 'key' ] = $ key ; return $ this ; } return $ this -> field [ 'key' ] ; } | Set or get the key of a field . Returns chainable instance if a key is supplied otherwise returns a string of the key . |
21,211 | public function addOption ( Option ... $ choices ) { collect ( $ choices ) -> map ( function ( $ choice ) { $ this -> field [ 'choices' ] -> push ( $ choice -> get ( ) ) ; } ) ; return $ this ; } | Set the available choices for a select field as an array of key value pairs |
21,212 | public function addOptions ( array $ choices ) { collect ( $ choices ) -> map ( function ( $ choice ) { $ this -> field [ 'choices' ] -> push ( $ choice ) ; } ) ; return $ this ; } | Set the available choices for a select field as an array of key value pairs taken directly from a supplied array |
21,213 | public function ratio ( int $ width , int $ height , bool $ resize = false ) { $ this -> field [ 'ratio' ] = "{$width}:{$height}" ; if ( $ resize ) { $ this -> field [ 'imagesize' ] = "{$width},{$height}" ; } return $ this ; } | Set the desired image ratio to be requested from the CMS . The UI will automatically resize any uploaded image to match this ratio . |
21,214 | protected function loadConfiguration ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ container -> setParameter ( "hexmedia.seo.options" , $ config [ 'seo' ] ) ; if ( ! isset ( $ config [ 'ga' ] [ 'domain' ] ) ) { $ config [ 'ga' ] [ 'domain' ] = $ container -> getParameter ( "domain" ) ; } $ container -> setParameter ( "hexmedia.ga.options" , $ config [ 'ga' ] ) ; } | Loads the configuration in with any defaults |
21,215 | public function manageSimpleMediaFor ( $ parentContent , $ editId , $ itemId , $ oneFileName , $ userId , $ parentType ) { $ newEditId = $ this -> fileManager -> generateItemId ( $ userId , $ itemId ) ; return $ this -> manageSimpleMedia ( $ parentContent , $ editId , $ newEditId , $ oneFileName , $ parentType ) ; } | For Entity with OneToOne relation to media |
21,216 | public function removeTransformers ( string $ key , string $ prefix = NULL ) { $ id = $ prefix ? "$prefix.$key" : $ key ; if ( isset ( $ this -> transformers [ $ id ] ) ) unset ( $ this -> transformers [ $ id ] ) ; } | Removes registered transformers identified by key and prefix |
21,217 | protected function encodeText ( $ text ) { $ encoded_text = '' ; for ( $ i = 0 ; $ i < strlen ( $ text ) ; $ i ++ ) { $ char = $ text { $ i } ; $ r = rand ( 0 , 100 ) ; if ( $ r > 90 && $ char != '@' ) { $ encoded_text .= $ char ; } else if ( $ r < 45 ) { $ encoded_text .= '&#x' . dechex ( ord ( $ char ) ) . ';' ; } else { $ encoded_text .= '&#' . ord ( $ char ) . ';' ; } } return $ encoded_text ; } | Thanks to SF 1 . 2 UrlHelper . php |
21,218 | protected static function titleCase ( $ command ) { $ words = explode ( '-' , $ command ) ; $ words = array_map ( function ( $ data ) { return mb_convert_case ( $ data , MB_CASE_TITLE ) ; } , $ words ) ; return implode ( '' , $ words ) ; } | Protected title case |
21,219 | protected static function arrayRemoveFirst ( Array $ array , Int $ count = 1 ) : Array { for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { array_shift ( $ array ) ; } return $ array ; } | Array Remove First |
21,220 | static public function isRegistered ( $ callBack = null , $ returnPriority = false ) { if ( null === $ callBack ) { return self :: $ _registered ; } if ( is_int ( $ callBack ) ) { return isset ( self :: $ _registeredCallbacks [ $ callBack ] ) ? ( $ returnPriority ? self :: $ _registeredCallbacks [ $ callBack ] [ 1 ] : true ) : false ; } foreach ( self :: $ _registeredCallbacks as $ cb ) { if ( $ cb [ 0 ] === $ callBack ) { return $ returnPriority ? $ cb [ 1 ] : true ; } } return false ; } | Check that given callable is registered by shutdown manager . It also allow to check that jShutdownManager is registered itself |
21,221 | static public function register ( $ callBack , $ priority = 0 ) { if ( ! self :: $ _registered ) { register_shutdown_function ( array ( __class__ , '_registered_shutdown' ) ) ; self :: $ _registered = true ; } $ params = func_get_args ( ) ; self :: $ _registeredCallbacks [ ++ self :: $ _id ] = array ( $ callBack , ( int ) $ priority , self :: $ _id , array_slice ( $ params , 2 ) ) ; return self :: $ _id ; } | register a callback function to be executed as a shutdown fucntion |
21,222 | static public function unregister ( $ callBack ) { if ( is_null ( $ callBack ) ) { self :: $ _registeredCallbacks = array ( ) ; return true ; } if ( is_int ( $ callBack ) ) { if ( ! isset ( self :: $ _registered [ $ callBack ] ) ) { return false ; } unset ( self :: $ _registered [ $ callBack ] ) ; return true ; } foreach ( self :: $ _registeredCallbacks as $ k => $ cb ) { if ( $ cb [ 0 ] === $ callBack ) { unset ( self :: $ _registeredCallbacks [ $ k ] ) ; return true ; } } return false ; } | unregister previously registered callback |
21,223 | static public function shutdown ( $ status = 0 , $ byPassCallBacks = false ) { self :: $ _byPassCallBacks = $ byPassCallBacks ; exit ( $ status ? $ status : 0 ) ; } | shutdown the script by calling exit . |
21,224 | static public function _registered_shutdown ( ) { if ( self :: $ _byPassCallBacks ) { return ; } uasort ( self :: $ _registeredCallbacks , array ( __class__ , '_compare' ) ) ; foreach ( self :: $ _registeredCallbacks as $ cb ) { call_user_func_array ( $ cb [ 0 ] , $ cb [ 3 ] ) ; } } | THIS IS NOT INTENTED TO BE CALLED OTHER THAN INTERNALLY the only reason for this to be public is that it s a necessity for register_shutdown_function to see it there s no reason at all for you to call this |
21,225 | public function p ( $ ipath , $ context = null ) { $ ipath = Utilities :: convertPath ( $ ipath ) ; if ( ! isset ( $ context ) ) { $ context = $ this -> basePath ; } if ( $ ipath == '' ) { return $ context ; } $ splits = explode ( '/' , $ ipath , 2 ) ; $ key = $ splits [ 0 ] ; $ path = '' ; if ( isset ( $ splits [ 1 ] ) ) { $ path = $ splits [ 1 ] ; } if ( $ key == '.' ) { return self :: combinePaths ( $ context , $ path ) ; } return self :: combinePaths ( $ this -> __get ( $ key ) , $ path ) ; } | Convert an internal path . |
21,226 | public function process ( MessageInterface $ message ) { return $ this -> worker -> forward ( ) -> dispatch ( $ message -> getContent ( ) , $ message -> getMetadata ( ) ) ; } | Processes a message and returns the result . |
21,227 | private function slug ( $ value = null ) { $ slug = strtolower ( Text :: slug ( $ value , $ this -> _config [ 'replacement' ] ) ) ; if ( $ this -> _config [ 'unique' ] ) { $ field = $ this -> _table -> getAlias ( ) . '.slug' ; $ conditions = [ $ field => $ slug ] ; $ suffix = '' ; $ i = 0 ; while ( $ this -> _table -> exists ( $ conditions ) ) { $ i ++ ; $ suffix = $ this -> _config [ 'replacement' ] . $ i ; $ conditions [ $ field ] = $ slug . $ suffix ; } if ( $ suffix ) $ slug .= $ suffix ; } return $ slug ; } | Slug a field passed in the default config with its replacement . |
21,228 | public function beforeSave ( Event $ event , Entity $ entity ) { if ( ! $ entity -> get ( 'slug' ) || $ this -> _config [ 'overwrite' ] ) $ entity -> set ( 'slug' , $ this -> slug ( $ entity -> get ( $ this -> _config [ 'field' ] ) ) ) ; } | BeforeSave handle . |
21,229 | public function isGranted ( $ permission , Array $ params = null ) { if ( $ this -> checkPermissionCurrent ( $ permission , $ params ) ) { return true ; } if ( $ this -> checkPermissionRecursive ( $ permission , $ params ) ) { return true ; } return false ; } | Checks if a permission exists for this role or any child roles . |
21,230 | public function getPermissions ( ) { $ mode = \ RecursiveIteratorIterator :: CHILD_FIRST ; $ iterator = $ this -> createRecursiveIterator ( $ mode ) ; $ permissions = [ ] ; foreach ( $ iterator as $ child ) { $ permissions = array_replace_recursive ( $ permissions , $ child -> getPermissions ( ) ) ; } return array_replace_recursive ( $ permissions , $ this -> permissions ) ; } | Returns permissions from the Role . |
21,231 | public static function write ( string $ message , string $ eol = "\r\n" ) : string { $ log_file = Plugin :: dataPath ( ) . DIRECTORY_SEPARATOR . "plugin.log" ; if ( ! file_exists ( dirname ( $ log_file ) ) ) mkdir ( dirname ( $ log_file ) ) ; $ line = sprintf ( "[%s] %s" , ( new \ DateTime ( ) ) -> format ( self :: TIMESTAMP_FORMAT ) , $ message ) ; file_put_contents ( $ log_file , $ line . $ eol , FILE_APPEND | LOCK_EX ) ; return $ line ; } | Writes a message to this Plugin s log file . |
21,232 | public static function clear ( ) : void { $ log_file = Plugin :: dataPath ( ) . DIRECTORY_SEPARATOR . "plugin.log" ; if ( ! file_exists ( dirname ( $ log_file ) ) ) mkdir ( dirname ( $ log_file ) ) ; file_put_contents ( $ log_file , "" , LOCK_EX ) ; } | Clears this Plugin s log file . |
21,233 | public static function lines ( int $ tail = 0 ) : ? array { $ log_file = Plugin :: dataPath ( ) . DIRECTORY_SEPARATOR . "plugin.log" ; if ( ! file_exists ( $ log_file ) ) throw new RequiredFileNotFoundException ( "A plugin.log file could not be found at '" . $ log_file . "'." ) ; $ lines = preg_split ( "/[\r\n|\r|\n]+/" , file_get_contents ( $ log_file ) ) ; if ( $ lines [ count ( $ lines ) - 1 ] === "" ) unset ( $ lines [ count ( $ lines ) - 1 ] ) ; if ( $ tail < 0 ) return null ; if ( $ tail === 0 ) return $ lines ; return array_slice ( $ lines , - $ tail , $ tail ) ; } | Reads the specified number of trailing lines from this Plugin s log file . |
21,234 | public static function createFromString ( $ Line ) { $ lines = explode ( "\n" , $ Line ) ; list ( $ method , $ uri ) = explode ( ' ' , array_shift ( $ lines ) ) ; $ headers = [ ] ; foreach ( $ lines as $ line ) { $ line = trim ( $ line ) ; if ( strpos ( $ line , ': ' ) !== false ) { list ( $ key , $ value ) = explode ( ': ' , $ line ) ; $ headers [ $ key ] = $ value ; } } $ reqBody = new \ Sofi \ HTTP \ RequestBody ( ) ; $ headers = \ Sofi \ HTTP \ Headers :: createFromArray ( $ headers ) ; $ cookies = \ Sofi \ HTTP \ Cookies :: parseHeader ( $ headers -> get ( 'cookie' ) ) ; return new static ( $ method , new \ Sofi \ HTTP \ message \ Uri ( $ uri ) , $ headers , $ cookies , $ _SERVER , $ reqBody ) ; } | Create new headers collection with data extracted from string |
21,235 | public function setMinRow ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'min-row' ] = $ value ; } else { unset ( $ this -> _params [ 'min-row' ] ) ; } return $ this ; } | Sets the min - row attribute for this query . |
21,236 | public function setMaxRow ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'max-row' ] = $ value ; } else { unset ( $ this -> _params [ 'max-row' ] ) ; } return $ this ; } | Sets the max - row attribute for this query . |
21,237 | public function setMinCol ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'min-col' ] = $ value ; } else { unset ( $ this -> _params [ 'min-col' ] ) ; } return $ this ; } | Sets the min - col attribute for this query . |
21,238 | public function setMaxCol ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'max-col' ] = $ value ; } else { unset ( $ this -> _params [ 'max-col' ] ) ; } return $ this ; } | Sets the max - col attribute for this query . |
21,239 | public function setRange ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'range' ] = $ value ; } else { unset ( $ this -> _params [ 'range' ] ) ; } return $ this ; } | Sets the range attribute for this query . |
21,240 | public function setReturnEmpty ( $ value ) { if ( is_bool ( $ value ) ) { $ this -> _params [ 'return-empty' ] = ( $ value ? 'true' : 'false' ) ; } else if ( $ value != null ) { $ this -> _params [ 'return-empty' ] = $ value ; } else { unset ( $ this -> _params [ 'return-empty' ] ) ; } return $ this ; } | Sets the return - empty attribute for this query . |
21,241 | protected function addFirewall ( Application $ app , $ pattern , $ authType ) { $ firewalls = $ app [ 'security.firewalls' ] ; $ key = is_object ( $ pattern ) ? spl_object_hash ( $ pattern ) : $ pattern ; $ firewalls [ $ key ] = [ 'pattern' => $ pattern , $ authType => true , ] ; $ app [ 'security.firewalls' ] = $ firewalls ; } | Add a firewall record |
21,242 | protected function addAccessRule ( Application $ app , $ pattern , $ roles ) { $ security = $ app [ 'security.access_rules' ] ; $ key = is_object ( $ pattern ) ? spl_object_hash ( $ pattern ) : $ pattern ; $ security [ $ key ] = [ $ pattern , $ roles ] ; $ app [ 'security.access_rules' ] = $ security ; } | Add access rule to limit specific paths by role |
21,243 | public static function getFormat ( $ format = null ) { if ( ! $ format ) $ format = self :: $ DEFAULT_FORMAT ; if ( array_key_exists ( $ format , self :: $ FORMATS ) ) return self :: $ FORMATS [ $ format ] ; return $ format ; } | Returns the format string . |
21,244 | public function Get ( $ UserID , $ Offset = '0' , $ Limit = '' , $ DiscussionID = '' ) { if ( ! is_numeric ( $ Offset ) || $ Offset < 0 ) $ Offset = 0 ; if ( ! is_numeric ( $ Limit ) || $ Limit < 1 ) $ Limit = 100 ; $ this -> DraftQuery ( ) ; $ this -> SQL -> Select ( 'd.Name, di.Name' , 'coalesce' , 'Name' ) -> Join ( 'Discussion di' , 'd.discussionID = di.DiscussionID' , 'left' ) -> Where ( 'd.InsertUserID' , $ UserID ) -> OrderBy ( 'd.DateInserted' , 'desc' ) -> Limit ( $ Limit , $ Offset ) ; if ( is_numeric ( $ DiscussionID ) && $ DiscussionID > 0 ) $ this -> SQL -> Where ( 'd.DiscussionID' , $ DiscussionID ) ; return $ this -> SQL -> Get ( ) ; } | Gets drafts matching the given criteria . |
21,245 | public function GetID ( $ DraftID ) { $ this -> DraftQuery ( ) ; return $ this -> SQL -> Where ( 'd.DraftID' , $ DraftID ) -> Get ( ) -> FirstRow ( ) ; } | Gets data for a single draft . |
21,246 | public function GetCount ( $ UserID ) { return $ this -> SQL -> Select ( 'DraftID' , 'count' , 'CountDrafts' ) -> From ( 'Draft' ) -> Where ( 'InsertUserID' , $ UserID ) -> Get ( ) -> FirstRow ( ) -> CountDrafts ; } | Gets number of drafts a user has . |
21,247 | public function Save ( $ FormPostValues ) { $ Session = Gdn :: Session ( ) ; $ this -> DefineSchema ( ) ; $ this -> Validation -> ApplyRule ( 'Body' , 'Required' ) ; $ MaxCommentLength = Gdn :: Config ( 'Vanilla.Comment.MaxLength' ) ; if ( is_numeric ( $ MaxCommentLength ) && $ MaxCommentLength > 0 ) { $ this -> Validation -> SetSchemaProperty ( 'Body' , 'Length' , $ MaxCommentLength ) ; $ this -> Validation -> ApplyRule ( 'Body' , 'Length' ) ; } $ DraftID = ArrayValue ( 'DraftID' , $ FormPostValues , '' ) ; $ Insert = $ DraftID == '' ? TRUE : FALSE ; if ( array_key_exists ( 'DiscussionID' , $ FormPostValues ) && $ FormPostValues [ 'DiscussionID' ] == '' ) unset ( $ FormPostValues [ 'DiscussionID' ] ) ; if ( $ Insert ) { if ( ArrayValue ( 'CategoryID' , $ FormPostValues ) === FALSE ) $ FormPostValues [ 'CategoryID' ] = $ this -> SQL -> Get ( 'Category' , '' , '' , 1 ) -> FirstRow ( ) -> CategoryID ; } $ this -> AddInsertFields ( $ FormPostValues ) ; $ this -> AddUpdateFields ( $ FormPostValues ) ; if ( ArrayValue ( 'Announce' , $ FormPostValues , '' ) === FALSE ) unset ( $ FormPostValues [ 'Announce' ] ) ; if ( ArrayValue ( 'Closed' , $ FormPostValues , '' ) === FALSE ) unset ( $ FormPostValues [ 'Closed' ] ) ; if ( ArrayValue ( 'Sink' , $ FormPostValues , '' ) === FALSE ) unset ( $ FormPostValues [ 'Sink' ] ) ; if ( $ this -> Validate ( $ FormPostValues , $ Insert ) ) { $ Fields = $ this -> Validation -> SchemaValidationFields ( ) ; $ DraftID = intval ( ArrayValue ( 'DraftID' , $ Fields , 0 ) ) ; if ( $ DraftID > 0 ) { $ Fields = RemoveKeyFromArray ( $ Fields , 'DraftID' ) ; $ this -> SQL -> Put ( $ this -> Name , $ Fields , array ( $ this -> PrimaryKey => $ DraftID ) ) ; } else { unset ( $ Fields [ 'DraftID' ] ) ; $ DraftID = $ this -> SQL -> Insert ( $ this -> Name , $ Fields ) ; $ this -> UpdateUser ( $ Session -> UserID ) ; } } return $ DraftID ; } | Insert or update a draft from form values . |
21,248 | public function Delete ( $ DraftID ) { $ DraftUser = $ this -> SQL -> Select ( 'InsertUserID' ) -> From ( 'Draft' ) -> Where ( 'DraftID' , $ DraftID ) -> Get ( ) -> FirstRow ( ) ; $ this -> SQL -> Delete ( 'Draft' , array ( 'DraftID' => $ DraftID ) ) ; if ( is_object ( $ DraftUser ) ) $ this -> UpdateUser ( $ DraftUser -> InsertUserID ) ; return TRUE ; } | Deletes a specified draft . |
21,249 | public function UpdateUser ( $ UserID ) { $ CountDrafts = $ this -> GetCount ( $ UserID ) ; Gdn :: UserModel ( ) -> SetField ( $ UserID , 'CountDrafts' , $ CountDrafts ) ; } | Updates a user s draft count . |
21,250 | public function jsonSaveAction ( Request $ request ) { $ this -> save ( $ request ) ; $ response = new Response ( json_encode ( [ 'status' => 'ok' ] ) ) ; $ response -> headers -> set ( "Content-Type" , 'application/json' ) ; return $ response ; } | Save from Raptor |
21,251 | public function validate ( $ subject ) : bool { switch ( $ this -> schema [ 'type' ] ) { case 'boolean' : return $ this -> validateTypBoolean ( $ subject ) ; case 'number' : case 'integer' : case 'float' : return $ this -> validateTypeNumeric ( $ subject ) ; case 'string' : return $ this -> validateTypeString ( $ subject ) ; case 'array' : return $ this -> validateTypeArray ( $ subject ) ; case 'object' : return $ this -> validateTypeObject ( $ subject ) ; case 'null' : return $ this -> validateTypeNull ( $ subject ) ; } return false ; } | Validates subject against type |
21,252 | private function validateTypeArray ( $ subject ) : bool { if ( ! \ is_array ( $ subject ) ) { return false ; } if ( count ( $ subject ) > 0 && ! \ is_int ( \ array_keys ( $ subject ) [ 0 ] ) ) { return false ; } return true ; } | Validates subject against type = array |
21,253 | private function validateTypeObject ( $ subject ) : bool { if ( ! \ is_array ( $ subject ) ) { return false ; } if ( count ( $ subject ) > 0 && ! \ is_string ( \ array_keys ( $ subject ) [ 0 ] ) ) { return false ; } return true ; } | Validates subject against type = object |
21,254 | private function findCascadeDetachableEntities ( EntityManager $ em , CascadeRemovableInterface $ entity , & $ visited = [ ] , $ depth = 0 ) { $ id = $ em -> getUnitOfWork ( ) -> getEntityIdentifier ( $ entity ) ; $ key = serialize ( [ get_class ( $ entity ) , $ id ] ) ; $ visited [ $ key ] = $ entity ; $ entities = $ entity -> getCascadeRemoveableEntities ( ) ; foreach ( $ entities as $ subEntity ) { $ id = $ em -> getUnitOfWork ( ) -> getEntityIdentifier ( $ subEntity ) ; $ key = serialize ( [ get_class ( $ subEntity ) , $ id ] ) ; if ( array_key_exists ( $ key , $ visited ) ) { continue ; } if ( $ subEntity instanceof CascadeRemovableInterface ) { $ this -> findCascadeDetachableEntities ( $ em , $ subEntity , $ visited , $ depth + 1 ) ; } else { $ visited [ $ key ] = $ subEntity ; } } } | Detaches associated entities from EntityManager and Cache . Normally these entities should either be deleted or updated in database in post - remove phase . |
21,255 | public function mapBrowserType ( ? string $ browserType ) : TypeInterface { if ( null === $ browserType ) { return ( new TypeLoader ( ) ) -> load ( 'unknown' ) ; } switch ( mb_strtolower ( $ browserType ) ) { case 'browser' : case 'mobile browser' : $ typeKey = 'browser' ; break ; case 'bot' : case 'robot' : case 'bot/crawler' : case 'library' : $ typeKey = 'bot' ; break ; case 'emailclient' : case 'email client' : $ typeKey = 'email-client' ; break ; case 'pim' : $ typeKey = 'pim' ; break ; case 'feedreader' : case 'feed reader' : $ typeKey = 'feed-reader' ; break ; case 'multimediaplayer' : case 'mediaplayer' : case 'multimedia player' : $ typeKey = 'multimedia-player' ; break ; case 'offlinebrowser' : case 'offline browser' : $ typeKey = 'offline-browser' ; break ; case 'useragentanonymizer' : case 'useragent anonymizer' : $ typeKey = 'useragent-anonymizer' ; break ; case 'wapbrowser' : case 'wap browser' : $ typeKey = 'wap-browser' ; break ; case 'application' : case 'mobile app' : $ typeKey = 'application' ; break ; case 'tool' : $ typeKey = 'tool' ; break ; default : $ typeKey = 'unknown' ; break ; } return ( new TypeLoader ( ) ) -> load ( $ typeKey ) ; } | maps the browser type |
21,256 | public function extract ( $ object ) { return [ 'name' => $ object -> getFileName ( ) , 'type' => $ object -> getType ( ) , 'size' => $ object -> getSize ( ) , 'tmp_name' => $ object -> getTempName ( ) , 'error' => $ object -> getError ( ) , 'size' => [ 0 => $ object -> getWidth ( ) , 1 => $ object -> getHeight ( ) , 2 => $ object -> getMimeType ( ) , ] , ] ; } | Extract values from model |
21,257 | public function getStatusInfo ( ) { $ int = $ this -> variant -> statusInfo ( ) ; $ possible = [ 1 => 'Other' , 2 => 'Unknown' , 3 => 'Enabled' , 4 => 'Disabled' , 5 => 'Not Applicable' , ] ; return $ this -> getFromPossibleValues ( $ int , $ possible ) ; } | Returns a string indicating the devices status . |
21,258 | protected function getCacheItem ( $ key ) { $ this -> validateKey ( $ key ) ; if ( $ this -> use_item_cache ) { if ( ! isset ( $ this -> item_cache [ $ key [ 0 ] ] [ $ key ] ) ) { $ this -> item_cache [ $ key [ 0 ] ] [ $ key ] = $ this -> createCacheItem ( $ key ) ; } return $ this -> item_cache [ $ key [ 0 ] ] [ $ key ] ; } else { return $ this -> createCacheItem ( $ key ) ; } } | Get a cache item |
21,259 | protected function createCacheItem ( $ key ) { if ( is_callable ( $ this -> item_factory ) ) { $ func = $ this -> item_factory ; $ item = $ func ( $ key , $ this ) ; } else { $ item = new CacheItem ( $ key , $ this ) ; } return $ item ; } | Create a cache item on the fly |
21,260 | protected function validateKey ( & $ key ) { if ( is_string ( $ key ) ) { $ key = trim ( $ key ) ; return ; } throw new InvalidArgumentException ( Message :: get ( Message :: CACHE_INVALID_KEY , $ key ) , Message :: CACHE_INVALID_KEY ) ; } | Validate key string |
21,261 | public function fetch ( $ id ) { $ rendition = CoreInterface :: RENDITION_ORIGINAL ; if ( $ this -> getEvent ( ) ) { $ rendition = $ this -> getEvent ( ) -> getQueryParam ( 'rendition' , CoreInterface :: RENDITION_ORIGINAL ) ; } $ src = $ this -> imageManager -> getSrc ( $ id , $ rendition ) ; if ( $ src && ! $ this -> isAccept ( 'application/json' ) ) { return $ this -> getRedirectResponse ( $ src ) ; } $ hasImage = $ this -> imageManager -> has ( $ id , $ rendition ) ; if ( $ hasImage ) { $ image = $ this -> imageManager -> get ( $ id , $ rendition ) ; if ( $ this -> isAccept ( $ image -> getMimeType ( ) ) || $ this -> isAccept ( '*/*' , true ) ) { return $ this -> getHttpResponse ( $ image ) ; } else { return $ this -> getApigilityResponse ( $ image , $ id ) ; } } return new ApiProblem ( 404 , 'Image not found' ) ; } | Fetch a resource |
21,262 | public function setTo ( $ value ) { if ( is_array ( $ value ) ) { $ value = new Person ( $ value ) ; } return $ this -> setParameter ( 'to' , $ value ) ; } | Set document to |
21,263 | private function load ( ) { $ this -> registry [ $ this -> section ] = $ this -> getDrupalCommonConnector ( ) -> variable_get ( $ this -> section , array ( ) ) ; } | Loads the current content of the registry . |
21,264 | public function unregister ( $ identifier ) { $ this -> load ( ) ; parent :: unregister ( $ identifier ) ; $ this -> getDrupalCommonConnector ( ) -> variable_set ( $ this -> section , $ this -> registry [ $ this -> section ] ) ; } | Removes an item from the regisrty . |
21,265 | public function destroy ( ) { $ this -> registry [ $ this -> section ] = array ( ) ; $ dcc = $ this -> getDrupalCommonConnector ( ) ; $ dcc -> variable_del ( $ this -> section ) ; $ content = $ dcc -> variable_get ( $ this -> section , array ( ) ) ; if ( ! empty ( $ content ) ) { throw new \ InvalidArgumentException ( "Section $this->section could not be destroyed from the registry." ) ; } } | Deletes the current registry from the database . |
21,266 | public function init ( ) { $ this -> load ( ) ; if ( ! empty ( $ this -> registry [ $ this -> section ] ) ) { throw new RegistryException ( RegistryException :: DUPLICATE_INITIATION_ATTEMPT_TEXT . '(section: ' . $ this -> section . ')' , RegistryException :: DUPLICATE_INITIATION_ATTEMPT_CODE ) ; } $ this -> getDrupalCommonConnector ( ) -> variable_set ( $ this -> section , $ this -> registry [ $ this -> section ] ) ; } | Initiates a registry . |
21,267 | public function isRegistered ( $ identifier ) { if ( ! parent :: isRegistered ( $ identifier ) ) { $ this -> load ( ) ; return parent :: isRegistered ( $ identifier ) ; } return true ; } | Determines if the given identifier refers to a registry item . |
21,268 | public static function buildUrl ( $ url , $ payload = array ( ) , $ numericPrefix = null , $ argSeparator = '&' , $ encodingType = PHP_QUERY_RFC1738 ) { $ _query = \ http_build_query ( $ payload , $ numericPrefix , $ argSeparator , $ encodingType ) ; return $ url . static :: urlSeparator ( $ url , $ argSeparator ) . $ _query ; } | Builds an URL properly appending the payload as the query string . |
21,269 | public function send ( ) { if ( ! isset ( $ this -> files [ $ this -> sent ] ) ) { return FALSE ; } $ file = $ this -> files [ $ this -> sent ] ; $ local = $ file -> genLocal ( self :: ZIP_VERSION , $ this -> dosStamp ) ; $ this -> output ( $ local ) ; $ file -> hasDeflation ( ) ? $ this -> outputDeflated ( $ file ) : $ this -> outputRaw ( $ file ) ; $ dataDescriptor = $ file -> isSmooth ( ) ? $ file -> genDataDescriptor ( ) : '' ; $ this -> output ( $ dataDescriptor ) ; $ file -> setLocalOffset ( $ this -> localOffset ) ; $ this -> localOffset += strlen ( $ local ) + $ file -> getDeflatedSize ( ) + strlen ( $ dataDescriptor ) ; $ file -> genCentral ( self :: ZIP_VERSION , $ this -> dosStamp ) ; $ this -> centralLength += strlen ( $ file -> getCentral ( ) ) ; $ this -> sent ++ ; return TRUE ; } | Sends the next file in the queue to the output interface . |
21,270 | public function flush ( ) { if ( $ this -> locked ) return ; while ( $ this -> send ( ) ) { } foreach ( $ this -> files as $ file ) { $ this -> output ( $ file -> getCentral ( ) ) ; } $ this -> output ( $ this -> getEOF ( ) ) ; $ this -> locked = TRUE ; $ this -> outputter -> flush ( ) ; } | Send any remaining files in the queue ( |
21,271 | public static function mkdir ( $ dirPath , $ perms = 0755 , $ recursive = true ) { $ result = true ; if ( ! is_dir ( $ dirPath ) ) { $ result = mkdir ( $ dirPath , $ perms , $ recursive ) ; } return $ result ; } | Wrapper around the mkdir that will only execute it if the directory doesn t already exist . Also this defaults to being recursive so that it will create all relevant parent directories |
21,272 | public static function lockFile ( $ filePath , $ is_write_lock , $ is_blocking ) { global $ globals ; $ globals [ 'file_locks' ] [ $ filePath ] = fopen ( $ filePath , 'a+' ) ; $ lock_params = 0 ; if ( $ is_write_lock ) { $ lock_params = $ lock_params | LOCK_EX ; } else { $ lock_params = $ lock_params | LOCK_SH ; } if ( ! $ is_blocking ) { $ lock_params = $ lock_params | LOCK_NB ; } $ result = flock ( $ globals [ 'file_locks' ] [ $ filePath ] , $ lock_params ) ; return $ result ; } | Lock a file so that only we can use it . This will NOT block untill the file can be locked but would return false immediately if cannot grab the lock . Note that this only allows other processes to see that you have locked it and does not actually guarantee that it cannot be edited at the same time on Linux . |
21,273 | public static function unlockFile ( $ filePath ) { global $ globals ; if ( isset ( $ globals [ 'file_locks' ] [ $ filePath ] ) ) { fclose ( $ globals [ 'file_locks' ] [ $ filePath ] ) ; unset ( $ globals [ 'file_locks' ] [ $ filePath ] ) ; } } | Unlock a file so that others may use it . |
21,274 | function createFileIndex ( $ dirToIndex , $ indexLocation ) { if ( $ dirToIndex == $ indexLocation ) { $ errMsg = 'Cannot place index in same folder being indexed!' ; throw new \ Exception ( $ errMsg ) ; } if ( file_exists ( $ indexLocation ) ) { self :: deleteDir ( $ indexLocation ) ; } if ( ! mkdir ( $ indexLocation ) ) { $ err = 'Failed to create index directory, check write permissions' ; throw new \ Exception ( $ err ) ; } $ files = scandir ( $ dirToIndex ) ; foreach ( $ files as $ filename ) { $ first_letter = $ filename [ 0 ] ; $ placement_dir = $ indexLocation . "/" . strtoupper ( $ first_letter ) ; if ( ctype_alpha ( $ first_letter ) ) { mkdir ( $ placement_dir ) ; $ newPath = $ placement_dir . "/" . $ filename ; if ( ! is_link ( $ newPath ) ) { symlink ( $ dirToIndex . '/' . $ filename , $ newPath ) ; } } } } | Creates an index of the files in the specified directory by creating symlinks to them which are separated into folders having the first letter . WARNING - this will only index files that start with alphabetical characters . |
21,275 | public static function zipDir ( $ sourceFolder , $ dest , $ deleteOnComplete = true ) { if ( ! extension_loaded ( 'zip' ) ) { throw new \ Exception ( "Your PHP does not have the zip extesion." ) ; } if ( ! file_exists ( $ sourceFolder ) ) { throw new \ Exception ( "Cannot zip non-existent folder" ) ; } $ rootPath = realpath ( $ sourceFolder ) ; $ zip = new \ ZipArchive ( ) ; $ zip -> open ( $ dest , \ ZipArchive :: CREATE ) ; $ files = self :: getDirContents ( $ sourceFolder , true , true , true ) ; $ baseDir = basename ( $ sourceFolder ) ; $ zip -> addEmptyDir ( $ baseDir ) ; foreach ( $ files as $ name => $ filepath ) { $ relativePath = str_replace ( $ sourceFolder , $ baseDir , $ filepath ) ; $ zip -> addFile ( $ filepath , $ relativePath ) ; } $ zip -> close ( ) ; if ( $ deleteOnComplete ) { self :: deleteDir ( $ sourceFolder ) ; } } | Zip a directory and all of its contents into a zip file . |
21,276 | public static function unzip ( $ sourceZip , $ destinationFolder , $ deleteOnComplete = true ) { if ( ! extension_loaded ( 'zip' ) ) { throw new \ Exception ( "Your PHP does not have the zip extesion." ) ; } if ( ! file_exists ( $ destinationFolder ) ) { mkdir ( $ destinationFolder ) ; } $ zip = new \ ZipArchive ( ) ; $ open = $ zip -> open ( $ sourceZip ) ; if ( ! $ open ) { throw new \ Exception ( 'Unable to open zip file: ' . $ sourceZip ) ; } $ unzip = $ zip -> extractTo ( $ destinationFolder ) ; if ( ! $ unzip ) { throw new \ Exception ( 'Unable to unzip file: ' . $ sourceZip . ' to destination: ' . $ destinationFolder ) ; } $ zip -> close ( ) ; if ( $ deleteOnComplete ) { self :: deleteDir ( $ sourceZip ) ; } } | Unzip a zip file and all of its contents into a directory . |
21,277 | public static function downloadFile ( string $ url ) : string { $ downloadedFilepath = tempnam ( sys_get_temp_dir ( ) , "" ) ; if ( function_exists ( 'curl_version' ) ) { $ fp = fopen ( $ downloadedFilepath , 'w+' ) ; $ ch = curl_init ( str_replace ( " " , "%20" , $ url ) ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , 50 ) ; curl_setopt ( $ ch , CURLOPT_FILE , $ fp ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , true ) ; curl_exec ( $ ch ) ; curl_close ( $ ch ) ; fclose ( $ fp ) ; } else { $ content = file_get_contents ( $ url ) ; file_put_contents ( $ downloadedFilepath , $ content ) ; } return $ downloadedFilepath ; } | Download a file from the provided URL This will use curl if it is available if not it will fallback to using file_get_contents . |
21,278 | public static function shouldBeReported ( $ errcode , $ reportingSettings = null ) { if ( ! $ reportingSettings || ! is_numeric ( $ reportingSettings ) ) { $ reportingSettings = ( int ) ( ( new ErrorConfig ( ) ) -> get ( ErrorConfig :: CFG_ERROR_LEVEL ) ) ; } $ reportingSettings = ( int ) $ reportingSettings ; return $ errcode && $ reportingSettings & ( ( int ) $ errcode ) ? true : false ; } | Checks if an error should be reported |
21,279 | public function loadUserByUsername ( $ username ) { if ( ! isset ( $ this -> cachedUsers [ $ username ] ) ) { $ this -> cachedUsers [ $ username ] = $ this -> userProvider -> loadUserByUsername ( $ username ) ; } return $ this -> cachedUsers [ $ username ] ; } | Get user from cached otherwise get it from the source User Provider . |
21,280 | public function refreshUser ( UserInterface $ user ) { $ username = $ user -> getUsername ( ) ; $ this -> cachedUsers [ $ username ] = $ this -> userProvider -> refreshUser ( $ user ) ; return $ this -> cachedUsers [ $ username ] ; } | Refresh user using source User Provider . |
21,281 | public function set ( $ key , $ value ) : HashMap { $ values = $ this -> _set ( $ key , $ value , false ) ; $ this -> setValues ( $ values ) ; return $ this ; } | update an element value |
21,282 | private function _setId ( $ pId ) { $ idField = ItemInterface :: IDFIELD ; if ( ! isset ( $ this -> _fields [ $ idField ] ) or ! $ this -> _fields [ $ idField ] ) { $ this -> _fields [ $ idField ] = $ pId ; } return $ this ; } | Set the insertion ID . |
21,283 | public function commit ( ) { try { $ prepared = Agl :: app ( ) -> getDb ( ) -> getConnection ( ) -> prepare ( " INSERT INTO `" . $ this -> getDbPrefix ( ) . $ this -> _dbContainer . "` (" . $ this -> _getFields ( ) . ") VALUES (" . $ this -> _getPreparedFields ( ) . ") " ) ; if ( ! $ prepared -> execute ( $ this -> _fields ) ) { $ error = $ prepared -> errorInfo ( ) ; throw new Exception ( "The insert query failed (table '" . $ this -> getDbPrefix ( ) . $ this -> _dbContainer . "') with message '" . $ error [ 2 ] . "'" ) ; } if ( Agl :: app ( ) -> isDebugMode ( ) ) { Agl :: app ( ) -> getDb ( ) -> incrementCounter ( ) ; } $ this -> _setId ( Agl :: app ( ) -> getDb ( ) -> getConnection ( ) -> lastInsertId ( ) ) ; return $ prepared -> rowCount ( ) ; } catch ( Exception $ e ) { throw new Exception ( $ e ) ; } return true ; } | Commit the insertion to MySQL and check the query result . |
21,284 | public function generateSlugAndPath ( ) { $ this -> slug = \ Gedmo \ Sluggable \ Util \ Urlizer :: urlize ( $ this -> title ) ; $ category = $ this ; $ pathSegments = array ( $ category -> getSlug ( ) ) ; while ( $ category -> getParent ( ) ) { $ category = $ category -> getParent ( ) ; $ pathSegments [ ] = $ category -> getSlug ( ) ; } $ this -> setPath ( implode ( '/' , array_reverse ( $ pathSegments ) ) ) ; } | Generate slug and path |
21,285 | public static function isNumber ( $ input , array $ options = array ( ) ) { if ( ! self :: _getUniCodeSupport ( ) ) { trigger_error ( "Sorry, your PCRE extension does not support UTF8 which is needed for the I18N core" , E_USER_NOTICE ) ; } $ options = self :: _checkOptions ( $ options ) + self :: $ _options ; $ symbols = Zend_Locale_Data :: getList ( $ options [ 'locale' ] , 'symbols' ) ; $ regexs = Zend_Locale_Format :: _getRegexForType ( 'decimalnumber' , $ options ) ; $ regexs = array_merge ( $ regexs , Zend_Locale_Format :: _getRegexForType ( 'scientificnumber' , $ options ) ) ; if ( ! empty ( $ input ) && ( $ input [ 0 ] == $ symbols [ 'decimal' ] ) ) { $ input = 0 . $ input ; } foreach ( $ regexs as $ regex ) { preg_match ( $ regex , $ input , $ found ) ; if ( isset ( $ found [ 0 ] ) ) { return true ; } } return false ; } | Checks if the input contains a normalized or localized number |
21,286 | public static function toInteger ( $ value , array $ options = array ( ) ) { $ options [ 'precision' ] = 0 ; $ options [ 'number_format' ] = Zend_Locale_Format :: STANDARD ; return self :: toNumber ( $ value , $ options ) ; } | Returns a localized number |
21,287 | public static function isInteger ( $ value , array $ options = array ( ) ) { if ( ! self :: isNumber ( $ value , $ options ) ) { return false ; } if ( self :: getInteger ( $ value , $ options ) == self :: getFloat ( $ value , $ options ) ) { return true ; } return false ; } | Returns if a integer was found |
21,288 | protected function parseExpression ( $ valueExpression ) { $ checkForExpression = substr ( $ valueExpression , 0 , 2 ) ; if ( str_contains ( $ checkForExpression , static :: $ validExpressions ) ) { foreach ( static :: $ validExpressions as $ expression ) { if ( substr ( $ valueExpression , 0 , strlen ( $ expression ) ) === $ expression ) { $ this -> expression = $ expression ; $ this -> value = $ this -> transformValue ( substr ( $ valueExpression , strlen ( $ expression ) ) ) ; return ; } } } $ this -> expression = '=' ; $ this -> value = $ this -> transformValue ( $ valueExpression ) ; } | Split expressionValue into expression and type - checked value |
21,289 | public function override ( $ config ) { self :: _checkArray ( $ config ) ; $ this -> _config = array_replace_recursive ( $ this -> _config , $ config ) ; } | override Merge with configuration array this array overrides the current values override Merges this configuration array with the base configuration override values |
21,290 | protected function updateLog ( $ level , $ message , array $ context = array ( ) ) { if ( $ this -> logger instanceof Logger ) { $ this -> logger -> $ level ( $ message , $ context ) ; $ message_logged = true ; } else { $ message_logged = false ; } return $ message_logged ; } | If it exists logs the message at the supplied level using the set Logger |
21,291 | protected function getModuleNamespace ( ) { if ( null === $ this -> moduleNamespace ) { $ class = get_class ( $ this ) ; $ this -> moduleNamespace = substr ( $ class , 0 , strpos ( $ class , '\\' ) ) ; } return $ this -> moduleNamespace ; } | Retrieve the module namespace |
21,292 | protected function getEntityName ( ) { if ( null === $ this -> entityName ) { $ name = get_class ( $ this ) ; $ type = ucfirst ( $ this -> abstractType ) ; $ name = str_replace ( $ this -> getModuleNamespace ( ) . '\\' . $ type . '\\' , '' , $ name ) ; $ name = str_replace ( $ type , '' , $ name ) ; $ this -> entityName = $ name ; } return $ this -> entityName ; } | Retrieve the entity name |
21,293 | public function Start ( $ Force = FALSE ) { if ( function_exists ( 'apc_fetch' ) && C ( 'Garden.Apc' , FALSE ) ) $ this -> Apc = TRUE ; $ this -> AvailablePlugins ( $ Force ) ; $ this -> EnabledPlugins ( $ Force ) ; $ this -> IncludePlugins ( ) ; $ this -> RegisterPlugins ( ) ; $ this -> Started = TRUE ; $ this -> FireEvent ( 'AfterStart' ) ; } | Sets up the plugin framework |
21,294 | public function IncludePlugins ( $ EnabledPlugins = NULL ) { if ( is_null ( $ EnabledPlugins ) ) $ EnabledPlugins = $ this -> EnabledPlugins ( ) ; $ PluginManager = & $ this ; foreach ( $ EnabledPlugins as $ PluginName => $ Trash ) { $ PluginInfo = $ this -> GetPluginInfo ( $ PluginName ) ; $ ClassName = GetValue ( 'ClassName' , $ PluginInfo , FALSE ) ; $ ClassFile = GetValue ( 'RealFile' , $ PluginInfo , FALSE ) ; if ( $ ClassName !== FALSE && ! class_exists ( $ ClassName , FALSE ) ) if ( file_exists ( $ ClassFile ) ) include_once ( $ ClassFile ) ; } } | Includes all of the plugin files for enabled plugins . |
21,295 | public function RegisterPlugins ( ) { foreach ( get_declared_classes ( ) as $ ClassName ) { if ( $ ClassName == 'Gdn_Plugin' ) continue ; if ( in_array ( 'Gdn_IPlugin' , class_implements ( $ ClassName ) ) ) { if ( array_key_exists ( $ ClassName , $ this -> RegisteredPlugins ) ) continue ; $ this -> RegisterPlugin ( $ ClassName ) ; } } } | Register all enabled plugins event handlers and overrides |
21,296 | public function GetPluginInstance ( $ AccessName , $ AccessType = self :: ACCESS_CLASSNAME , $ Sender = NULL ) { $ ClassName = NULL ; switch ( $ AccessType ) { case self :: ACCESS_PLUGINNAME : $ ClassName = GetValue ( 'ClassName' , $ this -> GetPluginInfo ( $ AccessName ) , FALSE ) ; break ; case self :: ACCESS_CLASSNAME : default : $ ClassName = $ AccessName ; break ; } if ( ! class_exists ( $ ClassName ) ) throw new Exception ( "Tried to load plugin '{$ClassName}' from access name '{$AccessName}:{$AccessType}', but it doesn't exist." ) ; if ( ! array_key_exists ( $ ClassName , $ this -> Instances ) ) { $ this -> Instances [ $ ClassName ] = ( is_null ( $ Sender ) ) ? new $ ClassName ( ) : new $ ClassName ( $ Sender ) ; $ this -> Instances [ $ ClassName ] -> PluginInfo = $ this -> GetPluginInfo ( $ AccessName , $ AccessType ) ; } return $ this -> Instances [ $ ClassName ] ; } | Gets an instance of a given plugin . |
21,297 | public function IsEnabled ( $ Name ) { $ Enabled = $ this -> EnabledPlugins ; return isset ( $ Enabled [ $ Name ] ) && $ Enabled [ $ Name ] ; } | Returns whether or not a plugin is enabled . |
21,298 | public function RegisterHandler ( $ HandlerClassName , $ HandlerMethodName , $ EventClassName = '' , $ EventName = '' , $ EventHandlerType = '' ) { $ HandlerKey = $ HandlerClassName . '.' . $ HandlerMethodName ; $ EventKey = strtolower ( $ EventClassName == '' ? $ HandlerMethodName : $ EventClassName . '_' . $ EventName . '_' . $ EventHandlerType ) ; if ( array_key_exists ( $ EventKey , $ this -> _EventHandlerCollection ) === FALSE ) $ this -> _EventHandlerCollection [ $ EventKey ] = array ( ) ; if ( in_array ( $ HandlerKey , $ this -> _EventHandlerCollection [ $ EventKey ] ) === FALSE ) $ this -> _EventHandlerCollection [ $ EventKey ] [ ] = $ HandlerKey ; } | Registers a plugin method name as a handler . |
21,299 | public function RegisterOverride ( $ OverrideClassName , $ OverrideMethodName , $ EventClassName = '' , $ EventName = '' ) { $ OverrideKey = $ OverrideClassName . '.' . $ OverrideMethodName ; $ EventKey = strtolower ( $ EventClassName == '' ? $ OverrideMethodName : $ EventClassName . '_' . $ EventName . '_Override' ) ; if ( array_key_exists ( $ EventKey , $ this -> _MethodOverrideCollection ) === TRUE ) trigger_error ( ErrorMessage ( 'Any object method can only be overridden by a single plugin. The "' . $ EventKey . '" override has already been assigned by the "' . $ this -> _MethodOverrideCollection [ $ EventKey ] . '" plugin. It cannot also be overridden by the "' . $ OverrideClassName . '" plugin.' , 'PluginManager' , 'RegisterOverride' ) , E_USER_ERROR ) ; $ this -> _MethodOverrideCollection [ $ EventKey ] = $ OverrideKey ; } | Registers a plugin override method . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.