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 ( ) ; } ) ; if ( null !== $ k ) { unset ( $ columns [ $ k ] ) ; } return array_join ( $ columns , $ this -> _settings , false ) ; } | 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 -> changedColumnsReset ( ) ; return $ this ; } | 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 ) { return $ inputTz ; } return new DateTimeZone ( date_default_timezone_get ( ) ) ; } | 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 ServerErrorHttpException ( "Unable to start task" ) ; } } | 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_template_params' => Json :: encode ( $ templateParams ) , 'status' => Message :: STATUS_NEW , ] ; if ( $ message -> save ( ) ) { static :: runTask ( [ realpath ( Yii :: getAlias ( '@app' ) . '/yii' ) , 'emails/send' , $ message -> id , ] , Module :: DEFERRED_TASK_GROUP_MESSAGE_SEND ) ; } } } | 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 .= ' <span class="Alert">' . $ NumFlaggedItems . '</span>' ; $ Menu = $ Sender -> EventArguments [ 'SideMenu' ] ; $ Menu -> AddItem ( 'Forum' , T ( 'Forum' ) ) ; $ Menu -> AddLink ( 'Forum' , $ LinkText , 'plugin/flagging' , 'Garden.Moderation.Manage' ) ; } | 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.Flag' ] = T ( 'Notify me when a comment is flagged.' ) ; } } | 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' ] ; $ Prefs = $ Sender -> EventArguments [ 'Name' ] ; $ FlagPref = GetValue ( 'Email.Flag' , $ Prefs , NULL ) ; if ( $ FlagPref !== NULL ) { $ NotifyUsers = C ( 'Plugins.Flagging.NotifyUsers' , array ( ) ) ; $ IsNotified = array_search ( $ UserID , $ NotifyUsers ) ; if ( $ IsNotified !== FALSE && ! $ FlagPref ) { unset ( $ NotifyUsers [ $ IsNotified ] ) ; } elseif ( $ IsNotified === FALSE && $ FlagPref ) { $ NotifyUsers [ ] = $ UserID ; } SaveToConfig ( 'Plugins.Flagging.NotifyUsers' , array_values ( $ NotifyUsers ) ) ; } } } } | 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 -> SetField ( array ( 'Plugins.Flagging.UseDiscussions' , 'Plugins.Flagging.CategoryID' ) ) ; $ Sender -> Form -> SetModel ( $ ConfigurationModel ) ; if ( $ Sender -> Form -> AuthenticatedPostBack ( ) === FALSE ) { $ Sender -> Form -> SetData ( $ ConfigurationModel -> Data ) ; } else { $ Saved = $ Sender -> Form -> Save ( ) ; if ( $ Saved ) { $ Sender -> InformMessage ( T ( "Your changes have been saved." ) ) ; } } $ FlaggedItems = Gdn :: SQL ( ) -> Select ( '*' ) -> From ( 'Flag fl' ) -> OrderBy ( 'DateInserted' , 'DESC' ) -> Get ( ) ; $ Sender -> FlaggedItems = array ( ) ; while ( $ Flagged = $ FlaggedItems -> NextRow ( DATASET_TYPE_ARRAY ) ) { $ URL = $ Flagged [ 'ForeignURL' ] ; $ Index = $ Flagged [ 'DateInserted' ] . '-' . $ Flagged [ 'InsertUserID' ] ; $ Flagged [ 'EncodedURL' ] = str_replace ( '=' , '-' , base64_encode ( $ Flagged [ 'ForeignURL' ] ) ) ; $ Sender -> FlaggedItems [ $ URL ] [ $ Index ] = $ Flagged ; } unset ( $ FlaggedItems ) ; $ Sender -> Render ( $ this -> GetView ( 'flagging.php' ) ) ; } | 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' => $ URL ) ) ; $ this -> Controller_Index ( $ Sender ) ; } | 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 ; $ ElementAuthor = 'Unknown' ; } else { $ ElementAuthorID = $ Args [ 'Author' ] -> UserID ; $ ElementAuthor = $ Args [ 'Author' ] -> Name ; } switch ( $ Context ) { case 'comment' : $ URL = "/discussion/comment/{$ElementID}/#Comment_{$ElementID}" ; break ; case 'discussion' : $ URL = "/discussion/{$ElementID}/" . Gdn_Format :: Url ( $ Args [ 'Discussion' ] -> Name ) ; break ; default : return ; } $ EncodedURL = str_replace ( '=' , '-' , base64_encode ( $ URL ) ) ; $ FlagLink = Anchor ( T ( 'Flag' ) , "discussion/flag/{$Context}/{$ElementID}/{$ElementAuthorID}/" . Gdn_Format :: Url ( $ ElementAuthor ) . "/{$EncodedURL}" , 'FlagContent Popup' ) ; echo Wrap ( $ FlagLink , 'span' , array ( 'class' => 'MItem CommentFlag' ) ) ; } | 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' , 'varchar(64)' ) -> Column ( 'ForeignURL' , 'varchar(255)' , FALSE , 'key' ) -> Column ( 'ForeignID' , 'int(11)' ) -> Column ( 'ForeignType' , 'varchar(32)' ) -> Column ( 'Comment' , 'text' ) -> Column ( 'DateInserted' , 'datetime' ) -> Set ( FALSE , FALSE ) ; if ( C ( 'Plugins.Flagging.Enabled' , NULL ) === FALSE ) { RemoveFromConfig ( 'EnabledPlugins.Flagging' ) ; } } | 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 :: $ classPath === null ) self :: $ classPath = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR ; $ classFilePath = str_replace ( '_' , DIRECTORY_SEPARATOR , substr ( $ className , 6 ) ) . '.php' ; include self :: $ classPath . $ classFilePath ; } return false ; } | 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 , $ name ) ) -> getClosure ( $ this ) ; } | 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 Category :: Schema ( ) -> First ( $ where ) ; } | 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 -> group ( ) , 'icon' => $ module -> icon ( ) ] ; } return $ result ; } | 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 ) ) { user_error ( __d ( 'wasabi_cms' , 'Module {0} has no associated class file {1} in {3}.' , $ moduleName , $ moduleClassFilename , $ modulePath ) ) ; } $ moduleClassFile = $ moduleClassFile [ 0 ] ; $ moduleNamespace = self :: _extractNamespace ( $ modulePath . DS . $ moduleClassFile ) ; if ( ! $ moduleNamespace ) { user_error ( __d ( 'wasabi_cms' , 'Module {3} has no namespace.' ) ) ; } $ class = $ moduleNamespace . '\\' . $ moduleName . 'Module' ; self :: $ _modules [ $ class ] = new $ class ( ) ; } | 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 ; } if ( ! $ this -> checkPermissions ( $ event , $ this -> options ) ) { return ; } $ repoName = $ event -> getRepositoryName ( ) ; $ branchName = $ event -> getBranchName ( ) ; $ repository = $ this -> getRepository ( $ repoName ) ; if ( ! $ repository || ! ( $ branch = $ repository -> getBranch ( $ branchName ) ) ) { $ this -> logger -> warning ( 'Repository: ' . $ repoName . ' and branch: ' . $ branchName . ' not found in the settings' ) ; $ this -> return404 ( ) ; return ; } $ commandResults = $ this -> commandExecutor -> execute ( array ( $ this , $ repository , $ branch ) ) ; $ this -> sendEmails ( $ event , $ commandResults ) ; $ this -> logger -> info ( 'End of web hook handle' ) ; } | 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 ( $ reqDelete ) ; if ( isset ( $ this -> variablesPost [ 'idElementSite' ] ) ) { $ idElementSite = $ this -> variablesPost [ 'idElementSite' ] ; foreach ( $ idElementSite as $ indice => $ value ) { $ reqInsert = "INSERT INTO droits (idProfil,idElementSite,acces) VALUES ('" . $ this -> variablesPost [ 'idProfilCourant' ] . "','" . $ value . "','1')" ; $ resInsert = $ this -> connexionBdd -> requete ( $ reqInsert ) ; } } } } | 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/" ' ; $ xml .= 'xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' ; $ xml .= '<c:processingDirectives ' ; $ xml .= 'c:contentType="' . $ this -> contentType . '" ' ; $ xml .= 'c:enableMetadataType="' . implode ( ',' , $ enabledMetadataTypes ) . '" ' ; $ xml .= 'c:outputFormat="' . $ this -> outputFormat . '" ' ; $ xml .= 'c:docRDFaccessible="' . ( $ this -> docRDFaccessible ? 'true' : 'false' ) . '" ' ; $ xml .= '></c:processingDirectives>' ; $ xml .= '<c:userDirectives ' ; $ xml .= 'c:allowDistribution="' . ( $ this -> allowDistribution ? 'true' : 'false' ) . '" ' ; $ xml .= 'c:allowSearch="' . ( $ this -> allowSearch ? 'true' : 'false' ) . '" ' ; $ xml .= '></c:userDirectives>' ; $ xml .= '<c:externalMetadata></c:externalMetadata>' ; $ xml .= '</c:params>' ; return $ xml ; } | 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 formats are " . implode ( ', ' , $ allowedFormats ) ) ; } $ this -> outputFormat = $ outputFormat ; return $ this ; } | 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 ( ', ' , $ allowedTypes ) ) ; } $ this -> contentType = $ contentType ; return $ this ; } | 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 ) ) { foreach ( $ criteria as $ key => $ value ) { $ queryBuilder -> andWhere ( $ queryBuilder -> getRootAliases ( ) [ 0 ] . '.' . $ key . ' = ' . $ this -> addNamedParameter ( $ key , $ value , $ queryBuilder ) ) ; } } if ( ! is_null ( $ orderBy ) ) { foreach ( $ orderBy as $ sort => $ order ) { $ queryBuilder -> addOrderBy ( $ queryBuilder -> getRootAliases ( ) [ 0 ] . '.' . $ sort , $ order ) ; } } if ( ! is_null ( $ limit ) ) { $ queryBuilder -> setMaxResults ( $ limit ) ; } if ( ! is_null ( $ offset ) ) { $ queryBuilder -> setFirstResult ( $ offset ) ; } return $ queryBuilder ; } | 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 = $ cacheDriver -> fetch ( 'my_array' ) ; } return $ 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 -> createQueryBuilder ( ) ; $ query -> andWhere ( $ query -> getRootAliases ( ) [ 0 ] . '.id = ' . $ this -> addNamedParameter ( 'id' , $ resource , $ query ) ) ; $ result = $ this -> getOneOrNullResultFromQueryBuilder ( $ query ) ; if ( $ result ) { return true ; } else { $ this -> throwException ( 'Access for this resource has been denied' , 'access-denied' ) ; } } } | 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 ( ) ) ; if ( is_null ( $ object -> getEnabled ( ) ) ) { $ object -> setEnabled ( true ) ; } return $ object ; } | 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 ; } return array ( 'config' => '' , 'content' => $ pageContent ) ; } | 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 ( $ values ) as $ key ) { $ values [ $ key ] = trim ( $ values [ $ key ] ) ; if ( $ values [ $ key ] == '' ) { unset ( $ values [ $ key ] ) ; } } return array_values ( array_unique ( $ values ) ) ; } | 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 -> update ( $ table , $ data , $ where ) ; } | 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' ; break ; } } | 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 = $ multiple ? 'M.' : 'S.' ; $ paths = array ( ) ; if ( $ pos = strripos ( $ file , '::' ) ) { if ( $ path = \ Autoloader :: namespace_path ( '\\' . ucfirst ( substr ( $ file , 0 , $ pos ) ) ) ) { $ cache_id .= substr ( $ file , 0 , $ pos ) ; $ paths = array ( substr ( $ path , 0 , - 8 ) ) ; $ file = substr ( $ file , $ pos + 2 ) ; } } else { $ paths = $ this -> paths ; if ( class_exists ( 'Request' , false ) and ( $ request = \ Request :: active ( ) ) ) { $ request -> module and $ cache_id .= $ request -> module ; $ paths = array_merge ( $ request -> get_paths ( ) , $ paths ) ; } } $ paths = array_merge ( $ this -> flash_paths , $ paths ) ; $ this -> clear_flash ( ) ; $ file = $ this -> prep_path ( $ dir ) . $ file . $ ext ; $ cache_id .= $ file ; if ( $ cache and $ cached_path = $ this -> from_cache ( $ cache_id ) ) { return $ cached_path ; } foreach ( $ paths as $ dir ) { $ file_path = $ dir . $ file ; if ( is_file ( $ file_path ) ) { if ( ! $ multiple ) { $ found = $ file_path ; break ; } $ found [ ] = $ file_path ; } } if ( ! empty ( $ found ) and $ cache ) { $ this -> add_to_cache ( $ cache_id , $ found ) ; } return $ found ; } | 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 ) ) { $ this -> cached_paths = $ cached ; } } | 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 ( $ dir . $ file ) ) < $ lifetime ) { try { return unserialize ( file_get_contents ( $ dir . $ file ) ) ; } catch ( \ Exception $ e ) { } } else { try { unlink ( $ dir . $ file ) ; } catch ( Exception $ e ) { } } } return null ; } if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , \ Config :: get ( 'file.chmod.folders' , 0777 ) , true ) ; chmod ( $ dir , \ Config :: get ( 'file.chmod.folders' , 0777 ) ) ; } $ data = serialize ( $ data ) ; try { if ( $ result = ( bool ) file_put_contents ( $ dir . $ file , $ data , LOCK_EX ) ) { try { chmod ( $ dir . $ file , \ Config :: get ( 'file.chmod.files' , 0666 ) ) ; } catch ( \ PhpErrorException $ e ) { if ( substr ( $ e -> getMessage ( ) , 0 , 8 ) !== 'chmod():' ) { throw new $ e ; } } } return $ result ; } catch ( \ Exception $ e ) { return false ; } } | 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 ( $ cacheGroup [ 'key' ] ) ) ) { return ; } $ cacheKey = $ this -> generateCacheKey ( $ cacheGroup [ 'key' ] , $ params ) ; return IlluminateCache :: tags ( $ tags ) -> get ( $ cacheKey ) ; } | 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 [ 'active' ] ) || empty ( $ cacheGroup [ 'key' ] ) ) ) { return false ; } $ cacheKey = $ this -> generateCacheKey ( $ cacheGroup [ 'key' ] , $ params ) ; if ( ! is_array ( $ tags ) ) { $ tags = [ $ tags ] ; } try { return IlluminateCache :: tags ( $ tags ) -> put ( $ cacheKey , $ data , $ cacheGroup [ 'lifetime' ] ? : $ this -> config [ 'lifetime' ] ) ; } catch ( ServerException $ e ) { cache_wipe ( ) ; try { $ errors = [ 'exception' => $ e -> getMessage ( ) , 'type' => 'redis wrong type' , 'tags' => $ tags , 'cache_key' => $ cacheKey , ] ; app ( 'nodes.bugsnag' ) -> notifyException ( $ e , json_encode ( $ errors ) , 'error' ) ; } catch ( \ Exception $ e ) { } } } | 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 -> cacheGroups [ $ groupName ] = $ settings ; } } } | 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" , array_merge ( [ "WebDriver Invalid Request Error: {$httpStatusCode}" ] , $ messageList ) ) ; $ exception = new WebDriver_Exception_InvalidRequest ( $ message ) ; $ exception -> httpStatusCode = $ httpStatusCode ; return $ exception ; } | 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-Authoritative Information' ; break ; case 204 : $ text = 'No Content' ; break ; case 205 : $ text = 'Reset Content' ; break ; case 206 : $ text = 'Partial Content' ; break ; case 300 : $ text = 'Multiple Choices' ; break ; case 301 : $ text = 'Moved Permanently' ; break ; case 302 : $ text = 'Moved Temporarily' ; break ; case 303 : $ text = 'See Other' ; break ; case 304 : $ text = 'Not Modified' ; break ; case 305 : $ text = 'Use Proxy' ; break ; case 400 : $ text = 'Bad Request' ; break ; case 401 : $ text = 'Unauthorized' ; break ; case 402 : $ text = 'Payment Required' ; break ; case 403 : $ text = 'Forbidden' ; break ; case 404 : $ text = 'Not Found' ; break ; case 405 : $ text = 'Method Not Allowed' ; break ; case 406 : $ text = 'Not Acceptable' ; break ; case 407 : $ text = 'Proxy Authentication Required' ; break ; case 408 : $ text = 'Request Time-out' ; break ; case 409 : $ text = 'Conflict' ; break ; case 410 : $ text = 'Gone' ; break ; case 411 : $ text = 'Length Required' ; break ; case 412 : $ text = 'Precondition Failed' ; break ; case 413 : $ text = 'Request Entity Too Large' ; break ; case 414 : $ text = 'Request-URI Too Large' ; break ; case 415 : $ text = 'Unsupported Media Type' ; break ; case 416 : $ text = 'Requested Range Not Satisfiable' ; break ; case 417 : $ text = 'Expectation Failed' ; break ; case 418 : $ text = 'I\'m a teapot' ; break ; case 500 : $ text = 'Internal Server Error' ; break ; case 501 : $ text = 'Not Implemented' ; break ; case 502 : $ text = 'Bad Gateway' ; break ; case 503 : $ text = 'Service Unavailable' ; break ; case 504 : $ text = 'Gateway Time-out' ; break ; case 505 : $ text = 'HTTP Version not supported' ; break ; } return $ text ; } | 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 $ this ; } | 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_slug ] = $ post_type_name ; } $ options = array_merge ( array ( 'post' => _x ( 'Blog' , 'archives widget' , 'church-theme-framework' ) ) , $ options ) ; return apply_filters ( 'ctc_archives_widget_post_type_options' , $ 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 ) { if ( ! isset ( $ keys [ $ i + 1 ] ) && $ player -> getElo ( ) > $ baseRange -> last ( ) ) { $ estimatedRange = $ baseRange -> last ( ) ; break ; } if ( $ player -> getElo ( ) >= $ eloMin && isset ( $ keys [ $ i + 1 ] ) && $ player -> getElo ( ) <= $ keys [ $ i + 1 ] ) { $ estimatedRange = $ range ; break ; } $ i ++ ; } return $ estimatedRange ; } | 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 $ lmodified ; } | 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.