idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
22,500 | public function UserGrantRole ( AuthUserGrantRoleRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/UserGrantRole' , $ argument , [ '\Etcdserverpb\AuthUserGrantRoleResponse' , 'decode' ] , $ metadata , $ options ) ; } | UserGrant grants a role to a specified user . |
22,501 | public function UserRevokeRole ( AuthUserRevokeRoleRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/UserRevokeRole' , $ argument , [ '\Etcdserverpb\AuthUserRevokeRoleResponse' , 'decode' ] , $ metadata , $ options ) ; } | UserRevokeRole revokes a role of specified user . |
22,502 | public function RoleAdd ( AuthRoleAddRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/RoleAdd' , $ argument , [ '\Etcdserverpb\AuthRoleAddResponse' , 'decode' ] , $ metadata , $ options ) ; } | RoleAdd adds a new role . |
22,503 | public function RoleGet ( AuthRoleGetRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/RoleGet' , $ argument , [ '\Etcdserverpb\AuthRoleGetResponse' , 'decode' ] , $ metadata , $ options ) ; } | RoleGet gets detailed role information . |
22,504 | public function RoleList ( AuthRoleListRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/RoleList' , $ argument , [ '\Etcdserverpb\AuthRoleListResponse' , 'decode' ] , $ metadata , $ options ) ; } | RoleList gets lists of all roles . |
22,505 | public function RoleDelete ( AuthRoleDeleteRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/RoleDelete' , $ argument , [ '\Etcdserverpb\AuthRoleDeleteResponse' , 'decode' ] , $ metadata , $ options ) ; } | RoleDelete deletes a specified role . |
22,506 | public function RoleGrantPermission ( AuthRoleGrantPermissionRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/RoleGrantPermission' , $ argument , [ '\Etcdserverpb\AuthRoleGrantPermissionResponse' , 'decode' ] , $ metadata , $ options ) ; } | RoleGrantPermission grants a permission of a specified key or range to a specified role . |
22,507 | public function RoleRevokePermission ( AuthRoleRevokePermissionRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/etcdserverpb.Auth/RoleRevokePermission' , $ argument , [ '\Etcdserverpb\AuthRoleRevokePermissionResponse' , 'decode' ] , $ metadata , $ options ) ; } | RoleRevokePermission revokes a key or range permission of a specified role . |
22,508 | public function load ( $ relations ) { $ query = $ this -> newQuery ( ) -> with ( is_string ( $ relations ) ? func_get_args ( ) : $ relations ) ; $ query -> eagerLoadRelations ( [ $ this ] ) ; return $ this ; } | Eager load relations on the model . |
22,509 | public function freshTimestamp ( ) { $ t = microtime ( true ) ; $ micro = sprintf ( "%06d" , ( $ t - floor ( $ t ) ) * 1000000 ) ; return new Carbon ( date ( 'Y-m-d H:i:s.' . $ micro , $ t ) ) ; } | Get a fresh timestamp for the model . |
22,510 | public function addDependency ( $ value ) { if ( $ this -> dependency === null ) { $ this -> dependency = new \ Protobuf \ ScalarCollection ( ) ; } $ this -> dependency -> add ( $ value ) ; } | Add a new element to dependency |
22,511 | public function addPublicDependency ( $ value ) { if ( $ this -> public_dependency === null ) { $ this -> public_dependency = new \ Protobuf \ ScalarCollection ( ) ; } $ this -> public_dependency -> add ( $ value ) ; } | Add a new element to public_dependency |
22,512 | public function addWeakDependency ( $ value ) { if ( $ this -> weak_dependency === null ) { $ this -> weak_dependency = new \ Protobuf \ ScalarCollection ( ) ; } $ this -> weak_dependency -> add ( $ value ) ; } | Add a new element to weak_dependency |
22,513 | public function addMessageType ( \ google \ protobuf \ DescriptorProto $ value ) { if ( $ this -> message_type === null ) { $ this -> message_type = new \ Protobuf \ MessageCollection ( ) ; } $ this -> message_type -> add ( $ value ) ; } | Add a new element to message_type |
22,514 | public function addEnumType ( \ google \ protobuf \ EnumDescriptorProto $ value ) { if ( $ this -> enum_type === null ) { $ this -> enum_type = new \ Protobuf \ MessageCollection ( ) ; } $ this -> enum_type -> add ( $ value ) ; } | Add a new element to enum_type |
22,515 | public function addService ( \ google \ protobuf \ ServiceDescriptorProto $ value ) { if ( $ this -> service === null ) { $ this -> service = new \ Protobuf \ MessageCollection ( ) ; } $ this -> service -> add ( $ value ) ; } | Add a new element to service |
22,516 | public function addExtension ( \ google \ protobuf \ FieldDescriptorProto $ value ) { if ( $ this -> extension === null ) { $ this -> extension = new \ Protobuf \ MessageCollection ( ) ; } $ this -> extension -> add ( $ value ) ; } | Add a new element to extension |
22,517 | public function execute ( $ command , callable $ callback = null ) { $ this -> login ( ) ; return $ this -> ssh -> exec ( sprintf ( 'cd %s; %s' , $ this -> directory , $ command ) , $ callback ) ; } | Executes command on connected server . |
22,518 | public function executeNanbando ( $ command , array $ parameter , callable $ callback = null ) { $ this -> login ( ) ; $ parameterString = [ ] ; foreach ( $ parameter as $ key => $ value ) { if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } foreach ( $ value as $ item ) { $ parameterString [ ] = trim ( ( is_string ( $ key ) ? $ key . ' ' : '' ) . $ item ) ; } } return $ this -> execute ( sprintf ( '%s %s %s' , $ this -> executable , $ command , implode ( ' ' , $ parameterString ) ) , $ callback ) ; } | Executes nanbando command on connected server . |
22,519 | public function get ( $ remoteFile , $ localFile ) { $ this -> login ( ) ; if ( ! isset ( $ this -> ssh ) ) { return false ; } if ( ! $ this -> ssh -> exec ( 'scp -f ' . escapeshellarg ( $ remoteFile ) , false ) ) { return false ; } $ this -> sendPacket ( "\0" ) ; if ( ! preg_match ( '#(?<perms>[^ ]+) (?<size>\d+) (?<name>.+)#' , rtrim ( $ this -> receivePacket ( ) ) , $ info ) ) { return false ; } $ this -> sendPacket ( "\0" ) ; $ size = 0 ; $ fp = null ; if ( $ localFile !== false ) { $ fp = @ fopen ( $ localFile , 'wb' ) ; if ( ! $ fp ) { return false ; } } $ progressBar = new ProgressBar ( $ this -> output , $ info [ 'size' ] ) ; $ progressBar -> setFormat ( ' %message% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%' ) ; $ progressBar -> start ( ) ; $ byteFormatter = new ByteFormatter ( ) ; $ content = '' ; while ( $ size < $ info [ 'size' ] ) { $ data = $ this -> receivePacket ( ) ; $ length = strlen ( $ data ) ; $ size += $ length ; $ progressBar -> advance ( $ length ) ; $ progressBar -> setMessage ( sprintf ( '%s/%s' , $ byteFormatter -> format ( $ size ) , $ byteFormatter -> format ( $ info [ 'size' ] ) ) ) ; if ( ! $ fp ) { $ content .= $ data ; } else { fwrite ( $ fp , $ data ) ; } } $ progressBar -> finish ( ) ; $ this -> output -> writeln ( '' ) ; $ this -> closeChannel ( ) ; return true ; } | Download remote - file and save it to given local - file . |
22,520 | private function login ( ) { if ( $ this -> loggedIn ) { return ; } if ( array_key_exists ( 'rsakey' , $ this -> sshConfig ) ) { $ this -> loginWithRsaKey ( ) ; } elseif ( array_key_exists ( 'password' , $ this -> sshConfig ) ) { $ this -> loginWithPassword ( ) ; } $ this -> loggedIn = $ this -> validate ( ) ; } | Executes login to server . |
22,521 | private function loginWithPassword ( ) { $ password = $ this -> sshConfig [ 'password' ] ; if ( ! is_string ( $ password ) ) { $ password = $ this -> askForPassword ( sprintf ( 'Password for %s@%s:%s: ' , $ this -> sshConfig [ 'username' ] , $ this -> sshConfig [ 'host' ] , $ this -> sshConfig [ 'port' ] ) ) ; } if ( ! $ this -> ssh -> login ( $ this -> sshConfig [ 'username' ] , $ password ) ) { throw new SshLoginException ( $ this -> name ) ; } return true ; } | Login to server using username and password . |
22,522 | private function loginWithRsaKey ( ) { $ key = new RSA ( ) ; $ password = $ this -> sshConfig [ 'rsakey' ] [ 'password' ] ; if ( $ password ) { if ( ! is_string ( $ password ) ) { $ password = $ this -> askForPassword ( sprintf ( 'Password for file "%s": ' , $ this -> sshConfig [ 'rsakey' ] [ 'file' ] ) ) ; } $ key -> setPassword ( $ password ) ; } $ key -> loadKey ( file_get_contents ( $ this -> sshConfig [ 'rsakey' ] [ 'file' ] ) ) ; if ( ! $ this -> ssh -> login ( $ this -> sshConfig [ 'username' ] , $ key ) ) { throw new SshLoginException ( $ this -> name ) ; } return true ; } | Login to server using rsa key - file . |
22,523 | private function askForPassword ( $ question ) { $ questionHelper = new QuestionHelper ( ) ; $ question = new Question ( $ question ) ; $ question -> setHidden ( true ) ; $ question -> setHiddenFallback ( false ) ; $ password = $ questionHelper -> ask ( $ this -> input , $ this -> output , $ question ) ; $ this -> output -> writeln ( '' ) ; return $ password ; } | Uses question helper to ask for password . |
22,524 | private function validate ( ) { if ( ! $ this -> testServer ( $ this -> ssh , sprintf ( '-d "%s"' , $ this -> directory ) ) ) { throw new SshValidateException ( 'Directory does not exists' ) ; } if ( ! $ this -> testServer ( $ this -> ssh , sprintf ( '-x "%s"' , $ this -> executable ) , $ this -> directory ) ) { throw new SshValidateException ( 'Executable does not exists' ) ; } return true ; } | Validates ssh connection . |
22,525 | public function create ( ) { $ script = "<script>\n\t$(function(){ \n\t\t" ; if ( $ this -> click ) { $ script .= "\t$('" . $ this -> click [ 0 ] . "').on('" . $ this -> click [ 1 ] . "',function(){ \n\t\t\t\t $.amaran(" . json_encode ( $ this -> amaran ) . ") \n\t\t\t}); \n\t\t});\n\t</script>\n" ; } else { $ script .= "$.amaran(" . json_encode ( $ this -> amaran ) . "); \n\t });\n</script>\n" ; } if ( $ this -> flash ) { $ this -> session -> flash ( 'amaranjs.content' , $ script ) ; } else { $ this -> viewBinder -> bind ( $ script ) ; } } | Bind AmaranJS to view . |
22,526 | protected function whereSub ( $ column , $ operator , Closure $ callback , $ boolean ) { $ type = 'Sub' ; $ query = $ this -> newQuery ( ) ; call_user_func ( $ callback , $ query ) ; $ this -> wheres [ ] = compact ( 'type' , 'column' , 'operator' , 'query' , 'boolean' ) ; $ this -> addBinding ( $ query -> getBindings ( ) , 'where' ) ; return $ this ; } | Add a full sub - select to the query . |
22,527 | protected function whereInSub ( $ column , Closure $ callback , $ boolean , $ not ) { $ type = $ not ? 'NotInSub' : 'InSub' ; call_user_func ( $ callback , $ query = $ this -> newQuery ( ) ) ; $ this -> wheres [ ] = compact ( 'type' , 'column' , 'query' , 'boolean' ) ; $ this -> addBinding ( $ query -> getBindings ( ) , 'where' ) ; return $ this ; } | Add a where in with a sub - select to the query . |
22,528 | public function whereTime ( $ column , $ operator , $ value , $ boolean = 'and' ) { return $ this -> addDateBasedWhere ( 'Time' , $ column , $ operator , $ value , $ boolean ) ; } | Add a where time statement to the query . |
22,529 | protected function backupFieldsForCount ( ) { foreach ( [ 'orders' , 'limit' , 'offset' , 'columns' ] as $ field ) { $ this -> backups [ $ field ] = $ this -> { $ field } ; $ this -> { $ field } = null ; } foreach ( [ 'order' , 'select' ] as $ key ) { $ this -> bindingBackups [ $ key ] = $ this -> bindings [ $ key ] ; $ this -> bindings [ $ key ] = [ ] ; } } | Backup then remove some fields for the pagination count . |
22,530 | protected function createFileHistory ( PostPersistEvent $ event ) { $ files = $ event -> getRequest ( ) -> files -> all ( ) ; $ uploadedFile = array_pop ( $ files ) ; $ originalFileName = $ uploadedFile -> getClientOriginalName ( ) ; $ fileName = $ event -> getFile ( ) -> getBasename ( ) ; return $ this -> fileHistoryManager -> createAndSave ( $ fileName , $ originalFileName , $ event -> getType ( ) ) ; } | Create a filehistory to retrieve original name and uploading user |
22,531 | public function mergeConstraintsFrom ( Builder $ from ) { $ whereBindings = array_get ( $ from -> getQuery ( ) -> getRawBindings ( ) , 'where' , [ ] ) ; return $ this -> withoutGlobalScopes ( $ from -> removedScopes ( ) ) -> mergeWheres ( $ from -> getQuery ( ) -> wheres , $ whereBindings ) ; } | Merge the where constraints from another query to the current query . |
22,532 | public function firstOr ( $ columns = [ '*' ] , callable $ callback = null ) { if ( is_callable ( $ columns ) ) { $ callback = $ columns ; $ columns = [ '*' ] ; } if ( ! is_null ( $ model = $ this -> first ( $ columns ) ) ) { return $ model ; } return call_user_func ( $ callback ) ; } | Execute the query and get the first result or call a callback . |
22,533 | public function map ( $ row ) { $ class = $ this -> modelClass ; $ model = new $ class ( $ this -> db , $ row , false ) ; $ model -> setAttribute ( 'table' , $ this -> table ) -> setAttribute ( 'pk' , $ this -> pk ) ; return $ model ; } | Map array to model |
22,534 | public function mapModels ( $ rows ) { $ rst = array ( ) ; foreach ( $ rows as $ row ) { $ rst [ ] = $ this -> map ( $ row ) ; } return $ rst ; } | Map data rows to model array |
22,535 | public function create ( $ row = array ( ) ) { $ class = $ this -> modelClass ; $ model = new $ class ( $ this -> db , $ row ) ; $ model -> setAttribute ( 'table' , $ this -> table ) -> setAttribute ( 'pk' , $ this -> pk ) ; return $ model ; } | Create a fresh model from array |
22,536 | public function count ( $ conditions = '' , $ params = array ( ) ) { return $ this -> db -> builder ( ) -> select ( 'COUNT(*)' ) -> from ( $ this -> table ) -> where ( $ conditions , $ params ) -> queryValue ( ) ; } | Count with conditions |
22,537 | public function findOne ( $ conditions , $ params = array ( ) ) { $ row = $ this -> db -> builder ( ) -> select ( ) -> from ( $ this -> table ) -> where ( $ conditions , $ params ) -> limit ( 1 ) -> queryRow ( ) ; if ( false === $ row ) { return false ; } return $ this -> map ( $ row ) ; } | Find one model with conditions |
22,538 | public function findByPK ( $ pk ) { $ pkConditions = $ this -> buildPKConditions ( $ this -> pk , $ pk ) ; return $ this -> findOne ( $ pkConditions [ 0 ] , $ pkConditions [ 1 ] ) ; } | Find one model by primary key |
22,539 | public function findMany ( $ conditions = '' , $ params = array ( ) , $ orderBy = null , $ limit = null , $ offset = null ) { $ cmd = $ this -> db -> builder ( ) -> select ( ) -> from ( $ this -> table ) -> where ( $ conditions , $ params ) ; if ( $ orderBy ) { $ cmd -> orderBy ( $ orderBy ) ; } $ rows = $ cmd -> limit ( $ limit , $ offset ) -> queryAll ( ) ; if ( false === $ rows ) { return false ; } else { return $ this -> mapModels ( $ rows ) ; } } | Find many models with conditions |
22,540 | public function findManyBy ( $ key , $ value , $ orderBy = null , $ limit = null , $ offset = null ) { return $ this -> findMany ( $ key . '=:key' , array ( ':key' => $ value ) , $ orderBy , $ limit , $ offset ) ; } | Find many models with by key |
22,541 | public function update ( $ values , $ conditions , $ params = array ( ) ) { return $ this -> db -> builder ( ) -> update ( $ this -> table , $ values , $ conditions , $ params ) ; } | Update table with condition |
22,542 | public function updateByPK ( $ pk , $ values ) { $ pkConditions = $ this -> buildPKConditions ( $ this -> pk , $ pk ) ; return $ this -> update ( $ values , $ pkConditions [ 0 ] , $ pkConditions [ 1 ] ) ; } | Update table by primary key |
22,543 | public function delete ( $ conditions , $ params = array ( ) ) { return $ this -> db -> builder ( ) -> delete ( $ this -> table , $ conditions , $ params ) ; } | Delete with condition |
22,544 | public function deleteByPK ( $ pk ) { $ pkConditions = $ this -> buildPKConditions ( $ this -> pk , $ pk ) ; return $ this -> delete ( $ pkConditions [ 0 ] , $ pkConditions [ 1 ] ) ; } | Delete by primary key |
22,545 | public function findMany ( $ ids , $ columns = [ '*' ] ) { return empty ( $ ids ) ? [ ] : $ this -> whereIn ( $ this -> getRelated ( ) -> getQualifiedKeyName ( ) , $ ids ) -> get ( $ columns ) ; } | Find multiple related models by their primary keys . |
22,546 | private function Array2string ( $ arr , $ glue = '&' ) { if ( ! is_array ( $ arr ) ) { throw new Exception ( 'Argument arr must be array' ) ; ; } $ new = array ( ) ; foreach ( $ arr as $ k => $ v ) { $ new [ ] = urlencode ( $ k ) . '=' . urlencode ( $ v ) ; } return implode ( $ glue , $ new ) ; } | Converts array to string |
22,547 | private function getHeaders ( $ str ) { $ str = explode ( self :: LE . self :: LE , $ str ) ; $ str = reset ( $ str ) ; $ str = explode ( self :: LE , $ str ) ; $ new = array ( ) ; $ s = 1 ; foreach ( $ str as $ line ) { $ pos = strpos ( $ line , ': ' ) ; if ( $ pos !== false ) { $ key = strtolower ( substr ( $ line , 0 , $ pos ) ) ; if ( ! isset ( $ new [ $ key ] ) ) { $ new [ $ key ] = preg_replace ( '/\s+/' , ' ' , trim ( substr ( $ line , $ pos + 1 ) ) ) ; } else { $ new [ $ key . '-' . $ s ] = preg_replace ( '/\s+/' , ' ' , trim ( substr ( $ line , $ pos + 1 ) ) ) ; $ s ++ ; } } else { $ new [ 'status' ] = $ line ; } } return $ new ; } | Parses headers from string |
22,548 | private function getBody ( $ str ) { $ str = substr ( $ str , strpos ( $ str , self :: LE . self :: LE ) ) ; return trim ( $ str ) ; } | Parses body from string |
22,549 | private function ParseCachingHeader ( $ arr ) { if ( ! empty ( $ arr [ 'cache-control' ] ) ) { if ( strpos ( 'no-cache' , $ arr [ 'cache-control' ] ) !== false ) { return 0 ; } if ( strpos ( 'no-store' , $ arr [ 'cache-control' ] ) !== false ) { return 0 ; } if ( strpos ( 'max-age=0' , $ arr [ 'cache-control' ] ) !== false ) { return 0 ; } if ( preg_match ( '/\bmax-age=(\d+),?\b/' , $ arr [ 'cache-control' ] , $ match ) ) { return ( integer ) $ match [ 1 ] ; } } if ( ! empty ( $ arr [ 'expires' ] ) ) { if ( preg_match ( '/^-\d+|0$/' , $ arr [ 'expires' ] ) ) { return 0 ; } $ epoch = strtotime ( $ arr [ 'expires' ] ) ; $ sec = $ epoch - time ( ) ; if ( $ sec > 0 ) { return $ sec ; } return 0 ; } return 0 ; } | Parses the response headers and returns the number of seconds that will be the maximum caching time of our cached file . |
22,550 | private function GetCookieFileName ( $ url ) { $ temp = parse_url ( $ url ) ; $ ext = ( string ) $ this -> CookieMaxAge ; return $ this -> CacheDir . '/CURL_COOKIE-' . sha1 ( $ temp [ 'host' ] ) . '.' . $ ext ; } | Returns name of a cookie file |
22,551 | public function DeleteChacheFile ( $ filename ) { if ( preg_match ( '/^\/CURL_RESPON-[0-9a-f]{40}\.\d+$/' , $ filename ) ) { $ filename = $ this -> CacheDir . $ filename ; if ( file_exists ( $ filename ) ) { unlink ( $ filename ) ; } } } | Deletes a cache file |
22,552 | private function FilePutContents ( $ file , $ str ) { $ fileObj = new SplFileObject ( $ file , 'w' ) ; while ( ! $ fileObj -> flock ( LOCK_EX ) ) { usleep ( 1 ) ; } $ bytes = $ fileObj -> fwrite ( $ str ) ; $ fileObj -> flock ( LOCK_UN ) ; return $ bytes ; } | Saves string inside a file |
22,553 | private function FileGetContents ( $ file ) { $ fileObj = new SplFileObject ( $ file , 'r' ) ; while ( ! $ fileObj -> flock ( LOCK_EX ) ) { usleep ( 1 ) ; } $ str = $ fileObj -> fread ( $ fileObj -> getSize ( ) ) ; $ fileObj -> flock ( LOCK_UN ) ; return $ str ; } | Retrieves contents of a file |
22,554 | protected function getBaseLink ( ) { $ res = '.' ; $ res .= str_repeat ( "/.." , sizeof ( $ this -> PWE -> getURL ( ) -> getParamsAsArray ( ) ) ) ; return $ res ; } | Wherever you called with URL params you may get relative link to your base structure node |
22,555 | public function addRoute ( string $ method , string $ route , ... $ callback ) { $ method = strtolower ( $ method ) ; $ route = ltrim ( $ route , '/' ) ; $ group = rtrim ( $ this -> group , '/' ) . '/' ; $ route = $ group . $ route ; $ scope = $ this -> middleware -> count ( ) ; $ this -> layer [ $ method ] [ ] = new Route ( $ method , $ route , $ callback , $ scope , $ this -> group ) ; return true ; } | add a route to stack |
22,556 | public function import ( array $ loader ) { $ this -> loader = $ loader ; foreach ( $ loader as $ alias => $ namespace ) { $ alias = $ this -> alias ( $ alias ) ; $ this -> container -> set ( $ alias , function ( $ c ) use ( $ alias , $ namespace ) { if ( is_callable ( [ $ namespace , 'make' ] ) ) { call_user_func_array ( $ namespace . '::make' , [ $ alias , $ c ] ) ; } return new $ namespace ( ) ; } ) ; } } | import custom files keep to psr - 4 |
22,557 | public function getData ( ) { $ data = [ ] ; foreach ( $ this -> providerList as $ provider ) { $ data += $ provider -> getData ( ) ; } return $ data ; } | Get data from all providers |
22,558 | public function throwsException ( $ exceptionClassOrObject ) : ObjectExceptionMatcher { $ class = is_string ( $ exceptionClassOrObject ) ? $ exceptionClassOrObject : get_class ( $ exceptionClassOrObject ) ; $ matcher = $ this -> createInternalMatcherWithDescription ( ObjectExceptionMatcher :: class , 'I see that exception "' . $ class . '"' ) ; $ matcher -> exceptionClassOrObject = $ exceptionClassOrObject ; return $ matcher ; } | Start sub - chain of exception matcher . |
22,559 | public function getValue ( $ endpoint , $ key ) { if ( isset ( $ this -> endpoints [ 'endpoints' ] [ $ endpoint ] ) && isset ( $ this -> endpoints [ 'endpoints' ] [ $ endpoint ] [ $ key ] ) ) { return $ this -> endpoints [ 'endpoints' ] [ $ endpoint ] [ $ key ] ; } if ( isset ( $ this -> endpoints [ $ key ] ) ) { return $ this -> endpoints [ $ key ] ; } return null ; } | Get configuration value |
22,560 | public function addPath ( $ value ) { if ( $ this -> path === null ) { $ this -> path = new \ Protobuf \ ScalarCollection ( ) ; } $ this -> path -> add ( $ value ) ; } | Add a new element to path |
22,561 | public function addSpan ( $ value ) { if ( $ this -> span === null ) { $ this -> span = new \ Protobuf \ ScalarCollection ( ) ; } $ this -> span -> add ( $ value ) ; } | Add a new element to span |
22,562 | public function addLeadingDetachedComments ( $ value ) { if ( $ this -> leading_detached_comments === null ) { $ this -> leading_detached_comments = new \ Protobuf \ ScalarCollection ( ) ; } $ this -> leading_detached_comments -> add ( $ value ) ; } | Add a new element to leading_detached_comments |
22,563 | public function getOldAttributes ( ) { $ attributes = $ this -> prepareAttributes ( $ this -> original ) ; $ attributes = $ this -> getRevisionableItems ( $ attributes ) ; return $ attributes ; } | Get an array of original revisionable attributes . |
22,564 | public function getNewAttributes ( ) { $ attributes = $ this -> prepareAttributes ( $ this -> attributes ) ; $ attributes = $ this -> getRevisionableItems ( $ attributes ) ; return $ attributes ; } | Get an array of current revisionable attributes . |
22,565 | public function generateSecurityCode ( ) { $ result = $ this -> getCertificatePrivateKey ( ) ; $ result .= $ this -> getOib ( ) ; $ result .= $ this -> getDateTime ( ) ; $ result .= $ this -> getInvoiceNumber ( ) -> getInvoiceNumber ( ) ; $ result .= $ this -> getInvoiceNumber ( ) -> getBusinessLocationCode ( ) ; $ result .= $ this -> getInvoiceNumber ( ) -> getPaymentDeviceCode ( ) ; $ result .= $ this -> getTotalValue ( ) ; $ this -> setSecurityCode ( md5 ( $ result ) ) ; return $ this ; } | Generate security code |
22,566 | protected function setUpEntityManagers ( ) { $ managers = [ ] ; $ connections = [ ] ; foreach ( $ this -> config [ 'managers' ] as $ manager => $ settings ) { $ managerName = IlluminateRegistry :: getManagerNamePrefix ( ) . $ manager ; $ connectionName = IlluminateRegistry :: getConnectionNamePrefix ( ) . $ manager ; $ this -> app -> singleton ( $ managerName , function ( ) use ( $ settings ) { $ manager = EntityManager :: create ( ConnectionManager :: resolve ( array_get ( $ settings , 'connection' ) ) , MetaDataManager :: resolve ( array_get ( $ settings , 'meta' ) ) ) ; $ configuration = $ manager -> getConfiguration ( ) ; if ( isset ( $ settings [ 'events' ] [ 'listeners' ] ) ) { foreach ( $ settings [ 'events' ] [ 'listeners' ] as $ event => $ listener ) { $ manager -> getEventManager ( ) -> addEventListener ( $ event , $ listener ) ; } } if ( isset ( $ settings [ 'events' ] [ 'subscribers' ] ) ) { foreach ( $ settings [ 'events' ] [ 'subscribers' ] as $ subscriber ) { $ manager -> getEventManager ( ) -> addEventSubscriber ( $ subscriber ) ; } } if ( isset ( $ settings [ 'filters' ] ) ) { foreach ( $ settings [ 'filters' ] as $ name => $ filter ) { $ configuration -> getMetadataDriverImpl ( ) -> addFilter ( $ name , $ filter ) ; $ manager -> getFilters ( ) -> enable ( $ name ) ; } } $ configuration -> getMetadataDriverImpl ( ) -> addPaths ( array_get ( $ settings , 'paths' , [ ] ) ) ; $ configuration -> setDefaultRepositoryClassName ( array_get ( $ settings , 'repository' , \ Doctrine \ ORM \ EntityRepository :: class ) ) ; $ configuration -> setAutoGenerateProxyClasses ( array_get ( $ settings , 'proxies.auto_generate' , false ) ) ; if ( $ namespace = array_get ( $ settings , 'proxies.namespace' , false ) ) { $ configuration -> setProxyNamespace ( $ namespace ) ; } return $ manager ; } ) ; $ this -> app -> singleton ( $ connectionName , function ( $ app ) use ( $ manager ) { $ app -> make ( IlluminateRegistry :: getManagerNamePrefix ( ) . $ manager ) -> getConnection ( ) ; } ) ; $ managers [ $ manager ] = $ manager ; $ connections [ $ manager ] = $ manager ; } return [ $ managers , $ connections ] ; } | Setup the entity managers |
22,567 | protected function registerEntityManager ( ) { $ this -> app -> singleton ( 'em' , function ( $ app ) { return $ app -> make ( ManagerRegistry :: class ) -> getManager ( ) ; } ) ; $ this -> app -> alias ( 'em' , EntityManager :: class ) ; $ this -> app -> alias ( 'em' , EntityManagerInterface :: class ) ; } | Setup the entity manager |
22,568 | protected function setupMetaData ( ) { MetaDataManager :: registerDrivers ( $ this -> config [ 'meta' ] [ 'drivers' ] , $ this -> config [ 'dev' ] ) ; MetaDataManager :: resolved ( function ( Configuration $ configuration ) { if ( $ this -> config [ 'debugbar' ] === true ) { $ debugStack = new DebugStack ( ) ; $ configuration -> setSQLLogger ( $ debugStack ) ; $ this -> app [ 'debugbar' ] -> addCollector ( new DoctrineCollector ( $ debugStack ) ) ; } $ configuration -> getMetadataDriverImpl ( ) -> addPaths ( [ __DIR__ . '/Migrations' , __DIR__ . '/Auth/Passwords' ] ) ; $ configuration -> setNamingStrategy ( $ this -> app -> make ( LaravelNamingStrategy :: class ) ) ; $ configuration -> setCustomDatetimeFunctions ( $ this -> config [ 'custom_datetime_functions' ] ) ; $ configuration -> setCustomNumericFunctions ( $ this -> config [ 'custom_numeric_functions' ] ) ; $ configuration -> setCustomStringFunctions ( $ this -> config [ 'custom_string_functions' ] ) ; if ( $ this -> config [ 'cache' ] [ 'second_level' ] ) { $ configuration -> setSecondLevelCacheEnabled ( true ) ; $ cacheConfig = $ configuration -> getSecondLevelCacheConfiguration ( ) ; $ cacheConfig -> setCacheFactory ( new DefaultCacheFactory ( $ cacheConfig -> getRegionsConfiguration ( ) , CacheManager :: resolve ( $ this -> config [ 'cache' ] [ 'default' ] ) ) ) ; } } ) ; } | Register the meta data drivers |
22,569 | public static function setup ( $ caches , Logger $ logger = null , $ logLevel = null ) { if ( ! is_array ( $ caches ) ) { $ caches = array ( self :: _DEFAULT => array ( 'backend' => $ caches ) ) ; } self :: $ logger = $ logger ; self :: $ logLevel = $ logLevel ; foreach ( $ caches as $ name => $ options ) { self :: $ caches [ $ name ] = self :: factory ( $ options ) ; } } | Setups the cache manager . |
22,570 | public function apply ( ) { $ filters = $ this -> filters ; $ inputs = $ this -> inputs ; $ assistant = $ this -> assistant ; if ( count ( $ filters ) ) { foreach ( $ filters as $ name => $ filter ) { $ rules = ( is_array ( $ filter ) ) ? $ filter : explode ( '|' , $ filter ) ; if ( count ( $ rules ) and isset ( $ inputs [ $ name ] ) ) { foreach ( $ rules as $ rule ) { $ splitAt = strpos ( $ rule , ':' ) ; $ argument = null ; if ( $ splitAt ) { $ argument = substr ( $ rule , $ splitAt + 1 ) ; $ rule = substr ( $ rule , 0 , $ splitAt ) ; } $ rule = strtolower ( $ rule ) ; $ rule = str_replace ( '_' , ' ' , $ rule ) ; $ rule = str_replace ( ' ' , '' , ucwords ( $ rule ) ) ; $ method = 'filter' . $ rule ; if ( method_exists ( $ this , $ method ) ) { $ inputs [ $ name ] = $ this -> $ method ( $ inputs [ $ name ] , $ argument ) ; } if ( $ assistant && method_exists ( $ assistant , $ method ) ) { $ inputs [ $ name ] = $ assistant -> $ method ( $ inputs [ $ name ] , $ argument ) ; } } } } } return $ inputs ; } | Apply filters to the inputs . |
22,571 | private function filterStripTags ( $ value , $ argument = null ) { $ allowedTags = array ( '<p>' , '<a>' , '<b>' , '<i>' , '<em>' , '<strong>' , '<img>' , '<br>' , '<ul>' , '<ol>' , '<li>' , '<span>' , '<blockquote>' , '<code>' , '<sub>' , '<sup>' , '<h1>' , '<h2>' , '<h3>' , '<h4>' , '<h5>' , '<h6>' , '<dd>' , '<dl>' , '<label>' ) ; return strip_tags ( $ value , join ( null , $ allowedTags ) ) ; } | Strip Tags filter |
22,572 | private function filterNumberFormat ( $ value , $ argument = null ) { if ( $ argument and is_int ( $ argument ) ) { $ value = number_format ( $ value , $ argument ) ; } return $ value ; } | Number Format filter |
22,573 | public function validate ( $ endpoint , $ value , $ configKey = 'upload_validators' ) { $ validationConfiguration = $ this -> configuration -> getValue ( $ endpoint , $ configKey ) ; foreach ( ( array ) $ validationConfiguration as $ validationType => $ config ) { $ validator = $ this -> validators -> getValidator ( $ validationType ) ; $ validator -> applyValidator ( $ value , $ config ) ; } } | Validate by applying validators from validator chain |
22,574 | public function start ( $ browserName = null ) { if ( $ this -> started ) { throw new Exception \ ConnectionException ( 'Client is already started' ) ; } if ( ! $ this -> con -> isProxyStarted ( ) ) { throw new Exception \ ConnectionException ( 'Sahi proxy seems not running' ) ; } if ( ! $ this -> con -> isCustomSidProvided ( ) ) { if ( null === $ browserName ) { throw new \ InvalidArgumentException ( 'Specify browser to run in' ) ; } $ this -> con -> start ( $ browserName ) ; $ limit = 600 ; while ( ! $ this -> con -> isReady ( ) ) { usleep ( 100000 ) ; if ( -- $ limit <= 0 ) { throw new Exception \ ConnectionException ( 'Connection time limit reached' ) ; } } $ this -> browserAutoruned = true ; } elseif ( ! $ this -> con -> isReady ( ) ) { throw new Exception \ ConnectionException ( sprintf ( "Can not connect to Sahi session with id \"%s\".\n" . "Start Sahi session in target browser by opening:\n" . "http://sahi.example.com/_s_/dyn/Driver_start?sahisid=%s&startUrl=http://sahi.example.com/_s_/dyn/Driver_initialized" , $ this -> con -> getSid ( ) , $ this -> con -> getSid ( ) ) ) ; } $ this -> started = true ; } | Start Sahi browser session . |
22,575 | public function stop ( ) { if ( ! $ this -> started ) { throw new Exception \ ConnectionException ( 'Client is not started' ) ; } if ( $ this -> browserAutoruned ) { $ this -> con -> stop ( ) ; } $ this -> started = false ; } | Stop Sahi browser session . |
22,576 | public function navigateTo ( $ url , $ reload = null ) { $ arguments = array ( json_encode ( $ url ) ) ; if ( null !== $ reload ) { $ arguments [ ] = ( bool ) $ reload ? 'true' : 'false' ; } $ this -> con -> executeStep ( sprintf ( '_sahi._navigateTo(%s)' , implode ( ', ' , $ arguments ) ) ) ; } | Navigates to the given URL . |
22,577 | public function wait ( $ timeout , $ condition ) { $ conditionResult = false ; while ( $ timeout > 0 && true !== $ conditionResult ) { usleep ( 100 ) ; $ timeout -= 100 ; try { $ conditionResult = $ this -> con -> evaluateJavascript ( $ condition ) ; } catch ( \ Exception $ e ) { $ conditionResult = false ; } } return ( boolean ) $ conditionResult ; } | Waits for timeInMilliseconds ms or till the condition is satisfied on the browser which ever is sooner . |
22,578 | public function findDiv ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ DivAccessor ( $ id , $ relations , $ this -> con ) ; } | Find DIV element . |
22,579 | public function findImage ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ ImageAccessor ( $ id , $ relations , $ this -> con ) ; } | Find img element . |
22,580 | public function findLabel ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ LabelAccessor ( $ id , $ relations , $ this -> con ) ; } | Find label element . |
22,581 | public function findLink ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ LinkAccessor ( $ id , $ relations , $ this -> con ) ; } | Find a element . |
22,582 | public function findListItem ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ ListItemAccessor ( $ id , $ relations , $ this -> con ) ; } | Find li element . |
22,583 | public function findSpan ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ SpanAccessor ( $ id , $ relations , $ this -> con ) ; } | Find span element . |
22,584 | public function findButton ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ ButtonAccessor ( $ id , $ relations , $ this -> con ) ; } | Find button element . |
22,585 | public function findCheckbox ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ CheckboxAccessor ( $ id , $ relations , $ this -> con ) ; } | Find checkbox element . |
22,586 | public function findFile ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ FileAccessor ( $ id , $ relations , $ this -> con ) ; } | Find file element . |
22,587 | public function findHidden ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ HiddenAccessor ( $ id , $ relations , $ this -> con ) ; } | Find hidden element . |
22,588 | public function findImageSubmitButton ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ ImageSubmitButtonAccessor ( $ id , $ relations , $ this -> con ) ; } | Find image submit button element . |
22,589 | public function findOption ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ OptionAccessor ( $ id , $ relations , $ this -> con ) ; } | Find select option element . |
22,590 | public function findPassword ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ PasswordAccessor ( $ id , $ relations , $ this -> con ) ; } | Find password element . |
22,591 | public function findRadio ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ RadioAccessor ( $ id , $ relations , $ this -> con ) ; } | Find radio button element . |
22,592 | public function findReset ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ ResetAccessor ( $ id , $ relations , $ this -> con ) ; } | Find reset button element . |
22,593 | public function findSelect ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ SelectAccessor ( $ id , $ relations , $ this -> con ) ; } | Find select element . |
22,594 | public function findSubmit ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ SubmitAccessor ( $ id , $ relations , $ this -> con ) ; } | Find submit element . |
22,595 | public function findTextarea ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ TextareaAccessor ( $ id , $ relations , $ this -> con ) ; } | Find textarea element . |
22,596 | public function findTextbox ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Form \ TextboxAccessor ( $ id , $ relations , $ this -> con ) ; } | Find textbox element . |
22,597 | public function findCell ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Table \ CellAccessor ( $ id , $ relations , $ this -> con ) ; } | Find table cell element . |
22,598 | public function findRow ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Table \ RowAccessor ( $ id , $ relations , $ this -> con ) ; } | Find table row element . |
22,599 | public function findTableHeader ( $ id = null , array $ relations = array ( ) ) { return new Accessor \ Table \ TableHeaderAccessor ( $ id , $ relations , $ this -> con ) ; } | Find table header element . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.