idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
25,100 | public function showAction ( $ groupName ) { $ acl = $ this -> get ( 'bacon_acl.service.authorization' ) ; if ( ! $ acl -> authorize ( 'groups' , 'show' ) ) { throw $ this -> createAccessDeniedException ( ) ; } $ group = $ this -> findGroupBy ( 'name' , $ groupName ) ; return $ this -> render ( 'FOSUserBundle:Group:show.html.twig' , array ( 'group' => $ group ) ) ; } | Show one group |
25,101 | public function editAction ( Request $ request , $ groupName ) { $ acl = $ this -> get ( 'bacon_acl.service.authorization' ) ; if ( ! $ acl -> authorize ( 'groups' , 'EDIT' ) ) { throw $ this -> createAccessDeniedException ( ) ; } $ group = $ this -> findGroupBy ( 'name' , $ groupName ) ; $ dispatcher = $ this -> get ( 'event_dispatcher' ) ; $ event = new GetResponseGroupEvent ( $ group , $ request ) ; $ dispatcher -> dispatch ( FOSUserEvents :: GROUP_EDIT_INITIALIZE , $ event ) ; if ( null !== $ event -> getResponse ( ) ) { return $ event -> getResponse ( ) ; } $ formFactory = $ this -> get ( 'fos_user.group.form.factory' ) ; $ form = $ formFactory -> createForm ( ) ; $ form -> setData ( $ group ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ groupManager = $ this -> get ( 'fos_user.group_manager' ) ; $ event = new FormEvent ( $ form , $ request ) ; $ dispatcher -> dispatch ( FOSUserEvents :: GROUP_EDIT_SUCCESS , $ event ) ; $ groupManager -> updateGroup ( $ group ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'message' , [ 'type' => 'success' , 'message' => sprintf ( 'The record has been %s successfully.' , 'updated' ) , ] ) ; if ( null === $ response = $ event -> getResponse ( ) ) { $ url = $ this -> generateUrl ( 'fos_user_group_show' , array ( 'groupName' => $ group -> getName ( ) ) ) ; $ response = new RedirectResponse ( $ url ) ; } $ dispatcher -> dispatch ( FOSUserEvents :: GROUP_EDIT_COMPLETED , new FilterGroupResponseEvent ( $ group , $ request , $ response ) ) ; return $ response ; } return $ this -> render ( 'FOSUserBundle:Group:edit.html.twig' , array ( 'form' => $ form -> createview ( ) , 'group_name' => $ group -> getName ( ) , 'group' => $ group , ) ) ; } | Edit one group show the edit form |
25,102 | public function deleteAction ( Request $ request , $ groupName ) { $ acl = $ this -> get ( 'bacon_acl.service.authorization' ) ; if ( ! $ acl -> authorize ( 'groups' , 'DELETE' ) ) { throw $ this -> createAccessDeniedException ( ) ; } $ group = $ this -> findGroupBy ( 'name' , $ groupName ) ; $ this -> get ( 'fos_user.group_manager' ) -> deleteGroup ( $ group ) ; $ response = new RedirectResponse ( $ this -> generateUrl ( 'fos_user_group_list' ) ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'message' , [ 'type' => 'success' , 'message' => 'The record has been remove successfully.' , ] ) ; $ dispatcher = $ this -> get ( 'event_dispatcher' ) ; $ dispatcher -> dispatch ( FOSUserEvents :: GROUP_DELETE_COMPLETED , new FilterGroupResponseEvent ( $ group , $ request , $ response ) ) ; return $ response ; } | Delete one group |
25,103 | protected function findGroupBy ( $ key , $ value ) { if ( ! empty ( $ value ) ) { $ group = $ this -> get ( 'fos_user.group_manager' ) -> { 'findGroupBy' . ucfirst ( $ key ) } ( $ value ) ; } if ( empty ( $ group ) ) { throw new NotFoundHttpException ( sprintf ( 'The group with "%s" does not exist for value "%s"' , $ key , $ value ) ) ; } return $ group ; } | Find a group by a specific property |
25,104 | public static function Ut1utc ( $ ut11 , $ ut12 , $ dut1 , & $ utc1 , & $ utc2 ) { $ big1 ; $ i ; $ iy ; $ im ; $ id ; $ js ; $ duts ; $ u1 ; $ u2 ; $ d1 ; $ dats1 ; $ d2 ; $ fd ; $ dats2 ; $ ddats ; $ us1 ; $ us2 ; $ du ; $ duts = $ dut1 ; $ big1 = ( $ ut11 >= $ ut12 ) ; if ( $ big1 ) { $ u1 = $ ut11 ; $ u2 = $ ut12 ; } else { $ u1 = $ ut12 ; $ u2 = $ ut11 ; } $ d1 = $ u1 ; $ dats1 = 0 ; for ( $ i = - 1 ; $ i <= 3 ; $ i ++ ) { $ d2 = $ u2 + ( double ) $ i ; if ( IAU :: Jd2cal ( $ d1 , $ d2 , $ iy , $ im , $ id , $ fd ) ) return - 1 ; $ js = IAU :: Dat ( $ iy , $ im , $ id , 0.0 , $ dats2 ) ; if ( $ js < 0 ) return - 1 ; if ( $ i == - 1 ) $ dats1 = $ dats2 ; $ ddats = $ dats2 - $ dats1 ; if ( abs ( $ ddats ) >= 0.5 ) { if ( $ ddats * $ duts >= 0 ) $ duts -= $ ddats ; if ( IAU :: Cal2jd ( $ iy , $ im , $ id , $ d1 , $ d2 ) ) return - 1 ; $ us1 = $ d1 ; $ us2 = $ d2 - 1.0 + $ duts / DAYSEC ; $ du = $ u1 - $ us1 ; $ du += $ u2 - $ us2 ; if ( $ du > 0 ) { $ fd = $ du * DAYSEC / ( DAYSEC + $ ddats ) ; $ duts += $ ddats * ( $ fd <= 1.0 ? $ fd : 1.0 ) ; } break ; } $ dats1 = $ dats2 ; } $ u2 -= $ duts / DAYSEC ; if ( $ big1 ) { $ utc1 = $ u1 ; $ utc2 = $ u2 ; } else { $ utc1 = $ u2 ; $ utc2 = $ u1 ; } return $ js ; } | - - - - - - - - - - i a u U t 1 u t c - - - - - - - - - - |
25,105 | protected function deliverContent ( Response $ response , $ type , $ hash , $ version , $ content ) { $ cachedAssetTimestamp = $ this -> assetCacheManager -> getCachedAssetTimestamp ( $ type , $ hash , $ version ) ; $ ifModifiedSince = - 1 ; if ( $ this -> isHeaderSetAndNotEmpty ( 'HTTP_IF_MODIFIED_SINCE' ) ) { $ ifModifiedSince = $ _SERVER [ 'HTTP_IF_MODIFIED_SINCE' ] ; } $ eTag = md5 ( $ content ) ; $ eTagHeader = - 1 ; if ( $ this -> isHeaderSetAndNotEmpty ( 'HTTP_IF_NONE_MATCH' ) ) { $ eTagHeader = $ _SERVER [ 'HTTP_IF_NONE_MATCH' ] ; } $ cacheTtl = 86400 * 365 ; header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' , $ cachedAssetTimestamp ) . ' GMT' ) ; header ( 'Expires: ' . gmdate ( "D, d M Y H:i:s" , time ( ) + $ cacheTtl ) . ' GMT' ) ; header ( 'Pragma: cache' ) ; header ( 'Etag: ' . $ eTag ) ; header ( 'Cache-Control: max-age=' . $ cacheTtl ) ; if ( $ cachedAssetTimestamp === $ ifModifiedSince || $ eTag === $ eTagHeader ) { header ( 'HTTP/1.1 304 Not Modified' ) ; exit ; } $ contentType = $ this -> getContentType ( $ type , $ version ) ; if ( $ contentType !== '' ) { header ( 'Content-type: ' . $ contentType , true ) ; } $ response -> setOutput ( $ content ) ; } | Adds the needed headers and prepares the content |
25,106 | protected function getContentType ( $ type , $ version ) { if ( $ type === 'css' ) { return 'text/css' ; } else if ( $ type === 'js' ) { return 'text/javascript' ; } else if ( $ type === 'image' ) { $ fileExtension = pathinfo ( $ version , PATHINFO_EXTENSION ) ; if ( $ fileExtension === 'svg' ) { return 'image/svg+xml' ; } else if ( $ fileExtension === 'jpg' ) { return 'image/jpeg' ; } else if ( $ fileExtension === 'gif' ) { return 'image/gif' ; } else if ( $ fileExtension === 'png' ) { return 'image/png' ; } } } | Returns the content type for the given asset type . |
25,107 | public function toString ( $ format = 'text' , $ relativeDir = NULL , $ relativeDirLabel = NULL ) { return self :: getExceptionText ( $ this , $ format , $ relativeDir , $ relativeDirLabel ) ; } | Returns a nicer string Representation for the Exception |
25,108 | public function execute ( ) { $ dic = $ this -> getDIC ( ) ; $ inputProcessor = $ dic -> make ( InputProcessor :: class ) ; $ requestProcessor = $ dic -> make ( RequestProcessor :: class ) ; $ response = $ dic -> make ( ResponseInterface :: class ) ; $ outputProcessor = $ dic -> make ( OutputProcessor :: class ) ; $ request = $ inputProcessor -> execute ( ) ; $ response = $ requestProcessor -> execute ( $ request , $ response ) ; $ outputProcessor -> execute ( $ response ) ; } | Process a web request using the designated InputProcessor RequestProcessor and OutputProcessor |
25,109 | public function execute ( $ params = array ( ) ) { if ( $ this -> entity instanceof OneToOneJoinInterface ) { if ( array_key_exists ( 'locale' , $ params ) ) { $ this -> getQueryBuilder ( ) -> where ( $ params [ 'locale' ] ) ; } $ this -> getQueryBuilder ( ) -> join ( $ this -> entity -> getJoinRelationships ( ) ) ; } $ this -> getQueryBuilder ( ) -> where ( $ params ) ; $ query = $ this -> getQueryBuilder ( ) -> getQuery ( $ this -> entity , QueryBuilder :: GET_ALL_ITEMS_QUERY , QueryBuilder :: PARENT_AND_CHILD ) ; $ result = $ this -> query ( $ query ) ; $ param = get_class ( $ this -> entity ) . 's' ; return array ( $ param => $ result , $ param . 'Count' => $ this -> getTotalRowCount ( ) ) ; } | retrieves a multiple rows from the database |
25,110 | public function getCode ( $ id = "" ) { switch ( $ this -> type ) { case Headers :: javascript : $ code = '<script id="' . $ id . '" type="text/javascript" src="' . $ this -> code . '"></script>' . "\n" ; break ; case Headers :: css : $ code = '<link id="' . $ id . '" href="' . $ this -> code . '" rel="stylesheet" type="text/css" />' . "\n" ; break ; case Headers :: jsCode : $ code = '<script id="' . $ id . '" type="text/javascript" >' . "\n" . $ this -> code . "\n</script>\n\n" ; break ; default : $ code = $ this -> code ; } return $ code ; } | Returns the string od this header . |
25,111 | public function has ( $ key , $ value = null ) { return CoreManager :: has ( $ this -> path , $ key , $ value ) ; } | Check the key exists |
25,112 | public function create ( $ key , $ value = null ) { if ( $ this -> check_path ( ) ) { return CoreManager :: create ( $ this -> path , $ key , $ value ) ; } return false ; } | Create a key with an value |
25,113 | public function sendShortMessage ( $ receivers , $ body = null ) { if ( ! $ receivers instanceof ShortMessage ) { $ receivers = $ this -> factory -> create ( $ receivers , $ body ) ; } if ( is_callable ( $ this -> beforeSingleShortMessageCallback ) ) { call_user_func_array ( $ this -> beforeSingleShortMessageCallback , [ $ receivers ] ) ; } $ response = $ this -> client -> sendShortMessage ( $ receivers ) ; if ( is_callable ( $ this -> afterSingleShortMessageCallback ) ) { call_user_func_array ( $ this -> afterSingleShortMessageCallback , [ $ response , $ receivers ] ) ; } return $ response ; } | Send the given body to the given receivers . |
25,114 | public function sendShortMessages ( $ messages ) { if ( ! $ messages instanceof ShortMessageCollection ) { $ collection = $ this -> collectionFactory -> create ( ) ; foreach ( $ messages as $ message ) { $ collection -> push ( $ this -> factory -> create ( $ message [ 'recipient' ] , $ message [ 'message' ] ) ) ; } $ messages = $ collection ; } if ( is_callable ( $ this -> beforeMultipleShortMessageCallback ) ) { call_user_func_array ( $ this -> beforeMultipleShortMessageCallback , [ $ messages ] ) ; } $ response = $ this -> client -> sendShortMessages ( $ messages ) ; if ( is_callable ( $ this -> afterMultipleShortMessageCallback ) ) { call_user_func_array ( $ this -> afterMultipleShortMessageCallback , [ $ response , $ messages ] ) ; } return $ response ; } | Send the given short messages . |
25,115 | public function MetaTags ( & $ tags ) { if ( $ code = GoogleAPI :: singleton ( ) -> getVerificationCode ( ) ) { if ( ! preg_match ( '/[\n]$/' , $ tags ) ) { $ tags .= "\n" ; } $ tags .= sprintf ( "<meta name=\"%s\" content=\"%s\" />\n" , self :: VERIFICATION_TAG_NAME , Convert :: raw2att ( $ code ) ) ; } } | Appends the additional Google tags to the provided meta tags . |
25,116 | protected function getFileIterator ( $ path , $ pattern = '/^.+\.php$/' ) { if ( is_dir ( $ path ) ) { return new \ RegexIterator ( new \ DirectoryIterator ( $ path ) , $ pattern , \ RegexIterator :: GET_MATCH ) ; } if ( is_file ( $ path ) && 1 === preg_match ( $ pattern , $ path ) ) { return [ new \ SplFileInfo ( $ path ) ] ; } return [ ] ; } | Get the iterator for specified config files . |
25,117 | public function findFromSession ( Session $ session ) { $ this -> addWhere ( 'user_email' , $ session -> get ( 'email' ) ) ; $ this -> addWhere ( 'user_id' , ( int ) $ session -> get ( 'id' ) ) ; $ this -> addWhere ( 'user_is_activated' , 1 ) ; try { $ user = $ this -> selectOne ( ) ; } catch ( ExceptionNoData $ exception ) { throw new LoginException ( 'Login and / or password is incorrect!' , 1000 , $ exception ) ; } return $ user ; } | Find user with data from Session . |
25,118 | public static function getOptions ( ) { $ options = [ ] ; $ options [ ] = [ 'id' => Operation :: PRODUCT_VISA , 'label' => "Visa" , ] ; $ options [ ] = [ 'id' => Operation :: PRODUCT_MASTERCARD , 'label' => "Mastercard" , ] ; $ options [ ] = [ 'id' => Operation :: PRODUCT_AMERICAN_EXPRESS , 'label' => "American Express" , ] ; $ options [ ] = [ 'id' => Operation :: PRODUCT_DINERS , 'label' => "Diners" , ] ; return $ options ; } | Payment options . |
25,119 | public static function requestStartTime ( $ test = false ) { if ( defined ( 'TIME_START' ) && $ test === false ) $ startTime = TIME_START ; elseif ( isset ( $ GLOBALS [ 'TIME_START' ] ) ) $ startTime = $ GLOBALS [ 'TIME_START' ] ; else $ startTime = env ( 'REQUEST_TIME' ) ; return $ startTime ; } | Get the time the current request started . |
25,120 | public function adm_get_safe_user_data ( ) { if ( ! $ this -> store_is_logged_in ( ) ) return [ AdminStoreError :: USER_NOT_LOGGED_IN ] ; $ data = $ this -> user_data ; foreach ( [ 'upass' , 'usalt' , 'sid' , 'token' , 'expire' ] as $ key ) unset ( $ data [ $ key ] ) ; return [ 0 , $ data ] ; } | Get user data excluding sensitive info . |
25,121 | public function attach ( EventManagerInterface $ events ) { $ this -> listeners [ ] = $ events -> attach ( ComposerEvent :: EVENT_HEADERS_POST , array ( $ this , 'injectOverrideHeaders' ) , - 100 ) ; } | Attach listener . |
25,122 | public function index ( Request $ request , Response $ response , array $ args ) { $ this -> request = $ request ; $ this -> response = $ response ; $ this -> args = $ args ; return $ this -> fire ( ) ; } | Setup the controller then run the fire method . |
25,123 | protected function success ( array $ data , $ code = 200 ) { $ this -> response -> setStatusCode ( $ code ) ; $ this -> response -> headers -> add ( [ 'Content-Type' => 'application/json' ] ) ; $ this -> response -> setContent ( json_encode ( [ 'success' => $ data ] , JSON_PRETTY_PRINT ) ) ; return $ this -> response ; } | Get a success response json . |
25,124 | protected function redirect ( $ url , $ code = 302 ) { $ this -> response -> setStatusCode ( $ code ) ; $ this -> response -> headers -> set ( 'Location' , $ url ) ; return $ this -> response ; } | Get a redirection response . |
25,125 | protected function raw ( $ data , $ mime , $ code = 200 ) { $ this -> response -> setStatusCode ( $ code ) ; $ this -> response -> headers -> add ( [ 'Content-Type' => $ mime ] ) ; $ this -> response -> setContent ( $ data ) ; return $ this -> response ; } | Get a custom response . |
25,126 | public function setFiles ( ) { $ this -> files = [ ] ; $ path = $ this -> getValue ( ) ; if ( ! preg_match ( '#^/#' , $ path ) ) { $ path = $ this -> parser -> getServer ( ) -> getPrefix ( ) . '/' . $ path ; } $ iterator = new GlobIterator ( $ path ) ; foreach ( $ iterator as $ path ) { $ this -> files [ ] = $ path ; } return $ this ; } | Detects and memoizes the included files . |
25,127 | public function compileFiles ( ) { foreach ( $ this -> files as $ file ) { $ activeConfig = $ this -> parser -> setConfigFile ( $ file ) -> getActiveConfig ( ) ; $ this -> add ( $ activeConfig ) ; } return $ this ; } | Fills the block directives by compiling the memoized files . |
25,128 | protected function compareParts ( array $ thisParts , array $ thatParts ) : int { $ compMajor = strnatcmp ( $ thisParts [ 0 ] , $ thatParts [ 0 ] ) ; if ( $ compMajor > 0 ) { return 1 ; } if ( $ compMajor < 0 ) { return - 1 ; } $ compMinor = strnatcmp ( $ thisParts [ 1 ] , $ thatParts [ 1 ] ) ; if ( $ compMinor > 0 ) { return 1 ; } if ( $ compMinor < 0 ) { return - 1 ; } if ( isset ( $ thisParts [ 2 ] ) && isset ( $ thatParts [ 2 ] ) ) { $ compSub = strnatcmp ( $ thisParts [ 2 ] , $ thatParts [ 2 ] ) ; return $ compSub <=> 0 ; } return 0 ; } | Compares two timezones by segments |
25,129 | public static function Apco ( $ date1 , $ date2 , array $ ebpv , array $ ehp , $ x , $ y , $ s , $ theta , $ elong , $ phi , $ hm , $ xp , $ yp , $ sp , $ refa , $ refb , iauASTROM & $ astrom ) { $ sl ; $ cl ; $ r = [ ] ; $ pvc = [ ] ; $ pv = [ [ ] , [ ] ] ; $ astrom -> along = $ elong + $ sp ; $ sl = sin ( $ astrom -> along ) ; $ cl = cos ( $ astrom -> along ) ; $ astrom -> xpl = $ xp * $ cl - $ yp * $ sl ; $ astrom -> ypl = $ xp * $ sl + $ yp * $ cl ; $ astrom -> sphi = sin ( $ phi ) ; $ astrom -> cphi = cos ( $ phi ) ; $ astrom -> refa = $ refa ; $ astrom -> refb = $ refb ; IAU :: Aper ( $ theta , $ astrom ) ; $ astrom -> diurab = 0.0 ; IAU :: C2ixys ( $ x , $ y , $ s , $ r ) ; IAU :: Pvtob ( $ elong , $ phi , $ hm , $ xp , $ yp , $ sp , $ theta , $ pvc ) ; IAU :: Trxpv ( $ r , $ pvc , $ pv ) ; IAU :: Apcs ( $ date1 , $ date2 , $ pv , $ ebpv , $ ehp , $ astrom ) ; IAU :: Cr ( $ r , $ astrom -> bpn ) ; } | - - - - - - - - i a u A p c o - - - - - - - - |
25,130 | public function setImplementation ( string $ className ) : Configuration { if ( ! \ is_subclass_of ( $ className , ACacheManager :: class ) ) { throw CacheException :: invalidImplementation ( $ className ) ; } $ this -> _implementation = $ className ; return $ this ; } | Sets the class name of the implementation of the cache manager that should be used on runtime . Consider that this class name has to extent the \ Gustav \ Cache \ ACacheManager class . Otherwise this method will throw an CacheException . |
25,131 | public function path ( $ type , $ path = null ) { $ instance = sprintf ( 'path.%s' , $ type ) ; $ base = $ this -> basePath ; if ( array_key_exists ( $ instance , $ this -> instances ) ) { $ base = $ this -> instances [ $ instance ] ; } $ key = sprintf ( 'paths.%s' , strtolower ( $ type ) ) ; $ base = config ( $ key , $ base ) ; if ( substr ( $ base , 0 , 2 ) == './' ) { $ base = $ this -> basePath . DIRECTORY_SEPARATOR . substr ( $ base , 2 ) ; } if ( $ base == $ this -> basePath ) { $ path = is_null ( $ path ) ? $ type : $ type . DIRECTORY_SEPARATOR . $ path ; } return is_null ( $ path ) ? $ base : $ base . DIRECTORY_SEPARATOR . $ path ; } | Return path of type . |
25,132 | protected function registerContainerBase ( ) { $ this -> singleton ( 'composer' , function ( $ app ) { return new Composer ( $ app -> make ( 'files' ) , $ this -> basePath ( ) ) ; } ) ; $ this -> singleton ( 'config' , function ( ) { return new ConfigRepository ( ) ; } ) ; $ this -> loadComponent ( 'filesystems' , '\Bugotech\Foundation\IO\FilesystemServiceProvider' , 'filesystem' ) ; $ this -> singleton ( 'log' , function ( ) { return new Logger ( 'netforce' , [ $ this -> getMonologHandler ( ) ] ) ; } ) ; $ this -> register ( '\Bugotech\Foundation\Console\ConsoleServiceProvider' ) ; $ this -> singleton ( 'cache' , function ( ) { return $ this -> loadComponent ( 'cache' , 'Illuminate\Cache\CacheServiceProvider' ) ; } ) ; $ this -> singleton ( 'cache.store' , function ( ) { return $ this -> loadComponent ( 'cache' , 'Illuminate\Cache\CacheServiceProvider' , 'cache.store' ) ; } ) ; $ this -> register ( '\Illuminate\Hashing\HashServiceProvider' ) ; $ this -> register ( '\Illuminate\Encryption\EncryptionServiceProvider' ) ; } | Register the core conteiner base structures . |
25,133 | public function apply ( $ condition , callable $ onMatch = null ) : self { if ( ! is_callable ( $ condition ) ) { if ( ! $ condition instanceof Condition ) { throw new \ InvalidArgumentException ( 'Expected a \nyx\diagnostics\Condition or a callable as first argument, got [' . diagnostics \ Debug :: getTypeName ( $ condition ) . '] instead.' ) ; } $ this -> conditions [ ] = $ condition ; } else { if ( null === $ onMatch ) { throw new \ InvalidArgumentException ( 'A callable must be given as second parameter when the first is also a callable.' ) ; } $ this -> conditions [ ] = [ 'matcher' => $ condition , 'onMatch' => $ onMatch ] ; } return $ this ; } | Applies a Condition to this Handler . |
25,134 | protected function runConditions ( \ Exception $ exception ) : bool { $ prevent = false ; foreach ( $ this -> conditions as $ condition ) { if ( $ condition instanceof Condition ) { if ( true === $ condition -> matches ( $ exception , $ this ) ) { $ response = $ condition -> onMatch ( $ exception , $ this ) ; } else { continue ; } } elseif ( true === call_user_func ( $ condition [ 'matcher' ] , $ exception , $ this ) ) { $ response = call_user_func ( $ condition [ 'onMatch' ] , $ exception , $ this ) ; } else { continue ; } if ( ( $ response & definitions \ Signals :: QUIT ) === definitions \ Signals :: QUIT && $ this -> allowQuit ) { exit ; } if ( ( $ response & definitions \ Signals :: PREVENT ) === definitions \ Signals :: PREVENT ) { $ prevent = true ; } if ( ( $ response & definitions \ Signals :: STOP ) === definitions \ Signals :: STOP ) { break ; } } return $ prevent ; } | Runs through the registered Conditions and invokes their callbacks when they match the given Exception . |
25,135 | protected function emitDebugEvent ( $ name , \ Throwable $ exception ) { if ( null === $ this -> emitter ) { return null ; } $ this -> emitter -> emit ( $ name , $ event = new Event ( $ exception , $ this ) ) ; return $ event -> getThrowable ( ) ; } | Helper method which emits a diagnostics \ events \ Debug event with the given name and the given initial Exception and returns the Exception set in the Event after emission is done . All of it assuming an Emitter is set for the Handler . False will be returned if that is not the case . |
25,136 | protected function checkStopped ( ) { if ( null === $ this -> data ) { throw new RuntimeException ( Message :: get ( Message :: SESSION_STOPPED ) , Message :: SESSION_STOPPED ) ; } } | Throw RuntimeException if stopped |
25,137 | public function getControllers ( array $ values ) { $ config = $ this -> getServiceLocator ( ) -> get ( 'Config' ) ; if ( ! isset ( $ config [ 'jaztec_admin' ] [ 'modules' ] [ 'controllers' ] [ 'paths' ] ) ) { return array ( ) ; } $ values [ 'paths' ] = $ config [ 'jaztec_admin' ] [ 'modules' ] [ 'controllers' ] [ 'paths' ] ; return $ this -> getFiles ( $ values [ 'paths' ] , 'controller' ) ; } | Scans the paths set in the KJSencha path loader to collect the controllers and scans them against the ACL returning only the controllers the user is allowed to use . |
25,138 | public function getViews ( array $ values ) { $ config = $ this -> getServiceLocator ( ) -> get ( 'Config' ) ; if ( ! isset ( $ values [ 'controller' ] ) ) { throw new Exception ( 'No controller data received.' ) ; } $ controller = $ values [ 'controller' ] ; if ( ! isset ( $ config [ 'jaztec_admin' ] [ 'modules' ] [ 'views' ] [ $ controller ] ) ) { return array ( ) ; } $ paths = $ config [ 'jaztec_admin' ] [ 'modules' ] [ 'views' ] [ $ controller ] [ 'paths' ] ; return $ this -> getFiles ( $ paths , 'view' ) ; } | Returns all views connected to a controller . |
25,139 | protected function getFiles ( array $ paths , $ aclNamespace ) { $ result = array ( ) ; $ object = '' ; foreach ( $ paths as $ namespace => $ path ) { foreach ( $ this -> rglob ( '*.js' , 0 , "$path/" ) as $ entry ) { $ entry = pathinfo ( $ entry ) ; $ extraNs = str_replace ( '/' , '.' , str_replace ( $ path , '' , $ entry [ 'dirname' ] ) ) ; $ object = $ namespace . $ extraNs . '.' . $ entry [ 'filename' ] ; if ( $ this -> checkAcl ( "extjs-$aclNamespace-" . $ object ) ) { $ result [ ] = $ object ; } } } return $ result ; } | Returns all the ExtJS objects in a given path and checks it against the ACL settings . |
25,140 | protected function rglob ( $ pattern = '*' , $ flags = 0 , $ path = '' ) { $ paths = glob ( $ path . '*' , GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT ) ; $ files = glob ( $ path . $ pattern , $ flags ) ; foreach ( $ paths as $ path ) { $ files = array_merge ( $ files , $ this -> rglob ( $ pattern , $ flags , $ path ) ) ; } return $ files ; } | Recursive glob function . |
25,141 | public function format ( $ xml ) { $ dom = new DOMDocument ( '1.0' ) ; $ dom -> preserveWhiteSpace = false ; $ dom -> formatOutput = true ; $ dom -> loadXML ( $ xml ) ; $ formatted = $ dom -> saveXML ( ) ; if ( ! $ formatted ) { throw new Exception ( "An error occurred while formatting the XML" ) ; } return $ formatted ; } | Return the XML with correct indentation . |
25,142 | protected function shutdownWorkers ( ) { $ workers = Resque_Worker :: all ( ) ; foreach ( $ workers as $ worker ) { list ( $ name , $ pid , $ queues ) = explode ( ':' , ( string ) $ worker ) ; posix_kill ( ( int ) $ pid , SIGQUIT ) ; } $ this -> output -> writeln ( '<info>SIGQUIT sent to ' . count ( $ workers ) . ' workers.</info>' ) ; } | Shutdown all workers |
25,143 | public function getAttribute ( $ sessionKey ) { return isset ( $ _SESSION [ $ this -> GetKey ( $ sessionKey ) ] ) ? $ _SESSION [ $ this -> GetKey ( $ sessionKey ) ] : false ; } | Get a value in current session from a given key . |
25,144 | public function setDeliveryAddressInfo ( Address $ address ) { $ this -> setDeliveryAddress ( $ address -> getAddress ( ) ) ; $ this -> setDeliveryPostalCode ( $ address -> getPostalCode ( ) ) ; $ this -> setDeliveryCity ( $ address -> getCity ( ) ) ; $ this -> setDeliveryState ( $ address -> getState ( ) ) ; $ this -> setDeliveryCountry ( $ address -> getCountry ( ) ) ; } | Set delivery address information |
25,145 | public function getDeliveryAddressInfo ( ) { $ address = new Address ( ) ; $ address -> setAddress ( $ this -> getDeliveryAddress ( ) ) ; $ address -> setPostalCode ( $ this -> getDeliveryPostalCode ( ) ) ; $ address -> setCity ( $ this -> getDeliveryCity ( ) ) ; $ address -> setState ( $ this -> getDeliveryState ( ) ) ; $ address -> setCountry ( $ this -> getDeliveryCountry ( ) ) ; return $ address ; } | Get delivery address information |
25,146 | public function validateDeliveryDni ( ExecutionContextInterface $ context ) { $ dni = $ this -> getDeliveryDni ( ) ; if ( is_null ( $ dni ) ) { return ; } if ( 0 === preg_match ( "/\d{1,8}[a-z]/i" , $ dni ) ) { $ context -> addViolationAt ( 'dni' , 'Invalid DNI number' ) ; return ; } $ number = substr ( $ dni , 0 , - 1 ) ; $ letter = strtoupper ( substr ( $ dni , - 1 ) ) ; if ( $ letter != substr ( "TRWAGMYFPDXBNJZSQVHLCKE" , strtr ( $ number , "XYZ" , "012" ) % 23 , 1 ) ) { $ context -> addViolationAt ( 'dni' , 'Invalid DNI letter' ) ; } } | Custom validator to check delivery Dni |
25,147 | public static function getString ( $ error ) { if ( ! is_int ( $ error ) ) { throw new \ BadMethodCallException ( "Invalid type, expected integer, got {$error}." ) ; } switch ( $ error ) { case PREG_NO_ERROR : return 'PREG_NO_ERROR' ; case PREG_INTERNAL_ERROR : return 'PREG_INTERNAL_ERROR' ; case PREG_BACKTRACK_LIMIT_ERROR : return 'PREG_BACKTRACK_LIMIT_ERROR' ; case PREG_BAD_UTF8_ERROR : return 'PREG_BAD_UTF8_ERROR' ; case PREG_RECURSION_LIMIT_ERROR : return 'PREG_RECURSION_LIMIT_ERROR' ; case PREG_BAD_UTF8_OFFSET_ERROR : return 'PREG_BAD_UTF8_OFFSET_ERROR' ; default : throw new \ BadMethodCallException ( "Tried to convert unknown PREG error {$error} to string" ) ; } } | Convert a PREG error message id to its string equivalent . |
25,148 | public function prepareArguments ( string $ id , array $ resolvingReferences ) { if ( ! isset ( $ this -> serviceArguments [ $ id ] ) ) $ this -> serviceArguments [ $ id ] = [ ] ; $ this -> serviceArguments [ $ id ] = array_merge ( $ this -> serviceArguments [ $ id ] , $ resolvingReferences ) ; } | Add arguments to entity before register it |
25,149 | public function handleEdit ( int $ id ) { if ( $ this -> presenter -> isAjax ( ) ) { $ this -> categoryId = $ id ; $ this -> onOpen ( ) ; } } | Handler pro editaci |
25,150 | public function init ( ) { foreach ( static :: defaultConfig ( ) as $ key => $ value ) { if ( ! isset ( $ this -> { $ key } ) ) { $ this -> { $ key } = $ value ; } } foreach ( static :: requiredConfig ( ) as $ key ) { if ( ! isset ( $ this -> { $ key } ) ) { throw new InvalidConfigException ( get_class ( $ this ) . " key provider requires '{$key}' config key" ) ; } } KeyProviderCollector :: internalRegisterProvider ( $ this ) ; } | Initializes the object and registers the provider |
25,151 | public function setMasterKeyPairProvider ( $ provider ) { if ( isset ( $ this -> masterKeyPairProvider ) ) { throw new InvalidCallException ( 'Setting read-only property: ' . get_class ( $ this ) . '::masterKeyPairProvider' ) ; } if ( is_array ( $ provider ) ) { $ provider = Yii :: createObject ( $ provider ) ; } $ this -> masterKeyPairProvider = $ provider ; } | Sets the master key pair provider for use in secure key pairs |
25,152 | protected function afterRetrieveKeyPair ( KeyPairInterface $ keyPair ) { if ( $ keyPair instanceof SecureKeyPairInterface ) { $ masterKeyPairProvider = $ this -> getMasterKeyPairProvider ( ) ; $ masterKeyName = $ this -> getMasterKeyName ( ) ; if ( $ masterKeyPairProvider === null || ! $ masterKeyPairProvider -> has ( $ masterKeyName ) ) { throw new InaccessibleKeyPairException ( 'Provider has an invalid master key provider specified for its secure keys' ) ; } $ masterKey = $ masterKeyPairProvider -> get ( $ masterKeyName ) ; $ keyPair -> unlock ( $ masterKey ) ; } return $ keyPair ; } | Process a key pair object after it was retrieved from the provider . Purpose is to unlock secure key pairs . |
25,153 | protected function afterGenerateKeyPair ( KeyPairInterface $ keyPair ) { if ( $ keyPair instanceof SecureKeyPairInterface ) { $ masterKeyPairProvider = $ this -> getMasterKeyPairProvider ( ) ; $ masterKeyName = $ this -> getMasterKeyName ( ) ; if ( $ masterKeyPairProvider === null ) { throw new InaccessibleKeyPairException ( 'Provider has an invalid master key provider specified for its secure keys' ) ; } if ( ! $ masterKeyPairProvider -> has ( $ masterKeyName ) ) { $ masterKey = $ masterKeyPairProvider -> generate ( $ masterKeyName ) ; } else { $ masterKey = $ masterKeyPairProvider -> get ( $ masterKeyName ) ; } $ keyPair -> lock ( $ masterKey ) ; } return $ keyPair ; } | Process a key pair object after it was generated |
25,154 | public function setId ( $ id ) { if ( isset ( $ this -> id ) ) { throw new InvalidCallException ( 'Setting read-only property: ' . get_class ( $ this ) . '::id' ) ; } $ this -> id = $ id ; } | Sets the provider ID |
25,155 | public function init ( $ config = [ ] ) { $ this -> initDefaults ( ) ; $ this -> initMail ( $ config ) ; $ this -> initLog ( $ config ) ; $ this -> initDatabase ( $ config ) ; $ this -> initRequest ( $ config ) ; $ this -> initRouter ( $ config ) ; $ this -> initSession ( $ config ) ; $ this -> initAppName ( $ config ) ; $ this -> initDefaultLanguage ( $ config ) ; } | Initialises the application . |
25,156 | protected function initDefaults ( ) { $ this -> bindShared ( 'RawPHP\RawDispatcher\Contract\IDispatcher' , function ( ) { return new Dispatcher ( ) ; } ) ; $ this -> bindShared ( 'RawPHP\RawFileSystem\Contract\IFileSystem' , function ( ) { return new FileSystem ( ) ; } ) ; $ this -> alias ( 'RawPHP\RawDispatcher\Contract\IDispatcher' , 'dispatcher' ) ; $ this -> alias ( 'RawPHP\RawFileSystem\Contract\IFileSystem' , 'files' ) ; } | Initialise default services . |
25,157 | protected function initMail ( array $ config ) { if ( isset ( $ config [ 'mail' ] ) ) { if ( isset ( $ config [ 'mail' ] [ 'class' ] ) ) { $ this -> bindShared ( 'RawPHP\RawMail\Contract\IMail' , function ( ) use ( $ config ) { $ class = $ config [ 'mail' ] [ 'class' ] ; return new $ class ( $ config ) ; } ) ; } else { $ this -> bindShared ( 'RawPHP\RawMail\Contract\IMail' , function ( ) use ( $ config ) { return new Mail ( $ config ) ; } ) ; } } else { $ this -> bindShared ( 'RawPHP\RawMail\Contract\IMail' , function ( ) { return new Mail ( ) ; } ) ; } $ this -> alias ( 'RawPHP\RawMail\Contract\IMail' , 'mail' ) ; } | Initialise the mail service . |
25,158 | protected function initLog ( array $ config ) { if ( isset ( $ config [ 'log' ] ) ) { if ( isset ( $ config [ 'log' ] [ 'class' ] ) ) { $ this -> bindShared ( 'RawPHP\RawLog\Contract\ILog' , function ( ) use ( $ config ) { $ class = $ config [ 'log' ] [ 'class' ] ; return new $ class ( $ config [ 'log' ] ) ; } ) ; } else { $ this -> bindShared ( 'RawPHP\RawLog\Contract\ILog' , function ( ) use ( $ config ) { return new Log ( $ config [ 'log' ] ) ; } ) ; } } else { $ this -> bindShared ( 'RawPHP\RawLog\Contract\ILog' , function ( ) { return new Log ( ) ; } ) ; } $ this -> alias ( 'RawPHP\RawLog\Contract\ILog' , 'log' ) ; } | Initialise the logger . |
25,159 | protected function initDatabase ( array $ config ) { if ( isset ( $ config [ 'db' ] ) ) { if ( isset ( $ config [ 'db' ] [ 'class' ] ) ) { $ this -> bindShared ( 'RawPHP\RawDatabase\Contract\IDatabase' , function ( ) use ( $ config ) { $ class = $ config [ 'db' ] [ 'class' ] ; return new $ class ( $ config [ 'db' ] ) ; } ) ; } else { $ this -> bindShared ( 'RawPHP\RawDatabase\Contract\IDatabase' , function ( ) use ( $ config ) { return new Database ( $ config [ 'db' ] ) ; } ) ; } } $ this -> alias ( 'RawPHP\RawDatabase\Contract\IDatabase' , 'db' ) ; } | Initialise the database . |
25,160 | protected function initRequest ( array $ config ) { if ( isset ( $ config [ 'request' ] ) ) { if ( isset ( $ config [ 'request' ] [ 'class' ] ) ) { $ this -> bindShared ( 'RawPHP\RawRequest\Contract\IRequest' , function ( ) use ( $ config ) { $ class = $ config [ 'request' ] [ 'class' ] ; return new $ class ( $ config [ 'request' ] ) ; } ) ; } else { $ this -> bindShared ( 'RawPHP\RawRequest\Contract\IRequest' , function ( ) use ( $ config ) { return new Request ( $ config [ 'request' ] ) ; } ) ; } } else { $ this -> bindShared ( 'RawPHP\RawRequest\Contract\IRequest' , function ( ) { $ request = new Request ( ) ; $ request -> init ( ) ; return $ request ; } ) ; } $ this -> alias ( 'RawPHP\RawRequest\Contract\IRequest' , 'request' ) ; } | Initialises the request instance . |
25,161 | protected function initRouter ( array $ config ) { if ( isset ( $ config [ 'router' ] ) ) { if ( isset ( $ config [ 'router' ] [ 'class' ] ) ) { $ this -> bindShared ( 'RawPHP\RawRouter\Contract\IRouter' , function ( ) use ( $ config ) { $ class = $ config [ 'router' ] [ 'class' ] ; return new $ class ( $ config [ 'router' ] ) ; } ) ; } else { $ this -> bindShared ( 'RawPHP\RawRouter\Contract\IRouter' , function ( ) use ( $ config ) { return new Router ( $ config [ 'router' ] ) ; } ) ; } } else { $ this -> bindShared ( 'RawPHP\RawRouter\Contract\IRouter' , function ( ) { return new Router ( ) ; } ) ; } $ this -> alias ( 'RawPHP\RawRouter\Contract\IRouter' , 'RawPHP\RawRouter\Router' ) ; $ this -> alias ( 'RawPHP\RawRouter\Contract\IRouter' , 'router' ) ; $ this [ 'router' ] -> setDispatcher ( $ this [ 'dispatcher' ] ) ; $ this -> defaultController = $ this [ 'router' ] -> getDefaultController ( ) ; $ this -> defaultAction = $ this [ 'router' ] -> getDefaultAction ( ) ; } | Initialises the router . |
25,162 | protected function initAppName ( array $ config ) { $ appName = 'Application' ; if ( isset ( $ config [ 'app' ] [ 'name' ] ) ) { $ appName = $ config [ 'app' ] [ 'name' ] ; } $ this -> appName = $ appName ; } | Initialises the application name . |
25,163 | protected function initDefaultLanguage ( array $ config ) { $ language = 'en_US' ; if ( isset ( $ config [ 'default_language' ] ) ) { $ language = $ config [ 'default_language' ] ; } $ this -> defaultLanguage = $ language ; } | Initialises the default language used in the app . |
25,164 | protected function processRequest ( ) { $ route = $ this [ 'request' ] -> getRoute ( ) ; $ params = $ this [ 'request' ] -> getParams ( ) ; $ controller = $ this [ 'router' ] -> createController ( $ route , $ params ) ; if ( NULL === $ controller ) { throw new RawException ( 'Failed to Initialise Controller' , 404 ) ; } $ this -> controller = $ controller ; $ controller -> run ( ) ; } | Processes the HTTP request . |
25,165 | public function createUrl ( $ route , $ params = [ ] , $ absolute = FALSE ) { return $ this [ 'request' ] -> createUrl ( $ route , $ params , $ absolute ) ; } | Creates a new url . |
25,166 | public function addFlash ( $ message , $ type = 'error' ) { if ( 'error' === $ type ) { $ this -> flash [ 'errors' ] [ ] = $ message ; } else { $ this -> flash [ 'success' ] [ ] = $ message ; } } | Adds a flash message to appear on the next page . |
25,167 | public function setDate ( \ DateTime $ date ) : void { $ this -> getFileElement ( ) -> setAttributeNS ( static :: XLIFF_NS , 'date' , $ date -> format ( \ DateTime :: ATOM ) ) ; } | Sets the last modification time in this file . |
25,168 | public function setSourceLanguage ( $ sourceLanguage ) : void { if ( ! preg_match ( '#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#' , $ sourceLanguage ) ) { throw new \ InvalidArgumentException ( 'Invalid language string: "' . $ sourceLanguage . '"' ) ; } $ this -> getFileElement ( ) -> setAttributeNS ( static :: XLIFF_NS , 'source-language' , $ sourceLanguage ) ; } | Set the source language for this file . |
25,169 | public function setTargetLanguage ( $ targetLanguage ) : void { if ( ! preg_match ( '#[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*#' , $ targetLanguage ) ) { throw new \ InvalidArgumentException ( 'Invalid language string: "' . $ targetLanguage . '"' ) ; } $ this -> getFileElement ( ) -> setAttributeNS ( static :: XLIFF_NS , 'target-language' , $ targetLanguage ) ; } | Set the target language for this file . |
25,170 | public function createTranslationUnit ( string $ identifier , string $ sourceValue = null ) : XmlElement { if ( null === $ body = $ this -> getXPathFirstItem ( '/xlf:xliff/xlf:file/xlf:body' ) ) { throw new \ InvalidArgumentException ( 'Could not find the xliff body element' ) ; } $ transUnit = $ this -> createElementNS ( self :: XLIFF_NS , 'trans-unit' ) ; $ body -> appendChild ( $ transUnit ) ; $ transUnit -> setAttributeNS ( self :: XLIFF_NS , 'id' , $ identifier ) ; $ source = $ transUnit -> appendChild ( $ this -> createElementNS ( self :: XLIFF_NS , 'source' ) ) ; if ( null !== $ sourceValue ) { $ source -> appendChild ( $ this -> createTextNode ( $ sourceValue ) ) ; } return $ transUnit ; } | Append a translation unit . |
25,171 | public function extractTranslationKeys ( ) : \ Generator { $ transUnits = $ this -> getXPath ( ) -> query ( '/xlf:xliff/xlf:file/xlf:body/xlf:trans-unit' ) ; if ( $ transUnits -> length > 0 ) { foreach ( $ transUnits as $ element ) { if ( '' === $ key = $ element -> getAttributeNS ( self :: XLIFF_NS , 'id' ) ) { throw new \ RuntimeException ( 'Empty Id: ' . var_export ( $ element , true ) ) ; } yield $ key ; } } } | Obtain all keys within the dictionary . |
25,172 | private function getXPathFirstItem ( $ query , $ contextNode = null ) { $ tmp = $ this -> getXPath ( ) -> query ( $ query , $ contextNode ) ; return $ tmp -> length ? $ tmp -> item ( 0 ) : null ; } | Perform a Xpath search with the given query and return the first match if found . |
25,173 | public function setupEnvironment ( Container $ container ) { $ env = new Environment ( $ container -> get ( 'Minty\\AbstractTemplateLoader' ) , $ this -> getConfiguration ( 'options' ) ) ; $ request = $ container -> get ( 'Miny\\HTTP\\Request' ) ; $ env -> addGlobalVariable ( 'is_ajax' , $ request -> isAjax ( ) ) ; $ env -> addGlobalVariable ( 'is_internal_request' , $ request -> isSubRequest ( ) ) ; $ env -> addExtension ( new Core ( ) ) ; $ env -> addExtension ( new Optimizer ( ) ) ; $ env -> addExtension ( $ container -> get ( __NAMESPACE__ . '\\Extensions\\Miny' ) ) ; if ( $ env -> getOption ( 'debug' ) ) { $ env -> addExtension ( new Debug ( ) ) ; if ( $ this -> getConfiguration ( 'enable_node_tree_visualizer' ) ) { $ env -> addExtension ( $ container -> get ( __NAMESPACE__ . '\\Extensions\\Visualizer' ) ) ; } } return $ env ; } | This method is responsible for initializing the Environment . Called by Container . |
25,174 | public function validateLocalPart ( $ value , $ send_errors = false ) { $ lengthValidator = new StringLengthValidator ( 0 , 64 ) ; try { if ( false === $ local_length_valid = $ lengthValidator -> validate ( $ value , false ) ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not be up to 64 characters!' , $ value ) ) ; } return false ; } } catch ( \ Exception $ e ) { throw $ e ; } if ( substr ( $ value , 0 , 1 ) == '.' ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not begin with a dot!' , $ value ) ) ; } return false ; } if ( substr ( $ value , - 1 , 1 ) == '.' ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not end with a dot!' , $ value ) ) ; } return false ; } if ( false !== strpos ( $ value , '..' ) ) { if ( true === $ send_errors ) { throw new \ Exception ( sprintf ( 'The local part of the email address [%s] must not contain double-dots!' , $ value ) ) ; } return false ; } $ last = 0 ; foreach ( self :: $ standards_list as $ standard ) { if ( 1 === $ last ) { continue ; } if ( $ standard == $ this -> must_pass ) { $ last = 1 ; } $ maskValidator = new StringMaskValidator ( '^' . $ this -> getMask ( $ standard ) . '$' , $ standard ) ; try { if ( false === $ local_part_mask_valid = $ maskValidator -> validate ( $ value , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } return true ; } | Process local part validation |
25,175 | public function validateDomainPart ( $ value , $ send_errors = false ) { if ( substr ( $ value , 0 , 1 ) == '[' && substr ( $ value , - 1 , 1 ) == ']' ) { $ ip_domain_part = substr ( $ value , 1 , strlen ( $ value ) - 2 ) ; if ( substr ( $ ip_domain_part , 0 , strlen ( 'IPv6:' ) ) == 'IPv6:' ) { $ ip6_domain_part = substr ( $ ip_domain_part , strlen ( 'IPv6:' ) ) ; $ ip6HostnameValidator = new InternetProtocolValidator ( 'v6' ) ; try { if ( false === $ ip6domain_name_valid = $ ip6HostnameValidator -> validate ( $ ip6_domain_part , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } else { $ ip4HostnameValidator = new InternetProtocolValidator ; try { if ( false === $ ip4domain_name_valid = $ ip4HostnameValidator -> validate ( $ ip_domain_part , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } } else { $ hostnameValidator = new HostnameValidator ; try { if ( false === $ hostdomain_name_valid = $ hostnameValidator -> validate ( $ value , $ send_errors ) ) { return false ; } } catch ( \ Exception $ e ) { throw $ e ; } } return true ; } | Process domain part validation |
25,176 | protected function getForeignKeyCheck ( $ enable = true ) { $ default = Config :: get ( 'database.default' ) ; switch ( $ default ) { case 'sqlite' : $ string = 'PRAGMA foreign_keys = ' . ( $ enable ? 'ON' : 'OFF' ) ; break ; default : $ string = 'SET FOREIGN_KEY_CHECKS = ' . ( $ enable ? '1' : '0' ) ; break ; } return $ string ; } | enable and disable foreign key constraints |
25,177 | protected function cleanDatabase ( array $ tables ) { DB :: statement ( $ this -> getForeignKeyCheck ( false ) ) ; foreach ( $ tables as $ table ) { if ( Schema :: hasTable ( $ table ) ) { DB :: table ( $ table ) -> truncate ( ) ; } } DB :: statement ( $ this -> getForeignKeyCheck ( true ) ) ; } | cleaning process of tables |
25,178 | protected function _delegateRenderTerm ( TermInterface $ term , $ context = null ) { try { $ childCtx = $ context ; $ childCtx [ ExprCtx :: K_EXPRESSION ] = $ term ; return $ this -> _getTermDelegateRenderer ( $ term , $ context ) -> render ( $ childCtx ) ; } catch ( OutOfRangeException $ outOfRangeException ) { $ this -> _throwRendererException ( $ this -> __ ( 'Could not find a delegate renderer for the given term.' ) , null , $ outOfRangeException ) ; } } | Delegates the rendering for the given term to another renderer . |
25,179 | private function scanNamespaceForPackages ( NamespaceInterface $ root , PackageInterface $ parent = null ) : Generator { foreach ( $ root -> iterateNamespaces ( ) as $ namespace ) { yield from $ this -> loadPackage ( $ namespace , $ parent ) ; } } | Finds all packages in a namespace . |
25,180 | private function loadPackage ( NamespaceInterface $ namespace , PackageInterface $ parent = null ) : Generator { $ package = new Package ( $ namespace , $ parent ) ; yield $ package ; if ( ! $ parent ) { yield from $ this -> findSubPackages ( $ package ) ; } } | Loads a package from a namespace . |
25,181 | private function findSubPackages ( PackageInterface $ package ) : Generator { $ readMes = new \ Symfony \ Component \ Finder \ Finder ( ) ; $ readMes -> files ( ) -> in ( $ package -> getPaths ( ) ) -> depth ( 1 ) -> name ( 'readme.md' ) ; if ( ! $ readMes -> count ( ) ) { return ; } yield from $ this -> scanNamespaceForPackages ( $ package , $ package ) ; } | Finds all sub - packages in a package . |
25,182 | public function DesignModule ( ) { $ module = $ this -> getModule ( ) ; if ( ! $ module ) { return ; } $ module -> loadRequirements ( ) ; $ viewer = SSViewer :: fromString ( $ module -> getTemplateContents ( ) ) ; return $ viewer -> process ( $ this -> toViewableData ( ) ) ; } | Renders the design module |
25,183 | public function getModule ( ) { if ( $ this -> owner -> DesignModule ) { return Green :: inst ( ) -> getDesignModule ( $ this -> owner -> DesignModule ) ; } return null ; } | Gets the design module that the DataObject is mapped to |
25,184 | public static function createTemporary ( ) { $ file = File :: createTemporary ( ) ; $ tempname = $ file -> getName ( ) ; $ file -> delete ( ) ; $ dir = $ file -> getDirectory ( ) -> sub ( $ tempname . '/' ) ; $ dir -> make ( ) ; return $ dir ; } | Creates a temporary Directory |
25,185 | public function wrapWith ( $ wrapperName , $ driveStyle = NULL ) { $ this -> wrapper = $ wrapperName ; $ this -> prefix = $ this -> wrapper . '://' . $ this -> getOSPrefix ( self :: UNIX , $ driveStyle ? : self :: WINDOWS_DRIVE_WINDOWS_STYLE ) ; return $ this ; } | Wraps the dir with the wrapper and converts windows paths |
25,186 | public function resolvePath ( ) { if ( count ( $ this -> path ) == 0 ) { return $ this ; } if ( $ this -> isRelative ( ) ) { $ cwd = self :: factory ( getcwd ( ) . DIRECTORY_SEPARATOR ) ; $ this -> prefix = $ cwd -> getPrefix ( $ this ) ; $ this -> path = array_merge ( $ cwd -> getPathArray ( ) , $ this -> path ) ; } $ newPath = array ( ) ; foreach ( $ this -> path as $ dir ) { if ( $ dir !== '.' ) { if ( $ dir == '..' ) { array_pop ( $ newPath ) ; } else { $ newPath [ ] = $ dir ; } } } $ this -> path = $ newPath ; return $ this ; } | Resolves relative parts of the path an normalizes |
25,187 | public function move ( Dir $ destination ) { $ ret = @ rename ( ( string ) $ this , ( string ) $ destination ) ; $ errInfo = 'Kann Verzeichnis ' . $ this . ' nicht nach ' . $ destination . ' verschieben / umbenennen.' ; if ( ! $ ret ) { if ( $ destination -> exists ( ) ) throw new Exception ( $ errInfo . ' Das Zielverzeichnis existiert.' ) ; if ( ! $ this -> exists ( ) ) throw new Exception ( $ errInfo . ' Das Quellverzeichnis existiert nicht.' ) ; else throw new Exception ( $ errInfo ) ; } $ this -> path = $ destination -> getPathArray ( ) ; return $ this ; } | Moves the directory and changes its internal state |
25,188 | public function make ( $ options = NULL ) { if ( is_int ( $ options ) ) { $ parent = ( $ options & self :: PARENT ) == self :: PARENT ; $ assert = ( $ options & self :: ASSERT_EXISTS ) == self :: ASSERT_EXISTS ; } else { $ parent = ( mb_strpos ( $ options , '-p' ) !== FALSE ) ; $ assert = FALSE ; } if ( ! $ this -> exists ( ) ) { $ ret = @ mkdir ( ( string ) $ this , $ this -> getDefaultMod ( ) , $ parent ) ; if ( $ ret == FALSE ) { throw new Exception ( 'Fehler beim erstellen des Verzeichnisses: ' . $ this ) ; } } else { if ( ! $ assert ) { throw new Exception ( 'Verzeichnis ' . $ this . ' kann nicht erstellt werden, da es schon existiert' ) ; } } return $ this ; } | Creates the Directory |
25,189 | public function getPath ( $ flags = 0x000000 ) { $ ds = $ this -> getDS ( ) ; $ trail = $ flags & self :: WITHOUT_TRAILINGSLASH ? '' : $ ds ; return $ this -> prefix . ( empty ( $ this -> path ) ? '' : implode ( $ ds , $ this -> path ) . $ trail ) ; } | Returns the Path as string |
25,190 | public function getOSPath ( $ os , $ flags = 0x000000 ) { $ osDS = $ this -> getOSDS ( $ os , $ flags ) ; return $ this -> getOSPrefix ( $ os , $ flags ) . ( empty ( $ this -> path ) ? '' : implode ( $ osDS , $ this -> path ) . $ osDS ) ; } | Returns the path of the directory converted to specific OS |
25,191 | protected function getOSPrefix ( $ os , $ flags = 0x000000 ) { $ letter = NULL ; if ( $ this -> isWindowsDrivePrefix ( $ letter ) ) { $ osPrefix = '' ; if ( ( $ flags & self :: WINDOWS_WITH_CYGWIN ) && $ os === self :: WINDOWS ) { $ osPrefix .= '/cygdrive/' . mb_strtolower ( $ letter ) . '/' ; } else { if ( ! ( $ flags & self :: WINDOWS_DRIVE_WINDOWS_STYLE ) && $ os === self :: UNIX ) { $ osPrefix .= '/' ; } $ osPrefix .= $ letter . ':' . $ this -> getOSDS ( $ os ) ; } } else { $ osPrefix = $ this -> prefix ; } return $ osPrefix ; } | Returns a prefix which is converted to the specific os |
25,192 | public function getOSDS ( $ os , $ flags = 0x000000 ) { return ( $ this -> isWrapped ( ) || $ this -> isCygwin ( ) || ( $ flags & self :: WINDOWS_WITH_CYGWIN ) || $ os === self :: UNIX ) ? '/' : '\\' ; } | Returns the DirectorySeperator for a specific operating system |
25,193 | public static function extract ( $ string ) { if ( mb_strlen ( $ string ) == 0 ) { throw new Exception ( 'String ist leer, kann kein Verzeichnis extrahieren' ) ; } $ path = dirname ( $ string ) . DIRECTORY_SEPARATOR ; try { $ dir = new Dir ( $ path ) ; } catch ( Exception $ e ) { throw new Exception ( 'kann kein Verzeichnis aus dem extrahierten Verzeichnis "' . $ path . '" erstellen: ' . $ e -> getMessage ( ) ) ; } return $ dir ; } | Extrahiert das Verzeichnis aus einer Angabe zu einer Datei |
25,194 | protected function extendsParents ( ReflectionClass $ reflectionClass ) { $ annotation = $ this -> parse ( $ reflectionClass -> getDocComment ( ) ) ; $ annotation [ 'class' ] = $ reflectionClass -> getName ( ) ; array_unshift ( $ this -> parentAnnotations , $ annotation ) ; if ( false !== $ reflectionClass -> getParentClass ( ) ) { $ this -> extendsParents ( $ reflectionClass -> getParentClass ( ) ) ; } } | Recursive reflection . |
25,195 | public function count ( ) : int { $ collection = $ this -> documentManager -> getCollection ( $ this -> documentClass ) ; return $ collection -> count ( $ this -> query ) ; } | Get the total hits of the current query . |
25,196 | public function getIterator ( ) : \ Iterator { $ hydrator = $ this -> documentManager -> newHydrator ( $ this -> hydrationMode ) ; $ query = clone $ this -> query ; if ( ! $ query -> hasParam ( '_source' ) ) { $ class = $ this -> documentManager -> getClassMetadata ( $ this -> documentClass ) ; $ query -> setSource ( $ class -> eagerFieldNames ) ; } if ( null !== $ this -> sort ) { $ query -> setSort ( $ this -> sort ) ; } if ( null !== $ this -> limit ) { $ query -> setSize ( $ this -> limit ) ; } if ( null !== $ this -> offset ) { $ query -> setFrom ( $ this -> offset ) ; } $ generator = null !== $ this -> cacheProfile ? $ this -> _doExecuteCached ( $ query ) : $ this -> _doExecute ( $ query ) ; foreach ( $ generator as $ resultSet ) { yield from $ hydrator -> hydrateAll ( $ resultSet , $ this -> documentClass ) ; } } | Iterate over the query results . |
25,197 | public function setSort ( $ fieldName , $ order = 'asc' ) : self { if ( null !== $ fieldName ) { $ sort = [ ] ; $ fields = is_array ( $ fieldName ) ? $ fieldName : [ $ fieldName => $ order ] ; foreach ( $ fields as $ fieldName => $ order ) { $ sort [ ] = [ $ fieldName => $ order ] ; } } else { $ sort = null ; } $ this -> sort = $ sort ; return $ this ; } | Sets the sort fields and directions . |
25,198 | public function useResultCache ( string $ cacheKey = null , int $ ttl = 0 ) : self { if ( null === $ cacheKey ) { $ this -> cacheProfile = null ; } else { $ this -> cacheProfile = new SearchCacheProfile ( $ cacheKey , $ ttl ) ; } return $ this ; } | Instructs the executor to use a result cache . |
25,199 | private function _doExecute ( Query $ query ) { $ collection = $ this -> documentManager -> getCollection ( $ this -> documentClass ) ; if ( $ this -> isScroll ( ) ) { $ scroll = $ collection -> scroll ( $ query ) ; foreach ( $ scroll as $ resultSet ) { yield $ resultSet ; } } else { yield $ collection -> search ( $ query ) ; } } | Executes the search action yield all the result sets . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.