idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
51,200 | public function getMultiple ( string ... $ keys ) : array { $ ret = [ ] ; foreach ( $ keys as $ key ) { $ ret [ ] = $ this -> get ( $ key ) ; } return $ ret ; } | Get multiple header values |
51,201 | public function getStringifiedArray ( ) : array { $ ret = [ ] ; foreach ( $ this -> headers as $ header => $ value ) { if ( is_array ( $ value ) ) { $ value = implode ( ", " , $ value ) ; } $ ret [ ] = "$header: $value" ; } return $ ret ; } | Retrieve an array of headers as strings |
51,202 | public function map ( $ type , $ transformation ) { if ( ! is_callable ( $ transformation ) ) throw new InvalidTransformationException ( 'Transformations must be callable objects' ) ; foreach ( ( array ) $ type as $ t ) { $ this -> getMatcher ( ) -> rule ( 'type' , $ t , $ transformation ) ; } return $ this ; } | Register a map for the compiler that matches on type |
51,203 | public function post2faRegisterDisplayForm ( Request $ request ) { if ( config ( 'lasallecmsusermanagement.auth_users_registration_front_end_require_terms_of_service' ) ) { if ( ! $ request -> input ( 'terms-of-service' ) ) { return redirect ( ) -> route ( 'auth.register' ) -> withInput ( $ request -> only ( 'name' , '... | The front - end 2FA registration form comes here . |
51,204 | public function findAll ( ) { $ files = array ( ) ; foreach ( new \ DirectoryIterator ( $ this -> path ) as $ file ) { if ( $ file -> isDot ( ) ) { continue ; } $ files [ ] = $ file -> getFilename ( ) ; } sort ( $ files ) ; return $ files ; } | Find all releases |
51,205 | public function tileUrlFunction ( $ text , $ extension = 'png' ) { $ router = $ this -> container -> get ( 'router' ) ; $ url = $ router -> generate ( 'tile' , [ 'text' => $ text , 'extension' => $ extension , ] ) ; return $ url ; } | Creates the QR code URL corresponding to the given message and extension . |
51,206 | public function typeAction ( $ contentDocument , $ _format , Request $ request ) { if ( ! $ contentDocument || ! $ contentDocument instanceof Page ) { throw new NotFoundHttpException ( 'Content not found' ) ; } if ( $ this -> container -> has ( 'profiler' ) ) { $ this -> container -> get ( 'profiler' ) -> disable ( ) ;... | This action is mapped in the controller_by_type map |
51,207 | public function getMessage ( $ type , $ id = null ) { $ result = null ; if ( null === $ id ) { if ( array_key_exists ( $ type , $ this -> messages ) ) { $ result = $ this -> messages [ $ type ] ; if ( ! $ this -> persistMessages ) { unset ( $ this -> messages [ $ type ] ) ; } } } if ( null !== $ id ) { if ( array_key_e... | Retrieve a message |
51,208 | public static function equalWithin ( $ a , $ b , $ delta ) { if ( is_infinite ( $ a ) xor is_infinite ( $ b ) ) { return false ; } if ( is_nan ( $ a ) || is_nan ( $ b ) || is_nan ( $ delta ) ) { return false ; } return abs ( $ a - $ b ) <= $ delta ; } | Are two numbers equal within given delta . |
51,209 | protected function compile ( ) { parent :: compile ( ) ; if ( $ GLOBALS [ 'TL_CONFIG' ] [ 'subcolumns' ] == 'bootstrap_customizable' ) { $ container = ColumnSet :: prepareContainer ( $ this -> columnset_id ) ; if ( $ container ) { $ this -> Template -> column = $ container [ $ this -> sc_sortid ] [ 0 ] . ' col_' . ( $ ... | extends subcolumns compile method for generating dynamically column set |
51,210 | public function getFluidRendererForTemplate ( string $ template , string $ format = 'html' ) { $ configurationManager = $ this -> objectManager -> get ( ConfigurationManagerInterface :: class ) ; $ configuration = $ configurationManager -> getConfiguration ( ConfigurationManagerInterface :: CONFIGURATION_TYPE_FRAMEWORK... | Gets a Fluid renderer for a template . |
51,211 | public function merge ( array $ members ) { foreach ( $ members as $ offset => $ value ) { $ this -> offsetSet ( $ offset , $ value ) ; } return $ this ; } | Merge a array of potential members into the flock replacing as required |
51,212 | public function add ( ) { $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( is_array ( $ arg ) ) { foreach ( $ arg as $ value ) { $ this [ ] = $ value ; } } else { $ this [ ] = $ arg ; } } return $ this ; } | Add items to this flock |
51,213 | public function remove ( $ member ) { if ( false !== $ key = array_search ( $ member , $ this -> members , true ) ) { unset ( $ this -> members [ $ key ] ) ; } return $ this ; } | Remove a member from the flock |
51,214 | private function makeCheckCallback ( $ check ) { if ( is_callable ( $ check ) ) { $ this -> check = $ check ; $ this -> type = $ this -> makeCallbackHumanReadable ( $ check ) ; return ; } if ( is_object ( $ check ) ) { $ class = get_class ( $ check ) ; } elseif ( is_string ( $ check ) ) { $ class = ( string ) $ check ;... | Make check callback for flock |
51,215 | private function makeCallbackHumanReadable ( Callable $ callback ) { if ( is_string ( $ callback ) ) { return $ callback ; } elseif ( is_array ( $ callback ) ) { return sprintf ( "%s::%s" , is_object ( $ callback [ 0 ] ) ? get_class ( $ callback [ 0 ] ) : $ callback [ 0 ] , $ callback [ 1 ] ) ; } elseif ( ! ( $ callbac... | Return a string which is a best human readable representation the callback possible |
51,216 | private function isPathWritable ( ) : bool { if ( ! file_exists ( $ this -> path ) ) { return is_writable ( dirname ( $ this -> path ) ) ; } return is_writable ( $ this -> path ) ; } | Return whether the path is writable . |
51,217 | private function write ( array $ compiled ) : void { $ tmp = tempnam ( sys_get_temp_dir ( ) , 'quanta' ) ; if ( $ tmp !== false ) { file_put_contents ( $ tmp , vsprintf ( '<?php%s%sreturn %s;%s' , [ PHP_EOL , PHP_EOL , Utils :: ArrayStr ( $ compiled ?? [ ] ) , PHP_EOL , ] ) ) ; rename ( $ tmp , $ this -> path ) ; } } | Write the given compiled factories array to a unique temporary file and move it to the compiled file path . |
51,218 | public function compiled ( callable $ callable ) : string { if ( ! $ this -> compiler ) { $ this -> compiler = new Compiler ( new AstAnalyzerAdapter ( new AstAnalyzer ) ) ; } return ( $ this -> compiler ) ( $ callable ) ; } | Return a string representation of the given callable . |
51,219 | public function getContext ( ) { if ( ! $ this -> locked ) { throw new Exception \ LogicException ( 'Context is not yet available. You must first call handleRequest()' ) ; } if ( null === $ this -> context ) { $ this -> context = new Context \ Context ( ) ; $ this -> context -> setVisibleColumns ( array_keys ( $ this -... | Returns the context . |
51,220 | public function sortElements ( ) { $ sort = function ( $ a , $ b ) { $ aPos = $ a -> getConfig ( ) -> getPosition ( ) ; $ bPos = $ b -> getConfig ( ) -> getPosition ( ) ; if ( $ aPos == $ bPos ) { return 0 ; } return $ aPos > $ bPos ? 1 : - 1 ; } ; uasort ( $ this -> columns , $ sort ) ; uasort ( $ this -> filters , $ ... | Sorts the columns and filers . |
51,221 | private function getSelectionMode ( ) { if ( null !== $ mode = $ this -> config -> getSelectionMode ( ) ) { return $ mode ; } if ( $ this -> config -> isBatchable ( ) && ! empty ( $ this -> actions ) ) { return Util \ Config :: SELECTION_MULTIPLE ; } if ( $ this -> config -> isExportable ( ) && $ this -> config -> hasE... | Returns the table s selection mode . |
51,222 | protected function fixTableSource ( $ refTbl ) { $ outS = [ ] ; if ( substr ( $ refTbl , 0 , 1 ) !== '`' ) { $ outS [ ] = '`' ; } $ psT = strpos ( $ refTbl , '.`' ) ; if ( $ psT !== false ) { $ refTbl = substr ( $ refTbl , $ psT + 2 , strlen ( $ refTbl ) - $ psT ) ; } $ outS [ ] = $ refTbl ; if ( substr ( $ refTbl , - ... | Adjust table name with proper sufix and prefix |
51,223 | protected function handleFeatures ( $ fieldName , $ features ) { $ rOly = $ this -> handleFeaturesSingle ( $ fieldName , $ features , 'readonly' ) ; $ rDbld = $ this -> handleFeaturesSingle ( $ fieldName , $ features , 'disabled' ) ; $ rNl = [ ] ; if ( isset ( $ features [ 'include_null' ] ) && in_array ( $ fieldName ,... | Manages features flag |
51,224 | private function handleFeaturesSingle ( $ fieldName , $ features , $ featureKey ) { $ fMap = [ 'readonly' => [ 'readonly' , 'class' , 'input_readonly' ] , 'disabled' => [ 'disabled' ] ] ; $ aReturn = [ ] ; if ( array_key_exists ( $ featureKey , $ features ) ) { if ( array_key_exists ( $ fieldName , $ features [ $ featu... | Handles the features |
51,225 | private function handleMySqlVersionConsistenly ( ) { if ( substr ( $ this -> mySQLconnection -> server_info , - 7 ) === 'MariaDB' ) { $ strVersionParts = explode ( '.' , explode ( '-' , $ this -> mySQLconnection -> server_info ) [ 1 ] ) ; return $ this -> getTwoDecimalsNumber ( $ strVersionParts [ 0 ] ) . $ this -> get... | Ensures a consistent output of version for MySQL as well as MariaDB |
51,226 | protected function setVariableTypeForMySqlStatements ( $ variabaleValue ) { $ sReturn = 'b' ; if ( is_int ( $ variabaleValue ) ) { $ sReturn = 'i' ; } elseif ( is_double ( $ variabaleValue ) ) { $ sReturn = 'd' ; } elseif ( is_string ( $ variabaleValue ) ) { $ sReturn = 's' ; } return $ sReturn ; } | Detects what kind of variable has been transmitted to return the identifier needed by MySQL statement preparing |
51,227 | protected function validateBounds ( ) { $ connection = $ this -> model -> getConnection ( ) ; $ grammar = $ connection -> getQueryGrammar ( ) ; $ tableName = $ this -> model -> getTable ( ) ; $ primaryKeyName = $ this -> model -> getKeyName ( ) ; $ parentColumn = $ this -> model -> getQualifiedParentColumnName ( ) ; $ ... | Validates bounds of the nested tree structure . It will perform checks on the lft rgt and parent_id columns . Mainly that they re not null rights greater than lefts and that they re within the bounds of the parent . |
51,228 | protected function validateDuplicates ( ) { return ( ! $ this -> duplicatesExistForColumn ( $ this -> model -> getQualifiedLeftColumnName ( ) ) && ! $ this -> duplicatesExistForColumn ( $ this -> model -> getQualifiedRightColumnName ( ) ) ) ; } | Checks that there are no duplicates for the lft and rgt columns . |
51,229 | protected function validateRoots ( ) { $ roots = forward_static_call ( [ get_class ( $ this -> model ) , 'roots' ] ) -> get ( ) ; if ( $ this -> model -> isScoped ( ) ) return $ this -> validateRootsByScope ( $ roots ) ; return $ this -> isEachRootValid ( $ roots ) ; } | For each root of the whole nested set tree structure checks that their lft and rgt bounds are properly set . |
51,230 | protected function keyForScope ( $ model ) { return implode ( '-' , array_map ( function ( $ column ) use ( $ model ) { $ value = $ model -> getAttribute ( $ column ) ; if ( is_null ( $ value ) ) return 'NULL' ; return $ value ; } , $ model -> getScopedColumns ( ) ) ) ; } | Builds a single string for the given scope columns values . Useful for making array keys for grouping . |
51,231 | function parse ( ) { $ name_without_parens = preg_replace ( '/[{}]/' , '' , $ this -> full_name ) ; $ parts = explode ( '::' , $ name_without_parens ) ; $ name_without_case_keys = trim ( $ parts [ 0 ] ) ; array_shift ( $ parts ) ; $ this -> case_keys = array_map ( 'trim' , $ parts ) ; $ parts = explode ( ':' , $ name_w... | Parses token name elements |
51,232 | public function contextForLanguage ( $ language , $ opts = array ( ) ) { if ( count ( $ this -> context_keys ) > 0 ) { $ ctx = $ language -> contextByKeyword ( $ this -> context_keys [ 0 ] ) ; } else { $ ctx = $ language -> contextByTokenName ( $ this -> short_name ) ; } return $ ctx ; } | For transform tokens we can only use the first context key if it is not mapped in the context itself . |
51,233 | public static function tokenObject ( $ token_values , $ token_name ) { if ( $ token_values == null ) return null ; if ( ! array_key_exists ( $ token_name , $ token_values ) ) return null ; $ token_object = $ token_values [ $ token_name ] ; if ( is_array ( $ token_object ) ) { if ( \ Tr8n \ Utils \ ArrayUtils :: isHash ... | Returns an object from values hash . |
51,234 | public function tokenValueFromArrayParam ( $ token_data , $ language , $ options = array ( ) ) { if ( count ( $ token_data ) == 0 ) return $ this -> error ( "Invalid number of params of an array" ) ; $ object = $ token_data [ 0 ] ; $ method = count ( $ token_data ) > 1 ? $ token_data [ 1 ] : null ; if ( is_array ( $ ob... | gets the value based on various evaluation methods |
51,235 | public function tokenValue ( $ token_values , $ language , $ options = array ( ) ) { if ( isset ( $ token_values [ $ this -> short_name ] ) ) { $ object = $ token_values [ $ this -> short_name ] ; } else { $ object = Config :: instance ( ) -> defaultToken ( $ this -> short_name , 'data' ) ; } if ( $ object === null ) r... | Returns a value from values hash . |
51,236 | public function substitute ( $ label , $ token_values , $ language , $ options = array ( ) ) { $ token_value = $ this -> tokenValue ( $ token_values , $ language , $ options ) ; return str_replace ( $ this -> full_name , $ token_value , $ label ) ; } | Main substitution function |
51,237 | public static function findFilters ( $ om , array $ filters , $ all = false ) { if ( ! $ om instanceof EntityManagerInterface || ( empty ( $ filters ) && ! $ all ) ) { return [ ] ; } $ all = ( $ all && ! empty ( $ filters ) ) ? false : $ all ; $ enabledFilters = self :: getEnabledFilters ( $ om ) ; return self :: doFin... | Get the list of SQL Filter name must to be disabled . |
51,238 | public static function getEnabledFilters ( $ om ) { $ filters = [ ] ; if ( $ om instanceof EntityManagerInterface ) { $ enabledFilters = $ om -> getFilters ( ) -> getEnabledFilters ( ) ; foreach ( $ enabledFilters as $ name => $ filter ) { if ( ! $ filter instanceof EnableFilterInterface || ( $ filter instanceof Enable... | Get the enabled sql filters . |
51,239 | public static function isEnabled ( $ om , $ name ) { if ( $ om instanceof EntityManagerInterface ) { $ sqlFilters = $ om -> getFilters ( ) ; if ( $ sqlFilters -> isEnabled ( $ name ) ) { $ filter = $ sqlFilters -> getFilter ( $ name ) ; return ! $ filter instanceof EnableFilterInterface || ( $ filter instanceof EnableF... | Check if the filter is enabled . |
51,240 | protected static function doFindFilters ( array $ filters , array $ enabledFilters , $ all ) { $ reactivateFilters = [ ] ; foreach ( $ enabledFilters as $ name => $ filter ) { if ( \ in_array ( $ name , $ filters , true ) || $ all ) { $ reactivateFilters [ ] = $ name ; } } return $ reactivateFilters ; } | Do find filters . |
51,241 | public function setFileFormats ( array $ formats ) { $ this -> file_formats = array ( ) ; foreach ( $ formats as $ mime => $ writer ) $ this -> addFileFormat ( $ mime , $ writer ) ; return $ this ; } | Set the available file formats - replacing the previous list |
51,242 | public function forceMimeType ( string $ mime ) { if ( ! isset ( $ this -> file_formats [ $ mime ] ) ) { throw new \ InvalidArgumentException ( "Cannot force output without a writer available: " . $ mime ) ; } $ this -> file_formats = [ $ mime => $ this -> file_formats [ $ mime ] ] ; return $ this ; } | Reduce the list of available file formats to a single one |
51,243 | public function addFileFormat ( string $ mime_type , $ writer_class ) { if ( is_string ( $ writer_class ) ) { if ( ! class_exists ( $ writer_class ) || ! ( is_subclass_of ( $ writer_class , AbstractWriter :: class , $ writer_class ) ) ) { throw new InvalidArgumentException ( "Class {$writer_class} does not exist or doe... | Add a file format that this writer can output . This can be used to add a custom mime - type - > writer mapping . If the format is already registered it is overwritten . |
51,244 | public function output ( string $ mime ) { $ pprint = $ this -> pretty_printing ; $ classname = $ this -> file_formats [ $ mime ] ?? "NullWriter" ; $ output = "" ; try { if ( $ classname instanceof AbstractWriter ) $ writer = $ classname ; elseif ( class_exists ( $ classname ) ) $ writer = new $ classname ( $ pprint ) ... | Output the response data in the selected format |
51,245 | public function findOrFail ( $ id ) { if ( $ model = $ this -> find ( $ id ) ) { return $ model ; } throw ( new ModelNotFoundException ) -> setModel ( get_class ( $ this -> getModel ( ) ) ) ; } | Find and throw an exception if model not found |
51,246 | public function render ( array $ vars = array ( ) ) { $ templateFile = $ this -> getTemplateRouter ( ) -> findTemplateFile ( $ this -> getRequest ( ) ) ; if ( $ templateFile ) { return $ this -> getAppController ( ) -> render ( $ templateFile , $ vars ) ; } return $ this -> getAppController ( ) -> error404 ( ) ; } | renders the template associated with the current route . |
51,247 | public function redirect ( array $ flashes = array ( ) ) { foreach ( $ flashes as $ type => $ message ) { $ this -> getAppController ( ) -> flash ( ) -> add ( $ type , $ message ) ; } return $ this -> getAppController ( ) -> redirect ( $ this -> getRequest ( ) -> getRequestUri ( ) ) ; } | redirects to the same same uri . |
51,248 | public function setStatusCode ( $ statusCode ) { $ statusCode = ( int ) $ statusCode ; if ( $ statusCode < 100 || $ statusCode >= 600 ) { throw new \ Exception ( "Invalid status code: {$statusCode}." ) ; } $ this -> statusCode = $ statusCode ; return $ this ; } | Sets the status code . |
51,249 | protected function getStatusMessage ( $ code ) { return ( isset ( $ this -> statusMessages [ $ code ] ) ? $ this -> statusMessages [ $ code ] : $ this -> statusMessages [ 500 ] ) ; } | Gets the HTTP status message for a status code . |
51,250 | public function removeHypertextRoute ( $ name ) { if ( isset ( $ this -> hypertextRoutes [ $ name ] ) ) { unset ( $ this -> hypertextRoutes [ $ name ] ) ; } return $ this ; } | Removes a hypertext route by name . |
51,251 | public function output ( $ isFinal = false ) { if ( $ this -> finalOutput ) { return ; } $ this -> finalOutput = $ isFinal ; header ( "HTTP/1.1 {$this->statusCode} {$this->getStatusMessage($this->statusCode)}" ) ; header ( "Cache-Control: no-cache, must-revalidate" ) ; header ( "Expires: 0" ) ; $ this -> hypertextRoute... | Outputs the current response in the correct response type and sets the headers . |
51,252 | public function process ( ) { if ( $ this -> configuration -> getUseAuthorization ( ) ) { if ( $ this -> uri != '/token' && $ this -> uri != '/authorize' && ! $ this -> tokenServer -> verifyResourceRequest ( \ OAuth2 \ Request :: createFromGlobals ( ) ) ) { $ data = $ this -> tokenServer -> getResponse ( ) -> getRespon... | Processes the API by calling the execute method on the router . |
51,253 | public function handleOptionsRequest ( ) { $ allow = '' ; foreach ( $ this -> router -> getMethodsByRoute ( $ this -> uri ) as $ method ) { $ allow .= strtoupper ( $ method ) . ',' ; } $ allow = substr ( $ allow , 0 , strlen ( $ allow ) - 1 ) ; header ( 'Allow: ' . $ allow ) ; $ this -> setResponse ( '' ) ; } | Handles an HTTP OPTIONS requests . Returns available methods for the current route . |
51,254 | protected function addRoutes ( ) { $ this -> router -> add ( '/' , [ $ this , 'unknownEndpoint' ] ) ; if ( $ this -> configuration -> getUseAuthorization ( ) ) { $ this -> router -> add ( '/token' , [ $ this , 'token' ] ) ; if ( $ this -> configuration -> getAuthorizationMode ( ) >= 2 ) { $ this -> router -> add ( '/au... | Adds default routes for the API regarding tokens . These routes can be overridden in the child API class . |
51,255 | private function createTokenServer ( ) { try { $ storage = new \ OAuth2 \ Storage \ Pdo ( [ 'dsn' => $ this -> configuration -> getDsn ( ) , 'username' => $ this -> configuration -> getUsername ( ) , 'password' => $ this -> configuration -> getPassword ( ) , ] ) ; $ server = new \ OAuth2 \ Server ( $ storage ) ; if ( $... | Creates the new token server . Sets the connection to the database and grant types . |
51,256 | public function token ( ) { $ response = $ this -> tokenServer -> handleTokenRequest ( \ OAuth2 \ Request :: createFromGlobals ( ) ) ; $ data = $ response -> getResponseBody ( 'json' ) ; $ data = json_decode ( $ data , true ) ; $ this -> response = $ data ; $ this -> statusCode = $ response -> getStatusCode ( ) ; $ thi... | Handles generating tokens for clients . |
51,257 | public function authorize ( ) { $ request = \ OAuth2 \ Request :: createFromGlobals ( ) ; $ response = new \ OAuth2 \ Response ( ) ; if ( ! $ this -> tokenServer -> validateAuthorizeRequest ( $ request , $ response ) ) { $ data = $ response -> getResponseBody ( 'json' ) ; $ data = json_decode ( $ data , true ) ; $ this... | Handles authorizing clients to receive an OAuth2 access token . |
51,258 | protected function secondsRemainingOnLockout ( Request $ request ) { return UniversalBuilder :: resolveClass ( RateLimiter :: class ) -> availableIn ( $ this -> getThrottleKey ( $ request ) ) ; } | Get the lockout seconds . |
51,259 | public function getShortcodes ( ) { $ shortcodes = array_map ( function ( $ replacement ) { return "[{$replacement}]" ; } , $ this -> replacements ) ; return collect ( array_combine ( $ shortcodes , $ this -> replacements ) ) ; } | Get the replacements shortcodes . |
51,260 | protected function mergeReplacements ( array $ replacements ) { return $ this -> getShortcodes ( ) -> transform ( function ( $ key ) use ( $ replacements ) { return Arr :: get ( $ replacements , $ key ) ; } ) -> filter ( ) ; } | Merge replacements . |
51,261 | public function highlight ( $ content , $ replacement = '<code>[\1]</code>' ) { return preg_replace ( '/\[(' . $ this -> getShortcodes ( ) -> values ( ) -> implode ( '|' ) . ')\]/' , $ replacement , $ content ) ; } | Highlight the replacement . |
51,262 | protected function processResponseType ( $ response = null ) { if ( $ response instanceof Response ) { $ this -> response = $ response ; } elseif ( is_string ( $ response ) || is_numeric ( $ response ) ) { $ this -> response -> setContent ( $ response ) ; } elseif ( is_array ( $ response ) ) { $ this -> response = new ... | Process the Response Type . |
51,263 | public function offsetSet ( $ offset , $ segment ) { if ( is_null ( $ offset ) ) { $ this -> segments [ ] = ( string ) $ segment ; } else { $ this -> segments [ $ offset ] = ( string ) $ segment ; } } | Set the segment at a given offset . |
51,264 | public static function implode ( $ segments , $ separator = self :: SEPARATOR ) { return ( string ) Uzi :: join ( $ separator , $ segments , true ) ; } | Join the segments of a key into a string |
51,265 | public function getRelationManager ( EntityContract $ entity ) { $ key = $ entity -> { $ this -> getRelationKey ( ) } ; if ( ! isset ( $ this -> relations [ $ key ] ) ) { return null ; } $ class = $ this -> relations [ $ key ] ; return new $ class ( $ this -> getManager ( ) -> getAgent ( ) ) ; } | Retrieve relation manager . |
51,266 | public function addHook ( Hook $ hook ) { if ( isset ( $ this -> hooks [ $ hook -> name ] ) === false ) { $ this -> logger -> debug ( "Adding definition for hook '{$hook->name}' for the first time." ) ; $ this -> hooks [ $ hook -> name ] = [ ] ; } $ this -> hooks [ $ hook -> name ] [ ] = $ hook -> definition ; } | Add hook definition to container |
51,267 | public function exec ( string $ name ) { if ( isset ( $ this -> hooks [ $ name ] ) === false ) { $ this -> logger -> debug ( "No hook definitions found for '{$name}'. Available hook " . "definitions" , [ array_keys ( $ this -> hooks ) ] ) ; return null ; } $ return = [ ] ; $ params = array_merge ( $ this -> params , ar... | Execute hook definition |
51,268 | public function createAndBindForm ( Request $ request , $ type , $ data = null , array $ options = array ( ) ) { $ form = $ this -> createForm ( $ type , $ data , $ options ) ; $ form -> submit ( $ request ) ; return $ form ; } | Creates binds and returns a Form instance from the type of the form . |
51,269 | protected function renderAttribute ( $ attribute , $ index ) { if ( is_string ( $ this -> template ) ) { return strtr ( $ this -> template , [ '{label}' => $ attribute [ 'label' ] , '{value}' => $ this -> formatter -> format ( $ attribute [ 'value' ] , $ attribute [ 'format' ] ) , ] ) ; } else { return call_user_func (... | Renders a single attribute . |
51,270 | protected function normalizeAttributes ( ) { if ( $ this -> attributes === null ) { if ( $ this -> model instanceof Model ) { $ this -> attributes = $ this -> model -> attributes ( ) ; } elseif ( is_object ( $ this -> model ) ) { $ this -> attributes = $ this -> model instanceof Arrayable ? $ this -> model -> toArray (... | Normalizes the attribute specifications . |
51,271 | public function getUserBySlug ( $ slug ) { $ return = array ( ) ; $ users = $ this -> repository -> users ; foreach ( $ users as $ user ) { if ( $ user -> slug == $ slug ) { $ return = $ user ; break ; } } return $ return ; } | Get user by slug |
51,272 | public function deleteUserBySlug ( $ slug ) { $ userToDelete = $ this -> getUserBySlug ( $ slug ) ; if ( empty ( $ userToDelete ) ) { throw new \ Exception ( 'Trying to delete a user that doesn\'t exist.' ) ; } $ users = $ this -> getUsers ( ) ; foreach ( $ users as $ key => $ user ) { if ( $ user -> slug == $ userToDe... | Delete user by slug |
51,273 | private function buildPathFromSource ( string $ path ) : string { return str_replace ( '.' , '/' , str_replace ( $ this -> context . "." , '' , $ this -> viewNameFromSource ( $ path ) ) ) . $ this -> buildExtension ; } | start with the build path strip context from view name including first . replace remaining dots in view name with slashes add build extension |
51,274 | public function agent ( $ arg = null ) { $ agent = new Agent ( ) ; if ( $ arg ) { return $ agent -> is ( $ arg ) ; } return new Agent ( ) ; } | Start Jenssegers Agent |
51,275 | public function authRequest ( $ guard = null ) { return is_null ( $ guard ) ? request ( ) -> user ( ) ?? request ( ) -> user ( 'api' ) : request ( ) -> user ( $ guard ) ; } | Get auth request by guard |
51,276 | public function randomNumbers ( $ length = 6 ) { $ nums = '0123456789' ; $ out = $ nums [ mt_rand ( 1 , strlen ( $ nums ) - 1 ) ] ; for ( $ p = 0 ; $ p < $ length - 1 ; $ p ++ ) { $ out .= $ nums [ mt_rand ( 0 , strlen ( $ nums ) - 1 ) ] ; } return $ out ; } | Generate random numbers |
51,277 | public function fileSearch ( $ file , $ subject ) { return str_contains ( file_get_contents ( str_contains ( $ file , '/' ) ? $ file : $ file ) , $ subject ) ; } | Search for a content within a file |
51,278 | public function fileEdit ( $ file , $ search , $ replace ) { file_put_contents ( $ file , str_replace ( $ search , $ replace , file_get_contents ( $ file ) ) ) ; } | Edit part of the contents of a file |
51,279 | public function rangeHours ( $ start , $ end , $ interval = 1 , $ select = true ) { $ tStart = strtotime ( $ start ) ; $ tEnd = strtotime ( $ end ) ; $ tNow = $ tStart ; $ hours = [ ] ; while ( $ tNow <= $ tEnd ) { $ hours [ ] = date ( "H:i" , $ tNow ) ; $ tNow = strtotime ( '+' . $ interval . ' hour' , $ tNow ) ; } if... | Interval between two hours |
51,280 | public function limtitLines ( $ str , $ lines = 1 ) { $ line = "\n" ; for ( $ i = 2 ; $ i <= $ lines ; $ i ++ ) { $ line .= "\n" ; } return preg_replace ( "/[\r\n]+/" , "$line" , $ str ) ; } | Limits the amount of line breaks in a string |
51,281 | public function urlParser ( $ str , $ rule ) { $ linkify = new Linkify ( [ 'callback' => function ( $ url , $ caption , $ isEmail ) use ( $ rule ) { $ rule = str_replace ( '[url]' , $ url , $ rule ) ; $ rule = str_replace ( '[caption]' , $ caption , $ rule ) ; return $ rule ; } ] ) ; return $ linkify -> process ( $ str... | Parse URLs from string |
51,282 | public function urlParserMultiple ( $ str , $ rule , $ html = null ) { $ explode = explode ( ';' , $ str ) ; $ url = collect ( $ explode ) -> map ( function ( $ item ) use ( $ rule ) { return $ this -> urlParser ( $ item , $ rule ) ; } ) ; if ( is_null ( $ html ) ) { $ url = $ url -> all ( ) ; } else { $ url = $ url ->... | Parse multiple URLs from string separated by commas or semicolons |
51,283 | public function countries ( $ by = null , $ value = null ) { $ countries = json_decode ( file_get_contents ( __DIR__ . '/../../data/countries.json' ) , true ) ; if ( is_null ( $ by ) && is_null ( $ value ) ) { $ countries = collect ( $ countries ) -> values ( ) -> all ( ) ; } else { if ( $ by == 'locale' ) { $ value = ... | Countries search and list |
51,284 | public function countryCodeByLocale ( $ locale ) { if ( str_contains ( $ locale , ' ' ) ) { $ locale = str_replace ( ' ' , '-' , $ locale ) ; } if ( strlen ( $ locale ) == 2 ) { if ( $ locale == 'en' ) { $ locale = 'en-US' ; } else { $ locale = $ locale . '-' . strtoupper ( $ locale ) ; } } return Locale :: getRegion (... | Get Country code by Locale |
51,285 | public function extractHashtags ( $ str , $ type = 'arr' ) { preg_match_all ( "/(#\w+)/" , $ str , $ matches ) ; $ matches = $ type == 'arr' ? $ matches [ 0 ] : implode ( ', ' , $ matches [ 0 ] ) ; return $ matches ; } | Extract hashtags from strings |
51,286 | public function summaryNumbers ( $ number ) { $ x = round ( $ number ) ; $ x_number_format = number_format ( $ x ) ; $ x_array = explode ( ',' , $ x_number_format ) ; $ x_parts = [ 'k' , 'm' , 'b' , 't' ] ; $ x_count_parts = count ( $ x_array ) - 1 ; $ x_display = $ x ; if ( ! isset ( $ x_array [ 1 ] ) ) { return $ x_a... | Format numbers in instagram followers style |
51,287 | public function urlWithParams ( $ path = null , $ qs = [ ] , $ secure = null ) { $ url = app ( 'url' ) -> to ( $ path , $ secure ) ; if ( count ( $ qs ) ) { foreach ( $ qs as $ key => $ value ) { $ qs [ $ key ] = sprintf ( '%s=%s' , $ key , urlencode ( $ value ) ) ; } $ url = sprintf ( '%s?%s' , $ url , implode ( '&' ,... | Laravel route with query strings |
51,288 | public function getRoutesName ( $ contains = null , $ exact = true ) { $ routeCollection = \ Route :: getRoutes ( ) ; $ routes = collect ( $ routeCollection ) -> map ( function ( $ item ) { return $ item -> getName ( ) ; } ) -> filter ( function ( $ item ) { return ! is_null ( $ item ) ; } ) -> values ( ) ; if ( $ cont... | Get all routes name |
51,289 | public function getAllKeysRoutes ( ) { $ routeCollection = \ Route :: getRoutes ( ) ; $ routes = collect ( $ routeCollection ) -> map ( function ( $ item ) { return explode ( '/' , $ item -> getPrefix ( ) ) ; } ) -> values ( ) -> collapse ( ) -> filter ( function ( $ item , $ key ) { return $ item !== '' ; } ) -> group... | Get all keys of routes |
51,290 | public function getScheduledJobs ( ) { $ jobs = [ ] ; foreach ( $ this -> jobs as $ job ) { $ model = CronJob :: find ( $ job [ 'id' ] ) ; if ( ! $ model ) { $ model = new CronJob ( ) ; $ model -> id = $ job [ 'id' ] ; $ model -> save ( ) ; } $ params = new DateParameters ( $ job ) ; $ date = new CronDate ( $ params , ... | Gets all of the jobs scheduled to run now . |
51,291 | public function runScheduled ( OutputInterface $ output ) { $ success = true ; $ event = new ScheduleRunBeginEvent ( ) ; $ this -> dispatcher -> dispatch ( $ event :: NAME , $ event ) ; foreach ( $ this -> getScheduledJobs ( ) as $ jobInfo ) { $ job = $ jobInfo [ 'model' ] ; $ run = $ this -> runJob ( $ job , $ jobInfo... | Runs any scheduled tasks . |
51,292 | public function add ( ModelObject $ obj ) { $ obj -> CreationDate = $ this -> DateFactory -> newStorageDate ( ) ; if ( ! $ obj -> hasModifiedDate ( ) ) $ obj -> ModifiedDate = $ this -> DateFactory -> newStorageDate ( ) ; $ this -> validator -> validateFor ( __FUNCTION__ , $ obj ) -> throwOnError ( ) ; return $ this ->... | Performs an INSERT for the given ModelObject through our DAO . CreationDate and ModifiedDate are set and the validator is run |
51,293 | public function edit ( ModelObject $ obj ) { if ( ! $ obj -> hasModifiedDate ( ) ) $ obj -> ModifiedDate = $ this -> DateFactory -> newStorageDate ( ) ; $ this -> validator -> validateFor ( __FUNCTION__ , $ obj ) -> throwOnError ( ) ; return $ this -> dao -> edit ( $ obj ) ; } | Performs an UPDATE for the given ModelObject through our DAO . ModifiedDate is updated and the validator is run . |
51,294 | public function delete ( $ objSlug ) { $ this -> validator -> validateFor ( __FUNCTION__ , $ objSlug ) -> throwOnError ( ) ; return $ this -> dao -> delete ( $ objSlug ) ; } | Performs a DELETE for the given slug through our DAO . The validator is run . |
51,295 | public function getSerializationType ( ) { switch ( $ this -> association ) { case self :: ASSOCIATION_TYPE_EMBED_ONE : case self :: ASSOCIATION_TYPE_EMBED_MANY : return TypeFactory :: getType ( Type :: MAP ) ; case self :: ASSOCIATION_TYPE_REFERENCE_ONE : case self :: ASSOCIATION_TYPE_REFERENCE_MANY : return $ this ->... | Return the Type used to serialize individual association values . |
51,296 | private function makeReflection ( ) { if ( $ this -> reflection === null ) { $ this -> reflection = new \ ReflectionProperty ( $ this -> className , $ this -> name ) ; $ this -> reflection -> setAccessible ( true ) ; } } | Retrieve and store reflection metadata for this property from php internals . |
51,297 | public function mapAttribute ( ClassMetadata $ class ) { $ this -> applyDefaults ( ) ; $ this -> validate ( ) ; $ this -> makeGenerator ( ) ; $ class -> addAttributeMapping ( $ this ) ; } | Map this property as an attribute . |
51,298 | public function mapManyEmbedded ( ClassMetadata $ class , $ type = Type :: LIST_ ) { $ this -> embedded = true ; $ this -> type = $ type ; $ this -> mapAttribute ( $ class ) ; } | Map this property as a collection of embedded documents . |
51,299 | public function mapManyReference ( ClassMetadata $ class , $ type = Type :: LIST_ ) { $ this -> reference = true ; $ this -> type = $ type ; $ this -> mapAttribute ( $ class ) ; } | Map this property as a collection of document references . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.