idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
229,100 | protected function symlinksTask ( $ worker , AbstractAuth $ auth , $ remote ) { $ collection = $ this -> collectionBuilder ( ) ; foreach ( $ remote [ 'symlinks' ] as $ link ) { $ collection -> taskSsh ( $ worker , $ auth ) -> exec ( 'ln -s -T -f ' . str_replace ( ':' , ' ' , $ link ) ) ; } return $ collection ; } | Create all required symlinks on the server . |
229,101 | protected function clearOpCacheTask ( $ worker , AbstractAuth $ auth , $ remote ) { $ clearOpcache = 'vendor/bin/robo digipolis:clear-op-cache ' . $ remote [ 'opcache' ] [ 'env' ] ; if ( isset ( $ remote [ 'opcache' ] [ 'host' ] ) ) { $ clearOpcache .= ' --host=' . $ remote [ 'opcache' ] [ 'host' ] ; } return $ this ->... | Clear OPcache on the server . |
229,102 | protected function cleanDirsTask ( $ worker , AbstractAuth $ auth , $ remote ) { $ cleandirLimit = isset ( $ remote [ 'cleandir_limit' ] ) ? max ( 1 , $ remote [ 'cleandir_limit' ] ) : '' ; $ task = $ this -> taskSsh ( $ worker , $ auth ) -> remoteDirectory ( $ remote [ 'rootdir' ] , true ) -> timeout ( $ this -> getTi... | Clean the release and backup directories on the server . |
229,103 | protected function tokenReplace ( $ input , $ replacements ) { if ( is_string ( $ input ) ) { return strtr ( $ input , $ replacements ) ; } if ( is_scalar ( $ input ) || empty ( $ input ) ) { return $ input ; } foreach ( $ input as & $ i ) { $ i = $ this -> tokenReplace ( $ i , $ replacements ) ; } return $ input ; } | Helper functions to replace tokens in an array . |
229,104 | protected function backupFileName ( $ extension , $ timestamp = null ) { if ( is_null ( $ timestamp ) ) { $ timestamp = $ this -> time ; } return $ timestamp . '_' . date ( 'Y_m_d_H_i_s' , $ timestamp ) . $ extension ; } | Generate a backup filename based on the given time . |
229,105 | protected function getRemoteSettings ( $ host , $ user , $ keyFile , $ app , $ timestamp = null ) { $ this -> readProperties ( ) ; $ defaults = [ 'user' => $ user , 'private-key' => $ keyFile , 'app' => $ app , 'createbackup' => true , 'time' => is_null ( $ timestamp ) ? $ this -> time : $ timestamp , ] ; $ replacement... | Get the settings from the remote config key with the tokens replaced . |
229,106 | protected function getLocalSettings ( $ app = null , $ timestamp = null ) { $ this -> readProperties ( ) ; $ defaults = [ 'app' => $ app , 'time' => is_null ( $ timestamp ) ? $ this -> time : $ timestamp , 'project_root' => $ this -> getConfig ( ) -> get ( 'digipolis.root.project' ) , 'web_root' => $ this -> getConfig ... | Get the settings from the local config key with the tokens replaced . |
229,107 | protected function getTimeoutSetting ( $ setting ) { $ timeoutSettings = $ this -> getTimeoutSettings ( ) ; return isset ( $ timeoutSettings [ $ setting ] ) ? $ timeoutSettings [ $ setting ] : static :: DEFAULT_TIMEOUT ; } | Timeouts can be overwritten in properties . yml under the timeout key . |
229,108 | protected function getUserHomeDir ( ) { $ home = getenv ( 'HOME' ) ; if ( ! empty ( $ home ) ) { return rtrim ( $ home , '/' ) ; } if ( ! empty ( $ _SERVER [ 'HOMEDRIVE' ] ) && ! empty ( $ _SERVER [ 'HOMEPATH' ] ) ) { $ home = $ _SERVER [ 'HOMEDRIVE' ] . $ _SERVER [ 'HOMEPATH' ] ; return rtrim ( $ home , '\\/' ) ; } th... | Get the home directory for the current user . |
229,109 | public function setRawData ( array $ data ) { $ this -> data = $ data + $ this -> data ; if ( $ data ) { $ this -> loaded = true ; $ this -> setDataSource ( '*' , 'db' ) ; } return $ this ; } | Set raw data to model |
229,110 | protected function getDataSource ( $ name ) { return isset ( $ this -> dataSources [ $ name ] ) ? $ this -> dataSources [ $ name ] : $ this -> dataSources [ '*' ] ; } | Returns the data source of specified column name |
229,111 | protected function generateDbData ( ) { $ dbData = [ ] ; foreach ( $ this -> data as $ name => $ value ) { if ( $ this -> getDataSource ( $ name ) !== 'db' ) { $ dbData [ $ name ] = $ this -> getSetValue ( $ name , $ value ) ; } else { $ dbData [ $ name ] = $ value ; } } return $ dbData ; } | Generates data for saving to database |
229,112 | protected function & getVirtualValue ( $ name ) { $ result = $ this -> callGetter ( $ name , $ this -> virtualData [ $ name ] ) ; if ( $ result ) { return $ this -> virtualData [ $ name ] ; } throw new InvalidArgumentException ( 'Invalid virtual column: ' . $ name ) ; } | Returns the virtual column value |
229,113 | protected function setVirtualValue ( $ name , $ value ) { $ result = $ this -> callSetter ( $ name , $ value ) ; if ( ! $ result ) { throw new InvalidArgumentException ( 'Invalid virtual column: ' . $ name ) ; } return $ this ; } | Sets the virtual column value |
229,114 | protected function hasVirtual ( $ name ) { $ name = $ this -> filterInputColumn ( $ name ) ; return in_array ( $ name , $ this -> virtual ) ; } | Check if the name is virtual column |
229,115 | private function verifyHandler ( callable $ func ) : bool { $ reflection = Func :: getReflection ( $ func ) ; $ params = $ reflection -> getParameters ( ) ; if ( count ( $ params ) !== 2 ) { return false ; } list ( $ value , $ validator ) = $ params ; if ( $ value -> getType ( ) !== null || $ value -> isOptional ( ) ) ... | Verify the validate function has the correct signature |
229,116 | protected function getDiscountForClientGroup ( ClientGroupInterface $ clientGroup = null ) : float { if ( null !== $ clientGroup ) { return round ( ( float ) $ clientGroup -> getDiscount ( ) / 100 , 2 ) ; } return 0 ; } | Returns the discount for client s group |
229,117 | public function validate ( ) { if ( $ this -> count ( ) > 1 ) { throw new DataException ( 'There should be only one root node to configure for Atom Logger data.' ) ; } foreach ( $ this -> getNodes ( ) as $ field => $ value ) { if ( ! in_array ( $ field , $ this -> getFields ( ) ) ) { throw new DataException ( "The fiel... | Validate the data to be correct for a request |
229,118 | public function cmdCronCron ( ) { if ( ! $ this -> cron -> run ( ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> output ( ) ; } | Callback for cron command Run CRON |
229,119 | public function reverseTransform ( $ value ) { if ( null === $ value ) { return null ; } $ repo = $ this -> em -> getRepository ( $ this -> className ) ; $ entity = $ repo -> find ( $ value ) ; if ( ! $ entity ) { return null ; } return $ entity ; } | Transform to single id value to an entity |
229,120 | private function inputToNorm ( $ value , string $ path ) { if ( null === $ this -> inputTransformer ) { $ this -> inputTransformer = $ this -> fieldConfig -> getNormTransformer ( ) ?? false ; } if ( false === $ this -> inputTransformer ) { if ( null !== $ value && ! is_scalar ( $ value ) ) { $ e = new \ RuntimeExceptio... | Reverse transforms a value if a value transformer is set . |
229,121 | public function applyFilter ( ImageInterface $ image , FilterInterface $ filter ) { if ( $ filter instanceof ImagineAware ) { if ( $ this -> imagine === null ) { throw new InvalidArgumentException ( sprintf ( 'In order to use %s pass an Imagine\Image\ImagineInterface instance to Transformation constructor' , get_class ... | Applies a given FilterInterface onto given ImageInterface and returns modified ImageInterface |
229,122 | public function getFilters ( ) { if ( null === $ this -> sorted ) { if ( ! count ( $ this -> filters ) ) { $ this -> sorted = array ( ) ; } else { ksort ( $ this -> filters ) ; $ this -> sorted = call_user_func_array ( 'array_merge' , $ this -> filters ) ; } } return $ this -> sorted ; } | Returns a list of filters sorted by their priority . Filters with same priority will be returned in the order they were added . |
229,123 | public function add ( FilterInterface $ filter , $ priority = 0 ) { $ this -> filters [ $ priority ] [ ] = $ filter ; $ this -> sorted = null ; return $ this ; } | Registers a given FilterInterface in an internal array of filters for later application to an instance of ImageInterface |
229,124 | public function prepend ( FilterChain $ chain ) { $ priorities = array_keys ( $ this -> filters ) ; if ( count ( $ priorities ) ) { $ priority = min ( array_keys ( $ this -> filters ) ) - 1 ; } else { $ priority = 0 ; } $ filters = $ chain -> getFilters ( ) ; foreach ( $ filters as $ filter ) { $ this -> add ( $ filter... | Prepend filters from another filter chain |
229,125 | public function append ( FilterChain $ chain ) { $ priorities = array_keys ( $ this -> filters ) ; if ( count ( $ priorities ) ) { $ priority = max ( array_keys ( $ this -> filters ) ) + 1 ; } else { $ priority = 0 ; } $ filters = $ chain -> getFilters ( ) ; foreach ( $ filters as $ filter ) { $ this -> add ( $ filter ... | Append filters from another filter chain |
229,126 | public static function convertToDatetime ( $ rawDate , $ format = 'd.m.Y' ) { if ( Any :: isInt ( $ rawDate ) ) { $ rawDate = date ( \ DateTime :: ATOM , $ rawDate ) ; } try { $ object = new \ DateTime ( $ rawDate ) ; return $ object -> format ( $ format ) ; } catch ( \ Exception $ e ) { return false ; } } | Try to convert string to date time format |
229,127 | public static function humanize ( $ raw ) { $ timestamp = $ raw ; if ( ! Any :: isInt ( $ raw ) ) { $ timestamp = self :: convertToTimestamp ( ( string ) $ timestamp ) ; } $ diff = time ( ) - $ timestamp ; if ( $ diff < 0 ) { return self :: convertToDatetime ( $ timestamp , static :: FORMAT_TO_SECONDS ) ; } $ deltaSec ... | Humanize date format |
229,128 | public static function getYoutubeId ( $ url ) { $ videoId = false ; if ( preg_match ( '%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i' , $ url , $ match ) ) { $ videoId = $ match [ 1 ] ; } return $ videoId ; } | Extracts the vimeo id from a vimeo url . Returns false if the url is not recognized as a vimeo url . |
229,129 | public function getTuples ( $ data ) { foreach ( $ this -> tuples as $ tuple ) $ tuples [ $ tuple ] = $ data [ $ tuple ] ; foreach ( $ this -> hidden_tuples as $ hidden_tuple ) unset ( $ tuples [ $ hidden_tuple ] ) ; return $ tuples ; } | Proceso de llenado de las relaciones permitidas y filtrado de las relaciones ocultas otorgadas al modelo Rest . |
229,130 | public function convert ( $ object , $ ignoreNonSerialisables = false , $ prettyPrint = false ) { $ object = $ this -> normaliseToArrayForm ( $ object , $ ignoreNonSerialisables ) ; return json_encode ( $ object , $ prettyPrint ? JSON_PRETTY_PRINT : null ) ; } | Convert a passed object to JSON notation |
229,131 | protected function Init ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = Site :: Schema ( ) -> Table ( ) ; $ order = $ sql -> OrderList ( $ sql -> OrderAsc ( $ tbl -> Field ( 'Name' ) ) ) ; $ sites = Site :: Schema ( ) -> Fetch ( false , null , $ order ) ; $ this -> sites = array ( ) ; foreach ( $ sites as $ site ) { i... | Initiaizes the set of sites |
229,132 | protected function PageTreeUrl ( Site $ site ) { $ args = array ( 'site' => $ site -> GetID ( ) ) ; return BackendRouter :: ModuleUrl ( new PageTree ( ) , $ args ) ; } | Returns the page tree url of a site |
229,133 | protected function CanEdit ( Site $ site ) { return self :: Guard ( ) -> Allow ( BackendAction :: Edit ( ) , $ site ) && self :: Guard ( ) -> Allow ( BackendAction :: UseIt ( ) , new SiteForm ( ) ) ; } | True if site can be edited |
229,134 | final public function pipe ( callable $ stage , callable $ fallback = null ) : PipeChainInterface { $ this -> stack -> attach ( $ stage , $ fallback ) ; return $ this ; } | pipes a stage with an optional associated fallback . |
229,135 | final public function process ( $ payload ) { $ payload = $ this -> processor -> processStack ( $ payload , $ this -> stack ) ; if ( $ this -> next instanceof PipeChainInterface ) { $ payload = $ this -> next -> process ( $ payload ) ; } return $ payload ; } | processes a payload . |
229,136 | final public function chain ( PipeChainInterface $ chain ) : PipeChainInterface { if ( $ this -> next instanceof PipeChainInterface ) { $ this -> next -> chain ( $ chain ) ; } else { $ this -> next = $ chain ; } return $ this ; } | appends the provided pipe to the end of the chain . |
229,137 | public function spec ( $ spec , $ value = null ) { $ key = "$spec" ; if ( array_key_exists ( $ key , $ this -> spec ) ) { return $ this -> spec [ $ key ] ; } if ( ! is_null ( $ value ) ) { return $ this -> spec [ $ key ] = $ value ; } if ( is_string ( $ spec ) ) { $ spec = new CK \ MARCspec \ MARCspec ( $ spec ) ; } $ ... | Cache a spec . |
229,138 | public function validation ( $ subSpec , $ value = null ) { $ key = "$subSpec" ; if ( is_null ( $ value ) ) { if ( array_key_exists ( $ key , $ this -> valid ) ) { return $ this -> valid [ $ key ] ; } else { return ; } } $ this -> valid [ $ key ] = $ value ; } | Set or get subspec validation . |
229,139 | private function sliceData ( $ key , $ spec ) { $ start = $ spec -> getIndexStart ( ) ; if ( '#' === $ start ) { $ end = count ( $ this -> data [ $ key ] ) - 1 ; $ start = $ spec -> getIndexEnd ( ) ; if ( '#' === $ start ) { return [ $ this -> data [ $ key ] [ $ end ] ] ; } $ length = $ end - $ start ; return array_sli... | Get a slice from data . |
229,140 | public function getContents ( $ spec , array $ value = [ ] ) { if ( ! $ value ) { $ value = $ this -> getData ( "$spec" ) ; } $ substring = false ; $ charStart = null ; $ length = null ; if ( $ spec -> offsetExists ( 'charStart' ) ) { $ substring = true ; $ charStart = $ spec [ 'charStart' ] ; $ length = $ spec [ 'char... | Get referenced data content . |
229,141 | public function push ( $ key , $ value ) { $ array = $ this -> get ( $ key , [ ] ) ; if ( ! is_array ( $ array ) ) throw new JsonPropertyException ( 'Cannot push value to non array' ) ; array_push ( $ array , $ value ) ; return $ this -> set ( $ key , $ array ) ; } | Push a value into an array assigned to the provided key . |
229,142 | public function merge ( array $ values , array $ allowedKeys = [ ] ) { $ this -> data = array_merge ( $ this -> data , array_only ( $ values , array_merge ( array_keys ( $ this -> data ) , $ allowedKeys ) ) ) ; $ this -> persist ( ) ; return $ this ; } | Merge the given array into existing values . Require whitelist to add keys |
229,143 | public function forget ( $ key ) { if ( $ this -> has ( $ key ) ) { array_forget ( $ this -> data , $ key ) ; } $ this -> persist ( ) ; } | Remove element from settings array |
229,144 | public function isEmpty ( $ key ) { return ! array_has ( $ this -> data , $ key ) || filled ( array_get ( $ this -> data , $ key ) ) ; } | Check if there is a value for the given key |
229,145 | public static function retError ( $ value , $ http_code = HttpCodes :: HTTP_BAD_REQUEST , $ prettyPrint = false ) { $ response = self :: buildResponse ( $ value , false , $ http_code ) ; return self :: retJSON ( $ response , $ prettyPrint ) ; } | Return error . |
229,146 | public static function buildResponse ( $ value , $ success , $ httpCode , Paginer $ pagingInfo = null ) { $ response = new stdClass ( ) ; $ response -> success = $ success ; $ response -> http_code = $ httpCode ; if ( $ pagingInfo ) { $ response -> pageNumber = $ pagingInfo -> getPageNumber ( ) ; $ response -> pageSize... | Builds API response . |
229,147 | public static function retSuccess ( $ value = null , $ http_code = HttpCodes :: HTTP_OK , Paginer $ pagingInfo = null , $ prettyPrint = false ) { $ response = self :: buildResponse ( $ value , true , $ http_code , $ pagingInfo ) ; return self :: retJSON ( $ response , $ prettyPrint ) ; } | Return success . |
229,148 | public static function isSuccess ( stdClass $ response ) { if ( is_object ( $ response ) && $ response -> success == true ) { return HttpCodes :: isOk ( $ response -> http_code ) ; } else { return false ; } } | Check if a response is a success . |
229,149 | private function set ( $ operand , $ value ) { $ reflector = $ this -> getReflector ( ) ; if ( ! $ reflector -> hasProperty ( $ operand ) ) { throw new RuntimeException ( 'Trying to access undefined property in reflection context: ' . $ operand ) ; } $ reflectionProperty = $ reflector -> getProperty ( $ operand ) ; if ... | Reflection property setter . |
229,150 | private function get ( $ operand ) { $ reflector = $ this -> getReflector ( ) ; if ( ! $ reflector -> hasProperty ( $ operand ) ) { throw new RuntimeException ( 'Trying to access undefined property from reflection context: ' . $ operand ) ; } $ reflectionProperty = $ reflector -> getProperty ( $ operand ) ; if ( $ refl... | Reflected p [ roperties defauilt getter . |
229,151 | public static function substring ( $ string , $ start = 0 , $ length = null ) { if ( ! self :: isValid ( $ string ) ) { return false ; } return mb_substr ( $ string , $ start , $ length ) ; } | Get a part of a string |
229,152 | public static function startsWith ( $ needle , $ haystack , $ caseSensitive = true ) { if ( ! self :: isValid ( $ needle ) ) { return false ; } list ( $ needle , $ haystack ) = self :: transformCase ( $ needle , $ haystack , $ caseSensitive ) ; if ( $ needle === false ) { return false ; } else { return ( self :: substr... | Check if string starts with another string |
229,153 | public static function endsWith ( $ needle , $ haystack , $ caseSensitive = true ) { list ( $ needle , $ haystack ) = self :: transformCase ( $ needle , $ haystack , $ caseSensitive ) ; return ( self :: substring ( $ haystack , - ( self :: length ( $ needle ) ) ) === $ needle ) ; } | Check if string ends with another string |
229,154 | public static function contains ( $ needle , $ haystack , $ caseSensitive = true ) { if ( ! self :: isValid ( $ haystack ) ) { return false ; } list ( $ needle , $ haystack ) = self :: transformCase ( $ needle , $ haystack , $ caseSensitive ) ; return ( mb_strpos ( $ haystack , $ needle ) !== false ) ; } | Check if string contains another string |
229,155 | public static function replace ( $ search , $ replace , $ string , $ caseSensitive = true ) { if ( ! self :: isValid ( $ replace ) ) { return false ; } if ( ! $ caseSensitive ) { return str_ireplace ( $ search , $ replace , $ string ) ; } else { return str_replace ( $ search , $ replace , $ string ) ; } } | Replace a string with another string |
229,156 | public static function isEmpty ( $ string ) { if ( ! self :: isValid ( $ string ) && null !== $ string ) { return false ; } return ( $ string === null || $ string === '' ) ; } | Check if string is empty |
229,157 | public static function isNotEmpty ( $ string ) { if ( ! self :: isValid ( $ string ) && null !== $ string ) { return false ; } return ( ! self :: isEmpty ( $ string ) ) ; } | Check if string is not empty |
229,158 | static function Trans ( $ text , $ from_charset , $ to_charset , $ options = array ( ) ) { $ from_charset = self :: _GetCharsetByName ( $ from_charset ) ; $ to_charset = self :: _GetCharsetByName ( $ to_charset ) ; if ( $ from_charset == $ to_charset ) { return $ text ; } return self :: _Trans ( $ text , $ from_charset... | Converts string from source charset to target charset . |
229,159 | static function Lower ( $ text , $ charset = null ) { static $ TR_TABLES = array ( ) ; $ charset = self :: _GetCharsetByName ( $ charset ) ; switch ( $ charset ) { case "windows-1250" : case "iso-8859-2" : if ( ! isset ( $ TR_TABLES [ $ charset ] ) ) { require ( dirname ( __FILE__ ) . "/tr_tables/lower_upper/$charset.p... | Converts string to lowercase . |
229,160 | static function Upper ( $ text , $ charset = null ) { static $ TR_TABLES = array ( ) ; $ charset = self :: _GetCharsetByName ( $ charset ) ; switch ( $ charset ) { case "windows-1250" : case "iso-8859-2" : if ( ! isset ( $ TR_TABLES [ $ charset ] ) ) { require ( dirname ( __FILE__ ) . "/tr_tables/lower_upper/$charset.p... | Converts string to uppercase . |
229,161 | static function CheckEncoding ( $ text , $ charset , $ disallowed_char_sequencies = array ( ) ) { if ( is_array ( $ text ) ) { foreach ( $ text as $ _key => $ _value ) { $ _stat_key = self :: CheckEncoding ( $ _key , $ charset , $ disallowed_char_sequencies ) ; $ _stat_value = self :: CheckEncoding ( $ _value , $ chars... | Checks if input string is in given charset . |
229,162 | static function Length ( & $ text , $ charset ) { $ charset = self :: _GetCharsetByName ( $ charset ) ; switch ( $ charset ) { case "utf8" : return self :: _LengthUtf8 ( $ text ) ; default : return strlen ( $ text ) ; } } | Counts length of a string . |
229,163 | public function asc ( array $ collection ) { $ count = count ( $ collection ) ; if ( $ count < 2 ) { return $ collection ; } $ leftCollection = array ( ) ; $ rightCollection = array ( ) ; reset ( $ collection ) ; $ sortPivot = key ( $ collection ) ; $ pivot = array_shift ( $ collection ) ; foreach ( $ collection as $ k... | Sorts the given array using a quick sort algorithm . |
229,164 | public function desc ( array $ collection ) { $ this -> changeDirection ( false ) ; $ collection = $ this -> asc ( $ collection ) ; $ this -> changeDirection ( true ) ; return $ collection ; } | Inversely sorts the given array using a quick sort algorithm |
229,165 | private function getNamespace ( $ class , $ source , $ destination ) { if ( false === is_object ( $ class ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type object, "%s" given' , __METHOD__ , gettype ( $ class ) ) , E_USER_ERROR ) ; } if ( false === is_array ( $ source ) ) { return tr... | Returns the path of a giving namespace |
229,166 | public static function normalizePath ( $ path ) { if ( is_string ( $ path ) ) { return explode ( '.' , $ path ) ; } if ( ! is_array ( $ path ) ) { return [ $ path ] ; } return $ path ; } | Normalize property paths . |
229,167 | public function count ( ) { $ result = 0 ; foreach ( $ this -> routes as $ routes ) { $ result += count ( $ routes ) ; } return $ result ; } | Returns the number of key - value mappings in the router map . |
229,168 | public function containsCallable ( callable $ callable ) { foreach ( $ this -> routes as $ method ) { foreach ( $ method as $ entry ) { if ( $ entry -> callable === $ callable ) { return true ; } } } return false ; } | Returns true if the router map maps one or more routes to the specified callable . |
229,169 | public function get ( $ method , $ route ) { if ( ! array_key_exists ( $ method , $ this -> routes ) ) { return null ; } foreach ( $ this -> routes [ $ method ] as $ key => $ entry ) { if ( $ entry -> route == $ route ) { return $ entry -> callable ; } } return null ; } | Returns the callable to which the specified route is mapped or null if the router map contains no mapping for the route . |
229,170 | public function set ( $ methods , $ route , callable $ callable ) { if ( is_string ( $ methods ) ) { $ methods = [ $ methods ] ; } foreach ( $ methods as $ method ) { $ this -> add ( $ method , $ route , $ callable ) ; } return $ this ; } | Associates the specified callable with the specified method & route in the route map . |
229,171 | private function add ( string $ method , string $ route , callable $ callable ) { $ entry = ( object ) [ 'route' => $ route , 'pattern' => $ this -> createPattern ( $ route ) , 'callable' => $ callable ] ; if ( ! array_key_exists ( $ method , $ this -> routes ) ) { $ this -> routes [ $ method ] = [ ] ; } $ this -> rout... | Adds a method & route to the to the route map . |
229,172 | public function remove ( $ method , $ route ) { if ( ! array_key_exists ( $ method , $ this -> routes ) ) { return ; } foreach ( $ this -> routes [ $ method ] as $ key => $ entry ) { if ( $ entry -> route == $ route ) { unset ( $ this -> routes [ $ method ] [ $ key ] ) ; } } if ( count ( $ this -> routes [ $ method ] )... | Removes the mapping for the specified route from the router map if present . |
229,173 | public function resolve ( $ method = null , $ route = null ) { $ serverRequest = new ServerRequest ( ) ; if ( $ method === null ) { $ method = $ serverRequest -> getMethod ( ) ; } if ( $ route === null ) { $ route = $ serverRequest -> getUri ( ) -> getPath ( ) ; } if ( $ this -> basePath !== '' && strpos ( $ route , $ ... | Returns the result of the given route s callable . |
229,174 | private function getCallable ( $ method , $ route ) { if ( ! array_key_exists ( $ method , $ this -> routes ) ) { throw new ServerResponseException ( new ServerResponse ( 404 ) ) ; } foreach ( $ this -> routes [ $ method ] as $ entry ) { if ( preg_match ( $ entry -> pattern , $ route , $ matches ) > 0 ) { array_shift (... | Returns the callable to which the specied method and route are mapped . |
229,175 | public function set ( $ name , $ value = null , $ time = 2592000 ) { $ value = json_encode ( $ value ) ; parent :: set ( $ name , $ value ) ; setcookie ( $ name , $ value , time ( ) + $ time , '/' , $ this -> server -> get ( 'name' ) ) ; } | Set cookie information . |
229,176 | public function seed ( array $ roles ) { Role :: query ( ) -> insert ( $ this -> prepareRoles ( $ roles ) ) ; $ this -> syncAdminRole ( ) ; } | Seed roles . |
229,177 | protected function prepareRoles ( array $ roles ) { $ now = now ( ) ; return array_map ( function ( $ role ) use ( $ now ) { return array_merge ( $ role , [ 'slug' => $ role [ 'slug' ] ?? $ this -> slugify ( $ role [ 'name' ] ) , 'is_locked' => $ role [ 'is_locked' ] ?? true , 'created_at' => $ now , 'updated_at' => $ ... | Prepare roles to seed . |
229,178 | protected function syncAdminRole ( ) { $ admin = Role :: admin ( ) -> first ( ) ; $ admin -> permissions ( ) -> sync ( Permission :: all ( ) -> pluck ( 'id' ) -> toArray ( ) ) ; } | Sync the admin role with all permissions . |
229,179 | protected function syncRoles ( array $ roles ) { $ permissions = Permission :: all ( ) ; foreach ( $ roles as $ roleSlug => $ permissionSlug ) { if ( $ role = Role :: query ( ) -> where ( 'slug' , $ roleSlug ) -> first ( ) ) { $ filtered = $ permissions -> filter ( function ( Permission $ permission ) use ( $ permissio... | Sync the roles . |
229,180 | public function cmdGetProduct ( ) { $ result = $ this -> getListProduct ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableProduct ( $ result ) ; $ this -> output ( ) ; } | Callback for product - get command |
229,181 | public function cmdUpdateProduct ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ this ... | Callback for product - update command |
229,182 | protected function addProduct ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> product -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new product |
229,183 | protected function submitAddProduct ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> setSubmitted ( 'form' , true ) ; $ this -> validateComponent ( 'product' ) ; $ this -> addProduct ( ) ; } | Add a new product at once |
229,184 | protected function wizardAddProduct ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'product' ) ; $ this -> validatePrompt ( 'description' , $ this -> text ( 'Description' ) , 'product' ) ; $ this -> validatePrompt ( 'store_id' , $ this -> text ( 'Store ID' ) , 'product' , 0 ) ; $ this -> valida... | Add a new product step by step |
229,185 | public function getClassNames ( $ withNamespace = true ) { $ tokens = new \ PHP_Token_Stream ( $ this -> _content ) ; $ classes = $ tokens -> getClasses ( ) ; $ classNames = array ( ) ; foreach ( $ classes as $ className => $ class ) { $ namespace = $ class [ 'package' ] [ 'namespace' ] ; if ( $ withNamespace === true ... | Get class names defined in target file |
229,186 | public function cmdGetCollection ( ) { $ result = $ this -> getListCollection ( ) ; $ this -> outputFormat ( $ result ) ; $ this -> outputFormatTableCollection ( $ result ) ; $ this -> output ( ) ; } | Callback for collection - get command |
229,187 | public function cmdDeleteCollection ( ) { $ id = $ this -> getParam ( 0 ) ; $ all = $ this -> getParam ( 'all' ) ; if ( empty ( $ id ) && empty ( $ all ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } $ options = null ; if ( isset ( $ id ) ) { if ( $ this -> getParam ( 'type' ) ) { $ options = ... | Callback for collection - delete command |
229,188 | public function cmdUpdateCollection ( ) { $ params = $ this -> getParam ( ) ; if ( empty ( $ params [ 0 ] ) || count ( $ params ) < 2 ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid command' ) ) ; } if ( ! is_numeric ( $ params [ 0 ] ) ) { $ this -> errorAndExit ( $ this -> text ( 'Invalid argument' ) ) ; } $ th... | Callback for collection - update command |
229,189 | protected function addCollection ( ) { if ( ! $ this -> isError ( ) ) { $ id = $ this -> collection -> add ( $ this -> getSubmitted ( ) ) ; if ( empty ( $ id ) ) { $ this -> errorAndExit ( $ this -> text ( 'Unexpected result' ) ) ; } $ this -> line ( $ id ) ; } } | Add a new collection |
229,190 | protected function submitAddCollection ( ) { $ this -> setSubmitted ( null , $ this -> getParam ( ) ) ; $ this -> validateComponent ( 'collection' ) ; $ this -> addCollection ( ) ; } | Add a new collection at once |
229,191 | protected function wizardAddCollection ( ) { $ this -> validatePrompt ( 'title' , $ this -> text ( 'Title' ) , 'collection' ) ; $ this -> validateMenu ( 'type' , $ this -> text ( 'Type' ) , 'collection' , $ this -> collection -> getTypes ( ) ) ; $ this -> validatePrompt ( 'store_id' , $ this -> text ( 'Store' ) , 'coll... | Add a new collection step by step |
229,192 | public function create ( $ timestamps = true , $ softDeletes = false , $ fields = [ ] ) { $ path = $ this -> getpath ( $ this -> name ) ; if ( $ this -> files -> exists ( $ path ) ) { throw new \ Exception ( "Factory [$this->name] already exists!" ) ; } $ stub = $ this -> files -> get ( $ this -> getStub ( ) ) ; $ stub... | Create a new factory file . |
229,193 | public function getPath ( $ name ) { $ segments = explode ( '\\' , $ name ) ; array_shift ( $ segments ) ; if ( $ this -> path ) return $ this -> path . '/' . ucfirst ( array_last ( $ segments ) ) . 'Factory.php' ; else return database_path ( 'factories/' . ucfirst ( array_last ( $ segments ) ) ) . 'Factory.php' ; } | Get path for migration file . |
229,194 | protected function replaceFakerArray ( & $ stub , $ fields , $ timestamps , $ softDeletes ) { $ array = [ ] ; foreach ( $ fields as $ f ) { if ( ! empty ( $ f [ 'fakerFunction' ] ) || ! empty ( $ f [ 'fkey' ] ) ) { $ params = ! empty ( $ f [ 'fakerFunctionParams' ] ) ? "({$f['fakerFunctionParams']})" : "" ; if ( ! empt... | Replace Faker array dummy . |
229,195 | public function getIsNode ( ) { return ! is_null ( $ this -> domNode ) && isset ( DOMXPathNavigator :: $ nodeTypeMap [ $ this -> domNode -> nodeType ] ) ; } | Gets a value indicating whether the item represents an XPath node or an atomic value |
229,196 | public function getValue ( ) { if ( is_null ( $ this -> domNode ) ) { return "" ; } if ( $ this -> domNode instanceof \ DOMNameSpaceNode ) { $ ns = $ this -> domNode ; return $ ns -> nodeValue ; } return $ this -> domNode instanceof \ DOMDocument ? $ this -> domNode -> textContent : $ this -> domNode -> nodeValue ; } | Gets the string value of the item |
229,197 | public function getValueType ( ) { $ xmlType = SchemaTypes :: getInstance ( ) -> getTypeForDOMNode ( $ this -> domNode ) ; if ( $ xmlType ) { $ type = Type :: XmlTypeToPHPType ( $ xmlType ) ; if ( $ type ) return $ type ; } return Type :: string ; } | Gets the PHP runtime type of the item . |
229,198 | public function getXmlType ( ) { if ( ! property_exists ( $ this -> domNode , "schemaType" ) ) { $ effectiveNode = $ this -> domNode -> nodeType == XML_TEXT_NODE ? $ this -> domNode -> parentNode : $ this -> domNode ; $ this -> domNode -> schemaType = DOMSchemaType :: getSchemaType ( $ effectiveNode ) ; } return $ this... | When overridden in a derived class gets the XmlSchemaType for the item . |
229,199 | public function createSession ( ) { if ( ! isset ( $ _SESSION ) ) { if ( PHP_SAPI === 'cli' ) { $ _SESSION = array ( ) ; } elseif ( ! headers_sent ( ) ) { if ( ! session_start ( ) ) { throw new SessionException ( 'session_start failed.' ) ; } } else { throw new SessionException ( 'Session started after headers sent.' )... | Init session parameters and init the class to manage the vars . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.