idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
41,900
public function detachFromSchool ( $ id = null , $ identifier = null , $ username = null , $ school_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ school_id ) ) $ fields [ 'school_id' ] = $ school_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _del ( $ fields , 'school' ) ; }
Detach Account From School
41,901
public function attachToSchool ( $ id = null , $ identifier = null , $ username = null , $ school_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ school_id ) ) $ fields [ 'school_id' ] = $ school_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _post ( $ fields , 'school' ) ; }
Attach Account To School
41,902
public function detachFromCourse ( $ id = null , $ identifier = null , $ username = null , $ course_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ course_id ) ) $ fields [ 'course_id' ] = $ course_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _del ( $ fields , 'course' ) ; }
Detach Account From Course
41,903
public function attachToCourse ( $ id = null , $ identifier = null , $ username = null , $ course_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ course_id ) ) $ fields [ 'course_id' ] = $ course_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _post ( $ fields , 'course' ) ; }
Attach Account To Course
41,904
public function detachFromDepartment ( $ id = null , $ identifier = null , $ username = null , $ department_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ department_id ) ) $ fields [ 'department_id' ] = $ department_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _del ( $ fields , 'department' ) ; }
Detach Account From Department
41,905
public function attachToDepartment ( $ id = null , $ identifier = null , $ username = null , $ department_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ department_id ) ) $ fields [ 'department_id' ] = $ department_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _post ( $ fields , 'department' ) ; }
Attach Account To Department
41,906
public function detachFromRoom ( $ id = null , $ identifier = null , $ username = null , $ room_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ room_id ) ) $ fields [ 'room_id' ] = $ room_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _del ( $ fields , 'room' ) ; }
Detach Account From Room
41,907
public function attachToRoom ( $ id = null , $ identifier = null , $ username = null , $ room_id = null , $ code = null ) { $ fields = [ ] ; if ( ! is_null ( $ id ) ) $ fields [ 'id' ] = $ id ; if ( ! is_null ( $ identifier ) ) $ fields [ 'identifier' ] = $ identifier ; if ( ! is_null ( $ username ) ) $ fields [ 'username' ] = $ username ; if ( ! is_null ( $ room_id ) ) $ fields [ 'room_id' ] = $ room_id ; if ( ! is_null ( $ code ) ) $ fields [ 'code' ] = $ code ; return $ this -> _post ( $ fields , 'room' ) ; }
Attach Account To Room
41,908
protected function _allow ( ) { $ url = Wasabi :: getCurrentUrlArray ( ) ; if ( $ this -> Guardian -> isGuestAction ( $ url ) ) { $ this -> Auth -> allow ( $ this -> request -> params [ 'action' ] ) ; } }
Allow all guest actions .
41,909
public function getList ( string $ path ) { $ entity = $ this -> getEntity ( $ path ) ; if ( null !== $ entity && $ entity -> file_exists ( ) && $ entity -> is_dir ( ) ) { $ files = [ ] ; $ changes = $ this -> getChanges ( ) ; $ own = $ changes -> own ( $ path ) ; if ( ! ( $ entity instanceof VirtualInterface ) ) { $ directory = $ this -> getRoot ( ) ; $ directoryPath = $ directory -> path ( ) . '/' . $ path ; $ dirHandler = opendir ( $ directoryPath ) ; if ( $ dirHandler ) { while ( true ) { $ file = readdir ( $ dirHandler ) ; if ( false === $ file ) { break ; } elseif ( '.' == $ file || '..' == $ file ) { continue ; } $ changesKey = ( $ path ? $ path . '/' : '' ) . $ file ; if ( isset ( $ own [ $ changesKey ] ) ) { continue ; } $ files [ $ changesKey ] = Entity :: newInstance ( $ changesKey ) ; } closedir ( $ dirHandler ) ; } } foreach ( $ own as $ changesKey => $ file ) { if ( $ file instanceof DeletedInterface ) { unset ( $ own [ $ changesKey ] ) ; } } $ mergedFiles = array_merge ( $ files , $ own ) ; ksort ( $ mergedFiles ) ; $ result = array_values ( $ mergedFiles ) ; } else { $ result = null ; } return $ result ; }
Get list of files inside directory path .
41,910
public function tempnam ( ) : string { $ root = $ this -> getFsRoot ( ) ; do { ++ $ this -> fsCounter ; $ name = $ root . '/' . $ this -> fsCounter ; } while ( file_exists ( $ name ) ) ; return $ name ; }
Get unique filename .
41,911
public function commit ( ) : void { if ( null !== $ this -> changes ) { $ this -> commitInternal ( $ this -> changes ) ; $ this -> changes = null ; } }
Commit changes to real FS .
41,912
protected function setRoot ( EntityInterface $ entity ) : void { if ( ! $ entity -> file_exists ( ) || ! $ entity -> is_dir ( ) ) { throw new Exception ( 'Root directory is not valid' ) ; } $ this -> root = $ entity ; }
Init root .
41,913
protected function getChanges ( ) : Changes { if ( null === $ this -> changes ) { $ this -> changes = new Changes ( ) ; } return $ this -> changes ; }
Get FS - changes object .
41,914
private function commitInternal ( Changes $ changes , string $ path = '' ) : void { $ root = $ this -> getRoot ( ) ; $ rootpath = $ root -> path ( ) ; if ( $ path ) { $ path .= '/' ; } $ own = $ changes -> own ( ) ; foreach ( $ own as $ filename => $ vEntity ) { $ filepath = $ path . $ filename ; $ rPath = $ rootpath . '/' . $ filepath ; $ vExists = $ vEntity -> file_exists ( ) ; $ rDeleted = false ; $ rEntity = $ vEntity ; do { $ rEntity = $ rEntity -> getRealEntity ( ) ; $ rDeleted = $ rDeleted || ! $ rEntity -> file_exists ( ) ; } while ( $ rEntity instanceof VirtualInterface ) ; $ rExists = $ rEntity -> file_exists ( ) ; if ( $ rExists && ! $ vExists ) { $ rDeleted = true ; } if ( ! $ vExists && ! $ rExists ) { continue ; } elseif ( $ rDeleted ) { if ( $ rExists ) { $ this -> fs -> remove ( $ rPath ) ; } if ( $ vExists ) { $ this -> copyChanges ( $ filepath ) ; } } else { if ( $ vEntity -> is_file ( ) ) { unlink ( $ rPath ) ; copy ( $ vEntity -> path ( ) , $ rPath ) ; } } } $ subtrees = $ changes -> sublists ( ) ; foreach ( $ subtrees as $ filename => $ tree ) { if ( ! isset ( $ own [ $ filename ] ) ) { $ this -> commitInternal ( $ tree , $ path . $ filename ) ; } } }
Commit changes into real FS .
41,915
private function getFsRoot ( ) : ? string { if ( null === $ this -> fsRoot ) { $ tempDir = rtrim ( sys_get_temp_dir ( ) , '\\/' ) ; do { $ name = $ tempDir . '/' . uniqid ( 'vfs' , true ) ; } while ( file_exists ( $ name ) ) ; $ this -> fs -> mkdir ( $ name ) ; $ this -> fsRoot = $ name ; } return $ this -> fsRoot ; }
Create own temp directory and return path .
41,916
public function paginate ( \ Twig_Environment $ twig , PaginatorInterface $ paginator , string $ template = '@Core/pagination/default.html.twig' ) { return $ twig -> render ( $ template , array ( 'available_pages' => $ paginator -> getAvailablePages ( ) , 'current_page' => $ paginator -> getCurrentPage ( ) , 'next_url' => $ this -> getNextUrl ( $ paginator ) , 'previous_url' => $ this -> getPreviousUrl ( $ paginator ) , 'route' => $ this -> getRoute ( ) , 'params' => $ this -> getMergedParams ( ) , ) ) ; }
Render the given paginator
41,917
private function getNextUrl ( PaginatorInterface $ paginator ) : ? string { $ page = $ paginator -> getCurrentPage ( ) ; if ( ++ $ page <= $ paginator -> getAvailablePages ( ) ) { return $ this -> generateUrl ( $ this -> getRoute ( ) , $ this -> getMergedParams ( [ 'page' => $ page ] ) ) ; } return null ; }
Get next URL
41,918
private function getPreviousUrl ( PaginatorInterface $ paginator ) : ? string { $ page = $ paginator -> getCurrentPage ( ) ; if ( -- $ page >= 1 ) { return $ this -> generateUrl ( $ this -> getRoute ( ) , $ this -> getMergedParams ( [ 'page' => $ page ] ) ) ; } return null ; }
Get previous URL
41,919
protected function callFilter ( $ filter , $ request , $ response = null ) { return $ this -> events -> until ( 'router.' . $ filter , array ( $ request , $ response ) ) ; }
Call the given filter with the request and response .
41,920
protected function filterSupportsMethod ( $ filter , $ method ) { $ methods = $ filter [ 'methods' ] ; return is_null ( $ methods ) || in_array ( $ method , $ methods ) ; }
Determine if the given pattern filters applies to a given method .
41,921
public function callRouteFilter ( $ filter , $ parameters , $ route , $ request , $ response = null ) { $ data = array_merge ( array ( $ route , $ request , $ response ) , $ parameters ) ; return $ this -> events -> until ( 'router.filter: ' . $ filter , $ this -> cleanFilterParameters ( $ data ) ) ; }
Call the given route filter .
41,922
protected function cropAlternative ( FormInterface $ form ) { $ needFlush = false ; foreach ( $ this -> thumbnailConfig as $ format => $ parameters ) { $ x = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'x' ) -> getData ( ) ; $ y = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'y' ) -> getData ( ) ; $ h = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'h' ) -> getData ( ) ; $ w = $ form -> get ( 'coordinates' ) -> get ( $ format ) -> get ( 'w' ) -> getData ( ) ; if ( null !== $ x && null !== $ y && null !== $ h && null !== $ w ) { $ media = $ form -> getData ( ) ; $ this -> imageAlternativeStrategy -> cropAlternative ( $ media , $ x , $ y , $ h , $ w , $ format ) ; $ this -> objectManager -> persist ( $ media ) ; $ needFlush = true ; } } if ( $ needFlush ) { $ this -> objectManager -> flush ( ) ; } }
Crop a new Alternative if required
41,923
protected function overrideAlternative ( FormInterface $ form ) { $ needFlush = false ; foreach ( $ this -> thumbnailConfig as $ format => $ parameters ) { $ file = $ form -> get ( 'files' ) -> get ( $ format ) -> get ( 'file' ) -> getData ( ) ; if ( null !== $ file ) { $ media = $ form -> getData ( ) ; $ tmpFileName = time ( ) . '-' . $ file -> getClientOriginalName ( ) ; $ file -> move ( $ this -> tmpDir , $ tmpFileName ) ; $ tmpFilePath = $ this -> tmpDir . DIRECTORY_SEPARATOR . $ tmpFileName ; $ this -> imageAlternativeStrategy -> overrideAlternative ( $ media , $ tmpFilePath , $ format ) ; $ this -> objectManager -> persist ( $ media ) ; $ needFlush = true ; } } if ( $ needFlush ) { $ this -> objectManager -> flush ( ) ; } }
Override an alternative if required
41,924
public function gpi ( $ data ) { if ( ! preg_match ( '/^[a-zA-Z0-9\_]+$/s' , $ data [ 'api' ] ) ) { return false ; } if ( is_file ( __DIR__ . '/gpis/' . urlencode ( $ data [ 'api' ] ) . '.php' ) ) { $ Api = include ( __DIR__ . '/gpis/' . urlencode ( $ data [ 'api' ] ) . '.php' ) ; $ result = $ Api ( $ this -> px2me , $ data ) ; return $ result ; } return false ; }
General Purpose Interface
41,925
public function get_visual_hook ( ) { printf ( '<div class="filter-container"><p class="filter-name">%s</p>%s</div>' , current_filter ( ) , empty ( $ this -> options [ 'show_hooked_callable' ] ) ? '' : $ this -> hooked -> get_hooked_list ( current_filter ( ) , false ) ) ; }
Get the HTML snippet
41,926
private function getConfigFileContent ( string $ configPath ) : array { if ( ! filesize ( $ configPath ) ) { return [ ] ; } $ config = file_get_contents ( $ configPath ) ; if ( strpos ( $ config , "\n" ) === false ) { $ config = [ $ config ] ; } else { $ config = ( array ) explode ( "\n" , $ config ) ; } return $ config ; }
reads the specific config file
41,927
public function mapToAbstractEntity ( $ entity ) { $ entityStack = new \ SplStack ( ) ; $ this -> mapXMLElementToEntity ( $ this -> xml , $ entity , $ entityStack ) ; }
Map XML to AbstractEntity
41,928
protected function mapToPropertyAttribut ( $ property , $ value , $ xmlEntry , $ entity , $ stackEntity ) { $ this -> mapToProperty ( $ property , $ value , $ xmlEntry , $ entity , $ stackEntity ) ; }
map attribut the value to the property
41,929
protected function mapToPropertyTagname ( $ property , $ value , $ xmlEntry , $ entity , $ stackEntity ) { if ( $ this -> mapToProperty ( $ property , $ value , $ xmlEntry , $ entity , $ stackEntity ) === false ) { $ this -> mapXMLElementToEntity ( $ xmlEntry , $ entity , $ stackEntity ) ; } }
map tag the value to the property
41,930
protected function mapToProperty ( $ property , $ value , $ xmlEntry , $ entity , $ stackEntity ) { $ classSchema = $ this -> reflectionService -> getClassSchema ( get_class ( $ entity ) ) ; if ( $ classSchema -> hasProperty ( $ property ) ) { $ propertyDefinition = $ classSchema -> getProperty ( $ property ) ; switch ( true ) { case is_a ( $ propertyDefinition [ 'type' ] , \ TYPO3 \ CMS \ Extbase \ Persistence \ ObjectStorage :: class , true ) : foreach ( $ xmlEntry -> children ( ) as $ xmlChildEntry ) { $ name = $ xmlChildEntry -> getName ( ) ; $ childEntity = new $ propertyDefinition [ 'elementType' ] ( ) ; $ entityForTagName = $ this -> getEntityForTagName ( $ childEntity , $ xmlEntry , $ name , $ stackEntity ) ; if ( is_a ( $ entityForTagName , $ propertyDefinition [ 'elementType' ] , true ) ) { $ entity -> _getProperty ( $ property ) -> attach ( $ childEntity ) ; } $ this -> mapXMLElementToEntity ( $ xmlChildEntry , $ entityForTagName , $ stackEntity ) ; } break ; case is_a ( $ propertyDefinition [ 'type' ] , \ TYPO3 \ CMS \ Extbase \ DomainObject \ AbstractEntity :: class , true ) : $ subEntity = $ entity -> _getProperty ( $ property ) ; if ( ! $ subEntity ) { $ subEntity = new $ propertyDefinition [ 'type' ] ( ) ; $ entity -> _setProperty ( $ property , $ subEntity ) ; } $ this -> mapXMLElementToEntity ( $ xmlEntry , $ subEntity , $ stackEntity ) ; break ; case is_a ( $ propertyDefinition [ 'type' ] , \ DateTime :: class , true ) : if ( ! empty ( $ value ) ) { $ dateTime = new \ DateTime ( $ value ) ; $ entity -> _setProperty ( $ property , $ dateTime ) ; } break ; default : $ entity -> _setProperty ( $ property , $ value ) ; } return true ; } else { return false ; } }
map the value to the property
41,931
protected function mapXMLElementToEntity ( $ xmlEntry , $ entity , $ stackEntity ) { $ stackEntity -> push ( $ entity ) ; foreach ( $ xmlEntry -> attributes ( ) as $ name => $ attribut ) { $ value = $ this -> mapAttributValue ( $ xmlEntry , $ name , $ attribut -> __toString ( ) , $ stackEntity ) ; $ entityForAttribut = $ this -> getEntityForAttribut ( $ entity , $ xmlEntry , $ name , $ stackEntity ) ; $ property = $ this -> mapAttributToProperty ( $ xmlEntry , $ name , $ stackEntity ) ; $ this -> mapToPropertyAttribut ( $ property , $ value , $ xmlEntry , $ entityForAttribut , $ stackEntity ) ; } foreach ( $ xmlEntry -> children ( ) as $ xmlChildEntry ) { $ name = $ xmlChildEntry -> getName ( ) ; $ value = $ this -> mapTagValue ( $ xmlEntry , $ name , $ xmlChildEntry -> __toString ( ) , $ stackEntity ) ; $ entityForTagName = $ this -> getEntityForTagName ( $ entity , $ xmlEntry , $ name , $ stackEntity ) ; $ property = $ this -> mapTagNameToProperty ( $ xmlEntry , $ name , $ stackEntity ) ; $ this -> mapToPropertyTagname ( $ property , $ value , $ xmlChildEntry , $ entityForTagName , $ stackEntity ) ; } $ stackEntity -> pop ( ) ; }
map XML Element to Entity
41,932
public function getDiskData ( $ wmiConnection ) { $ LogicalDisk = $ wmiConnection -> query ( "SELECT Size, FreeSpace, DeviceID FROM Win32_LogicalDisk" ) ; $ return = Array ( ) ; $ index = 0 ; foreach ( $ LogicalDisk as $ wmi_LogicalDisk ) { if ( isset ( $ wmi_LogicalDisk -> Size ) and $ wmi_LogicalDisk -> Size > 0 ) { $ return [ 'index' ] [ $ index ] = $ index ; $ return [ 'total_size' ] [ $ index ] = $ wmi_LogicalDisk -> Size ; $ return [ 'free_size' ] [ $ index ] = $ wmi_LogicalDisk -> FreeSpace ; $ return [ 'used_size' ] [ $ index ] = $ return [ 'total_size' ] [ $ index ] - $ return [ 'free_size' ] [ $ index ] ; $ return [ 'used_percent' ] [ $ index ] = round ( ( ( $ return [ 'free_size' ] [ $ index ] / $ return [ 'total_size' ] [ $ index ] ) * 100 ) , 2 ) ; $ return [ 'free_percent' ] [ $ index ] = round ( ( ( $ return [ 'used_size' ] [ $ index ] / $ return [ 'total_size' ] [ $ index ] ) * 100 ) , 2 ) ; $ return [ 'path' ] [ $ index ] = $ wmi_LogicalDisk -> DeviceID ; $ index ++ ; } } return $ return ; }
Return Disk Data
41,933
protected function hasIn ( $ key , $ in ) { $ keys = explode ( $ this -> getSeparator ( ) , $ key , 2 ) ; if ( count ( $ keys ) <= 0 ) { return false ; } else { if ( ! isset ( $ in [ $ keys [ 0 ] ] ) ) { return false ; } else { if ( count ( $ keys ) >= 2 ) { return true && $ this -> hasIn ( $ keys [ 1 ] , $ in [ $ keys [ 0 ] ] ) ; } else { return true ; } } } }
Does the collection have a given key?
41,934
public function scopeActive ( $ query ) { return $ this -> scopeActiveOn ( $ query , AcademicPeriod :: current ( ) -> get ( ) -> first ( ) -> id ) ; }
Only teachers active for current period .
41,935
public function getParam ( $ name , $ default = null ) { if ( isset ( $ this -> params [ $ name ] ) ) { return $ this -> params [ $ name ] ; } return $ default ; }
Gets parameter .
41,936
public function setResult ( $ name = null , $ result = null ) { if ( null === $ result ) { $ result = $ name ; array_push ( $ this -> results , $ result ) ; return $ this ; } $ this -> results [ ( string ) $ name ] = $ result ; return $ this ; }
Sets event result .
41,937
public function getResult ( $ name = null , $ default = null ) { if ( null === $ name ) { return end ( $ this -> results ) ; } if ( ! isset ( $ this -> results [ $ name ] ) ) { return $ default ; } return $ this -> results [ $ name ] ; }
Gets event result .
41,938
public function read ( $ bytesRequested ) { $ len = strlen ( $ this -> _sourceString ) ; if ( $ this -> _bytesRead == $ len ) { return FALSE ; } else if ( $ bytesRequested > $ len - $ this -> _bytesRead ) { $ bytesRequested = $ len - $ this -> _bytesRead ; } $ buffer = substr ( $ this -> _sourceString , $ this -> _bytesRead , $ bytesRequested ) ; $ this -> _bytesRead += $ bytesRequested ; return $ buffer ; }
Read the next chunk of the string .
41,939
public function build ( $ string = '' , $ groupSeparator = ',' , $ viewSeparator = ':' ) { $ this -> options = array ( ) ; foreach ( explode ( $ groupSeparator , $ string ) as $ group ) { $ group = explode ( $ viewSeparator , $ group ) ; $ value = $ group [ 0 ] ; $ view = isset ( $ group [ 1 ] ) ? $ group [ 1 ] : $ group [ 0 ] ; $ this -> options [ $ value ] = $ view ; } $ optionsHTML = '' ; foreach ( $ this -> options as $ k => $ v ) { $ optionsHTML .= '<option value="' . $ k . '"' . ( $ v == $ this -> value ( ) ? ' selected' : '' ) . '>' . $ v . '</option>' ; } $ this -> optionsHTML = $ optionsHTML ; }
Parse string into select options
41,940
static function combine ( $ inputs , array $ fields = null , $ flags = 2 ) { $ mul = new MultipleIterator ( $ flags ) ; foreach ( iterator ( $ inputs ) as $ k => $ it ) $ mul -> attachIterator ( iterator ( $ it ) , isset ( $ fields ) ? $ fields [ $ k ] : $ k ) ; return new static ( $ mul ) ; }
Creates a Flow from a list of iterable inputs that iterates over all of them in parallel .
41,941
static function sequence ( $ list ) { $ a = new AppendIterator ; foreach ( iterator ( $ list ) as $ it ) $ a -> append ( iterator ( $ it ) ) ; return new static ( $ a ) ; }
Concatenates the specified iterables and iterates them in sequence .
41,942
function all ( ) { if ( ! isset ( $ this -> data ) ) $ this -> data = iterator_to_array ( $ this -> it ) ; return $ this -> data ; }
Materializes the current iterator chain into an array .
41,943
function append ( $ list ) { $ cur = $ this -> getIterator ( ) ; if ( $ cur instanceof AppendIterator ) { foreach ( iterator ( $ list ) as $ it ) $ cur -> append ( iterator ( $ it ) ) ; } else { $ a = new AppendIterator ; $ a -> append ( $ cur ) ; foreach ( iterator ( $ list ) as $ it ) $ a -> append ( iterator ( $ it ) ) ; $ this -> setIterator ( $ a ) ; } return $ this ; }
Appends one or more iterators to the current one and sets a new iterator that iterates over all of them .
41,944
function apply ( $ traversableClass ) { $ args = func_get_args ( ) ; $ args [ 0 ] = $ this -> getIterator ( ) ; $ c = new \ ReflectionClass ( $ traversableClass ) ; $ this -> setIterator ( $ c -> newInstanceArgs ( $ args ) ) ; return $ this ; }
Instantiates an outer iterator and chains it to the current iterator .
41,945
function concat ( ) { $ a = new AppendIterator ; foreach ( $ this -> getIterator ( ) as $ it ) $ a -> append ( iterator ( $ it ) ) ; $ this -> setIterator ( $ a ) ; return $ this ; }
Assumes the current iterator is a sequence of iterables and sets a new iterator that iterates over all of them .
41,946
function each ( callable $ fn ) { foreach ( $ this -> getIterator ( ) as $ k => $ v ) if ( $ fn ( $ v , $ k ) === false ) break ; return $ this ; }
Calls a function for every element in the iterator .
41,947
function expand ( callable $ fn , $ keepOriginals = false ) { $ keepOriginals ? $ this -> intercalate ( $ fn ) : $ this -> map ( $ fn ) ; return $ this -> unfold ( ) ; }
Expands values from the current iteration into their own iterations and provides a new iteration that concatenates all of them .
41,948
function fetch ( ) { $ it = $ this -> getIterator ( ) ; if ( ! $ this -> fetching ) { $ this -> fetching = true ; $ it -> rewind ( ) ; } if ( $ it -> valid ( ) ) { $ v = $ it -> current ( ) ; $ it -> next ( ) ; return $ v ; } return false ; }
Gets the current value from the composite iterator and iterates to the next .
41,949
function fetchKey ( ) { $ it = $ this -> getIterator ( ) ; if ( ! $ this -> fetching ) { $ this -> fetching = true ; $ it -> rewind ( ) ; } if ( $ it -> valid ( ) ) { $ k = $ it -> key ( ) ; $ it -> next ( ) ; return $ k ; } return false ; }
Gets the current key from the composite iterator and iterates to the next .
41,950
function intercalate ( callable $ fn ) { return $ this -> map ( function ( $ v , & $ k ) use ( $ fn ) { $ r = $ fn ( $ v , $ k ) ; if ( is_iterable ( $ r ) ) return new HeadAndTailIterator ( $ v , $ r , $ k , true ) ; return $ r ; } ) -> unfold ( ) ; }
Appends to each item a new one computed by the specified function . This doubles the size of the iteration set .
41,951
function map ( callable $ fn , $ arg = null ) { $ this -> setIterator ( new MapIterator ( $ this -> getIterator ( ) , $ fn , $ arg ) ) ; return $ this ; }
Transforms the iterated data using a callback function .
41,952
function mapAndFilter ( callable $ fn , $ arg = null ) { $ this -> setIterator ( new CallbackFilterIterator ( new MapIterator ( $ this -> getIterator ( ) , $ fn , $ arg ) , function ( $ v ) { return isset ( $ v ) ; } ) ) ; return $ this ; }
Transforms each input data item optionally filtering it out .
41,953
function pack ( ) { $ this -> data = isset ( $ this -> data ) ? array_values ( $ this -> data ) : iterator_to_array ( $ this -> it , false ) ; return $ this ; }
Materializes and reindexes the current data into a series of sequential integer keys .
41,954
function prepend ( $ list ) { $ a = new AppendIterator ; foreach ( iterator ( $ list ) as $ it ) $ a -> append ( iterator ( $ it ) ) ; $ a -> append ( $ this -> getIterator ( ) ) ; $ this -> setIterator ( $ a ) ; return $ this ; }
Prepends one or more iterators to the current one and sets a new iterator that iterates over all of them .
41,955
function prependValue ( $ value , $ key = 0 ) { $ this -> setIterator ( new HeadAndTailIterator ( $ value , $ this -> getIterator ( ) , $ key , true ) ) ; return $ this ; }
Prepends a single value to the current iteration and sets a new iterator that iterates over that value and all values of the previously set iterator .
41,956
function recursive ( callable $ fn , $ mode = RecursiveIteratorIterator :: SELF_FIRST ) { $ this -> setIterator ( new RecursiveIteratorIterator ( new RecursiveIterator ( $ this -> getIterator ( ) , $ fn ) , $ mode ) ) ; return $ this ; }
Wraps a recursive iterator over the current iterator .
41,957
function recursiveUnfold ( callable $ fn , $ keepOriginals = false ) { $ w = function ( $ v , $ k , $ d ) use ( $ fn , & $ w , $ keepOriginals ) { $ r = $ fn ( $ v , $ k , $ d ) ; if ( is_iterableEx ( $ r ) ) { $ it = new UnfoldIterator ( new MapIterator ( $ r , $ w , $ d + 1 ) , UnfoldIterator :: USE_ORIGINAL_KEYS ) ; return $ keepOriginals ? new HeadAndTailIterator ( $ v , $ it , $ k , true , true ) : $ it ; } return $ r ; } ; $ this -> map ( $ w , 0 ) -> unfold ( ) ; return $ this ; }
Maps some or all iteration values to sub - iterations recursively and unfolds them into a single iteration .
41,958
function regex ( $ regexp , $ preg_flags = 0 , $ useKeys = false ) { $ this -> setIterator ( new RegexIterator ( $ this -> getIterator ( ) , $ regexp , RegexIterator :: ALL_MATCHES , $ useKeys ? RegexIterator :: USE_KEY : 0 , $ preg_flags ) ) ; return $ this ; }
Transforms data into arrays of regular expression matches for each item .
41,959
function regexExtract ( $ regexp , $ preg_flags = 0 , $ useKeys = false ) { $ this -> setIterator ( new RegexIterator ( $ this -> getIterator ( ) , $ regexp , RegexIterator :: GET_MATCH , $ useKeys ? RegexIterator :: USE_KEY : 0 , $ preg_flags ) ) ; return $ this ; }
Transforms data by extracting the first regular expression match for each item .
41,960
function regexMap ( $ regexp , $ replaceWith , $ useKeys = false ) { $ this -> setIterator ( new RegexIterator ( $ this -> getIterator ( ) , $ regexp , RegexIterator :: REPLACE , $ useKeys ? RegexIterator :: USE_KEY : 0 ) ) ; $ this -> it -> replacement = $ replaceWith ; return $ this ; }
Transforms each string data item into another using a regular expression .
41,961
function regexSplit ( $ regexp , $ preg_flags = 0 , $ useKeys = false ) { $ this -> setIterator ( new RegexIterator ( $ this -> getIterator ( ) , $ regexp , RegexIterator :: SPLIT , $ useKeys ? RegexIterator :: USE_KEY : 0 , $ preg_flags ) ) ; return $ this ; }
Splits each data item into arrays of strings using a regular expression .
41,962
function reindex ( $ i = 0 , $ st = 1 ) { $ this -> setIterator ( new ReindexIterator ( $ this -> getIterator ( ) , $ i , $ st ) ) ; return $ this ; }
Reindexes the current data into a series of sequential integer values starting from the specified value .
41,963
function repeatWhile ( callable $ fn ) { $ this -> setIterator ( $ it = new LoopIterator ( $ this -> getIterator ( ) ) ) ; $ it -> test ( $ fn ) ; return $ this ; }
Repeats the iteration until the callback returns false .
41,964
function reverse ( $ preserveKeys = false ) { $ this -> pack ( ) ; $ this -> it = $ this -> array_reverse_iterator ( $ this -> data , $ preserveKeys ) ; unset ( $ this -> data ) ; return $ this ; }
Reverses the order of iteration .
41,965
function slice ( $ offset = 0 , $ count = - 1 ) { $ this -> setIterator ( new LimitIterator ( $ this -> getIterator ( ) , $ offset , $ count ) ) ; return $ this ; }
Limits iteration to the specified range .
41,966
function sort ( $ type = 'sort' , $ flags = SORT_REGULAR , callable $ fn = null ) { if ( ! isset ( self :: $ SORT_TYPES [ $ type ] ) ) throw new InvalidArgumentException ( "Bad sort type: $type" ) ; $ n = self :: $ SORT_TYPES [ $ type ] ; $ this -> all ( ) ; switch ( $ n ) { case 1 : $ type ( $ this -> data ) ; break ; case 2 : $ type ( $ this -> data , $ flags ) ; break ; case 3 : $ type ( $ this -> data , $ fn ) ; break ; } return $ this ; }
Sorts the data by its keys .
41,967
function swap ( callable $ fn ) { $ this -> pack ( ) ; $ this -> data = $ fn ( $ this -> data ) ; return $ this ; }
Replaces the current data set by another .
41,968
function whereMatch ( $ regexp , $ preg_flags = 0 , $ useKeys = false ) { $ this -> setIterator ( new RegexIterator ( $ this -> getIterator ( ) , $ regexp , RegexIterator :: MATCH , $ useKeys ? RegexIterator :: USE_KEY : 0 , $ preg_flags ) ) ; return $ this ; }
Filters data using a regular expression test .
41,969
private function array_reverse_iterator ( array $ a , $ preserveKeys = false ) { if ( $ preserveKeys ) for ( end ( $ a ) ; ( $ key = key ( $ a ) ) !== null ; prev ( $ a ) ) yield $ key => current ( $ a ) ; else for ( end ( $ a ) ; ( $ key = key ( $ a ) ) !== null ; prev ( $ a ) ) yield current ( $ a ) ; }
Returns an iterator that iterates an array on reverse .
41,970
public function load ( $ file ) { $ this -> file = $ file ; $ msg = array ( ) ; @ include ( $ file ) ; $ this -> msg = $ msg ; }
Loads the php file
41,971
public function scanPortRange ( ) { if ( strtolower ( $ this -> typePort ) == 'tcp' ) { $ hostIp = $ this -> hostIP ; } else if ( strtolower ( $ this -> typePort ) == 'udp' ) { $ hostIp = "udp://$this->hostIP" ; } else { throw new \ Exception ( 'Port Type undefined!' ) ; } $ errno = $ errstr = null ; for ( $ portNumber = $ this -> startPort ; $ portNumber <= $ this -> endPort ; $ portNumber ++ ) { $ handle = @ fsockopen ( $ hostIp , $ portNumber , $ errno , $ errstr , $ this -> timeout ) ; if ( $ handle ) { $ service = $ this -> getService ( $ portNumber , strtolower ( $ this -> typePort ) ) ; $ this -> openPorts [ $ portNumber ] = ( ! empty ( $ service ) ) ? $ service : null ; fclose ( $ handle ) ; } } return $ this -> openPorts ; }
Scan range ports in host
41,972
private function removeOldItems ( ) { $ emailSendReceiveOld = $ this -> getEmailSendReceiveColl ( ) -> findAll ( $ this -> findOldEmailReceiveOldCallback ( ) ) ; foreach ( $ emailSendReceiveOld as $ emailSendCheckI ) { $ this -> getEmailSendReceiveColl ( ) -> remove ( $ this -> findSameItemCallback ( $ emailSendCheckI ) ) ; } }
remove old items .
41,973
public function setInfoAttribute ( $ value ) { return ( $ value ) ? $ this -> attributes [ 'info' ] = json_encode ( $ value ) : $ this -> attributes [ 'info' ] = null ; }
Set the info value
41,974
public function removeExistingTranslation ( $ languageCode ) { return $ this -> translations ( ) -> where ( 'file_id' , $ this -> id ) -> where ( 'language_code' , $ languageCode ) -> delete ( ) ; }
Function removes file translations in provided language code
41,975
public function getQueryableProperties ( ) { $ classMetadata = $ this -> getObjectManager ( ) -> getClassMetadata ( $ this -> getEntityClass ( ) ) ; $ fields = $ classMetadata -> getFieldNames ( ) ; $ alias = $ this -> getEntityClassAlias ( ) ; foreach ( $ fields as $ key => & $ field ) { $ fieldType = $ classMetadata -> getTypeOfField ( $ field ) ; if ( ! in_array ( $ fieldType , array ( 'string' , 'text' ) ) ) { unset ( $ fields [ $ key ] ) ; } else { $ field = $ alias . '.' . $ field ; } } return $ fields ; }
Returns a list of fields for the query condition
41,976
public function getOrderByIdentifier ( $ orderBy ) { $ objectManager = $ this -> getObjectManager ( ) ; $ classMetadata = $ objectManager -> getClassMetadata ( $ this -> getEntityClass ( ) ) ; if ( strpos ( $ orderBy , '::' ) === false ) { if ( ! $ classMetadata -> hasField ( $ orderBy ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid order by column: Entity "%s" has no field "%s"' , $ this -> getEntityClass ( ) , $ orderBy ) ) ; } $ orderByIdentifier = $ this -> getEntityClassAlias ( ) . '.' . $ orderBy ; } else { list ( $ association , $ assocProperty ) = explode ( '::' , $ orderBy ) ; if ( ! $ classMetadata -> hasAssociation ( $ association ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid order by column: Entity "%s" has no association "%s"' , $ this -> getEntityClass ( ) , $ association ) ) ; } if ( in_array ( $ assocProperty , array ( 'count' ) ) ) { $ orderByIdentifier = $ this -> getEntityClassAlias ( ) . '.id' ; } else { $ assocTargetClass = $ classMetadata -> getAssociationTargetClass ( $ association ) ; if ( ! $ objectManager -> getClassMetadata ( $ assocTargetClass ) -> hasField ( $ assocProperty ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid order by column: Entity "%s" has no field "%s"' , $ assocTargetClass , $ assocProperty ) ) ; } $ joinAlias = self :: JOIN_ALIAS_PREFIX . $ association ; $ orderByIdentifier = $ joinAlias . '.' . $ assocProperty ; } } return $ orderByIdentifier ; }
Returns the column identifier for the order by property
41,977
protected function addJoinTablesToQueryBuilder ( QueryBuilder $ queryBuilder ) { $ objectManager = $ this -> getObjectManager ( ) ; $ entityAlias = $ this -> getEntityClassAlias ( ) ; $ classMetaData = $ objectManager -> getClassMetadata ( $ this -> getEntityClass ( ) ) ; $ assocMappings = $ classMetaData -> getAssociationMappings ( ) ; foreach ( $ assocMappings as $ fieldName => $ assocMapping ) { $ join = $ entityAlias . '.' . $ fieldName ; $ alias = self :: JOIN_ALIAS_PREFIX . $ fieldName ; $ queryBuilder -> addSelect ( $ alias ) ; $ queryBuilder -> leftJoin ( $ join , $ alias ) ; } }
Adds joins for all association mappings to the query builder
41,978
protected function addFilterToQueryBuilder ( array $ filter , QueryBuilder $ queryBuilder ) { $ objectManager = $ this -> getObjectManager ( ) ; $ entityClassAlias = $ this -> getEntityClassAlias ( ) ; $ classMetaData = $ objectManager -> getClassMetadata ( $ this -> getEntityClass ( ) ) ; $ assocMappings = $ classMetaData -> getAssociationMappings ( ) ; $ andExpressions = array ( ) ; $ paramCounter = 0 ; foreach ( $ filter as $ property => $ value ) { if ( empty ( $ value ) ) { continue ; } if ( ! isset ( $ assocMappings [ $ property ] ) ) { throw new \ InvalidArgumentException ( 'Unkown association "' . $ property . '"' ) ; } $ paramCounter ++ ; $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> eq ( $ entityClassAlias . '.' . $ property , '?' . $ paramCounter ) ) ; $ queryBuilder -> setParameter ( $ paramCounter , $ value ) ; } return $ paramCounter ; }
Adds filter conditions to query bilder
41,979
public function hasService ( $ name , $ resolve = TRUE ) { if ( array_key_exists ( $ name , $ this -> services ) ) { return TRUE ; } if ( ! $ resolve ) { return FALSE ; } $ classname = "Loops\\Service\\" . Misc :: camelize ( $ name ) ; if ( class_exists ( $ classname ) ) { $ reflection = new ReflectionClass ( $ classname ) ; if ( $ reflection -> implementsInterface ( "Loops\ServiceInterface" ) ) { if ( ! $ classname :: hasService ( $ this ) ) { return FALSE ; } $ this -> registerService ( $ name , $ classname , [ ] , $ classname :: isShared ( $ this ) ) ; } } return $ this -> hasService ( $ name , FALSE ) ; }
Checks if a service exists
41,980
public function createService ( $ name , ArrayObject $ config = NULL , $ merge_into_config = FALSE ) { if ( $ merge_into_config ) { $ service_config = $ this -> config -> offsetExists ( $ name ) ? $ this -> config -> offsetGet ( $ name ) : new ArrayObject ; if ( is_array ( $ service_config ) ) { $ service_config = ArrayObject :: fromArray ( $ service_config ) ; } if ( $ config ) { $ service_config -> merge ( $ config ) ; } } else { $ service_config = $ config ? : new ArrayObject ; } if ( ! $ this -> hasService ( $ name ) ) { throw new Exception ( "Service '$name' does not exist." ) ; } $ service = $ this -> services [ $ name ] ; if ( array_key_exists ( "classname" , $ service ) ) { $ reflection = new ReflectionClass ( $ service [ "classname" ] ) ; $ params = new ArrayObject ( $ service [ "params" ] ) ; $ params -> merge ( $ service_config ) ; if ( $ reflection -> implementsInterface ( "Loops\ServiceInterface" ) ) { return call_user_func_array ( [ $ service [ "classname" ] , "getService" ] , [ $ params , $ this ] ) ; } else { $ params -> offsetSet ( "loops" , $ this ) ; return Misc :: reflectionInstance ( $ service [ "classname" ] , $ params ) ; } } if ( array_key_exists ( "callback" , $ service ) ) { $ params = new ArrayObject ( $ service [ "params" ] ) ; $ params -> merge ( $ service_config ) ; return call_user_func_array ( $ service [ "callback" ] , $ params -> toArray ( ) ) ; } if ( array_key_exists ( "object" , $ service ) ) { return $ service [ "object" ] ; } }
Creates a new instance of a service
41,981
public function registerService ( $ name , $ service , array $ params = [ ] , $ shared = TRUE ) { if ( is_callable ( $ service ) ) { $ this -> services [ $ name ] = [ "shared" => $ shared , "params" => $ params , "callback" => $ service ] ; } elseif ( is_object ( $ service ) ) { $ this -> services [ $ name ] = [ "shared" => $ shared , "object" => $ service ] ; } elseif ( is_string ( $ service ) ) { $ this -> services [ $ name ] = [ "shared" => $ shared , "params" => $ params , "classname" => $ service ] ; } else { throw new Exception ( "Failed to register service." ) ; } }
Registers a custom Service
41,982
public function getTree ( ) : array { $ tree = [ ] ; $ size = count ( $ this -> segments ) ; for ( $ index = 0 ; $ index < $ size ; $ index = $ index + 1 ) { $ temp = array_slice ( $ this -> segments , 0 , $ index + 1 ) ; $ path = implode ( DIRECTORY_SEPARATOR , $ temp ) ; $ tree [ ] = Path :: normalize ( $ path ) ; } return $ tree ; }
Devuelve el arbol de directorios desde la raiz hasta la ruta actual como un array de strings
41,983
public function getPathTree ( ) : array { $ tree = [ ] ; foreach ( $ this -> getTree ( ) as $ branch ) { $ tree [ ] = Path :: make ( $ branch ) ; } return $ tree ; }
Devuelve el arbol de directorios desde la raiz hasta la ruta actual como un array de objetos Paths
41,984
public function bindValue ( $ parameter , $ value , $ data_type = \ PDO :: PARAM_STR ) { $ this -> _debugBindValues [ $ parameter ] = $ value ; parent :: bindValue ( $ parameter , $ value , $ data_type ) ; }
override binvalue to keep in memory the vars
41,985
public function debugQuery ( $ replaced = true ) { $ q = $ this -> queryString ; if ( ! $ replaced ) { return $ q ; } else { if ( count ( $ this -> _debugBindValues ) > 0 ) { return preg_replace_callback ( '/:([0-9a-z_]+)/i' , [ $ this , '_debugReplaceBindValue' ] , $ q ) ; } else { return $ q ; } } }
return query with vars or not
41,986
protected function _debugReplaceBindValue ( $ m ) { $ v = $ this -> _debugBindValues [ ':' . $ m [ 1 ] ] ; switch ( gettype ( $ v ) ) { case 'boolean' : return $ v ; break ; case 'integer' : return $ v ; break ; case 'double' : return $ v ; break ; case 'string' : return "'" . addslashes ( $ v ) . "'" ; break ; case 'NULL' : return 'NULL' ; break ; default : return 'NULL' ; break ; } }
replace vars in the query
41,987
public static function CreditCard ( $ value , $ options ) { $ number_pattern_list = [ 'American Express' => [ "/^34[0-9]{13}$/" , "/^37[0-9]{13}$/" , ] , 'China UnionPay' => [ "/^62212[6-9][0-9]{10}$/" , "/^6221[3-9][0-9][0-9]{10}$/" , "/^622[2-8] [0-9]{12}$/" , "/^6229[01][0-9][0-9]{10}$/" , "/^62292[0-5][0-9]{10}$/" , "/^62[4-6][0-9]{13}$/" , "/^628[2-8][0-9]{12}$/" , ] , 'Diners Club International' => [ "/^300[0-9]{11}$/" , "/^305[0-9]{11}$/" , "/^3095[0-9]{10}$/" , "/^36[0-9]{11}$/" , "/^3[89][0-9]{12}$/" , ] , 'Discover Card' => [ "/^60110[0-9]{11}$/" , "/^6011[2-4][0-9]{11}$/" , "/^60117[4-9][0-9]{10}$/" , "/^60118[6-9][0-9]{10}$/" , "/^60119[0-9][0-9]{10}$/" , "/^64[4-9][0-9]{13}$/" , "/^65[0-9]{14}$/" , ] , 'JCB' => [ "/^352[89][0-9]{12}$/" , "/^35[3-7][0-9]{12}$/" , "/^358[1-9][0-9]{12}$/" , ] , 'MasterCard' => [ "/^5[0-9]{15}$/" , ] , 'UATP' => [ "/^1[0-9]{14}$/" , ] , 'Visa' => [ "/^4[0-9]{13}(?:[0-9]{3})?$/" , ] , ] ; foreach ( $ number_pattern_list as $ card_name => $ pattern_list ) { foreach ( $ pattern_list as $ pattern ) { if ( 1 === preg_match ( $ pattern , $ value ) ) { for ( $ i = 0 , $ value = strrev ( $ value ) , $ alt = true , $ total = 0 ; ( $ str = substr ( $ value , $ i , 1 ) ) !== false ; $ total += $ alt ? $ str : ( $ str < 5 ? $ str * 2 : 1 + ( $ str - 5 ) * 2 ) , $ alt = ! $ alt , $ i ++ ) ; return $ total % 10 === 0 ; } } } return false ; }
Credit card check
41,988
public static function toText ( string $ value , bool $ double_encode = true ) : string { return htmlspecialchars ( $ value , ENT_QUOTES , 'utf-8' , $ double_encode ) ; }
Convert special characters to HTML entities . All untrusted content should be passed through this method to prevent XSS injections .
41,989
public static function arrow ( string $ direction ) : string { switch ( $ direction ) { case "up" : $ output = '<span class="arrow">&uarr;</span>' ; break ; case "down" : $ output = '<span class="arrow">&darr;</span>' ; break ; case "left" : $ output = '<span class="arrow">&larr;</span>' ; break ; case "right" : $ output = '<span class="arrow">&rarr;</span>' ; break ; } return $ output ; }
Create an arrow
41,990
public static function anchor ( string $ title , string $ url = '' , array $ attributes = null ) : string { if ( $ url !== '' ) $ attributes [ 'href' ] = $ url ; return '<a' . Html :: attributes ( $ attributes ) . '>' . $ title . '</a>' ; }
Create HTML link anchor .
41,991
public static function doctype ( string $ type = 'html5' ) { $ doctypes = [ 'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' , 'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' , 'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' , 'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">' , 'html5' => '<!DOCTYPE html>' , 'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' , 'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' , 'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">' ] ; if ( isset ( $ doctypes [ $ type ] ) ) return $ doctypes [ $ type ] ; else return false ; }
Generate document type declarations
41,992
private function _validateState ( ) { if ( ! $ this -> getAuthority ( ) ) { if ( 0 === strpos ( $ this -> path , '//' ) ) { throw new InvalidArgumentException ( 'The path of a URI without an authority must not start with two slashes "//"' ) ; } if ( ! $ this -> scheme && false !== strpos ( explode ( '/' , $ this -> path , 2 ) [ 0 ] , ':' ) ) { throw new InvalidArgumentException ( 'A relative URI must not have a path beginning with a segment containing a colon' ) ; } } elseif ( isset ( $ this -> path [ 0 ] ) && $ this -> path [ 0 ] !== '/' ) { throw new InvalidArgumentException ( 'The path of a URI with an authority must start with a slash "/" or be empty' ) ; } }
Valid Uri State
41,993
public static function sort ( array $ array , string $ field , string $ direction = 'ASC' , $ method = SORT_REGULAR ) : array { if ( count ( $ array ) > 0 ) { foreach ( $ array as $ key => $ row ) { $ helper [ $ key ] = function_exists ( 'mb_strtolower' ) ? mb_strtolower ( Arr :: get ( $ row , $ field ) ) : strtolower ( Arr :: get ( $ row , $ field ) ) ; } if ( $ method === SORT_NATURAL ) { natsort ( $ helper ) ; ( $ direction === 'DESC' ) and $ helper = array_reverse ( $ helper ) ; } elseif ( $ direction == 'DESC' ) { arsort ( $ helper , $ method ) ; } else { asort ( $ helper , $ method ) ; } foreach ( $ helper as $ key => $ val ) { $ result [ $ key ] = $ array [ $ key ] ; } return $ result ; } }
Sorts a multi - dimensional array by a certain column
41,994
public static function set ( array & $ array , string $ path , $ value ) { $ segments = explode ( '.' , $ path ) ; while ( count ( $ segments ) > 1 ) { $ segment = array_shift ( $ segments ) ; if ( ! isset ( $ array [ $ segment ] ) || ! is_array ( $ array [ $ segment ] ) ) { $ array [ $ segment ] = [ ] ; } $ array = & $ array [ $ segment ] ; } $ array [ array_shift ( $ segments ) ] = $ value ; }
Sets an array value using dot notation .
41,995
public static function keyExists ( array $ array , $ path ) : bool { foreach ( explode ( '.' , $ path ) as $ segment ) { if ( ! is_array ( $ array ) or ! array_key_exists ( $ segment , $ array ) ) { return false ; } $ array = $ array [ $ segment ] ; } return true ; }
Checks if the given dot - notated key exists in the array .
41,996
public static function createFromJson ( string $ json , bool $ assoc = true , int $ depth = 512 , int $ options = 0 ) : array { return json_decode ( $ json , $ assoc , $ depth , $ options ) ; }
Create an new Array from JSON string .
41,997
public static function overwrite ( array $ array1 , array $ array2 ) : array { foreach ( array_intersect_key ( $ array2 , $ array1 ) as $ key => $ value ) { $ array1 [ $ key ] = $ value ; } if ( func_num_args ( ) > 2 ) { foreach ( array_slice ( func_get_args ( ) , 2 ) as $ array2 ) { foreach ( array_intersect_key ( $ array2 , $ array1 ) as $ key => $ value ) { $ array1 [ $ key ] = $ value ; } } } return $ array1 ; }
Overwrites an array with values from input arrays . Keys that do not exist in the first array will not be added!
41,998
public function execute ( ) { $ this -> container -> set ( 'securityContext' , $ this -> securityContext ) ; if ( is_null ( $ this -> node ) || ! array_key_exists ( 'authentication' , $ this -> node ) ) { return ; } if ( array_key_exists ( 'security' , $ this -> node ) && ( ! $ this -> node [ 'security' ] || $ this -> node [ 'security' ] == 'false' ) ) { error_log ( 'security element null or not found in node' ) ; return ; } $ token = $ this -> getToken ( ) ; try { $ this -> authenticationManager -> authenticate ( $ this -> securityContext ) ; } catch ( \ Exception $ e ) { if ( array_key_exists ( 'fail_url' , $ this -> node ) ) { header ( 'Location: ' . $ this -> getSiteURL ( ) . $ this -> node [ 'fail_url' ] ) ; } else { echo json_encode ( array ( 'message' => $ e -> getMessage ( ) , 'code' => $ e -> getCode ( ) ) ) ; } die ( ) ; } }
main method called . calls the provider and gets the provider to authenticate the user
41,999
public function scan ( ) : ModularCollection { if ( $ this -> hasScanned ) { return $ this ; } foreach ( new RecursiveDirectoryIterator ( $ this -> getModularDirectory ( ) ) as $ path ) { $ baseName = $ path -> getBaseName ( ) ; if ( $ baseName == '.' || $ baseName == '..' ) { continue ; } $ directory = $ this -> getModularDirectory ( ) . DIRECTORY_SEPARATOR . $ baseName ; if ( $ path -> isLink ( ) || ! $ path -> isDir ( ) ) { $ this -> unwantedPath [ $ baseName ] = $ path -> getType ( ) ; continue ; } $ file = $ directory . DIRECTORY_SEPARATOR . $ baseName . '.php' ; if ( ! file_exists ( $ file ) ) { $ this -> invalidModular [ $ baseName ] = new ModularNotFoundException ( $ file , sprintf ( '%1$s file for %2$s has not found' , $ this -> modularParser -> getName ( ) , $ baseName ) ) ; continue ; } try { $ modular = $ this -> modularParser -> create ( $ file ) -> process ( ) ; if ( ! $ modular -> isValid ( ) ) { throw new InvalidModularException ( sprintf ( '%1$s Is not valid.' , $ this -> modularParser -> getName ( ) ) ) ; } $ this -> validModular [ $ this -> sanitizeModularName ( $ baseName ) ] = [ static :: CLASS_NAME_KEY => $ modular -> getClassName ( ) , static :: FILE_PATH_KEY => $ modular -> getFile ( ) , ] ; } catch ( \ Exception $ e ) { $ this -> invalidModular [ $ this -> sanitizeModularName ( $ baseName ) ] = $ e ; } } return $ this ; }
Scan ModularAbstract Directory