idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
30,600 | public function getOrderFiled ( ) { $ result = [ ] ; $ orderField = $ this -> _getOrderField ( ) ; if ( empty ( $ orderField ) ) { return $ result ; } $ result [ $ this -> alias . '.' . $ orderField ] = 'asc' ; return $ result ; } | Return field for ordering data as array |
30,601 | protected function _getConditionsForEmployee ( $ id = null ) { $ conditions = [ ] ; if ( empty ( $ id ) ) { return $ conditions ; } $ id = ( string ) $ id ; if ( ctype_digit ( $ id ) ) { $ conditions [ $ this -> alias . '.id' ] = $ id ; } elseif ( isGuid ( $ id ) ) { $ conditions [ $ this -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_OBJECT_GUID ] = $ id ; } else { $ conditions [ $ this -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_DISTINGUISHED_NAME ] = $ id ; } return $ conditions ; } | Return conditions for find employee |
30,602 | public function existsEmployee ( $ id = null ) { if ( empty ( $ id ) ) { return false ; } $ conditions = $ this -> _getConditionsForEmployee ( $ id ) ; $ callbacks = false ; $ this -> recursive = - 1 ; return ( bool ) $ this -> find ( 'count' , compact ( 'count' , 'conditions' , 'callbacks' ) ) ; } | Check employee exists |
30,603 | public function getListEmployees ( $ includeBlock = true ) { $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.' . $ this -> displayField , ] ; $ conditions = [ ] ; $ blockExists = $ this -> hasField ( 'block' ) ; if ( ! $ includeBlock && $ blockExists ) { $ conditions [ $ this -> alias . '.block' ] = false ; } $ order = $ this -> getOrderFiled ( ) ; $ this -> recursive = - 1 ; return $ this -> find ( 'list' , compact ( 'fields' , 'conditions' , 'order' ) ) ; } | Return a list of employees |
30,604 | public function getListEmployeesManager ( $ guid = null , $ limit = CAKE_LDAP_SYNC_AD_LIMIT ) { $ result = [ ] ; if ( ! $ this -> hasField ( 'manager_id' ) ) { return $ result ; } $ conditions = [ ] ; if ( ! empty ( $ guid ) ) { $ conditions [ $ this -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_OBJECT_GUID ] = $ guid ; } $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.manager_id' , $ this -> alias . '.' . $ this -> displayField . ' AS name' , ] ; $ order = [ $ this -> alias . '.id' => 'asc' , ] ; $ this -> recursive = - 1 ; $ data = $ this -> find ( 'all' , compact ( 'fields' , 'conditions' , 'order' , 'limit' ) ) ; if ( empty ( $ data ) ) { return $ result ; } $ result = Hash :: combine ( $ data , '{n}.' . $ this -> alias . '.id' , '{n}.' . $ this -> alias ) ; return $ result ; } | Return list of managers for synchronization tree of subordinate employees |
30,605 | public function getPaginateOptions ( $ excludeFields = null ) { $ page = 1 ; $ limit = 20 ; $ fields = $ this -> getListLocalFields ( $ excludeFields ) ; $ order = $ this -> getOrderFiled ( ) ; $ contain = $ this -> getListContain ( 'Subordinate' ) ; $ result = compact ( 'page' , 'limit' , 'fields' , 'order' , 'contain' ) ; return $ result ; } | Return options for Paginator component |
30,606 | public function getFilterOptions ( ) { $ language = ( string ) Configure :: read ( 'Config.language' ) ; $ cachePath = 'local_fields_filter_opt_' . $ language ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB ) ; if ( $ cached !== false ) { return $ cached ; } $ result = [ ] ; $ excludeFields = [ 'id' , 'department_id' , 'manager_id' , 'lft' , 'rght' , CAKE_LDAP_LDAP_ATTRIBUTE_OBJECT_GUID , CAKE_LDAP_LDAP_ATTRIBUTE_DISTINGUISHED_NAME , ] ; $ excludeFieldsLabel = [ $ this -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_OBJECT_GUID , $ this -> alias . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_DISTINGUISHED_NAME , ] ; $ fieldsInfo = $ this -> _modelConfigSync -> getLocalFieldsInfo ( ) ; $ fieldsInfo += $ this -> _modelConfigSync -> getLdapFieldsInfo ( ) ; $ fieldsInfo = array_diff_key ( $ fieldsInfo , array_flip ( $ excludeFields ) ) ; $ fieldsLabels = $ this -> _getLabelForFields ( $ fieldsInfo , true ) ; foreach ( $ fieldsLabels as $ fieldName => $ label ) { $ fieldOptions = [ ] ; if ( ! empty ( $ label ) ) { $ fieldOptions [ 'label' ] = $ label ; } if ( $ this -> _isHashPath ( $ fieldName ) ) { $ fieldOptions [ 'disabled' ] = true ; } $ result [ $ fieldName ] = $ fieldOptions ; } Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB ) ; return $ result ; } | Return options for Filter component |
30,607 | public function getListFieldsLabelExtend ( $ useAlternative = false , $ excludeFields = null ) { $ language = ( string ) Configure :: read ( 'Config.language' ) ; $ cachePath = 'local_fields_label_ext_' . md5 ( serialize ( func_get_args ( ) ) . '_' . $ language ) ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB ) ; if ( $ cached !== false ) { return $ cached ; } $ fieldsInfo = $ this -> getExtendFieldsInfo ( ) ; $ result = $ this -> _getLabelForFields ( $ fieldsInfo , $ useAlternative , true ) ; if ( ! empty ( $ excludeFields ) ) { $ result = array_diff_key ( $ result , array_flip ( ( array ) $ excludeFields ) ) ; } Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB ) ; return $ result ; } | Return list of labels for extended fields order by Priority |
30,608 | protected function _isHashPath ( $ fieldName = null ) { if ( empty ( $ fieldName ) ) { return false ; } $ pos = mb_stripos ( $ fieldName , '.{n}.' ) ; if ( $ pos !== false ) { return true ; } return false ; } | Check field name is Hash path |
30,609 | public function getFieldsConfig ( ) { $ cachePath = 'local_fields_fields_schema' ; $ cached = Cache :: read ( $ cachePath , CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB ) ; if ( $ cached !== false ) { return $ cached ; } $ result = [ ] ; $ schema = $ this -> schema ( ) ; $ ldapFieldsInfo = $ this -> _modelConfigSync -> getLdapFieldsInfo ( ) ; $ bindModelFields = $ this -> _getListBindModelFields ( ) ; foreach ( $ schema as $ fieldName => $ fieldInfo ) { switch ( $ fieldName ) { case CAKE_LDAP_LDAP_ATTRIBUTE_OBJECT_GUID : $ type = 'guid' ; break ; case CAKE_LDAP_LDAP_ATTRIBUTE_BIRTHDAY : $ type = 'date' ; break ; case CAKE_LDAP_LDAP_ATTRIBUTE_PHOTO : $ type = 'photo' ; break ; case CAKE_LDAP_LDAP_ATTRIBUTE_MAIL : $ type = 'mail' ; break ; default : $ type = $ fieldInfo [ 'type' ] ; } $ truncate = ( bool ) Hash :: get ( $ ldapFieldsInfo , $ fieldName . '.truncate' ) ; $ result [ $ this -> alias . '.' . $ fieldName ] = compact ( 'type' , 'truncate' ) ; } foreach ( $ bindModelFields as $ fieldName => $ bindFieldName ) { switch ( $ fieldName ) { case CAKE_LDAP_LDAP_ATTRIBUTE_DEPARTMENT : $ type = 'string' ; break ; case CAKE_LDAP_LDAP_ATTRIBUTE_MANAGER : $ type = 'manager' ; break ; case CAKE_LDAP_LDAP_ATTRIBUTE_OTHER_TELEPHONE_NUMBER : case CAKE_LDAP_LDAP_ATTRIBUTE_OTHER_MOBILE_TELEPHONE_NUMBER : $ type = 'string' ; break ; } $ truncate = ( bool ) Hash :: get ( $ ldapFieldsInfo , $ fieldName . '.truncate' ) ; $ result [ $ bindFieldName ] = compact ( 'type' , 'truncate' ) ; } $ extendFieldsConfig = $ this -> getExtendFieldsConfig ( ) ; if ( ! empty ( $ extendFieldsConfig ) && is_array ( $ extendFieldsConfig ) ) { $ result += $ extendFieldsConfig ; } Cache :: write ( $ cachePath , $ result , CAKE_LDAP_CACHE_KEY_LDAP_SYNC_DB ) ; return $ result ; } | Return fields configuration for helper |
30,610 | public function getColumnModel ( ) : ColumnModel { if ( $ this -> source === null ) { throw new Exception \ RuntimeException ( __METHOD__ . ' Prior to get column model, a source must be set.' ) ; } $ this -> hydrate_options_initialized = false ; return $ this -> source -> getColumnModel ( ) ; } | Return source column model . |
30,611 | public function destroy ( $ id ) { $ phone = Phone :: findOrFail ( $ id ) ; $ this -> authorize ( 'manage' , $ phone ) ; $ phone -> delete ( ) ; return fractal ( $ id , new DeletedTransformer ( ) ) -> withResourceName ( 'deletedPhone' ) -> respond ( ) ; } | Delete a Phone object |
30,612 | public function update ( Request $ request , $ id ) { $ request -> validate ( [ "countryCode" => 'required|regex:/\d{1,2}/' , "label" => "required|max:50" , "phoneNumber" => 'required|regex:/\d{10}/' , ] ) ; $ phone = Phone :: findOrFail ( $ id ) ; $ this -> authorize ( 'manage' , $ phone ) ; $ phone -> country_code = $ request -> countryCode ; $ phone -> label = $ request -> label ; $ phone -> phone_number = $ request -> phoneNumber ; $ this -> authorize ( 'manage' , $ phone ) ; $ phone -> save ( ) ; return fractal ( $ phone , new PhoneTransformer ( ) ) -> withResourceName ( 'phone' ) -> respond ( ) ; } | Store an updated Phone |
30,613 | public function run ( ) { $ results = [ $ this -> simulateDelete ( ) , $ this -> simulateUpdate ( ) , $ this -> simulateCreate ( ) ] ; return array_search ( false , $ results , true ) === false ; } | Runs the pre update package . This runs the pre - checks and a simulation upgrade . |
30,614 | protected function writable ( $ path ) { $ fullPath = "{$this->basePath}/$path" ; while ( ! file_exists ( $ fullPath ) && $ fullPath != basename ( $ fullPath ) ) { $ fullPath = dirname ( $ fullPath ) ; } return is_writable ( $ fullPath ) ; } | Checks if a file is writable if the file does not exist traverses up the file path . |
30,615 | protected function handle ( Request $ request ) { try { list ( $ routeInformation , $ parameters ) = $ this -> findRoute ( $ request ) ; return ( new Pipeline ( $ this -> container ) ) -> through ( $ routeInformation [ 'middlewares' ] ) -> send ( $ request ) -> then ( function ( Request $ request ) use ( $ routeInformation , $ parameters ) { if ( $ routeInformation [ 'action' ] instanceof Closure ) { return call_user_func_array ( $ routeInformation [ 'action' ] , $ parameters ) ; } list ( $ controller , $ action ) = $ routeInformation [ 'action' ] ; $ controllerInstance = new $ controller ; if ( $ controllerInstance instanceof KeeperBaseController ) { $ controllerInstance -> setContainer ( $ this -> container ) ; $ controllerInstance -> setRequest ( $ request ) ; } return call_user_func_array ( [ $ controllerInstance , $ action ] , $ parameters ) ; } ) ; } catch ( Throwable $ exception ) { if ( $ this -> exceptionHandler ) { return $ this -> exceptionHandler -> handle ( $ exception , $ request ) ; } return new Response ( ( string ) $ exception , 500 ) ; } } | Handle Http request and return processed result |
30,616 | public function visitFile ( vfsStreamFile $ file ) { $ this -> current [ $ file -> getName ( ) ] = $ file -> getContent ( ) ; return $ this ; } | visit a file and process it |
30,617 | public function addOption ( Doozr_Form_Service_Component_Interface_Option $ option ) { $ option -> setTemplate ( Doozr_Form_Service_Constant :: DEFAULT_TEMPLATE_NONCLOSING ) ; return parent :: addOption ( $ option ) ; } | Proxy to parents addOption - > cause we need to modify the input and we want to do this inline . |
30,618 | protected function addPolymorphicRules ( $ rules , $ polymorphicKey , $ type ) { $ rules [ "{$polymorphicKey}Type" ] = "required|in:" . $ this -> getAllowedTypeString ( $ polymorphicKey ) ; if ( array_key_exists ( $ type , config ( 'combine-core.validation.polymorphicTypes' ) ) ) { $ rules [ "{$polymorphicKey}Id" ] = "required|exists:" . config ( 'combine-core.validation.polymorphicTypes' ) [ $ type ] . ",id" ; } return $ rules ; } | Updates a validation ruleset to include rules needed for polymorphic Eloquent objects . |
30,619 | protected function getAllowedTypeString ( $ modelKey ) { switch ( $ modelKey ) { case 'addressable' : return implode ( "," , array_keys ( config ( 'combine-core.validation.polymorphicTypes.addressable' ) ) ) ; case 'author' : return implode ( "," , array_keys ( config ( 'combine-core.validation.authorTypes' ) ) ) ; case 'noteable' : return implode ( "," , array_keys ( config ( 'combine-core.validation.polymorphicTypes.noteable' ) ) ) ; case 'phoneable' : return implode ( "," , array_keys ( config ( 'combine-core.validation.polymorphicTypes.phoneable' ) ) ) ; } ; return null ; } | Provides a comma - delimited string list of valid Model classnames for attachable_type fields . For use in validation rules . |
30,620 | public static function arr ( $ arr , $ breakLine = false ) { if ( $ breakLine === false ) print '<pre>' ; print_r ( $ arr ) ; print $ breakLine === false ? '</pre>' : "\n" ; } | Print arrays in readable format |
30,621 | public static function create ( string $ format = SerializerBuilder :: DEFAULT_FORMAT ) : SerializerInterface { return SerializerBuilder :: instance ( ) -> setFormat ( $ format ) -> build ( ) ; } | Creates Serializer instance by format |
30,622 | protected function existsInCondition ( $ name ) { foreach ( $ this -> conditionColumns as $ column ) { if ( 0 === strpos ( $ column , $ name . '.' ) ) { return true ; } } return false ; } | Checks if condition depends on that relation or not . If it doesn t then there s no need for a join when counting . |
30,623 | public function hasSingleResult ( $ name ) { $ parts = explode ( "." , $ name ) ; $ nameSoFar = "" ; foreach ( $ parts as $ part ) { $ lastNameSoFar = $ nameSoFar ; $ nameSoFar .= ( $ nameSoFar ? '.' : '' ) . $ part ; if ( ! isset ( $ this -> relations [ $ nameSoFar ] ) ) { $ this -> relations [ $ nameSoFar ] = $ this -> initSubRelation ( $ nameSoFar , $ this -> relations [ $ lastNameSoFar ] ) ; } if ( ! $ this -> relations [ $ nameSoFar ] -> hasSingleResult ( ) ) { if ( ! isset ( $ this -> toBeSelectedSeparately [ $ nameSoFar ] ) ) { $ this -> toBeSelectedSeparately [ $ nameSoFar ] = [ 'relation' => $ this -> relations [ $ nameSoFar ] , 'subrelations' => [ ] ] ; } if ( $ nameSoFar != $ name ) { $ this -> toBeSelectedSeparately [ $ nameSoFar ] [ 'subrelations' ] [ ] = substr ( $ name , strlen ( $ nameSoFar ) + 1 ) ; } return false ; } } return true ; } | Checks if the relation returns a single result . It also checks for parents if it s a relation of a relation . |
30,624 | protected function getFieldsForRelationPath ( $ fields , $ relationPath ) { if ( '*' == $ fields ) { return '*' ; } if ( is_array ( $ fields ) ) { $ final = [ ] ; foreach ( $ fields as $ column => $ as ) { $ cName = is_numeric ( $ column ) ? $ as : $ column ; if ( ( $ relationPath . '.' ) == substr ( $ cName , 0 , strlen ( $ relationPath ) + 1 ) ) { $ cName = substr ( $ cName , strlen ( $ relationPath ) + 1 ) ; if ( is_numeric ( $ column ) ) { $ final [ ] = $ cName ; } else { $ final [ $ cName ] = $ as ; } } } return $ final ; } return '*' ; } | Extracts only fields required for this relations |
30,625 | protected function getAllChildsFromPath ( $ models , $ relationPath ) { $ path = explode ( '.' , $ relationPath , 2 ) ; $ childs = [ ] ; $ name = $ path [ 0 ] ; foreach ( $ models as $ model ) { if ( is_array ( $ model -> $ name ) ) { $ childs += $ model -> $ name ; } elseif ( $ model -> $ name ) { $ childs [ ] = $ model -> $ name ; } } if ( ! isset ( $ path [ 1 ] ) || ! trim ( $ path [ 1 ] ) ) { return $ childs ; } else { return $ this -> getAllChildsFromPath ( $ childs , $ path [ 1 ] ) ; } } | Get list of all model childs from a selected path . |
30,626 | public function to ( $ impl ) : self { if ( ! is_string ( $ impl ) && ! ( $ impl instanceof \ ReflectionClass ) ) { throw new \ InvalidArgumentException ( '$impl must be a string or an instance of \ReflectionClass' ) ; } $ this -> impl = $ impl ; return $ this ; } | set the concrete implementation |
30,627 | public function toInstance ( $ instance ) : self { if ( ! ( $ instance instanceof $ this -> type ) ) { throw new \ InvalidArgumentException ( 'Instance of ' . $ this -> type . ' expectected, ' . get_class ( $ instance ) . ' given.' ) ; } $ this -> instance = $ instance ; return $ this ; } | set the concrete instance |
30,628 | public function toProviderClass ( $ providerClass ) : self { $ this -> providerClass = ( ( $ providerClass instanceof \ ReflectionClass ) ? ( $ providerClass -> getName ( ) ) : ( $ providerClass ) ) ; return $ this ; } | set the provider class that should be used to create instances for this binding |
30,629 | public function getKey ( ) : string { if ( null === $ this -> name ) { return $ this -> type ; } return $ this -> type . '#' . $ this -> name ; } | creates a unique key for this binding |
30,630 | protected function init ( $ config ) { foreach ( $ this -> loggers as $ class => $ config ) { if ( ! is_array ( $ config ) ) { $ class = $ config ; $ config = [ ] ; } $ instance = $ class :: get ( $ config ) ; if ( ! is_a ( $ instance , 'mpf\\loggers\\Logger' ) ) throw new \ Exception ( "Loggers must extend mpf\\base\\Logger class!" ) ; $ this -> loggersInstances [ ] = $ instance ; } } | Init logs for current component ; |
30,631 | public function alert ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> alert ( $ message , $ context ) ; } } | Log alert messages! |
30,632 | public function critical ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> critical ( $ message , $ context ) ; } } | Log critical messages! |
30,633 | public function debug ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> debug ( $ message , $ context ) ; } } | Log debug messages ; |
30,634 | public function emergency ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> emergency ( $ message , $ context ) ; } } | Log emergency messages ; |
30,635 | public function error ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> error ( $ message , $ context ) ; } } | Log error messages ; |
30,636 | public function info ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> info ( $ message , $ context ) ; } } | Log info messages ; |
30,637 | public function log ( $ level , $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> log ( $ level , $ message , $ context ) ; } } | Log messages ; |
30,638 | public function notice ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> notice ( $ message , $ context ) ; } } | Log notice messages ; |
30,639 | public function warning ( $ message , array $ context = array ( ) ) { $ context [ 'fromClass' ] = get_called_class ( ) ; foreach ( $ this -> loggersInstances as $ logger ) { $ logger -> warning ( $ message , $ context ) ; } } | Log warning messages |
30,640 | public function addPublished ( \ DateTimeInterface $ time ) { $ element = $ this -> addChild ( 'atom:published' , 'published' ) ; $ element -> setDate ( $ time ) ; return $ element ; } | Add date published . |
30,641 | public function getAsArray ( ) { if ( $ result = $ this -> getDecodedContent ( ) === null ) { throw new Doozr_Configuration_Reader_Exception ( 'Please read() a configuration file before you try to access it as array.' ) ; } if ( $ result !== null ) { $ result = object_to_array ( $ result ) ; } return $ result ; } | Returns the configuration as array . |
30,642 | function ToString ( ) { $ result = ( string ) $ this -> type ; if ( $ this -> value ) { $ result .= '=' . $ this -> value ; } return $ result ; } | Gets the flag as string |
30,643 | public function compile ( File $ file , File $ cacheFile ) { $ this -> file = $ file ; $ content = $ this -> compileString ( $ file -> read ( ) ) ; return $ cacheFile -> write ( $ this -> compileHeaders ( ) . $ content ) !== false ; } | COMPILER FILE TO CACHE FILE |
30,644 | public function log ( \ Throwable $ throwable ) { $ logData = date ( 'Y-m-d H:i:s' ) ; $ logData .= $ this -> fieldsOf ( $ throwable ) ; $ logData .= $ this -> fieldsOf ( $ throwable -> getPrevious ( ) ) ; error_log ( $ logData . "\n" , 3 , $ this -> logDir ( ) . DIRECTORY_SEPARATOR . 'exceptions-' . date ( 'Y-m-d' ) . '.log' ) ; } | logs the exception into a logfile |
30,645 | private function fieldsOf ( \ Throwable $ throwable = null ) : string { if ( null === $ throwable ) { return '||||' ; } return '|' . get_class ( $ throwable ) . '|' . $ throwable -> getMessage ( ) . '|' . $ throwable -> getFile ( ) . '|' . $ throwable -> getLine ( ) ; } | returns fields for exception to log |
30,646 | private function logDir ( ) : string { $ logDir = str_replace ( '{Y}' , date ( 'Y' ) , str_replace ( '{M}' , date ( 'm' ) , $ this -> logDir ) ) ; if ( ! file_exists ( $ logDir ) ) { mkdir ( $ logDir , $ this -> filemode , true ) ; } return $ logDir ; } | returns directory where to write logfile to |
30,647 | static public function getNodePath ( $ nodeId ) { if ( ! $ nodeId or ! is_numeric ( $ nodeId ) ) { return false ; } $ node = eZContentObjectTreeNode :: fetch ( $ nodeId ) ; if ( ! $ node or ! $ node instanceof eZContentObjectTreeNode ) { return false ; } $ parents = $ node -> attribute ( 'path' ) ; $ path = array ( 'path' => array ( ) , 'title_path' => array ( ) ) ; foreach ( $ parents as $ parent ) { $ path [ 'path' ] [ ] = array ( 'text' => $ parent -> attribute ( 'name' ) , 'url' => '/content/view/full/' . $ parent -> attribute ( 'node_id' ) , 'url_alias' => $ parent -> attribute ( 'url_alias' ) , 'node_id' => $ parent -> attribute ( 'node_id' ) ) ; } $ path [ 'title_path' ] = $ path [ 'path' ] ; $ path [ 'path' ] [ ] = array ( 'text' => $ node -> attribute ( 'name' ) , 'url' => false , 'url_alias' => false , 'node_id' => $ node -> attribute ( 'node_id' ) ) ; $ path [ 'title_path' ] [ ] = array ( 'text' => $ node -> attribute ( 'name' ) , 'url' => false , 'url_alias' => false ) ; return $ path ; } | function to generate path and title_path from node id |
30,648 | public function toUsers ( $ ids ) { if ( ! is_array ( $ ids ) ) { $ ids = [ $ ids ] ; } $ this -> externalUserIds = $ ids ; return $ this ; } | Set the external user ids to send to . |
30,649 | public function setName ( string $ name ) : void { if ( $ name === "" || preg_match ( "/^([a-zA-Z0-9_])+$/" , $ name ) !== 1 ) { throw new \ InvalidArgumentException ( "Invalid cookie name. Use only a-zA-Z0-9 characters." ) ; } $ this -> name = $ name ; } | Define o nome do cookie . |
30,650 | public function setDomain ( ? string $ domain ) : void { $ this -> domain = ( ( $ domain === null ) ? null : strtolower ( $ domain ) ) ; } | Define o Domain do cookie . |
30,651 | public function setPath ( ? string $ path ) : void { if ( strpos ( $ path , "/" ) !== 0 ) { $ path = "/" . $ path ; } $ this -> path = $ path ; } | Define o Path do cookie . |
30,652 | protected function percentEncode ( string $ value ) : string { $ value = str_replace ( "+" , "%20" , $ value ) ; while ( ( strpos ( $ value , "%" ) !== false && rawurlencode ( rawurldecode ( $ value ) ) === $ value ) ) { $ value = rawurldecode ( $ value ) ; } return rawurlencode ( $ value ) ; } | Aplica percent - encoding aos caracteres unsafe . |
30,653 | public function toString ( bool $ urldecoded = true ) : string { $ str = $ this -> name . "=" . $ this -> getValue ( $ urldecoded ) . ";" ; if ( $ this -> expires !== null ) { $ str .= " Expires=" . $ this -> getStrExpires ( ) . ";" ; } if ( $ this -> domain !== null ) { $ str .= " Domain=" . $ this -> domain . ";" ; } if ( $ this -> path !== null ) { $ str .= " Path=" . $ this -> path . ";" ; } if ( $ this -> secure !== null ) { $ str .= " Secure;" ; } if ( $ this -> httpOnly !== null ) { $ str .= " HttpOnly;" ; } return $ str ; } | Devolve uma string com o valor completo do Cookie . |
30,654 | public function defineCookie ( ) : bool { $ timeStamp = ( ( $ this -> expires === null ) ? null : $ this -> expires -> getTimestamp ( ) ) ; return setcookie ( $ this -> name , $ this -> value , $ timeStamp , $ this -> path , $ this -> domain , $ this -> secure , $ this -> httpOnly ) ; } | Cria o cookie e envia - o para o UA . |
30,655 | public static function fromString ( string $ str ) : Cookie { $ err = false ; $ name = "" ; $ value = "" ; $ expires = null ; $ domain = null ; $ path = "/" ; $ secure = false ; $ httpOnly = false ; if ( $ str === "" ) { $ err = "The string is not a valid representation of a cookie." ; } if ( $ err === false ) { $ parts = array_map ( "trim" , explode ( ";" , $ str ) ) ; $ nameValue = explode ( "=" , $ parts [ 0 ] ) ; $ name = $ nameValue [ 0 ] ; $ value = ( ( count ( $ nameValue ) === 2 ) ? $ nameValue [ 1 ] : "" ) ; if ( count ( $ parts ) > 1 ) { array_shift ( $ parts ) ; foreach ( $ parts as $ p ) { $ keyPair = array_map ( "trim" , explode ( "=" , $ p ) ) ; if ( count ( $ keyPair ) === 1 ) { $ keyPair [ ] = null ; } $ val = $ keyPair [ 1 ] ; switch ( strtolower ( $ keyPair [ 0 ] ) ) { case "expires" : if ( $ val !== null ) { if ( is_numeric ( $ val ) === true ) { $ expires = new \ DateTime ( ) ; $ expires -> setTimestamp ( ( int ) $ val ) ; } else { if ( strpos ( strtolower ( $ val ) , " utc" ) !== false || strpos ( strtolower ( $ val ) , " gmt" ) !== false ) { $ val = substr ( $ val , 0 , strlen ( $ val ) - 4 ) ; } $ expires = \ DateTime :: createFromFormat ( "D, d M Y H:i:s" , $ val ) ; } } break ; case "domain" : $ domain = $ val ; break ; case "path" : $ path = $ val ; break ; case "secure" : $ secure = true ; break ; case "httponly" : $ httpOnly = true ; break ; } } } } if ( $ err === false ) { return new Cookie ( $ name , $ value , $ expires , $ domain , $ path , $ secure , $ httpOnly ) ; } else { throw new \ InvalidArgumentException ( $ err ) ; } } | Converte a string passada em um objeto Cookie . |
30,656 | private function setValue ( $ value ) { switch ( gettype ( $ value ) ) { case 'int' : case 'integer' : $ this -> attributes [ 'type' ] = 'int' ; return ( int ) $ value ; case 'real' : case 'float' : case 'double' : $ this -> attributes [ 'type' ] = 'float' ; return ( float ) $ value ; case 'bool' : case 'boolean' : $ this -> attributes [ 'type' ] = 'bool' ; return ( bool ) $ value ; case 'object' : if ( $ value instanceof Collection ) { $ this -> attributes [ 'type' ] = 'collection' ; return json_encode ( $ value ) ; } $ this -> attributes [ 'type' ] = 'object' ; return json_encode ( $ value ) ; case 'array' : $ this -> attributes [ 'type' ] = 'array' ; return json_encode ( $ value ) ; default : $ this -> attributes [ 'type' ] = 'string' ; return $ value ; } } | Internal function utilized by setValueAttribute to find the value type and set the attribute accordingly . |
30,657 | private function getValue ( $ value ) { switch ( $ this -> attributes [ 'type' ] ) { case 'int' : case 'integer' : return ( int ) $ value ; case 'real' : case 'float' : case 'double' : return ( float ) $ value ; case 'bool' : case 'boolean' : return ( bool ) $ value ; case 'collection' : return new Collection ( json_decode ( $ value , true ) ) ; case 'object' : return json_decode ( $ value ) ; case 'array' : return json_decode ( $ value , true ) ; default : return $ value ; } } | Internal function utilized by getValueAttribute to get raw results from the db and format as they were set during insertion . |
30,658 | public static function cli ( $ args ) { $ cwd = getcwd ( ) ; $ cli = new self ( $ cwd ) ; return $ cli -> run ( array_slice ( $ args , 1 ) ) ; } | Entry point for command - line interface . |
30,659 | protected function run ( $ args ) { if ( ! isset ( $ args [ 0 ] ) ) { return "> Producer: Command required.\n" ; } switch ( trim ( $ args [ 0 ] ) ) { case 'init' : return $ this -> runInit ( $ args ) ; case 'autoload' : return $ this -> cmdAutoload ( $ args ) ; case 'check' : return $ this -> cmdCheck ( $ args ) ; case 'test' : return $ this -> cmdTest ( $ args ) ; case 'clone' : return $ this -> cmdClone ( $ args ) ; case 'mount' : return $ this -> cmdMount ( $ args ) ; case 'purge' : return $ this -> cmdPurge ( $ args ) ; case 'reset' : return $ this -> cmdReset ( $ args ) ; case 'update' : return $ this -> runUpdate ( $ args ) ; case 'install' : return $ this -> cmdInstall ( ) ; case 'publish' : return $ this -> cmdPublish ( $ args ) ; case '--version' : return $ this -> cmdVersion ( ) ; case '--help' : return $ this -> cmdHelp ( $ args ) ; default : return "> Producer: Undefined '{$args[0]}' command.\n" ; } } | Script runner . |
30,660 | private function cmdClone ( $ args ) { $ cmd = new CloneCommand ( $ this -> cwd ) ; return $ cmd -> run ( array_slice ( $ args , 1 ) ) ; } | Clone script . |
30,661 | private function cmdPurge ( $ args ) { $ cmd = new PurgeCommand ( $ this -> cwd ) ; return $ cmd -> run ( array_slice ( $ args , 1 ) ) ; } | Purge script . |
30,662 | private function cmdHelp ( $ args ) { $ help = isset ( $ args [ 1 ] ) ? $ args [ 1 ] : 'help' ; $ file = __DIR__ . '/../help/' . $ help . '.txt' ; if ( ! file_exists ( $ file ) ) { return $ this -> error ( '&help-not-found' ) ; } echo file_get_contents ( __DIR__ . '/../help/' . $ help . '.txt' ) ; } | Return commanline helps . |
30,663 | public static function addPsr4 ( $ paths ) { $ loader = new ClassLoader ( ) ; foreach ( $ paths as $ namespace => $ path ) { $ loader -> addPsr4 ( $ namespace , $ path ) ; } $ loader -> register ( ) ; } | Tool to register Psr4 namespaces vs paths . |
30,664 | public static function getNameCount ( String $ get ) : Int { $ segArr = self :: segmentArray ( ) ; if ( in_array ( $ get , $ segArr ) ) { $ segVal = array_search ( $ get , $ segArr ) ; return count ( $ segArr ) - 1 - $ segVal ; } return false ; } | Returns the number of segments after the specified segment . |
30,665 | public static function getNameAll ( String $ get ) : String { $ segArr = self :: segmentArray ( ) ; if ( in_array ( $ get , $ segArr ) ) { $ return = '' ; $ segVal = array_search ( $ get , $ segArr ) ; for ( $ i = 1 ; $ i < count ( $ segArr ) - $ segVal ; $ i ++ ) { $ return .= $ segArr [ $ segVal + $ i ] . "/" ; } $ return = substr ( $ return , 0 , - 1 ) ; return $ return ; } return false ; } | Returns all segments after the specified segment . |
30,666 | public static function getByIndex ( Int $ get = 1 , Int $ index = 1 ) : String { $ segArr = self :: segmentArray ( ) ; if ( $ get == 0 ) { $ get = 1 ; } $ get -= 1 ; $ uri = '' ; $ countSegArr = count ( $ segArr ) ; if ( $ index < 0 ) { $ index = $ countSegArr + $ index + 1 ; } if ( $ index > 0 ) { $ index = $ get + $ index ; } if ( abs ( $ index ) > $ countSegArr ) { $ index = $ countSegArr ; } for ( $ i = $ get ; $ i < $ index ; $ i ++ ) { $ uri .= $ segArr [ $ i ] . '/' ; } return rtrim ( $ uri , '/' ) ; } | Used to get the range according to the index of the specified segment . |
30,667 | public static function getByName ( String $ get , $ index = NULL ) : String { $ segArr = self :: segmentArray ( ) ; $ getVal = ( int ) array_search ( $ get , $ segArr ) ; if ( $ index === 'all' ) { $ indexVal = count ( $ segArr ) - 1 ; } else { $ indexVal = array_search ( $ index , $ segArr ) ; } $ return = '' ; for ( $ i = $ getVal ; $ i <= $ indexVal ; $ i ++ ) { $ return .= $ segArr [ $ i ] . "/" ; } return substr ( $ return , 0 , - 1 ) ; } | Used to get the range according to the specified segment names . |
30,668 | public static function segmentArray ( ) : Array { $ segmentEx = Arrays \ RemoveElement :: element ( explode ( '/' , self :: _cleanPath ( ) ) , '' ) ; return $ segmentEx ; } | Get Segment Array |
30,669 | public static function totalSegments ( ) : Int { $ segmentEx = array_diff ( self :: segmentArray ( ) , [ "" , " " ] ) ; $ totalSegments = count ( $ segmentEx ) ; return $ totalSegments ; } | Get Total Segments |
30,670 | protected static function _addFix ( $ query , $ type ) { $ query = rtrim ( $ query , '/' ) ; switch ( $ type ) { case 'left' : return Base :: prefix ( $ query ) ; case 'right' : return Base :: suffix ( $ query ) ; case 'both' : return Base :: presuffix ( $ query ) ; default : return $ query ; } } | Protected Add Fix |
30,671 | public static function add ( $ request , $ match ) { $ perm = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'role_id' ] ) ; if ( array_key_exists ( 'user_id' , $ match ) ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'user_id' ] ) ; } elseif ( array_key_exists ( 'user_id' , $ request -> REQUEST ) ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ request -> REQUEST [ 'user_id' ] ) ; } elseif ( array_key_exists ( 'login' , $ request -> REQUEST ) ) { $ user = new User_Account ( ) ; $ user = $ user -> getUser ( $ request -> REQUEST [ 'login' ] ) ; } if ( ! isset ( $ user ) || $ user -> isAnonymous ( ) ) { throw new Pluf_HTTP_Error404 ( __ ( 'User not found' ) ) ; } $ perm -> setAssoc ( $ user ) ; return $ user ; } | Add new user to a role . In other word grant a role to a user . Id of added user should be specified in request . |
30,672 | public static function find ( $ request , $ match ) { $ perm = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'role_id' ] ) ; $ pag = new Pluf_Paginator ( new User_Account ( ) ) ; $ sql = new Pluf_SQL ( 'user_role_id=%s' , array ( $ perm -> id ) ) ; $ pag -> forced_where = $ sql ; $ pag -> list_filters = array ( 'is_active' , 'login' , 'first_name' , 'last_name' , 'email' ) ; $ pag -> sort_order = array ( 'id' , 'ASC' ) ; $ search_fields = array ( 'login' , 'first_name' , 'last_name' , 'email' ) ; $ list_display = array ( 'login' => __ ( 'login' ) , 'first_name' => __ ( 'first name' ) , 'last_name' => __ ( 'last name' ) , 'email' => __ ( 'email' ) ) ; $ sort_fields = array ( 'id' , 'login' , 'first_name' , 'last_name' , 'date_joined' , 'last_login' ) ; $ pag -> model_view = 'join_role' ; $ pag -> configure ( $ list_display , $ search_fields , $ sort_fields ) ; $ pag -> setFromRequest ( $ request ) ; return $ pag -> render_object ( ) ; } | Returns list of users of a role . Resulted list can be customized by using filters conditions and sort rules . |
30,673 | public static function get ( $ request , $ match ) { $ perm = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'role_id' ] ) ; $ userModel = new User_Account ( ) ; $ param = array ( 'view' => 'join_role' , 'filter' => array ( 'id=' . $ match [ 'user_id' ] , 'role_id=' . $ perm -> id ) ) ; $ users = $ userModel -> getList ( $ param ) ; if ( $ users -> count ( ) == 0 ) { throw new Pluf_Exception_DoesNotExist ( 'User has not such role' ) ; } return $ users [ 0 ] ; } | Returns information of a user of a role . |
30,674 | public function chmod ( $ permissions ) { $ this -> permissions = $ permissions ; $ this -> lastAttributeModified = time ( ) ; clearstatcache ( ) ; return $ this ; } | change file runtimeEnvironment to given permissions |
30,675 | public function isRouteAllowed ( ) { return $ this -> _redirected || in_array ( Request :: getRequestMethod ( ) , $ this -> getRoute ( ) -> getMethods ( ) ) === true ; } | Only allow defined methods for specific route . When a route is redirected it is always allowed |
30,676 | protected function ping ( InputInterface $ input , OutputInterface $ output ) { $ input ; $ result = Splash :: Selftest ( ) ; $ output -> writeln ( $ result ? "<bg=green;fg=white;options=bold>=== SPLASH : PING TEST PASSED </>" : "<bg=green;fg=white;options=bold>=== SPLASH : PING TEST PASSED </>" ) ; } | Execute Module Ping Test |
30,677 | protected function connect ( InputInterface $ input , OutputInterface $ output ) { $ input ; $ result = Splash :: Connect ( ) ; $ output -> writeln ( $ result ? "<bg=green;fg=white;options=bold>=== SPLASH : CONNECT TEST PASSED </>" : "<bg=green;fg=white;options=bold>=== SPLASH : CONNECT TEST PASSED </>" ) ; $ this -> ShowLogs ( $ output , $ result ) ; } | Execute Module Connect Test |
30,678 | protected function showLogs ( OutputInterface $ output , bool $ result ) { if ( ! $ result || $ output -> isVerbose ( ) ) { $ output -> write ( Splash :: log ( ) -> GetConsoleLog ( true ) ) ; $ output -> writeln ( "" ) ; $ output -> writeln ( "" ) ; } } | Render Splash Core Logs |
30,679 | public function registerFieldMapper ( FieldMapper $ fieldMapper ) { $ targetFields = $ fieldMapper -> getSupportedFields ( ) ; foreach ( $ targetFields as $ fieldName ) { $ this -> fieldMappers [ $ fieldName ] = $ fieldMapper ; } } | Registers given FieldMapper instance Allows overwriting an already existing mapper for a given field |
30,680 | public function updateListItem ( $ key , $ itemKey , $ itemValue , $ listDefaultValue = array ( ) ) { if ( ! isset ( $ _SESSION [ $ key ] ) ) { $ _SESSION [ $ key ] = $ listDefaultValue ; } $ _SESSION [ $ key ] [ $ itemKey ] = $ itemValue ; return $ this ; } | Updates a single item from list . If that list is not found then it will have the selected default value that will then be updated with the selected options . |
30,681 | protected function getSelectedChoices ( $ choiceViews , array $ values ) { $ selectedChoices = [ ] ; foreach ( $ choiceViews as $ index => $ choiceView ) { if ( $ choiceView instanceof ChoiceGroupView ) { $ selectedChoices = array_merge ( $ selectedChoices , $ this -> getSelectedChoices ( $ choiceView -> choices , $ values ) ) ; } elseif ( $ choiceView instanceof ChoiceView ) { if ( \ in_array ( $ choiceView -> value , $ values ) ) { $ selectedChoices [ ] = $ choiceView ; } } } return $ selectedChoices ; } | Get the selected choices . |
30,682 | public function transform ( Job $ job ) { return [ 'createdAt' => $ job -> created_at -> toW3cString ( ) , 'memberIds' => $ job -> members -> pluck ( 'id' ) , 'memberName' => ( count ( $ job -> members ) > 0 ) ? $ job -> members -> first ( ) -> user -> name : null , 'memberTagIds' => $ job -> member_tags -> pluck ( 'id' ) , 'memberTagNames' => ( count ( $ job -> member_tags ) > 0 ) ? implode ( ', ' , $ job -> member_tags -> pluck ( 'name' ) -> toArray ( ) ) : null , 'id' => $ job -> id , 'locationId' => $ job -> location_id , 'locationName' => is_null ( $ job -> location_id ) ? null : $ job -> location -> name , 'start' => $ job -> start -> toW3cString ( ) , 'updatedAt' => $ job -> updated_at -> toW3cString ( ) , ] ; } | Transformer to generate JSON response with summary Job data |
30,683 | protected function getDeadPlacesFromRoundPlayed ( Round $ round ) : array { $ deadPlaces = [ ] ; $ multipleRules = array_filter ( $ round -> getToQualifyRules ( ) , function ( $ toRule ) { return $ toRule -> isMultiple ( ) ; } ) ; $ multipleWinnersRules = array_filter ( $ multipleRules , function ( $ toRule ) { return $ toRule -> getWinnersOrLosers ( ) === Round :: WINNERS ; } ) ; $ multipleWinnersRule = reset ( $ multipleWinnersRules ) ; $ multipleLosersRules = array_filter ( $ multipleRules , function ( $ toRule ) { return $ toRule -> getWinnersOrLosers ( ) === Round :: LOSERS ; } ) ; $ multipleLosersRule = reset ( $ multipleLosersRules ) ; $ nrOfUniqueFromPlacesMultiple = count ( $ this -> getUniqueFromPlaces ( $ multipleRules ) ) ; if ( $ multipleWinnersRule !== false ) { $ qualifyAmount = count ( $ multipleWinnersRule -> getToPoulePlaces ( ) ) ; $ rankingItems = $ this -> getRankingItemsForMultipleRule ( $ multipleWinnersRule ) ; for ( $ i = 0 ; $ i < $ qualifyAmount ; $ i ++ ) { $ nrOfUniqueFromPlacesMultiple -- ; array_shift ( $ rankingItems ) ; } $ amountQualifyLosers = $ multipleLosersRule !== false ? count ( $ multipleLosersRule -> getToPoulePlaces ( ) ) : 0 ; while ( $ nrOfUniqueFromPlacesMultiple - $ amountQualifyLosers > 0 ) { $ nrOfUniqueFromPlacesMultiple -- ; $ deadPlaces [ ] = array_shift ( $ rankingItems ) -> getPoulePlace ( ) ; } } $ poulePlacesPer = $ this -> getPoulePlacesPer ( $ round ) ; foreach ( $ poulePlacesPer as $ poulePlaces ) { if ( $ round -> getWinnersOrLosers ( ) === Round :: LOSERS ) { $ poulePlaces = array_reverse ( $ poulePlaces ) ; } $ deadPlacesPer = array_filter ( $ poulePlaces , function ( $ poulePlace ) { return count ( $ poulePlace -> getToQualifyRules ( ) ) === 0 ; } ) ; foreach ( $ this -> getDeadPlacesFromPlaceNumber ( $ deadPlacesPer , $ round ) as $ deadPoulePlace ) { $ deadPlaces [ ] = $ deadPoulePlace ; } } if ( $ multipleLosersRule !== false ) { $ qualifyAmount = count ( $ multipleLosersRule -> getToPoulePlaces ( ) ) ; $ rankingItems = $ this -> getRankingItemsForMultipleRule ( $ multipleLosersRule ) ; for ( $ i = 0 ; $ i < $ qualifyAmount ; $ i ++ ) { $ nrOfUniqueFromPlacesMultiple -- ; array_pop ( $ rankingItems ) ; } while ( $ nrOfUniqueFromPlacesMultiple ) { $ nrOfUniqueFromPlacesMultiple -- ; $ deadPlaces [ ] = array_pop ( $ rankingItems ) -> getPoulePlace ( ) ; } } return $ deadPlaces ; } | 1 pak weer de unique plaatsen 2 bepaal wie er doorgaan van de winnaars en haal deze eraf 3 doe de plekken zonder to - regels 4 bepaal wie er doorgaan van de verliezers en haal deze eraf 5 voeg de overgebleven plekken toe aan de deadplaces |
30,684 | public function init ( Configurable $ configurable , string $ environment , InputInterface $ input , OutputInterface $ output ) { $ environmentConfigurable = new PrefixConfigurableDecorator ( $ configurable , "project.environments.$environment." ) ; $ projectConfigurable = new PrefixConfigurableDecorator ( $ configurable , "project.default." ) ; $ fallbackConfigurable = new ConfigurableFallback ( $ environmentConfigurable , $ projectConfigurable ) ; $ initializer = new ConfigurationInitializer ( $ output ) ; if ( $ this -> getFlag ( 'dev' , false ) ) { $ initializer -> init ( $ fallbackConfigurable , 'mount-workdir' , true ) ; $ initializer -> init ( $ fallbackConfigurable , 'use-app-container' , false ) ; } else { $ initializer -> init ( $ fallbackConfigurable , 'rancher.stack' , 'Project' ) ; $ schedulerInitializer = new SchedulerInitializer ( $ initializer ) ; $ schedulerInitializer -> init ( $ fallbackConfigurable , $ projectConfigurable ) ; } $ initializer -> init ( $ fallbackConfigurable , 'external_links' , [ ] ) ; $ initializer -> init ( $ fallbackConfigurable , 'docker.repository' , 'repo/name' , $ projectConfigurable ) ; $ initializer -> init ( $ fallbackConfigurable , 'docker.version-prefix' , '' , $ projectConfigurable ) ; $ initializer -> init ( $ fallbackConfigurable , 'service-name' , 'Project' , $ projectConfigurable ) ; $ initializer -> init ( $ fallbackConfigurable , 'docker.base-image' , 'php:7.0-alpine' , $ projectConfigurable ) ; $ initializer -> init ( $ fallbackConfigurable , 'environment' , [ "EXAMPLE" => 'value' ] ) ; $ initializer -> init ( $ fallbackConfigurable , 'php' , '7.0' , $ projectConfigurable ) ; $ initializer -> init ( $ fallbackConfigurable , 'add-composer' , false , $ projectConfigurable ) ; $ initializer -> init ( $ fallbackConfigurable , 'command' , "-i" , $ projectConfigurable ) ; } | Fill the configurable with all possible options with explanatory default options set |
30,685 | public function validate ( Configuration $ configurable , string $ environment ) { $ projectConfigurable = new PrefixConfigurationDecorator ( $ configurable , "project.default." ) ; $ environmentConfigurable = new PrefixConfigurationDecorator ( $ configurable , "project.environments.$environment." ) ; $ config = new ConfigurationFallback ( $ environmentConfigurable , $ projectConfigurable ) ; $ this -> getValidator ( ) -> validate ( $ config , [ 'service-name' => 'required' , ] ) ; } | Ensure that the given environment has at least the minimal configuration options set to start and deploy this blueprint |
30,686 | public function set ( & $ variable , $ identifier = null ) { if ( null === $ identifier ) { $ identifier = sha1 ( serialize ( $ variable ) ) ; } self :: $ references [ ] = $ variable ; $ index = count ( self :: $ references ) - 1 ; self :: $ lookup [ $ identifier ] = $ index ; self :: $ reverseLookup [ $ index ] = $ identifier ; self :: $ count = $ index + 1 ; return $ identifier ; } | This method storages an element in the registry under the passed key . |
30,687 | public function get ( $ identifier = null ) { $ result = null ; if ( null === $ identifier ) { $ result = self :: $ lookup ; } elseif ( 'doozr.registry' === $ identifier ) { $ result = $ this ; } else { if ( true === isset ( self :: $ lookup [ $ identifier ] ) ) { $ result = self :: $ references [ self :: $ lookup [ $ identifier ] ] ; } } return $ result ; } | This method returns a previously stored element from the registry . |
30,688 | public function add ( & $ variable , $ identifier = null ) { if ( $ identifier === null ) { $ identifier = $ this -> calculateUuid ( ) ; } return $ this -> set ( $ variable , $ identifier ) ; } | Adds an multi element like a multi instance service to registry by generating UUID for instances . |
30,689 | protected function calculateUuid ( ) { try { $ uuid4 = Uuid :: uuid4 ( ) ; $ uuid = $ uuid4 -> toString ( ) ; } catch ( UnsatisfiedDependencyException $ exception ) { throw new Doozr_Registry_Exception ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) , $ exception ) ; } return $ uuid ; } | Calculates a random UUID . |
30,690 | public function getParameter ( $ key ) { if ( true === isset ( self :: $ parameters [ $ key ] ) ) { $ value = self :: $ parameters [ $ key ] ; } else { throw new Doozr_Registry_Exception ( sprintf ( 'Key "%s" does not exist!' , $ key ) ) ; } return $ value ; } | Getter for parameter . |
30,691 | public function routes ( $ routes ) { foreach ( $ routes as $ route => $ controllerAction ) { if ( is_array ( $ controllerAction ) ) { } else { $ explodedRoute = explode ( ' ' , $ route ) ; list ( $ method , $ path ) = $ explodedRoute ; if ( $ method == 'RESOURCE' ) { $ controller = $ controllerAction ; require_once app_path ( "controllers/$controller.php" ) ; $ routes = $ controller :: _registerRoutes ( $ this , $ path , $ controller ) ; } else { $ explodedAction = explode ( '@' , $ controllerAction ) ; list ( $ controller , $ action ) = $ explodedAction ; $ this -> register ( $ method , $ path , $ controller , $ action ) ; } } } } | Route out our routes |
30,692 | private function register ( $ method , $ path , $ controller , $ action ) { $ this -> klein -> respond ( $ method , $ path , function ( $ request , $ response , $ service ) use ( $ controller , $ action ) { require_once app_path ( "controllers/$controller.php" ) ; $ class = new $ controller ( $ request , $ response , $ service ) ; $ class -> _preRender ( ) ; echo $ class -> _render ( $ class -> $ action ( ) , array ( ) ) ; $ class -> _postRender ( ) ; } ) ; } | Register a specific route and call it s renderers |
30,693 | public function sendResponseHttpHeaders ( ResponseInterface $ response ) : void { if ( headers_sent ( ) ) { throw new ResponseSenderException ( "A response has already been sent to the web browser" , $ this ) ; } if ( $ this -> removePhpHttpHeaders ) { foreach ( headers_list ( ) as $ header ) { header_remove ( explode ( ":" , $ header ) [ 0 ] ) ; } } $ this -> sendHttpVersionHeader ( $ response -> getProtocolVersion ( ) , $ response -> getStatusCode ( ) , $ response -> getReasonPhrase ( ) ) ; $ this -> sendHttpHeaders ( $ this -> listResponseHeaders ( $ response ) ) ; } | Sends the response HTTP headers . |
30,694 | protected function listResponseHeaders ( ResponseInterface $ response ) : \ Generator { foreach ( $ response -> getHeaders ( ) as $ header => $ values ) { foreach ( $ values as $ value ) { yield $ header => $ value ; } } } | Returns the list of all the headers of a PSR - 7 response . |
30,695 | protected function sendHttpVersionHeader ( string $ protocolVersion , int $ statusCode , ? string $ reasonPhrase = null ) : void { header ( sprintf ( "HTTP/%s %d %s" , $ protocolVersion , $ statusCode , $ reasonPhrase ?? HttpReasonPhraseLookup :: getReasonPhrase ( $ statusCode ) ) , true ) ; } | Sends the HTTP version header . |
30,696 | protected function sendHttpHeaders ( iterable $ headers ) : void { foreach ( $ headers as $ header => $ value ) { header ( "$header: $value" , false ) ; } } | Sends multiple HTTP headers . |
30,697 | public function sendResponseBody ( ResponseInterface $ response ) : void { if ( ( $ body = $ response -> getBody ( ) -> detach ( ) ) === null ) { $ body = $ response -> getBody ( ) -> __toString ( ) ; } $ this -> sendBody ( $ body ) ; } | Sends a response s body . |
30,698 | protected function sendBody ( $ body ) : void { if ( is_resource ( $ body ) ) { fpassthru ( $ body ) ; fclose ( $ body ) ; } else { echo $ body ; } } | Sends the body . |
30,699 | public static function update ( $ request , $ match ) { $ model = Pluf_Shortcuts_GetObjectOr404 ( 'User_Role' , $ match [ 'id' ] ) ; $ form = Pluf_Shortcuts_GetFormForUpdateModel ( $ model , $ request -> REQUEST , array ( ) ) ; $ model = $ form -> save ( ) ; $ request -> user -> setMessage ( sprintf ( __ ( 'Role data has been updated.' ) , ( string ) $ model ) ) ; return new Pluf_HTTP_Response_Json ( $ model ) ; } | Updates information of a role . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.