idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
13,400 | protected function messageToString ( $ level , $ message , array $ context ) { if ( ! empty ( $ context ) ) { $ message .= ' ' . json_encode ( $ context , JSON_UNESCAPED_UNICODE | JSON_PARTIAL_OUTPUT_ON_ERROR ) ; } return $ message ; } | Converts a log message and its context to a string . |
13,401 | public function handle ( Request $ request , $ redirect = null ) { if ( \ is_user_logged_in ( ) === true ) { return true ; } if ( $ redirect === 'login' ) { Response :: redirect_to_login ( ) ; } if ( $ redirect === 'admin' ) { Response :: redirect_to_admin ( ) ; } if ( $ redirect !== null ) { Response :: redirect ( $ r... | Check if the current user is logged in and perform the redirect if not . |
13,402 | public function boot ( ) { $ this -> enable_thumbnail_support ( ) ; $ this -> register_image_sizes ( ) ; if ( Config :: get ( 'images.reset_image_sizes' ) !== false ) { $ this -> add_filter ( 'intermediate_image_sizes_advanced' , 'remove_default_image_sizes' ) ; $ this -> add_filter ( 'intermediate_image_sizes_advanced... | Register class conditional filters . |
13,403 | public function placeholder_image_fallback ( $ html , $ post_id , $ post_thumbnail_id , $ size , $ attr ) { if ( $ html === '' && Config :: get ( 'images.placeholder_dir' ) !== false ) { $ html = $ this -> image_service -> get_placeholder_image ( $ post_id , $ post_thumbnail_id , $ size , $ attr ) ; } return $ html ; } | If no post_thumbnail was found find the corresponding placeholder image and return the image HTML . |
13,404 | public function enable_custom_image_sizes ( $ sizes ) { $ sizes = \ array_merge ( $ sizes , $ this -> size_dropdown_names ) ; unset ( $ sizes [ 'full' ] ) ; unset ( $ sizes [ 'thumbnail' ] ) ; if ( Config :: get ( 'images.insert_image_allow_full_size' ) || empty ( $ sizes ) ) { $ sizes [ 'full' ] = 'Full Size' ; } retu... | Adds any extra sizes to add media sizes dropdown . |
13,405 | public function remove_default_image_sizes ( $ sizes = [ ] ) { $ user_sizes_to_remove = \ collect ( Config :: get ( 'images.image_sizes' ) ) -> filter ( function ( $ value ) { return $ value === false ; } ) -> all ( ) ; $ user_sizes_to_remove = \ array_keys ( $ user_sizes_to_remove ) ; $ sizes_to_remove = \ array_merge... | Removes all built in image sizes leaving only full and thumbnail . |
13,406 | public function remove_custom_image_sizes ( $ sizes = [ ] ) { if ( Config :: get ( 'images.dynamic_image_sizes' ) !== false ) { return \ array_diff_key ( $ sizes , self :: $ dynamic_sizes ) ; } return $ sizes ; } | Removes all custom image sizes that do not have dropdown names . |
13,407 | private function set_dynamic_sizes ( ) { foreach ( Config :: get ( 'images.image_sizes' ) as $ size => $ data ) { if ( ! isset ( $ data [ 3 ] ) || ! $ data [ 3 ] ) { self :: $ dynamic_sizes [ $ size ] = true ; } } if ( ! empty ( Config :: get ( 'images.dynamic_image_sizes' ) ) ) { foreach ( Config :: get ( 'images.dyna... | Set the dynamic_sizes array . |
13,408 | private function enable_thumbnail_support ( ) { $ enabled_thumbnails = Config :: get ( 'images.supports_featured_images' ) ; if ( ! empty ( $ enabled_thumbnails ) ) { if ( \ is_array ( $ enabled_thumbnails ) ) { \ add_theme_support ( 'post-thumbnails' , $ enabled_thumbnails ) ; } elseif ( $ enabled_thumbnails === true ... | Enabled theme support for thumbnails . |
13,409 | private function register_image_sizes ( ) { if ( empty ( Config :: get ( 'images.image_sizes' ) ) && empty ( Config :: get ( 'images.dynamic_image_sizes' ) ) ) { return ; } $ sizes = Config :: get ( 'images.image_sizes' ) ; if ( ! empty ( Config :: get ( 'images.dynamic_image_sizes' ) ) ) { $ sizes = \ array_merge ( $ ... | Registers image sizes . |
13,410 | public function prepareRouter ( ) { $ router = new Router ( ) ; if ( $ this -> logger ) { $ router -> setLogger ( $ this -> logger ) ; } $ router -> addMatcher ( $ this -> buildDefaultMatcher ( ) ) ; if ( $ this -> hasRoutingTemplates ( ) ) { $ router -> addMatcher ( $ this -> buildTemplateMatcher ( ) ) ; } if ( $ this... | prepareRouter Build the route matchers and router . |
13,411 | protected function buildSymfonyMatcher ( ) { if ( ! $ this -> locator ) { throw new \ InvalidArgumentException ( 'Unable to build Symfony matcher without config locator.' ) ; } $ yaml_loader = new YamlFileLoader ( $ this -> locator ) ; $ routes = $ yaml_loader -> load ( $ this -> getRoutingFilename ( ) ) ; $ matcher = ... | buildSymfonyMatcher Build a Symfony matcher for matching yaml configured routes . |
13,412 | protected function hasRoutingConfig ( ) { $ has_config = false ; if ( $ this -> locator ) { try { $ routing_file = $ this -> locator -> locate ( $ this -> getRoutingFilename ( ) ) ; if ( filesize ( $ routing_file ) > 0 ) { $ this -> debug ( sprintf ( 'hasRoutingConfig: Located Routing File %s' , $ routing_file ) ) ; $ ... | hasRoutingConfig Check if the routing file exists and needs to be parsed . |
13,413 | public function setActive ( ) { if ( ! $ this -> _active ) { $ this -> addClass ( self :: CLASS_ACTIVE ) ; $ this -> _active = true ; } return $ this ; } | Set the element active |
13,414 | public function setInactive ( ) { if ( $ this -> _active ) { $ this -> removeClass ( self :: CLASS_ACTIVE ) ; $ this -> _active = false ; } return $ this ; } | Set the element inactive |
13,415 | public function render ( $ html = null ) { $ link = $ this -> getAnchor ( ) -> render ( ) ; if ( $ html !== null ) { $ link .= $ this -> getSeparator ( ) ; $ link .= $ html ; } return parent :: render ( $ link ) ; } | Render the navigation element |
13,416 | private function filterDiffs ( $ compRes ) { $ result = [ ] ; if ( is_array ( $ this -> config [ 'updateTypes' ] ) ) { $ updateActions = $ this -> config [ 'updateTypes' ] ; } else { $ updateActions = array_map ( 'trim' , explode ( ',' , $ this -> config [ 'updateTypes' ] ) ) ; } $ allowedActions = [ 'create' , 'drop' ... | Filters comparison result and lefts only sync actions allowed by updateTypes option |
13,417 | private function compare ( $ source , $ destination ) { $ this -> source_structure = $ source ; $ this -> destination_structure = $ destination ; $ result = [ ] ; $ destTabNames = $ this -> getTableList ( $ this -> destination_structure ) ; $ sourceTabNames = $ this -> getTableList ( $ this -> source_structure ) ; $ co... | Makes comparison of the given database structures support some options |
13,418 | private function getTableList ( $ structure ) { $ result = [ ] ; if ( preg_match_all ( '/CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?(?:`?(\w+)`?\.)?`?(\w+)`?/i' , $ structure , $ m ) ) { foreach ( $ m [ 2 ] as $ match ) { $ result [ ] = $ match ; } } return $ result ; } | Retrieves list of table names from the database structure dump |
13,419 | private function getTabSql ( $ struct , $ tab , $ removeDatabase = true ) { $ result = '' ; $ database = '' ; $ tableDef = '' ; if ( preg_match ( '/(CREATE(?:\s*TEMPORARY)?\s*TABLE\s*(?:IF NOT EXISTS\s*)?)(?:`?(\w+)`?\.)?(`?(' . $ tab . ')`?(\W|$))/i' , $ struct , $ m , PREG_OFFSET_CAPTURE ) ) { $ tableDef = $ m [ 0 ] ... | Retrieves table structure definition from the database structure dump |
13,420 | private function splitTabSql ( $ sql ) { $ result = [ ] ; $ openBracketPos = $ this -> getDelimiterPos ( $ sql , 0 , '(' ) ; if ( $ openBracketPos === false ) { trigger_error ( '[WARNING] can not find opening bracket in table definition' ) ; return false ; } $ prefix = substr ( $ sql , 0 , $ openBracketPos + 1 ) ; $ re... | Splits table sql into indexed array |
13,421 | private function compareSql ( $ sourceSql , $ destinationSql ) { $ result = [ ] ; $ sourceParts = $ this -> splitTabSql ( $ sourceSql ) ; if ( $ sourceParts === false ) { trigger_error ( '[WARNING] error parsing source sql' ) ; return false ; } $ destinationParts = $ this -> splitTabSql ( $ destinationSql ) ; if ( $ de... | returns array of fields or keys definitions that differs in the given tables structure |
13,422 | private function processLine ( $ line ) { $ options = $ this -> config ; $ result = [ 'key' => '' , 'line' => '' ] ; $ line = rtrim ( trim ( $ line ) , ',' ) ; if ( preg_match ( '/^(CREATE\s+TABLE)|(\) ENGINE=)/i' , $ line ) ) { return false ; } if ( preg_match ( '/^(PRIMARY\s+KEY)|(((UNIQUE\s+)|(FULLTEXT\s+))?KEY\s+`?... | Transforms table structure definition line into key = > value pair where the key is a string that uniquely defines field or key described |
13,423 | private function getActionSql ( $ action , $ tab , $ sql ) { $ result = 'ALTER TABLE `' . $ tab . '` ' ; $ action = strtolower ( $ action ) ; $ keyField = '`?\w`?(?:\(\d+\))?' ; $ keyFieldList = '(?:' . $ keyField . '(?:,\s?)?)+' ; if ( preg_match ( '/((?:PRIMARY )|(?:UNIQUE )|(?:FULLTEXT ))?KEY `?(\w+)?`?\s(\(' . $ ke... | Compiles update sql |
13,424 | private function getDelimiterPos ( $ string , $ offset = 0 , $ delimiter = ';' , $ skipInBrackets = false ) { $ stack = [ ] ; $ rbs = '\\\\' ; $ regPrefix = "(?<!$rbs)(?:$rbs{2})*" ; $ reg = $ regPrefix . '("|\')|(/\\*)|(\\*/)|(-- )|(\r\n|\r|\n)|' ; if ( $ skipInBrackets ) { $ reg .= '(\(|\))|' ; } else { $ reg .= '()'... | Searches for the position of the next delimiter which is not inside string literal like this ; or like this ; . |
13,425 | private function getDelimiterRightPosition ( $ string , $ offset = 0 , $ delimiter = ';' , $ skipInBrackets = false ) { $ pos = $ this -> getDelimiterPos ( $ string , $ offset , $ delimiter , $ skipInBrackets ) ; if ( $ pos === false ) { return false ; } do { $ newPos = $ this -> getDelimiterPos ( $ string , $ pos + 1 ... | works the same as getDelimiterPos except returns position of the first occurrence of the delimiter starting from the end of the string |
13,426 | public function register ( ) { $ this -> bindGuzzle ( ) ; $ this -> bindAuth ( ) ; $ this -> bindHttpClient ( ) ; $ this -> bindApiClient ( ) ; $ this -> bindTaxonomyMapper ( ) ; } | Bind Repository interfaces to their appropriate implementations . |
13,427 | public function bindHttpClient ( ) { $ this -> app -> bind ( HttpClient :: class , function ( Application $ app ) { $ client = $ app -> make ( 'ej:sdk:guzzle' ) ; $ auth = $ app -> make ( Authentication \ Authenticator :: class ) ; return new HttpClient ( $ client , $ auth ) ; } ) ; } | Bind http client |
13,428 | private function recursiveSort ( array & $ element ) { foreach ( $ element as & $ value ) { if ( is_array ( $ value ) ) { $ this -> recursiveSort ( $ value ) ; } } uasort ( $ element , function ( Translation $ a , Translation $ b ) { return strcmp ( $ a -> getKey ( ) , $ b -> getKey ( ) ) ; } ) ; } | Sort array level . |
13,429 | private function createInstance ( ) { if ( $ this -> arguments === null ) { $ this -> arguments = [ ] ; if ( null !== ( $ method = $ this -> getReflection ( ) -> getConstructor ( ) ) ) { $ this -> arguments = $ this -> getArguments ( $ method ) ; } } return $ this -> getReflection ( ) -> newInstanceArgs ( $ this -> arg... | Create new object and inject constructor dependencies |
13,430 | private function getArguments ( \ ReflectionMethod $ method ) { $ arguments = [ ] ; foreach ( $ method -> getParameters ( ) as $ index => $ parameter ) { $ argument = $ this -> getArgument ( $ index , $ parameter ) ; if ( null === $ argument && false === $ parameter -> allowsNull ( ) ) { throw new Exception ( sprintf (... | Resolve all required constructor arguments |
13,431 | protected function shouldCatch ( \ Exception $ e ) { foreach ( $ this -> exceptionClasses as $ exceptionClass ) { if ( is_a ( $ e , $ exceptionClass , true ) ) { return true ; } } return false ; } | Returns true if the exception is an instance of the exceptions we are catching . |
13,432 | protected function refinePath ( $ path ) { $ path = str_replace ( array ( '/' , "\\" ) , DIRECTORY_SEPARATOR , $ path ) ; list ( $ path ) = explode ( '?' , $ path ) ; return $ path ; } | Correct the directory separator |
13,433 | public function css ( $ filename ) { $ ds = DIRECTORY_SEPARATOR ; $ filename = ( isset ( $ this -> assetPaths [ 'css' ] ) ? $ this -> assetPaths [ 'css' ] . '/' : '' ) . $ filename ; $ filepath = $ this -> refinePath ( $ this -> basePath . $ ds . $ filename ) ; return new Asset ( $ this -> urlFactory , 'css' , $ filepa... | Instantiate a css asset |
13,434 | public function setClosed ( $ flag = true ) { $ this -> _closed = ( bool ) $ flag ; $ this -> _tagCached = null ; return $ this ; } | Set the tag is closed or not |
13,435 | public function setAttrs ( array $ attrs ) { foreach ( $ attrs as $ attr => $ value ) { $ this -> setAttr ( $ attr , $ value ) ; } return $ this ; } | Set the tag s attributes |
13,436 | public function setAttr ( $ attr , $ value ) { $ this -> _attrs [ $ attr ] = trim ( $ value ) ; $ this -> _tagCached = null ; return $ this ; } | Set the tag s attribute |
13,437 | public function addClass ( $ class ) { $ class = trim ( $ class ) ; if ( strpos ( $ class , ' ' ) !== false ) { $ this -> addClasses ( explode ( ' ' , $ class ) ) ; return $ this ; } $ this -> _classes [ $ class ] = $ class ; $ this -> _tagCached = null ; return $ this ; } | Add the class to the tag Overrides the class attribute |
13,438 | public function addStyles ( array $ styles ) { foreach ( $ styles as $ param => $ value ) { $ this -> addStyle ( $ param , $ value ) ; } return $ this ; } | Add the styles to the tag |
13,439 | public function addStyle ( $ param , $ value ) { $ this -> _style [ $ param ] = $ value ; $ this -> _tagCached = null ; return $ this ; } | Add the style element to the tag Owerrides the style attribute |
13,440 | public function generatePalette ( ) { if ( \ Input :: get ( 'table' ) != 'tl_layout' || \ Input :: get ( 'act' ) != 'edit' ) { return ; } $ layout = $ this -> getCurrentLayout ( ) ; if ( $ layout -> layoutType == 'bootstrap' ) { $ GLOBALS [ 'TL_DCA' ] [ 'tl_layout' ] [ 'metapalettes' ] [ '__base__' ] = $ this -> getMet... | modify palette if bootstrap is used |
13,441 | protected function getUninstalledFiles ( $ type , $ modelClass , $ themeId ) { $ installed = array ( ) ; $ collection = $ modelClass :: findBy ( 'type="file" AND pid' , $ themeId ) ; if ( $ collection !== null ) { $ installed = $ collection -> fetchEach ( 'file' ) ; } $ available = $ GLOBALS [ 'BOOTSTRAP' ] [ 'assets' ... | generic get uninstall files helper method |
13,442 | protected function installFiles ( $ value , $ modelClass , $ layout , $ field , $ toggle ) { $ value = deserialize ( $ value , true ) ; $ result = $ modelClass :: findAll ( array ( 'limit' => '1' , 'order' => 'sorting DESC' ) ) ; $ sorting = $ result === null ? 0 : $ result -> sorting ; $ new = array ( ) ; foreach ( $ ... | generic importer helper for asset files |
13,443 | public function addArguments ( ? string $ arguments = null ) { $ args = [ ] ; preg_match_all ( '/(?P<argument>\w+):(?P<value>[\w+\-]+)/' , $ arguments , $ matches ) ; if ( isset ( $ matches [ 'argument' ] ) ) { foreach ( $ matches [ 'argument' ] as $ key => $ argKey ) { if ( isset ( $ matches [ 'value' ] [ $ key ] ) ) ... | Add cron arguments . |
13,444 | public function getArguments ( ) : string { $ arguments = [ ] ; foreach ( $ this -> arguments as $ key => $ val ) { $ arguments [ ] = $ key . ':' . $ val ; } return implode ( ' ' , $ arguments ) ; } | List arguments . |
13,445 | public function getArgument ( InputInterface $ input , $ key ) : ? string { if ( $ input -> hasArgument ( $ key ) ) { return $ input -> getArgument ( $ key ) ; } if ( isset ( $ this -> arguments [ $ key ] ) ) { return $ this -> arguments [ $ key ] ; } return null ; } | Get Cron arguments . |
13,446 | public static function method ( $ method , $ value , $ params = [ ] , $ options = [ ] , $ neighbouring_values = [ ] ) { $ method = \ Factory :: method ( $ method ) ; $ params = $ params ?? [ ] ; $ params [ 'options' ] = $ options ; $ params [ 'neighbouring_values' ] = $ neighbouring_values ; return \ Factory :: model (... | Call validator method |
13,447 | public function getEventsManager ( ) { if ( $ this -> _eventsManager === null ) { if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) ) { $ this -> _eventsManager = $ this -> getLocator ( ) -> get ( $ this -> getEventsManagerServiceId ( ) ) ; if ( ! $ this -> _eventsManager instanceof EventsManager... | Get an events manager |
13,448 | public function hasEventsManager ( ) { if ( $ this -> _eventsManager !== null ) { return true ; } if ( $ this instanceof LocatorAwareInterface && $ this -> hasLocator ( ) && $ this -> getLocator ( ) -> has ( $ this -> getEventsManagerServiceId ( ) ) ) { return true ; } return false ; } | Has an avent manager |
13,449 | public function openStream ( string $ mode ) : StreamInterface { try { $ res = Thrower :: call ( 'fopen' , $ this , $ mode ) ; } catch ( \ Exception $ e ) { throw new \ RuntimeException ( sprintf ( 'Unable to open %s using mode "%s"' , $ this , $ mode ) , 0 , $ e ) ; } return StreamFactoryDiscovery :: find ( ) -> creat... | Create a stream for the file . |
13,450 | public function createWriter ( bool $ append = true ) : CsvWriterInterface { $ stream = $ this -> openStream ( $ append ? 'a+' : 'w+' ) ; $ writer = new CsvStreamWriter ( $ stream ) ; $ writer -> setCsvControl ( $ this -> delimiter , $ this -> enclosure , $ this -> escape ) ; if ( $ this -> associativeRows ) { $ writer... | Create a writer to be used externally . |
13,451 | public static function multiExecGet ( array $ urls ) : array { $ result = [ 'success' => false , 'error' => [ ] , 'data' => [ ] ] ; $ ch = [ ] ; $ mh = curl_multi_init ( ) ; foreach ( $ urls as $ k => $ v ) { $ ch [ $ k ] = curl_init ( ) ; curl_setopt ( $ ch [ $ k ] , CURLOPT_URL , $ v [ 'url' ] ) ; curl_setopt ( $ ch ... | Multi exec get |
13,452 | static function createEntryFactory ( ? FileFormatInterface $ fileFormat = null , ? PathResolverInterface $ pathResolver = null , ? string $ temporaryDirPath = null , ? int $ umask = null ) : EntryFactoryInterface { if ( DIRECTORY_SEPARATOR === '\\' ) { return new FlockEntryFactory ( $ fileFormat , $ pathResolver , $ um... | Create an entry factory suitable for the current environment |
13,453 | public function param ( $ name , $ default = null ) { return isset ( $ this -> parameters [ $ name ] ) ? $ this -> parameters [ $ name ] : $ default ; } | Get named parameter value |
13,454 | public static function Html ( $ html ) : string { $ html = str_replace ( [ "\0" , "\t" , "\r" ] , '' , $ html ) ; while ( strpos ( $ html , ' ' ) !== false ) { $ html = str_replace ( ' ' , ' ' , $ html ) ; } $ html = str_replace ( "\n " , "\n" , $ html ) ; $ textarea = strpos ( $ html , '<textarea' ) ; if ( $ textare... | Removes all spaces in HTML output |
13,455 | public function build ( ) { if ( $ this -> user -> trashed ( ) ) { return $ this -> actions ; } $ this -> checkBlocked ( ) ; $ this -> checkInactive ( ) ; $ this -> checkInvites ( ) ; $ this -> checkPasswordReset ( ) ; return $ this -> actions ; } | Get the list of available actions . |
13,456 | protected function checkBlocked ( ) { if ( $ this -> user -> status_id === Status :: BLOCKED ) { return $ this -> addAction ( 'Un-Block' , 'unlock' , $ this -> makeRoute ( 'block' , 0 ) ) ; } return $ this -> addAction ( 'Block' , 'lock' , $ this -> makeRoute ( 'block' , 1 ) ) ; } | Actions for a blocked user . |
13,457 | protected function checkInactive ( ) { if ( $ this -> user -> status_id !== Status :: INACTIVE ) { return true ; } return $ this -> addAction ( 'Activate' , 'check-square-o' , $ this -> makeRoute ( 'activate' , 0 ) ) ; } | Actions for an inactive user . |
13,458 | protected function checkInvites ( ) { if ( ! config ( 'jumpgate.users.settings.allow_invitations' ) || is_null ( $ this -> user -> actionTimestamps -> invited_at ) ) { return true ; } return $ this -> addAction ( 'Re-Send Invite' , 'envelope-o' , $ this -> makeRoute ( 'resendInvite' ) ) ; return $ this -> addAction ( '... | Actions for an invited user . |
13,459 | protected function makeRoute ( $ status , $ action = null ) { $ route = 'admin.users.confirm' ; return route ( $ route , [ $ this -> user -> id , $ status , $ action ] ) ; } | A helper to make routes easily . |
13,460 | protected function addAction ( $ label , $ icon , $ route ) { $ action = ( object ) [ 'route' => $ route , 'icon' => 'fa-' . $ icon , 'text' => $ label , ] ; $ this -> actions -> add ( $ action ) ; } | Adds the action to the collection . |
13,461 | public static function createFromFile ( $ path , array $ options = [ ] ) { if ( isset ( $ options [ self :: OPTION_TYPE ] ) ) { $ type = ( string ) $ options [ self :: OPTION_TYPE ] ; unset ( $ options [ self :: OPTION_TYPE ] ) ; } else { $ type = pathinfo ( $ path , PATHINFO_EXTENSION ) ; } return self :: createFromSo... | Create a config from the file |
13,462 | public static function createFromSource ( $ source , $ type , array $ options = [ ] ) { if ( isset ( self :: $ readers [ $ type ] ) ) { $ reader = self :: $ readers [ $ type ] ; } else { $ class = self :: READERS_NAMESPACE . '\\' . ucfirst ( $ type ) ; $ reader = new $ class ( ) ; if ( ! $ reader instanceof ReaderInter... | Create a config from the source |
13,463 | protected static function readFile ( $ pathRaw ) { $ path = realpath ( $ pathRaw ) ; if ( $ path === false ) { throw new UnableToRead ( 'File "' . $ pathRaw . '" not found or inaccessible' ) ; } $ content = file_get_contents ( $ path ) ; if ( $ content === false ) { throw new UnableToRead ( 'Unable to read the file "' ... | Read a config file |
13,464 | public function handle ( Login $ request ) { $ userData = [ 'email' => $ request -> get ( 'email' ) , 'password' => $ request -> get ( 'password' ) , ] ; return $ this -> login -> loginUser ( $ userData ) -> redirectIntended ( ) ; } | Handle validating the login details . |
13,465 | public function startEvent ( $ message , $ type = ProfileInterface :: TYPE_INFO , array $ options = null ) { $ profile = new Profile ( $ message , $ type , $ options ) ; $ this -> _profiles [ ] = $ profile ; $ this -> _lastProfile = $ profile ; $ profile -> start ( ) ; return $ profile ; } | Start an event |
13,466 | public function startInfo ( $ message , array $ options = null ) { return $ this -> startEvent ( $ message , ProfileInterface :: TYPE_INFO , $ options ) ; } | Start an info event |
13,467 | public function startRead ( $ message , array $ options = null ) { return $ this -> startEvent ( $ message , ProfileInterface :: TYPE_READ , $ options ) ; } | Start a read event |
13,468 | public function startWrite ( $ message , array $ options = null ) { return $ this -> startEvent ( $ message , ProfileInterface :: TYPE_WRITE , $ options ) ; } | Start a write event |
13,469 | public function startInsert ( $ message , array $ options = null ) { return $ this -> startEvent ( $ message , ProfileInterface :: TYPE_INSERT , $ options ) ; } | Start an isert event |
13,470 | public function startDelete ( $ message , array $ options = null ) { return $ this -> startEvent ( $ message , ProfileInterface :: TYPE_DELETE , $ options ) ; } | Start a delete event |
13,471 | public function stopEvent ( $ status = ProfileInterface :: STATUS_SUCCESS ) { if ( $ this -> _lastProfile === null ) { throw new Exception ( 'No one event has been started' ) ; } $ this -> _lastProfile -> stop ( $ status ) ; return $ this ; } | Stop a last event |
13,472 | public function getTotalElapsedTime ( ) { $ time = 0 ; foreach ( $ this -> _profiles as $ profile ) { $ time += $ profile -> getElapsedTime ( ) ; } return $ time ; } | Get the total elapsed time of an events |
13,473 | public function render ( ) { $ totalEvents = $ this -> getTotalEvents ( ) ; if ( $ totalEvents > 0 ) { $ text = 'Total: ' . $ totalEvents . ' events in: ' ; $ text .= round ( $ this -> getTotalElapsedTime ( ) , 4 ) . 's ' ; } else { $ text = 'No events' ; } $ text .= PHP_EOL ; $ info = $ this -> getAdditionalInfo ( ) ;... | Render the results as a formatted text |
13,474 | public function translate ( $ id , $ params = null , $ domain = null , $ locale = null ) { if ( $ domain === null ) { $ domain = $ this -> handleDomain ( $ id ) ; } if ( $ locale === null ) { $ locale = $ this -> getLocale ( ) ; } else { $ locale = $ this -> normalizeLocale ( $ locale ) ; } $ translation = $ this -> ge... | Translate the ID or message |
13,475 | protected function handleDomain ( & $ id ) { if ( $ this -> idDelimiter === null ) { return $ this -> domain ; } $ delimiterPos = strpos ( $ id , $ this -> idDelimiter ) ; if ( $ delimiterPos === false ) { return $ this -> domain ; } $ domain = substr ( $ id , 0 , $ delimiterPos ) ; $ id = substr ( $ id , $ delimiterPo... | Handle the translation s domain |
13,476 | protected function normalizeParams ( array $ params ) { $ processed = [ ] ; foreach ( $ params as $ param => $ value ) { $ processed [ sprintf ( $ this -> paramsPattern , $ param ) ] = $ value ; } return $ processed ; } | Normalize the parameters by pattern |
13,477 | protected function getTranslation ( $ id , $ domain , $ locale , $ fallbacks ) { if ( ! isset ( $ this -> initializedCatalogs [ $ locale ] [ $ domain ] ) ) { $ this -> initCatalogs ( $ locale , $ domain ) ; } if ( ! isset ( $ this -> catalogs [ $ locale ] [ $ domain ] [ $ id ] ) ) { if ( empty ( $ fallbacks ) ) { retur... | Get the translation |
13,478 | protected function handleFailure ( $ id ) { if ( $ this -> failBehaviour & self :: NOTFOUND_NOTICE ) { trigger_error ( 'Translation absent for the ID "' . $ id . '" in the catalogs' ) ; } if ( $ this -> failBehaviour & self :: NOTFOUND_RETURN_ID ) { return $ id ; } if ( $ this -> failBehaviour & self :: NOTFOUND_EXCEPT... | Handle the not found ID |
13,479 | protected function handlePlugins ( $ locale , $ translation , $ params ) { foreach ( $ this -> plugins as $ plugin ) { $ translation = $ plugin -> handle ( $ locale , $ translation , $ params ) ; } return $ translation ; } | Handle the plugins |
13,480 | public function addPlugins ( array $ plugins ) { foreach ( $ plugins as $ name => $ plugin ) { if ( is_numeric ( $ name ) ) { $ this -> addPlugin ( $ plugin ) ; continue ; } $ this -> addPlugin ( $ plugin , $ name ) ; } return $ this ; } | Add the plugins |
13,481 | public function addPlugin ( PluginInterface $ plugin , $ name = null ) { if ( $ name === null ) { $ this -> plugins [ ] = $ plugin ; return $ this ; } $ this -> plugins [ $ name ] = $ plugin ; return $ this ; } | Add the plugin |
13,482 | public function addFallbackLocales ( array $ locales , $ preinit = false ) { foreach ( $ locales as $ locale ) { $ this -> addFallbackLocale ( $ locale , $ preinit ) ; } return $ this ; } | Add the fallback locales |
13,483 | public function addFallbackLocale ( $ locale , $ preinit = false ) { $ locale = ( string ) $ locale ; $ locale = $ this -> normalizeLocale ( $ locale ) ; if ( in_array ( $ locale , $ this -> fallbackLocales , true ) ) { return $ this ; } $ this -> fallbackLocales [ ] = $ locale ; if ( $ preinit ) { $ this -> addPreinit... | Add the fallback locale |
13,484 | public function addResources ( array $ resources ) { foreach ( $ resources as $ name => $ resource ) { if ( is_numeric ( $ name ) ) { $ this -> addResource ( $ resource ) ; continue ; } $ this -> addResource ( $ resource , $ name ) ; } return $ this ; } | Add the resources |
13,485 | public function addResource ( ResourceInterface $ resource , $ name = null ) { if ( $ name === null ) { $ this -> resources [ ] = $ resource ; return $ this ; } $ this -> resources [ $ name ] = $ resource ; return $ this ; } | Add the resource |
13,486 | public function reinitializeCatalogs ( ) { $ this -> catalogs = [ ] ; $ this -> initializedCatalogs = [ ] ; if ( ! empty ( $ this -> preinitLocales ) || ! empty ( $ this -> preinitDomains ) ) { $ this -> preinitNeed = true ; } return $ this ; } | Reinitialize the catalogs |
13,487 | public function addPreinitLocale ( $ locale ) { $ locale = ( string ) $ locale ; if ( in_array ( $ locale , $ this -> preinitLocales , true ) ) { return $ this ; } $ this -> preinitLocales [ ] = $ locale ; $ this -> preinitNeed = true ; return $ this ; } | Add the locale to preinitialize |
13,488 | public function addPreinitDomain ( $ domain ) { $ domain = ( string ) $ domain ; if ( in_array ( $ domain , $ this -> preinitDomains , true ) ) { return $ this ; } $ this -> preinitDomains [ ] = $ domain ; $ this -> preinitNeed = true ; return $ this ; } | Add the domain to preinitialize |
13,489 | protected function handlePreinit ( $ locale , $ domain ) { if ( ! empty ( $ this -> preinitLocales ) ) { $ locale = array_unique ( array_merge ( ( array ) $ locale , $ this -> preinitLocales ) ) ; } if ( ! empty ( $ this -> preinitDomains ) ) { $ domain = array_unique ( array_merge ( ( array ) $ domain , $ this -> prei... | Handle the preinitialize routine |
13,490 | protected function calculateRequestDiff ( $ locale , $ domain , array $ catalogs ) { $ domain = array_flip ( ( array ) $ domain ) ; $ locale = array_flip ( ( array ) $ locale ) ; $ diffLocale = array_diff_key ( $ locale , $ catalogs ) ; $ diffDomain = empty ( $ diffLocale ) ? [ ] : $ domain ; foreach ( $ catalogs as $ ... | Calculate difference between the requested data and the obtained |
13,491 | protected function normalizeRequestDiff ( $ diff ) { if ( count ( $ diff ) === 1 ) { reset ( $ diff ) ; return key ( $ diff ) ; } return array_keys ( $ diff ) ; } | Normalize the difference data |
13,492 | protected function getCatalogsFromResources ( $ locale , $ domain ) { $ catalogs = [ ] ; foreach ( $ this -> resources as $ resource ) { $ catalogs = array_replace_recursive ( $ catalogs , $ resource -> getCatalogs ( $ locale , $ domain ) ) ; } return $ catalogs ; } | Initialize catalogs from the resources |
13,493 | protected function markAsInitialized ( $ locale , $ domain ) { if ( is_array ( $ locale ) ) { foreach ( $ locale as $ part ) { $ this -> markAsInitializedLocale ( $ part , $ domain ) ; } return ; } $ this -> markAsInitializedLocale ( $ locale , $ domain ) ; } | Mark the catalogs as initialized |
13,494 | final public static function findBySql ( string $ sql ) : array { $ dbObject = Database :: getInstance ( ) ; $ resultSet = $ dbObject -> query ( $ sql ) ; $ objectArray = [ ] ; while ( $ row = Database :: fetchAssoc ( $ resultSet ) ) { $ objectArray [ ] = static :: instantiate ( $ row ) ; } return $ objectArray ; } | Returns each row as objects in an associative array |
13,495 | final public static function instantiate ( array $ record ) { $ className = get_called_class ( ) ; $ object = new $ className ; foreach ( $ record as $ attribute => $ value ) : $ object -> $ attribute = $ value ; endforeach ; return $ object ; } | Instantiates a new record |
13,496 | final public static function limitFindBySql ( string $ sqlQuery , int $ limit = 0 ) { $ resultArray = static :: findBySql ( $ sqlQuery . static :: limitQuery ( $ limit ) ) ; if ( empty ( $ resultArray ) ) return FALSE ; return ( $ limit == 1 ) ? array_shift ( $ resultArray ) : $ resultArray ; } | Checks if returned resultArray should return 1 element . |
13,497 | final public function attributes ( ) : array { $ attributes = [ ] ; foreach ( static :: $ databaseFields as $ field ) : if ( isset ( $ this -> $ field ) ) $ attributes [ $ field ] = $ this -> $ field ; endforeach ; return $ attributes ; } | Return an array of attribute names and their values . |
13,498 | final public function generateQueryForUPdate ( ) : string { $ generatedArray = [ ] ; foreach ( $ this -> sanitizedAttributes ( ) as $ key => $ value ) : $ generatedArray [ ] = "{$key} = '{$value}'" ; endforeach ; return joinArray ( $ generatedArray , ", " ) ; } | Generating sql query for update |
13,499 | final public function hasAttribute ( string $ attribute ) : bool { $ objectAttributes = $ this -> attributes ( ) ; return array_key_exists ( $ attribute , $ objectAttributes ) ; } | Checks if an object has given attribute . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.