idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
52,300
public function afterConsume ( int $ type ) : void { if ( ! $ this -> currentlyEscaping && $ type === AnnotationLexer :: T_BACKSLASH ) { $ this -> currentlyEscaping = true ; } else { $ this -> currentlyEscaping = false ; } }
A method that is executed after consuming a token .
52,301
public static function getRoot ( NodeInterface $ parent ) : ? PhpFileModelInterface { while ( $ parent !== null ) { if ( $ parent instanceof PhpFileModelInterface ) { return $ parent ; } $ parent = $ parent -> getParentNode ( ) ; } return null ; }
Get the root of the node .
52,302
protected function validate ( $ config ) : void { if ( ! Validator :: arrayType ( ) -> validate ( $ config ) ) { throw new InvalidConfigException ( 'The config must be an array.' ) ; } if ( ! Validator :: key ( 'interface' , Validator :: boolType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"interface" parameter must be set as a boolean.' ) ; } if ( ! Validator :: key ( 'private' , Validator :: boolType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"private" parameter must be set as a boolean.' ) ; } if ( ! Validator :: key ( 'auto' , Validator :: boolType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"auto" parameter must be set as a boolean.' ) ; } $ this -> validatePhpdoc ( $ config ) ; }
Validate a configuration to know if it can be used to construct an instance .
52,303
private function validatePhpdoc ( $ config ) : void { if ( ! Validator :: key ( 'phpdoc' , Validator :: arrayType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"phpdoc" parameter is not an array.' ) ; } if ( ! Validator :: arrayVal ( ) -> each ( Validator :: stringType ( ) , Validator :: stringType ( ) ) -> validate ( $ config [ 'phpdoc' ] ) ) { throw new InvalidConfigException ( 'Some annotation in "phpdoc" parameter are not strings.' ) ; } }
Validate the phpdoc key in the config array .
52,304
private function autoGetterOrSetter ( FunctionModel $ function , InterfaceModelInterface $ parent ) : bool { if ( $ this -> config -> hasAuto ( ) && $ parent instanceof TraitModelInterface ) { if ( $ this -> getter ( $ function , $ parent ) ) { return true ; } if ( $ this -> setter ( $ function , $ parent ) ) { return true ; } } return false ; }
Check if auto generation is enabled and try to generate getter or setter annotation .
52,305
private function getter ( FunctionModel $ function , TraitModelInterface $ parent ) : bool { preg_match ( '/^get(.+)$/' , $ function -> getName ( ) , $ matches ) ; if ( Validator :: arrayType ( ) -> length ( 2 , 2 ) -> validate ( $ matches ) ) { $ property = lcfirst ( $ matches [ 1 ] ) ; if ( $ parent -> hasAttribute ( $ property , $ function -> isStatic ( ) ) ) { $ annotation = new GetAnnotation ( ) ; $ annotation -> setName ( '@PhpUnitGen\\getter' ) ; $ function -> addAnnotation ( $ annotation ) ; $ annotation -> setParentNode ( $ function ) ; $ annotation -> compile ( ) ; return true ; } } return false ; }
Try to create a getter annotation for function .
52,306
protected function getConfiguration ( InputInterface $ input ) : ConsoleConfigInterface { if ( $ input -> getOption ( 'default' ) ) { $ this -> validatePathsExist ( $ input ) ; if ( $ input -> getOption ( 'dir' ) ) { return ( new DefaultConsoleConfigFactory ( ) ) -> invokeDir ( $ input -> getArgument ( 'source' ) , $ input -> getArgument ( 'target' ) ) ; } return ( new DefaultConsoleConfigFactory ( ) ) -> invokeFile ( $ input -> getArgument ( 'source' ) , $ input -> getArgument ( 'target' ) ) ; } $ path = $ input -> getOption ( 'config' ) ; $ path = preg_replace ( '/^\=/' , '' , $ path ) ; $ factory = $ this -> getConfigurationFactory ( $ path ) ; if ( $ input -> getOption ( 'dir' ) ) { $ this -> validatePathsExist ( $ input ) ; return $ factory -> invokeDir ( $ path , $ input -> getArgument ( 'source' ) , $ input -> getArgument ( 'target' ) ) ; } if ( $ input -> getOption ( 'file' ) ) { $ this -> validatePathsExist ( $ input ) ; return $ factory -> invokeFile ( $ path , $ input -> getArgument ( 'source' ) , $ input -> getArgument ( 'target' ) ) ; } return $ factory -> invoke ( $ path ) ; }
Build a configuration from a configuration file path .
52,307
protected function getConfigurationFactory ( string $ path ) : AbstractConsoleConfigFactory { if ( ! file_exists ( $ path ) ) { throw new InvalidConfigException ( sprintf ( 'Config file "%s" does not exists' , $ path ) ) ; } $ extension = pathinfo ( $ path , PATHINFO_EXTENSION ) ; if ( ! Validator :: key ( $ extension ) -> validate ( static :: CONSOLE_CONFIG_FACTORIES ) ) { throw new InvalidConfigException ( sprintf ( 'Config file "%s" must have .yml, .json or .php extension' , $ path ) ) ; } $ factoryClass = static :: CONSOLE_CONFIG_FACTORIES [ $ extension ] ; return new $ factoryClass ( ) ; }
Get the configuration factory depending on configuration path .
52,308
protected function validatePathsExist ( InputInterface $ input ) : void { if ( ! is_string ( $ input -> getArgument ( 'source' ) ) ) { throw new Exception ( 'Missing the source path' ) ; } if ( ! is_string ( $ input -> getArgument ( 'target' ) ) ) { throw new Exception ( 'Missing the target path' ) ; } }
Throw an exception if the source or the target path is missing .
52,309
public function checkTargetPath ( string $ targetPath ) : void { if ( $ this -> fileSystem -> has ( $ targetPath ) ) { if ( ! $ this -> config -> hasOverwrite ( ) ) { throw new FileExistsException ( sprintf ( 'The target file "%s" already exists' , $ targetPath ) ) ; } if ( $ this -> config -> hasBackup ( ) ) { $ backupTarget = $ targetPath . '.bak' ; if ( $ this -> fileSystem -> has ( $ backupTarget ) ) { throw new FileExistsException ( sprintf ( 'The backup target file "%s" already exists' , $ backupTarget ) ) ; } $ this -> fileSystem -> copy ( $ targetPath , $ backupTarget ) ; } $ this -> fileSystem -> delete ( $ targetPath ) ; } }
Check if an old file exists . If overwrite option is activated delete it else throw an exception .
52,310
private function executeFileExecutor ( string $ sourcePath , string $ targetPath , string $ filePath ) : void { try { $ name = pathinfo ( $ filePath ) [ 'filename' ] . 'Test' ; $ targetPath = str_replace ( $ sourcePath , $ targetPath , $ filePath ) ; $ targetPath = preg_replace ( '/(.php|.phtml)/' , 'Test.php' , $ targetPath ) ; $ this -> fileExecutor -> invoke ( $ filePath , $ targetPath , $ name ) ; } catch ( Exception $ exception ) { $ this -> exceptionCatcher -> catch ( $ exception , $ filePath ) ; } }
Execute the file executor for a file in a directory .
52,311
public static function getVisibility ( Node \ Stmt \ ClassMethod $ method ) : int { if ( $ method -> isPrivate ( ) ) { return VisibilityInterface :: PRIVATE ; } if ( $ method -> isProtected ( ) ) { return VisibilityInterface :: PROTECTED ; } return VisibilityInterface :: PUBLIC ; }
Get the visibility of a method .
52,312
public function invoke ( array $ parameters ) : string { $ string = '' ; foreach ( $ parameters as $ parameter ) { $ string .= $ parameter . ', ' ; } return substr ( $ string , 0 , - 2 ) ; }
Convert an array of string parameters in string with each parameters separated with a .
52,313
private function validatePath ( string $ path ) : bool { if ( ! $ this -> fileSystem -> has ( $ path ) ) { throw new FileNotFoundException ( sprintf ( 'The source file "%s" does not exist.' , $ path ) ) ; } if ( $ this -> fileSystem -> get ( $ path ) -> getType ( ) === 'dir' ) { return false ; } return true ; }
Validate file has a valid path .
52,314
private function validateIncludeRegex ( string $ path ) : bool { $ includeRegex = $ this -> config -> getIncludeRegex ( ) ; return $ includeRegex === null || Validator :: regex ( $ includeRegex ) -> validate ( $ path ) === true ; }
Validate file has the include regex if this regex is set .
52,315
private function validateExcludeRegex ( string $ path ) : bool { $ excludeRegex = $ this -> config -> getExcludeRegex ( ) ; return $ excludeRegex === null || Validator :: regex ( $ excludeRegex ) -> validate ( $ path ) !== true ; }
Validate file has not the exclude regex if this regex is set .
52,316
public function preParseUses ( array $ nodes , PhpFileModelInterface $ parent ) : void { foreach ( $ nodes as $ node ) { if ( $ node instanceof Use_ ) { $ this -> useNodeParser -> invoke ( $ node , $ parent ) ; } else { if ( $ node instanceof GroupUse ) { $ this -> groupUseNodeParser -> invoke ( $ node , $ parent ) ; } } } }
Pre parse uses in nodes .
52,317
public static function getVisibility ( Node \ Stmt \ Property $ property ) : int { if ( $ property -> isPrivate ( ) ) { return VisibilityInterface :: PRIVATE ; } if ( $ property -> isProtected ( ) ) { return VisibilityInterface :: PROTECTED ; } return VisibilityInterface :: PUBLIC ; }
Get the visibility of a property .
52,318
public function view ( UserPolicy $ user , Calendar $ calendar ) { if ( $ user -> canDo ( 'calendar.calendar.view' ) && $ user -> hasRole ( 'admin' ) ) { return true ; } if ( $ user -> isUser ( ) || $ user -> isAdmin ( ) ) { return true ; } return $ user -> id == $ calendar -> user_id && get_class ( $ user ) == $ calendar -> user_type ; }
Determine if the given user can view the calendar .
52,319
public function destroy ( UserPolicy $ user , Calendar $ calendar ) { return $ user -> id == $ calendar -> user_id && get_class ( $ user ) == $ calendar -> user_type ; }
Determine if the given user can delete the given calendar .
52,320
public function count ( $ type = 'admin.web' ) { return $ this -> calendar -> scopeQuery ( function ( $ query ) use ( $ type ) { return $ query -> where ( 'status' , '<>' , 'Draft' ) -> whereUserId ( user_id ( $ type ) ) -> whereUserType ( user_type ( $ type ) ) ; } ) -> count ( ) ; }
Returns count of calendar .
52,321
public function display ( $ view , $ count = 10 ) { $ data = $ this -> calendar -> scopeQuery ( function ( $ query ) use ( $ count ) { return $ query -> where ( 'status' , '<>' , 'Draft' ) -> orderBy ( 'id' , 'DESC' ) -> take ( $ count ) ; } ) -> all ( ) ; return view ( 'calendar::admin.calendar.' . $ view , compact ( 'data' ) ) ; }
Display Calendar of the user .
52,322
public function users ( ) { $ list = [ ] ; $ users = User :: all ( ) ; foreach ( $ users as $ key => $ user ) { $ list [ $ user -> id ] = $ user -> name ; } return $ list ; }
Make Users list .
52,323
public function show ( CalendarRequest $ request , Calendar $ calendar ) { if ( $ calendar -> exists ) { $ view = 'calendar::calendar.show' ; } else { $ view = 'calendar::calendar.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'calendar::calendar.name' ) ) -> data ( compact ( 'calendar' ) ) -> view ( $ view , true ) -> output ( ) ; }
Display calendar .
52,324
public function create ( CalendarRequest $ request ) { $ calendar = $ this -> repository -> newInstance ( [ ] ) ; $ calendar [ 'start' ] = request ( 'start' ) ; $ calendar [ 'end' ] = request ( 'end' ) ; Form :: populate ( $ calendar ) ; return $ this -> response -> title ( trans ( 'app.create' ) . ' ' . trans ( 'calendar::calendar.name' ) ) -> data ( compact ( 'calendar' ) ) -> view ( 'calendar::calendar.create' , true ) -> output ( ) ; }
Show the form for creating a new calendar .
52,325
public function store ( CalendarRequest $ request ) { try { $ attributes = $ request -> all ( ) ; $ attributes [ 'user_id' ] = user_id ( ) ; $ attributes [ 'user_type' ] = user_type ( ) ; $ calendar = $ this -> repository -> create ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.created' , [ 'Module' => trans ( 'calendar::calendar.name' ) ] ) ) -> code ( 204 ) -> status ( 'success' ) -> url ( trans_url ( $ this -> getGuardRoute ( ) . '/calendar/calendar/' . $ calendar -> getRouteKey ( ) ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( trans_url ( $ this -> getGuardRoute ( ) . '/calendar/calendar' ) ) -> redirect ( ) ; } }
Create new calendar .
52,326
public function edit ( CalendarRequest $ request , Calendar $ calendar ) { Form :: populate ( $ calendar ) ; return response ( ) -> view ( 'calendar::admin.calendar.edit' , compact ( 'calendar' ) ) ; }
Show calendar for editing .
52,327
public function update ( CalendarRequest $ request , Calendar $ calendar ) { try { $ attributes = $ request -> all ( ) ; $ calendar -> update ( $ attributes ) ; return response ( ) -> json ( [ 'message' => trans ( 'messages.success.updated' , [ 'Module' => trans ( 'calendar::calendar.name' ) ] ) , 'code' => 204 , 'redirect' => trans_url ( '/admin/calendar/calendar/' ) , ] , 201 ) ; } catch ( Exception $ e ) { return response ( ) -> json ( [ 'message' => $ e -> getMessage ( ) , 'code' => 400 , 'redirect' => trans_url ( '/admin/calendar/calendar/' ) , ] , 400 ) ; } }
Update the calendar .
52,328
public function destroy ( CalendarRequest $ request , Calendar $ calendar ) { try { $ t = $ calendar -> delete ( ) ; return response ( ) -> json ( [ 'message' => trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'calendar::calendar.name' ) ] ) , 'code' => 202 , 'redirect' => trans_url ( '/admin/calendar/calendar/0' ) , ] , 202 ) ; } catch ( Exception $ e ) { return response ( ) -> json ( [ 'message' => $ e -> getMessage ( ) , 'code' => 400 , 'redirect' => trans_url ( '/admin/calendar/calendar/' . $ calendar -> getRouteKey ( ) ) , ] , 400 ) ; } }
Remove the calendar .
52,329
public function calendarList ( ) { $ arr = $ this -> repository -> scopeQuery ( function ( $ query ) { return $ query -> where ( 'status' , '!=' , 'Draft' ) ; } ) -> all ( ) ; $ temp = [ ] ; foreach ( $ arr as $ key => $ value ) { $ temp [ $ key ] [ 'id' ] = $ value -> getRouteKey ( ) ; $ temp [ $ key ] [ 'title' ] = $ value [ 'title' ] ; $ temp [ $ key ] [ 'start' ] = date ( 'Y-m-d H:i:s' , strtotime ( $ value [ 'start' ] ) ) ; $ temp [ $ key ] [ 'end' ] = date ( 'Y-m-d H:i:s' , strtotime ( $ value [ 'end' ] ) ) ; $ temp [ $ key ] [ 'className' ] = $ value [ 'color' ] ; } return json_encode ( $ temp ) ; }
display the calendarList .
52,330
protected function index ( ) { $ calendars = $ this -> repository -> pushCriteria ( new \ Litepie \ Calendar \ Repositories \ Criteria \ CalendarPublicCriteria ( ) ) -> scopeQuery ( function ( $ query ) { return $ query -> orderBy ( 'id' , 'DESC' ) ; } ) -> paginate ( ) ; return $ this -> theme -> of ( 'calendar::public.calendar.index' , compact ( 'calendars' ) ) -> render ( ) ; }
Show calendar s list .
52,331
protected function show ( $ slug ) { $ calendar = $ this -> repository -> scopeQuery ( function ( $ query ) use ( $ slug ) { return $ query -> orderBy ( 'id' , 'DESC' ) -> where ( 'slug' , $ slug ) ; } ) -> first ( [ '*' ] ) ; return $ this -> theme -> of ( 'calendar::public.calendar.show' , compact ( 'calendar' ) ) -> render ( ) ; }
Show calendar .
52,332
public function onCoreController ( FilterControllerEvent $ event ) { if ( ! is_array ( $ controller = $ event -> getController ( ) ) ) { return ; } $ class = new \ ReflectionClass ( $ controller [ 0 ] ) ; $ method = $ class -> getMethod ( $ controller [ 1 ] ) ; if ( $ classAnnotations = $ this -> reader -> getClassAnnotations ( $ class ) ) { foreach ( $ classAnnotations as $ classAnnotation ) { if ( $ classAnnotation instanceof Firewall ) { if ( is_array ( $ classAnnotation -> actions ) && in_array ( $ method -> name , $ classAnnotation -> actions ) ) { $ this -> loadFirewall ( $ classAnnotation ) ; } elseif ( $ classAnnotation -> actions === null ) { $ this -> loadFirewall ( $ classAnnotation ) ; } } } } if ( $ methodAnnotation = $ this -> reader -> getMethodAnnotation ( $ method , 'M6Web\Bundle\FirewallBundle\Annotation\Firewall' ) ) { $ this -> loadFirewall ( $ methodAnnotation ) ; } }
Event before action execution
52,333
protected function loadFirewall ( $ annotation ) { $ firewall = $ this -> provider -> getFirewall ( $ annotation -> config , $ annotation -> options ) ; $ firewall -> handle ( $ annotation -> options [ 'callback' ] ) ; }
Load firewall with a configuration
52,334
protected function loadConfig ( $ configName , array $ config ) { $ this -> configs [ $ configName ] = $ this -> normalizeConfig ( $ config ) ; return $ this ; }
Load a formated configuration
52,335
protected function loadPattern ( $ patternName , array $ pattern ) { $ pattern [ 'matcher' ] = new RequestMatcher ( $ pattern [ 'path' ] ) ; $ this -> patterns [ $ patternName ] = $ pattern ; return $ this ; }
Load a formated pattern
52,336
protected function normalizeConfig ( array $ config ) { foreach ( $ this -> configModel as $ elmt => $ settings ) { if ( ! isset ( $ config [ $ elmt ] ) ) { $ config [ $ elmt ] = $ settings [ 'default' ] ; } } foreach ( $ config as $ elmtName => $ value ) { if ( ! isset ( $ this -> configModel [ $ elmtName ] ) ) { unset ( $ config [ $ elmtName ] ) ; } } return $ config ; }
Format an array of configurations with the model
52,337
public function getFirewall ( $ configName = null , array $ options = array ( ) , Request $ request = null ) { if ( ! $ request ) { if ( $ this -> container -> has ( 'request_stack' ) ) { $ requestStack = $ this -> container -> get ( 'request_stack' ) ; $ request = $ requestStack -> getCurrentRequest ( ) ; } elseif ( $ this -> container -> has ( 'request' ) ) { $ request = $ this -> container -> get ( 'request' ) ; } else { throw new \ Exception ( 'Request object undefined' ) ; } } $ firewall = new $ this -> firewallClass ( ) ; $ firewall -> setProvider ( $ this ) ; $ firewall -> setRequest ( $ request ) ; $ this -> setDefaults ( $ firewall , $ configName , $ options ) ; $ this -> firewalls [ ] = $ firewall ; return $ firewall ; }
Get a firewall set with a predefined configuration or with additional setting
52,338
protected function setDefaults ( FirewallInterface $ firewall , $ configName = null , array $ options = array ( ) ) { $ config = $ this -> getNormalizedConfig ( $ configName ) ; $ this -> mergeOptions ( $ config , $ options ) ; foreach ( $ config as $ paramName => $ paramValue ) { $ this -> setDefault ( $ firewall , $ paramName , $ paramValue , $ config ) ; } return $ this ; }
Configure a firewall
52,339
protected function setDefault ( FirewallInterface $ firewall , $ param , $ value , $ config ) { $ configModel = $ this -> configModel [ $ param ] ; switch ( $ param ) { case 'lists' : if ( is_array ( $ value ) ) { $ this -> setDefaultLists ( $ firewall , $ value ) ; } break ; case 'entries' : $ this -> setEntries ( $ firewall , $ config , $ value ) ; break ; default : if ( ! is_null ( $ value ) ) { $ method = $ configModel [ 'method' ] ; $ firewall -> $ method ( $ value ) ; } } return $ this ; }
Set a default value for a configuration parameter
52,340
protected function setDefaultLists ( FirewallInterface $ firewall , array $ lists ) { foreach ( $ lists as $ listName => $ state ) { if ( isset ( $ this -> lists [ $ listName ] ) ) { $ list = $ this -> lists [ $ listName ] ; $ firewall -> addList ( $ list , $ listName , $ state ) ; } else { throw new \ Exception ( sprintf ( 'Firewall list "%s" not found.' , $ listName ) ) ; } } return $ this ; }
Set the default lists of the firewall
52,341
protected function setEntries ( FirewallInterface $ firewall , $ config ) { $ entries = ( isset ( $ config [ 'entries' ] ) ? $ config [ 'entries' ] : array ( ) ) ; $ blackEntries = array_keys ( $ entries , false ) ; $ whiteEntries = array_keys ( $ entries , true ) ; if ( count ( $ blackEntries ) ) { $ firewall -> addList ( $ blackEntries , 'blackedOptions' , false ) ; } if ( count ( $ whiteEntries ) ) { $ firewall -> addList ( $ whiteEntries , 'whitedOptions' , true ) ; } return $ this ; }
Set up firewall lists from independent input
52,342
protected function getNormalizedConfig ( $ configName = null ) { if ( isset ( $ this -> configs [ $ configName ] ) ) { $ config = $ this -> configs [ $ configName ] ; } elseif ( $ configName === null ) { $ arr = array ( ) ; $ config = $ this -> normalizeConfig ( $ arr ) ; } else { throw new \ Exception ( sprintf ( 'Firewall configuration "%s" not found.' , $ configName ) ) ; } return $ config ; }
Get the normalized configuration
52,343
protected function mergeOptions ( & $ config , $ options ) { foreach ( $ config as $ paramName => $ paramValue ) { if ( isset ( $ options [ $ paramName ] ) ) { if ( is_array ( $ paramValue ) ) { $ config [ $ paramName ] = array_merge ( $ config [ $ paramName ] , $ options [ $ paramName ] ) ; } else { $ config [ $ paramName ] = $ options [ $ paramName ] ; } } } return $ config ; }
Include on the fly generated options in the main configuration
52,344
public function onRequest ( GetResponseEvent $ event ) { if ( HttpKernelInterface :: MASTER_REQUEST !== $ event -> getRequestType ( ) ) { return ; } $ patterns = $ this -> provider -> getPatterns ( ) ; if ( $ patterns ) { foreach ( $ patterns as $ pattern ) { if ( $ pattern [ 'matcher' ] -> matches ( $ event -> getRequest ( ) ) ) { $ firewall = $ this -> provider -> getFirewall ( $ pattern [ 'config' ] ) ; $ firewall -> handle ( ) ; } } } }
on request event
52,345
public function getHttpMethod ( ) { switch ( $ this -> method ) { case Method :: LINK : return Method :: POST ; case Method :: UNLINK : return Method :: DELETE ; default : return $ this -> method ; } }
Return a HTTP safe method .
52,346
public function resource ( $ resourceDefinition ) { $ parameter = new ResourceParameter ( $ resourceDefinition ) ; $ parameter -> setRoute ( $ this -> route ) ; $ this -> parameters [ $ resourceDefinition ] = $ parameter ; return $ parameter ; }
Define the resource that can be sent with the request . Note that this method will not generate actual parameters but instead will let the InputParsers know this resource can be expected .
52,347
public function isViewable ( $ action = null ) { if ( $ action === Action :: IDENTIFIER ) { return false ; } return $ this -> isVisible ( $ action ) ; }
Can this field be viewed?
52,348
public function getPropertyName ( ) : string { if ( ! empty ( $ this -> path ) ) { return $ this -> path . '.' . $ this -> getDisplayName ( ) ; } else { return $ this -> getDisplayName ( ) ; } }
Return the human readable path of the property .
52,349
public function getEntityName ( $ plural = false ) { $ entityClassName = $ this -> getEntityClassName ( ) ; if ( $ entityClassName !== null ) { $ entityName = ObjectHelper :: class_basename ( $ entityClassName ) ; } else { $ entityName = ObjectHelper :: class_basename ( $ this ) ; } if ( $ plural ) { return StringHelper :: plural ( $ entityName , is_numeric ( $ plural ) ? $ plural : 2 ) ; } else { return $ entityName ; } }
Similar to getEntityClassName but instead returns a human readable name .
52,350
public function getRoutes ( ) { $ out = [ ] ; foreach ( $ this -> routes as $ route ) { $ out [ ] = $ route ; } foreach ( $ this -> children as $ child ) { foreach ( $ child -> getRoutes ( ) as $ route ) { $ out [ ] = $ route ; } } return $ out ; }
Return a flat list of routes
52,351
public function findFromPath ( $ path , $ method = null ) { foreach ( $ this -> getRoutes ( ) as $ route ) { if ( $ matchedRoute = $ route -> matches ( $ path , $ method ) ) { return $ matchedRoute ; } } return null ; }
Find a route based on method and path .
52,352
public function index ( $ contentType ) { $ pets = PetFactory :: instance ( ) -> getAll ( ) ; $ transformer = new ResourceTransformer ( ) ; $ context = $ this -> getContext ( Action :: INDEX ) ; $ resources = $ transformer -> toResources ( PetDefinition :: class , $ pets , $ context ) ; $ this -> outputResources ( $ resources , $ contentType ) ; }
Get an index of all pets .
52,353
public function hasPropertyInput ( ResourceTransformer $ transformer , & $ input , Field $ field , Context $ context ) : bool { return array_key_exists ( $ field -> getDisplayName ( ) , $ input ) ; }
Check if input contains data .
52,354
public function hasRelationshipInput ( ResourceTransformer $ transformer , & $ input , RelationshipField $ field , Context $ context ) : bool { return $ this -> hasPropertyInput ( $ transformer , $ input , $ field , $ context ) ; }
Check if relationship data exists in input .
52,355
protected function hasInputIdentifier ( ResourceTransformer $ transformer , ResourceDefinition $ resourceDefinition , Context $ context , & $ input ) { $ identifiers = $ resourceDefinition -> getFields ( ) -> getIdentifiers ( ) ; if ( count ( $ identifiers ) > 0 ) { foreach ( $ identifiers as $ field ) { try { $ value = $ this -> resolvePropertyInput ( $ transformer , $ input , $ field , $ context ) ; if ( ! $ value ) { return false ; } } catch ( ValueUndefined $ e ) { return false ; } } return true ; } return false ; }
Return TRUE if the input has an id and thus is an edit of an existing field .
52,356
public function getAllowedValues ( ) { $ inArrayFilters = $ this -> getRequirements ( ) -> filter ( function ( $ value ) { return $ value instanceof InArray ; } ) ; if ( count ( $ inArrayFilters ) > 0 ) { return $ inArrayFilters -> first ( ) -> getValues ( ) ; } return [ ] ; }
Is only a selected set of values allowed?
52,357
public function getIncludedInContext ( Context $ context , CurrentPath $ path = null ) { if ( ! isset ( $ path ) ) { $ path = new CurrentPath ( ) ; } $ out = new self ( ) ; foreach ( $ this as $ v ) { if ( $ v -> shouldInclude ( $ context , $ path ) ) { $ out [ ] = $ v ; } } return $ out ; }
Get all resource fields that should be included in a given context
52,358
public function editChildren ( ResourceTransformer $ transformer , $ entity , RelationshipField $ field , array $ childEntities , Context $ context ) { list ( $ entity , $ name , $ parameters ) = $ this -> resolvePath ( $ transformer , $ entity , $ field , $ context ) ; $ this -> editChildrenInEntity ( $ entity , $ name , $ childEntities , $ parameters ) ; }
Edit a child to a colleciton
52,359
public function linkable ( $ create = true , $ edit = true ) { $ this -> linkOnly = true ; parent :: writeable ( $ create , $ edit ) ; return $ this ; }
Similar to writeable but no new items can be created .
52,360
public static function fromArray ( array $ displayNames ) { $ path = new self ( ) ; foreach ( $ displayNames as $ v ) { $ path -> push ( new ResourceField ( new ResourceDefinition ( null ) , $ v ) ) ; } return $ path ; }
Only used for tests .
52,361
public function countSame ( Field $ field ) { $ sum = 0 ; foreach ( $ this -> fields as $ v ) { if ( $ v === $ field ) { $ sum ++ ; } } return $ sum ; }
Return the amount of times this specific field was already shown .
52,362
public function getTransformers ( ) { if ( count ( $ this -> transformers ) === null ) { return null ; } $ out = [ ] ; foreach ( $ this -> transformers as $ transformer ) { $ out [ ] = TransformerLibrary :: make ( $ transformer ) ; } return $ out ; }
Get all transformers attached to this parameter .
52,363
protected function getSwaggerType ( ) { $ type = $ this -> getType ( ) ; switch ( $ type ) { case null : return PropertyType :: STRING ; case PropertyType :: INTEGER : case PropertyType :: STRING : case PropertyType :: NUMBER : case PropertyType :: BOOL : case PropertyType :: OBJECT : return $ type ; case PropertyType :: DATETIME : return PropertyType :: STRING ; default : throw new \ InvalidArgumentException ( "Type cannot be matched with a swagger type." ) ; } }
Translate the local property type to swagger type .
52,364
protected function getTransformers ( ) { $ out = [ ] ; foreach ( $ this -> transformers as $ transformer ) { if ( $ transformer instanceof Transformer ) { $ out [ ] = $ transformer ; } else if ( is_string ( $ transformer ) ) { $ out [ ] = TransformerLibrary :: make ( $ transformer ) ; } else { throw new LogicException ( "All transformers must implement " . Transformer :: class ) ; } } return $ out ; }
Get a list of all transformers .
52,365
public function fromArray ( $ resourceDefinition , array $ body , ContextContract $ context ) : ResourceContract { $ resourceDefinition = ResourceDefinitionLibrary :: make ( $ resourceDefinition ) ; if ( ! Action :: isWriteContext ( $ context -> getAction ( ) ) ) { throw InvalidContextAction :: expectedWriteable ( $ context -> getAction ( ) ) ; } $ resource = new RESTResource ( $ resourceDefinition ) ; $ resource -> setSource ( $ body ) ; $ fields = $ resourceDefinition -> getFields ( ) ; foreach ( $ fields as $ field ) { $ this -> currentPath -> push ( $ field ) ; if ( $ this -> isWritable ( $ field , $ context ) ) { if ( $ field instanceof RelationshipField ) { $ this -> relationshipFromArray ( $ field , $ body , $ resource , $ context ) ; } else { try { $ value = $ this -> propertyResolver -> resolvePropertyInput ( $ this , $ body , $ field , $ context ) ; $ resource -> setProperty ( $ field , $ value , true ) ; } catch ( ValueUndefined $ e ) { } } } $ this -> currentPath -> pop ( ) ; } return $ resource ; }
Create a resource from a data array
52,366
public function processEagerLoading ( $ entities , $ resourceDefinition , Context $ context ) { $ definition = ResourceDefinitionLibrary :: make ( $ resourceDefinition ) ; foreach ( $ definition -> getFields ( ) as $ field ) { $ this -> currentPath -> push ( $ field ) ; if ( $ field instanceof RelationshipField && $ this -> shouldInclude ( $ field , $ context ) && $ this -> shouldExpand ( $ field , $ context ) ) { $ this -> propertyResolver -> eagerLoadRelationship ( $ this , $ entities , $ field , $ context ) ; } $ this -> currentPath -> pop ( ) ; } }
Given a querybuilder or a list of items process eager loading for each relationship that should be visible . This method should be called before calling toEntities and is also called for each relationship that needs to be loaded .
52,367
public function fromInput ( $ resourceDefinition , ContextContract $ context , $ request = null ) : ResourceCollection { $ resourceDefinition = ResourceDefinitionLibrary :: make ( $ resourceDefinition ) ; $ resources = $ context -> getInputParser ( ) -> getResources ( $ this , $ resourceDefinition , $ context , $ request ) ; if ( ! $ resources ) { throw new \ InvalidArgumentException ( "No data found in body" ) ; } return $ resources ; }
Create resources from whatever is in the inputs defined from the input parsers .
52,368
public function identifiersFromInput ( $ resourceDefinition , ContextContract $ context , $ request = null ) : IdentifierCollection { $ resourceDefinition = ResourceDefinitionLibrary :: make ( $ resourceDefinition ) ; $ identifiers = $ context -> getInputParser ( ) -> getIdentifiers ( $ this , $ resourceDefinition , $ context , $ request ) ; if ( ! $ identifiers ) { throw new \ InvalidArgumentException ( "No data found in body" ) ; } return $ identifiers ; }
Create resource identifiers from whatever is in the inputs defined from the input parsers
52,369
protected function getResourceDefinitionName ( ResourceDefinition $ resourceDefinition ) { $ resourceDefinitionClassName = get_class ( $ resourceDefinition ) ; if ( ! isset ( $ this -> resourceDefinitionNames [ $ resourceDefinitionClassName ] ) ) { $ prettyName = $ this -> entityNameLibrary -> toPretty ( $ resourceDefinition -> getEntityClassName ( ) ) ; $ name = $ prettyName ; $ counter = 1 ; while ( in_array ( $ name , $ this -> resourceDefinitionNames ) ) { $ counter ++ ; $ name = $ prettyName . $ counter ; } $ this -> resourceDefinitionNames [ $ resourceDefinitionClassName ] = $ name ; } return $ this -> resourceDefinitionNames [ $ resourceDefinitionClassName ] ; }
Get a unique pretty name for a resource definition .
52,370
public static function strpos ( $ haystack , $ needle , $ offset = 0 ) { return mb_strpos ( $ haystack , $ needle , $ offset , self :: ENCODING ) ; }
Find position of first occurrence of string in a string .
52,371
public static function strrpos ( $ haystack , $ needle , $ offset = 0 ) { return mb_strrpos ( $ haystack , $ needle , $ offset , self :: ENCODING ) ; }
Find position of last occurrence of a string in a string .
52,372
public static function isValid ( $ hostname ) { $ hostname = trim ( $ hostname ) ; if ( Str :: startsWith ( $ hostname , '[' ) && Str :: endsWith ( $ hostname , ']' ) ) { $ hostname = substr ( $ hostname , 1 , - 1 ) ; } return ( bool ) filter_var ( $ hostname , FILTER_VALIDATE_IP ) ; }
Check if the input is a valid IP address . Recognizes both IPv4 and IPv6 addresses .
52,373
protected function describeCommands ( Application $ application , OutputInterface $ output ) : DescriberContract { $ this -> width = 0 ; $ namespaces = collect ( $ application -> all ( ) ) -> filter ( function ( $ command ) { return ! $ command -> isHidden ( ) ; } ) -> groupBy ( function ( $ command ) { $ nameParts = explode ( ':' , $ name = $ command -> getName ( ) ) ; $ this -> width = max ( $ this -> width , mb_strlen ( $ name ) ) ; return isset ( $ nameParts [ 1 ] ) ? $ nameParts [ 0 ] : '' ; } ) -> sortKeys ( ) -> each ( function ( $ commands ) use ( $ output ) { $ output -> write ( "\n" ) ; $ commands = $ commands -> toArray ( ) ; usort ( $ commands , function ( $ a , $ b ) { return $ a -> getName ( ) > $ b -> getName ( ) ; } ) ; foreach ( $ commands as $ command ) { $ output -> write ( sprintf ( " <fg=green>%s</>%s%s\n" , $ command -> getName ( ) , str_repeat ( ' ' , $ this -> width - mb_strlen ( $ command -> getName ( ) ) + 1 ) , $ command -> getDescription ( ) ) ) ; } } ) ; return $ this ; }
Describes the application commands .
52,374
public function addDependencies ( $ resourceId , array $ dependencies ) { $ this -> _resourceGraph [ $ resourceId ] = array_merge ( $ this -> _resourceGraph [ $ resourceId ] , $ dependencies ) ; return $ this ; }
This method is used to add multiple dependencies to a resource .
52,375
private function _errorConfig ( ) { $ error1 = ( object ) [ 'code' => 1 , 'resourceId' => false , 'description' => 'Resource Not Found' ] ; $ error2 = ( object ) [ 'code' => 2 , 'resourceId' => false , 'description' => 'Circular Dependency Detected' ] ; $ this -> _errorCodes = [ 1 => $ error1 , 2 => $ error2 ] ; }
This method is a helper method to set the default error config values .
52,376
private function _getError ( $ code , $ resourceId = false ) { $ error = $ this -> _errorCodes [ $ code ] ; $ error -> resourceId = $ resourceId ; $ this -> resetDepenencyCheck ( ) ; return $ error ; }
This method returns an error object based on the code sets the resourceId .
52,377
private function _runCircularDependencyCheck ( $ resourceId ) { $ this -> _unresolved [ $ resourceId ] = $ resourceId ; foreach ( $ this -> _resourceGraph [ $ resourceId ] as $ dependency ) { if ( ! in_array ( $ dependency , $ this -> _resolved ) ) { if ( in_array ( $ dependency , $ this -> _unresolved ) ) { return $ this -> _getError ( 2 , $ resourceId ) ; } if ( $ error = $ this -> runDependencyCheck ( $ dependency ) ) { return $ error ; } } } unset ( $ this -> _unresolved [ $ resourceId ] ) ; $ this -> _resolved [ $ resourceId ] = $ resourceId ; }
This method checks a resource and its dependencies for any situations where there is a case that causes the dependnecy to be not resolvable .
52,378
public function get ( $ className ) { if ( ! $ this -> has ( $ className ) ) { $ errorMsg = sprintf ( self :: ERROR_SERVICE_NOT_FOUND , $ className ) ; throw new ulfberhtException ( $ errorMsg ) ; } if ( isset ( $ this -> _serviceCache [ $ className ] ) ) { return $ this -> _serviceCache [ $ className ] ; } return $ this -> _resolveService ( $ className ) ; }
This method is used get the instanciated version of a class that has been registered in a module .
52,379
private function _registerService ( $ className , $ constructorType ) { if ( ! class_exists ( $ className ) ) { $ errorMsg = sprintf ( self :: ERROR_CLASS_NOT_FOUND , $ className ) ; throw new ulfberhtException ( $ errorMsg ) ; } elseif ( $ this -> has ( $ className ) ) { $ errorMsg = sprintf ( self :: ERROR_CLASS_ALREADY_DEFINED , $ className ) ; throw new ulfberhtException ( $ errorMsg ) ; } $ this -> _services [ $ className ] = new serviceWrapper ( $ className , $ constructorType ) ; $ this -> _serviceDependencyGraph -> addResource ( $ className ) ; $ this -> _serviceDependencyGraph -> addDependencies ( $ className , $ this -> _services [ $ className ] -> dependencies ) ; }
Registers a new service into ulfberht .
52,380
private function _resolveService ( $ className ) { $ serviceDependencies = $ this -> _serviceDependencyErrorCheck ( $ className ) ; if ( empty ( $ serviceDependencies ) ) { return $ this -> _instanciateService ( $ className , [ ] ) ; } else { $ di = [ ] ; foreach ( $ serviceDependencies as $ dependency ) { $ di [ ] = $ this -> _resolveService ( $ dependency ) ; } return $ this -> _instanciateService ( $ className , $ di ) ; } }
This method is used to resolve a service and all of its dependencies .
52,381
private function _instanciateService ( $ className , $ resolvedDependencies ) { $ service = $ this -> _services [ $ className ] ; switch ( $ service -> constructorType ) { case ( serviceWrapper :: SINGLETON_CONSTRUCTOR ) : if ( ! isset ( $ this -> _serviceCache [ $ className ] ) ) { $ classDef = $ service -> classDef ; $ this -> _serviceCache [ $ className ] = $ classDef -> newInstanceArgs ( $ resolvedDependencies ) ; } return $ this -> _serviceCache [ $ className ] ; case ( serviceWrapper :: FACTORY_CONSTRUCTOR ) : $ classDef = $ service -> classDef ; return $ classDef -> newInstanceArgs ( $ resolvedDependencies ) ; } }
This method is used to instanciate a service based on its instanciation plan .
52,382
public function run ( ) { $ port = ( int ) $ this -> arg -> options ( '--port' , 5000 ) ; $ hostname = $ this -> arg -> options ( '--host' , 'localhost' ) ; $ settings = $ this -> arg -> options ( '--php-settings' , false ) ; if ( is_bool ( $ settings ) ) { $ settings = '' ; } else { $ settings = '-d ' . $ settings ; } $ writing_stream = fopen ( "php://stdout" , "w" ) ; $ message = sprintf ( "[%s] Server start at http://%s:%s \033[0;31;7mCTRL-C for shutdown it\033[00m\n" , date ( 'F d Y H:i:s a' ) , $ hostname , $ port ) ; fwrite ( $ writing_stream , $ message ) ; fclose ( $ writing_stream ) ; $ filename = $ this -> setting -> getServerFilename ( ) ; $ public_directory = $ this -> setting -> getPublicDirectory ( ) ; shell_exec ( "php -S $hostname:$port -t {$public_directory} " . $ filename . " $settings" ) ; }
The run server command
52,383
private function factory ( $ model , $ type ) { $ migrations = [ ] ; foreach ( $ this -> getMigrationFiles ( ) as $ file ) { $ migrations [ $ file ] = explode ( '.' , basename ( $ file ) ) [ 0 ] ; } $ this -> createMigrationTable ( ) ; $ current_migrations = $ this -> getMigrationTable ( ) -> whereIn ( 'migration' , array_values ( $ migrations ) ) -> get ( ) ; try { $ action = 'make' . strtoupper ( $ type ) ; return $ this -> $ action ( $ current_migrations , $ migrations ) ; } catch ( \ Exception $ exception ) { throw $ exception ; } }
Create a migration in both directions
52,384
private function printExceptionMessage ( $ message , $ migration ) { $ message = Color :: red ( $ message ) ; $ migration = Color :: yellow ( $ migration ) ; exit ( sprintf ( "\nOn %s\n\n%s\n\n" , $ migration , $ message ) ) ; }
Print the error message
52,385
private function createMigrationTable ( ) { $ adapter = Database :: getConnectionAdapter ( ) ; $ table = $ adapter -> getTablePrefix ( ) . config ( 'database.migration' ) ; $ generator = new SQLGenerator ( $ table , $ adapter -> getName ( ) , 'create' ) ; $ generator -> addColumn ( 'migration' , 'string' , [ 'unique' => true ] ) ; $ generator -> addColumn ( 'batch' , 'int' ) ; $ generator -> addColumn ( 'created_at' , 'datetime' , [ 'default' => 'CURRENT_TIMESTAMP' , 'nullable' => true ] ) ; $ sql = sprintf ( 'CREATE TABLE IF NOT EXISTS %s (%s);' , $ table , $ generator -> make ( ) ) ; return Database :: statement ( $ sql ) ; }
Create the migration status table
52,386
private function updateMigrationStatus ( $ migration , $ batch ) { $ table = $ this -> getMigrationTable ( ) ; return $ table -> where ( 'migration' , $ migration ) -> update ( [ 'migration' => $ migration , 'batch' => $ batch ] ) ; }
Update migration status
52,387
private function checkMigrationExistance ( $ migration ) { $ result = $ this -> getMigrationTable ( ) -> where ( 'migration' , $ migration ) -> first ( ) ; return ! is_null ( $ result ) ; }
Check the migration existance
52,388
public function generate ( $ model ) { $ create_at = date ( "YmdHis" ) ; $ filename = sprintf ( "Version%s%s" , $ create_at , ucfirst ( Str :: camel ( $ model ) ) ) ; $ generator = new Generator ( $ this -> setting -> getMigrationDirectory ( ) , $ filename ) ; $ options = $ this -> arg -> options ( ) ; if ( $ options -> has ( '--create' ) && $ options -> has ( '--table' ) ) { $ this -> throwFailsCommand ( 'bad command' , 'add help' ) ; } $ type = "model/standard" ; if ( $ options -> has ( '--table' ) ) { if ( $ options -> get ( '--table' ) === true ) { $ this -> throwFailsCommand ( 'bad command option [--table=table]' , 'add help' ) ; } $ table = $ options -> get ( '--table' ) ; $ type = 'model/table' ; } elseif ( $ options -> has ( '--create' ) ) { if ( $ options -> get ( '--create' ) === true ) { $ this -> throwFailsCommand ( 'bad command option [--create=table]' , 'add help' ) ; } $ table = $ options -> get ( '--create' ) ; $ type = 'model/create' ; } $ generator -> write ( $ type , [ 'table' => $ table ?? 'table_name' , 'className' => $ filename ] ) ; echo Color :: green ( 'The migration file has been successfully created' ) . "\n" ; }
Create a migration command
52,389
public static function has ( $ key , $ strict = false ) { $ isset = isset ( $ _COOKIE [ $ key ] ) ; if ( ! $ strict ) { return $ isset ; } if ( $ isset ) { $ isset = $ isset && ! empty ( $ _COOKIE [ $ key ] ) ; } return $ isset ; }
Check for existence of a key in the session collection
52,390
public static function get ( $ key , $ default = null ) { if ( static :: has ( $ key ) ) { return Crypto :: decrypt ( $ _COOKIE [ $ key ] ) ; } if ( is_callable ( $ default ) ) { return $ default ( ) ; } return $ default ; }
Allows you to retrieve a value or collection of cookie value .
52,391
public static function all ( ) { foreach ( $ _COOKIE as $ key => $ value ) { $ _COOKIE [ $ key ] = Crypto :: decrypt ( $ value ) ; } return $ _COOKIE ; }
Return all values of COOKIE
52,392
public static function set ( $ key , $ data , $ expirate = 3600 , $ path = null , $ domain = null , $ secure = false , $ http = true ) { $ data = Crypto :: encrypt ( $ data ) ; return setcookie ( $ key , $ data , time ( ) + $ expirate , $ path , $ domain , $ secure , $ http ) ; }
Add a value to the cookie table .
52,393
public static function remove ( $ key ) { $ old = null ; if ( ! static :: has ( $ key ) ) { return $ old ; } if ( ! static :: $ is_decrypt [ $ key ] ) { $ old = Crypto :: decrypt ( $ _COOKIE [ $ key ] ) ; unset ( static :: $ is_decrypt [ $ key ] ) ; } static :: add ( $ key , null , - 1000 ) ; unset ( $ _COOKIE [ $ key ] ) ; return $ old ; }
Delete an entry in the table
52,394
private function lexique ( $ key , $ attributes ) { if ( is_string ( $ attributes ) ) { $ attributes = [ 'attribute' => $ attributes ] ; } $ lexique = trans ( 'lexique.' . $ key , $ attributes ) ; if ( is_null ( $ lexique ) ) { $ lexique = $ this -> lexique [ $ key ] ; foreach ( $ attributes as $ key => $ value ) { $ lexique = str_replace ( ':' . $ key , $ value , $ lexique ) ; } } return $ lexique ; }
Get error debuging information
52,395
protected function compileRequired ( $ key , $ masque ) { if ( ! isset ( $ this -> inputs [ $ key ] ) || is_null ( $ this -> inputs [ $ key ] ) || $ this -> inputs [ $ key ] === '' ) { $ this -> last_message = $ message = $ this -> lexique ( 'required' , $ key ) ; $ this -> errors [ $ key ] [ ] = [ "masque" => $ masque , "message" => $ message ] ; $ this -> fails = true ; } }
Compile Required Rule
52,396
protected function compileEmpty ( $ key , $ masque ) { if ( ! isset ( $ this -> inputs [ $ key ] ) ) { $ this -> fails = true ; $ this -> last_message = $ message = $ this -> lexique ( 'empty' , $ key ) ; $ this -> errors [ $ key ] [ ] = [ "masque" => $ masque , "message" => $ message ] ; } }
Compile Empty Rule
52,397
protected function compileMin ( $ key , $ masque ) { if ( ! preg_match ( "/^min:(\d+)$/" , $ masque , $ match ) ) { return ; } $ length = ( int ) end ( $ match ) ; if ( Str :: len ( $ this -> inputs [ $ key ] ) > $ length ) { return ; } $ this -> fails = true ; $ this -> last_message = $ this -> lexique ( 'min' , [ 'attribute' => $ key , 'length' => $ length ] ) ; $ this -> errors [ $ key ] [ ] = [ "masque" => $ masque , "message" => $ this -> last_message ] ; }
Complie Min Mask
52,398
protected function compileSame ( $ key , $ masque ) { if ( ! preg_match ( "/^same:(.+)$/" , $ masque , $ match ) ) { return ; } $ value = ( string ) end ( $ match ) ; if ( $ this -> inputs [ $ key ] == $ value ) { return ; } $ this -> last_message = $ this -> lexique ( 'same' , [ 'attribute' => $ key , 'value' => $ value ] ) ; $ this -> fails = true ; $ this -> errors [ $ key ] [ ] = [ "masque" => $ masque , "message" => $ this -> last_message ] ; }
Compile Some Rule
52,399
protected function compileEmail ( $ key , $ masque ) { if ( ! preg_match ( "/^email$/" , $ masque , $ match ) ) { return ; } if ( Str :: isMail ( $ this -> inputs [ $ key ] ) ) { return ; } $ this -> last_message = $ this -> lexique ( 'email' , $ key ) ; $ this -> fails = true ; $ this -> errors [ $ key ] [ ] = [ "masque" => $ masque , "message" => $ this -> last_message ] ; }
Compile Email Rule