idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
15,600
public function createEmailList ( $ emailList ) { $ entry = $ this -> newEmailListEntry ( ) ; $ list = $ this -> newEmailList ( ) ; $ list -> name = $ emailList ; $ entry -> emailList = $ list ; return $ this -> insertEmailList ( $ entry ) ; }
Create a new email list .
15,601
public function retrieveEmailLists ( $ recipient ) { $ query = $ this -> newEmailListQuery ( ) ; $ query -> recipient = $ recipient ; return $ this -> getEmailListFeed ( $ query ) ; }
Retrieve all email lists associated with a recipient .
15,602
public function retrievePageOfEmailLists ( $ startNickname = null ) { $ query = $ this -> newEmailListQuery ( ) ; $ query -> setStartEmailListName ( $ startNickname ) ; return $ this -> getEmailListFeed ( $ query ) ; }
Retrieve a page of email lists in alphabetical order starting with the provided email list .
15,603
public function addRecipientToEmailList ( $ recipientAddress , $ emailList ) { $ entry = $ this -> newEmailListRecipientEntry ( ) ; $ who = $ this -> newWho ( ) ; $ who -> email = $ recipientAddress ; $ entry -> who = $ who ; $ address = $ this -> getBaseUrl ( ) . self :: APPS_EMAIL_LIST_PATH . '/' . $ emailList . self :: APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/' ; return $ this -> insertEmailListRecipient ( $ entry , $ address ) ; }
Add a specified recipient to an existing emailList .
15,604
public function retrievePageOfRecipients ( $ emailList , $ startRecipient = null ) { $ query = $ this -> newEmailListRecipientQuery ( ) ; $ query -> setEmailListName ( $ emailList ) ; $ query -> setStartRecipient ( $ startRecipient ) ; return $ this -> getEmailListRecipientFeed ( $ query ) ; }
Retrieve a page of email list recipients in alphabetical order starting with the provided email list recipient .
15,605
public function removeRecipientFromEmailList ( $ recipientAddress , $ emailList ) { $ this -> delete ( $ this -> getBaseUrl ( ) . self :: APPS_EMAIL_LIST_PATH . '/' . $ emailList . self :: APPS_EMAIL_LIST_RECIPIENT_POSTFIX . '/' . $ recipientAddress ) ; }
Remove a specified recipient from an email list .
15,606
protected function getPropertyValueFromObject ( ClassMetadata $ meta , $ propertyName , $ object ) { $ refl = $ meta -> getReflectionClass ( ) ; $ prop = $ refl -> getProperty ( $ propertyName ) ; $ prop -> setAccessible ( true ) ; $ value = $ prop -> getValue ( $ object ) ; return $ value ; }
Returns value of the entity s property
15,607
protected function prepareRoutes ( ) { $ this -> dispatcher = \ FastRoute \ simpleDispatcher ( function ( \ FastRoute \ RouteCollector $ collector ) { $ router = new RouteCollection ( $ this , $ collector , '' , [ ] , '' ) ; $ router -> group ( [ 'middlewares' => [ 'api' ] ] , function ( RouteCollection $ router ) { $ route_file = app_path ( 'routes_api.php' ) ; if ( file_exists ( $ route_file ) ) { require $ route_file ; } } ) ; $ router -> group ( [ 'middlewares' => [ 'web' ] ] , function ( RouteCollection $ router ) { $ route_file = app_path ( 'routes.php' ) ; if ( file_exists ( $ route_file ) ) { require $ route_file ; } } ) ; } ) ; }
Carregar e preparar rotas .
15,608
public function route ( $ name ) { if ( array_key_exists ( $ name , $ this -> allNames ) ) { return $ this -> allNames [ $ name ] ; } return null ; }
Find a route by name .
15,609
public function setNames ( $ old , $ name , Route $ route ) { if ( ( ! is_null ( $ old ) ) && ( isset ( $ this -> allNames [ $ old ] ) ) ) { unset ( $ this -> allNames [ $ old ] ) ; } if ( ! is_null ( $ name ) ) { $ this -> allNames [ $ name ] = $ route ; } }
Set name .
15,610
public function render ( $ view = null ) { if ( $ this -> config [ 'auto_hide' ] === true AND $ this -> total_pages <= 1 ) { return '' ; } if ( $ view === null ) { $ view = $ this -> config [ 'view' ] ; } $ tpl = \ Meerkat \ Twig \ Twig :: from_template ( $ view ) ; return $ tpl -> set ( get_object_vars ( $ this ) ) -> set ( 'page' , $ this ) -> render ( ) ; }
Renders the pagination links .
15,611
public function getBoard ( $ name ) { $ byName = Models \ Board :: search ( ) -> where ( 'name' , $ name ) -> execOne ( ) ; $ bySlug = Models \ Board :: getBySlug ( $ name ) ; return $ bySlug instanceof Models \ Board ? $ bySlug : $ byName ; }
Get Board by Name or Slug .
15,612
public function getData ( bool $ asObject = false ) { $ data = $ this -> data [ 'data' ] ?? $ this -> data ; return $ asObject && $ data !== null ? ( object ) $ data : $ data ; }
Returns the value of the data key in the response if available else it returns the parsed response .
15,613
public function getErrors ( bool $ asObject = false ) { $ errors = $ this -> data [ 'errors' ] ?? [ ] ; return $ asObject ? ( object ) $ errors : $ errors ; }
Returns the errors in the response if any .
15,614
public function dumpRequest ( ) : array { if ( empty ( $ this -> request ) ) { return [ 'http_status' => $ this -> httpStatus , 'response' => $ this -> data ] ; } $ this -> request -> getBody ( ) -> rewind ( ) ; $ size = $ this -> request -> getBody ( ) -> getSize ( ) ? : 1024 ; $ bodyParams = json_decode ( $ this -> request -> getBody ( ) -> read ( $ size ) , true ) ; $ possibleJsonString = ( string ) $ this -> request -> getBody ( ) ; $ jsonData = json_decode ( $ possibleJsonString ) ; $ uri = $ this -> request -> getUri ( ) ; $ url = $ uri -> getScheme ( ) . '://' . $ uri -> getAuthority ( ) . '/' . $ uri -> getPath ( ) ; return [ 'http_status' => $ this -> httpStatus , 'endpoint' => $ url , 'params' => $ bodyParams , 'response' => $ jsonData ? : $ possibleJsonString ] ; }
Returns a summary of the request . This will usually be available in the case of a failure .
15,615
public function children ( $ lang = '' , $ alias = '' ) { $ collname = $ this -> collectionName ; $ bitems = $ collname :: GetInstance ( ) ; $ children = $ bitems -> itemsFilter ( array ( 'parent' => $ this -> id ) ) ; if ( empty ( $ alias ) ) { return $ children ; } foreach ( $ children as $ ch ) { $ chalias = $ ch -> getalias ( $ lang ) ; if ( $ chalias == $ alias ) { return $ ch ; } } return NULL ; }
Get children items by alias .
15,616
protected function getfieldsvalues ( & $ qr_fields , & $ qr_values ) { $ qr_fields = array ( ) ; $ qr_values = array ( ) ; parent :: getfieldsvalues ( $ qr_fields , $ qr_values ) ; $ parent = $ this -> getparent ( ) ; if ( empty ( $ parent ) ) { $ collectionName = $ this -> collectionName ; $ collection = $ collectionName :: getInstance ( ) ; $ parent = $ collection -> itemGet ( 1 ) ; $ this -> { $ this -> parentKeyName } = 1 ; } $ qr_fields [ ] = $ this -> parentKeyName ; $ qr_values [ ] = $ this -> { $ this -> parentKeyName } ; $ qr_fields [ ] = $ this -> leftKeyName ; $ qr_values [ ] = $ this -> { $ this -> leftKeyName } ; $ qr_fields [ ] = $ this -> rightKeyName ; $ qr_values [ ] = $ this -> { $ this -> rightKeyName } ; $ qr_fields [ ] = $ this -> levelKeyName ; $ qr_values [ ] = $ this -> { $ this -> levelKeyName } ; return true ; }
Get fields values
15,617
public static function setDbType ( $ dbType ) { $ dbTypeCast = ( string ) $ dbType ; if ( array_search ( $ dbTypeCast , self :: $ dbList ) === false ) { throw new DBException ( 'Illegal database type provided to DB Service' ) ; } self :: $ dbType = $ dbTypeCast ; }
Static function to set the db type
15,618
public static function sanitizeDbParameters ( $ dbParams ) { switch ( self :: getDbType ( ) ) { case 'mysql' : if ( empty ( $ dbParams [ 'unix_socket' ] ) ) { unset ( $ dbParams [ 'unix_socket' ] ) ; } if ( empty ( $ dbParams [ 'charset' ] ) ) { unset ( $ dbParams [ 'charset' ] ) ; } break ; case 'sqlite' : if ( empty ( $ dbParams [ 'user' ] ) ) { unset ( $ dbParams [ 'user' ] ) ; } if ( empty ( $ dbParams [ 'password' ] ) ) { unset ( $ dbParams [ 'password' ] ) ; } if ( empty ( $ dbParams [ 'host' ] ) ) { unset ( $ dbParams [ 'host' ] ) ; } if ( empty ( $ dbParams [ 'port' ] ) ) { unset ( $ dbParams [ 'port' ] ) ; } break ; } return $ dbParams ; }
Sanitize the database parameters provided
15,619
public static function connectDb ( ) { if ( ! isset ( self :: $ dbLink ) ) { $ dbParams = self :: getDatabaseParameters ( ) ; self :: validateDbParameters ( $ dbParams ) ; $ dbParamsSan = self :: sanitizeDbParameters ( $ dbParams ) ; $ config = new Configuration ( ) ; self :: $ dbLink = DriverManager :: getConnection ( $ dbParamsSan , $ config ) ; } return self :: $ dbLink ; }
Create a database connection or return singleton connection using environment settings
15,620
public static function connectDbNew ( $ dbParams ) { self :: validateDbParameters ( $ dbParams ) ; $ dbParamsSan = self :: sanitizeDbParameters ( $ dbParams ) ; $ config = new Configuration ( ) ; return DriverManager :: getConnection ( $ dbParamsSan , $ config ) ; }
For new connections that are building transactions
15,621
public static function closeDbConnection ( ) { if ( isset ( self :: $ dbLink ) ) { $ dbConn = self :: $ dbLink ; $ dbConn -> close ( ) ; self :: $ dbLink = null ; } return null ; }
Closes the static db connection
15,622
protected function loadConfigs ( array $ config , ContainerBuilder $ container ) { foreach ( $ config [ 'configs' ] as $ name => $ arguments ) { if ( ! $ arguments [ 'enabled' ] ) { continue ; } $ id = 'integrated_channel.config.memory.' . $ name ; if ( $ container -> hasDefinition ( $ id ) ) { continue ; } do { $ id_options = $ id . '.options.' . uniqid ( ) ; } while ( $ container -> hasDefinition ( $ id_options ) ) ; $ definition = new Definition ( '%integrated_channel.config.options.class%' ) ; $ definition -> setPublic ( false ) ; $ definition -> setArguments ( [ $ arguments [ 'options' ] ] ) ; $ container -> setDefinition ( $ id_options , $ definition ) ; $ definition = new Definition ( '%integrated_channel.config.class%' ) ; $ definition -> setArguments ( [ $ name , $ arguments [ 'adaptor' ] , new Reference ( $ id_options ) ] ) ; if ( $ arguments [ 'channel' ] ) { foreach ( $ arguments [ 'channel' ] as $ channel ) { $ definition -> addTag ( 'integrated_channel.config' , [ 'channel' => $ channel ] ) ; } } else { $ definition -> addTag ( 'integrated_channel.config' ) ; } $ container -> setDefinition ( $ id , $ definition ) ; } }
Process the adaptor config configuration .
15,623
protected function getUserId ( UserInterface $ user ) { $ class = $ this -> container -> getParameter ( 'tree_house.keystone.model.user.class' ) ; $ meta = $ this -> getDoctrine ( ) -> getManagerForClass ( $ class ) -> getClassMetadata ( $ class ) ; $ ids = $ meta -> getIdentifierValues ( $ user ) ; if ( sizeof ( $ ids ) === 1 ) { return current ( $ ids ) ; } return $ ids ; }
Returns the user identifier . If this is a single identifier that value is returned . Otherwise all the identifiers are returned as an array .
15,624
protected function _getField ( ) { $ fields = [ ] ; $ fieldsData = $ this -> _entity -> fields ( ) ; if ( ! preg_match ( '#\.#isU' , $ this -> _field ) ) { if ( isset ( $ fieldsData [ $ this -> _field ] ) ) { $ fields = [ $ fieldsData [ $ this -> _field ] -> value ] ; } else { throw new MissingEntityException ( 'The field "' . $ this -> _field . '" in the Entity "' . $ this -> _entity -> name ( ) . '" does\'nt exist' ) ; } } else { $ entityName = explode ( '.' , $ this -> _field ) ; if ( array_key_exists ( $ entityName [ 0 ] , $ fieldsData ) && $ fieldsData [ $ entityName [ 0 ] ] -> foreign != null ) { $ foreignType = $ fieldsData [ $ entityName [ 0 ] ] -> foreign -> type ( ) ; $ fieldValue = $ fieldsData [ $ entityName [ 0 ] ] -> value -> fields ( ) [ $ entityName [ 1 ] ] ; if ( $ foreignType == ForeignKey :: ONE_TO_MANY || $ foreignType == ForeignKey :: MANY_TO_ONE ) { $ fields = $ this -> _getForeignKeyFieldValue ( $ fieldValue ) ; } else { foreach ( $ fieldValue -> data ( ) as $ fieldValueCollection ) { $ fields = array_merge ( $ fields , $ this -> _getForeignKeyFieldValue ( $ fieldValueCollection ) ) ; } } } else { throw new MissingEntityException ( 'The field "' . $ this -> _field . '" in the Entity "' . $ this -> _entity -> name ( ) . '" does\'nt exist' ) ; } } return $ fields ; }
Before validating the field we need to get the correct field from the current Entity or a linked Entity
15,625
private function _getForeignKeyFieldValue ( $ field ) { $ fields = null ; if ( gettype ( $ field -> value ) != 'object' ) { if ( is_array ( $ field -> value ) ) { $ fields = $ field -> value ; } else { $ fields = [ $ field -> value ] ; } } else if ( get_class ( $ field -> value ) != 'System\Collection\Collection' ) { $ fields = $ field -> value -> data ( ) ; } else if ( get_class ( $ field -> value ) != 'System\Orm\Entity\Type\File' ) { $ fields = [ $ field -> value ] ; } return $ fields ; }
The method _getField return the value of each field in the Entity . This method is used to factorize the source code
15,626
public function equal ( $ equal , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: EQUAL , 'value' => $ equal , 'message' => $ error ] ) ; } return $ this ; }
the field must be equal to
15,627
public function different ( $ different , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: DIFFERENT , 'value' => $ different , 'message' => $ error ] ) ; } return $ this ; }
the field must be different from
15,628
public function moreThan ( $ moreThan , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: MORETHAN , 'value' => $ moreThan , 'message' => $ error ] ) ; } return $ this ; }
the field value must be more than
15,629
public function lessThan ( $ lessThan , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: LESSTHAN , 'value' => $ lessThan , 'message' => $ error ] ) ; } return $ this ; }
the field value must be less than
15,630
public function between ( $ between , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: BETWEEN , 'value' => $ between , 'message' => $ error ] ) ; } return $ this ; }
the field value must be between
15,631
public function in ( $ in , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: IN , 'value' => $ in , 'message' => $ error ] ) ; } return $ this ; }
the field value must be in
15,632
public function notIn ( $ notIn , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: NOTIN , 'value' => $ notIn , 'message' => $ error ] ) ; } return $ this ; }
the field value must not be in
15,633
public function length ( $ length , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: LENGTH , 'value' => $ length , 'message' => $ error ] ) ; } return $ this ; }
the field size must be
15,634
public function lengthMin ( $ lengthMin , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: LENGTHMIN , 'value' => $ lengthMin , 'message' => $ error ] ) ; } return $ this ; }
the field size must more than
15,635
public function mail ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: MAIL , 'message' => $ error ] ) ; } return $ this ; }
the field must be an email address
15,636
public function int ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: INT , 'message' => $ error ] ) ; } return $ this ; }
the field must be an int
15,637
public function float ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: FLOAT , 'message' => $ error ] ) ; } return $ this ; }
the field must be a float
15,638
public function alpha ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: ALPHA , 'message' => $ error ] ) ; } return $ this ; }
the field must contains only letters
15,639
public function alphaNum ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: ALPHANUM , 'message' => $ error ] ) ; } return $ this ; }
the field must contain only letters and numerics
15,640
public function alphaDash ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: ALPHADASH , 'message' => $ error ] ) ; } return $ this ; }
the field must contain only letters numerics ans underscore
15,641
public function ip ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: IP , 'message' => $ error ] ) ; } return $ this ; }
the field must be an ip
15,642
public function sql ( $ sql , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: SQL , 'value' => $ sql , 'message' => $ error ] ) ; } return $ this ; }
the field must valid the query
15,643
public function count ( $ count , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: COUNT , 'value' => $ count , 'message' => $ error ] ) ; } return $ this ; }
When the field value is an array it must contain N lines
15,644
public function countMin ( $ countMin , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: COUNTIN , 'value' => $ countMin , 'message' => $ error ] ) ; } return $ this ; }
When the field value is an array it must contain at least N lines
15,645
public function countMax ( $ countMax , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: COUNTMAX , 'value' => $ countMax , 'message' => $ error ] ) ; } return $ this ; }
When the field value is an array it must contain less than N + 1 lines
15,646
public function countIn ( $ countIn , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: COUNTIN , 'value' => $ countIn , 'message' => $ error ] ) ; } return $ this ; }
When the field value is an array its value must be in
15,647
public function countBetween ( $ countBetween , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: COUNTBETWEEN , 'value' => $ countBetween , 'message' => $ error ] ) ; } return $ this ; }
When the field value is an array its value must be between
15,648
public function exist ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: EXIST , 'message' => $ error ] ) ; } return $ this ; }
The field must exist
15,649
public function notExist ( $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: NOTEXIST , 'message' => $ error ] ) ; } return $ this ; }
The field must not exist
15,650
public function listAction ( ) { if ( false === $ this -> get ( 'security.authorization_checker' ) -> isGranted ( 'ROLE_ADMIN' ) ) throw new AccessDeniedException ( ) ; $ source = new Entity ( $ this -> get ( 'asf_website.config.manager' ) -> getClassName ( ) ) ; $ tableAlias = $ source -> getTableAlias ( ) ; $ source -> manipulateQuery ( function ( $ query ) use ( $ tableAlias ) { $ query instanceof QueryBuilder ; if ( count ( $ query -> getDQLPart ( 'orderBy' ) ) == 0 ) { $ query -> orderBy ( $ tableAlias . '.name' , 'ASC' ) ; } } ) ; $ grid = $ this -> get ( 'grid' ) ; $ grid instanceof Grid ; $ grid -> setSource ( $ source ) ; $ grid -> setId ( 'asf_website_config_list' ) ; $ grid -> hideColumns ( array ( 'id' ) ) ; $ grid -> getColumn ( 'name' ) -> setTitle ( $ this -> get ( 'translator' ) -> trans ( 'Config name' , array ( ) , 'asf_website' ) ) -> setDefaultOperator ( 'like' ) -> setOperatorsVisible ( false ) ; $ editAction = new RowAction ( 'btn_edit' , 'asf_website_config_edit' ) ; $ editAction -> setRouteParameters ( array ( 'id' ) ) ; $ grid -> addRowAction ( $ editAction ) ; $ deleteAction = new RowAction ( 'btn_delete' , 'asf_website_config_delete' , true ) ; $ deleteAction -> setRouteParameters ( array ( 'id' ) ) -> setConfirmMessage ( $ this -> get ( 'translator' ) -> trans ( 'Do you want to delete this config?' , array ( ) , 'asf_website' ) ) ; $ grid -> addRowAction ( $ deleteAction ) ; $ grid -> setNoDataMessage ( $ this -> get ( 'translator' ) -> trans ( 'No config was found.' , array ( ) , 'asf_website' ) ) ; return $ grid -> getGridResponse ( 'ASFWebsiteBundle:Config:list.html.twig' ) ; }
List all website config
15,651
public function editAction ( Request $ request , $ id = null ) { if ( false === $ this -> get ( 'security.authorization_checker' ) -> isGranted ( 'ROLE_ADMIN' ) ) throw new AccessDeniedException ( ) ; $ formFactory = $ this -> get ( 'asf_website.form.factory.config' ) ; $ configManager = $ this -> get ( 'asf_website.config.manager' ) ; if ( ! is_null ( $ id ) ) { $ config = $ configManager -> getRepository ( ) -> findOneBy ( array ( 'id' => $ id ) ) ; $ success_message = $ this -> get ( 'translator' ) -> trans ( 'Updated successfully' , array ( ) , 'asf_website' ) ; } else { $ config = $ configManager -> createInstance ( ) ; $ config -> setName ( $ this -> get ( 'translator' ) -> trans ( 'New website config' , array ( ) , 'asf_website' ) ) ; $ success_message = $ this -> get ( 'translator' ) -> trans ( 'Created successfully' , array ( ) , 'asf_website' ) ; } if ( is_null ( $ config ) ) throw new \ Exception ( $ this -> get ( 'translator' ) -> trans ( 'An error occurs when generating or getting the configuration' , array ( ) , 'asf_website' ) ) ; $ form = $ formFactory -> createForm ( ) ; $ form -> setData ( $ config ) ; $ formHandler = new ConfigFormHandler ( $ form , $ request , $ this -> container ) ; if ( true === $ formHandler -> process ( ) ) { try { if ( is_null ( $ config -> getId ( ) ) ) { $ configManager -> getEntityManager ( ) -> persist ( $ config ) ; } $ configManager -> getEntityManager ( ) -> flush ( ) ; $ this -> get ( 'asf_layout.flash_message' ) -> success ( $ success_message ) ; return $ this -> redirect ( $ this -> get ( 'router' ) -> generate ( 'asf_website_config_edit' , array ( 'id' => $ config -> getId ( ) ) ) ) ; } catch ( \ Exception $ e ) { $ this -> get ( 'asf_layout.flash_message' ) -> danger ( $ e -> getMessage ( ) ) ; } } return $ this -> render ( 'ASFWebsiteBundle:Config:edit.html.twig' , array ( 'config' => $ config , 'form' => $ form -> createView ( ) ) ) ; }
Add or edit a website config
15,652
public function deleteAction ( $ id ) { if ( false === $ this -> get ( 'security.authorization_checker' ) -> isGranted ( 'ROLE_ADMIN' ) ) throw new AccessDeniedException ( ) ; $ config = $ this -> get ( 'asf_website.config.manager' ) -> getRepository ( ) -> findOneBy ( array ( 'id' => $ id ) ) ; try { $ this -> get ( 'asf_website.config.manager' ) -> getEntityManager ( ) -> remove ( $ config ) ; $ this -> get ( 'asf_website.config.manager' ) -> getEntityManager ( ) -> flush ( ) ; $ this -> get ( 'asf_layout.flash_message' ) -> success ( $ this -> get ( 'translator' ) -> trans ( 'The website config "%name%" successfully deleted.' , array ( '%name%' => $ config -> getName ( ) ) , 'asf_website' ) ) ; } catch ( \ Exception $ e ) { $ this -> get ( 'asf_layout.flash_message' ) -> danger ( $ e -> getMessage ( ) ) ; } return $ this -> redirect ( $ this -> get ( 'router' ) -> generate ( 'asf_website_config_list' ) ) ; }
Delete a website config
15,653
public function prosesLogin ( UserFormLoginRequest $ request ) { $ users = User :: where ( 'email' , $ request -> get ( 'username' ) ) -> where ( 'password' , $ request -> get ( 'password' ) ) -> get ( ) ; if ( $ users -> count ( ) > 0 ) { Auth :: login ( $ users -> first ( ) ) ; return redirect ( ) -> intended ( ) ; return redirect ( ) -> to ( '/' ) -> with ( "message" , [ 'alert' => 'success' , 'message' => 'Welcome ' . $ users -> first ( ) -> name . '.' . ' You successfully logged in.' ] ) ; } return redirect ( ) -> back ( ) -> with ( "message" , [ 'alert' => 'danger' , 'message' => 'Combination Username and Password is not match' ] ) ; }
This method uses to check the user credential
15,654
public function get ( string $ className , ... $ constructorArguments ) { if ( ! isset ( $ this -> container [ $ className ] ) ) { $ instance = $ this -> createWithArguments ( $ className , $ constructorArguments , $ implementationClassName ) ; $ this -> container [ $ className ] = $ instance ; if ( $ implementationClassName ) { $ this -> container [ $ implementationClassName ] = $ instance ; } } return $ this -> container [ $ className ] ; }
Retrieve the class from the container or creates a new instance
15,655
private function createWithArguments ( string $ className , array $ constructorArguments , & $ implementationClassName = null ) { if ( interface_exists ( $ className ) ) { $ className = $ implementationClassName = $ this -> getClassForInterface ( $ className ) ; } if ( ! class_exists ( $ className ) ) { throw ClassDoesNotExistException :: exceptionWithClassName ( $ className ) ; } if ( $ constructorArguments ) { $ reflector = new ReflectionClass ( $ className ) ; return $ reflector -> newInstanceArgs ( $ constructorArguments ) ; } return new $ className ( ) ; }
Returns a new instance of the given class
15,656
private function getClassForInterface ( string $ interfaceName ) { $ implementationName = '' ; if ( strtolower ( substr ( $ interfaceName , - 9 ) ) === 'interface' ) { $ implementationName = substr ( $ interfaceName , 0 , - 9 ) ; } if ( ! class_exists ( $ implementationName ) ) { throw NoImplementationForInterfaceException :: exceptionWithInterfaceName ( $ interfaceName ) ; } return $ implementationName ; }
Try to find the class name for the given interface
15,657
function map ( $ view_content , $ view_params = array ( ) ) { $ rules = ViewUtility :: find_rules ( $ view_content , '{{' , '}}' ) ; foreach ( $ rules as $ rule ) { $ rule_code = str_replace ( '{{' , '' , $ rule ) ; $ rule_code = str_replace ( '}}' , '' , $ rule_code ) ; $ rule_code = trim ( $ rule_code ) ; $ rule_code = trim ( $ rule_code , ';' ) ; $ rule_code_value = null ; if ( strpos ( $ rule_code , '$' ) === 0 ) { if ( $ rule_code_value == null ) { $ rule_code_variable = ltrim ( $ rule_code , '$' ) ; foreach ( $ view_params as $ param_key => $ param_value ) { if ( $ param_key == $ rule_code_variable ) { $ rule_code_value = $ param_value ; break ; } } } } else { $ rule_code_value = eval ( "$rule_code;" ) ; if ( $ rule_code_value == null ) { $ rule_code_value = eval ( "return $rule_code;" ) ; } } $ view_content = str_replace ( $ rule , $ rule_code_value , $ view_content ) ; } return $ view_content ; }
Map php functions and variables
15,658
protected function renderXmlHttpException ( $ e ) { $ data = [ 'message' => $ e -> getMessage ( ) , ] ; if ( $ e instanceof HttpException ) { return new JsonResponse ( $ data , $ e -> getStatusCode ( ) ) ; } return new JsonResponse ( $ data , 500 ) ; }
Renders an exception from ajax requests .
15,659
protected function renderDebugXmlHttpException ( $ e ) { $ data = [ 'message' => $ e -> getMessage ( ) , 'trace' => $ e -> getTrace ( ) , ] ; if ( $ e instanceof HttpException ) { return new JsonResponse ( $ data , $ e -> getStatusCode ( ) ) ; } return new JsonResponse ( $ data , 500 ) ; }
Renders an exception from ajax requests Only use this in debug mode .
15,660
private function getElementsToProcess ( ) : array { $ result = [ ] ; foreach ( get_object_vars ( $ this ) as $ element ) { if ( $ element instanceof FormElementInterface ) { $ result [ ] = $ element ; } } $ result = array_merge ( $ result , $ this -> extraElements ) ; return $ result ; }
Returns the elements to process .
15,661
protected function imports ( $ object ) { $ newImport = new $ object ( ) ; $ importName = get_class ( $ newImport ) ; $ importFunctions = get_class_methods ( $ newImport ) ; array_push ( $ this -> imported , array ( $ importName , $ newImport ) ) ; foreach ( $ importFunctions as $ key => $ functionName ) { $ this -> importedFunctions [ $ functionName ] = & $ newImport ; } }
Imports a plugin
15,662
public function initValue ( $ value ) { try { $ value = Json :: decode ( $ value ) ; } catch ( \ Exception $ e ) { $ value = [ ] ; } return $ value ; }
Conversion property value received from the database
15,663
public function beforeSaveValue ( $ value ) { try { $ value = Json :: encode ( $ value ) ; } catch ( \ Exception $ e ) { $ value = "{}" ; } return $ value ; }
Converting the property value before saving to database
15,664
protected function setLoggers ( ) { if ( $ loggers = $ this -> hasLoggerConfig ( ) ) { foreach ( $ loggers as $ channel => $ logger ) { $ loggerChannel = $ this -> getChannelName ( $ logger , $ channel ) ; $ loggerName = $ this -> getLoggerIdentified ( $ logger , $ loggerChannel ) ; $ this -> container [ $ loggerName ] = Logger :: get ( $ loggerChannel , $ this -> buildHandlers ( $ logger [ 'handlers' ] ?? [ ] ) ) ; } } }
Crea los loggers en el container
15,665
protected function buildHandlers ( array $ config ) : array { $ handlers = [ ] ; foreach ( $ config as $ handler ) { $ level = constant ( '\Mostofreddy\Loggy\Logger::' . strtoupper ( $ handler [ 'level' ] ) ) ; $ handlerObj = '\Mostofreddy\Loggy\Handler\\' . ucfirst ( $ handler [ 'handler' ] ) ; $ handlers [ ] = ( new $ handlerObj ( $ level ) ) -> config ( $ handler ) ; } return $ handlers ; }
Instancia los handlers del logger
15,666
public function GetFileType ( $ dataPost ) { $ templateTypeKey = "templateType" ; if ( ! array_key_exists ( $ templateTypeKey , $ dataPost ) ) { throw new \ Exception ( "The POST data doesn't contain the value $templateTypeKey. See dump" . var_dump ( $ dataPost ) , 0 , null ) ; } $ this -> templateType = $ dataPost [ $ templateTypeKey ] ; return $ this ; }
Get the file type in the POST request .
15,667
public function help ( ) { $ this -> showHeader ( ) ; echo "ufw - Helper to uFw framework\n\nOptions:\n" ; foreach ( self :: HELP [ 'options' ] as $ helpOption => $ helpDescription ) { echo "\n $helpOption \t " . ( $ helpDescription [ 'summary' ] ?? "" ) ; if ( array_key_exists ( 'examples' , $ helpDescription ) ) { echo "\n \t Ex:" ; foreach ( $ helpDescription [ 'examples' ] as $ example ) { echo "\n \t $example" ; } echo "\n" ; } } echo "\n" ; }
Shows the help options
15,668
public function run ( ) { if ( Console :: getArg ( '--create' ) ) { $ this -> createProject ( Console :: getArg ( '--create' ) ) ; return ; } elseif ( Console :: getArg ( '--init' ) ) { $ this -> initProject ( ) ; return ; } elseif ( Console :: getArg ( '--run' ) ) { $ this -> runAction ( Console :: getArg ( '--run' ) , json_decode ( Console :: getArg ( '--data' , '[]' ) , true ) ) ; return ; } else { $ this -> help ( ) ; } }
Inspect the command line arguments and execute it .
15,669
protected function initProject ( ) { $ this -> showHeader ( ) ; Utils :: getInstance ( ) -> createDirectory ( [ 'apps' , 'bootstrap' , 'config' , 'public' , 'tmp/tpl_compile' , 'plugins' ] ) ; foreach ( self :: FILES_BASE as $ pathname => $ contents ) { Utils :: getInstance ( ) -> createFile ( $ pathname , $ contents ) ; } chmod ( "tmp" , 775 ) ; chmod ( "tmp/tpl_compile" , 775 ) ; }
Initialize the current workspace
15,670
protected function createProject ( $ projectName = 'myProj' ) { $ this -> showHeader ( ) ; Console :: stdout ( "Creating $projectName \n" ) ; Utils :: getInstance ( ) -> createDirectory ( "./apps/" . $ projectName , [ 'src' , 'routes' , 'config' , 'public' , 'doc' , 'templates' ] ) ; echo "\n" ; foreach ( self :: FILES_APP as $ pathname => $ contents ) { Utils :: getInstance ( ) -> createFile ( "./apps/" . $ projectName . "/" . $ pathname , $ contents ) ; } echo "\n Don't forget to run 'composer update' in your root project folder (apps/" . $ projectName . ") before start to use! \n" ; }
Create a new project workspace and initialize it .
15,671
protected function performRunAction ( ) { require __DIR__ . "/../../../../../vendor/autoload.php" ; $ request = \ harpya \ ufw \ Request :: of ( ) ; $ appFolder = __DIR__ . '/../../../../../apps/' ; $ appFolder = '../apps/' ; $ app = \ harpya \ ufw \ ApplicationCli :: getInstance ( [ Application :: DEF_APPS_PATH => $ appFolder , Application :: CMP_ROUTER => new \ harpya \ ufw \ Router ( ) , Application :: CMP_REQUEST => $ request , Application :: CMP_CONFIG => \ harpya \ ufw \ Config :: of ( __DIR__ . '/../../../..' ) ] ) ; $ app -> init ( ) ; $ out = $ app -> run ( ) ; print_r ( $ out ) ; exit ; }
Emulate the same as what the web server do to fulfill a request .
15,672
public static function fill ( array $ data , COCEntity & $ entity ) { $ vars = get_object_vars ( $ entity ) ; foreach ( $ vars as $ var => $ _ ) { if ( array_key_exists ( $ var , $ data ) ) { $ entity -> { $ var } = $ data [ $ var ] ; } } }
Fills the data from an array into the given class
15,673
public function isAllowed ( $ resource , $ privilege = null , $ role = null ) { return $ this -> getPermissionsModel ( ) -> isAllowed ( $ resource , $ privilege , $ role ) ; }
Is a permission allowed or not
15,674
private function getContentFromRequest ( Request $ request ) : array { $ data = json_decode ( $ request -> getContent ( ) , true ) ; foreach ( $ data as $ key => $ value ) { if ( $ value === null || $ value === '' ) { unset ( $ data [ $ key ] ) ; } } return $ data ; }
Returns an array of data from the request body and omits null values .
15,675
protected function initPaths ( array $ exclude_dirs = [ ] ) { $ apps_dir = $ this -> core -> config -> get ( 'Core' , 'dir.apps' ) ; $ apps_url = $ this -> core -> config -> get ( 'Core' , 'url.apps' ) ; $ dir = $ this -> getDir ( ) ; $ scanned_directory = array_diff ( scandir ( $ dir ) , array ( '..' , '.' ) ) ; $ this -> paths = new Paths ( ) ; $ dir = $ this -> getDir ( ) ; $ string = new CamelCase ( '' ) ; foreach ( $ scanned_directory as $ item ) { if ( is_dir ( $ dir . '/' . $ item ) && ! in_array ( $ item , $ exclude_dirs ) ) { $ string -> setString ( $ item ) ; $ key = $ string -> uncamelize ( ) ; $ this -> paths -> add ( 'dir.' . $ key , $ dir . '/' . $ item ) ; $ this -> paths -> add ( 'url.' . $ key , $ apps_url . '/' . $ this -> name . '/' . $ item ) ; } } $ this -> paths -> add ( 'dir.app' , $ dir ) ; $ this -> paths -> add ( 'url.app' , $ apps_url . '/' . $ this -> name ) ; }
Initializes the apps paths by creating the paths and writing them into the apps config .
15,676
protected function initPermissions ( ) { if ( isset ( $ this -> settings ) && $ this -> settings -> exists ( 'permissions' ) && ! self :: $ init_stages [ $ this -> name ] [ 'permissions' ] ) { $ permissions = [ 'admin' ] ; if ( $ this -> settings -> exists ( 'config' ) ) { $ permissions [ ] = 'config' ; } $ permissions = array_merge ( $ permissions , $ this -> settings -> get ( 'permissions' ) ) ; $ this -> permissions = new Permissions ( ) ; $ this -> permissions -> set ( $ permissions ) ; self :: $ init_stages [ $ this -> name ] [ 'perms' ] = true ; } }
Inits apps permissions by addind default values for admin and for config if confix exists
15,677
private function MVCFactory ( string $ name , string $ type , $ arguments = null ) { if ( ! in_array ( $ this -> name , self :: $ init_done ) ) { if ( ! $ this -> core -> router -> isAjax ( ) ) { $ this -> initCss ( ) ; $ this -> initJs ( ) ; } self :: $ init_done [ ] = $ this -> name ; } $ string = new CamelCase ( $ name ) ; $ name = $ string -> camelize ( $ name ) ; $ class = $ this -> getNamespace ( ) . '\\' . $ type . '\\' . $ name . $ type ; $ args = [ $ name , $ this ] ; if ( isset ( $ arguments ) ) { if ( ! is_array ( $ arguments ) ) { $ arguments = ( array ) $ arguments ; } foreach ( $ arguments as $ arg ) { $ args [ ] = $ arg ; } } $ classfile = new Classfile ( $ class ) ; if ( ! $ classfile -> exists ( ) ) { return false ; } $ object = $ this -> core -> di -> instance ( $ class , $ args ) ; switch ( $ type ) { case 'Controller' : $ object -> model = $ this -> getModel ( $ name ) ; break ; } return $ object ; }
Hidden method to factory mvc components like models views or controllers
15,678
private function getComponentsName ( ) : string { $ dt = debug_backtrace ( ) ; $ parts = array_reverse ( explode ( '\\' , $ dt [ 2 ] [ 'class' ] ) ) ; $ strip = [ 'Controller' , 'Model' , 'View' ] ; return str_replace ( $ strip , '' , $ parts [ 0 ] ) ; }
Autodiscovery of the components name
15,679
public function getModel ( string $ name = '' ) { if ( empty ( $ name ) ) { $ name = $ this -> getComponentsName ( ) ; } $ model = $ this -> MVCFactory ( $ name , 'Model' ) ; return $ model ; }
Creates an app related model object form this or a different app
15,680
public function getController ( string $ name = '' ) { if ( empty ( $ name ) ) { $ name = $ this -> getComponentsName ( ) ; } $ controller = $ this -> MVCFactory ( $ name , 'Controller' ) ; return $ controller ; }
Creates an app related controller object
15,681
public function getView ( string $ name = '' ) { if ( empty ( $ name ) ) { $ name = $ this -> getComponentsName ( ) ; } $ view = $ this -> MVCFactory ( $ name , 'View' ) ; return $ view ; }
Creates an app related view object
15,682
public function getName ( bool $ uncamelize = false ) { if ( $ uncamelize == true ) { $ string = new CamelCase ( $ this -> name ) ; return $ string -> uncamelize ( ) ; } else { return $ this -> name ; } }
Returns the name of this app .
15,683
public function url ( string $ name , array $ params = [ ] ) : string { return $ this -> core -> router -> generate ( $ name , $ params ) ; }
Generates an url by it s name
15,684
protected function _setTransition ( $ transition ) { $ this -> transition = ( $ transition === null ) ? null : $ this -> _normalizeStringable ( $ transition ) ; }
Sets the transition for with this instance .
15,685
function convertTimeZone ( $ date , $ to_tz , $ from_tz = null ) { throw new RuntimeException ( 'Not implemented!' ) ; if ( $ to_tz instanceof DateTimeZone ) { $ to_tz = $ to_tz -> getName ( ) ; } if ( $ from_tz instanceof DateTimeZone ) { $ from_tz = $ from_tz -> getName ( ) ; } return "NEW_TIME($date, '$from_tz', '$to_tz')" ; }
Returns SQL which converts the date value to its value in the target timezone
15,686
public function resolve ( $ curl , $ response ) { $ http_status = curl_getinfo ( $ curl , CURLINFO_HTTP_CODE ) ; if ( curl_errno ( $ curl ) ) { $ this -> fill ( false , $ http_status , curl_error ( $ curl ) , [ ] ) ; } else { if ( $ http_status == 200 ) { $ res = json_decode ( EncryptAes :: dencrypt ( $ response ) ) ; $ this -> fill ( $ res -> success , $ http_status , curl_error ( $ curl ) , $ res ) ; } else { $ this -> fill ( false , $ http_status , curl_error ( $ curl ) , [ ] ) ; } } return $ this ; }
Handle the curl response
15,687
public function fill ( $ success , $ statusCode , $ statusText , $ response ) { $ this -> success = $ success ; $ this -> statusCode = $ statusCode ; $ this -> statusText = $ statusText ; $ this -> response = $ response ; }
Fill the CurlResponse attributes
15,688
public function comparePasswords ( $ password ) { $ passwordSalted = $ this -> saltPassword ( $ password ) ; if ( password_verify ( $ passwordSalted , $ this -> privateKey ) ) { return true ; } return false ; }
Compares the given password from the login form with the saved one .
15,689
protected function encodePassword ( $ password ) { $ passwordSalted = $ this -> saltPassword ( $ password ) ; $ passwordEncoded = password_hash ( $ passwordSalted , PASSWORD_DEFAULT ) ; return $ passwordEncoded ; }
Encodes the given plain password
15,690
protected function saltPassword ( $ password ) { if ( isset ( $ this -> metaData [ 'salt' ] ) ) { $ salt = $ this -> metaData [ 'salt' ] ; } else { $ salt = $ this -> generateSalt ( ) ; } return $ salt . $ password ; }
Returns the salted password
15,691
public function getDbConnectionCmd ( ) { $ dbParams = $ this -> getDbConnectionParams ( ) ; $ dbConnectionCmd = 'mysql -u ' . $ dbParams [ 'user' ] . ' -h ' . $ dbParams [ 'host' ] . ' -P ' . $ dbParams [ 'port' ] ; if ( strlen ( $ dbParams [ 'password' ] ) > 0 ) { $ dbConnectionCmd .= ' -p"' . $ dbParams [ 'password' ] . '"' ; } return $ dbConnectionCmd ; }
Returns the mysql connection command
15,692
public function isAllowed ( RoleInterface $ role , ResourceInterface $ resource , PermissionInterface $ permission , array $ params = array ( ) ) { $ roleId = spl_object_hash ( $ role ) ; $ resourceId = spl_object_hash ( $ resource ) ; $ permissionId = spl_object_hash ( $ permission ) ; if ( isset ( $ this -> logger ) ) { $ this -> logger -> addRecord ( Logger :: INFO , sprintf ( " Start checking if role %s (class: %s) has permission %s (class: %s) to resource %s (class: %s)" , $ this -> stringify ( $ role ) , get_class ( $ role ) , $ this -> stringify ( $ permission ) , get_class ( $ permission ) , $ this -> stringify ( $ resource ) , get_class ( $ resource ) ) , $ params ) ; } $ allowed = $ this -> searchACEs ( $ roleId , $ resourceId , $ permissionId , $ params , 1 ) ; if ( ! isset ( $ allowed ) ) { $ allowed = $ this -> searchParentResourceACEs ( $ roleId , $ resourceId , $ permissionId , $ params , 1 ) ; } if ( ! isset ( $ allowed ) ) { $ allowed = $ this -> searchParentRoleACEs ( $ roleId , $ resourceId , $ permissionId , $ params , 1 ) ; } if ( isset ( $ allowed ) ) { return $ allowed ; } if ( isset ( $ this -> logger ) ) { $ this -> logger -> addRecord ( Logger :: INFO , sprintf ( " Access denied because no ACE has taken any decision" , $ this -> stringify ( $ role ) , $ this -> stringify ( $ permission ) , $ this -> stringify ( $ resource ) ) ) ; } return false ; }
Check access right to the specified permission of the specified resource for the specified role .
15,693
protected function searchParentRoleACEs ( $ roleId , $ resourceId , $ permissionId , array $ params = array ( ) , $ level = 0 ) { $ allowedAny = null ; if ( isset ( $ this -> rolesParents [ $ roleId ] ) && isset ( $ this -> resources [ $ resourceId ] ) && isset ( $ this -> permissions [ $ permissionId ] ) ) { if ( isset ( $ this -> logger ) ) { $ this -> logger -> addRecord ( Logger :: DEBUG , sprintf ( "%sChecking if any parent role has specified permission to specified resource" , str_repeat ( ' ' , $ level ) ) ) ; } foreach ( $ this -> rolesParents [ $ roleId ] as $ parentRoleId => $ parentRole ) { $ allowed = $ this -> searchACEs ( $ parentRoleId , $ resourceId , $ permissionId , $ params , $ level + 1 ) ; if ( ! isset ( $ allowed ) ) { $ allowed = $ this -> searchParentResourceACEs ( $ parentRoleId , $ resourceId , $ permissionId , $ params , $ level + 1 ) ; } if ( ! isset ( $ allowed ) ) { $ allowed = $ this -> searchParentRoleACEs ( $ parentRoleId , $ resourceId , $ permissionId , $ params , $ level + 1 ) ; } if ( isset ( $ allowed ) ) { if ( ! $ allowed ) { return $ allowed ; } else { $ allowedAny = true ; } } } } return $ allowedAny ; }
Search ACEs associated with parent roles of specified role for pemissions granted to the specified resource .
15,694
protected function searchParentResourceACEs ( $ roleId , $ resourceId , $ permissionId , array $ params = array ( ) , $ level = 0 ) { $ allowedAny = null ; if ( isset ( $ this -> resourcesParents [ $ resourceId ] ) && isset ( $ this -> roles [ $ roleId ] ) && isset ( $ this -> permissions [ $ permissionId ] ) ) { if ( isset ( $ this -> logger ) ) { $ this -> logger -> addRecord ( Logger :: DEBUG , sprintf ( "%sChecking if specified role has specified permission to any parent resource" , str_repeat ( ' ' , $ level ) ) ) ; } foreach ( $ this -> resourcesParents [ $ resourceId ] as $ parentResourceId => $ parentResource ) { $ allowed = $ this -> searchACEs ( $ roleId , $ parentResourceId , $ permissionId , $ params , $ level + 1 ) ; if ( ! isset ( $ allowed ) ) { $ allowed = $ this -> searchParentResourceACEs ( $ roleId , $ parentResourceId , $ permissionId , $ params , $ level + 1 ) ; } if ( isset ( $ allowed ) ) { if ( ! $ allowed ) { return $ allowed ; } else { $ allowedAny = true ; } } } } return $ allowedAny ; }
Search ACEs associated with parent resources of specified resource for pemissions granted for the specified role .
15,695
protected function searchACEs ( $ roleId , $ resourceId , $ permissionId , array $ params = array ( ) , $ level = 0 ) { if ( ! isset ( $ this -> ACEs [ $ roleId ] [ $ resourceId ] [ $ permissionId ] ) ) { return null ; } else { $ allowedAny = null ; foreach ( $ this -> ACEs [ $ roleId ] [ $ resourceId ] [ $ permissionId ] as $ ace ) { $ allowed = $ ace -> isAllowed ( $ params ) ; if ( isset ( $ this -> logger ) ) { $ this -> logger -> addRecord ( Logger :: INFO , sprintf ( " %s%s ACE (class: %s) {resource: %s (class: %s), role: %s (class: %s), permission: %s (class: %s)}" , str_repeat ( ' ' , $ level ) , isset ( $ allowed ) ? ( $ allowed ? 'Access granted by' : 'Access denied by' ) : 'No decision from' , $ ace , $ this -> stringify ( $ ace -> getResource ( ) ) , get_class ( $ ace -> getResource ( ) ) , $ this -> stringify ( $ ace -> getRole ( ) ) , get_class ( $ ace -> getRole ( ) ) , $ this -> stringify ( $ this -> permissions [ $ permissionId ] ) , get_class ( $ this -> permissions [ $ permissionId ] ) ) ) ; } if ( isset ( $ allowed ) ) { if ( ! $ allowed ) { return false ; } else { $ allowedAny = true ; } } } return $ allowedAny ; } }
Search ACEs associated with specified role resource and permission .
15,696
protected function getFlashMessengerHelper ( ) { if ( $ this -> flashMessengerHelper ) { return $ this -> flashMessengerHelper ; } if ( method_exists ( $ this -> view , 'plugin' ) ) { $ this -> flashMessengerHelper = $ this -> view -> plugin ( FlashMessengerHelper :: class ) ; } if ( ! $ this -> flashMessengerHelper instanceof FlashMessengerHelper ) { $ this -> flashMessengerHelper = new FlashMessengerHelper ( ) ; } return $ this -> flashMessengerHelper ; }
Retrieve the FlashMessenger helper
15,697
protected function trigger ( $ event ) { $ arguments = func_get_args ( ) ; array_shift ( $ arguments ) ; if ( isset ( $ this -> events [ $ event ] ) ) { foreach ( $ this -> events [ $ event ] as $ call ) { call_user_func_array ( $ call , $ arguments ) ; } } foreach ( $ this -> observing as $ observer ) { $ observer -> update ( ) ; } }
Trigger an event possibly with parameters .
15,698
public function on ( $ event , callable $ callback ) { if ( ! isset ( $ this -> events [ $ event ] ) ) { $ this -> events [ $ event ] = array ( ) ; } $ this -> events [ $ event ] [ ] = $ callback ; }
Listen to specific events
15,699
public function get ( $ property , $ default = null ) { if ( is_array ( $ property ) ) { $ values = array ( ) ; foreach ( $ property as $ key => $ prop ) { if ( isset ( $ this -> $ prop ) ) { $ values [ $ prop ] = $ this -> $ prop ; } } return ( ! empty ( $ values ) ) ? $ values : $ default ; } if ( isset ( $ this -> $ property ) ) { return $ this -> $ property ; } return $ default ; }
Get a protected object property