idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
36,100 | public function createSubdomain ( $ domainName , \ Transip \ Model \ SubDomain $ subDomain ) { return $ this -> getSoapClient ( array_merge ( array ( $ domainName , $ subDomain ) , array ( '__method' => 'createSubdomain' ) ) ) -> createSubdomain ( $ domainName , $ subDomain ) ; } | Creates a SubDomain |
36,101 | public function make ( array $ items , $ total , $ perPage ) { $ paginator = new Paginator ( $ this , $ items , $ total , $ perPage ) ; return $ paginator -> setupPaginationContext ( ) ; } | Get a new paginator instance . |
36,102 | public function getPaginationView ( Paginator $ paginator , $ view = null ) { $ data = array ( 'environment' => $ this , 'paginator' => $ paginator ) ; return $ this -> view -> make ( $ this -> getViewName ( $ view ) , $ data ) ; } | Get the pagination view . |
36,103 | public function getCurrentPage ( ) { $ page = ( int ) $ this -> currentPage ? : $ this -> request -> query -> get ( $ this -> pageName , 1 ) ; if ( $ page < 1 || filter_var ( $ page , FILTER_VALIDATE_INT ) === false ) { return 1 ; } return $ page ; } | Get the number of the current page . |
36,104 | public function hasAccess ( array $ url , array $ user ) : bool { $ result = parent :: hasAccess ( $ url , $ user ) ; if ( ! $ result ) { return $ result ; } if ( ! empty ( $ user [ 'is_supervisor' ] ) && $ user [ 'is_supervisor' ] ) { $ users = Utils :: getReportToUsers ( $ user [ 'id' ] ) ; foreach ( $ users as $ userRecord ) { $ result = ( new AccessFactory ( ) ) -> hasAccess ( $ url , $ userRecord -> toArray ( ) ) ; if ( $ result ) { return $ result ; } } } return false ; } | hasAccess for superviser user |
36,105 | public function show ( ) { $ content = Content :: newPostInstance ( ) ; if ( Gate :: denies ( 'create' , $ content ) ) { return view ( 'orchestra/story::admin.home' ) ; } return $ this -> writePost ( $ content ) ; } | Show Dashboard . |
36,106 | protected function writePost ( Content $ content ) { set_meta ( 'title' , 'Write a Post' ) ; $ content -> setAttribute ( 'format' , $ this -> editorFormat ) ; return view ( 'orchestra/story::admin.editor' , [ 'content' => $ content , 'url' => handles ( 'orchestra::storycms/posts' ) , 'method' => 'POST' , ] ) ; } | Write a post . |
36,107 | private function getForwardOnlyField ( ) { $ fFields = [ ] ; $ fields = $ this -> fetchFields ( [ 'reverse' => false ] ) ; foreach ( $ fields as $ field ) { $ fFields [ $ field -> getName ( ) ] = $ field ; $ fFields [ $ field -> getAttrName ( ) ] = $ field ; } return $ fFields ; } | Used only when we are trying to get field that belongs to the scope model . |
36,108 | public function getConcreteFields ( ) { $ concreteFields = [ ] ; foreach ( $ this -> getNonM2MForwardFields ( ) as $ name => $ field ) { if ( $ field -> concrete ) { $ concreteFields [ $ name ] = $ field ; } } return $ concreteFields ; } | Returns a list of all concrete fields on the model and its parents . |
36,109 | public function contributeToClass ( $ propertyName , $ classObject ) { ClassHelper :: setAttributes ( $ classObject , [ $ propertyName => $ this ] ) ; $ modelClass = $ this -> modelClassInfo ( $ classObject ) ; $ this -> modelName = $ modelClass -> getShortName ( ) ; $ this -> modelNamespace = $ modelClass -> getNamespaceName ( ) ; $ this -> namspacedModelName = $ modelClass -> getName ( ) ; $ this -> scopeModel = $ classObject ; foreach ( static :: $ DEFAULT_NAMES as $ defaultName ) { if ( ArrayHelper :: hasKey ( $ this -> overrides , $ defaultName ) ) { $ this -> { $ defaultName } = $ this -> overrides [ $ defaultName ] ; } } if ( null == $ this -> getDbTable ( ) ) { $ this -> setDbTable ( $ this -> getTableName ( ) ) ; } $ vName = $ this -> verboseName ; $ this -> verboseName = ( empty ( $ vName ) ) ? ucwords ( StringHelper :: camelToSpace ( $ this -> modelName ) ) : $ vName ; } | Add the current object to the passed in object . |
36,110 | public function setupPrimaryKey ( Field $ field ) { if ( ! $ this -> primaryKey && $ field -> primaryKey ) { $ this -> primaryKey = $ field ; } } | Set the primary key field of the model . |
36,111 | public static function trigger ( $ event , & $ data ) { if ( ! isset ( self :: $ manager ) ) { self :: init ( ) ; } return self :: $ manager -> triggerEvent ( $ event , $ data ) ; } | Trigger a set of event handlers if present . |
36,112 | public static function patch ( $ classes = [ ] , $ options = [ ] ) { $ loaders = spl_autoload_functions ( ) ; $ loader = reset ( $ loaders ) ; $ interceptor = null ; if ( method_exists ( $ loader [ 0 ] , 'patchers' ) ) { $ interceptor = $ loader [ 0 ] ; class_exists ( 'Lead\Jit\JitException' ) ; class_exists ( 'Lead\Jit\Node\NodeDef' ) ; class_exists ( 'Lead\Jit\Node\FunctionDef' ) ; class_exists ( 'Lead\Jit\Node\BlockDef' ) ; class_exists ( 'Lead\Jit\TokenStream' ) ; class_exists ( 'Lead\Jit\Parser' ) ; } elseif ( isset ( $ options [ 'loader' ] ) ) { $ interceptor = Interceptor :: patch ( $ options ) ; static :: $ _unpatch = true ; } else { foreach ( $ loaders as $ loader ) { if ( $ loader [ 0 ] instanceof ClassLoader ) { $ options [ 'loader' ] = [ $ loader [ 0 ] , 'loadClass' ] ; $ interceptor = Interceptor :: patch ( $ options ) ; static :: $ _unpatch = true ; break ; } } } if ( ! $ interceptor ) { throw new Exception ( "Unable to find a valid autoloader to apply the JIT filter patcher." ) ; } $ filter = new Filter ( [ 'patch' => $ classes ] ) ; $ patchers = $ interceptor -> patchers ( ) ; $ patchers -> add ( 'filter' , $ filter ) ; return static :: $ _interceptor = $ interceptor ; } | Enables filter JIT patching . |
36,113 | public static function unpatch ( ) { if ( ! static :: $ _interceptor ) { return true ; } $ patchers = static :: $ _interceptor -> patchers ( ) ; $ patchers -> remove ( 'filter' ) ; static :: $ _interceptor = null ; if ( static :: $ _unpatch ) { static :: $ _unpatch = false ; return Interceptor :: unpatch ( ) ; } return true ; } | Disables filter JIT patching . |
36,114 | public function checkRequestForArraySessions ( Request $ request ) { if ( is_null ( $ this -> reject ) ) return ; if ( call_user_func ( $ this -> reject , $ request ) ) { $ this -> manager -> setDefaultDriver ( 'array' ) ; } } | Check the request and reject callback for array sessions . |
36,115 | public function runAsync ( $ blocking = self :: NON_BLOCKING ) { if ( $ this -> running ) { throw new RuntimeException ( 'Process already running.' ) ; } try { $ this -> exec ( false , $ blocking ) ; } catch ( ProcessException $ ex ) { throw $ ex ; } catch ( Exception $ ex ) { $ this -> cleanup ( ) ; throw new ProcessException ( 'Unknown process exception.' , $ this , $ ex ) ; } return $ this ; } | Execute the command asynchronously . |
36,116 | public function run ( $ timeout = - 1 , $ blocking = self :: NON_BLOCKING ) { if ( $ this -> running ) { throw new RuntimeException ( 'Process already running.' ) ; } try { $ this -> exec ( false , $ blocking ) ; $ this -> wait ( $ timeout ) ; } catch ( ProcessException $ ex ) { throw $ ex ; } catch ( Exception $ ex ) { $ this -> cleanup ( ) ; throw new ProcessException ( 'Unknown process exception.' , $ this , $ ex ) ; } return $ this ; } | Execute the command synchronously . |
36,117 | public function runInteractive ( $ blocking = self :: NON_BLOCKING ) { if ( $ this -> running ) { throw new RuntimeException ( 'Process already running.' ) ; } try { $ this -> exec ( true , $ blocking ) ; } catch ( ProcessException $ ex ) { throw $ ex ; } catch ( Exception $ ex ) { $ this -> cleanup ( ) ; throw new ProcessException ( 'Unknown process exception.' , $ this , $ ex ) ; } return $ this ; } | Execute the command interactively . |
36,118 | public function wait ( $ timeout = - 1 ) { $ forever = ( $ timeout < 0 ) ; while ( $ this -> isAlive ( ) ) { $ this -> read ( ) ; if ( ! $ forever && ( microtime ( true ) - $ this -> start > $ timeout ) ) { $ this -> kill ( SIGKILL ) ; break ; } usleep ( 5000 ) ; } $ this -> cleanup ( ) ; } | Wait for the process to finish execution . |
36,119 | public function send ( $ input ) { if ( ! $ this -> isAlive ( ) ) { throw new LogicException ( 'Process is not alive.' ) ; } elseif ( ! $ this -> interactive ) { throw new LogicException ( "Process [{$this->pid}] not running interactively." ) ; } $ bytes = fwrite ( $ this -> pipes [ static :: STDIN ] , $ input , strlen ( $ input ) ) ; if ( $ bytes === false ) { $ this -> kill ( ) ; throw new ProcessException ( "Error sending [$input] to $this stdin." , $ this ) ; } } | Sends the text to the interactive process via its stdin . |
36,120 | public function kill ( $ signal = SIGTERM ) { if ( ! $ this -> isAlive ( ) ) { return false ; } if ( ! proc_terminate ( $ this -> resource , $ signal ) ) { return false ; } $ this -> setStreamBlocking ( ) ; while ( $ this -> isAlive ( ) ) { usleep ( 50000 ) ; } $ this -> cleanup ( ) ; return true ; } | Kill the running process . |
36,121 | protected function readStream ( $ id ) { $ isDescriptorFile = isset ( $ this -> descriptorspec [ $ id ] [ 0 ] ) && $ this -> descriptorspec [ $ id ] [ 0 ] == 'file' ; $ isDescriptorResource = isset ( $ this -> descriptorspec [ $ id ] ) && is_resource ( $ this -> descriptorspec [ $ id ] ) ; if ( $ isDescriptorFile || $ isDescriptorResource ) { return '' ; } return stream_get_contents ( $ this -> pipes [ $ id ] ) ; } | Reads the current contents of the specified pipe . |
36,122 | protected final function validate ( ) { if ( isset ( $ this -> pid ) && ! isset ( $ this -> resource ) ) { throw new LogicException ( 'Process already closed.' , static :: ERR_COMPLETED ) ; } elseif ( $ this -> running ) { throw new LogicException ( 'Process already running.' , static :: ERR_RUNNING ) ; } $ this -> command -> validate ( ) ; } | Validate the process can be run . |
36,123 | protected function cleanup ( ) { if ( $ this -> running ) { throw new RuntimeException ( sprintf ( 'Cleanup error - process still running: %s' , is_scalar ( $ this -> command ) ? $ this -> command : $ this -> command -> serialize ( ) ) ) ; } if ( ! isset ( $ this -> resource ) ) { return ; } $ this -> pid = - 1 ; $ this -> read ( ) ; foreach ( $ this -> pipes as $ index => $ pipe ) { if ( ! $ this -> interactive && $ index === static :: STDIN ) { continue ; } fclose ( $ pipe ) ; } proc_close ( $ this -> resource ) ; unset ( $ this -> resource , $ this -> pipes ) ; $ this -> running = false ; if ( in_array ( $ this -> exitcode , $ this -> getExpectedExitcodes ( ) ) ) { if ( isset ( $ this -> onSuccess ) ) { call_user_func ( $ this -> onSuccess ) ; } } else { if ( isset ( $ this -> onError ) ) { call_user_func ( $ this -> onError , $ this ) ; } else { throw new ProcessException ( sprintf ( 'Error executing process: %s' , is_scalar ( $ this -> command ) ? $ this -> command : $ this -> command -> serialize ( ) ) , $ this ) ; } } } | Release the process memory . |
36,124 | private function checkStatus ( ) { if ( ! $ this -> running ) { return ; } if ( $ this -> running ) { foreach ( proc_get_status ( $ this -> resource ) as $ key => $ value ) { if ( $ key == 'command' ) { continue ; } $ this -> $ key = $ value ; } } if ( ! $ this -> running ) { $ this -> cleanup ( ) ; } } | Check the current processes status . |
36,125 | public function init ( ) { $ options = & Options_Framework :: _optionsframework_options ( ) ; if ( $ options ) { add_action ( 'admin_menu' , array ( $ this , 'add_custom_options_page' ) ) ; add_action ( 'admin_enqueue_scripts' , array ( $ this , 'enqueue_admin_styles' ) ) ; add_action ( 'admin_enqueue_scripts' , array ( $ this , 'enqueue_admin_scripts' ) ) ; add_action ( 'admin_init' , array ( $ this , 'settings_init' ) ) ; add_action ( 'wp_before_admin_bar_render' , array ( $ this , 'optionsframework_admin_bar' ) ) ; } else { add_action ( 'admin_notices' , array ( $ this , 'options_notice' ) ) ; add_action ( 'admin_init' , array ( $ this , 'options_notice_ignore' ) ) ; } } | Hook in the scripts and styles |
36,126 | function options_notice ( ) { global $ pagenow ; if ( ! is_multisite ( ) && ( $ pagenow == 'plugins.php' || $ pagenow == 'themes.php' ) ) { global $ current_user ; $ user_id = $ current_user -> ID ; if ( ! get_user_meta ( $ user_id , 'optionsframework_ignore_notice' ) ) { echo '<div class="updated optionsframework_setup_nag"><p>' ; printf ( __ ( 'Your current theme does not have support for the Options Framework plugin. <a href="%1$s" target="_blank">Learn More</a> | <a href="%2$s">Hide Notice</a>' , 'options-framework' ) , 'http://wptheming.com/options-framework-plugin' , '?optionsframework_nag_ignore=0' ) ; echo "</p></div>" ; } } } | Let s the user know that options aren t available for their theme |
36,127 | function options_notice_ignore ( ) { global $ current_user ; $ user_id = $ current_user -> ID ; if ( isset ( $ _GET [ 'optionsframework_nag_ignore' ] ) && '0' == $ _GET [ 'optionsframework_nag_ignore' ] ) { add_user_meta ( $ user_id , 'optionsframework_ignore_notice' , 'true' , true ) ; } } | Allows the user to hide the options notice |
36,128 | function add_custom_options_page ( ) { $ menu = $ this -> menu_settings ( ) ; switch ( $ menu [ 'mode' ] ) { case 'menu' : $ this -> options_screen = add_menu_page ( $ menu [ 'page_title' ] , $ menu [ 'menu_title' ] , $ menu [ 'capability' ] , $ menu [ 'menu_slug' ] , array ( $ this , 'options_page' ) , $ menu [ 'icon_url' ] , $ menu [ 'position' ] ) ; break ; default : $ this -> options_screen = add_submenu_page ( $ menu [ 'parent_slug' ] , $ menu [ 'page_title' ] , $ menu [ 'menu_title' ] , $ menu [ 'capability' ] , $ menu [ 'menu_slug' ] , array ( $ this , 'options_page' ) ) ; break ; } } | Add a subpage called Theme Options to the appearance menu . |
36,129 | function enqueue_admin_styles ( $ hook ) { if ( $ this -> options_screen != $ hook ) return ; wp_enqueue_style ( 'optionsframework' , plugin_dir_url ( dirname ( __FILE__ ) ) . 'css/optionsframework.css' , array ( ) , Options_Framework :: VERSION ) ; wp_enqueue_style ( 'wp-color-picker' ) ; } | Loads the required stylesheets |
36,130 | function enqueue_admin_scripts ( $ hook ) { if ( $ this -> options_screen != $ hook ) return ; wp_enqueue_script ( 'options-custom' , plugin_dir_url ( dirname ( __FILE__ ) ) . 'js/options-custom.js' , array ( 'jquery' , 'wp-color-picker' ) , Options_Framework :: VERSION ) ; add_action ( 'admin_head' , array ( $ this , 'of_admin_head' ) ) ; } | Loads the required javascript |
36,131 | function options_page ( ) { ?> <div id="optionsframework-wrap" class="wrap"> <?php $ menu = $ this -> menu_settings ( ) ; ?> <h2> <?php echo esc_html ( $ menu [ 'page_title' ] ) ; ?> </h2> <h2 class="nav-tab-wrapper"> <?php echo Options_Framework_Interface :: optionsframework_tabs ( ) ; ?> </h2> <?php settings_errors ( 'options-framework' ) ; ?> <div id="optionsframework-metabox" class="metabox-holder"> <div id="optionsframework" class="postbox"> <form action="options.php" method="post"> <?php settings_fields ( 'optionsframework' ) ; ?> <?php Options_Framework_Interface :: optionsframework_fields ( ) ; ?> <div id="optionsframework-submit"> <input type="submit" class="button-primary" name="update" value=" <?php esc_attr_e ( 'Save Options' , 'options-framework' ) ; ?> " /> <input type="submit" class="reset-button button-secondary" name="reset" value=" <?php esc_attr_e ( 'Restore Defaults' , 'options-framework' ) ; ?> " onclick="return confirm( ' <?php print esc_js ( __ ( 'Click OK to reset. Any theme settings will be lost!' , 'options-framework' ) ) ; ?> ' );" /> <div class="clear"></div> </div> </form> </div> <!-- / #container <?php do_action ( 'optionsframework_after' ) ; ?> </div> <!-- / .wrap <?php } | Builds out the options panel . |
36,132 | function validate_options ( $ input ) { if ( isset ( $ _POST [ 'reset' ] ) ) { add_settings_error ( 'options-framework' , 'restore_defaults' , __ ( 'Default options restored.' , 'options-framework' ) , 'updated fade' ) ; return $ this -> get_default_values ( ) ; } $ clean = array ( ) ; $ options = & Options_Framework :: _optionsframework_options ( ) ; foreach ( $ options as $ option ) { if ( ! isset ( $ option [ 'id' ] ) ) { continue ; } if ( ! isset ( $ option [ 'type' ] ) ) { continue ; } $ id = preg_replace ( '/[^a-zA-Z0-9._\-]/' , '' , strtolower ( $ option [ 'id' ] ) ) ; if ( 'checkbox' == $ option [ 'type' ] && ! isset ( $ input [ $ id ] ) ) { $ input [ $ id ] = false ; } if ( 'multicheck' == $ option [ 'type' ] && ! isset ( $ input [ $ id ] ) ) { foreach ( $ option [ 'options' ] as $ key => $ value ) { $ input [ $ id ] [ $ key ] = false ; } } if ( has_filter ( 'of_sanitize_' . $ option [ 'type' ] ) ) { $ clean [ $ id ] = apply_filters ( 'of_sanitize_' . $ option [ 'type' ] , $ input [ $ id ] , $ option ) ; } } do_action ( 'optionsframework_after_validate' , $ clean ) ; return $ clean ; } | Validate Options . |
36,133 | function get_default_values ( ) { $ output = array ( ) ; $ config = & Options_Framework :: _optionsframework_options ( ) ; foreach ( ( array ) $ config as $ option ) { if ( ! isset ( $ option [ 'id' ] ) ) { continue ; } if ( ! isset ( $ option [ 'std' ] ) ) { continue ; } if ( ! isset ( $ option [ 'type' ] ) ) { continue ; } if ( has_filter ( 'of_sanitize_' . $ option [ 'type' ] ) ) { $ output [ $ option [ 'id' ] ] = apply_filters ( 'of_sanitize_' . $ option [ 'type' ] , $ option [ 'std' ] , $ option ) ; } } return $ output ; } | Get the default values for all the theme options |
36,134 | function optionsframework_admin_bar ( ) { $ menu = $ this -> menu_settings ( ) ; global $ wp_admin_bar ; if ( 'menu' == $ menu [ 'mode' ] ) { $ href = admin_url ( 'admin.php?page=' . $ menu [ 'menu_slug' ] ) ; } else { $ href = admin_url ( 'themes.php?page=' . $ menu [ 'menu_slug' ] ) ; } $ args = array ( 'parent' => 'appearance' , 'id' => 'of_theme_options' , 'title' => $ menu [ 'menu_title' ] , 'href' => $ href ) ; $ wp_admin_bar -> add_menu ( apply_filters ( 'optionsframework_admin_bar' , $ args ) ) ; } | Add options menu item to admin bar |
36,135 | private function getSelectFromParent ( & $ klassInfo ) { foreach ( $ klassInfo [ 'related_klass_infos' ] as & $ relatedKlassInfo ) { if ( $ relatedKlassInfo [ 'from_parent' ] ) { $ relatedKlassInfo [ 'select_fields' ] = array_merge ( $ klassInfo [ 'select_fields' ] , $ relatedKlassInfo [ 'select_fields' ] ) ; } $ this -> getSelectFromParent ( $ relatedKlassInfo ) ; } } | For each related klass if the klass extends the model whose info we get we need to add the models class to the select_fields of the related class . |
36,136 | public function preparedResults ( $ values ) { $ preparedValues = [ ] ; foreach ( $ this -> select as $ pos => $ selectColumn ) { $ col = $ selectColumn [ 0 ] ; $ field = $ col -> getOutputField ( ) ; $ val = ArrayHelper :: getValue ( $ values , $ pos ) ; try { $ val = Type :: getType ( $ field -> dbType ( $ this -> connection ) ) -> convertToPHPValue ( $ val , $ this -> connection -> getDatabasePlatform ( ) ) ; } catch ( DBALException $ exception ) { } $ converters = $ field -> getDbConverters ( $ this -> connection ) ; if ( $ converters ) { foreach ( $ converters as $ converter ) { $ val = call_user_func ( $ converter , $ this -> connection , $ val , $ field ) ; } } $ preparedValues [ ] = $ val ; } return $ preparedValues ; } | Ensure results are converted back to there respective php types . |
36,137 | private function resolveOrderName ( $ col , Meta $ meta , $ alias = null , $ defaultOrder = 'ASC' , & $ alreadyResolved = [ ] ) { list ( $ col , $ order ) = Query :: getOrderDirection ( $ col , $ defaultOrder ) ; $ nameParts = explode ( BaseLookup :: LOOKUP_SEPARATOR , $ col ) ; list ( $ relationField , $ targetFields , $ alias , $ joinList , $ paths , $ meta ) = $ this -> _setupJoins ( $ nameParts , $ meta , $ alias ) ; if ( $ relationField -> isRelation && $ meta -> getOrderBy ( ) && empty ( $ relationField -> getAttrName ( ) ) ) { throw new NotImplemented ( 'This capability is yet to be implemented' ) ; } list ( $ targets , $ alias , $ joinList ) = $ this -> query -> trimJoins ( $ targetFields , $ joinList , $ paths ) ; $ fields = [ ] ; $ descending = ( 'DESC' == $ order ) ? true : false ; foreach ( $ targets as $ target ) { $ fields [ ] = [ new OrderBy ( $ target -> getColExpression ( $ alias ) , $ descending ) , false , ] ; } return $ fields ; } | Tries ot resolve a name like username into a model field and then into Col expression suitable for making queries . |
36,138 | private function _setupJoins ( $ nameParts , Meta $ meta , $ rootAlias = null ) { if ( is_null ( $ rootAlias ) ) { $ rootAlias = $ this -> query -> getInitialAlias ( ) ; } list ( $ field , $ targets , $ joinList , $ paths , $ meta ) = $ this -> query -> setupJoins ( $ nameParts , $ meta , $ rootAlias ) ; $ alias = end ( $ joinList ) ; return [ $ field , $ targets , $ alias , $ joinList , $ paths , $ meta ] ; } | A helper method for get_order_by and get_distinct . |
36,139 | public static function getClassNameFromFile ( $ file , $ classesDir ) { $ className = substr ( $ file , strlen ( $ classesDir ) ) ; $ className = preg_replace ( "/^\//" , '' , $ className ) ; $ className = preg_replace ( "/\//" , '\\' , $ className ) ; $ className = preg_replace ( '/.php$/' , '' , $ className ) ; return $ className ; } | Gets the class name of a class defined in a file . |
36,140 | public static function getNameFromNs ( $ className , $ namespace ) { $ className = static :: getFormatNamespace ( $ className , true , true ) ; $ namespace = static :: getFormatNamespace ( $ namespace , true , true ) ; if ( StringHelper :: startsWith ( $ className , $ namespace ) ) { $ className = substr ( $ className , strlen ( $ namespace ) ) ; } return trim ( $ className , '\\' ) ; } | Gets a class name from the namespace by trimming out the namespace from the classname . |
36,141 | public static function getFormatNamespace ( $ namespace , $ leadingBackslash = false , $ closingBackslash = true ) { $ namespace = trim ( $ namespace , '\\' ) ; if ( $ closingBackslash ) { $ namespace = sprintf ( '%s\\' , $ namespace ) ; } if ( $ leadingBackslash ) { $ namespace = sprintf ( '\\%s' , $ namespace ) ; } return $ namespace ; } | Format a namespace to have a leading or a closing backslash or both . |
36,142 | public static function classExists ( $ className , $ namespace ) { if ( class_exists ( $ className ) ) { return $ className ; } $ className = sprintf ( '%s%s' , static :: getFormatNamespace ( $ namespace , true ) , $ className ) ; if ( class_exists ( $ className ) ) { return $ className ; } return false ; } | checks of a class exists on the global scope try the namespace . |
36,143 | public static function getParents ( $ instance , $ stopAt = [ ] ) { $ reflectionClass = new \ ReflectionObject ( $ instance ) ; $ parents = [ ] ; while ( $ reflectionClass -> getParentClass ( ) ) { $ reflectionClass = $ reflectionClass -> getParentClass ( ) ; if ( in_array ( $ reflectionClass -> getName ( ) , $ stopAt ) ) { break ; } $ parents [ $ reflectionClass -> getName ( ) ] = $ reflectionClass ; } return $ parents ; } | Returns all the parents for the instance from the youngest to the oldest The resolution order to follow when going up a inheritance hierarchy . |
36,144 | public static function getClassFromFile ( $ path_to_file ) { $ contents = file_get_contents ( $ path_to_file ) ; $ namespace = $ class = '' ; $ getting_namespace = $ getting_class = false ; foreach ( token_get_all ( $ contents ) as $ token ) { if ( is_array ( $ token ) && T_NAMESPACE == $ token [ 0 ] ) { $ getting_namespace = true ; } if ( is_array ( $ token ) && T_CLASS == $ token [ 0 ] ) { $ getting_class = true ; } if ( true === $ getting_namespace ) { if ( is_array ( $ token ) && in_array ( $ token [ 0 ] , [ T_STRING , T_NS_SEPARATOR ] ) ) { $ namespace .= $ token [ 1 ] ; } elseif ( ';' === $ token ) { $ getting_namespace = false ; } } if ( true === $ getting_class ) { if ( is_array ( $ token ) && T_STRING == $ token [ 0 ] ) { $ class = $ token [ 1 ] ; break ; } } } return $ namespace ? $ namespace . '\\' . $ class : $ class ; } | Gets the first class defined on a php file . |
36,145 | protected function registerGenerator ( ) { $ this -> app -> bindShared ( 'command.controller.make' , function ( $ app ) { $ path = $ app [ 'path' ] . '/controllers' ; $ generator = new ControllerGenerator ( $ app [ 'files' ] ) ; return new MakeControllerCommand ( $ generator , $ path ) ; } ) ; } | Register the controller generator command . |
36,146 | public function getStub ( $ type , $ name ) { if ( in_array ( $ name , $ this -> ignores ) ) { return ; } $ type = $ this -> getInputType ( $ type , $ name ) ; return Stub :: create ( '/form/' . $ type . '.stub' , [ 'name' => $ name , 'label' => ucwords ( str_replace ( '_' , ' ' , $ name ) ) , ] ) -> render ( ) ; } | Get stub template . |
36,147 | public function getInputType ( $ type , $ name ) { if ( in_array ( $ name , $ this -> specials ) ) { return $ name ; } if ( array_key_exists ( $ type , $ this -> types ) ) { return $ this -> types [ $ type ] ; } return in_array ( $ type , $ this -> inputs ) ? $ type : 'text' ; } | Get input type . |
36,148 | public function updateAttributes ( & $ attributes ) { if ( $ validator = $ this -> getValidator ( ) ) { if ( $ extra = $ validator -> getAttributesForField ( $ this -> owner ) ) { $ attributes = array_merge ( $ attributes , $ extra ) ; } } } | Updates the HTML attributes of the extended field . |
36,149 | public function getValidatorMessages ( ) { $ messages = [ ] ; foreach ( $ this -> owner -> getValidatorRules ( ) as $ rule ) { if ( $ rule -> hasMessage ( ) ) { $ messages [ $ rule -> getType ( ) ] = $ rule -> getMessage ( ) ; } } return $ messages ; } | Answers an array of the validator messages for the extended field . |
36,150 | protected function getValidator ( ) { if ( $ form = $ this -> owner -> getForm ( ) ) { if ( ( $ validator = $ form -> getValidator ( ) ) && $ validator instanceof Validator ) { return $ validator ; } } } | Answers the validator instance from the associated form . |
36,151 | public function locate ( $ file , $ first = true ) { $ paths = array ( ) ; foreach ( $ this -> locators as $ locator ) { if ( null !== ( $ found = $ locator -> locate ( $ file , $ first ) ) ) { if ( $ first ) { return $ found ; } $ paths = array_merge ( $ paths , $ found ) ; } } return $ first ? null : array_values ( array_unique ( $ paths ) ) ; } | Locates a file using the locators in the collection . |
36,152 | public function getHandler ( ) : ? Autowire { if ( empty ( $ this -> config [ 'handler' ] ) ) { return null ; } if ( $ this -> config [ 'handler' ] instanceof Autowire ) { return $ this -> config [ 'handler' ] ; } if ( class_exists ( $ this -> config [ 'handler' ] ) ) { return new Autowire ( $ this -> config [ 'handler' ] ) ; } $ handler = $ this -> config [ 'handlers' ] [ $ this -> config [ 'handler' ] ] ; return new Autowire ( $ handler [ 'class' ] , $ handler [ 'options' ] ) ; } | Get handler autowire options . |
36,153 | public function getView ( $ view ) { if ( Template :: exists ( 'Form/' . $ view ) ) { return Template :: getAdminTemplate ( 'Form/' . $ view ) ; } return new View ( $ view , B8_PATH . 'Form/View/' ) ; } | Get the correct view for the form |
36,154 | protected function getPath ( $ connection ) { if ( $ this -> option ( 'path' ) ) return $ this -> option ( 'path' ) ; if ( is_null ( $ connection ) ) { return base_path ( ) . '/app/storage/logs/flyphp.log' ; } else { return $ this -> getRoot ( $ connection ) . '/app/storage/logs/flyphp.log' ; } } | Get the path to the Laraevl log file . |
36,155 | public function getUser ( ) : ? User { $ key = $ this -> getUserId ( ) ; if ( empty ( $ key ) ) { return null ; } return User :: Store ( ) -> getById ( $ key ) ; } | Get the User model for this by Id . |
36,156 | protected function parseLocale ( $ locale ) { if ( ! is_null ( $ locale ) ) { return array_filter ( array ( $ locale , $ this -> fallback ) ) ; } else { return array_filter ( array ( $ this -> locale , $ this -> fallback ) ) ; } } | Get the array of locales to be checked . |
36,157 | public function sendServiceCheck ( string $ host , string $ service , int $ returncode , string $ message = null ) : bool { if ( '' === $ service || "\0" === $ service ) { throw new \ InvalidArgumentException ( 'service can not be empty' ) ; } return $ this -> send ( $ host , $ service , $ returncode , $ message ) ; } | Sends passive service check |
36,158 | public function sendHostCheck ( string $ host , int $ returncode , string $ message = null ) : bool { return $ this -> send ( $ host , '' , $ returncode , $ message ) ; } | Sends passive host check |
36,159 | protected function isReturncodeValid ( int $ code ) : bool { try { $ reflection = new \ ReflectionClass ( '\\' . __NAMESPACE__ . '\\interfaces\\NagiosCodes' ) ; return in_array ( $ code , $ reflection -> getConstants ( ) ) ; } catch ( \ ReflectionException $ exception ) { return false ; } } | Determines if given returncode is a valid code that nagios understands |
36,160 | public static function startsWith ( $ string , $ with , $ caseSensitive = true ) { if ( ! $ bytes = static :: byteLength ( $ with ) ) { return true ; } if ( $ caseSensitive ) { return 0 === strncmp ( $ string , $ with , $ bytes ) ; } else { return mb_strtolower ( mb_substr ( $ string , 0 , $ bytes , '8bit' ) , self :: getCharset ( ) ) === mb_strtolower ( $ with , self :: getCharset ( ) ) ; } } | Check if given string starts with specified substring . Binary and multibyte safe . |
36,161 | protected function sendResponse ( $ response ) { return $ this -> responsePreparer -> readyForResponses ( ) && ! $ this -> runningInConsole ( ) ? $ response : $ response -> send ( ) ; } | Send the repsonse back to the client . |
36,162 | protected function handlesException ( Closure $ handler , $ exception ) { $ reflection = new ReflectionFunction ( $ handler ) ; return $ reflection -> getNumberOfParameters ( ) == 0 || $ this -> hints ( $ reflection , $ exception ) ; } | Determine if the given handler handles this exception . |
36,163 | protected function hints ( ReflectionFunction $ reflection , $ exception ) { $ parameters = $ reflection -> getParameters ( ) ; $ expected = $ parameters [ 0 ] ; return ! $ expected -> getClass ( ) || $ expected -> getClass ( ) -> isInstance ( $ exception ) ; } | Determine if the given handler type hints the exception . |
36,164 | protected function formatException ( \ Exception $ e ) { if ( $ this -> debug ) { $ location = $ e -> getMessage ( ) . ' in ' . $ e -> getFile ( ) . ':' . $ e -> getLine ( ) ; return 'Error in exception handler: ' . $ location ; } return 'Error in exception handler.' ; } | Format an exception thrown by a handler . |
36,165 | protected function registerRepository ( ) { $ this -> app -> singleton ( RepositoryContract :: class , function ( Container $ container ) { $ config = $ container -> make ( ConfigRepository :: class ) ; $ guard = $ container -> make ( Guard :: class ) ; $ cache = $ container -> make ( CacheFactory :: class ) -> store ( $ config -> get ( 'vi-kon.db-config.cache' ) ) ; return new Repository ( $ guard , $ cache ) ; } ) ; $ this -> app -> alias ( RepositoryContract :: class , 'config.db' ) ; } | Register config repository |
36,166 | public function fullClean ( $ exclude = [ ] ) { $ errors = [ ] ; try { $ this -> cleanFields ( $ exclude ) ; } catch ( ValidationError $ error ) { } try { $ this -> clean ( ) ; } catch ( ValidationError $ error ) { } if ( ! empty ( $ errors ) ) { throw new ValidationError ( $ errors ) ; } } | Calls cleanFields clean on the model and throws a ValidationError for any errors that occurred . |
36,167 | public function cleanFields ( $ exclude = [ ] ) { $ errors = [ ] ; foreach ( $ this -> getMeta ( ) -> getConcreteFields ( ) as $ field ) { if ( in_array ( $ field -> getName ( ) , $ exclude ) ) { continue ; } $ value = $ this -> { $ field -> getAttrName ( ) } ; if ( $ field -> formBlank && empty ( $ value ) ) { continue ; } try { $ this -> { $ field -> getAttrName ( ) } = $ field -> clean ( $ this , $ value ) ; } catch ( ValidationError $ error ) { $ errors [ $ field -> getName ( ) ] = $ error -> getErrorList ( ) ; } } if ( ! empty ( $ errors ) ) { throw new ValidationError ( $ errors ) ; } } | Cleans all fields and throw a ValidationError containing an associtive array of all validation errors if any occur . |
36,168 | protected function resolvePredicate ( ? PredicateInterface $ predicate , string $ fallback ) : PredicateInterface { $ is_a_predicate = function ( string $ class_name ) : bool { if ( ! class_exists ( $ class_name ) ) return false ; $ reflector = new \ ReflectionClass ( $ class_name ) ; return $ reflector -> implementsInterface ( PredicateInterface :: class ) ; } ; if ( ! is_null ( $ predicate ) && $ is_a_predicate ( get_class ( $ predicate ) ) ) { return $ predicate ; } else { $ predicate_class = get_class ( $ this ) . "Predicate" ; if ( $ is_a_predicate ( $ predicate_class ) ) { return new $ predicate_class ; } else if ( $ is_a_predicate ( $ fallback ) ) { return new $ fallback ; } else { return new Predicate ( ) ; } } } | Resolves the predicate of this class . |
36,169 | public function observeTailDestruction ( ) : void { if ( $ this -> predicate ( ) -> binding ( ) ) { $ this -> head ( ) -> destroy ( ) ; } $ this -> destroy ( ) ; } | Tail Nodes use this method to update about deletion |
36,170 | public function setGlobPatternFromFile ( $ file ) { if ( ! is_file ( $ file ) ) { $ message = "Glob pattern file {$file} doesn't exist." ; throw new NonExistentGlobPatternFile ( $ message ) ; } $ globPatternContent = ( string ) file_get_contents ( $ file ) ; $ globPatternLines = preg_split ( '/\\r\\n|\\r|\\n/' , $ globPatternContent ) ; $ globPatterns = [ ] ; array_filter ( $ globPatternLines , function ( $ line ) use ( & $ globPatterns ) { if ( trim ( $ line ) !== '' ) { $ globPatterns [ ] = trim ( $ line ) ; } } ) ; $ globPattern = '{' . implode ( ',' , $ globPatterns ) . '}*' ; try { $ this -> setGlobPattern ( $ globPattern ) ; return $ this ; } catch ( InvalidGlobPattern $ e ) { $ message = "Glob pattern file '{$file}' is invalid." ; throw new InvalidGlobPatternFile ( $ message ) ; } } | Set the glob pattern file . |
36,171 | private function guardGlobPattern ( ) { $ invalidGlobPattern = false ; if ( substr ( $ this -> globPattern , 0 ) !== '{' && ( substr ( $ this -> globPattern , - 1 ) !== '}' && substr ( $ this -> globPattern , - 2 ) !== '}*' ) ) { $ invalidGlobPattern = true ; } $ bracesContent = trim ( substr ( $ this -> globPattern , 1 , - 1 ) ) ; if ( empty ( $ bracesContent ) ) { $ invalidGlobPattern = true ; } $ globPatterns = explode ( ',' , $ bracesContent ) ; if ( count ( $ globPatterns ) == 1 ) { $ invalidGlobPattern = true ; } if ( $ invalidGlobPattern === true ) { throw new InvalidGlobPattern ; } } | Guard the set glob pattern . |
36,172 | public function setDirectory ( $ directory = __DIR__ ) { if ( ! is_dir ( $ directory ) ) { $ message = "Directory {$directory} doesn't exist." ; throw new \ RuntimeException ( $ message ) ; } $ this -> directory = $ directory ; $ this -> gitattributesFile = $ directory . DIRECTORY_SEPARATOR . '.gitattributes' ; return $ this ; } | Set the directory to analyse . |
36,173 | public function getGitignoredPatterns ( ) { $ gitignoreFile = $ this -> getDirectory ( ) . DIRECTORY_SEPARATOR . '.gitignore' ; if ( ! file_exists ( $ gitignoreFile ) ) { return [ ] ; } $ gitignoreContent = ( string ) file_get_contents ( $ gitignoreFile ) ; $ eol = $ this -> detectEol ( $ gitignoreContent ) ; $ gitignoreLines = preg_split ( '/\\r\\n|\\r|\\n/' , $ gitignoreContent ) ; $ gitignoredPatterns = [ ] ; array_filter ( $ gitignoreLines , function ( $ line ) use ( & $ gitignoredPatterns ) { $ line = trim ( $ line ) ; if ( $ line !== '' && strpos ( $ line , '#' ) === false ) { if ( substr ( $ line , 0 , 1 ) === "/" ) { $ gitignoredPatterns [ ] = substr ( $ line , 1 ) ; } if ( substr ( $ line , - 1 , 1 ) === "/" ) { $ gitignoredPatterns [ ] = substr ( $ line , 0 , - 1 ) ; } $ gitignoredPatterns [ ] = $ line ; } } ) ; return $ gitignoredPatterns ; } | Return patterns in . gitignore file . |
36,174 | public function getExpectedGitattributesContent ( array $ postfixlessExportIgnores = [ ] ) { if ( $ postfixlessExportIgnores === [ ] ) { $ postfixlessExportIgnores = $ this -> collectExpectedExportIgnores ( ) ; } if ( ! $ this -> hasGitattributesFile ( ) && count ( $ postfixlessExportIgnores ) > 0 ) { $ postfixlessExportIgnores [ ] = '.gitattributes' ; } sort ( $ postfixlessExportIgnores , SORT_STRING | SORT_FLAG_CASE ) ; if ( count ( $ postfixlessExportIgnores ) > 0 ) { if ( $ this -> isAlignExportIgnoresEnabled ( ) || $ this -> isStrictAlignmentCamparisonEnabled ( ) ) { $ postfixlessExportIgnores = $ this -> getAlignedExportIgnoreArtifacts ( $ postfixlessExportIgnores ) ; } $ content = implode ( " export-ignore" . $ this -> preferredEol , $ postfixlessExportIgnores ) . " export-ignore" . $ this -> preferredEol ; if ( $ this -> hasGitattributesFile ( ) ) { $ exportIgnoreContent = rtrim ( $ content ) ; $ content = $ this -> getPresentNonExportIgnoresContent ( ) ; if ( strstr ( $ content , self :: EXPORT_IGNORES_PLACEMENT_PLACEHOLDER ) ) { $ content = str_replace ( self :: EXPORT_IGNORES_PLACEMENT_PLACEHOLDER , $ exportIgnoreContent , $ content ) ; } else { $ content = $ content . str_repeat ( $ this -> preferredEol , 2 ) . $ exportIgnoreContent ; } } else { $ content = "* text=auto eol=lf" . str_repeat ( $ this -> preferredEol , 2 ) . $ content ; } return $ content ; } return '' ; } | Return the expected . gitattributes content . |
36,175 | public function getPresentExportIgnoresToPreserve ( array $ globPatternMatchingExportIgnores ) { $ gitattributesContent = ( string ) file_get_contents ( $ this -> gitattributesFile ) ; if ( preg_match ( "/(\*\h*)(text\h*)(=\h*auto)/" , $ gitattributesContent ) ) { $ this -> hasTextAutoConfiguration = true ; } $ eol = $ this -> detectEol ( $ gitattributesContent ) ; $ gitattributesLines = preg_split ( '/\\r\\n|\\r|\\n/' , $ gitattributesContent ) ; $ basenamedGlobPatternMatchingExportIgnores = array_map ( 'basename' , $ globPatternMatchingExportIgnores ) ; $ exportIgnoresToPreserve = [ ] ; array_filter ( $ gitattributesLines , function ( $ line ) use ( & $ exportIgnoresToPreserve , & $ globPatternMatchingExportIgnores , & $ basenamedGlobPatternMatchingExportIgnores ) { if ( strstr ( $ line , 'export-ignore' ) && strpos ( $ line , '#' ) === false ) { list ( $ pattern , $ void ) = explode ( 'export-ignore' , $ line ) ; if ( substr ( $ pattern , 0 , 1 ) === '/' ) { $ pattern = substr ( $ pattern , 1 ) ; $ this -> hasPrecedingSlashesInExportIgnorePattern = true ; } $ patternMatches = $ this -> patternHasMatch ( $ pattern ) ; $ pattern = trim ( $ pattern ) ; if ( $ patternMatches && ! in_array ( $ pattern , $ globPatternMatchingExportIgnores ) && ! in_array ( $ pattern , $ basenamedGlobPatternMatchingExportIgnores ) ) { return $ exportIgnoresToPreserve [ ] = trim ( $ pattern ) ; } } } ) ; return $ exportIgnoresToPreserve ; } | Return export ignores in . gitattributes file to preserve . |
36,176 | public function collectExpectedExportIgnores ( ) { $ expectedExportIgnores = [ ] ; $ initialWorkingDirectory = ( string ) getcwd ( ) ; chdir ( $ this -> directory ) ; $ ignoredGlobMatches = array_merge ( $ this -> ignoredGlobMatches , $ this -> getGitignoredPatterns ( ) ) ; foreach ( glob ( $ this -> globPattern , GLOB_BRACE ) as $ filename ) { if ( ! in_array ( $ filename , $ ignoredGlobMatches ) ) { if ( is_dir ( $ filename ) ) { $ expectedExportIgnores [ ] = $ filename . '/' ; continue ; } $ expectedExportIgnores [ ] = $ filename ; } } chdir ( $ initialWorkingDirectory ) ; if ( $ this -> hasGitattributesFile ( ) ) { $ expectedExportIgnores = array_merge ( $ expectedExportIgnores , $ this -> getPresentExportIgnoresToPreserve ( $ expectedExportIgnores ) ) ; } sort ( $ expectedExportIgnores , SORT_STRING | SORT_FLAG_CASE ) ; if ( $ this -> isKeepLicenseEnabled ( ) ) { $ licenseLessExpectedExportIgnores = [ ] ; array_filter ( $ expectedExportIgnores , function ( $ exportIgnore ) use ( & $ licenseLessExpectedExportIgnores ) { if ( ! preg_match ( '/(License.*)/i' , $ exportIgnore ) ) { $ licenseLessExpectedExportIgnores [ ] = $ exportIgnore ; } } ) ; $ expectedExportIgnores = $ licenseLessExpectedExportIgnores ; } return array_unique ( $ expectedExportIgnores ) ; } | Collect the expected export - ignored files . |
36,177 | private function detectEol ( $ content ) { $ maxCount = 0 ; $ preferredEol = $ this -> preferredEol ; $ eols = [ "\n" , "\r" , "\n\r" , "\r\n" ] ; foreach ( $ eols as $ eol ) { if ( ( $ count = substr_count ( $ content , $ eol ) ) >= $ maxCount ) { $ maxCount = $ count ; $ preferredEol = $ eol ; } } $ this -> preferredEol = $ preferredEol ; return $ preferredEol ; } | Detect most frequently used end of line sequence . |
36,178 | private function patternHasMatch ( $ globPattern ) { if ( substr ( trim ( $ globPattern ) , 0 , 1 ) === '/' ) { $ globPattern = trim ( substr ( $ globPattern , 1 ) ) ; } elseif ( substr ( trim ( $ globPattern ) , - 1 ) === '/' ) { $ globPattern = trim ( substr ( $ globPattern , 0 , - 1 ) ) ; } else { $ globPattern = '{' . trim ( $ globPattern ) . '}*' ; } $ initialWorkingDirectory = ( string ) getcwd ( ) ; chdir ( $ this -> directory ) ; $ matches = glob ( $ globPattern , GLOB_BRACE ) ; chdir ( $ initialWorkingDirectory ) ; return is_array ( $ matches ) && count ( $ matches ) > 0 ; } | Check if a given pattern produces a match against the repository directory . |
36,179 | public static function getFieldClass ( $ type ) { $ config = b8 \ Config :: getInstance ( ) ; $ try = '\\' . $ config -> get ( 'site.namespace' ) . '\\Form\\Element\\' . $ type ; if ( class_exists ( $ try ) ) { return $ try ; } $ try = '\\Octo\\Form\\Element\\' . $ type ; if ( class_exists ( $ try ) ) { return $ try ; } $ try = '\\b8\\Form\\Element\\' . $ type ; if ( class_exists ( $ try ) ) { return $ try ; } return null ; } | Get the correct field class for the form |
36,180 | public function prepareLookup ( ) { $ value = $ this -> rhs ; if ( $ this -> rhsValueIsIterable ) { $ this -> rhs = array_map ( function ( $ value ) { return static :: getNomalizedValue ( $ value , $ this -> lhs ) ; } , $ this -> rhs ) ; if ( method_exists ( $ this -> lhs , 'getPathInfo' ) ) { $ path = $ this -> lhs -> getOutputField ( ) -> getPathInfo ( ) ; $ sources = end ( $ path ) [ 'targetFields' ] ; $ targetField = end ( $ sources ) ; $ this -> rhs = array_map ( function ( $ value ) use ( $ targetField ) { return $ targetField -> prepareValue ( $ value ) ; } , $ this -> rhs ) ; } } else { $ this -> rhs = static :: getNomalizedValue ( $ value , $ this -> lhs ) ; if ( method_exists ( $ this -> rhs , '_prepare' ) ) { return $ this -> rhs -> _prepare ( $ this -> lhs -> getOutputField ( ) ) ; } if ( $ this -> prepareRhs && method_exists ( $ this -> lhs -> getOutputField ( ) , 'prepareValue' ) ) { return $ this -> lhs -> getOutputField ( ) -> prepareValue ( $ this -> rhs ) ; } } return $ this -> rhs ; } | Preperes the rhs for use in the lookup . |
36,181 | public function prepareLookupForDb ( $ values , ConnectionInterface $ connection ) { $ preparedValues = [ ] ; if ( $ this -> rhsValueIsIterable ) { foreach ( $ values as $ value ) { $ preparedValues [ ] = $ this -> lhs -> getOutputField ( ) -> convertToDatabaseValue ( $ value , $ connection ) ; } } else { $ preparedValues [ ] = $ this -> lhs -> getOutputField ( ) -> convertToDatabaseValue ( $ values , $ connection ) ; } return $ preparedValues ; } | Prepare the rhs for use on database queries . |
36,182 | public function setExtension ( $ extension ) { $ pathinfo = pathinfo ( $ this -> pathname ) ; $ pathname = new Text ( $ pathinfo [ 'dirname' ] ) ; if ( ! empty ( $ pathinfo [ 'dirname' ] ) ) { $ pathname = $ pathname -> append ( '/' ) ; } $ this -> init ( $ pathname -> append ( $ pathinfo [ 'filename' ] ) -> append ( '.' ) -> append ( $ extension ) ) ; return $ this ; } | Changes the extension of this path |
36,183 | public function isAbsolute ( ) { if ( $ this -> isStream ( ) ) { return true ; } if ( realpath ( $ this -> pathname -> toString ( ) ) == $ this -> pathname -> toString ( ) ) { return true ; } if ( $ this -> pathname -> length ( ) == 0 || $ this -> pathname -> startsWith ( '.' ) ) { return false ; } if ( $ this -> pathname -> match ( '#^[a-zA-Z]:\\\\#' ) ) { return true ; } return $ this -> pathname -> startsWith ( '/' ) || $ this -> pathname -> startsWith ( '\\' ) ; } | Returns whether this path is an absolute path . |
36,184 | public function makeRelativeTo ( Path $ base ) { $ pathname = clone $ this -> pathname ; return new Path ( $ pathname -> replace ( $ base -> removeTrailingSeparator ( ) -> getPathname ( ) , '' ) ) ; } | Makes the path relative to another given path |
36,185 | public function matchingFirstSegments ( Path $ anotherPath ) { $ segments = $ anotherPath -> segments ( ) ; $ count = 0 ; foreach ( $ this -> segments as $ i => $ segment ) { if ( $ segment != $ segments [ $ i ] ) { break ; } $ count ++ ; } return $ count ; } | Returns a count of the number of segments which match in this path and the given path comparing in increasing segment number order . |
36,186 | public function removeFirstSegments ( $ count ) { $ segments = new ArrayObject ( ) ; for ( $ i = $ count ; $ i < $ this -> segmentCount ( ) ; $ i ++ ) { $ segments -> push ( $ this -> segments [ $ i ] ) ; } return new Path ( $ segments -> join ( '/' ) ) ; } | Returns a copy of this path with the given number of segments removed from the beginning . |
36,187 | public function segment ( $ index ) { if ( isset ( $ this -> segments [ $ index ] ) ) { return $ this -> segments [ $ index ] ; } return null ; } | Returns the specified segment of this path or null if the path does not have such a segment . |
36,188 | public function upToSegment ( $ count ) { $ segments = new ArrayObject ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ segments -> push ( $ this -> segments [ $ i ] ) ; } return new Path ( $ segments -> join ( '/' ) ) ; } | Returns a copy of this path truncated after the given number of segments . |
36,189 | public function equals ( $ anotherPath ) { $ anotherPath = $ anotherPath instanceof Path ? $ anotherPath : new Path ( $ anotherPath ) ; if ( $ this -> isStream ( ) ^ $ anotherPath -> isStream ( ) ) { return false ; } if ( $ this -> isStream ( ) && $ anotherPath -> isStream ( ) ) { return $ this -> toString ( ) === $ anotherPath -> toString ( ) ; } return realpath ( $ this -> pathname -> toString ( ) ) == realpath ( $ anotherPath -> toString ( ) ) ; } | Checks whether both paths point to the same location |
36,190 | function run ( ) { if ( ! $ this -> is_initialized ) $ this -> init ( ) ; if ( ! defined ( 'BORS_SITE' ) ) define ( 'BORS_SITE' , COMPOSER_ROOT ) ; $ view = NULL ; if ( $ this -> cfg ( 'view.preset' ) ) $ view = $ this -> cfg ( 'view.preset' ) ; if ( ! $ view && class_exists ( '\\Zend\\Diactoros\\ServerRequestFactory' ) ) { $ request = \ Zend \ Diactoros \ ServerRequestFactory :: fromGlobals ( ) ; $ view = $ this -> route_view ( $ request ) ; } if ( $ view ) { $ ret = $ view -> pre_show ( ) ; if ( $ ret ) return $ ret ; $ response = $ view -> response ( ) ; if ( $ response ) { $ app = new \ Slim \ App ; $ app -> respond ( $ response ) ; return ; } } return \ bors :: run ( ) ; } | Main routing process run |
36,191 | public function getAttributesForForm ( Form $ form ) { $ attributes = parent :: getAttributesForForm ( $ form ) ; $ attributes [ 'data-group-class' ] = $ this -> config ( ) -> group_class ; $ attributes [ 'data-error-wrapper-class' ] = $ this -> config ( ) -> error_wrapper_class ; $ attributes [ 'data-group-error-class' ] = $ this -> config ( ) -> group_error_class ; $ attributes [ 'data-field-error-class' ] = $ this -> config ( ) -> field_error_class ; $ attributes [ 'data-group-success-class' ] = $ this -> config ( ) -> group_success_class ; $ attributes [ 'data-field-success-class' ] = $ this -> config ( ) -> field_success_class ; $ attributes [ 'data-parsley-trigger' ] = $ this -> getTriggerOn ( ) ; return $ this -> flatten ( $ attributes ) ; } | Answers an array of the validator attributes for the given form . |
36,192 | public function getAttributesForField ( FormField $ field ) { $ attributes = parent :: getAttributesForField ( $ field ) ; if ( $ field instanceof CheckboxSetField ) { $ attributes [ $ this -> prefix ( 'multiple' ) ] = $ field -> getName ( ) ; } if ( $ rules = $ field -> getValidatorRules ( ) ) { foreach ( $ rules as $ rule ) { if ( $ rule -> isValid ( ) ) { $ attributes [ $ this -> prefix ( $ rule -> getAttribute ( ) ) ] [ ] = $ rule -> getValue ( ) ; if ( $ rule -> hasMessage ( ) ) { $ attributes [ $ this -> attr ( 'message' , $ rule -> getAttribute ( ) ) ] = $ rule -> getMessage ( ) ; } } foreach ( $ rule -> getAttributes ( ) as $ name => $ value ) { $ attributes [ $ this -> attr ( $ name ) ] [ ] = $ value ; } } } return $ this -> flatten ( $ attributes ) ; } | Answers an array of the validator attributes for the given form field . |
36,193 | public function setTriggerOn ( $ triggerOn ) { $ this -> triggerOn = is_array ( $ triggerOn ) ? implode ( ' ' , $ triggerOn ) : ( string ) $ triggerOn ; return $ this ; } | Defines the value of the triggerOn attribute . |
36,194 | public function setForm ( $ form ) { parent :: setForm ( $ form ) ; foreach ( $ this -> rules as $ fieldName => $ rules ) { if ( $ field = $ this -> getDataField ( $ fieldName ) ) { foreach ( $ rules as $ rule ) { $ rule -> setField ( $ field ) ; } } } $ this -> backend -> setFrontend ( $ this ) ; $ this -> backend -> doInit ( ) ; if ( $ classes = $ this -> getClassesForForm ( $ form ) ) { foreach ( $ classes as $ class ) { $ form -> addExtraClass ( $ class ) ; } } if ( $ attributes = $ this -> getAttributesForForm ( $ form ) ) { foreach ( $ attributes as $ key => $ value ) { $ form -> setAttribute ( $ key , $ value ) ; } } return $ this ; } | Associates the form and data field instances with the validator and rules . |
36,195 | public function setRule ( $ fieldName , Rule $ rule ) { $ this -> rules [ $ fieldName ] [ get_class ( $ rule ) ] = $ rule ; $ rule -> setValidator ( $ this ) ; return $ this ; } | Sets the given rule for the form field with the given name . |
36,196 | public function setRules ( $ fieldNameOrArray , $ rules = [ ] ) { if ( is_array ( $ fieldNameOrArray ) ) { foreach ( $ fieldNameOrArray as $ fieldName => $ rules ) { $ this -> setRules ( $ fieldName , $ rules ) ; } } else { foreach ( $ rules as $ rule ) { $ this -> setRule ( $ fieldNameOrArray , $ rule ) ; } } return $ this ; } | Sets the rules for the form field with the given name from the given array or the entire list of rules . |
36,197 | public function addRequiredField ( $ fieldName , $ message = null ) { return $ this -> setRule ( $ fieldName , RequiredRule :: create ( $ message ) ) ; } | Adds a required rule for the form field with the specified name . |
36,198 | public function fieldIsRequired ( $ fieldName ) { if ( $ rules = $ this -> getRulesForFieldName ( $ fieldName ) ) { foreach ( $ rules as $ rule ) { if ( $ rule instanceof RequiredRule ) { return true ; } } } return parent :: fieldIsRequired ( $ fieldName ) ; } | Answers true if the field with the given name is required . |
36,199 | public function php ( $ data ) { if ( ! $ this -> getServerSide ( ) ) { return true ; } $ valid = true ; foreach ( $ this -> getFormFields ( ) as $ field ) { $ valid = ( $ field -> validate ( $ this ) && $ valid ) ; } foreach ( $ this -> rules as $ fieldName => $ rules ) { if ( $ field = $ this -> getDataField ( $ fieldName ) ) { foreach ( $ rules as $ rule ) { if ( ! $ rule -> test ( $ data [ $ fieldName ] ) ) { $ this -> validationError ( $ fieldName , $ rule -> getMessage ( ) , 'validation' ) ; $ valid = false ; } } } } return $ valid ; } | Performs server - side validation of the submitted form data . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.