idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
18,100
public static function unregisterStreamWrapperClass ( ) { $ unregisterFunction = self :: getStreamWrapperUnregisterFunction ( ) ; if ( ! isset ( self :: $ protocolName ) ) { throw new \ RuntimeException ( sprintf ( 'Scheme name not found for %s' , __CLASS__ ) ) ; } @ $ unregisterFunction ( self :: $ protocolName ) ; }
Registers the stream wrapper to handle the specified protocolName
18,101
public function stream_flush ( ) { if ( ! $ this -> getResource ( ) ) { return false ; } $ buffer = $ this -> getDataBuffer ( ) ; $ bufferWritten = $ buffer ; $ retVal = true ; if ( ! empty ( $ buffer ) ) { $ object = $ this -> getResource ( ) -> getObject ( ) ; $ mimetype = $ this -> getService ( ) -> guessFileType ( $ this -> getResource ( ) -> getResourceName ( ) ) ; $ object -> content_type = $ mimetype ; $ object -> setData ( $ buffer ) ; $ object -> Create ( ) ; } if ( strlen ( $ bufferWritten ) == strlen ( $ buffer ) ) { $ this -> setDataBuffer ( null ) ; } else { $ this -> setDataBuffer ( $ buffer ) ; } $ this -> setDataBuffer ( null ) ; return $ retVal ; }
Flush the data buffer to the CDN .
18,102
public function reset ( ) { $ this -> setPosition ( 0 ) ; $ this -> setOnWriteDataMode ( false ) ; $ this -> setDataBuffer ( null ) ; $ this -> setResource ( null ) ; }
reset the variable
18,103
public function initFromPath ( $ path ) { $ this -> setPosition ( 0 ) ; $ this -> setDataBuffer ( null ) ; $ resource = $ this -> getService ( ) -> createResourceFromPath ( $ path ) ; if ( ! $ resource ) { return false ; } $ this -> setResource ( $ resource ) ; return $ this ; }
creates the resource the container and the object by the path given
18,104
public function appendDataBuffer ( $ data ) { if ( is_null ( $ this -> dataBuffer ) ) { $ this -> dataBuffer = $ data ; } else { $ this -> dataBuffer .= $ data ; } return $ this ; }
Append some data to the current property data
18,105
public function appendPosition ( $ length ) { $ this -> dataPosition = ( int ) $ this -> dataPosition ; $ this -> dataPosition += ( int ) $ length ; return $ this ; }
sum the int of the position to the var given
18,106
public function field_get ( $ type , $ com = '' ) { if ( empty ( $ com ) ) { $ fn = BLIBRARIESFRAMEWORKPATH . 'mvc' . DIRECTORY_SEPARATOR . 'field' . DIRECTORY_SEPARATOR . $ type . '.php' ; $ class = 'BControllerField_' . $ type ; } else { $ fn = BCOMPONENTSAPPLICATIONPATH . $ com . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR . $ type . '.php' ; if ( ! file_exists ( $ fn ) ) { $ fn = BCOMPONENTSFRAMEWORKPATH . $ com . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR . $ type . '.php' ; } $ class = 'BControllerField_' . $ com . '_' . $ type ; } if ( ! file_exists ( $ fn ) ) { if ( DEBUG_MODE ) { BDebug :: error ( 'File "' . $ fn . '" does not exist! type=' . $ type . ', com=' . $ com ) ; } return NULL ; } require_once ( $ fn ) ; $ field = new $ class ; $ field -> controller = $ this ; $ field -> com = $ com ; return $ field ; }
Load fields objects by component & field type
18,107
public function softmodule_fields_list ( $ fview , $ fcontroller = NULL ) { $ mylist = $ this -> softmodules_list ( ) ; $ myitm = NULL ; foreach ( $ mylist as $ itm ) { if ( $ itm -> view == $ fview ) { $ myitm = $ itm ; } } if ( empty ( $ myitm ) ) { return false ; } $ params = array ( ) ; foreach ( $ myitm -> params as $ p ) { $ fld = $ this -> field_get ( $ p -> fieldtype , $ p -> com ) ; if ( empty ( $ fld ) ) { continue ; } $ fld -> controller = empty ( $ fcontroller ) ? $ this : $ fcontroller ; $ fld -> name = $ p -> name ; $ fld -> id = $ p -> id ; $ fld -> fieldtype = $ p -> fieldtype ; $ fld -> params = $ p -> params ; $ fld -> prepare ( ) ; $ params [ ] = $ fld ; } return $ params ; }
Load fields objects list ...
18,108
public function LoadModel ( $ mdlname = '' ) { if ( empty ( $ mdlname ) ) { bimport ( 'mvc.model' ) ; return new BModel ( ) ; } $ fn = BCOMPONENTSAPPLICATIONPATH . $ this -> componentname . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . $ mdlname . '.php' ; if ( ! file_exists ( $ fn ) ) { $ fn = BCOMPONENTSFRAMEWORKPATH . $ this -> componentname . DIRECTORY_SEPARATOR . 'models' . DIRECTORY_SEPARATOR . $ mdlname . '.php' ; } $ class = 'Model_' . $ this -> componentname . '_' . $ mdlname ; if ( ! file_exists ( $ fn ) ) { echo ( 'File "' . $ fn . '" does not exist!' ) ; return NULL ; } require_once ( $ fn ) ; $ model = new $ class ; $ model -> controller = $ this ; return $ model ; }
Load the model of current component by alias
18,109
public function LoadView ( $ viewname ) { $ fn = BCOMPONENTSAPPLICATIONPATH . $ this -> componentname . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $ viewname . '.php' ; if ( ! file_exists ( $ fn ) ) { $ fn = BCOMPONENTSFRAMEWORKPATH . $ this -> componentname . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $ viewname . '.php' ; } $ class = 'View_' . $ this -> componentname . '_' . $ viewname ; if ( ! file_exists ( $ fn ) ) { return NULL ; } require_once ( $ fn ) ; $ view = new $ class ; $ view -> controller = $ this ; $ view -> componentname = $ this -> componentname ; $ view -> templatename = $ this -> templatename ; $ view -> viewname = $ viewname ; $ view -> init ( ) ; return $ view ; }
Load the view of current component by alias
18,110
public function idIsDuplicate ( string $ id ) : bool { $ id = strtolower ( $ id ) ; return isset ( $ this -> byId [ $ id ] ) && count ( $ this -> byId [ $ id ] ) > 1 ; }
Tells whether there is more than one requirement identified by the id . If there are none this returns false .
18,111
public function setJSFromFile ( string $ filename , Scopable $ scope = null , bool $ relativeToRootPath = true ) : void { $ this -> jsElement = new HtmlFromFile ( $ filename , $ scope , $ relativeToRootPath ) ; }
Sets the script outputed in the JS section
18,112
public function setCSSFromFile ( string $ filename , Scopable $ scope = null , bool $ relativeToRootPath = true ) : void { $ this -> cssElement = new HtmlFromFile ( $ filename , $ scope , $ relativeToRootPath ) ; }
Sets the script outputed in the CSS section
18,113
public function setAdditionalElementFromFile ( string $ filename , Scopable $ scope = null , bool $ relativeToRootPath = true ) : void { $ this -> additionalElement = new HtmlFromFile ( $ filename , $ scope , $ relativeToRootPath ) ; }
Sets the additional items outputed below the JS and CSS sections
18,114
public function load ( FilesystemResource $ resource ) { if ( ! $ this -> validateExtension ( $ resource ) ) { return false ; } return $ this -> transform ( $ resource ) ; }
Load config as Array from resource
18,115
protected function setAssigns ( array & $ options ) { $ assigns = $ this -> controller -> assigns ( ) ; if ( isset ( $ options [ 'assigns' ] ) && is_array ( $ options [ 'assigns' ] ) ) { foreach ( $ options [ 'assigns' ] as $ name => $ value ) { $ assigns -> set ( $ name , $ value ) ; } } $ options [ 'assigns' ] = $ assigns ; }
Set assigns for template Checks if the assigns value was passed as option and sets all the assigns set there to the Assigns object . If the value for assigns isn t an array it is ignored . Then the assigns value is set to the Assigns object which will be used when rendering the template .
18,116
protected function generateRenderOptions ( array & $ options ) { $ i18n = $ this -> controller -> getService ( 'i18n' ) ; $ defaultLocales = $ i18n -> fallbacks ( ) ; array_unshift ( $ defaultLocales , $ i18n -> defaultLocale ( ) ) ; $ format = $ this -> controller -> request ( ) ? $ this -> controller -> request ( ) -> format ( ) : null ; if ( isset ( $ options [ 'details' ] ) ) { $ details = $ options [ 'details' ] ; } else { $ details = [ ] ; } if ( ! isset ( $ details [ 'formats' ] ) ) { $ details [ 'formats' ] = [ ] ; } if ( $ format ) { $ details [ 'formats' ] [ ] = $ format ; } if ( ! isset ( $ details [ 'handlers' ] ) ) { $ details [ 'handlers' ] = [ ] ; } $ details [ 'handlers' ] = array_merge ( array_keys ( $ this -> actionView ( ) -> handlers ( ) ) , $ details [ 'handlers' ] ) ; if ( ! isset ( $ details [ 'locale' ] ) ) { $ details [ 'locale' ] = [ ] ; } $ details [ 'locale' ] = array_merge ( $ defaultLocales , $ details [ 'locale' ] ) ; $ options [ 'details' ] = $ details ; $ layout = $ this -> controller -> layout ( ) ; if ( $ layout === null ) { $ options [ 'layout' ] = 'application' ; } elseif ( is_string ( $ layout ) ) { $ options [ 'layout' ] = $ layout ; } }
Generate render options Sets the default details for template rendering .
18,117
public function leaveNode ( Node $ node ) { if ( $ this -> phpClass instanceof PhpClass ) { if ( $ node instanceof Class_ ) { if ( ! empty ( $ node -> extends ) && count ( $ node -> extends -> parts ) > 0 ) { $ this -> phpClass -> setExtends ( implode ( '\\' , $ node -> extends -> parts ) ) ; } if ( ! empty ( $ node -> implements ) && is_array ( $ node -> implements ) ) { foreach ( $ node -> implements as $ implements ) { $ this -> phpClass -> setImplements ( implode ( '\\' , $ implements -> parts ) ) ; } } if ( $ node -> type === 0 ) { $ this -> phpClass -> setClassType ( PhpClass :: TYPE_CLASS ) ; } elseif ( $ node -> type === 16 ) { $ this -> phpClass -> setClassType ( PhpClass :: TYPE_ABSTRACT_CLASS ) ; } elseif ( $ node -> type === 32 ) { $ this -> phpClass -> setClassType ( PhpClass :: TYPE_FINAL_CLASS ) ; } $ this -> phpClass -> setClass ( $ node -> name ) ; } elseif ( $ node instanceof Interface_ ) { if ( ! empty ( $ node -> extends ) && is_array ( $ node -> extends ) ) { foreach ( $ node -> extends as $ implements ) { $ this -> phpClass -> setImplements ( implode ( '\\' , $ implements -> parts ) ) ; } } $ this -> phpClass -> setClassType ( PhpClass :: TYPE_INTERFACE ) ; $ this -> phpClass -> setClass ( $ node -> name ) ; } elseif ( $ node instanceof Trait_ ) { $ this -> phpClass -> setClassType ( PhpClass :: TYPE_TRAIT ) ; $ this -> phpClass -> setClass ( $ node -> name ) ; } elseif ( $ node instanceof Namespace_ ) { $ this -> phpClass -> setNamespace ( implode ( '\\' , $ node -> name -> parts ) ) ; } elseif ( $ node instanceof TraitUse ) { if ( ! empty ( $ node -> traits ) && is_array ( $ node -> traits ) ) { foreach ( $ node -> traits as $ trait ) { $ this -> phpClass -> setTraits ( implode ( '\\' , $ trait -> parts ) ) ; } } } } }
This code can evaluate the data from the parser . It sorts out which object type we are dealing with and passes this to the PhpClass
18,118
public function GetValue ( $ key ) { $ resources = $ this -> GetList ( ) ; $ actionLower = strtolower ( $ this -> ActionValue ) ; $ keyLower = strtolower ( $ key ) ; $ actionExists = array_key_exists ( $ actionLower , $ resources ) ; $ keyExist = $ actionExists ? array_key_exists ( $ keyLower , $ resources [ $ actionLower ] ) : false ; if ( $ keyExist ) { return $ resources [ $ actionLower ] [ $ keyLower ] [ F_controller_resource :: F_CONTROLLER_RESOURCE_VALUE ] ; } else { return "???" ; } }
Get the resource by module action and key .
18,119
public function GetComment ( $ key ) { $ resources = $ this -> GetList ( ) ; $ actionExists = array_key_exists ( $ this -> ActionValue , $ resources ) ; $ keyExist = $ actionExists ? array_key_exists ( $ key , $ resources [ $ this -> ActionValue ] ) : false ; if ( $ keyExist ) { return $ resources [ $ this -> ActionValue ] [ $ key ] [ F_controller_resource :: F_CONTROLLER_RESOURCE_COMMENT ] ; } else { return "???" ; } }
Get the resource comment by module action and key .
18,120
public function removeDir ( $ dir , ? callable $ onRemoveCallback = null ) : void { if ( is_dir ( $ dir ) ) { $ objects = scandir ( $ dir ) ; foreach ( $ objects as $ object ) { if ( '.' != $ object && '..' != $ object ) { if ( 'dir' == filetype ( $ dir . DIRECTORY_SEPARATOR . $ object ) ) { $ this -> removeDir ( $ dir . DIRECTORY_SEPARATOR . $ object , $ onRemoveCallback ) ; } else { unlink ( $ pathName = $ dir . DIRECTORY_SEPARATOR . $ object ) ; if ( null !== $ onRemoveCallback ) { call_user_func ( $ onRemoveCallback , $ pathName ) ; } } } } reset ( $ objects ) ; rmdir ( $ dir ) ; if ( null !== $ onRemoveCallback ) { call_user_func ( $ onRemoveCallback , $ dir ) ; } } }
Remove directory recursively .
18,121
public function generate ( ) { switch ( $ this -> properties [ 'node' ] ) { case 'post' : return new GeneratePost ( $ this -> prepareConfig ( $ this -> config ) , $ this -> properties ) ; break ; case 'page' : return new GeneratePage ( $ this -> prepareConfig ( $ this -> config ) , $ this -> properties ) ; break ; default : return ; break ; } }
Create class instance of GenerateNode
18,122
public function get_cached_file ( $ label ) { $ filename = $ this -> cache_path . $ this -> safe_filename ( $ label ) . $ this -> cache_extension ; if ( file_exists ( $ filename ) ) return file_get_contents ( $ filename ) ; return false ; }
Non - existing method in SimpleCache Fetch the cache without regarding its expiry
18,123
public function details ( ) { return array_intersect_key ( count ( $ this -> _details ) ? $ this -> _details : array ( ) , array_flip ( $ this -> _public_details ) ) ; }
Return public user details
18,124
public static function base ( ) { $ base = $ _SERVER [ 'SERVER_NAME' ] ; $ url = Registry :: getUrl ( ) ; if ( ! empty ( $ url ) ) { $ base .= substr ( $ _SERVER [ 'REQUEST_URI' ] , 0 , strpos ( $ _SERVER [ 'REQUEST_URI' ] , Registry :: getUrl ( ) ) ) ; } else { $ base .= substr ( $ _SERVER [ 'REQUEST_URI' ] , 0 ) ; } $ protocol = ( isset ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] != "off" ) ? "https" : "http" ; return $ protocol . '://' . $ base ; }
This method returns the base url
18,125
public static function assets ( $ assetName = null ) { $ base = $ _SERVER [ 'SERVER_NAME' ] ; $ url = Registry :: getUrl ( ) ; if ( ! empty ( $ url ) ) { $ base .= substr ( $ _SERVER [ 'REQUEST_URI' ] , 0 , strpos ( $ _SERVER [ 'REQUEST_URI' ] , Registry :: getUrl ( ) ) ) ; } else { $ base .= substr ( $ _SERVER [ 'REQUEST_URI' ] , 0 ) ; } $ protocol = ( isset ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] != "off" ) ? "https" : "http" ; return $ protocol . '://' . $ base . 'public/' . $ assetName ; }
This method returns the assets url
18,126
public static function link ( $ linkParams = null ) { if ( $ linkParams === null ) { $ link_params = null ; } elseif ( is_array ( $ linkParams ) ) { $ link_params = join ( Registry :: getConfig ( ) [ 'url_component_separator' ] , $ linkParams ) ; } else { $ params = func_get_args ( ) ; $ link_params = join ( Registry :: getConfig ( ) [ 'url_component_separator' ] , $ params ) ; } $ base = $ _SERVER [ 'SERVER_NAME' ] ; $ url = Registry :: getUrl ( ) ; if ( ! empty ( $ url ) ) { $ base .= substr ( $ _SERVER [ 'REQUEST_URI' ] , 0 , strpos ( $ _SERVER [ 'REQUEST_URI' ] , Registry :: getUrl ( ) ) ) ; } else { $ base .= substr ( $ _SERVER [ 'REQUEST_URI' ] , 0 ) ; } $ protocol = ( isset ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] != "off" ) ? "https" : "http" ; return $ protocol . '://' . $ base . $ link_params ; }
This method returns the url string .
18,127
public function addHandler ( $ name , $ handler , $ priority = self :: PRIORITY_DEFAULT ) { $ priority = ( int ) $ priority ; if ( $ priority >= self :: PRIORITY_MIN || $ priority < self :: PRIORITY_MAX ) { throw new InvalidArgumentException ( "Invalid event priority" ) ; } $ isObject = false ; if ( is_array ( $ handler ) ) { $ isObject = is_object ( $ handler [ 0 ] ) ; $ key = sprintf ( "%s%s%s" , $ isObject ? get_class ( $ handler [ 0 ] ) : $ handler [ 0 ] , $ isObject ? "->" : "::" , $ handler [ 1 ] ) ; } else { $ key = $ handler ; } $ addHandler = true ; if ( empty ( $ this -> handlers [ $ name ] ) ) { $ this -> handlers [ $ name ] = [ ] ; } else if ( isset ( $ this -> handlers [ $ name ] [ $ key ] ) ) { if ( $ isObject ) { $ this -> key = $ key . " " ; $ handlers = array_filter ( $ this -> handlers [ $ name ] , [ $ this , 'filterHandlers' ] , ARRAY_FILTER_USE_KEY ) ; $ handlers [ $ key ] = $ this -> handlers [ $ name ] [ $ key ] ; foreach ( $ handlers as $ existing ) { if ( $ handler [ 0 ] === $ existing [ 1 ] [ 0 ] ) { $ addHandler = false ; break ; } if ( $ addHandler ) { $ key = sprintf ( "%s #%d" , $ key , sizeof ( $ handlers ) + 1 ) ; } } } else { $ addHandler = false ; } } if ( $ addHandler ) { $ this -> handlers [ $ name ] [ $ key ] = [ $ priority , $ handler ] ; unset ( $ this -> orderedHandlers [ $ name ] ) ; } if ( $ this -> debug && ! in_array ( $ name , self :: $ debugEvents ) ) { $ debugArgs = new Args ( [ 'name' => $ name , 'handler' => $ handler , 'added' => $ addHandler , 'source' => 'core:event:debug' , 'level' => $ addHandler ? E_NOTICE : E_WARNING , ] ) ; $ this -> fire ( ':onAddHandler:' , $ debugArgs ) ; } }
Adds event handler .
18,128
public function dropHandlers ( $ name = '' , $ handler = null ) { if ( in_array ( $ name , self :: $ debugEvents ) ) { throw new InvalidArgumentException ( "Cannot drop debug event" ) ; } if ( $ this -> debug ) { $ debugArgs = new Args ( [ 'name' => $ name , 'handler' => $ handler , 'source' => 'core:event:debug' , 'level' => E_NOTICE , ] ) ; $ this -> fire ( ':onDropHandlers:' , $ debugArgs ) ; } $ this -> runByHandler ( $ name , $ handler , [ $ this , 'deleteHandler' ] ) ; }
Drops event handlers .
18,129
public function disableHandler ( $ name ) { if ( in_array ( $ name , self :: $ debugEvents ) ) { throw new InvalidArgumentException ( "Cannot disable debug event" ) ; } if ( $ this -> debug ) { $ debugArgs = new Args ( [ 'name' => $ name , 'source' => 'core:event:debug' , 'level' => E_NOTICE , ] ) ; $ this -> fire ( ':onDisableHandler:' , $ debugArgs ) ; } $ this -> disabledEvents [ $ name ] = true ; }
Disables handler .
18,130
public function enableHandler ( $ name ) { if ( $ this -> debug ) { $ debugArgs = new Args ( [ 'name' => $ name , 'source' => 'core:event:debug' , 'level' => E_NOTICE , ] ) ; $ this -> fire ( ':onEnableHandler:' , $ debugArgs ) ; } unset ( $ this -> disabledEvents [ $ name ] ) ; }
Enables handler .
18,131
public function hasHandlers ( $ name , $ handler = null ) { $ args = new Args ; $ this -> runByHandler ( $ name , $ handler , [ $ this , 'hasHandler' ] , $ args ) ; $ result = $ args -> get ( 'hasHandler' ) ; return $ result ; }
Returns true if there are any handlers for specified event .
18,132
public function getHandlers ( $ name = null ) { $ result = is_null ( $ name ) ? $ this -> handlers : $ this -> handlers [ $ name ] ; return $ result ; }
Returns handlers for passed event or all .
18,133
protected function deleteHandler ( I_Registry $ args , $ name , $ index = null ) { $ cleanupAllHandlers = is_null ( $ index ) ; if ( ! $ cleanupAllHandlers ) { unset ( $ this -> handlers [ $ name ] [ $ index ] ) ; if ( sizeof ( $ this -> handlers [ $ name ] ) ) { ksort ( $ this -> handlers [ $ name ] ) ; unset ( $ this -> orderedHandlers [ $ name ] ) ; } else { $ cleanupAllHandlers = true ; } } if ( $ cleanupAllHandlers ) { unset ( $ this -> handlers [ $ name ] , $ this -> orderedHandlers [ $ name ] ) ; } }
Deletes handler .
18,134
protected function hasHandler ( I_Registry $ args , $ name , $ index = null ) { $ result = is_null ( $ index ) ? ! empty ( $ this -> handlers [ $ name ] ) : true ; $ args -> set ( 'hasHandler' , $ result ) ; return $ result ; }
Sets up hasHandler flag .
18,135
protected function sortEvents ( $ name ) { $ priorities = [ ] ; foreach ( $ this -> orderedHandlers [ $ name ] as $ key => $ row ) { if ( is_array ( $ row ) ) { $ priorities [ $ key ] = $ row [ 0 ] ; } } Arrays :: adaptOrderCol ( $ priorities ) ; foreach ( $ priorities as $ key => $ priority ) { $ this -> orderedHandlers [ $ name ] [ $ key ] [ 0 ] = $ priority ; } Arrays :: sortByCol ( $ this -> orderedHandlers [ $ name ] , 0 , SORT_NUMERIC , SORT_ASC ) ; }
Modifies priorities and sorts events .
18,136
public function show ( $ template = '.app/system/helper/pagination/default' ) { $ rand = rand ( 0 , 2 ) ; $ tpl = new Template ( $ template , 'pagination_' . $ rand , 0 ) ; $ tpl -> assign ( [ 'paginationFirst' => $ this -> _buttonFirst , 'paginationLast' => $ this -> _buttonLast , 'paginationBefore' => $ this -> _buttonBefore , 'paginationAfter' => $ this -> _buttonAfter , 'currentPage' => $ this -> _currentPage , 'paginationFirstBefore' => $ this -> _paginationFirstBefore , 'paginationLastAfter' => $ this -> _paginationLastAfter , 'urlFirst' => preg_replace ( '#\{page\}#isU' , 1 , $ this -> _url ) , 'urlLast' => preg_replace ( '#\{page\}#isU' , $ this -> _nbrPage , $ this -> _url ) , 'urlBefore' => preg_replace ( '#\{page\}#isU' , $ this -> _currentPage - 1 , $ this -> _url ) , 'urlAfter' => preg_replace ( '#\{page\}#isU' , $ this -> _currentPage + 1 , $ this -> _url ) , 'pagination' => $ this -> _paginationList , 'totalPage' => $ this -> _paginationTotalPage , 'nbrPage' => $ this -> _nbrPage ] ) ; return $ tpl -> show ( ) ; }
display the pagination
18,137
public function getData ( $ data = [ ] ) { for ( $ i = ( ( ( $ this -> _byPage * $ this -> _currentPage ) - $ this -> _byPage ) ) ; $ i <= ( ( $ this -> _byPage * $ this -> _currentPage ) - 1 ) ; $ i ++ ) { if ( isset ( $ data [ $ i ] ) ) { array_push ( $ this -> _data , $ data [ $ i ] ) ; } } return $ this -> _data ; }
get the data to be displayed from all data
18,138
protected function getStaticElementHelper ( ) { if ( $ this -> staticElementHelper ) { return $ this -> staticElementHelper ; } $ renderer = $ this -> getView ( ) ; if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> staticElementHelper = $ renderer -> plugin ( $ this -> defaultStaticElementHelper ) ; } if ( ! $ this -> staticElementHelper instanceof FormStatic ) { $ this -> staticElementHelper = new FormStatic ( ) ; $ this -> staticElementHelper -> setView ( $ renderer ) ; } return $ this -> staticElementHelper ; }
Retrieve the FormStatic helper
18,139
protected function renderAttribute ( $ name , $ value = null ) { if ( $ value === null ) { return $ name ; } if ( is_array ( $ value ) ) { $ value = implode ( ' ' , $ value ) ; } return vsprintf ( '%s="%s"' , [ $ name , Html :: escape ( ( string ) $ value ) , ] ) ; }
Render a single attribute in a node .
18,140
protected function renderAttributes ( ) { return ArrayMap :: of ( $ this -> attributes ) -> map ( function ( $ value , $ name ) { return $ this -> renderAttribute ( $ name , $ value ) ; } ) -> join ( ' ' ) ; }
Render the attributes part of the opening tag .
18,141
protected function renderContent ( ) { if ( is_string ( $ this -> content ) || $ this -> content instanceof SafeHtmlWrapper || $ this -> content instanceof SafeHtmlProducerInterface ) { return Html :: escape ( $ this -> content ) ; } elseif ( $ this -> content instanceof RenderableInterface ) { return Html :: escape ( $ this -> content -> render ( ) ) ; } elseif ( is_array ( $ this -> content ) || $ this -> content instanceof ArrayableInterface ) { return ArrayList :: of ( $ this -> content ) -> map ( function ( $ child ) { if ( is_string ( $ child ) || $ child instanceof SafeHtmlWrapper || $ child instanceof SafeHtmlProducerInterface ) { return Html :: escape ( $ child ) ; } elseif ( $ child instanceof RenderableInterface ) { return Html :: escape ( $ child -> render ( ) ) ; } throw new NodeChildRenderingException ( $ child ) ; } ) -> join ( ) ; } throw new NodeRenderingException ( $ this -> content ) ; }
Render the content of the tag .
18,142
public function render ( ) { $ result = $ this -> spec -> check ( $ this -> attributes ) ; if ( $ result -> failed ( ) ) { throw new InvalidAttributesException ( $ result ) ; } $ attributes = $ this -> renderAttributes ( ) ; if ( strlen ( $ attributes ) ) { $ attributes = ' ' . $ attributes ; } if ( $ this -> selfClosing ) { return vsprintf ( '<%s%s/>' , [ $ this -> tagName , $ attributes ] ) ; } return vsprintf ( '<%s%s>%s</%s>' , [ $ this -> tagName , $ attributes , $ this -> renderContent ( ) , $ this -> tagName , ] ) ; }
Render the Node .
18,143
public function dispatch ( $ url , Request $ request , Response $ response ) { $ output = $ this -> resolveOutput ( $ url , $ request -> isAjax ( ) ) ; if ( is_object ( $ output ) ) { if ( $ output instanceof ElementInterface ) { $ response -> addHeader ( "X-Loops-ID" , $ output -> getLoopsId ( ) ) ; } $ output = $ this -> display ( $ output , $ request , $ response ) ; } $ response -> setHeader ( ) ; return $ output ; }
Dispatches a web request to an url and returns the contents to display
18,144
public static function getParameterCount ( $ pageclass ) { if ( is_object ( $ pageclass ) ) { $ pageclass = get_class ( $ pageclass ) ; } $ count = array_count_values ( explode ( "\\" , $ pageclass ) ) ; return array_key_exists ( "_" , $ count ) ? $ count [ "_" ] : 0 ; }
Counts the number of the needed page parameter given the classname or an object
18,145
private function display ( $ element , Request $ request , Response $ response ) { $ loops = $ this -> getLoops ( ) ; $ renderer = $ loops -> getService ( "renderer" ) ; $ appearance = [ ] ; if ( $ request -> isAjax ( ) ) { $ renderer -> addExtraAppearance ( "ajax" ) ; } $ renderer -> addExtraAppearance ( ( string ) $ response -> status_code ) ; return $ renderer -> render ( $ element , $ appearance ) ; }
Renders an object with the renderer
18,146
public static function getPagePathFromClassname ( $ classname , $ page_parameter = [ ] , Loops $ loops = NULL ) { $ count = count ( $ page_parameter ) ; if ( ! $ routes = self :: getRoutes ( $ loops ? : Loops :: getCurrentLoops ( ) ) ) { return FALSE ; } $ routes = array_filter ( $ routes , function ( $ value , $ key ) use ( $ classname , $ count ) { if ( $ classname != str_replace ( "*" , "_" , $ value ) ) { return FALSE ; } if ( substr_count ( $ key , "*" ) > $ count ) { return FALSE ; } return TRUE ; } , ARRAY_FILTER_USE_BOTH ) ; if ( ! $ routes ) { return FALSE ; } $ pagepath = key ( $ routes ) ; while ( $ page_parameter && ( ( $ pos = strpos ( $ pagepath , "*" ) ) !== FALSE ) ) { $ pagepath = substr ( $ pagepath , 0 , $ pos ) . array_shift ( $ page_parameter ) . substr ( $ pagepath , $ pos + 1 ) ; } return ltrim ( $ pagepath , "/" ) ; }
Generates the page path for a page element
18,147
private static function getRoutes ( $ loops ) { $ cache = $ loops -> getService ( "cache" ) ; $ key = "Loops-WebCore-getRoutes" ; if ( $ cache -> contains ( $ key ) ) { return $ cache -> fetch ( $ key ) ; } if ( ! $ loops -> hasService ( "application" ) ) { return FALSE ; } $ classnames = $ loops -> getService ( "application" ) -> definedClasses ( ) ; $ classnames = array_filter ( $ classnames , function ( $ classname ) { return substr ( $ classname , 0 , 6 ) == "Pages\\" ; } ) ; $ routes = [ ] ; foreach ( $ classnames as $ classname ) { if ( ! in_array ( "Loops\ElementInterface" , class_implements ( $ classname ) ) ) { continue ; } if ( ! $ classname :: isPage ( ) ) { continue ; } $ reflection = new ReflectionClass ( $ classname ) ; if ( $ reflection -> isAbstract ( ) ) { continue ; } if ( substr ( $ reflection -> getFileName ( ) , - strlen ( $ classname ) - 4 , strlen ( $ classname ) ) != str_replace ( "\\" , "/" , $ classname ) ) { continue ; } $ classbase = substr ( str_replace ( "\\" , "/" , strtolower ( $ classname ) ) , 5 ) ; if ( substr ( $ classbase , - 6 ) == "/index" ) { $ classbase = substr ( $ classbase , 0 , - 5 ) ; } $ routes [ str_replace ( "_" , "*" , substr ( $ classbase , 1 ) ) ] = $ classname ; } uksort ( $ routes , function ( $ a , $ b ) { return substr_count ( $ b , "/" ) - substr_count ( $ a , "/" ) ? : strlen ( $ b ) - strlen ( $ a ) ; } ) ; $ cache -> save ( $ key , $ routes ) ; return $ routes ; }
Generates an array with all available routes
18,148
private function resolvePage ( $ url , $ processing = [ ] ) { $ path = ltrim ( $ url , "/" ) ; $ routes = self :: getRoutes ( $ this -> getLoops ( ) ) ; foreach ( $ routes as $ route => $ pageclass ) { $ regexp = "/^" . str_replace ( "\*" , "([^\/]+)" , preg_quote ( $ route , "/" ) ) . "/" ; if ( ! preg_match ( $ regexp , $ path , $ match ) ) { continue ; } $ page_parameter = array_slice ( $ match , 1 ) ; if ( $ page_parameter ) { $ reqs = $ this -> getLoops ( ) -> getService ( "annotations" ) -> get ( $ pageclass ) -> find ( "PageParameter" ) ; foreach ( $ page_parameter as $ parameter ) { if ( $ req = array_pop ( $ reqs ) ) { if ( $ req -> regexp ) { if ( ! preg_match ( $ req -> regexp , $ parameter ) ) { continue 2 ; } } if ( is_array ( $ req -> allow ) ) { if ( ! in_array ( $ parameter , $ req -> allow ) ) { continue 2 ; } } if ( is_array ( $ req -> exclude ) ) { if ( in_array ( $ parameter , $ req -> exclude ) ) { continue 2 ; } } if ( $ req -> callback ) { if ( ! call_user_func ( [ $ pageclass , $ req -> callback ] , $ parameter ) ) { continue 2 ; } } } } } $ parameter = ltrim ( substr ( $ path , strlen ( $ match [ 0 ] ) ) , "/" ) ; $ parameter = strlen ( $ parameter ) ? array_values ( explode ( "/" , $ parameter ) ) : [ ] ; yield [ $ pageclass , $ page_parameter , $ parameter ] ; } }
Find the page object that should be displayed based on the accessed url
18,149
public static function dashToCamelCase ( $ string ) { $ result = '' ; $ urlPart = explode ( '-' , $ string ) ; foreach ( $ urlPart as $ word ) { $ result .= ucfirst ( strtolower ( $ word ) ) ; } return $ result ; }
Replace dashes to CamelCase string format
18,150
public static function routeParse ( $ from , $ to , $ url ) { $ result = preg_match ( '/^(\(([^\)]+)\)|[^\/]*)(.*)/' , $ from , $ data ) ; if ( $ result !== 1 ) { return false ; } $ pattern = '/^' . str_replace ( '/' , '\/' , $ data [ 3 ] ) . '$/' ; $ result = preg_match ( $ pattern , $ url ) ; if ( $ result !== 1 ) { return false ; } $ route = new RouteInfo ( ) ; $ route -> methods = empty ( $ data [ 2 ] ) ? [ ] : explode ( '|' , $ data [ 2 ] ) ; $ route -> url = preg_replace ( $ pattern , $ to , $ url ) ; return $ route ; }
Parse route and return object RouteInfo with information about accepted route or return false if route pattern does not math
18,151
public function processBundles ( ) { $ loader = $ this -> getLoader ( ) ; $ view = $ this -> ensureView ( $ this -> owner ) ; foreach ( array_keys ( $ view -> assetBundles ) as $ name ) { $ loader -> registerAssetBundle ( $ name ) ; } }
Registers asset bundles in the JS loader
18,152
public function read ( \ PDOStatement $ stmt ) { $ this -> unfoundPrecedence = array ( ) ; $ preparedReader = new PreparedOperations ( $ this -> FQuery ) ; while ( $ row = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ) { foreach ( $ preparedReader -> getPreparedFaces ( ) as $ basePath => $ preparedFace ) { $ identity = $ preparedFace -> rowIdentity ( $ row , $ basePath ) ; if ( $ identity ) { if ( $ this -> instancesKeeper -> hasInstance ( $ preparedFace -> getFace ( ) -> getClass ( ) , $ identity ) ) { $ instance = $ this -> instancesKeeper -> getInstance ( $ preparedFace -> getFace ( ) -> getClass ( ) , $ identity ) ; $ preparedFace -> runOperations ( $ instance , $ row , $ this -> instancesKeeper , $ this -> unfoundPrecedence ) ; if ( ! $ this -> resultSet -> pathHasIdentity ( $ basePath , $ identity ) ) { $ this -> resultSet -> addInstanceByPath ( $ basePath , $ instance , $ identity ) ; } } else { $ instance = $ this -> createInstance ( $ preparedFace -> getFace ( ) ) ; $ this -> instancesKeeper -> addInstance ( $ instance , $ identity ) ; $ this -> resultSet -> addInstanceByPath ( $ basePath , $ instance , $ identity ) ; $ preparedFace -> runOperations ( $ instance , $ row , $ this -> instancesKeeper , $ this -> unfoundPrecedence ) ; } } } } foreach ( $ this -> unfoundPrecedence as $ unfound ) { if ( ! $ this -> instancesKeeper -> hasInstance ( $ unfound [ 'elementToSet' ] -> getClass ( ) , $ unfound [ 'identityOfElement' ] ) ) { var_dump ( $ unfound [ 'elementToSet' ] -> getClass ( ) ) ; var_dump ( $ unfound [ 'identityOfElement' ] ) ; var_dump ( get_class ( $ instance ) ) ; } $ unfoundInstance = $ this -> instancesKeeper -> getInstance ( $ unfound [ 'elementToSet' ] -> getClass ( ) , $ unfound [ 'identityOfElement' ] ) ; $ unfound [ 'instance' ] -> faceSetter ( $ unfound [ 'elementToSet' ] , $ unfoundInstance ) ; } return $ this -> resultSet ; }
parse the pdo statement of the fquery
18,153
protected function createInstance ( \ Face \ Core \ EntityFace $ face ) { $ className = $ face -> getClass ( ) ; $ instance = new $ className ( ) ; return $ instance ; }
Create an instance from an assoc array returned by sql
18,154
public static function fromString ( string $ string , array $ properties = null ) : ? Style { if ( ! preg_match_all ( '/([^:]+):([^;]+)(;|$)/' , strtolower ( $ string ) , $ matches , PREG_SET_ORDER ) ) { return null ; } $ style = new Style ( null ) ; foreach ( $ matches as $ match ) { $ property = trim ( $ match [ 1 ] ) ; $ value = trim ( $ match [ 2 ] ) ; if ( $ property === ( $ properties [ 'foreground' ] ?? 'color' ) ) { $ style -> setForeground ( $ value ) ; } elseif ( $ property === ( $ properties [ 'background' ] ?? 'bg' ) ) { $ style -> setBackground ( $ value ) ; } else { $ style -> setEmphasis ( [ $ value ] ) ; } } return $ style ; }
Factory which attempts to create a new Style based on an inline styling syntax .
18,155
protected function setColor ( string $ type , ? string $ color ) : interfaces \ Style { if ( isset ( $ color ) && ! isset ( static :: $ { $ type . 's' } [ $ color ] ) ) { throw new \ InvalidArgumentException ( "The $type color [$color] is not recognized." ) ; } $ this -> $ type = $ color ; return $ this ; }
Sets a specific type of color on this Style .
18,156
public function preRun ( ) : void { if ( $ output = $ this -> getOutput ( ) ) { $ max = 0 ; $ iterator = $ this -> getIterator ( ) ; if ( $ iterator instanceof \ SplFileObject ) { $ max = $ iterator -> getSize ( ) ; } elseif ( $ iterator instanceof \ Countable ) { $ max = count ( $ iterator ) ; } $ this -> progress = new ProgressBar ( $ output , $ max ) ; if ( $ output -> isDecorated ( ) ) { $ this -> progress -> setRedrawFrequency ( $ max / 100 ) ; } $ this -> progress -> start ( ) ; } }
Starts a new progress bar output in the pre - run phase .
18,157
public function postSearch ( ) : void { if ( $ this -> progress ) { $ iterator = $ this -> getIterator ( ) ; if ( $ iterator instanceof \ SplFileObject ) { $ this -> progress -> setProgress ( $ iterator -> ftell ( ) ) ; } elseif ( is_int ( $ key = $ iterator -> key ( ) ) ) { $ this -> progress -> setProgress ( $ key + 1 ) ; } else { $ this -> progress -> advance ( ) ; } } }
Updates the current progress in the post - search phase .
18,158
public function postRun ( ) : void { if ( $ this -> progress ) { $ this -> progress -> finish ( ) ; $ this -> getOutput ( ) -> writeln ( '' ) ; } }
Finishes the progress output in the post - run phase .
18,159
protected function outputInProgress ( string $ line ) : void { if ( $ this -> progress ) { $ this -> progress -> clear ( ) ; $ this -> getOutput ( ) -> writeln ( $ line ) ; $ this -> progress -> display ( ) ; } }
Outputs a line of text while a progress bar is running .
18,160
public function getMetaData ( $ key ) { if ( ! isset ( $ this -> metaData [ $ key ] ) ) { return false ; } return $ this -> metaData [ $ key ] ; }
Returns the meta data value for the given key
18,161
public function hasAccess ( $ accessLevel ) { foreach ( $ this -> permissions as $ permission ) { if ( $ permission == '\\Global\\*' ) { return true ; } if ( $ permission == $ accessLevel ) { return true ; } $ posStar = strpos ( $ permission , '*' ) ; if ( $ posStar !== false ) { $ startPermission = substr ( $ permission , 0 , $ posStar ) ; $ startAccessLevel = substr ( $ accessLevel , 0 , $ posStar ) ; if ( $ startPermission == $ startAccessLevel ) { return true ; } } } return false ; }
Returns true if the access entity has access to the given permission access level
18,162
public function setGroup ( ChildGroup $ v = null ) { if ( null !== $ this -> aGroup && $ v !== $ this -> aGroup ) { $ this -> oldGroupSkillCount = $ this -> aGroup ; } if ( $ v === null ) { $ this -> setGroupId ( NULL ) ; } else { $ this -> setGroupId ( $ v -> getId ( ) ) ; } $ this -> aGroup = $ v ; if ( $ v !== null ) { $ v -> addSkillGroup ( $ this ) ; } return $ this ; }
Declares an association between this object and a ChildGroup object .
18,163
public function getGroup ( ConnectionInterface $ con = null ) { if ( $ this -> aGroup === null && ( $ this -> group_id !== null ) ) { $ this -> aGroup = ChildGroupQuery :: create ( ) -> findPk ( $ this -> group_id , $ con ) ; } return $ this -> aGroup ; }
Get the associated ChildGroup object
18,164
protected function updateRelatedGroupSkillCount ( ConnectionInterface $ con ) { if ( $ group = $ this -> getGroup ( ) ) { $ group -> updateSkillCount ( $ con ) ; } if ( $ this -> oldGroupSkillCount ) { $ this -> oldGroupSkillCount -> updateSkillCount ( $ con ) ; $ this -> oldGroupSkillCount = null ; } }
Update the aggregate column in the related Group object
18,165
public function withLabels ( array $ labels ) : Validator { $ translator = $ this -> translator -> withLabels ( $ labels ) ; return new Validator ( $ this -> rules , $ this -> parser , $ translator ) ; }
Return a new validator with the given list of labels added to the translator .
18,166
public function withTemplates ( array $ templates ) : Validator { $ translator = $ this -> translator -> withTemplates ( $ templates ) ; return new Validator ( $ this -> rules , $ this -> parser , $ translator ) ; }
Return a new validator with the given list of templates added to the translator .
18,167
public function validate ( array $ input = [ ] ) : ValidationResult { $ results = [ ] ; foreach ( $ this -> rules as $ key => $ definition ) { $ rules = $ this -> parser -> parseRulesDefinition ( $ definition ) ; $ results [ $ key ] = $ rules -> validate ( $ key , $ input ) ; } return new ValidationResult ( $ results , $ this -> translator ) ; }
Validate the given input against the rules .
18,168
public function isRequired ( ) : Testable { $ this -> attributes [ 'required' ] = true ; return $ this -> addTest ( 'required' , function ( $ value ) { if ( is_array ( $ value ) ) { return $ value ; } return strlen ( trim ( $ value ) ) ; } ) ; }
This is a required field .
18,169
protected function serializeModel ( Model $ model , AdapterInterface $ adapter ) { $ metadata = $ model -> getMetadata ( ) ; $ serialized = [ 'type' => $ model -> getType ( ) , 'id' => $ model -> getId ( ) , ] ; if ( $ this -> depth > 0 ) { return $ serialized ; } foreach ( $ metadata -> getAttributes ( ) as $ key => $ attrMeta ) { if ( false === $ attrMeta -> shouldSerialize ( ) ) { continue ; } $ value = $ model -> get ( $ key ) ; $ serialized [ 'attributes' ] [ $ key ] = $ this -> serializeAttribute ( $ value , $ attrMeta ) ; } foreach ( $ metadata -> getEmbeds ( ) as $ key => $ embeddedPropMeta ) { if ( false === $ attrMeta -> shouldSerialize ( ) ) { continue ; } $ value = $ model -> get ( $ key ) ; $ serialized [ 'attributes' ] [ $ key ] = $ this -> serializeEmbed ( $ value , $ embeddedPropMeta ) ; } $ serialized [ 'links' ] = [ 'self' => $ adapter -> buildUrl ( $ metadata , $ model -> getId ( ) ) ] ; $ model -> enableCollectionAutoInit ( false ) ; $ this -> increaseDepth ( ) ; foreach ( $ metadata -> getRelationships ( ) as $ key => $ relMeta ) { if ( false === $ relMeta -> shouldSerialize ( ) ) { continue ; } $ relationship = $ model -> get ( $ key ) ; $ serialized [ 'relationships' ] [ $ key ] = $ this -> serializeRelationship ( $ model , $ relationship , $ relMeta , $ adapter ) ; } $ this -> decreaseDepth ( ) ; $ model -> enableCollectionAutoInit ( true ) ; return $ serialized ; }
Serializes the interior of a model . This is the serialization that takes place outside of a data container . Can be used for root model and relationship model serialization .
18,170
protected function serializeAttribute ( $ value , AttributeMetadata $ attrMeta ) { if ( 'date' === $ attrMeta -> dataType && $ value instanceof \ DateTime ) { $ milliseconds = sprintf ( '%03d' , round ( $ value -> format ( 'u' ) / 1000 , 0 ) ) ; return gmdate ( sprintf ( 'Y-m-d\TH:i:s.%s\Z' , $ milliseconds ) , $ value -> getTimestamp ( ) ) ; } if ( 'array' === $ attrMeta -> dataType && empty ( $ value ) ) { return [ ] ; } if ( 'object' === $ attrMeta -> dataType ) { return ( array ) $ value ; } return $ value ; }
Serializes an attribute value .
18,171
protected function serializeEmbed ( $ value , EmbeddedPropMetadata $ embeddedPropMeta ) { $ embedMeta = $ embeddedPropMeta -> embedMeta ; if ( true === $ embeddedPropMeta -> isOne ( ) ) { return $ this -> serializeEmbedOne ( $ embedMeta , $ value ) ; } return $ this -> serializeEmbedMany ( $ embedMeta , $ value ) ; }
Serializes an embed value .
18,172
protected function serializeEmbedOne ( EmbedMetadata $ embedMeta , Embed $ embed = null ) { if ( null === $ embed ) { return ; } $ serialized = [ ] ; foreach ( $ embedMeta -> getAttributes ( ) as $ key => $ attrMeta ) { $ serialized [ $ key ] = $ this -> serializeAttribute ( $ embed -> get ( $ key ) , $ attrMeta ) ; } foreach ( $ embedMeta -> getEmbeds ( ) as $ key => $ embeddedPropMeta ) { $ serialized [ $ key ] = $ this -> serializeEmbed ( $ embed -> get ( $ key ) , $ embeddedPropMeta ) ; } return empty ( $ serialized ) ? null : $ serialized ; }
Serializes an embed one value .
18,173
protected function serializeEmbedMany ( EmbedMetadata $ embedMeta , EmbedCollection $ collection ) { $ serialized = [ ] ; foreach ( $ collection as $ embed ) { if ( ! $ embed instanceof Embed ) { continue ; } $ serialized [ ] = $ this -> serializeEmbedOne ( $ embedMeta , $ embed ) ; } return $ serialized ; }
Serializes an embed many value .
18,174
protected function serializeRelationship ( Model $ owner , $ relationship = null , RelationshipMetadata $ relMeta , AdapterInterface $ adapter ) { if ( $ relMeta -> isOne ( ) ) { if ( is_array ( $ relationship ) ) { throw SerializerException :: badRequest ( 'Invalid relationship value.' ) ; } $ serialized = $ this -> serializeHasOne ( $ owner , $ relationship , $ adapter ) ; } elseif ( is_array ( $ relationship ) || null === $ relationship ) { $ serialized = $ this -> serializeHasMany ( $ owner , $ relationship , $ adapter ) ; } else { throw SerializerException :: badRequest ( 'Invalid relationship value.' ) ; } $ ownerMeta = $ owner -> getMetadata ( ) ; $ serialized [ 'links' ] = [ 'self' => $ adapter -> buildUrl ( $ ownerMeta , $ owner -> getId ( ) , $ relMeta -> getKey ( ) ) , 'related' => $ adapter -> buildUrl ( $ ownerMeta , $ owner -> getId ( ) , $ relMeta -> getKey ( ) , true ) , ] ; return $ serialized ; }
Serializes a relationship value
18,175
protected function serializeHasMany ( Model $ owner , array $ models = null , AdapterInterface $ adapter ) { if ( empty ( $ models ) ) { return $ this -> serialize ( null , $ adapter ) ; } return $ this -> serializeArray ( $ models , $ adapter ) ; }
Serializes a has - many relationship value
18,176
protected function serializeHasOne ( Model $ owner , Model $ model = null , AdapterInterface $ adapter ) { return $ this -> serialize ( $ model , $ adapter ) ; }
Serializes a has - one relationship value
18,177
public function buildCommand ( ) { if ( $ this -> withoutOverlapping ) { $ command = '(touch ' . $ this -> mutexPath ( ) . '; ' . $ this -> command . '; rm ' . $ this -> mutexPath ( ) . ') > ' . $ this -> output . ' 2>&1 &' ; } else { $ command = $ this -> command . ' > ' . $ this -> output . ' 2>&1 &' ; } return $ this -> user ? 'sudo -u ' . $ this -> user . ' ' . $ command : $ command ; }
Build the comand string .
18,178
protected function tokenizePath ( $ path ) { $ parts = explode ( $ this -> pathSeparator , $ path ) ; if ( $ this -> trimTokens ) { for ( $ i = 0 ; $ i < count ( $ parts ) ; $ i ++ ) { $ parts [ $ i ] = trim ( $ parts [ $ i ] ) ; if ( $ parts [ $ i ] === "" ) { unset ( $ parts [ $ i ] ) ; } } } return array_values ( $ parts ) ; }
Tokenize the given path String into parts based on this matcher s settings .
18,179
protected function matchStrings ( $ pattern , $ str , & $ uriTemplateVariables ) { return $ this -> getStringMatcher ( $ pattern ) -> matchStrings ( $ str , $ uriTemplateVariables ) ; }
Tests whether or not a string matches against a pattern .
18,180
protected function concat ( $ path1 , $ path2 ) { if ( substr ( $ path1 , - 1 ) == $ this -> pathSeparator || substr ( $ path2 , 0 , 1 ) == $ this -> pathSeparator ) { return $ path1 . $ path2 ; } return $ path1 . $ this -> pathSeparator . $ path2 ; }
Concats two paths using the path separator
18,181
public function getAllCurrent ( ) { $ notifications = [ ] ; $ container = $ this -> getContainer ( ) ; foreach ( $ container as $ namespace => $ notification ) { $ notifications [ $ namespace ] = $ this -> getCurrent ( $ namespace ) ; } return $ notifications ; }
Get all current notifications
18,182
protected function getNotificationsFromContainer ( ) { if ( ! empty ( $ this -> notifications ) || $ this -> isAdded ) { return ; } $ container = $ this -> getContainer ( ) ; $ namespaces = [ ] ; foreach ( $ container as $ namespace => $ notification ) { $ this -> notifications [ $ namespace ] = $ notification ; $ namespaces [ ] = $ namespace ; } $ this -> clearNotificationsFromContainer ( $ namespaces ) ; }
Clear notifications from container
18,183
public function clearCurrent ( $ namespace = null ) { $ container = $ this -> getContainer ( ) ; if ( $ namespace ) { if ( ! $ container -> offsetExists ( $ namespace ) ) { return false ; } unset ( $ container -> { $ namespace } ) ; return true ; } foreach ( $ container as $ namespace => $ notifications ) { $ container -> offsetUnset ( $ namespace ) ; } return true ; }
Clear notifications from container if namespace is provided or clear all notifications added during this request if namespace is not provided .
18,184
public function clear ( $ namespace = null ) { $ this -> getNotificationsFromContainer ( ) ; if ( $ namespace ) { if ( isset ( $ this -> notifications [ $ namespace ] ) ) { unset ( $ this -> notifications [ $ namespace ] ) ; return true ; } return false ; } foreach ( $ this -> notifications as $ nm => $ type ) { unset ( $ this -> notifications [ $ nm ] ) ; } return true ; }
Clear notifications from previous request by provided namespace or clear all notifications if namespace is not provided
18,185
public function updateOne ( string $ referenceName , string $ value ) : array { return $ this -> sendPatch ( sprintf ( '/profiles/%s/references/%s' , $ this -> userName , $ referenceName ) , [ ] , [ 'value' => $ value ] ) ; }
Updates a reference given its slug .
18,186
public function calculateDate ( $ gYear , $ gMonth , $ gDay ) { return $ this -> getPoirotPersian ( ) -> calculateDate ( $ gYear , $ gMonth , $ gDay ) ; }
Calculate date to calendar system
18,187
protected function syncCookies ( ) { foreach ( $ this -> cookies as $ name => $ id ) { if ( null === $ id ) { setcookie ( $ name , '' , time ( ) - 3600 ) ; } else { setcookie ( $ name , $ id , $ this -> ttl ? ( time ( ) + $ this -> ttl ) : 0 , $ this -> path , $ this -> domain , $ this -> secure , $ this -> httponly ) ; } } }
Sync session cookies with the client
18,188
private function getDaysInMonth ( Month $ month , Year $ year ) { return ( int ) date ( 't' , mktime ( 0 , 0 , 0 , ( string ) $ month , 1 , ( string ) $ year ) ) ; }
Get number of days in specified month .
18,189
public function connection ( $ name = null ) { if ( is_null ( $ name ) ) { $ name = $ this -> getDefaultConnection ( ) ; } if ( ! isset ( $ this -> connections [ $ name ] ) ) { throw new InvalidArgumentException ( "Connection [{$name}] is not registered." ) ; } return $ this -> connections [ $ name ] ; }
Get an API connection instance .
18,190
public static function getMembers ( ) { $ className = static :: class ; $ members = & self :: $ members [ $ className ] ; if ( empty ( $ members ) ) { new $ className ( null ) ; } return $ members ; }
Returns members of enum
18,191
public function httpGetRequest ( $ url ) { $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , $ url ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , 1 ) ; $ response = curl_exec ( $ curl ) ; $ resolve = $ this -> curlResponse -> resolve ( $ curl , $ response ) ; curl_close ( $ curl ) ; return $ resolve ; }
Make a GET HTTP request
18,192
public function httpStatusConnection ( $ url ) { if ( ! filter_var ( $ url , FILTER_VALIDATE_URL ) ) { return false ; } $ handle = curl_init ( $ url ) ; curl_setopt ( $ handle , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ handle , CURLOPT_FOLLOWLOCATION , true ) ; $ response = curl_exec ( $ handle ) ; $ httpCode = curl_getinfo ( $ handle , CURLINFO_HTTP_CODE ) ; curl_close ( $ handle ) ; return $ httpCode == 200 ? true : false ; }
Check the connection status
18,193
public function httpPosRequest ( $ url , $ data ) { $ enc = EncryptAes :: encrypt ( $ data ) ; $ dataEncrypt = 'data=' . $ enc ; $ dataEncrypt = str_replace ( '+' , '%2B' , $ dataEncrypt ) ; $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ curl , CURLOPT_POST , count ( $ dataEncrypt ) ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ dataEncrypt ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_FAILONERROR , true ) ; curl_setopt ( $ curl , CURLOPT_FRESH_CONNECT , true ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYPEER , false ) ; curl_setopt ( $ curl , CURLOPT_URL , $ url ) ; $ response = curl_exec ( $ curl ) ; $ resolve = $ this -> curlResponse -> resolve ( $ curl , $ response ) ; curl_close ( $ curl ) ; return $ resolve ; }
Make a POST HTTP request
18,194
public function redeemAction ( $ accessToken ) { if ( $ this -> request -> getHttpRequest ( ) -> getMethod ( ) !== 'POST' ) { $ this -> response -> setStatus ( 405 ) ; $ this -> response -> setHeader ( 'Allow' , 'POST' ) ; return ; } $ accessTokenObject = $ this -> accessTokenRepository -> findByIdentifier ( $ accessToken ) ; if ( ! $ accessTokenObject instanceof AccessToken ) { $ this -> response -> setStatus ( 404 ) ; $ this -> view -> assign ( 'value' , array ( 'message' => 'Invalid access token' ) ) ; return ; } $ sessionId = $ accessTokenObject -> getSessionId ( ) ; $ session = $ this -> sessionManager -> getSession ( $ sessionId ) ; if ( ! $ this -> sessionIsActive ( $ session ) ) { $ this -> response -> setStatus ( 403 ) ; $ this -> view -> assign ( 'value' , array ( 'message' => 'Session expired' ) ) ; return ; } $ this -> accessTokenRepository -> remove ( $ accessTokenObject ) ; $ ssoClient = $ accessTokenObject -> getSsoClient ( ) ; $ this -> singleSignOnSessionManager -> registerSsoClient ( $ session , $ ssoClient ) ; $ account = $ accessTokenObject -> getAccount ( ) ; $ accountData = $ this -> clientAccountMapper -> getAccountData ( $ accessTokenObject -> getSsoClient ( ) , $ account ) ; if ( $ this -> ssoLogger !== NULL ) { $ this -> ssoLogger -> log ( 'Redeemed access token "' . $ accessToken . '" from client "' . $ ssoClient -> getServiceBaseUri ( ) . '" for session "' . $ sessionId . '" and account "' . $ account -> getAccountIdentifier ( ) . '"' , LOG_INFO ) ; } $ this -> response -> setStatus ( 201 ) ; $ this -> view -> assign ( 'value' , array ( 'account' => $ accountData , 'sessionId' => $ sessionId ) ) ; }
Redeem an access token and return global account data for the authenticated account and a global session id .
18,195
public function GetListOfTablesInDatabase ( ) { $ dbConfig = new \ Puzzlout \ Framework \ Dal \ DbStatementConfig ( null , \ Puzzlout \ Framework \ Dal \ DbExecutionType :: SHOWTABLES , new \ Puzzlout \ Framework \ Dal \ DbQueryFilters ( ) ) ; $ dbConfig -> setQuery ( "SHOW TABLES;" ) ; $ this -> addDbConfigItem ( $ dbConfig ) ; return $ this -> BindParametersAndExecute ( ) ; }
Gets the list of table names in a database .
18,196
public function GetTableColumnsMeta ( $ tableName , $ columnNames ) { $ tableColumnsMetadata = array ( ) ; foreach ( $ columnNames as $ columnName ) { $ this -> setDbConfigList ( array ( ) ) ; $ dbConfig = new \ Puzzlout \ Framework \ Dal \ DbStatementConfig ( null , \ Puzzlout \ Framework \ Dal \ DbExecutionType :: COLUMNMETAS , new \ Puzzlout \ Framework \ Dal \ DbQueryFilters ( ) ) ; $ dbConfig -> setQuery ( "SHOW COLUMNS FROM `$tableName` WHERE `Field` = '$columnName';" ) ; $ this -> addDbConfigItem ( $ dbConfig ) ; $ tableColumnsMetadata [ $ columnName ] = $ this -> BindParametersAndExecute ( ) ; } return $ tableColumnsMetadata ; }
Gets the list of column metadata for a table .
18,197
public function GetTableColumnNames ( $ tableName ) { $ this -> setDbConfigList ( array ( ) ) ; $ dbConfig = new \ Puzzlout \ Framework \ Dal \ DbStatementConfig ( null , \ Puzzlout \ Framework \ Dal \ DbExecutionType :: COLUMNNAMES , new \ Puzzlout \ Framework \ Dal \ DbQueryFilters ( ) ) ; $ dbConfig -> setQuery ( "DESCRIBE `$tableName`;" ) ; $ this -> addDbConfigItem ( $ dbConfig ) ; return $ this -> BindParametersAndExecute ( ) ; }
Gets the column names for a table .
18,198
public function prepareSortOrProjection ( array $ fields ) { $ preparedFields = array ( ) ; foreach ( $ fields as $ key => $ value ) { $ preparedFields [ $ this -> prepareFieldName ( $ key ) ] = $ value ; } return $ preparedFields ; }
Prepare a sort or projection array by converting keys which are PHP property names to MongoDB field names .
18,199
public function addFilterToPreparedQuery ( array $ preparedQuery ) { if ( $ filterCriteria = $ this -> dm -> getFilterCollection ( ) -> getFilterCriteria ( $ this -> class ) ) { $ preparedQuery = $ this -> cm -> merge ( $ preparedQuery , $ this -> prepareQueryOrNewObj ( $ filterCriteria ) ) ; } return $ preparedQuery ; }
Adds filter criteria to an already - prepared query .