idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
52,900 | protected function getMenuOptions ( array $ settings ) { $ mapping = [ 'current_class' => 'currentClass' , 'first_class' => 'firstClass' , 'last_class' => 'lastClass' , 'safe_labels' => 'allow_safe_labels' , 'menu_template' => 'template' , ] ; $ options = [ ] ; foreach ( $ settings as $ key => $ value ) { if ( \ array_... | Replaces setting keys with knp menu item options keys . |
52,901 | public function configureProfiler ( ContainerBuilder $ container , array $ config ) { $ container -> setAlias ( 'sonata.block.renderer' , 'sonata.block.renderer.default' ) ; if ( ! $ config [ 'profiler' ] [ 'enabled' ] ) { return ; } $ definition = new Definition ( 'Sonata\BlockBundle\Profiler\DataCollector\BlockDataCo... | Configures the block profiler . |
52,902 | public function configureException ( ContainerBuilder $ container , array $ config ) { $ filters = [ ] ; foreach ( $ config [ 'exception' ] [ 'filters' ] as $ name => $ filter ) { $ filters [ $ name ] = $ filter ; } $ renderers = [ ] ; foreach ( $ config [ 'exception' ] [ 'renderers' ] as $ name => $ renderer ) { $ ren... | Configure the exception parameters . |
52,903 | private function sortServices ( $ services ) { uasort ( $ services , static function ( $ a , $ b ) { if ( $ a -> getName ( ) === $ b -> getName ( ) ) { return 0 ; } return ( $ a -> getName ( ) < $ b -> getName ( ) ) ? - 1 : 1 ; } ) ; return $ services ; } | Sort alphabetically services . |
52,904 | protected function addMetaInformation ( Response $ response , BlockContextInterface $ blockContext , BlockServiceInterface $ service ) { if ( $ this -> lastResponse && $ this -> lastResponse -> isCacheable ( ) ) { $ response -> setTtl ( $ this -> lastResponse -> getTtl ( ) ) ; $ response -> setPublic ( ) ; } elseif ( $... | This method is responsible to cascade ttl to the parent block . |
52,905 | public function applyContext ( ContainerBuilder $ container ) { $ definition = $ container -> findDefinition ( 'sonata.block.context_manager' ) ; foreach ( $ container -> getParameter ( 'sonata_block.blocks' ) as $ service => $ settings ) { if ( \ count ( $ settings [ 'settings' ] ) > 0 ) { $ definition -> addMethodCal... | Apply configurations to the context manager . |
52,906 | private function replaceBlockName ( ContainerBuilder $ container , Definition $ definition , $ id ) { $ arguments = $ definition -> getArguments ( ) ; if ( $ this -> serviceDefinitionNeedsFirstArgument ( $ definition ) ) { if ( method_exists ( $ definition , 'setArgument' ) ) { $ definition -> setArgument ( 0 , $ id ) ... | Replaces the empty service name with the service id . |
52,907 | public function exists ( $ type ) { foreach ( $ this -> loaders as $ loader ) { if ( $ loader -> exists ( $ type ) ) { return true ; } } return false ; } | Check if a given block type exists . |
52,908 | protected function computeAssets ( BlockContextInterface $ blockContext , array & $ stats = null ) { if ( $ blockContext -> getBlock ( ) -> hasParent ( ) ) { return ; } $ service = $ this -> blockServiceManager -> get ( $ blockContext -> getBlock ( ) ) ; $ assets = [ 'js' => $ service -> getJavascripts ( 'all' ) , 'css... | Traverse the parent block and its children to retrieve the correct list css and javascript only for main block . |
52,909 | public function & toArray ( ) { if ( ! isset ( $ this -> __propertyToData [ Schema :: DEFAULT_MAPPING ] ) ) { return $ this -> __arrayOfData ; } if ( null === $ this -> __mappedProperties ) { $ properties = array ( ) ; foreach ( $ this -> __arrayOfData as $ propertyName => $ property ) { if ( isset ( $ this -> __proper... | Returns a map of properties by default data name |
52,910 | public function jsonSerialize ( ) { $ result = new \ stdClass ( ) ; $ schema = static :: schema ( ) ; foreach ( $ schema -> getProperties ( ) -> getDataKeyMap ( ) as $ propertyName => $ dataName ) { $ value = $ this -> $ propertyName ; if ( ( null !== $ value ) || array_key_exists ( $ propertyName , $ this -> __arrayOf... | todo skip validation during import |
52,911 | private static function unboolSchema ( $ schema ) { static $ trueSchema ; static $ falseSchema ; if ( null === $ trueSchema ) { $ trueSchema = new Schema ( ) ; $ trueSchema -> __booleanSchema = true ; $ falseSchema = new Schema ( ) ; $ falseSchema -> not = $ trueSchema ; $ falseSchema -> __booleanSchema = false ; } if ... | Resolves boolean schema into Schema instance |
52,912 | public static function createJalali ( $ year = null , $ month = null , $ day = null , $ hour = null , $ minute = null , $ second = null , $ timezone = null ) { $ now = static :: instance ( null , $ timezone ) -> format ( 'Y-n-j-G-i-s' ) ; $ defaults = array_combine ( array ( 'year' , 'month' , 'day' , 'hour' , 'minute'... | Create a new Verta instance from a specific date and time . |
52,913 | public static function createJalaliDate ( $ year = null , $ month = null , $ day = null , $ timezone = null ) { return static :: createJalali ( $ year , $ month , $ day , null , null , null , $ timezone ) ; } | Create a Verta from just a date . |
52,914 | public static function createJalaliTime ( $ hour = null , $ minute = null , $ second = null , $ timezone = null ) { return static :: createJalali ( null , null , null , $ hour , $ minute , $ second , $ timezone ) ; } | Create a Verta instance from just a time . |
52,915 | protected function daysYear ( $ month , $ day ) { $ days = 0 ; for ( $ i = 1 ; $ i < $ month ; $ i ++ ) { $ days += static :: $ daysMonthJalali [ $ i ] ; } return ( $ days + $ day ) ; } | return day number from first day of year |
52,916 | public function formatDifference ( Verta $ v = null ) { $ difference = $ this -> diffSeconds ( $ v ) ; $ absolute = $ difference < 0 ? self :: POST : self :: PRE ; $ difference = abs ( $ difference ) ; for ( $ j = 0 ; $ difference >= static :: $ unitNumber [ $ j ] and $ j < count ( static :: $ unitNumber ) - 1 ; $ j ++... | get difference in all |
52,917 | public static function isLeapYear ( $ year ) { $ mod = ( $ year % 33 ) ; if ( ( $ mod == 1 ) or ( $ mod == 5 ) or ( $ mod == 9 ) or ( $ mod == 13 ) or ( $ mod == 17 ) or ( $ mod == 22 ) or ( $ mod == 26 ) or ( $ mod == 30 ) ) { return true ; } return false ; } | check jalali the instance is a leap year |
52,918 | public static function isValideTime ( $ hour , $ minute , $ second ) { return $ hour >= 0 && $ hour <= 24 && $ minute >= 0 && $ minute <= 59 && $ second >= 0 && $ second <= 59 ; } | validate a time |
52,919 | public static function getJalali ( $ g_y , $ g_m , $ g_d ) { $ gy = $ g_y - 1600 ; $ gm = $ g_m - 1 ; $ g_day_no = ( 365 * $ gy + static :: div ( $ gy + 3 , 4 ) - static :: div ( $ gy + 99 , 100 ) + static :: div ( $ gy + 399 , 400 ) ) ; for ( $ i = 0 ; $ i < $ gm ; ++ $ i ) { $ g_day_no += static :: $ daysMonthGregori... | gregorian to jalali convertion |
52,920 | public static function getGregorian ( $ j_y , $ j_m , $ j_d ) { $ jy = $ j_y - 979 ; $ jm = $ j_m - 1 ; $ j_day_no = ( 365 * $ jy + static :: div ( $ jy , 33 ) * 8 + static :: div ( $ jy % 33 + 3 , 4 ) ) ; for ( $ i = 0 ; $ i < $ jm ; ++ $ i ) { $ j_day_no += static :: $ daysMonthJalali [ $ i ] ; } $ j_day_no += $ j_d ... | jalali to gregorian convertion |
52,921 | public function generateMapping ( ) { $ mapping = array ( ) ; $ lines = explode ( "\n" , $ this -> mime_types_text ) ; foreach ( $ lines as $ line ) { $ line = trim ( preg_replace ( '~\\#.*~' , '' , $ line ) ) ; $ parts = $ line ? array_values ( array_filter ( explode ( "\t" , $ line ) ) ) : array ( ) ; if ( count ( $ ... | Read the given mime . types text and return a mapping compatible with the MimeTypes class . |
52,922 | protected static function getBuiltIn ( ) { if ( self :: $ built_in === null ) { self :: $ built_in = require ( dirname ( __DIR__ ) . '/mime.types.php' ) ; } return self :: $ built_in ; } | Get the built - in mapping . |
52,923 | public function save ( $ file , $ flags = null , $ context = null ) { return file_put_contents ( $ file , $ this -> compile ( ) , $ flags , $ context ) ; } | Save the current mapping to a file . |
52,924 | protected function note ( ... $ message ) : void { if ( $ this -> notice instanceof Notice ) { $ this -> notice -> add ( $ message ) ; } } | Raise a note event . |
52,925 | protected function resolveMigratorWithNotes ( string $ table ) : Migrator { $ migrator = $ this -> resolveMigrator ( $ table ) ; if ( $ this -> notice instanceof Notice ) { $ this -> notice -> mergeWith ( $ migrator ) ; } return $ migrator ; } | Resolve migrator with notable . |
52,926 | public function handle ( ) { if ( $ this -> shouldBeFailed ( ) ) { return ; } $ database = $ this -> config [ 'database' ] ?? null ; $ migrator = $ this -> resolveMigrator ( ) ; if ( ! $ this -> shouldBeDelayed ( ) ) { $ migrator -> runInstall ( $ this -> model , $ database ) ; $ migrator -> runUp ( $ this -> model , $... | Fire queue on creating a model . |
52,927 | protected function registerQueuedCommand ( ) : void { $ this -> app -> singleton ( 'orchestra.commands.tenanti.queue' , function ( Application $ app ) { return new QueuedCommand ( $ app -> make ( 'orchestra.tenanti' ) ) ; } ) ; } | Register the queue migration command . |
52,928 | protected function registerMakeCommand ( ) : void { $ this -> app -> singleton ( 'orchestra.tenanti.creator' , function ( Application $ app ) { return new Creator ( $ app -> make ( 'files' ) ) ; } ) ; $ this -> app -> singleton ( 'orchestra.commands.tenanti.make' , function ( Application $ app ) { return new MigrateMak... | Register the make migration command . |
52,929 | protected function registerRefreshCommand ( ) : void { $ this -> app -> singleton ( 'orchestra.commands.tenanti.refresh' , function ( Application $ app ) { return new RefreshCommand ( $ app -> make ( 'orchestra.tenanti' ) ) ; } ) ; } | Register the refresh migration command . |
52,930 | protected function registerTinkerCommand ( ) : void { $ this -> app -> singleton ( 'orchestra.commands.tenanti.tinker' , function ( Application $ app ) { return new TinkerCommand ( $ app -> make ( 'orchestra.tenanti' ) ) ; } ) ; } | Register the tinker migration command . |
52,931 | public function handle ( ) { if ( $ this -> shouldBeFailed ( ) ) { return ; } $ database = $ this -> config [ 'database' ] ?? null ; $ migrator = $ this -> resolveMigrator ( ) ; if ( ! $ this -> shouldBeDelayed ( ) ) { $ migrator -> runReset ( $ this -> model , $ database ) ; $ this -> delete ( ) ; } } | Fire queue on deleting a model . |
52,932 | public function setTenantor ( ? Tenantor $ tenantor ) { $ this -> tenantor = $ tenantor ; $ this -> connection = $ tenantor -> getTenantConnectionName ( ) ; $ this -> setTable ( $ this -> getTenantTable ( ) ) ; return $ this ; } | Get the tenantor associated with the model . |
52,933 | protected function getDriver ( ) : string { $ driver = $ this -> argument ( 'driver' ) ? : $ this -> getDriverFromConfig ( ) ; if ( ! empty ( $ driver ) ) { return $ driver ; } throw new RuntimeException ( 'Not enough arguments (missing: "driver").' ) ; } | Get driver argument or first driver in the config . |
52,934 | protected function getDriverFromConfig ( ) : ? string { $ drivers = \ array_keys ( $ this -> tenant -> getConfig ( 'drivers' ) ) ; if ( \ count ( $ drivers ) === 1 ) { return $ drivers [ 0 ] ; } return null ; } | Get first driver in the config . |
52,935 | protected function getArgumentsWithDriver ( ... $ arguments ) : array { \ array_unshift ( $ arguments , 'driver' ) ; $ resolvedArguments = [ ] ; $ this -> validateMissingArguments ( $ arguments ) ; if ( empty ( $ this -> argument ( \ end ( $ arguments ) ) ) ) { $ driver = $ this -> getDriverFromConfig ( ) ; if ( empty ... | Get the required arguments when used with optional driver argument . |
52,936 | protected function validateMissingArguments ( array $ arguments ) : bool { $ missingArguments = \ array_filter ( $ arguments , function ( $ argument ) { return empty ( $ this -> argument ( $ argument ) ) ; } ) ; if ( \ count ( $ missingArguments ) > 1 ) { throw new RuntimeException ( \ sprintf ( 'Not enough arguments (... | Validate missing arguments . |
52,937 | public function executeFor ( $ id , Closure $ callback ) : void { $ callback ( $ this -> newQuery ( ) -> findOrFail ( $ id ) ) ; } | Execute query by id . |
52,938 | public function executeForEach ( Closure $ callback ) : void { $ query = $ this -> newQuery ( ) ; foreach ( $ query -> cursor ( ) as $ entity ) { $ callback ( $ entity ) ; } } | Execute query via cursor . |
52,939 | public function getModel ( ) : Model { $ name = $ this -> getModelName ( ) ; $ model = $ this -> app -> make ( $ name ) ; if ( ! $ model instanceof Model ) { throw new InvalidArgumentException ( "Model [{$name}] should be an instance of Eloquent." ) ; } $ database = $ this -> getConfig ( 'database' ) ; if ( ! \ is_null... | Resolve model . |
52,940 | protected function resolveMigrator ( string $ table ) : Migrator { $ app = $ this -> app ; if ( ! isset ( $ this -> migrator [ $ table ] ) ) { $ respositoryClass = $ this -> resolver [ 'repository' ] ; $ migratorClass = $ this -> resolver [ 'migrator' ] ; $ repository = new $ respositoryClass ( $ app [ 'db' ] , $ table... | Resolve migrator . |
52,941 | public function asDefaultConnection ( Model $ entity , ? string $ database ) : ? string { $ connection = $ this -> asConnection ( $ entity , $ database ) ; $ this -> app -> make ( 'config' ) -> set ( 'database.default' , $ connection ) ; return $ connection ; } | Set tenant as default database connection and get the connection name . |
52,942 | public function asConnection ( Model $ entity , ? string $ database ) : ? string { $ repository = $ this -> app -> make ( 'config' ) ; $ tenants = $ this -> getConfig ( 'connection' ) ; if ( ! \ is_null ( $ tenants ) ) { $ database = $ tenants [ 'name' ] ; } if ( \ substr ( $ database , - 5 ) !== '_{id}' && $ this -> g... | Set tenant database connection . |
52,943 | public function resolveConnection ( Model $ entity , string $ database ) { return $ this -> app -> make ( 'db' ) -> connection ( $ this -> asConnection ( $ entity , $ database ) ) ; } | Resolve tenant database connection . |
52,944 | protected function bindWithKey ( Model $ entity , ? string $ name ) : ? string { if ( \ is_null ( $ name ) || ( \ strpos ( $ name , '{' ) === false && \ strpos ( $ name , '}' ) === false ) ) { return $ name ; } $ id = $ entity -> getKey ( ) ; if ( ! isset ( $ this -> data [ $ id ] ) ) { $ data = \ array_merge ( Arr :: ... | Resolve table name . |
52,945 | public function loadMigrationsFrom ( $ paths , Model $ entity ) : void { $ id = $ entity -> getKey ( ) ; if ( ! isset ( $ this -> migrationPaths [ $ id ] ) ) { $ this -> migrationPaths [ $ id ] = $ this -> getDefaultMigrationPaths ( ) ; } $ this -> migrationPaths [ $ id ] = \ array_merge ( $ this -> migrationPaths [ $ ... | Load migrations from a specific path . |
52,946 | public function created ( Model $ entity ) { $ data = [ 'database' => $ this -> getConnectionName ( ) , 'driver' => $ this -> getDriverName ( ) , ] ; $ this -> dispatch ( $ this -> getCreateTenantJob ( $ entity , $ data ) ) ; return true ; } | Run on created observer . |
52,947 | public function restored ( Model $ entity ) { $ data = [ 'database' => $ this -> getConnectionName ( ) , 'driver' => $ this -> getDriverName ( ) , ] ; $ this -> dispatch ( $ this -> getRestoreTenantJob ( $ entity , $ data ) ) ; return true ; } | Run on restored observer . |
52,948 | public function deleted ( Model $ entity ) { $ data = [ 'database' => $ this -> getConnectionName ( ) , 'driver' => $ this -> getDriverName ( ) , ] ; $ this -> dispatch ( $ this -> getDeleteTenantJob ( $ entity , $ data ) ) ; return true ; } | Run on deleted observer . |
52,949 | protected function registerConfigurationForManager ( TenantiManager $ manager ) : void { $ namespace = $ this -> hasPackageRepository ( ) ? 'orchestra/tenanti::' : 'orchestra.tenanti' ; $ this -> app -> booted ( function ( $ app ) use ( $ manager , $ namespace ) { $ manager -> setConfig ( $ app -> make ( 'config' ) -> ... | Register configuration for manager . |
52,950 | public function fillFromExistingOrNew ( array $ attributes = [ ] ) { $ this -> fill ( $ attributes ) ; $ this -> exists = ! empty ( $ attributes [ $ this -> getKeyName ( ) ] ) ; return $ this ; } | Create model instance from existing . |
52,951 | public function newEloquentBuilder ( $ query ) { return \ tap ( new Builder ( $ query ) , function ( $ builder ) { $ builder -> setTenantor ( $ this -> tenantor ?? null ) ; } ) ; } | Create a new Eloquent query builder for the model . |
52,952 | protected function shouldBeFailed ( ) : bool { if ( $ this -> attempts ( ) > 3 && $ this -> job ) { $ this -> fail ( null ) ; return true ; } return false ; } | Should the job be failed . |
52,953 | protected function shouldBeDelayed ( ) : bool { if ( $ this -> job && \ is_null ( $ this -> model ) ) { $ this -> release ( 10 ) ; return true ; } return false ; } | Should the job be delayed . |
52,954 | public function install ( ? string $ database , $ id = null ) : void { if ( ! \ is_null ( $ id ) ) { $ this -> executeFor ( $ id , function ( $ entity ) use ( $ database ) { $ this -> runInstall ( $ entity , $ database ) ; } ) ; return ; } $ this -> executeForEach ( function ( $ entity ) use ( $ database ) { $ this -> ... | Install migrations . |
52,955 | public function run ( ? string $ database , $ id = null , bool $ pretend = false ) : void { if ( ! \ is_null ( $ id ) ) { $ this -> executeFor ( $ id , function ( $ entity ) use ( $ database , $ pretend ) { $ this -> runUp ( $ entity , $ database , $ pretend ) ; } ) ; return ; } $ this -> executeForEach ( function ( $ ... | Run migrations . |
52,956 | public function rollback ( ? string $ database , $ id = null , bool $ pretend = false ) : void { if ( ! \ is_null ( $ id ) ) { $ this -> executeFor ( $ id , function ( $ entity ) use ( $ database , $ pretend ) { $ this -> runDown ( $ entity , $ database , $ pretend ) ; } ) ; return ; } $ this -> executeForEach ( functi... | Rollback migrations . |
52,957 | public function reset ( ? string $ database , $ id = null , bool $ pretend = false ) : void { if ( ! \ is_null ( $ id ) ) { $ this -> executeFor ( $ id , function ( $ entity ) use ( $ database , $ pretend ) { $ this -> runReset ( $ entity , $ database , $ pretend ) ; } ) ; return ; } $ this -> executeForEach ( function... | Reset migrations . |
52,958 | public function getConfig ( ? string $ group = null , $ default = null ) { return Arr :: get ( $ this -> config , $ group , $ default ) ; } | Get configuration values . |
52,959 | public function connection ( ? string $ using , Closure $ callback , array $ options = [ ] ) : void { $ repository = $ this -> app -> make ( 'config' ) ; if ( \ is_null ( $ using ) ) { $ using = $ repository -> get ( 'database.default' ) ; } $ config = $ repository -> get ( "database.connections.{$using}" , null ) ; if... | Setup multiple database connection from template . |
52,960 | protected function setupDriverConfig ( string $ driver ) : ? array { if ( isset ( $ this -> config [ $ driver ] ) ) { return null ; } if ( \ is_null ( $ config = Arr :: pull ( $ this -> config , "drivers.{$driver}" ) ) ) { return null ; } $ connection = $ this -> config [ 'connection' ] ?? null ; if ( ! \ is_null ( $ c... | Prepare configuration values . |
52,961 | protected function driverExcludedByOptions ( string $ driver , array $ options ) : bool { return ( ! empty ( $ options [ 'only' ] ) && ! \ in_array ( $ driver , ( array ) $ options [ 'only' ] ) ) || ( ! empty ( $ options [ 'except' ] ) && \ in_array ( $ driver , ( array ) $ options [ 'except' ] ) ) ; } | Determine if the given options exclude a particular driver . |
52,962 | protected function send ( array $ notes ) : void { foreach ( $ notes as $ note ) { $ this -> output -> writeln ( $ note ) ; } } | Send output of notes . |
52,963 | public function resetConnection ( ) : void { if ( ! \ is_null ( $ this -> defaultConnection ) ) { $ this -> resolver -> connection ( $ this -> connection ) -> disconnect ( ) ; $ this -> setConnection ( $ this -> defaultConnection ) ; } } | Reset the default connection name . |
52,964 | protected function pretendToRun ( $ migration , $ method ) { $ table = $ this -> entity -> getTable ( ) ; $ key = $ this -> entity -> getKey ( ) ; foreach ( $ this -> getQueries ( $ migration , $ method ) as $ query ) { $ name = \ get_class ( $ migration ) ; $ this -> note ( "<info>{$name} [{$table}:{$key}]:</info> {$q... | Pretend to run the migrations . |
52,965 | public function name ( FileInterface $ file ) { $ bytes = random_bytes ( 256 / 8 ) ; return rtrim ( strtr ( base64_encode ( $ bytes ) , '+/' , '-_' ) , '=' ) . '.' . $ file -> getExtension ( ) ; } | Name a given file and return the name . |
52,966 | protected function handleChunkedUpload ( UploadedFile $ file , ResponseInterface $ response , Request $ request ) { $ chunkManager = $ this -> container -> get ( 'oneup_uploader.chunk_manager' ) ; [ $ last , $ uuid , $ index , $ orig ] = $ this -> parseChunkedRequest ( $ request ) ; $ chunk = $ chunkManager -> addChunk... | This function will be called in order to upload and save an uploaded chunk . |
52,967 | protected function dispatchChunkEvents ( $ uploaded , ResponseInterface $ response , Request $ request , $ isLast ) { $ dispatcher = $ this -> container -> get ( 'event_dispatcher' ) ; $ postUploadEvent = new PostChunkUploadEvent ( $ uploaded , $ response , $ request , $ isLast , $ this -> type , $ this -> config ) ; $... | This function is a helper function which dispatches post chunk upload event . |
52,968 | public function getSize ( ) { if ( $ this -> filesystem -> getAdapter ( ) instanceof StreamFactory && ! $ this -> size ) { if ( $ this -> streamWrapperPrefix ) { try { $ this -> setSize ( filesize ( $ this -> streamWrapperPrefix . $ this -> getKey ( ) ) ) ; } catch ( \ Exception $ e ) { return parent :: getSize ( ) ; }... | Returns the size of the file . |
52,969 | protected function getFiles ( FileBag $ bag ) { $ files = [ ] ; $ fileBag = $ bag -> all ( ) ; $ fileIterator = new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ fileBag ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ fileIterator as $ file ) { if ( is_array ( $ file ) || null === $ file ... | Flattens a given filebag to extract all files . |
52,970 | protected function dispatchPreUploadEvent ( FileInterface $ uploaded , ResponseInterface $ response , Request $ request ) { $ dispatcher = $ this -> container -> get ( 'event_dispatcher' ) ; $ preUploadEvent = new PreUploadEvent ( $ uploaded , $ response , $ request , $ this -> type , $ this -> config ) ; $ dispatcher ... | This function is a helper function which dispatches pre upload event . |
52,971 | protected function dispatchPostEvents ( $ uploaded , ResponseInterface $ response , Request $ request ) { $ dispatcher = $ this -> container -> get ( 'event_dispatcher' ) ; $ postUploadEvent = new PostUploadEvent ( $ uploaded , $ response , $ request , $ this -> type , $ this -> config ) ; $ dispatcher -> dispatch ( Up... | This function is a helper function which dispatches post upload and post persist events . |
52,972 | protected function createSupportedJsonResponse ( $ data , $ statusCode = 200 ) { $ request = $ this -> getRequest ( ) ; $ response = new JsonResponse ( $ data , $ statusCode ) ; $ response -> headers -> set ( 'Vary' , 'Accept' ) ; if ( ! in_array ( 'application/json' , $ request -> getAcceptableContentTypes ( ) , true ... | Creates and returns a JsonResponse with the given data . |
52,973 | protected function getRequest ( ) { if ( version_compare ( Kernel :: VERSION , '2.4' , '<=' ) ) { return $ this -> container -> get ( 'request' ) ; } return $ this -> container -> get ( 'request_stack' ) -> getMasterRequest ( ) ; } | Get the master request . |
52,974 | public function getIndexVertex ( Vertex $ vertex ) { $ id = array_search ( $ vertex , $ this -> vertices , true ) ; if ( $ id === false ) { throw new OutOfBoundsException ( 'Given vertex does NOT exist' ) ; } return $ id ; } | get array index for given Vertex |
52,975 | public function getVertexFirst ( ) { if ( ! $ this -> vertices ) { throw new UnderflowException ( 'Does not contain any vertices' ) ; } reset ( $ this -> vertices ) ; return current ( $ this -> vertices ) ; } | return first Vertex in this set of Vertices |
52,976 | public function getVertexLast ( ) { if ( ! $ this -> vertices ) { throw new UnderflowException ( 'Does not contain any vertices' ) ; } end ( $ this -> vertices ) ; return current ( $ this -> vertices ) ; } | return last Vertex in this set of Vertices |
52,977 | public function getVertexMatch ( $ callbackCheck ) { $ ret = $ this -> getVertexMatchOrNull ( $ callbackCheck ) ; if ( $ ret === null ) { throw new UnderflowException ( 'No vertex found' ) ; } return $ ret ; } | return first Vertex that matches the given callback filter function |
52,978 | public function getVerticesIntersection ( $ otherVertices ) { $ otherArray = self :: factory ( $ otherVertices ) -> getVector ( ) ; $ vertices = array ( ) ; foreach ( $ this -> vertices as $ vid => $ vertex ) { $ i = array_search ( $ vertex , $ otherArray , true ) ; if ( $ i !== false ) { unset ( $ otherArray [ $ i ] )... | get intersection of Vertices with given other Vertices |
52,979 | public function getMap ( ) { $ vertices = array ( ) ; foreach ( $ this -> vertices as $ vertex ) { $ vertices [ $ vertex -> getId ( ) ] = $ vertex ; } return $ vertices ; } | get a mapping array of Vertex ID = > Vertex instance and thus remove duplicate vertices |
52,980 | public function getIds ( ) { $ ids = array ( ) ; foreach ( $ this -> vertices as $ vertex ) { $ ids [ ] = $ vertex -> getId ( ) ; } return $ ids ; } | return array of Vertex IDs |
52,981 | public function getIndexEdge ( Edge $ edge ) { $ id = array_search ( $ edge , $ this -> edges , true ) ; if ( $ id === false ) { throw new OutOfBoundsException ( 'Given edge does NOT exist' ) ; } return $ id ; } | get array index for given Edge |
52,982 | public function getEdgeFirst ( ) { if ( ! $ this -> edges ) { throw new UnderflowException ( 'Does not contain any edges' ) ; } reset ( $ this -> edges ) ; return current ( $ this -> edges ) ; } | return first Edge in this set of Edges |
52,983 | public function getEdgeLast ( ) { if ( ! $ this -> edges ) { throw new UnderflowException ( 'Does not contain any edges' ) ; } end ( $ this -> edges ) ; return current ( $ this -> edges ) ; } | return last Edge in this set of Edges |
52,984 | public function getEdgeIndex ( $ index ) { if ( ! isset ( $ this -> edges [ $ index ] ) ) { throw new OutOfBoundsException ( 'Invalid edge index' ) ; } return $ this -> edges [ $ index ] ; } | return Edge at given array index |
52,985 | public function getEdgeMatch ( $ callbackCheck ) { $ ret = $ this -> getEdgeMatchOrNull ( $ callbackCheck ) ; if ( $ ret === null ) { throw new UnderflowException ( 'No edge found' ) ; } return $ ret ; } | return first Edge that matches the given callback filter function |
52,986 | public function getEdgesIntersection ( $ otherEdges ) { $ otherArray = self :: factory ( $ otherEdges ) -> getVector ( ) ; $ edges = array ( ) ; foreach ( $ this -> edges as $ eid => $ edge ) { $ i = array_search ( $ edge , $ otherArray , true ) ; if ( $ i !== false ) { unset ( $ otherArray [ $ i ] ) ; $ edges [ $ eid ... | get intersection of Edges with given other Edges |
52,987 | public function getEdgesOut ( ) { $ that = $ this ; return $ this -> getEdges ( ) -> getEdgesMatch ( function ( Edge $ edge ) use ( $ that ) { return $ edge -> hasVertexStart ( $ that ) ; } ) ; } | get set of all outgoing Edges attached to this vertex |
52,988 | public function getEdgesIn ( ) { $ that = $ this ; return $ this -> getEdges ( ) -> getEdgesMatch ( function ( Edge $ edge ) use ( $ that ) { return $ edge -> hasVertexTarget ( $ that ) ; } ) ; } | get set of all ingoing Edges attached to this vertex |
52,989 | public function getEdgesTo ( Vertex $ vertex ) { $ that = $ this ; return $ this -> getEdges ( ) -> getEdgesMatch ( function ( Edge $ edge ) use ( $ that , $ vertex ) { return $ edge -> isConnection ( $ that , $ vertex ) ; } ) ; } | get set of Edges FROM this vertex TO the given vertex |
52,990 | public function getVerticesEdgeTo ( ) { $ ret = array ( ) ; foreach ( $ this -> getEdgesOut ( ) as $ edge ) { $ ret [ ] = $ edge -> getVertexToFrom ( $ this ) ; } return new Vertices ( $ ret ) ; } | get set of all Vertices this vertex has an edge to |
52,991 | public function getVerticesEdgeFrom ( ) { $ ret = array ( ) ; foreach ( $ this -> getEdgesIn ( ) as $ edge ) { $ ret [ ] = $ edge -> getVertexFromTo ( $ this ) ; } return new Vertices ( $ ret ) ; } | get set of all Vertices that have an edge TO this vertex |
52,992 | public function destroy ( ) { foreach ( $ this -> getEdges ( ) -> getEdgesDistinct ( ) as $ edge ) { $ edge -> destroy ( ) ; } $ this -> graph -> removeVertex ( $ this ) ; } | destroy vertex and all edges connected to it and remove reference from graph |
52,993 | public function createVertex ( $ id = NULL , $ returnDuplicate = false ) { if ( $ id === NULL ) { $ id = $ this -> getNextId ( ) ; } if ( $ returnDuplicate && $ this -> vertices -> hasVertexId ( $ id ) ) { return $ this -> vertices -> getVertexId ( $ id ) ; } return new Vertex ( $ this , $ id ) ; } | create a new Vertex in the Graph |
52,994 | public function createVertexClone ( Vertex $ originalVertex ) { $ id = $ originalVertex -> getId ( ) ; if ( $ this -> vertices -> hasVertexId ( $ id ) ) { throw new RuntimeException ( 'Id of cloned vertex already exists' ) ; } $ newVertex = new Vertex ( $ this , $ id ) ; $ newVertex -> getAttributeBag ( ) -> setAttribu... | create a new Vertex in this Graph from the given input Vertex of another graph |
52,995 | private function createEdgeCloneInternal ( Edge $ originalEdge , $ ia , $ ib ) { $ ends = $ originalEdge -> getVertices ( ) -> getIds ( ) ; $ a = $ this -> getVertex ( $ ends [ $ ia ] ) ; $ b = $ this -> getVertex ( $ ends [ $ ib ] ) ; if ( $ originalEdge instanceof EdgeDirected ) { $ newEdge = $ a -> createEdgeTo ( $ ... | create new clone of the given edge between adjacent vertices |
52,996 | public function createVertices ( $ n ) { $ vertices = array ( ) ; if ( is_int ( $ n ) && $ n >= 0 ) { for ( $ id = $ this -> getNextId ( ) , $ n += $ id ; $ id < $ n ; ++ $ id ) { $ vertices [ $ id ] = new Vertex ( $ this , $ id ) ; } } elseif ( is_array ( $ n ) ) { foreach ( $ n as $ id ) { if ( ! is_int ( $ id ) && !... | create the given number of vertices or given array of Vertex IDs |
52,997 | public function getEdgeClone ( Edge $ edge ) { $ vertices = $ edge -> getVertices ( ) -> getVector ( ) ; return $ this -> getEdgeCloneInternal ( $ edge , $ vertices [ 0 ] , $ vertices [ 1 ] ) ; } | Extracts edge from this graph |
52,998 | public function getEdgeCloneInverted ( Edge $ edge ) { $ vertices = $ edge -> getVertices ( ) -> getVector ( ) ; return $ this -> getEdgeCloneInternal ( $ edge , $ vertices [ 1 ] , $ vertices [ 0 ] ) ; } | Extracts inverted edge from this graph |
52,999 | public function setWeight ( $ weight ) { if ( $ weight !== NULL && ! is_float ( $ weight ) && ! is_int ( $ weight ) ) { throw new InvalidArgumentException ( 'Invalid weight given - must be numeric or NULL' ) ; } $ this -> weight = $ weight ; return $ this ; } | set new weight for edge |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.