idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
27,200 | protected function prepareEntityForNew ( AbstractEntity $ entity ) : bool { if ( $ entity instanceof TimestampableInterface ) { $ entity -> setCreationDate ( new DateTime ( ) ) ; $ entity -> setEditionDate ( new DateTime ( ) ) ; } return $ this -> prepareEntityForGet ( $ entity ) ; } | Prepares an entity setting its default values |
27,201 | protected function prepareEntityForGet ( AbstractEntity $ entity ) : bool { if ( $ entity instanceof AbstractDocument ) { $ this -> prepareDocumentForGet ( $ entity ) ; } return true ; } | Prepares an entity when retrieved from database |
27,202 | protected function prepareDocumentForGet ( AbstractDocument $ entity ) : bool { $ document = $ entity -> getMongoDocument ( ) ; if ( ! $ document or empty ( $ document ) ) { return true ; } foreach ( $ document as $ key => $ value ) { if ( $ value instanceof BSONDocument ) { $ value = $ value -> getArrayCopy ( ) ; } if ( is_array ( $ value ) and array_key_exists ( 'document_serialization' , $ value ) ) { $ documentEntity = $ this -> loadDocumentSerializedEntity ( $ value ) ; $ entity -> __set ( $ key , $ documentEntity ) ; } } return true ; } | Prepares a document from MongoDB to be gotten |
27,203 | protected function prepareEntityForPersist ( AbstractEntity $ entity ) : bool { if ( $ entity instanceof TimestampableInterface ) { $ entity -> setEditionDate ( new DateTime ( ) ) ; } return true ; } | Prepares an entity for persist |
27,204 | protected function prepareEntitesForGet ( $ entities ) : bool { foreach ( $ entities as $ entity ) { if ( $ this -> prepareEntityForGet ( $ entity ) === false ) { return false ; } } return true ; } | Prepares multiple entities for get |
27,205 | public function getById ( $ id ) : ? AbstractEntity { $ entity = $ this -> getRepository ( ) -> findById ( $ id ) ; if ( $ entity instanceof AbstractEntity ) { $ this -> prepareEntityForGet ( $ entity ) ; } return $ entity ; } | Gets an entity by its ids |
27,206 | public function getEntitiesBy ( array $ criteria = [ ] , array $ orders = [ ] , $ limit = null , $ offset = null ) : array { $ entities = $ this -> getRepository ( ) -> findBy ( $ criteria , $ orders , $ limit , $ offset ) ; $ this -> prepareEntitesForGet ( $ entities ) ; return $ entities ; } | Gets Entities by criteria ... |
27,207 | public function getOneEntityBy ( array $ criteria = [ ] , array $ orders = [ ] , $ offset = null ) : ? AbstractEntity { $ entity = $ this -> getRepository ( ) -> findOneBy ( $ criteria , $ orders , $ offset ) ; if ( $ entity instanceof AbstractEntity ) { $ this -> prepareEntityForGet ( $ entity ) ; } return $ entity ; } | Gets all entities matching a Criteria |
27,208 | public function getAllNotDeleted ( ) : array { if ( ! $ this -> entityImplements ( SoftDeleteInterface :: class ) ) { throw new \ Exception ( sprintf ( 'Entities of class "%s" do not implement interface "%s"' , $ this -> getEntityClassName ( ) , SoftDeleteInterface :: class ) ) ; } return $ this -> getEntitiesBy ( [ 'deleted' => false ] ) ; } | Gets all entities not deleted |
27,209 | protected function loadAndCacheFaces ( ) { $ faces = $ this -> _loadFaces ( ) ; foreach ( $ faces as $ face ) { $ this -> cacheFace ( $ face ) ; $ this -> addFace ( $ face ) ; } } | Load all faces and cache them |
27,210 | protected function cacheFace ( EntityFace $ face ) { $ serialized = serialize ( $ face ) ; $ this -> getCache ( ) -> set ( "name_" . $ face -> getName ( ) , $ serialized ) ; $ this -> getCache ( ) -> set ( "class_" . $ face -> getClass ( ) , $ serialized ) ; } | register a face in the cache |
27,211 | protected function eagerLoadRelations ( ) { $ query = $ this -> model ; if ( is_array ( $ this -> eagerLoadRelations ) ) { $ eagerLoads = [ ] ; foreach ( $ this -> eagerLoadRelations as $ relation => $ rules ) { $ relation = ( is_integer ( $ relation ) ) ? $ rules : $ relation ; if ( is_array ( $ rules ) && array_key_exists ( 'attributes' , $ rules ) ) { $ eagerLoads [ $ relation ] = function ( $ q ) use ( $ rules ) { if ( $ q instanceof HasOneOrMany && ! in_array ( $ fk = $ q -> getParent ( ) -> getForeignKey ( ) , $ rules [ 'attributes' ] ) ) { array_push ( $ rules [ 'attributes' ] , $ fk ) ; } $ q -> select ( $ rules [ 'attributes' ] ) ; } ; } else { array_push ( $ eagerLoads , $ relation ) ; } } return $ query -> with ( $ eagerLoads ) ; } return $ query -> with ( $ this -> eagerLoadRelations ) ; } | Eagerload relations . |
27,212 | public function first ( array $ attributes = null ) { $ query = $ this -> eagerLoadRelations ( ) ; if ( ! is_null ( $ attributes ) ) { $ query = $ query -> where ( $ attributes ) ; } return $ query -> first ( ) ; } | Get the first model or the first model for the given attributes . |
27,213 | public function create ( array $ attributes ) { if ( array_is_assoc ( head ( $ attributes ) ) ) { throw new InvalidArgumentException ( 'Trying to pass multiple items in create() method. Please use createMany() instead.' ) ; } if ( array_is_assoc ( $ attributes ) && $ this -> updateWhenIdExists && array_key_exists ( $ pk = $ this -> model -> getKeyName ( ) , $ attributes ) ) { unset ( $ attributes [ $ pk ] ) ; } $ this -> validation ( ) -> validate ( 'create' , $ attributes ) ; $ model = $ this -> model -> newInstance ( $ attributes ) ; $ this -> beforeSaveModel ( $ model ) ; $ model -> save ( ) ; return $ model ; } | Create and store a new model . |
27,214 | public function createMany ( array $ items ) { $ models = collection ( ) ; foreach ( $ items as $ item ) { $ models [ ] = $ this -> create ( $ item ) ; } return $ models ; } | Create and store multiple new models . |
27,215 | public function update ( $ id , array $ attributes ) { $ model = $ this -> model -> findOrFail ( $ id ) ; $ this -> validation ( ) -> validate ( 'update' , array_merge ( $ attributes , [ $ this -> model -> getKeyName ( ) => $ id ] ) ) ; $ model -> fill ( $ attributes ) ; $ model -> save ( ) ; return $ model ; } | Update the model or models attributes . |
27,216 | public function updateMany ( array $ items ) { $ ids = array_pluck ( $ items , $ this -> model -> getKeyName ( ) ) ; $ models = $ this -> model -> find ( $ ids ) ; foreach ( $ models as $ model ) { $ attributes = array_first ( $ items , function ( $ i , $ attributes ) use ( $ model ) { if ( ! array_key_exists ( $ model -> getKeyName ( ) , $ attributes ) ) { return false ; } return $ attributes [ $ model -> getKeyName ( ) ] == $ model -> getKey ( ) ; } ) ; $ this -> validation ( ) -> validate ( 'update' , array_merge ( $ attributes , [ $ model -> getKeyName ( ) => $ model -> getKey ( ) ] ) ) ; $ model -> fill ( $ attributes ) ; $ model -> save ( ) ; } return $ models ; } | Update multiple models attributes in the storage . |
27,217 | public function save ( $ model ) { if ( $ model instanceof Collection || is_array ( $ model ) ) { throw new InvalidArgumentException ( 'Parameter $model must be an instance of \Illuminate\Database\Eloquent\Model' ) ; } $ this -> validation ( ) -> validate ( 'save' , $ model -> getAttributes ( ) ) ; $ this -> beforeSaveModel ( $ model ) ; return $ model -> save ( ) ; } | Save the model . |
27,218 | public function saveMany ( $ models ) { $ models = is_array ( $ models ) ? collection ( $ models ) : $ models ; foreach ( $ models as & $ model ) { $ model = $ this -> save ( $ model ) ; } return $ models ; } | Save multiple models . |
27,219 | public function has ( $ relation , $ operator = '>=' , $ count = 1 ) { $ this -> hasRelations [ $ relation ] = [ $ operator , $ count ] ; return $ this ; } | Query model if it has a given relation . |
27,220 | protected function queryHasRelations ( $ query , $ hasRelations = [ ] ) { $ hasRelations = $ hasRelations ? : $ this -> hasRelations ; foreach ( $ hasRelations as $ relation => $ operatorCount ) { list ( $ operator , $ count ) = $ operatorCount ; $ query -> has ( $ relation , $ operator , $ count ) ; } return $ query ; } | Query has relations . |
27,221 | protected function queryFilters ( $ query , $ filters = [ ] ) { $ filters = $ filters ? : $ this -> filters ; foreach ( $ filters as $ key => $ filter ) { foreach ( $ filter as $ operator => $ values ) { $ values = is_array ( $ values ) ? $ values : [ $ values ] ; $ operator = is_numeric ( $ operator ) ? '=' : $ operator ; if ( $ operator == '=' ) { $ query -> whereIn ( $ key , $ values ) ; } elseif ( $ operator == '!=' ) { $ query -> whereNotIn ( $ key , $ values ) ; } elseif ( $ operator == 'null' ) { $ query -> whereNull ( $ key ) ; } elseif ( $ operator == 'not_null' ) { $ query -> whereNotNull ( $ key ) ; } else { $ query -> where ( $ key , $ operator , head ( $ values ) ) ; } } } return $ query ; } | Query filters . |
27,222 | protected function querySort ( $ query , $ sort = [ ] ) { $ sort = $ sort ? : $ this -> sort ; foreach ( $ sort as $ attribute => $ order ) { $ query -> orderBy ( $ attribute , $ order ) ; } return $ query ; } | Query sort . |
27,223 | protected function queryLimitOffset ( $ query , $ limit = null , $ offset = 0 ) { $ limit = $ limit ? : $ this -> limit ; $ offset = $ offset ? : $ this -> offset ; if ( $ limit ) { $ query -> take ( $ limit ) -> skip ( $ offset ) ; } return $ query ; } | Query limit and offset . |
27,224 | public function paginate ( $ perPage = 15 , $ page = null , $ attributes = [ '*' ] ) { $ pagelo = new PageLimitOffset ( $ perPage , $ page ) ; return $ this -> limit ( $ pagelo -> limit ( ) ) -> offset ( $ pagelo -> offset ( ) ) -> get ( $ attributes ) ; } | Return a collection of models by paginated approach . |
27,225 | protected function prepareQuery ( ) { $ query = $ this -> eagerLoadRelations ( ) ; $ this -> queryHasRelations ( $ query ) ; $ this -> queryFilters ( $ query ) ; $ this -> querySort ( $ query ) ; $ this -> queryLimitOffset ( $ query ) ; return $ query ; } | Prepare query to fetch models . |
27,226 | protected function selectAttributes ( $ attributes = [ '*' ] ) { $ attributes = $ attributes ? : [ '*' ] ; if ( $ attributes == [ '*' ] && $ this -> attributes != [ '*' ] ) { $ attributes = $ this -> attributes ; } return $ attributes ; } | Return the final attributes to be selected . |
27,227 | public function search ( $ input , $ compareAttributes = [ '*' ] , $ attributes = [ '*' ] ) { $ query = $ this -> query ( ) ; $ compareAttributes = $ compareAttributes ? : [ '*' ] ; if ( $ compareAttributes == [ '*' ] ) { $ compareAttributes = Schema :: getColumnListing ( $ this -> model -> getTable ( ) ) ; } foreach ( $ compareAttributes as $ column ) { $ query -> orWhere ( $ column , 'like' , '%' . join ( '%' , str_split ( $ input ) ) . '%' ) ; } return $ query -> get ( $ this -> selectAttributes ( $ attributes ) ) ; } | Search any input against the given attributes . |
27,228 | protected function onSet ( & $ offset , $ value ) { if ( is_string ( $ value ) ) { $ value = app ( ) -> make ( $ value ) ; } return $ value ; } | Resolves value that s being set |
27,229 | public static function get ( ) { mt_srand ( ( int ) ( microtime ( true ) * 1000 ) ) ; $ b = md5 ( uniqid ( mt_rand ( ) , true ) , true ) ; $ b [ 6 ] = chr ( ( ord ( $ b [ 6 ] ) & 0x0F ) | 0x40 ) ; $ b [ 8 ] = chr ( ( ord ( $ b [ 8 ] ) & 0x3F ) | 0x80 ) ; return implode ( '-' , unpack ( 'H8a/H4b/H4c/H4d/H12e' , $ b ) ) ; } | erstellt eine 36 stellige uuid nach dce standard |
27,230 | protected function onFormatText ( string & $ text ) : void { $ lines = preg_split ( "/\r\n|\n|\r/" , $ text ) ; $ result = [ ] ; $ lastEmptyLinesCount = 0 ; $ hasFoundNonEmptyLines = false ; foreach ( $ lines as $ line ) { if ( ( $ this -> textFormatOptions & TextFormatOptions :: TRIM ) !== 0 ) { $ line = trim ( $ line ) ; } if ( ( $ this -> textFormatOptions & TextFormatOptions :: COMPACT ) !== 0 ) { $ line = preg_replace ( '/\s+/' , ' ' , $ line ) ; } if ( $ line === '' ) { if ( ( $ this -> textFormatOptions & TextFormatOptions :: COMPACT_LINES ) !== 0 && $ lastEmptyLinesCount > 0 ) { continue ; } if ( ( $ this -> textFormatOptions & TextFormatOptions :: TRIM_LINES ) !== 0 && ! $ hasFoundNonEmptyLines ) { continue ; } $ lastEmptyLinesCount ++ ; } else { $ lastEmptyLinesCount = 0 ; $ hasFoundNonEmptyLines = true ; } $ result [ ] = $ line ; } if ( ( $ this -> textFormatOptions & TextFormatOptions :: TRIM_LINES ) !== 0 && $ lastEmptyLinesCount > 0 ) { array_splice ( $ result , - $ lastEmptyLinesCount ) ; } $ text = implode ( "\r\n" , $ result ) ; } | Called when text should be formatted . |
27,231 | private function sanitizeText ( string $ text ) : string { $ text = preg_replace ( $ this -> isMultiLine ( ) ? '/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/u' : '/[\x00-\x1F\x7F]/u' , '' , $ text ) ; return $ text ; } | Sanitizes the text . |
27,232 | public static function create ( $ template = null , $ view = '' , $ viewdata = [ ] , $ status = 200 , $ headers = array ( ) ) { if ( ! $ template instanceof TemplateEngineInterface ) { throw new InvalidArgumentException ( 'The first argument of ViewResponse::create must be an instance of Laasti\Response\Engines\TemplateEngineInterface' ) ; } return new static ( $ template , $ view , $ viewdata , $ status , $ headers ) ; } | Instantiates a new ViewResponse |
27,233 | public function filterByGroupId ( $ groupId = null , $ comparison = null ) { if ( is_array ( $ groupId ) ) { $ useMinMax = false ; if ( isset ( $ groupId [ 'min' ] ) ) { $ this -> addUsingAlias ( SkillGroupTableMap :: COL_GROUP_ID , $ groupId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ groupId [ 'max' ] ) ) { $ this -> addUsingAlias ( SkillGroupTableMap :: COL_GROUP_ID , $ groupId [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( SkillGroupTableMap :: COL_GROUP_ID , $ groupId , $ comparison ) ; } | Filter the query on the group_id column |
27,234 | protected function findRelatedGroupSkillCounts ( $ con ) { $ criteria = clone $ this ; if ( $ this -> useAliasInSQL ) { $ alias = $ this -> getModelAlias ( ) ; $ criteria -> removeAlias ( $ alias ) ; } else { $ alias = '' ; } $ this -> groupSkillCounts = \ gossi \ trixionary \ model \ GroupQuery :: create ( ) -> joinSkillGroup ( $ alias ) -> mergeWith ( $ criteria ) -> find ( $ con ) ; } | Finds the related Group objects and keep them for later |
27,235 | public function route ( $ key , $ default = null ) { if ( isset ( $ this -> routeParams [ $ key ] ) ) { return $ this -> routeParams [ $ key ] ; } return $ default ; } | data from routeParams |
27,236 | public function uri ( ) { if ( isset ( $ this -> server [ 'X_ORIGINAL_URL' ] ) && ! empty ( $ this -> server [ 'X_ORIGINAL_URL' ] ) ) { return $ this -> server [ 'X_ORIGINAL_URL' ] ; } return $ this -> server [ 'REQUEST_URI' ] ; } | get request uri |
27,237 | public function create ( $ method , $ params ) { if ( strtolower ( $ method ) == 'get' ) { $ this -> get = $ params ; } else { $ this -> post = $ params ; } return $ this ; } | create request by create |
27,238 | public function builder ( StatementInterface $ statement ) { if ( $ statement instanceof Insert ) { return new InsertBuilder ( $ statement ) ; } $ factory = $ this -> expression ( 'BuilderFactory' ) ; if ( $ statement instanceof Select ) { return new SelectBuilder ( $ statement , $ factory ) ; } elseif ( $ statement instanceof Update ) { return new UpdateBuilder ( $ statement , $ factory ) ; } else { return new DeleteBuilder ( $ statement , $ factory ) ; } } | Create an instance of a query builder . Different between the several statement types and return the correct query builder for the passed statement . |
27,239 | private function _invokeCreateMethod ( $ type , $ name , array $ arguments ) { $ createMethodName = '_create' . $ type . $ name ; if ( method_exists ( $ this , $ createMethodName ) ) { return $ this -> $ createMethodName ( $ arguments ) ; } throw new \ Exception ( 'no creation method for the ' . strtolower ( $ type ) . ' class ' . $ name . ' found!' ) ; } | Invoke the expected private create method . |
27,240 | private function _createReferencesColumn ( array $ args ) { $ this -> _checkSecondArgument ( $ args ) ; $ table = ( isset ( $ args [ 2 ] ) ) ? $ args [ 2 ] : null ; $ alias = ( isset ( $ args [ 3 ] ) ) ? $ args [ 3 ] : null ; return new Column ( $ args [ 1 ] , $ table , $ alias ) ; } | Create an instance of a column references . |
27,241 | private function _createReferencesSqlFunction ( array $ args ) { $ this -> _checkSecondArgument ( $ args ) ; if ( isset ( $ args [ 2 ] ) && ! is_array ( $ args [ 2 ] ) ) { throw new \ Exception ( 'sql function references argument have to be an array or null!' ) ; } $ argArray = ( isset ( $ args [ 2 ] ) ) ? $ args [ 2 ] : array ( ) ; return new SqlFunction ( $ args [ 1 ] , $ argArray ) ; } | Create an instance of a sql function references object . |
27,242 | private function _createReferencesTable ( array $ args ) { $ this -> _checkSecondArgument ( $ args ) ; $ alias = ( isset ( $ args [ 2 ] ) ) ? $ args [ 2 ] : null ; return new Table ( $ args [ 1 ] , $ alias ) ; } | Create an instance of a table references object . |
27,243 | public function postCreate ( MediaCreateRequest $ request ) { $ media = Media :: create ( $ request -> all ( ) ) ; return redirect ( $ this -> admin -> currentUrl ( 'view/' . $ media -> id ) ) -> with ( 'notifications_below_header' , [ [ 'type' => 'success' , 'icon' => 'check-circle' , 'title' => 'Success!' , 'message' => 'Your Media was successfully added.' , 'dismissable' => false ] ] ) ; } | Processes a new Media Request . |
27,244 | public function postUpload ( Request $ request ) { if ( ! $ request -> file ( 'file' ) ) { return [ ] ; } $ filename = time ( ) . '-' . $ request -> file ( 'file' ) -> getClientOriginalName ( ) ; $ request -> file ( 'file' ) -> move ( 'uploads/media' , $ filename ) ; foreach ( \ Config :: get ( 'flare-config.media.resize' ) as $ sizeArray ) { $ newfilename = $ sizeArray [ 0 ] . '-' . ( array_key_exists ( 1 , $ sizeArray ) ? $ sizeArray [ 1 ] : $ sizeArray [ 0 ] ) . '-' . $ filename ; Image :: make ( 'uploads/media/' . $ filename ) -> fit ( $ sizeArray [ 0 ] , ( array_key_exists ( 1 , $ sizeArray ) ? $ sizeArray [ 1 ] : $ sizeArray [ 0 ] ) ) -> save ( 'uploads/media/' . $ newfilename ) ; } $ media = Media :: create ( [ 'name' => $ request -> file ( 'file' ) -> getClientOriginalName ( ) , 'path' => $ filename , 'extension' => $ request -> file ( 'file' ) -> getClientOriginalExtension ( ) , 'mimetype' => $ request -> file ( 'file' ) -> getClientMimeType ( ) , 'size' => $ request -> file ( 'file' ) -> getClientSize ( ) , ] ) ; $ file = new \ stdClass ( ) ; $ file -> name = $ media -> name ; $ file -> url = url ( 'uploads/media/' . $ media -> path ) ; $ file -> thumbnailUrl = url ( 'uploads/media/100-100-' . $ media -> path ) ; $ file -> type = $ media -> mimetype ; $ file -> size = $ media -> size ; $ object = new \ stdClass ( ) ; $ object -> files = [ $ file ] ; return json_encode ( $ object ) ; } | Process a File Upload from the Jquery File Uploader . |
27,245 | public function postDelete ( $ mediaId ) { $ media = Media :: findOrFail ( $ mediaId ) ; $ media -> delete ( ) ; return redirect ( $ this -> admin -> currentUrl ( ) ) -> with ( 'notifications_below_header' , [ [ 'type' => 'success' , 'icon' => 'check-circle' , 'title' => 'Success!' , 'message' => 'The Media was successfully deleted.' , 'dismissable' => false ] ] ) ; } | Process Delete Media Request . |
27,246 | public function getFields ( ) { $ ownerClass = get_class ( $ this -> owner ) ; $ ownerTable = $ ownerClass :: tableName ( ) ; if ( ! isset ( self :: $ _fields [ $ ownerTable ] ) ) { self :: $ _fields [ $ ownerTable ] = [ ] ; $ _f = [ 'deletedField' , 'deletedByField' , 'createdField' , 'createdByField' , 'modifiedField' , 'modifiedByField' ] ; $ schema = $ ownerClass :: getTableSchema ( ) ; foreach ( $ _f as $ field ) { if ( isset ( $ schema -> columns [ $ this -> { $ field } ] ) ) { self :: $ _fields [ $ ownerTable ] [ $ field ] = $ this -> { $ field } ; } } } return self :: $ _fields [ $ ownerTable ] ; } | Get fields . |
27,247 | public function getPaginator ( $ where = null , $ order = null ) { return $ this -> getMapper ( ) -> getPaginator ( $ where , $ order ) ; } | Find package element by name |
27,248 | protected static function loadJsonData ( $ file ) { if ( ! is_file ( $ file ) ) { return null ; } return Json :: decode ( @ file_get_contents ( $ file ) , Json :: TYPE_ARRAY ) ; } | Load json data |
27,249 | protected static function loadPackageData ( ) { if ( ! is_file ( static :: PACKAGE_FILE ) ) { return null ; } if ( null === static :: $ packageData ) { static :: $ packageData = static :: loadJsonData ( static :: PACKAGE_FILE ) ; } return static :: $ packageData ; } | Load package data |
27,250 | protected static function savePackageData ( $ data ) { if ( ! is_file ( static :: PACKAGE_FILE ) ) { return false ; } if ( is_file ( static :: PACKAGE_FILE_BACKUP ) ) { @ unlink ( static :: PACKAGE_FILE_BACKUP ) ; } @ copy ( static :: PACKAGE_FILE , static :: PACKAGE_FILE_BACKUP ) ; $ result = static :: saveJsonData ( static :: PACKAGE_FILE , $ data ) ; if ( $ result ) { static :: $ packageData = $ data ; } else if ( is_file ( static :: PACKAGE_FILE_BACKUP ) ) { @ unlink ( static :: PACKAGE_FILE ) ; @ copy ( static :: PACKAGE_FILE_BACKUP , static :: PACKAGE_FILE ) ; } return $ result ; } | Save package data |
27,251 | protected static function mergeJsonData ( $ file , $ data ) { return static :: saveJsonData ( $ file , ArrayUtils :: merge ( ( array ) static :: loadJsonData ( $ file ) , $ data ) ) ; } | Merge json data |
27,252 | public function makePathRelative ( $ endPath , $ startPath ) { if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { $ endPath = strtr ( $ endPath , '\\' , '/' ) ; $ startPath = strtr ( $ startPath , '\\' , '/' ) ; } $ startPathArr = explode ( '/' , trim ( $ startPath , '/' ) ) ; $ endPathArr = explode ( '/' , trim ( $ endPath , '/' ) ) ; $ index = 0 ; while ( isset ( $ startPathArr [ $ index ] ) && isset ( $ endPathArr [ $ index ] ) && $ startPathArr [ $ index ] === $ endPathArr [ $ index ] ) { $ index ++ ; } $ depth = count ( $ startPathArr ) - $ index ; $ traverser = str_repeat ( '../' , $ depth ) ; $ endPathRemainder = implode ( '/' , array_slice ( $ endPathArr , $ index ) ) ; $ relativePath = $ traverser . ( strlen ( $ endPathRemainder ) > 0 ? $ endPathRemainder . '/' : '' ) ; return ( strlen ( $ relativePath ) === 0 ) ? './' : $ relativePath ; } | Given an existing path convert it to a path relative to a given starting path |
27,253 | public function mirror ( $ originDir , $ targetDir , \ Traversable $ iterator = null , $ options = array ( ) ) { $ targetDir = rtrim ( $ targetDir , '/\\' ) ; $ originDir = rtrim ( $ originDir , '/\\' ) ; if ( $ this -> exists ( $ targetDir ) && isset ( $ options [ 'delete' ] ) && $ options [ 'delete' ] ) { $ deleteIterator = $ iterator ; if ( null === $ deleteIterator ) { $ flags = \ FilesystemIterator :: SKIP_DOTS ; $ deleteIterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ targetDir , $ flags ) , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; } foreach ( $ deleteIterator as $ file ) { $ origin = str_replace ( $ targetDir , $ originDir , $ file -> getPathname ( ) ) ; if ( ! $ this -> exists ( $ origin ) ) { $ this -> remove ( $ file ) ; } } } $ copyOnWindows = false ; if ( isset ( $ options [ 'copy_on_windows' ] ) && ! function_exists ( 'symlink' ) ) { $ copyOnWindows = $ options [ 'copy_on_windows' ] ; } if ( null === $ iterator ) { $ flags = $ copyOnWindows ? \ FilesystemIterator :: SKIP_DOTS | \ FilesystemIterator :: FOLLOW_SYMLINKS : \ FilesystemIterator :: SKIP_DOTS ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ originDir , $ flags ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; } foreach ( $ iterator as $ file ) { $ target = str_replace ( $ originDir , $ targetDir , $ file -> getPathname ( ) ) ; if ( $ copyOnWindows ) { if ( is_link ( $ file ) || is_file ( $ file ) ) { $ this -> copy ( $ file , $ target , isset ( $ options [ 'override' ] ) ? $ options [ 'override' ] : false ) ; } elseif ( is_dir ( $ file ) ) { $ this -> mkdir ( $ target ) ; } else { throw new \ RuntimeException ( sprintf ( 'Unable to guess "%s" file type.' , $ file ) , 0 , null ) ; } } else { if ( is_link ( $ file ) ) { $ this -> symlink ( $ file -> getLinkTarget ( ) , $ target ) ; } elseif ( is_dir ( $ file ) ) { $ this -> mkdir ( $ target ) ; } elseif ( is_file ( $ file ) ) { $ this -> copy ( $ file , $ target , isset ( $ options [ 'override' ] ) ? $ options [ 'override' ] : false ) ; } else { throw new \ RuntimeException ( sprintf ( 'Unable to guess "%s" file type.' , $ file ) , 0 , null ) ; } } } } | Mirrors a directory to another . |
27,254 | public function submitForm ( string $ formId = '' , string $ targetId = '' , bool $ preventDefault = true ) { static $ attached = false ; if ( $ attached ) { Checkers :: notice ( 'This button is already attached to a form.' ) ; return $ this ; } $ this -> id = 'btnf' . self :: $ idCount ++ ; Component :: getVueJs ( ) -> registerSubmitLink ( $ this -> id , $ formId , VueJs :: EVENT_CLIC , $ targetId , $ preventDefault ) ; return $ this ; } | Set submit action |
27,255 | public function swipe ( $ xSpeed , $ ySpeed ) { $ this -> webDriver -> getDriver ( ) -> curl ( $ this -> webDriver -> getDriver ( ) -> factoryCommand ( 'touch/flick' , WebDriver_Command :: METHOD_POST , [ 'xspeed' => ( int ) $ xSpeed , 'yspeed' => ( int ) $ ySpeed , ] ) ) ; return $ this ; } | Performs swipe on screen . |
27,256 | public function down ( $ x , $ y ) { $ this -> webDriver -> getDriver ( ) -> curl ( $ this -> webDriver -> getDriver ( ) -> factoryCommand ( 'touch/down' , WebDriver_Command :: METHOD_POST , [ 'x' => ( int ) $ x , 'y' => ( int ) $ y , ] ) ) ; return $ this ; } | Performs touch on screen . |
27,257 | public static function addAlternativeTypeInformation ( string $ type , UnmappableInput $ exception ) : UnmappableInput { return new self ( sprintf ( '%s It could not be mapped to %s either.' , $ exception -> getMessage ( ) , $ type ) , 0 , $ exception ) ; } | Add the alternative type information to the original exception . |
27,258 | private static function inputData ( MapsProperty $ mapped , string $ type , $ input , string $ message = '' ) : Throwable { if ( is_scalar ( $ input ) ) { return new self ( trim ( sprintf ( 'Cannot assign `%s` to property `%s`: ' . 'it is not clean for conversion to %s. %s' , $ input , $ mapped -> name ( ) , $ type , $ message ) ) ) ; } return new self ( trim ( sprintf ( 'Cannot assign the %s to property `%s`: ' . 'it is not clean for conversion to %s. %s' , gettype ( $ input ) , $ mapped -> name ( ) , $ type , $ message ) ) ) ; } | Notifies the client code when the input is not mappable . |
27,259 | public static function hasSignature ( $ string , $ signature ) { if ( ctype_xdigit ( $ signature ) === false ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid HEX signature provided: %s' , $ signature ) ) ; } $ signatureChars = str_split ( $ signature , 2 ) ; $ hexChars = array_map ( function ( $ val ) { return strtoupper ( bin2hex ( $ val ) ) ; } , str_split ( substr ( $ string , 0 , count ( $ signatureChars ) ) ) ) ; return $ hexChars === $ signatureChars ; } | Determine whether the given string contains one of the registered signatures |
27,260 | public function prepareTable ( WebRequest $ request , TableAbstract $ table , $ paginationUrl , $ numberOfEntries = 10 ) { if ( ! $ table -> hasPagination ( ) ) { $ numberOfEntries = false ; } $ dataRequest = $ this -> generateDataRequest ( $ request , $ table , $ numberOfEntries ) ; $ data = $ table -> getData ( $ dataRequest ) ; if ( ! is_array ( $ data ) ) { $ data = array ( ) ; } $ preparedTable = new PreparedTable ( $ table , $ table -> getColumns ( ) ) ; $ preparedTable -> setOptions ( $ table -> getOptions ( ) ) ; $ preparedTable -> setHead ( $ this -> renderHead ( $ table , $ dataRequest ) ) ; $ body = new Body ( ) ; foreach ( $ data as $ object ) { $ body -> addRow ( $ this -> renderRow ( $ table , $ body , $ object ) ) ; } $ preparedTable -> setBody ( $ body ) ; $ preparedTable -> setFoot ( $ this -> renderFoot ( $ table ) ) ; $ token = uniqid ( 'dt' ) ; $ preparedTable -> setToken ( $ token ) ; $ request -> setSessionData ( 'dt-class-' . $ token , get_class ( $ table ) ) ; $ request -> setSessionData ( 'dt-time-' . $ token , time ( ) ) ; $ request -> setSessionData ( 'dt-options-' . $ token , json_encode ( $ table -> getOptions ( ) ) ) ; return $ preparedTable ; } | Renders the whole table |
27,261 | protected function generateDataRequest ( WebRequest $ request , TableAbstract $ table , $ numberOfEntries ) { $ sortBy = 'name' ; $ sortByDirection = 'ASC' ; $ savedDataRequestKey = get_class ( $ table ) . '.DataRequest.Saved' ; $ dataRequest = false ; if ( $ table -> shouldSaveDataRequest ( ) && $ request -> getSessionData ( $ savedDataRequestKey ) !== false ) { $ dataRequest = unserialize ( $ request -> getSessionData ( $ savedDataRequestKey ) ) ; } if ( $ dataRequest === false ) { $ dataRequest = new DataRequest ( 1 , $ numberOfEntries , $ sortBy , $ sortByDirection ) ; } if ( $ table -> shouldSaveDataRequest ( ) ) { $ request -> setSessionData ( $ savedDataRequestKey , serialize ( $ dataRequest ) ) ; } return $ dataRequest ; } | Generates a DataRequest object |
27,262 | protected function renderHead ( TableAbstract $ table , DataRequest $ dataRequest ) { $ head = new Head ( ) ; $ row = new Row ( $ head ) ; foreach ( $ table -> getColumns ( ) as $ column ) { $ cell = new Cell ( $ column , $ row , $ column -> getName ( ) ) ; $ row -> addCell ( $ cell ) ; } $ head -> addRow ( $ row ) ; return $ head ; } | Generates the object structure for the head |
27,263 | protected function renderRow ( TableAbstract $ table , Body $ body , $ object ) { $ row = new Row ( $ body ) ; foreach ( $ table -> getColumns ( ) as $ column ) { $ value = $ table -> getDataForRow ( $ column -> getKey ( ) , $ object ) ; $ cell = new Cell ( $ column , $ row , $ value ) ; $ row -> addCell ( $ cell ) ; } return $ row ; } | Renders the table row with the given row data |
27,264 | public static function exists ( string $ dir = '' ) : bool { $ dir = static :: normalizePath ( $ dir ) ; return static :: verifyPath ( $ dir ) && \ file_exists ( $ dir ) && \ is_dir ( $ dir ) ; } | Checks whether directory exists . |
27,265 | public static function isLink ( string $ dir = '' ) : bool { $ dir = static :: normalizePath ( $ dir ) ; return static :: exists ( $ dir ) && \ is_link ( $ dir ) ; } | Checks whether directory is a link |
27,266 | public static function remove ( string $ dir = '' , bool $ emptyOnly = false ) : bool { $ ret = true ; $ dir = static :: normalizePath ( $ dir ) ; if ( static :: exists ( $ dir ) ) { if ( $ handle = @ \ opendir ( $ dir ) ) { while ( false !== ( $ item = @ \ readdir ( $ handle ) ) ) { if ( $ item !== '.' && $ item !== '..' ) { $ item = $ dir . DIRECTORY_SEPARATOR . $ item ; \ is_dir ( $ item ) ? static :: remove ( $ item ) : @ \ unlink ( $ item ) ; } } @ \ closedir ( $ handle ) ; } if ( $ emptyOnly === false ) { @ \ rmdir ( $ dir ) ; } return true ; } return $ ret ; } | Removes a directory with all subdirectories files and symbolic links inside . |
27,267 | public function moveToDirectory ( $ directory ) { $ targetPath = rtrim ( $ directory , '/' ) . '/' . $ this -> getClientFilename ( ) ; return $ this -> moveTo ( $ targetPath ) ; } | Move file from directory keeping the cliente file name |
27,268 | public function getErrorMessage ( ) { if ( array_key_exists ( $ this -> error , $ this -> errorMessages ) ) { return $ this -> errorMessages [ $ this -> error ] ; } return 'Unknow error' ; } | Gets the value of errorMessages . |
27,269 | public function pipe ( $ stage ) { $ pipeline = clone $ this ; $ this -> handleStage ( $ pipeline -> stages , $ stage ) ; return $ pipeline ; } | Create a new pipeline with an appended stage . |
27,270 | protected function handleStage ( & $ stages , $ stage ) { if ( $ stage instanceof Pipeline ) { $ stages = array_merge ( $ stages , $ stage -> stages ( ) ) ; } else { $ stages [ ] = is_callable ( $ stage ) ? new Callback ( $ stage ) : $ stage ; } } | Handles merging or converting the stage to a callback |
27,271 | public function run ( ) { $ request = ServerRequestFactory :: fromGlobals ( ) ; $ this -> pipeline -> build ( ) -> pipe ( new Stage ( function ( ResponseInterface $ response = null ) { $ emitter = new SapiEmitter ; if ( is_null ( $ response ) ) { throw new Exception ( 404 ) ; } return $ emitter -> emit ( $ response ) ; } ) ) -> process ( $ request ) ; } | Run the HTTP kernel controller . This processes your pipeline and emits the resulting response . |
27,272 | public function export ( string $ path ) : File { $ target_dir = new File ( $ path ) ; if ( ! $ target_dir -> exists ( ) ) { throw new DecoyException ( 'Export target directory not exists:' . $ path ) ; } if ( ! $ target_dir -> canWrite ( ) ) { throw new DecoyException ( 'Export target directory not writable:' . $ path ) ; } $ file = new File ( $ this -> autogenerated_file -> getName ( ) , $ target_dir ) ; $ parent_dir = $ file -> getParent ( ) ; try { $ parent_dir -> makeDirectory ( ) ; } catch ( MakeDirectoryException $ e ) { throw new DecoyException ( 'Making parent directory failed:' . $ parent_dir , $ e ) ; } try { $ file -> putContents ( $ this -> autogenerated_file -> getContent ( ) ) ; } catch ( FileOutputException $ e ) { throw new DecoyException ( 'Writing output file failed:' . $ file ) ; } return $ file ; } | Export to local file |
27,273 | public function get ( $ id ) { if ( isset ( $ this -> aliases [ $ id ] ) ) { $ id = $ this -> aliases [ $ id ] ; } if ( ! isset ( $ this -> keys [ $ id ] ) ) { throw new NotFoundException ( sprintf ( 'The service "%s" is not found' , $ id ) ) ; } if ( isset ( $ this -> values [ $ id ] ) ) { return $ this -> values [ $ id ] ; } if ( ! $ this -> keys [ $ id ] ) { if ( isset ( $ this -> factories [ $ id ] ) ) { return $ this -> createFromFactory ( $ this -> factories [ $ id ] ) ; } else { return $ this -> createFromDefinition ( $ this -> definition [ $ id ] ) ; } } if ( isset ( $ this -> factories [ $ id ] ) ) { $ service = $ this -> createFromFactory ( $ this -> factories [ $ id ] ) ; unset ( $ this -> factories [ $ id ] ) ; } else { $ service = $ this -> createFromDefinition ( $ this -> definition [ $ id ] ) ; unset ( $ this -> definition [ $ id ] ) ; } $ this -> values [ $ id ] = $ service ; $ this -> immutable [ $ id ] = true ; return $ service ; } | Get entry of the container by its identifier . |
27,274 | public function setAlias ( $ alias , $ service ) { if ( $ alias == $ service ) { throw new ContainerException ( 'Alias and service names can not be equals' ) ; } $ this -> aliases [ $ alias ] = $ service ; } | Set entry alias in the container |
27,275 | public function getServiceIdFromAlias ( $ alias , $ default = null ) { if ( isset ( $ this -> aliases [ $ alias ] ) ) { return $ this -> aliases [ $ alias ] ; } return $ default ; } | Retrive service identifier for alias or default value if alias is not define . |
27,276 | public function has ( $ id ) { if ( isset ( $ this -> aliases [ $ id ] ) ) { $ id = $ this -> aliases [ $ id ] ; } return isset ( $ this -> keys [ $ id ] ) ; } | Returns true if the container can return an entry for the given identifier and returns false otherwise . |
27,277 | public function remove ( $ id ) { if ( isset ( $ this -> aliases [ $ id ] ) ) { $ aliasId = $ id ; $ id = $ this -> aliases [ $ id ] ; unset ( $ this -> aliases [ $ aliasId ] ) ; } unset ( $ this -> keys [ $ id ] ) ; unset ( $ this -> values [ $ id ] ) ; unset ( $ this -> immutable [ $ id ] ) ; unset ( $ this -> factories [ $ id ] ) ; unset ( $ this -> definition [ $ id ] ) ; } | Remove an entry of the container by its identifier . |
27,278 | public function registerDefinition ( $ id , array $ definition , $ isShared = true ) { if ( isset ( $ this -> immutable [ $ id ] ) ) { throw new ContainerException ( sprintf ( 'A service by the name "%s" already exists and cannot be overridden' , $ id ) ) ; } $ this -> definition [ $ id ] = $ definition ; $ this -> keys [ $ id ] = boolval ( $ isShared ) ; if ( isset ( $ this -> aliases [ $ id ] ) ) { unset ( $ this -> aliases [ $ id ] ) ; } } | Register array of definition which will be used to create the service . |
27,279 | protected function createFromFactory ( $ factory ) { try { if ( is_string ( $ factory ) && class_exists ( $ factory ) ) { $ factory = new $ factory ( ) ; } if ( is_callable ( $ factory ) ) { $ service = $ factory ( $ this ) ; } else { throw new ContainerException ( 'Service could not be created: "There were incorrectly ' . 'transmitted data when registering the service".' ) ; } } catch ( ContainerException $ e ) { throw $ e ; } catch ( \ Throwable $ e ) { throw new ContainerException ( 'Service could not be created: "Service factory may be ' . 'callable or string (that can be resolving to an ' . 'invokable class or to a FactoryInterface instance).' ) ; } return $ service ; } | Create a new instance of service from factory . |
27,280 | protected function createFromDefinition ( array $ definition ) { if ( ! isset ( $ definition [ 'class' ] ) ) { throw new ContainerException ( 'Service could not be created from definition:' . ' option "class" is not exists in definition array.' ) ; } $ className = $ definition [ 'class' ] ; if ( ! class_exists ( $ className ) ) { throw new ContainerException ( sprintf ( 'Service could not be created from definition:' . ' Class "%s" is not exists.' , $ className ) ) ; } $ reflection = new \ ReflectionClass ( $ className ) ; if ( ! $ reflection -> isInstantiable ( ) ) { throw new ContainerException ( sprintf ( 'Service could not be created from definition:' . ' Unable to create instance of class "%s".' , $ className ) ) ; } if ( null !== ( $ constructor = $ reflection -> getConstructor ( ) ) ) { if ( ! isset ( $ definition [ 'args' ] ) ) { throw new ContainerException ( 'Service could not be created from definition:' . ' option "args" is not exists in definition array.' ) ; } $ params = $ this -> resolveArgs ( $ constructor -> getParameters ( ) , $ definition [ 'args' ] ) ; $ service = $ reflection -> newInstanceArgs ( $ params ) ; } else { $ service = $ reflection -> newInstance ( ) ; } if ( ! isset ( $ definition [ 'calls' ] ) ) { return $ service ; } $ calls = isset ( $ definition [ 'calls' ] ) ? $ definition [ 'calls' ] : [ ] ; foreach ( $ calls as $ method => $ args ) { if ( ! is_callable ( [ $ service , $ method ] ) ) { throw new ContainerException ( sprintf ( 'Service could not be created from definition:' . ' can not call method "%s" from class: "%s"' , $ method , $ className ) ) ; } $ method = new \ ReflectionMethod ( $ service , $ method ) ; $ params = $ method -> getParameters ( ) ; $ arguments = is_array ( $ args ) ? $ this -> resolveArgs ( $ params , $ args ) : [ ] ; $ method -> invokeArgs ( $ service , $ arguments ) ; } return $ service ; } | Create a new instance of service from array definition . |
27,281 | private function getCacheInstance ( array $ config ) { if ( ! isset ( $ config [ 'enable' ] ) || ! $ config [ 'enable' ] ) { return null ; } $ className = $ config [ 'adapter' ] ; if ( ! class_exists ( $ className ) ) { $ errMsg = sprintf ( 'Adapter "%s" is not supported for caching' , $ config [ 'adapter' ] ) ; throw new Exception \ RuntimeException ( $ errMsg ) ; } return new $ className ( $ config [ 'options' ] ) ; } | Get cache instance for config or module |
27,282 | protected function initPhalconApplication ( ) { $ diFactory = $ this -> diManager -> getDI ( ) ; $ moduleHandler = $ diFactory -> get ( 'moduleHandler' ) ; ( new Autoloader ( $ diFactory ) ) -> register ( ) ; $ this -> diManager -> initInvokableServices ( ) -> initFactoriedServices ( ) -> initRouterDi ( ) ; ( new Listener ( $ diFactory ) ) -> listenApplicationEvents ( new Listener \ Application ( ) ) -> listenDispatchEvents ( new Listener \ Dispatch ( ) ) ; $ application = new PhalconApplication ( $ diFactory ) ; $ application -> setEventsManager ( $ diFactory [ 'eventsManager' ] ) ; $ application -> registerModules ( $ moduleHandler -> getRegisteredModules ( ) ) ; return $ application ; } | Initialize phalcon application |
27,283 | private function generateServices ( array $ services , ContainerBuilder $ container ) { foreach ( $ services as $ serviceName => $ service ) { $ serviceId = 'bridge.' . $ serviceName ; $ serviceDefinition = $ this -> createComponentDefinition ( $ serviceName , $ service [ 'class' ] , $ service [ 'options' ] ) ; $ serviceDefinition -> addMethodCall ( 'setEventDispatcher' , array ( new Reference ( 'bridge.event_dispatcher' ) ) ) ; $ serviceDefinition -> addMethodCall ( 'setRegistry' , array ( new Reference ( 'bridge.registry' ) ) ) ; $ this -> generateGroups ( $ service [ 'groups' ] , $ serviceId , $ serviceDefinition , $ container ) ; $ container -> setDefinition ( $ serviceId , $ serviceDefinition ) ; $ container -> getDefinition ( 'bridge.registry' ) -> addMethodCall ( 'addService' , array ( new Reference ( $ serviceId ) ) ) ; } } | Generates service definitions for services . |
27,284 | private function generateGroups ( array $ groups , $ parentId , Definition $ parent , ContainerBuilder $ container ) { foreach ( $ groups as $ groupName => $ group ) { $ groupId = $ parentId . '.' . $ groupName ; $ groupDefinition = $ this -> createComponentDefinition ( $ groupName , $ group [ 'class' ] , $ group [ 'options' ] ) ; $ groupDefinition -> addMethodCall ( 'setService' , array ( new Reference ( $ parentId ) ) ) ; $ this -> generateActions ( $ group [ 'actions' ] , $ groupId , $ groupDefinition , $ container ) ; $ container -> setDefinition ( $ groupId , $ groupDefinition ) ; $ parent -> addMethodCall ( 'addGroup' , array ( new Reference ( $ groupId ) ) ) ; } } | Generates services definitions for groups associated to a service . |
27,285 | private function generateActions ( array $ actions , $ parentId , Definition $ parent , ContainerBuilder $ container ) { foreach ( $ actions as $ actionName => $ action ) { $ actionId = $ parentId . '.' . $ actionName ; $ actionDefinition = $ this -> createComponentDefinition ( $ actionName , $ action [ 'class' ] , $ action [ 'options' ] ) ; $ actionDefinition -> addMethodCall ( 'setGroup' , array ( new Reference ( $ parentId ) ) ) ; $ container -> setDefinition ( $ actionId , $ actionDefinition ) ; $ parent -> addMethodCall ( 'addAction' , array ( new Reference ( $ actionId ) ) ) ; } } | Generates service definitions for actions associated to service groups . |
27,286 | public static function destroy ( ) { if ( \ session_status ( ) !== PHP_SESSION_ACTIVE ) { return false ; } foreach ( \ array_keys ( $ _SESSION ) as $ key ) { unset ( $ _SESSION [ $ key ] ) ; } self :: $ cfgStatic [ 'id' ] = null ; $ success = \ session_destroy ( ) ; if ( ! $ success ) { return false ; } \ setcookie ( self :: $ cfgStatic [ 'name' ] , '' , \ time ( ) - 60 * 60 * 24 , self :: $ cfgStatic [ 'cookiePath' ] , self :: $ cfgStatic [ 'cookieDomain' ] , self :: $ cfgStatic [ 'cookieSecure' ] , self :: $ cfgStatic [ 'cookieHttponly' ] ) ; return $ success ; } | Destroys all data registered to session Removes session cookie |
27,287 | public static function gc ( ) { if ( \ version_compare ( PHP_VERSION , '7.0.0' , '>=' ) ) { return \ session_gc ( ) ; } $ initial = array ( 'status' => \ session_status ( ) , 'probability' => \ ini_get ( 'session.gc_probability' ) , 'divisor' => \ ini_get ( 'session.gc_divisor' ) , ) ; if ( $ initial [ 'status' ] === PHP_SESSION_DISABLED ) { return false ; } if ( $ initial [ 'status' ] === PHP_SESSION_ACTIVE ) { \ session_write_close ( ) ; } \ ini_set ( 'session.gc_probability' , 1 ) ; \ ini_set ( 'session.gc_divisor' , 1 ) ; \ session_start ( ) ; \ ini_set ( 'session.gc_probability' , $ initial [ 'probability' ] ) ; \ ini_set ( 'session.gc_divisor' , $ initial [ 'divisor' ] ) ; if ( $ initial [ 'status' ] === PHP_SESSION_NONE ) { if ( self :: $ status [ 'requestId' ] ) { \ session_write_close ( ) ; } else { \ session_destroy ( ) ; } } return true ; } | Perform session data garbage collection |
27,288 | public static function & get ( $ key ) { self :: startIf ( ) ; if ( isset ( $ _SESSION [ $ key ] ) ) { return $ _SESSION [ $ key ] ; } else { $ val = null ; return $ val ; } } | Get session value |
27,289 | public static function regenerateId ( $ delOldSession = false ) { $ success = false ; if ( self :: $ status [ 'regenerated' ] ) { return false ; } if ( empty ( self :: $ status [ 'requestId' ] ) ) { return false ; } if ( \ session_status ( ) === PHP_SESSION_NONE ) { self :: $ cfgStatic [ 'regenOnStart' ] = true ; } if ( \ session_status ( ) === PHP_SESSION_ACTIVE ) { $ success = \ session_regenerate_id ( $ delOldSession ) ; self :: $ cfgStatic [ 'regenOnStart' ] = false ; self :: $ status [ 'regenerated' ] = true ; } if ( $ success ) { \ bdk \ Debug :: _info ( 'new session_id' , \ session_id ( ) ) ; } return $ success ; } | Assign new session id |
27,290 | public static function start ( ) { if ( \ session_status ( ) === PHP_SESSION_ACTIVE ) { return true ; } if ( \ headers_sent ( ) ) { return false ; } self :: setCfg ( array ( ) ) ; $ success = \ session_start ( ) ; \ bdk \ Debug :: _info ( 'started' , \ session_id ( ) ) ; if ( self :: $ cfgStatic [ 'regenOnStart' ] ) { self :: regenerateId ( ) ; } return $ success ; } | Start session if it s not already started |
27,291 | private static function cfgApply ( ) { $ iniMap = array ( 'gcMaxlifetime' => 'session.gc_maxlifetime' , 'gcProbability' => 'session.gc_probability' , 'gcDivisor' => 'session.gc_divisor' , 'savePath' => 'session.save_path' , 'useCookies' => 'session.use_cookies' , 'useOnlyCookies' => 'session.use_only_cookies' , ) ; foreach ( $ iniMap as $ cfgKey => $ iniKey ) { \ ini_set ( $ iniKey , self :: $ cfgStatic [ $ cfgKey ] ) ; } \ session_set_cookie_params ( self :: $ cfgStatic [ 'cookieLifetime' ] , self :: $ cfgStatic [ 'cookiePath' ] , self :: $ cfgStatic [ 'cookieDomain' ] , self :: $ cfgStatic [ 'cookieSecure' ] , self :: $ cfgStatic [ 'cookieHttponly' ] ) ; if ( \ ini_get ( 'session.save_handler' ) == 'files' && ! \ is_dir ( self :: $ cfgStatic [ 'savePath' ] ) ) { \ bdk \ Debug :: _warn ( 'savePath doesn\'t exist -> creating' ) ; \ mkdir ( self :: $ cfgStatic [ 'savePath' ] , 0700 , true ) ; } \ session_cache_expire ( self :: $ cfgStatic [ 'cacheExpire' ] ) ; \ session_cache_limiter ( self :: $ cfgStatic [ 'cacheLimiter' ] ) ; if ( self :: $ cfgStatic [ 'name' ] != \ session_name ( ) ) { \ session_name ( self :: $ cfgStatic [ 'name' ] ) ; } if ( self :: $ cfgStatic [ 'id' ] ) { \ bdk \ Debug :: _log ( 'setting useStrictMode to false (session_id passed)' ) ; \ ini_set ( 'session.use_strict_mode' , false ) ; \ session_id ( self :: $ cfgStatic [ 'id' ] ) ; } else { \ ini_set ( 'session.use_strict_mode' , self :: $ cfgStatic [ 'useStrictMode' ] ) ; } } | Apply configuration settings |
27,292 | private static function cfgGetDefaults ( ) { if ( self :: $ status [ 'cfgInitialized' ] ) { return array ( ) ; } $ defaults = array ( 'cacheExpire' => \ session_cache_expire ( ) , 'cacheLimiter' => \ session_cache_limiter ( ) , 'gcMaxlifetime' => ( int ) \ ini_get ( 'session.gc_maxlifetime' ) , 'gcProbability' => ( int ) \ ini_get ( 'session.gc_probability' ) , 'gcDivisor' => ( int ) \ ini_get ( 'session.gc_divisor' ) , 'savePath' => ( string ) \ ini_get ( 'session.save_path' ) , 'name' => empty ( self :: $ cfgExplicitlySet [ 'name' ] ) ? self :: cfgGetDefaultName ( ) : null , ) ; if ( empty ( $ defaults [ 'savePath' ] ) && \ ini_get ( 'session.save_handler' ) == 'files' ) { $ defaults [ 'savePath' ] = \ sys_get_temp_dir ( ) ; } self :: $ status [ 'cfgInitialized' ] = true ; return \ array_diff_key ( $ defaults , self :: $ cfgExplicitlySet ) ; } | Get default config values |
27,293 | private static function cfgGetDefaultName ( ) { $ nameDefault = null ; $ sessionNamePref = array ( 'SESSIONID' , \ session_name ( ) ) ; foreach ( $ sessionNamePref as $ nameTest ) { $ useCookies = isset ( self :: $ cfgExplicitlySet [ 'useCookies' ] ) ? self :: $ cfgExplicitlySet [ 'useCookies' ] : self :: $ cfgStatic [ 'useCookies' ] ; if ( $ useCookies && ! empty ( $ _COOKIE [ $ nameTest ] ) ) { $ nameDefault = $ nameTest ; self :: $ status [ 'requestId' ] = $ _COOKIE [ $ nameTest ] ; break ; } $ useOnlyCookies = isset ( self :: $ cfgExplicitlySet [ 'useOnlyCookies' ] ) ? self :: $ cfgExplicitlySet [ 'useOnlyCookies' ] : self :: $ cfgStatic [ 'useOnlyCookies' ] ; if ( ! $ useOnlyCookies && ! empty ( $ _GET [ $ nameTest ] ) ) { $ nameDefault = $ nameTest ; self :: $ status [ 'requestId' ] = $ _GET [ $ nameTest ] ; break ; } } if ( ! $ nameDefault ) { $ nameDefault = $ sessionNamePref [ 0 ] ; } return $ nameDefault ; } | Determine session name |
27,294 | public function emit ( Response $ response ) { $ emitter = new \ Zend \ Diactoros \ Response \ SapiEmitter ( ) ; $ emitter -> emit ( $ response ) ; } | Output to the client the contents of the provided PSR7 Response object . |
27,295 | public static function select ( $ db , $ tableName , $ colNames , $ id ) { $ cols = array_map ( function ( $ colName ) { return Db :: quote ( $ colName ) ; } , $ colNames ) ; $ sql = "select " . implode ( $ cols , ", " ) . " from " . Db :: quote ( $ tableName ) . " where id = ?" ; return $ db -> query ( $ sql , [ $ id ] ) ; } | Selects a record from a table . |
27,296 | public static function Init ( \ Puzzlout \ Framework \ Core \ Application $ app ) { $ instance = new ArrayFilterFileSearch ( ) ; $ instance -> FileList = array ( ) ; $ instance -> ContextApp = $ app ; return $ instance ; } | Builds the instance of class |
27,297 | private function AddFileToResult ( $ directory , $ file ) { if ( array_key_exists ( $ directory , $ this -> FileList ) ) { array_push ( $ this -> FileList [ $ directory ] , $ file ) ; return ; } $ this -> FileList [ $ directory ] = [ $ file ] ; } | Add a file to the result list in the proper subarray using the directory . |
27,298 | public function editAction ( ) { $ params = $ this -> params ( ) ; $ request = $ this -> getRequest ( ) ; $ service = $ this -> getServiceLocator ( ) ; $ cid = $ params -> fromQuery ( 'contentId' ) ; $ pid = $ params -> fromRoute ( 'paragraphId' ) ; $ locale = $ service -> get ( 'AdminLocale' ) -> getCurrent ( ) ; $ model = $ service -> get ( 'Grid\Paragraph\Model\Dashboard\Model' ) ; $ permission = $ service -> get ( 'Grid\User\Model\Permissions\Model' ) ; $ dashboard = $ model -> setLocale ( $ locale ) -> find ( $ pid ) ; $ customize = $ permission -> isAllowed ( 'paragraph.customize' , 'edit' ) ; if ( empty ( $ dashboard ) ) { $ this -> getResponse ( ) -> setStatusCode ( 404 ) ; return ; } $ paragraph = $ dashboard -> paragraph ; if ( ! $ paragraph -> isEditable ( ) ) { $ this -> getResponse ( ) -> setStatusCode ( 403 ) ; return ; } if ( $ cid && $ paragraph instanceof ContentDependentAwareInterface ) { $ content = $ service -> get ( 'Grid\Paragraph\Model\Paragraph\Model' ) -> setLocale ( $ locale ) -> find ( $ cid ) ; if ( $ content instanceof AbstractRoot ) { $ paragraph -> setDependentContent ( $ content ) ; } } $ form = $ dashboard -> getForm ( $ service -> get ( 'Form' ) , $ customize ) ; $ view = new ViewModel ( array ( 'form' => $ form , 'success' => null , ) ) ; if ( $ request -> isPost ( ) ) { $ form -> setData ( $ request -> getPost ( ) ) ; $ view -> setVariable ( 'success' , $ form -> isValid ( ) && $ dashboard -> save ( ) ) ; } return $ view -> setTerminal ( true ) ; } | Edit - paragraph action |
27,299 | public function getBoxSize ( array $ imageSize , array $ size ) { list ( $ width , $ height ) = $ size ; if ( ( null == $ width ) && ( null == $ height ) ) { return $ imageSize ; } list ( $ imageWidth , $ imageHeight ) = $ imageSize ; if ( ( null !== $ width ) && ( null == $ height ) ) { $ height = ceil ( $ width * ( $ imageHeight / $ imageWidth ) ) ; if ( $ height > $ imageHeight ) { $ height = $ imageHeight ; } return array ( $ width , $ height ) ; } if ( ( null === $ width ) && ( null != $ height ) ) { $ width = ceil ( $ height * ( $ imageWidth / $ imageHeight ) ) ; if ( $ width > $ imageWidth ) { $ width = $ imageWidth ; } return array ( $ width , $ height ) ; } return $ size ; } | Get box size . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.