idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
59,400
|
private function scheduleForDeletion ( $ object ) { $ oid = spl_object_hash ( $ object ) ; if ( isset ( $ this -> documentInsertions [ $ oid ] ) ) { if ( $ this -> isInIdentityMap ( $ object ) ) { $ this -> removeFromIdentityMap ( $ object ) ; } unset ( $ this -> documentInsertions [ $ oid ] , $ this -> documentStates [ $ oid ] ) ; return ; } if ( ! $ this -> isInIdentityMap ( $ object ) ) { return ; } $ this -> removeFromIdentityMap ( $ object ) ; unset ( $ this -> documentUpdates [ $ oid ] ) ; $ this -> documentDeletions [ $ oid ] = $ object ; $ this -> documentStates [ $ oid ] = self :: STATE_REMOVED ; }
|
Schedule a document for deletion .
|
59,401
|
private function newInstance ( DocumentMetadata $ class ) { $ document = $ class -> newInstance ( ) ; if ( $ document instanceof ObjectManagerAware ) { $ document -> injectObjectManager ( $ this -> manager , $ class ) ; } return $ document ; }
|
Creates a new instance of given class and inject object manager if needed .
|
59,402
|
private function getCommitOrder ( ) : array { static $ calculator = null ; if ( null === $ calculator ) { $ calculator = new CommitOrderCalculator ( ) ; } $ objects = array_merge ( $ this -> documentInsertions , $ this -> documentUpdates , $ this -> documentDeletions ) ; $ classes = [ ] ; foreach ( $ objects as $ object ) { $ metadata = $ this -> manager -> getClassMetadata ( get_class ( $ object ) ) ; $ calculator -> addClass ( $ metadata ) ; $ classes [ $ metadata -> getName ( ) ] = $ metadata ; } $ order = $ calculator -> getOrder ( array_keys ( $ classes ) ) ; return array_map ( function ( array $ element ) { return $ element [ 0 ] -> getClassName ( ) ; } , $ order ) ; }
|
Calculates the commit order based on associations on document metadata .
|
59,403
|
public function signupAction ( ) { $ form = new SignUpForm ( ) ; if ( $ this -> request -> isPost ( ) ) { if ( $ form -> isValid ( $ this -> request -> getPost ( ) ) != false ) { $ user = new Users ( [ 'name' => $ this -> request -> getPost ( 'name' , 'striptags' ) , 'email' => $ this -> request -> getPost ( 'email' ) , 'password' => $ this -> security -> hash ( $ this -> request -> getPost ( 'password' ) ) , 'profilesId' => 2 ] ) ; if ( $ user -> save ( ) ) { return $ this -> response -> redirect ( 'index' ) ; } $ this -> flash -> error ( $ user -> getMessages ( ) ) ; } } $ this -> view -> form = $ form ; }
|
Allow a user to signup to the system
|
59,404
|
public function loginAction ( ) { $ form = new LoginForm ( ) ; try { if ( ! $ this -> request -> isPost ( ) ) { if ( $ this -> auth -> hasRememberMe ( ) ) { return $ this -> auth -> loginWithRememberMe ( ) ; } } else { if ( $ form -> isValid ( $ this -> request -> getPost ( ) ) == false ) { foreach ( $ form -> getMessages ( ) as $ message ) { $ this -> flash -> error ( $ message ) ; } } else { $ this -> auth -> check ( [ 'email' => $ this -> request -> getPost ( 'email' ) , 'password' => $ this -> request -> getPost ( 'password' ) , 'remember' => $ this -> request -> getPost ( 'remember' ) ] ) ; return $ this -> response -> redirect ( 'dashboard' ) ; } } } catch ( AuthException $ e ) { $ this -> flash -> error ( $ e -> getMessage ( ) ) ; } $ this -> view -> form = $ form ; }
|
Starts a session in the admin backend
|
59,405
|
public function forgotPasswordAction ( ) { $ form = new ForgotPasswordForm ( ) ; if ( $ this -> request -> isPost ( ) ) { if ( $ this -> getDI ( ) -> get ( 'config' ) -> useMail ) { if ( $ form -> isValid ( $ this -> request -> getPost ( ) ) == false ) { foreach ( $ form -> getMessages ( ) as $ message ) { $ this -> flash -> error ( $ message ) ; } } else { $ user = Users :: findFirstByEmail ( $ this -> request -> getPost ( 'email' ) ) ; if ( ! $ user ) { $ this -> flash -> success ( 'There is no account associated to this email' ) ; } else { $ resetPassword = new ResetPasswords ( ) ; $ resetPassword -> usersId = $ user -> id ; if ( $ resetPassword -> save ( ) ) { $ this -> flash -> success ( 'Success! Please check your messages for an email reset password' ) ; } else { foreach ( $ resetPassword -> getMessages ( ) as $ message ) { $ this -> flash -> error ( $ message ) ; } } } } } else { $ this -> flash -> warning ( 'Emails are currently disabled. Change config key "useMail" to true to enable emails.' ) ; } } $ this -> view -> form = $ form ; }
|
Shows the forgot password form
|
59,406
|
public function registerInstance ( $ name = null ) { if ( $ name === null ) { $ name = 'default' ; } $ this -> instanceName ( $ name ) ; return $ this ; }
|
This function manually registers an instance of this object with the management routines . Helpful if you have hand - cranked this object by calling construct explicitly .
|
59,407
|
public function unregisterInstance ( ) { if ( array_key_exists ( $ this -> instanceName , self :: $ instances ) ) { unset ( self :: $ instances [ $ this -> instanceName ] ) ; unset ( $ this -> instanceName ) ; } return $ this ; }
|
Unregisters an instance with the manager .
|
59,408
|
public function classTask ( Option $ option ) { $ current = $ this -> getRootAppDir ( $ option ) ; $ base_dir = $ current ; foreach ( $ option -> getArgs ( ) as $ class ) { $ path = str_replace ( '\\' , DS , $ class ) ; $ dir = dirname ( $ path ) ; if ( $ dir == '.' ) $ dir = '' ; $ skeleton = $ this -> getSkeleton ( $ option -> get ( 'skeleton' ) ) ; $ class_name = basename ( $ path , '.php' ) ; $ namespace = str_replace ( DS , '\\' , $ dir ) ; $ skeleton -> assign ( 'namespace' , $ namespace ) ; $ skeleton -> assign ( 'class' , $ class_name ) ; $ skeleton -> assign ( 'extends' , $ option -> get ( 'extends' ) ) ; $ skeleton -> assign ( 'use-raikiri' , $ option -> get ( 'use-raikiri' ) ) ; $ skeleton -> assign ( 'use-accessor' , $ option -> get ( 'use-accessor' ) ) ; $ file = $ base_dir . DS . ( $ dir ? $ dir . DS : '' ) . $ class_name . '.php' ; $ file = $ this -> loader -> find ( $ current . DS . ( $ dir ? $ dir . DS : '' ) . $ class_name . '.php' , true ) -> first ( ) ; if ( ! $ file -> isExists ( ) || $ this -> confirmation ( [ 'class file(%s) is already exists. override ?' , $ file ] ) ) { $ this -> fileUtil -> mkdirP ( dirname ( $ file ) ) ; $ this -> fileUtil -> putContents ( $ file , $ skeleton -> render ( ) ) ; $ this -> sendMessage ( 'created class file. -> %s' , $ file ) ; } if ( $ option -> get ( 'with-spec' ) ) $ this -> task ( 'add:spec' , [ $ class ] ) ; } }
|
add a class .
|
59,409
|
public function componentTask ( Option $ option ) { $ root = $ this -> getRootAppDir ( $ option ) ; $ current = $ this -> getCurrentAppDir ( $ option ) ; $ prefix = trim ( preg_replace ( '/^' . preg_quote ( $ root , '/' ) . '/' , '' , $ current ) , DS ) ; $ option -> setArg ( 0 , $ prefix . DS . 'Component' . DS . $ option -> getArg ( 0 ) ) ; $ this -> task ( 'add:class' , $ option ) ; }
|
add a component .
|
59,410
|
public function filterTask ( Option $ option ) { $ root = $ this -> getRootAppDir ( $ option ) ; $ current = $ this -> getCurrentAppDir ( $ option ) ; $ prefix = trim ( preg_replace ( '/^' . preg_quote ( $ root , '/' ) . '/' , '' , $ current ) , DS ) ; $ name = $ option -> getArg ( 0 ) ; if ( ! preg_match ( '/Filter$/' , $ name ) ) $ name .= 'Filter' ; $ option -> set ( 'skeleton' , 'filter' ) ; $ option -> setArg ( 0 , $ prefix . DS . 'Filter' . DS . $ name ) ; $ this -> task ( 'add:class' , $ option ) ; }
|
add a filter .
|
59,411
|
public function specTask ( Option $ option ) { $ runner = $ this -> specHelper -> getRunner ( ) ; foreach ( $ option -> getArgs ( ) as $ class ) { $ path = str_replace ( '\\' , DS , $ class ) ; $ dir = dirname ( $ path ) ; if ( $ dir == '.' ) $ dir = '' ; try { $ skeleton = $ this -> getSkeleton ( 'Spec' ) ; $ class_name = basename ( $ path , '.php' ) ; $ skeleton -> assign ( 'class' , $ class_name ) ; $ namespace = str_replace ( DS , '\\' , $ dir ) ; $ skeleton -> assign ( 'namespace' , $ namespace ? $ namespace . '\\' : '' ) ; $ spec_file = $ runner -> getSpecFile ( $ class ) ; $ spec_dir = $ spec_file -> getDirectory ( ) ; $ skeleton -> assign ( 'spec_namespace' , $ spec_file -> getNameSpace ( ) ) ; $ skeleton -> assign ( 'spec_class' , $ spec_file -> getClassName ( false ) ) ; if ( ! $ spec_file -> isExists ( ) || $ this -> confirmation ( [ 'spec file(%s) is already exists. override ?' , $ spec_file ] ) ) { $ this -> fileUtil -> mkdirP ( $ spec_dir ) ; $ this -> fileUtil -> putContents ( $ spec_file , $ skeleton -> render ( ) ) ; $ this -> sendMessage ( 'created spec file. -> %s' , $ spec_file ) ; } } catch ( NotFoundException $ e ) { $ this -> sendMessage ( 'not found spec dir for %s' , $ class ) ; } } }
|
add a spec .
|
59,412
|
public function migrationTask ( Option $ option ) { $ database = $ option -> get ( 'database' ) ; $ current = $ this -> getCurrentAppDir ( $ option ) ; $ migration_dir = $ this -> loader -> find ( $ current . DS . $ this -> application -> config ( 'directory.database.migration' ) ) -> first ( ) ; $ migration_dir -> absolutize ( ) ; foreach ( $ option -> getArgs ( ) as $ arg ) { $ name = $ this -> migrationHelper -> nameStrategy ( $ arg ) ; $ filename = $ this -> migrationHelper -> fileNameStrategy ( $ database , $ name ) ; $ classname = $ this -> migrationHelper -> classNameStrategy ( $ database , $ name ) ; $ namespace = $ this -> migrationHelper -> namespaceStrategy ( $ migration_dir , $ database , $ name ) ; $ skeleton = $ this -> getSkeleton ( 'Migration' ) ; $ base_dir = clone $ migration_dir ; $ skeleton -> assign ( 'namespace' , $ namespace ? $ namespace . '\\' : '' ) ; $ skeleton -> assign ( 'class' , $ classname ) ; $ migration_file = $ migration_dir -> getRealPath ( ) . DS . $ filename ; $ this -> fileUtil -> mkdirP ( dirname ( $ migration_file ) ) ; $ this -> fileUtil -> putContents ( $ migration_file , $ skeleton -> render ( ) ) ; $ this -> sendMessage ( 'created migration file. -> %s' , $ migration_file ) ; } }
|
add a migration
|
59,413
|
public function seederTask ( Option $ option ) { $ database = $ option -> get ( 'database' ) ; $ current = $ this -> getCurrentAppDir ( $ option ) ; $ seeder_dir = $ this -> loader -> find ( $ current . DS . $ this -> application -> config ( 'directory.database.seed' ) ) -> first ( ) ; $ seeder_dir -> absolutize ( ) ; foreach ( $ option -> getArgs ( ) as $ arg ) { $ name = $ this -> migrationHelper -> seederNameStrategy ( $ arg ) ; $ filename = $ this -> migrationHelper -> seederFileNameStrategy ( $ database , $ name ) ; $ seeder_file = $ this -> loader -> findFirst ( $ seeder_dir . DS . $ filename , true ) ; $ classname = $ seeder_file -> getClassName ( false ) ; $ namespace = $ seeder_file -> getNameSpace ( ) ; $ skeleton = $ this -> getSkeleton ( 'Seeder' ) ; $ base_dir = clone $ seeder_dir ; $ skeleton -> assign ( 'namespace' , $ namespace ? $ namespace : '' ) ; $ skeleton -> assign ( 'class' , $ classname ) ; $ this -> fileUtil -> mkdirP ( dirname ( $ seeder_file ) ) ; $ this -> fileUtil -> putContents ( $ seeder_file , $ skeleton -> render ( ) ) ; $ this -> sendMessage ( 'created seeder file. -> %s' , $ seeder_file ) ; } }
|
add a seeder
|
59,414
|
private function getSkeleton ( $ name , $ suffix = 'php' ) { $ file = $ this -> loader -> find ( $ this -> application -> config ( 'directory.skeleton' ) . DS . ucfirst ( $ name ) . 'Skeleton.' . $ suffix . '.twig' ) -> first ( ) ; $ skeleton = new Skeleton ( $ file ) ; return $ skeleton ; }
|
get skeleton .
|
59,415
|
public function getCurrentAppDir ( Option $ option ) { if ( $ dir = $ option -> get ( 'app-dir' ) ) { return $ dir [ 0 ] === '/' ? $ dir : getcwd ( ) . DS . $ dir ; } else { $ current = getcwd ( ) ; $ default = null ; foreach ( $ this -> application -> config ( 'directory.apps' ) as $ app ) { if ( strpos ( $ current , $ app [ 'dir' ] ) === 0 ) return $ app [ 'dir' ] ; if ( ! $ default ) $ default = $ app [ 'dir' ] ; } return $ default ; } }
|
get current dir in application .
|
59,416
|
public function getRootAppDir ( Option $ option ) { if ( $ dir = $ option -> get ( 'root-dir' ) ) { return $ dir [ 0 ] === '/' ? $ dir : getcwd ( ) . DS . $ dir ; } else { $ root = getcwd ( ) ; $ default = null ; foreach ( $ this -> application -> config ( 'directory.apps' ) as $ app ) { if ( strpos ( $ root , $ app [ 'dir' ] ) === 0 ) return $ app [ 'root' ] ; if ( ! $ default ) $ default = $ app [ 'root' ] ; } return $ default ; } }
|
get root dir in application .
|
59,417
|
function save ( ) { $ file = $ this -> _getFilePath ( ) ; $ data = $ this -> data ; $ data = $ this -> getDataInterchange ( ) -> makeForward ( $ data ) ; $ dataStr = "<?php\n" . "return " . var_export ( $ data , true ) . ";\n" ; ErrorStack :: handleError ( E_ALL ) ; $ dirPath = dirname ( $ file ) ; if ( ! file_exists ( $ dirPath ) ) if ( false === mkdir ( $ dirPath , 0777 , true ) ) throw new \ RuntimeException ( sprintf ( 'Cant create store directory on (%s).' , $ dirPath ) ) ; file_put_contents ( $ file , $ dataStr , LOCK_EX ) ; if ( $ exception = ErrorStack :: handleDone ( ) ) throw $ exception ; $ this -> _setState ( self :: $ STATE_OK ) ; return $ this ; }
|
Write Data Into Storage
|
59,418
|
function _load ( ) { $ file = $ this -> _getFilePath ( ) ; if ( ! file_exists ( $ file ) ) return ; ErrorStack :: handleError ( E_ALL ) ; $ data = include $ file ; $ data = $ this -> getDataInterchange ( ) -> retrieveBackward ( $ data ) ; if ( $ exception = ErrorStack :: handleDone ( ) ) throw new exReadError ( 'Error While Read Data.' , $ exception -> getCode ( ) , $ exception ) ; if ( ! is_array ( $ data ) ) throw new exDataMalformed ( 'Error Data Structure, it must be array.' ) ; $ this -> data = $ data ; }
|
Import Persist Data Into Entity as Default Values
|
59,419
|
protected function _writeDataOnShutdown ( ) { if ( ! isset ( $ this -> _states [ $ this -> getRealm ( ) ] ) || $ this -> _states [ $ this -> getRealm ( ) ] === self :: $ STATE_OK ) return ; $ this -> save ( ) ; }
|
Write Data To File
|
59,420
|
protected function _getFilePath ( ) { $ opt_directory = $ this -> getDirPath ( ) ; $ file = $ opt_directory . DIRECTORY_SEPARATOR . $ this -> getRealm ( ) . '.array.php' ; return $ file ; }
|
Get Current Storage FilePath Name
|
59,421
|
public function equals ( $ value , bool $ strict = false ) : bool { if ( ! ( $ value instanceof Type ) ) { $ value = new Type ( $ value ) ; } $ res = ( $ value -> typeName === $ this -> typeName ) ; if ( ! $ res && $ strict ) { return $ res ; } if ( $ value -> isStringConvertible ) { return ( $ value -> stringValue === $ this -> stringValue ) ; } return ( $ value -> value === $ this -> value ) ; }
|
Checks if the current instance is equal to defined value . If strict is FALSE only the value is checked . Otherwise also the type is checked .
|
59,422
|
public function getLogLevelName ( $ level ) : string { return isset ( self :: $ levels [ $ level ] ) ? self :: $ levels [ $ level ] : '' ; }
|
Devuelve el nombre del nivel
|
59,423
|
public function logDebug ( $ message , $ object = null ) { $ this -> doLog ( LogHelper :: LOG_LEVEL_DEBUG , $ message , $ object ) ; }
|
log debug message
|
59,424
|
public function logInfo ( $ message , $ object = null ) { $ this -> doLog ( LogHelper :: LOG_LEVEL_INFO , $ message , $ object ) ; }
|
log an informational message
|
59,425
|
public function logWarning ( $ message , $ object = null ) { $ this -> doLog ( LogHelper :: LOG_LEVEL_WARNING , $ message , $ object ) ; }
|
log a message which may need the attention of the developer but may not endager the main purpose of the application
|
59,426
|
public function logFatal ( $ message , $ object = null ) { $ this -> doLog ( LogHelper :: LOG_LEVEL_FATAL , $ message , $ object ) ; }
|
log an error which may be related to a programming mistake and not related to corrupt data
|
59,427
|
public function logException ( Exception $ exception , $ message = null ) { $ msg = $ exception -> getMessage ( ) ; if ( $ message != null ) { $ msg = "Message: " . $ message . " Exception: " . $ msg ; } $ this -> doLog ( LogHelper :: LOG_LEVEL_FATAL , $ msg , null ) ; }
|
log an exception
|
59,428
|
public function read ( $ id ) { $ tmp = $ _SESSION ; $ key = $ this -> getKey ( $ id ) ; $ _SESSION = json_decode ( $ this -> mem -> get ( $ key , false , '' ) , true ) ; $ user = $ this -> getUser ( ) ; if ( $ user instanceof UserInterface ) { $ roles = array ( ) ; foreach ( $ user -> getRoles ( ) as $ role ) { $ roles [ ] = $ role -> getRole ( ) ; } $ userData = array ( 'username' => $ user -> getUsername ( ) , 'roles' => $ roles ) ; $ _SESSION [ 'user' ] = $ userData ; } if ( isset ( $ _SESSION ) && ! empty ( $ _SESSION ) && $ _SESSION != null ) { $ new_data = session_encode ( ) ; $ _SESSION = $ tmp ; return $ new_data ; } return '' ; }
|
Read the id
|
59,429
|
public function write ( $ id , $ data ) { $ tmp = $ _SESSION ; session_decode ( $ data ) ; $ newData = $ _SESSION ; $ _SESSION = $ tmp ; $ key = $ this -> getKey ( $ id ) ; return $ this -> mem -> set ( $ key , json_encode ( $ newData ) , $ this -> ttl ) ; }
|
Write the session data convert to json before storing
|
59,430
|
public function destroy ( $ id ) { $ key = $ this -> getKey ( $ id ) ; return $ this -> mem -> remove ( $ key ) ; }
|
Delete object in session
|
59,431
|
public function parseRoute ( $ beforeDispatch ) { $ request = $ this -> application -> request ; $ route = $ this -> router -> matchToRoute ( $ request ) ; if ( ! ( $ route instanceof Route ) ) { throw new Exception ( "A valid route could not be determined" ) ; } $ format = "html" ; if ( isset ( $ route -> params [ 'format' ] ) ) { $ format = str_replace ( [ "." , " " , "_" , "-" ] , "" , $ route -> params [ 'format' ] ) ; } $ route -> setParam ( "format" , $ format ) ; $ request -> setAttributes ( $ route -> params ) ; $ beforeDispatch -> data [ 'route' ] = $ route ; }
|
Recieves the beforeDispatchEvent Routes the applicaition and gets all route params Stores Route params in the beforeDispatch Event results
|
59,432
|
public function redirect ( $ url , $ code = HTTP_FOUND , $ message = "Moved Permanently" , $ alerts = [ ] ) { $ response = $ this -> application -> response ; $ uri = $ this -> application -> createInstance ( Uri :: class , [ $ this -> application -> request ] ) ; if ( ! empty ( $ alerts ) ) { $ session = $ this -> application -> session ; $ session -> set ( "alerts" , $ alerts , "default" ) ; } $ response -> setStatusCode ( $ code ) ; $ response -> setStatusMessage ( $ message ) ; $ response -> addHeader ( "Location" , $ uri -> internalize ( $ url ) ) ; $ response -> sendRedirect ( ) ; $ this -> abort ( ) ; }
|
Executes post dispatch redirect
|
59,433
|
public function render ( $ template , array $ localVariables = array ( ) ) { $ view = $ this -> getView ( ) ; if ( $ view -> getLayout ( ) ) { $ content = $ view -> renderWithLayout ( $ template , $ localVariables ) ; } else { $ content = $ view -> render ( $ template , $ localVariables ) ; } $ this -> getResponse ( ) -> setBody ( $ content ) ; return $ this ; }
|
Appends template content to the body
|
59,434
|
protected function getSpecificRoleSuffix ( $ role ) { return ( empty ( $ role ) || 'LIST' === strtoupper ( $ role ) ) ? '' : self :: ROLE_SEPARATOR . strtoupper ( $ role ) ; }
|
Get a specific role suffix .
|
59,435
|
protected function getSpecificRoleFormatted ( $ role ) { return '' . self :: ROLE_PREFIX . self :: ROLE_SEPARATOR . str_replace ( '\\' , '' , strtoupper ( $ this -> getBundleName ( ) ) ) . self :: ROLE_SEPARATOR . strtoupper ( $ this -> getControllerName ( ) ) . $ this -> getSpecificRoleSuffix ( $ role ) ; }
|
Get a specific role formatted .
|
59,436
|
protected function isGranted ( $ specificRole = 'LIST' , $ genericRole = null ) { $ securityContext = $ this -> getSecurityContext ( ) ; if ( $ securityContext -> isGranted ( is_null ( $ genericRole ) ? $ this -> getSecurityRoleAdmin ( ) : $ genericRole ) ) { return true ; } if ( $ securityContext -> isGranted ( $ this -> getSpecificRoleFormatted ( $ specificRole ) ) ) { return true ; } return false ; }
|
Checks if the user has permission to perform the action .
|
59,437
|
public function add ( InstallTarget $ target ) { $ this -> targets [ $ target -> getName ( ) ] = $ target ; if ( ! $ this -> defaultTarget ) { $ this -> defaultTarget = $ target ; } }
|
Adds a target to the collection .
|
59,438
|
public function get ( $ targetName ) { if ( InstallTarget :: DEFAULT_TARGET === $ targetName ) { return $ this -> getDefaultTarget ( ) ; } if ( ! isset ( $ this -> targets [ $ targetName ] ) ) { throw NoSuchTargetException :: forTargetName ( $ targetName ) ; } return $ this -> targets [ $ targetName ] ; }
|
Returns the target with the given name .
|
59,439
|
public function remove ( $ targetName ) { if ( InstallTarget :: DEFAULT_TARGET === $ targetName && $ this -> defaultTarget ) { $ targetName = $ this -> defaultTarget -> getName ( ) ; } unset ( $ this -> targets [ $ targetName ] ) ; if ( $ this -> defaultTarget && $ targetName === $ this -> defaultTarget -> getName ( ) ) { $ this -> defaultTarget = $ this -> targets ? reset ( $ this -> targets ) : null ; } }
|
Removes a target from the collection .
|
59,440
|
public function contains ( $ targetName ) { if ( InstallTarget :: DEFAULT_TARGET === $ targetName ) { return null !== $ this -> defaultTarget ; } return isset ( $ this -> targets [ $ targetName ] ) ; }
|
Returns whether a target exists .
|
59,441
|
private function sortFactories ( ) { $ this -> sorted = [ ] ; krsort ( $ this -> factories ) ; $ this -> sorted = call_user_func_array ( 'array_merge' , $ this -> factories ) ; }
|
Sorts the internal list of factories by priority .
|
59,442
|
public function withMethods ( array $ methods ) { foreach ( $ methods as $ method => $ args ) { $ this -> withMethod ( $ method , $ args ) ; } return $ this ; }
|
Adds multiple method calls to be executed after instantiating .
|
59,443
|
public static function fromEnvironment ( ) : RequestInterface { $ headers = [ ] ; foreach ( $ _SERVER as $ name => $ value ) { if ( strpos ( $ name , 'HTTP_' ) === 0 ) { $ name = substr ( $ name , 5 ) ; $ name = str_replace ( '_' , ' ' , $ name ) ; $ name = strtolower ( $ name ) ; $ name = ucwords ( $ name ) ; $ name = str_replace ( ' ' , '-' , $ name ) ; $ headers [ $ name ] = $ value ; } } $ input = file_get_contents ( 'php://input' ) ? : '' ; if ( empty ( $ input ) === false ) { $ body = json_decode ( file_get_contents ( 'php://input' ) ? : '' ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new InvalidRequestBody ( json_last_error_msg ( ) ) ; } } return ( new static ( ) ) -> withMethod ( $ _SERVER [ 'REQUEST_METHOD' ] ) -> withBody ( $ body ?? null ) -> withHeaders ( $ headers ) -> withUri ( Uri :: fromEnvironment ( ) ) ; }
|
Construct from environment variables .
|
59,444
|
public function intersect ( array $ tags ) { $ result = new self ( ) ; foreach ( $ tags as $ tag ) { if ( $ this -> contains ( $ tag ) ) { $ result -> addTag ( $ tag ) ; } } return $ result ; }
|
Return intersection with given tags
|
59,445
|
function transact ( callable $ callable ) { $ this -> beginTransaction ( ) ; try { call_user_func ( $ callable ) ; $ this -> commit ( ) ; } catch ( Exception $ e ) { $ this -> rollBack ( ) ; throw $ e ; } }
|
Runs the given callable in a transaction . If the callback throws automatically rollback the transaction and rethrow . If the callback doesn t throw commit the transaction .
|
59,446
|
function storeRedirectUrl ( $ url ) { $ sessionManager = $ this -> _getSessionFlashes ( ) ; $ sessionManager -> offsetSet ( 'auth.login.redirect_url' , $ url ) ; $ sessionManager -> setExpirationHops ( 1 , 'auth.login.redirect_url' ) ; }
|
On UnAuthorized Or Banned Page Usually Guard redirect to login page . here we store redirect url that can be restore on successful login for redirect .
|
59,447
|
public function handleRoutes ( $ event ) { $ event -> getRouter ( ) -> prefix ( '/api/attachment' ) -> post ( 'attachment-upload' , '' , UploadController :: class ) -> prefix ( '/api/helper' ) -> get ( 'helper-pinyin' , '/pinyin' , PinyinController :: class ) -> prefix ( '/api/permission' ) -> get ( 'permission-list' , '' , PermissionListController :: class ) -> put ( 'permission-update' , '' , PermissionUpdateController :: class ) -> prefix ( '/api/config' ) -> get ( 'config-list' , '' , ConfigListController :: class ) -> put ( 'config-update' , '/{key}' , ConfigUpdateController :: class ) -> post ( 'config-logo' , '/logo' , LogoUpdateController :: class ) -> prefix ( '/api/auth' ) -> get ( 'auth-check' , '' , AuthCheckController :: class ) -> post ( 'auth-login' , '/login' , LoginController :: class ) -> post ( 'auth-logout' , '/logout' , LogoutController :: class ) -> post ( 'auth-forget' , '/forget' , ForgetPasswordController :: class ) -> post ( 'auth-reset' , '/reset/{token}' , ResetPasswordController :: class ) -> prefix ( '/api/member' ) -> get ( 'member-list' , '' , MemberListController :: class ) -> post ( 'member-create' , '' , MemberCreateController :: class ) -> get ( 'member-item' , '/{username}' , MemberItemController :: class ) -> put ( 'member-update' , '/{username}' , MemberUpdateController :: class ) -> put ( 'member-role-update' , '/{username}/role' , MemberRoleUpdateController :: class ) -> prefix ( '/api/role' ) -> get ( 'role-list' , '' , RoleListController :: class ) -> post ( 'role-create' , '' , RoleCreateController :: class ) -> put ( 'role-update' , '/{id}' , RoleUpdateController :: class ) -> delete ( 'role-delete' , '/{id}' , RoleDeleteController :: class ) -> prefix ( '/api/extension' ) -> get ( 'extension-list' , '' , ExtensionListController :: class ) -> put ( 'extension-activate' , '/{vendor}/{package}' , ExtensionActivateController :: class ) -> delete ( 'extension-uninstall' , '/{vendor}/{package}' , ExtensionUninstallController :: class ) -> prefix ( '' ) ; }
|
handle RoutesWillBeLoaded event all core api routes will be loaded here
|
59,448
|
function onMvcErrorInjectResponse ( $ e ) { $ error = $ e -> getError ( ) ; if ( empty ( $ error ) || ! $ error instanceof \ Exception ) return ; if ( $ e -> getResult ( ) instanceof Response ) $ e -> setResponse ( $ e -> getResult ( ) ) ; $ response = $ e -> getResponse ( ) ; if ( ! $ response ) { $ response = new Response ( ) ; $ e -> setResponse ( $ response ) ; } if ( $ response -> getStatusCode ( ) === 200 ) $ response -> setStatusCode ( $ this -> __getResponseCodeFromException ( $ error ) ) ; $ this -> error = $ error ; }
|
Inject Status Response Code related on Exception
|
59,449
|
protected function __getExceptionTemplate ( $ e ) { $ config = $ this -> sm -> get ( 'Config' ) ; $ config = isset ( $ config [ 'view_manager' ] ) && ( is_array ( $ config [ 'view_manager' ] ) || $ config [ 'view_manager' ] instanceof \ ArrayAccess ) ? $ config [ 'view_manager' ] : array ( ) ; $ exceptionTemplate = 'spec/error' ; $ exClass = get_class ( $ e ) ; while ( $ exClass ) { if ( isset ( $ config [ 'layout_exception' ] ) && isset ( $ config [ 'layout_exception' ] [ $ exClass ] ) ) { $ exceptionTemplate = $ config [ 'layout_exception' ] [ $ exClass ] ; break ; } $ exClass = get_parent_class ( $ exClass ) ; } return $ exceptionTemplate ; }
|
Retrieve the exception template
|
59,450
|
public function purge ( $ data ) { $ processPayload = $ this -> process ( __FUNCTION__ , $ data ) ; if ( ! $ processPayload -> isStatus ( Payload :: STATUS_VALID ) ) { return $ processPayload ; } $ identifierPayload = $ this -> aggregate [ IdentifierServiceProvider :: getProviderKey ( ) ] -> get ( [ 'filter' => [ 'uuid' => $ processPayload -> getData ( ) [ 'uuid' ] ] ] ) ; if ( $ identifierPayload -> getStatus ( ) != 'found' ) { return $ identifierPayload ; } $ entityPurgePayload = $ this -> aggregate [ self :: getEntityType ( ) ] -> purge ( $ identifierPayload -> getData ( ) -> pluck ( 'entity_id' ) -> toArray ( ) ) ; if ( $ entityPurgePayload -> getStatus ( ) != 'purged' ) { return new Payload ( $ identifierPayload -> getData ( ) , $ entityPurgePayload -> getStatus ( ) ) ; } $ identifierPurgePayload = $ this -> aggregate [ IdentifierServiceProvider :: getProviderKey ( ) ] -> purge ( $ identifierPayload -> getData ( ) -> pluck ( 'id' ) -> toArray ( ) ) ; return new Payload ( $ identifierPayload -> getData ( ) , $ entityPurgePayload -> getStatus ( ) ) ; }
|
Purge Entity .
|
59,451
|
protected function updateByEntity ( $ data , $ entity ) { return $ this -> aggregate [ $ entity -> getType ( true ) ] -> update ( $ data , $ entity ) ; }
|
Update a Entity by object .
|
59,452
|
protected function updateByIdentifier ( $ identifier , $ data ) { return $ this -> aggregate [ IdentifierServiceProvider :: getProviderKey ( ) ] -> update ( $ identifier -> getEntity ( ) , $ data ) ; }
|
Update an Entity by Identifier .
|
59,453
|
public function getOneByUuid ( $ uuid ) { $ identifierPayload = $ this -> aggregate [ IdentifierServiceProvider :: getProviderKey ( ) ] -> first ( [ 'filter' => [ 'uuid' => $ uuid ] ] ) ; if ( $ identifierPayload -> getStatus ( ) != 'found' ) { return $ identifierPayload ; } return $ this -> aggregate [ $ this -> formatEntityType ( $ identifierPayload -> getData ( ) -> getEntityType ( ) ) ] -> first ( [ 'filter' => [ 'id' => $ identifierPayload -> getData ( ) -> getEntityKey ( ) ] ] ) ; }
|
Get an Entity by it s UUID .
|
59,454
|
protected function getOneByCompoundKey ( $ key ) { $ sanitizedKey = [ ] ; if ( $ this -> isAssociativeArray ( $ key ) ) { if ( array_key_exists ( 'entity_type' , $ key ) && array_key_exists ( 'entity_id' , $ key ) ) { $ sanitizedKey [ 'entity_type' ] = $ key [ 'entity_type' ] ; $ sanitizedKey [ 'entity_id' ] = $ key [ 'entity_id' ] ; } else { return new Payload ( null , 'insufficient_entity_key' ) ; } } else { $ sanitizedKey [ 'entity_type' ] = $ key [ 0 ] ; $ sanitizedKey [ 'entity_id' ] = $ key [ 1 ] ; } return $ this -> aggregate [ $ this -> formatEntityType ( $ sanitizedKey [ 'entity_type' ] ) ] -> first ( [ 'filter' => [ 'id' => $ sanitizedKey [ 'entity_id' ] ] ] ) ; }
|
Get an Entity by compound key .
|
59,455
|
public function createIdentifier ( $ data ) { switch ( gettype ( $ data ) ) { case 'object' : $ createData = [ 'entity_type' => $ data -> getType ( ) , 'entity_id' => $ data -> getKey ( ) ] ; break ; default : $ createData = $ data ; break ; } return $ this -> aggregate [ IdentifierServiceProvider :: getProviderKey ( ) ] -> create ( $ createData ) ; }
|
Create a new EntityIdentifier for a newly created Entity .
|
59,456
|
public function getConfiguration ( $ key = null ) { if ( is_null ( $ key ) ) { return $ this -> configuration + $ this -> core [ 'configuration' ] ; } $ configuration = $ this -> configuration + $ this -> core [ 'configuration' ] ; if ( array_key_exists ( $ key , $ configuration ) ) { return $ configuration [ $ key ] ; } return null ; }
|
Get the process configuration .
|
59,457
|
protected function process ( $ context , $ data ) { $ context = strtoupper ( $ context ) ; if ( is_null ( $ this -> getConfiguration ( $ context ) ) ) { return new Payload ( null , strtolower ( $ context . '_not_configured' ) ) ; } return $ this -> processor -> process ( $ data , $ this -> getConfiguration ( $ context ) [ 'keys' ] , $ this -> getConfiguration ( $ context ) [ 'rules' ] , $ this -> getConfiguration ( $ context ) [ 'defaults' ] ) ; }
|
Process Data for the Given Context .
|
59,458
|
public function build ( RootNode & $ root ) { $ parser = new RoutingRuleParser ( $ this -> routing_rule ) ; try { $ section_list_set = $ parser -> parse ( ) ; } catch ( RoutingRuleParseException $ e ) { throw new RouterNodeBuilderException ( $ this -> routing_rule , 'Parse failed' ) ; } $ node = $ root ; foreach ( $ section_list_set as $ section_list ) { while ( ( $ section = array_shift ( $ section_list ) ) !== null ) { $ last = empty ( $ section_list ) ; if ( is_string ( $ section ) ) { if ( $ last ) { $ node -> leaf ( $ section ) -> bind ( $ this -> filter , $ this -> event ) ; break ; } $ node = $ node -> node ( $ section ) ; } else if ( is_array ( $ section ) ) { $ varname = $ section [ 'varname' ] ?? null ; $ regex = $ section [ 'regex' ] ?? null ; $ type = $ section [ 'type' ] ?? null ; $ regex = empty ( $ regex ) ? '.*' : $ regex ; if ( $ last ) { $ node -> leaf ( $ regex , $ varname , $ type ) -> bind ( $ this -> filter , $ this -> event ) ; break ; } $ node = $ node -> node ( $ regex , $ varname , $ type ) ; } else if ( $ section instanceof EmptyRoutingPathInterface ) { if ( $ last ) { $ node -> leaf ( '()' ) -> bind ( $ this -> filter , $ this -> event ) ; break ; } throw new RouterNodeBuilderException ( $ this -> routing_rule , 'Empty section not allowed before last section' ) ; } else { throw new RouterNodeBuilderException ( $ this -> routing_rule , 'invalid section' ) ; } } } }
|
Build router node tree
|
59,459
|
private function createCreateForm ( SurveyCategory $ entity ) { $ form = $ this -> createForm ( new SurveyCategoryType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'surveycategory_create' ) , 'method' => 'POST' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Create' ) ) ; return $ form ; }
|
Creates a form to create a SurveyCategory entity .
|
59,460
|
public function newAction ( ) { $ entity = new SurveyCategory ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
|
Displays a form to create a new SurveyCategory entity .
|
59,461
|
private function createEditForm ( SurveyCategory $ entity ) { $ form = $ this -> createForm ( new SurveyCategoryType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'surveycategory_update' , array ( 'id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Update' ) ) ; return $ form ; }
|
Creates a form to edit a SurveyCategory entity .
|
59,462
|
public function setHiddenColumns ( $ columns ) { $ this -> hiddenColumns = array ( ) ; foreach ( $ columns as $ column ) { $ this -> hiddenColumns [ ] = $ column ; } return $ this ; }
|
Set hidden - columns
|
59,463
|
public function setDefaultSearch ( $ search ) { $ this -> defaultSearch = array ( ) ; foreach ( $ search as $ column => $ spec ) { $ this -> defaultSearch [ $ column ] = $ spec ; } return $ this ; }
|
Set default search
|
59,464
|
public function setDefaultOrders ( $ orders ) { $ this -> defaultOrders = array ( ) ; foreach ( $ orders as $ order => $ dir ) { $ this -> defaultOrders [ $ order ] = $ dir ; } return $ this ; }
|
Set default orders
|
59,465
|
public function getColumnId ( $ column ) { if ( $ this -> getColumnsUseTranslation ( ) ) { $ translatePrefix = $ this -> getColumnTranslatePrefix ( ) ; $ translatePostfix = $ this -> getColumnTranslatePostfix ( ) ; $ column = ( empty ( $ translatePrefix ) ? '' : $ translatePrefix . '.' ) . $ column . ( empty ( $ translatePostfix ) ? '' : '.' . $ translatePostfix ) ; } return $ column ; }
|
Get column s id
|
59,466
|
public function getColumnName ( $ column ) { if ( $ this -> getColumnsUseTranslation ( ) ) { $ column = $ this -> view -> translate ( $ this -> getColumnId ( $ column ) , $ this -> getColumnTranslateTextDomain ( ) ) ; } return $ column ; }
|
Get column s translated name
|
59,467
|
public function getId ( ) { if ( empty ( $ this -> id ) ) { if ( $ this -> getColumnsUseTranslation ( ) ) { $ id = trim ( $ this -> getColumnTranslatePrefix ( ) . '.' . $ this -> getColumnTranslatePostfix ( ) , '.' ) ; if ( ! empty ( $ id ) ) { return str_replace ( '.' , '_' , $ id ) ; } } $ this -> id = String :: generateRandom ( ) ; } return $ this -> id ; }
|
Get RowSet s ID
|
59,468
|
public function isColumnSearched ( $ column ) { $ store = $ this -> getStore ( ) ; if ( isset ( $ store [ 'search' ] [ $ column ] ) ) { foreach ( $ store [ 'search' ] [ $ column ] as $ search ) { if ( ! empty ( $ search ) ) { return true ; } } } return false ; }
|
Is column searched
|
59,469
|
public function column ( $ type ) { $ classPrefix = __CLASS__ . '\\Type\\' ; if ( is_string ( $ type ) && class_exists ( $ classPrefix . ucfirst ( $ type ) ) ) { $ type = ucfirst ( $ type ) ; $ args = func_get_args ( ) ; array_shift ( $ args ) ; } else if ( is_callable ( $ type ) ) { $ args = func_get_args ( ) ; $ type = static :: CALLBACK ; } else { $ type = ucfirst ( ( string ) $ type ) ; $ args = func_get_args ( ) ; array_shift ( $ args ) ; } $ class = $ classPrefix . $ type ; if ( ! class_exists ( $ class ) ) { throw new \ LogicException ( 'RowSet-type does not exists: ' . $ class ) ; } $ reflection = new \ ReflectionClass ( $ class ) ; $ result = $ reflection -> newInstanceArgs ( $ args ) ; if ( $ result instanceof HelperInterface ) { $ result -> setView ( $ this -> getView ( ) ) ; } return $ result ; }
|
Create a column type
|
59,470
|
public function render ( $ bodyOnly = false ) { $ this -> parseRequest ( ) ; $ result = $ this -> view -> render ( 'rowSet/layout' , array ( 'rowSet' => $ this , ) ) ; if ( $ bodyOnly ) { return $ result ; } if ( $ this -> hasFlags ( self :: FLAG_LAYOUT_FILTERING ) ) { $ result = $ this -> view -> render ( 'rowSet/layout/filtering' , array ( 'content' => $ result , 'rowSet' => $ this , ) ) ; } if ( $ this -> hasFlags ( self :: FLAG_LAYOUT_AJAX ) ) { $ result = $ this -> view -> render ( 'rowSet/layout/ajax' , array ( 'content' => $ result , 'rowSet' => $ this , ) ) ; } else { $ result = $ this -> view -> render ( 'rowSet/layout/basic' , array ( 'content' => $ result , 'rowSet' => $ this , ) ) ; } return $ result ; }
|
Render the row - set
|
59,471
|
public function init ( $ config = [ ] ) { if ( isset ( $ config [ 'error_callback' ] ) ) { $ this -> errorCallback = $ config [ 'error_callback' ] ; } if ( isset ( $ config [ 'exception_callback' ] ) ) { $ this -> exceptionCallback = $ config [ 'exception_callback' ] ; } if ( isset ( $ config [ 'shutdown_callback' ] ) ) { $ this -> shutdownCallback = $ config [ 'shutdown_callback' ] ; register_shutdown_function ( $ this -> shutdownCallback ) ; } set_error_handler ( [ $ this , 'handleError' ] , E_ALL ) ; set_exception_handler ( [ $ this , 'handleException' ] ) ; }
|
Initialises the error handler .
|
59,472
|
public function handleError ( $ errno , $ message = '' , $ file = '' , $ line = '' , $ context = [ ] ) { restore_error_handler ( ) ; if ( $ errno === NULL ) { $ error = error_get_last ( ) ; $ error = [ 'file' => $ error [ 'file' ] , 'line' => $ error [ 'line' ] , 'message' => $ error [ 'message' ] , 'trace' => $ this -> getBacktrace ( debug_backtrace ( ) ) , ] ; } else { $ error = [ 'message' => $ message , 'file' => $ file , 'line' => $ line , 'context' => $ context , ] ; } if ( NULL !== $ this -> errorCallback ) { call_user_func_array ( $ this -> errorCallback , $ error ) ; } return TRUE ; }
|
Handles PHP errors that may occur .
|
59,473
|
public function getBacktrace ( $ trace ) { $ traces = [ ] ; $ i = 1 ; foreach ( $ trace as $ t ) { $ traceString = '' ; if ( ! isset ( $ t [ 'file' ] ) ) { $ t [ 'file' ] = 'unknown' ; } if ( ! isset ( $ t [ 'line' ] ) ) { $ t [ 'line' ] = 0 ; } if ( ! isset ( $ t [ 'function' ] ) ) { $ t [ 'function' ] = 'unknown' ; } $ traceString .= '#' . $ i . ' ' . $ t [ 'file' ] . '(' . $ t [ 'line' ] . '): ' ; if ( isset ( $ t [ 'object' ] ) && is_object ( $ t [ 'object' ] ) ) { $ traceString .= get_class ( $ t [ 'object' ] ) . '->' ; } $ traceString .= $ t [ 'function' ] . '()' ; $ traces [ ] = $ traceString ; $ i ++ ; } return $ traces ; }
|
Returns a list of traces for the error or exception .
|
59,474
|
public function format ( $ ex ) { $ this -> inspector = new Inspector ( $ ex ) ; if ( $ ex instanceof ErrorException ) { $ type = $ this -> determineSeverityTextValue ( $ ex -> getSeverity ( ) ) ; } else { $ type = ( $ ex instanceof Exception ? 'Uncaught ' : '' ) . $ this -> inspector -> getExceptionName ( ) ; } return $ this -> render ( ( object ) [ 'file' => $ ex -> getFile ( ) , 'frames' => $ this -> inspector -> getFrames ( ) , 'hasFrames' => $ this -> inspector -> hasFrames ( ) , 'line' => $ ex -> getLine ( ) , 'message' => $ ex -> getMessage ( ) , 'previousException' => $ this -> inspector -> getPreviousExceptionInspector ( ) , 'type' => $ type ] ) ; }
|
Format function required by the FormatterInterface . Will be called by BooBoo . We will use this as our entry point for rendering the error page .
|
59,475
|
public function setTheme ( $ theme ) { $ this -> theme = [ ] ; foreach ( ( array ) $ theme as $ path ) { $ this -> theme [ ] = $ path === 'default' ? self :: $ defaultCSS : $ path ; } return $ this ; }
|
Sets the theme files to use for theming the default template .
|
59,476
|
public function isExcerptOnly ( $ excerptOnly = null ) { if ( $ excerptOnly !== null ) { $ this -> excerptOnly = ( bool ) $ excerptOnly ; } return $ this -> excerptOnly ; }
|
Returns whether excerpt mode is enabled or not .
|
59,477
|
public function getExcerptStart ( $ line ) { if ( $ this -> isExcerptOnly ( ) === false ) { return 1 ; } return max ( 1 , $ line - floor ( $ this -> getExcerptSize ( ) / 2 ) ) ; }
|
Returns the starting line number of an excerpt for a given line number .
|
59,478
|
protected function getCaller ( Frame $ frame ) { $ class = $ frame -> getClass ( ) ; $ fn = $ frame -> getFunction ( ) ; $ caller = '' ; if ( $ class ) { $ caller .= $ class ; } if ( $ class && $ fn ) { $ caller .= '::' ; } if ( $ fn ) { $ caller .= $ fn . '(' . $ this -> getArgumentsAsString ( $ frame -> getArgs ( ) ) . ')' ; } return $ caller ; }
|
Returns the fully qualified name for the called function .
|
59,479
|
protected function getArgumentsAsString ( array $ args ) { $ result = [ ] ; $ isNumeric = Jasny \ is_numeric_array ( $ args ) ; $ stringify = function ( $ input ) { return sprintf ( "'%s'" , addcslashes ( $ input , "'" ) ) ; } ; foreach ( $ args as $ key => $ arg ) { switch ( strtolower ( gettype ( $ arg ) ) ) { case 'string' : $ string = $ stringify ( $ arg ) ; break ; case 'object' : $ string = get_class ( $ arg ) ; break ; case 'array' : $ string = "[{$this->getArgumentsAsString($arg)}]" ; break ; case 'null' : $ string = 'null' ; break ; case 'boolean' : $ string = $ arg ? 'true' : 'false' ; break ; case 'resource' : $ string = sprintf ( '*%s' , get_resource_type ( $ arg ) ) ; break ; default : $ string = $ arg ; } if ( $ isNumeric === false ) { $ result [ ] = is_string ( $ key ) === true ? $ stringify ( $ key ) . ' => ' . $ string : $ string ; } else { $ result [ ] = $ string ; } } return join ( ', ' , $ result ) ; }
|
Turns an array of arguments into a pretty formatted argument string which can be used to visualize the original function call .
|
59,480
|
protected function render ( $ error ) { $ ife = function ( $ condition , $ if , $ else = null ) { return $ condition ? $ if : $ else ; } ; $ classes = function ( ... $ classes ) { return implode ( ' ' , array_filter ( $ classes , 'strlen' ) ) ; } ; $ showCode = $ this -> isExcerptOnly ( ) === false || $ this -> getExcerptSize ( ) > 0 ; if ( is_readable ( $ header = $ this -> getHeader ( ) ) ) { $ header = $ this -> read ( $ header , 'require' , compact ( 'ife' , 'classes' ) ) ; } if ( is_readable ( $ footer = $ this -> getFooter ( ) ) ) { $ footer = $ this -> read ( $ footer , 'require' , compact ( 'ife' , 'classes' ) ) ; } return $ this -> read ( $ this -> getTemplate ( ) , 'require' , compact ( 'error' , 'ife' , 'classes' , 'showCode' , 'header' , 'footer' ) ) ; }
|
Renders the error page with the given error and template file .
|
59,481
|
protected function read ( $ file , $ type = 'raw' , array $ data = [ ] ) { $ type = strtolower ( $ type ) ; if ( $ type === 'include' || $ type === 'require' ) { ob_start ( ) ; extract ( $ data ) ; unset ( $ data ) ; if ( $ type === 'include' ) { include $ file ; } else { require $ file ; } return ob_get_clean ( ) ; } $ raw = is_readable ( $ file ) === true ? file_get_contents ( $ file ) : $ file ; if ( $ type === 'base64' ) { return base64_encode ( $ raw ) ; } return $ raw ; }
|
Tries to read a given file . May use a specific type of reading .
|
59,482
|
public static function concat ( $ items ) { if ( is_string ( $ items ) ) { $ lines = explode ( "\n" , $ items ) ; $ str = '' ; foreach ( $ lines as $ line ) { $ str .= trim ( $ line ) ; } $ items = explode ( '|' , $ str ) ; } $ txt = '' ; foreach ( $ items as $ value ) { if ( ! preg_match ( '/^\{[^}]+\}$/' , $ value ) ) { $ value = '"' . str_replace ( '"' , '\"' , $ value ) . '"' ; } else { $ value = substr ( $ value , 1 , - 1 ) ; } $ txt = $ txt === '' ? $ value : 'CONCAT(' . $ txt . ', ' . $ value . ')' ; } return $ txt ; }
|
Transform a string or a tab to an SQL concatenation
|
59,483
|
public static function makeSuccess ( CheckerInterface $ checker , $ messages = null ) : Success { return new Success ( $ checker , ... self :: castIntoArray ( $ messages ) ) ; }
|
Make a success instance with optional message .
|
59,484
|
public static function makeDisabled ( CheckerInterface $ checker , $ messages = null ) : Disabled { return new Disabled ( $ checker , ... self :: castIntoArray ( $ messages ) ) ; }
|
Make a disable instance with optional message .
|
59,485
|
protected function setHeader ( $ name , $ value ) { if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } $ this -> headers [ $ name ] = $ value ; $ this -> headerKeys [ strtolower ( $ name ) ] = $ name ; }
|
Set the value of a header .
|
59,486
|
private function createFile ( InputInterface $ input , OutputInterface $ output , $ subDir = '' , $ content = '' ) { $ path = $ this -> getFilePath ( $ input , $ subDir ) ; $ this -> writeFile ( $ input , $ output , $ path , $ content ) ; }
|
Create a new file .
|
59,487
|
private function getFilePath ( InputInterface $ input , $ subDir ) { $ path = [ ] ; $ path [ ] = $ this -> getContainer ( ) -> getParameter ( 'sculpin.source_dir' ) ; $ path [ ] = $ subDir ; $ path [ ] = $ input -> getOption ( 'filename' ) ; return implode ( DIRECTORY_SEPARATOR , array_filter ( $ path ) ) ; }
|
Generate the name and path for the new file .
|
59,488
|
private function writeFile ( InputInterface $ input , OutputInterface $ output , $ path , $ content ) { $ shortPath = str_replace ( getcwd ( ) . '/' , '' , $ path ) ; $ filesystem = $ this -> getContainer ( ) -> get ( 'filesystem' ) ; if ( ! $ filesystem -> exists ( $ path ) || $ input -> getOption ( 'force' ) ) { $ filesystem -> dumpFile ( $ path , $ content ) ; $ output -> writeln ( '<info>' . sprintf ( '%s has been created.' , $ shortPath ) . '</info>' ) ; } else { $ output -> writeln ( '<error>' . sprintf ( '%s already exists.' , $ shortPath ) . '</error>' ) ; } return $ this ; }
|
Writes a file to disk .
|
59,489
|
protected function _assertSessionRestriction ( ) { $ stat = false ; if ( php_sapi_name ( ) !== 'cli' ) { if ( version_compare ( phpversion ( ) , '5.4.0' , '>=' ) ) { $ stat = ( session_status ( ) !== PHP_SESSION_DISABLED ? true : false ) ; } else { $ stat = ( session_id ( ) === '' ? false : true ) ; } } if ( false === $ stat ) throw new \ Exception ( 'Session Cant Be Initialized.' ) ; }
|
Does a session exist and is it currently active?
|
59,490
|
public static function Init ( \ Puzzlout \ Framework \ Controllers \ BaseController $ controller ) { $ viewLoader = new ViewLoader ( ) ; $ viewLoader -> controller = $ controller ; return $ viewLoader ; }
|
Instantiate the class .
|
59,491
|
public function GetView ( ) { $ FrameworkView = $ this -> GetPathForView ( DirectoryManager :: GetFrameworkRootDir ( ) ) ; $ ApplicationView = $ this -> GetPathForView ( DirectoryManager :: GetApplicationRootDir ( ) ) ; if ( file_exists ( $ FrameworkView ) ) { return $ FrameworkView ; } if ( file_exists ( $ ApplicationView ) ) { return $ ApplicationView ; } $ errMsg = "View " . $ FrameworkView . " nor " . $ ApplicationView . " exists" ; throw new ViewNotFoundException ( $ errMsg , MvcErrors :: VIEW_NOT_FOUND , null ) ; }
|
Retrieve the view from either the Framework folder or the current Application folder .
|
59,492
|
public function GetPartialView ( $ viewName ) { $ ListOfPathToCheck = array ( DirectoryManager :: GetFrameworkRootDir ( ) . "Modules/" , DirectoryManager :: GetFrameworkRootDir ( ) . $ this -> controller -> module ( ) . "/Modules/" , DirectoryManager :: GetApplicationRootDir ( ) . "/Modules/" , DirectoryManager :: GetApplicationRootDir ( ) . $ this -> controller -> module ( ) . "/Modules/" ) ; foreach ( $ ListOfPathToCheck as $ path ) { $ fileToCheck = $ path . $ viewName . self :: VIEWFILEEXTENSION ; if ( file_exists ( $ fileToCheck ) ) { return $ fileToCheck ; } } $ errMsg = "Partial view \"" . $ viewName . "\" not found in list." . var_dump ( $ ListOfPathToCheck ) ; throw new ViewNotFoundException ( $ errMsg , MvcErrors :: PARTIAL_VIEW_NOT_FOUND , null ) ; }
|
Retrieve the partial view from either the Framework folder or the current Application folder .
|
59,493
|
public function GetPathForView ( $ rootDir ) { $ path = "APP_ROOT_DIR" . $ rootDir . ucfirst ( $ this -> controller -> module ( ) ) . "/" . ucfirst ( $ this -> controller -> action ( ) ) . self :: VIEWFILEEXTENSION ; return $ path ; }
|
Computes the path of the view .
|
59,494
|
public function useSportQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinSport ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Sport' , '\gossi\trixionary\model\SportQuery' ) ; }
|
Use the Sport relation Sport object
|
59,495
|
public function useSkillGroupQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinSkillGroup ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SkillGroup' , '\gossi\trixionary\model\SkillGroupQuery' ) ; }
|
Use the SkillGroup relation SkillGroup object
|
59,496
|
public function filterBySkill ( $ skill , $ comparison = Criteria :: EQUAL ) { return $ this -> useSkillGroupQuery ( ) -> filterBySkill ( $ skill , $ comparison ) -> endUse ( ) ; }
|
Filter the query by a related Skill object using the kk_trixionary_skill_group table as cross reference
|
59,497
|
private function logException ( \ Exception $ e ) { if ( isset ( $ this -> logger ) ) { $ this -> logger -> notice ( $ e -> getMessage ( ) , [ 'code' => $ e -> getCode ( ) , 'line' => $ e -> getLine ( ) , 'file' => $ e -> getFile ( ) , ] ) ; } else { error_log ( sprintf ( '[%s] [%s:%d] %s' , $ e -> getCode ( ) , $ e -> getFile ( ) , $ e -> getLine ( ) , $ e -> getMessage ( ) ) , E_NOTICE ) ; } }
|
Savely wrap the logger .
|
59,498
|
public static function exec ( ) : array { self :: $ output = self :: $ input = file_get_contents ( self :: $ filePath ) ; self :: $ arrInput = file ( self :: $ filePath ) ; $ annotationService = ServiceFactory :: getInstance ( AnnotationServiceImpl :: class ) ; $ className = Main :: getClassNameFromFile ( self :: $ input ) ; if ( empty ( $ className ) ) return [ 'output' => self :: $ input , 'namespace' => '' , 'fileName' => self :: $ filePath , 'className' => $ className ] ; $ className = Main :: getClassNameFromFile ( self :: $ input ) ; ; $ namespace = Main :: getNamespaceFromFile ( self :: $ input ) . '\\' . $ className ; $ annotationService -> setSrcClass ( $ namespace ) ; $ data = $ annotationService -> exec ( ) ; $ default = [ 'output' => self :: $ input , 'namespace' => $ data [ 'namespace' ] , 'fileName' => self :: $ filePath , 'className' => $ className ] ; if ( empty ( $ data [ 'classInfo' ] [ 'annotation' ] [ 'name' ] ) && empty ( $ data [ 'varList' ] ) && empty ( $ data [ 'methodList' ] ) ) return $ default ; ! empty ( $ data [ 'classInfo' ] [ 'annotation' ] [ 'name' ] ) and self :: encodeClassInfo ( $ data [ 'classInfo' ] ) ; self :: updateArrInput ( ) ; ! empty ( $ data [ 'varList' ] ) && self :: encodeVarList ( $ data [ 'varList' ] ) ; self :: updateArrInput ( ) ; ! empty ( $ data [ 'methodList' ] ) && self :: encodeMethodList ( $ data [ 'methodList' ] ) ; self :: updateArrInput ( ) ; return [ 'output' => self :: $ output , 'namespace' => $ data [ 'namespace' ] , 'fileName' => $ data [ 'fileName' ] , 'className' => $ className ] ; }
|
return the result string
|
59,499
|
protected static function encodeVarList ( array & $ info ) { foreach ( $ info as $ k => & $ var ) { $ var [ 'annotation' ] [ 'name' ] = self :: aliasMapParse ( $ var [ 'annotation' ] [ 'name' ] ) ; self :: setInput ( $ var ) ; $ info [ $ k ] [ 'buildStr' ] = forward_static_call_array ( [ $ var [ 'annotation' ] [ 'name' ] , 'exec' ] , [ 'argv' => $ var , 'param' => $ var [ 'annotation' ] [ 'param' ] ] ) ; self :: $ output = $ info [ $ k ] [ 'buildStr' ] ; } }
|
encode var list
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.