idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
19,300 | public function getEntityPayments ( $ startDate , $ endDate ) { $ requestInterval = new Structure \ RequestInterval ( $ startDate , $ endDate ) ; $ this -> response = parent :: getEntityPayments ( $ this -> entity , $ requestInterval ) ; if ( Exception \ IntegrationState :: check ( $ this -> response -> integrationState ) ) { throw new Exception \ IntegrationState ( $ this -> response -> integrationState ) ; } return $ this -> response ; } | Calls the PayPay Webservice to obtain a list of payments whose state was updated in the given interval . |
19,301 | public function checkEntityPayments ( $ payments = array ( ) ) { $ requestReferenceDetails = new Structure \ RequestEntityPayments ( ) ; if ( $ payments ) { foreach ( $ payments as $ key => $ value ) { $ requestPayment = new Structure \ RequestReferenceDetails ( $ value ) ; $ requestReferenceDetails -> addPayment ( $ requestPayment ) ; } } $ this -> response = parent :: checkEntityPayments ( $ this -> entity , $ requestReferenceDetails ) ; if ( Exception \ IntegrationState :: check ( $ this -> response -> state ) ) { throw new Exception \ IntegrationState ( $ this -> response -> state ) ; } if ( $ this -> response -> state -> state == 0 ) { throw new Exception \ IntegrationResponse ( $ this -> response -> state -> message , $ this -> response -> state -> code ) ; } return $ this -> response ; } | Calls the PayPay Webservice to check the state of multiple payments . |
19,302 | public static function getDependence ( FileManager $ fileManager ) { if ( null === self :: $ serviceManager ) { $ config = self :: findConfigFile ( $ fileManager ) ; try { self :: $ serviceManager = Application :: init ( $ fileManager -> includeFile ( $ config ) ) -> getServiceManager ( ) ; } catch ( RuntimeException $ e ) { throw new EnvironnementResolverException ( $ e -> getMessage ( ) ) ; } catch ( ExceptionInterface $ e ) { throw new EnvironnementResolverException ( sprintf ( '%s. Config loaded %s' , $ e -> getMessage ( ) , $ config ) ) ; } } return self :: $ serviceManager ; } | Check if we are in zf2 env |
19,303 | function collect_non_deterministic ( Grammar $ Grammar , $ k ) { if ( isset ( $ this -> etransitions ) ) { return ; } $ this -> etransitions = array ( ) ; foreach ( $ Grammar -> get_rules ( $ this -> nt ) as $ r => $ rule ) { $ Item = LRItem :: make ( $ r , $ rule , 0 ) ; if ( isset ( $ this -> la ) && $ k === 1 ) { $ Item -> lookahead ( $ this -> la ) ; } $ State = LRState :: make ( $ Item ) ; $ State -> collect_non_deterministic ( $ Grammar , $ k ) ; $ this -> etransitions [ ] = $ State ; } } | Start recursive collection of e - transtions to states |
19,304 | function collect_states ( Grammar $ Grammar ) { $ states = array ( ) ; $ this -> collect_states_recursive ( $ states , $ Grammar , array ( ) , ++ self :: $ threadInc ) ; return $ states ; } | Collect all child states passing through any e - transitions to further stations |
19,305 | static function make ( $ nt , $ la = null ) { if ( isset ( self :: $ uindex [ $ nt ] [ $ la ] ) ) { return self :: $ uindex [ $ nt ] [ $ la ] ; } return new LRStation ( $ nt , $ la ) ; } | Factory method to ensure unique object instances globally And stored in global index in an accessible way |
19,306 | static function get ( $ nt , $ la = null ) { if ( isset ( self :: $ uindex [ $ nt ] [ $ la ] ) ) { return self :: $ uindex [ $ nt ] [ $ la ] ; } return null ; } | Getter method that consults global index |
19,307 | function get_args ( array $ consts , array $ vars ) { $ args = array ( ) ; $ argnodes = $ this -> get_nodes_by_symbol ( NT_ARG , 3 ) ; foreach ( $ argnodes as $ i => $ arg ) { $ args [ ] = $ arg -> compile_string ( $ consts , $ vars ) ; } return $ args ; } | Fetch full resolved arguments . |
19,308 | public static function getInstance ( ContextInterface $ context ) { $ fileManager = new FileManager ( ) ; $ historyHydrator = HistoryHydratorFactory :: getInstance ( $ context ) ; return new HistoryManager ( $ fileManager , $ historyHydrator ) ; } | Create HistoryManager instance |
19,309 | static function make ( array $ grammar , $ class = __CLASS__ ) { $ Me = new $ class ; foreach ( $ grammar as $ nt => $ rhss ) { foreach ( $ rhss as $ rhs ) { $ Me -> make_rule ( $ nt , $ rhs ) ; } } return $ Me ; } | Convert a hard - coded grammar into a Grammar instance |
19,310 | private static function rule_signature ( $ lhs , array $ rhs ) { $ a [ ] = $ lhs ; foreach ( $ rhs as $ t ) { $ a [ ] = $ t ; } return implode ( '.' , $ a ) ; } | Create a signature to identify a rule uniquely |
19,311 | function make_rule ( $ nt , array $ rhs ) { if ( ! isset ( $ this -> uindex ) || ! isset ( $ this -> ntindex ) ) { $ this -> rebuild_index ( ) ; } if ( end ( $ rhs ) === P_EOF ) { $ this -> goal = $ nt ; $ this -> rules [ - 2 ] = array ( P_GOAL , array ( $ nt ) ) ; $ this -> rebuild_index ( ) ; } else if ( is_null ( $ this -> start_symbol ( ) ) ) { $ this -> start_symbol ( $ nt ) ; } reset ( $ rhs ) ; $ sig = self :: rule_signature ( $ nt , $ rhs ) ; if ( isset ( $ this -> uindex [ $ sig ] ) ) { return $ this -> rules [ $ this -> uindex [ $ sig ] ] ; } $ rule = array ( $ nt , $ rhs ) ; $ this -> rules [ $ this -> i ] = $ rule ; $ this -> uindex [ $ sig ] = $ this -> i ; $ this -> ntindex [ $ nt ] [ ] = $ this -> i ; $ this -> i += 2 ; if ( isset ( $ this -> ts [ $ nt ] ) ) { unset ( $ this -> ts [ $ nt ] ) ; } $ this -> nts [ $ nt ] = $ nt ; foreach ( $ rhs as $ s ) { is_array ( $ s ) and $ s = $ s [ 0 ] ; if ( ! isset ( $ this -> nts [ $ s ] ) ) { $ this -> ts [ $ s ] = $ s ; } } return $ rule ; } | Factory method ensures unique rules |
19,312 | function remove_rules ( $ nt ) { if ( ! isset ( $ this -> ntindex ) ) { $ this -> rebuild_index ( ) ; } if ( isset ( $ this -> ntindex [ $ nt ] ) ) { foreach ( $ this -> ntindex [ $ nt ] as $ i ) { $ sig = self :: rule_signature ( $ nt , $ this -> rules [ $ i ] [ 1 ] ) ; unset ( $ this -> rules [ $ i ] ) ; unset ( $ this -> uindex [ $ sig ] ) ; } } unset ( $ this -> nts [ $ nt ] , $ this -> ntindex [ $ nt ] ) ; } | Remove a non - terminal symbol and delete all of its rules . |
19,313 | private function build_first_sets ( ) { $ firsts = array ( ) ; do { $ changes = 0 ; foreach ( $ this -> rules as $ rule ) { list ( $ nt , $ rhs ) = $ rule ; $ s = reset ( $ rhs ) ; do { if ( $ this -> is_terminal ( $ s ) ) { if ( ! isset ( $ firsts [ $ nt ] [ $ s ] ) ) { $ firsts [ $ nt ] [ $ s ] = $ s ; $ changes ++ ; } continue 2 ; } if ( ! isset ( $ firsts [ $ s ] ) ) { $ changes ++ ; continue 2 ; } $ derives_e = isset ( $ firsts [ $ s ] [ P_EPSILON ] ) ; foreach ( $ firsts [ $ s ] as $ t ) { if ( $ t !== P_EPSILON && ! isset ( $ firsts [ $ nt ] [ $ t ] ) ) { $ firsts [ $ nt ] [ $ t ] = $ t ; $ changes ++ ; } } } while ( $ derives_e && $ s = next ( $ rhs ) ) ; } } while ( $ changes > 0 ) ; return $ firsts ; } | Generate FIRST sets for each non - terminal . |
19,314 | private function build_follow_sets ( ) { if ( ! isset ( $ this -> firsts ) ) { $ this -> firsts = $ this -> build_first_sets ( ) ; } $ follows = array ( P_GOAL => array ( ) , P_EOF => array ( ) ) ; do { $ changes = 0 ; foreach ( $ this -> rules as $ rule ) { list ( $ s , $ rhs ) = $ rule ; while ( $ a = current ( $ rhs ) ) { if ( $ a === P_EPSILON ) { next ( $ rhs ) ; continue ; } if ( false === next ( $ rhs ) ) { if ( ! isset ( $ follows [ $ s ] ) ) { continue 2 ; } foreach ( $ follows [ $ s ] as $ t ) { if ( ! isset ( $ follows [ $ a ] [ $ t ] ) ) { $ follows [ $ a ] [ $ t ] = $ t ; $ changes ++ ; } } continue 2 ; } $ r = array_slice ( $ rhs , key ( $ rhs ) ) ; while ( $ b = current ( $ r ) ) { $ fs = $ this -> is_terminal ( $ b ) ? array ( $ b ) : $ this -> firsts [ $ b ] ; foreach ( $ fs as $ t ) { if ( ! isset ( $ follows [ $ a ] [ $ t ] ) && $ t !== P_EPSILON ) { $ follows [ $ a ] [ $ t ] = $ t ; $ changes ++ ; } } if ( ! isset ( $ fs [ P_EPSILON ] ) ) { break ; } if ( false === next ( $ r ) ) { if ( ! isset ( $ follows [ $ s ] ) ) { continue 3 ; } foreach ( $ follows [ $ s ] as $ t ) { if ( ! isset ( $ follows [ $ a ] [ $ t ] ) ) { $ follows [ $ a ] [ $ t ] = $ t ; $ changes ++ ; } } } } } } } while ( $ changes ) ; return $ follows ; } | Generate FOLLOW sets for each non - terminal . |
19,315 | public function extract ( callable $ callback = null ) { $ this -> response = Di :: getDefault ( ) -> get ( 'response' ) ; if ( $ callback === null ) { $ this -> response -> setContent ( json_encode ( $ this -> result -> toArray ( ) ) ) ; } else { $ this -> response -> setContent ( $ callback ( json_encode ( $ this -> result -> toArray ( ) ) ) ) ; } $ this -> response -> send ( ) ; } | Extract result data to json |
19,316 | protected function matches ( $ other ) : bool { $ this -> resetProblems ( ) ; if ( ! ( $ other instanceof EventSubscriberInterface ) ) { $ this -> addProblem ( 'Subscriber must implement \Symfony\Component\EventDispatcher\EventSubscriberInterface.' ) ; return false ; } $ subscribedEvents = call_user_func ( array ( get_class ( $ other ) , 'getSubscribedEvents' ) ) ; if ( ! is_array ( $ subscribedEvents ) ) { $ this -> addProblem ( 'getSubscribedEvents() must return an array.' ) ; return false ; } foreach ( $ subscribedEvents as $ event => $ subscription ) { $ this -> checkListener ( $ other , $ event , $ subscription ) ; } return ! $ this -> hasProblems ( ) ; } | Checks if the given object is an event subscriber . |
19,317 | protected function checkListener ( EventSubscriberInterface $ subscriber , $ event , $ listener ) { if ( is_string ( $ listener ) ) { $ listener = array ( $ listener , 0 ) ; } if ( ! is_array ( $ listener ) ) { $ this -> addProblem ( sprintf ( 'Listener definition for event "%s" must be an array or a string.' , $ event ) ) ; return ; } if ( $ this -> containsSeveralSubscriptions ( $ listener ) ) { foreach ( $ listener as $ subListener ) { $ this -> checkListener ( $ subscriber , $ event , $ subListener ) ; } return ; } if ( count ( $ listener ) === 1 ) { $ listener [ ] = 0 ; } if ( count ( $ listener ) !== 2 ) { $ message = 'Listener definition for event "%s" must consist of a method and a priority, but received: %s' ; $ this -> addProblem ( sprintf ( $ message , $ event , $ this -> exporter -> export ( $ listener ) ) ) ; return ; } list ( $ method , $ priority ) = $ listener ; $ this -> checkMethod ( $ subscriber , $ event , $ method ) ; $ this -> checkPriority ( $ event , $ priority ) ; } | Checks if the listener definition for the given event is valid . |
19,318 | protected function checkMethod ( $ subscriber , $ event , $ method ) { if ( ! is_string ( $ method ) ) { $ message = 'Listener definition for event "%s" contains an invalid method reference: %s' ; $ this -> addProblem ( sprintf ( $ message , $ event , $ this -> exporter -> export ( $ method ) ) ) ; return ; } if ( ! method_exists ( $ subscriber , $ method ) ) { $ message = 'Listener definition for event "%s" references method "%s", ' . 'but the method does not exist on subscriber.' ; $ this -> addProblem ( sprintf ( $ message , $ event , $ method ) ) ; return ; } if ( ! is_callable ( array ( $ subscriber , $ method ) ) ) { $ message = 'Listener definition for event "%s" references method "%s", ' . 'but the method is not publicly accessible.' ; $ this -> addProblem ( sprintf ( $ message , $ event , $ method ) ) ; return ; } } | Checks the given subscriber method . |
19,319 | protected function checkPriority ( $ event , $ priority ) { if ( ! is_int ( $ priority ) ) { $ message = 'Priority for event "%s" must be an integer, but received: %s' ; $ this -> addProblem ( sprintf ( $ message , $ event , $ this -> exporter -> export ( $ priority ) ) ) ; return ; } } | Checks the given priority . |
19,320 | public function isIgnoredDomain ( $ domain ) { if ( $ ignoreRegexes = $ this -> config ( ) -> get ( 'ignore_domain_regexes' ) ) { foreach ( $ ignoreRegexes as $ ignore ) { if ( preg_match ( $ ignore , $ domain ) > 0 ) { return true ; } } } return false ; } | Check if the given domain is on the list of ignored domains . |
19,321 | public function process ( HTTPRequest $ request , callable $ delegate ) { $ response = $ delegate ( $ request ) ; if ( $ this -> shouldCheckHttpHost ( ) && $ this -> isIgnoredDomain ( $ _SERVER [ 'HTTP_HOST' ] ) ) { return $ response ; } foreach ( $ this -> requestedPolicies as $ requestedPolicy ) { $ policyInstance = $ requestedPolicy [ 'policy' ] ; $ policyInstance -> applyToResponse ( $ requestedPolicy [ 'originator' ] , $ request , $ response ) ; } return $ response ; } | Apply all the requested policies . |
19,322 | public function _message ( $ type , $ message ) { $ context = $ this -> _context ; $ cssClasses = isset ( $ this -> _cssClasses [ $ type ] ) ? $ this -> _cssClasses [ $ type ] : '' ; $ context -> messages [ ] = '<div class="' . $ cssClasses . '">' . $ message . '</div>' . PHP_EOL ; } | Outputs a message |
19,323 | protected function _updateAcl ( \ Cms \ Orm \ CmsCategoryAclRecord $ aclRecord ) { foreach ( $ this -> _getChildrenCategoryIds ( $ aclRecord -> cmsCategoryId ) as $ categoryId ) { $ aclRecord -> access == 'allow' ? $ this -> _acl -> allow ( $ aclRecord -> getJoined ( 'cms_role' ) -> name , $ categoryId ) : $ this -> _acl -> deny ( $ aclRecord -> getJoined ( 'cms_role' ) -> name , $ categoryId ) ; } } | Aktualizuje ustawienie ACL |
19,324 | static function import_php ( $ package , $ silent = false ) { $ type = current ( explode ( '.' , $ package ) ) ; $ paths = self :: collect_package ( $ package , 'php' , $ silent , 'conf' ) ; if ( ! $ silent && empty ( $ paths ) ) { trigger_error ( "Bad import `$package'" , E_USER_ERROR ) ; } foreach ( $ paths as $ cname => $ path ) { if ( $ silent ) { include_once $ path ; continue ; } require_once $ path ; switch ( $ type ) { case 'conf' : break ; default : if ( ! function_exists ( $ cname ) && ! class_exists ( $ cname ) ) { trigger_error ( "Class, or function '$cname' not defined in file `$path'" , E_USER_ERROR ) ; } } } } | Import PHP classes and functions into the runtime environment |
19,325 | static function collect_package ( $ package , $ ext , $ silent , $ confname ) { $ cachekey = $ package . '.' . $ ext ; if ( isset ( self :: $ dircache [ $ cachekey ] ) ) { return self :: $ dircache [ $ cachekey ] ; } $ apath = explode ( '.' , $ package ) ; $ type = $ apath [ 0 ] ; $ cname = array_pop ( $ apath ) ; switch ( $ type ) { case 'conf' : $ ext = 'conf.php' ; break ; } switch ( $ ext ) { case 'js' : $ dpath = PLUG_VIRTUAL_DIR . '/plug/js/' . implode ( '/' , $ apath ) ; break ; case 'conf.php' : $ apath [ 0 ] = $ confname ; default : $ dpath = PLUG_HOST_DIR . '/' . implode ( '/' , $ apath ) ; } $ incs = array ( ) ; switch ( $ cname ) { case '' : case '*' : if ( ! $ silent && ! self :: check_dir ( $ dpath ) ) { break ; } $ dhandle = opendir ( $ dpath ) ; while ( $ f = readdir ( $ dhandle ) ) { if ( $ f { 0 } === '.' ) { continue ; } $ i = strpos ( $ f , ".$ext" ) ; if ( $ i ) { if ( substr ( $ f , 0 , 2 ) === '__' ) { continue ; } $ cname = substr_replace ( $ f , '' , $ i ) ; $ incs [ $ cname ] = "$dpath/$f" ; } } closedir ( $ dhandle ) ; break ; default : $ path = "$dpath/$cname.$ext" ; if ( ! $ silent && ! self :: check_file ( $ path ) ) { break ; } $ incs [ $ cname ] = $ path ; } self :: $ dircache [ $ cachekey ] = $ incs ; return $ incs ; } | Collect files from import argument |
19,326 | static function collect_files ( $ dpath , $ r = false , $ match = null , $ ignore = null ) { $ paths = array ( ) ; $ dhandle = opendir ( $ dpath ) ; while ( $ f = readdir ( $ dhandle ) ) { if ( $ f === '.' || $ f === '..' ) { continue ; } if ( isset ( $ ignore ) && preg_match ( $ ignore , $ f ) ) { continue ; } $ path = $ dpath . '/' . $ f ; if ( is_dir ( $ path ) ) { if ( $ r ) { $ paths = array_merge ( $ paths , self :: collect_files ( $ path , true , $ match , $ ignore ) ) ; } } else if ( isset ( $ match ) && ! preg_match ( $ match , $ f ) ) { continue ; } else { $ paths [ ] = $ path ; } } closedir ( $ dhandle ) ; return $ paths ; } | Collect files from a directory |
19,327 | static function check_file ( $ path , $ w = false , $ isdir = false ) { $ strtype = $ isdir ? 'Directory' : 'File' ; if ( ! file_exists ( $ path ) ) { trigger_error ( "$strtype not found; `$path'" , E_USER_NOTICE ) ; return false ; } if ( $ isdir && ! is_dir ( $ path ) ) { trigger_error ( "Not a directory; `$path'" , E_USER_NOTICE ) ; return false ; } if ( ! $ isdir && ! is_file ( $ path ) ) { trigger_error ( "Not a file; `$path'" , E_USER_NOTICE ) ; return false ; } if ( ! is_readable ( $ path ) ) { trigger_error ( "$strtype not readable by `" . trim ( `whoami` ) . "'; `$path'" , E_USER_NOTICE ) ; return false ; } if ( $ w && ! is_writeable ( $ path ) ) { trigger_error ( "$strtype not writeable by `" . trim ( `whoami` ) . "'; `$path'" , E_USER_NOTICE ) ; return false ; } return true ; } | Utility function to check resource can be read . - Include paths will not be evaluated . - E_USER_NOTICE raised on failure . |
19,328 | static function map_deployment_virtual ( $ path ) { if ( strpos ( $ path , PLUG_VIRTUAL_DIR ) !== 0 ) { if ( strpos ( $ path , PLUG_HOST_DIR ) === 0 ) { $ len = strlen ( PLUG_HOST_DIR ) + 1 ; $ subpath = substr_replace ( $ path , '' , 0 , $ len ) ; } else { $ subpath = md5 ( dirname ( $ path ) ) . '/' . basename ( $ path ) ; } return '/plug/inc/' . $ subpath ; } return str_replace ( PLUG_VIRTUAL_DIR , '' , $ path ) ; } | Map source file location to a virtual path under document root . |
19,329 | public function getRelationFiles ( ) { $ filesByObject = new \ Mmi \ Orm \ RecordCollection ; foreach ( $ this -> getAttributeValues ( ) as $ record ) { if ( $ record -> getJoined ( 'cms_attribute_type' ) -> uploader ) { foreach ( \ Cms \ Orm \ CmsFileQuery :: byObject ( $ record -> value , $ this -> _objectId ) -> find ( ) as $ file ) { $ filesByObject -> append ( $ file ) ; } } } return $ filesByObject ; } | Pobiera wszystkie rekordy plikowe |
19,330 | public function setCsv ( array & $ data , $ detectHead = true ) { $ handle = self :: createMemoryHandle ( ) ; if ( $ detectHead && count ( $ data ) > 0 ) { fputcsv ( $ handle , array_keys ( $ data [ 0 ] ) , $ this -> delimiter , $ this -> enclosure ) ; } foreach ( $ data as $ row ) { fputcsv ( $ handle , $ row , $ this -> delimiter , $ this -> enclosure ) ; } rewind ( $ handle ) ; $ output = chr ( 255 ) . chr ( 254 ) . mb_convert_encoding ( 'sep=' . $ this -> delimiter . "\n" . stream_get_contents ( $ handle ) , self :: UTF_16_LE , $ this -> encodingFrom ) ; $ this -> setData ( $ output ) ; fclose ( $ handle ) ; } | Generate CSV list |
19,331 | public function setType ( $ type ) { switch ( $ type ) { case self :: TYPE_CSV : $ this -> headers -> add ( array ( 'Content-Type' => 'text/csv;charset=' . self :: UTF_16_LE ) ) ; break ; case self :: TYPE_XLS : $ this -> headers -> add ( array ( "Content-Type" => "application/vnd.ms-excel" ) ) ; break ; } $ this -> type = $ type ; } | Set export type |
19,332 | public function setFileName ( $ fileName ) { $ this -> fileName = $ fileName ; $ this -> headers -> add ( array ( 'Content-Disposition' => 'attachment; filename="' . $ this -> fileName . '"' ) ) ; return $ this ; } | Set export file name |
19,333 | function collect_symbols ( ) { if ( ! $ this -> length ) { return null ; } $ Rule = $ this -> reset ( ) ; do { if ( $ Rule -> length !== 6 ) { continue ; } $ Name = $ Rule -> get_child ( 1 ) ; $ n = $ Name -> evaluate ( ) ; $ nts [ $ n ] = $ n ; if ( is_null ( $ this -> startsymbol ) ) { $ this -> startsymbol = $ n ; } $ Expr = $ Rule -> get_child ( 4 ) ; $ List = $ Expr -> reset ( ) ; do { $ Term = $ List -> reset ( ) ; do { $ s = $ Term -> evaluate ( ) ; switch ( $ Term -> length ) { case 1 : if ( $ s === P_EPSILON || $ s === P_EOF ) { break ; } $ ts [ $ s ] = ( string ) $ Term ; break ; case 3 : $ nts [ $ s ] = ( string ) $ Term ; break ; } } while ( $ Term = $ List -> next ( ) ) ; } while ( $ Expr -> next ( ) && $ List = $ Expr -> next ( ) ) ; } while ( $ Rule = $ this -> next ( ) ) ; return array ( $ ts , $ nts ) ; } | Recursively collect terminal and nonterminal strings from Term nodes . |
19,334 | function make_lex ( $ i = 0 ) { $ Lex = new LexBuilder ( $ i ) ; foreach ( $ this -> collect_symbols ( ) as $ symbols ) { foreach ( $ symbols as $ t => $ s ) { if ( preg_match ( '/^\W/' , $ s , $ r ) ) { $ Lex -> define_literal ( ( string ) $ t ) ; } else if ( $ Lex -> defined ( $ s ) ) { } else if ( defined ( $ s ) ) { $ Lex -> redefine ( $ s ) ; } else { $ Lex -> define ( $ t ) ; } } } return $ Lex ; } | Create a Lex instance fro symbols |
19,335 | public function setVar ( $ name , $ value ) { $ context = $ this -> _context ; $ context -> vars [ $ name ] = $ value ; return $ this ; } | Set a single view parameter |
19,336 | public function setVars ( $ vars ) { $ context = $ this -> _context ; $ context -> vars = array_merge ( $ context -> vars , $ vars ) ; return $ this ; } | Adds parameters to view |
19,337 | public function getVar ( $ name = null ) { $ context = $ this -> _context ; if ( $ name === null ) { return $ context -> vars ; } else { return isset ( $ context -> vars [ $ name ] ) ? $ context -> vars [ $ name ] : null ; } } | Returns a parameter previously set in the view |
19,338 | public function render ( $ template = null , $ vars = null ) { $ context = $ this -> _context ; if ( $ vars !== null ) { $ context -> vars = $ vars ; } if ( ! $ template ) { $ area = $ this -> dispatcher -> getArea ( ) ; $ controller = $ this -> dispatcher -> getController ( ) ; if ( $ area ) { $ dir = "@app/Areas/$area/Views/$controller" ; } else { $ dir = "@views/$controller" ; } if ( ! isset ( $ this -> _dirs [ $ dir ] ) ) { $ this -> _dirs [ $ dir ] = $ this -> filesystem -> dirExists ( $ dir ) ; } if ( $ this -> _dirs [ $ dir ] ) { $ template = $ dir . '/' . ucfirst ( $ this -> dispatcher -> getAction ( ) ) ; } else { $ template = $ dir ; } } $ this -> eventsManager -> fireEvent ( 'view:beforeRender' , $ this ) ; $ context -> content = $ this -> _render ( $ template , $ context -> vars , false ) ; if ( $ context -> layout !== false ) { $ layout = $ this -> _findLayout ( ) ; $ context -> content = $ this -> _render ( $ layout , $ context -> vars , false ) ; } $ this -> eventsManager -> fireEvent ( 'view:afterRender' , $ this ) ; return $ context -> content ; } | Executes render process from dispatching data |
19,339 | public function parseFile ( $ file ) { $ bundleConfig = Yaml :: parse ( file_get_contents ( realpath ( $ file ) ) ) ; if ( ! is_array ( $ bundleConfig ) ) { return array ( ) ; } return $ bundleConfig ; } | Parse a navigation . yml file |
19,340 | public static function getInstance ( ) { return new GeneratorFinderCache ( new GeneratorFinder ( TranstyperFactory :: getInstance ( ) , GeneratorValidatorFactory :: getInstance ( ) , new FileManager ( ) ) , Installer :: getDirectories ( ) , new FileManager ( ) ) ; } | Create GeneratorFinder instance |
19,341 | protected function _compilePattern ( $ pattern ) { if ( strpos ( $ pattern , '{' ) !== false ) { $ tr = [ '{area}' => '{area:[a-z]\w*}' , '{controller}' => '{controller:[a-z]\w*}' , '{action}' => '{action:[a-z]\w*}' , '{params}' => '{params:.*}' , '{id}' => '{id:[^/]+}' , ':int' => ':\d+' , ] ; $ pattern = strtr ( $ pattern , $ tr ) ; } if ( strpos ( $ pattern , '{' ) !== false ) { $ need_restore_token = false ; if ( preg_match ( '#{\d#' , $ pattern ) === 1 ) { $ need_restore_token = true ; $ pattern = ( string ) preg_replace ( '#{([\d,]+)}#' , '@\1@' , $ pattern ) ; } $ matches = [ ] ; if ( preg_match_all ( '#{([A-Z].*)}#Ui' , $ pattern , $ matches , PREG_SET_ORDER ) > 0 ) { foreach ( $ matches as $ match ) { $ parts = explode ( ':' , $ match [ 1 ] , 2 ) ; $ to = '(?<' . $ parts [ 0 ] . '>' . ( isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : '[\w-]+' ) . ')' ; $ pattern = ( string ) str_replace ( $ match [ 0 ] , $ to , $ pattern ) ; } } if ( $ need_restore_token ) { $ pattern = ( string ) preg_replace ( '#@([\d,]+)@#' , '{\1}' , $ pattern ) ; } return '#^' . $ pattern . '$#i' ; } else { return $ pattern ; } } | Replaces placeholders from pattern returning a valid PCRE regular expression |
19,342 | private function buildCacheData ( ) { $ metadata = $ this -> driver -> getMetadataForUser ( ) ; return serialize ( array_map ( function ( \ ReflectionProperty $ property ) { return $ property -> getName ( ) ; } , $ metadata ) ) ; } | Builds the cache data . |
19,343 | public function addBuilder ( BuilderInterface $ builder ) { $ builder -> setGenerator ( $ this ) ; $ builder -> setTemplateDirs ( $ this -> templateDirectories ) ; $ builder -> setMustOverwriteIfExists ( $ this -> mustOverwriteIfExists ) ; $ builder -> setVariables ( array_merge ( $ this -> variables , $ builder -> getVariables ( ) ) ) ; $ this -> builders [ ] = $ builder ; return $ builder ; } | Add a builder . |
19,344 | public function createLM ( $ text , $ maxNgrams ) { $ ngram = [ ] ; foreach ( preg_split ( "/[{$this->wordSeparator}]+/u" , $ text ) as $ word ) { if ( empty ( $ word ) ) { continue ; } $ word = "_" . $ word . "_" ; $ len = mb_strlen ( $ word , "UTF-8" ) ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ rlen = $ len - $ i ; if ( $ rlen > 4 ) { @ $ ngram [ mb_substr ( $ word , $ i , 5 , "UTF-8" ) ] ++ ; } if ( $ rlen > 3 ) { @ $ ngram [ mb_substr ( $ word , $ i , 4 , "UTF-8" ) ] ++ ; } if ( $ rlen > 2 ) { @ $ ngram [ mb_substr ( $ word , $ i , 3 , "UTF-8" ) ] ++ ; } if ( $ rlen > 1 ) { @ $ ngram [ mb_substr ( $ word , $ i , 2 , "UTF-8" ) ] ++ ; } @ $ ngram [ mb_substr ( $ word , $ i , 1 , "UTF-8" ) ] ++ ; } } if ( $ this -> minFreq ) { $ min = $ this -> minFreq ; $ ngram = array_filter ( $ ngram , function ( $ v ) use ( $ min ) { return $ v > $ min ; } ) ; } uksort ( $ ngram , function ( $ k1 , $ k2 ) use ( $ ngram ) { if ( $ ngram [ $ k1 ] == $ ngram [ $ k2 ] ) { return strcmp ( $ k1 , $ k2 ) ; } return $ ngram [ $ k2 ] - $ ngram [ $ k1 ] ; } ) ; if ( count ( $ ngram ) > $ maxNgrams ) { array_splice ( $ ngram , $ maxNgrams ) ; } return $ ngram ; } | Create ngrams list for text . |
19,345 | public function writeLanguageFile ( $ ngrams , $ outfile ) { $ out = fopen ( $ outfile , "w" ) ; fwrite ( $ out , '<?php $ngrams = ' . var_export ( $ ngrams , true ) . ";\n" ) ; $ rank = 1 ; $ ranks = array_map ( function ( $ x ) use ( & $ rank ) { return $ rank ++ ; } , $ ngrams ) ; fwrite ( $ out , '$ranks = ' . var_export ( $ ranks , true ) . ";\n" ) ; fclose ( $ out ) ; } | Write ngrams to file in PHP format |
19,346 | public function classify ( $ text , $ candidates = null ) { $ results = [ ] ; $ this -> resultStatus = '' ; $ wordLength = mb_strlen ( preg_replace ( "/[{$this->wordSeparator}]+/" , "" , $ text ) ) ; if ( $ wordLength < $ this -> minInputLength || $ wordLength == 0 ) { $ this -> resultStatus = self :: STATUSTOOSHORT ; return $ results ; } $ inputgrams = array_keys ( $ this -> createLM ( $ text , $ this -> maxNgrams ) ) ; if ( $ candidates ) { $ candidates = array_flip ( $ candidates ) ; } foreach ( $ this -> langFiles as $ language => $ langFile ) { if ( $ candidates && ! isset ( $ candidates [ $ language ] ) ) { continue ; } $ ngrams = $ this -> loadLanguageFile ( $ langFile ) ; $ p = 0 ; foreach ( $ inputgrams as $ i => $ ingram ) { if ( ! empty ( $ ngrams [ $ ingram ] ) ) { $ p += abs ( $ ngrams [ $ ingram ] - $ i ) ; } else { $ p += $ this -> maxNgrams ; } } if ( isset ( $ this -> boostedLangs [ $ language ] ) ) { $ p = round ( $ p * ( 1 - $ this -> langBoostScore ) ) ; } $ results [ $ language ] = $ p ; } asort ( $ results ) ; $ max = reset ( $ results ) * $ this -> resultsRatio ; $ results = array_filter ( $ results , function ( $ res ) use ( $ max ) { return $ res <= $ max ; } ) ; if ( count ( $ results ) > $ this -> maxReturnedLanguages ) { $ this -> resultStatus = self :: STATUSAMBIGUOUS ; return [ ] ; } $ max = count ( $ inputgrams ) * $ this -> maxNgrams * $ this -> maxProportion ; $ results = array_filter ( $ results , function ( $ res ) use ( $ max ) { return $ res <= $ max ; } ) ; if ( count ( $ results ) == 0 ) { $ this -> resultStatus = self :: STATUSNOMATCH ; return $ results ; } return $ results ; } | Classify text . |
19,347 | private function findAccessToken ( array $ identity ) { $ config = $ this -> container -> get ( 'config' ) ; foreach ( $ config [ 'zf-oauth2-doctrine' ] as $ oauth2Config ) { if ( array_key_exists ( 'object_manager' , $ oauth2Config ) ) { $ objectManager = $ this -> container -> get ( $ oauth2Config [ 'object_manager' ] ) ; $ accessTokenRepository = $ objectManager -> getRepository ( $ oauth2Config [ 'mapping' ] [ 'AccessToken' ] [ 'entity' ] ) ; $ accessToken = $ accessTokenRepository -> findOneBy ( [ $ oauth2Config [ 'mapping' ] [ 'AccessToken' ] [ 'mapping' ] [ 'access_token' ] [ 'name' ] => array_key_exists ( 'access_token' , $ identity ) ? $ identity [ 'access_token' ] : $ identity [ 'id' ] , ] ) ; if ( $ accessToken ) { if ( $ accessToken -> getClient ( ) -> getClientId ( ) == $ identity [ 'client_id' ] ) { return $ accessToken ; } } } } } | Search each OAuth2 configuration for a matching clientId and access_token |
19,348 | public function GroupedFeatures ( $ showungrouped = false ) { $ features = $ this -> owner -> Features ( ) -> innerJoin ( "Feature" , "Feature.ID = ProductFeatureValue.FeatureID" ) ; $ groupids = FeatureGroup :: get ( ) -> innerJoin ( "Feature" , "Feature.GroupID = FeatureGroup.ID" ) -> innerJoin ( "ProductFeatureValue" , "Feature.ID = ProductFeatureValue.FeatureID" ) -> filter ( "ProductID" , $ this -> owner -> ID ) -> getIDList ( ) ; $ result = new ArrayList ( ) ; foreach ( $ groupids as $ groupid ) { $ group = FeatureGroup :: get ( ) -> byID ( $ groupid ) ; $ result -> push ( new ArrayData ( array ( 'Group' => $ group , 'Children' => $ features -> filter ( "GroupID" , $ groupid ) ) ) ) ; } $ ungrouped = $ features -> filter ( "GroupID:not" , $ groupids ) ; if ( $ ungrouped -> exists ( ) && $ showungrouped ) { $ result -> push ( new ArrayData ( array ( 'Children' => $ ungrouped ) ) ) ; } return $ result ; } | Override features list with grouping . |
19,349 | static function parse_string ( $ s ) { if ( $ s == '' ) { throw new Exception ( 'Cannot parse empty string' ) ; } $ Parser = new BNFParser ; $ tokens = bnf_tokenize ( $ s ) ; return $ Parser -> parse ( $ tokens ) ; } | parse input string |
19,350 | static function parse_file ( $ f ) { $ src = file_get_contents ( $ f , true ) ; if ( $ src === false ) { throw new Exception ( "Cannot read file $f" ) ; } return self :: parse_string ( $ src ) ; } | Parse input from file |
19,351 | public function fetchOne ( $ sql , $ bind = [ ] , $ fetchMode = \ PDO :: FETCH_ASSOC , $ useMaster = false ) { return ( $ rs = $ this -> fetchAll ( $ sql , $ bind , $ fetchMode , $ useMaster ) ) ? $ rs [ 0 ] : false ; } | Returns the first row in a SQL query result |
19,352 | public function fetchAll ( $ sql , $ bind = [ ] , $ fetchMode = \ PDO :: FETCH_ASSOC , $ useMaster = false ) { $ context = $ this -> _context ; $ context -> sql = $ sql ; $ context -> bind = $ bind ; $ context -> affected_rows = 0 ; $ this -> eventsManager -> fireEvent ( 'db:beforeQuery' , $ this ) ; if ( $ context -> connection ) { $ type = null ; $ connection = $ context -> connection ; } else { $ type = $ this -> _has_slave ? 'slave' : 'default' ; $ connection = $ this -> poolManager -> pop ( $ this , $ this -> _timeout , $ type ) ; } try { $ start_time = microtime ( true ) ; $ result = $ connection -> query ( $ sql , $ bind , $ fetchMode , $ useMaster ) ; $ elapsed = round ( microtime ( true ) - $ start_time , 3 ) ; } finally { if ( $ type ) { $ this -> poolManager -> push ( $ this , $ connection , $ type ) ; } } $ count = $ context -> affected_rows = count ( $ result ) ; $ event_data = compact ( 'elapsed' , 'count' , 'sql' , 'bind' , 'result' ) ; $ this -> logger -> debug ( $ event_data , 'db.query' ) ; $ this -> eventsManager -> fireEvent ( 'db:afterQuery' , $ this , $ event_data ) ; return $ result ; } | Dumps the complete result of a query into an array |
19,353 | public function delete ( $ table , $ conditions , $ bind = [ ] ) { if ( is_string ( $ conditions ) ) { $ conditions = [ $ conditions ] ; } $ wheres = [ ] ; foreach ( $ conditions as $ k => $ v ) { if ( is_int ( $ k ) ) { $ wheres [ ] = stripos ( $ v , ' or ' ) ? "($v)" : $ v ; } else { $ wheres [ ] = "[$k]=:$k" ; $ bind [ $ k ] = $ v ; } } $ sql = 'DELETE' . ' FROM ' . $ this -> _escapeIdentifier ( $ table ) . ' WHERE ' . implode ( ' AND ' , $ wheres ) ; return $ this -> _execute ( 'delete' , $ sql , $ bind ) ; } | Deletes data from a table using custom SQL syntax |
19,354 | public function getEmulatedSQL ( $ preservedStrLength = - 1 ) { $ context = $ this -> _context ; if ( ! $ context -> bind ) { return ( string ) $ context -> sql ; } $ bind = $ context -> bind ; if ( isset ( $ bind [ 0 ] ) ) { return ( string ) $ context -> sql ; } else { $ replaces = [ ] ; foreach ( $ bind as $ key => $ value ) { $ replaces [ ':' . $ key ] = $ this -> _parseBindValue ( $ value , $ preservedStrLength ) ; } return strtr ( $ context -> sql , $ replaces ) ; } } | Active SQL statement in the object with replace the bind with value |
19,355 | public function begin ( ) { $ context = $ this -> _context ; $ this -> logger -> info ( 'transaction begin' , 'db.transaction.begin' ) ; if ( $ context -> transaction_level === 0 ) { $ this -> eventsManager -> fireEvent ( 'db:beginTransaction' , $ this ) ; try { $ connection = $ this -> poolManager -> pop ( $ this , $ this -> _timeout ) ; if ( ! $ connection -> beginTransaction ( ) ) { throw new DbException ( 'beginTransaction failed.' ) ; } $ context -> connection = $ connection ; } catch ( \ PDOException $ exception ) { throw new DbException ( 'beginTransaction failed: ' . $ exception -> getMessage ( ) , $ exception -> getCode ( ) , $ exception ) ; } finally { if ( ! $ context -> connection ) { $ this -> poolManager -> push ( $ this , $ context ) ; } } } $ context -> transaction_level ++ ; } | Starts a transaction in the connection |
19,356 | public function rollback ( ) { $ context = $ this -> _context ; if ( $ context -> transaction_level > 0 ) { $ this -> logger -> info ( 'transaction rollback' , 'db.transaction.rollback' ) ; $ context -> transaction_level -- ; if ( $ context -> transaction_level === 0 ) { $ this -> eventsManager -> fireEvent ( 'db:rollbackTransaction' , $ this ) ; try { if ( ! $ context -> connection -> rollBack ( ) ) { throw new DbException ( 'rollBack failed.' ) ; } } catch ( \ PDOException $ exception ) { throw new DbException ( 'rollBack failed: ' . $ exception -> getMessage ( ) , $ exception -> getCode ( ) , $ exception ) ; } finally { $ this -> poolManager -> push ( $ this , $ context -> connection ) ; $ context -> connection = null ; } } } } | Rollbacks the active transaction in the connection |
19,357 | public function getCategoryTree ( $ parentCategoryId = null ) { if ( $ parentCategoryId === null ) { return $ this -> _categoryTree ; } return $ this -> _searchChildren ( $ this -> _categoryTree , $ parentCategoryId ) ; } | Zwraca drzewo kategorii |
19,358 | private function _buildTree ( array & $ tree , array $ parents , array $ orderedCategories , CmsCategoryRecord $ parentCategory = null ) { if ( $ parentCategory !== null ) { $ parents [ $ parentCategory -> id ] = $ parentCategory ; } else { $ parentCategory = new CmsCategoryRecord ; $ parentCategory -> id = null ; } foreach ( $ orderedCategories as $ key => $ categoryRecord ) { if ( $ categoryRecord -> parentId != $ parentCategory -> id ) { continue ; } $ this -> _flatCategories [ $ categoryRecord -> id ] = $ categoryRecord ; unset ( $ orderedCategories [ $ key ] ) ; $ tree [ $ categoryRecord -> id ] = [ ] ; $ tree [ $ categoryRecord -> id ] [ 'record' ] = $ categoryRecord -> setOption ( 'parents' , $ parents ) ; $ tree [ $ categoryRecord -> id ] [ 'children' ] = [ ] ; $ this -> _buildTree ( $ tree [ $ categoryRecord -> id ] [ 'children' ] , $ parents , $ orderedCategories , $ categoryRecord ) ; } } | Buduje drzewo rekurencyjnie |
19,359 | public function getRoles ( ) { $ roles = array ( ) ; foreach ( $ this -> groups as $ group ) { $ roles [ ] = $ group -> getAsRole ( ) ; } $ roles [ ] = 'ROLE_USER' ; return $ roles ; } | Get role objects |
19,360 | public function getHashName ( ) { if ( $ this -> id === null ) { return ; } return substr ( md5 ( $ this -> name . \ App \ Registry :: $ config -> salt ) , 0 , 8 ) ; } | Pobiera hash dla danej nazwy pliku |
19,361 | public function getPosterUrl ( $ scaleType = 'default' , $ scale = null , $ https = null ) { if ( null === $ this -> id || ! $ this -> data -> posterFileName ) { return ; } $ cdnPath = rtrim ( \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) -> cdn ? \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) -> cdn : \ Mmi \ App \ FrontController :: getInstance ( ) -> getView ( ) -> url ( [ ] , true , $ https ) , '/' ) ; return $ cdnPath . ( new \ Cms \ Model \ FileSystemModel ( $ this -> data -> posterFileName ) ) -> getPublicPath ( $ scaleType , $ scale ) ; } | Pobiera adres postera pliku |
19,362 | public function delete ( ) { if ( ! parent :: delete ( ) ) { return false ; } if ( 0 != ( new CmsFileQuery ) -> whereName ( ) -> equals ( $ this -> name ) -> count ( ) ) { return true ; } ( new \ Cms \ Model \ FileSystemModel ( $ this -> name ) ) -> unlink ( ) ; return true ; } | Usuwa plik fizycznie i z bazy danych |
19,363 | public function limit ( $ limit , $ offset = null ) { $ this -> _limit = $ limit > 0 ? ( int ) $ limit : null ; $ this -> _offset = $ offset > 0 ? ( int ) $ offset : null ; return $ this ; } | Sets a LIMIT clause optionally a offset clause |
19,364 | protected function _retrievePostFilter ( \ Mmi \ Http \ RequestPost $ post ) { if ( false === strpos ( $ post -> filter , $ this -> _grid -> getClass ( ) ) ) { return ; } $ columnName = substr ( $ post -> filter , strpos ( $ post -> filter , '[' ) + 1 , - 1 ) ; $ tableName = null ; $ fieldName = $ columnName ; if ( strpos ( $ columnName , '.' ) ) { $ fieldTable = explode ( '.' , $ columnName ) ; $ tableName = $ fieldTable [ 0 ] ; $ fieldName = $ fieldTable [ 1 ] ; } if ( $ fieldName == '_paginator_' ) { return ( new GridStateFilter ( ) ) -> setField ( $ fieldName ) -> setValue ( $ post -> value ) ; } foreach ( $ this -> _grid -> getColumns ( ) as $ column ) { if ( $ column -> getName ( ) != $ columnName ) { continue ; } return ( new GridStateFilter ( ) ) -> setField ( $ fieldName ) -> setTableName ( $ tableName ) -> setMethod ( $ column -> getMethod ( ) ) -> setValue ( $ post -> value ) ; } } | Zwraca obiekt filtra na podstawie post |
19,365 | public function create ( ReflectionClass $ modelReflection , $ classFileName , $ shortClassName , $ classNamespace , $ contractFileName , $ shortContractName , $ contractNamespace , array $ methods ) { $ createdFiles = [ $ this -> createRepository ( $ modelReflection , $ classFileName , $ shortClassName , $ classNamespace , $ shortContractName , $ contractNamespace , $ methods ) ] ; if ( $ shortContractName ) { $ createdFiles [ ] = $ this -> createContract ( $ modelReflection , $ contractFileName , $ shortContractName , $ contractNamespace , $ methods ) ; } return $ createdFiles ; } | Create the repository and contract . |
19,366 | protected function createRepository ( ReflectionClass $ model , $ fileName , $ shortName , $ namespace , $ contractName , $ contractNamespace , array $ methods ) { $ path = app_path ( $ fileName ) ; $ stub = $ this -> compileStub ( 'repository.stub' , [ 'namespace' => $ namespace , 'class' => $ shortName , 'model.fullname' => $ model -> getName ( ) , 'model' => $ model -> getShortName ( ) , 'implementation' => $ this -> getImplementationClass ( $ contractName ) , 'implementation.use' => $ this -> getImplementationUse ( $ contractNamespace , $ contractName ) , ] ) ; $ stub = $ this -> compileMethods ( $ stub , $ methods ) ; $ this -> files -> makeDirectory ( dirname ( $ path ) , 0755 , true , true ) ; $ this -> files -> put ( $ path , $ stub ) ; return $ namespace . '\\' . $ shortName ; } | Create the repository . |
19,367 | protected function createContract ( ReflectionClass $ model , $ fileName , $ shortName , $ namespace , array $ methods ) { $ path = app_path ( $ fileName ) ; $ stub = $ this -> compileStub ( 'contract.stub' , [ 'namespace' => $ namespace , 'class' => $ shortName , 'model.fullname' => $ model -> getName ( ) , 'model' => $ model -> getShortName ( ) , ] ) ; $ stub = $ this -> compileMethods ( $ stub , $ methods ) ; $ this -> files -> makeDirectory ( dirname ( $ path ) , 0755 , true , true ) ; $ this -> files -> put ( $ path , $ stub ) ; return $ namespace . '\\' . $ shortName ; } | Create the contract for the repository . |
19,368 | protected function compileMethods ( $ stub , array $ methods ) { foreach ( $ methods as $ method ) { $ stub = str_replace ( [ '{{' . $ method . '}}' , '{{/' . $ method . '}}' ] , '' , $ stub ) ; } foreach ( $ this -> methods as $ method ) { $ stub = preg_replace ( '/{{' . $ method . '}}(.*){{\/' . $ method . '}}(\r\n)?/s' , '' , $ stub ) ; } return $ stub ; } | Compile the stub with the given methods to keep . |
19,369 | protected function compileStub ( $ stub , array $ data ) { $ stub = $ this -> files -> get ( __DIR__ . '/../stub/' . $ stub ) ; foreach ( $ data as $ key => $ value ) { $ stub = str_replace ( '{{' . $ key . '}}' , $ value , $ stub ) ; } return $ stub ; } | Compile the stub with the given data . |
19,370 | public function menuNodeHierarchy ( $ depth = 10 ) { if ( $ depth == 0 ) { return $ this ; } return $ this -> prototype ( 'array' ) -> children ( ) -> scalarNode ( 'route' ) -> end ( ) -> arrayNode ( 'routeParameters' ) -> prototype ( 'variable' ) -> end ( ) -> end ( ) -> scalarNode ( 'uri' ) -> end ( ) -> scalarNode ( 'label' ) -> end ( ) -> booleanNode ( 'display' ) -> defaultTrue ( ) -> end ( ) -> booleanNode ( 'displayChildren' ) -> defaultTrue ( ) -> end ( ) -> integerNode ( 'order' ) -> end ( ) -> arrayNode ( 'attributes' ) -> prototype ( 'variable' ) -> end ( ) -> end ( ) -> arrayNode ( 'linkAttributes' ) -> prototype ( 'variable' ) -> end ( ) -> end ( ) -> arrayNode ( 'childrenAttributes' ) -> prototype ( 'variable' ) -> end ( ) -> end ( ) -> arrayNode ( 'labelAttributes' ) -> prototype ( 'variable' ) -> end ( ) -> end ( ) -> arrayNode ( 'roles' ) -> prototype ( 'scalar' ) -> end ( ) -> end ( ) -> arrayNode ( 'extras' ) -> prototype ( 'scalar' ) -> end ( ) -> end ( ) -> menuNode ( 'children' ) -> menuNodeHierarchy ( $ depth - 1 ) -> end ( ) -> end ( ) ; } | Make menu hierarchy |
19,371 | public function deleteRoleAction ( ) { if ( ( null !== $ role = ( new \ Cms \ Orm \ CmsRoleQuery ) -> findPk ( $ this -> id ) ) ) { $ this -> getMessenger ( ) -> addMessage ( ( $ deleteResult = ( bool ) $ role -> delete ( ) ) ? 'messenger.acl.role.deleted' : 'messenger.acl.role.delete.error' , $ deleteResult ) ; } $ this -> getResponse ( ) -> redirect ( 'cmsAdmin' , 'acl' , 'index' , [ 'roleId' => $ this -> id ] ) ; } | Akcja usuwania roli |
19,372 | public function pluploadAction ( ) { set_time_limit ( 5 * 60 ) ; $ pluploadHandler = new Model \ PluploadHandler ( ) ; if ( ! $ pluploadHandler -> handle ( ) ) { return $ this -> _jsonError ( $ pluploadHandler -> getErrorCode ( ) , $ pluploadHandler -> getErrorMessage ( ) ) ; } if ( $ this -> getPost ( ) -> afterUpload && null !== $ record = $ pluploadHandler -> getSavedCmsFileRecord ( ) ) { $ this -> _operationAfter ( $ this -> getPost ( ) -> afterUpload , $ record ) ; } return json_encode ( [ 'result' => 'OK' , 'cmsFileId' => $ pluploadHandler -> getSavedCmsFileId ( ) ] ) ; } | Odbieranie danych z plugina Plupload |
19,373 | public function deleteAction ( ) { if ( ! $ this -> getPost ( ) -> cmsFileId || null === $ record = ( new CmsFileQuery ) -> findPk ( $ this -> getPost ( ) -> cmsFileId ) ) { return $ this -> _jsonError ( 178 ) ; } if ( $ record -> object === $ this -> getPost ( ) -> object && $ record -> objectId == $ this -> getPost ( ) -> objectId ) { if ( $ record -> delete ( ) ) { if ( $ this -> getPost ( ) -> afterDelete ) { $ this -> _operationAfter ( $ this -> getPost ( ) -> afterDelete , $ record ) ; } return json_encode ( [ 'result' => 'OK' ] ) ; } } return $ this -> _jsonError ( 178 ) ; } | Usuwa wybrany rekord pliku |
19,374 | public function downloadAction ( ) { if ( null === $ file = ( new CmsFileQuery ) -> byObject ( $ this -> object , $ this -> objectId ) -> findPk ( $ this -> id ) ) { return '' ; } $ this -> getResponse ( ) -> redirectToUrl ( $ file -> getUrl ( ) ) ; } | Przekierowanie na plik |
19,375 | protected function _savePoster ( $ blob , \ Cms \ Orm \ CmsFileRecord $ file ) { if ( ! \ preg_match ( '/^data:(image\/[a-z]+);base64,(.*)/i' , $ blob , $ match ) ) { return ; } $ posterFileName = substr ( $ file -> name , 0 , strpos ( $ file -> name , '.' ) ) . '-' . $ file -> id . '.' . \ Mmi \ Http \ ResponseTypes :: getExtensionByType ( $ match [ 1 ] ) ; try { mkdir ( dirname ( $ file -> getRealPath ( ) ) , 0777 , true ) ; } catch ( \ Exception $ e ) { } file_put_contents ( str_replace ( $ file -> name , $ posterFileName , $ file -> getRealPath ( ) ) , base64_decode ( $ match [ 2 ] ) ) ; $ file -> data -> posterFileName = $ posterFileName ; return $ posterFileName ; } | Zapisanie postera dla video |
19,376 | public function getAllClasses ( MetaDataInterface $ metadata = null ) { $ cacheFilename = $ this -> directories [ 'Cache' ] . DIRECTORY_SEPARATOR ; $ cacheFilename .= md5 ( 'genrator_getAllClasses' . ( $ metadata !== null ) ? get_class ( $ metadata ) : '' ) ; if ( $ this -> fileManager -> isFile ( $ cacheFilename ) === true && $ this -> noCache === false ) { $ data = unserialize ( $ this -> fileManager -> fileGetContent ( $ cacheFilename ) ) ; } else { $ data = $ this -> generatorFinder -> getAllClasses ( $ metadata ) ; $ this -> fileManager -> filePutsContent ( $ cacheFilename , serialize ( $ data ) ) ; } return $ data ; } | Find all adapters allow in project |
19,377 | public function fireEvent ( $ event , $ source , $ data = [ ] ) { if ( $ this -> _listeners ) { list ( $ p1 , $ p2 ) = explode ( ':' , $ event , 2 ) ; if ( isset ( $ this -> _listeners [ $ p1 ] ) ) { foreach ( $ this -> _listeners [ $ p1 ] as $ k => $ v ) { if ( is_int ( $ v ) ) { $ this -> _listeners [ $ p1 ] [ $ k ] = $ listener = $ this -> _di -> getShared ( $ k ) ; } else { $ listener = $ v ; } $ listener -> process ( $ p2 , $ source , $ data ) ; } } } foreach ( $ this -> _peekers as $ handler ) { if ( $ handler instanceof \ Closure ) { $ handler ( $ event , $ source , $ data ) ; } else { $ handler [ 0 ] -> { $ handler [ 1 ] } ( $ event , $ source , $ data ) ; } } if ( ! isset ( $ this -> _events [ $ event ] ) ) { return ; } foreach ( $ this -> _events [ $ event ] as $ handler ) { if ( $ handler instanceof \ Closure ) { $ handler ( $ source , $ data , $ event ) ; } else { $ handler [ 0 ] -> { $ handler [ 1 ] } ( $ source , $ data , $ event ) ; } } } | Fires an event in the events manager causing that active listeners be notified about it |
19,378 | protected function getStandardPermissions ( array $ options , $ master , $ owner ) { switch ( $ options [ 'permissions' ] ) { case 'standard::object' : $ disable = array ( ) ; if ( ! $ master && ! $ owner ) { $ disable = array ( 1 , 3 , 4 , 6 , 7 , 8 ) ; } return array ( 'show' => array ( 1 => 'View' , 3 => 'Edit' , 4 => 'Delete' , 6 => 'Operator' , 7 => 'Master' , 8 => 'Owner' ) , 'disable' => $ disable ) ; break ; case 'standard::class' : return array ( 'show' => array ( 1 => 'View' , 2 => 'Create' , 3 => 'Edit' , 4 => 'Delete' , 6 => 'Operator' , 7 => 'Master' , 8 => 'Owner' ) ) ; break ; default : throw new \ RuntimeException ( '"' . $ options [ 'permissions' ] . '" is not a valid standard permission set identifier' ) ; } } | Get standard permission sets for provided string identifier . |
19,379 | public function manacliCommand ( ) { $ this -> alias -> set ( '@phar' , '@data/manacli_phar' ) ; $ pharFile = $ this -> alias -> resolve ( '@root/manacli.phar' ) ; $ this -> console -> writeLn ( [ 'cleaning `:dir` dir' , 'dir' => $ this -> alias -> resolve ( '@phar' ) ] ) ; $ this -> filesystem -> dirReCreate ( '@phar' ) ; $ this -> console -> writeLn ( 'copying manaphp framework files.' ) ; $ this -> filesystem -> dirCopy ( '@root/ManaPHP' , '@phar/ManaPHP' ) ; $ this -> filesystem -> fileCopy ( '@root/manacli.php' , '@phar/manacli.php' ) ; $ phar = new \ Phar ( $ pharFile , \ FilesystemIterator :: CURRENT_AS_FILEINFO | \ FilesystemIterator :: KEY_AS_FILENAME , basename ( $ pharFile ) ) ; $ phar -> buildFromDirectory ( $ this -> alias -> resolve ( '@phar' ) ) ; $ phar -> setStub ( $ phar :: createDefaultStub ( 'manacli.php' ) ) ; $ this -> console -> writeLn ( 'compressing files' ) ; $ phar -> compressFiles ( \ Phar :: BZ2 ) ; $ this -> console -> writeLn ( [ '`:phar` created successfully' , 'phar' => $ this -> alias -> resolve ( $ pharFile ) ] ) ; } | create manacli . phar file |
19,380 | public function handle ( $ filePath , $ results ) { $ responseCollection = new PredefinedResponseCollection ( ) ; $ responseCollection -> append ( new PredefinedResponse ( 'postpone' , 'postpone' , self :: POSTPONE ) ) ; $ responseCollection -> append ( new PredefinedResponse ( 'show diff' , 'show diff' , self :: SHOW_DIFF ) ) ; $ responseCollection -> append ( new PredefinedResponse ( 'erase' , 'erase' , self :: ERASE ) ) ; $ responseCollection -> append ( new PredefinedResponse ( 'cancel' , 'cancel' , self :: CANCEL ) ) ; $ question = new QuestionWithPredefinedResponse ( sprintf ( 'File "%s" already exist, erase it with the new' , $ filePath ) , 'conflict' . $ filePath , $ responseCollection ) ; $ question -> setShutdownWithoutResponse ( true , sprintf ( 'Conflict with file "%s" not resolved' , $ filePath ) ) ; while ( ( $ response = $ this -> context -> askCollection ( $ question ) ) !== null ) { $ response = intval ( $ response ) ; if ( $ response === self :: SHOW_DIFF ) { $ this -> context -> log ( '<info>' . $ this -> diffPHP -> diff ( $ results , $ this -> fileManager -> fileGetContent ( $ filePath ) ) . '</info>' ) ; } else { break ; } } if ( $ response === self :: POSTPONE ) { $ this -> fileManager -> filePutsContent ( $ filePath . '.diff' , $ this -> diffPHP -> diff ( $ results , $ this -> fileManager -> fileGetContent ( $ filePath ) ) ) ; $ this -> context -> log ( ' . $ filePath . '.diff' , 'generationLog' ) ; } elseif ( $ response === self :: ERASE ) { $ this -> fileManager -> filePutsContent ( $ filePath , $ results ) ; $ this -> context -> log ( ' . $ filePath , 'generationLog' ) ; } } | Handle the file conflict |
19,381 | private function analyzeDependencies ( array $ process , PhpStringParser $ phpParser , GeneratorDataObject $ generator ) { $ generator = clone $ generator ; if ( isset ( $ process [ 'dependencies' ] ) === true && is_array ( $ process [ 'dependencies' ] ) === true ) { foreach ( $ process [ 'dependencies' ] as $ dependencieName ) { $ generator -> addDependency ( $ this -> analyze ( $ dependencieName , $ phpParser , $ generator , $ generator -> getDto ( ) -> getMetadata ( ) ) ) ; } $ generator = $ this -> addDependenciesVariablesToMainGenerator ( $ generator ) ; } return $ generator ; } | Analyze the dependencies generator |
19,382 | private function analyzePreParser ( array $ process , PhpStringParser $ phpParser , GeneratorDataObject $ generator , $ firstIteration ) { $ generator = clone $ generator ; if ( $ this -> parserCollection -> getPreParse ( ) -> count ( ) > 0 ) { foreach ( $ this -> parserCollection -> getPreParse ( ) as $ parser ) { $ generator = $ parser -> evaluate ( $ process , $ phpParser , $ generator , $ firstIteration ) ; } } return $ generator ; } | Analyze pre parser |
19,383 | private function analyzePostParser ( array $ process , PhpStringParser $ phpParser , GeneratorDataObject $ generator , $ firstIteration ) { $ generator = clone $ generator ; if ( $ this -> parserCollection -> getPostParse ( ) -> count ( ) > 0 ) { foreach ( $ this -> parserCollection -> getPostParse ( ) as $ parser ) { $ generator = $ parser -> evaluate ( $ process , $ phpParser , $ generator , $ firstIteration ) ; } } return $ generator ; } | Analyze post parser |
19,384 | public function setContainer ( ContainerInterface $ container = null ) { parent :: setContainer ( $ container ) ; if ( ! $ this -> container -> getParameter ( 'fom_user.reset_password' ) ) { throw new AccessDeniedHttpException ( ) ; } } | Check if password reset is allowed . |
19,385 | public function retrieveAll ( ) { $ adapterCollection = new MetaDataSourceCollection ( ) ; foreach ( $ this -> fileManager -> glob ( Installer :: BASE_PATH . self :: SOURCE_PATH . '*' . self :: EXTENSION ) as $ file ) { $ config = $ this -> transtyper -> decode ( $ this -> fileManager -> fileGetContent ( $ file ) ) ; try { $ this -> arrayValidator -> isValid ( 'CrudGenerator\Metadata\MetaDataSource' , $ config ) ; } catch ( ValidationException $ e ) { continue ; } $ adapter = $ this -> metaDataSourceHydrator -> adapterNameToMetaDataSource ( $ config [ MetaDataSource :: METADATA_DAO_FACTORY ] ) ; $ adapter -> setMetadataDaoFactory ( $ config [ MetaDataSource :: METADATA_DAO_FACTORY ] ) ; $ adapter -> setMetadataDao ( $ config [ MetaDataSource :: METADATA_DAO ] ) ; if ( isset ( $ config [ MetaDataSource :: CONFIG ] ) === true ) { $ adapter -> setConfig ( $ this -> driverHydrator -> arrayToDto ( $ config [ MetaDataSource :: CONFIG ] ) ) ; } $ adapterCollection -> append ( $ adapter ) ; } return $ adapterCollection ; } | Retrieve all config |
19,386 | public static function getInstance ( DriverConfig $ config ) { $ pdoDriver = PdoDriverFactory :: getInstance ( ) ; return new MySQLMetaDataDAO ( $ pdoDriver -> getConnection ( $ config ) , $ config ) ; } | Create MySQL Metadata DAO instance |
19,387 | public function deleteAttributeRelationAction ( ) { ( new AttributeController ( $ this -> getRequest ( ) , $ this -> view ) ) -> deleteAttributeRelationAction ( ) ; $ this -> getResponse ( ) -> redirect ( 'cmsAdmin' , 'categoryWidget' , 'edit' , [ 'id' => $ this -> id ] ) ; } | Usuwanie relacji widget atrybut |
19,388 | public static function getInstance ( DriverConfig $ config ) { $ pdoDriver = PdoDriverFactory :: getInstance ( ) ; return new PostgreSQLMetaDataDAO ( $ pdoDriver -> getConnection ( $ config ) , $ config , new SqlManager ( ) ) ; } | Create PostgreSQL Metadata DAO instance |
19,389 | public function addGuest ( $ id , $ guest ) { if ( is_string ( $ guest ) ) { $ params = array ( 'email' => $ guest ) ; } elseif ( is_numeric ( $ guest ) ) { $ params = array ( 'user_id' => $ guest ) ; } else { throw new \ Exception ( 'Invalid parameter' ) ; } return $ this -> post ( '/projects/' . $ id . '/add_guest.json' , $ params ) ; } | Add a member to a project |
19,390 | public function afterSave ( ) { if ( ! parent :: afterSave ( ) ) { return false ; } if ( ! $ this -> _saveRoles ( ) ) { return false ; } if ( $ this -> getElement ( 'commit' ) -> getValue ( ) ) { $ this -> getRecord ( ) -> commitVersion ( ) ; } return ( new CategoryLockModel ( $ this -> getRecord ( ) -> cmsCategoryOriginalId ) ) -> releaseLock ( ) ; } | Zapisuje dodatkowe dane m . in . role |
19,391 | protected function getPlaceholderArray ( ) { $ placeholderArray = [ ] ; foreach ( $ this -> getConfigKey ( 'Placeholders' ) as $ key => $ data ) { $ placeholderArray [ $ key ] = $ data [ 'value' ] ; } return $ placeholderArray ; } | Get an array of placeholder = > value combinations to be used by Mustache . |
19,392 | public function beforeSave ( ) { $ tag = $ this -> getElement ( 'tag' ) -> getValue ( ) ; if ( null === $ tagRecord = ( new \ Cms \ Orm \ CmsTagQuery ) -> whereTag ( ) -> equals ( $ tag ) -> findFirst ( ) ) { $ tagRecord = new \ Cms \ Orm \ CmsTagRecord ; $ tagRecord -> tag = $ tag ; $ tagRecord -> save ( ) ; } $ this -> getRecord ( ) -> cmsTagId = $ tagRecord -> id ; return true ; } | Przed zapisem odnalezienie identyfikatora wprowadzonego tagu |
19,393 | public function set ( $ name , $ definition ) { if ( is_string ( $ definition ) ) { if ( strpos ( $ definition , '/' ) !== false || preg_match ( '#^[\w\\\\]+$#' , $ definition ) !== 1 ) { $ definition = [ 'class' => $ this -> _interClassName ( $ name ) , $ definition , 'shared' => false ] ; } else { if ( strpos ( $ definition , '\\' ) === false ) { $ definition = $ this -> _completeClassName ( $ name , $ definition ) ; } $ definition = [ 'class' => $ definition , 'shared' => false ] ; } } elseif ( is_array ( $ definition ) ) { if ( isset ( $ definition [ 'class' ] ) ) { if ( strpos ( $ definition [ 'class' ] , '\\' ) === false ) { $ definition [ 'class' ] = $ this -> _completeClassName ( $ name , $ definition [ 'class' ] ) ; } } elseif ( isset ( $ definition [ 0 ] ) && count ( $ definition ) !== 1 ) { if ( strpos ( $ definition [ 0 ] , '\\' ) === false ) { $ definition [ 0 ] = $ this -> _completeClassName ( $ name , $ definition [ 0 ] ) ; } } else { $ definition [ 'class' ] = $ this -> _interClassName ( $ name ) ; } $ definition [ 'shared' ] = false ; } elseif ( is_object ( $ definition ) ) { $ definition = [ 'class' => $ definition , 'shared' => ! $ definition instanceof \ Closure ] ; } else { throw new UnexpectedValueException ( [ '`:definition` definition is unknown' , 'definition' => $ name ] ) ; } $ this -> _definitions [ $ name ] = $ definition ; return $ this ; } | Registers a component in the components container |
19,394 | public function setShared ( $ name , $ definition ) { if ( isset ( $ this -> _instances [ $ name ] ) ) { throw new MisuseException ( [ 'it\'s too late to setShared(): `:name` instance has been created' , 'name' => $ name ] ) ; } if ( is_string ( $ definition ) ) { if ( strpos ( $ definition , '/' ) !== false || preg_match ( '#^[\w\\\\]+$#' , $ definition ) !== 1 ) { $ definition = [ 'class' => $ this -> _interClassName ( $ name ) , $ definition ] ; } elseif ( strpos ( $ definition , '\\' ) === false ) { $ definition = $ this -> _completeClassName ( $ name , $ definition ) ; } } elseif ( is_array ( $ definition ) ) { if ( isset ( $ definition [ 'class' ] ) ) { if ( strpos ( $ definition [ 'class' ] , '\\' ) === false ) { $ definition [ 'class' ] = $ this -> _completeClassName ( $ name , $ definition [ 'class' ] ) ; } } elseif ( isset ( $ definition [ 0 ] ) && count ( $ definition ) !== 1 ) { if ( strpos ( $ definition [ 0 ] , '\\' ) === false ) { $ definition [ 0 ] = $ this -> _completeClassName ( $ name , $ definition [ 0 ] ) ; } } else { $ definition [ 'class' ] = $ this -> _interClassName ( $ name ) ; } } elseif ( is_object ( $ definition ) ) { $ definition = [ 'class' => $ definition ] ; } else { throw new UnexpectedValueException ( [ '`:definition` definition is unknown' , 'definition' => $ name ] ) ; } $ this -> _definitions [ $ name ] = $ definition ; return $ this ; } | Registers an always shared component in the components container |
19,395 | public function remove ( $ name ) { unset ( $ this -> _definitions [ $ name ] , $ this -> _instances [ $ name ] , $ this -> { $ name } ) ; return $ this ; } | Removes a component in the components container |
19,396 | public function get ( $ name , $ parameters = null ) { if ( isset ( $ this -> _instances [ $ name ] ) ) { return $ this -> _instances [ $ name ] ; } if ( isset ( $ this -> _definitions [ $ name ] ) ) { $ definition = $ this -> _definitions [ $ name ] ; } else { return $ this -> getInstance ( $ name , $ parameters , $ name ) ; } $ instance = $ this -> getInstance ( $ definition , $ parameters , $ name ) ; if ( is_string ( $ definition ) || ! isset ( $ definition [ 'shared' ] ) || $ definition [ 'shared' ] === true ) { $ this -> _instances [ $ name ] = $ instance ; } return $ instance ; } | Resolves the component based on its configuration |
19,397 | public function getShared ( $ name ) { if ( isset ( $ this -> _instances [ $ name ] ) ) { return $ this -> _instances [ $ name ] ; } if ( isset ( $ this -> _definitions [ $ name ] ) ) { return $ this -> _instances [ $ name ] = $ this -> getInstance ( $ this -> _definitions [ $ name ] , null , $ name ) ; } elseif ( strpos ( $ name , '\\' ) !== false ) { return $ this -> _instances [ $ name ] = $ this -> getInstance ( $ name , null , $ name ) ; } else { $ className = $ this -> _getPatterned ( $ name ) ; if ( $ className === null ) { throw new InvalidValueException ( [ '`:component` component is not exists' , 'component' => $ name ] ) ; } return $ this -> _instances [ $ name ] = $ this -> getInstance ( $ className , null , $ name ) ; } } | Resolves a component the resolved component is stored in the DI subsequent requests for this component will return the same instance |
19,398 | function reset ( ) { $ tmp = $ this -> milliseconds ( ) ; $ this -> started = microtime ( false ) ; $ this -> stopped = null ; return $ tmp ; } | Reset timer . |
19,399 | function stop ( ) { if ( $ this -> is_running ( ) ) { $ this -> stopped = microtime ( false ) ; return $ this -> milliseconds ( ) ; } else { trigger_error ( "Timer already stopped" , E_USER_NOTICE ) ; return false ; } } | Stop timer . Use this when you want to evaluate a value without the clock continuing . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.