idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
700
public function getPrototype ( ReflectionMethod $ method ) { $ modifiers = implode ( ' ' , Reflection :: getModifierNames ( $ method -> getModifiers ( ) ) ) ; if ( $ this -> hideAbstract ) { $ modifiers = str_replace ( 'abstract ' , '' , $ modifiers ) ; } $ parameters = array ( ) ; foreach ( $ method -> getParameters ( ) as $ p ) { $ param = $ this -> getTypeHint ( $ p ) ; $ param .= $ this -> getName ( $ p ) ; $ param .= $ this -> getDefaultValue ( $ p ) ; $ parameters [ ] = $ param ; } return $ modifiers . ' function ' . $ method -> getName ( ) . "(" . implode ( ', ' , $ parameters ) . ")" ; }
Get the prototype for the method .
701
public function register ( ) { $ packages = $ this -> repository -> enabled ( ) ; $ packages -> each ( function ( $ properties ) { $ this -> registerServiceProvider ( $ properties ) ; } ) ; }
Register the Package service provider file from all Packages .
702
protected function registerServiceProvider ( $ properties ) { $ namespace = $ this -> resolveNamespace ( $ properties ) ; $ name = Str :: studly ( isset ( $ properties [ 'type' ] ) ? $ properties [ 'type' ] : 'package' ) ; $ provider = "{$namespace}\\Providers\\{$name}ServiceProvider" ; if ( ! class_exists ( $ provider ) ) { $ name = Str :: singular ( $ properties [ 'basename' ] ) ; if ( ! class_exists ( $ provider = "{$namespace}\\{$name}ServiceProvider" ) ) { return ; } } $ this -> app -> register ( $ provider ) ; }
Register the Package Service Provider .
703
protected function generate ( $ type ) { $ slug = $ this -> data [ 'slug' ] ; if ( $ type == 'module' ) { $ path = $ this -> getModulePath ( $ slug ) ; } else if ( $ type == 'theme' ) { $ path = $ this -> getThemePath ( $ slug ) ; } else { $ path = $ this -> getPackagePath ( $ slug ) ; } if ( $ this -> files -> exists ( $ path ) ) { $ this -> error ( 'The Package [' . $ slug . '] already exists!' ) ; return false ; } $ steps = array ( 'Generating folders...' => 'generateFolders' , 'Generating files...' => 'generateFiles' , 'Generating .gitkeep ...' => 'generateGitkeep' , 'Updating the composer.json ...' => 'updateComposerJson' , ) ; $ progress = new ProgressBar ( $ this -> output , count ( $ steps ) ) ; $ progress -> start ( ) ; foreach ( $ steps as $ message => $ method ) { $ progress -> setMessage ( $ message ) ; call_user_func ( array ( $ this , $ method ) , $ type ) ; $ progress -> advance ( ) ; } $ progress -> finish ( ) ; $ this -> info ( "\nGenerating optimized class loader" ) ; $ this -> container [ 'composer' ] -> dumpOptimized ( ) ; $ this -> info ( "Package generated successfully." ) ; }
Generate the Package .
704
protected function generateFolders ( $ type ) { $ slug = $ this -> data [ 'slug' ] ; if ( $ type == 'module' ) { $ path = $ this -> packages -> getModulesPath ( ) ; $ packagePath = $ this -> getModulePath ( $ slug ) ; $ mode = 'module' ; } else if ( $ type == 'theme' ) { $ path = $ this -> packages -> getThemesPath ( ) ; $ packagePath = $ this -> getThemePath ( $ slug ) ; $ mode = 'theme' ; } else { $ path = $ this -> packages -> getPackagesPath ( ) ; $ packagePath = $ this -> getPackagePath ( $ slug ) ; $ mode = $ this -> option ( 'extended' ) ? 'extended' : 'default' ; } if ( ! $ this -> files -> isDirectory ( $ path ) ) { $ this -> files -> makeDirectory ( $ path , 0755 , true , true ) ; } $ this -> files -> makeDirectory ( $ packagePath ) ; $ packageFolders = $ this -> packageFolders [ $ mode ] ; foreach ( $ packageFolders as $ folder ) { $ path = $ packagePath . $ folder ; $ this -> files -> makeDirectory ( $ path ) ; } $ languageFolders = $ this -> getLanguagePaths ( $ slug , $ type ) ; foreach ( $ languageFolders as $ folder ) { $ path = $ packagePath . $ folder ; $ this -> files -> makeDirectory ( $ path ) ; } }
Generate defined Package folders .
705
protected function generateFiles ( $ type ) { if ( $ type == 'module' ) { $ mode = 'module' ; $ this -> data [ 'type' ] = 'Module' ; $ this -> data [ 'lower_type' ] = 'module' ; } else if ( $ type == 'theme' ) { $ mode = 'theme' ; $ this -> data [ 'type' ] = 'Theme' ; $ this -> data [ 'lower_type' ] = 'theme' ; } else { $ mode = $ this -> option ( 'extended' ) ? 'extended' : 'default' ; $ this -> data [ 'type' ] = 'Package' ; $ this -> data [ 'lower_type' ] = 'package' ; } $ packageFiles = $ this -> packageFiles [ $ mode ] ; $ slug = $ this -> data [ 'slug' ] ; if ( $ type == 'module' ) { $ packagePath = $ this -> getModulePath ( $ slug ) ; } else if ( $ type == 'theme' ) { $ packagePath = $ this -> getThemePath ( $ slug ) ; } else { $ packagePath = $ this -> getPackagePath ( $ slug ) ; } foreach ( $ packageFiles as $ key => $ file ) { $ file = $ this -> formatContent ( $ file ) ; $ this -> files -> put ( $ this -> getDestinationFile ( $ file , $ packagePath ) , $ this -> getStubContent ( $ key , $ mode ) ) ; } $ content = '<?phpreturn array ();' ; $ languageFolders = $ this -> getLanguagePaths ( $ slug , $ type ) ; foreach ( $ languageFolders as $ folder ) { $ path = $ packagePath . $ folder . DS . 'messages.php' ; $ this -> files -> put ( $ path , $ content ) ; } }
Generate defined Package files .
706
protected function getDestinationFile ( $ file , $ packagePath ) { $ slug = $ this -> data [ 'slug' ] ; return $ packagePath . $ this -> formatContent ( $ file ) ; }
Get destination file .
707
public function showAction ( Request $ request , $ slug ) { $ query = trim ( strtolower ( strip_tags ( $ request -> get ( 'query' , '' ) ) ) ) ; $ search = null ; if ( $ slug ) { $ search = $ this -> getSearchRepository ( ) -> findOneBySlug ( $ slug ) ; } elseif ( $ query != '' ) { $ question = $ this -> getQuestionRepository ( ) -> findOneById ( $ query ) ; if ( $ question ) { return $ this -> redirectToRoute ( $ question -> getRouteName ( ) , $ question -> getRouteParameters ( ) ) ; } $ search = $ this -> getSearchRepository ( ) -> findOneByHeadline ( $ query ) ; } if ( ! $ search and $ query != '' ) { $ className = $ this -> getSearchRepository ( ) -> getClassName ( ) ; $ search = new $ className ( ) ; $ search -> setHeadline ( $ query ) ; } if ( $ search ) { $ search -> setSearchCount ( $ search -> getSearchCount ( ) + 1 ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ search ) ; $ em -> flush ( ) ; } return $ this -> render ( 'GenjFaqBundle:Search:show.html.twig' , array ( 'query' => $ query , 'search' => $ search ) ) ; }
shows search results for previous queries
708
public function listMostPopularAction ( $ max = 3 ) { $ queries = $ this -> getSearchRepository ( ) -> retrieveMostPopular ( $ max ) ; return $ this -> render ( 'GenjFaqBundle:Search:list_most_popular.html.twig' , array ( 'queries' => $ queries , 'max' => $ max ) ) ; }
list most popular search queries based on searchCount
709
protected function getPackages ( $ type ) { $ packages = $ this -> packages -> all ( ) ; if ( ! is_null ( $ type ) ) { $ packages = $ packages -> where ( 'type' , $ type ) ; } $ results = array ( ) ; foreach ( $ packages -> sortBy ( 'basename' ) as $ package ) { $ results [ ] = $ this -> getPackageInformation ( $ package ) ; } return array_filter ( $ results ) ; }
Get all Packages .
710
protected function getPackageInformation ( $ package ) { $ location = ( $ package [ 'location' ] === 'local' ) ? 'Local' : 'Vendor' ; $ type = Str :: title ( $ package [ 'type' ] ) ; if ( $ this -> packages -> isEnabled ( $ package [ 'slug' ] ) ) { $ status = 'Enabled' ; } else { $ status = 'Disabled' ; } return array ( 'name' => $ package [ 'name' ] , 'slug' => $ package [ 'slug' ] , 'order' => $ package [ 'order' ] , 'location' => $ location , 'type' => $ type , 'status' => $ status , ) ; }
Returns Package manifest information .
711
protected function compileEchos ( $ value ) { $ difference = strlen ( $ this -> contentTags [ 0 ] ) - strlen ( $ this -> escapedTags [ 0 ] ) ; if ( $ difference > 0 ) { return $ this -> compileEscapedEchos ( $ this -> compileRegularEchos ( $ value ) ) ; } return $ this -> compileRegularEchos ( $ this -> compileEscapedEchos ( $ value ) ) ; }
Compile Template echos into valid PHP .
712
public function stripParentheses ( $ expression ) { if ( Str :: startsWith ( $ expression , '(' ) && Str :: endsWith ( $ expression , ')' ) ) { $ expression = substr ( $ expression , 1 , - 1 ) ; } return $ expression ; }
Strip the parentheses from the given expression .
713
protected function callScope ( $ scope , $ parameters ) { array_unshift ( $ parameters , $ this ) ; return call_user_func_array ( array ( $ this -> model , $ scope ) , $ parameters ) ? : $ this ; }
Call the given model scope on the underlying model .
714
protected function createBaseMigration ( ) { $ name = 'create_session_table' ; $ path = $ this -> container [ 'path' ] . DS . 'Database' . DS . 'Migrations' ; return $ this -> container [ 'migration.creator' ] -> create ( $ name , $ path ) ; }
Create a base migration file for the session .
715
public function retriesLeft ( $ key , $ maxAttempts ) { $ attempts = $ this -> attempts ( $ key ) ; return ( $ attempts === 0 ) ? $ maxAttempts : $ maxAttempts - $ attempts + 1 ; }
Get the number of retries left for the given key .
716
public function clear ( $ key ) { $ this -> cache -> forget ( $ key ) ; $ this -> cache -> forget ( $ key . ':lockout' ) ; }
Clear the hits and lockout for the given key .
717
public function getLastGroupPrefix ( ) { if ( ! empty ( $ this -> groupStack ) ) { $ last = end ( $ this -> groupStack ) ; return isset ( $ last [ 'prefix' ] ) ? $ last [ 'prefix' ] : '' ; } return '' ; }
Get the prefix from the last group on the stack .
718
protected function findActionClosure ( array $ action ) { return Arr :: first ( $ action , function ( $ key , $ value ) { return is_callable ( $ value ) && is_numeric ( $ key ) ; } ) ; }
Find the Closure in an action array .
719
public function resolveMiddleware ( $ name ) { if ( isset ( $ this -> middlewareGroups [ $ name ] ) ) { return $ this -> parseMiddlewareGroup ( $ name ) ; } return $ this -> parseMiddleware ( $ name ) ; }
Resolve the middleware name to class name preserving passed parameters .
720
protected function parseMiddleware ( $ name ) { list ( $ name , $ parameters ) = array_pad ( explode ( ':' , $ name , 2 ) , 2 , null ) ; $ callable = isset ( $ this -> middleware [ $ name ] ) ? $ this -> middleware [ $ name ] : $ name ; if ( is_null ( $ parameters ) ) { return $ callable ; } else if ( is_string ( $ callable ) ) { return $ callable . ':' . $ parameters ; } $ parameters = explode ( ',' , $ parameters ) ; return function ( $ passable , $ stack ) use ( $ callable , $ parameters ) { return call_user_func_array ( $ callable , array_merge ( array ( $ passable , $ stack ) , $ parameters ) ) ; } ; }
Parse the middleware and format it for usage .
721
protected function performBinding ( $ key , $ value , $ route ) { $ callback = $ this -> binders [ $ key ] ; return call_user_func ( $ callback , $ value , $ route ) ; }
Call the binding callback for the given key .
722
public function is ( ) { $ patterns = func_get_args ( ) ; $ name = $ this -> currentRouteName ( ) ; foreach ( $ patterns as $ pattern ) { if ( Str :: is ( $ pattern , $ this -> currentRouteName ( ) ) ) { return true ; } } return false ; }
Alias for the currentRouteNamed method .
723
public function currentRouteNamed ( $ name ) { if ( ! is_null ( $ route = $ this -> current ( ) ) ) { return ( $ route -> getName ( ) == $ name ) ; } return false ; }
Determine if the current route matches a given name .
724
public function getRegistrar ( ) { if ( isset ( $ this -> registrar ) ) { return $ this -> registrar ; } return $ this -> registrar = new ResourceRegistrar ( $ this ) ; }
Get a Resource Registrar instance .
725
protected function migrate ( $ slug ) { if ( ! $ this -> packages -> exists ( $ slug ) ) { return $ this -> error ( 'Package does not exist.' ) ; } $ path = $ this -> getMigrationPath ( $ slug ) ; $ pretend = $ this -> input -> getOption ( 'pretend' ) ; $ this -> migrator -> run ( $ path , $ pretend , $ slug ) ; foreach ( $ this -> migrator -> getNotes ( ) as $ note ) { if ( ! $ this -> option ( 'quiet' ) ) { $ this -> line ( $ note ) ; } } if ( $ this -> option ( 'seed' ) ) { $ this -> call ( 'package:seed' , array ( 'slug' => $ slug , '--force' => true ) ) ; } }
Run migrations for the specified Package .
726
protected function getMigrationPath ( $ slug ) { $ package = $ this -> packages -> where ( 'slug' , $ slug ) ; $ path = $ this -> packages -> resolveClassPath ( $ package ) ; return $ path . 'Database' . DS . 'Migrations' . DS ; }
Get migration directory path .
727
protected function registerAssetDispatcher ( ) { $ this -> app -> singleton ( 'assets.dispatcher' , function ( $ app ) { $ dispatcher = new AssetDispatcher ( $ app ) ; $ dispatcher -> route ( 'assets/(.*)' , function ( Request $ request , $ path ) use ( $ dispatcher ) { $ basePath = $ this -> app [ 'config' ] -> get ( 'routing.assets.path' , base_path ( 'assets' ) ) ; $ path = $ basePath . DS . str_replace ( '/' , DS , $ path ) ; return $ dispatcher -> serve ( $ path , $ request ) ; } ) ; $ dispatcher -> route ( 'packages/([^/]+)/([^/]+)/(.*)' , function ( Request $ request , $ vendor , $ package , $ path ) use ( $ dispatcher ) { $ namespace = $ vendor . '/' . $ package ; if ( is_null ( $ packagePath = $ dispatcher -> getPackagePath ( $ namespace ) ) ) { return new Response ( 'File Not Found' , 404 ) ; } $ path = $ packagePath . str_replace ( '/' , DS , $ path ) ; return $ dispatcher -> serve ( $ path , $ request ) ; } ) ; $ dispatcher -> route ( 'vendor/(.*)' , function ( Request $ request , $ path ) use ( $ dispatcher ) { $ paths = $ dispatcher -> getVendorPaths ( ) ; if ( ! Str :: startsWith ( $ path , $ paths ) ) { return new Response ( 'File Not Found' , 404 ) ; } $ path = BASEPATH . 'vendor' . DS . str_replace ( '/' , DS , $ path ) ; return $ dispatcher -> serve ( $ path , $ request ) ; } ) ; return $ dispatcher ; } ) ; }
Register the Assets Dispatcher .
728
public function markAsRead ( ) { if ( is_null ( $ this -> read_at ) ) { $ this -> forceFill ( array ( 'read_at' => $ this -> freshTimestamp ( ) ) ) ; $ this -> save ( ) ; } }
Mark the notification as read .
729
protected function getResourceAction ( $ resource , $ controller , $ method , $ options ) { $ name = $ this -> getResourceName ( $ resource , $ method , $ options ) ; return array ( 'as' => $ name , 'uses' => $ controller . '@' . $ method ) ; }
Get the action array for a resource route .
730
public function make ( $ view , $ data = array ( ) , $ mergeData = array ( ) ) { if ( isset ( $ this -> aliases [ $ view ] ) ) $ view = $ this -> aliases [ $ view ] ; $ path = $ this -> finder -> find ( $ view ) ; if ( is_null ( $ path ) || ! is_readable ( $ path ) ) { throw new BadMethodCallException ( "File path [$path] does not exist" ) ; } $ data = array_except ( array_merge ( $ mergeData , $ this -> parseData ( $ data ) ) , array ( '__data' , '__path' ) ) ; $ this -> callCreator ( $ view = new View ( $ this , $ this -> getEngineFromPath ( $ path ) , $ view , $ path , $ data ) ) ; return $ view ; }
Create a View instance
731
public function fetch ( $ view , $ data = array ( ) , Closure $ callback = null ) { unset ( $ data [ '__path' ] , $ data [ '__path' ] ) ; return $ this -> make ( $ view , $ data ) -> render ( $ callback ) ; }
Create a View instance and return its rendered content .
732
public function getEngineFromPath ( $ path ) { $ extension = $ this -> getExtension ( $ path ) ; $ engine = $ this -> extensions [ $ extension ] ; return $ this -> engines -> resolve ( $ engine ) ; }
Get the appropriate View Engine for the given path .
733
public function creator ( $ views , $ callback ) { $ creators = array ( ) ; foreach ( ( array ) $ views as $ view ) { $ creators [ ] = $ this -> addViewEvent ( $ view , $ callback , 'creating: ' ) ; } return $ creators ; }
Register a view creator event .
734
protected function addViewEvent ( $ view , $ callback , $ prefix = 'composing: ' , $ priority = null ) { if ( $ callback instanceof Closure ) { $ this -> addEventListener ( $ prefix . $ view , $ callback , $ priority ) ; return $ callback ; } else if ( is_string ( $ callback ) ) { return $ this -> addClassEvent ( $ view , $ callback , $ prefix , $ priority ) ; } }
Add an event for a given view .
735
public function appendSection ( ) { $ last = array_pop ( $ this -> sectionStack ) ; if ( isset ( $ this -> sections [ $ last ] ) ) { $ this -> sections [ $ last ] .= ob_get_clean ( ) ; } else { $ this -> sections [ $ last ] = ob_get_clean ( ) ; } return $ last ; }
Stop injecting content into a section and append it .
736
public function retrieveByPartialHeadline ( $ query ) { $ query = $ this -> createQueryBuilder ( 'q' ) -> select ( 'q.id, q.headline' ) -> where ( 'q.headline LIKE :query' ) -> orderBy ( 'q.publishAt' , 'DESC' ) -> setParameter ( 'query' , '%' . $ query . '%' ) -> getQuery ( ) ; return $ query -> getArrayResult ( ) ; }
used for autocomplete in admin
737
protected function compileCommand ( ) { $ output = ProcessUtils :: escapeArgument ( $ this -> output ) ; $ redirect = $ this -> shouldAppendOutput ? ' >> ' : ' > ' ; if ( ! $ this -> runInBackground ) { return $ this -> command . $ redirect . $ output . ' 2>&1' ; } $ delimiter = windows_os ( ) ? '&' : ';' ; $ phpBinary = ProcessUtils :: escapeArgument ( with ( new PhpExecutableFinder ) -> find ( false ) ) ; $ forgeBinary = defined ( 'FORGE_BINARY' ) ? ProcessUtils :: escapeArgument ( FORGE_BINARY ) : 'forge' ; $ finished = $ phpBinary . ' ' . $ forgeBinary . ' schedule:finish ' . ProcessUtils :: escapeArgument ( $ this -> mutexName ( ) ) ; return '(' . $ this -> command . $ redirect . $ output . ' 2>&1 ' . $ delimiter . ' ' . $ finished . ') > ' . ProcessUtils :: escapeArgument ( $ this -> getDefaultOutput ( ) ) . ' 2>&1 &' ; }
Build a command string with mutex .
738
protected function publish ( $ group = null ) { $ paths = ServiceProvider :: pathsToPublish ( $ group ) ; if ( empty ( $ paths ) ) { if ( is_null ( $ group ) ) { return $ this -> comment ( "Nothing to publish." ) ; } return $ this -> comment ( "Nothing to publish for group [{$group}]." ) ; } foreach ( $ paths as $ from => $ to ) { if ( $ this -> files -> isFile ( $ from ) ) { $ this -> publishFile ( $ from , $ to ) ; } else if ( $ this -> files -> isDirectory ( $ from ) ) { $ this -> publishDirectory ( $ from , $ to ) ; } else { $ this -> error ( "Can't locate path: <{$from}>" ) ; } } if ( is_null ( $ group ) ) { return $ this -> info ( "Publishing complete!" ) ; } $ this -> info ( "Publishing complete for group [{$group}]!" ) ; }
Publish the assets for a given group name .
739
public function publish ( $ package , $ source ) { $ destination = $ this -> publishPath . str_replace ( '/' , DS , "/Packages/{$package}" ) ; $ this -> makeDestination ( $ destination ) ; return $ this -> files -> copyDirectory ( $ source , $ destination ) ; }
Publish view files from a given path .
740
public function publishPackage ( $ package , $ packagePath = null ) { $ source = $ this -> getSource ( $ package , $ packagePath ? : $ this -> packagePath ) ; return $ this -> publish ( $ package , $ source ) ; }
Publish the view files for a package .
741
public function withTrashed ( ) { $ this -> withTrashed = true ; $ this -> query = $ this -> useWithTrashed ( $ this -> query ) ; return $ this ; }
Fetch soft - deleted model instances with query
742
protected function useWithTrashed ( Builder $ query ) { if ( $ this -> withTrashed && $ query -> getMacro ( 'withTrashed' ) !== null ) { return $ query -> withTrashed ( ) ; } return $ query ; }
Return trashed models with query if told so
743
public function whereMonth ( $ column , $ operator , $ value , $ boolean = 'and' ) { return $ this -> addDateBasedWhere ( 'Month' , $ column , $ operator , $ value , $ boolean ) ; }
Add a where month statement to the query .
744
public function pluck ( $ column ) { $ result = ( array ) $ this -> first ( array ( $ column ) ) ; return count ( $ result ) > 0 ? reset ( $ result ) : null ; }
Pluck a single column s value from the first result of a query .
745
public function getCached ( $ columns = array ( '*' ) ) { if ( is_null ( $ this -> columns ) ) $ this -> columns = $ columns ; list ( $ key , $ minutes ) = $ this -> getCacheInfo ( ) ; $ cache = $ this -> getCache ( ) ; $ callback = $ this -> getCacheCallback ( $ columns ) ; if ( $ minutes < 0 ) { return $ cache -> rememberForever ( $ key , $ callback ) ; } return $ cache -> remember ( $ key , $ minutes , $ callback ) ; }
Execute the query as a cached select statement .
746
public function paginate ( $ perPage = 15 , $ columns = array ( '*' ) , $ pageName = 'page' , $ page = null ) { if ( is_null ( $ page ) ) { $ page = Paginator :: resolveCurrentPage ( $ pageName ) ; } $ path = Paginator :: resolveCurrentPath ( $ pageName ) ; $ total = $ this -> getPaginationCount ( ) ; if ( $ total > 0 ) { $ results = $ this -> forPage ( $ page , $ perPage ) -> get ( $ columns ) ; } else { $ results = collect ( ) ; } return new Paginator ( $ results , $ total , $ perPage , $ page , compact ( 'path' , 'pageName' ) ) ; }
Paginate the given query into a paginator .
747
protected function backupFieldsForCount ( ) { foreach ( array ( 'orders' , 'limit' , 'offset' ) as $ field ) { $ this -> backups [ $ field ] = $ this -> { $ field } ; $ this -> { $ field } = null ; } }
Backup certain fields for a pagination count .
748
protected function validateProtocolVersion ( $ protocolVersion ) : void { if ( ! \ is_string ( $ protocolVersion ) ) { throw new \ InvalidArgumentException ( 'HTTP protocol version must be a string' ) ; } else if ( ! \ preg_match ( '/^\d(?:\.\d)?$/' , $ protocolVersion ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The given protocol version "%s" is not valid' , $ protocolVersion ) ) ; } }
Validates the given protocol version
749
protected function validateHeaderName ( $ headerName ) : void { if ( ! \ is_string ( $ headerName ) ) { throw new \ InvalidArgumentException ( 'Header name must be a string' ) ; } else if ( ! \ preg_match ( HeaderInterface :: RFC7230_TOKEN , $ headerName ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The given header name "%s" is not valid' , $ headerName ) ) ; } }
Validates the given header name
750
protected function validateHeaderValue ( $ headerValue ) : void { if ( \ is_string ( $ headerValue ) ) { $ headerValue = [ $ headerValue ] ; } if ( ! \ is_array ( $ headerValue ) || [ ] === $ headerValue ) { throw new \ InvalidArgumentException ( 'Header value must be a string or not an empty array' ) ; } foreach ( $ headerValue as $ oneOf ) { if ( ! \ is_string ( $ oneOf ) ) { throw new \ InvalidArgumentException ( 'Header value must be a string or an array containing only strings' ) ; } else if ( ! \ preg_match ( HeaderInterface :: RFC7230_FIELD_VALUE , $ oneOf ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The given header value "%s" is not valid' , $ oneOf ) ) ; } } }
Validates the given header value
751
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { if ( $ request -> getUri ( ) -> getPath ( ) === '/favicon.ico' ) { throw new NotAcceptableException ( 'access favicon.ico' ) ; } return $ handler -> handle ( $ request ) ; }
fix the bug of chrome
752
public function saveMany ( array $ models , array $ joinings = array ( ) ) { foreach ( $ models as $ key => $ model ) { $ this -> save ( $ model , ( array ) array_get ( $ joinings , $ key ) , false ) ; } $ this -> touchIfTouching ( ) ; return $ models ; }
Save an array of new models and attach them to the parent model .
753
protected function guessInverseRelation ( ) { $ relation = Str :: plural ( class_basename ( $ this -> getParent ( ) ) ) ; return Str :: camel ( $ relation ) ; }
Attempt to guess the name of the inverse of the relation .
754
public function add ( $ name , $ html , $ folderId = null ) { $ payload = array ( 'name' => $ name , 'html' => $ html , 'folder_id' => $ folderId ) ; $ apiCall = 'templates/add' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return isset ( $ data [ 'template_id' ] ) ? $ data [ 'template_id' ] : false ; }
Create a new user template NOT campaign content . These templates can then be applied while creating campaigns .
755
public function listAll ( $ types = array ( ) , $ filters = array ( ) ) { $ payload = array ( 'types' => $ types , 'filters' => $ filters ) ; $ apiCall = 'templates/list' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return $ data ; }
Retrieve various templates available in the system allowing some thing similar to our template gallery to be created .
756
public function info ( $ type = 'user' ) { $ payload = array ( 'template_id' => $ this -> templateId , 'type' => $ type ) ; $ apiCall = 'templates/info' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return $ data ; }
Pull details for a specific template to help support editing
757
public function update ( $ options = array ( ) ) { $ payload = array ( 'template_id' => $ this -> templateId , 'values' => $ options ) ; $ apiCall = 'templates/update' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return true ; }
Replace the content of a user template NOT campaign content .
758
public function getByName ( $ name ) { $ templates = $ this -> listAll ( ) ; if ( empty ( $ templates [ 'user' ] ) ) return false ; foreach ( $ templates [ 'user' ] as $ template ) { if ( $ template [ 'name' ] === $ name ) { return $ template [ 'id' ] ; } } return false ; }
Get template id by Name
759
protected function validateStatusCode ( $ statusCode ) : void { if ( ! \ is_int ( $ statusCode ) ) { throw new \ InvalidArgumentException ( 'HTTP status-code must be an integer' ) ; } else if ( ! ( $ statusCode >= 100 && $ statusCode <= 599 ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The given status-code "%d" is not valid' , $ statusCode ) ) ; } }
Validates the given status - code
760
protected function validateReasonPhrase ( $ reasonPhrase ) : void { if ( ! \ is_string ( $ reasonPhrase ) ) { throw new \ InvalidArgumentException ( 'HTTP reason-phrase must be a string' ) ; } else if ( ! \ preg_match ( HeaderInterface :: RFC7230_FIELD_VALUE , $ reasonPhrase ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The given reason-phrase "%s" is not valid' , $ reasonPhrase ) ) ; } }
Validates the given reason - phrase
761
public function authorizeAtGate ( GateInterface $ gate , $ ability , $ arguments ) { try { return $ gate -> authorize ( $ ability , $ arguments ) ; } catch ( UnauthorizedException $ e ) { $ exception = $ this -> createGateUnauthorizedException ( $ ability , $ arguments , $ e -> getMessage ( ) , $ e ) ; throw $ exception ; } }
Authorize the request at the given gate .
762
protected function normalizeGuessedAbilityName ( $ ability ) { $ map = $ this -> resourceAbilityMap ( ) ; return isset ( $ map [ $ ability ] ) ? $ map [ $ ability ] : $ ability ; }
Normalize the ability name that has been guessed from the method name .
763
public function overridesFrom ( $ namespace ) { if ( ! isset ( $ this -> hints [ $ namespace ] ) ) { return ; } $ paths = $ this -> hints [ $ namespace ] ; $ path = dirname ( head ( $ paths ) ) . DS . 'Overrides' ; if ( ! in_array ( $ path , $ this -> paths ) && $ this -> files -> isDirectory ( $ path ) ) { if ( Str :: endsWith ( head ( $ this -> paths ) , DS . 'Overrides' ) ) { array_shift ( $ this -> paths ) ; } array_unshift ( $ this -> paths , $ path ) ; } }
Prepend a path specified by its namespace .
764
public function deleteMessage ( $ queue , $ id ) { $ this -> pheanstalk -> useTube ( $ this -> getQueue ( $ queue ) ) -> delete ( $ id ) ; }
Delete a message from the Beanstalk queue .
765
protected function manageException ( OutputInterface $ output , Exception $ e ) { $ handler = $ this -> getExceptionHandler ( ) ; $ handler -> report ( $ e ) ; $ handler -> renderForConsole ( $ output , $ e ) ; }
Report and render the given exception .
766
public function call ( $ command , array $ parameters = array ( ) , OutputInterface $ output = null ) { $ parameters [ 'command' ] = $ command ; $ output = $ output ? : new NullOutput ; $ input = new ArrayInput ( $ parameters ) ; return $ this -> find ( $ command ) -> run ( $ input , $ output ) ; }
Run an Nova console command by name .
767
protected function createPdoStatement ( $ query , $ pdo = null ) { if ( is_null ( $ pdo ) ) { $ pdo = $ this -> getPdo ( ) ; } $ grammar = $ this -> getQueryGrammar ( ) ; $ query = preg_replace_callback ( '#\{(.*?)\}#' , function ( $ matches ) use ( $ grammar ) { $ value = $ matches [ 1 ] ; return $ grammar -> wrap ( $ value ) ; } , $ query ) ; return $ pdo -> prepare ( $ query ) ; }
Parse and wrap the variables from query then return a propared PDO Statement instance .
768
public function getDoctrineConnection ( ) { $ driver = $ this -> getDoctrineDriver ( ) ; $ data = array ( 'pdo' => $ this -> pdo , 'dbname' => $ this -> getConfig ( 'database' ) ) ; return new DoctrineConnection ( $ data , $ driver ) ; }
Get the Doctrine DBAL database connection instance .
769
public function getCacheManager ( ) { if ( $ this -> cache instanceof Closure ) { $ this -> cache = call_user_func ( $ this -> cache ) ; } return $ this -> cache ; }
Get the cache manager instance .
770
public function wrap ( Closure $ callback , array $ parameters = array ( ) ) { return function ( ) use ( $ callback , $ parameters ) { return $ this -> call ( $ callback , $ parameters ) ; } ; }
Wrap the given closure such that its dependencies will be injected when executed .
771
protected function resolvingCallback ( Closure $ callback ) { $ abstract = $ this -> getFunctionHint ( $ callback ) ; if ( $ abstract ) { $ this -> resolvingCallbacks [ $ abstract ] [ ] = $ callback ; } else { $ this -> globalResolvingCallbacks [ ] = $ callback ; } }
Register a new resolving callback by type of its first argument .
772
protected function afterResolvingCallback ( Closure $ callback ) { $ abstract = $ this -> getFunctionHint ( $ callback ) ; if ( $ abstract ) { $ this -> afterResolvingCallbacks [ $ abstract ] [ ] = $ callback ; } else { $ this -> globalAfterResolvingCallbacks [ ] = $ callback ; } }
Register a new after resolving callback by type of its first argument .
773
protected function getFunctionHint ( Closure $ callback ) { $ function = new ReflectionFunction ( $ callback ) ; if ( $ function -> getNumberOfParameters ( ) == 0 ) { return ; } $ expected = $ function -> getParameters ( ) [ 0 ] ; if ( ! $ expected -> getClass ( ) ) { return ; } return $ expected -> getClass ( ) -> name ; }
Get the type hint for this closure s first argument .
774
protected function fireCallbackArray ( $ object , array $ callbacks ) { foreach ( $ callbacks as $ callback ) { call_user_func ( $ callback , $ object , $ this ) ; } }
Fire an array of callbacks with an object .
775
public function create ( $ type , $ options = array ( ) , $ content = array ( ) , $ segment_opts = array ( ) , $ type_opts = array ( ) ) { if ( ! in_array ( $ type , array ( "regular" , "plaintext" , "absplit" , "rss" , "auto" ) ) ) { throw new \ Exception ( 'the Campaign Type has to be one of "regular", "plaintext", "absplit", "rss", "auto" ' ) ; } $ payload = array ( 'type' => $ type , 'options' => $ options , 'content' => $ content , 'segment_opts' => $ segment_opts , 'type_opts' => $ type_opts ) ; $ apiCall = 'campaigns/create' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return isset ( $ data ) ? $ data : false ; }
Create a new draft campaign to send . You can not have more than 32 000 campaigns in your account .
776
public function get ( $ filters = array ( ) , $ start = 0 , $ limit = 25 , $ sort_field = 'create_time' , $ sort_dir = "DESC" ) { if ( ! in_array ( strtolower ( $ sort_field ) , array ( "create_time" , "send_time" , "title" , "subject" ) ) ) throw new \ Exception ( 'sort_field has to be one of "create_time", "send_time", "title", "subject" ' ) ; if ( ! in_array ( strtoupper ( $ sort_dir ) , array ( "ASC" , "DESC" ) ) ) throw new \ Exception ( 'sort_dir has to be one of "ASC", "DESC" ' ) ; $ payload = array ( 'filters' => $ filters , 'start' => $ start , 'limit' => $ limit , 'sort_field' => $ sort_field , 'sort_dir' => $ sort_dir ) ; $ apiCall = 'campaigns/list' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return isset ( $ data ) ? $ data : false ; }
Get the list of campaigns and their details matching the specified filters
777
public function del ( ) { $ payload = array ( 'cid' => $ this -> cid ) ; $ apiCall = 'campaigns/delete' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return true ; }
Delete a campaign . Seriously poof gone! - be careful! Seriously no one can undelete these .
778
public function templateContent ( ) { $ payload = array ( 'cid' => $ this -> cid ) ; $ apiCall = 'campaigns/template-content' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return isset ( $ data ) ? $ data : false ; }
Get the HTML template content sections for a campaign . Note that this will return very jagged non - standard results based on the template a campaign is using . You only want to use this if you want to allow editing template sections in your application .
779
public function schedule ( $ schedule_time , $ schedule_time_b = null ) { $ payload = array ( 'cid' => $ this -> cid , 'schedule_time' => $ schedule_time , 'schedule_time_b' => $ schedule_time_b ) ; $ apiCall = 'campaigns/schedule' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return true ; }
Schedule a campaign to be sent in the future
780
public function scheduleBatch ( $ schedule_time , $ num_batches = 2 , $ stagger_mins = 5 ) { $ payload = array ( 'cid' => $ this -> cid , 'schedule_time' => $ schedule_time , 'num_batches' => $ num_batches , 'stagger_mins' => $ stagger_mins ) ; $ apiCall = 'campaigns/schedule-batch' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return true ; }
Schedule a campaign to be sent in batches sometime in the future . Only valid for regular campaigns
781
public function update ( $ name , $ value ) { $ payload = array ( 'cid' => $ this -> cid , 'name' => $ name , 'value' => $ value ) ; $ apiCall = 'campaigns/update' ; $ data = $ this -> requestMonkey ( $ apiCall , $ payload ) ; $ data = json_decode ( $ data , true ) ; if ( isset ( $ data [ 'error' ] ) ) throw new MailchimpAPIException ( $ data ) ; else return true ; }
Update just about any setting besides type for a campaign that has not been sent
782
public function dropIfExists ( $ table ) { $ blueprint = $ this -> createBlueprint ( $ table ) ; $ blueprint -> dropIfExists ( ) ; $ this -> build ( $ blueprint ) ; }
Drop a table from the schema if it exists .
783
protected function getForeignKey ( $ foreign ) { $ on = $ this -> wrapTable ( $ foreign -> on ) ; $ columns = $ this -> columnize ( $ foreign -> columns ) ; $ onColumns = $ this -> columnize ( ( array ) $ foreign -> references ) ; return ", foreign key($columns) references $on($onColumns)" ; }
Get the SQL for the foreign key .
784
protected function addPrimaryKeys ( Blueprint $ blueprint ) { $ primary = $ this -> getCommandByName ( $ blueprint , 'primary' ) ; if ( ! is_null ( $ primary ) ) { $ columns = $ this -> columnize ( $ primary -> columns ) ; return ", primary key ({$columns})" ; } }
Get the primary key syntax for a table creation statement .
785
public function provideSymfonyService ( $ name , $ symfonyName = null ) { if ( null === $ symfonyName ) { $ symfonyName = $ name ; } if ( parent :: offsetExists ( $ name ) ) { throw new \ LogicException ( sprintf ( 'Service %s has already been defined.' , $ name ) ) ; } $ this -> delegates [ $ name ] = $ symfonyName ; }
Provide a symfony service in this container .
786
public function offsetUnset ( $ id ) { if ( isset ( $ this -> delegates [ $ id ] ) ) { throw new \ LogicException ( sprintf ( 'Service %s has been delegated to symfony, cannot unset.' , $ id ) ) ; } @ trigger_error ( 'unset service: The pimple based DIC is deprecated, use the symfony DIC in new projects.' , E_USER_DEPRECATED ) ; parent :: offsetUnset ( $ id ) ; }
Unset a parameter or an object .
787
protected function getUsers ( ) { $ qb = $ this -> registry -> getManager ( ) -> createQueryBuilder ( ) ; $ qb -> select ( 'u' ) -> from ( $ this -> userClass , 'u' ) -> where ( $ qb -> expr ( ) -> like ( 'u.roles' , ':roles' ) ) -> setParameter ( 'roles' , '%"ROLE_SUPER_ADMIN"%' ) ; return $ qb -> getQuery ( ) -> iterate ( ) ; }
Returns corresponding users .
788
public function signature ( $ signature , $ private_key = false ) { $ signature = strtoupper ( $ signature ) ; if ( $ signature == 'RSA' || $ signature == 'RSA-SHA1' ) { if ( ! $ private_key ) { return false ; } $ this -> signature = new RsaSha1 ( $ private_key ) ; return true ; } elseif ( $ signature == 'HMAC' || $ signature == 'HMAC-SHA1' ) { $ this -> signature = new HmacSha1 ; return true ; } else { return false ; } }
Set the signing method to be used to encrypt request signature .
789
public function checkLogin ( $ tokenKey , $ tokenSecret , $ tokenVerifier ) { $ this -> token = new Consumer ( $ tokenKey , $ tokenSecret ) ; $ returnUrl = $ this -> base . $ this -> loc_api . $ this -> loc_return . $ this -> format . '/' ; $ req = Request :: from_consumer_and_token ( $ this -> consumer , $ this -> token , "POST" , $ returnUrl , array ( 'oauth_token' => $ tokenKey , 'oauth_verifier' => $ tokenVerifier ) ) ; $ req -> sign_request ( $ this -> signature , $ this -> consumer , $ this -> token ) ; $ response = $ this -> curlRequest ( $ returnUrl , $ req -> to_postdata ( ) ) ; if ( $ response ) { $ sso = $ this -> responseFormat ( $ response ) ; if ( $ sso -> request -> result == 'success' ) { $ this -> token = false ; return $ sso ; } else { $ this -> error = array ( 'type' => 'oauth_response' , 'code' => false , 'message' => $ sso -> request -> message ) ; return false ; } } else { return false ; } }
Obtains a user s login details from a token key and secret
790
public function edit ( Listener $ listener ) { $ eloquent = Auth :: user ( ) ; $ form = $ this -> presenter -> password ( $ eloquent ) ; return $ listener -> showPasswordChanger ( [ 'eloquent' => $ eloquent , 'form' => $ form ] ) ; }
Get password information .
791
public function update ( Listener $ listener , array $ input ) { $ user = Auth :: user ( ) ; if ( ! $ this -> validateCurrentUser ( $ user , $ input ) ) { return $ listener -> abortWhenUserMismatched ( ) ; } $ validation = $ this -> validator -> on ( 'changePassword' ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> updatePasswordFailedValidation ( $ validation -> getMessageBag ( ) ) ; } if ( ! Hash :: check ( $ input [ 'current_password' ] , $ user -> password ) ) { return $ listener -> verifyCurrentPasswordFailed ( ) ; } try { $ this -> saving ( $ user , $ input ) ; } catch ( Exception $ e ) { return $ listener -> updatePasswordFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> passwordUpdated ( ) ; }
Update password information .
792
public function create ( Listener $ listener ) { $ eloquent = Foundation :: make ( 'orchestra.user' ) ; $ form = $ this -> presenter -> profile ( $ eloquent , 'orchestra::register' ) ; $ form -> extend ( function ( $ form ) { $ form -> submit = 'orchestra/foundation::title.register' ; } ) ; $ this -> fireEvent ( 'form' , [ $ eloquent , $ form ] ) ; return $ listener -> showProfileCreator ( compact ( 'eloquent' , 'form' ) ) ; }
View registration page .
793
protected function notifyCreatedUser ( Listener $ listener , Eloquent $ user , ? string $ temporaryPassword ) { try { $ user -> sendWelcomeNotification ( $ temporaryPassword ) ; } catch ( Exception $ e ) { return $ listener -> profileCreatedWithoutNotification ( ) ; } return $ listener -> profileCreated ( ) ; }
Send new registration e - mail to user .
794
protected function saving ( Eloquent $ user , array $ input , $ password ) { $ user -> setAttribute ( 'email' , $ input [ 'email' ] ) ; $ user -> setAttribute ( 'fullname' , $ input [ 'fullname' ] ) ; $ user -> setAttribute ( 'password' , $ password ) ; $ this -> fireEvent ( 'creating' , [ $ user ] ) ; $ this -> fireEvent ( 'saving' , [ $ user ] ) ; $ user -> saveOrFail ( ) ; $ this -> fireEvent ( 'created' , [ $ user ] ) ; $ this -> fireEvent ( 'saved' , [ $ user ] ) ; }
Saving new user .
795
public static function progressbar ( $ title , $ numerator , $ denominator , $ line , $ time_id = null , $ color = 'cyan' ) { static $ timer = array ( ) ; if ( $ time_id ) { if ( ! isset ( $ timer [ $ time_id ] ) || $ timer [ $ time_id ] [ 'last_numerator' ] > $ numerator ) { $ timer [ $ time_id ] = array ( 'start' => microtime ( true ) ) ; } $ timer [ $ time_id ] [ 'last_numerator' ] = $ numerator ; } $ text = $ title . ' - ' . self :: num_display ( $ numerator ) . '/' . self :: num_display ( $ denominator ) ; $ time_text = '' ; if ( $ time_id ) { $ diff = microtime ( true ) - $ timer [ $ time_id ] [ 'start' ] ; $ time_left = self :: formtime ( ( $ numerator ? $ diff / $ numerator : 0 ) * ( $ denominator - $ numerator ) ) ; $ elapsed = self :: formtime ( $ diff ) ; if ( $ diff > 2 ) { $ time_text = $ time_left . " ($elapsed)" ; } } $ width = max ( min ( Misc :: cols ( ) - strlen ( $ text ) - ( strlen ( $ time_text ) ? : - 1 ) - 6 , $ denominator ) , 4 ) ; $ main_xs = floor ( ( $ numerator / $ denominator ) * $ width ) ; $ str = $ text . ' [' . Style :: $ color ( str_repeat ( '#' , $ main_xs ) ) . str_repeat ( '.' , $ width - $ main_xs ) . "] " . $ time_text ; Output :: line ( $ str , $ line ) ; }
Draw a Progress Bar
796
public function update ( Listener $ listener , Fluent $ extension , array $ input ) { if ( ! Extension :: started ( $ extension -> get ( 'name' ) ) ) { return $ listener -> suspend ( 404 ) ; } $ validation = $ this -> validator -> with ( $ input , [ "orchestra.validate: extension.{$extension->get('name')}" ] ) ; if ( $ validation -> fails ( ) ) { return $ listener -> updateConfigurationFailedValidation ( $ validation -> getMessageBag ( ) , $ extension -> uid ) ; } $ input [ 'handles' ] = str_replace ( [ '{domain}' , '{{domain}}' ] , '{{domain}}' , $ input [ 'handles' ] ) ; unset ( $ input [ '_token' ] ) ; $ memory = Foundation :: memory ( ) ; $ config = ( array ) $ memory -> get ( "extension.active.{$extension->get('name')}.config" , [ ] ) ; $ input = new Fluent ( \ array_merge ( $ config , $ input ) ) ; Event :: dispatch ( "orchestra.saving: extension.{$extension->get('name')}" , [ & $ input ] ) ; $ memory -> put ( "extensions.active.{$extension->get('name')}.config" , $ input -> getAttributes ( ) ) ; $ memory -> put ( "extension_{$extension->get('name')}" , $ input -> getAttributes ( ) ) ; Event :: dispatch ( "orchestra.saved: extension.{$extension->get('name')}" , [ $ input ] ) ; return $ listener -> configurationUpdated ( $ extension ) ; }
Update an extension configuration .
797
public function view ( UserViewerListener $ listener , array $ input = [ ] ) { $ search = [ 'keyword' => $ input [ 'q' ] ?? '' , 'roles' => $ input [ 'roles' ] ?? [ ] , ] ; $ eloquent = Foundation :: make ( 'orchestra.user' ) -> search ( $ search [ 'keyword' ] ) -> hasRolesId ( $ search [ 'roles' ] ) ; $ roles = Foundation :: make ( 'orchestra.role' ) -> pluck ( 'name' , 'id' ) ; $ table = $ this -> presenter -> table ( $ eloquent ) ; Event :: dispatch ( 'orchestra.list: users' , [ $ eloquent , $ table ] ) ; $ this -> presenter -> actions ( $ table ) ; $ data = [ 'eloquent' => $ eloquent , 'roles' => $ roles , 'table' => $ table , 'search' => $ search , ] ; return $ listener -> showUsers ( $ data ) ; }
View list users page .
798
public function edit ( UserUpdaterListener $ listener , $ id ) { $ eloquent = Foundation :: make ( 'orchestra.user' ) -> findOrFail ( $ id ) ; $ form = $ this -> presenter -> form ( $ eloquent , 'update' ) ; $ this -> fireEvent ( 'form' , [ $ eloquent , $ form ] ) ; return $ listener -> showUserChanger ( \ compact ( 'eloquent' , 'form' ) ) ; }
View edit user page .
799
public function store ( UserCreatorListener $ listener , array $ input ) { $ validation = $ this -> validator -> on ( 'create' ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { return $ listener -> createUserFailedValidation ( $ validation -> getMessageBag ( ) ) ; } $ user = Foundation :: make ( 'orchestra.user' ) ; $ user -> status = Eloquent :: UNVERIFIED ; $ user -> password = $ input [ 'password' ] ; try { $ this -> saving ( $ user , $ input , 'create' ) ; } catch ( Exception $ e ) { return $ listener -> createUserFailed ( [ 'error' => $ e -> getMessage ( ) ] ) ; } return $ listener -> userCreated ( ) ; }
Store a user .