idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
19,000
protected function cleanupVendors ( Storage $ storage ) { $ this -> outputLine ( ) ; $ this -> outputLine ( 'Cleanup vendors ...' ) ; $ this -> outputLine ( '-------------------' ) ; $ count = $ this -> importer -> cleanupVendors ( $ storage , function ( NodeInterface $ vendor ) { $ this -> outputLine ( sprintf ( '%s deleted' , $ vendor -> getLabel ( ) ) ) ; } ) ; if ( $ count > 0 ) { $ this -> outputLine ( sprintf ( ' Deleted %d vendor(s)' , $ count ) ) ; } }
Remove vendors that don t exist on Packagist or contains no packages
19,001
public function addCollection ( self $ collection ) { $ this -> renderDefinitions = \ array_merge ( $ this -> renderDefinitions , $ collection -> all ( ) ) ; $ this -> resources = \ array_merge ( $ this -> resources , $ collection -> getResources ( ) ) ; }
Adds a render definition collection at the end of the current set by appending all render definitions of the added collection .
19,002
private function loadTypoScript ( ) : string { if ( null === $ this -> options [ 'cache_dir' ] ) { return $ this -> concatenateTypoScript ( ) ; } $ cache = $ this -> getConfigCacheFactory ( ) -> cache ( $ this -> options [ 'cache_dir' ] . '/content_elements.typoscript' , function ( ConfigCacheInterface $ cache ) { $ cache -> write ( $ this -> concatenateTypoScript ( ) , $ this -> getRenderDefinitionCollection ( ) -> getResources ( ) ) ; } ) ; return \ file_get_contents ( $ cache -> getPath ( ) ) ; }
Load the TypoScript code for the content element render definitions itself without adding them to the template .
19,003
public function compose ( $ keyId = null , $ head = null ) { if ( ! $ this -> payload ) throw new \ Firebase \ JWT \ BeforeValidException ( ExceptionMessages :: JWT_PAYLOAD_NOT_FOUND ) ; return parent :: encode ( $ this -> payload , $ this -> key , $ this -> algorithm , $ keyId , $ head ) ; }
Composes and signs the JWT
19,004
public static function hasFile ( $ key ) { if ( isset ( $ _FILES [ $ key ] ) === false || ( isset ( $ _FILES [ $ key ] [ 'error' ] ) && $ _FILES [ $ key ] [ 'error' ] != 0 ) ) { return false ; } return true ; }
Checks to see if request contains file
19,005
public function getAuthorizationBearer ( ) { $ allHeaders = array_change_key_case ( parent :: getHeaders ( ) , CASE_UPPER ) ; if ( array_key_exists ( 'AUTHORIZATION' , $ allHeaders ) ) { if ( preg_match ( '/Bearer\s(\S+)/' , $ allHeaders [ 'AUTHORIZATION' ] , $ matches ) ) { return $ matches [ 1 ] ; } } else { throw new \ Exception ( ExceptionMessages :: AUTH_BEARER_NOT_FOUND ) ; } }
Gets Authorization Bearer token
19,006
public function initErrorHandler ( Config $ config ) { if ( $ this -> getDI ( ) -> get ( 'environment' ) === Constants :: PROD_ENV ) { return ; } $ this -> debug = new Debug ( ) ; $ this -> debug -> listen ( ) ; set_error_handler ( [ $ this , 'errorHandler' ] , error_reporting ( ) ) ; register_shutdown_function ( function ( ) { if ( ( error_reporting ( ) & E_ERROR ) === E_ERROR ) { $ lastError = error_get_last ( ) ; if ( $ lastError [ 'type' ] === E_ERROR ) { $ this -> errorHandler ( E_ERROR , $ lastError [ 'message' ] , $ lastError [ 'file' ] , $ lastError [ 'line' ] ) ; } } } ) ; }
Initializes error handling
19,007
public function errorHandler ( $ code , $ message , $ file , $ line ) { $ this -> debug -> setShowBackTrace ( false ) ; $ this -> debug -> onUncaughtException ( new \ ErrorException ( $ message , $ code , 0 , $ file , $ line ) ) ; }
Create default error handler .
19,008
protected function processVariable ( PHP_CodeSniffer_File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ token = $ tokens [ $ stackPtr ] ; $ varName = $ this -> normalizeVarName ( $ token [ 'content' ] ) ; if ( ( $ currScope = $ this -> findVariableScope ( $ phpcsFile , $ stackPtr ) ) === false ) { return ; } if ( $ this -> checkForSymbolicObjectProperty ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForFunctionPrototype ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForCatchBlock ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForThisWithinClass ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForSuperGlobal ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForStaticMember ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForAssignment ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForListAssignment ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForGlobalDeclaration ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForStaticDeclaration ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForForeachLoopVar ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } if ( $ this -> checkForPassByReferenceFunctionCall ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { return ; } $ this -> markVariableReadAndWarnIfUndefined ( $ phpcsFile , $ varName , $ stackPtr , $ currScope ) ; }
Called to process normal member vars .
19,009
protected function processVariableInString ( PHP_CodeSniffer_File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ token = $ tokens [ $ stackPtr ] ; if ( ! preg_match_all ( $ this -> _double_quoted_variable_regexp , $ token [ 'content' ] , $ matches ) ) { return ; } $ currScope = $ this -> findVariableScope ( $ phpcsFile , $ stackPtr ) ; foreach ( $ matches [ 1 ] as $ varName ) { $ varName = $ this -> normalizeVarName ( $ varName ) ; if ( $ this -> checkForThisWithinClass ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { continue ; } if ( $ this -> checkForSuperGlobal ( $ phpcsFile , $ stackPtr , $ varName , $ currScope ) ) { continue ; } $ this -> markVariableReadAndWarnIfUndefined ( $ phpcsFile , $ varName , $ stackPtr , $ currScope ) ; } }
Called to process variables found in double quoted strings .
19,010
protected function processScopeClose ( PHP_CodeSniffer_File $ phpcsFile , $ stackPtr ) { $ scopeInfo = $ this -> getScopeInfo ( $ stackPtr , false ) ; if ( is_null ( $ scopeInfo ) ) { return ; } foreach ( $ scopeInfo -> variables as $ varInfo ) { if ( $ varInfo -> ignoreUnused || isset ( $ varInfo -> firstRead ) ) { continue ; } if ( $ this -> allowUnusedFunctionParameters && $ varInfo -> scopeType == 'param' ) { continue ; } if ( $ varInfo -> passByReference && isset ( $ varInfo -> firstInitialized ) ) { continue ; } if ( isset ( $ varInfo -> firstDeclared ) ) { $ phpcsFile -> addWarning ( "Unused %s %s." , $ varInfo -> firstDeclared , 'UnusedVariable' , array ( VariableInfo :: $ scopeTypeDescriptions [ $ varInfo -> scopeType ] , "\${$varInfo->name}" , ) ) ; } if ( isset ( $ varInfo -> firstInitialized ) ) { $ phpcsFile -> addWarning ( "Unused %s %s." , $ varInfo -> firstInitialized , 'UnusedVariable' , array ( VariableInfo :: $ scopeTypeDescriptions [ $ varInfo -> scopeType ] , "\${$varInfo->name}" , ) ) ; } } }
Called to process the end of a scope .
19,011
public function validate ( $ args ) { $ matched = false ; foreach ( $ args as $ arg => $ value ) { if ( is_numeric ( $ arg ) ) continue ; foreach ( $ this -> options as $ option ) { if ( $ option -> matchParam ( $ arg ) ) { if ( ! $ option -> validate ( $ value ) ) { throw new InvalidArgumentException ( $ arg , $ value ) ; } $ matched = true ; } } if ( ! $ matched ) { throw new InvalidOptionException ( $ arg ) ; } } foreach ( $ this -> options as $ option ) { if ( ! $ option -> isRequired ( ) ) { continue ; } if ( ! $ option -> getValue ( $ args ) ) { throw new MissingRequiredArgumentException ( $ option -> getName ( ) ) ; } } return true ; }
Validates current action options
19,012
private function phpMailerSettings ( ) { $ phpMailer = new PHPMailer ( ) ; if ( strlen ( env ( 'MAIL_HOST' ) ) > 0 ) { $ phpMailer -> SMTPDebug = 0 ; $ phpMailer -> isSMTP ( ) ; $ phpMailer -> Host = env ( 'MAIL_HOST' ) ; $ phpMailer -> SMTPAuth = true ; $ phpMailer -> SMTPSecure = env ( 'MAIL_SMTP_SECURE' ) ; $ phpMailer -> Port = env ( 'MAIL_PORT' ) ; $ phpMailer -> Username = env ( 'MAIL_USERNAME' ) ; $ phpMailer -> Password = env ( 'MAIL_PASSWORD' ) ; } else { $ phpMailer -> isMail ( ) ; } $ phpMailer -> isHTML ( true ) ; $ this -> mailer = $ phpMailer ; }
PHP Mailer Settings
19,013
private function createFromTemplate ( $ message , $ template ) { ob_start ( ) ; ob_implicit_flush ( false ) ; if ( is_array ( $ message ) && ! empty ( $ message ) ) { extract ( $ message , EXTR_OVERWRITE ) ; } $ current_module = RouteController :: $ currentRoute [ 'module' ] ; $ templatePath = MODULES_DIR . '/' . $ current_module . '/Views/' . $ template . '.php' ; require $ templatePath ; return ob_get_clean ( ) ; }
Create From Template
19,014
private function createStringAttachments ( $ attachments ) { if ( array_key_exists ( 'string' , $ attachments ) ) { $ this -> mailer -> addStringAttachment ( $ attachments [ 'string' ] , $ attachments [ 'name' ] ) ; } else { foreach ( $ attachments as $ attachment ) { $ this -> mailer -> addStringAttachment ( $ attachment [ 'string' ] , $ attachment [ 'name' ] ) ; } } }
Create String Attachments
19,015
public function render ( $ page , $ settings = array ( ) ) { $ this -> settings = array_merge ( $ this -> settings , $ settings ) ; if ( ! empty ( $ page -> currentUri ) ) { $ this -> htmlAHref = str_replace ( '?' , '&' , $ this -> htmlAHref ) ; $ this -> currentUri = $ page -> currentUri ; } else { $ this -> currentUri = $ this -> di -> get ( 'router' ) -> getRewriteUri ( ) ; } $ html = '' ; if ( $ page -> total_pages > 1 ) { $ this -> page = $ page ; $ this -> checkBoundary ( ) ; $ html .= '<ul class="pagination">' ; $ html .= $ this -> renderPreviousButton ( ) ; $ html .= $ this -> renderPages ( ) ; $ html .= $ this -> renderNextButton ( ) ; $ html .= '</ul>' ; } return $ html ; }
Renders pagination html
19,016
private function checkBoundary ( ) { if ( $ this -> page -> current > $ this -> page -> total_pages ) { $ queryLink = ! empty ( $ this -> page -> currentUri ) ? '&' : '?' ; $ redirectUrl = substr ( $ this -> currentUri , 1 ) . $ queryLink . 'page=' . $ this -> page -> total_pages ; $ this -> di -> get ( 'response' ) -> redirect ( $ redirectUrl ) ; } }
Checks if current page fit in total pages
19,017
private function renderPreviousButton ( ) { $ before = $ this -> page -> before ; $ extraClass = $ before ? '' : ' not-active' ; if ( empty ( $ before ) ) { $ before = 1 ; } return $ this -> renderElement ( $ before , $ this -> settings [ 'label_previous' ] , 'prev' . $ extraClass ) ; }
Renders button - previous page
19,018
private function renderNextButton ( ) { $ next = $ this -> page -> next ; $ extraClass = $ next ? '' : ' not-active' ; if ( empty ( $ next ) ) { $ next = $ this -> page -> total_pages ; } return $ this -> renderElement ( $ next , $ this -> settings [ 'label_next' ] , 'next' . $ extraClass ) ; }
Renders button - next page
19,019
private function renderElement ( $ page , $ title , $ class = '' ) { $ href = sprintf ( $ this -> htmlHref , $ this -> currentUri , $ page ) ; $ href .= $ this -> getUrlParams ( ) ; $ element = sprintf ( $ this -> htmlAHref , $ href , $ title ) ; return sprintf ( $ this -> htmlElement , $ class , $ element ) ; }
Renders html element
19,020
private function renderPages ( ) { $ html = '' ; for ( $ i = 1 ; $ i <= $ this -> page -> total_pages ; $ i ++ ) { if ( $ i == $ this -> page -> current ) { $ html .= $ this -> renderElement ( $ i , $ i , 'active' ) ; } elseif ( $ this -> isPrintablePage ( $ i ) ) { $ html .= $ this -> renderElement ( $ i , $ i ) ; } elseif ( $ this -> isMiddleOffsetPage ( $ i ) ) { $ html .= $ this -> renderElement ( $ this -> page -> current , '...' , 'more' ) ; } } return $ html ; }
Renders the pages list
19,021
public function getResults ( ) { $ skip = ( $ this -> page - 1 ) * $ this -> limit ; $ cursor = $ this -> getCursor ( ) ; $ cursor -> skip ( $ skip ) ; $ results = array ( ) ; $ i = 0 ; while ( $ cursor -> valid ( ) && $ cursor -> current ( ) && $ i ++ < $ this -> limit ) { $ object = new $ this -> modelName ( ) ; $ object -> writeAttributes ( $ cursor -> current ( ) ) ; $ pseudoCursor = new \ stdClass ( ) ; foreach ( $ object as $ key => $ value ) { $ pseudoCursor -> $ key = $ value ; } $ results [ ] = $ pseudoCursor ; $ cursor -> skip ( ) ; } return $ results ; }
Returns results for current page
19,022
public function stateless ( $ username , $ password ) { $ user = $ this -> sentinel -> stateless ( [ 'email' => $ username , 'password' => $ password , ] ) ; if ( ! ( $ user instanceof CartalystUserInterface ) ) { return false ; } $ this -> sentinel -> getUserRepository ( ) -> recordLogin ( $ user ) ; event ( new CmsUserLoggedIn ( $ user , true ) ) ; return true ; }
Performs stateless login .
19,023
public function forceUser ( UserInterface $ user , $ remember = true ) { $ user = $ this -> sentinel -> authenticate ( $ user , $ remember ) ; if ( ! ( $ user instanceof CartalystUserInterface ) ) { return false ; } event ( new CmsUserLoggedIn ( $ user , false , true ) ) ; return true ; }
Forces a user to be logged in without credentials verification .
19,024
public function forceUserStateless ( UserInterface $ user ) { $ user = $ this -> sentinel -> authenticate ( $ user , false , false ) ; if ( ! ( $ user instanceof CartalystUserInterface ) ) { return false ; } event ( new CmsUserLoggedIn ( $ user , true , true ) ) ; return true ; }
Forces a user to be logged in without credentials verification without persistence and without marking it as a login .
19,025
public function assign ( $ role , UserInterface $ user ) { $ roles = is_array ( $ role ) ? $ role : [ $ role ] ; $ count = 0 ; foreach ( $ roles as $ singleRole ) { $ count += $ this -> assignSingleRole ( $ singleRole , $ user ) ? 1 : 0 ; } if ( $ count !== count ( $ roles ) ) { return false ; } $ this -> fireUserPermissionChangeEvent ( $ user ) ; return true ; }
Assigns one or several roles to a user .
19,026
public function unassign ( $ role , UserInterface $ user ) { $ roles = is_array ( $ role ) ? $ role : [ $ role ] ; $ count = 0 ; foreach ( $ roles as $ singleRole ) { $ count += $ this -> unassignSingleRole ( $ singleRole , $ user ) ? 1 : 0 ; } if ( $ count !== count ( $ roles ) ) { return false ; } $ this -> fireUserPermissionChangeEvent ( $ user ) ; return true ; }
Removes one or several roles from a user .
19,027
public function removeRole ( $ role ) { if ( ! ( $ roleModel = $ this -> sentinel -> findRoleBySlug ( $ role ) ) ) { return false ; } $ roleModel -> delete ( ) ; $ this -> fireRoleChangeEvent ( ) ; return true ; }
Removes a role .
19,028
public function grantToRole ( $ permission , $ role ) { if ( ! ( $ roleModel = $ this -> sentinel -> findRoleBySlug ( $ role ) ) ) { return false ; } $ permissions = is_array ( $ permission ) ? $ permission : [ $ permission ] ; foreach ( $ permissions as $ singlePermission ) { $ this -> grantSinglePermissionToRole ( $ singlePermission , $ roleModel ) ; } if ( ! $ roleModel -> save ( ) ) { return false ; } $ this -> fireRoleChangeEvent ( ) ; return true ; }
Grants one or more permissions to a role .
19,029
public function revokeFromRole ( $ permission , $ role ) { if ( ! ( $ roleModel = $ this -> sentinel -> findRoleBySlug ( $ role ) ) ) { return false ; } $ permissions = is_array ( $ permission ) ? $ permission : [ $ permission ] ; foreach ( $ permissions as $ singlePermission ) { $ this -> revokeSinglePermissionFromRole ( $ singlePermission , $ roleModel ) ; } if ( ! $ roleModel -> save ( ) ) { return false ; } $ this -> fireRoleChangeEvent ( ) ; return true ; }
Revokes one or more permissions of a role .
19,030
public function createUser ( $ username , $ password , array $ data = [ ] ) { $ user = $ this -> sentinel -> registerAndActivate ( [ 'email' => $ username , 'password' => $ password , ] ) ; if ( ! $ user ) { throw new \ Exception ( "Failed to create user '{$username}'" ) ; } $ user -> update ( $ data ) ; return $ user ; }
Create new CMS user .
19,031
public function deleteUser ( $ username ) { if ( ! ( $ user = $ this -> sentinel -> findByCredentials ( [ 'email' => $ username ] ) ) ) { return false ; } if ( $ user -> isAdmin ( ) ) { return false ; } return ( bool ) $ user -> delete ( ) ; }
Removes a user from the CMS .
19,032
public function updatePassword ( $ username , $ password ) { if ( ! ( $ user = $ this -> sentinel -> findByCredentials ( [ 'email' => $ username ] ) ) ) { return false ; } return $ this -> sentinel -> update ( $ user , [ 'password' => $ password ] ) instanceof UserInterface ; }
Sets a new password for an existing CMS user .
19,033
public function cleanAction ( ) { $ this -> putText ( "Cleaning cache..." ) ; $ di = DI :: getDefault ( ) ; if ( $ di -> has ( 'config' ) ) { $ config = $ di -> get ( 'config' ) ; if ( ! empty ( $ config -> application -> view -> cacheDir ) ) { $ this -> removeFilesFromDir ( $ config -> application -> view -> cacheDir ) ; } $ this -> putSuccess ( "Done." ) ; } }
Cleans application cache
19,034
private function removeFilesFromDir ( $ dir ) { if ( $ handle = opendir ( $ dir ) ) { while ( false !== ( $ entry = readdir ( $ handle ) ) ) { if ( $ entry == "." || $ entry == ".." ) { continue ; } if ( ! unlink ( $ dir . DIRECTORY_SEPARATOR . $ entry ) ) { $ this -> putWarning ( "Can not remove: " . $ dir . DIRECTORY_SEPARATOR . $ entry ) ; } } closedir ( $ handle ) ; } }
Removes files from cache dir
19,035
protected function filterActionMethodName ( $ name ) { $ filter = new FilterChain ; $ filter -> attachByName ( 'Zend\Filter\Word\CamelCaseToDash' ) ; $ filter -> attachByName ( 'StringToLower' ) ; return rtrim ( preg_replace ( '/action$/' , '' , $ filter -> filter ( $ name ) ) , '-' ) ; }
Sanitizes action name to use in route .
19,036
protected function getRouteConfig ( Route $ annotation ) { return [ $ annotation -> getName ( ) => [ 'type' => $ annotation -> getType ( ) , 'options' => [ 'route' => $ annotation -> getRoute ( ) , 'defaults' => $ annotation -> getDefaults ( ) , 'constraints' => $ annotation -> getConstraints ( ) ] , 'priority' => ( int ) $ annotation -> getPriority ( ) , 'may_terminate' => ( bool ) $ annotation -> getMayTerminate ( ) , 'child_routes' => [ ] ] ] ; }
Converts annotation into ZF2 route config item .
19,037
protected function & getReferenceForPath ( array $ path , array & $ config ) { $ path = array_filter ( $ path , function ( $ value ) { return ( bool ) $ value ; } ) ; $ ref = & $ config ; if ( empty ( $ path ) ) { return $ ref ; } foreach ( $ path as $ key ) { if ( ! isset ( $ ref [ $ key ] ) ) { $ ref [ $ key ] = [ 'child_routes' => [ ] ] ; } $ ref = & $ ref [ $ key ] [ 'child_routes' ] ; } return $ ref ; }
Extend parent route with children .
19,038
public function isValidForRootNode ( Route $ annotation ) { if ( ! $ annotation -> name ) { return false ; } if ( ! $ annotation -> route ) { return false ; } return true ; }
Checks if current route can be a class - level route .
19,039
public function load ( $ lang ) { $ langDir = MODULES_DIR . DS . RouteController :: $ currentModule . '/Views/lang/' . $ lang ; $ files = glob ( $ langDir . "/*.php" ) ; if ( count ( $ files ) == 0 ) { throw new \ Exception ( ExceptionMessages :: TRANSLATION_FILES_NOT_FOUND ) ; } foreach ( $ files as $ file ) { $ fileInfo = pathinfo ( $ file ) ; self :: $ translations [ $ fileInfo [ 'filename' ] ] = require_once $ file ; } }
Finds and loads translation files
19,040
public static function set ( $ lang = NULL ) { $ languages = get_config ( 'langs' ) ; if ( ! $ languages ) { throw new \ Exception ( ExceptionMessages :: MISCONFIGURED_LANG_CONFIG ) ; } if ( ! get_config ( 'lang_default' ) ) { throw new \ Exception ( ExceptionMessages :: MISCONFIGURED_LANG_DEFAULT_CONFIG ) ; } if ( empty ( $ lang ) || ! in_array ( $ lang , $ languages ) ) { $ lang = get_config ( 'lang_default' ) ; } self :: $ currentLang = $ lang ; self :: load ( $ lang ) ; }
Sets current language
19,041
public function loadConfiguration ( ) { $ config = $ this -> getConfig ( ) ; if ( ! isset ( $ config [ 'path' ] ) ) { throw new ServiceCreationException ( 'Missing required path parameter in PaletteExtension configuration' ) ; } if ( ! isset ( $ config [ 'url' ] ) ) { throw new ServiceCreationException ( 'Missing required url parameter in PaletteExtension configuration' ) ; } $ builder = $ this -> getContainerBuilder ( ) ; $ builder -> addDefinition ( $ this -> prefix ( 'service' ) ) -> setClass ( 'NettePalette\Palette' , array ( $ config [ 'path' ] , $ config [ 'url' ] , $ config [ 'basepath' ] , empty ( $ config [ 'fallbackImage' ] ) ? NULL : $ config [ 'fallbackImage' ] , empty ( $ config [ 'template' ] ) ? NULL : $ config [ 'template' ] , empty ( $ config [ 'websiteUrl' ] ) ? NULL : $ config [ 'websiteUrl' ] , empty ( $ config [ 'pictureLoader' ] ) ? NULL : $ config [ 'pictureLoader' ] , ) ) -> addSetup ( 'setHandleExceptions' , [ ! isset ( $ config [ 'handleException' ] ) ? TRUE : $ config [ 'handleException' ] , ] ) ; $ builder -> addDefinition ( $ this -> prefix ( 'filter' ) ) -> setClass ( 'NettePalette\LatteFilter' , [ $ this -> prefix ( '@service' ) ] ) ; $ this -> getLatteService ( ) -> addSetup ( 'addFilter' , [ 'palette' , $ this -> prefix ( '@filter' ) ] ) ; $ builder -> getDefinition ( 'nette.presenterFactory' ) -> addSetup ( 'setMapping' , [ [ 'Palette' => 'NettePalette\*Presenter' ] ] ) ; }
Processes configuration data .
19,042
protected function getLatteService ( ) { $ builder = $ this -> getContainerBuilder ( ) ; return $ builder -> hasDefinition ( 'nette.latteFactory' ) ? $ builder -> getDefinition ( 'nette.latteFactory' ) : $ builder -> getDefinition ( 'nette.latte' ) ; }
Get Latte service definition
19,043
public static function write ( $ filePath , $ content , $ compareContents = false ) { if ( $ compareContents && self :: compareContents ( $ filePath , $ content ) ) { return 0 ; } return file_put_contents ( $ filePath , $ content ) ; }
Writes string content to a file
19,044
public static function writeObject ( $ filePath , $ object , $ compareContents = false ) { $ content = '<?php return ' . var_export ( $ object , true ) . ';' ; return self :: write ( $ filePath , $ content , $ compareContents ) ; }
Writes string representation of PHP object into plain file
19,045
private static function compareContents ( $ filePath , $ newContent ) { if ( file_exists ( $ filePath ) ) { $ currentContent = file_get_contents ( $ filePath ) ; return strcmp ( $ currentContent , $ newContent ) === 0 ; } return false ; }
Compares file contents
19,046
public function registerFilter ( $ filterName ) { $ className = __CLASS__ . '\\Filter\\' . ucfirst ( $ filterName ) ; try { $ filterInstance = $ this -> getClassInstance ( $ className ) ; if ( ! $ filterInstance instanceof VoltFilterAbstract ) { throw new InvalidFilterException ( ) ; } $ this -> getCompiler ( ) -> addFilter ( $ filterName , $ filterInstance -> getFilter ( ) ) ; } catch ( \ ReflectionException $ e ) { throw new UnknownFilterException ( sprintf ( 'Filter \'%s\' does not exist' , $ filterName ) ) ; } catch ( \ Exception $ e ) { throw new InvalidFilterException ( sprintf ( 'Invalid filter \'%s\'' , $ filterName ) ) ; } }
Registers a new filter in the compiler
19,047
public function registerHelper ( $ helperName ) { $ className = __CLASS__ . '\\Helper\\' . ucfirst ( $ helperName ) ; try { $ helperInstance = $ this -> getClassInstance ( $ className ) ; if ( ! $ helperInstance instanceof VoltHelperAbstract ) { throw new InvalidHelperException ( ) ; } $ this -> getCompiler ( ) -> addFunction ( $ helperName , $ helperInstance -> getHelper ( ) ) ; } catch ( \ ReflectionException $ e ) { throw new UnknownHelperException ( sprintf ( 'Helper \'%s\' does not exist' , $ helperName ) ) ; } catch ( \ Exception $ e ) { throw new InvalidHelperException ( sprintf ( 'Invalid helper \'%s\'' , $ helperName ) ) ; } }
Registers a new helper in the compiler
19,048
public function controller ( $ uri , $ controller , $ names = [ ] ) { $ arr = explode ( '\\' , $ controller ) ; $ controllerClassName = $ arr [ sizeof ( $ arr ) - 1 ] ; $ routable = ( new ControllerInspector ) -> getRoutable ( $ this -> addGroupNamespace ( $ controller ) , $ uri ) ; foreach ( $ routable as $ method => $ routes ) { if ( $ method == 'getMethodProperties' ) { continue ; } foreach ( $ routes as $ route ) { Route :: { $ route [ 'verb' ] } ( $ route [ 'uri' ] , "{$controllerClassName}@{$method}" ) ; } } }
Register a controller .
19,049
protected function addGroupNamespace ( $ controller ) { if ( ! empty ( $ this -> groupStack ) ) { $ group = end ( $ this -> groupStack ) ; if ( isset ( $ group [ 'namespace' ] ) && strpos ( $ controller , '\\' ) !== 0 ) { return $ group [ 'namespace' ] . '\\' . $ controller ; } } return $ controller ; }
Add the group namespace to a controller .
19,050
protected function addRouteMiddlewares ( array $ action ) { foreach ( [ static :: API_RATE_LIMIT_MIDDLEWARE , static :: API_AUTH_MIDDLEWARE ] as $ middleware ) { if ( ( $ key = array_search ( $ middleware , $ action [ 'middleware' ] ) ) !== false ) { unset ( $ action [ 'middleware' ] [ $ key ] ) ; } array_unshift ( $ action [ 'middleware' ] , $ middleware ) ; } return $ action ; }
Add the route middlewares to the action array .
19,051
private function initializeType ( array $ data ) { if ( isset ( $ data [ 'type' ] ) === false ) { return ; } if ( $ data [ 'type' ] === 'error' ) { $ this -> type = self :: TYPE_ERROR ; } elseif ( $ data [ 'type' ] === 'info' ) { if ( isset ( $ data [ 'subType' ] ) === true && $ data [ 'subType' ] === 'warning' ) { $ this -> type = self :: TYPE_WARNING ; } else { $ this -> type = self :: TYPE_INFO ; } } }
Initializes message type .
19,052
public function extend ( $ annotation ) { $ params = get_object_vars ( $ annotation ) ; foreach ( $ params as $ property => $ value ) { if ( property_exists ( $ this , $ property ) && ! in_array ( $ property , [ 'name' , 'route' ] ) ) { if ( ! $ this -> $ property ) { $ this -> $ property = $ value ; } } } }
Extend this route with data from another one .
19,053
protected function parse ( string $ key ) : array { if ( strpos ( $ key , '(' ) === false && strpos ( $ key , ')' ) === false ) { return [ 'field' => trim ( $ key ) , 'operator' => '' ] ; } if ( ! preg_match ( static :: REGEXP , $ key , $ matches ) ) { throw new InvalidFilterException ( "Invalid filter item '$key': Bad use of parentheses" ) ; } return array_only ( $ matches , [ 'field' , 'operator' ] ) + [ 'operator' => '' ] ; }
Parse the key into field and operator .
19,054
public function indexAction ( ) { $ this -> initializeScaffolding ( ) ; $ paginator = $ this -> scaffolding -> doPaginate ( $ this -> request -> get ( 'page' , 'int' , 1 ) ) ; $ this -> view -> page = $ paginator -> getPaginate ( ) ; $ this -> view -> fields = $ this -> indexFields ; }
Display records list .
19,055
public function showAction ( $ id ) { $ this -> initializeScaffolding ( ) ; $ this -> beforeRead ( ) ; $ this -> view -> record = $ this -> scaffolding -> doRead ( $ id ) ; $ this -> view -> fields = $ this -> showFields ; $ this -> afterRead ( ) ; }
Display record details .
19,056
public function newAction ( ) { $ this -> initializeScaffolding ( ) ; $ this -> beforeNew ( ) ; $ this -> view -> form = $ this -> scaffolding -> getForm ( ) ; $ this -> afterNew ( ) ; }
Displays form for new record
19,057
public function createAction ( ) { $ this -> initializeScaffolding ( ) ; $ this -> checkRequest ( ) ; try { $ this -> beforeCreate ( ) ; $ this -> scaffolding -> doCreate ( $ this -> request -> getPost ( ) ) ; $ this -> flash -> success ( $ this -> successMessage ) ; return $ this -> afterCreate ( ) ; } catch ( Exception $ e ) { $ this -> flash -> error ( $ e -> getMessage ( ) ) ; $ this -> afterCreateException ( ) ; } return $ this -> dispatcher -> forward ( [ 'action' => 'new' ] ) ; }
Creates new record
19,058
public function editAction ( $ id ) { $ this -> initializeScaffolding ( ) ; $ this -> beforeRead ( ) ; $ this -> view -> record = $ this -> scaffolding -> doRead ( $ id ) ; $ this -> afterRead ( ) ; $ this -> beforeEdit ( ) ; $ this -> view -> form = $ this -> scaffolding -> getForm ( $ this -> view -> record ) ; $ this -> afterEdit ( ) ; }
Displays form for existing record
19,059
public function updateAction ( $ id ) { $ this -> initializeScaffolding ( ) ; $ this -> checkRequest ( ) ; try { $ this -> beforeRead ( ) ; $ this -> view -> record = $ this -> scaffolding -> doRead ( $ id ) ; $ this -> afterRead ( ) ; $ this -> beforeUpdate ( ) ; $ this -> scaffolding -> doUpdate ( $ id , $ this -> request -> getPost ( ) ) ; $ this -> flash -> success ( $ this -> successMessage ) ; return $ this -> afterUpdate ( ) ; } catch ( Exception $ e ) { $ this -> flash -> error ( $ e -> getMessage ( ) ) ; $ this -> afterUpdateException ( ) ; } return $ this -> dispatcher -> forward ( [ 'action' => 'edit' ] ) ; }
Updates existing record indicated by its ID
19,060
public function deleteAction ( $ id ) { $ this -> initializeScaffolding ( ) ; try { $ this -> beforeRead ( ) ; $ this -> view -> record = $ this -> scaffolding -> doRead ( $ id ) ; $ this -> afterRead ( ) ; $ this -> beforeDelete ( ) ; $ this -> scaffolding -> doDelete ( $ id ) ; $ this -> flash -> success ( $ this -> successMessage ) ; return $ this -> afterDelete ( ) ; } catch ( Exception $ e ) { $ this -> flash -> error ( $ e -> getMessage ( ) ) ; return $ this -> afterDeleteException ( ) ; } }
Deletes existing record by its ID
19,061
public static function create ( $ collection , $ id = null , $ database = null ) { if ( $ collection instanceof \ Phalcon \ Mvc \ Collection ) { $ id = $ collection -> getId ( ) ; $ collection = $ collection -> getSource ( ) ; } if ( $ id instanceof \ Phalcon \ Mvc \ Collection ) { $ id = $ id -> getId ( ) ; } if ( ! $ id instanceof \ MongoId && $ id !== null ) { $ id = new \ MongoId ( $ id ) ; } return parent :: create ( $ collection , $ id , $ database ) ; }
Creates a new database reference
19,062
public static function usePath ( $ path ) { if ( $ path === self :: PATH_DOCUMENT_ROOT ) { if ( empty ( $ _SERVER [ "DOCUMENT_ROOT" ] ) || ! is_dir ( $ _SERVER [ "DOCUMENT_ROOT" ] ) ) { throw new \ InvalidArgumentException ( "DOCUMENT_ROOT not defined" ) ; } static :: $ path = $ _SERVER [ "DOCUMENT_ROOT" ] ; return ; } if ( $ path === self :: PATH_PHP_SELF ) { if ( empty ( $ _SERVER [ "PHP_SELF" ] ) || ! $ path = realpath ( $ _SERVER [ "PHP_SELF" ] ) ) { throw new \ InvalidArgumentException ( "PHP_SELF not defined" ) ; } static :: $ path = pathinfo ( $ path , PATHINFO_DIRNAME ) ; return ; } if ( $ path === self :: PATH_VENDOR_PARENT ) { static :: $ path = realpath ( __DIR__ . "/../../../.." ) ; return ; } if ( is_dir ( $ path ) ) { static :: $ path = $ path ; } else { throw new \ InvalidArgumentException ( "Invalid path specified" ) ; } }
Set the root path to use in the path methods .
19,063
public static function getRevision ( $ length = 10 ) { $ revision = Cache :: call ( "revision" , function ( ) { $ path = static :: path ( ".git" ) ; if ( ! is_dir ( $ path ) ) { return ; } $ head = $ path . "/HEAD" ; if ( ! file_exists ( $ head ) ) { return ; } $ data = File :: getContents ( $ head ) ; if ( ! preg_match ( "/ref: ([^\s]+)\s/" , $ data , $ matches ) ) { return ; } $ ref = $ path . "/" . $ matches [ 1 ] ; if ( ! file_exists ( $ ref ) ) { return ; } return File :: getContents ( $ ref ) ; } ) ; if ( $ length > 0 ) { return substr ( $ revision , 0 , $ length ) ; } else { return $ revision ; } }
Get the revision number from the local git clone data .
19,064
public static function getVars ( ) { if ( ! is_array ( static :: $ vars ) ) { $ path = static :: path ( "data/env.json" ) ; try { $ vars = Json :: decodeFromFile ( $ path ) ; } catch ( \ Exception $ e ) { $ vars = [ ] ; } static :: $ vars = Helper :: toArray ( $ vars ) ; } return static :: $ vars ; }
Get all defined environment variables .
19,065
protected function registerAuthRepository ( ) { $ this -> app -> singleton ( AuthRepositoryInterface :: class , function ( Application $ app ) { return $ app -> make ( AuthRepository :: class ) ; } ) ; return $ this ; }
Registers authentication repository
19,066
protected function registerCommands ( ) { $ this -> app -> singleton ( 'cms.commands.user-create' , CreateUser :: class ) ; $ this -> app -> singleton ( 'cms.commands.user-delete' , DeleteUser :: class ) ; $ this -> commands ( [ 'cms.commands.user-create' , 'cms.commands.user-delete' , ] ) ; return $ this ; }
Register Authorization CMS commands
19,067
public static function is_valid ( array $ data , array $ validators ) { $ gump = self :: get_instance ( ) ; $ gump -> validation_rules ( $ validators ) ; if ( $ gump -> run ( $ data ) === false ) { return $ gump -> get_errors_array ( false ) ; } else { return true ; } }
Validates by rules
19,068
public static function load ( $ path = BASE_DIR ) { $ librariesDir = dirname ( dirname ( $ path ) ) . DS . 'libraries' ; foreach ( glob ( $ librariesDir . DS . "*.php" ) as $ filename ) { require_once $ filename ; } }
Loads 3rd party libraries
19,069
public function getAllUsers ( $ withAdmin = false ) { $ query = $ this -> userModel -> query ( ) -> orderBy ( 'email' ) ; if ( ! $ withAdmin ) { $ query -> where ( 'is_superadmin' , false ) ; } return $ query -> get ( ) ; }
Returns all CMS users .
19,070
public function getUsersForRole ( $ role , $ withAdmin = false ) { $ query = $ this -> userModel -> query ( ) -> orderBy ( 'email' ) -> whereHas ( 'roles' , function ( $ query ) use ( $ role ) { $ query -> where ( 'slug' , $ role ) ; } ) ; if ( ! $ withAdmin ) { $ query -> where ( 'is_superadmin' , false ) ; } return $ query -> get ( ) ; }
Returns all CMS users with the given role .
19,071
public function getAllPermissions ( ) { $ permissions = [ ] ; foreach ( $ this -> roleModel -> all ( ) as $ role ) { $ permissions = array_merge ( $ permissions , array_keys ( array_filter ( $ role -> getPermissions ( ) ) ) ) ; } foreach ( $ this -> userModel -> all ( ) as $ user ) { $ permissions = array_merge ( $ permissions , array_keys ( array_filter ( $ user -> getPermissions ( ) ) ) ) ; } sort ( $ permissions ) ; return array_unique ( $ permissions ) ; }
Returns all permissions known by the authenticator .
19,072
public function getAllPermissionsForRole ( $ role ) { $ role = $ this -> getRole ( $ role ) ; if ( ! $ role ) { return [ ] ; } $ permissions = array_keys ( array_filter ( $ role -> getPermissions ( ) ) ) ; sort ( $ permissions ) ; return $ permissions ; }
Returns all permission keys for a given role .
19,073
public function getAllPermissionsForUser ( $ user ) { $ user = $ this -> resolveUser ( $ user ) ; if ( ! $ user ) { return [ ] ; } $ permissions = [ ] ; foreach ( $ user -> getRoles ( ) as $ role ) { $ permissions = array_merge ( $ permissions , array_keys ( array_filter ( $ role -> getPermissions ( ) ) ) ) ; } $ permissions = array_merge ( $ permissions , array_keys ( array_filter ( $ user -> getPermissions ( ) ) ) ) ; sort ( $ permissions ) ; return array_unique ( $ permissions ) ; }
Returns all permission keys for a given user .
19,074
protected function resolveUser ( $ user ) { if ( $ user instanceof UserInterface ) { return $ user ; } if ( is_integer ( $ user ) ) { $ user = $ this -> sentinel -> findById ( $ user ) ; } else { $ user = $ this -> sentinel -> findByCredentials ( [ 'email' => $ user ] ) ; } return $ user ? : false ; }
Resolves user to UserInterface if possible
19,075
public static function signUp ( UserId $ anId , UserEmail $ anEmail , UserPassword $ aPassword , array $ userRoles ) { $ user = new static ( $ anId , $ anEmail , $ userRoles , $ aPassword ) ; $ user -> confirmationToken = new UserToken ( ) ; $ user -> publish ( new UserRegistered ( $ user -> id ( ) , $ user -> email ( ) , $ user -> confirmationToken ( ) ) ) ; return $ user ; }
Sign up user .
19,076
public static function invite ( UserId $ anId , UserEmail $ anEmail , array $ userRoles ) { $ user = new static ( $ anId , $ anEmail , $ userRoles ) ; $ user -> invitationToken = new UserToken ( ) ; $ user -> publish ( new UserInvited ( $ user -> id ( ) , $ user -> email ( ) , $ user -> invitationToken ( ) ) ) ; return $ user ; }
Invites user .
19,077
public function acceptInvitation ( ) { if ( $ this -> isInvitationTokenAccepted ( ) ) { throw new UserInvitationAlreadyAcceptedException ( ) ; } if ( $ this -> isInvitationTokenExpired ( ) ) { throw new UserTokenExpiredException ( ) ; } $ this -> invitationToken = null ; $ this -> updatedOn = new \ DateTimeImmutable ( ) ; $ this -> publish ( new UserRegistered ( $ this -> id ( ) , $ this -> email ( ) ) ) ; }
Accepts the invitation request .
19,078
public function changePassword ( UserPassword $ aPassword ) { $ this -> password = $ aPassword ; $ this -> rememberPasswordToken = null ; $ this -> updatedOn = new \ DateTimeImmutable ( ) ; }
Updates the user password .
19,079
public function confirmationToken ( ) { return $ this -> confirmationToken instanceof UserToken && null === $ this -> confirmationToken -> token ( ) ? null : $ this -> confirmationToken ; }
Gets the confirmation token .
19,080
public function enableAccount ( ) { $ this -> confirmationToken = null ; $ this -> updatedOn = new \ DateTimeImmutable ( ) ; $ this -> publish ( new UserEnabled ( $ this -> id , $ this -> email ) ) ; }
Enables the user account .
19,081
public function grant ( UserRole $ aRole ) { if ( false === $ this -> isRoleAllowed ( $ aRole ) ) { throw new UserRoleInvalidException ( ) ; } if ( true === $ this -> isGranted ( $ aRole ) ) { throw new UserRoleAlreadyGrantedException ( ) ; } $ this -> roles [ ] = $ aRole ; $ this -> updatedOn = new \ DateTimeImmutable ( ) ; $ this -> publish ( new UserRoleGranted ( $ this -> id , $ this -> email , $ aRole ) ) ; }
Adds the given role .
19,082
public function invitationToken ( ) { return $ this -> invitationToken instanceof UserToken && null === $ this -> invitationToken -> token ( ) ? null : $ this -> invitationToken ; }
Gets the invitation token .
19,083
public function isInvitationTokenExpired ( ) { if ( ! $ this -> invitationToken ( ) instanceof UserToken ) { throw new UserTokenNotFoundException ( ) ; } return $ this -> invitationToken -> isExpired ( $ this -> invitationTokenLifetime ( ) ) ; }
Checks if the invitation token is expired or not .
19,084
public function isRememberPasswordTokenExpired ( ) { if ( ! $ this -> rememberPasswordToken ( ) instanceof UserToken ) { throw new UserTokenNotFoundException ( ) ; } return $ this -> rememberPasswordToken -> isExpired ( $ this -> rememberPasswordTokenLifetime ( ) ) ; }
Checks if the remember password token is expired or not .
19,085
public function login ( $ aPlainPassword , UserPasswordEncoder $ anEncoder ) { if ( false === $ this -> isEnabled ( ) ) { throw new UserInactiveException ( ) ; } if ( false === $ this -> password ( ) -> equals ( $ aPlainPassword , $ anEncoder ) ) { throw new UserPasswordInvalidException ( ) ; } $ this -> lastLogin = new \ DateTimeImmutable ( ) ; $ this -> publish ( new UserLoggedIn ( $ this -> id , $ this -> email ) ) ; }
Validates user login for the given password .
19,086
public function logout ( ) { if ( false === $ this -> isEnabled ( ) ) { throw new UserInactiveException ( ) ; } $ this -> publish ( new UserLoggedOut ( $ this -> id , $ this -> email ) ) ; }
Updated the user state after logout .
19,087
public function regenerateInvitationToken ( ) { if ( null === $ this -> invitationToken ( ) ) { throw new UserInvitationAlreadyAcceptedException ( ) ; } $ this -> invitationToken = new UserToken ( ) ; $ this -> publish ( new UserInvitationTokenRegenerated ( $ this -> id , $ this -> email , $ this -> invitationToken ) ) ; }
Updates the invitation token in case a user has been already invited and has lost the token .
19,088
public function rememberPasswordToken ( ) { return $ this -> rememberPasswordToken instanceof UserToken && null === $ this -> rememberPasswordToken -> token ( ) ? null : $ this -> rememberPasswordToken ; }
Gets the remember password token .
19,089
public function rememberPassword ( ) { $ this -> rememberPasswordToken = new UserToken ( ) ; $ this -> publish ( new UserRememberPasswordRequested ( $ this -> id , $ this -> email , $ this -> rememberPasswordToken ) ) ; }
Remembers the password .
19,090
public function isValid ( $ value ) { if ( $ value instanceof ElectronicAddress ) { $ addressType = $ value -> getType ( ) ; switch ( $ addressType ) { case 'Email' : $ addressValidator = $ this -> validatorResolver -> createValidator ( 'EmailAddress' ) ; break ; default : $ addressValidator = $ this -> validatorResolver -> createValidator ( 'Neos.Party:' . $ addressType . 'Address' ) ; } if ( $ addressValidator === null ) { $ this -> addError ( 'No validator found for electronic address of type "' . $ addressType . '".' , 1268676030 ) ; } else { $ result = $ addressValidator -> validate ( $ value -> getIdentifier ( ) ) ; if ( $ result -> hasErrors ( ) ) { $ this -> result = $ result ; } } } }
Checks if the given value is a valid electronic address according to its type .
19,091
public function isSuccessful ( ) { return $ this -> data -> getStatus ( ) === InvoiceInterface :: STATUS_CONFIRMED || $ this -> data -> getStatus ( ) === InvoiceInterface :: STATUS_COMPLETE ; }
Whether the payment is successful .
19,092
public function getTime ( ) { $ time = $ this -> data -> getInvoiceTime ( ) ; if ( $ time instanceof \ DateTime ) { return $ time -> format ( 'c' ) ; } return date ( 'c' , $ time / 1000 ) ; }
Returns the payment date .
19,093
protected function registerSentinel ( ) { $ this -> app -> singleton ( 'sentinel' , function ( $ app ) { $ sentinel = new Sentinel ( $ app [ 'sentinel.persistence' ] , $ app [ 'sentinel.users' ] , $ app [ 'sentinel.roles' ] , $ app [ 'sentinel.activations' ] , $ app [ 'events' ] ) ; if ( isset ( $ app [ 'sentinel.checkpoints' ] ) ) { foreach ( $ app [ 'sentinel.checkpoints' ] as $ key => $ checkpoint ) { $ sentinel -> addCheckpoint ( $ key , $ checkpoint ) ; } } $ sentinel -> setActivationRepository ( $ app [ 'sentinel.activations' ] ) ; $ sentinel -> setReminderRepository ( $ app [ 'sentinel.reminders' ] ) ; $ sentinel -> setRequestCredentials ( function ( ) use ( $ app ) { $ request = $ app [ 'request' ] ; $ login = $ request -> getUser ( ) ; $ password = $ request -> getPassword ( ) ; if ( $ login === null && $ password === null ) { return null ; } return compact ( 'login' , 'password' ) ; } ) ; $ sentinel -> creatingBasicResponse ( function ( ) { $ headers = [ 'WWW-Authenticate' => 'Basic' ] ; return response ( 'Invalid credentials.' , 401 , $ headers ) ; } ) ; return $ sentinel ; } ) ; }
Overrides parent so as not to use the alias .
19,094
protected function registerUsers ( ) { $ this -> registerHasher ( ) ; $ this -> app -> singleton ( 'sentinel.users' , function ( $ app ) { $ config = $ app [ 'config' ] -> get ( 'cartalyst.sentinel' ) ; $ users = array_get ( $ config , 'users.model' ) ; $ roles = array_get ( $ config , 'roles.model' ) ; $ persistences = array_get ( $ config , 'persistences.model' ) ; $ permissions = array_get ( $ config , 'permissions.class' ) ; if ( class_exists ( $ roles ) && method_exists ( $ roles , 'setUsersModel' ) ) { forward_static_call_array ( [ $ roles , 'setUsersModel' ] , [ $ users ] ) ; } if ( class_exists ( $ persistences ) && method_exists ( $ persistences , 'setUsersModel' ) ) { forward_static_call_array ( [ $ persistences , 'setUsersModel' ] , [ $ users ] ) ; } if ( class_exists ( $ users ) && method_exists ( $ users , 'setPermissionsClass' ) ) { forward_static_call_array ( [ $ users , 'setPermissionsClass' ] , [ $ permissions ] ) ; } return new IlluminateUserRepository ( $ app [ 'sentinel.hasher' ] , $ app [ 'events' ] , $ users ) ; } ) ; }
Overrides the parent so we can bind our own UserRepository
19,095
protected function withAddedStep ( string $ stage , callable $ step , bool $ replace = false ) { $ clone = clone $ this ; if ( $ replace ) { $ clone -> stages [ $ stage ] = [ ] ; } $ clone -> stages [ $ stage ] [ ] = $ step ; return $ clone ; }
Create a clone with a new step
19,096
public function withFilteredSteps ( callable $ matcher ) { $ clone = clone $ this ; foreach ( $ clone -> stages as $ stage => & $ steps ) { $ steps = array_filter ( $ steps , function ( $ step ) use ( $ matcher , $ stage ) { return $ matcher ( $ stage , $ step ) ; } ) ; } return $ clone ; }
Return a query builder with some steps removed .
19,097
public function buildQuery ( iterable $ filter , array $ opts = [ ] ) { return Pipeline :: with ( $ this -> stages ) -> flatten ( ) -> reduce ( function ( $ data , callable $ step ) use ( $ opts ) { return $ step ( $ data , $ opts ) ; } , $ filter ) ; }
Create the query from a filter
19,098
public static function buildFromContainer ( ContainerInterface $ container ) : App { return new App ( self :: request ( $ container ) , self :: response ( $ container ) , self :: processor ( $ container ) , self :: matchableRequest ( $ container ) , self :: errorHandler ( $ container ) , self :: invalidRequestHandler ( $ container ) , self :: streamReadLength ( $ container ) ) ; }
Create an App using a container .
19,099
private static function request ( ContainerInterface $ container ) : ServerRequestInterface { if ( ! $ container -> has ( ServerRequestInterface :: class ) ) { throw new InvalidArgumentException ( 'Moon received an invalid request instance from the container' ) ; } return $ container -> get ( ServerRequestInterface :: class ) ; }
Return an instance of the ServerRequestInterface .