idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
2,100 | public function getColumnSettings ( $ columns = null ) { if ( null == $ columns ) { $ columns = array_map ( function ( $ descriptor ) { return zend_column_name ( $ descriptor ) ; } , $ this -> getColumns ( ) ) ; } $ k = array_find_key ( $ columns , function ( $ v , $ k ) { return $ v == $ this -> getPrimaryKey ( ) ; } ... | Return settings only for set columns |
2,101 | public function findOneBy ( $ conditions ) { debug_assert ( false , 'Function findOneBy is scheduled for deletion, replace with Model::getBy($conditions)' ) ; $ instance = static :: getBy ( $ conditions , array_keys ( $ this -> schemaColumnsGet ( ) ) ) ; $ this -> fromArray ( $ instance -> toArray ( ) ) ; $ this -> cha... | Return one of row from DB or new row with data from params |
2,102 | protected function determineTimezone ( DateLexerResult $ parts , TimeOffset $ offset , DateTimeZone $ inputTz = null ) { if ( null !== $ tz = $ parts -> getFirst ( 'e' , 'O' , 'P' ) ) { return new DateTimeZone ( $ tz ) ; } if ( null !== $ tz = $ offset -> buildTimeZone ( ) ) { return $ tz ; } if ( null !== $ inputTz ) ... | Determine date s timezone . If an offset has been found Timezone has no effect on the date parsing but will have on the date display . |
2,103 | public function newAction ( ) { $ entity = new Family ( ) ; $ form = $ this -> createForm ( new FamilyType ( ) , $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; } | Displays a form to create a new Family entity . |
2,104 | public function add ( $ exception ) { if ( $ this -> checkException ( $ exception ) === FALSE ) { trigger_error ( 'Only subclasses of \Exception and implementations of \Throwable can be aggregated!' , E_USER_ERROR ) ; } $ this -> collection [ ] = $ exception ; } | Add a new exception to the stack |
2,105 | public static function runTask ( $ command , $ groupName , $ immediate = false ) { $ task = ExtensionDataHelper :: buildTask ( $ command , $ groupName ) ; if ( $ task -> registerTask ( ) ) { if ( $ immediate ) { DeferredHelper :: runImmediateTask ( $ task -> model ( ) -> id ) ; } } else { throw new ServerErrorHttpExcep... | Create and run a new deferred task |
2,106 | public static function sendNewMessage ( $ email , $ templateId , $ templateParams = [ ] ) { $ email = explode ( ',' , $ email ) ; foreach ( ( array ) $ email as $ singleEmail ) { $ message = new Message ; $ message -> attributes = [ 'email' => trim ( $ singleEmail ) , 'template_id' => $ templateId , 'packed_json_templa... | Create a new message and send it via deferred tasks |
2,107 | public function Base_GetAppSettingsMenuItems_Handler ( $ Sender ) { $ NumFlaggedItems = Gdn :: SQL ( ) -> Select ( 'fl.ForeignID' , 'DISTINCT' , 'NumFlaggedItems' ) -> From ( 'Flag fl' ) -> GroupBy ( 'ForeignURL' ) -> Get ( ) -> NumRows ( ) ; $ LinkText = T ( 'Flagged Content' ) ; if ( $ NumFlaggedItems ) $ LinkText .=... | Add Flagging to Dashboard menu . |
2,108 | public function ProfileController_AfterPreferencesDefined_Handler ( $ Sender ) { if ( Gdn :: Session ( ) -> CheckPermission ( 'Plugins.Flagging.Notify' ) ) { $ Sender -> Preferences [ 'Notifications' ] [ 'Email.Flag' ] = T ( 'Notify me when a comment is flagged.' ) ; $ Sender -> Preferences [ 'Notifications' ] [ 'Popup... | Let users with permission choose to receive Flagging emails . |
2,109 | public function UserModel_BeforeSaveSerialized_Handler ( $ Sender ) { if ( Gdn :: Session ( ) -> CheckPermission ( 'Plugins.Flagging.Notify' ) ) { if ( $ Sender -> EventArguments [ 'Column' ] == 'Preferences' && is_array ( $ Sender -> EventArguments [ 'Name' ] ) ) { $ UserID = $ Sender -> EventArguments [ 'UserID' ] ; ... | Save Email . Flag preference list in config for easier access . |
2,110 | public function PluginController_Flagging_Create ( $ Sender ) { $ Sender -> Permission ( 'Garden.Moderation.Manage' ) ; $ Sender -> Title ( 'Content Flagging' ) ; $ Sender -> AddSideMenu ( 'plugin/flagging' ) ; $ Sender -> Form = new Gdn_Form ( ) ; $ this -> Dispatch ( $ Sender , $ Sender -> RequestArgs ) ; } | Create virtual Flagging controller . |
2,111 | public function Controller_Index ( $ Sender ) { $ Sender -> AddCssFile ( 'admin.css' ) ; $ Sender -> AddCssFile ( $ this -> GetResource ( 'design/flagging.css' , FALSE , FALSE ) ) ; $ Validation = new Gdn_Validation ( ) ; $ ConfigurationModel = new Gdn_ConfigurationModel ( $ Validation ) ; $ ConfigurationModel -> SetFi... | Get flagged content & show settings . |
2,112 | public function Controller_Dismiss ( $ Sender ) { $ Arguments = $ Sender -> RequestArgs ; if ( sizeof ( $ Arguments ) != 2 ) return ; list ( $ Controller , $ EncodedURL ) = $ Arguments ; $ URL = base64_decode ( str_replace ( '-' , '=' , $ EncodedURL ) ) ; Gdn :: SQL ( ) -> Delete ( 'Flag' , array ( 'ForeignURL' => $ UR... | Dismiss a flag then view index . |
2,113 | public function DiscussionController_AfterDiscussionMeta_Handler ( $ Sender , $ Args ) { if ( Gdn :: Session ( ) -> UserID ) $ this -> AddFlagButton ( $ Sender , $ Args , 'discussion' ) ; } | Add Flag link for discussions . |
2,114 | public function DiscussionController_InsideCommentMeta_Handler ( $ Sender , $ Args ) { if ( Gdn :: Session ( ) -> UserID ) $ this -> AddFlagButton ( $ Sender , $ Args ) ; } | Add Flag link for comments . |
2,115 | protected function AddFlagButton ( $ Sender , $ Args , $ Context = 'comment' ) { $ ElementID = ( $ Context == 'comment' ) ? $ Args [ 'Comment' ] -> CommentID : $ Args [ 'Discussion' ] -> DiscussionID ; if ( ! is_object ( $ Args [ 'Author' ] ) || ! isset ( $ Args [ 'Author' ] -> UserID ) ) { $ ElementAuthorID = 0 ; $ El... | Output Flag link . |
2,116 | public function Structure ( ) { $ Structure = Gdn :: Structure ( ) ; $ Structure -> Table ( 'Flag' ) -> Column ( 'DiscussionID' , 'int(11)' , TRUE ) -> Column ( 'InsertUserID' , 'int(11)' , FALSE , 'key' ) -> Column ( 'InsertName' , 'varchar(64)' ) -> Column ( 'AuthorID' , 'int(11)' ) -> Column ( 'AuthorName' , 'varcha... | Database changes needed for this plugin . |
2,117 | public static function loadClass ( $ className ) { if ( $ className === null ) { throw new WURFL_WURFLException ( "Unable To Load Class : " . $ className ) ; } if ( substr ( $ className , 0 , 6 ) !== WURFL_ClassLoader :: CLASS_PREFIX ) { return false ; } if ( ! class_exists ( $ className , false ) ) { if ( self :: $ cl... | Loads a Class given the class name |
2,118 | protected function getMethod ( MessageInterface $ message , string $ prefix = null ) : Closure { $ name = lcfirst ( $ prefix . $ message -> getPayloadType ( ) -> getName ( ) ) ; if ( method_exists ( $ this , $ name ) === false ) { throw new MethodNotFound ( $ message ) ; } return ( new ReflectionMethod ( $ this , $ nam... | Get method for message . |
2,119 | public function TopMost ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tblCategory = Category :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblCategory -> Field ( 'Archive' ) , $ sql -> Value ( $ this -> archive -> GetID ( ) ) ) -> And_ ( $ sql -> IsNull ( $ tblCategory -> Field ( 'Previous' ) ) ) ; return Cat... | Gets the very first category in the archive |
2,120 | public static function registerModulePath ( $ path ) { if ( file_exists ( $ path ) ) { self :: $ _modulePaths [ ] = $ path ; } else { user_error ( __d ( 'wasabi_cms' , 'Module path {0} does not exist.' , $ path ) ) ; } } | Register a module path . |
2,121 | public static function init ( ) { foreach ( self :: $ _modulePaths as $ path ) { $ folder = new Folder ( $ path ) ; $ modulePaths = $ folder -> read ( true , false , true ) [ 0 ] ; foreach ( $ modulePaths as $ modulePath ) { self :: _initializeModule ( $ modulePath ) ; } } self :: $ _initialized = true ; } | Initialize all available modules . |
2,122 | public static function getAvailableModules ( ) { if ( ! self :: $ _initialized ) { self :: init ( ) ; } $ result = [ ] ; foreach ( self :: $ _modules as $ ns => $ module ) { $ result [ ] = [ 'namespace' => $ ns , 'name' => $ module -> name ( ) , 'description' => $ module -> description ( ) , 'group' => $ module -> grou... | Get all available Modules . |
2,123 | protected static function _initializeModule ( $ modulePath ) { $ moduleFolder = new Folder ( $ modulePath ) ; $ moduleName = basename ( $ moduleFolder -> path ) ; $ moduleClassFilename = $ moduleName . 'Module.php' ; $ moduleClassFile = $ moduleFolder -> find ( $ moduleClassFilename ) ; if ( empty ( $ moduleClassFile )... | Initialize a single module instance . |
2,124 | public function execute ( Event $ event = null ) { $ event = $ event ? $ event : $ this -> createEvent ( ) ; $ this -> logger -> info ( 'Starting web hook handle' ) ; if ( ! $ event -> isValid ( ) ) { $ this -> logger -> error ( 'Found not valid event from ' . $ event -> getHost ( ) ) ; $ this -> return404 ( ) ; return... | Handle git web hook query . |
2,125 | public function enregistreDroits ( ) { if ( isset ( $ this -> variablesPost [ 'idProfilCourant' ] ) && $ this -> variablesPost [ 'idProfilCourant' ] != '' ) { $ reqDelete = "DELETE FROM droits WHERE idProfil='" . $ this -> variablesPost [ 'idProfilCourant' ] . "'" ; $ resDelete = $ this -> connexionBdd -> requete ( $ r... | Enregistre les droits |
2,126 | public function getProfilFromIdProfil ( $ idProfil = 0 ) { $ retour = array ( ) ; $ req = "SELECT idProfil,libelle FROM droitsProfils WHERE idProfil = '" . $ idProfil . "'" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ fetch = mysql_fetch_assoc ( $ res ) ; return $ fetch ; } | Obtenir un profil depuis son ID |
2,127 | public function getArrayListeProfils ( ) { $ retour = array ( ) ; $ req = "SELECT idProfil,libelle FROM droitsProfils" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; while ( $ fetch = mysql_fetch_assoc ( $ res ) ) { $ retour [ $ fetch [ 'idProfil' ] ] = $ fetch [ 'libelle' ] ; } return $ retour ; } | Obtenir une liste des profils |
2,128 | public function generateXMLRequestString ( ) { $ enabledMetadataTypes = array ( ) ; if ( $ this -> enableSocialTags ) { $ enabledMetadataTypes [ ] = 'GenericRelations' ; } if ( $ this -> enableGenericRelations ) { $ enabledMetadataTypes [ ] = 'SocialTags' ; } $ xml = '<c:params xmlns:c="http://s.opencalais.com/1/pred/"... | Generate XML request string from parameters |
2,129 | public function setOutputFormat ( $ outputFormat ) { $ allowedFormats = array ( 'xml/rdf' , 'text/simple' , 'text/microformats' , 'application/json' , 'text/n3' ) ; if ( ! in_array ( strtolower ( $ outputFormat ) , $ allowedFormats ) ) { throw new \ InvalidArgumentException ( "Illegal output format, allowed output form... | Set output format |
2,130 | public function setContentType ( $ contentType ) { $ allowedTypes = array ( 'text/html' , 'text/xml' , 'text/htmlraw' , 'text/raw' ) ; if ( ! in_array ( strtolower ( $ contentType ) , $ allowedTypes ) ) { throw new \ InvalidArgumentException ( "Illegal content type, allowed content types are " . implode ( ', ' , $ allo... | Set request data content type |
2,131 | public function content ( ) { $ path = '../App/' . $ this -> viewsDir . $ this -> view . '.phtml' ; if ( file_exists ( $ path ) ) { require $ path ; } else { die ( 'No view file ' . $ this -> view . ' present in view directory.' ) ; } } | Content function - it is use in template file |
2,132 | public function partial ( $ view ) { $ path = '../App/' . $ this -> viewsDir . $ view . '.phtml' ; if ( file_exists ( $ path ) ) { require $ path ; } else { die ( 'No partial view file ' . $ view . ' present in view directory.' ) ; } } | Partial function - rendering a piece of code . |
2,133 | public function jsonResponse ( $ data ) { $ this -> _headers [ ] = 'Content-Type: application/json' ; if ( ! headers_sent ( ) ) { foreach ( $ this -> _headers as $ header ) { header ( $ header , true ) ; } } echo json_encode ( $ data ) ; } | Response with JSON format without view and template |
2,134 | protected function isAllowed ( ) { if ( is_null ( $ user = auth ( ) -> user ( ) ) ) return false ; return $ user -> isAdmin ( ) || $ user -> isModerator ( ) ; } | Check if the user is allowed . |
2,135 | public function createQueryBuilder ( array $ criteria = null , array $ orderBy = null , $ limit = null , $ offset = null , $ class = null ) { $ baseQueryBuilder = $ this -> createBaseQueryBuilder ( $ class ) ; $ queryBuilder = $ this -> alterBaseQueryBuilder ( $ baseQueryBuilder ) ; if ( ! is_null ( $ criteria ) ) { fo... | Create an queryBuilder object for an Entity class |
2,136 | public function find ( $ id ) { if ( ! ( $ object = $ this -> getDoctrineEntityRepository ( ) -> find ( $ id ) ) ) { $ this -> throwException ( sprintf ( 'The resource \'%s\' was not found' , $ id ) , 'not-found' ) ; } return $ object ; } | Get an resource by id or throw 404 Not Found Http Exception . |
2,137 | public function findOneBy ( array $ criteria ) { $ query = $ this -> createQueryBuilder ( $ criteria ) ; if ( ! ( $ object = $ this -> getOneOrNullResultFromQueryBuilder ( $ query ) ) ) { $ this -> throwException ( 'The resource was not found' , 'not-found' ) ; } return $ object ; } | Get an resource by an array criteria or throw 404 Not Found Http Exception . |
2,138 | public function findOneByName ( $ name ) { $ qb = $ this -> createQueryBuilder ( ) ; $ qb -> andWhere ( $ qb -> getRootAliases ( ) [ 0 ] . '.name = ' . $ this -> addNamedParameter ( 'name' , $ name , $ qb ) ) ; $ result = $ qb -> getQuery ( ) -> getOneOrNullResult ( ) ; return $ result ; } | Get an resource by name . |
2,139 | public function findOneOrNullBy ( array $ criteria ) { $ query = $ this -> createQueryBuilder ( $ criteria ) ; $ object = $ this -> getOneOrNullResultFromQueryBuilder ( $ query ) ; return $ object ; } | OGet an resource by an array criteria |
2,140 | public function findBy ( array $ criteria , array $ orderBy = null , $ limit = null , $ offset = null ) { $ query = $ this -> createQueryBuilder ( $ criteria , $ orderBy , $ limit , $ offset ) ; return $ this -> getResultFromQueryBuilder ( $ query ) ; } | Find some elements by an array criteria |
2,141 | public function findAll ( ) { $ query = $ this -> createQueryBuilder ( ) ; $ cacheDriver = new \ Doctrine \ Common \ Cache \ ArrayCache ( ) ; if ( ! $ cacheDriver -> contains ( 'cache_id' ) ) { $ array = $ this -> getResultFromQueryBuilder ( $ query ) ; $ cacheDriver -> save ( 'my_array' , $ array ) ; } else { $ array ... | Find all elements by default |
2,142 | public function checkAccess ( $ action , $ resource ) { if ( ( is_null ( $ resource ) || is_null ( $ resource -> getId ( ) ) ) && ( empty ( $ action ) || in_array ( strtolower ( $ action ) , array ( 'list' , 'create' , 'post' ) ) ) ) { return true ; } if ( ! is_null ( $ resource ) ) { $ query = $ this -> createQueryBui... | Verify access for an action and a resource |
2,143 | public function persist ( $ object , $ flushed = true ) { $ this -> prePersist ( $ object ) ; $ em = $ this -> getEntityManager ( ) ; $ em -> persist ( $ object ) ; if ( $ flushed ) { $ em -> flush ( $ object ) ; } $ this -> postPersist ( $ object ) ; return $ object ; } | Persist an element |
2,144 | public function persistWithoutPreAndPostPersist ( $ object , $ flushed = true ) { $ em = $ this -> getEntityManager ( ) ; $ em -> persist ( $ object ) ; if ( $ flushed ) { $ em -> flush ( $ object ) ; } return $ object ; } | Persist an element without prePersist and postPersist actions |
2,145 | public function prePersist ( $ object ) { if ( $ this -> getHasContextProperty ( ) ) { $ this -> getResourceContextManager ( ) -> addContextRelationToObject ( $ object , $ this -> getContextPropertyValueNamePrefix ( ) ) ; } $ object -> setCreatedAt ( new \ Datetime ( ) ) ; $ object -> setUpdatedAt ( new \ Datetime ( ) ... | Actions before persist an element |
2,146 | public function update ( $ object , $ flushed = true ) { $ this -> preUpdate ( $ object , $ flushed ) ; $ em = $ this -> getEntityManager ( ) ; $ em -> persist ( $ object ) ; if ( $ flushed ) { $ em -> flush ( $ object ) ; } $ this -> postUpdate ( $ object , $ flushed ) ; return $ object ; } | Update an element |
2,147 | public function removeWithoutPreAndPostRemove ( $ object , $ flushed = true ) { $ em = $ this -> getEntityManager ( ) ; $ em -> remove ( $ object ) ; if ( $ flushed ) { $ em -> flush ( $ object ) ; } return $ object ; } | Remove an element without preRemove and postRemove actions |
2,148 | public function strip ( $ pageContent , $ wrap ) { $ pattern = '/' . $ wrap . '(.*?)' . $ wrap . '/s' ; $ match = preg_match ( $ pattern , $ pageContent , $ matches ) ; if ( $ match ) { $ page [ 'config' ] = $ matches [ 1 ] ; $ page [ 'content' ] = str_replace ( $ matches [ 0 ] , '' , $ pageContent ) ; return $ page ; ... | Strip the config from the page and return the config and content in an array . |
2,149 | public function addValue ( $ value ) { $ this -> values = array_values ( array_unique ( array_merge ( $ this -> values , $ this -> prepareValues ( $ value ) ) ) ) ; } | Adds the given values to the internal list . |
2,150 | public static function getRegisteredName ( string $ name ) : string { $ key = strtolower ( $ name ) ; return isset ( self :: $ headers [ $ key ] ) ? self :: $ headers [ $ key ] [ 'name' ] : $ name ; } | Returns the registered name of a header . |
2,151 | public static function hasMultipleValues ( string $ name ) : bool { $ key = strtolower ( $ name ) ; return isset ( self :: $ headers [ $ key ] ) ? self :: $ headers [ $ key ] [ 'multiple' ] : true ; } | Checks if the header can contain multiple values separated by comma . |
2,152 | private function prepareValues ( $ value ) : array { if ( ! self :: hasMultipleValues ( $ this -> name ) ) { $ values = is_array ( $ value ) ? $ value : [ trim ( $ value ) ] ; } elseif ( ! is_array ( $ value ) ) { $ values = explode ( ',' , ( string ) $ value ) ; } else { $ values = $ value ; } foreach ( array_keys ( $... | Splits comma - separated strings into an array and removes whitespaces and empty values . |
2,153 | public function create ( string $ table , array $ data ) { $ data [ 'created_at' ] = time ( ) ; $ this -> db -> insert ( $ table , $ data ) ; $ id = $ this -> db -> id ( ) ; if ( $ id ) { return $ id ; } else { return false ; } } | Criar linha no banco de dados |
2,154 | public function update ( string $ table , array $ data , array $ where ) { $ created_at = $ this -> db -> get ( $ table , 'created_at' , $ where ) ; $ data [ 'updated_at' ] = time ( ) ; return $ this -> db -> update ( $ table , $ data , $ where ) ; $ data = [ 'created_at' => $ created_at ] ; return $ this -> db -> upda... | Atualiza uma linha do banco de dados |
2,155 | public function isCacheActual ( ) { if ( ! isset ( $ this -> latestCachingTime ) ) { return false ; } return ( ( time ( ) - $ this -> latestCachingTime ) > self :: ONE_DAY_IN_SECONDS ) ; } | Define a criteria which indicates the actual datastore with cache is not outdated . |
2,156 | public function levelToJSLogger ( $ level ) { switch ( $ level ) { case Client :: LOG_LEVEL_WARN : return 'warn' ; break ; case Client :: LOG_LEVEL_ERROR : case Client :: LOG_LEVEL_FATAL : return 'error' ; break ; case Client :: LOG_LEVEL_INFO : return 'info' ; break ; case Client :: LOG_LEVEL_DEBUG : default : return ... | log level convert to javascript logger level |
2,157 | protected function decodeField ( $ tsvField ) { if ( false === stripos ( $ tsvField , static :: DELIMITER ) ) { throw new \ RuntimeException ( sprintf ( 'Could not unserialize LTSV field(%s).' , $ tsvField ) ) ; } return explode ( static :: DELIMITER , $ tsvField , 2 ) ; } | Decode LTSV field . |
2,158 | public function getRealClassName ( string $ virtual ) : string { assert ( isset ( $ this -> virtualMap [ $ virtual ] ) ) ; return $ this -> virtualMap [ $ virtual ] ; } | Only ConfigProviderAbstract can call this function . So ConfigProviderAbstract is responsible for the assertion . |
2,159 | public function remove_path ( $ path ) { foreach ( $ this -> paths as $ i => $ p ) { if ( $ p === $ path ) { unset ( $ this -> paths [ $ i ] ) ; break ; } } return $ this ; } | Removes a path from the search path . |
2,160 | public function flash ( $ paths ) { if ( ! is_array ( $ paths ) ) { $ paths = array ( $ paths ) ; } foreach ( $ paths as $ path ) { $ this -> flash_paths [ ] = $ this -> prep_path ( $ path ) ; } return $ this ; } | Adds multiple flash paths . |
2,161 | public function prep_path ( $ path ) { $ path = str_replace ( array ( '/' , '\\' ) , DS , $ path ) ; return rtrim ( $ path , DS ) . DS ; } | Prepares a path for usage . It ensures that the path has a trailing Directory Separator . |
2,162 | public function prep_paths ( array $ paths ) { foreach ( $ paths as & $ path ) { $ path = $ this -> prep_path ( $ path ) ; } return $ paths ; } | Prepares an array of paths . |
2,163 | public function locate ( $ dir , $ file , $ ext = '.php' , $ multiple = false , $ cache = true ) { $ found = $ multiple ? array ( ) : false ; if ( $ file [ 0 ] === '/' or substr ( $ file , 1 , 2 ) === ':\\' ) { if ( ! is_file ( $ file ) ) { return $ found ; } return $ multiple ? array ( $ file ) : $ file ; } $ cache_id... | Locates a given file in the search paths . |
2,164 | public function read_cache ( $ cache_id ) { empty ( $ this -> cache_dir ) and $ this -> cache_dir = \ Config :: get ( 'cache_dir' , APPPATH . 'cache/' ) ; empty ( $ this -> cache_lifetime ) and $ this -> cache_lifetime = \ Config :: get ( 'cache_lifetime' , 3600 ) ; if ( $ cached = $ this -> cache ( $ cache_id ) ) { $ ... | Reads in the cached paths with the given cache id . |
2,165 | protected function cache ( $ name , $ data = null , $ lifetime = null ) { $ file = $ name . '.pathcache' ; $ dir = rtrim ( $ this -> cache_dir , DS ) . DS ; if ( $ lifetime === NULL ) { $ lifetime = $ this -> cache_lifetime ; } if ( $ data === null ) { if ( is_file ( $ dir . $ file ) ) { if ( ( time ( ) - filemtime ( $... | This method does basic filesystem caching . It is used for things like path caching . |
2,166 | public function get ( $ cacheGroupKey , array $ params = [ ] , $ tags = null ) { if ( ! $ this -> isCachingEnabled ( ) ) { return ; } $ cacheGroup = $ this -> getCacheGroup ( $ cacheGroupKey ) ; if ( ! $ tags ) { $ tags = $ cacheGroupKey ; } if ( empty ( $ cacheGroup ) || ( empty ( $ cacheGroup [ 'active' ] ) || empty ... | Retrieve cache . |
2,167 | public function put ( $ cacheGroupKey , array $ params , $ data , $ tags = [ 'default' ] ) { if ( ! $ this -> isCachingEnabled ( ) ) { return false ; } $ cacheGroup = $ this -> getCacheGroup ( $ cacheGroupKey ) ; if ( ! $ tags ) { $ tags = $ cacheGroupKey ; } if ( empty ( $ cacheGroup ) || ( empty ( $ cacheGroup [ 'act... | Write to cache . |
2,168 | public function getCacheGroup ( $ cacheGroup ) { return ! empty ( $ this -> cacheGroups [ $ cacheGroup ] ) ? $ this -> cacheGroups [ $ cacheGroup ] : null ; } | Retrieve cache group . |
2,169 | private function generateCacheKey ( $ key , $ params ) { if ( is_array ( $ params ) ) { asort ( $ params ) ; $ params = http_build_query ( $ params ) ; } return $ key . '|' . $ params ; } | Generate cache key . |
2,170 | private function setupCacheGroups ( array $ groups ) { foreach ( $ groups as $ group => $ keys ) { if ( ! is_array ( $ keys ) ) { continue ; } foreach ( $ keys as $ key => $ settings ) { $ groupName = $ group . '.' . $ key ; if ( array_key_exists ( $ groupName , $ this -> cacheGroups ) ) { continue ; } $ this -> cacheG... | Setup cache groups . |
2,171 | public static function A2af ( $ ndp , $ angle , & $ sign , array & $ idmsf ) { $ F = 15.0 / D2PI ; static :: D2tf ( $ ndp , $ angle * $ F , $ sign , $ idmsf ) ; return ; } | - - - - - - - - i a u A 2 a f - - - - - - - - |
2,172 | protected function loadProperties ( ) { $ methods = get_class_methods ( $ this ) ; foreach ( $ methods as $ method ) { preg_match ( "/load[a-zA-Z]+Property/" , $ method , $ matches ) ; if ( count ( $ matches ) ) { $ this -> $ method ( ) ; } } } | Run all defined property loader methods . |
2,173 | final public static function factory ( WebDriver_Command $ command , array $ infoList = [ ] , $ rawResponse = null ) { $ httpStatusCode = isset ( $ infoList [ 'http_code' ] ) ? $ infoList [ 'http_code' ] : 0 ; $ messageList = [ $ rawResponse , static :: getCommandDescription ( $ command ) ] ; $ message = implode ( "\n"... | Factory for Invalid Request errors . |
2,174 | private static function validateArray ( array $ object ) : bool { return ( count ( $ object ) === 2 ) && ( isset ( $ object [ 0 ] ) ) && ( is_object ( $ object [ 0 ] ) ) && ( isset ( $ object [ 1 ] ) ) && ( is_string ( $ object [ 1 ] ) ) && ( $ object [ 0 ] instanceof $ object [ 1 ] ) ; } | Validate array . |
2,175 | public static function statusCodeText ( $ code , $ text = "" ) { switch ( $ code ) { case 100 : $ text = 'Continue' ; break ; case 101 : $ text = 'Switching Protocols' ; break ; case 200 : $ text = 'OK' ; break ; case 201 : $ text = 'Created' ; break ; case 202 : $ text = 'Accepted' ; break ; case 203 : $ text = 'Non-A... | Lookup a text representation of HTTP status codes . |
2,176 | public function save ( ) { $ response = $ this -> client -> put ( '/{id}' , [ $ this -> data -> code ] , $ this -> data ) ; if ( ! $ response -> hasErrors ( ) ) { $ this -> event -> dispatch ( 'PLAN.UPDATE' , new PlansEvent ( $ this -> data ) ) ; } return $ this ; } | Save a plan |
2,177 | public function setInterval ( $ unit = self :: INTERVAL_MONTH , $ length = 1 ) { $ this -> data -> interval = new stdClass ; $ this -> data -> interval -> unit = $ unit ; $ this -> data -> interval -> length = $ length ; return $ this ; } | Set plan interval |
2,178 | public function setTrial ( $ enable = false , $ days = null , $ hold_setup_fee = false ) { $ this -> data -> trial = new stdClass ; $ this -> data -> trial -> enabled = ( boolean ) $ enable ; $ this -> data -> trial -> days = $ days ; $ this -> data -> trial -> hold_setup_fee = ( boolean ) $ hold_setup_fee ; return $ t... | Set plan trial |
2,179 | public static function normalizeName ( $ name ) { if ( is_object ( $ name ) ) { $ name = get_class ( $ name ) ; } else { $ name = ( string ) $ name ; } $ name = preg_replace ( '/[^\w\.\\\\]+/' , '' , $ name ) ; $ name = preg_replace ( '/[\\_]/' , '.' , $ name ) ; return $ name ; } | Normalize a given logger name . |
2,180 | function ctc_post_type_options ( ) { $ options = array ( ) ; $ post_types = get_post_types ( array ( 'public' => true , 'show_ui' => true , 'has_archive' => true ) , 'objects' ) ; foreach ( $ post_types as $ post_type_slug => $ post_type_object ) { $ post_type_name = $ post_type_object -> labels -> name ; $ options [ $... | Post type options |
2,181 | private function calculateExperience ( $ playerA , $ playerB ) { $ difference = $ playerB -> getElo ( ) - $ playerA -> getElo ( ) ; $ exp = $ difference / $ this -> configuration -> getFloor ( ) ; return 1 / ( 1 + pow ( 10 , $ exp ) ) ; } | Estimate experience between player A - player B or player B - player A |
2,182 | private function estimateRange ( EloPlayerInterface $ player ) { $ baseRange = new ArrayCollection ( $ this -> configuration -> getBaseRange ( ) ) ; $ keys = array_keys ( $ this -> configuration -> getBaseRange ( ) ) ; $ estimatedRange = $ baseRange -> first ( ) ; $ i = 0 ; foreach ( $ baseRange as $ eloMin => $ range ... | Get estimate points |
2,183 | final protected function checkRequiredFields ( ) { foreach ( $ this -> getRequiredFields ( ) as $ requiredField ) { $ value = $ this -> getAttribute ( $ requiredField ) ; if ( empty ( $ value ) ) { throw new RequiredFieldException ( $ requiredField ) ; } } } | Checks required fields |
2,184 | final public function toArray ( ) { $ this -> checkRequiredFields ( ) ; $ fields = get_object_vars ( $ this ) ; $ array = [ ] ; foreach ( $ fields as $ field => $ value ) { $ array [ $ field ] = $ this -> transformToArray ( $ this -> getAttribute ( $ field ) ) ; } return $ array ; } | Converts Model to array for Soap Request |
2,185 | public function getName ( $ file = "" , $ default = null ) { $ file = ( empty ( $ file ) && isset ( $ this -> file ) ) ? $ this -> file : $ file ; if ( empty ( $ file ) ) { return $ default ; } return pathinfo ( $ file , PATHINFO_FILENAME ) ; } | Get File Name |
2,186 | public function getExtension ( $ file = "" , $ default = null ) { $ file = ( empty ( $ file ) && isset ( $ this -> file ) ) ? $ this -> file : $ file ; if ( empty ( $ file ) ) { return $ default ; } return pathinfo ( $ file , PATHINFO_EXTENSION ) ; } | Gets the file extension ; |
2,187 | final public function getPath ( $ file = "" , $ default = null ) { $ file = ( empty ( $ file ) && isset ( $ this -> file ) ) ? $ this -> file : $ file ; if ( empty ( $ file ) ) { return $ default ; } return pathinfo ( $ file , PATHINFO_DIRNAME ) ; } | Returns only the directory name from the filepath ; |
2,188 | public function getFileStream ( $ file , $ mode = "w+" ) { if ( ( $ handle = fopen ( $ file , $ mode ) ) == false ) { return false ; } return $ handle ; } | Get the file stream |
2,189 | public function getModifiedDate ( $ path ) { $ lmodified = 0 ; $ files = glob ( $ path . '/*' ) ; foreach ( $ files as $ file ) { if ( is_dir ( $ file ) ) { $ modified = dirmtime ( $ file ) ; } else { $ modified = filemtime ( $ file ) ; } if ( $ modified > $ lmodified ) { $ lmodified = $ modified ; } } return $ lmodifi... | Returns the UNIX timestamp representation of the last time the folder was modified |
2,190 | public function move ( $ path , $ toPath , $ deleteOriginal = true ) { if ( copy ( $ path , $ toPath ) ) { if ( $ deleteOriginal ) { if ( ! $ this -> remove ( $ path ) ) { } } return true ; } return false ; } | Moves the folder to a new location |
2,191 | final public function delete ( $ path ) { if ( $ this -> isWritable ( $ path ) ) { if ( ! @ unlink ( $ path ) ) { return false ; } } else { if ( ! @ unlink ( $ path ) ) { return false ; } } return true ; } | Deletes a file or folder if exists |
2,192 | public function copy ( $ path , $ toPath ) { if ( empty ( $ path ) || empty ( $ toPath ) ) return false ; return copy ( $ path , $ toPath ) ; } | Copies the file or folder to a new destination |
2,193 | public function setFile ( $ file ) { if ( ! $ this -> isFile ( $ file ) ) { return false ; } $ this -> file = $ file ; $ this -> pathinfo [ $ file ] = pathinfo ( $ file ) ; return $ this ; } | Sets the file for execution |
2,194 | public function getMimeType ( $ path , $ default = "application/octet-stream" ) { $ finfo = finfo_open ( FILEINFO_MIME_TYPE ) ; $ fmtype = finfo_file ( $ finfo , $ path ) ; finfo_close ( $ finfo ) ; return ! empty ( $ fmtype ) ? $ fmtype : $ default ; } | Get the MimeType of a file ; |
2,195 | public static function of ( ... $ elements ) : self { if ( count ( $ elements ) === 1 ) { $ elements = $ elements [ 0 ] ; } if ( $ elements instanceof self ) { return $ elements ; } if ( $ elements instanceof \ Traversable || is_array ( $ elements ) ) { return new self ( $ elements ) ; } return new self ( [ $ elements ... | creates sequence of given data |
2,196 | public static function generate ( $ seed , callable $ operation , callable $ validator ) : self { return new self ( new Generator ( $ seed , $ operation , $ validator ) ) ; } | creates a sequence which generates values while being worked on |
2,197 | public function limit ( int $ n ) : self { return new self ( new Limit ( $ this -> getIterator ( ) , 0 , $ n ) , $ this -> type ) ; } | limits sequence to the first n elements |
2,198 | public function skip ( int $ n ) : self { return new self ( new Limit ( $ this -> getIterator ( ) , $ n ) , $ this -> type ) ; } | skips the first n elements of the sequence |
2,199 | public function filter ( callable $ predicate ) : self { return new self ( new Filter ( $ this -> getIterator ( ) , $ predicate ) , $ this -> type ) ; } | returns a new sequence with elements matching the given predicate |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.