idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
46,100 | public function createItem ( $ itemRouteName , array $ itemOptions ) { if ( isset ( $ itemOptions [ 'item_class' ] ) ) { $ class = $ itemOptions [ 'item_class' ] ; } else { $ class = $ this -> getDefaultItemClass ( ) ; } if ( isset ( $ this -> itemClassAliases [ $ class ] ) ) { $ class = $ this -> itemClassAliases [ $ class ] ; } if ( ! $ this -> isValidMenuItemClass ( $ class ) ) { throw new NoMenuItemClassException ( sprintf ( 'Item class %s does not extend \C33s\MenuBundle\Item\MenuItem' , $ itemOptions [ 'item_class' ] ) ) ; } $ item = new $ class ( $ itemRouteName , $ itemOptions , $ this ) ; return $ item ; } | MenuItem factory method . |
46,101 | public function getBreadcrumbItems ( ) { $ item = $ this -> getBaseItem ( ) ; $ items = array ( ) ; while ( $ current = $ item -> getCurrentChild ( ) ) { $ items [ ] = $ current ; $ item = $ current ; } return $ items ; } | Get all items on the current item s path starting with the lowest . Useful for breadcrumb rendering . |
46,102 | protected function isValidMenuItemClass ( $ className ) { if ( ! isset ( $ this -> checkedClasses [ $ className ] ) ) { $ this -> checkedClasses [ $ className ] = $ this -> hasParentClass ( $ className , 'C33s\\MenuBundle\\Item\\MenuItem' ) ; } return $ this -> checkedClasses [ $ className ] ; } | Check if the given class is a valid MenuItem class . |
46,103 | protected function boot ( ) : void { foreach ( $ this -> extensionManager -> getExtensions ( ) as $ extension ) { if ( $ extension -> isActivated ( ) ) { $ extension -> boot ( ) ; } } $ this -> dispatch ( new RoutesWillBeLoaded ( $ this -> router ) ) ; $ this -> dispatch ( new RoutesHaveBeenLoaded ( $ this -> router ) ) ; try { $ response = $ this -> router -> getResponse ( ) ; $ response -> send ( ) ; } catch ( RouteNotFoundException $ exception ) { throw new HttpNotFoundException ( ) ; } catch ( ResourceNotFoundException $ exception ) { throw new HttpNotFoundException ( ) ; } catch ( MethodNotAllowedException $ exception ) { throw new HttpMethodNotAllowedException ( ) ; } } | boot all services |
46,104 | static function actioncmp ( PHP_ParserGenerator_Action $ ap1 , PHP_ParserGenerator_Action $ ap2 ) { $ rc = $ ap1 -> sp -> index - $ ap2 -> sp -> index ; if ( $ rc === 0 ) { $ rc = $ ap1 -> type - $ ap2 -> type ; } if ( $ rc === 0 ) { if ( $ ap1 -> type == self :: SHIFT ) { if ( $ ap1 -> x -> statenum != $ ap2 -> x -> statenum ) { throw new Exception ( 'Shift conflict: ' . $ ap1 -> sp -> name . ' shifts both to state ' . $ ap1 -> x -> statenum . ' (rule ' . $ ap1 -> x -> cfp -> rp -> lhs -> name . ' on line ' . $ ap1 -> x -> cfp -> rp -> ruleline . ') and to state ' . $ ap2 -> x -> statenum . ' (rule ' . $ ap2 -> x -> cfp -> rp -> lhs -> name . ' on line ' . $ ap2 -> x -> cfp -> rp -> ruleline . ')' ) ; } } if ( $ ap1 -> type != self :: REDUCE && $ ap1 -> type != self :: RD_RESOLVED && $ ap1 -> type != self :: CONFLICT ) { throw new Exception ( 'action has not been processed: ' . $ ap1 -> sp -> name . ' on line ' . $ ap1 -> x -> cfp -> rp -> ruleline . ', rule ' . $ ap1 -> x -> cfp -> rp -> lhs -> name ) ; } if ( $ ap2 -> type != self :: REDUCE && $ ap2 -> type != self :: RD_RESOLVED && $ ap2 -> type != self :: CONFLICT ) { throw new Exception ( 'action has not been processed: ' . $ ap2 -> sp -> name . ' on line ' . $ ap2 -> x -> cfp -> rp -> ruleline . ', rule ' . $ ap2 -> x -> cfp -> rp -> lhs -> name ) ; } $ rc = $ ap1 -> x -> index - $ ap2 -> x -> index ; } return $ rc ; } | Compare two actions |
46,105 | static function Action_add ( & $ app , $ type , PHP_ParserGenerator_Symbol $ sp , $ arg ) { $ new = new PHP_ParserGenerator_Action ; $ new -> next = $ app ; $ app = $ new ; $ new -> type = $ type ; $ new -> sp = $ sp ; $ new -> x = $ arg ; echo ' Adding ' ; $ new -> display ( ) ; } | create linked list of PHP_ParserGenerator_Actions |
46,106 | function PrintAction ( $ fp , $ indent ) { if ( ! $ fp ) { $ fp = STDOUT ; } $ result = 1 ; switch ( $ this -> type ) { case self :: SHIFT : fprintf ( $ fp , "%${indent}s shift %d" , $ this -> sp -> name , $ this -> x -> statenum ) ; break ; case self :: REDUCE : fprintf ( $ fp , "%${indent}s reduce %d" , $ this -> sp -> name , $ this -> x -> index ) ; break ; case self :: ACCEPT : fprintf ( $ fp , "%${indent}s accept" , $ this -> sp -> name ) ; break ; case self :: ERROR : fprintf ( $ fp , "%${indent}s error" , $ this -> sp -> name ) ; break ; case self :: CONFLICT : fprintf ( $ fp , "%${indent}s reduce %-3d ** Parsing conflict **" , $ this -> sp -> name , $ this -> x -> index ) ; break ; case self :: SH_RESOLVED : case self :: RD_RESOLVED : case self :: NOT_USED : $ result = 0 ; break ; } return $ result ; } | Print an action to the given file descriptor . Return FALSE if nothing was actually printed . |
46,107 | public static function removeElementFromArray ( $ elements , $ array ) { if ( is_array ( $ elements ) && is_array ( $ array ) ) { foreach ( $ elements as $ element ) { if ( in_array ( $ element , $ array ) ) { $ key = array_search ( $ element , $ array ) ; unset ( $ array [ $ key ] ) ; } } } return $ array ; } | For example remove admins from writers array |
46,108 | public function add ( $ entry , $ priority = self :: DEFAULT_PRIORITY ) { if ( isset ( $ this -> entryClass ) && ! ( $ entry instanceof $ this -> entryClass ) ) { throw new InvalidObjectClassException ( $ this -> entryClass , get_class ( $ entry ) ) ; } $ this -> entries [ ] = [ 'data' => $ entry , 'priority' => $ priority ] ; $ this -> sorted = false ; return $ this ; } | Add an entry to the list . |
46,109 | public function remove ( $ entry , $ priority = false ) { $ unsetAnything = false ; foreach ( $ this -> entries as $ i => $ entryData ) { if ( $ entry === $ entryData [ 'data' ] && ( $ priority === false || $ entryData [ 'priority' ] == $ priority ) ) { unset ( $ this -> entries [ $ i ] ) ; $ unsetAnything = true ; } } if ( $ unsetAnything ) { $ this -> sorted = false ; } return $ this ; } | Removes an entry from the list . |
46,110 | public function reprioritise ( $ entry , $ newPriority , $ oldPriority = false ) { $ changedAnything = false ; foreach ( $ this -> entries as $ i => & $ entryData ) { if ( $ entry === $ entryData [ 'data' ] && ( $ oldPriority === false || $ entryData [ 'priority' ] == $ oldPriority ) ) { $ entryData [ 'priority' ] = $ newPriority ; $ changedAnything = true ; } } if ( $ changedAnything ) { $ this -> sorted = false ; } return $ this ; } | change the priority for an entry . |
46,111 | public function toArray ( ) { if ( ! $ this -> sorted ) { $ this -> rewind ( ) ; } return array_map ( function ( $ entry ) { return $ entry [ 'data' ] ; } , $ this -> entries ) ; } | Returns all items ordered by priority . |
46,112 | public static function dotGet ( array $ array , $ key , $ default = null ) { if ( is_null ( $ key ) ) { return $ array ; } if ( isset ( $ array [ $ key ] ) ) { return $ array [ $ key ] ; } foreach ( explode ( '.' , $ key ) as $ segment ) { if ( ! is_array ( $ array ) || ! array_key_exists ( $ segment , $ array ) ) { return Std :: thunk ( $ default ) ; } $ array = $ array [ $ segment ] ; } return $ array ; } | Get the resulting value of an attempt to traverse a key path . |
46,113 | public static function dotSet ( array $ array , $ key , $ value ) { $ path = explode ( '.' , $ key ) ; $ total = count ( $ path ) ; $ current = & $ array ; for ( $ ii = 0 ; $ ii < $ total ; $ ii ++ ) { if ( $ ii === $ total - 1 ) { $ current [ $ path [ $ ii ] ] = $ value ; } else { if ( ! is_array ( $ current ) ) { throw new LackOfCoffeeException ( 'Part of the path is not an array.' ) ; } if ( ! array_key_exists ( $ path [ $ ii ] , $ current ) ) { $ current [ $ path [ $ ii ] ] = [ ] ; } $ current = & $ current [ $ path [ $ ii ] ] ; } } } | Set an array element using dot notation . |
46,114 | public static function walk ( array & $ array , callable $ callback , $ recurse = false , $ path = '' , $ considerLeaves = true ) { $ path = trim ( $ path , '.' ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) && $ recurse ) { if ( $ considerLeaves === false && ! static :: hasNested ( $ value ) ) { $ callback ( $ key , $ value , $ array , $ path ) ; continue ; } $ deeperPath = $ key ; if ( $ path !== '' ) { $ deeperPath = vsprintf ( '%s.%s' , [ $ path , $ key ] ) ; } static :: walk ( $ array [ $ key ] , $ callback , true , $ deeperPath , $ considerLeaves ) ; continue ; } $ callback ( $ key , $ value , $ array , $ path ) ; } return $ array ; } | A more complicated but flexible version of array_walk . |
46,115 | public static function filterNullValues ( $ properties , array $ allowed = null ) { $ properties = static :: only ( $ properties , $ allowed ) ; return array_filter ( $ properties , function ( $ value ) { return ! is_null ( $ value ) ; } ) ; } | Get array elements that are not null . |
46,116 | public static function filterKeys ( array $ input , $ included = [ ] ) { if ( is_null ( $ included ) || count ( $ included ) == 0 ) { return $ input ; } return array_intersect_key ( $ input , array_flip ( $ included ) ) ; } | Filter the keys of an array to only the allowed set . |
46,117 | public static function except ( array $ input , $ excluded = [ ] ) { Arguments :: define ( Boa :: arrOf ( Boa :: either ( Boa :: string ( ) , Boa :: integer ( ) ) ) ) -> check ( $ excluded ) ; return Std :: filter ( function ( $ _ , $ key ) use ( $ excluded ) { return ! in_array ( $ key , $ excluded ) ; } , $ input ) ; } | Get a copy of the provided array excluding the specified keys . |
46,118 | public static function exchange ( array & $ elements , $ indexA , $ indexB ) { $ count = count ( $ elements ) ; if ( ( $ indexA < 0 || $ indexA > ( $ count - 1 ) ) || $ indexB < 0 || $ indexB > ( $ count - 1 ) ) { throw new IndexOutOfBoundsException ( ) ; } $ temp = $ elements [ $ indexA ] ; $ elements [ $ indexA ] = $ elements [ $ indexB ] ; $ elements [ $ indexB ] = $ temp ; } | Exchange two elements in an array . |
46,119 | public static function indexOf ( array $ input , $ value ) { foreach ( $ input as $ key => $ inputValue ) { if ( $ inputValue === $ value ) { return $ key ; } } return false ; } | Returns the index of the first occurrence of a value in the provided array . |
46,120 | public function store ( $ name = null ) { if ( is_null ( $ name ) ) { $ name = $ this -> defaultStore ; } if ( isset ( $ this -> caches [ $ name ] ) ) { return $ this -> caches [ $ name ] ; } $ config = config ( 'cache.stores.' . $ name ) ; if ( $ config === null ) { throw new InvalidArgumentException ( 'Cache store "' . $ name . '" is not defined.' ) ; } if ( ! isset ( $ config [ 'driver' ] ) ) { throw new InvalidArgumentException ( 'Cache driver for store "' . $ name . '" is not specified.' ) ; } switch ( $ config [ 'driver' ] ) { case 'APCu' : $ provider = new ApcuCache ; break ; case 'Array' : $ provider = new ArrayCache ; break ; case 'File' : $ provider = new FilesystemCache ( $ config [ 'path' ] ) ; break ; case 'Memcached' : $ memcached = new Memcached ( ) ; $ memcached -> addServer ( $ config [ 'host' ] , $ config [ 'port' ] , $ config [ 'weight' ] ) ; $ provider = new MemcachedCache ( ) ; $ provider -> setMemcached ( $ memcached ) ; break ; case 'Redis' : $ redis = new Redis ; $ redis -> connect ( $ config [ 'host' ] , $ config [ 'port' ] , $ config [ 'timeout' ] ) ; $ provider = new RedisCache ; $ provider -> setRedis ( $ redis ) ; break ; default : throw new InvalidArgumentException ( 'Cache driver "' . $ config [ 'driver' ] . '" is not supported.' ) ; } return $ this -> caches [ $ name ] = new Cache ( $ provider ) ; } | Get a Cache instance by given store name . |
46,121 | protected function generatePathname ( $ id ) { if ( ! file_exists ( $ this -> basePath ) ) { mkdir ( $ this -> basePath , 0777 , true ) ; } return $ this -> basePath . '/' . $ id ; } | Generate a pathname for an ID |
46,122 | public function & SetGroupLabelCssClasses ( $ groupLabelCssClasses ) { if ( gettype ( $ groupLabelCssClasses ) == 'array' ) { $ this -> groupLabelCssClasses = $ groupLabelCssClasses ; } else { $ this -> groupLabelCssClasses = explode ( ' ' , ( string ) $ groupLabelCssClasses ) ; } return $ this ; } | Set css class or classes for group label as array of strings or string with classes separated by space . Any previously defined group css classes will be replaced . |
46,123 | public function AddGroupLabelCssClasses ( $ groupLabelCssClasses ) { if ( gettype ( $ groupLabelCssClasses ) == 'array' ) { $ groupCssClasses = $ groupLabelCssClasses ; } else { $ groupCssClasses = explode ( ' ' , ( string ) $ groupLabelCssClasses ) ; } $ this -> groupLabelCssClasses = array_merge ( $ this -> groupLabelCssClasses , $ groupCssClasses ) ; return $ this ; } | Add css class or classes for group label as array of strings or string with classes separated by space . |
46,124 | public function changeUserMode ( EventInterface $ event , EventQueueInterface $ queue ) { $ logger = $ this -> getLogger ( ) ; $ params = $ event -> getParams ( ) ; $ logger -> debug ( 'Changing user mode' , array ( 'params' => $ params ) ) ; if ( ! isset ( $ params [ 'channel' ] ) || ! isset ( $ params [ 'user' ] ) ) { $ logger -> debug ( 'Missing channel or user, skipping' ) ; return ; } $ connectionMask = $ this -> getConnectionMask ( $ event -> getConnection ( ) ) ; $ channel = $ params [ 'channel' ] ; $ nick = $ params [ 'user' ] ; $ modes = str_split ( $ params [ 'mode' ] ) ; $ operation = array_shift ( $ modes ) ; $ logger -> debug ( 'Extracted event data' , array ( 'connectionMask' => $ connectionMask , 'channel' => $ channel , 'nick' => $ nick , 'operation' => $ operation , 'modes' => $ modes , ) ) ; foreach ( $ modes as $ mode ) { switch ( $ operation ) { case '+' : if ( ! isset ( $ this -> modes [ $ connectionMask ] ) ) { $ this -> modes [ $ connectionMask ] = array ( ) ; } if ( ! isset ( $ this -> modes [ $ connectionMask ] [ $ channel ] ) ) { $ this -> modes [ $ connectionMask ] [ $ channel ] = array ( ) ; } if ( ! isset ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] ) ) { $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] = array ( ) ; } $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] [ $ mode ] = true ; break ; case '-' : unset ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] [ $ mode ] ) ; break ; default : $ logger -> warning ( 'Encountered unknown operation' , array ( 'operation' => $ operation , ) ) ; break ; } } } | Monitors use mode changes . |
46,125 | protected function removeUserData ( $ connectionMask , array $ channels , $ nick ) { $ logger = $ this -> getLogger ( ) ; foreach ( $ channels as $ channel ) { $ logger -> debug ( 'Removing user mode data' , array ( 'connectionMask' => $ connectionMask , 'channel' => $ channel , 'nick' => $ nick , ) ) ; unset ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] ) ; } } | Removes mode data for a user and list of channels . |
46,126 | public function changeUserNick ( UserEventInterface $ event , EventQueueInterface $ queue ) { $ logger = $ this -> getLogger ( ) ; $ connectionMask = $ this -> getConnectionMask ( $ event -> getConnection ( ) ) ; $ old = $ event -> getNick ( ) ; $ params = $ event -> getParams ( ) ; $ new = $ params [ 'nickname' ] ; $ logger -> debug ( 'Changing user nick' , array ( 'connectionMask' => $ connectionMask , 'oldNick' => $ old , 'newNick' => $ new , ) ) ; foreach ( array_keys ( $ this -> modes [ $ connectionMask ] ) as $ channel ) { if ( ! isset ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ old ] ) ) { continue ; } $ logger -> debug ( 'Moving user mode data' , array ( 'connectionMask' => $ connectionMask , 'channel' => $ channel , 'oldNick' => $ old , 'newNick' => $ new , ) ) ; $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ new ] = $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ old ] ; unset ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ old ] ) ; } } | Accounts for user nick changes in stored data . |
46,127 | public function loadUserModes ( EventInterface $ event , EventQueueInterface $ queue ) { $ logger = $ this -> getLogger ( ) ; $ connectionMask = $ this -> getConnectionMask ( $ event -> getConnection ( ) ) ; $ params = $ event -> getParams ( ) ; $ channel = $ params [ 1 ] ; $ validPrefixes = implode ( '' , array_keys ( $ this -> prefixes ) ) ; $ pattern = '/^([' . preg_quote ( $ validPrefixes ) . ']+)(.+)$/' ; $ logger -> debug ( 'Gathering initial user mode data' , array ( 'connectionMask' => $ connectionMask , 'channel' => $ channel , ) ) ; foreach ( $ params [ 'iterable' ] as $ fullNick ) { if ( ! preg_match ( $ pattern , $ fullNick , $ match ) ) { continue ; } $ nickPrefixes = str_split ( $ match [ 1 ] ) ; $ nick = $ match [ 2 ] ; foreach ( $ nickPrefixes as $ prefix ) { $ mode = $ this -> prefixes [ $ prefix ] ; $ logger -> debug ( 'Recording user mode' , array ( 'connectionMask' => $ connectionMask , 'channel' => $ channel , 'nick' => $ nick , 'mode' => $ mode , ) ) ; $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] [ $ mode ] = true ; } } } | Loads initial user mode data when the bot joins a channel . |
46,128 | public function userHasMode ( ConnectionInterface $ connection , $ channel , $ nick , $ mode ) { $ connectionMask = $ this -> getConnectionMask ( $ connection ) ; return isset ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] [ $ mode ] ) ; } | Returns whether a user has a particular mode in a particular channel . |
46,129 | public function getUserModes ( ConnectionInterface $ connection , $ channel , $ nick ) { $ connectionMask = $ this -> getConnectionMask ( $ connection ) ; if ( isset ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] ) ) { return array_keys ( $ this -> modes [ $ connectionMask ] [ $ channel ] [ $ nick ] ) ; } return array ( ) ; } | Returns a list of modes for a user in a particular channel . |
46,130 | protected function getConnectionMask ( ConnectionInterface $ connection ) { return strtolower ( sprintf ( '%s!%s@%s' , $ connection -> getNickname ( ) , $ connection -> getUsername ( ) , $ connection -> getServerHostname ( ) ) ) ; } | Returns the mask string for a given connection . |
46,131 | public function make ( string $ name , array $ params = null ) { if ( isset ( $ this -> bindings [ $ name ] ) ) return $ this -> bindings [ $ name ] ; static $ constructors = null ; if ( isset ( $ constructors [ $ name ] ) ) { $ constructor = $ constructors [ $ name ] ; } else { $ constructors [ $ name ] = $ constructor = method_exists ( $ name , '__construct' ) ? new \ ReflectionMethod ( $ name , '__construct' ) : null ; } return $ constructor ? ( new \ ReflectionClass ( $ name ) ) -> newInstanceArgs ( $ this -> _buildArgList ( $ constructor , $ params ) ) : ( new \ ReflectionClass ( $ name ) ) -> newInstance ( ) ; } | Build an object by its name . |
46,132 | public static function base ( ) { self :: write ( 'application.encoding' , 'UTF8' ) ; self :: write ( 'application.env' , 'dev' ) ; self :: write ( 'application.name' , 'Awesome Application' ) ; self :: write ( 'application.namespace' , '\App' ) ; self :: write ( 'application.path' , 'auto' ) ; self :: write ( 'bootstrap.enable' , true ) ; self :: write ( 'database.config.enable' , true ) ; self :: write ( 'database.config.file' , 'databases.php' ) ; self :: write ( 'debug.level' , E_ALL ) ; self :: write ( 'html.script.test_file_existance' , true ) ; self :: write ( 'html.css.test_file_existance' , true ) ; self :: write ( 'mvc.autoload_shared_var' , true ) ; self :: write ( 'mvc.controller.namespace' , '\App\Controller' ) ; self :: write ( 'mvc.layout.namespace' , '\App\Layout' ) ; self :: write ( 'mvc.layout.path' , '/src/Layout' ) ; self :: write ( 'mvc.layout.default' , 'Application' ) ; self :: write ( 'mvc.layout.extension' , 'php' ) ; self :: write ( 'mvc.layout.auto_render' , true ) ; self :: write ( 'mvc.model.namespace' , '\App\Model' ) ; self :: write ( 'mvc.view.auto_render' , true ) ; self :: write ( 'mvc.view.extension' , 'php' ) ; self :: write ( 'mvc.view.path' , '/src/View' ) ; self :: write ( 'routing.auto' , true ) ; self :: write ( 'routing.config.enable' , true ) ; self :: write ( 'routing.config.file' , 'routes.php' ) ; self :: write ( 'routing.fallback.action' , 'index' ) ; self :: write ( 'routing.fallback.controller' , 'Error' ) ; self :: write ( 'routing.default_separator' , '/' ) ; } | Get base configuration of Pabana |
46,133 | public static function prepare ( $ key , $ value ) { if ( $ value == 'true' ) { return true ; } elseif ( $ value == 'false' ) { return false ; } elseif ( $ key == 'debug.level' && substr ( $ value , 0 , 2 ) == "E_" ) { return eval ( 'return ' . $ value . ';' ) ; } elseif ( $ key == 'application.path' && ( $ value === false || $ value === 'false' || $ value === 'auto' ) ) { $ sLibraryPath = DS . 'vendor' . DS . 'pabana' . DS . 'pabana' . DS . 'src' . DS . 'Core' ; return str_replace ( $ sLibraryPath , '' , __DIR__ ) ; } return $ value ; } | Prepare a configuration value |
46,134 | public static function prepareArray ( $ configList ) { $ preparedConfigList = array ( ) ; foreach ( $ configList as $ key => $ value ) { $ preparedConfigList [ $ key ] = self :: prepare ( $ key , $ value ) ; } return $ preparedConfigList ; } | Prepare a configuration array |
46,135 | public static function read ( $ key ) { if ( ! self :: check ( $ key ) ) { throw new \ Exception ( 'Configuration key "' . $ key . '" doesn\'t exists' ) ; return false ; } return self :: $ configList [ $ key ] ; } | Read a configuration key |
46,136 | public static function write ( $ key , $ value , $ force = true ) { if ( self :: check ( $ key ) && $ force === false ) { throw new \ Exception ( 'Configuration key "' . $ key . '" already exist (use force argument to modify an already defined key).' ) ; return false ; } $ preparedValue = self :: prepare ( $ key , $ value ) ; self :: $ configList [ $ key ] = $ preparedValue ; return true ; } | Write a configuration key |
46,137 | public function generate ( MediaProviderInterface $ mediaProvider ) { $ path = rtrim ( $ this -> basePath , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . $ mediaProvider -> getMedia ( ) -> getContext ( ) . DIRECTORY_SEPARATOR . date ( 'Y' ) . DIRECTORY_SEPARATOR . date ( 'm' ) . DIRECTORY_SEPARATOR . date ( 'd' ) ; if ( ! is_dir ( $ path ) ) { mkdir ( $ path , 0777 , true ) ; } return $ path ; } | Generate path for Media |
46,138 | public function generate ( string $ content = null ) : string { if ( empty ( $ content ) ) { $ guid = Uuid :: uuid4 ( ) ; } else { $ guid = Uuid :: uuid5 ( Uuid :: NAMESPACE_DNS , $ content ) ; } return $ guid -> toString ( ) ; } | Generates a GUID optionally from specified Content . |
46,139 | public static function html ( ) { $ fargs = func_get_args ( ) ; $ mode = self :: enabled ( ) ; self :: enabled ( self :: MODE_RICH ) ; $ ret = self :: dump ( empty ( $ fargs ) ? null : $ fargs [ 0 ] ) ; self :: enabled ( $ mode ) ; return $ ret ; } | Dumps in HTML mode |
46,140 | public function addFormField ( $ type , $ params = array ( ) ) { $ namespace = "\\iJos\\iForms\\Fields\\" . ucfirst ( $ type ) ; $ field = new $ namespace ( $ params ) ; array_push ( $ this -> form_fields , $ field ) ; } | Add a Field to the curent form |
46,141 | public function normalizeFormFieldTagParams ( $ name , $ value , array $ attributes , $ fieldType = null ) { if ( ! isset ( $ attributes [ 'id' ] ) ) { $ attributes [ 'id' ] = trim ( str_replace ( [ '[' , ']' , '()' , '__' ] , [ '_' , '_' , '' , '_' ] , $ name ) , '_' ) ; } if ( $ name ) { $ attributes [ 'name' ] = $ name ; } return [ $ name , ( string ) $ value , $ attributes ] ; } | This method can be extended to edit attributes for form - related tags . |
46,142 | public function normalizeFormTagOptions ( $ urlOptions , $ options , $ block ) { if ( ! $ urlOptions || ! $ options || ! $ block ) { if ( $ urlOptions instanceof Closure ) { $ block = $ urlOptions ; $ urlOptions = null ; $ options = [ ] ; } elseif ( is_array ( $ urlOptions ) && is_string ( key ( $ urlOptions ) ) ) { $ block = $ options ; $ options = $ urlOptions ; $ urlOptions = null ; } elseif ( $ options instanceof Closure ) { $ block = $ options ; $ options = [ ] ; } } if ( ! $ block instanceof Closure ) { throw new Exception \ BadMethodCallException ( "One of the arguments for formTag must be a Closure" ) ; } if ( empty ( $ options [ 'method' ] ) ) { $ options [ 'method' ] = 'post' ; } if ( ! empty ( $ options [ 'multipart' ] ) ) { $ options [ 'enctype' ] = 'multipart/form-data' ; unset ( $ options [ 'multipart' ] ) ; } if ( $ urlOptions ) { if ( ! $ this -> isUrl ( $ urlOptions ) ) { $ options [ 'action' ] = $ this -> urlFor ( $ urlOptions ) ; } else { $ options [ 'action' ] = $ urlOptions ; } } return [ $ urlOptions , $ options , $ block ] ; } | This method may be extended to customize form options such as HTML attributes . |
46,143 | protected function runContentBlock ( Closure $ block ) { ob_start ( ) ; $ result = $ block ( ) ; $ contents = ob_get_clean ( ) ; return $ result ? : $ contents ; } | Runs a Closure that can either output content itself or return the content as a string . |
46,144 | protected function normalizeSizeOption ( array & $ options ) { if ( isset ( $ options [ 'size' ] ) ) { $ size = explode ( 'x' , $ options [ 'size' ] ) ; if ( isset ( $ size [ 0 ] ) && isset ( $ size [ 1 ] ) ) { list ( $ options [ 'cols' ] , $ options [ 'rows' ] ) = $ size ; } unset ( $ options [ 'size' ] ) ; } } | Checks for the size option which is expected to be something like 50x20 and is splitted into cols and rows . |
46,145 | public function & createScript ( $ content , $ defer = true , $ combine = true , $ minify = true ) : JavascriptObjectInterface { $ obj = new JavascriptObject ( ) ; $ obj -> setType ( $ obj :: TYPE_SCRIPT ) ; $ obj -> setContent ( $ content ) ; $ obj -> setDefer ( $ defer ) ; $ obj -> setCombine ( $ combine ) ; $ obj -> setMinify ( $ minify ) ; $ this -> addObject ( $ obj ) ; return $ obj ; } | Adds an script javascript object to the output queue |
46,146 | public function & createBlock ( $ content , $ defer = true , $ combine = true , $ minify = true ) : JavascriptObjectInterface { $ obj = new JavascriptObject ( ) ; $ obj -> setType ( $ obj :: TYPE_BLOCK ) ; $ obj -> setContent ( $ content ) ; $ obj -> setDefer ( $ defer ) ; $ obj -> setCombine ( $ combine ) ; $ obj -> setMinify ( $ minify ) ; $ this -> addObject ( $ obj ) ; return $ obj ; } | Blocks with complete code |
46,147 | public function matchUrl ( $ pattern ) { if ( $ this -> matchValue ( $ this -> getUrl ( ) , $ pattern ) ) { return $ this -> getUrl ( ) ; } return false ; } | Check if the url matches the given pattern . |
46,148 | public function matchHeader ( $ name , $ pattern = null ) { if ( isset ( $ this -> getHeaders ( ) [ $ name ] ) ) { if ( ! empty ( $ pattern ) ) { if ( $ this -> matchValue ( $ this -> getHeaders ( ) [ $ name ] , $ pattern ) ) { return $ this -> getHeaders ( ) [ $ name ] ; } } else { if ( empty ( $ this -> getHeaders ( ) [ $ name ] ) ) { return true ; } else { return $ this -> getHeaders ( ) [ $ name ] ; } } } elseif ( $ pattern == '?' ) { return true ; } return false ; } | Check if the given header exists and optionally if the pattern matches the header value . |
46,149 | public function matchCookie ( $ name , $ pattern = null ) { if ( isset ( $ this -> getCookies ( ) [ $ name ] ) ) { if ( ! empty ( $ pattern ) ) { if ( $ this -> matchValue ( $ this -> getCookies ( ) [ $ name ] , $ pattern ) ) { return $ this -> getCookies ( ) [ $ name ] ; } } else { if ( empty ( $ this -> getCookies ( ) [ $ name ] ) ) { return true ; } else { return $ this -> getCookies ( ) [ $ name ] ; } } } elseif ( $ pattern == '?' ) { return true ; } return false ; } | Check if the given cookie exists and optionally if the pattern matches the cookie value . |
46,150 | public function matchQueryParam ( $ name , $ pattern = null ) { if ( isset ( $ this -> getQueryParams ( ) [ $ name ] ) ) { if ( ! empty ( $ pattern ) ) { if ( $ this -> matchValue ( $ this -> getQueryParams ( ) [ $ name ] , $ pattern ) ) { return $ this -> getQueryParams ( ) [ $ name ] ; } } else { if ( empty ( $ this -> getQueryParams ( ) [ $ name ] ) ) { return true ; } else { return $ this -> getQueryParams ( ) [ $ name ] ; } } } elseif ( $ pattern == '?' ) { return true ; } return false ; } | Check if the given query param exists and optionally if the pattern matches the query param value . |
46,151 | private function matchValue ( $ value , $ pattern ) { if ( $ value == $ pattern ) { return true ; } if ( $ pattern == '?' ) { return true ; } if ( $ pattern == '*' && $ value != '' ) { return true ; } $ pattern = str_replace ( '*' , '(.+)' , $ pattern ) ; if ( strpos ( $ pattern , '(' ) !== false || strpos ( $ pattern , '[' ) !== false || strpos ( $ pattern , '\\' ) !== false ) { return preg_match ( '#^' . $ pattern . '$#' , $ value ) ; } return false ; } | Method that tries to match the given pattern to the given value . |
46,152 | protected static function strlen ( $ text ) { $ exits = ( function_exists ( 'mb_strlen' ) && ( ( int ) ini_get ( 'mbstring.func_overload' ) ) & 2 ) ; return $ exits ? mb_strlen ( $ text , '8bit' ) : strlen ( $ text ) ; } | Calculates the length from given string |
46,153 | protected static function normalizeEncoding ( $ encodingLabel ) { $ encoding = strtoupper ( $ encodingLabel ) ; $ encoding = preg_replace ( '/[^a-zA-Z0-9\s]/' , '' , $ encoding ) ; $ equivalences = [ 'ISO88591' => 'ISO-8859-1' , 'ISO8859' => 'ISO-8859-1' , 'ISO' => 'ISO-8859-1' , 'LATIN1' => 'ISO-8859-1' , 'LATIN' => 'ISO-8859-1' , 'UTF8' => 'UTF-8' , 'UTF' => 'UTF-8' , 'WIN1252' => 'ISO-8859-1' , 'WINDOWS1252' => 'ISO-8859-1' ] ; if ( empty ( $ equivalences [ $ encoding ] ) ) { return 'UTF-8' ; } return $ equivalences [ $ encoding ] ; } | Returns normalized encoding name from common aliases |
46,154 | public static function to ( $ encodingLabel , $ text ) { $ encodingLabel = static :: normalizeEncoding ( $ encodingLabel ) ; if ( $ encodingLabel == 'ISO-8859-1' ) { return static :: toLatin1 ( $ text ) ; } return static :: toUTF8 ( $ text ) ; } | Encode to supported encoding types aliases ISO88591 ISO8859 ISO LATIN1 LATIN UTF8 UTF WIN1252 WINDOWS1252 |
46,155 | protected static function utf8Decode ( $ text , $ option ) { if ( $ option == self :: WITHOUT_ICONV || ! function_exists ( 'iconv' ) ) { $ decoded = utf8_decode ( str_replace ( array_keys ( static :: $ utf8ToWin1252 ) , array_values ( static :: $ utf8ToWin1252 ) , static :: toUTF8 ( $ text ) ) ) ; } else { $ decoded = iconv ( "UTF-8" , "Windows-1252" . ( $ option == self :: ICONV_TRANSLIT ? '//TRANSLIT' : ( $ option == self :: ICONV_IGNORE ? '//IGNORE' : '' ) ) , $ text ) ; } return $ decoded ; } | Converts a string with ISO - 8859 - 1 characters encoded with UTF - 8 to single - byte Windows - 1252 |
46,156 | public function allFor ( $ name ) { $ result = array ( ) ; foreach ( $ this -> _envSettings as $ env => $ settings ) { $ result [ $ env ] = $ settings [ $ name ] ; } return $ result ; } | Get the values of the given setting for each environment |
46,157 | public function getError ( $ attribute ) { $ result = null ; if ( $ this -> isErrorExists ( $ attribute ) ) { $ result = $ this -> errors [ $ attribute ] ; } return $ result ; } | Get error by attribute name |
46,158 | protected function html ( $ newLine , $ condition = true ) { if ( $ condition ) { $ this -> lines [ ] = ltrim ( $ newLine ) ; } return $ this ; } | Cumulate HTML code in order to restitute it |
46,159 | public function getPageUrl ( Page $ page ) { return $ this -> config [ 'base_url' ] . '/' . ( $ page -> getSubFolder ( ) === null ? '' : $ page -> getSubFolder ( ) . '/' ) . $ this -> getPagePublishFilename ( $ page ) ; } | Return the page URL . |
46,160 | public function getPagePublishDirectory ( Page $ page ) { return $ this -> getPublishDirectory ( ) . rtrim ( DIRECTORY_SEPARATOR . $ page -> getSubFolder ( ) , DIRECTORY_SEPARATOR ) ; } | Return the directory to which the page should be published . |
46,161 | public function getPagePublishPath ( Page $ page ) { return $ this -> getPagePublishDirectory ( $ page ) . DIRECTORY_SEPARATOR . $ this -> getPagePublishFilename ( $ page ) ; } | Return the full page publish path . |
46,162 | public function transform ( \ Closure $ callback ) { $ this -> photos = array_map ( $ callback , $ this -> photos ) ; return $ this ; } | Executes a callback on each photo in the collection Setting each item to the result from the callback . |
46,163 | public function createNew ( string $ section , string $ property , string $ value , bool $ protected ) : array { return $ this -> sendPost ( sprintf ( '/companies/%s/settings' , $ this -> companySlug ) , [ ] , [ 'section' => $ section , 'property' => $ property , 'value' => $ value , 'protected' => $ protected ] ) ; } | Creates a new setting for the given company . |
46,164 | function _verifyIsBannedRoute ( $ currentRoute ) { $ r = false ; $ currentRoute = rtrim ( $ currentRoute , '/' ) ; foreach ( $ this -> routesDenied as $ deniedRoute ) { $ deniedRoute = rtrim ( $ deniedRoute , '/' ) ; $ allowLeft = false ; if ( substr ( $ deniedRoute , - 1 ) == '*' ) { $ allowLeft = true ; $ deniedRoute = substr ( $ deniedRoute , 0 , strlen ( $ deniedRoute ) - 1 ) ; } if ( ( $ left = str_replace ( $ deniedRoute , '' , $ currentRoute ) ) !== $ currentRoute ) { if ( $ allowLeft || $ left == '' ) return true ; } } return $ r ; } | Check given route name is in banned list |
46,165 | public static function minimal ( string $ filePath = null ) { if ( is_file ( $ filePath ) ) { $ configItems = require_once $ filePath ; ! is_array ( $ configItems ) || Config :: items ( $ configItems ) ; ini_set ( 'error_reporting' , Config :: exists ( 'errors.error_reporting' , 0 ) ) ; ini_set ( 'display_errors' , Config :: exists ( 'errors.display_errors' , 0 ) ) ; Event :: dispatch ( 'minimal.loaded.minimal' , [ $ filePath , is_array ( $ configItems ) ? $ configItems : [ ] ] ) ; } } | Registers the minimal config file . It stores the array items from the minimal config file in the Config object and eventually sets the php . ini error_reporting and display_errors . |
46,166 | public static function dir ( $ sourcePath , $ outZipPath ) { $ sourcePath = rtrim ( $ sourcePath , "/" ) ; $ zip = new ZipArchive ( ) ; $ zip -> open ( $ outZipPath , ZipArchive :: CREATE ) ; self :: folderToZip ( $ sourcePath , $ zip , strlen ( $ sourcePath . "/" ) ) ; $ zip -> close ( ) ; } | Zip a folder |
46,167 | public function add ( $ message ) { $ this -> _messages [ ] = $ this -> log_timestamp ( ) . $ message . PHP_EOL ; $ this -> debug ( $ message ) ; } | Add message to logger buffer |
46,168 | public function error ( $ message ) { $ this -> _errors [ ] = $ this -> log_timestamp ( ) . $ message . PHP_EOL ; $ this -> debug ( 'ERROR: ' . $ message ) ; } | Add error message to logger buffer |
46,169 | public function shutdown ( ) { if ( $ this -> ondebug === TRUE ) { $ this -> _debugs [ ] = $ this -> log_debug_event ( 'end' ) . PHP_EOL ; } $ this -> sync ( ) ; } | Finish and sync all buffers to files |
46,170 | public function sync ( ) { $ this -> sync_single_log ( $ this -> _messages , '' ) ; $ this -> sync_single_log ( $ this -> _debugs , '_debug' ) ; $ this -> sync_single_log ( $ this -> _errors , '_error' ) ; } | Sync all buffers to files |
46,171 | protected function sync_single_log ( & $ buffer , $ suffix ) { if ( ! empty ( $ buffer ) ) { $ this -> write ( $ buffer , $ this -> dir . $ this -> prefix . $ suffix . '.log' ) ; $ buffer = array ( ) ; } } | Sync specific buffer to file |
46,172 | protected function write ( $ messages , $ file ) { $ f = @ fopen ( $ file , 'a' ) ; if ( $ f === false ) { throw new \ Exception ( "Logfile $file is not writeable!" ) ; } foreach ( $ messages as $ msg ) { fwrite ( $ f , $ msg ) ; } fclose ( $ f ) ; } | Write text to file |
46,173 | public function setConfiguration ( array $ configuration ) : ConfigurationProviderInterface { if ( isset ( $ configuration [ 'configuration' ] ) && $ configuration [ 'configuration' ] ) { $ configuration = array_merge ( $ configuration , $ this -> load ( $ configuration [ 'configuration' ] ) , array_filter ( $ configuration ) ) ; } $ this -> configuration = $ configuration ; return $ this ; } | Sets the underlying configuration |
46,174 | protected function initConnectionData ( ) { if ( $ this -> connectionData ) { return ; } if ( ! $ this -> connectionUrl ) { throw new \ UnexpectedValueException ( 'Expected a connectionUrl, got nowt.' ) ; } $ parsed = parse_url ( $ this -> connectionUrl ) ; if ( $ parsed === false ) { throw new UnexpectedValueException ( 'Expected a sensible connectionUrl, got nowt but rubbish.' ) ; } $ this -> connectionData = $ parsed ; } | Parse a connection url and populate connectionData with the result . |
46,175 | public function readFileLine ( $ length = null ) { $ this -> openFile ( ) ; if ( $ length === null ) { $ line = fgets ( $ this -> getFile ( ) ) ; } else { $ line = fgets ( $ this -> getFile ( ) , $ length ) ; } return $ line ; } | Read line from file |
46,176 | public function getParentRepository ( ) { if ( null == $ this -> parentRepository ) { $ this -> setParentRepository ( Orm :: getRepository ( $ this -> getParentEntity ( ) ) ) ; } return $ this -> parentRepository ; } | Gets parent entity repository |
46,177 | public function dequeue ( & $ item ) : Queue { $ values = $ this -> _shift ( $ item ) ; $ this -> setValues ( $ values ) ; return $ this ; } | Take item from the queue |
46,178 | public function enqueue ( ... $ items ) : Queue { $ values = $ this -> _pushAll ( $ items ) ; $ this -> setValues ( $ values ) ; return $ this ; } | Add item to the queue |
46,179 | private function normalizeBody ( $ body = null ) { $ body = $ body ? $ body : new Stream ( fopen ( 'php://temp' , 'r+' ) ) ; if ( is_string ( $ body ) ) { $ memoryStream = fopen ( 'php://temp' , 'r+' ) ; fwrite ( $ memoryStream , $ body ) ; rewind ( $ memoryStream ) ; $ body = new Stream ( $ memoryStream ) ; } elseif ( ! ( $ body instanceof StreamInterface ) ) { throw new InvalidArgumentException ( 'Body must be a string, null or implement Psr\Http\Message\StreamInterface' ) ; } return $ body ; } | Normalize provided body and ensure that the result object is Stream . |
46,180 | private function normalizeHeaders ( $ headers ) { if ( is_array ( $ headers ) ) { $ headers = new Headers ( $ headers ) ; } elseif ( ! ( $ headers instanceof Headers ) ) { throw new InvalidArgumentException ( 'Headers must be an array or instance of Headers' ) ; } return $ headers ; } | Normalize provided headers and ensure that the result object is Headers . |
46,181 | private function validateProtocol ( $ version ) { $ valid = [ '1.0' => true , '1.1' => true , '2.0' => true , ] ; if ( ! isset ( $ valid [ $ version ] ) ) { throw new InvalidArgumentException ( 'Invalid HTTP version. Must be one of: 1.0, 1.1, 2.0' ) ; } } | Validate version of the HTTP protocol . |
46,182 | public function getPackages ( ) { $ filename = $ this -> vendorPath . '/composer/installed.json' ; if ( ! file_exists ( $ filename ) ) { throw new Exception ( $ filename . ' not exists!' ) ; } $ packages = [ ] ; foreach ( json_decode ( file_get_contents ( $ filename ) , true ) as $ package ) { if ( $ package [ 'type' ] === 'teamelf-extension' ) { $ packages [ ] = $ package ; } } return $ packages ; } | get install packages |
46,183 | public function load ( ) { $ this -> extensions = [ ] ; foreach ( $ this -> getPackages ( ) as $ package ) { [ $ v , $ p ] = explode ( '/' , $ package [ 'name' ] ) ; $ extension = Extension :: findBy ( [ 'vendor' => $ v , 'package' => $ p ] ) ; if ( ! $ extension ) { $ extension = ( new Extension ( ) ) -> vendor ( $ v ) -> package ( $ p ) ; } $ extension -> version ( $ package [ 'version' ] ?? '' ) -> description ( $ package [ 'description' ] ?? '' ) -> save ( ) ; $ this -> extensions [ ] = $ extension ; } return $ this ; } | sync install packages with extension repository |
46,184 | public function countSkillGroups ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collSkillGroupsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collSkillGroups || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collSkillGroups ) { return 0 ; } if ( $ partial && ! $ criteria ) { return count ( $ this -> getSkillGroups ( ) ) ; } $ query = ChildSkillGroupQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByGroup ( $ this ) -> count ( $ con ) ; } return count ( $ this -> collSkillGroups ) ; } | Returns the number of related SkillGroup objects . |
46,185 | public function initSkills ( ) { $ this -> collSkills = new ObjectCollection ( ) ; $ this -> collSkillsPartial = true ; $ this -> collSkills -> setModel ( '\gossi\trixionary\model\Skill' ) ; } | Initializes the collSkills crossRef collection . |
46,186 | public function countSkills ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collSkillsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collSkills || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collSkills ) { return 0 ; } else { if ( $ partial && ! $ criteria ) { return count ( $ this -> getSkills ( ) ) ; } $ query = ChildSkillQuery :: create ( null , $ criteria ) ; if ( $ distinct ) { $ query -> distinct ( ) ; } return $ query -> filterByGroup ( $ this ) -> count ( $ con ) ; } } else { return count ( $ this -> collSkills ) ; } } | Gets the number of Skill objects related by a many - to - many relationship to the current object by way of the kk_trixionary_skill_group cross - reference table . |
46,187 | public function addSkill ( ChildSkill $ skill ) { if ( $ this -> collSkills === null ) { $ this -> initSkills ( ) ; } if ( ! $ this -> getSkills ( ) -> contains ( $ skill ) ) { $ this -> collSkills -> push ( $ skill ) ; $ this -> doAddSkill ( $ skill ) ; } return $ this ; } | Associate a ChildSkill to this object through the kk_trixionary_skill_group cross reference table . |
46,188 | public function removeSkill ( ChildSkill $ skill ) { if ( $ this -> getSkills ( ) -> contains ( $ skill ) ) { $ skillGroup = new ChildSkillGroup ( ) ; $ skillGroup -> setSkill ( $ skill ) ; if ( $ skill -> isGroupsLoaded ( ) ) { $ skill -> getGroups ( ) -> removeObject ( $ this ) ; } $ skillGroup -> setGroup ( $ this ) ; $ this -> removeSkillGroup ( clone $ skillGroup ) ; $ skillGroup -> clear ( ) ; $ this -> collSkills -> remove ( $ this -> collSkills -> search ( $ skill ) ) ; if ( null === $ this -> skillsScheduledForDeletion ) { $ this -> skillsScheduledForDeletion = clone $ this -> collSkills ; $ this -> skillsScheduledForDeletion -> clear ( ) ; } $ this -> skillsScheduledForDeletion -> push ( $ skill ) ; } return $ this ; } | Remove skill of this object through the kk_trixionary_skill_group cross reference table . |
46,189 | public function get ( string $ name ) : EventHandlerInterface { if ( ! isset ( $ this -> eventHandlers [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'DataGrid event handler %s not found' , $ name ) ) ; } return $ this -> eventHandlers [ $ name ] ; } | Returns chosen event handler by its function name |
46,190 | protected function makeRequest ( $ type ) { if ( isset ( $ this -> { $ type . 'Request' } ) && $ this -> { $ type . 'Request' } ) { $ request = app ( ) -> make ( $ this -> { $ type . 'Request' } ) ; if ( ! $ request instanceof Request ) { throw new \ Exception ( "Class {$this->{$type . 'Request'}} must be an instance of Illuminate\\Http\\Request" ) ; } return $ request ; } } | Create a FormRequest declared in property type |
46,191 | protected function maybeMakeResource ( $ type , $ data , $ status = 200 ) { $ resourceName = $ type . 'Resource' ; if ( isset ( $ this -> $ resourceName ) && $ this -> $ resourceName ) { $ class = $ this -> $ resourceName ; return ( new $ class ( $ data ) ) -> response ( ) -> setStatusCode ( $ status ) ; } elseif ( is_bool ( $ data ) ) { return strval ( $ data ) ; } else { return $ data ; } } | If is defined return a Api Resource object |
46,192 | public static function getDefaultParameters ( $ className ) { if ( ! isset ( static :: $ registeredClasses [ $ className ] ) ) { return null ; } $ params = static :: $ registeredClasses [ $ className ] ; if ( is_callable ( $ params ) ) { $ params = $ params ( ) ; } return $ params ; } | Get the registered parameters for a given class |
46,193 | public static function getInstance ( $ className ) { if ( ! isset ( static :: $ registeredClasses [ $ className ] ) ) { return null ; } $ object = $ className :: build ( ) -> auto ( ) ; return $ object ; } | Get a new instance of a registered class returns null if the class is not registered |
46,194 | protected function defineMany ( $ gate , $ class , array $ policies ) { foreach ( $ policies as $ method => $ ability ) { $ gate -> define ( $ ability , "$class@$method" ) ; } } | Define policies . |
46,195 | public static function normalize ( $ pattern ) { return self :: $ delimiter . trim ( $ pattern , self :: $ delimiter ) . self :: $ delimiter ; } | This method normalizes the regular expression pattern before we use it |
46,196 | public static function sanitize ( $ string , $ mask ) { if ( is_array ( $ mask ) ) { $ parts = $ mask ; } else if ( is_string ( $ mask ) ) { $ parts = str_split ( $ mask ) ; } else { return $ string ; } foreach ( $ parts as $ part ) { $ normalized = self :: normalize ( "\\{$part}" ) ; $ string = preg_replace ( "{$normalized}m" , "\\{$part}" , $ string ) ; } return $ string ; } | This method loops through the characters of a string replacing them with regualar expression friendly character representations . |
46,197 | public static function unique ( $ string ) { $ unique = '' ; $ parts = str_split ( $ string ) ; foreach ( $ parts as $ part ) { if ( ! strstr ( $ unique , $ part ) ) { $ unique .= $ part ; } } return $ unique ; } | This method removes duplicates from a string |
46,198 | public static function indexOf ( $ string , $ substring , $ offset = null ) { $ position = strpos ( $ string , $ substring , $ offset ) ; if ( ! is_int ( $ position ) ) { return - 1 ; } return $ position ; } | This method determines substrings within larger strings |
46,199 | public static function singular ( $ string ) { $ result = $ string ; foreach ( $ self :: $ singulars as $ rule => $ replacement ) { $ rule = self :: normalize ( $ rule ) ; if ( preg_match ( $ rule , $ string ) ) { $ result = preg_replace ( $ rule , $ replacement , $ string ) ; break ; } } return $ result ; } | This method gets the singular form of an input string |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.