idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
1,500 | protected function _getSelect ( ) { $ ret = parent :: _getSelect ( ) ; $ componentId = $ this -> _getParam ( 'componentId' ) ; $ component = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentByDbId ( $ componentId , array ( 'ignoreVisible' => true ) ) ; if ( isset ( $ component -> parent -> chained ) ) { $ component = $ component -> parent -> chained ; } $ dbIds = array ( $ component -> dbId ) ; foreach ( Kwc_Chained_Abstract_Component :: getAllChainedByMaster ( $ component , 'Trl' ) as $ c ) { $ dbIds [ ] = $ c -> dbId ; } $ ret -> whereEquals ( 'component_id' , $ dbIds ) ; return $ ret ; } | shows all feedbacks in all languages |
1,501 | public static function getResponsiveImageVars ( $ dimensions , $ imageFile ) { $ ret = array ( ) ; $ width = 0 ; $ aspectRatio = 0 ; $ ret [ 'minWidth' ] = 0 ; $ ret [ 'maxWidth' ] = 0 ; if ( isset ( $ dimensions [ 'width' ] ) && $ dimensions [ 'width' ] > 0 ) { $ aspectRatio = $ dimensions [ 'height' ] / $ dimensions [ 'width' ] * 100 ; $ width = $ dimensions [ 'width' ] ; $ ret [ 'widthSteps' ] = Kwf_Media_Image :: getResponsiveWidthSteps ( $ dimensions , $ imageFile ) ; } $ ret [ 'width' ] = $ width ; $ ret [ 'aspectRatio' ] = $ aspectRatio ; return $ ret ; } | Helper function that calculates vars needed by components with responsive images |
1,502 | public function hideForValue ( Kwf_Form_Field_Abstract $ field , $ value , Kwf_Form_Field_Abstract $ hideField ) { $ this -> _hideForValue [ ] = array ( 'field' => $ field , 'value' => $ value , 'hide' => $ hideField ) ; return $ this ; } | Hide a field has a specific value hide other fields |
1,503 | public static function formatValidationErrors ( $ errors ) { $ msg = array ( ) ; foreach ( $ errors as $ i ) { if ( ! is_array ( $ i ) ) { throw new Kwf_Exception ( 'Form errors must be of type array' ) ; } $ name = '' ; if ( isset ( $ i [ 'field' ] ) ) { $ name = $ i [ 'field' ] -> getFieldLabel ( ) ; if ( ! $ name ) $ name = $ i [ 'field' ] -> getName ( ) ; } if ( isset ( $ i [ 'message' ] ) ) { $ i [ 'messages' ] = array ( $ i [ 'message' ] ) ; } foreach ( $ i [ 'messages' ] as $ m ) { $ msg [ ] = ( $ name ? ( $ name . ': ' ) : '' ) . Kwf_Util_HtmlSpecialChars :: filter ( $ m ) ; } } return $ msg ; } | Static helper function that formats form errors |
1,504 | public function jsonConfirmOrderAction ( ) { $ component = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ this -> _getParam ( 'paymentComponentId' ) ) ; $ order = Kwf_Model_Abstract :: getInstance ( Kwc_Abstract :: getSetting ( $ component -> chained -> getParentByClass ( 'Kwc_Shop_Cart_Component' ) -> componentClass , 'childModel' ) ) -> getReferencedModel ( 'Order' ) -> getCartOrder ( ) ; if ( $ order && $ component && is_instance_of ( $ component -> componentClass , 'Kwc_Shop_Cart_Checkout_Payment_PayPal_Trl_Component' ) ) { $ order -> payment_component_id = $ component -> componentId ; $ order -> checkout_component_id = $ component -> parent -> componentId ; $ order -> cart_component_class = $ component -> parent -> parent -> componentClass ; $ order -> status = 'processing' ; $ order -> date = date ( 'Y-m-d H:i:s' ) ; $ order -> save ( ) ; $ session = new Kwf_Session_Namespace ( 'kwcShopCart' ) ; $ session -> paypalCartId = $ order -> id ; } } | is called by js so it might be that this code isn t called at all |
1,505 | public function getMenuData ( $ parentData = null , $ select = array ( ) , $ editableClass = 'Kwc_Menu_EditableItems_Component' ) { return $ this -> _getMenuData ( $ parentData , $ select , $ editableClass ) ; } | Used by chained and Events |
1,506 | protected function _onOwnRowUpdateNotVisible ( Kwf_Component_Data $ c , Kwf_Events_Event_Row_Abstract $ event ) { parent :: _onOwnRowUpdateNotVisible ( $ c , $ event ) ; if ( $ event -> isDirty ( array ( 'kwf_upload_id' , 'width' , 'height' , 'dimension' , 'crop_x' , 'crop_y' , 'crop_width' , 'crop_height' ) ) ) { $ this -> _fireMediaChanged ( $ c ) ; } } | gets called when own row gets updated weather component is visible or not |
1,507 | protected function _getSelect ( ) { $ select = $ this -> _model -> select ( ) ; if ( $ this -> _hasPosition ) { $ select -> order ( 'pos' ) ; } else if ( ! $ select -> hasPart ( 'order' ) && $ this -> _defaultOrder ) { $ select -> order ( $ this -> _defaultOrder [ 'field' ] , $ this -> _defaultOrder [ 'direction' ] ) ; } return $ select ; } | override this method to handle the output of this view . Just return the select statement which serves your needs . |
1,508 | public static function get ( $ cacheClusterId ) { if ( ! $ cacheClusterId ) throw new Kwf_Exception ( "cacheClusterId is requried" ) ; $ ec = new Kwf_Util_Aws_ElastiCache ( ) ; $ r = $ ec -> describe_cache_clusters ( array ( 'ShowCacheNodeInfo' => true , 'CacheClusterId' => $ cacheClusterId ) ) ; if ( ! $ r -> isOk ( ) ) { if ( isset ( $ r -> body -> Error -> Message ) ) { throw new Kwf_Exception ( $ r -> body -> Error -> Message ) ; } else { throw new Kwf_Exception ( "Getting CacheClusters failed" ) ; } } $ servers = array ( ) ; foreach ( $ r -> body -> DescribeCacheClustersResult -> CacheClusters -> CacheCluster -> CacheNodes -> CacheNode as $ node ) { $ servers [ ] = array ( 'host' => ( string ) $ node -> Endpoint -> Address , 'port' => ( int ) $ node -> Endpoint -> Port , ) ; } return $ servers ; } | uncached use getCached to use cache |
1,509 | public static function getCached ( $ cacheClusterId ) { $ cacheId = self :: _getCacheId ( $ cacheClusterId ) ; $ servers = self :: _getCache ( ) -> load ( $ cacheId ) ; if ( $ servers === false ) { $ servers = self :: refreshCache ( $ cacheClusterId ) ; } return $ servers ; } | if used you need to refresh this cache yourself |
1,510 | public function searchLike ( $ searchValues = array ( ) , $ searchFields = '*' ) { if ( is_string ( $ searchValues ) ) $ searchValues = array ( 'query' => $ searchValues ) ; if ( is_string ( $ searchFields ) ) $ searchFields = array ( $ searchFields ) ; foreach ( $ searchValues as $ column => $ value ) { if ( empty ( $ value ) || ( $ column != 'query' && ! in_array ( $ column , $ this -> _table ( ) -> getColumns ( ) ) ) ) { continue ; } $ searchWords = preg_split ( '/[\s-+,;*]/' , $ value ) ; foreach ( $ searchWords as $ searchWord ) { $ searchWord = trim ( $ searchWord ) ; if ( empty ( $ searchWord ) ) continue ; if ( $ column == 'query' ) { if ( ! $ searchFields ) { throw new Kwf_Exception ( "Search field 'query' was found, " . "but no 'searchFields' were given as second argument in " . "'searchLike' method of Kwf_Db_Table_Select object" ) ; } if ( in_array ( '*' , $ searchFields ) ) { $ searchFields = array_merge ( $ searchFields , $ this -> _table ( ) -> getColumns ( ) ) ; foreach ( $ searchFields as $ sfk => $ sfv ) { if ( $ sfv == '*' ) unset ( $ searchFields [ $ sfk ] ) ; if ( substr ( $ sfv , 0 , 1 ) == '!' ) { unset ( $ searchFields [ $ sfk ] ) ; unset ( $ searchFields [ array_search ( substr ( $ sfv , 1 ) , $ searchFields ) ] ) ; } } } $ wheres = array ( ) ; foreach ( $ searchFields as $ field ) { if ( strpos ( $ field , '.' ) === false ) { $ field = $ this -> _table -> getTableName ( ) . '.' . $ field ; } $ wheres [ ] = Kwf_Registry :: get ( 'db' ) -> quoteInto ( $ field . ' LIKE ?' , "%$searchWord%" ) ; } $ this -> where ( implode ( ' OR ' , $ wheres ) ) ; } else { $ this -> where ( $ column . ' LIKE ?' , "%" . $ searchWord . "%" ) ; } } } return $ this ; } | Adds the needed wheres for a search |
1,511 | public function assemble ( ) { $ fields = $ this -> getPart ( Kwf_Db_Table_Select :: COLUMNS ) ; $ primary = $ this -> _table -> getTableName ( ) ; $ schema = $ this -> _table -> getSchemaName ( ) ; if ( count ( $ this -> _parts [ self :: UNION ] ) == 0 ) { if ( ! count ( $ fields ) ) { $ this -> from ( $ primary , self :: SQL_WILDCARD , $ schema ) ; $ fields = $ this -> getPart ( Kwf_Db_Table_Select :: COLUMNS ) ; } $ from = $ this -> getPart ( Kwf_Db_Table_Select :: FROM ) ; if ( $ this -> _integrityCheck !== false ) { foreach ( $ fields as $ columnEntry ) { list ( $ table , $ column ) = $ columnEntry ; if ( $ column ) { if ( ! isset ( $ from [ $ table ] ) || $ from [ $ table ] [ 'tableName' ] != $ primary ) { throw new Kwf_Exception ( 'Select query cannot join with another table' ) ; } } } } } return parent :: assemble ( ) ; } | Performs a validation on the select query before passing back to the parent class . Ensures that only columns from the primary Kwf_Db_Table are returned in the result . |
1,512 | public static function getConfigDomain ( $ host ) { if ( ! $ host ) return null ; $ longDomainEndings = array ( 'or.at' , 'co.at' , 'gv.at' , 'co.uk' ) ; foreach ( $ longDomainEndings as $ k => $ v ) { $ longDomainEndings [ $ k ] = str_replace ( '.' , '' , $ v ) ; } $ hostParts = explode ( '.' , $ host ) ; if ( count ( $ hostParts ) <= 1 ) { $ ret = $ host ; } else { $ ret = $ hostParts [ count ( $ hostParts ) - 2 ] . $ hostParts [ count ( $ hostParts ) - 1 ] ; } if ( in_array ( $ ret , $ longDomainEndings ) ) { $ ret = $ hostParts [ count ( $ hostParts ) - 3 ] . $ ret ; } return $ ret ; } | for unit testing only |
1,513 | public static function getSettings ( ) { $ ret = parent :: getSettings ( ) ; $ ret [ 'viewCache' ] = true ; $ ret [ 'contentSender' ] = 'Kwf_Component_Abstract_ContentSender_Default' ; $ ret [ 'layoutClass' ] = 'Kwf_Component_Layout_Default' ; $ ret [ 'plugins' ] = array ( ) ; return $ ret ; } | Returns static settings of this component |
1,514 | public static function getIndirectChildComponentClasses ( $ class , $ select = array ( ) ) { if ( is_array ( $ select ) ) { $ select = new Kwf_Component_Select ( $ select ) ; } $ cacheId = $ select -> getHash ( ) ; $ ret = self :: _getIndirectChildComponentClasses ( $ class , $ select , $ cacheId ) ; return $ ret ; } | Returns indirect child component classes of a componentclass or a componentData |
1,515 | public static function getChildComponentClass ( $ class , $ generator , $ componentKey = null ) { $ constraints = array ( 'generator' => $ generator , ) ; if ( $ componentKey ) $ constraints [ 'componentKey' ] = $ componentKey ; $ classes = array_values ( self :: getChildComponentClasses ( $ class , $ constraints ) ) ; if ( ! isset ( $ classes [ 0 ] ) ) { if ( ! $ componentKey ) { throw new Kwf_Exception ( "no component for generator '$generator' not set for '$class'" ) ; } else { throw new Kwf_Exception ( "childComponentClass '$componentKey' for generator '$generator' not set for '$class'" ) ; } } return $ classes [ 0 ] ; } | Returns a single child component class of a componentClass |
1,516 | public static function hasChildComponentClass ( $ class , $ generator , $ componentKey = null ) { $ constraints = array ( 'generator' => $ generator , 'componentKey' => $ componentKey ) ; $ classes = self :: getChildComponentClasses ( $ class , $ constraints ) ; return count ( $ classes ) > 0 ; } | Return if a child component class with a given generator key and componentKey exists |
1,517 | protected function _getRow ( ) { if ( ! isset ( $ this -> _row ) ) { $ model = $ this -> getOwnModel ( ) ; if ( ! $ model ) return null ; $ dbId = $ this -> getData ( ) -> dbId ; $ sharedDataClass = self :: getFlag ( $ this -> getData ( ) -> componentClass , 'sharedDataClass' ) ; if ( $ sharedDataClass ) { $ component = $ this -> getData ( ) ; while ( $ component ) { if ( is_instance_of ( $ component -> componentClass , $ sharedDataClass ) ) $ dbId = $ component -> dbId ; $ component = $ component -> parent ; } } $ this -> _row = $ model -> getRow ( $ dbId ) ; if ( ! $ this -> _row ) { $ this -> _row = $ model -> createRow ( ) ; $ this -> _row -> component_id = $ dbId ; } } return $ this -> _row ; } | Returns the row from the ownModel of this component |
1,518 | public function getPdfWriter ( $ pdf ) { if ( ! isset ( $ this -> _pdfWriter ) ) { $ class = Kwc_Admin :: getComponentFile ( get_class ( $ this ) , 'Pdf' , 'php' , true ) ; $ this -> _pdfWriter = new $ class ( $ this , $ pdf ) ; } return $ this -> _pdfWriter ; } | Returns the Pdf Writer object associated with this component . |
1,519 | public function getTemplateVars ( Kwf_Component_Renderer_Abstract $ renderer ) { $ ret = array ( ) ; $ ret [ 'placeholder' ] = $ this -> _getPlaceholder ( ) ; $ ret [ 'rootElementClass' ] = self :: getRootElementClass ( $ this ) ; $ ret [ 'bemClass' ] = $ this -> _getBemClass ( '' ) ; $ ret [ 'data' ] = $ this -> getData ( ) ; $ ret [ 'row' ] = $ this -> _getRow ( ) ; $ supportedContexts = Kwf_Component_Layout_Abstract :: getInstance ( $ this -> getData ( ) -> componentClass ) -> getSupportedContexts ( ) ; if ( $ supportedContexts ) { $ contexts = Kwf_Component_Layout_Abstract :: getInstance ( $ this -> getData ( ) -> componentClass ) -> getContexts ( $ this -> getData ( ) ) ; if ( is_null ( $ contexts ) ) { $ e = new Kwf_Exception ( "Didn't get layout contexts for " . $ this -> getData ( ) -> componentId ) ; $ e -> logOrThrow ( ) ; } foreach ( $ contexts as $ ctx ) { if ( ! in_array ( $ ctx , $ supportedContexts ) ) { $ e = new Kwf_Exception ( "Master Layout Context " . json_encode ( $ ctx ) . " is not supported by " . $ this -> getData ( ) -> componentClass . " for '" . $ this -> getData ( ) -> componentId . "'" ) ; $ e -> logOrThrow ( ) ; } } } return $ ret ; } | Returns variables that can be used in Component . tpl |
1,520 | public function getMasterTemplateVars ( Kwf_Component_Data $ innerComponent , Kwf_Component_Renderer_Abstract $ renderer ) { $ ret = array ( ) ; $ ret [ 'component' ] = $ innerComponent ; $ ret [ 'data' ] = $ innerComponent ; $ ret [ 'template' ] = self :: getMasterTemplateFile ( $ this -> getData ( ) -> componentClass ) ; $ ret [ 'pageLanguage' ] = $ innerComponent -> getLanguage ( ) ; $ ret [ 'boxes' ] = array ( ) ; foreach ( $ innerComponent -> getPageOrRoot ( ) -> getChildBoxes ( ) as $ box ) { $ ret [ 'boxes' ] [ $ box -> box ] = $ box ; } $ ret [ 'multiBoxes' ] = array ( ) ; foreach ( $ innerComponent -> getPageOrRoot ( ) -> getRecursiveChildComponents ( array ( 'multiBox' => true ) ) as $ box ) { $ ret [ 'multiBoxes' ] [ $ box -> box ] [ ] = $ box ; } foreach ( $ ret [ 'multiBoxes' ] as $ box => $ components ) { usort ( $ ret [ 'multiBoxes' ] [ $ box ] , array ( 'Kwf_Component_View_Helper_ComponentWithMaster' , '_sortByPriority' ) ) ; } $ up = Kwf_Config :: getValue ( 'application.uniquePrefix' ) ; if ( ! $ up ) { $ ret [ 'bemClass' ] = '' ; } else { $ ret [ 'bemClass' ] = Kwf_Component_Abstract :: formatRootElementClass ( $ this -> getData ( ) -> componentClass , '' ) . 'Master__' ; } $ ret [ 'rootElementClass' ] = 'kwfUp-frontend ' . Kwf_Component_Abstract :: formatRootElementClass ( $ this -> getData ( ) -> componentClass , '' ) . 'Master' ; return $ ret ; } | Returns variables that can be used in Master . tpl |
1,521 | protected function _getPlaceholder ( $ placeholder = null ) { $ ret = $ this -> _getSetting ( 'placeholder' ) ; if ( $ placeholder ) { return $ this -> getData ( ) -> trlStaticExecute ( $ ret [ $ placeholder ] ) ; } foreach ( $ ret as $ k => $ v ) { $ ret [ $ k ] = $ this -> getData ( ) -> trlStaticExecute ( $ v ) ; } return $ ret ; } | Returns a placeholder text placeholders are set in settings |
1,522 | static public function getRootElementClass ( $ component ) { if ( ! is_string ( $ component ) ) $ component = $ component -> getData ( ) -> componentClass ; $ ret = '' ; if ( self :: hasSetting ( $ component , 'rootElementClass' ) ) { $ ret .= self :: getSetting ( $ component , 'rootElementClass' ) . ' ' ; } $ ret .= Kwf_Component_Abstract :: formatRootElementClass ( $ component , '' ) ; return $ ret ; } | Returns the processed rootElementClass used in various places for a component |
1,523 | public static function getComponentClassesByParentClass ( $ class ) { if ( ! is_array ( $ class ) ) $ class = array ( $ class ) ; static $ prefix ; $ cacheId = 'cclsbpc-' . implode ( '-' , $ class ) . '-' . Kwf_Component_Data_Root :: getComponentClass ( ) ; $ ret = Kwf_Cache_SimpleStatic :: fetch ( $ cacheId , $ success ) ; if ( $ success ) { return $ ret ; } $ ret = array ( ) ; foreach ( Kwc_Abstract :: getComponentClasses ( ) as $ c ) { if ( in_array ( $ c , $ class ) || in_array ( ( strpos ( $ c , '.' ) ? substr ( $ c , 0 , strpos ( $ c , '.' ) ) : $ c ) , $ class ) ) { $ ret [ ] = $ c ; continue ; } foreach ( Kwc_Abstract :: getParentClasses ( $ c ) as $ p ) { if ( in_array ( $ p , $ class ) ) { $ ret [ ] = $ c ; break ; } } } Kwf_Cache_SimpleStatic :: add ( $ cacheId , $ ret ) ; return $ ret ; } | Returns componentClasses that match a given class in their inheritance chain |
1,524 | public static function getComponentClassByParentClass ( $ class ) { $ ret = self :: getComponentClassesByParentClass ( $ class ) ; if ( count ( $ ret ) != 1 ) { if ( ! $ ret ) { throw new Kwf_Exception ( "No Component with class '$class' found" ) ; } throw new Kwf_Exception ( "More then one component with class '$class' found, there should exist only one" ) ; } return $ ret [ 0 ] ; } | Returns a componentClass that match a given class in their inheritance chain |
1,525 | public function getActiveViewPlugins ( ) { $ ret = $ this -> _getSetting ( 'plugins' ) ; $ d = $ this -> getData ( ) ; if ( $ d -> isPage ) { while ( $ d ) { foreach ( Kwc_Abstract :: getSetting ( $ d -> componentClass , 'pluginsInherit' ) as $ i ) { if ( ! in_array ( $ i , $ ret ) ) $ ret [ ] = $ i ; } $ d = $ d -> parent ; } } return $ ret ; } | Returns the view plugins that should be used for this component instance |
1,526 | public static function duplicate ( Kwf_Component_Data $ source , Kwf_Component_Data $ parentTarget , Zend_ProgressBar $ progressBar = null ) { $ new = $ source -> generator -> duplicateChild ( $ source , $ parentTarget , $ progressBar ) ; if ( ! $ new ) { throw new Kwf_Exception ( "Failed duplicating '$source->componentId'" ) ; } Kwf_Component_Generator_Abstract :: clearInstances ( ) ; Kwf_Component_Data_Root :: reset ( ) ; Kwc_Root_TrlRoot_Chained_Admin :: duplicated ( $ source , $ new ) ; return $ new ; } | Recursively duplicate components |
1,527 | public function onPageChanged ( Kwf_Component_Event_Component_Abstract $ event ) { $ this -> _updates [ ] = array ( 'type' => 'componentLink' , 'component_id' => $ event -> component -> componentId ) ; $ this -> _log ( "type=componentLink component_id={$event->component->componentId}" ) ; } | namechanged and filnamechanged - events |
1,528 | protected function _isDirty ( $ column = null ) { if ( $ column ) { return array_key_exists ( $ column , $ this -> _cleanData ) ; } return ! empty ( $ this -> _cleanData ) ; } | Ob die Row seblst dirty ist |
1,529 | public final function isDirty ( $ column = null ) { if ( $ this -> _isDirty ( $ column ) ) return true ; foreach ( $ this -> _getSiblingRows ( ) as $ r ) { if ( $ r -> _isDirty ( $ column ) ) return true ; } if ( ! $ column ) { foreach ( $ this -> _childRows as $ rule => $ rows ) { foreach ( $ rows as $ row ) { if ( $ row -> isDirty ( ) ) return true ; } } } return false ; } | Ob die Row oder eine sibling row dirty ist |
1,530 | public function getDirtyColumns ( ) { $ ret = array_keys ( $ this -> _cleanData ) ; foreach ( $ this -> _getSiblingRows ( ) as $ r ) { $ ret = array_merge ( $ ret , $ r -> getDirtyColumns ( ) ) ; } return $ ret ; } | dirty columns der row und der sibling rows |
1,531 | public function getCleanValue ( $ name ) { if ( array_key_exists ( $ name , $ this -> _cleanData ) ) { return $ this -> _cleanData [ $ name ] ; } foreach ( $ this -> _getSiblingRows ( ) as $ r ) { if ( array_key_exists ( $ name , $ r -> _cleanData ) ) { return $ r -> _cleanData [ $ name ] ; } } return $ this -> __get ( $ name ) ; } | Returns the original value of a column like it exists in the data source . |
1,532 | protected final function _duplicateDependentModel ( $ newRow , $ rule , $ select = array ( ) ) { $ rowset = $ this -> getChildRows ( $ rule , $ select ) ; foreach ( $ rowset as $ row ) { $ ref = $ row -> getModel ( ) -> getReferenceByModelClass ( get_class ( $ this -> getModel ( ) ) , null ) ; $ data = array ( ) ; $ data [ $ ref [ 'column' ] ] = $ newRow -> { $ this -> _getPrimaryKey ( ) } ; $ row -> duplicate ( $ data ) ; } } | Hilfsfunktion die von duplicate aufgerufen werden kann |
1,533 | public static function sendSpammedMail ( $ id , $ key , $ tranport = null ) { $ row = Kwf_Model_Abstract :: getInstance ( 'Kwf_Model_Mail' ) -> getRow ( $ id ) ; if ( ! $ row ) return false ; if ( Kwf_Util_Check_Spam :: getSpamKey ( $ row ) != $ key ) { return false ; } if ( ! $ row -> mail_sent ) { $ row -> is_spam = 0 ; $ row -> sendMail ( $ tranport ) ; return true ; } return false ; } | Public only for testing!!! |
1,534 | public function match ( $ request , $ partial = null ) { $ path = trim ( $ request -> getPathInfo ( ) , self :: URI_DELIMITER ) ; $ subPath = $ path ; $ values = array ( ) ; $ numRoutes = count ( $ this -> _routes ) ; $ matchedPath = null ; foreach ( $ this -> _routes as $ key => $ route ) { if ( $ key > 0 && $ matchedPath !== null && $ subPath !== '' && $ subPath !== false ) { $ separator = substr ( $ subPath , 0 , strlen ( $ this -> _separators [ $ key ] ) ) ; if ( $ separator !== $ this -> _separators [ $ key ] ) { return false ; } $ subPath = substr ( $ subPath , strlen ( $ separator ) ) ; } if ( ! method_exists ( $ route , 'getVersion' ) || $ route -> getVersion ( ) == 1 ) { $ match = $ subPath ; } else { $ request -> setPathInfo ( $ subPath ) ; $ match = $ request ; } $ res = $ route -> match ( $ match , true , ( $ key == $ numRoutes - 1 ) ) ; if ( $ res === false ) { $ request -> setPathInfo ( $ path ) ; return false ; } $ matchedPath = $ route -> getMatchedPath ( ) ; if ( $ matchedPath !== null ) { $ subPath = substr ( $ subPath , strlen ( $ matchedPath ) ) ; $ separator = substr ( $ subPath , 0 , strlen ( $ this -> _separators [ $ key ] ) ) ; } $ values = $ res + $ values ; } $ request -> setPathInfo ( $ path ) ; if ( $ subPath !== '' && $ subPath !== false ) { return false ; } return $ values ; } | zend implementation overridden to avoid pathInfo getting modified even if route didn t match |
1,535 | public function getRecursivePageChildIds ( $ parentId ) { $ select = new Kwf_Model_Select ( ) ; $ ret = $ this -> _getChildPageIds ( $ parentId ) ; foreach ( $ ret as $ i ) { $ ret = array_merge ( $ ret , $ this -> getRecursivePageChildIds ( $ i ) ) ; } return $ ret ; } | Returns all recursive children of a page |
1,536 | public function saveIncludes ( $ componentId , $ type , $ includedComponents ) { $ m = $ this -> getModel ( 'includes' ) ; $ s = $ m -> select ( ) -> whereEquals ( 'component_id' , $ componentId ) -> whereEquals ( 'type' , $ type ) ; $ existingTargetIds = array ( ) ; foreach ( $ m -> export ( Kwf_Model_Abstract :: FORMAT_ARRAY , $ s , array ( 'columns' => array ( 'id' , 'target_id' , 'type' ) ) ) as $ i ) { $ existingTargetIds [ $ i [ 'id' ] ] = $ i [ 'target_id' ] ; } $ newTargetIds = array ( ) ; if ( $ includedComponents ) { $ data = array ( ) ; foreach ( $ includedComponents as $ includedComponent ) { $ cmp = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ componentId , array ( 'ignoreVisible' => true ) ) ; $ id = substr ( $ includedComponent , 0 , strrpos ( $ includedComponent , ':' ) ) ; $ targetCmp = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ id , array ( 'ignoreVisible' => true ) ) ; if ( $ cmp -> getInheritsParent ( ) !== $ targetCmp -> getInheritsParent ( ) ) { if ( ! in_array ( $ includedComponent , $ existingTargetIds ) ) { $ c = array ( 'target_id' => $ includedComponent , 'type' => $ type , 'component_id' => $ componentId , ) ; $ data [ ] = $ c ; } $ newTargetIds [ ] = $ includedComponent ; } } $ m -> import ( Kwf_Model_Abstract :: FORMAT_ARRAY , $ data ) ; } $ diffTargetIds = array_diff ( $ existingTargetIds , $ newTargetIds ) ; if ( $ diffTargetIds ) { $ m = $ this -> getModel ( 'includes' ) ; $ s = $ m -> select ( ) -> whereEquals ( 'component_id' , $ componentId ) -> whereEquals ( 'type' , $ type ) -> whereEquals ( 'target_id' , $ diffTargetIds ) ; $ m -> deleteRows ( $ s ) ; } } | For unit testing - DO NOT DELETE! |
1,537 | protected function _loadIniFile ( $ filename ) { if ( version_compare ( PHP_VERSION , '5.3.0' ) >= 0 ) { $ loaded = parse_ini_file ( $ filename , true , INI_SCANNER_RAW ) ; $ this -> _fixValues ( $ loaded ) ; } else { $ loaded = parse_ini_file ( $ filename , true ) ; } $ iniArray = array ( ) ; foreach ( $ loaded as $ key => $ data ) { $ pieces = explode ( $ this -> _sectionSeparator , $ key ) ; $ thisSection = trim ( $ pieces [ 0 ] ) ; switch ( count ( $ pieces ) ) { case 1 : $ iniArray [ $ thisSection ] = $ data ; break ; case 2 : $ extendedSection = trim ( $ pieces [ 1 ] ) ; $ iniArray [ $ thisSection ] = array_merge ( array ( ';extends' => $ extendedSection ) , $ data ) ; break ; default : throw new Zend_Config_Exception ( "Section '$thisSection' may not extend multiple sections in $filename" ) ; } } return $ iniArray ; } | im neuen zend gibts _parseIniFile - nur das sollte ?berschrieben werden |
1,538 | protected function _getComponentsFromRow ( $ row , $ select ) { $ idColumn = $ this -> _getGenerator ( ) -> getIdColumn ( ) ; if ( $ this -> _getGenerator ( ) -> hasSetting ( 'dbIdShortcut' ) && $ this -> _getGenerator ( ) -> getSetting ( 'dbIdShortcut' ) ) { $ dbId = $ this -> _getGenerator ( ) -> getSetting ( 'dbIdShortcut' ) . $ row -> $ idColumn ; $ ret = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentsByDbId ( $ dbId , $ select ) ; } else if ( $ row -> getModel ( ) -> hasColumn ( 'component_id' ) ) { $ dbId = $ row -> component_id . $ this -> _getGenerator ( ) -> getIdSeparator ( ) . $ row -> $ idColumn ; $ ret = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentsByDbId ( $ dbId , $ select ) ; } else { $ cls = $ this -> _getClassFromRowFromGenerator ( $ row ) ; $ select [ 'id' ] = $ this -> _getGenerator ( ) -> getIdSeparator ( ) . $ row -> $ idColumn ; $ ret = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentsBySameClass ( $ cls , $ select ) ; } foreach ( $ ret as $ k => $ i ) { if ( $ i -> generator !== $ this -> _getGenerator ( ) ) { unset ( $ ret [ $ k ] ) ; } } return array_values ( $ ret ) ; } | overrridden in Kwc_Root_Category_GeneratorEvents |
1,539 | public static function getKernel ( ) { if ( ! isset ( self :: $ _instance ) ) { if ( $ cls = Kwf_Config :: getValue ( 'symfony.kernelClass' ) ) { if ( ! class_exists ( 'Symfony\Component\HttpKernel\Kernel' ) ) return null ; self :: $ _instance = new $ cls ( ) ; self :: $ _instance -> boot ( ) ; } else { return null ; } } return self :: $ _instance ; } | Don t use this method in Symfony context |
1,540 | public static function getInstance ( ) { if ( is_null ( self :: $ _instance ) ) { $ c = self :: getComponentClass ( ) ; if ( $ c ) { self :: $ _instance = new self ( array ( 'componentClass' => $ c ) ) ; } else { self :: $ _instance = false ; } } return self :: $ _instance ; } | Returns the root component data instance |
1,541 | public function freeMemory ( ) { $ this -> _freeMemory ( ) ; foreach ( $ this -> _dataCache as $ id => $ c ) { if ( isset ( $ this -> _dataCacheIgnoreVisible [ $ id ] ) ) { unset ( $ this -> _dataCacheIgnoreVisible [ $ id ] ) ; } $ c -> _freeMemory ( ) ; } foreach ( $ this -> _dataCacheIgnoreVisible as $ id => $ c ) { $ c -> _freeMemory ( ) ; } $ this -> _dataCache = array ( ) ; $ this -> _dataCacheIgnoreVisible = array ( ) ; $ this -> _componentsByClassCache = null ; $ this -> _componentsByDbIdCache = null ; $ this -> _generatorsForClassesCache = array ( ) ; Kwf_Model_Abstract :: clearAllRows ( ) ; if ( function_exists ( 'gc_collect_cycles' ) ) gc_collect_cycles ( ) ; } | Tries to clear all cached data objects and row objects |
1,542 | public function getPageGenerators ( ) { if ( ! is_null ( $ this -> _pageGenerators ) ) return $ this -> _pageGenerators ; $ cacheId = $ this -> componentClass . '_pageGenerators' ; $ generators = Kwf_Cache_SimpleStatic :: fetch ( $ cacheId ) ; if ( ! $ generators ) { $ generators = array ( ) ; foreach ( Kwc_Abstract :: getComponentClasses ( ) as $ class ) { foreach ( Kwc_Abstract :: getSetting ( $ class , 'generators' ) as $ key => $ generator ) { if ( ! isset ( $ generator [ 'class' ] ) ) { throw new Kwf_Exception ( "no generator class set for generator '$key' in component '$class'" ) ; } if ( is_instance_of ( $ generator [ 'class' ] , 'Kwc_Root_Category_Generator' ) ) { $ generators [ ] = array ( 'class' => $ class , 'key' => $ key , 'generator' => $ generator ) ; } } } Kwf_Cache_SimpleStatic :: add ( $ cacheId , $ generators ) ; } $ this -> _pageGenerators = array ( ) ; foreach ( $ generators as $ g ) { $ this -> _pageGenerators [ ] = Kwf_Component_Generator_Abstract :: getInstance ( $ g [ 'class' ] , $ g [ 'key' ] , $ g [ 'generator' ] ) ; } return $ this -> _pageGenerators ; } | Returns all Kwc_Root_Category_Generators used . |
1,543 | public function getComponentByDbId ( $ dbId , $ select = array ( ) ) { $ components = $ this -> getComponentsByDbId ( $ dbId , $ select ) ; $ this -> _checkSingleComponent ( $ components ) ; if ( isset ( $ components [ 0 ] ) ) { return $ components [ 0 ] ; } return null ; } | Searches for a component data by it s dbId |
1,544 | public function getComponentsBySameClass ( $ lookingForChildClasses , $ select = array ( ) ) { $ ret = array ( ) ; if ( ! is_array ( $ lookingForChildClasses ) ) { $ lookingForChildClasses = array ( $ lookingForChildClasses ) ; } foreach ( $ lookingForChildClasses as $ c ) { if ( $ c == $ this -> componentClass ) { $ ret [ ] = $ this ; if ( isset ( $ limitCount ) && $ limitCount == 1 ) { return $ ret ; } } } if ( is_array ( $ select ) ) { $ select = new Kwf_Component_Select ( $ select ) ; } else { $ select = clone $ select ; } $ select -> whereComponentClasses ( $ lookingForChildClasses ) ; if ( $ select -> hasPart ( Kwf_Component_Select :: LIMIT_COUNT ) ) { $ limitCount = $ select -> getPart ( Kwf_Component_Select :: LIMIT_COUNT ) ; } foreach ( $ this -> _getGeneratorsForClasses ( $ lookingForChildClasses ) as $ generator ) { foreach ( $ generator -> getChildData ( null , $ select ) as $ data ) { $ ret [ ] = $ data ; if ( isset ( $ limitCount ) && $ limitCount - count ( $ ret ) <= 0 ) { return $ ret ; } } } return $ ret ; } | Returns all components exactly matching a component class |
1,545 | public function indexRecursive ( Kwf_Component_Data $ page ) { if ( $ page -> isPage ) { $ r = $ this -> getRow ( $ page -> componentId ) ; if ( ! $ r ) { $ r = $ this -> createRow ( ) ; $ r -> changed_date = date ( 'Y-m-d H:i:s' ) ; } $ r -> updateFromPage ( $ page ) ; $ r -> save ( ) ; } $ childPages = $ page -> getChildPseudoPages ( array ( 'pageGenerator' => false ) , array ( 'pseudoPage' => false , 'unique' => false ) ) ; $ childPages = array_merge ( $ childPages , $ page -> getChildPseudoPages ( array ( 'pageGenerator' => true ) , array ( 'pseudoPage' => false ) ) ) ; $ ret = array ( ) ; foreach ( $ childPages as $ p ) { $ this -> indexRecursive ( $ p ) ; } } | in web ComponentPagesMetaController is used |
1,546 | public static function getInstance ( Kwf_Component_Data $ subroot ) { while ( $ subroot ) { if ( Kwc_Abstract :: getFlag ( $ subroot -> componentClass , 'subroot' ) ) { break ; } $ subroot = $ subroot -> parent ; } if ( ! $ subroot ) $ subroot = Kwf_Component_Data_Root :: getInstance ( ) ; static $ instance = array ( ) ; if ( ! isset ( $ instance [ $ subroot -> componentId ] ) ) { $ analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive ( ) ; $ analyzer -> addFilter ( new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords ( 2 ) ) ; Zend_Search_Lucene_Analysis_Analyzer :: setDefault ( $ analyzer ) ; Zend_Search_Lucene_Search_QueryParser :: setDefaultEncoding ( 'utf-8' ) ; Zend_Search_Lucene_Storage_Directory_Filesystem :: setDefaultFilePermissions ( 0666 ) ; $ path = 'cache/fulltext' ; $ path .= '/' . $ subroot -> componentId ; try { $ instance [ $ subroot -> componentId ] = Zend_Search_Lucene :: open ( $ path ) ; } catch ( Zend_Search_Lucene_Exception $ e ) { $ instance [ $ subroot -> componentId ] = Zend_Search_Lucene :: create ( $ path ) ; } } return $ instance [ $ subroot -> componentId ] ; } | Returns Zend_Search_Lucene instance for given subroot |
1,547 | protected function _getMultiFieldsFieldset ( ) { $ fs = new Kwf_Form_Container_FieldSet ( trlKwf ( 'Paragraph {0}' ) ) ; $ fs -> add ( new Kwf_Form_Field_Checkbox ( 'visible' , trlKwf ( 'Visible' ) ) ) ; $ fs -> add ( new Kwf_Form_Field_SimpleAbstract ( 'edit' ) ) -> setXtype ( 'kwc.listeditbutton' ) -> setLabelSeparator ( '' ) -> setData ( new Kwc_Abstract_List_FormWithEditButton_NoSaveData ( 'id' ) ) ; return $ fs ; } | MultiFields content fields . |
1,548 | public function getMailContent ( $ type = Kwf_Model_Mail_Row :: MAIL_CONTENT_AUTO ) { if ( $ type == Kwf_Model_Mail_Row :: MAIL_CONTENT_AUTO ) { $ ret = $ this -> _getHtmlMailContent ( ) ; if ( is_null ( $ ret ) ) $ ret = $ this -> _getTextMailContent ( ) ; return $ ret ; } else if ( $ type == Kwf_Model_Mail_Row :: MAIL_CONTENT_HTML ) { return $ this -> _getHtmlMailContent ( ) ; } else if ( $ type == Kwf_Model_Mail_Row :: MAIL_CONTENT_TEXT ) { return $ this -> _getTextMailContent ( ) ; } return null ; } | constants for type defined in Kwf_Model_Mail_Row |
1,549 | protected function _initSettings ( ) { parent :: _initSettings ( ) ; $ this -> _emptyIfSingleEntry = $ menuLevel = Kwc_Abstract :: getSetting ( $ this -> _class , 'emptyIfSingleEntry' ) ; } | overwritten in Kwc_Menu_Trl_Events |
1,550 | protected function _onMenuChanged ( Kwf_Events_Event_Abstract $ event , Kwf_Component_Data $ menu ) { parent :: _onMenuChanged ( $ event , $ menu ) ; $ newCount = count ( $ menu -> getComponent ( ) -> getMenuData ( ) ) ; if ( $ event instanceof Kwf_Component_Event_Page_Removed && $ event -> flag == Kwf_Component_Event_Page_Removed :: FLAG_ROW_ADDED_REMOVED ) { $ newCount -- ; } if ( $ this -> _emptyIfSingleEntry ) $ newCount -- ; $ previousCount = $ newCount ; if ( $ event instanceof Kwf_Component_Event_Page_Added ) { $ previousCount -- ; } else if ( $ event instanceof Kwf_Component_Event_Page_Removed ) { $ previousCount ++ ; } if ( ! $ previousCount && $ newCount || $ previousCount && ! $ newCount ) { $ this -> fireEvent ( new Kwf_Component_Event_Component_HasContentChanged ( $ this -> _class , $ menu ) ) ; } } | fire HasContentChanged here because hasContent is implemented in this component |
1,551 | private function _isAllowedComponentClass ( $ userRow , $ componentClass ) { if ( $ this -> _isAllowedComponentClassByRole ( $ this -> _getRole ( $ userRow ) , $ componentClass ) ) { return true ; } foreach ( $ this -> _getAdditionalRoles ( $ userRow ) as $ role ) { if ( $ this -> _isAllowedComponentClassByRole ( $ role , $ componentClass ) ) { return true ; } } return false ; } | darum erstmal private gemacht |
1,552 | public function allowComponent ( $ role , $ componentClass , $ privilege = null ) { if ( $ privilege ) throw new Kwf_Exception ( "Not yet implemented" ) ; if ( ! is_null ( $ role ) ) $ role = $ this -> _roleRegistry -> get ( $ role ) ; $ rules = & $ this -> _getRules ( 'Component' , $ componentClass , $ role , true ) ; $ rules [ 'type' ] = Kwf_Acl :: TYPE_ALLOW ; return $ this ; } | Allow Component plus child components on same page |
1,553 | protected function _fireComponentEvent ( $ eventType , Kwf_Component_Event_Component_AbstractFlag $ ev ) { $ cls = 'Kwf_Component_Event_Component_' . $ eventType ; $ g = $ this -> _getGenerator ( ) ; foreach ( $ ev -> component -> getChildComponents ( array ( 'generator' => $ g -> getGeneratorKey ( ) ) ) as $ c ) { $ this -> fireEvent ( new $ cls ( $ c -> componentClass , $ c , $ ev -> flag ) ) ; } } | overridden in Page_Events_Static |
1,554 | public function processOutput ( $ output , $ renderer ) { $ output = parent :: processOutput ( $ output , $ renderer ) ; $ c = Kwf_Component_Data_Root :: getInstance ( ) -> getComponentById ( $ this -> _componentId ) ; $ recipient = $ c -> getComponent ( ) -> getRecipient ( ) ; $ redirectComponent = $ c -> getChildComponent ( '_redirect' ) ; if ( $ redirectComponent && $ recipient ) { $ redirectComponent = $ redirectComponent -> getComponent ( ) ; $ output = $ redirectComponent -> replaceLinks ( $ output , $ recipient , 'html' ) ; } return $ output ; } | recipient is set when showing mail in browser not when sending mail |
1,555 | public static function parseMasterStyles ( $ masterContent ) { $ styles = array ( ) ; $ up = Kwf_Config :: getValue ( 'application.uniquePrefix' ) ; if ( $ up ) $ up .= '-' ; if ( strpos ( $ masterContent , ".{$up}webStandard" ) === false ) return $ styles ; $ up = str_replace ( '-' , '\-' , $ up ) ; preg_match_all ( "#\.{$up}webStandard\s+(span|p|h[1-6])(\.(.+))?(\s+)?{([^}]+)}\s*\/\*(.*)\*\/#mU" , $ masterContent , $ m ) ; foreach ( array_keys ( $ m [ 1 ] ) as $ i ) { $ styles [ ] = array ( 'id' => 'master' . $ i , 'name' => trim ( $ m [ 6 ] [ $ i ] ) , 'tagName' => $ m [ 1 ] [ $ i ] , 'className' => $ m [ 3 ] [ $ i ] , 'styles' => $ m [ 5 ] [ $ i ] , ) ; } return $ styles ; } | public fuer test |
1,556 | public function createFile ( $ start = null ) { if ( file_exists ( $ this -> _fileName ) ) { throw new Kwf_Exception ( "$this->_fileName already exists" ) ; } $ initialValueDates = array ( ) ; if ( is_null ( $ start ) ) { $ initialValueDates = $ this -> _getInitialValueDates ( ) ; if ( ! $ initialValueDates ) { $ start = time ( ) - 1 ; } else { sort ( $ initialValueDates ) ; $ start = $ initialValueDates [ 0 ] - 1 ; } } $ cmd = "rrdtool create $this->_fileName " ; $ cmd .= "--start " . $ start . " " ; $ cmd .= "--step " . ( $ this -> _interval ) . " " ; foreach ( $ this -> _fields as $ field ) { if ( ! is_null ( $ field -> getHeartbeat ( ) ) ) { $ heartbeat = $ field -> getHeartbeat ( ) ; } else { $ heartbeat = ( $ this -> _interval * 2 ) ; } $ cmd .= "DS:" . $ field -> getEscapedName ( ) . ":" . $ field -> getType ( ) . ":" . $ heartbeat . ":" . $ field -> getMin ( ) . ":" . ( $ field -> getMax ( ) ) . " " ; } foreach ( $ this -> getRRAs ( ) as $ rra ) { if ( ! isset ( $ rra [ 'method' ] ) ) $ rra [ 'method' ] = 'AVERAGE' ; if ( ! isset ( $ rra [ 'xff' ] ) ) $ rra [ 'xff' ] = '0.6' ; $ cmd .= "RRA:$rra[method]:$rra[xff]:$rra[steps]:$rra[rows] " ; } system ( $ cmd , $ ret ) ; if ( $ ret != 0 ) throw new Kwf_Exception ( "Command failed" ) ; foreach ( $ initialValueDates as $ date ) { $ this -> record ( $ date , $ this -> getRecordValuesForDate ( $ date ) ) ; } } | erstellt rrd Datei |
1,557 | public function createSale ( Sale $ sale ) { $ createSaleRequest = new CreateSaleRequest ( $ this -> merchant , $ this -> environment ) ; return $ createSaleRequest -> execute ( $ sale ) ; } | Send the Sale to be created and return the Sale with tid and the status returned by Cielo . |
1,558 | public function getSale ( $ paymentId ) { $ querySaleRequest = new QuerySaleRequest ( $ this -> merchant , $ this -> environment ) ; return $ querySaleRequest -> execute ( $ paymentId ) ; } | Query a Sale on Cielo by paymentId |
1,559 | public function getRecurrentPayment ( $ recurrentPaymentId ) { $ queryRecurrentPaymentRequest = new queryRecurrentPaymentRequest ( $ this -> merchant , $ this -> environment ) ; return $ queryRecurrentPaymentRequest -> execute ( $ recurrentPaymentId ) ; } | Query a RecurrentPayment on Cielo by RecurrentPaymentId |
1,560 | public function cancelSale ( $ paymentId , $ amount = null ) { $ updateSaleRequest = new UpdateSaleRequest ( 'void' , $ this -> merchant , $ this -> environment ) ; $ updateSaleRequest -> setAmount ( $ amount ) ; return $ updateSaleRequest -> execute ( $ paymentId ) ; } | Cancel a Sale on Cielo by paymentId and speficying the amount |
1,561 | public function captureSale ( $ paymentId , $ amount = null , $ serviceTaxAmount = null ) { $ updateSaleRequest = new UpdateSaleRequest ( 'capture' , $ this -> merchant , $ this -> environment ) ; $ updateSaleRequest -> setAmount ( $ amount ) ; $ updateSaleRequest -> setServiceTaxAmount ( $ serviceTaxAmount ) ; return $ updateSaleRequest -> execute ( $ paymentId ) ; } | Capture a Sale on Cielo by paymentId and specifying the amount and the serviceTaxAmount |
1,562 | public static function getIncludes ( $ func ) { $ loader = new static ( ) ; call_user_func ( $ func , $ loader ) ; $ loader -> unregister ( ) ; $ config = new Config ( ) ; foreach ( $ loader -> getFilenames ( ) as $ file ) { $ config -> addFile ( $ file ) ; } return $ config ; } | Wrap a block of code in the autoloader and get a list of loaded classes . |
1,563 | public function loadClass ( $ class ) { foreach ( spl_autoload_functions ( ) as $ func ) { if ( is_array ( $ func ) && $ func [ 0 ] === $ this ) { continue ; } $ this -> classList -> push ( $ class ) ; if ( call_user_func ( $ func , $ class ) ) { break ; } } $ this -> classList -> next ( ) ; return true ; } | Loads the given class interface or trait . |
1,564 | public function getFilenames ( ) { $ files = [ ] ; foreach ( $ this -> classList -> getClasses ( ) as $ class ) { try { $ r = new \ ReflectionClass ( $ class ) ; foreach ( $ r -> getInterfaces ( ) as $ inf ) { $ name = $ inf -> getFileName ( ) ; if ( $ name && ! in_array ( $ name , $ files ) ) { $ files [ ] = $ name ; } } if ( ! in_array ( $ r -> getFileName ( ) , $ files ) ) { $ files [ ] = $ r -> getFileName ( ) ; } } catch ( \ ReflectionException $ e ) { } } return $ files ; } | Get an array of loaded file names in order of loading . |
1,565 | public function getFilenames ( ) { $ filenames = [ ] ; foreach ( $ this -> filenames as $ f ) { foreach ( $ this -> inclusiveFilters as $ filter ) { if ( ! preg_match ( $ filter , $ f ) ) { continue 2 ; } } foreach ( $ this -> exclusiveFilters as $ filter ) { if ( preg_match ( $ filter , $ f ) ) { continue 2 ; } } $ filenames [ ] = $ f ; } return $ filenames ; } | Get an array of file names that satisfy any added filters . |
1,566 | public function traverseFile ( array $ nodes , $ filename ) { foreach ( $ this -> visitors as $ visitor ) { if ( $ visitor instanceof AbstractNodeVisitor ) { $ visitor -> setFilename ( $ filename ) ; } } return $ this -> traverse ( $ nodes ) ; } | Transverse the file . |
1,567 | public function next ( ) { if ( isset ( $ this -> current -> next ) ) { $ this -> current = $ this -> current -> next ; } else { $ this -> current -> next = new ClassNode ( null , $ this -> current ) ; $ this -> current = $ this -> current -> next ; } } | Traverse to the next node in the list . |
1,568 | public function push ( $ value ) { if ( ! $ this -> current -> value ) { $ this -> current -> value = $ value ; } else { $ temp = $ this -> current ; $ this -> current = new ClassNode ( $ value , $ temp -> prev ) ; $ this -> current -> next = $ temp ; $ temp -> prev = $ this -> current ; if ( $ temp === $ this -> head ) { $ this -> head = $ this -> current ; } else { $ this -> current -> prev -> next = $ this -> current ; } } } | Insert a value at the current position in the list . |
1,569 | public function getClasses ( ) { $ classes = [ ] ; $ current = $ this -> head ; while ( $ current && $ current -> value ) { $ classes [ ] = $ current -> value ; $ current = $ current -> next ; } return array_filter ( $ classes ) ; } | Traverse the ClassList and return a list of classes . |
1,570 | public function create ( array $ options = [ ] ) { $ printer = new PrettyPrinter ( ) ; $ parser = $ this -> getParser ( ) ; $ options = array_merge ( [ 'dir' => true , 'file' => true , 'skip' => false , 'strict' => false ] , $ options ) ; $ traverser = $ this -> getTraverser ( $ options [ 'dir' ] , $ options [ 'file' ] , $ options [ 'skip' ] , $ options [ 'strict' ] ) ; return new ClassPreloader ( $ printer , $ parser , $ traverser ) ; } | Create a new class preloader instance . |
1,571 | protected function getTraverser ( $ dir , $ file , $ skip , $ strict ) { $ traverser = new NodeTraverser ( ) ; if ( $ dir ) { $ traverser -> addVisitor ( new DirVisitor ( $ skip ) ) ; } if ( $ file ) { $ traverser -> addVisitor ( new FileVisitor ( $ skip ) ) ; } if ( ! $ strict ) { $ traverser -> addVisitor ( new StrictTypesVisitor ( ) ) ; } return $ traverser ; } | Get the node traverser to use . |
1,572 | public function prepareOutput ( $ output , $ strict = false ) { if ( $ strict && version_compare ( PHP_VERSION , '7' ) < 1 ) { throw new RuntimeException ( 'Strict mode requires PHP 7 or greater.' ) ; } $ dir = dirname ( $ output ) ; if ( ! is_dir ( $ dir ) && ! mkdir ( $ dir , 0777 , true ) ) { throw new RuntimeException ( "Unable to create directory $dir." ) ; } $ handle = fopen ( $ output , 'w' ) ; if ( ! $ handle ) { throw new RuntimeException ( "Unable to open $output for writing." ) ; } if ( $ strict ) { fwrite ( $ handle , "<?php declare(strict_types=1);\n" ) ; } else { fwrite ( $ handle , "<?php\n" ) ; } return $ handle ; } | Prepare the output file and directory . |
1,573 | public function getCode ( $ file , $ comments = true ) { if ( ! is_string ( $ file ) || empty ( $ file ) ) { throw new RuntimeException ( 'Invalid filename provided.' ) ; } if ( ! is_readable ( $ file ) ) { throw new RuntimeException ( "Cannot open $file for reading." ) ; } if ( $ comments ) { $ content = file_get_contents ( $ file ) ; } else { $ content = php_strip_whitespace ( $ file ) ; } $ parsed = $ this -> parser -> parse ( $ content ) ; $ stmts = $ this -> traverser -> traverseFile ( $ parsed , $ file ) ; $ pretty = $ this -> printer -> prettyPrint ( $ stmts ) ; $ pretty = preg_replace ( '#^(<\?php)?[\s]*(/\*\*?.*?\*/)?[\s]*(declare[\s]*\([\s]*strict_types[\s]*=[\s]*1[\s]*\);)?#s' , '' , $ pretty ) ; return $ this -> getCodeWrappedIntoNamespace ( $ parsed , $ pretty ) ; } | Get a pretty printed string of code from a file while applying visitors . |
1,574 | protected function getCodeWrappedIntoNamespace ( array $ parsed , $ pretty ) { if ( $ this -> parsedCodeHasNamespaces ( $ parsed ) ) { $ pretty = preg_replace ( '/^\s*(namespace.*);/im' , '${1} {' , $ pretty , 1 ) . "\n}\n" ; } else { $ pretty = sprintf ( "namespace {\n%s\n}\n" , $ pretty ) ; } return preg_replace ( '/(?<!.)[\r\n]+/' , '' , $ pretty ) ; } | Wrap the code into a namespace . |
1,575 | protected function parsedCodeHasNamespaces ( array $ parsed ) { $ node = array_filter ( $ parsed , function ( $ value ) { return $ value instanceof NamespaceNode ; } ) ; return ! empty ( $ node ) ; } | Check parsed code for having namespaces . |
1,576 | public function pipe ( $ callback , ... $ arguments ) { if ( ! is_callable ( $ callback ) ) { return new PipeProxy ( $ this , $ callback ) ; } $ this -> value = $ callback ( ... $ this -> addValueToArguments ( $ arguments ) ) ; return $ this ; } | Perform an operation on the current value . |
1,577 | public function addValueToArguments ( array $ arguments ) : array { if ( ! in_array ( PIPED_VALUE , $ arguments , true ) ) { return array_merge ( [ $ this -> value ] , $ arguments ) ; } return array_map ( function ( $ argument ) { return $ argument === PIPED_VALUE ? $ this -> value : $ argument ; } , $ arguments ) ; } | Add the given value to the list of arguments . |
1,578 | public function createRequest ( $ url , $ method = 'GET' , array $ headers = [ ] , $ body = null ) { $ headers = array_merge ( $ headers , [ 'User-Agent' => strval ( $ this -> userAgent ) ] ) ; return new Request ( $ method , $ url , $ headers , $ body ) ; } | Creates a request object . |
1,579 | public static function create ( $ merchantId , $ sharedSecret , $ baseUrl = self :: EU_BASE_URL , UserAgentInterface $ userAgent = null ) { $ client = new Client ( [ 'base_uri' => $ baseUrl ] ) ; return new static ( $ client , $ merchantId , $ sharedSecret , $ userAgent ) ; } | Factory method to create a connector instance . |
1,580 | public function getCSVPayoutsSummaryReport ( array $ params = [ ] ) { return $ this -> get ( self :: $ path . '/payouts-summary-with-transactions?' . http_build_query ( $ params ) ) -> status ( '200' ) -> contentType ( 'text/csv' ) -> getBody ( ) ; } | Returns CSV summary . |
1,581 | public function generateToken ( array $ data ) { $ response = $ this -> post ( $ this -> getLocation ( ) . '/customer-token' , $ data ) -> status ( '200' ) -> contentType ( 'application/json' ) -> getJson ( ) ; return $ response ; } | Generates consumer token . |
1,582 | public function createOrder ( array $ data , $ klarnaIdempotencyKey = null ) { $ headers = [ 'Content-Type' => 'application/json' ] ; if ( ! is_null ( $ klarnaIdempotencyKey ) ) { $ headers [ 'Klarna-Idempotency-Key' ] = $ klarnaIdempotencyKey ; } return $ this -> request ( 'POST' , $ this -> getLocation ( ) . '/order' , $ headers , $ data !== null ? \ json_encode ( $ data ) : null ) -> status ( '200' ) -> contentType ( 'application/json' ) -> getJson ( ) ; } | Creates order using Customer Token . |
1,583 | public function fetch ( ) { parent :: fetch ( ) ; $ captures = [ ] ; foreach ( $ this [ 'captures' ] as $ capture ) { $ captureId = $ capture [ Capture :: ID_FIELD ] ; $ object = new Capture ( $ this -> connector , $ this -> getLocation ( ) , $ captureId ) ; $ object -> exchangeArray ( $ capture ) ; $ captures [ ] = $ object ; } $ this [ 'captures' ] = $ captures ; if ( isset ( $ this [ 'refunds' ] ) ) { $ refunds = [ ] ; foreach ( $ this [ 'refunds' ] as $ refund ) { $ refundId = null ; if ( isset ( $ refund [ Refund :: ID_FIELD ] ) ) { $ refundId = $ refund [ Refund :: ID_FIELD ] ; } $ object = new Refund ( $ this -> connector , $ this -> getLocation ( ) , $ refundId ) ; $ object -> exchangeArray ( $ refund ) ; $ refunds [ ] = $ object ; } $ this [ 'refunds' ] = $ refunds ; } return $ this ; } | Fetches the order . |
1,584 | public function refund ( array $ data ) { $ refund = new Refund ( $ this -> connector , $ this -> getLocation ( ) ) ; $ refund -> create ( $ data ) ; return $ refund ; } | Refunds an amount of a captured order . |
1,585 | public function createCapture ( array $ data ) { $ capture = new Capture ( $ this -> connector , $ this -> getLocation ( ) ) ; $ capture -> create ( $ data ) ; $ this [ 'captures' ] [ ] = $ capture ; return $ capture ; } | Capture all or part of an order . |
1,586 | public function fetchCapture ( $ captureId ) { if ( $ this -> offsetExists ( 'captures' ) ) { foreach ( $ this [ 'captures' ] as $ capture ) { if ( $ capture -> getId ( ) !== $ captureId ) { continue ; } return $ capture -> fetch ( ) ; } } $ capture = new Capture ( $ this -> connector , $ this -> getLocation ( ) , $ captureId ) ; $ capture -> fetch ( ) ; $ this [ 'captures' ] [ ] = $ capture ; return $ capture ; } | Fetches the specified capture . |
1,587 | public function fetchRefund ( $ refundId ) { if ( $ this -> offsetExists ( 'refunds' ) ) { foreach ( $ this [ 'refunds' ] as $ refund ) { if ( $ refund -> getId ( ) !== $ refundId ) { continue ; } return $ refund ; } } $ refund = new Refund ( $ this -> connector , $ this -> getLocation ( ) , $ refundId ) ; $ refund -> fetch ( ) ; $ this [ 'refunds' ] [ ] = $ refund ; return $ refund ; } | Fetches the specified refund . |
1,588 | public function fetchCaptures ( ) { $ captures = new Capture ( $ this -> connector , $ this -> getLocation ( ) ) ; $ captures = $ captures -> fetch ( ) -> getArrayCopy ( ) ; foreach ( $ captures as $ id => $ capture ) { $ captures [ $ id ] = new Capture ( $ this -> connector , $ this -> getLocation ( ) , $ capture [ 'capture_id' ] ) ; $ captures [ $ id ] -> exchangeArray ( $ capture ) ; } return $ captures ; } | Fetches all captures . |
1,589 | public function create ( array $ data ) { $ response = $ this -> post ( self :: $ path , $ data ) -> status ( '201' ) -> contentType ( 'application/json' ) -> getJson ( ) ; return $ response ; } | Creates a new settlement . |
1,590 | public function retrieveSettlement ( $ settlementId , $ keyId ) { $ response = $ this -> request ( 'GET' , self :: $ path . "/$settlementId" , [ 'KeyId' => $ keyId ] ) -> status ( '200' ) -> contentType ( 'application/json' ) -> getJson ( ) ; return $ response ; } | Retrieve an existing settlement . |
1,591 | public function retrieveOrderSettlement ( $ orderId , $ keyId ) { $ response = $ this -> request ( 'GET' , self :: $ path . "/order/$orderId" , [ 'KeyId' => $ keyId ] ) -> status ( '200' ) -> contentType ( 'application/json' ) -> getJson ( ) ; return $ response ; } | Retrieves a settled order s settlement . |
1,592 | public function setField ( $ key , $ name , $ version = '' , array $ options = [ ] ) { $ field = [ 'name' => $ name ] ; if ( ! empty ( $ version ) ) { $ field [ 'version' ] = $ version ; } if ( ! empty ( $ options ) ) { $ field [ 'options' ] = $ options ; } $ this -> fields [ $ key ] = $ field ; return $ this ; } | Sets the specified field . |
1,593 | public static function createDefault ( ) { $ agent = new static ( ) ; $ options = [ 'Guzzle/' . ClientInterface :: VERSION ] ; if ( extension_loaded ( 'curl' ) ) { $ options [ ] = 'curl/' . curl_version ( ) [ 'version' ] ; } return $ agent -> setField ( 'Library' , static :: NAME , static :: VERSION , $ options ) -> setField ( 'OS' , php_uname ( 's' ) , php_uname ( 'r' ) ) -> setField ( 'Language' , 'PHP' , phpversion ( ) ) ; } | Creates the default user agent . |
1,594 | public function disable ( ) { if ( empty ( $ this [ static :: ID_FIELD ] ) ) { throw new \ RuntimeException ( 'HPP Session ID is not defined' ) ; } $ this -> delete ( $ this -> getLocation ( ) ) -> status ( '204' ) ; return $ this ; } | Disables HPP session . |
1,595 | public function update ( array $ data ) { if ( empty ( $ this [ static :: ID_FIELD ] ) ) { throw new \ RuntimeException ( static :: ID_FIELD . ' property is not defined' ) ; } return $ this -> put ( $ this -> getLocation ( ) , $ data ) -> status ( '200' ) -> contentType ( 'application/json' ) -> getJson ( ) ; } | Updates the setup options for a specific button key . |
1,596 | public function decline ( array $ data = null ) { $ this -> delete ( $ this -> getLocation ( ) , $ data ) -> status ( '204' ) ; return $ this ; } | Declines an authorized order identified by the authorization token . |
1,597 | public function getAllPayouts ( array $ params = [ ] ) { return $ this -> get ( self :: $ path . '?' . http_build_query ( $ params ) ) -> status ( '200' ) -> contentType ( 'application/json' ) -> getJson ( ) ; } | Returns a collection of payouts . |
1,598 | public function fetch ( ) { $ data = $ this -> get ( $ this -> getLocation ( ) ) -> status ( '200' ) -> contentType ( 'application/json' ) -> getJson ( ) ; $ this -> exchangeArray ( $ data ) ; return $ this ; } | Fetches the resource . |
1,599 | protected function request ( $ method , $ url , array $ headers = [ ] , $ body = '' ) { $ debug = getenv ( 'DEBUG_SDK' ) || defined ( 'DEBUG_SDK' ) ; $ request = $ this -> connector -> createRequest ( $ url , $ method , $ headers , $ body ) ; if ( $ debug ) { $ clientConfig = $ this -> connector -> getClient ( ) -> getConfig ( ) ; $ baseUri = isset ( $ clientConfig [ 'base_uri' ] ) ? $ clientConfig [ 'base_uri' ] : '' ; $ debugHeaders = $ request -> getHeaders ( ) ; $ debugHeaders = json_encode ( $ debugHeaders ) ; echo <<<DEBUG_BODYDEBUG MODE: Request>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {$method} : {$baseUri}{$url}Headers : $debugHeaders Body : {$request->getBody()}\nDEBUG_BODY ; } $ response = $ this -> connector -> send ( $ request ) ; if ( $ debug ) { $ debugHeaders = json_encode ( $ response -> getHeaders ( ) ) ; echo <<<DEBUG_BODYDEBUG MODE: Response<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Headers : $debugHeaders Body : {$response->getBody()}\nDEBUG_BODY ; } return new ResponseValidator ( $ response ) ; } | Sends a HTTP request to the specified url . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.