idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
236,600
public function add ( ) { if ( ! $ args = func_get_args ( ) ) { return $ this ; } $ intervals = array_map ( array ( $ this , 'addHelper' ) , $ args ) ; $ intervals [ ] = $ this -> intervals ; $ output = array ( ) ; $ intervals = call_user_func_array ( 'array_merge' , $ intervals ) ; usort ( $ intervals , array ( $ this...
Variable number of argument of things we re likey to be able to make a set out of .
236,601
public function contains ( ) { $ reflection = new \ ReflectionClass ( get_called_class ( ) ) ; $ comparing = $ reflection -> newInstanceArgs ( func_get_args ( ) ) ; if ( ! $ this -> containsNull and $ comparing -> containsNull ) { return false ; } reset ( $ this -> intervals ) ; reset ( $ comparing -> intervals ) ; lis...
Is a set contained within another set
236,602
public function invert ( ) { $ this -> containsNull = ! $ this -> containsNull ; if ( $ this -> intervals === array ( array ( null , null ) ) ) { $ this -> intervals = array ( ) ; return $ this ; } $ output = array ( ) ; $ working = array ( null , null ) ; reset ( $ this -> intervals ) ; while ( list ( , $ interval ) =...
Invert a set .
236,603
protected function addHelper ( $ data ) { if ( is_array ( $ data ) ) { $ originalSize = count ( $ data ) ; $ data = array_filter ( $ data , '\Bond\is_not_null' ) ; if ( $ originalSize !== count ( $ data ) ) { $ this -> containsNull = true ; } $ argIntervals = array_map ( null , $ data , $ data ) ; $ argIntervals = arra...
Convert something that looks like it s going to be a set castable into a array of intervals Not nessisarily sorted
236,604
private function parseStringToIntervals ( $ string ) { if ( ! $ length = mb_strlen ( $ string ) ) { return array ( ) ; } $ intervals = array ( ) ; $ interval = array ( '' ) ; $ c = 0 ; $ isCharEscaped = false ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ char = mb_substr ( $ string , $ i , 1 ) ; if ( $ isCharEscaped ...
Parse the data into an array of unique values
236,605
private final function sortIntervals ( $ a , $ b ) { if ( 0 !== $ lowerCompare = $ this -> sort ( $ a [ 0 ] , $ b [ 0 ] , self :: NULL_IS_LOW ) ) { return $ lowerCompare ; } return - $ this -> sort ( $ a [ 1 ] , $ b [ 1 ] , self :: NULL_IS_HIGH ) ; }
Sort two intervals
236,606
protected function max ( $ a , $ b , $ handleNull ) { return $ this -> sort ( $ a , $ b , $ handleNull ) > 0 ? $ a : $ b ; }
Return the max of two things
236,607
protected function min ( $ a , $ b , $ handleNull ) { return $ this -> sort ( $ a , $ b , $ handleNull ) > 0 ? $ b : $ a ; }
Return the min of two things .
236,608
public static function escape ( $ value , $ escapeNull = true ) { if ( $ value === null ) { return $ escapeNull ? self :: ESCAPE_CHARACTER . self :: NULL_CHARACTER : '' ; } $ value = str_replace ( self :: ESCAPE_CHARACTER , self :: ESCAPE_CHARACTER . self :: ESCAPE_CHARACTER , $ value ) ; $ value = str_replace ( self :...
Escape a interval fragments
236,609
public function prepare ( ) { $ this -> preparedRoutes = true ; foreach ( $ this -> routers as $ router ) { $ this -> prepareRoutes ( $ router -> routes ) ; } }
prepares reverse routes from added routers .
236,610
public static function maps ( array $ mappings , $ key = 'default' ) { self :: $ mappings = array_merge_recursive ( self :: $ mappings , [ $ key => $ mappings ] ) ; }
Register mappings .
236,611
public static function getMappings ( $ resource , $ key = 'default' ) { $ resourceName = $ resource ; if ( is_object ( $ resource ) ) { $ resourceName = get_class ( $ resource ) ; } $ mappings = [ ] ; if ( isset ( self :: $ mappers [ $ key ] ) ) { $ mappings = array_merge_recursive ( $ mappings , call_user_func ( self ...
Get mappings for the resource .
236,612
public function resolveMapping ( $ resource , $ parameters = [ ] , $ key = 'default' , $ method = null ) { $ resourceName = $ resource ; if ( is_object ( $ resource ) ) { $ resourceName = get_class ( $ resource ) ; } $ mappings = $ this -> getMappings ( $ resourceName , $ key ) ; if ( empty ( $ mappings ) ) { throw new...
Resolve mapping end return result
236,613
public function runResolver ( $ resolver , $ parameters = [ ] , $ method = null ) { if ( is_callable ( $ resolver ) ) { return call_user_func_array ( $ resolver , $ parameters ) ; } if ( class_exists ( $ resolver ) ) { $ instance = $ this -> container -> make ( $ resolver , $ parameters ) ; if ( $ instance instanceof C...
Handle and run the resolver
236,614
public function getPostFields ( ) { $ this -> validate ( ) ; $ mappedFields = $ this -> getMappedFields ( ) ; $ this -> paymentMethod -> addAdditionalFields ( $ mappedFields ) ; return $ mappedFields ; }
Get the post fields for the requests .
236,615
private function createSimple ( ) : Redis { $ redis = new Redis ( ) ; $ redis -> connect ( $ this -> config [ 'host' ] , ( int ) $ this -> config [ 'port' ] ) ; $ redis -> setOption ( Redis :: OPT_READ_TIMEOUT , '-1' ) ; if ( $ this -> config [ 'database' ] ) { $ redis -> select ( $ this -> config [ 'database' ] ) ; } ...
Create single redis .
236,616
protected function getAssetsUrl ( $ inputUrl ) { $ assets = $ this -> getService ( 'assets.packages' ) ; $ url = preg_replace ( '/^asset\[(.+)\]$/i' , '$1' , $ inputUrl ) ; if ( $ inputUrl !== $ url ) { return $ assets -> getUrl ( $ this -> baseUrl . $ url ) ; } return $ inputUrl ; }
Get url from config string
236,617
public function getSelector ( $ pkey , array $ record ) { if ( $ pkey !== null && ! is_array ( $ pkey ) ) throw new InvalidTypeException ( "Invalid primary key: " . WF :: str ( $ pkey ) ) ; $ is_primary_key = true ; if ( $ pkey === null ) { $ pkey = array ( ) ; foreach ( $ record as $ k => $ v ) $ pkey [ $ k ] = $ this...
Form a condition that matches the record using the values in the provided record .
236,618
public function save ( Model $ model ) { $ database = $ model -> getSourceDB ( ) ; $ pkey = $ model -> getID ( ) ; if ( $ database === null || $ database !== $ this -> db ) $ this -> insert ( $ model ) ; else $ this -> update ( $ model ) ; return $ this ; }
Save the current record to the database .
236,619
public function getByID ( $ id ) { $ pkey = $ this -> getPrimaryKey ( ) ; if ( $ pkey === null ) throw new DAOException ( "A primary key is required to select a record by ID" ) ; if ( count ( $ pkey ) === 1 && is_scalar ( $ id ) ) foreach ( $ pkey as $ colname => $ def ) $ id = [ $ colname => $ id ] ; $ condition = $ t...
Load the record from the database
236,620
public function get ( ... $ args ) { $ record = $ this -> fetchSingle ( $ args ) ; if ( ! $ record ) return null ; $ obj = new $ this -> model_class ; $ obj -> assignRecord ( $ record , $ this -> db ) ; return $ obj ; }
Retrieve a single record based on a provided query
236,621
public function getAll ( ... $ args ) { $ pkey = $ this -> getPrimaryKey ( ) ; if ( count ( $ pkey ) === 1 ) { reset ( $ pkey ) ; $ pkey_as_index = key ( $ pkey ) ; } else $ pkey_as_index = false ; $ list = array ( ) ; $ records = $ this -> fetchAll ( $ args ) ; foreach ( $ records as $ record ) { $ obj = new $ this ->...
Retrieve a set of records create object from them and return the resulting list .
236,622
public function fetchSingle ( ... $ args ) { $ args [ ] = QB :: limit ( 1 ) ; $ select = $ this -> select ( $ args ) ; return $ select -> fetch ( ) ; }
Execute a query retrieve the first record and return it .
236,623
public function select ( ... $ args ) { $ args = WF :: flatten_array ( $ args ) ; $ select = new Query \ Select ; $ select -> add ( new Query \ SourceTableClause ( $ this -> tablename ) ) ; $ cols = $ this -> getColumns ( ) ; foreach ( $ cols as $ name => $ def ) $ select -> add ( new Query \ GetClause ( $ name ) ) ; f...
Select one or more records from the database .
236,624
public function update ( $ id , array $ record = null ) { $ model = is_a ( $ id , $ this -> model_class ) ? $ id : null ; if ( null !== $ model ) { if ( $ record !== null ) throw new DAOException ( "You should not pass an array of updates when supplying a Model" ) ; if ( $ id -> getSourceDB ( ) !== $ this -> db ) throw...
Update records in the database .
236,625
public function delete ( $ where ) { $ is_model = is_a ( $ where , $ this -> model_class ) ; if ( ! $ is_model && ! is_a ( $ where , Query \ WhereClause :: class ) ) throw new InvalidTypeException ( "Must provide a WhereClause or an instance of {$this->model_class} to delete" ) ; $ modelInstance = null ; if ( $ is_mode...
Delete records from the database .
236,626
public function route ( $ name , $ details = [ ] ) { $ this -> route = route ( $ name , $ details ) ; $ this -> routeName = $ name ; return $ this ; }
Add a route to redirect the request to .
236,627
public function redirectIntended ( ) { if ( is_null ( $ this -> route ) ) { throw new \ Exception ( 'No route has been provided. Please use route() to add one.' ) ; } if ( $ this -> success ) { return redirect ( ) -> intended ( $ this -> route ) -> with ( 'message' , $ this -> message ) ; } return redirect ( $ this ->...
Redirect the request to the intended route or the provided one .
236,628
public function associateRelatedRecordsToNewRecord ( $ modelInstance , $ associatedRecords , $ relatedNamespace , $ relatedModelClass ) { if ( count ( $ associatedRecords ) > 0 ) { $ namespaceModelclass = $ relatedNamespace . "\\" . $ relatedModelClass ; $ relatedRepository = new \ Lasallecms \ Lasallecmsapi \ Reposito...
Associate each related record with the record just created
236,629
public function associateRelatedRecordsToUpdatedRecord ( $ modelInstance , $ associatedRecords , $ relatedModelClass ) { if ( count ( $ associatedRecords ) > 0 ) { $ newIds = array ( ) ; foreach ( $ associatedRecords as $ associatedId ) { $ newIds [ ] = $ associatedId ; } $ relatedMethod = strtolower ( $ relatedModelCl...
Associate each related record with the record just updated .
236,630
public function get ( $ idOrKey , array $ fields = null ) { $ parameters = $ fields ? sprintf ( '?%s' , $ this -> createUriParameters ( [ 'fields' => implode ( ',' , $ fields ) ] ) ) : '' ; return $ this -> getRequest ( sprintf ( 'issue/%s%s' , $ idOrKey , $ parameters ) ) ; }
Returns issue by id or key .
236,631
public function delete ( $ idOrKey , $ deleteSubtasks = false ) { $ parameters = sprintf ( '?deleteSubtasks=%s' , $ deleteSubtasks ) ; return $ this -> deleteRequest ( sprintf ( 'issue/%s%s' , $ idOrKey , $ parameters ) ) ; }
Deletes an issue by id or key
236,632
public function createAttachment ( $ idOrKey , $ fileHandle ) { if ( gettype ( $ fileHandle ) != 'resource' ) { throw new \ RuntimeException ( sprintf ( 'createAttachment() expects parameter 2 to be resource, %s given' , gettype ( $ fileHandle ) ) ) ; } return $ this -> postFile ( sprintf ( 'issue/%s/attachments' , $ i...
Create issue attachment by its id or key
236,633
public function updateComment ( $ idOrKey , $ commentId , array $ data ) { return $ this -> putRequest ( sprintf ( 'issue/%s/comment/%s' , $ idOrKey , $ commentId ) , $ data ) ; }
Updates a comment by issue id or key comment id with given data
236,634
public function createWorklog ( $ idOrKey , array $ data , $ adjustEstimate = null , $ newEstimate = null , $ reduceBy = null ) { $ parameters = http_build_query ( [ 'adjustEstimate' => $ adjustEstimate , 'newEstimate' => $ newEstimate , 'reduceBy' => $ reduceBy , ] ) ; if ( $ parameters ) { $ parameters = sprintf ( '?...
Creates worklog for the issue by issue id or key
236,635
public function updateWorklog ( $ idOrKey , $ worklogId , array $ data , $ adjustEstimate = null , $ newEstimate = null ) { $ parameters = http_build_query ( [ 'adjustEstimate' => $ adjustEstimate , 'newEstimate' => $ newEstimate , ] ) ; if ( $ parameters ) { $ parameters = sprintf ( '?%s' , $ parameters ) ; } return $...
Updates worklog for the issue by issue id or key and worklog id
236,636
public function deleteWorklog ( $ idOrKey , $ worklogId , $ adjustEstimate = null , $ newEstimate = null , $ increaseBy = null ) { $ parameters = http_build_query ( [ 'adjustEstimate' => $ adjustEstimate , 'newEstimate' => $ newEstimate , 'increaseBy' => $ increaseBy , ] ) ; if ( $ parameters ) { $ parameters = sprintf...
Deletes worklog for the issue by issue id or key and worklog id
236,637
public function getListeners ( $ event ) { $ parentListeners = [ ] ; $ wildcards = [ ] ; if ( is_object ( $ event ) ) { $ eventName = get_class ( $ event ) ; $ parentListeners = $ this -> getParentListeners ( $ event ) ; } else { $ eventName = $ event ; $ wildcards = $ this -> getWildcardListeners ( $ event ) ; } if ( ...
Get all of the listeners for a given event .
236,638
protected function getParentListeners ( $ event ) { $ parentListeners = [ ] ; foreach ( $ this -> listeners as $ key => $ listeners ) { if ( $ event instanceof $ key ) { $ parentListeners = array_merge ( $ parentListeners , $ listeners ) ; } } return $ parentListeners ; }
Get the parent class or interface listeners for the event .
236,639
public function unlockMyRecords ( $ tableName ) { $ results = $ this -> lockedRecordsByUser ( $ tableName , Auth :: user ( ) -> id ) ; foreach ( $ results as $ result ) { $ this -> unpopulateLockFields ( $ result -> id ) ; } }
Unlock records belonging to the current user .
236,640
public function isLocked ( $ id ) { $ record = $ this -> model -> findOrFail ( $ id ) ; if ( $ record -> locked_by > 0 ) return true ; return false ; }
Is the record locked? Locked is defined as the locked_by field being populated ; that is > 0
236,641
public function populateLockFields ( $ id ) { $ record = $ this -> model -> findOrFail ( $ id ) ; $ record -> locked_by = Auth :: user ( ) -> id ; $ record -> locked_at = date ( 'Y-m-d H:i:s' ) ; return $ record -> save ( ) ; }
Populate the locked_at and locked_by fields . By definition this must be an UPDATE
236,642
public function unpopulateLockFields ( $ id ) { $ record = $ this -> model -> findOrFail ( $ id ) ; $ record -> locked_by = null ; $ record -> locked_at = null ; return $ record -> save ( ) ; }
Un - populate the locked_at and locked_by fields . By definition this must be an UPDATE
236,643
public static function to ( $ model , $ target , $ position ) { $ instance = new static ( $ model , $ target , $ position ) ; return $ instance -> perform ( ) ; }
Easy static accessor for performing a move operation .
236,644
public function perform ( ) { $ this -> guardAgainstImpossibleMove ( ) ; if ( $ this -> fireMoveEvent ( 'moving' ) === false ) return $ this -> model ; if ( $ this -> hasChange ( ) ) { $ self = $ this ; $ this -> model -> getConnection ( ) -> transaction ( function ( ) use ( $ self ) { $ self -> updateStructure ( ) ; }...
Perform the move operation .
236,645
protected function resolveNode ( $ model ) { if ( $ model instanceof NestedModel ) return $ model -> reload ( ) ; return $ this -> model -> newNestedSetQuery ( ) -> find ( $ model ) ; }
Resolves suplied node . Basically returns the node unchanged if supplied parameter is an instance of NestedModel . Otherwise it will try to find the node in the database .
236,646
protected function guardAgainstImpossibleMove ( ) { if ( ! $ this -> model -> exists ) throw new MoveNotPossibleException ( 'A new node cannot be moved.' ) ; if ( array_search ( $ this -> position , [ 'child' , 'left' , 'right' , 'root' ] ) === false ) throw new MoveNotPossibleException ( "Position should be one of ['c...
Check wether the current move is possible and if not rais an exception .
236,647
protected function bound1 ( ) { if ( ! is_null ( $ this -> _bound1 ) ) return $ this -> _bound1 ; switch ( $ this -> position ) { case 'child' : $ this -> _bound1 = $ this -> target -> getRight ( ) ; break ; case 'left' : $ this -> _bound1 = $ this -> target -> getLeft ( ) ; break ; case 'right' : $ this -> _bound1 = $...
Computes the boundary .
236,648
protected function boundaries ( ) { if ( ! is_null ( $ this -> _boundaries ) ) return $ this -> _boundaries ; $ this -> _boundaries = [ $ this -> model -> getLeft ( ) , $ this -> model -> getRight ( ) , $ this -> bound1 ( ) , $ this -> bound2 ( ) ] ; sort ( $ this -> _boundaries ) ; return $ this -> _boundaries ; }
Computes the boundaries array .
236,649
protected function parentId ( ) { switch ( $ this -> position ) { case 'root' : return null ; case 'child' : return $ this -> target -> getKey ( ) ; default : return $ this -> target -> getParentId ( ) ; } }
Computes the new parent id for the node being moved .
236,650
protected function hasChange ( ) { return ! ( $ this -> bound1 ( ) == $ this -> model -> getRight ( ) || $ this -> bound1 ( ) == $ this -> model -> getLeft ( ) ) ; }
Check wether there should be changes in the downward tree structure .
236,651
protected function fireMoveEvent ( $ event , $ halt = true ) { $ event = "eloquent.{$event}: " . get_class ( $ this -> model ) ; $ method = $ halt ? 'until' : 'fire' ; Hooks :: trigger ( $ event , [ 'model' => $ this -> model ] ) ; }
Fire the given move event for the model .
236,652
protected function applyLockBetween ( $ lft , $ rgt ) { $ this -> model -> newQuery ( ) -> where ( $ this -> model -> getLeftColumnName ( ) , '>=' , $ lft ) -> where ( $ this -> model -> getRightColumnName ( ) , '<=' , $ rgt ) -> select ( $ this -> model -> getKeyName ( ) ) -> lockForUpdate ( ) -> get ( ) ; }
Applies a lock to the rows between the supplied index boundaries .
236,653
public function cleanUpUnassignedTokens ( array $ tokens ) { $ this -> em -> clear ( ) ; foreach ( $ tokens as $ token ) { $ token = $ this -> em -> merge ( $ token ) ; $ this -> em -> remove ( $ token ) ; } $ this -> em -> flush ( ) ; }
Removes the not assigned tokens .
236,654
protected function setCleanUrl ( $ urlString ) { $ arrayToReplace = [ '&#038;' => '&amp;' , '&' => '&amp;' , '&amp;amp;' => '&amp;' , ' ' => '%20' , ] ; $ kys = array_keys ( $ arrayToReplace ) ; $ vls = array_values ( $ arrayToReplace ) ; return str_replace ( $ kys , $ vls , filter_var ( $ urlString , FILTER_SANITIZE_U...
Cleans a string for certain internal rules
236,655
protected function setFeedbackModern ( $ sType , $ sTitle , $ sMsg , $ skipBr = false ) { if ( $ sTitle == 'light' ) { return $ sMsg ; } $ legend = $ this -> setStringIntoTag ( $ sTitle , 'legend' , [ 'style' => $ this -> setFeedbackStyle ( $ sType ) ] ) ; return implode ( '' , [ ( $ skipBr ? '' : '<br/>' ) , $ this ->...
Builds a structured modern message
236,656
protected function setHeaderNoCache ( $ contentType = 'application/json' ) { header ( "Content-Type: " . $ contentType . "; charset=utf-8" ) ; header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . " GMT" ) ; header ( "Cache-Control: no-store, no-cache, must-revalidate" ) ; header ( "Cache-Control: post-check=0, pr...
Sets the no - cache header
236,657
protected function setStringIntoShortTag ( $ sTag , $ features = null ) { return '<' . $ sTag . $ this -> buildAttributesForTag ( $ features ) . ( isset ( $ features [ 'dont_close' ] ) ? '' : '/' ) . '>' ; }
Puts a given string into a specific short tag
236,658
protected function setStringIntoTag ( $ sString , $ sTag , $ features = null ) { return '<' . $ sTag . $ this -> buildAttributesForTag ( $ features ) . '>' . $ sString . '</' . $ sTag . '>' ; }
Puts a given string into a specific tag
236,659
public function int ( $ value , $ min = false , $ max = false , $ default = false ) { $ options = array ( "options" => array ( ) ) ; if ( isset ( $ default ) ) { $ options [ "options" ] [ "default" ] = $ default ; } if ( is_numeric ( $ min ) ) { $ options [ "options" ] [ "min_range" ] = $ min ; } if ( is_numeric ( $ ma...
Validates integer value .
236,660
public function str ( $ value , $ minLength = 0 , $ maxLength = false , $ default = false ) { $ value = trim ( $ value ) ; if ( ( ! empty ( $ minLength ) && ( mb_strlen ( $ value , $ this -> encoding ) < $ minLength ) ) || ( ! empty ( $ maxLength ) && ( mb_strlen ( $ value , $ this -> encoding ) > $ maxLength ) ) ) { r...
Validates string value .
236,661
public function plain ( $ value , $ minLength = 0 , $ maxLength = false , $ default = false ) { $ value = strip_tags ( $ value ) ; return $ this -> str ( $ value , $ minLength , $ maxLength , $ default ) ; }
Validates string and is removing tags from it .
236,662
public function email ( $ value , $ default = false , $ checkMxRecord = false ) { if ( ! $ value = filter_var ( $ value , FILTER_VALIDATE_EMAIL ) ) { return $ default ; } $ dom = explode ( "@" , $ value ) ; $ dom = array_pop ( $ dom ) ; if ( ! $ this -> url ( "http://$dom" ) ) { return $ default ; } return ( ! $ checkM...
Validates email .
236,663
public function setRequired ( bool $ required ) : BaseAttribute { parent :: setRequired ( $ required ) ; if ( $ this -> getMinLength ( ) === 0 ) { $ this -> setMinLength ( 1 ) ; } return $ this ; }
Set Required .
236,664
public function setLocalColumnNames ( array $ localColumnNames ) { $ this -> localColumnNames = array ( ) ; foreach ( $ localColumnNames as $ localColumnName ) { $ this -> addLocalColumnName ( $ localColumnName ) ; } }
Sets the local column names .
236,665
public function addLocalColumnName ( $ localColumnName ) { if ( ! is_string ( $ localColumnName ) || ( strlen ( $ localColumnName ) <= 0 ) ) { throw SchemaException :: invalidForeignKeyLocalColumnName ( $ this -> getName ( ) ) ; } $ this -> localColumnNames [ ] = $ localColumnName ; }
Adds a local column name to the foreign key .
236,666
public function setForeignTableName ( $ foreignTableName ) { if ( ! is_string ( $ foreignTableName ) || ( strlen ( $ foreignTableName ) <= 0 ) ) { throw SchemaException :: invalidForeignKeyForeignTableName ( $ this -> getName ( ) ) ; } $ this -> foreignTableName = $ foreignTableName ; }
Sets the foreign table name .
236,667
public function addForeignColumnName ( $ foreignColumnName ) { if ( ! is_string ( $ foreignColumnName ) || ( strlen ( $ foreignColumnName ) <= 0 ) ) { throw SchemaException :: invalidForeignKeyForeignColumnName ( $ this -> getName ( ) ) ; } $ this -> foreignColumnNames [ ] = $ foreignColumnName ; }
Adds a foreign column name to the foreign key .
236,668
protected function setDotNotationKey ( $ key , $ value ) { $ splitKey = explode ( '.' , $ key ) ; $ root = & $ this -> data ; while ( $ part = array_shift ( $ splitKey ) ) { if ( ! isset ( $ root [ $ part ] ) && count ( $ splitKey ) ) { $ root [ $ part ] = [ ] ; } $ root = & $ root [ $ part ] ; } $ root = $ value ; }
Handle setting a configuration value with a dot notation key .
236,669
private function compileAndSetName ( ) { $ name = \ Nuki \ Handlers \ Core \ Assist :: classNameShort ( $ this ) ; $ this -> name = strtolower ( $ name ) ; }
Private function to compile and set the driver name
236,670
private function isAlreadyInstalled ( ) : bool { $ public = new SplFileInfo ( self :: PROJECT_ROOT . '/public' ) ; $ src = new SplFileInfo ( self :: PROJECT_ROOT . '/src' ) ; return $ public -> isDir ( ) && $ src -> isDir ( ) ; }
Finds out if the framework has already been installed
236,671
private function modifyComposerFile ( ) { if ( ! is_writeable ( 'composer.json' ) ) { throw new Exception ( 'Make sure a composer.json file exists and is writable' ) ; } $ json = file_get_contents ( 'composer.json' ) ; $ composer = json_decode ( $ json ) ; if ( ! isset ( $ composer -> autoload ) || ! isset ( $ composer...
Modifies the composer file - Add the new project namespace to the autoload list
236,672
public static function getReadableSize ( $ bytes ) { $ unit = [ 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ] ; $ exp = floor ( log ( $ bytes , 1024 ) ) | 0 ; return round ( $ bytes / ( pow ( 1024 , $ exp ) ) , 2 ) . " $unit[$exp]" ; }
Get file size with correct extension
236,673
public function validateFor ( $ context ) { $ this -> errors = new Errors ( ) ; $ methodResolved = ActionUtils :: parseMethod ( $ context ) ; if ( ! method_exists ( $ this , $ methodResolved ) ) throw new Exception ( 'Method [' . $ methodResolved . '] does not exist on class [' . get_class ( $ this ) . ']' ) ; $ this -...
This method is called to perform validation
236,674
public function fromGeoCoordinate ( GeoCoordinate $ geoCoordinate = null ) { if ( $ geoCoordinate !== null ) { $ this -> latitude = $ geoCoordinate -> latitude ; $ this -> longitude = $ geoCoordinate -> longitude ; } return $ this ; }
= 0 ;
236,675
public static function getExtensionsByMimeType ( $ mimeType , $ magicFile = null ) { $ mimeTypes = static :: loadMimeTypes ( $ magicFile ) ; return array_keys ( $ mimeTypes , mb_strtolower ( $ mimeType , 'utf-8' ) , true ) ; }
Determines the extensions by given MIME type . This method will use a local map between extension names and MIME types .
236,676
private static function matchBasename ( $ baseName , $ pattern , $ firstWildcard , $ flags ) { if ( $ firstWildcard === false ) { if ( $ pattern === $ baseName ) { return true ; } } elseif ( $ flags & self :: PATTERN_ENDSWITH ) { $ n = StringHelper :: byteLength ( $ pattern ) ; if ( StringHelper :: byteSubstr ( $ patte...
Performs a simple comparison of file or directory names .
236,677
private static function matchPathname ( $ path , $ basePath , $ pattern , $ firstWildcard , $ flags ) { if ( isset ( $ pattern [ 0 ] ) && $ pattern [ 0 ] == '/' ) { $ pattern = StringHelper :: byteSubstr ( $ pattern , 1 , StringHelper :: byteLength ( $ pattern ) ) ; if ( $ firstWildcard !== false && $ firstWildcard !==...
Compares a path part against a pattern with optional wildcards .
236,678
public function countValues ( ) : int { $ count = 0 ; foreach ( $ this -> fields as $ field ) { $ count += $ field -> count ( ) ; } return $ count ; }
Gets the total number of values in the fields list structure .
236,679
private function lookupChannelKey ( $ channelName ) { if ( $ channelName == '#niche_monitoring' ) { $ channelKey = $ this -> slackConfig [ 'webhookURL_niche_monitoring' ] ; } elseif ( $ channelName == '#after-school-internal' ) { $ channelKey = $ this -> slackConfig [ 'webhookURL_after-school-internal' ] ; } else { $ c...
Lookup channel key value based on channel name .
236,680
public function alert ( $ channelNames , $ message , $ tos = [ '@dee' ] ) { $ to = implode ( ',' , $ tos ) ; foreach ( $ channelNames as $ channelName ) { $ channelKey = $ this -> lookupChannelKey ( $ channelName ) ; $ slack = new Client ( $ channelKey ) ; $ slack -> to ( $ to ) -> attach ( $ message ) -> send ( ) ; $ ...
Send report to Slack .
236,681
protected function createJsonResponse ( $ data = null , $ scope = null , $ status = 200 ) { if ( $ data !== null ) { $ data = is_string ( $ data ) ? $ data : $ this -> container -> get ( 'serializer' ) -> serialize ( $ data , 'json' , empty ( $ scope ) ? array ( ) : array ( 'scope' => $ scope ) ) ; } $ response = new R...
Create a JsonResponse with given data if object given it will be serialize with registered serializer .
236,682
protected function createJsonBadRequestResponse ( array $ errors = array ( ) ) { foreach ( $ errors as $ key => $ error ) { if ( ! $ error instanceof FormError ) { continue ; } $ errors [ 'errors' ] [ $ key ] = array ( 'message' => $ error -> getMessage ( ) , 'parameters' => $ error -> getMessageParameters ( ) , ) ; un...
create and returns a 400 Bad Request response .
236,683
protected function getRequestData ( Request $ request , $ inflection = 'camelize' ) { switch ( $ request -> headers -> get ( 'content-type' ) ) { case 'application/json' : if ( ! ( $ data = @ json_decode ( $ request -> getContent ( ) , true ) ) && ( $ error = json_last_error ( ) ) != JSON_ERROR_NONE ) { throw new HttpE...
Retrieve given request data depending on its content type .
236,684
protected function assertSubmitedFormIsValid ( Request $ request , FormInterface $ form ) { $ form -> submit ( $ this -> getRequestData ( $ request ) , $ request -> getMethod ( ) !== 'PATCH' ) ; if ( ! $ valid = $ form -> isValid ( ) ) { throw new ValidationException ( $ form -> getData ( ) , $ form -> getErrors ( true...
Custom method for form submission to handle http method bugs and extra fields error options .
236,685
public function bootstrap ( $ webDir , array $ config = [ ] ) { $ baseDir = dirname ( $ webDir ) ; $ this [ "gluggi.config" ] = $ this -> resolveConfig ( $ config ) ; $ this [ "gluggi.baseDir" ] = $ baseDir ; $ this -> registerProviders ( ) ; $ this -> registerCoreTwigNamespace ( ) ; $ this -> registerModelsAndTwigLayo...
Bootstraps the complete application
236,686
private function registerProviders ( ) { $ this -> register ( new TwigServiceProvider ( ) ) ; $ this -> register ( new UrlGeneratorServiceProvider ( ) ) ; $ this -> register ( new ServiceControllerServiceProvider ( ) ) ; }
Registers all used service providers
236,687
private function registerModelsAndTwigLayoutNamespaces ( $ baseDir ) { $ elementTypesModel = new ElementTypesModel ( $ baseDir ) ; $ this [ "model.element_types" ] = $ elementTypesModel ; $ this [ "model.download" ] = new DownloadModel ( $ baseDir ) ; foreach ( $ elementTypesModel -> getAllElementTypes ( ) as $ element...
Registers all models and all twig layout namespaces
236,688
private function registerTwigExtensions ( ) { $ this [ 'twig' ] = $ this -> share ( $ this -> extend ( 'twig' , function ( Twig_Environment $ twig , Application $ app ) { $ twig -> addExtension ( new TwigExtension ( $ app ) ) ; $ twig -> addGlobal ( "gluggi" , [ "config" => $ this [ "gluggi.config" ] ] ) ; return $ twi...
Registers all used twig extensions
236,689
private function defineCoreRouting ( ) { $ this -> get ( "/" , "controller.core:indexAction" ) -> bind ( "index" ) ; $ this -> get ( "/all/{elementType}" , "controller.core:elementsOverviewAction" ) -> bind ( "elements_overview" ) ; $ this -> get ( "/{elementType}/{key}" , "controller.core:showElementAction" ) -> bind ...
Defines the routes of the core app
236,690
public function setGenus ( \ Librinfo \ VarietiesBundle \ Entity \ Genus $ genus = null ) { $ this -> genus = $ genus ; return $ this ; }
Set genus .
236,691
public function addSubspecies ( \ Librinfo \ VarietiesBundle \ Entity \ Species $ subspecies ) { $ subspecies -> setParentSpecies ( $ this ) ; $ this -> subspecieses [ ] = $ subspecies ; return $ this ; }
Add subspecies .
236,692
public function removeSubspeciese ( \ Librinfo \ VarietiesBundle \ Entity \ Species $ subspecies ) { return $ this -> subspecieses -> removeElement ( $ subspecies ) ; }
Remove subspecies .
236,693
public function setParentSpecies ( \ Librinfo \ VarietiesBundle \ Entity \ Species $ parentSpecies = null ) { $ this -> parent_species = $ parentSpecies ; return $ this ; }
Set parentSpecies .
236,694
public function setOffset ( $ offset ) { $ this -> checkStreamAvailable ( ) ; fseek ( $ this -> fileDescriptor , $ offset < 0 ? $ this -> getSize ( ) + $ offset : $ offset ) ; }
Sets the point of operation ie the cursor offset value . The offset may also be set to a negative value when it is interpreted as an offset from the end of the stream instead of the beginning .
236,695
final public function readInt16LE ( ) { if ( $ this -> isBigEndian ( ) ) { return $ this -> fromInt16 ( strrev ( $ this -> read ( 2 ) ) ) ; } else { return $ this -> fromInt16 ( $ this -> read ( 2 ) ) ; } }
Reads 2 bytes from the stream and returns little - endian ordered binary data as signed 16 - bit integer .
236,696
final public function readInt16BE ( ) { if ( $ this -> isLittleEndian ( ) ) { return $ this -> fromInt16 ( strrev ( $ this -> read ( 2 ) ) ) ; } else { return $ this -> fromInt16 ( $ this -> read ( 2 ) ) ; } }
Reads 2 bytes from the stream and returns big - endian ordered binary data as signed 16 - bit integer .
236,697
private function fromUInt16 ( $ value , $ order = 0 ) { list ( , $ int ) = unpack ( ( $ order == self :: BIG_ENDIAN_ORDER ? 'n' : ( $ order == self :: LITTLE_ENDIAN_ORDER ? 'v' : 'S' ) ) . '*' , $ value ) ; return $ int ; }
Returns machine endian ordered binary data as unsigned 16 - bit integer .
236,698
private function fromInt24 ( $ value ) { list ( , $ int ) = unpack ( 'l*' , $ this -> isLittleEndian ( ) ? ( "\x00" . $ value ) : ( $ value . "\x00" ) ) ; return $ int ; }
Returns machine endian ordered binary data as signed 24 - bit integer .
236,699
final public function readInt24LE ( ) { if ( $ this -> isBigEndian ( ) ) { return $ this -> fromInt24 ( strrev ( $ this -> read ( 3 ) ) ) ; } else { return $ this -> fromInt24 ( $ this -> read ( 3 ) ) ; } }
Reads 3 bytes from the stream and returns little - endian ordered binary data as signed 24 - bit integer .